Using Switches in NI TestStand

Publish Date: Oct 21, 2014 | 8 Ratings | 3.25 out of 5 |  PDF

Overview

There are several ways to integrate switching into your TestStand sequences. This document discusses the different methods of controlling switches from NI TestStand, as well as some guidelines as to when to use each method.

Table of Contents

  1. Code Module
  2. IVI Switch Step Type
  3. Switch Executive - Step Switching Property
  4. Recommended Options in Order of Preference

1. Code Module

A code module is a program module such as a Microsoft Windows dynamic link library or LabVIEW VI that contains one or more functions that perform a specific test or other action.  You can create a code module in a variety of programming environments that contain switching operations, which in turn can be called from TestStand.  



Figure 1: Insert a new step from the Insertion Palette


Figure 2: Specify the code module to be executed from the Step Settings Module tab

Controlling NI Switches from Code Modules

You can create code modules to control National Instruments switch modules using either the NI-Switch or DAQmx Switch Application Programming Interfaces (API).  To learn about the differences between the two APIs, refer to:
KnowledgeBase 43CFNUAY: Differences Between the NI-SWITCH and NI-DAQmx Switch APIs for Switch Applications


Figure 3: DAQmx Switch API in LabVIEW

 


Figure 4: NI-Switch API in LabVIEW

Controlling Third Party Switches from Code Modules

If you are controlling third party switches, you can create code modules that contain calls to the instrument driver functions for your switch.  Refer to the Instrument Driver Network at www.ni.com/idnet for more information about instrument drivers and for finding and downloading instrument drivers compatible with National Instruments software.  

IVI and NI Switch Executive

If your switch module is IVI-compliant, you can create code modules that contain calls to the IVI Switch Class Driver.  All NI Switch modules are IVI-compliant.  Refer to www.ni.com/ivi for more information about IVI.

Note: You must use the instrument-specific driver to call driver functions the IVI Switch Class Driver does not support, when the instrument does not conform to an IVI class, or when no IVI driver exists for the instrument.  

In addition to using the IVI Switch Class Driver, if your switch hardware is IVI-compliant, it can be programmed using the NI Switch Executive API.  For more information regarding NI Switch Executive, refer to:
Developer Zone Tutorial: What Is NI Switch Executive?

Figure 5: Switch Executive API

Back to Top

2. IVI Switch Step Type

The IVI Switch step, shown at left, provides a high-level programming layer for instruments compliant with the IVI Switch class and NI Switch Executive virtual devices.  Insert an IVI Switch Step from the Insertion Palette.

Figure 6: Insert IVI Switch Step


Click the Edit Switch button on the Switch tab of the Step Properties dialog box.


Figure 7: Select the IVI Switch Step "Edit Switch..." button.  


The IVI Switch step type also has the following two different modes:

Ο IVI Switching
Ο Switch Executive

The mode you select determines the operations available when you use the IVI Switch step type.

IVI Switching Mode

The IVI Switching Mode allows the use of IVI-compliant switch drivers to control NI and third party switches.  You can use this mode connect and disconnect paths and routes, to determine the connectivity of two switches or the state of a route, and to query the state of the switch module or virtual device.  For more information regarding the IVI Switch operations supported by the IVI Switch Step Type: IVI Switching Mode, refer to:
NI TestStand 4.2 Help: Edit IVI Switch Step Dialog Box - IVI Switching Mode


Figure 8: IVI Switch Step: IVI Switching Mode

Switch Executive Mode 

NI Switch Executive is an intelligent switch management and routing application that sits on top of IVI.  Switch Executive allows you to create a pre-configured Switch Executive Virtual Device that can contain one or more IVI-compliant switch modules.  Additionally, you can create channel aliases and configure end-to-end routes graphically (even across multiple switches) in a point-and-click environment.  For more information regarding the features of NI Switch Executive, refer to:
Developer Zone Tutorial: What Is NI Switch Executive?

The purchase and installation of NI Switch Executive software allows you to use the Switch Executive Mode of the IVI Switch Step.  From the Edit IVI Switch Step dialog box, you can select a pre-configured NI Switch Executive Virtual Device to connect and disconnect routes/route groups made for your switching system.  Also, you can specify whether you want the route to exist until manually disconnected later or until the step, sequence, thread, or execution completes.
Note: For more information regarding the IVI Switch operations supported by the IVI Switch Step Type: Switch Executive Mode, refer to:
NI TestStand 4.2 Help: Edit IVI Switch Step Dialog Box - Switch Executive Mode


Figure 9: IVI Switch Step: Switch Executive Mode

Back to Top

3. Switch Executive - Step Switching Property

In addition to using the Switch Executive Mode of the IVI Switch Step, the purchase and installation of NI Switch Executive allows you to perform switching actions around the execution of a step.  You can configure the switching actions in the Switching panel on the Properties tab of the Step Settings pane.


Figure 10: Insert a step from the Insertion Palette.  Switching Panel on the Properties tab of the Step Settings.

 

Back to Top

4. Recommended Options in Order of Preference

