Skip to content
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
b7abc39
Analog Input - Voltage and Thermocouple Single Task
Jun 19, 2025
aa6488a
Merge branch 'main' of https://github.com/ni/nipanel-python
Jun 19, 2025
6d2ec85
Merge branch 'main' of https://github.com/ni/nipanel-python
Jun 19, 2025
89d9c2e
Merge branch 'main' of https://github.com/ni/nipanel-python
Jun 24, 2025
871f6e1
add niscope
Jun 24, 2025
336d7b5
Rename
Jun 25, 2025
31e7f0c
Merge branch 'main' of https://github.com/ni/nipanel-python
Jun 25, 2025
5f7776f
Merge branch 'main' into users/DilmiWickramanayake/niscope_ex_fetch_f…
Jun 25, 2025
1b00959
Merge branch 'main' into users/DilmiWickramanayake/niscope_ex_fetch_f…
Jun 25, 2025
5534c9a
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
6083519
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
01a2e08
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
435aedd
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
8dbd7d0
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
b6e43c6
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
9643953
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
66808fb
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
afeb185
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
eb3da14
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
8b9cc4a
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
b27c77f
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
94a0afc
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
0d720c5
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
be1839f
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
4e7e158
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 26, 2025
c394513
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
fe6a780
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
498c199
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
c4d6d7d
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
414257d
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
5b7d789
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
742b685
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
e50dadc
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
838cd70
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
7338e2c
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
e99a548
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
93fede0
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
b2bfe84
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
5cdc785
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
a80d753
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
2056cf3
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
f1395d6
Merge branch 'users/DilmiWickramanayake/niscope_ex_fetch_forever' of …
Jun 27, 2025
a8f847b
Analog Input Filtering
Jul 8, 2025
24c532b
Merge branch 'main' of https://github.com/ni/nipanel-python into user…
Jul 8, 2025
27a8154
Merge branch 'main' of https://github.com/ni/nipanel-python
Jun 25, 2025
4d49c37
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 8, 2025
2fedc38
Merge branch 'main' of https://github.com/ni/nipanel-python into user…
Jul 8, 2025
8c70ac5
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 8, 2025
4937acd
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 8, 2025
d50204f
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 11, 2025
5d2d549
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 11, 2025
577b344
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 11, 2025
4807eb1
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 11, 2025
0a8da81
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filte…
Jul 14, 2025
a82f608
Completed Task Settings
Jul 15, 2025
c62c497
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 15, 2025
e667025
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filte…
Jul 15, 2025
39959b5
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filte…
Jul 15, 2025
0988885
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
0f7ddc1
Added README.md
Jul 15, 2025
79ae4db
fixed mypy & lint errors
Jul 15, 2025
957ef54
fixed mypy & lint errors
Jul 15, 2025
8422770
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
ee296f9
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
a03250b
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
2655fd9
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
9efb83a
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
886623e
Revert changes
Jul 15, 2025
28f2209
simple graph changes
Jul 15, 2025
709d47e
simple graph changes
Jul 15, 2025
372531f
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
a2a803e
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
7c6737b
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
56f5e10
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
374ef68
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
219c2de
Update simple_graph.py
DilmiWickramanayake Jul 15, 2025
809ced3
Poetry lock
Jul 15, 2025
fcbc70c
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
e5e2b9b
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
f241821
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
81114c4
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
fd75741
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
3a043a7
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
ee3ff1d
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 15, 2025
ffca8c1
update lint errors
Jul 16, 2025
66faa59
update lint errors
Jul 16, 2025
29835f5
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 17, 2025
82c2b7f
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filte…
Jul 17, 2025
a69ad29
fix changes to filtering
Jul 17, 2025
2f569a8
fix changes to filtering
Jul 17, 2025
fb2b46f
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 17, 2025
c385fb2
changes to poetry lock file
Jul 18, 2025
1ab9fa6
changes to poetry lock file
Jul 18, 2025
85a7856
Merge branch 'users/DilmiWickramanayake/Analog_Input_filtering' of ht…
Jul 18, 2025
6354786
Pyright error
Jul 18, 2025
722c3d5
lint error
Jul 18, 2025
bbdeb81
fixed errors
Jul 18, 2025
065d6f4
Fixed panel comments
Jul 18, 2025
3a22846
Fixed panel comments
Jul 18, 2025
f48c26b
format number input
Jul 18, 2025
92b3260
format number input
Jul 18, 2025
68db2a4
adding number format
Jul 18, 2025
ee3f07a
lint errors fixed
Jul 18, 2025
62aa111
fixing lint errors
Jul 18, 2025
d89726c
changed source settings
Jul 21, 2025
4ca3b00
setting source up
Jul 21, 2025
098d9fb
fixing lint error
Jul 21, 2025
d0cb228
resolved comments
Jul 21, 2025
ded87ce
deleting unecessary variables
Jul 21, 2025
585f3e4
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 22, 2025
2d31d50
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filte…
Jul 23, 2025
f158a15
updated run button and panel methods
Jul 23, 2025
be3c739
setting default values
Jul 23, 2025
207fe57
adding daq errors
Jul 23, 2025
f19d608
README.md changes
Jul 24, 2025
d06a4fd
error handling
Jul 24, 2025
338424d
rename daq_errors -> daq_error
Jul 24, 2025
2b1af62
rename daq_error
Jul 24, 2025
25294c4
source now works
Jul 24, 2025
ec42095
fix lint errors
Jul 24, 2025
4721e33
remove comment
Jul 24, 2025
9105a3a
remove logging
Jul 24, 2025
e4a9179
disable run button
Jul 24, 2025
8440772
added onboard clock
Jul 24, 2025
76a8d26
renaming hide_button method
Jul 24, 2025
9d2f392
fixing mypy error
Jul 24, 2025
282c530
lint error
Jul 24, 2025
80970c4
removed function and simplified code
Jul 25, 2025
2d4b95e
remove analog output and markdown
Jul 25, 2025
5401b66
renaming labels
Jul 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/nidaqmx/nidaqmx_analog_input_filtering/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Prerequisites
===============
Requires a Physical or Simulated Device. Refer to the [Getting Started Section](https://github.com/ni/nidaqmx-python/blob/master/README.rst) to learn how to create a simulated device.
## Sample

This is an nipanel example that displays an interactive Streamlit app and updates and fetches data from device.

### Feature

Script demonstrates analog input data getting continuously acquired, and being filtered.
- Supports various data types

### Required Software

- Python 3.9 or later

### Usage

```pwsh
poetry install --with examples
poetry run python examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
"""Data acquisition script that continuously acquires analog input data."""

import time
from pathlib import Path

import nidaqmx
import nidaqmx.system
from nidaqmx.constants import (
AcquisitionType,
CurrentShuntResistorLocation,
CurrentUnits,
Edge,
ExcitationSource,
FilterResponse,
Slope,
StrainGageBridgeType,
TerminalConfiguration,
)

import nipanel

panel_script_path = Path(__file__).with_name("nidaqmx_analog_input_filtering_panel.py")
panel = nipanel.create_streamlit_panel(panel_script_path)
panel.set_value("is_running", False)

system = nidaqmx.system.System.local()

available_channel_name = []
for dev in system.devices:
for chan in dev.ai_physical_chans:
available_channel_name.append(chan.name)
panel.set_value("available_channel_name", available_channel_name)

available_trigger_sources = []
for dev in system.devices:
if hasattr(dev, "terminals"):
for term in dev.terminals:
available_trigger_sources.append(term)
panel.set_value("available_trigger_sources", available_trigger_sources)
try:
print(f"Panel URL: {panel.panel_url}")
print(f"Waiting for the 'Run' button to be pressed...")
print(f"(Press Ctrl + C to quit)")
while True:
panel.set_value("run_button", False)
while not panel.get_value("run_button", False):
time.sleep(0.1)
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
with nidaqmx.Task() as task:

chan_type = panel.get_value("chan_type", "1")

if chan_type == "2":
chan = task.ai_channels.add_ai_current_chan(
panel.get_value("physical_channel", ""),
max_val=panel.get_value("max_value_current", 0.01),
min_val=panel.get_value("min_value_current", -0.01),
ext_shunt_resistor_val=panel.get_value("shunt_resistor_value", 249.0),
shunt_resistor_loc=panel.get_value(
"shunt_location", CurrentShuntResistorLocation.EXTERNAL
),
units=panel.get_value("units", CurrentUnits.AMPS),
)

elif chan_type == "3":
chan = task.ai_channels.add_ai_strain_gage_chan(
panel.get_value("physical_channel", ""),
nominal_gage_resistance=panel.get_value("gage_resistance", 350.0),
voltage_excit_source=ExcitationSource.EXTERNAL, # Only mode that works
max_val=panel.get_value("max_value_strain", 0.001),
min_val=panel.get_value("min_value_strain", -0.001),
poisson_ratio=panel.get_value("poisson_ratio", 0.3),
lead_wire_resistance=panel.get_value("wire_resistance", 0.0),
initial_bridge_voltage=panel.get_value("initial_voltage", 0.0),
gage_factor=panel.get_value("gage_factor", 2.0),
voltage_excit_val=panel.get_value("voltage_excitation_value", 0.0),
strain_config=panel.get_value(
"strain_configuration", StrainGageBridgeType.FULL_BRIDGE_I
),
)
else:
chan = task.ai_channels.add_ai_voltage_chan(
panel.get_value("physical_channel", ""),
terminal_config=panel.get_value(
"terminal_configuration", TerminalConfiguration.DEFAULT
),
max_val=panel.get_value("max_value_voltage", 5.0),
min_val=panel.get_value("min_value_voltage", -5.0),
)

task.timing.cfg_samp_clk_timing(
rate=panel.get_value("rate", 1000.0),
sample_mode=AcquisitionType.CONTINUOUS,
samps_per_chan=panel.get_value("total_samples", 100),
)
panel.set_value("sample_rate", task.timing.samp_clk_rate)

if panel.get_value("filter", "Filter") == "Filter":
chan.ai_filter_enable = True
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
chan.ai_filter_order = panel.get_value("filter_order", 1)
# Not all hardware supports all filter types.
# Refer to your device documentation for more information.
panel.set_value("actual_filter_freq", chan.ai_filter_freq)
panel.set_value("actual_filter_response", chan.ai_filter_response)
panel.set_value("actual_filter_order", chan.ai_filter_order)
else:
panel.set_value("actual_filter_freq", 0.0)
panel.set_value("actual_filter_response", FilterResponse.COMB)
panel.set_value("actual_filter_order", 0)

trigger_type = panel.get_value("trigger_type")
if trigger_type == "5":
task.triggers.start_trigger.cfg_anlg_edge_start_trig(
trigger_source=panel.get_value("analog_source", ""),
trigger_slope=panel.get_value("slope", Slope.FALLING),
trigger_level=panel.get_value("level", 0.0),
)

if trigger_type == "2":
task.triggers.start_trigger.cfg_dig_edge_start_trig(
trigger_source=panel.get_value("digital_source", ""),
trigger_edge=panel.get_value("edge", Edge.FALLING),
)
task.triggers.start_trigger.anlg_edge_hyst = hysteresis = panel.get_value(
"hysteresis", 0.0
)

try:
task.start()
panel.set_value("is_running", True)

panel.set_value("stop_button", False)
while not panel.get_value("stop_button", False):
data = task.read(
number_of_samples_per_channel=100 # pyright: ignore[reportArgumentType]
)
panel.set_value("acquired_data", data)
except KeyboardInterrupt:
pass
finally:
task.stop()
panel.set_value("is_running", False)


except KeyboardInterrupt:
pass
Loading
Loading