Shared Variables to Transfer Data from Vision Builder for Automated Inspection to LabVIEW

Updated Sep 25, 2023

Environment

Software

  • LabVIEW Full
  • LabVIEW Base
  • Vision Builder for Automated Inspection

Operating System

  • Windows

I would like to transfer data from Vision Builder for Automation Inspection (VBAI) to LabVIEW using Shared Variables.
It this possible?

There are two methods to using shared variables to communicate between LabVIEW and VBAI, creating variables in LabVIEW and binding to them in VBAI or creating variable in VBAI and binding to them in LabVIEW.

Hosting the Shared Variables from VBAI

  1. Bring up the Variable Manager window by selecting Tools»Variable Manager... within the inspection configuration instance of VBAI.
 ​
  1. Navigate to the System Variables tab and select Add to create a new variable.
  2. In the Add System Variable window, give the new variable a unique name (ideally a name that represents what the data is), type, and initial value. In order to be able to share the information stored in this variable with LabVIEW, be sure to select Publish on Network.
  3. When you have finished configuring the variable, hit OK in the Add System Variable window. You should see your variable listed in the System Variables tab of your Variable Manager window. 
  4. When you have finished configuring your variables, select OK in the Variable Manager window
  5. Use the Set Variable step (under the Use Additional Tools palette) to set the data that is to be stored in the variable.

Note: For arrays of data, it is important to consider that Vision Builder for Automated Inspection only supports 1D Arrays in the Set Variable step.

For 2D Arrays you will have to create a variable for every column or row. For example, if you are exporting the data taken from a previous "Detect Objects" step, in the Set Variable step you can choose Set to Measurement operation to select which column of your array you want to export to the variable, as you can see in the following image:
 

 

  1. Create a variable in LabVIEW by right-clicking My Computer in your project and selecting New»Variable.
  2. Configure your variable by giving it a unique name, data type, and setting the Variable Type to Network-Published. Select Enable Aliasing and bind the variable to a PSP URL. Click Browse and select <Your System>»Vision Builder»<Your Variable>.
  3. Select OK in the Shared Variable Properties window.
  4. You can now use this shared variable in your LabVIEW program to extract the information that VBAI put into the variable with the Set Variable step.

Hosting the Shared Variables from LabVIEW

  1. Create a variable in LabVIEW from the Project Explorer window by right-clicking My Computer in your project and selecting New»Variable.
  2. Configure your variable by giving it a unique name, data type, and setting the Variable Type to Network-Published.
  3. Deploy the variable to make it accessible from VBAI by right-clicking on the library and selecting Deploy All.
  4. Bring up the variable manager window by selecting Tools»Variable Manager... (see picture above) within the inspection configuration instance of VBAI.
  5. Navigate to the Network Variables tab and select Add to create a new variable.
  6. Configure your variable by giving it a unique name and type. Click the Select Source Item box to the right of the Network Path box. Navigate to the system and library where the LabVIEW variable was created and select the variable to bind to.
  7. Select OK in the Add Network Variable window. You should see your variable listed in the Network Variables tab of your Variable Manager window.
  8. When you have finished configuring your variables, select OK in the Variable Manager window.
  9. Use the Set Variable step in your VBAI inspection to set the data that is to be stored in the variable.
  10. You can now use this shared variable in your LabVIEW program to extract the information that VBAI put into the variable with the Set Variable step.

Additional Information

For other options for Communicating outside of VBAI to other programs visit the Communicate tab in the Inspection Steps shown here:

Use the NI Vision Builder for Automation Inspection Tutorial to find examples of common inspections and how to set them up.