Calling LabVIEW VIs
- Updated2025-03-28
- 12 minute(s) read
Calling LabVIEW VIs
Use the LabVIEW Adapter to call VIs from TestStand, to create new LabVIEW projects and VIs to call from TestStand, to edit and debug existing VIs, and to use LabVIEW data types in TestStand.
Required LabVIEW Settings
All of the tutorials on this page require you to have the LabVIEW development system and TestStand installed on the same computer. In addition, you must configure the LabVIEW Adapter to run VIs using the LabVIEW development system.
Confirm the following settings in LabVIEW:
- To edit or run a VI from TestStand, you must include the VI in the VI Server: Exported VIs list in LabVIEW. By default, LabVIEW allows access to all VIs. Select Tools»Options to launch the Options dialog box. Select the VI Server category and browse to the Exported VIs section.
- Confirm that "*" is included in the VI Server: Exported VIs list and that the Allow Access option is enabled.
Creating and Configuring Steps with the LabVIEW Adapter
You can create steps that call stand-alone VIs, call VIs in the context of a LabVIEW project, and call LabVIEW class member VIs.
Calling a Stand-alone VI
Complete the following steps to insert a new LabVIEW step and configure the step to call a stand-alone VI.
- Select File»New»Sequence File to open a new sequence file.
- Save the sequence file as Call LabVIEW VI.seq in the <TestStand Public>\Tutorial directory.
- Select the LabVIEW adapter from the Adapter ring control above the Step Types list.
- Insert a Pass/Fail Test step in the Main step group and rename the new step LabVIEW Pass/Fail Test.
- On the LabVIEW Module tab of the Step Settings pane, click the Browse for VI button located to the right of the VI Path control, navigate to <TestStand Public>\Tutorial\LabVIEW Pass-Fail Test.vi, and click Open. TestStand reads the description and connector pane information from the VI and updates the LabVIEW Module tab so you can configure the data to pass to and from the VI.
- In the VI Parameter Table, enter the values shown in Table 11-1. When TestStand calls the VI, it places the value the VI returns in the PASS/FAIL Flag and Report Text indicators into the Result.PassFail and Result.ReportText properties of the step, respectively. Notice that TestStand automatically fills in the Value column of the error out output parameter with the Step.Result.Error property. By default, when a VI uses the standard LabVIEW error out cluster as an output parameter, TestStand automatically passes that value into the Step.Result.Error property for the step. You can also update the value manually. If an error occurs during execution of the VI and the error out cluster is passed to Step.Result.Error, TestStand launches the Run-Time Error dialog box by default.
Parameter Name Value PASS/FAIL Flag Step.Result.PassFail Report Text Step.Result.ReportText - Save the changes. Leave the sequence file open for the next tutorial.
Calling a VI in the Context of a LabVIEW Project
Complete the following steps to insert a new LabVIEW step and configure the step to call a VI in the context of a LabVIEW project.
- Insert another Pass/Fail Test step in the Main step group and rename the new step LabVIEW Project Pass/Fail Test.
- On the LabVIEW Module tab, click the Browse for LabVIEW Project button located to the right of the Project Path control, navigate to <TestStand Public>\Tutorial\Test Project.lvproj, and click Open. Notice that some of the TestStand button icons and tool tips change to indicate support for LabVIEW projects.
- Click the Browse for VI in LabVIEW Project button, located to the right of the VI Path control, to launch the Select VI from LabVIEW Project dialog box.
- Select LabVIEW ProjectPass-Fail Test.vi and click OK. Notice that the path defined in the project is selected as the VI path.
- In the VI Parameter Table, enter the values shown in Table 11-2.
Parameter Name Value PASS/FAIL Flag Step.Result.PassFail Report Text Step.Result.ReportText - Save the changes. Leave the sequence file open for the next tutorial.
Calling LabVIEW Class Member VIs
Complete the following steps to insert two new LabVIEW steps, configure the first step to call a static member VI from a LabVIEW class to create a LabVIEW class object, and configure the second step to call a dynamically dispatched member method VI on the created object.
Calling a Static Member VI from a LabVIEW Class
Complete the following steps to insert a new LabVIEW step and configure the step to call a static member VI from a LabVIEW class in order to create a LabVIEW class object.
- Insert an Action step in the Main step group and rename the new step Create LabVIEW Class Object.
- On the LabVIEW Module tab, select Class Member Call from the Call Type ring control. Notice that some of the TestStand button icons and tool tips change to indicate support for LabVIEW class member calls.
- Click the Browse for LabVIEW Project button, navigate to <TestStand Public>\Tutorial\Test Project.lvproj, and click Open.
- Click the Browse for LabVIEW Class in LabVIEW Project button, located to the right of the Class Path control, to launch the Select a Class from LabVIEW Project dialog box.
- Select LabVIEW Child Class.lvclass and click OK.
- Select LabVIEW Child Static Factory Member.vi from the Member Name ring control.
- In the VI Parameter Table, enter Locals.myChildObject in the Value column of the LabVIEW Child Class out output parameter. The myChildObject local variable name appears in red text because it does not exist yet. You create this variable in the next step.
- Right-click the Locals.myChildObject value and select Create Locals.myChildObject»Object Reference from the context menu to create Locals.myChildObject as an object reference local variable, which appears on the Variables pane.
- Save the changes. Leave the sequence file open for the next tutorial.
Calling a Dynamically Dispatched Member Method VI
Complete the following steps to insert a new LabVIEW step and configure the step to call a dynamically dispatched member method VI on the LabVIEW class object that the Create LabVIEW Class Object step creates.
- Insert another Pass/Fail Test step in the Main step group and rename the new step LabVIEW Class Member Pass/Fail Test.
- On the LabVIEW Module tab, select Class Member Call from the Call Type ring control.
- Click the Browse for LabVIEW Project button, navigate to <TestStand Public>\Tutorial\Test Project.lvproj, and click Open.
- Click the Browse for LabVIEW Class in LabVIEW Project button to launch the Select a Class from LabVIEW Project dialog box.
- Select LabVIEW Parent Class.lvclass and click OK.
- Select LabVIEW Dynamic Pass-Fail Test Member.vi from the Member Name ring control.
- In the VI Parameter table, enter the values shown in Table 11-3.
Parameter Name Value LabVIEW Parent Class in Locals.myChildObject LabVIEW Parent Class out Locals.myChildObject PASS/FAIL Flag Step.Result.PassFail Report Text Step.Result.ReportText - Save the changes. Leave the sequence file open for the next tutorial.
Executing the Sequence
Complete the following steps to execute the sequence of steps.
- Select Execute»Single Pass. When the execution completes, the report indicates the steps passed.
- Close the Execution window. Leave the sequence file open for the next tutorial.
Creating and Editing VIs
You can use the LabVIEW Adapter to create a new VI from TestStand, create a new LabVIEW project and add a new VI to the project from TestStand, and edit an existing VI from TestStand.
Creating a New VI from TestStand
Complete the following steps to create a new VI from TestStand.
- Select File»Save <filename> As and save the sequence file as Call LabVIEW VI 2.seq in the <TestStand Public>\Tutorial directory.
- Insert a Numeric Limit Test step after the LabVIEW Class Member Pass/Fail Test step and rename the new step LabVIEW Numeric Limit Test.
- On the LabVIEW Module tab, complete the following steps to configure the LabVIEW Numeric Limit Test step.
- Click the Create VI button, located to the right of the VI Path control, to create a new VI.
- In the File dialog box, browse to the <TestStand Public>\Tutorial directory, enter LabVIEW Numeric Limit Test.vi in the File Name control, and click OK. TestStand creates a new VI based on the available code templates for the TestStand Numeric Limit Test and opens the VI in LabVIEW. Note The TestStand Numeric Limit Test step type requires code modules to store a measurement value in the Step.Result.Numeric property, and the step type performs a comparison operation to determine whether the step passes or fails. Code modules can pass step properties as parameters to and from the code module or use the TestStand API in the code module to update step properties. When you use a default code template from NI to create a code module, TestStand creates the parameters needed to access the step properties for you.
- In LabVIEW, select Window»Show Block Diagram to open the block diagram.
- Right-click the Numeric Measurement indicator terminal, select Create»Constant from the context menu, and enter 10.0.
- Save and close the VI.
- In TestStand, click the LabVIEW Module tab. Notice that TestStand automatically updates the output parameters for the VI based on the information stored in the code template for the Numeric Limit Test step type.
- Save the changes and select Execute»Single Pass. When the execution completes, the report indicates the step passed with a numeric measurement of 10.
- Close the Execution window. Leave the sequence file open for the next tutorial.
Creating a New LabVIEW Project and Adding a New VI to the Project from TestStand
Complete the following steps to create a new LabVIEW project and add a new VI to that project from TestStand.
- Insert another Numeric Limit Test step after the LabVIEW Numeric Limit Test step and rename the new step LabVIEW Project Numeric Limit Test.
- On the LabVIEW Module tab, complete the following steps to configure the LabVIEW Project Numeric Limit Test step.
- Click the Create LabVIEW Project button, located to the right of the Project Path control, to create a new LabVIEW Project.
- In the File dialog box, browse to the <TestStand Public>\Tutorial directory, enter LabVIEW Project Test.lvproj in the File Name control, and click OK. TestStand creates a new LabVIEW Project and opens the project in LabVIEW.
- In TestStand, click the Add or Remove VIs from LabVIEW Project button, located to the right of the VI Path control, to launch the Add or Remove Items from LabVIEW Project dialog box.
- Right-click the My Computer item in the LabVIEW Project control and select New VI from the context menu to launch the Select the LabVIEW VI to Create dialog box.
- In the Select LabVIEW VI to Create dialog box, browse to the <TestStand Public>\Tutorial directory, enter LabVIEW Project Numeric Limit Test.vi in the File Name control, and click OK. TestStand creates a new VI based on the available code templates for the TestStand Numeric Limit Test step type and adds the VI to the LabVIEW project.
- Right-click the new VI under the My Computer item and select Edit VI from the context menu. TestStand opens the VI in LabVIEW within the project context, which LabVIEW displays in the bottom left corner of the front panel.
- In LabVIEW, open the block diagram for the VI.
- Right-click the Numeric Measurement indicator terminal, select Create»Constant from the context menu, and enter 10.0.
- Save and close the VI.
- In TestStand, select LabVIEW Project Numeric Limit Test.vi in the Add or Remove Items from the LabVIEW Project dialog box, and click Select to close the Add or Remove Items from LabVIEW Project dialog box. On the LabVIEW Module tab, notice that TestStand automatically updates the output parameters for the VI based on the information stored in the code template for the Numeric Limit step type.
- Save the changes and select Execute»Single Pass. When the execution completes, the report indicates the steps passed with a numeric measurement of 10.0.
- Close the Execution window. Leave the sequence file open for the next tutorial.
Editing Existing VIs from TestStand
Complete the following steps to edit existing VIs from TestStand.
- Select the LabVIEW Pass/Fail Test step and use the LabVIEW Module tab to complete the following steps.
- Click the Edit VI button, located to the right of the VI Path control. LabVIEW becomes the active application in which the LabVIEW Pass-Fail Test VI is open.
- Open the block diagram for the VI and change the PASS/FAIL Flag Boolean constant to False.
- Save and close the VI.
- In TestStand, select the LabVIEW Project Pass/Fail Test step and use the LabVIEW Module tab to complete the following steps.
- Click the Edit VI button. LabVIEW becomes the active application and the LabVIEW Project Pass-Fail Test VI is open within the LabVIEW project context.
- Open the block diagram for the VI and change the PASS/FAIL Flag Boolean constant to False.
- Save and close the VI.
- In TestStand, save the changes and select Execute»Single Pass. When the execution completes, the report indicates the LabVIEW Pass/Fail Test and LabVIEW Project Pass/Fail Test steps failed.
- Close the Execution window. Leave the sequence file open for the next tutorial.
Debugging VIs
Complete the following steps to debug VIs you call from TestStand using the LabVIEW Adapter.
- Place a breakpoint at the LabVIEW Pass/Fail Test step.
- Select Execute»Run MainSequence. The execution pauses at the LabVIEW Pass/Fail Test step.
- Complete the following steps to debug the LabVIEW Pass-Fail Test VI the LabVIEW Pass/Fail Test step calls.
- Click the Step Into button at the top of the Execution window. LabVIEW becomes the active application, in which the LabVIEW Pass-Fail Test VI is open and in a suspended state.
- Open the block diagram of the suspended VI.
- Click the Step Into or Step Over button on the LabVIEW toolbar to begin stepping through the VI. You can click the Finish VI button at any time to finish stepping through the VI.
- When you finish stepping through the VI, click the Return to Caller button on the LabVIEW toolbar to return to TestStand. The execution pauses at the next step in the sequence.
- Click the Resume button on the Debug toolbar in TestStand to complete the execution.
- Close the Execution window.
- Remove the breakpoint from the LabVIEW Pass/Fail Test step. Leave the sequence file open for the next tutorial.
Creating TestStand Data Types from
LabVIEW Clusters
TestStand provides number, string, Boolean, and object reference built-in data types. TestStand also provides several standard named data types, including Path, Error, LabVIEWAnalogWaveform, and others. You can create container data types to hold any number of other data types. TestStand container data types are analogous to LabVIEW clusters.
Complete the following steps to create a TestStand data type that matches a LabVIEW cluster.
- Select File»Save <filename> As and save the sequence file as Call LabVIEW VI 3.seq in the <TestStand Public>\Tutorial directory.
- Insert a Pass/Fail Test step in the Main step group after the LabVIEW Project Numeric Limit Test step and rename the new step Pass Container to VI.
- On the LabVIEW Module tab, click the Browse for VI button, navigate to <TestStand Public>\Tutorial\VI with Cluster Input.vi, and click Open.
- Click the Create/Update Custom Data Type button, located in the Type column of the Input Cluster parameter in the VI Parameter Table, to launch the Create/Update Custom Data Type From Cluster dialog box. TestStand maps the cluster elements to subproperties in a container called Input_Cluster, which is a new TestStand custom data type. You can rename the data type and subproperties as necessary and specify where TestStand stores the new data type.
- In the Create/Update Custom Data Type From Cluster dialog box, change the type name to InputData and click the Create button to accept the automatically assigned values and to create the data type in the current sequence file.
- On the LabVIEW Module tab, remove the checkmark from the Default column for the
Input Cluster input parameter, click the
Expression Browse button in the Value column to
launch the Expression Browser dialog box, and complete the following steps.
- On the Variables/Properties tab, right-click the Locals item and select Insert Types»InputData to create a local variable of the InputData data type. Rename the local variable ContainerData.
- Right-click the Number subproperty of ContainerData and select Properties from the context menu to launch the Number Properties dialog box.
- Enter 23 in the Value control and click OK.
- Right-click the String subproperty of ContainerData and select Properties from the context menu to launch the String Properties dialog box.
- Enter My String Data in the Value control and click OK.
- Enter Locals.ContainerData in the Expression control on the Variables/Properties tab and click OK. The Value column for the Input Cluster parameter now contains Locals.ContainerData.
- Enter Step.Result.ReportText in the Value column for the Report Text output parameter. When TestStand calls the VI, it passes the values in the ContainerData local variable to the Input Cluster control on the VI and returns the Number and String elements of the Input Cluster parameter to the ReportText property of the step.
- Save the changes and select Execute»Single Pass. When the execution completes, the report shows the text the VI with Cluster Input VI returns.
- Close all the windows in the sequence editor.
In This Section
- Required LabVIEW Settings
- Creating and Configuring Steps with the LabVIEW Adapter
- Calling a Stand-alone VI
- Calling a VI in the Context of a LabVIEW Project
- Calling LabVIEW Class Member VIs
- Calling a Static Member VI from a LabVIEW Class
- Calling a Dynamically Dispatched Member Method VI
- Executing the Sequence
- Creating and Editing VIs
- Creating a New VI from TestStand
- Creating a New LabVIEW Project and Adding a New VI to the Project from TestStand
- Editing Existing VIs from TestStand
- Debugging VIs
- Creating TestStand Data Types from
LabVIEW Clusters