RobotStudio event

Unhandled error

Hi, in my program I'm trying to check whether robot picked a product and did not lose it during movement. I am doing this by TriggCheckIO - the trigger trigIOGrpFull is then activated in TriggL movement and when the signal does not have the right value program pointer moves into a trap tR2VacLost. Inside of the trap, I clear the robot path, which might cause an error, hence the error handler. I raise the error in trap and have the error handler in the procedure, where the TriggL movement is. However, I still get the error "40229: Execution error; Description: Task T_ROB2: Unhandled error."

I should probably mention, that the routine in which the TriggL instruction is is not the main routine and I'd rather do not have the error handler for this particular error in main. The controller for this robot is IRC5 6.15.

Here are parts of the code:

sCommon - a module in which I have a routine to initialize all traps and the trap tR2VacLost:

LOCAL PROC rInitTraps()
...
IDelete iCheckGrpFullIO;
CONNECT iCheckGrpFullIO WITH tR2VacLost;
TriggCheckIO trigIOGrpFull,80,GI_R2P_VacSensHigh,EQ,GInput(GI_REC_VacSecActive),iCheckGrpFullIO;
...
ENDPROC

TRAP tR2VacLost
        
        StopMove;
        !BookErrNo ERR_DROP_LOAD;
        bFailToPickProd:=TRUE;
        nR2PProdFailedIteration:=nR2PProdFailedIteration+1;
        ClearPath;
        StorePath;
        RestoPath;
        RAISE ERR_DROP_LOAD;
    ERROR
            RAISE;      
 ENDTRAP

sPick - a module in which I have a routine rPick:

TASK VAR errnum ERR_DROP_LOAD:=-1;

PROC rPick()
   BookErrNo ERR_DROP_LOAD;
   lblTryToPickR2:
   TriggL pR2PPick, vR2PFast, trigIntGripperPickProd \t2:=trigR2ReleasePusherCIPON \T3:=trigReduceAccValuePostPick, z0, tR2PCalcGripper \WObj:=wobjCIPCnv;
...
   TriggL Offs(pR2PPostPick1,0,0,-10), vMovement,trigIOGrpFull \T2:=trigR2ReleasePusherCIPOFF \T3:=trigIWatchILostVac,z50, tR2PCalcGripper \WObj:=wobjCIPCnv;

   IF bFailToPickProd GOTO lblTryToPickR2;

   ERROR (ERR_DROP_LOAD)
            StartMove;
            StorePath;
            TRYNEXT;
 ENDPROC

What should I do to get more or less the intended result without getting the Unhandled Error error?

Best Answer

  • zuz_7
    zuz_7
    Answer ✓
    After some digging I found out that PP moved too fast after the last instruction in rPick and it was already in a different (next) procedure. Handling the error in the following procedure helped.

Answers

  • lemster68
    lemster68 ✭✭✭
    A couple things here:  You are using Clearpath followed by StorePath and then RestoPath, but how can it do those two if you have already cleared the path?  I am not certain that is wrong, but intuitively it seems like it won't work.  The other thing, I always recommend that people use a TEST CASE for the error number in an error handler.  You have only allowed for what you think is the only error which could occur.  It is quite possible that there is another error which has occurred.  To catch this you should include a DEFAULT in your TEST CASE.  Use a program stop or break to stop execution.  At this point you should examine the value stored in the ERRNO system variable.  Then you match it to the predefined error numbers in the Errnum data.
    Lee Justice
  • I think using StorePath and RestoPath makes no difference, I tested my code without error handler and with those two commands and also without them - the result is the same. My Motion Pointer gets destroyed (no error raised). 

    I think the issue here is the RAISE instruction in the trap's error handler (or to be more clear, the jump from the trap's error handler into the rPick error handler).

    After raising the ERR_DROP_LOAD PP jumps into error handler in trap and the program outputs the error "Unhandled Error" once PP reaches the RAISE instruction (no matter whether the error handler in sPick specifies the error it refers to or not - I mean ERROR / ERROR (ERR_DROP_LOAD) ).