RobotStudio event

Interrupt Routines and I/O's

Hello,

So I am receiving a signal from an outside source, that can turn on at random. If this signal is high, the robot should not move matter what button is pressed (MoveJ, MoveL, etc.), and if the robot is moving and that signal goes high, RS turns the signal off, and then continues to its target. Right now I can make the robot not move and also use an interrupt routine to do things if that signal goes high while the robot is moving. Unfortunately though, I am simulating that using 2 different signals, as I don't want it to go to the interrupt routine every time the signal goes high, because depending on the state of the robot when that signal goes high, I need different things to happen... So my question is, is there a way to do 2 different things in a interrupt routine based on the state of the robot?
Here is my code that kind of helps explain my current scenario:

! While loop is constantly looping unless interrupt routine is active
! DO1 is if the signal goes high when the robot is stationary
! DO2 is if the signal goes high when the robot is moving
CONNECT sig1Int WITH IntRoutineDO2High;
ISignalDO DO2,1,sig1Int; ! If DO2 is high, jumps to interrupt routine (seen below)

TRAP IntRoutineDO2High
        ! Routine is active when the robot is moving and the DO2 is high
        ! Stops movement
        ! Sends message to server saying DO2 is high, turns DO2 off
        ! Continues path
        StopMove\Quick;
        Reset DO2;
        SocketSend clientSocket\Str:="DO2 was turned high while the robot was moving. Stopped movement and reset DO2"
        WaitTime 2;
        StorePath;
        RestoPath;
       StartMove;
ENDTRAP

PROC main()
......
i:=1;
While i=1 DO
......
        IF DO1=1 THEN
               SocketSend clientSocket\Str:="DO1 is high, robot will not move until DO1 is off"
        ELSE
               MoveJ myRobotTarget,v150,z100,tool0\WObj:=wobj0;
        ENDIF
......
ENDWHILE
......
ENDPROC

As seen in my code, I want what happens when DO1 and DO2 are pressed to happen, but use only 1 signal instead of 2 signals. Basically I want the interrupt routine to happen, but only if the robot is moving, otherwise just keep looping and checking the state of the DO if the robot is stationary. Any ideas?

Thanks for any help!
SM



Comments

  • Hello,

    Never mind, I answered my own question... For anyone else having trouble with this, this is what I had to do:
    1. Create a digital output for the robot moving
    2. Set that digital output high the line before any move statement
    3. See code below:

    TRAP IntRoutineDO1High
            ! RobotMoving is just a regular Digital Output that is set high right before a move (see PROC Main())
            IF RobotMoving=1 THEN
                StopMove\Quick;
                Reset DO1;
                Reset RobotMoving;
                SocketSend clientSocket\Str:="DO1 is high while robot is moving"
                WaitTime 2;
                IF DO1=0 THEN
                    Set RobotMoving;
                    StorePath;
                    RestoPath;
                    StartMove;
                ENDIF
            ENDIF
        ENDTRAP

    PROC Main()
    ......
    i:=1;
    While i=1 DO
    ......

                   Set RobotMoving;
                   MoveJ myRobotTarget,v150,z100,tool0\WObj:=wobj0;
                   Reset RobotMoving;
    ......
    ENDWHILE
    ......
    ENDPROC



  • Nice that it works! :) I was wondering, does it works well? In my opinion you have to put the 'StorePath' instruction before you stopped the robot movement...
  • SteveMob
    SteveMob
    edited October 2016
    John,

    It does work well actually, exactly how I wanted it to work. If the robot isn't moving then it runs through the TRAP Routine super fast so it takes virtually no time is wasted. If the robot is moving then it performs what's in the loop. So yeah, it works just like how I wanted it to. However, per your suggestion, I will put the "StorePath" instruction before I stop the robot. Unfortunately doing it that way, the robot continues its path until it reaches the next target (finishes the move command), and then proceeds to do the TRAP routine stuff, so it works better the way that I have it. It stops instantly, shuts DO1 off, and then proceeds to the next target...

    Thanks,
    SM