introduction to scorpion - demo 1- label on syringe page 1
TRANSCRIPT
Introduction to Scorpion - Demo 1- Label on Syringe Page 1
An introduction to Scorpionbased on
Demo 1 – Label on syringeScorpion 1.70
16. January 2003
Thor Vollset – TORDIVEL AS
Introduction to Scorpion - Demo 1- Label on Syringe Page 3
Label system description
• Scorpion Vision Software
• Industrial PC (IPC)
• One industrial camera
• Lighting
• Host Communication
Introduction to Scorpion - Demo 1- Label on Syringe Page 4
Task - Label
• Measure– Label position on syringe
• Resolution 1/100 mm
• Tolerance 5/100 mm
• Check – Position is between 3.6 and 3.85 mm.
Introduction to Scorpion - Demo 1- Label on Syringe Page 5
SetupImage shows syringe with label.
The syringe is illuminated with a diffuse lighting with a dark background. This reduces reflections and ensures edge contrasts.
To measure the label position it is necessary to constructs a reference line defined by the two edgepoints where the syringe starts to get smaller.
The image is captured with an industrial Sony b/w camera XC-75, 760 x 570 pixels and 256 gray levels
Introduction to Scorpion - Demo 1- Label on Syringe Page 6
Scorpion in Operation
Introduction to Scorpion - Demo 1- Label on Syringe Page 7
System Requirements
• Regional Settings– English US
Introduction to Scorpion - Demo 1- Label on Syringe Page 8
Operation Screen
• Operation consists of– Image with visualization
– Indicator panel
– State panel
– Web page – custom user interface• Statistics
• User configuration
Introduction to Scorpion - Demo 1- Label on Syringe Page 9
Label block diagram
Industrial VISION-PC SCORPIONVision Software
Set Mode capture Pass / Fail
TDVCmdProtocolRS-232
DataExport
csvfile
External VDUand Keyboard
Cam
era
PLCDisk
Introduction to Scorpion - Demo 1- Label on Syringe Page 10
Starting Scorpion
• Starting Scorpion is normally executed from the Scorpion program group
Introduction to Scorpion - Demo 1- Label on Syringe Page 11
Automatic start using a shortcut
• A shortcut is defined by setting the path:– ..\scorpion.exe system=<path>
• In the label demo the following is defined:– ...\scorpion.exe system=.\label
Introduction to Scorpion - Demo 1- Label on Syringe Page 12
Profile selection dialog
• If no path is specified on the Scorpion command line the profile selection dialog is activated
• The following operations is supported from the dialog: – Start profile
– Create / delete and copying of profiles
– Create shortcuts
Introduction to Scorpion - Demo 1- Label on Syringe Page 13
Creating label test profile
• Precondition– Scorpion 1.70 installed– Demo 1 – Label installed
• Create shortcut to Scorpion.exe• Create test profile
– Start Scorpion– Press New in profile selection dialog
• Name profile Test
– Select Default profile• Press Copy to transfer profile to test
– Start Test profile by pressing OK
Introduction to Scorpion - Demo 1- Label on Syringe Page 14
System logError messages and events are
collected in the System logThere are five levels of messages System log operation is supported
from a popup menu. It is an important source of
information under operation and configuration.
Hint 1 – If nothing happens or you do not understands what happens – take a look at the system log.
Hint 2 – It is always save to restart Scorpion. The profile is always persistent.
Introduction to Scorpion - Demo 1- Label on Syringe Page 15
Password protected profiles
• Scorpion has three modes of operation:– Operation
– Settings
– Service
• Password to service and settings are:– 911
– 1234
• Press Service– 911 OK opens Service Mode
Introduction to Scorpion - Demo 1- Label on Syringe Page 16
Service mode
• In service mode gives the user access to profile configuration
• Main modules are– General
– Scheduler
– Actions
– Toolbox
– Camera
– Communication
Introduction to Scorpion - Demo 1- Label on Syringe Page 17
Camera Setup – Service.Camera
• In this profile we grab images from a directory
– Camera driver is FireGrab.dll
• It is easy to switch from live camera to file
– File simulation is turn on/off by Image Settings.Simulate
Hint : Live video is also supported
Introduction to Scorpion - Demo 1- Label on Syringe Page 18
Camera Setup• Add a new camera
– Or choose an existing camera• Select grabber and port in Camera Setup
– Port must be unique• Select camera type
• ”Advance” opens the camera property pages– Documentation from camera vendor
Introduction to Scorpion - Demo 1- Label on Syringe Page 19
Camera Support• All cameras are activated from Device
Manager is available in Scorpion• WDM-Drivers and documentation is normally
provide by the camera vendor• Scorpion is based on DirectShow and support
all cameras with WDM-driver• Scorpion is tested with FireWire cameras
from Sony, Unibrain, Imaging Source in addition to web cameras from Logitech
Introduction to Scorpion - Demo 1- Label on Syringe Page 20
File simulation• Activate simulation under
service/camera/image settings• Press Edit to change simulation directory
– Set Image Name = Syringe– Directory selection – next page– A file filter is supported– Scorpion supports standard bitmap
files in simulation mode
Introduction to Scorpion - Demo 1- Label on Syringe Page 21
Choose simulation directory• Active Simulate under
Service.Camera.Image Settings• Press Edit
– Choose directory ... \Label\Images
– Press OK– Close Image Configuration
• Verify image directory by pressing Snapshot– Image of the Syringe is
shown on the left hand side of Scorpion
Introduction to Scorpion - Demo 1- Label on Syringe Page 22
Image operationsBy using the image menu on
can perform operation on the active image
The following operations are available by right clicking the mouse on an image
• Cursor position with intensity
• Distance measurement
• Copy/Store images with or without overlay graphics
• Image zoom
• Polygon construction
Introduction to Scorpion - Demo 1- Label on Syringe Page 23
Image processing - Toolbox• The image processing is defined under
Service.Toolbox• The image processing consists of a
sequential list of user created and configured tools.
• Scorpion has a number tool categories: – Basic, Data, Edge, Reference and
Advanced tools• All tools can be activated / deactivated
by the user or by using guards reflecting the image processing state
• A tool is connected to an image and a reference tool
Introduction to Scorpion - Demo 1- Label on Syringe Page 24
Help - Toolbox
• All tools has a Help button
• By pressing the help button context sensitive help is activated
Introduction to Scorpion - Demo 1- Label on Syringe Page 25
Image processing steps
Image processing typically divided in the following steps:
• Define reference system
• Declare external data
• Locate object
• Image Processing
• Classification
• Prepare data for host communication
Introduction to Scorpion - Demo 1- Label on Syringe Page 26
Creating the Reference System
• Activate Service.Toolbox.New to create MMReference of ScaleReference type
• Set x and y scale to 24.8
• Active Results tab– Set unit for pixel resolution to
mm by using the popup menu
Note that an image must be captured for Results.pixel resolution to be defined
Introduction to Scorpion - Demo 1- Label on Syringe Page 27
Defining the reference systemWith Scorpion reference systems are
defined with a family reference tools.
In the label case MMReference of type ScaleReference is used to transform pixels to mm.
With x and y scale of 24.8 the pixel resolution is 0.04 mm
Check MMReference.Results
The scalefactor was defined by using a ruler.
Introduction to Scorpion - Demo 1- Label on Syringe Page 28
External DataThe three tools Lowtolerance, Distance_Low and
Distance_High of type ExternalScalar
is set from the PLC using the user defined actions
Mode_Lowtolerance og Mode_Hightolerance
The data tools are later used to set boundary values for the corresponding Logic Tools
Distance Cannot Measure is defined to capture values obvious wrong
Introduction to Scorpion - Demo 1- Label on Syringe Page 29
Data Tools
• Active Service.Toolbox.New to create the following tools:
– ExternalScalar
• Distance_Low
• Distance_High
• Distance Cannot Measure
– ExternalLogic
• Low tolerance
Introduction to Scorpion - Demo 1- Label on Syringe Page 30
Limit valuesTwo modes are defined:
• Sample test – Lowtolerance
• Operation
Sample test limits are Low = 3.60 mm and High = 3.85 mm
Operation mode limits are Low = 3.40 and High = 4.00 mm
Distance Cannot Measure are 1.00 mm – The assumption is that all values less than 1.00 mm is erroneous and thus are
classified Cannot Measure
Introduction to Scorpion - Demo 1- Label on Syringe Page 31
Setup Distance_LowOpen Service.ToolBox
Update Distance_Low by selecting this tools and pressing Edit
Active the Setup tab
Turn on Make external changes permanent – Scorpion will remember this value after restart
Initial value to 3.40 This is the Operation Mode limit
Hint : Limit values for sample mode is set by user defined actions
Introduction to Scorpion - Demo 1- Label on Syringe Page 32
Define precision and unit The user defines a result’s precision
and unit manually by activating a tools results tab and right clicking the actual result.
Set Distance_Low precision to two decimals and the unit to mm.
Repeat the same for Distance_High and Distance Cannot Measure
For Lowtolerance set precision to 0 and unit to [bool]
Introduction to Scorpion - Demo 1- Label on Syringe Page 33
Setup External DataSet the following values::• Distance_High
– Initial value = 4.00 mm
• Distance Cannot Measure – Initial Value = 1.00
• Low tolerance – Initial Value = 1
– 1 means operation mode
Introduction to Scorpion - Demo 1- Label on Syringe Page 34
Backup of profile
• Activate Service.Maintenance
• Press Backup – Add comment
– Press OK
Hint : Profile Backup ensures simple restore of a working profile
Introduction to Scorpion - Demo 1- Label on Syringe Page 35
Locate syringeThe following steps are performed to locate the syringe:
• Calculates blob threshold with Lightmeter
• Finds course location of syringe with blob - FindSyringe
• Establishes SyringeReference using three edge finders:
– Left Edge
– Upper Left Edge and Upper Right Edge
Introduction to Scorpion - Demo 1- Label on Syringe Page 36
Locate Syringe - LightMeterActivate Service.ToolboxCreate LightMeter – IntensityTool.Set MMReference as reference.Using LightMeter an adaptive threshold
for the blob Find Syringe is calculated.
The LightMeter ROI is defined in a narrow band across the syringe.
The LightMeter’s 70 % percentil is a good candidate for the Find Syringe threshold.
Using this threshold makes Find Syringe robust to light variations.
The LightMeter’s ROI is in a narrow band across the syringe.
Introduction to Scorpion - Demo 1- Label on Syringe Page 37
Find Syringe Create Find Syringe – BlobTool.
Set MMReference as reference.
Find Syringe requires that the light area of the syringe is greater than 10 mm2.
The ROI is around the syringe. The size defines how large variation in syringe position the system can tolerate.
Hint : All values are in mm. This is defined by the reference MMReference
Introduction to Scorpion - Demo 1- Label on Syringe Page 38
Verify – Find Syringe• Verify
– Press Start• Check that Blob locates syringe on all images
– Press Stop to terminate
• Activate Find Syringe.Visualization – Turn off all elements except MaxContour and
Center Of Gravity
• Turn off Show graphics on LightMeter.Visualization
Hint : A tool can be examined in detail using Visualization – this only
Introduction to Scorpion - Demo 1- Label on Syringe Page 39
State – Syringe Present Create the Lag logic state Syringe
Present - LogicTool
Open Syringe Present and activate the Setup tab.
Add a new condition pressing NewSet Find Syringe.Total blob area
greater than 40 mm2.
Set Syringe Present to false if condition is undefined. In this case this means that Find Syringe has failed.
Introduction to Scorpion - Demo 1- Label on Syringe Page 40
Locate Syringe Using edge finders the upper left
edges of the syringe is located.
The following edge finder – LineEdgeFinderTool is used:
• Find Left Edge
• Find Upper Left Edge
• Find Upper Right Edge
Tracecomb Find Upper Left Edge
Introduction to Scorpion - Demo 1- Label on Syringe Page 41
Setup Find Left Edge
• Create a tool – LineEdgeFinderTool named Find Left Edge
• Set Find Syringe as reference– Press Apply
– Turn on visualizations – trace lines
– Activate Show Info – Image Menu
• Position mouse at left edge to find center of ROI
Hint – All values are in mm
Introduction to Scorpion - Demo 1- Label on Syringe Page 42
Advances setup LineEdgeFinderTool• Differentiation = 1
– This means that seek peaks where the derivative is at it’s maximum. This is robust and handles light variations.
• Smooth base and counter = 4 and 2– Means that the trace combs is filtered to
remove noise
• Fit-tolerance = 0,08– This means that all points used in the
curve fitting is in a band of 0.08 mm – approx 2 pixels
• Good-fraction = 12 points– This means that more than 12 of the
trace combs has edges for the fitted line to be accepted
Introduction to Scorpion - Demo 1- Label on Syringe Page 43
Verify Find Left EdgeActivate Find Left Edge.Results
Hint : Press Start and run live inspections – the results are updated continuously
• Check the Gradient against Setup.Threshold
– Gradient should be minimum 1.5 – 2 time the threshold
• Line-fit 0.0247 means that the points on the calculated line has a noise approximately half a pixel
– The edgeline has a greater accuracy than half a pixel
– The LineEdgeFinderTool has sub-pixel resolution
Introduction to Scorpion - Demo 1- Label on Syringe Page 44
Find Upper Right Edge• Activate Service.Toolbox• Select Find Left Edge• Open mouse menu
– Press Copy
• Open mouse menu– Press Paste
• Select Copy of Find Left Edge• Name Find Upper Right Edge
• Select Find Upper Right Edge– Press Edit
• Move Find Upper Right Edge ROI to the right side of the syringe – see image– Remember to rotate trace comb
Introduction to Scorpion - Demo 1- Label on Syringe Page 45
Finn Upper Left Edge
• Activate Service.Toolbox
• Select Find Upper Right Edge
• Open mouse menu– Press Copy
• Open mouse menu– Press Paste
• Select Copy of Find Upper Right Edge
• Name Find Upper Left Edge
• Select Find Upper Left Edge– Press Edit
– Move ROI to left side of syringe
Introduction to Scorpion - Demo 1- Label on Syringe Page 46
Locate – Reference Line• Create Reference Line -
LineFromPoints
• Reference Line is defined by the Find Upper Left and Find Upper Right Edge center points.
Introduction to Scorpion - Demo 1- Label on Syringe Page 47
Locate – Syringe ReferenceCreate Syringe Reference –
PointLineReferenceSet the reference to MMReferenceReference Line and Find Left Edge
defines a reference system that handles syringe rotation and translation. The rest of the image analysis benefits from this.
It is important that Reference Line is defined as the first tool in PointLineReference because the first points handles rotation.
Introduction to Scorpion - Demo 1- Label on Syringe Page 48
Syringe Width Create Syringe Width- LineEdgeCaliper
– Purpose measure width of syringe in mm
LineEdgeCaliper has two trace combs – see image. Select Syringe Reference as reference. Using Syringe Reference means that the tool is
relatively positioned and all parameters and results are in mm inherited from MMReference.
Set Trace line start and end point to 2 and 6 – remember to set the angle and threshold
Remember to set fit-tolerance in mm. A good starting point is 0.04 mm – equal to the pixel size.
Set number of trace lines to 21Set unit and precision of the width and line fit
results to mm and two and four decimals. Nominal width is 8.90 mm
Introduction to Scorpion - Demo 1- Label on Syringe Page 49
Measure label positionUsing two edge finders the left edge and the
left slope edge is found. The intersection of these lines defines where the syringe bends. The same applies to the right side of the syringe.
The two bends points is used to construct a Label Reference Line.
Using a blob Find Marker and an edge finder the upper edge of the upper marker is located precisely.
The label position is defined as the distance between the Label Reference Line and the Upper Marker Edge.
The distance is classified and is presented in mm i the state panel.
Introduction to Scorpion - Demo 1- Label on Syringe Page 50
Find Left SlopeCreate Find Left Slope –
LineEdgeFinderTool • Make a copy of Find Left Edge
• Paste Find Left Slope
Select Find Left Slope
Set Syringe Reference as reference
Activate image menu Show Info
Set ROI center and correct angle
Hint : By activating Visualization.Tracelines one can see where the trace comb hits the edge
Introduction to Scorpion - Demo 1- Label on Syringe Page 51
Find Lower Left EdgeCreate Find Lower Left Edge –
LineEdgeFinderTool • Copy Find Left Slope• Paste Find Lower Left Edge
Select Find Lower Left EdgeActivate image menu Show InfoSet new roi center and correct angleHint – Gradient is lower on this edge
and threshold must be lower on this tool. The edge detection can be improved by smoothing or increasing the number of trace lines.
Introduction to Scorpion - Demo 1- Label on Syringe Page 52
Right side edgefindersThe easiest way to configure Find Right
Slope and Find Lower Right Edge is to copy the corresponding left edge finders
After copying – Change ROI
• Center and angle– Turn on trace line visualization to
see where the trace comb is located– Verify edge polarity and threshold
Hint – When moving a copied tool it is very convenient to activate Visualization.this only
Introduction to Scorpion - Demo 1- Label on Syringe Page 53
Verify edgefinders
• Press Start – Verify that the edge finders located all edge for all test images
– On failure• Verify threshold and position
• The number of trace lines increases the image processing time but also the probability to locate an edge
Hint : By stopping the continuous inspection it is possible to select images from the history list and reprocess interactively until the edges are located. By pressing Inspection image processing is performed on user request.
Introduction to Scorpion - Demo 1- Label on Syringe Page 54
Construct intersectionsCreate Left intersection –
PointFromLines.
Select Find Left Slope.Line and Find Lower Left Edge.Line
Copy Left Intersection
Paste Right Intersection
Select Find Right Slope.Line and
Find Lower Right Edge.Line
Introduction to Scorpion - Demo 1- Label on Syringe Page 55
Marker Reference LineCreate Marker Reference Line
using LineFromPoints
Select Right Intersection and Left Intersection as points
The constructed line defines a zero position for the marker label.
The Marker Reference Line has to be constructed. It is not possible to measure due to missing contrast and varying reflection from the syringe.
Introduction to Scorpion - Demo 1- Label on Syringe Page 56
Locate label markerThe next step is to locate the
label marker.
This is done by using a Marker LightMeter and the blob Find Marker.
The blob threshold is set dynamically using a python script.
Introduction to Scorpion - Demo 1- Label on Syringe Page 57
Marker LightMeter Create Marker LightMeter of type
IntensityTool.
Set the reference to Syringe Reference.
Press Apply.
Active Marker LightMeter.Visualization.this only
Activate Image.Show Info to set the center of the lightmeter roi.
Verify that the lightmeter roi is placed on the syringe and handles both syringe rotation and translation.
Introduction to Scorpion - Demo 1- Label on Syringe Page 58
Find Marker ThresholdCreate Find Marker Threshold of type PythonScript
The Find Marker blob’s dynamic threshold is calculated using the following script:
min = GetTagValue('Marker LightMeter.Min');
#LightMeter.Min is a result of Marker LightMeter
SetTagValue('Find Marker Threshold.Value',min+25)
#Sets the threshold to itself
Hint : Activate Parameters
The parameter dialog is available to find the name of the results in the Scorpion tag database.
Introduction to Scorpion - Demo 1- Label on Syringe Page 59
Find MarkerCreate Find Marker of BlobTool
Set reference to Syringe Reference
Set the roi equal to Marker LightMeter
Set Area Search - thresholdsMinimum = 0
Maximum = Find Marker Threshold.Value
Set minimum area to 0.2 mm2
Verify that the marker is found for all images by pressing Start.
Introduction to Scorpion - Demo 1- Label on Syringe Page 60
Find Marker Upper EdgeCreate Find Marker Upper Edge –
LineEdgeFinderToolCopy Find Lower Right Edge
Paste Find Marker Upper Edge
Set reference to Find Marker
Set roi x and y to zero.
Activate Visualization.Show Graphics
Use Image.Show Info to select position and correct angle
Adjust and verify threshold for all test images
Verify that the upper edge is found by pressing Start.
Hint : Increase smooth base and count if the edge of the label is detected.
Introduction to Scorpion - Demo 1- Label on Syringe Page 61
Marker DistanceCreate Marker Distance –
NearestPointOnLine
Set reference to MMReferanse
Select Find Marker Upper Edge.Center to point and select Marker Reference Line.Line to line.
The marker distance is equal to the Marker Distance.Distance result.
The dimension is in mm given by the MMReference reference tool.
Set the unit and the precision for the Marker Distance.Distance result.
Introduction to Scorpion - Demo 1- Label on Syringe Page 62
Classification - StatesCreate the following LogicTools
• Distance High
• Distance OK
• Distance Low
• Cannot Measure
These tools defines the classification state.
Set external data tools, e.g. Distance_High, to set limits for MarkerDistance.Distance
State when undefined measured values is False for all states except Cannot Measure which is set to True
Classification states are important when defining system states and to show results in the indicator panel.
Introduction to Scorpion - Demo 1- Label on Syringe Page 63
Classification Verification
• Activate Operation.Results• Add the following results
– Distance OK.Value– Distance Low.Value– Distance High.Value– Cannot Measure.Value– Marker Distance.Value
• Press Start– Verify that only one state is true at the time– Verify that the state corresponds to the correct distance
Introduction to Scorpion - Demo 1- Label on Syringe Page 64
Definition of System States
• Scorpion States are defined under Settings
• The following states are defined:– Distance OK - green
– Distance Low - light red
– Distance High - red
– Cannot Measure - yellow
– No syringe - white
Introduction to Scorpion - Demo 1- Label on Syringe Page 65
Creating Distance OK• Activate Settings• Create Distance OK by pressing
New• Select Distance OK – press Edit• Set background color to green
– Click the Condition Colors and the color selection dialog appears
• Activate Constraints and set the following classification states– Distance OK– Syringe Present
Introduction to Scorpion - Demo 1- Label on Syringe Page 66
Defining states
• Copy Distance OK
• Paste– Distance High
– Distance Low
– Cannot Measure
• Edit – Colors and constraints
• Create the state No Syringe
Test the states and verify that no duplicate states are defined
Introduction to Scorpion - Demo 1- Label on Syringe Page 67
Label System States
Introduction to Scorpion - Demo 1- Label on Syringe Page 68
User Panels
• Scorpion has four user configurable panels for display of image processing results:– Indicator Panel
– State Panel
– Results
– Curves
Introduction to Scorpion - Demo 1- Label on Syringe Page 69
Configuration of Indicator/State Panels
• In service mode the indicator / state panel menu is available by right clicking the mouse
• The menu helps the configurer to configure the panels according to the task
Introduction to Scorpion - Demo 1- Label on Syringe Page 70
Display distance in State Panel
• Activate State Panel Menu– Select General.No of measured values
– Set No of measured values to 1
– Set General.caption = State
• Activate menu by clicking the value– Select Measured Value.Title = Distance
– Select Measured Value.Parameter = Marker Distance.Distance
– Select Measured Value .Decimals = 2
– Select Measured Value.Unit = mm
• Set font Condition to size=20 and bold
Introduction to Scorpion - Demo 1- Label on Syringe Page 71
Configure the Indicator Panel• Activate the Indicator Panel
– Activate Service.General– Turn on – Show Indicator Panel
• Activate Indicator Panel Menu– Set rows = 1– Set columns = 2
• Activate Indicator Panel Menu over column 1– Set title = Syringe– Set Color True = green– Set Color False = red– Set parameter = Syringe Present.Value
• Activate Indicator Panel Menu over column 2– Set title = Distance– Set Color True = green– Set Color False = gray– Set parameter = Find Marker.Distance
Introduction to Scorpion - Demo 1- Label on Syringe Page 72
Operation.Results• Active Operation.Results
• Press New and select a set of parameters
• To the right a selection of parameters are shown
Introduction to Scorpion - Demo 1- Label on Syringe Page 73
Operation.Curves• All results can be graphed and
watched• To the right the Marker Distance is
displayed• Activate the Curve Menu and
select parameter– The curve configuration is changed
by double clicking the curve.
Hint : The curve can only be edited in service mode.
Hint 2 : Watch the inspection cycle time is a good way to check the system condition
Introduction to Scorpion - Demo 1- Label on Syringe Page 74
Curve Setup – Marker DistanceHint : By capturing N images of a
syringe one can establish an estimate for the noise level of measurement by recording the standard deviation
Introduction to Scorpion - Demo 1- Label on Syringe Page 75
Communication
The Label profile communicates with a PLC over rs-232.
Scorpion is a slave of the PLC.
The text protocol TDVCmdProtocol is used. TDVCmdProtocol is a simple stateless packet protocol supported by Scorpion for both tcp/ip and rs-232.
Using Scorpion and TDVCmdProtocol ensures a very easy and flexible configuration of messages and commands.
Introduction to Scorpion - Demo 1- Label on Syringe Page 76
Preparing results for communication with PLC
Create Status of type LogicPack.
This tools packs the values of Cannot Measure and Distance OK into one status word
This word will be transferred to the PLC as a two binary status bits.
LogicPack packs classification states into words.
Introduction to Scorpion - Demo 1- Label on Syringe Page 77
Distance in 1/100 mm units
Create Result of type LinearScaleTool
Active Setup
Select Find Marker.Distance
Set Coefficient = 100
Set Offset = 0
Set the unit of Result.Value to 1/100 mm
Hint : The tool converts the distance to mm/100 – this means that the distance can be transferred as a integer value to the PLC
Introduction to Scorpion - Demo 1- Label on Syringe Page 78
Alias
• Scorpion has a cross index – Alias List – where tag value are given an alternative name
• Service.Advanced.Alias– Keeps this alias list
Hint : Alias is useful when reducing the length of a command and to hide the internal tag name.
Introduction to Scorpion - Demo 1- Label on Syringe Page 79
Communication Aliases
• Create the following Aliases: – Distance = Result.Value
– Status = Status.Value
Introduction to Scorpion - Demo 1- Label on Syringe Page 80
Command sequence and StatesTo every State there is a command
sequence.
Command Sequences are very handy when communicating with a robot or plc.
A command can be defined by the system or by the user.
There is a help page for every system command.
To the right is the help page for SetValue shown.
Introduction to Scorpion - Demo 1- Label on Syringe Page 81
Distance OK – Command Sequence
Activate Settings– Select Distance OK– Press Edit– Activate Command Sequence– Press New
• Set name = Send result• Set command = RS232Cmd• Set Parameter =
Result=%3.0fDistance;Status=%2bStatus• Press OK
– Press Activate– Activate Service.Communication.RS232
• Verify log• <stx>Result=382;Status=01<stx>
Introduction to Scorpion - Demo 1- Label on Syringe Page 82
Command Sequences for Distance Low and Distance High
Copy the Command Sequence from Distance OK to Distance Low and Distance High.
Press Start and verify Service.Communication.RS232 displays a kommand for each inspection and that the results are changing
<stx> result=386;status=11<etx>
No message is sent if no value is measured There is no command sequence connected to Cannot Measure or No Syringe
Hint : By replacing RS232Cmd by IMCmd the message are transmitted over tcp/ip. To Scorpion it is transparent to use RS232 or tcp/ip. OPC is supported with a corresponding set of commands.
Introduction to Scorpion - Demo 1- Label on Syringe Page 83
PLC communication sequence
1. CameraTrigger – sent from PLC to Scorpion• CameraTrigger captures an image and performs an inspection before classifying
the determining the system state
• Send result – Scorpion’s answer to CameraTrigger
• Distance and status is sent - <stx>Distance=387;Status=00<etx> • Distance is given i mm/100
• Status are Pass / Failure and Cannot Measure
The PLC can change the mode of operation by sending the commands, at any time, to Scorpion:
• Mode_Lowtolerance
• Mode_Hightolerance
Introduction to Scorpion - Demo 1- Label on Syringe Page 84
Action – Before Start• Activate Service.Actions• Press Action.System Events.New
– Select Before Start• This is event is called before automatic inspection is started. This happens when is
pressed.
– Select Before Start– Press Action.Command Sequence .... .New
• Set – name = LogMsg– Command = LogMsg– Parameter = msg=Starts profile
• Press Ok
– Select Before Start – Press Execute• Verify system log
Hint : Before Start is an event defined by Scorpion.
Introduction to Scorpion - Demo 1- Label on Syringe Page 85
Action – After Stop
• Create system event After Stop
• Add LogMsg – Stops Profile
Hint : LogMsg is a command that can be used to verify command sequences and to check task time consumption
Introduction to Scorpion - Demo 1- Label on Syringe Page 86
Actions – System EventsThe following system events are active:
• Before start
• After stop
• Image grab
• After Image Acquisition
• Inspection
• CameraTrigger
Introduction to Scorpion - Demo 1- Label on Syringe Page 87
Changing Mode of Operation
• The PLC sends the user-defined commands:– Mode_Lowtolerance –
activates operation mode
– Mode_Hightolerance – activate sample mode
• The commands are specific to the label profile and are define under Service.Actions.System Events
Introduction to Scorpion - Demo 1- Label on Syringe Page 88
Mode_Lowtolerance• Activate Service.Actions• Press Actions.System Events.New
– Define Mode_Lowtolerance– Select Mode_Lowtolerance
• Press Actions.Command Sequence ... .New– Set
• Name = Operation mode• Command = SetValue• Parameter =
Distance_Low.Value=3.4;Distance_High.Value=4.0;LowTolerance.Value=1
• Press OK• Test by pressing Execute
Introduction to Scorpion - Demo 1- Label on Syringe Page 89
Mode_Hightolerance• Activate Service.Actions• Press Actions.System Events.New
– Define Mode_Hightolerance– Select Mode_Hightolerance
• Press Actions.Command Sequence ... .New– Set
• Name = Set Sample Mode• Command = SetValue• Parameter =
Distance_Low.Value=3.6;Distance_High.Value=3.85;LowTolerance.Value=0
• Press OK• Test by pressing Execute
Introduction to Scorpion - Demo 1- Label on Syringe Page 90
Testing Mode CommandsActivate Service.Advanced.Results
– Add the following results• Distance_Low.Value
• Distance_High.Value
• Lowtolerance.Value
Activate Service.Actions
– Select Mode_Lowtolerance
– Press Execute• Verify Service.Advanced.Results
– Select Mode_Hightolerance
– Press Execute• Verify Service.Advanced.Results
Hint – Check systemlog for error messages
Introduction to Scorpion - Demo 1- Label on Syringe Page 91
Custom Statistics• Using Python Scripts and external data tools any requirement for
statistics can be met with Scorpion• Create the tools – External Scalar with Make external changes
permanent On– Error– OK– Total
• Add the following Aliases under Service.Advanced.Alias– Error = Error.Value– OK = OK.Value– Total = Total.Value
Introduction to Scorpion - Demo 1- Label on Syringe Page 92
Statistics - ScriptCreate Statistics – PythonScript.Open Statistics.Setup and add the right
hand side script.
The script adds simple operation statistics. The script has four steps:
– Read counters– Get the inspection result– Update counters– Write counters
Hint : All values are available using Scorpion’s command interface
Hint 2 : Check System Log to see any script error messages
#Read Countersok_count = GetTagValue('OK')total_count = GetTagValue('Total')error_count = GetTagValue('Error')
#Get Inspection Stateok = GetTagValue('Distance OK.Value');
#Update countersif (ok): ok_count = ok_count+1else: error_count = error_count+1total_count = total_count +1
#Write countersSetTagValue('OK',ok_count)SetTagValue('Total',total_count)SetTagValue('Error',error_count)
Introduction to Scorpion - Demo 1- Label on Syringe Page 93
Statistics - Zero
• Activate Service.Actions
• Add System Events– Name = Zero
• Select Zero Statistics– Add new command
• Name = Zero statistics
• Command = SetValue
• Parameter = OK=0;Feil=0;Total=0
Hint : The command requires that the OK, Error and Total aliases are defined.
Introduction to Scorpion - Demo 1- Label on Syringe Page 94
Test – Zero Statistics
• Activate Service.Advanced.Results– Add OK.Value, Error.Value
and Total.Value
• Start inspections– Verify results as they are
updated
• Execute Zero Statistics– All counter are zeroed
• Stop inspections
Introduction to Scorpion - Demo 1- Label on Syringe Page 95
Custom User Interface
The following function are implemented:
• Operation Mode selection
• System Description
• Operation Statistics
The user interface is implemented using standard web pages and ActiveX controls.
The ActiveX controls are a part of the Tordivel Software Solutions.
Introduction to Scorpion - Demo 1- Label on Syringe Page 96
Internet Messenger 4.5
InternetMessenger is used to send text to and from Scorpion over tcp/ip.
This is easy and the recommended way to communicate with Scorpion.
InternetMessengers properties are configured using FrontPage
Introduction to Scorpion - Demo 1- Label on Syringe Page 97
Activate the web page• Open Windows Explorer
– Easy to do from Service.Advanced.General
• Go to directory .\Label• Copy the directory .\label\web • Paste the directory to .\test\web• Activate the Web Page under
Service.General– Activate
• Show Webbrowser in Operation
– Set caption = Description– Set page index to 1– Open Settings
• Set directory to .\Test\Web\Setup.htm
Introduction to Scorpion - Demo 1- Label on Syringe Page 98
Connecting a web page to ScorpionScorpion has a Internet Explorer
Browser insideWeb pages can be displayed by
the web browserIn a web page can contain scripts
and ActiveX controls. Scorpion and the webpage is
connected using the ActiveX control Internet Messenger.
Commands and messages uses the TDVCmdProtocol format.
TDVCmdProtocol is the Scorpion command-language
Scorpion
Web Page
InternetMessengerActiveX
tcp/iptdvcmdprotocol
VBScriptmethods / events
Introduction to Scorpion - Demo 1- Label on Syringe Page 99
ActiveX Components
The following ActiveX components from Tordivel Software Solution is used in the example:
• InternetMessenger4
• SimpleStat2X
• TDropDownList
• TButtonX
Microsoft Frontpage can be used to edit the web pages.
Introduction to Scorpion - Demo 1- Label on Syringe Page 100
VBScript in HTML• On the following pages the vb script driving the web page shown. This is only for
reference.
• The web page talks with Scorpion using the ActiveX InternetMessenger.
– In the event InternetMessenger_Receive messages is received from Scorpion
– The methods InternetMessenger.Send sends commands / requests to Scorpion
• The following Scorpion Scorpion actions are called from the web page:– Zero Statistics
– Mode_Lowtolerance
– Mode_Hightolerance
– SendSetup
• The webpage accepts the following messages from Scorpion:– Statistics
– Setup
Introduction to Scorpion - Demo 1- Label on Syringe Page 101
Create SendSetup in Scorpion
• Activate Service.Actions
• Create new system event– SendSetup
• Select SendSetup
• Create new command– Name = Send Setup
– Command = ImCmd
– Parameter =• destination=localhost:8701:
• Setup;
• Lowtolerance=%0.0fLowtolerance.Value;
Note : Parameter must end with ; for the web page to parse the command
Hint : ImCmd can send message to many tcp/ip servers over tcp/ip
• destination=<ip-addr>:<port> means that the command is sent directly to the specified adress – port number combination
Verify command transmittal in Service.Communication.TCP/IP
Introduction to Scorpion - Demo 1- Label on Syringe Page 102
Create SendStatistics
• Activate Service.Actions
• Create new system event– SendStatistics
• Select SendSetup
• Create new command– Name = Send Setup
– Command = ImCmd
– Parameter =• destination=localhost:8701:
• Statistics;
• OK=%0.0fOK;Error=%0.0fError;Total=%0.0fTotal;
Verify command transmittal in Service.Communication.TCP/IP
Webside requires that the Statistics message is terminated by a ;
Introduction to Scorpion - Demo 1- Label on Syringe Page 103
Maintain Actions• Add the following commands:
– Zero Statistics in Before Start• Zero statistics for each Start
– SendStatistics in Zero Statistics• Updates web page when statistics are
zeroed
– Statistics;cmd=zero in Before Start
• Zeros state statistics
• Press Start – Verify Operation Statistics on web
page is zeroed
• Activate Operation.Statistics– Check that period is zeroed
Introduction to Scorpion - Demo 1- Label on Syringe Page 104
TCP/IP Communication Log
The log Service.Communication.TCP/IP shows the complete dialog n between Scorpion and the web page.
Hint : It is possible to activate logging to file. This is useful to provide documentation.
Introduction to Scorpion - Demo 1- Label on Syringe Page 105
Get Setup when loading web page
The Scorpion setup is request when loading the web page. The answer from Scorpion is to send the Setup message.
sub init_web_page()
InternetMessenger.Send "SendSetup"
end sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 106
Receive messages from Scorpion
This method decodes all messages from Scorpion. Tow messages are defined: Setup and Statistics
sub InternetMessenger_Receive(From,Command)
SendDebugMessage(Command)
pos = InStr(1,Command,"Setup")
if (pos=1) then
ProcessSetup(Command)
end if
pos = InStr(1,Command,"Statistics")
if (pos=1) then
ProcessStatistics(Command)
end if
end sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 107
Update Statistics
ProsessStatistics updates the SimpleStatX counters with counter from the Statistics message – Statistikk;Error=2;OK=10;Total=12;
sub ProcessStatistics(Command) SendDebugMessage(Command) str0 = Mid(Command,11) pos = InStr(str0,";") Do While pos ' Inner loop. str1 = Mid(str0,1,pos-1) pos1 = InStr(str1,"=") if (pos1) then name = Mid(str1,1,pos1-1) value = Mid(str1,pos1+1) SendDebugMessage(name + "-" + value) SimpleStatX.Set name,value end if str0 = Mid(str0,pos+1) pos = InStr(str0,";") Loopend sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 108
Custom counters - SimpleStat2X
SimpleStat2X is a simple way to include custom counters on a web page.
SimpleStatX relies on Scorpion holding statistics counter and sending them to the web page
– SendStatistics
Zero Statistics is sent when the user pushed the Zero button
Zero is an ActiveX - TDVButtonX
Introduction to Scorpion - Demo 1- Label on Syringe Page 109
Update Operation ModeProsessSetup decodes the Setup message – Setup;Lowtolerance=1;sub ProcessSetup(Command) str0 = Mid(Command,5) pos = InStr(str0,";") Do While pos str1 = Mid(str0,1,pos-1) pos1 = InStr(str1,"=") if (pos1) then name = Mid(str1,1,pos1-1) value = Mid(str1,pos1+1) SendDebugMessage(name & "-" & value) if ( name = "Lowtolerance" ) then if (value=0) then Mode.ItemName="Sample" else Mode.ItemName="Operation" end if end if end if str0 = Mid(str0,pos+1) pos = InStr(str0,";") Loopend sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 110
User changing Operation ModeMode_OnChange is called when the user changes the list
control – selects an new Operation Mode.
In addition the Statistics are Zeroed sub Mode_OnChange(ItemName) if (ItemName = "Operation") then SetLowTolerance() Zero() else SetHighTolerance() Zero() end ifend sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 111
Set the Operation Mode
Operation Mode is changed in Scorpion by sending the commands: Mode_Hightolerance or Mode_Lowtolerance
sub SetHighTolerance()
InternetMessenger.Send "Mode_Hightolerance"
end sub
sub SetLowTolerance()
InternetMessenger.Send "Mode_Lowtolerance"
end sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 112
Send Zero Statistics The Zero_OnClick event is executed when the user click the
Zero button.
sub Zero_OnClick()
Zero()
end sub
sub Zero()
InternetMessenger.Send "Zero Statistics"
end sub
Introduction to Scorpion - Demo 1- Label on Syringe Page 113
SendDebugMessagessub SendDebugMessage(text)
InternetMessenger.Send "destination=localhost:7700:" & text
end sub
/ to the right the test program – IMTdvCmdProtocol5 is shown receiving messages under test
/ Note the receiving port number = 7700
Introduction to Scorpion - Demo 1- Label on Syringe Page 114
Curves - System.Analysis time
• Using Curves and System.Analysis time it is easy to verify the time used
• Mean value = 27.15 ms on a portable P4 – 2GHz CPU
• This means that it is easy to do more than 10 inspections/second
Introduction to Scorpion - Demo 1- Label on Syringe Page 115
Summary Label on Syringe
• Scorpion solved this task by using it’s robust and good edge tools.
• The edges where detected with a sub-pixel resolution of 5 micrometer.
• The lines detected are intermediate results but ensures that the label position is measured with at 3 sigma tolerance better than 0.06 mm – this is very good.
• This means that the customer’s expectations are met without any programming.
Introduction to Scorpion - Demo 1- Label on Syringe Page 116
Conclusion
This example show some of the possibilities with Scorpion Vision Software and integrated model for implementing
optical gauging and robot guiding systems.
Scorpion is a tool to
configure, operate and maintain vision systems.
Introduction to Scorpion - Demo 1- Label on Syringe Page 117