Example Code

VISA Custom Steps Types for TestStand

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

    Driver

  • NI VISA

Code and Documents

Attachment

Description

Overview

 

 The VISA step types are an example of custom steps that integrate TestStand with VISA devices.  This example provides a set of new steps that allow TestStand to perform basic VISA operations such as Read, Write, and Configure Serial Port without additional code. The VISA steps use substeps called using the LabWindows™/CVI Adapter to communicate with a DLL created with  LabWindows™/CVI.  

If you need to perform more sophisticated VISA tasks, you can use the NI-VISA built-in functions available in LabVIEW or LabWindows™/CVI to develop your code.  This example requires the NI-VISA driver.

 

Description

 

The VISA step types use the NI-VISA driver functions to perform basic VISA operations.  This example uses the  LabWindows™/CVI adapter and the source code is provided. The VISA steps can be configured for any VISA device.  Each step type provides a configuration dialog to set the parameters at edit-time for the VISA call using an edit substep defined in the step type.  When the step is executed, the VISA call is implemented in a post-step substep.

 

 

 

Note: These step types are compatible with 32-bit versions of TestStand only.  

 

The TestStand Step Types include:

  • VISA Open
  • VISA Config Serial Port
  • VISA Write
  • VISA Read
  • VISA Close

If you need to perform more sophisticated VISA tasks, create specific code modules using the NI-VISA built-in functions available in LabVIEW or LabWindows™/CVI to develop your code.

 

Visa Open

Opens a VISA session to a VISA Resource. To configure the VISA Open step, Right Click on the step » Configure VISA Open.

  • VISA Resource Name - String data type that specifies the VISA Resource Name. You can directly specify the string using VISA conventions or use TestStand string variables in this field.
  • VISA Resource Handle - Numeric data type used to store a handle to the current VISA session. This handle is used in all subsequent VISA steps.

 

VISA Config Serial Port

When the VISA session is a serial port, use this step to configure parameters of the serial port. To configure the VISA Config Serial Port, Right Click on the step » Configure VISA Serial Port.

  • VISA Resource Handle - Numeric data type used to define the current VISA session. This handle is created using the VISA Open Step.
  • Baud Rate - Used to define the current serial port transfer rate. You can enter any number; however, if the serial port does not support the specified speed an error is generated.
  • Flow Control - Used to define the current serial port flow control mode. You can select None, XON XOFF, RTS/CTS, or DTR/DSR.
  • Parity - Used to define the current serial port parity. You can select none, odd, even, mark, or space.
  • Data Bits - Used to define the current serial port data bits. You can select 8, 7, 6, or 5.
  • Stop Bits - Used to define the current serial port Stop Bits. You can select 1, or 2.
  • Termination Mode - Used to define the current serial port Termination Mode. You can select none or char. When you select char, you must specify the hex code of the termination char.
  • Termination Char - Used to define the current serial port termination char. This field is only used when Termination Mode is set to char. Enter the hex code of the termination char.

VISA Write

Allows basic Write operation to VISA sessions. To configure the VISA Write, Right Click on the step » Configure VISA Write.

  • VISA Resource Handle - Numeric data type used to define the current VISA session. This handle is created using the VISA Open Step.
  • Data - String data type that specifies the string to be sent to the VISA session. You can directly specify the string to send or use TestStand string variables in this field.

VISA Read

Allows basic Read operation to VISA sessions. To configure the VISA Read, Right Click on the step » Configure VISA Read.

  • VISA Resource Handle - Numeric data type used to define the current VISA session. This handle is created using the VISA Open Step.
  • Data - String data type used to store the data read from the VISA session.
  • Max Byte Count - Specifies the max number of bytes to read from the VISA Session.

VISA Close

Closes a VISA session. To configure the VIS Close step, Right Click on the step » Configure Close.

  • VISA Resource Handle - Numeric data type used to define the current VISA session. This handle is created using the VISA Open Step.

 

 

Hardware and Software Requirements

VISA Step Types for TestStand  - TS2019.zip

TestStand 2019 or Compatible (32-bit only)

 LabWindows™\CVI 2015 SP1 or compatible

 

VISA Step Types for TestStand  - TS2016.zip

TestStand 2016 or Compatible (32-bit only)

 LabWindows™\CVI 2013 SP2 or compatible

 

Steps to Implement or Execute Code

 

Installing the VISA Step Types

  1. Unzip the Files to <TestStand Public>/Components/StepTypes/VISA
  2. Copy the Install_NI_VISATypes.ini to <TestStand Public>/Components/TypePalettes
  3. When you launch the sequence editor or a user interface, TestStand identifies files with the Install_ prefix and takes one of the following actions
    • If TestStand locates a type palette file in the type palette list with the same name, but without the Install_ prefix, TestStand merges the types in the Install_ prefix version of the file with the types in the existing file and then deletes the Install_ prefix version.
    • If TestStand locates a type palette file with the same name, but without the Install_ prefix, that is not included in the type palette list because a user explicitly excluded it, TestStand does not change the contents of either file.
  4. Copy the VISA.ico to <TestStand Public>/Components/Icons

 

Using the VISA Step Types

After installing the step types, a new "VISA" folder will appear in the insertion palette. You can insert these step types in a sequence in the same way as other TestStand steps

 

 

 

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
wing98
Member
Member
on

Hi there, I am using this but unable to figure out what is VISA Resource Handle - Numeric data type used to store a handle to the current VISA session.

 

I am having a .lvproj file where I have many subVIs and one front panel. I can remote the hardware from the front panel and playing around with different functions of the hardware (it is an electronic load - Array 3720A). However, I would like to have this feature to be run in Teststand, is there any way to run the front panel and it will able to call subVIs? 

 

The reason I am using this VISA step because I am trying to run all subVIs at the setup and then the front panel VI at main in Teststand. However, it shows Run-Time Error with detail "VISA Write in 3721A_On.vi->3721A_On.vi.ProxyCaller
VISA: (Hex 0xBFFF000E) The given session or object reference is invalid." 

So when I add in VISA Open, Configure and Write, I stuck at VISA Open where the Handle was unable to detect, I thought that 0xBFFF000E is the current session, no? Btw, I have also tried many weird numbers or sessions that I got from NI MAX.

 

Just in case if you need to have the .lvproj file, you may download the file from the link below and convert the whole folder to lvproj. 
Array 372x Series LABVIEW GUI

http://www.array.sh/yqxzcnE.htm


Hope to get reply ASAP! 
Thank you!

do-178
Member
Member
on

It would be nide to recompile it to 64bit.

Compativility with Teststand 2022.

Contributors