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 @@ -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

Expand Down
9 changes: 9 additions & 0 deletions docs/nidigital/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ nidigital_load_sheets_and_burst.py
:encoding: utf8
:caption: `(nidigital_load_sheets_and_burst.py) <https://github.com/ni/nimi-python/blob/master/src/nidigital/examples/load_sheets_and_burst/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) <https://github.com/ni/nimi-python/blob/master/src/nidigital/examples/nidigital_spi/nidigital_spi.py>`_

nidigital_ppmu_source_and_measure.py
------------------------------------

Expand Down
Binary file not shown.
51 changes: 51 additions & 0 deletions src/nidigital/examples/nidigital_spi/PinLevels.digilevels
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<PinLevelsFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" xmlns="http://www.ni.com/Semiconductor/PinLevels">
<PinLevelsSheet>
<DigitalPinLevelSets>
<DigitalPinLevelSet pin="CS">
<Vil>dc.vcc * 0.7</Vil>
<Vih>0</Vih>
<Vol>2.5</Vol>
<Voh>0.5</Voh>
<Iol>1.5 m</Iol>
<Ioh>-1.5 m</Ioh>
<Vcom>0</Vcom>
<Vterm>0</Vterm>
<TerminationMode>HighZ</TerminationMode>
</DigitalPinLevelSet>
<DigitalPinLevelSet pin="SCLK">
<Vil>dc.vcc * 0.7</Vil>
<Vih>0</Vih>
<Vol>2.5</Vol>
<Voh>0.5</Voh>
<Iol>1.5 m</Iol>
<Ioh>-1.5 m</Ioh>
<Vcom>0</Vcom>
<Vterm>0</Vterm>
<TerminationMode>HighZ</TerminationMode>
</DigitalPinLevelSet>
<DigitalPinLevelSet pin="MOSI">
<Vil>dc.vcc * 0.7</Vil>
<Vih>0</Vih>
<Vol>2.5</Vol>
<Voh>0.5</Voh>
<Iol>1.5 m</Iol>
<Ioh>-1.5 m</Ioh>
<Vcom>0</Vcom>
<Vterm>0</Vterm>
<TerminationMode>HighZ</TerminationMode>
</DigitalPinLevelSet>
<DigitalPinLevelSet pin="MISO">
<Vil>dc.vcc * 0.7</Vil>
<Vih>0</Vih>
<Vol>2.5</Vol>
<Voh>0.5</Voh>
<Iol>1.5 m</Iol>
<Ioh>-1.5 m</Ioh>
<Vcom>0</Vcom>
<Vterm>0</Vterm>
<TerminationMode>HighZ</TerminationMode>
</DigitalPinLevelSet>
</DigitalPinLevelSets>
</PinLevelsSheet>
</PinLevelsFile>
45 changes: 45 additions & 0 deletions src/nidigital/examples/nidigital_spi/PinMap.pinmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<PinMap schemaVersion="1.5" xmlns="http://www.ni.com/TestStand/SemiconductorModule/PinMap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Instruments>
<NIDigitalPatternInstrument name="PXI1Slot2" numberOfChannels="32" group="Digital" />
<NIDigitalPatternInstrument name="PXI1Slot3" numberOfChannels="32" group="Digital" />
</Instruments>
<Pins>
<DUTPin name="CS" />
<DUTPin name="SCLK" />
<DUTPin name="MOSI" />
<DUTPin name="MISO" />
</Pins>
<PinGroups>
<PinGroup name="SPI_PINS">
<PinReference pin="SCLK" />
<PinReference pin="CS" />
<PinReference pin="MOSI" />
<PinReference pin="MISO" />
</PinGroup>
</PinGroups>
<Sites>
<Site siteNumber="0" />
<Site siteNumber="1" />
<Site siteNumber="2" />
<Site siteNumber="3" />
</Sites>
<Connections>
<Connection pin="CS" siteNumber="0" instrument="PXI1Slot2" channel="0" />
<Connection pin="SCLK" siteNumber="0" instrument="PXI1Slot2" channel="1" />
<Connection pin="MOSI" siteNumber="0" instrument="PXI1Slot2" channel="2" />
<Connection pin="MISO" siteNumber="0" instrument="PXI1Slot2" channel="3" />
<Connection pin="CS" siteNumber="1" instrument="PXI1Slot2" channel="4" />
<Connection pin="CS" siteNumber="2" instrument="PXI1Slot3" channel="0" />
<Connection pin="CS" siteNumber="3" instrument="PXI1Slot3" channel="4" />
<Connection pin="SCLK" siteNumber="1" instrument="PXI1Slot2" channel="5" />
<Connection pin="MOSI" siteNumber="1" instrument="PXI1Slot2" channel="6" />
<Connection pin="MISO" siteNumber="1" instrument="PXI1Slot2" channel="7" />
<Connection pin="MISO" siteNumber="2" instrument="PXI1Slot3" channel="3" />
<Connection pin="MISO" siteNumber="3" instrument="PXI1Slot3" channel="7" />
<Connection pin="MOSI" siteNumber="2" instrument="PXI1Slot3" channel="2" />
<Connection pin="MOSI" siteNumber="3" instrument="PXI1Slot3" channel="6" />
<Connection pin="SCLK" siteNumber="2" instrument="PXI1Slot3" channel="1" />
<Connection pin="SCLK" siteNumber="3" instrument="PXI1Slot3" channel="5" />
</Connections>
</PinMap>
14 changes: 14 additions & 0 deletions src/nidigital/examples/nidigital_spi/Shmoo.digishmoo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<SourceFile Checksum="D2BAABBF12CBC90C7D79BDBE3006E7C3" xmlns="http://www.ni.com/PlatformFramework">
<SourceModelFeatureSet>
<ParsableNamespace AssemblyFileVersion="4.0.0.24189" FeatureSetName="NI Digital Pattern Editor" MinimumParsableVersion="4.0.0.0" MinimumSemanticallyEquivalentVersion="4.0.0.0" Name="http://www.ni.com/PatternBasedDigital" Version="4.0.0.0" />
<ParsableNamespace AssemblyFileVersion="4.0.0.24189" FeatureSetName="Editor" MinimumParsableVersion="4.0.0.0" MinimumSemanticallyEquivalentVersion="4.0.0.0" Name="http://www.ni.com/PlatformFramework" Version="4.0.0.29" />
<ApplicationVersionInfo Name="Digital Pattern Editor" Version="4.0.0.24189" />
</SourceModelFeatureSet>
<ShmooSetupDefinition xmlns="http://www.ni.com/PatternBasedDigital">
<Shmoo Id="1" OutputPath="" PatternName="SPI_Pattern">
<ShmooAxisSetup Id="2" Name="X-Axis" PinItems="MISO" ShmooType="CompareStrobe" Start="0 µs" StepSize="10 ns" Stop="1.2 µs" TimeSets="SPI" />
<ShmooAxisSetup Id="3" Name="Y-Axis" PinItems="MISO" ShmooType="Voh" Start="2 V" StepSize="0.1 V" Stop="3 V" TimeSets="SPI" />
</Shmoo>
</ShmooSetupDefinition>
</SourceFile>
16 changes: 16 additions & 0 deletions src/nidigital/examples/nidigital_spi/Specifications.specs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Specifications xmlns:f="http://www.ni.com/schemas/Semiconductor/Formula.xsd" schemaVersion="1.0" xmlns="http://www.ni.com/schemas/Semiconductor/Specifications.xsd">
<Section name="dc">
<f:Formula symbol="vcc">
<f:Definition>5</f:Definition>
<f:Description>V</f:Description>
</f:Formula>
</Section>
<Section name="ac">
<f:Formula symbol="period">
<f:Definition>1 / 1000000</f:Definition>
<f:Description>1 MHz</f:Description>
</f:Formula>
</Section>
<Description />
</Specifications>
57 changes: 57 additions & 0 deletions src/nidigital/examples/nidigital_spi/Timing.digitiming
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<TimingFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.0" xmlns="http://www.ni.com/Semiconductor/Timing">
<TimingSheet>
<TimeSets>
<TimeSet name="SPI">
<Period>ac.period</Period>
<PinEdges>
<PinEdge pin="CS">
<DriveNonReturn>
<On>0</On>
<Data>0</Data>
<Off>ac.period</Off>
</DriveNonReturn>
<CompareStrobe>
<Strobe>(3 * ac.period) / 4</Strobe>
</CompareStrobe>
<DataSource>Pattern</DataSource>
</PinEdge>
<PinEdge pin="SCLK">
<ReturnToLow>
<On>ac.period / 2</On>
<Data>ac.period / 2</Data>
<Return>ac.period</Return>
<Off>ac.period</Off>
</ReturnToLow>
<CompareStrobe>
<Strobe>(3 * ac.period) / 4</Strobe>
</CompareStrobe>
<DataSource>Pattern</DataSource>
</PinEdge>
<PinEdge pin="MOSI">
<DriveNonReturn>
<On>0</On>
<Data>0</Data>
<Off>ac.period</Off>
</DriveNonReturn>
<CompareStrobe>
<Strobe>(3 * ac.period) / 4</Strobe>
</CompareStrobe>
<DataSource>Pattern</DataSource>
</PinEdge>
<PinEdge pin="MISO">
<DriveNonReturn>
<On>0</On>
<Data>0</Data>
<Off>ac.period</Off>
</DriveNonReturn>
<CompareStrobe>
<Strobe>(3 * ac.period) / 4</Strobe>
</CompareStrobe>
<DataSource>Pattern</DataSource>
</PinEdge>
</PinEdges>
</TimeSet>
</TimeSets>
</TimingSheet>
</TimingFile>
39 changes: 39 additions & 0 deletions src/nidigital/examples/nidigital_spi/nidigital_spi.digiproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<SourceFile Checksum="BB0032E819E476A89A56C8757D885885" xmlns="http://www.ni.com/PlatformFramework">
<SourceModelFeatureSet>
<ParsableNamespace AssemblyFileVersion="5.3.1.51258" FeatureSetName="Digital Pattern Editor" Name="http://www.ni.com/PatternBasedDigital" OldestCompatibleVersion="4.5.0.0" Version="4.6.0.49152" />
<ParsableNamespace AssemblyFileVersion="5.3.1.51258" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="5.2.0.49153" Version="5.2.0.49153" />
<ApplicationVersionInfo Build="5.3.1.51258" Name="Digital Pattern Editor" Version="19.0.0" />
</SourceModelFeatureSet>
<Project xmlns="http://www.ni.com/PlatformFramework">
<ProjectSettings Id="1" ModelDefinitionType="ProjectSettings" Name="ZProjectSettings" />
<NameScopingEnvoy Id="2" ModelDefinitionType="DefaultTarget" Name="DefaultTarget">
<DefaultTarget />
<FileReference Id="44" ModelDefinitionType="PinLevelsDefinition" Name="PinLevels\.digilevels" StoragePath="PinLevels.digilevels" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<SourceFileReference Id="45" ModelDefinitionType="ShmooSetupDefinition" Name="Shmoo\.digishmoo" StoragePath="Shmoo.digishmoo" />
<FileReference Id="46" ModelDefinitionType="SpecificationsDefinition" Name="Specifications\.specs" StoragePath="Specifications.specs" />
<FileReference Id="49" ModelDefinitionType="TimingDefinition" Name="Timing\.digitiming" StoragePath="Timing.digitiming" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<FileReference Id="56" ModelDefinitionType="PinMap" Name="PinMap\.pinmap" StoragePath="PinMap.pinmap" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<FileReference Id="57" ModelDefinitionType="DigitalPatternEditor.PatternDefinition" Name="Pattern\.digipat" StoragePath="Pattern.digipat" />
<EmbeddedDefinitionReference Id="58" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}CaptureResultsDefinition" Name="CaptureResults">
<CaptureResultsDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="60" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}BurstResultsDefinition" Name="BurstResults">
<BurstResultsDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="62" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}SystemInfoDefinition" Name="SystemInfo">
<SystemInfoDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="63" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}DigitalScopeDefinition" Name="DigitalScope">
<DigitalScopeDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
</NameScopingEnvoy>
<EmbeddedDefinitionReference Id="5" ModelDefinitionType="NationalInstruments.ProjectExplorer.Modeling.ProjectDataManager" Name="ProjectExplorer">
<ProjectExplorer />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="37" ModelDefinitionType="DigitalPatternEditor.ProjectPropertiesDefinition" Name="ProjectProperties">
<ProjectPropertiesDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
</Project>
<ProjectInformation xmlns="http://www.ni.com/PlatformFramework" />
</SourceFile>
65 changes: 65 additions & 0 deletions src/nidigital/examples/nidigital_spi/nidigital_spi.py
Original file line number Diff line number Diff line change
@@ -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([])
Comment thread
NI-velmurugan marked this conversation as resolved.
Resolved


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()
Loading