RobotStudio event

Raise an Error from TRAP

MNeuer
MNeuer
edited November 2016 in RobotStudio
Hi to all,

I  have developed next script in order to modify by fliying the speed. As I am using an old robot version I have no "speedrefresh" and I have realized that I can not refresh speed value using "velset" if I do not make again a new one MOVEL. 

Proc MOVEMENTS
   init_TRAP;
   MOVEL()
   ERROR
       VELSET();
       RETRY;
ENDPROC

Proc init_TRAP
    ConectSignals; !Conect analog signal from sensor with trap.
ENDPROC

TRAP trp_func
    RAISE Err_move_stop;
    ERROR
          RAISE;
ENDPROC


What I get in pendant is an error which tells me about unhandled error. Following the procedures structure Error should be raise to Movements procedure is it?.

Thanks in advance.
Manuel,

Comments

  • Hello, did you have an answer? I'm looking for that too.

    ☑️2024 - RobotStudio® User Group

  • lemster68
    lemster68 ✭✭✭
    Try this:  remove the error from your trap, in the trap add StopMove, ClearPath, then Velset, Then Retry.
    Lee Justice
  • DenisFR
    DenisFR ✭✭✭
    Hello,
    What I've wanted, was to raise an error in a TRAP.
    Because TRAP is on a NOVIEW module that an other call and catch error.


    ☑️2024 - RobotStudio® User Group

  • lemster68
    lemster68 ✭✭✭
    Is it NoStepIn also?  RAISETOUSER may be of use to you then.
    Lee Justice
  • DenisFR
    DenisFR ✭✭✭
    Yes, but doesn't works too.

    ☑️2024 - RobotStudio® User Group

  • lemster68
    lemster68 ✭✭✭
    MNeuer said:

    What I get in pendant is an error which tells me about unhandled error. Following the procedures structure Error should be raise to Movements procedure is it?.

    Thanks in advance.
    Manuel,

    From the Rapid reference manual:
    If the RAISE instruction is present in a trap routine,the error is dealt with by the system’s error handler.

    It seems that this is your unhandled error, because it won't be dealt with by the PROC Movement's error handler.
    If you add the error handler to your Main with a retry, I believe it should retry the procedure call which generated the error, Movements.

    Lee Justice
  • Hi, Your error handler must have code to deal with the error especially if it is one you have created, e.g.


    TRAP trp_func
        RAISE Err_move_stop;
        ERROR

    IF ERRNO=Err_move_stop THEN

    !do code to handle the error

    ENDIF
              RAISE; !only raise if a higher level error handler has code to handle the error or if the error is not Err_Move_Stop and you want to see it's error message
    ENDPROC

  • I have the same problem, someone have any idea?

    from spain, thx.

  • Hi Enriquetracker

    The solution is to use "error recovery with long jump".
    It sounds like a fancy term but it is just explicitly stating any errors you want to catch that you have raised from a trap routine. 

    Here is a basic example, check out the code below, the key is the brackets next to the ERROR statement:

    Any error numbers listed in brackets next to the ERROR statement are handled in that error handler, up to any amount you like, e.g. ERROR(ErrNum1, ErrNum2, Errnum3)  etc. 

    This is primarily used to handle errors that occur in trap routines at specific levels of execution. An interrupt could occur anywhere in the code and raise an error, so this just provides a way of catching them in specific places. For some more info and examples see: Technical reference manual - System parameters, section Basic Characteristics - Error Recovery, page 47.
    VAR intnum in_Interrupt;
    VAR errnum en_Interrupt := -1;
    
    PROC Main()
        RoutineA;
    ENDPROC 
    
    ! Procedure to set up an interrupt
    PROC RoutineA()
        ! Book the error number to be raised by the trap routine
        BookErrNo en_Interrupt;
    
        ! Connect the interrupt to the trap routine
        CONNECT in_Interrupt WITH TrapRoutineB;
        ! Execute some code to set up the interrupt, i.e. on a timer or input
    
        ! Other code that is executing when the interrupt occurs
    
    ERROR(en_Interrupt) ! Any errors in brackets are caught here specifically
        ! Execute code to warn the user or retry a movement
        StartMove;
        RETRY;
    ENDPROC
    
    TRAP TrapRoutineB
        ! Execute trap routine code for example:
        StopMove\Quick;
        ClearPath;
        
        ! Raise the error to be caught in routine A
        RAISE en_Interrupt;
    ERROR
        RAISE;
    ENDTRAP
    
    

  • This works!

    Thank you so much @Forge_Engineering!

    -----------------
    David
    Swedish freelance ABB robot programmer