Interfacing with NI-Hardware drivers using Python Custom step and Python Adapter

TestStand 2019 Help

Edition Date: May 2019

Part Number: 370052AA-01

»View Product Info
Download Help (Windows Only)

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


Open Example

<TestStand Public>Examples\Interfacing with Hardware\Interfacing Modular Instruments Using Python Custom Step Type\Interfacing Modular Instruments Using Python Custom Step Type.seq

Highlighted Features

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. Select Execute»Single Pass to run the sequence.
  9. When execution completes, review the report.

WAS THIS ARTICLE HELPFUL?

Not Helpful