diff --git a/CHANGELOG.md b/CHANGELOG.md index 53c979fcd..5846ee323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -559,6 +559,7 @@ - Added - (Common) Added `nitlsconfig[grpc]>=1.0.0a2` to the optional gRPC dependencies. - Added the `nidigital_load_sheets_and_burst.py` example. + - Added the `nidigital_spi.py` example. - Changed - Removed diff --git a/docs/nidigital/examples.rst b/docs/nidigital/examples.rst index cde76451e..4a88a8dfd 100644 --- a/docs/nidigital/examples.rst +++ b/docs/nidigital/examples.rst @@ -30,6 +30,15 @@ nidigital_load_sheets_and_burst.py :encoding: utf8 :caption: `(nidigital_load_sheets_and_burst.py) `_ +nidigital_spi.py +---------------- + +.. literalinclude:: ../../src/nidigital/examples/nidigital_spi/nidigital_spi.py + :language: python + :linenos: + :encoding: utf8 + :caption: `(nidigital_spi.py) `_ + nidigital_ppmu_source_and_measure.py ------------------------------------ diff --git a/src/nidigital/examples/nidigital_spi/Pattern.digipat b/src/nidigital/examples/nidigital_spi/Pattern.digipat new file mode 100644 index 000000000..a3566238d Binary files /dev/null and b/src/nidigital/examples/nidigital_spi/Pattern.digipat differ diff --git a/src/nidigital/examples/nidigital_spi/PinLevels.digilevels b/src/nidigital/examples/nidigital_spi/PinLevels.digilevels new file mode 100644 index 000000000..2abf8995b --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/PinLevels.digilevels @@ -0,0 +1,51 @@ + + + + + + dc.vcc * 0.7 + 0 + 2.5 + 0.5 + 1.5 m + -1.5 m + 0 + 0 + HighZ + + + dc.vcc * 0.7 + 0 + 2.5 + 0.5 + 1.5 m + -1.5 m + 0 + 0 + HighZ + + + dc.vcc * 0.7 + 0 + 2.5 + 0.5 + 1.5 m + -1.5 m + 0 + 0 + HighZ + + + dc.vcc * 0.7 + 0 + 2.5 + 0.5 + 1.5 m + -1.5 m + 0 + 0 + HighZ + + + + \ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/PinMap.pinmap b/src/nidigital/examples/nidigital_spi/PinMap.pinmap new file mode 100644 index 000000000..b1d83f29c --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/PinMap.pinmap @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/Shmoo.digishmoo b/src/nidigital/examples/nidigital_spi/Shmoo.digishmoo new file mode 100644 index 000000000..dc44ec00c --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/Shmoo.digishmoo @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/Specifications.specs b/src/nidigital/examples/nidigital_spi/Specifications.specs new file mode 100644 index 000000000..f403e1704 --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/Specifications.specs @@ -0,0 +1,16 @@ + + +
+ + 5 + V + +
+
+ + 1 / 1000000 + 1 MHz + +
+ +
\ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/Timing.digitiming b/src/nidigital/examples/nidigital_spi/Timing.digitiming new file mode 100644 index 000000000..2051e0ece --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/Timing.digitiming @@ -0,0 +1,57 @@ + + + + + + ac.period + + + + 0 + 0 + ac.period + + + (3 * ac.period) / 4 + + Pattern + + + + ac.period / 2 + ac.period / 2 + ac.period + ac.period + + + (3 * ac.period) / 4 + + Pattern + + + + 0 + 0 + ac.period + + + (3 * ac.period) / 4 + + Pattern + + + + 0 + 0 + ac.period + + + (3 * ac.period) / 4 + + Pattern + + + + + + \ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/nidigital_spi.digiproj b/src/nidigital/examples/nidigital_spi/nidigital_spi.digiproj new file mode 100644 index 000000000..2957367af --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/nidigital_spi.digiproj @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/nidigital/examples/nidigital_spi/nidigital_spi.py b/src/nidigital/examples/nidigital_spi/nidigital_spi.py new file mode 100644 index 000000000..fc62d616d --- /dev/null +++ b/src/nidigital/examples/nidigital_spi/nidigital_spi.py @@ -0,0 +1,65 @@ +#!/usr/bin/python + +import argparse +import nidigital +import os +import sys + + +def example(resource_name, options, start_label='SPI_Pattern'): + + with nidigital.Session(resource_name=resource_name, options=options) as session: + + dir = os.path.join(os.path.dirname(__file__)) + + pin_map_filename = os.path.join(dir, 'PinMap.pinmap') + session.load_pin_map(pin_map_filename) + + spec_filename = os.path.join(dir, 'Specifications.specs') + levels_filename = os.path.join(dir, 'PinLevels.digilevels') + timing_filename = os.path.join(dir, 'Timing.digitiming') + session.load_specifications_levels_and_timing(spec_filename, levels_filename, timing_filename) + + session.apply_levels_and_timing(levels_filename, timing_filename) + + pattern_filename = os.path.join(dir, 'Pattern.digipat') + session.load_pattern(pattern_filename) + + # The returned dictionary maps each site number to its pass/fail result + site_pass_fail_results = session.burst_pattern(start_label=start_label) + + session.selected_function = nidigital.SelectedFunction.DISCONNECT + + for site, passed in site_pass_fail_results.items(): + print('Site {}: {}'.format(site, 'Pass' if passed else 'Fail')) + + +def _main(argsv): + parser = argparse.ArgumentParser(description='Demonstrates how to burst an SPI pattern on the digital pattern instrument and display the pass/fail result for each site.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('-n', '--resource-name', default='PXI1Slot2,PXI1Slot3', help='The specified resource name of a digital pattern instrument, for example, PXI1Slot3, where PXI1Slot3 is an instrument resource name.') + parser.add_argument('-s', '--simulate', default='True', choices=['True', 'False'], help='Whether to run on simulated hardware or real hardware') + parser.add_argument('-l', '--start-label', default='SPI_Pattern', help='Pattern label or name of the pattern from which to start bursting.') + args = parser.parse_args(argsv) + + example(args.resource_name, + 'Simulate=1, DriverSetup=Model:6570' if args.simulate == 'True' else '', + args.start_label) + + +def main(): + _main(sys.argv[1:]) + + +def test_main(): + _main([]) + + +def test_example(): + resource_name = 'PXI1Slot2,PXI1Slot3' + options = {'simulate': True, 'driver_setup': {'Model': '6570'}, } + start_label = 'SPI_Pattern' + example(resource_name, options, start_label) + + +if __name__ == '__main__': + main()