Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -799,6 +799,7 @@
#### [nidmm] Unreleased
- Added
- Added the `nidmm_measure_ac_volts.py` example.
- Added the `nidmm_diode_test.py` example.
- Added the `nidmm_measure_temperature_rtd.py` example.
- Added the `nidmm_measure_temperature_thermocouple.py` example.
- (Common) Added `nitlsconfig[grpc]>=1.0.0a2` to the optional gRPC dependencies.
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_diode_test.py
-------------------

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

nidmm_fetch_waveform.py
-----------------------

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

import argparse
import math
import nidmm
import sys


def example(resource_name, options, range, digits, current_source):
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function.DIODE, range=range, resolution_digits=digits)
session.current_source = current_source
measurement = session.read()
out_of_range = math.isnan(measurement) or (math.isinf(measurement) and measurement > 0)
print(f'Measurement (volts): {measurement}')
print(f'Signal Out of Range: {out_of_range}')


def _main(argsv):
parser = argparse.ArgumentParser(description='Performs a single diode measurement 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('-r', '--range', default=2, 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('-c', '--current-source', default=0.001, type=float, help='Specifies the current source provided during diode measurements.')
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.range, args.digits, args.current_source)


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


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


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


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