Skip to content
Draft
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 @@ -558,6 +558,7 @@
#### [nidigital] Unreleased
- Added
- (Common) Added `nitlsconfig[grpc]>=1.0.0a2` to the optional gRPC dependencies.
- Added the `nidigital_burst_with_conditional_trigger.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 @@ -3,6 +3,15 @@ Examples

`You can download all nidigital examples for latest version here <https://github.com/ni/nimi-python/releases/download/nidigital-1.5.0/nidigital_examples.zip>`_

nidigital_burst_with_conditional_trigger.py
-------------------------------------------

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

nidigital_burst_with_start_trigger.py
-------------------------------------

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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="PinGroup1">
<Vil>0</Vil>
<Vih>3.3</Vih>
<Vol>0.8</Vol>
<Voh>2</Voh>
<Vterm>0</Vterm>
<TerminationMode>HighZ</TerminationMode>
</DigitalPinLevelSet>
</DigitalPinLevelSets>
</PinLevelsSheet>
</PinLevelsFile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<PinMap xmlns="http://www.ni.com/TestStand/SemiconductorModule/PinMap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaVersion="1.5">
<Instruments>
<NIDigitalPatternInstrument name="PXI1Slot2" numberOfChannels="32" group="Digital" />
<NIDigitalPatternInstrument name="PXI1Slot3" numberOfChannels="32" group="Digital" />
</Instruments>
<Pins>
<DUTPin name="DUTPin1" />
<DUTPin name="DUTPin2" />
<DUTPin name="DUTPin3" />
<DUTPin name="DUTPin4" />
<DUTPin name="DUTPin5" />
<DUTPin name="DUTPin6" />
<DUTPin name="DUTPin7" />
<DUTPin name="DUTPin8" />
</Pins>
<PinGroups>
<PinGroup name="PinGroup1">
<PinReference pin="DUTPin1" />
<PinReference pin="DUTPin2" />
<PinReference pin="DUTPin3" />
<PinReference pin="DUTPin4" />
<PinReference pin="DUTPin5" />
<PinReference pin="DUTPin6" />
<PinReference pin="DUTPin7" />
<PinReference pin="DUTPin8" />
</PinGroup>
</PinGroups>
<Sites>
<Site siteNumber="0" />
<Site siteNumber="1" />
</Sites>
<Connections>
<Connection pin="DUTPin1" siteNumber="0" instrument="PXI1Slot2" channel="0" />
<Connection pin="DUTPin1" siteNumber="1" instrument="PXI1Slot3" channel="0" />
<Connection pin="DUTPin2" siteNumber="0" instrument="PXI1Slot2" channel="1" />
<Connection pin="DUTPin2" siteNumber="1" instrument="PXI1Slot3" channel="1" />
<Connection pin="DUTPin3" siteNumber="0" instrument="PXI1Slot2" channel="2" />
<Connection pin="DUTPin3" siteNumber="1" instrument="PXI1Slot3" channel="2" />
<Connection pin="DUTPin4" siteNumber="0" instrument="PXI1Slot2" channel="3" />
<Connection pin="DUTPin4" siteNumber="1" instrument="PXI1Slot3" channel="3" />
<Connection pin="DUTPin5" siteNumber="0" instrument="PXI1Slot2" channel="4" />
<Connection pin="DUTPin5" siteNumber="1" instrument="PXI1Slot3" channel="4" />
<Connection pin="DUTPin6" siteNumber="0" instrument="PXI1Slot2" channel="5" />
<Connection pin="DUTPin6" siteNumber="1" instrument="PXI1Slot3" channel="5" />
<Connection pin="DUTPin7" siteNumber="0" instrument="PXI1Slot2" channel="6" />
<Connection pin="DUTPin7" siteNumber="1" instrument="PXI1Slot3" channel="6" />
<Connection pin="DUTPin8" siteNumber="0" instrument="PXI1Slot2" channel="7" />
<Connection pin="DUTPin8" siteNumber="1" instrument="PXI1Slot3" channel="7" />
</Connections>
</PinMap>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?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="timing">
<f:Formula symbol="period">
<f:Definition>1 µs</f:Definition>
</f:Formula>
</Section>
<Description />
</Specifications>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="tset0">
<Period>timing.period</Period>
<PinEdges>
<PinEdge pin="PinGroup1">
<DriveNonReturn>
<On>0 µs</On>
<Data>timing.period / 2</Data>
<Off>timing.period</Off>
</DriveNonReturn>
<CompareStrobe>
<Strobe>(3 * timing.period) / 4</Strobe>
</CompareStrobe>
<DataSource>Pattern</DataSource>
</PinEdge>
</PinEdges>
</TimeSet>
</TimeSets>
</TimingSheet>
</TimingFile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<SourceFile Checksum="6668C444DB638177C65AECE6B645605A" xmlns="http://www.ni.com/PlatformFramework">
<SourceModelFeatureSet>
<ParsableNamespace AssemblyFileVersion="5.3.1.49673" 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.49673" FeatureSetName="Editor" Name="http://www.ni.com/PlatformFramework" OldestCompatibleVersion="5.2.0.49153" Version="5.2.0.49153" />
<ApplicationVersionInfo Build="5.3.1.49673" Name="Digital Pattern Editor" Version="19.0.0" />
</SourceModelFeatureSet>
<Project xmlns="http://www.ni.com/PlatformFramework">
<ProjectSettings Id="1" ModelDefinitionType="ProjectSettings" Name="ZProjectSettings" />
<EmbeddedDefinitionReference Id="2" ModelDefinitionType="NationalInstruments.ProjectExplorer.Modeling.ProjectDataManager" Name="ProjectExplorer">
<ProjectExplorer />
</EmbeddedDefinitionReference>
<NameScopingEnvoy Id="3" ModelDefinitionType="DefaultTarget" Name="DefaultTarget">
<DefaultTarget />
<FileReference Id="14" ModelDefinitionType="DigitalPatternEditor.PatternDefinition" Name="Pattern\.digipat" StoragePath="Pattern.digipat" />
<FileReference Id="15" ModelDefinitionType="PinLevelsDefinition" Name="PinLevels\.digilevels" StoragePath="PinLevels.digilevels" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<FileReference Id="17" ModelDefinitionType="SpecificationsDefinition" Name="Specifications\.specs" StoragePath="Specifications.specs" />
<FileReference Id="18" ModelDefinitionType="PinMap" Name="PinMap\.pinmap" StoragePath="PinMap.pinmap" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<FileReference Id="19" ModelDefinitionType="TimingDefinition" Name="Timing\.digitiming" StoragePath="Timing.digitiming" p4:IsActive="True" xmlns:p4="http://www.ni.com/PatternBasedDigital" />
<EmbeddedDefinitionReference Id="20" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}CaptureResultsDefinition" Name="CaptureResults">
<CaptureResultsDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="22" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}BurstResultsDefinition" Name="BurstResults">
<BurstResultsDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="24" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}SystemInfoDefinition" Name="SystemInfo">
<SystemInfoDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
<EmbeddedDefinitionReference Id="25" ModelDefinitionType="{http://www.ni.com/PatternBasedDigital}DigitalScopeDefinition" Name="DigitalScope">
<DigitalScopeDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
</NameScopingEnvoy>
<EmbeddedDefinitionReference Id="7" ModelDefinitionType="DigitalPatternEditor.ProjectPropertiesDefinition" Name="ProjectProperties">
<ProjectPropertiesDefinition xmlns="http://www.ni.com/PatternBasedDigital" />
</EmbeddedDefinitionReference>
</Project>
<ProjectInformation xmlns="http://www.ni.com/PlatformFramework" />
</SourceFile>
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/python

