PF_Vision
This is used when the user wishes to program image capture processes (light control, using vision system, SPEL program processing). This is also used when it is difficult to detect parts and determine orientation (side facing, etc.) with vision system alone. To use this function, select "User processes vision for part via PF_Vision callback" in Epson RC+ 8.0 Menu - [Tools] - [Part Feeding] - [Vision].
Syntax
Function PF_Vision(part ID As Integer, ByRef NumBack As Integer) As Integer
'(Vision processing)
Fend
Parameters
- Part ID
The part ID (integer number from 1 to 32) goes here.
When multi-part operation, the active part goes here. - numBack
Assigns the number of parts that cannot be picked up (facing down, etc.). (ByRef is specified)
This value is used by the Part Feeding process to determine whether flipping is required.
Enter "0" if the part does not have defined sides.
Return values
To continue processing, set the return value to PF_CALLBACKSUCCESS.
To perform error processing, set the return value to a user-defined error number (8000 - 8999).
This value is passed back as a PF_Status callback function parameter.
Description
This function is used when using combinations of multiple vision sequences and external lighting controls to detect parts coordinates. The following processes are to be described by the user.
- User lighting controls
- Vision processing (running the VGet statement)
- Parts coordinates queue management (initialization and registering point data)
Program Example
The following example describes a program detecting parts using two vision sequences, VSeq1 (including one Geom object) and VSeq2 (including one Geom object). VSeq1 is used with the user lighting 1. This can detect the position of parts, but cannot determine their orientation. VSeq2 is used with the user lighting 2, and can only detect parts facing up.
The coordinates of detected parts (local number 1 in this example) are added to the coordinates queue with the PF_QueAdd command. When doing so, the value obtained in following is assigned as the Z coordinate.
Teach Window
To enable flip, see below.
General
Specify VSeq2 for [Part Vision Sequence] and turn on User lighting 2. Refer to the following for further details.
Vision
Run the flip calibration. Refer to the following for further details.
Calibration
' ** IO Label (Output) **
' O_FrontLight1 User lighting 1
' O_FrontLight2 User lighting 2
Function PF_Vision(partID As Integer, ByRef NumBack As Integer) As Integer
Boolean found
Integer i, numFound
Real PX_X, PX_Y, PX_U
Real RB_X, RB_Y, RB_U, RB_Z
' Pick Z coordinate
RB_Z = -80.0
' Initialize coordinates queue
PF_QueRemove partID, All
' Turn on the user lighting 1
On O_FrontLight1
' Detect part (run UsrVisionSeq1)
VRun VSeq1
VGet VSeq1.Geom01.NumberFound, numFound
' Turn off the user lighting 1
Off O_FrontLight1
' Turn on the user lighting 2
On O_FrontLight2
numBack = 0
For i = 1 To numFound
' Retrieve XY pixel coordinates for part detected with VSeq1.Geom01
' Set the VSeq2.Geom01 search window to cover this part
' Part size = 100× 100 × l
VGet VSeq1.Geom01.PixelXYU(i), found, PXX, PXY, PXU
VSet VSeq2.Geom01.SearchWinLeft, (- 50)
VSet VSeq2.Geom01.SearchWinTop, (- 50)
' Run VSeq2
VRun VSeq2
VGet VSeq2.Geom01.Found, found
If found = True Then
' If found, register to the coordinates queue as the part is facing up
' Local number is 1
VGet VSeq1.Geom01.RobotXYU(i), found, RB_X, RB_Y, RB_U
PF_QueAdd partID, XY(RB_X, RB_Y, RB_Z, RB_U) /1
Else
' If not found, part is facing down
numBack = numBack + 1
EndIf
Next
' Turn off the external lighting 2
Off O_FrontLight2
PF_Vision = PF_CALLBACK_SUCCESS
Fend