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
Open
divakar-selvam07
wants to merge
13
commits into
ni:master
Choose a base branch
from
NI-velmurugan:users/diva/add-nidmm-improve-dc-noise-rejection-example
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4eb8624
Add @Avinash2Suresh as a code owner
NI-velmurugan cdf7fa8
add: add Improve DC Noise Rejection example for nidmm
divakar-selvam07 c965114
Remove @Avinash2Suresh from CODEOWNERS
divakar-selvam07 9d4d325
Merge branch 'master' of https://github.com/NI-velmurugan/nimi-python…
divakar-selvam07 b12451d
fix: fix tests
divakar-selvam07 944eda7
Trigger CI build
divakar-selvam07 8173be4
Merge remote-tracking branch 'upstream/master' into users/diva/add-ni…
divakar-selvam07 f97bec3
resolve PR comments
divakar-selvam07 eeb4882
Trigger CI build
divakar-selvam07 5b30a87
Trigger CI build
divakar-selvam07 a39ffd0
Trigger CI build
divakar-selvam07 5c9e94f
add: add number of averages parameter
divakar-selvam07 ab9bcff
doc: add self explainatory comments
divakar-selvam07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| session.auto_zero = nidmm.AutoZero[auto_zero] | ||
| session.aperture_time_units = nidmm.ApertureTimeUnits.SECONDS | ||
|
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.') | ||
|
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() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.