Create the PF_Robot Callback Function
In the PF_Robot callback function, you describe the operations by which the robot picks and places the parts. This function executes the following steps. (Steps 1 through 7 are repeated in a loop.)
- Retrieve the coordinates of parts on the platform from the parts coordinates queue.
Use "PF_QueGet". - Move the robot to the part position.
Use Jump or similar commands. (For SCARA robots) - Turn suction on, or grip the part using some other method.
- Move the robot to the position where the part will be placed.
Use Jump or similar commands. (For SCARA robots) - Turn suction off, or release the part using some other method.
- Delete one data entry in the parts coordinates queue.
Use "PF_QueRemove". - Check whether a stop command has been issued. If it is issued, leave the loop.
Use "PF_IsStopRequested". - It returns PF_Robot = PF_CALLBACK_SUCCESS.
The following is a sample PF_Robot callback function.
As the handling of a loop and steps 1, 6, 7 are described in automatically generated PartFeeding.prg, this sample describes the handling of the rest of the steps.
The labels used in this program are as follows:
IO label: Chuck (grip part by suction), UnVacumm (release part)
Point label: PlacePos (Place coordinate)
Function PF_Robot(partID As Integer) As Integer
Do While PF_QueLen(partID) > 0
' Pick
P0 = PF_QueGet(partID)
Jump P0 ! Wait 0.1; Off UnVacumm !
On Chuck
Wait 0.1
' Place
Jump PlacePos
Off Chuck
On UnVacumm
Wait 0.1
' Deque
PF_QueRemove partID
' Check Cycle stop
If PF_IsStopRequested = True Then
Exit Do
EndIf
Loop
Off UnVacumm
PF_Robot = PF_CALLBACK_SUCCESS
Fend