As discussed in this document, there are several options available to control switches from TestStand.  The following section describes the advantages and disadvantages of each.  

1. Code Module

Writing test sequences which perform switch operations from code modules is the recommended method for controlling switches from TestStand.  This option is the most modular approach, as test developers can modify the code which performs the switch operations with minimal affect on the rest of the test sequence.  Using either the instrument-specific driver or the Switch Executive API in code modules give access to low-level IVI sessions as well as additional functionality that the other options do not expose.  Use NI Switch Executive to simplify and streamline the configuration and control of your IVI-compliant switches.

Note: The NI Switch Executive API requires the purchase and installation of NI Switch Executive software.

Using this method has the potential disadvantage of increased likelihood of user error.  Test developers must be familiar with the instrument driver or NI Switch Executive API and ensure that they implement proper test system architecture to create maintainable and expandable test sequences.  For example, niSE Connect and Disconnect should be used to decrease switching time and increase device lifetime in automated test systems.


Figure 11: Use niSE Connect and Disconnect to specify which routes/route groups to control from code modules  

2. Step Switching Property 

Installing NI Switch Executive gives test developers the ability to add switching functionality to any step within a TestStand sequence using the Step Switching Property.  A clear advantage of the Switching property is code reusability.  For example, imagine you have a particular test that requires multiple routes to be connected.  If you perform that test in several different test routines, you can simply create a step template and reuse that step in another sequence.  All of the properties that come with the step (including switching) get included in the step template.  In order to add a step to the Templates list, simply drag the step from the Steps Pane and drop into the Template list.  


Figure 12: The Templates list is part of the Insertion Palette Pane.  Drag and drop a step from the Steps Pane to the Templates list in order to reuse the step in another sequence.


For more information regarding the TestStand Templates list, refer to:
NI TestStand 4.2 Help: Insertion Palette Pane

A potential disadvantage to the Step Switching Property is decreased test sequence readability.  When using the Switching property, make sure to document your TestStand sequences.  When modifying step properties from the default behavior, TestStand will automatically document this change in the Steps Pane.  For example, if you Enable Switching for a LabVIEW Action step, TestStand will enter Switch into the Settings category for the step in the Steps Pane.


Figure 13: Enable Switching has been checked for this LabVIEW Action Step.  Notice that TestStand has automatically inserted Switch in the Settings category for the Action step in the Steps Pane.



You can also document your sequences by using the step Comment field and Label steps.

Figure 14: Enter comments into the Comment field in the General Panel of the Properties tab for the step settings.



Figure 15: Further document the step with a preceding Label step and comments (appear above the step name)

IVI Switch Step Type: Switch Executive Mode

The IVI Switch step in Switch Executive mode has very similar functionality to the Step Switching Property.  One advantage that the IVI Switch Step has over the Step Switching property is the ability to find routes and determine whether the virtual device is debounced using the Get Information operation.


Figure 16: Get Information operation of the IVI Switch Step: Switch Executive Mode


Test developers can specify the same step properties available to the other built-in step types (e.g. Preconditions, Looping, etc.).  

Note: You cannot use the Step Switching property with the IVI Switch Step type.

Additionally, the IVI Switch step has the advantage of being self documenting, as users can determine at a glance whether the test sequence involves switching.  However, the Step Switching property is generally preferred over the IVI Switch Step.  Use the documentation practices discussed in the previous section to create readable test sequences when using the Step Switching property.

The main disadvantage of the Switch Executive options in TestStand (Step Switching Property and IVI Switch Step) is that you do not have full access to the Switch Executive API (such as the ability to programmatically import/export Switch Executive configurations and generate XML reports).  In order to develop test sequences with maximum customizability and expandability, use code modules which call the NI Switch Executive API.

IVI Switch Step Type: IVI Switching Mode

The IVI Switch step in IVI Switching mode gives access to the basic operations supported by the IVI Switch Class driver.  For more information regarding the functionality available through the IVI Switch step in IVI Switching mode, refer to:

NI TestStand 4.2 Help: Edit IVI Switch Step Dialog Box - IVI Switching Mode

The IVI Switching mode for the IVI Switch Step has its disadvantages.  If your application employs multiple switches, you must use a unique step for every switch module.  Therefore you cannot use this method to create complete routes across multiple switches.  Also, creating a desired switching configuration requires the use of multiple steps.  In general, controlling switches from code modules or the Switch Executive options is preferred over using the IVI Switch Step: IVI Switching mode. 

Note: The instrument handles that TestStand IVI step types create cannot be used within code modules that execute using their respective development environment. The underlying C-based handle can only be used within the TestStand process. If your test sequence includes code modules which invoke IVI class and driver-specific VIs or functions, National Instruments does not recommend using the TestStand IVI step types at the same time.

Additional Resources

Developer Zone Tutorial: What Is NI Switch Executive?
NI Switch Executive Getting Started Guide
Accelerating Development and Simplifying Maintenance with NI Switch Executive
NI TestStand - Getting Started Videos
NI TestStand Reference Manual

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit