Skip to content
Merged
Show file tree
Hide file tree
Changes from 157 commits
Commits
Show all changes
161 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
733b953
update error message
Jul 28, 2025
b0a4fdf
update README.md
Jul 28, 2025
3ea497b
remove changes
Jul 28, 2025
457020a
removing changes
Jul 28, 2025
b9b85ef
resolve changes
Jul 28, 2025
ae409d5
Dev4 -> Dev1
Jul 28, 2025
0bb90e5
readme
Jul 29, 2025
8256e5b
Merge branch 'main' of https://github.com/ni/nipanel-python
Jul 29, 2025
ada35d6
Merge branch 'main' of https://github.com/ni/nipanel-python into user…
Jul 29, 2025
7167f42
Merge branch 'main' into users/DilmiWickramanayake/Analog_Input_conti…
Jul 29, 2025
498bd7b
readme
Jul 29, 2025
a415fe7
run_button = deleted
Jul 29, 2025
869a13b
adding niscope binary example
Aug 1, 2025
d45e9c7
reset run button
Aug 1, 2025
09be84f
moving ex fetch forever files to folder
Aug 1, 2025
fcd7215
changes to panel
Aug 1, 2025
33e74a9
updating branch
Aug 1, 2025
7e85c89
removed comment & fixed wording
Aug 1, 2025
d56a096
changes to wording
Aug 1, 2025
48f5626
Merge branch 'users/DilmiWickramanayake/niscope_binary' of https://gi…
Aug 1, 2025
577a116
delete space
Aug 1, 2025
ec66512
Merge branch 'users/DilmiWickramanayake/niscope_binary' of https://gi…
Aug 1, 2025
a3e70f7
revert changes
Aug 1, 2025
771fad5
revert changes
Aug 1, 2025
f0b3056
Update nidaqmx_continuous_analog_input.py
DilmiWickramanayake Aug 1, 2025
2e25548
fix lint error
Aug 4, 2025
789c1b9
fix mypy errors
Aug 4, 2025
34bc778
resolved changes
Aug 4, 2025
a712048
changes to README.md
Aug 4, 2025
2b30a8f
removed .fetch_array_measurement
Aug 5, 2025
ce35c34
fixing lint errors
Aug 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Script demonstrates NIScope waveform data getting continuously acquired.

```pwsh
poetry install --with examples
poetry run examples/niscope/niscope_ex_fetch_forever.py
poetry run examples\niscope\niscope_ex_fetch_forever\niscope_ex_fetch_forever.py
```
23 changes: 23 additions & 0 deletions examples/niscope/niscope_binary_acquisition/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. This example uses NI oscilloscopes/digitizers, which have the module numbering pattern _51xx_. One example is NI PXIe-5114.

## Sample

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

### Feature

Script demonstrates NIScope waveform data getting continuously acquired and being converted to binary data.
- Supports various data types

### Required Software

- Python 3.9 or later

### Usage

