Troubleshooting
Catch a conveyor tracking error with an IError trap
Short answer
Event errors 50174 and 50221 are reported against the event log numbering, so IF ERRNO = 174 or 221 is dead code in a routine ERROR handler. Connect a TRAP routine and arm IError COMMON_ERR with error IDs 174 and 221; the trap drops the work object, deactivates the conveyor unit and sets a restart flag the tracking routine checks at its entry point.

On this page
A conveyor tracking event that stops the robot writes 50174 or 50221 into the event log, and an ERROR section that tests IF ERRNO = 174 OR ERRNO = 221 will never see them: the event log numbers and the routine error numbers are different lists. The catch that works is an arm-time trap — CONNECT a TRAP routine and arm it with IError COMMON_ERR at error ID 174 for the not-connected event and 221 for the past-max-distance event. The trap drops the work object, deactivates the conveyor unit and sets a restart flag the tracking routine checks before its next pick.
Why the routine ERROR handler never sees 174 or 221 #
RAPID keeps two error number lists apart. The ERRNO value an ERROR section compares is filled by errors raised inside the routine's own call chain. The conveyor tracking events come from outside that path: the tracking system raises them while a tracking move is running and reports them against the event log numbering. They stop the task and appear in the event log as 50174 or 50221; ERRNO in your routine never holds 174 or 221 for them. The handler can still run for other faults, but for these two events its branch is dead code.
The two events also mean different things, so the first check differs:
- 50174, work object not connected. A move was commanded on the conveyor work object with no conveyor connected behind it. Every tracking move must follow WaitWObj on an active conveyor unit; the failure mode of waiting for a connection that was never made is covered in WaitWObj waits forever when the tracking object is not connected.
- 50221, work object moved past the maximum distance. The work object passed the maximum tracking distance before the robot finished its move — the robot could not keep up. That is a capacity problem, the same timing family as conveyor tracking error during start and stop ramps.
What to check, cheapest first #
- Read the event log text, not just the number. The text of 50174 names a missing connection; the text of 50221 names a distance passed. That alone tells you which line below to work.
- Check the code order. Confirming check: step the program pointer at the fault and see whether it sits on a tracking move that ran ahead of WaitWObj on an active conveyor unit. That order mistake is the cause behind 50174.
- Time the cycle against the belt. For 50221, compare the time one pick needs with the time one part takes to cross the tracking window. Confirming check: run the belt at half speed — if the event disappears, the robot cannot keep up at production speed and the fix is speed or path, not code.
- Prove the handler is dead code. Log
ERRNOat the top of the ERROR section and let the event happen: it will not read 174 or 221, which confirms that no routine-level branch can catch these events.
The catch: connect and arm a trap #
IError is the arm-time error handler documented in the RAPID instructions technical reference manual: it arms a TRAP routine for one error number, and the armed trap interrupts the task wherever execution happens to be when that number is raised. Three rules make it work: CONNECT is only allowed inside a routine, the arming must run before tracking starts, and each event number gets its own IError line. The IDs are the event log numbers without the 50 prefix — 174 for 50174, 221 for 50221. If the trap is armed but stays silent, a walkthrough of IError traps that never trigger lists the arming mistakes behind it. For the syntax of the two mechanisms side by side, a comparison of the ERROR IF ERRNO handler with trap handler syntax covers when each applies.
Worked example: events 50174 and 50221 on conveyor CNV1 #
Inputs. Conveyor unit CNV1 and conveyor work object wobjcnv1, the names used in the build below; event 50174 (no conveyor connected) and event 50221 (work object moved past the maximum distance) from the event log; error IDs 174 and 221, the same numbers with the 50 prefix dropped; boolean bFelConv as the restart flag.
Rule. Arm the trap once, before tracking starts. On either event the trap drops the work object, deactivates the conveyor unit and sets the flag. The tracking routine checks the flag before it starts another pick; a set flag sends the routine back to its beginning instead of into the next move.
Build.
PROC initCnvTrk()
CONNECT nCnvTrackError WITH T_CnvTrk_Error;
! event 50174: work object not connected
IError COMMON_ERR\ErrorId:=174,TYPE_ALL,nCnvTrackError;
! event 50221: work object moved past max distance
IError COMMON_ERR\ErrorId:=221,TYPE_ALL,nCnvTrackError;
ENDPROC
TRAP T_CnvTrk_Error
DropWObj wobjcnv1;
DeactUnit CNV1;
bFelConv:=TRUE;
ENDTRAP
Keep the arming line in this form — domain COMMON_ERR, the \ErrorId value, then the trap name, with the middle argument left as written — because the domain and the ID together decide which event arms the trap.
One illustrative guard at the top of the pick loop — this part is my example of the check, not part of the documented pattern:
IF bFelConv THEN
bFelConv:=FALSE;
ReactUnit CNV1;
RETURN;
ENDIF
Trace. Start-up runs initCnvTrk once; both IDs are armed. Mid-pick, the work object passes the maximum distance: event 50221 fires, the trap interrupts the task, drops wobjcnv1, deactivates CNV1 and sets bFelConv. The pick loop reaches the guard, sees the flag, clears it, reactivates CNV1 and leaves the pass so the routine re-enters from its beginning — queue restart, WaitWObj, next pick. A 50174 event takes the identical path, so one trap serves both events.
Result. Either event costs one clean restart, the event log keeps the record, and the task never sits stopped on a half-finished tracking move.
Decision. Arm both IDs on every conveyor tracking cell and check the flag before every pick. If the event then fires every cycle, the trap is recovery, not capacity: slow the belt, shorten the path or give the pick more distance, and treat the trap as protection for the event that should be rare.
Making the restart safe #
Clear bFelConv at initialization as well, so a flag left set by an earlier session cannot send the first pick into a pointless restart pass. Reactivate the conveyor unit before the next WaitWObj — a tracking move with the unit still deactivated is the missing-connection condition behind 50174. And one safety line that belongs here: an automatic restart out of a trap is still a machine restart, so keep it inside the machine's risk assessment and behind the same guards and interlocks as a manual restart.
Questions asked
Can I catch event 50221 in the ERROR section by testing ERRNO against 221?
No. The routine ERROR section only receives numbers raised inside its own call chain, and the conveyor tracking system reports the max-distance event against the event log as 50221, so 221 never arrives in ERRNO. Arm it with IError and error ID 221 instead; the armed trap fires wherever the program was running when the event occurred.
Why does DropWObj inside my trap raise a new error?
The conveyor tracking application manual flags one case: dropping a conveyor work object while the robot is still inside the corner zone of the tracked zone is itself reported as an error. If the trap can run while the robot is still in the zone, let the trap set the flag only, and perform the DropWObj once the robot has stopped under control and left the zone.
The trap fires on event 50221 every few picks. Is that a working recovery?
It is a working recovery but not a fix. The event says the work object passed the maximum tracking distance before the robot finished its move, which is a capacity limit: belt speed, robot speed, tool time, or the distance between the queue sensor and the pick point. Adjust the speeds, shorten the path, or move the sensor further upstream, and treat the trap as protection for the event that should be rare.
Where does the CONNECT instruction have to sit?
Inside a routine. RAPID only allows CONNECT inside a routine body, so put the connection and the IError arming in an initialization routine that runs once before conveyor tracking starts. From that moment the armed trap can interrupt any routine in the task when one of the armed error numbers is raised.
