Professional Documents
Culture Documents
August 2009
371424H-01
Support
Worldwide Offices
Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599,
Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00,
Finland 358 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000,
Israel 972 3 6393737, Italy 39 02 41309277, Japan 0120-527196, Korea 82 02 3451 3400,
Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466,
New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 328 90 10, Portugal 351 210 311 210,
Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151, Taiwan 886 02 2377 2222,
Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter
the info code feedback.
Chapter 1
Installing the Vision Builder AI Development Toolkit
Introduction....................................................................................................................1-1
System Requirements ....................................................................................................1-2
Installation Instructions..................................................................................................1-3
Installation Instructions If Vision Builder AI Is Already Installed .................1-3
Importing Vision Builder AI 3.6 Custom Steps ............................................................1-4
Importing Custom Steps That Use an XControl..............................................1-4
Chapter 2
Understanding Custom Steps
Types of Custom Steps ..................................................................................................2-1
Custom Step Files ..........................................................................................................2-2
Source Code VIs..............................................................................................2-2
All VIs VI..........................................................................................2-2
Init Globals VI ..................................................................................2-3
Parameters Control............................................................................2-4
User Interface VI...............................................................................2-4
User Programming VI .......................................................................2-4
Utility VIs ......................................................................................................................2-5
VBAI Display in Main Window VI ................................................................2-5
VBAI Resource Manager VI ...........................................................................2-5
VBAI CoordSys Name Utility VI ...................................................................2-5
VBAI CoordSys ID Utility VI.........................................................................2-6
VBAI Decision Maker (Float) VI....................................................................2-6
VBAI Get Global Variables VI .......................................................................2-6
VBAI Check Unique Step Name VI ...............................................................2-6
VBAI SDK Get Result VI ...............................................................................2-7
VBAI SDK Get All Results VI .......................................................................2-7
VBAI SDK - Populate Results Ring VI ..........................................................2-7
VBAI SDK WindSetROI VI ...........................................................................2-7
Custom Step Concepts ...................................................................................................2-7
Examples .........................................................................................................2-9
Setup Variant ...................................................................................................2-9
Process ID........................................................................................................2-10
Chapter 3
Creating a Custom Image Processing Step
Generating a Custom Step from a Template ................................................................. 3-1
Accessing the Custom Step Source VIs ........................................................................ 3-3
Modifying the Custom Step Source VIs........................................................................ 3-3
Modifying the User Interface VI..................................................................... 3-3
Adding Threshold Range Controls ................................................... 3-4
Initializing Values for the Threshold Range Controls...................... 3-6
Modifying the User Programming VI ............................................................. 3-7
Preparing the Custom Step for Distribution .................................................................. 3-8
Changing the Tab Location of the Custom Step ............................................. 3-8
Customizing the Custom Step Icon................................................................. 3-9
Creating Documentation for the Custom Step ................................................ 3-9
Debugging the Custom Step.......................................................................................... 3-9
Configuring LabVIEW to Debug Custom Steps............................................. 3-9
Debugging the Custom Step ........................................................................... 3-10
Distributing The Custom Step ....................................................................................... 3-12
Chapter 4
Logging Measurement and Setting Limit Conditions
Generating the Custom Step from an Existing Step...................................................... 4-1
Accessing the Custom Step Source VIs ........................................................................ 4-3
Logging Measurements ................................................................................................. 4-3
Calculating the Threshold Percentage............................................................. 4-3
Storing the Threshold Percentage in the Measurements Array....................... 4-5
Returning Pass/Fail Data................................................................................. 4-6
Adding Pass/Fail Controls............................................................................................. 4-8
Initializing Values for the Pass/Fail Controls................................................................ 4-10
Initializing Default Values for the Pass/Fail Controls .................................... 4-10
Saving Values for the Pass/Fail Controls........................................................ 4-12
Initializing Existing Values for the Pass/Fail Controls ................................... 4-13
Handling Value Changes for the Pass/Fail Controls....................................... 4-14
Setting the Step Status Based on Pass/Fail Analysis..................................................... 4-15
Updating the User Interface with Measurement Data ................................................... 4-16
Debugging the Custom Step.......................................................................................... 4-19
Chapter 5
Using Previous Measurements
Generating the Custom Step from an Existing Step ......................................................5-1
Accessing the Custom Step Source VIs.........................................................................5-2
Modifying the Type Definition......................................................................................5-2
Adding Previous Measurement Controls .......................................................................5-4
Enumerating Previous Measurements ...........................................................................5-7
Initializing Values for Previous Measurement Controls................................................5-8
Initializing Default Values for Previous Measurement Controls ....................5-8
Initializing Existing Values for Previous Measurements Controls .................5-10
Handling Value Changes for Previous Measurement Controls .....................................5-13
Handling a New Image ..................................................................................................5-16
Performing an Image Threshold with Previous Measurement ......................................5-16
Debugging the Custom Step ..........................................................................................5-19
Appendix A
Controls and Indicators Used in Source Code VIs
Init Globals VI Parameters ............................................................................................A-1
User Interface VI Parameters.........................................................................................A-3
User Programming VI Parameters .................................................................................A-6
Appendix B
Creating Documentation for the Custom Step
Creating HTML Documentation for the Custom Step...................................................B-1
Downloading and Installing HTML Workshop.............................................................B-1
Integrating the Custom Step Documentation.................................................................B-2
Appendix C
Technical Support and Professional Services
Note The Vision Builder AI Development Toolkit is designed for advanced LabVIEW
users who have experience developing LabVIEW applications with the NI Vision
Development Module.
Conventions
The following conventions appear in this manual:
» The » symbol leads you through nested menu items and dialog box options
to a final action. The sequence File»Page Setup»Options directs you to
pull down the File menu, select the Page Setup item, and select Options
from the last dialog box.
bold Bold text denotes items that you must select or click in the software, such
as menu items and dialog box options. Bold text also denotes parameter
names.
monospace Text in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames, and extensions.
<Custom Step Name> The name of a step that you created with the Vision Builder AI
Development Toolkit.
<Vision Builder AI> The location to which you installed Vision Builder AI.
Related Documentation
The following documents contain information that you may find helpful as
you read this manual:
• NI Vision Concepts Help—Describes the basic concepts of image
analysis, image processing, and machine vision. This document also
contains in-depth discussions about imaging functions for advanced
users. The NI Vision Concepts Help is available by selecting
Start»All Programs»National Instruments»Vision Builder AI»
Documentation»NI Vision Concepts Help from the Start menu.
• NI Vision Builder for Automated Inspection: Configuration
Help—Contains information about using the Vision Builder for
Automated Inspection Configuration Interface to create a machine
vision application. The NI Vision Builder for Automated Inspection:
Configuration Help is available by selecting Start»All Programs»
National Instruments»Vision Builder AI»Documentation»Vision
Builder AI Configuration Interface Help from the Start menu.
• NI Vision Builder for Automated Inspection: Inspection
Help—Contains information about running applications created with
Vision Builder AI Inspection Interface. The NI Vision Builder for
Automated Inspection: Inspection Help is available by selecting
Start»All Programs»National Instruments»Vision Builder AI»
Documentation»Vision Builder AI Inspection Interface Help from
the Start menu.
• NI Vision Builder for Automated Inspection Tutorial—Describes
Vision Builder for Automated Inspection and provides step-by-step
instructions for solving common visual inspection tasks, such as
inspection, gauging, part presence, guidance, and counting. The
NI Vision Builder for Automated Inspection Tutorial is available by
selecting Start»All Programs»National Instruments»Vision
Builder AI»Documentation»Vision Builder AI Tutorial from the
Start menu.
Introduction
The Vision Builder AI Development Toolkit features a wizard and an
application program interface (API) to create custom steps for use in any
Vision Builder AI inspection.
Note This toolkit is designed for advanced LabVIEW users who have experience
developing LabVIEW applications with the NI Vision Development Module.
Note The Vision Builder AI Development Toolkit does not support the creation of
acquisition steps for remote targets, such as the NI 17xx Smart Camera, NI CVS-1450
Series Compact Vision System, or NI EVS-1460 Series Embedded Vision System.
You can distribute custom steps with the executable version of Vision
Builder AI, to provide end users with a customized Vision Builder AI
package.
System Requirements
Table 1-1 includes minimum system requirements for the Vision
Builder AI Development Toolkit:
Installation Instructions
Complete the following steps to install the Vision Builder AI Development
Toolkit.
Note You must install LabVIEW before installing the Vision Builder AI Development
Toolkit.
Note To install the Vision Builder AI Development Toolkit on a Windows system, you
must be logged in with administrator privileges.
1. In the feature tree for Vision Builder AI, select Development Toolkit
and select Install this feature to the local drive.
2. Click Next.
3. Follow the setup instructions on your screen.
Note You must install LabVIEW before installing the Vision Builder AI Development
Toolkit.
The Import Vision Builder AI 3.6 Step wizard creates the following files in
the <Vision Builder AI 2009>\UserPlugins folder:
• 59 <Custom Step Name>.llb—Source code for the custom step
• <Custom Step Name>.tif—Icon for the custom step
The XControl still links to the custom step created for Vision Builder
AI 3.6. To link the XControl to the custom step created for Vision Builder
AI 2009, complete the following steps:
1. Navigate to the <Vision Builder AI 3.6>\UserPlugins folder and
delete the custom step created for Vision Builder AI 3.6.
2. Launch LabVIEW.
3. Navigate to the <Vision Builder AI 2009>\UserPlugins folder,
select the LLB of the custom step created for Vision Builder AI 2009,
and click OK.
4. Select the XControl (.xctl) file, then click OK.
5. A dialog box indicates that the XControl is no longer linked to the
custom step for Vision Builder AI 3.6. Click OK.
6. Select File»Save All.
7. Close the XControl.
8. Close LabVIEW.
9. Navigate to the <Vision Builder AI 3.6>\UserPlugins folder,
and rename the backup copy of the custom step for Vision Builder
AI 3.6 to the original step name.
The XControl in the custom step for Vision Builder AI 2009 functions
properly.
Tip Examine other templates to help determine how to modify your custom step. For
example, if you want to create a custom step that combines image processing and creating
image masks, use the Simple Processing template to create the custom step, then refer to
the Coordinate System template for ideas about how to implement image mask creation.
To deploy a custom step, you must save the custom step for distribution.
Refer to the Distributing The Custom Step section of Chapter 3, Creating a
Custom Image Processing Step, for more information about deploying
custom steps.
All VIs VI
The All VIs VI is not designed to be executed. The block diagram of the
All VIs VI provides a project window that contains the VIs that you can
modify or use in your custom step.
• Utility VIs—This section contains utility VIs that you can call within
the source VIs to perform specific functions, such as displaying an
image in the main Vision Builder AI window. You cannot modify these
VIs. Refer to the Utility VIs section for more information about utility
VIs.
• Dynamic VIs—This section is designed to contain any VIs that you
call dynamically. Place any VIs that you call dynamically within a
source VI in this section to ensure that the VI is saved correctly when
you build the custom step for distribution.
Init Globals VI
The Init Globals VI allows you to specify the following properties for a
custom step:
• The name and description of the step that appear in Vision Builder AI.
• The version of the custom step.
• The tools palette tab that contains the custom step in Vision
Builder AI.
• The region where the user interface for the custom step appears in
Vision Builder AI.
• Whether the custom step can be used in product selection mode.
• The path to a help file that you create for the custom step. Refer to
Appendix B, Creating Documentation for the Custom Step, for
information about creating help for the custom step.
• The default ROI tool for the step, the ROI tools supported by the
custom step, the names of the available ROI tools, and the display of
previously created ROIs.
• The image file types supported by the custom step.
For detailed information about the parameters in the Init Globals VI that
you can set to specify the properties of your custom step, refer to
Appendix A, Controls and Indicators Used in Source Code VIs.
Note When you modify the controls and indicators in the Init Globals VI, you must make
the new values the default for the control or indicator and save the changes. To make the
current values the default for a control or indicator, select Edit»Make Current Values
Default, and save the VI.
Parameters Control
This is the type definition for the parameters used by the custom step. Type
definitions link all the instances of a custom control or indicator to a saved
custom control or indicator file. You can update all instances of a parameter
by editing the <Custom Step Name> - parameters.ctl file, which
allows you to easily use the same controls and indicators in multiple source
code VIs.
Tip If you have multiple parameters, place them inside a cluster. By bundling several data
elements into a single cluster data structure, you eliminate wire clutter on the block
diagram and reduce the number of VI connector pane terminals required to handle
parameter data.
User Interface VI
The front panel of the User Interface VI is the interface the user sees when
configuring the custom step. The User Interface VI allows the user to
modify step parameters, and can compare data from the User Programming
VI with user-defined parameters to indicate the step status.
The User Interface VI is executed when a user selects the custom step from
the Vision Builder AI Inspection Steps palette or when the user opens a step
already inserted in the script to edit parameters.
Note Do not resize the tab control on the user interface or change its position. Changing
the tab control on the custom step user interface might move the user interface controls and
indicators to a position that the user cannot access.
Tip To display the user interface of the custom step in the main window of Vision Builder
AI, open the Init Globals VI and select Main Window from the Region list.
User Programming VI
The User Programming VI performs image processing, and can return
image processing results. The front panel is never displayed, so it does not
have to be modified. Do not modify the connector pane of this VI.
The Vision Builder AI engine sets the value of the Setup variant control,
which contains the setup parameters defined by the user in the user
interface. Use the Variant To Data VI to access this data. Use the same data
structure that you used to package the data in User Interface VI. To ensure
that you use the same data type, always use the Parameters control type
definition with the Variant to Data VI.
Utility VIs
Utility VIs perform tasks that are commonly necessary in Vision Builder
AI steps. These VIs can be accessed from the All VIs block diagram, but
not all utility VIs are included with every type of custom step. The utility
VIs are located at <Vision Builder AI>\Plugins\
Common SDK VIs.llb.
Figure 2-1 shows how the custom step configuration data flows from the
user interface to the execution of the custom step, which occurs in a loop.
The outputs of the User Interface VI are saved in the Vision Builder AI
engine, which then dispatches the outputs to the inputs of the User
Programming VI.
Figure 2-1. Dataflow between the User Interface, User Programming, and Utility VIs
The User Interface VI is called when the user inserts the custom step into a
script, or opens the custom step to edit its configuration. The front panel of
the User Interface VI is the interface that the user sees when configuring the
custom step.
Note When developing the User Interface VI, ensure that you call the User Programming
VI in setup mode to perform any initialization before you call the execution mode of the
User Programming VI.
When the step executes, the Vision Builder AI engine sets the image and
the Previous Measurements array, and sets the Setup variant to the value
previously set in User Interface VI. In execution mode, the User
Programming VI accesses the data from the User Interface VI, then
processes the image and produces results.
When the user closes the script, the Vision Builder AI engine calls the
cleanup mode of the User Programming VI. Figure 2-1 illustrates the
sequence of the setup, execution, and cleanup modes of the User
Programming VI.
Examples
Complete the following steps to view a block diagram that shows the event
structure that handles the OK button in the user interface of the custom
step:
1. Create a custom step using the Simple Processing Step template.
2. Open the User Interface VI.
3. View the block diagram.
4. Select frame 3 of the sequence structure.
5. Select event case 3 of the event structure. In this event case, the step
uses the VBAI Check Unique Step Name utility VI to verify that the
step name is valid before it allows the step to exit.
Complete the following steps to view a block diagram that shows the
relationship between the User Interface VI and the User Programming VI:
1. Create a custom step using the Processing Step that Logs
Measurements template.
2. Open the User Interface VI.
3. View the block diagram.
4. Select frame 3 of the sequence structure.
5. Select event case 0 of the event structure. In this event case, the step
compares the Pass/Fail Data returned from the User Programming VI
to the Pass/Fail Conditions set by the user in the user interface, then
updates the Step Status indicator based on the comparison results.
The step also uses the VBAI Display in Main Window utility VI to
update the main window of Vision Builder AI with the processed
image returned by the User Programming VI.
Setup Variant
The Setup variant stores the parameters of the step. If the step requests
more than one parameter, bundle the parameters in a cluster, and
use the To Variant VI to store the parameters in the variant. Use the
Variant to Data VI to retrieve these parameters in the User Programming
VI.
Complete the following steps to view a block diagram that shows the
relationship between the step parameters and the Variant to Data VI:
1. Create a custom step using the Simple Processing Step template.
2. Open the User Interface VI.
Process ID
When the user creates an instance of a custom step, the Vision Builder AI
engine provides the step instance with a Process ID, which is a string that
uniquely identifies the custom step. The Process ID differentiates multiple
instances of the same step.
Tip The VBAI Resource Manager utility VI is designed to help you create, get, and
deallocate step specific resources. Refer to the Utility VIs section for more information
about the VBAI Resource Manager VI.
Tip You can use a variable to pass information between the different modes of the VI.
If the values of the variable change between multiple instances of the same custom VI,
the variable is overwritten with the latest value.
Save any global variables created in the 59 <Custom Step Name>.llb with the step
name as the prefix, followed by a dash. For example, if you created a variable called
MyGlobal for a step you named Image Processing, save the global variable as Image
Processing - MyGlobal.vi.
Note This tutorial requires the NI Vision Development Module in addition to the
minimum system requirements of the Vision Builder AI Development Toolkit.
Note The custom step is not available in Vision Builder AI until you save it for
distribution. National Instruments recommends that you debug the custom step before you
save it for distribution. Refer to the Debugging the Custom Step section for information
about debugging custom steps.
Complete the following steps to open the All VIs VI for the custom step,
if it is not already open:
1. Launch LabVIEW.
2. Select File»Open.
3. Navigate to <Vision Builder AI>\UserPlugins\
59 Manual Threshold.llb
4. Open the LLB.
5. Select the Manual Threshold - All VIs.vi and click OK.
• Modify the block diagram of the User Interface VI to set default values
for the threshold range
Note Do not resize the tab control on the user interface or change its position. Changing
the tab control on the custom step user interface might move the user interface controls and
indicators to a position that the user cannot access.
a. b.
Tip Set the color of the cluster background and border to transparent to hide the cluster on
the user interface. To change the cluster color to transparent, select View»Tools Palette,
and select the Set Color tool. Right-click the cluster background or border to open the
color picker, and Select the T box in the upper right corner of the color picker.
The user interface now contains two numeric controls that allow the user to
specify the range for the image threshold.
When the user adds the custom step to an inspection in Vision Builder AI,
the User Interface VI initializes the Maximum Value control to 90.
Note When you modify the controls and indicators in the Init Globals VI, you must make
the new values the default for the control or indicator and save the changes.
Note You must open Vision Builder AI from LabVIEW to test a custom step that has not
been saved for distribution. Refer to the Distributing The Custom Step section for
information about saving custom steps for use with the Vision Builder AI executable.
7. Modify the Minimum Value and Maximum Value, and observe the
changes made to the image in the main window of Vision Builder AI.
8. Press <Ctrl-E> or select Window»Show Block Diagram to open the
block diagram and begin debugging the custom step.
Standard LabVIEW debugging tools are available to debug the custom
step. Select the appropriate debugging options and breakpoints to
debug the custom step.
9. Exit debugging mode by clicking Abort Execution in the LabVIEW
toolbar, by clicking Cancel in the custom step User Interface VI front
panel, or by clicking the Exit button in Vision Builder AI.
Note Refer to the Processing Step that Logs Measurements template as you proceed with
this tutorial. Use the Processing Step that Logs Measurements template to create new
custom steps that perform pass/fail analysis.
Note This tutorial requires the NI Vision Development Module in addition to the
minimum system requirements of the Vision Builder AI Developer’s Toolkit.
6. Click Next.
7. Select Manual Threshold from the Existing Custom Steps Previously
Created list.
8. Click Next and verify the setup information. Close all open VIs to
ensure that the custom step is created successfully.
9. Click Finish to create the custom step.
The Create Custom Step wizard opens the Manual Threshold Pass
Fail - All VIs VI. This VI provides a project window that contains the
VIs you can modify for the custom step. Refer to the Source Code VIs
section of Chapter 2, Understanding Custom Steps, for information
about the VIs that make up a custom step.
Note The custom step is not available in Vision Builder AI until you save it for
distribution. National Instruments recommends that you debug the custom step before you
save it for distribution. Refer to the Debugging the Custom Step section for information
about debugging custom steps.
Complete the following steps to open the All VIs VI for the custom step,
if it is not already open:
1. Launch LabVIEW.
2. Select File»Open.
3. Navigate to <Vision Builder AI>\UserPlugins\
59 Manual Threshold Pass Fail.llb
4. Open the LLB.
Logging Measurements
Follow the steps in this section to modify the User Programming VI to
perform the following functions:
• Calculate the percentage of the image that is removed by an image
threshold
• Store the thresholded percentage to the Measurements array so that
other steps can access the value
• Log the thresholded percentage so that Vision Builder AI can compare
the value with the limits specified by the user in the user interface
9. Click the Type enum and select Numeric from the list.
10. Enter Threshold Percentage as the value for the Name string.
11. Connect the cluster to the input cluster input of the Bundle By Name
function.
12. Place a Build Array function inside the case structure.
13. Connect the output cluster output of the Bundle By Name function to
the element 0 input of the Build Array function.
14. Locate the Measurements array that is inside the case structure.
Connect the appended array output of the Build Array function to the
Measurements array.
15. Select File»Save.
Note You can log additional results by adding more elements to the array.
Complete the following steps to modify the block diagram to store the
thresholded percentage to the Pass/Fail Data array, as shown in Figure 4-4:
Figure 4-4. Storing the Threshold Percentage in the Pass/Fail Data Array
Tip To automatically resize a string constant, right-click the string and select Size To
Text.
12. Locate the Pass/Fail Data array that is inside the case structure.
Connect the appended array output of the Build Array function to the
Pass/Fail Data array.
13. Select File»Save to save the User Programming VI.
14. Select File»Close to close the User Programming VI.
Note The Pass/Fail Data array must have the same number of elements as the Pass/Fail
Condition out array found in the User Interface VI. Each element of the Pass/Fail Data
array is compared to a condition specified in the Pass/Fail Condition out array.
Note Do not resize the tab control on the user interface or change its position. Changing
the tab control on the custom step user interface might move the user interface controls and
indicators to a position that the user cannot access.
The user interface now contains controls that allow the user to enable
pass/fail analysis, and to specify a limit condition for pass/fail analysis.
a. Place a local variable outside the right side of the case structure.
b. Click the local variable and select Pass/Fail Condition from the
list.
c. Right-click the Pass/Fail Condition variable and select
Create»Constant.
d. Place the constant inside the case structure.
e. Wire the constant to the Pass/Fail Condition variable.
6. Select File»Save.
When the user adds the custom step to an inspection in Vision Builder AI,
the User Interface VI initializes the pass/fail controls to the values specified
in the constant.
Complete the following steps to modify the block diagram to save the
values specified by the user:
1. With the User Interface VI block diagram open, select frame 4 of the
stacked sequence structure. Locate the case structure within frame 4
and select the False case.
The False case stores the step values in the indicators so that the values
can passed to the Vision Builder AI engine. When a user edits the step,
the Vision Builder AI engine passes the stored values back to the step.
2. Complete the following steps to build the block diagram shown in
Figure 4-8:
When the user saves the step, the values from the Pass/Fail Condition
control are stored in the Pass/Fail Conditions out array. When the user edits
the step, the Vision Builder AI engine passes the values stored in the
Pass/Fail Conditions out array to the Pass/Fail Conditions in array. Use
the Pass/Fail Conditions in array to initialize values for the pass/fail
controls on the Limits tab.
When the user edits the step, the User Interface VI initializes the pass/fail
controls to the values specified in the Pass/Fail Conditions in array.
1. With the User Interface VI block diagram open, select frame 3 of the
stacked sequence structure.
2. Locate the event structure within frame 3 and select event case 0.
3. Place a local variable inside the event structure.
4. Click the local variable and select Pass/Fail Condition from the list.
5. Right-click the Pass/Fail Condition variable and select Change to
Read.
6. Place a Build Array function inside the event structure.
7. Wire the Pass/Fail Condition variable to the element 0 input of the
Build Array function.
8. Open the All VIs VI block diagram and locate the VBAI Decision
Maker (Float) VI.
9. Copy the VBAI Decision Maker (Float) VI into the event structure of
the User Interface VI.
The VBAI Decision Maker (Float) VI compares results from User
Programming VI against the limit conditions specified by the user in
the User Interface VI to determine whether the step result conditions
are met.
10. Wire the output of the Build Array function to the Pass/Fail Condition
input of the VBAI Decision Maker (Float) VI.
11. Wire the Pass/Fail Data output of the Manual Threshold Pass Fail -
User Programming VI to the Pass/Fail Data input of the VBAI
Decision Maker (Float) VI.
12. Delete the Boolean constant that is wired to the Step Status indicator.
13. Wire the Pass/Fail Flag output of the VBAI Decision Maker (Float)
VI to the Step Status indicator.
14. Select File»Save to save the User Interface VI.
Note You must configure LabVIEW before debugging a custom step. Refer to the
Configuring LabVIEW to Debug Custom Steps section of Chapter 3, Creating a Custom
Image Processing Step, for more information about configuring LabVIEW.
Note You must open Vision Builder AI from LabVIEW to test a custom step that has not
been saved for distribution. Refer to the Distributing The Custom Step section of Chapter 3,
Creating a Custom Image Processing Step, for information about saving custom steps for
use with the Vision Builder AI executable.
When you are satisfied with the performance of the step, save the step for
distribution. Refer to the Distributing The Custom Step section of
Chapter 3, Creating a Custom Image Processing Step, for more
information about saving custom steps for distribution.
You can use the Measurements indicator in the Execution mode of the User
Programming VI to log double, Boolean, and string measurements of the
custom step for use in subsequent steps. For more information about the
Measurements indicator, refer to the User Programming VI Parameters
section of Appendix A, Controls and Indicators Used in Source Code VIs.
Note This tutorial requires the NI Vision Development Module in addition to the
minimum system requirements of the Vision Builder AI Developer’s Toolkit.
The Create Custom Step wizard opens the Manual Threshold Previous
Measurements - All VIs VI. This VI provides a project window that
contains the VIs you can modify for the custom step.
Note The custom step is not available in Vision Builder AI until you save it for
distribution. National Instruments recommends that you debug the custom step before you
save it for distribution. Refer to the Debugging the Custom Step section for information
about debugging custom steps.
Complete the following steps to open the All VIs VI for the custom step,
if it is not already open:
1. Launch LabVIEW.
2. Select File»Open.
3. Navigate to <Vision Builder AI>\UserPlugins\
59 Manual Threshold Previous Measurements.llb
4. Open the LLB.
5. Select the Manual Threshold Previous
Measurements - All VIs.vi and click OK.
Complete the following steps to add two GUIDs to the type definition:
1. Open the All VIs VI.
2. Double-click the User Interface VI to open it.
3. Select the Settings tab.
Note Do not resize the tab control on the user interface or change its position. Changing
the tab control on the custom step user interface might move the user interface controls and
indicators to a position that the user cannot access.
4. Right-click the Threshold Range cluster and select Open Type Def to
open the Parameters control.
5. Expand the size of the Parameters control window and the Threshold
Range cluster.
6. Complete the following steps to build the front panel shown in
Figure 5-1:
Note Do not resize the tab control on the user interface or change its position. Changing
the tab control on the custom step user interface might move the user interface controls and
indicators to a position that the user cannot access.
3. Move the Threshold Range cluster off of the tab control, as illustrated
in Figure 5-2:
a. Add a system ring to the Settings tab. Label the system ring
Minimum Value Source.
b. Add a system ring to the Settings tab. Label the system ring
Maximum Value Source.
c. Add a system spin control to the Settings tab. Label the system
spin control Minimum Value (Constant).
d. Add a system spin control to the Settings tab. Label the system
spin control Maximum Value (Constant).
5. Press <Ctrl-E> or select Window»Show Block Diagram to show the
block diagram.
6. Move the Minimum Value Source, Minimum Value (Constant),
Maximum Value Source, and Maximum Value (Constant) controls
outside the stacked sequence structure.
7. Select File»Save.
Figure 5-5. Initializing the Previous Measurement Controls with Default Values
When the user adds the custom step to an inspection in Vision Builder AI,
the User Interface VI initializes the Minimum Value Constant and
Maximum Value Constant controls to default values. The User Interface VI
initializes the Minimum Value Source and Maximum Value Source ring
structures to a value of 0, which corresponds to a selection of the constant
values as the source values.
Figure 5-6. Initializing the Previous Measurement Controls with Existing Values
When the user edits the step, the Vision Builder AI engine passes that
values stored in the Setup out array to the Setup in array. The User
Interface VI initializes the previous measurement controls to the values
specified in the Setup in array.
The User Interface VI uses the Search 1D Array functions to verify that the
values stored for the Minimum Value Source and Maximum Value Source
ring structures correspond to the Measurement IDs of available
measurements. If the search function returns an index with a negative value,
then the measurement is missing and the corresponding ring structure is
initialized to a value of 0.
When the user clicks the Run Once button, the User Interface VI updates
the property nodes for the Minimum Value (Constant) control and triggers
the User Programming VI.
The User Programming VI uses the VBAI SDK Get Result VI to verify that
the GUID for the measurement specified by the user contains a valid
numeric value. If the GUID contains a valid numeric value, the User
Programming VI performs the image threshold using the measurement
value stored in the GUID. If the GUID does not contain a valid numeric
value, the User Programming VI uses the value of the corresponding
constant.
Note You must configure LabVIEW before debugging a custom step. Refer to the
Configuring LabVIEW to Debug Custom Steps section of Chapter 3, Creating a Custom
Image Processing Step, for more information about configuring LabVIEW.
Note You must open Vision Builder AI from LabVIEW to test a custom step that has not
been saved for distribution. Refer to the Distributing The Custom Step section of Chapter 3,
Creating a Custom Image Processing Step, for information about saving custom steps for
use with the Vision Builder AI executable.
Note When you modify the controls and indicators in the Init Globals VI, you must make
the new values the default for the control or indicator and save the changes. To make the
current values the default for a control or indicator, select Edit»Make Current Values
Default, and save the VI.
Setup in Variant that contains the step parameters that were entered during editing and saved
when the user clicked OK and inserted the step into the script. Use the Parameters
control to save a type definition of the parameters. Use the Variant To Data VI to
access data stored in Setup in. Bundle multiple parameters in a cluster and use the
To Variant VI to package the cluster for the Setup out indicator.
Edit Mode FALSE indicates a new instance of the custom step. TRUE indicates that the step is
being edited by the user. For example, if a user double-clicks a step that is already in
the script, Edit Mode is TRUE.
ROI Event Notifies you when a region of interest is drawn in the main image window. The ROI
Event is fired by Vision Builder AI when you draw an ROI in the main image. The
ROI Event returns the following elements:
To handle the ROI Event, add code to the <ROI Event>: User Event
case of the event structure in the User Interface VI.
Event Refers to activity in the Vision Builder AI interface. This Event is fired by Vision
Builder AI to notify you of an action in the Vision Builder AI interface. The Event
string contains the type of event.
Currently, New Image is the only supported type of event. The New Image event
allows you to execute the custom step on a new image while you are still configuring
the custom step. The New Image event is fired when you click the Run State Once
button on the Vision Builder AI toolbar.
To handle the Event, add code to the <Event>: User Event case of the
event structure in the User Interface VI.
Reference CoordSys Array List of available coordinate systems. Use this in conjunction with the Coordsys
Utilities to manage coordinate systems.
Pass/Fail Condition In Pass/fail conditions of the custom step. This array contains the following elements:
Value 1, Value 2—Limit conditions. In execution mode, these values are compared
against the Pass/Fail Data produced by the User Programming VI, depending on the
relational operator function selected.
You can modify other types of custom steps to use the Pass/Fail Condition In
controls and Pass/Fail Condition Out indicator. Refer to the Types of Custom Steps
section of Chapter 2, Understanding Custom Steps, for information about each
custom step template.
Previous Measurements Measurements made by previous steps. This array of clusters has as many elements
as there are steps in the script. Each element of the array describes the measurements
logged by the corresponding step.
Note: Use the Get Result VI to access information about the measurement, such as
the value, type, name, and unit. If you need to use the Previous Measurements control
in the step, save the Measurement ID in the Setup variant, which you can access from
the User Programming VI. Use the Get Result VI to get the value of the Measurement
ID when the User Programming VI is executed. For examples on how to use Previous
Measurements, examine the Generate a Report template or the Global Step Status
template.
ROI Descriptor The constant ROI to be saved. The array contains the following elements:
Table A-3 lists the indicators that return data from the User Interface VI.
Table A-3. User Interface VI Indicators
Indicators Description
Name out Name the user entered for the step.
Setup out Variant that contains the parameters of the step. If the step
requires more than one parameter, bundle the parameters in a
cluster, and use the To Variant VI to package the parameters in
the variant.
Pass/Fail Condition out Pass/fail conditions of the custom step.
ROI Descriptor Out The constant ROI to be saved. If a programmable ROI was
selected, the ROI will be saved automatically.
Table A-5 lists the indicators that return data from the User
Programming VI.
Although not required, you can create three HTML files for the custom step
to be consistent with the Vision Builder AI online help. These three HTML
files include one describing configuration procedures, one describing the
controls, and one listing frequently asked questions regarding the custom
step.
For information about creating compiled HTML help, refer to Help for
HTML Help, which is available from the Help menu in HTML Help
Workshop.
Complete the following steps to add the custom step documentation to the
Vision Builder AI user interface:
1. Save the .chm file to the <Vision Builder AI>\Help folder.
2. Launch LabVIEW.
3. Click File»Open. Navigate to <Vision Builder AI>\
UserPlugins\59 <Custom Step Name>.llb.
4. Select <Custom Step Name> - Init Globals.vi and click OK.
5. Type the .chm file name and the HTML page in the elements of the
Context Help array. For example, if the help file name is myhelp.chm
and the HTML file name of the page you that contains configuration
information is config.html, enter myhelp.chm\config.html for
the first element of the array.
Each element of the array is the relative path of the HTML page for the
associated tab. For example, the first element is the relative path of the
HTML file you want to display for the Configuration tab. These tabs
appear in the context help window of Vision Builder AI. Refer to
Figure B-1 for an example of the context help window.
If you add at least one file to the Context Help array, make sure all
three elements of the array are populated, duplicating the file name if
necessary. If you add a file name to one element and leave one or more
of the remaining elements blank, Vision Builder AI displays an error
indicating that a page was not found for the tabs that are represented
by the blank elements.
For example, if you created an HTML file that covers configuring the
custom step and you add that file name to the first element in Context
Help but leave the other two elements blank, the Control
Descriptions and FAQs tabs in Vision Builder AI display an error
indicating a page was not found for the custom step.
6. Select Edit»Make Current Values Default.
7. Save and close the VI.
8. Select Tools»Vision Builder AI»Test Your Custom Step in Vision
Builder AI.
9. Navigate to the appropriate tab and click the custom step to view the
newly added documentation.
If you searched ni.com and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit
the Worldwide Offices section of ni.com/niglobal to access the branch
office Web sites, which provide up-to-date contact information, support
phone numbers, email addresses, and current events.