Sensor Conveyor Programming
Typically, two tasks are used to operate a sensor conveyor. One task waits for a part to trip the sensor and add it to the conveyor queue. The other task checks for parts in the Pickup Area of the conveyor queue. When parts are in the Pickup Area, the robot picks up the parts. Next, the robot places the parts picked up to the specified position.
This sample program automatically recovers when the robot tracks the parts that is out of the Pickup Area.
Function main
Motor On
Power High
Speed 30
Accel 30, 30
Xqt ScanConveyor 'Task that registers queues
Xqt PickParts 'Task that tracks parts (queue)
Fend
Function ScanConveyor
Double lpulse1 'Previous latch pulse
lpulse1 = Cnv_LPulse(1) 'Registers the latch pulse as lpulse1
Do
'Registers a part as a queue only when it passes the sensor
If lpulse1 <> Cnv_LPulse(1) Then
Cnv_QueAdd 1, Cnv_Point(1, 0, 0)
lpulse1 = Cnv_LPulse(1) 'Updates lpulse1
EndIf
Loop
Fend
Function PickParts
OnErr GoTo ErrHandler
Integer ErrNum
Cnv_Mode 1,1 'Selects the tracking mode
WaitParts:
Do
'Waits until a part (queue) enters the Pickup Area
Wait Cnv_QueLen(1, CNV_QUELEN_PICKUPAREA) > 0
'Starts tracking the part
'When using the SCARA robot
Jump Cnv_QueGet(1)
Wait 0.1 'The robot moves at the same speed as the conveyor for the Wait time specified to this part
Jump P1 'Moves the picked part to a specified place
Cnv_QueRemove 1, 0 'Clears the picked part (queue)
Loop
'Clears the parts (queue) in the downstream side from the Pickup Area
'Automatically recovers from the error '"The specified queue data is outside the set area"
ErrHandler:
ErrNum = Err
If ErrNum = 4406 Then
Cnv_QueRemove 1, 0
EResume WaitParts
'Displays an error other than "The specified queue data is outside the set area"
Else
Print "Error!"
Print "No.", Err, ":", ErrMsg$(Err, 1)
Print "Line :", Erl(0)
'User error occurred
Error 8000
EndIf
Fend