Running a Vision Builder AI Inspection from TestStand
Overview
Since Vision Builder for Automated Inspection (Vision Builder AI) 2.6, you can connect to remote targets, run inspections, retrieve inspection results, and view inspection images from ActiveX-enabled environments. While TestStand can natively use ActiveX interfaces, the Vision Builder AI Inspection step greatly eases development. This document describes how to use the TestStand Vision Builder AI Inspection step to connect to a target, open a Vision Builder AI inspection, run the inspection, and retrieve the inspection results.
Table of Contents
- Downloading and Installing the Vision Builder AI Inspection Step
- Adding a Vision Builder AI Inspection Step to a TestStand Sequence
- Defining TestStand Variables
- Connecting to a Target
- Opening an Inspection
- Running an Inspection
- Returning Inspection Results
- Closing an Inspection
- Disconnecting from a Target
- Example TestStand Sequence File
Downloading and Installing the Vision Builder AI Inspection Step
Before you begin running Vision Builder AI Inspections from TestStand, you must first add the Vision Builder AI Inspection step to TestStand. Complete the following steps to download and install the necessary files:
- Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
- Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
- Download VBAI_Inspection_Step.zip, and extract the files.
Note: If you want to customize the Vision Builder AI Inspection step, download and modify the source files provided in VBAI_Inspection_Step.zip, and extract the files.
- Complete one of the following sets of steps:
- If you are using TestStand 3.0, complete the following steps:
- Copy inspection.ico to <TestStand 3.0>\Components\User\Icons, where <TestStand 3.0> is the location where TestStand is installed.
- Copy NIVBAITestStandSteps.ini to <TestStand 3.0>\Cfg\TypePalettes.
- Windows XP—Copy NIVBAITestStandAPI.dll to <Windows>\System32.
Windows 2000\NT—Copy NIVBAITestStandAPI.dll to <Winnt>\System32. - Select Start»Run to open the Run dialog box
- Enter regsvr32 NIVBAITestStandAPI.dll in the Open control and click OK. A dialog box should appear that reads DLRegisterServer in NIVBAITestStandAPI.dll succeeded.
- Click OK to close the regsvr32 dialog box.
- If you are using TestStand 3.1 or later, complete the following steps:
- Copy inspection.ico to <TestStand X.X>\Components\User\Icons, where <TestStand X.X> is the location where TestStand is installed and X.X is the version of TestStand you are using.
- Copy NIVBAITestStandSteps.ini to <TestStand X.X>\Components\User\TypePalettes.
- Windows XP—Copy NIVBAITestStandAPI.dll to <Windows>\System32.
Windows 2000\NT—Copy NIVBAITestStandAPI.dll to <Winnt>\System32. - Select Start»Run to open the Run dialog box
- Enter regsvr32 NIVBAITestStandAPI.dll in the Open control and click OK. A dialog box should appear that reads DLRegisterServer in NIVBAITestStandAPI.dll succeeded.
- Click OK to close the regsvr32 dialog box.
- If you are using TestStand 3.0, complete the following steps:
- If TestStand is already running, you must close and relaunch TestStand before the Vision Builder AI Inspection step will appear in TestStand.
Adding a Vision Builder AI Inspection Step to a TestStand Sequence
- Launch the TestStand Sequence File editor.
- Open a sequence file.
- Right-click in the Sequence File window and select Insert Step»NI Vision Builder AI»Inspection to add an Inspection step to the sequence file.
- Enter a descriptive name for the step.
Defining TestStand Variables
- Click the
Expression Browser button next to the control for which you want to define a variable.
- In the Expression Browser, right-click the category of variable you want to add, and insert the correct variable type for the data you want to store.
- Enter a descriptive name for the variable.
- Select the variable and click the Insert button to add the variable to your inspection sequence.
- Click OK to close the Expression Browser.
Connecting to a Target

