Using a LabVIEW VI as the Inspection Interface
The templates provided with Vision Builder AI for customizing your inspection may not have the exact appearance or functionality you need. Vision Builder AI 3.5 allows you to use the front panel of a LabVIEW VI as your user interface for ultimate flexibility in designing your custom interface. Follow the steps below to display more information on the custom interface by selecting a LabVIEW VI.
Close any inspections that are open. In the Welcome window of Vision Builder AI, click Configure Inspection to load a blank Vision Builder AI inspection.
- Select File»Open from the Vision Builder AI toolbar.
- Browse to <Vision Builder AI 3.5>\Examples\Tutorial 4 - Two Cameras Inspection.vbai.
- Click OK to open the inspection.
- Click Tools»Inspection Interface Configuration to launch the Configure Inspection Interface dialog box.
- On the Inspection Interface tab, select the Create New Custom Inspection Interface from: option.
- Select LabVIEW VI.
- Click the Browse button. The Select a VI dialog box opens.
- Navigate to the location where you saved the two_images_with_data.vi that is included at the end of this tutorial.
- Select the two_images_with_data.vi, and click Select.
NOTE: Vision Builder AI cannot import VIs that have dependencies, such as sub VIs, DLL calls, or control type definitions.
This user interface consists of two image display indicators, a Chart, a Boolean and two controls and indicators.
- Click OK to close the Configure Inspection Interface dialog box.
- In the State Configuration Window, click the Set Inspection Status step. This ensures that the next step we add will be placed immediately after this step.
- In the Inspection Steps Palette, click the Use Additional Tools tab.
- Click the Update Inspection UI step. The property page for the step opens.
Notice that several items appear in the Inspection Interface Indicators table. These are the indicators from the VI front panel.
- Select each indicator in the table and set the value for the indicator using the Set to Measurement radio button so that the Inspection Interface Indicators table in your inspection matches the table shown in Figure 3.
Figure 3. Updating Indicators on the LabVIEW VI with Measurement Results
In order for the chart on the LabVIEW front panel to update properly, the code in the block diagram must be run. To run the block diagram code, enable the Run the VI after updating indicators checkbox.
- Click OK to close the property page.
- Save the Inspection, switch to the Inspection Interface, and click the Start Inspection button.
Notice that the controls update with the corresponding values. The Inspection interface should resemble the Inspection interface shown in Figure 4.
Figure 4. The Custom UI is Updated with Data from the Inspection
- Stop the Inspection and return to the Configuration Interface.
In the current Inspection interface, notice that there are two controls— Upper Limit and Lower Limit. You can use these controls as inputs to the Vision Builder AI inspection. Complete the following instructions to edit the inspection so that the inspection passes only when the Width is below the Upper Limit and above the Lower Limit.
- If Vision Builder AI is not in the Configuration interface, switch to the Configuration interface.
- In the State Configuration window, double-click the Compute Plank Width step. The property page for the step opens. The calculator diagram should resemble the diagram shown in Figure 5.
Figure 5. Calculator Diagram of Compute Plank Width Step
- Click the Edit Inputs/Outputs button. The Edit Inputs/Outputs dialog box opens.
- In the Input Measurements tree control, select User Interface Control»Lower Limit and User Interface Control»Upper Limit, and click OK.
- On the calculator diagram, you should now see two new controls for the lower and upper limits.
- Delete the constants 39.5 and 40.5 and wire the controls as shown in Figure 6. Now, instead of using constants, the step uses the values of the Lower Limit and Upper Limit controls to determine the Step Result.
Figure 6. Edit the Calculator Diagram to use the User Interface Controls
- Click OK to save the changes to the Compute Plank Width step and return to the Main window.
- Save the inspection, switch to the Inspection Interface, and start the inspection.
- Now, you can change the values of the Upper Limit and Lower Limit controls and watch Vision Builder AI pass or fail the inspection based on the control values.
Figure 7. Editing Control Values to Change the Outcome of the Inspection
- Stop the inspection.
Block diagram of the User Interface VI
While there is no need for any code on the block diagram of the VI that you use as the Inspection interface, you can have a simple block diagram, with no sub VIs, to allow the interface to execute additional code when the Update Inspection UI step executes. Figure 8 shows the LabVIEW block diagram for Two Images with Data.vi.
Figure 8. Block diagram of Two Images with Data.viContinue to the additional examples to learn more about using custom Inspection interfaces with Vision Builder AI inspections.