Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1ee80b2
feat: add nidmm cont acq chart multiple samples example
NI-velmurugan Oct 12, 2026
3d7669b
simplify plotting
divakar-selvam07 Oct 12, 2026
20c6c25
implement minor improvements and include matplotlib in tox env
divakar-selvam07 Oct 12, 2026
4d53b59
Adding fix for testing the examples with matplotlib
NI-velmurugan Oct 13, 2026
be80a33
Reverting change on example, and fixing the pipeline error
NI-velmurugan Oct 13, 2026
0226df1
Changes the plotting logic
NI-velmurugan Oct 13, 2026
6edc712
Updating the cancel logic to match the existing examples
NI-velmurugan Oct 20, 2026
394cfec
Fixing flake8 failure
NI-velmurugan Oct 20, 2026
9562e54
Simlifying the graph logic to helper functions
NI-velmurugan Oct 21, 2026
91f7a3d
Trigger CI build
divakar-selvam07 Oct 21, 2026
82b855c
Trigger CI build
divakar-selvam07 Oct 21, 2026
e744de4
Trigger CI build
divakar-selvam07 Oct 22, 2026
858edf5
Merge branch 'master' into users/velmurugan/add-nidmm-cont-acq-chart-…
NI-velmurugan Oct 23, 2026
79b2fc3
Merge branch 'master' into users/velmurugan/add-nidmm-cont-acq-chart-…
NI-velmurugan Oct 29, 2026
7f5755c
Restructuring the update graph and the fetch size
NI-velmurugan Oct 29, 2026
3fe4792
Rephrasing the help comments
NI-velmurugan Oct 29, 2026
2105895
Trigger CI build
NI-velmurugan Oct 29, 2026
dcccca5
Trigger CI build
NI-velmurugan Oct 29, 2026
fd3a76e
Trigger CI build
NI-velmurugan Oct 29, 2026
fb642b9
Trigger CI build
NI-velmurugan Oct 29, 2026
ad141c4
Merge branch 'master' into users/velmurugan/add-nidmm-cont-acq-chart-…
NI-velmurugan Nov 2, 2026
ea23bc5
Removing graph plotting
NI-velmurugan Nov 2, 2026
7aca4fb
Rephrased the print statement
NI-velmurugan Nov 2, 2026
68c4c99
Removing continuous option
NI-velmurugan Nov 2, 2026
5ec5ae2
Trigger CI build
NI-velmurugan Nov 2, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@
#### [nidmm] Unreleased
- Added
- Added the `nidmm_measure_ac_volts.py` example.
- Added the `nidmm_cont_acq_chart_multiple_samples.py` example.
- Added the `nidmm_diode_test.py` example.
- Added the `nidmm_measure_capacitance.py` example.
- Added the `nidmm_measure_temperature_rtd.py` example.
Expand Down
9 changes: 9 additions & 0 deletions docs/nidmm/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ Examples

`You can download all nidmm examples for latest version here <https://github.com/ni/nimi-python/releases/download/nidmm-1.5.0/nidmm_examples.zip>`_

nidmm_cont_acq_chart_multiple_samples.py
----------------------------------------

.. literalinclude:: ../../src/nidmm/examples/nidmm_cont_acq_chart_multiple_samples.py
:language: python
:linenos:
:encoding: utf8
:caption: `(nidmm_cont_acq_chart_multiple_samples.py) <https://github.com/ni/nimi-python/blob/master/src/nidmm/examples/nidmm_cont_acq_chart_multiple_samples.py>`_

nidmm_diode_test.py
-------------------

Expand Down
61 changes: 61 additions & 0 deletions src/nidmm/examples/nidmm_cont_acq_chart_multiple_samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/python

import argparse
import nidmm
import sys


# Maximum points a single fetch_multi_point call can return in a continuous acquisition, per the array_size documentation
MAX_SAMPLES_PER_FETCH = 100000


def example(resource_name, options, function, measurement_range, digits, samples_to_fetch, total_samples):
print(f'Starting acquisition on resource {resource_name}, for {total_samples} samples.')
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function[function], range=measurement_range, resolution_digits=digits)
# A sample_count of 0 configures a continuous acquisition
session.configure_multi_point(trigger_count=1, sample_count=0)

samples_fetched = 0
with session.initiate():
while samples_fetched < total_samples:
# Fetch the whole backlog when it exceeds samples_to_fetch so the buffer does not overflow
backlog, _ = session.read_status()
samples_in_this_fetch = min(max(samples_to_fetch, backlog), MAX_SAMPLES_PER_FETCH)

new_samples = session.fetch_multi_point(array_size=samples_in_this_fetch)

samples_fetched += len(new_samples)

print(f'Fetched {samples_fetched} measurements')


def _main(argsv):
parser = argparse.ArgumentParser(description='Acquires measurements and prints a summary using the NI-DMM API.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--resource-name', default='PXI1Slot2', help='Contains the resource_name of the device to initialize.')
parser.add_argument('-f', '--function', default='DC_VOLTS', choices=nidmm.Function.__members__.keys(), type=str.upper, help='Specifies the measurement_function used to acquire the measurement.')
parser.add_argument('-r', '--range', default=10, type=float, help='Specifies the range for the function specified in the Measurement_Function parameter.')
parser.add_argument('-d', '--digits', default=5.5, type=float, help='Specifies the resolution of the measurement in digits.')
parser.add_argument('-s', '--samples-to-fetch', default=4, type=int, help='Specifies the minimum number of measurements to fetch at a time.')
parser.add_argument('--total-samples', default=100, type=int, help='Number of measurements to fetch before stopping.')
parser.add_argument('-op', '--option-string', default='', type=str, help='Sets the initial value of certain attributes for the session.')
args = parser.parse_args(argsv)
example(args.resource_name, args.option_string, args.function, args.range, args.digits, args.samples_to_fetch, args.total_samples)


def main():
_main(sys.argv[1:])


def test_example():
options = {'simulate': True, 'driver_setup': {'Model': '4082', 'BoardType': 'PXIe', }, }
example('PXI1Slot2', options, 'DC_VOLTS', 10, 5.5, 4, 10)


def test_main():
cmd_line = ['--option-string', 'Simulate=1, DriverSetup=Model:4082; BoardType:PXIe', '--total-samples', '10', ]
_main(cmd_line)


if __name__ == '__main__':
main()
Loading