Figure 1. Edit Vision Builder AI Inspection Step Dialog Box.
Complete the following steps to connect to a Vision Builder AI target:
- Add a Vision Builder AI Inspection step to your TestStand sequence file.
- Rename the step with a descriptive name, such as Connect to Target.
- Right-click the step and select Edit Inspection to launch the Edit Vision Builder AI Inspection Step dialog box.
- Select Connect to Target from the Operation drop-down list.
- Enter the IP address of the target to which you want to connect. Enter 127.0.0.1 to connect to an inspection on a local machine.
- If you want to return the measurements associated with each step in the Vision Builder AI inspection, enter True in the Update Measurements on Refresh control. Otherwise, enter False. Refer to the Returning Inspection Results section of this document for more information about returning inspection results.
Retrieving Target Information
Once you have established a connection to a target, the Vision Builder AI Inspection step allows you to retrieve information about the target such as the IP address, status, date, time, and target type. The target information is displayed in the TestStand sequence report. Complete the following steps to retrieve information about a target:
- Add a Vision Builder AI Inspection step to your TestStand sequence file.
- Rename the step with a descriptive name, such as Get Target Info.
- Right-click the step and select Edit Inspection.
- Select Get Target Information from the Operation drop-down list.
- If you want to access the target information in other TestStand steps, define a variable of type NIVBAITarget for the Target control. Refer to the Defining TestStand Variables section of this document for more information about defining a variable.
- Click OK.
Opening an Inspection
- If you know the name of the inspection you want to run and you want to run the same inspection every time the TestStand sequence is run, complete the following steps:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Open Inspection.
- Right-click the step and select Edit Inspection.
- Select Open Inspection from the Operation drop-down list.
- Enter the name, in quotes, or the index number of the inspection you want to run in the Name or Index control.
- If you want to choose which inspection is run each time you run the TestStand sequence, complete the following steps:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Open Inspection.
- Right-click the step and select Edit Inspection.
- Select Show Open Inspection Dialog from the Operation drop-down list.
Retrieving Inspection Information
The Vision Builder AI Inspection step allows you to retrieve information about an inspection once it is opened. You can retrieve the inspection name, a description of the inspection, the date the inspection was created, the date the inspection was last modified, a list of all the steps in the inspection, and the limits associated with each step. The inspection information is displayed in the TestStand sequence report. Complete the following steps to retrieve information about an inspection:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Get Inspection Info.
- Right-click the step and select Edit Inspection.
- Select Get Inspection Information from the Operation drop-down list.
- If you want to access the inspection information in other TestStand steps, define a variable of type NIVBAIInspection for the Inspection control. Refer to the Defining TestStand Variables section for more information about defining a variable.
- Click OK.
Running an Inspection
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Inspect.
- Right-click the step and select Edit Inspection.
- Select Inspect from the Operation drop-down list.
- Choose one of the following options for returning the results of the inspection:
- If you want to return the results of individual steps in the inspection as well as the overall result of the inspection, enter True in the Refresh Results control.
- If you only want to return the overall result of the inspection, enter False in the Refresh Results control.
Refer to the Returning Inspection Results section for more information about options for returning inspection results.
If an inspection has been run more than once, the Vision Builder AI Inspection step allows you to retrieve overall statistics about multiple inspections in addition to the results of individual inspections. The statistics you can retrieve include the number of inspections that have passed/failed since the last reset, the percentage of the total that passed/failed, the total time spent processing the inspection, the total idle time, and the percentage of the total time spent either processing or idle. Inspection statistics are displayed in the TestStand sequence report. Complete the following steps to retrieve inspection statistics:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Get Statistics.
- Right-click the step and select Edit Inspection.
- Select Get Statistics from the Operation drop-down list.
- If you want to access the inspection statistics in other TestStand steps, define a variable of type NIVBAIStatistics for the Statistics control. Refer to the Defining TestStand Variables section for more information about defining a variable.
- Click OK.
Returning Inspection Results
Refresh Results = False | Refresh Results = True | |
| Update Measurements on Refresh = False | The inspection returns:
| The inspection returns:
|
| Update Measurements on Refresh = True | The inspection returns:
| The inspection returns:
|
If the value of the Refresh Results control is True, you can use the Get Result operation the access the step information returned by the inspection. The results of an inspection are also displayed in the TestStand sequence report. Complete the following steps to configure the Get Result operation and retrieve your results:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Get Result.
- Right-click the step and select Edit Inspection.
- Select Get Result from the Operation drop-down list.
- Enter the name, in quotes, or index number of the step you want to retrieve information about in the Name or Index control. The index number refers to the location of the step in your inspection script. For example, if you want to return information about the third step in your inspection script, enter 3 in the Name or Index control.
- If you want to access the inspection results in other TestStand steps, define a variable of type NIVBAIStepResult for the Result control. Refer to the Defining TestStand Variables section for more information about defining a variable.
- Click OK.
In addition to returning the results of an inspection, you can also return the inspection image as an object reference. Complete the following steps to return the inspection image:
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Get Image.
- Right-click the step and select Edit Inspection.
- Select Get Image from the Operation drop-down list.
- In the Image ActiveX Reference control, define an object reference variable for the image. Refer to the Defining TestStand Variables section for more information about defining a variable.
- Click OK.
Currently, TestStand does not natively support displaying images. To display inspection images, you must create an Operator Interface that uses the CWIMAQViewer ActiveX control. The CWIMAQViewer control is included with Vision Builder AI. Example code for developing an Operator Interface using Microsoft Visual Basic 6.0 is available at ni.com/zone. Complete the following steps to download the example Operator Interface:
- Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
- Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
- Download Display_Images_Operator_Interface.zip, and extract the files.
- Right-click in the Sequence File window and select Insert Step»Action.
- Enter a descriptive name for the step, such as Display Image.
- Double-click the step to launch the Step Properties dialog box.
- Select ActiveX/COM from the Adapter drop-down list.
- Click the Specify Module button for launch the Edit ActiveX/COM Call dialog box.
- Edit the controls in the Edit ActiveX/COM Call dialog box to match the values shown in Figure 2. The value for activeXdataParam is the name of the object reference for the image returned by an inspection. Refer to Returning Inspection Images for information about returning an inspection image.
- Click OK to close the Edit ActiveX/COM Call dialog box.
- Click OK to close the Step Properties dialog box.
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Close Inspection.
- Right-click the step and select Edit Inspection.
- Select Close Inspection from the Operation drop-down list.
- Click OK.
Disconnecting from a Target
- Add a Vision Builder AI Inspection step to your sequence file.
- Rename the step with a descriptive name, such as Disconnect.
- Right-click the step and select Edit Inspection.
- Select Disconnect from Target from the Operation drop-down list.
- Click OK.
Example TestStand Sequence File
- Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
- Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
- Download VBAI_Inspection_Example.seq.
- Open VBAI_Inspection_Example.seq in TestStand.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).


