Interfacing with NI-Hardware drivers using Python Custom step and Python Adapter
- Updated2025-03-28
- 3 minute(s) read
Interfacing with NI-Hardware drivers using Python Custom step and Python Adapter
Purpose
This example demonstrates the possibility of TestStand interfacing with NI device drivers through Python packages for the desired NI devices.
The example will not use the actual device drivers. It will mimic the behaviour of the device drivers. You can modify the Python modules to interact with actual Python drivers.
The example will call into a Python module that will use simulated Python drivers for accessing device.
Example File Location
<TestStand Public>Examples\Interfacing with Hardware\Interfacing Modular Instruments Using Python Custom Step Type\InterfacingModularInstrumentsUsingPyCustomStepType.seq
Highlighted Features
- Custom Step Types
Major API
None
Prerequisites
You must have Python 3.6 installed and added to your PATH variable.
How to Use This Example
Complete the following steps to use this example.
- On the Steps pane of the MainSequence sequence, review the steps in the Setup step group.
- The Create Device Sessions step, which is a Sequence Call step, simulates the creation of device sessions for the NI-DMM and NI-DcPower devices.
- On the Steps pane of the MainSequence sequence, review the steps in the Main step group.
- The NI-DMM step, which is a Sequence Call step, simulates the interfacing with the NI-DMM Python package for the NI-DMM device.
- The NI-SMU [DcPower] step, which is a Sequence Call step, simulates the interfacing with the NI-DcPower Python package for the NI-DCPower device.
- On the Steps pane of the MainSequence sequence, review the steps in the Cleanup step group.
- The Close Device Sessions step, which is a Sequence Call step, simulates the releasing of the device sessions for NI-DMM and NI-DcPower devices.
- On the Steps pane of the CreateDeviceSessions subsequence, review the steps in the Main step group.
- The New NI-DMM Session and the New NI-DCPower Session steps, which are instances of the Custom Step Types NIDMM_NewSession and NIDCPOWER_NewSession of the sequence file respectively, create new sessions.
- The New NI-DMM Session step and the New NI-DCPower Session step open two separate Python interpreter sessions for the respective devices.
- On the Steps pane of the NI-DMM subsequence, review the steps in the Main step group.
- The Auto Schedule step, which is an Auto Schedule Synchronization step, performs auto scheduling (avoids multiple access) of the steps within the Use Auto Scheduled Resource block.
- The Use Auto Scheduled Resource block, which is a Use Auto Scheduled Resource Synchronization step, defines the set of steps that needs to be considered for auto scheduling.
- The Configure NI-DMM Session step, simulates the initialization of the NI-DMM device session by setting the Range, Rate, number of Points to measure and the measurement type properties in the NI-DMM device session object.
- The Get DMM Measurements step simulates the collecting of measurement values from the NI-DMM device using the NI-DMM device session object.
- The Average DMM Measurements, which is a Numeric Limit Test step, calculates the average of the measured values and validates it with a defined test range.
- The Results step, which is an Additional Results step, displays the measurement values obtained from the NI-DMM session object.
- On the Steps pane if the NI-SMU [DcPower] subsequence, review the steps in the Main step group.
- The Auto Schedule step, which is an Auto Schedule Synchronization step, performs auto scheduling (avoids multiple access) of the steps within the Use Auto Scheduled Resource block.
- The Use Auto Scheduled Resource block, which is a Use Auto Scheduled Resource Synchronization step, defines the set of steps that needs to be considered for auto scheduling.
- The Configure NI-DCPower Session step, simulates the initialization of the NI-DCPower device session by setting the current and voltage Limits and Ranges and the number of Points to measure in the NI-DCPower device session object.
- The Get DCPower Measurements [Voltage, Current] step simulates the collecting of voltage and current measurement values from the NI-DCPower device using the NI-DCPower device session object.
- The Average DCPower Voltage Measurement in Channel 0 and 1 and the Average DCPower Current Measurement in Channel 0 and 1, which is an Action step, calculates the average of the measured values across channels 0 and 1.
- The Validate Averaged Measurements, which is a Multiple Numeric Limit Test step, validates the average of the measured values with defined test ranges.
- the Results step, which is an Additional Results step, displays the measurement values obtained from the NI-DCPower session object across channels 0 and 1.
- On the Steps pane of the CloseDeviceSessions subsequence, review the steps in the Main step group.
- The Close NI-DMM Session and the Close NI-DCPower Session steps, which are instances of the Custom Step Types NIDMM_CloseSession and NIDCPOWER_CloseSession respectively of the sequence file, simulate the releasing of the device sessions.
- Select Execute»Single Pass to run the sequence.
- When execution completes, review the report.