Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006

Running a Vision Builder AI Inspection from TestStand

2 ratings | 4.50 out of 5
Print

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.

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:
  1. Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
  2. Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
  3. 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.

  4. Complete one of the following sets of steps:

    • If you are using TestStand 3.0, complete the following steps:
      1. Copy inspection.ico to <TestStand 3.0>\Components\User\Icons, where <TestStand 3.0> is the location where TestStand is installed.
      2. Copy NIVBAITestStandSteps.ini to <TestStand 3.0>\Cfg\TypePalettes.
      3. Windows XP—Copy NIVBAITestStandAPI.dll to <Windows>\System32.
        Windows 2000\NT—Copy NIVBAITestStandAPI.dll to <Winnt>\System32.
      4. Select Start»Run to open the Run dialog box
      5. Enter regsvr32 NIVBAITestStandAPI.dll in the Open control and click OK. A dialog box should appear that reads DLRegisterServer in NIVBAITestStandAPI.dll succeeded.
      6. Click OK to close the regsvr32 dialog box.

    • If you are using TestStand 3.1 or later, complete the following steps:
      1. 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.
      2. Copy NIVBAITestStandSteps.ini to <TestStand X.X>\Components\User\TypePalettes.
      3. Windows XP—Copy NIVBAITestStandAPI.dll to <Windows>\System32.
        Windows 2000\NT—Copy NIVBAITestStandAPI.dll to <Winnt>\System32.
      4. Select Start»Run to open the Run dialog box
      5. Enter regsvr32 NIVBAITestStandAPI.dll in the Open control and click OK. A dialog box should appear that reads DLRegisterServer in NIVBAITestStandAPI.dll succeeded.
      6. Click OK to close the regsvr32 dialog box.

  5. 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

Complete the following steps to add a Vision Builder AI Inspection step to a TestStand sequence file:
  1. Launch the TestStand Sequence File editor.
  2. Open a sequence file.
  3. 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.
  4. Enter a descriptive name for the step.

    Defining TestStand Variables

TestStand uses variables to store and share data between steps within a sequence file, between sequence files, and between TestStand and another application. If your application requires you to share data, you need to define a variable to store the data. Complete the following steps to define a TestStand variable:
  1. Click the Expression Browser button next to the control for which you want to define a variable.
  2. 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.
  3. Enter a descriptive name for the variable.
  4. Select the variable and click the Insert button to add the variable to your inspection sequence.
  5. Click OK to close the Expression Browser.

    Connecting to a Target

Before you can run a Vision Builder AI Inspection in TestStand, you must specify the location where you want to run the inspection. You can run an inspection from a local computer or from a remote target, such as the NI CVS-1450 Series compact vision system. Figure 1 shows the Edit Vision Builder AI Inspection Step dialog box, which is used to configure the Vision Builder AI Inspection step.

Figure 1. Edit Vision Builder AI Inspection Step Dialog Box.

Complete the following steps to connect to a Vision Builder AI target:
  1. Add a Vision Builder AI Inspection step to your TestStand sequence file.
  2. Rename the step with a descriptive name, such as Connect to Target.
  3. Right-click the step and select Edit Inspection to launch the Edit Vision Builder AI Inspection Step dialog box.
  4. Select Connect to Target from the Operation drop-down list.
  5. 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.
  6. 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.
The Target ActiveX Reference control allows you to store the object reference to the NIVBAITarget object so you can access the target directly. If you do not need the object reference for your application, leave the Target ActiveX Reference control blank.

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:
  1. Add a Vision Builder AI Inspection step to your TestStand sequence file.
  2. Rename the step with a descriptive name, such as Get Target Info.
  3. Right-click the step and select Edit Inspection.
  4. Select Get Target Information from the Operation drop-down list.
  5. 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.
  6. Click OK.

    Opening an Inspection

After you have defined the target where the inspection will run, you need to specify which inspection to run, and open the 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:
    1. Add a Vision Builder AI Inspection step to your sequence file.
    2. Rename the step with a descriptive name, such as Open Inspection.
    3. Right-click the step and select Edit Inspection.
    4. Select Open Inspection from the Operation drop-down list.
    5. 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:
    1. Add a Vision Builder AI Inspection step to your sequence file.
    2. Rename the step with a descriptive name, such as Open Inspection.
    3. Right-click the step and select Edit Inspection.
    4. Select Show Open Inspection Dialog from the Operation drop-down list.
The Inspection ActiveX Reference control allows you to store the object reference to the NIVBAIInspection object so you can access the inspection directly. If you do not need the object reference for your application, leave the Inspection ActiveX Reference blank.

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:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Get Inspection Info.
  3. Right-click the step and select Edit Inspection.
  4. Select Get Inspection Information from the Operation drop-down list.
  5. 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.
  6. Click OK.

    Running an Inspection

