Skip to content

Commit 82c2b7f

Browse files
author
Dilmi Wickramanayake
committed
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_filtering
2 parents 66faa59 + 29835f5 commit 82c2b7f

21 files changed

+589
-338
lines changed

examples/all_types/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
## All Types Example
22

3-
This is an example for `nipanel` that demonstrates all supported data types
3+
This is an example for `nipanel` that demonstrates all supported data types.
44

55
### Feature
66

7-
- Demonstrates support for all data types
7+
- Demonstrates all supported data types
88

99
### Required Software
1010

1111
- Python 3.9 or later
1212

1313
### Usage
1414

15-
Run `poetry run python examples/all_types/all_types.py`
15+
```pwsh
16+
poetry install --with examples
17+
poetry run python examples/all_types/all_types.py
18+
```

examples/hello/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Hello
22

3-
This is a simple nipanel example that displays a Streamlit app.
3+
This is a simple `nipanel` example that displays a Streamlit app.
44

55
### Feature
66

@@ -12,4 +12,7 @@ This is a simple nipanel example that displays a Streamlit app.
1212

1313
### Usage
1414

15-
Run `poetry run python examples/hello/hello.py`
15+
```pwsh
16+
poetry install --with examples
17+
poetry run python examples/hello/hello.py
18+
```

examples/nidaqmx/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Prerequisites
1+
Prerequisites
22
===============
33
Requires a Physical or Simulated Device : https://github.com/ni/nidaqmx-python/blob/master/README.rst (Getting Started Section)
44

@@ -16,5 +16,7 @@ This is a nipanel example that displays an interactive Streamlit app and updates
1616

1717
### Usage
1818

19-
Run `poetry run examples/nidaqmx/nidaqmx_continuous_analog_input.py`
20-
19+
```pwsh
20+
poetry install --with examples
21+
poetry run examples/nidaqmx/nidaqmx_continuous_analog_input.py
22+
```

examples/nidaqmx_analog_input_filtering/nidaqmx_analog_input_filtering.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,8 @@
3535
# How to use nidaqmx: https://nidaqmx-python.readthedocs.io/en/stable/
3636
with nidaqmx.Task() as task:
3737
chan_type = panel.get_value("chan_type", "1")
38-
if chan_type == "1":
39-
chan = task.ai_channels.add_ai_voltage_chan(
40-
"Mod3/ai10",
41-
terminal_config=panel.get_value(
42-
"terminal_configuration", TerminalConfiguration.DEFAULT
43-
),
44-
max_val=panel.get_value("max_value_voltage", 5.0),
45-
min_val=panel.get_value("min_value_voltage", -5.0),
46-
)
47-
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
48-
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
49-
chan.ai_filter_order = 1
50-
51-
elif chan_type == "2":
38+
39+
if chan_type == "2":
5240
chan = task.ai_channels.add_ai_current_chan(
5341
"Mod3/ai10",
5442
max_val=panel.get_value("max_value_current", 0.01),
@@ -59,9 +47,6 @@
5947
),
6048
units=panel.get_value("units", CurrentUnits.AMPS),
6149
)
62-
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
63-
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
64-
chan.ai_filter_order = 1
6550

6651
elif chan_type == "3":
6752
chan = task.ai_channels.add_ai_strain_gage_chan(
@@ -79,24 +64,45 @@
7964
"strain_configuration", StrainGageBridgeType.FULL_BRIDGE_I
8065
),
8166
)
82-
83-
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
84-
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
85-
chan.ai_filter_order = 1
67+
else:
68+
chan = task.ai_channels.add_ai_voltage_chan(
69+
"Mod3/ai10",
70+
terminal_config=panel.get_value(
71+
"terminal_configuration", TerminalConfiguration.DEFAULT
72+
),
73+
max_val=panel.get_value("max_value_voltage", 5.0),
74+
min_val=panel.get_value("min_value_voltage", -5.0),
75+
)
8676

8777
task.timing.cfg_samp_clk_timing(
8878
rate=panel.get_value("rate", 1000.0),
8979
sample_mode=AcquisitionType.CONTINUOUS,
9080
samps_per_chan=panel.get_value("total_samples", 100),
9181
)
82+
panel.set_value("actual_sample_rate", task._timing.samp_clk_rate)
83+
panel.set_value("sample_rate", panel.get_value("rate", 100.0))
84+
9285
task.in_stream.configure_logging(
9386
file_path=panel.get_value("tdms_file_path", "data.tdms"),
9487
logging_mode=panel.get_value("logging_mode", LoggingMode.OFF),
9588
operation=LoggingOperation.OPEN_OR_CREATE,
9689
)
90+
if panel.get_value("filter","Filter") == "Filter":
91+
chan.ai_filter_enable = True
92+
chan.ai_filter_freq = panel.get_value("filter_freq", 0.0)
93+
chan.ai_filter_response = panel.get_value("filter_response", FilterResponse.COMB)
94+
chan.ai_filter_order = panel.get_value("filter_order", 1)
95+
# Not all hardware supports all filter types.
96+
# Refer to your device documentation for more information.
97+
panel.set_value("actual_filter_freq", chan.ai_filter_freq)
98+
panel.set_value("actual_filter_response", chan.ai_filter_response)
99+
panel.set_value("actual_filter_order", chan.ai_filter_order)
100+
else:
101+
panel.set_value("actual_filter_freq", 0.0)
102+
panel.set_value("actual_filter_response", FilterResponse.COMB)
103+
panel.set_value("actual_filter_order", 0)
97104

98105
trigger_type = panel.get_value("trigger_type")
99-
panel.set_value("sample_rate", task._timing.samp_clk_rate)
100106
if trigger_type == "5":
101107
task.triggers.start_trigger.cfg_anlg_edge_start_trig(
102108
trigger_source="APFI0",
@@ -112,15 +118,10 @@
112118
)
113119

114120
try:
115-
116121
task.start()
117-
118122
while not panel.get_value("stop_button", False):
119123
data = task.read(number_of_samples_per_channel=100)
120-
panel.set_value("voltage_data", data)
121-
panel.set_value("current_data", data)
122-
panel.set_value("strain_data", data)
123-
124+
panel.set_value("acquired_data", data)
124125
except KeyboardInterrupt:
125126
pass
126127
finally:

0 commit comments

Comments
 (0)