import argparse
import nidigital
import os
import sys


def example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger):

with nidigital.Session(resource_name=resource_name, reset_device=True, options=options) as session:

directory = os.path.dirname(os.path.abspath(__file__))

# Load the pin map (.pinmap) created using the Digital Pattern Editor
pin_map_filename = os.path.join(directory, 'PinMap.pinmap')
session.load_pin_map(pin_map_filename)

# Load the specifications (.specs), levels (.digilevels), and timing (.digitiming) sheets created using the Digital Pattern Editor
spec_filename = os.path.join(directory, 'Specifications.specs')
levels_filename = os.path.join(directory, 'PinLevels.digilevels')
timing_filename = os.path.join(directory, 'Timing.digitiming')
session.load_specifications_levels_and_timing(spec_filename, levels_filename, timing_filename)

# Apply the settings from the levels and timing sheets we just loaded to the session
session.apply_levels_and_timing(levels_filename, timing_filename)

# Load the pattern file (.digipat) created using the Digital Pattern Editor
pattern_filename = os.path.join(directory, 'Pattern.digipat')
session.load_pattern(pattern_filename)

# Configure the conditional jump trigger instance used by the pattern
trigger_identifier = 'conditionalJumpTrigger0'
conditional_trigger = session.conditional_jump_triggers[trigger_identifier]
conditional_trigger.conditional_jump_trigger_type = trigger_type
if trigger_type == nidigital.TriggerType.DIGITAL_EDGE:
# Specify a source and edge for the external conditional jump trigger
conditional_trigger.digital_edge_conditional_jump_trigger_source = trigger_source
conditional_trigger.digital_edge_conditional_jump_trigger_edge = trigger_edge