Once you have selected a target to run the inspection on and opened the inspection, you are ready to run the inspection. Complete the following steps to run an inspection:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Inspect.
  3. Right-click the step and select Edit Inspection.
  4. Select Inspect from the Operation drop-down list.
  5. 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.
Getting Inspection Statistics

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:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Get Statistics.
  3. Right-click the step and select Edit Inspection.
  4. Select Get Statistics from the Operation drop-down list.
  5. 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.
  6. Click OK.

    Returning Inspection Results

Every time a Vision Builder AI inspection is run in TestStand, the overall pass/fail result of the inspection is returned from the target. However, you can configure the Inspection step to also return the pass/fail results for individual steps in the inspection, measurements returned by steps in the inspection, and errors that occurred during the inspection. You can control the amount of information returned by the inspection by setting the Update Measurements on Refresh control of the Connect to Target operation and the Refresh Results control of the Inspect operation to either True or False. Table 1 lists the inspection information returned depending on the values specified for the Update Measurements on Refresh and Refresh Results controls.
Table 1 Options for Returning Information about an Inspection
Refresh Results = False
Refresh Results = True
Update Measurements on Refresh = FalseThe inspection returns:
  • Pass/fail value for the inspection
The inspection returns:
  • Pass/fail value for the inspection
  • Pass/fail value for each step in the inspection and the primary measurement associated with each step
  • Any errors that occurred during the inspection
Update Measurements on Refresh = TrueThe inspection returns:
  • Pass/fail value for the inspection
The inspection returns:
  • Pass/fail value for the inspection
  • Pass/fail value for each step in the inspection
  • All measurement values calculated by steps in the inspection
  • Any errors that occurred during the inspection

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:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Get Result.
  3. Right-click the step and select Edit Inspection.
  4. Select Get Result from the Operation drop-down list.
  5. 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.
  6. 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.
  7. Click OK.
Returning Inspection Images

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:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Get Image.
  3. Right-click the step and select Edit Inspection.
  4. Select Get Image from the Operation drop-down list.
  5. 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.
  6. Click OK.
Displaying Images in TestStand

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:
  1. Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
  2. Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
  3. Download Display_Images_Operator_Interface.zip, and extract the files.
To send images to the Operator Interface, you must use a TestStand Action step to send a User Message containing the image to the Operator Interface. Complete the following steps to insert an Action step and send an image to the Operator Interface:
  1. Right-click in the Sequence File window and select Insert Step»Action.
  2. Enter a descriptive name for the step, such as Display Image.
  3. Double-click the step to launch the Step Properties dialog box.
  4. Select ActiveX/COM from the Adapter drop-down list.
  5. Click the Specify Module button for launch the Edit ActiveX/COM Call dialog box.
  6. 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.
  7. Click OK to close the Edit ActiveX/COM Call dialog box.
  8. Click OK to close the Step Properties dialog box.

[+] Enlarge Image
Figure 2. Edit ActiveX/COM Call Dialog Box

Closing an Inspection

Once an inspection has run and you have retrieved the necessary inspection results, close the inspection using the Close Inspection operation. Complete the following steps to close an inspection:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Close Inspection.
  3. Right-click the step and select Edit Inspection.
  4. Select Close Inspection from the Operation drop-down list.
  5. Click OK.

    Disconnecting from a Target

After you have closed the inspection, the final step is to disconnect from the Vision Builder AI target. Complete the following steps to disconnect from a target and conclude the TestStand sequence:
  1. Add a Vision Builder AI Inspection step to your sequence file.
  2. Rename the step with a descriptive name, such as Disconnect.
  3. Right-click the step and select Edit Inspection.
  4. Select Disconnect from Target from the Operation drop-down list.
  5. Click OK.

    Example TestStand Sequence File

For your convenience, an example TestStand sequence file is available at ni.com/zone. The example includes all the steps described in this document. Complete the following steps to download and view the example sequence file:
  1. Navigate to ni.com/zone, and select Example Code from the menu on the left side of the screen.
  2. Enter Running a Vision Builder AI Inspection from TestStand in the Search control, and click the Go button.
  3. Download VBAI_Inspection_Example.seq.
  4. Open VBAI_Inspection_Example.seq in TestStand.
Figure 3 shows the VBAI_Inspection_Example.seq sequence file.


[+] Enlarge Image
Figure 3. TestStand Sequence File Using the Vision Builder AI Inspection Step
2 ratings | 4.50 out of 5
Print

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/).