```pwsh
poetry install --with examples
poetry run examples\niscope\niscope_binary_acquisition\niscope_binary_acquisition.py
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
"""Continuously acquires waveforms from NI-SCOPE, processes/scales them."""

import time
from pathlib import Path
from typing import Any

import hightime
import niscope
import numpy as np
from niscope.enums import ArrayMeasurement
from niscope.errors import Error

import nipanel

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


"""Example fetch data from device (Dev1)."""
panel.set_value("is_running", False)
panel.set_value("run_button", False)

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("run_button", False)
while not panel.get_value("run_button", False):
time.sleep(0.1)
with niscope.Session(resource_name=panel.get_value("resource_name", "Dev1")) as session:
session.configure_vertical(
range=panel.get_value("vertical_range", 5.0),
coupling=niscope.VerticalCoupling.DC,
offset=panel.get_value("vertical_offset", 0.0),
)
session.configure_horizontal_timing(
min_sample_rate=panel.get_value("min_sample_rate", 200000000.0),
min_num_pts=1000,
ref_position=50.0,
num_records=1000,
enforce_realtime=True,
)

session.configure_trigger_immediate()

with session.initiate():
data_size = panel.get_value("data_size", 8)
wfm: np.ndarray[Any, Any]

if data_size == 8:
wfm = np.ndarray(1000 * 1000, dtype=np.int8)

elif data_size == 16:
wfm = np.ndarray(1000 * 1000, dtype=np.int16)
else:
wfm = np.ndarray(1000 * 1000, dtype=np.int32)

waveforms = session.channels[panel.get_value("channel", 0)].fetch_into(
relative_to=niscope.FetchRelativeTo.READ_POINTER,
offset=0,
timeout=hightime.timedelta(seconds=5.0),
waveform=wfm,
)

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

panel.set_value("stop_button", False)
while not panel.get_value("stop_button", False):
wfm_info = session.channels[0].fetch_array_measurement(
array_meas_function=ArrayMeasurement.ADD_CHANNELS,
num_records=1000,
meas_num_samples=1000,
)
gain = 0
offset = 0
for waveform in waveforms:
gain = waveform.gain
offset = waveform.offset
panel.set_value("gain_factor", gain)
panel.set_value("offset", offset)

for i in range(len(waveforms)):
if panel.get_value("stop_button", True):
break
else:
time.sleep(0.1)
binary_data = waveforms[i].samples.tolist()
panel.set_value("binary_data", waveforms[i].samples.tolist())

samples_array = np.array(binary_data)
voltage_values = samples_array * gain + offset
panel.set_value("scaled_voltage_data", voltage_values.tolist())

actual_binary_data_size = session.binary_sample_width
panel.set_value("actual_binary_data_size", actual_binary_data_size)
except KeyboardInterrupt:
pass
finally:
panel.set_value("is_running", False)

except Error 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,192 @@
"""Streamlit visualization script to display data acquired by nidaqmx_analog_input_filtering.py."""

import streamlit as st
from streamlit_echarts import st_echarts

import nipanel

st.set_page_config(page_title="NiSCOPE Binary", page_icon="📈", layout="wide")
st.title("NiScope Binary Acquisition")
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):
if panel.get_value("is_running", False):
st.button(r"⏹️ Stop", key="stop_button")
elif not panel.get_value("is_running", False) and panel.get_value("daq_error", "") == "":
run_button = st.button(r"▶️ Run", key="run_button")
else:
st.error(
f"There was an error running the script. Fix the issue and re-run niscope_binary_acquisition.py \n\n {panel.get_value('daq_error', '')}"
)

st.text_input(
label="Resource Name",
value="Dev1",
key="resource_name",
disabled=panel.get_value("is_running", False),
)
st.number_input(
"Channel",
value=0,
step=1,
disabled=panel.get_value("is_running", False),
key="channel",
)

st.title("Vertical")
st.number_input(
"Vertical Range(V)",
value=5.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="vertical_range",
)
st.number_input(
"Vertical Offset",
value=0.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="vertical_offset",
)
st.title("Horizontal")
st.number_input(
"Min Sample Rate",
value=20000000.0,
step=1.0,
disabled=panel.get_value("is_running", False),
key="min_sample_rate",
)
st.number_input(
"Min Record Length",
value=1000,
step=1,
disabled=panel.get_value("is_running", False),
key="min_record_length",
)
data_size = st.selectbox(
"Binary Data Size",
options=[8, 16, 32],
disabled=panel.get_value("is_running", False),
key="data_size",
)
st.number_input(
"Actual Binary Data Size",
value=panel.get_value("actual_binary_data_size", 16),
step=1,
disabled=True,
key="actual_binary_data_size",
)
st.title("Scaling Calculation")
st.number_input(
"Gain Factor",
value=panel.get_value("gain_factor", 0.0000),
step=0.0001,
disabled=True,
format="%.10f",
key="gain_factor",
)
st.number_input(
"Offset",
value=panel.get_value("offset", 0.0000),
step=0.0001,
disabled=True,
key="offset",
)


with right_col:
with st.container(border=True):
st.title("Binary Waveform Graph")
binary_data = panel.get_value("binary_data", [0])

binary_graph = {
"animation": False,
"tooltip": {"trigger": "axis"},
"legend": {"data": ["Amplitude (ADC Codes)"]},
"xAxis": {
"type": "category",
"data": list(range(len(binary_data))),
"name": "Samples",
"nameLocation": "center",
"nameGap": 40,
},
"yAxis": {
"type": "value",
"name": "Amplitude(ADC Codes)",
"nameRotate": 90,
"nameLocation": "center",
"nameGap": 40,
},
"series": [
{
"name": "niscope data",
"type": "line",
"data": binary_data,
"emphasis": {"focus": "series"},
"smooth": True,
"seriesLayoutBy": "row",
},
],
}
st_echarts(options=binary_graph, height="400px", width="75%", key="binary_graph")
with st.container(border=True):
st.title("Scaled Voltage Graph")
scaled_voltage_data = panel.get_value("scaled_voltage_data", [0])
scaled_voltage_graph = {
"animation": False,
"tooltip": {"trigger": "axis"},
"legend": {"data": ["Amplitude (V)"]},
"xAxis": {
"type": "category",
"data": list(range(len(scaled_voltage_data))),
"name": "Samples",
"nameLocation": "center",
"nameGap": 40,
},
"yAxis": {
"type": "value",
"name": "Amplitude(V)",
"nameRotate": 90,
"nameLocation": "center",
"nameGap": 40,
},
"series": [
{
"name": "niscope data",
"type": "line",
"data": scaled_voltage_data,
"emphasis": {"focus": "series"},
"smooth": True,
"seriesLayoutBy": "row",
},
],
}
st_echarts(
options=scaled_voltage_graph, height="400px", width="75%", key="scaled_voltage_graph"
)
Loading