try:
print('Start bursting pattern')
if trigger_type == nidigital.TriggerType.SOFTWARE:
# Start the burst without blocking so the software conditional trigger can be sent
session.burst_pattern(start_label='new_pattern', wait_until_done=False)
if not send_software_trigger:
print('Pattern burst stopped without sending a software trigger')
return

# Send the software conditional trigger and wait until the pattern is done bursting
session.send_software_edge_trigger(nidigital.SoftwareTrigger.CONDITIONAL_JUMP, trigger_identifier)
session.wait_until_done()
else:
# Burst the pattern and block until completion, including any wait for an external conditional trigger
session.burst_pattern(start_label='new_pattern')
finally:
try:
# Abort any pending burst before disconnecting the channels
session.abort()
finally:
# Disconnect all channels using programmable onboard switching
session.selected_function = nidigital.SelectedFunction.DISCONNECT
print('Done bursting pattern')


def _main(argsv):
parser = argparse.ArgumentParser(description='Demonstrates how to burst a pattern on the digital pattern instrument using a conditional trigger.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-n', '--resource-name', default='PXI1Slot2,PXI1Slot3', help='The specified resource name shown in Measurement & Automation Explorer (MAX) for 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('-tt', '--trigger-type', default='SOFTWARE', type=str.upper, choices=nidigital.TriggerType.__members__, help='Disables the conditional jump trigger or configures it for either hardware triggering or software triggering.')
parser.add_argument('-ts', '--trigger-source', default='/PXI1Slot2/PXI_Trig0', help='Configures the digital trigger source terminal for a conditional jump trigger instance.')
parser.add_argument('-te', '--trigger-edge', default='RISING', type=str.upper, choices=nidigital.DigitalEdge.__members__, help='Configures the active edge of the incoming trigger signal for the conditional jump trigger instance.')
parser.add_argument('--send-software-trigger', default='True', choices=['True', 'False'], help='Whether to send the software conditional trigger or stop the burst without sending it; applies only to SOFTWARE mode.')
args = parser.parse_args(argsv)

example(args.resource_name,
'Simulate=1, DriverSetup=Model:6570' if args.simulate == 'True' else '',
nidigital.TriggerType[args.trigger_type], args.trigger_source,
nidigital.DigitalEdge[args.trigger_edge], args.send_software_trigger == 'True')


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


def test_main():
_main([])
_main(['--trigger-type', 'NONE'])
_main(['--trigger-type', 'DIGITAL_EDGE'])
_main(['--trigger-type', 'DIGITAL_EDGE', '--trigger-edge', 'FALLING'])
_main(['--send-software-trigger', 'False'])


def test_example():
resource_name = 'PXI1Slot2,PXI1Slot3'
options = {'simulate': True, 'driver_setup': {'Model': '6570'}}
trigger_source = '/PXI1Slot2/PXI_Trig0'
trigger_edge = nidigital.DigitalEdge.RISING

trigger_type = nidigital.TriggerType.SOFTWARE
example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger=True)
example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger=False)

trigger_type = nidigital.TriggerType.NONE
example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger=True)

trigger_type = nidigital.TriggerType.DIGITAL_EDGE
example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger=True)

trigger_edge = nidigital.DigitalEdge.FALLING
example(resource_name, options, trigger_type, trigger_source, trigger_edge, send_software_trigger=True)


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