This program programmatically changes the limits of steps in Vision Builder for Automated Inspection during the inpection. To do so, this program uses access to Modbus through VBAI as well as LabVIEW.
There are two major pieces to this example; the VBAI inspection which accesses the Modbus, and the LabVIEW Modbus library. In order to run this program you need to:
The VBAI inspection, Dynamic Tolerances.vbai, contains several steps, most of which are just inspection steps. The steps vital to dynamically changing the inspections limits are the two Modbus steps, Read Tolerances and Write Data. If you double click on the Read Tolerances step it will open its configuration. Notice that it is reading two registers, 0x0 and 0x1 to get the intensity limit data that LabVIEW has placed in those locations. Click Cancel to close the configuration. Now double click on the Compute Status step. This step takes the two values read from the Modbus, and compares the intensity reading from the Check Cap Presence step to the limits. If it is above the minimum and below the maximum it passes, otherwise it fails. If you double click on the Write Data step it will open its configuration. Notice that it is writing two pieces of data to the Modbus, the current intensity reading from the Check Cap Presence step, and the success or failure of the Compute Status step. These are then read by the LabVIEW VI.
The Modbus Library, NI Modbus.llb controls all of LabVIEW's interactions with the Modbus. The main VI we are using, MB Set VBAI Limits.vi, indicates all communication with the Modbus. First, it connects to the TCP Modbus at the listed IP. This is defaulted to your own computer, but it can be edited for remote computers. Also, the communication can be changed to serial if need be in both LabVIEW and the VBAI inspection. For more information on Modbus over serial, see these two tutorials concerning Modbus on touchscreens with LabVIEW and VBAI.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.