RobotStudio event

Trap routine not executing

csmith
csmith
edited January 2020 in RAPID Programming
Hi, 

I want to setup a trap routine to execute when the robot runs into a Motion Error.
In my motion task, I'm setting up the interrupt and tying it to a DO;
<div>PROC SetupInterrupts()
     IDelete intOverride;
     CONNECT intOverride WITH tOverride;
     ISignalDO errorsig, 1, intOverride;
     TPWrite "Interrupt Setup";
ENDPROC</div>

This is my TRAP:
<div>TRAP tOverride
    ISleep intOverride;
    CONST jointtarget homepos:=[[0,10,20,30,40,50],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
    TPWrite "Interrupt fired";
    MoveAbsJ homepos,v100,fine,tool0;
    IWatch intOverride;
ENDTRAP</div>

VAR intnum intOverride:=0
is defined in my System Module


You can see, I want to move to a safe home position in case we get a Motion Error. 
In my main() I ultimately call an EGMRunPose and have the robot controlled by an EGM data-stream.
Once the robot get's into a singularity, Dynamic load too high or joint out of range error, I can see the DO toggle,
but I'm getting a 40210 - Interrupt removed from queue error, which means the TRAP routine won't run.  

What am I missing?


Thank you

Tagged:

Comments

  • It seems like a TRAP is only executing if the Program is running.
    Am I out of luck after a Motion Error which stops the program execution and turns off the motors ? 
    How can I recover from a situation like that? Just turning Motors back on doesn't seem to work as I immediately trip the same error again.
    Right now I have to go to Manual mode, jog out of the Singularity/Joint out of range, go back to automatic and restart.
    This works but I was hoping there is a more elegant solution. 

    Thanks
  • You are correct the program has to be running to execute an interrupt.

    You need to catch the error (if it is a recoverable error) in an error handler at the end of the executing procedure/routine.

    I could not find an errnum (error number) for singularity, but for joint out of range it is ERR_ROBLIMIT (yes the errnum is text not a number!) - but instead of trying to trap an individual error you could just respond to any error and return the robot to the home position as per your trap routine code above.

    There is help on error handlers in the RAPID overview manual under the basic programing chapter->error recovery. 

  • EricH
    EricH
    edited January 2020
    Or you check in a background task for the state of that output signal and try to handle it there. Of Course you can not move the robot from a background task, but you can handle signals for example.

    For example, resetting the error by signal (system input and cross connection) and then call an interrupt by signal.