Skip to content
Merged
Show file tree
Hide file tree
Changes from 149 commits
Commits
Show all changes
151 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
5ebf678
d
Jul 22, 2025
8a70cd0
Voltage - Continuous Output
Jul 22, 2025
3104384
Voltage - Continuous Output
Jul 22, 2025
585f3e4
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 22, 2025
015a208
formatting changes
Jul 22, 2025
42acc7d
Merge branch 'main' into users/DilmiWickramanayake/Analog_Output_voltage
Jul 22, 2025
4add656
matplotlib to echarts
Jul 23, 2025
c41d5ef
changed run button
Jul 23, 2025
cfdd482
resolve sample rate error
Jul 23, 2025
d20cbaa
Daq errors (unfinished)
Jul 23, 2025
beedfde
daq errors
Jul 23, 2025
eb4ad21
updating daq error display
Jul 23, 2025
e0e6c9d
README.md change
Jul 24, 2025
ea7efdd
fixing lint errors
Jul 24, 2025
81b9c7a
deleted trigger types
Jul 24, 2025
a3680b4
error handling
Jul 24, 2025
0b858e9
fixing source settings
Jul 24, 2025
3f5c35f
fixing lint errors
Jul 24, 2025
da485d6
lint error
Jul 24, 2025
126d3fb
disable run button
Jul 24, 2025
dd9d95b
disable run button
Jul 24, 2025
12c2a37
Merge branch 'users/DilmiWickramanayake/Analog_Output_voltage' of htt…
Jul 24, 2025
6492de6
delete current example
Jul 24, 2025
32c6a78
lint errors
Jul 28, 2025
8a31082
removing files
Jul 28, 2025
46cf8ae
restructure
Jul 28, 2025
b4302cd
space
Jul 28, 2025
667bce1
rename
Jul 28, 2025
2a00e84
Update nidaqmx_continuous_analog_input_panel.py
DilmiWickramanayake Jul 28, 2025
01c58a7
readme
Jul 28, 2025
c3f2df8
Merge branch 'users/DilmiWickramanayake/Analog_Output_voltage' of htt…
Jul 28, 2025
2def6b2
poetry lock changes
Jul 28, 2025
38b3cc8
Update nidaqmx_continuous_analog_input.py
DilmiWickramanayake Jul 28, 2025
8c0bc34
Update README.md
DilmiWickramanayake Jul 28, 2025
27fb20b
add readme
Jul 28, 2025
c4725e4
Merge branch 'users/DilmiWickramanayake/Analog_Output_voltage' of htt…
Jul 28, 2025
14db8ff
rename
Jul 28, 2025
16cdcc5
run button change
Jul 28, 2025
58de63a
remove function
Jul 28, 2025
2f9aa38
lint errors
Jul 28, 2025
355d3bb
resolve changes
Jul 29, 2025
9c82e5b
change triggers
Jul 30, 2025
eba2ce8
changes README.md
Jul 31, 2025
cc650b5
set run button to false
Aug 1, 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
22 changes: 22 additions & 0 deletions examples/nidaqmx/nidaqmx_analog_output_voltage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Prerequisites
===============
Requires a Physical or Simulated Device : https://github.com/ni/nidaqmx-python/blob/master/README.rst (Getting Started Section)

## Sample

This is a nipanel example that displays an interactive Streamlit app and updates continuous analog output examples.

### Feature

- Supports various data types

### Required Software

- Python 3.9 or later

### Usage

