Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@
- Added
- Added the `nidmm_measure_ac_volts.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.
- Changed
- Removed
Expand Down
9 changes: 9 additions & 0 deletions docs/nidmm/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ nidmm_measure_temperature_rtd.py
:encoding: utf8
:caption: `(nidmm_measure_temperature_rtd.py) <https://github.com/ni/nimi-python/blob/master/src/nidmm/examples/nidmm_measure_temperature_rtd.py>`_

nidmm_measure_temperature_thermocouple.py
-----------------------------------------

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

nidmm_measurement.py
--------------------

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

import argparse
import nidmm
import sys


def example(resource_name, options, thermocouple_type, reference_junction_type, fixed_reference_junction, range, digits):
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function.TEMPERATURE, range=range, resolution_digits=digits)
session.temp_transducer_type = nidmm.TransducerType.THERMOCOUPLE
session.configure_thermocouple(nidmm.ThermocoupleType[thermocouple_type], nidmm.ThermocoupleReferenceJunctionType[reference_junction_type])
# Reference junction temperature, in degrees Celsius, used with the FIXED reference junction type
session.temp_tc_fixed_ref_junc = fixed_reference_junction
measurement = session.read()
print(f'Measurement (Celsius): {measurement}')


def _main(argsv):
supported_thermocouple_types = list(nidmm.ThermocoupleType.__members__.keys())
parser = argparse.ArgumentParser(description='Performs a single temperature measurement using a thermocouple with 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('-t', '--thermocouple-type', default='J', choices=supported_thermocouple_types, type=str.upper, help='Specifies the type of thermocouple used to measure the temperature.')
parser.add_argument('--reference-junction-type', default='FIXED', choices=nidmm.ThermocoupleReferenceJunctionType.__members__.keys(), type=str.upper, help='Specifies the type of reference junction to be used in the reference junction compensation of a thermocouple measurement.')
parser.add_argument('--fixed-reference-junction', default=25.0, type=float, help='Specifies the reference junction temperature when a fixed reference junction is used to take a thermocouple measurement.')
parser.add_argument('-r', '--range', default=0.1, type=float, help='Specifies the range of the measurement in volts.')
parser.add_argument('-d', '--digits', default=5.5, type=float, help='Specifies the resolution of the measurement in digits.')
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.thermocouple_type, args.reference_junction_type, args.fixed_reference_junction, args.range, args.digits)


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


def test_example():
options = {'simulate': True, 'driver_setup': {'Model': '4082', 'BoardType': 'PXIe', }, }
example('PXI1Slot2', options, 'J', 'FIXED', 25.0, 0.1, 5.5)


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


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