Skip to content
Open
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_improve_dc_noise_rejection.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 @@ -12,6 +12,15 @@ nidmm_fetch_waveform.py
:encoding: utf8
:caption: `(nidmm_fetch_waveform.py) <https://github.com/ni/nimi-python/blob/master/src/nidmm/examples/nidmm_fetch_waveform.py>`_

nidmm_improve_dc_noise_rejection.py
-----------------------------------

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

nidmm_measure_ac_volts.py
-------------------------

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

import argparse
import nidmm
import sys


def example(resource_name, options, function, range, digits, aperture_time, dc_noise_rejection, sample_count, auto_zero, number_of_averages):
with nidmm.Session(resource_name=resource_name, options=options) as session:
session.configure_measurement_digits(measurement_function=nidmm.Function[function], range=range, resolution_digits=digits)
session.configure_multi_point(trigger_count=1, sample_count=sample_count)
Comment thread
divakar-selvam07 marked this conversation as resolved.
session.auto_zero = nidmm.AutoZero[auto_zero]
session.aperture_time_units = nidmm.ApertureTimeUnits.SECONDS
Comment thread
divakar-selvam07 marked this conversation as resolved.
# To remove low frequency noise from a measurement, set the aperture time to a multiple of 1/f, where f is the noise frequency.
session.aperture_time = aperture_time
# NORMAL weighs all samples equally; SECOND_ORDER and HIGH_ORDER weigh samples in the middle of the aperture more.
session.dc_noise_rejection = nidmm.DCNoiseRejection[dc_noise_rejection]
# For aperture times over 100 ms, enable AutoZero to compensate for drift.
# The DMM takes shorter measurements, applies a new AutoZero offset to each,
# averages them, and returns one value.
session.number_of_averages = number_of_averages
measurements = session.read_multi_point(array_size=sample_count)
print(f'Measurements for {sample_count} Samples: {measurements}')


def _main(argsv):
supported_functions = list(nidmm.Function.__members__.keys())
supported_noise_rejection_modes = list(nidmm.DCNoiseRejection.__members__.keys())
parser = argparse.ArgumentParser(description='Performs a multipoint DC voltage measurement with configurable DC noise rejection.', 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('-op', '--option-string', default='', type=str, help='Sets the initial value of certain attributes for the session.')
parser.add_argument('-f', '--function', default='DC_VOLTS', choices=supported_functions, type=str.upper, help='Specifies the measurement_function used to acquire the measurement.')
parser.add_argument('-r', '--range', default=0.1, type=float, help='Specifies the range for the function specified in the Measurement_Function parameter.')
parser.add_argument('-d', '--digits', default=6.5, type=float, help='Specifies the resolution of the measurement in digits.')
parser.add_argument('--auto-zero', default='OFF', choices=nidmm.AutoZero.__members__.keys(), type=str.upper, help='Specifies the AutoZero mode.')
parser.add_argument('-a', '--aperture-time', default=0.1, type=float, help='Specifies the measurement aperture time for the current configuration, in seconds.')
parser.add_argument('--dc-noise-rejection', default='NORMAL', choices=supported_noise_rejection_modes, type=str.upper, help='Specifies the DC noise rejection mode.')
parser.add_argument('-s', '--sample-count', default=10, type=int, help='Specifies the number of measurements the DMM takes each time it receives a trigger in a multiple point acquisition.')
Comment thread
divakar-selvam07 marked this conversation as resolved.
parser.add_argument('--number-of-averages', default=8, type=int, help='Specifies the number of averages to perform in a measurement.')
args = parser.parse_args(argsv)
example(args.resource_name, args.option_string, args.function, args.range, args.digits, args.aperture_time, args.dc_noise_rejection, args.sample_count, args.auto_zero, args.number_of_averages)


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


def test_example():
options = {'simulate': True, 'driver_setup': {'Model': '4082', 'BoardType': 'PXIe', }, }
example('PXI1Slot2', options, 'DC_VOLTS', 0.1, 6.5, 0.1, 'NORMAL', 10, 'OFF', 8)


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


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