Skip to content

Commit 3a22846

Browse files
author
Dilmi Wickramanayake
committed
Fixed panel comments
1 parent bbdeb81 commit 3a22846

File tree

8 files changed

+445
-462
lines changed

8 files changed

+445
-462
lines changed

examples/nidaqmx_analog_input_filtering/README.md renamed to examples/nidaqmx/nidaqmx_analog_input_filtering/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Script demonstrates analog input data getting continuously acquired, and being f
1616

1717
### Usage
1818

19+
```pwsh
1920
poetry install --with examples
20-
poetry run examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py
21-
Run `poetry run examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py`
21+
poetry run python examples/all_types/all_types.py
22+
```
2223

examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py renamed to examples/nidaqmx/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
"""Data acquisition script that continuously acquires analog input data."""
22

3+
import time
34
from pathlib import Path
45

56
import nidaqmx
7+
import nidaqmx.system
68
from nidaqmx.constants import (
79
AcquisitionType,
810
CurrentShuntResistorLocation,
911
CurrentUnits,
1012
Edge,
1113
ExcitationSource,
1214
FilterResponse,
13-
LoggingMode,
14-
LoggingOperation,
1515
Slope,
1616
StrainGageBridgeType,
1717
TerminalConfiguration,
@@ -22,23 +22,39 @@
2222
panel_script_path = Path(__file__).with_name("nidaqmx_analog_input_filtering_panel.py")
2323
panel = nipanel.create_panel(panel_script_path)
2424
panel.set_value("is_running", False)
25+
26+
system = nidaqmx.system.System.local()
27+
28+
channel_name = []
29+
for dev in system.devices:
30+
for chan in dev.ai_physical_chans:
31+
channel_name.append(chan.name)
32+
panel.set_value("channel_name", channel_name)
33+
trigger_sources = []
34+
for dev in system.devices:
35+
if hasattr(dev, "terminals"):
36+
for term in dev.terminals:
37+
trigger_sources.append(term)
38+
panel.set_value("trigger_sources", trigger_sources)
2539
try:
2640
print(f"Panel URL: {panel.panel_url}")
2741
print(f"Waiting for the 'Run' button to be pressed...")
2842
print(f"(Press Ctrl + C to quit)")
2943
while True:
3044
while not panel.get_value("run_button", False):
3145
panel.set_value("is_running", False)
46+
# time.sleep(0.1)
3247
panel.set_value("is_running", True)
3348
panel.set_value("stop_button", False)
3449

3550
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
3651
with nidaqmx.Task() as task:
52+
3753
chan_type = panel.get_value("chan_type", "1")
3854

3955
if chan_type == "2":
4056
chan = task.ai_channels.add_ai_current_chan(
41-
"Mod3/ai10",
57+
panel.get_value("physical_channel", ""),
4258
max_val=panel.get_value("max_value_current", 0.01),
4359
min_val=panel.get_value("min_value_current", -0.01),
4460
ext_shunt_resistor_val=panel.get_value("shunt_resistor_value", 249.0),
@@ -50,7 +66,7 @@
5066

5167
elif chan_type == "3":
5268
chan = task.ai_channels.add_ai_strain_gage_chan(
53-
"Mod3/ai10",
69+
panel.get_value("physical_channel", ""),
5470
nominal_gage_resistance=panel.get_value("gage_resistance", 350.0),
5571
voltage_excit_source=ExcitationSource.EXTERNAL, # Only mode that works
5672
max_val=panel.get_value("max_value_strain", 0.001),
@@ -66,7 +82,7 @@
6682
)
6783
else:
6884
chan = task.ai_channels.add_ai_voltage_chan(
69-
"Mod3/ai10",
85+
panel.get_value("physical_channel", ""),
7086
terminal_config=panel.get_value(
7187
"terminal_configuration", TerminalConfiguration.DEFAULT
7288
),
@@ -79,14 +95,9 @@
7995
sample_mode=AcquisitionType.CONTINUOUS,
8096
samps_per_chan=panel.get_value("total_samples", 100),
8197
)
82-
panel.set_value("actual_sample_rate", task._timing.samp_clk_rate)
98+
panel.set_value("actual_sample_rate", task.timing.samp_clk_rate)
8399
panel.set_value("sample_rate", panel.get_value("rate", 100.0))
84100

85-
task.in_stream.configure_logging(
86-
file_path=panel.get_value("tdms_file_path", "data.tdms"),
87-
logging_mode=panel.get_value("logging_mode", LoggingMode.OFF),
88-
operation=LoggingOperation.OPEN_OR_CREATE,
89-
)
90101
if panel.get_value("filter", "Filter") == "Filter":
91102
chan.ai_filter_enable = True
92103
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
@@ -109,6 +120,7 @@
109120
trigger_slope=panel.get_value("slope", Slope.FALLING),
110121
trigger_level=panel.get_value("level", 0.0),
111122
)
123+
112124
if trigger_type == "2":
113125
task.triggers.start_trigger.cfg_dig_edge_start_trig(
114126
trigger_source="/Dev2/PFI0", trigger_edge=panel.get_value("edge", Edge.FALLING)

0 commit comments

Comments
 (0)