Repository navigation
Adding Improve DC Noise Rejection example in NI-DMM #2217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4eb8624
cdf7fa8
c965114
9d4d325
b12451d
944eda7
8173be4
f97bec3
eeb4882
5b30a87
a39ffd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/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): | ||
| 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) | ||
| session.auto_zero = nidmm.AutoZero[auto_zero] | ||
| session.aperture_time_units = nidmm.ApertureTimeUnits.SECONDS | ||
| session.aperture_time = aperture_time | ||
| session.dc_noise_rejection = nidmm.DCNoiseRejection[dc_noise_rejection] | ||
| 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.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add the number of averages property for the user to set? I know this isn't in the DC noise rejection example but I think it's a useful thing to show. You can set the default to 8 (which is what is set in the LV example called "Improve DC Resolution"). After adding it, can you add a comment (place comment above in example) explaining the number of averages. Something like "For measurements with a long aperture time (>100ms), it is recommend that Auto Zero is enabled. To compensate for any drift during the aperture time, several shorter measurements can be taken with a new Auto Zero offset applied to each measurement. These measurement are then averaged and a single value is returned." |
||
| 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) | ||
|
divakar-selvam07 marked this conversation as resolved.
|
||
|
|
||
|
|
||
| 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') | ||
|
|
||
|
|
||
| def test_main(): | ||
| cmd_line = ['--option-string', 'Simulate=1, DriverSetup=Model:4082; BoardType:PXIe', ] | ||
| _main(cmd_line) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
Uh oh!
There was an error while loading. Please reload this page.