Sherlock Embedded Tutorial - v13
Sherlock Embedded Tutorial - v13
a BOA PRO with an IP Address compatible with the PC, and the Sherlock Embedded software running.
a PC with the Sherlock Embedded Client software installed (see the installation manual for instructions).
a BOA Breakout board with the I/O cable attached (see the installation manual for instructions).
You can use the iDiscover utility (in Sherlock Embedded\Utility) to find and change the IP Address of your BOA
PRO camera. But do not use iDiscover to connect to the camera. Refer to the BOA Pro Installation Manual.
You can use the Windows® “Close” control in the top right corner of each
window, or you can use the View menu in the Main Window’s menu bar. A
check to the left of a window name indicates the window is open. The absence
of a check indicates the window is closed. Click on a window name to toggle
between open and closed.
If you maximize the Image Window, the controls will appear at the far right of the Main Window’s menu bar.
You can drag and drop windows onto each other. Tabs will appear at the bottom of the stacked windows.
Drag and drop the Configuration Window onto the Monitor Window. Drag and drop the Program Window onto
the Properties Window. Click the Properties tab. Drag and drop the Properties Window beside the Configuration
Window. Resize windows to your liking.
Your window layout is saved to a file “layout.ini” when you close the Sherlock Embedded Client Application
Program. You can save a copy of the layout file to another directory so you can restore it, or so it is not lost
when you uninstall the Client application before upgrading to a newer version.
In the Main Window menu bar, click on “Options” and click on “Application settings”. The first entry
“Application->Gui Style” defines the windows style used in the Client Application, for this client PC.
Click once on the entry in the “Value” column to activate the drop list. Click a second time to open the drop list
and show the styles available. Change the style if you wish, and click “Close”.
Scroll down to find “Angle unit of measure”. Select either Radians or Degrees before you begin programming.
The Sherlock Embedded software does not convert from one unit to the other automatically. Do not save
programs in one unit of measure and later change the unit of measure. The software does not convert numbers
for you when loading a saved program.
A new or default program will have three tabs at the bottom of the Program Window, for the “main” routine
and two subroutines, named “onPass” and “onFail”.
The default program contains an image acquisition instruction (acqA) and an Image Window instruction
(image_windowA) in the routine. NOTE: The image handle from the acqA instruction is connected to the image
handle in the image_windowA instruction.
The letter A is appended to your instructions to indicate the first instance of each instruction. A letter is always
appended because these instructions can be repeated in a program. You can change the names of instructions in
the Properties Window to suit your needs.
IMPORTANT!
If you create an Image Window, you must connect the
image input (handle) to some image source; usually a
camera acquisition.
The number wheel is grayed out, but the second control on the right is active. It currently shows a entry field
icon . Click on this icon and it changes to two chain links , for linking the value to a variable. Now click on
the Value field to open a drop list of the defined variables that could be attached to this value. At this time there
are no available variables. Click on “<none>” to close the list. Click once on the link icon to change it back to
an entry field and the value 640.00 is again displayed.
In the Program Window, click on the instruction “image_windowA”. The Properties Window changes to show
the Image Window properties.
The Image Window has Properties: “name”, “enabled”, “time” and “calibration”. The Image Window has one
Input: “image”. The Properties Window show the input of the Image Window is connected to “acqA.image”.
The Program Window also shows this connection: Hdl image<-acqA.image.
Notice that all instructions have a property “enabled”. You can disable any instruction for debugging purposes.
Create an ROI
“ROI” stands for “Region Of Interest”.
In the Image Window toolbar, click on the “Create Rectangle” button . Click on the image to define the
starting point of the rectangle. Move your cursor and click a second time to define the ending point of the
rectangle. A label “rectangleA” appears at the top of the rectangle (in red).
In this menu you can also copy or delete the ROI. If you Copy, an
option to Paste will also appear in this menu. When you copy and
paste an ROI, the new ROI appears on top of the original, at the
same location. Drag the new ROI to a new location.
If you right-click in the image window, outside the ROI, you get a
popup menu for colorizing the image.
Algorithms and preprocessors you create by right-clicking in the ROI in the Image Window are added or
appended in the order you create them.
Algorithms or preprocessors you create by right-clicking on the ROI instruction in the Program Window are
added right below the ROI instruction.
You can drag and drop algorithms and preprocessors to arrange them, with no restrictions on the order.
You can drag the point readings to a new location (for example,
outside the ROI). You can also hide the readings, by right-clicking on
the point and clearing the check beside “Display in image” in the
popup.
Create Variables
In the System Window, click on “Variables”.
A toolbar appears in the System widow.
The buttons display the variable data types
available: B = Boolean, N = Number, S =
String, P = Point, L = Line, B[] = Boolean
array, N[] = Number array, S[] = String
array, P[] = Point array, L[] = Line array.
There are other data types supported by Sherlock Embedded, but you cannot create variables for those types;
for example Hdl = Handle.
The System Window is the only place you can create and delete variables.
405-00032-00 edited 25 January 2013 page 10 of 36
Sherlock Embedded Tutorial
Assign Variables
IMPORTANT! “varA” is the variable name. “varA.value” is the current value (0.00) of the variable.
Notice that the list is shorter for the output than it was for the input. There are more numbers and variables
available to assign to an input, but fewer numbers or variables that can accept an output value (or “reading”).
Click on the gray divider labeled “Outputs” or press “Enter” or “Return” on your keyboard, to accept this change.
The Configuration Window shows three tabs at the top. Click on the “Pass/Fail script” tab. This tab has two
panes for a code statement and properties. Note this code entry window is case sensitive. The right pane
displays all the defined object names.
If you have closed the Configuration Window it will not automatically open on its own when you select an object
that uses the Configuration Window. If the Configuration Window is open and behind another tab, it will come
to the front.
“VEngine” is a special variable that links the Sherlock program environment to the JavaScript environment. But
“vengine” is not a special variable.
You can drag values from the right pane into the left pane. The right pane displays the names and values of all
objects and variables; defined by you and by Sherlock instructions. For this statement you could scroll through
the right pane to find “VEngine.varA.value”. You could also find “VEngine.min_max.max” and use that
measurement directly, without using the variable value “varA.value”.
Click the “Save” button. The code will not be saved or used in the program if you do not click “Save”.
In the Image Window, the rectangle outline will change to red if the test fails (script statement evaluates
“false”), and change to green if the test passes (script statement evaluates “true”).
Click the “Add” button to open a list of all available variables and properties. Click on “rectangleA.pass [B]”. The
[B] indicates this object is a Boolean.
In the Decision Table, click on the property name “rectangleA.pass” and then click in the checkbox to enable this
property for the composite Pass/Fail result.
The checkbox allows you to disable an object from the composite result, without deleting it from the table.
Now click the “Reset” button at the bottom of the panel. All values are reset to zero. In the Properties Window,
the values for “pass” and “pass_fail_history” are also set to zero.
At the end of the Main routine, if the rectangle test condition passes, this property evaluates “true” and the
result of the Decision Table is a pass. The main routine calls the “onPass” subroutine. If the result of the Decision
Table is a fail, the main routine calls the “onFail” subroutine.
The result of the Decision Table is referred to as the “composite result” because you can add multiple variables
or objects to the Decision Table. The composite result passes only if all enabled objects pass. The composite
result fails if one or more enable objects fail.
In the Status bar, there will be an indication of “Pass” and “Fail” based on the
Decision Table passing or failing.
Alternatively, you could use the maximum value from the min_maxA measurement directly, instead of the ROI
pass condition. Or you could use the value of variable varA, which is also the maximum value.
In the Program Window, click on the “onFail” tab. Right-click on the statement “onFail” in the Program Window.
In the Instruction popup move your cursor to Number and click on “add_number”.
The Properties Window changes to show the value contained in “sum” is still zero. This matches the value in the
right pane of the System Window, beside the variable name “Number Failed”.
Sherlock Embedded has System variables that track the number of passed and failed parts, but this exercise
shows how to assign variables, change variable names and increment numbers. All these are frequently used.
Add a Message
In the Program Window, click on the “onPass” tab.
Right click on the “add_numberA” instruction. In
the Instruction menu move your cursor to
IO:Monitor and in the second menu click on
“display_message”. The instruction
“display_messageA” appears in the Program
Window.
In the Main Window Toolbar, click the “Run program once” button.
You can clear the Monitor Window messages at any time, by right-clicking in the Monitor Window.
In the System Window, click on “System”. The Configuration Window should display over the Monitor Window,
and show the Decision Table.
In the Save program window, change the Index to 1. Enter Tutorial2 in the Name field and enter Add messages
in the Description field. Click on “OK” to save the program in BOA memory.
We changed all variables to 0 before saving, so you do not see outdated values when you reload the program.
You can also clear the variables in a routine “onEvent_program_loaded” that runs when you load the program.
pulse_dig_io – Sherlock sends the pulse command to the hardware, and waits for the pulse to complete. This
makes the program execution wait at least the pulse duration time before going to the next statement.
async_pulse_dig_io – Sherlock sends the pulse command to the hardware, and continues to the next statement
without waiting. The pulse begins almost immediately, with minimum wait time.
schedule_async_pulse_dig_io – Sherlock sends the pulse command to the hardware, and continues to the next
statement without waiting. The pulse delay count begins almost immediately.
set_dig_io – Sherlock sends a command to the hardware and continues to the next statement without waiting.
Clear the checkbox, and the value changes to “false”. Press Enter.
In the Main Window toolbar, click the Stop button. In the Image Window, move the ROI to an area that does not
contain any bright pixels, so the program fails. In the Main Window toolbar, click the “Run program
continuously” button. Observe the LEDs on the breakout board again. The LED for Out0 should be blinking, and
the LED for Out1 should be off. Notice also, in the Image Window the rectangle outline is red (fail).
In the System Window, click on Digital Input 0. The Configuration Window changes to an interactive way to
monitor the inputs. In the System Window, click on Digital Output 0. The Configuration Window changes to an
interactive way to monitor or set the outputs.
In this step, we create a routine that runs when the program is stopped, and sets both outputs to zero.
You can use onEvent_program_stop to set or clear IO and values, or finalize communications with peripheral
devices such as a PLC.
In the Save program window, change the Index to 2. Enter Tutorial3 in the Name field and enter Add Digital IO
in the Description field. Click on “OK” to save the program in BOA memory.
Repeat the Paste two more times, so you have four “set_number”
instructions.
Drag “varA” into the Program Window and drop it onto the “result”
output for instruction “set_numberA”.
Drag “varB” and drop it onto the “result” output for instruction
“set_numberB”.
Now all the variables are cleared when the program is loaded. You do
not have to clear the values before saving the program.
Expand Values
At the bottom of the Program Window, click on the “onPass” tab.
The variable value inside the square brackets gets evaluated or expanded into its number value in the string
result. The 0 forces no decimal point. You can specify any number of decimal places (display precision). If you do
not specify a number, the default precision is 2.
At the bottom of the Program Window, click on the “onFail” tab. In the Program Window right-click on
“add_numberB”. In the Instruction menu move your cursor to String and click on “expand_values” in the second
menu.
Note: You can also click on the “Advanced edit” button to open a
“String edit” window.
This window is resizable, and allows you to more easily enter longer
strings than the one in this example.
You can clear the Monitor Window messages at any time, by right-clicking in the Monitor Window.
In the Main Window menu bar, click on “View” and click on “watch”.
The Watch Window may appear as a tab at the bottom of the Properties
Window, and may be behind the Properties Window. If it is, click on the
tab to bring it in front. If the Watch Window appears somewhere else,
drag and drop the Watch Window onto the Properties Window.
You can drag any variable from the System Window into the Watch Window. You cannot drag variables, strings,
or numbers from the Program Window into the Watch Window.
When you deploy your program to your test group, you may wish to leave the Watch Window open and close
the Properties Window and other windows for a cleaner or simplified look.
The window layout is saved in a separate file. It is not saved in the program file. If the Watch Window is closed
by a user, loading or running this program will not automatically open the Watch Window.
In the Save program window, change the Index to 3. Enter Tutorial4 in the Name field and enter Initialize,
Expand Strings and Watch Window in the Description field. Click on “OK” to save the program in BOA memory.
Load a Program
In the Main Window, click the “Open program file” button, or use the menu bar.
The “Load program” window opens. The “Load programs” window allows you to select a program saved to the
BOA storage memory, and load it to the active program memory, so it can be run.
If you load Tutorial4, you can see that the numbers in the Watch Window are reset to zero. And if you click on
“Variables” in the System Window, you can see that the variables are also reset to zero. This shows that the
onEvent_program_load routine is working correctly to initialize all values.
Export Programs
In the Main Window click on “Program” in the menu bar. Click on “Export”.
The “Export programs” window allows you to save one or all programs stored in the BOA’s memory to your PC.
You can use this to copy programs to a second BOA, or archive your programs.
The default export location is shown above the OK and Cancel buttons. Use the Browse button to change the
location. The Client/Emulator will remember the new location for future Export and Import operations.
The default location uses a Windows environment variable for user application data. This translates to a
different location under Windows XP and Windows 7.
Import Programs
In the Main Window click on “Program” in the menu bar. Click on “Import”.
The “Import programs” window allows you to import Sherlock Embedded programs stored on the Client PC, into
the storage memory on the BOA smart camera.
NOTE: You cannot change the index numbers as you import programs.
You can change the index numbers before you import, by using Windows® Explorer to change the subdirectory
name/number. This will change the index number in the Import window, and in the BOA Pro program memory.