The following is a sample GPL conveyor-tracking program. It assumes that parts will come down the conveyor and pass a sensor that sets a digital input signal. When each part is in range, this program will move the robot from a safe position, through an approach position, to a position just above the part. The system will dwell for 1 second and track the part on the moving conveyor. The robot will then return to the safe location until the next part is detected.
This sample program includes the manual teaching of all positions and a continuous loop that automatically tracks any parts that come down the conveyor. If required, the accuracy of the part position could be improved by utilizing encoder latching instead of the simple signal polling method that is employed.
To execute this procedure, perform the following steps.
The following is the complete sample program. No global data need to be defined for this program.
Public Sub MAIN
Dim belt1 As New RefFrame
Dim loc1 As New Location
Dim safe As New Location
Dim pf1 As New Profile
Dim msg As String
Dim btn_idx As Integer
Const PART_PRESENT As Integer = 10001' Part sensor DIO signal
Const CNV_ROB As Integer = 2 ' Robot #2 is the conveyor
belt1.Type = 2 ' Conveyor reference frame
belt1.ConveyorRobot = CNV_ROB ' This is the conveyor robot
loc1.RefFrame = belt1 ' loc1 is belt relative
loc1.ZClearance = 25.4
pf1.Speed = 20 ' Move slow
pf1.Straight = True ' Must be Cartesian motion
' Manually define part location relative to the belt.
While (Not Signal.DIO(PART_PRESENT))' Wait till part comes down
Controller.SleepTick(1)
End While
belt1.ConveyorOffset = Robot.WhereAngles(CNV_ROB).Angle(1)
msg = "Stop the conveyor when the part is in range of the "
msg &= "robot. Position robot over the part and press Teach."
Controller.Showdialog("Teach", msg, btn_idx)
loc1.Here ' Record belt rel position
' Automatically track a series of parts on the conveyor.
msg = "Move robot to a safe position. Send parts down the "
msg &= "conveyor and press Go to momentarily track each part."
Controller.Showdialog("Go", msg, btn_idx)
Robot.Attached = 1
safe.Here ' Record safe location
While True
While (Signal.DIO(PART_PRESENT))' Wait until no part
Controller.SleepTick(1)
End While
While (Not Signal.DIO(PART_PRESENT))' Wait until next part
Controller.SleepTick(1)
End While
belt1.ConveyorOffset = Robot.WhereAngles(CNV_ROB).Angle(1)
Move.Approach(loc1,pf1) ' Go touch the part
Move.Loc(loc1,pf1)
Move.Delay(1) ' Demonstrate tracking
Move.Approach(loc1,pf1) ' Back to safe position
Move.Loc(safe,pf1)
End While
End Sub