```pwsh
poetry install --with examples
poetry run examples\nidaqmx_analog_output_voltage\nidaqmx_analog_output_voltage.py
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""Data acquisition script that continuously generates analog output data."""

import time
from pathlib import Path

import nidaqmx
import nidaqmx.stream_writers
import nidaqmx.system
import numpy as np
from nidaqmx.constants import AcquisitionType, Edge
from nidaqmx.errors import DaqError

import nipanel

panel_script_path = Path(__file__).with_name("nidaqmx_analog_output_voltage_panel.py")
panel = nipanel.create_streamlit_panel(panel_script_path)

system = nidaqmx.system.System.local()

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

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:
panel.set_value("daq_error", "")
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("is_running", 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 = task.ao_channels.add_ao_voltage_chan(
panel.get_value("physical_channel", ""),
max_val=panel.get_value("max_value_voltage", 5.0),
min_val=panel.get_value("min_value_voltage", -5.0),
)

sample_rate = panel.get_value("rate", 1000.0)
num_samples = panel.get_value("total_samples", 1000)
frequency = panel.get_value("frequency", 10.0)
amplitude = panel.get_value("amplitude", 1.0)

task.timing.cfg_samp_clk_timing(
source=panel.get_value("source", ""), # "" - OnboardClock
rate=sample_rate,
sample_mode=AcquisitionType.CONTINUOUS,
)
# Not all hardware supports all trigger types.
# Refer to your device documentation for more information.
trigger_type = panel.get_value("trigger_type")

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),
)

panel.set_value("sample_rate", task.timing.samp_clk_rate)
t = np.arange(num_samples) / sample_rate
wave_type = panel.get_value("wave_type", "Sine Wave")

if wave_type == "Sine Wave":
waveform = amplitude * np.sin(2 * np.pi * frequency * t)
elif wave_type == "Square Wave":
waveform = amplitude * np.sign(np.sin(2 * np.pi * frequency * t))
else:
waveform = amplitude * (2 * np.abs(2 * (t * frequency % 1) - 1) - 1)

writer = nidaqmx.stream_writers.AnalogSingleChannelWriter(
task.out_stream, auto_start=False # pyright: ignore[reportArgumentType]
)
writer.write_many_sample(waveform)
panel.set_value("data", waveform.tolist())
try:
task.start()
panel.set_value("is_running", True)
panel.set_value("stop_button", False)
while not panel.get_value("stop_button", False):
time.sleep(0.1)

except KeyboardInterrupt:
break
finally:
task.stop()
panel.set_value("is_running", False)

except DaqError as e:
daq_error = str(e)
print(daq_error)
panel.set_value("daq_error", daq_error)

except KeyboardInterrupt:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
"""Streamlit visualization script to display data acquired by nidaqmx_analog_output_voltage.py."""

import extra_streamlit_components as stx # type: ignore[import-untyped]
import streamlit as st
from nidaqmx.constants import Edge
from streamlit_echarts import st_echarts

import nipanel
from nipanel.controls import enum_selectbox

st.set_page_config(page_title="Voltage - Continuous Output", page_icon="📈", layout="wide")
st.title("Voltage - Continuous Output")
panel = nipanel.get_streamlit_panel_accessor()

left_col, right_col = st.columns(2)

st.markdown(
"""
<style>
div.stNumberInput {
max-width: 190px !important;
}
div.stTextInput {
max-width: 190px !important;
}

div[data-baseweb="select"] {
width: 190px !important; /* Adjust the width as needed */
}
</style>
<style>
iframe[title="streamlit_echarts.st_echarts"]{ height: 400px; width:100%;}
</style>
""",
unsafe_allow_html=True,
)


with left_col:
with st.container(border=True):
is_running = panel.get_value("is_running", True)
if is_running:
st.button("Stop", key="stop_button")
elif not is_running and panel.get_value("daq_error", "") == "":
run_button = st.button("Run", key="run_button")
else:
st.error(
f"There was an error running the script. Fix the issue and re-run nidaqmx_analog_output_voltage.py \n\n {panel.get_value('daq_error', '')}"
)

st.title("Channel Settings")
physical_channel = st.selectbox(
options=panel.get_value("available_channel_names", ["Mod2/ai0"]),
index=0,
label="Physical Channels",
disabled=panel.get_value("is_running", False),
)
panel.set_value("physical_channel", physical_channel)

max_value_voltage = st.number_input(
"Max Value",
value=5.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="max_value_voltage",
)

min_value_voltage = st.number_input(
"Min Value",
value=-5.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="min_value_voltage",
)
st.title("Timing and Buffer Settings")

source = st.selectbox(
"Sample Clock Source",
options=panel.get_value("available_trigger_sources", [""]),
index=0,
disabled=panel.get_value("is_running", False),
)
panel.set_value("source", source)
st.number_input(
"Sample Rate",
value=1000.0,
min_value=1.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="rate",
)
st.number_input(
"Number of Samples",
value=1000,
min_value=1,
step=1,
disabled=panel.get_value("is_running", False),
key="total_samples",
)
st.number_input(
"Actual Sample Rate",
value=panel.get_value("actual_sample_rate", 1000.0),
key="actual_sample_rate",
step=1.0,
disabled=True,
)
st.title("Waveform Settings")
st.number_input(
"Frequency",
value=panel.get_value("frequency", 10.0),
key="frequency",
step=1.0,
disabled=panel.get_value("is_running", False),
)
st.number_input(
"Amplitude",
value=panel.get_value("amplitude", 1.0),
key="amplitude",
step=1.0,
disabled=panel.get_value("is_running", False),
)
wave_type = st.selectbox(
label="Wave Type",
options=["Sine Wave", "Triangle Wave", "Square Wave"],
key="wave_type",
disabled=panel.get_value("is_running", False),
)
panel.set_value("wave_type", wave_type)

with right_col:
with st.container(border=True):
st.title("Output")
acquired_data = panel.get_value("data", [0.0])
sample_rate = panel.get_value("sample_rate", 1000.0)
acquired_data_graph = {
"animation": False,
"tooltip": {"trigger": "axis"},
"legend": {"data": ["Voltage (V)"]},
"xAxis": {
"type": "category",
"data": [x / sample_rate for x in range(len(acquired_data))],
"name": "Time",
"nameLocation": "center",
"nameGap": 40,
},
"yAxis": {
"type": "value",
"name": "Amplitude",
"nameRotate": 90,
"nameLocation": "center",
"nameGap": 40,
},
"series": [
{
"name": "voltage_amplitude",
"type": "line",
"data": acquired_data,
"emphasis": {"focus": "series"},
"smooth": True,
"seriesLayoutBy": "row",
},
],
}
st_echarts(options=acquired_data_graph, height="400px", key="graph", width="100%")

with st.container(border=True):
st.title("Trigger Settings")
trigger_type = stx.tab_bar(
data=[
stx.TabBarItemData(id=1, title="No Trigger", description=""),
stx.TabBarItemData(id=2, title="Digital Start", description=""),
stx.TabBarItemData(id=3, title="Digital Pause", description=""),
stx.TabBarItemData(id=4, title="Digital Reference", description=""),
stx.TabBarItemData(id=5, title="Analog Start", description=""),
stx.TabBarItemData(id=6, title="Analog Pause", description=""),
stx.TabBarItemData(id=7, title="Analog Reference", description=""),
],
default=1,
)
trigger_type = int(trigger_type) # pyright: ignore[reportArgumentType]
panel.set_value("trigger_type", trigger_type)

if trigger_type == 2:
with st.container(border=True):
source = st.selectbox(
"Source:", options=panel.get_value("available_trigger_sources", [""])
)
panel.set_value("digital_source", source)
enum_selectbox(
panel,
label="Edge",
value=Edge.FALLING,
disabled=panel.get_value("is_running", False),
key="edge",
)
elif trigger_type == 1:
with st.container(border=True):
st.write(
"To enable triggers, select a tab above, and configure the settings. Not all hardware supports all trigger types. Refer to your device documentation for more information."
)

else:
st.write(
"This trigger type is not supported in output tasks. Refer to your device documentation for more information on which triggers are supported."
)