RobotStudio event

Interrupt Trap routine.

Hello everyone!  I'm doing a school project that consists of a virtual em physic simulation of an ink producing machine made by me in this video:

https://youtu.be/G26clvVVUpo

The project will be carried out with a siemens S7 300 PLC and an ABB irb-140 ROBOT.  I have a digital input associated with an interrupt that executes a TRAP routine.
When the plc sends a signal to this DI, it activates a TRAP routine, inside this routine, the robot stops.  After stopping I have 2 conditions associated with 2 more inputs that wait for 1 signal from the plc.
One input makes the robot continue the process in the same place where the interrupt was activated, so far so good! When I activate the other digital input, I want the robot to go to another position (home position), and not return to the position where the interrupt was activated, following a new signal (start), restarting the whole process from the beginning .
What am I doing wrong? Someone can help me?
 Thanks.
 Bruno Santos.
Portugal. 



Answers

  • Give the System input StartMain.  Be careful that you do not crash the robot.  At the top of your main program add a homing routine that can determine where the robot is and safely return it to home, then resume the program as I suppose you have normally been doing.
    Lee Justice
  • Sorry, but I don't understand what you're trying to say. I added an ExitCycle, it happens that the PP enters the main and the program is stopped. I have to reconnect the controller/simulator manually. I send part of my code, I try to understand where the error is.

    ««

     VAR num CICLOS:=3;
        VAR intnum INT_EMERG_STOP;


        PROC MAIN()
            
            StartMove;
            
            LOOP:

            WaitDI START,1;

            MoveJ Target_10_2,v1500,z50,MyTool\WObj:=wobj0;

            SET EMERG_OUT;
            SET ENABLE_OUT;

            IDelete INT_EMERG_STOP;


            !! INTERRUPT EMERGENCIA

            CONNECT INT_EMERG_STOP WITH INTERRUPT_EMERG_STOP;

            iSignaldi EMERG_STOP_IN,1,INT_EMERG_STOP;


            IF MISTURA_A=1 THEN

                TPWrite "EXECUTAR MISTURA A";

                ARRANQUE;
                PEGAR_FERRAMENTA_MIST_A;

                WHILE START=1 DO

                    MISTURA_A_ESQUERDA;

                    Set CONT_PEÇA;
                    WaitTime 0.5;
                    Reset CONT_PEÇA;
                    WaitTime 0.5;

                ENDWHILE

                TPWrite "A FINALIZAR PROCESSO";
                LAVAGEM;
                PEGAR_FERRAMENTA_MIST_A;
                RECUO;

            ENDIF

            IF MISTURA_B=1 THEN

                TPWrite "EXECUTAR MISTURA B";

                ARRANQUE;
                PEGAR_FERRAMENTA_MIST_B;

                WHILE START=1 DO

                    MISTURA_B_DIREITA;

                    Set CONT_PEÇA;
                    WaitTime 0.5;
                    Reset CONT_PEÇA;
                    WaitTime 0.5;

                ENDWHILE

                TPWrite "A FINALIZAR PROCESSO";
                LAVAGEM;
                PEGAR_FERRAMENTA_MIST_B;
                MoveJ Target_50,v1500,z5,MyTool\WObj:=wobj0;
                RECUO;

            ENDIF

            GOTO LOOP;

        ENDPROC


        TRAP INTERRUPT_EMERG_STOP

            VAR robtarget posição;

            StopMove;
            StorePath;
            posição:=CRobT(\Tool:=MyTool\WObj:=wobj0);

            MoveL Offs(posição,0,0,100),v100,z0,MyTool\WObj:=wobj0;
            MoveJ Target_50,v1500,z5,MyTool\WObj:=wobj0;

            WaitUntil CONTINUAR=1 OR RESTART=1;

            IF CONTINUAR=1 THEN

                Movej Offs(posição,0,0,100),v1500,z0,MyTool\WObj:=wobj0;
                Movel posição,v100,z0,MyTool\WObj:=wobj0;
                RestoPath;
                StartMove;

            ENDIF

            IF RESTART=1 THEN

                IF MISTURA_A=1 THEN

                    LAVAGEM_RESTART;
                    PEGAR_FERRAMENTA_MIST_A;
                    RECUO;
                    ExitCycle;
                    RETURN ;

                ELSEIF MISTURA_B=1 THEN

                    LAVAGEM_RESTART;
                    PEGAR_FERRAMENTA_MIST_B;
                    MoveJ Target_50,v1500,z5,MyTool\WObj:=wobj0;
                    RECUO;
                    ExitCycle;
                    RETURN ;

                ENDIF

            ENDIF
            RETURN ;


        ENDTRAP

    »»
  • First I have to ask,  iSignaldi EMERG_STOP_IN, INT_EMERG_STOP are those for an actual Emergency stop?  If so, then that is a big No-No.  E-stops must be hardwired into the robot's safety circuit.
    Lee Justice
  • Yes I know.  But let's say it's a process stop/pause button. 
  • So you have not explained the undesired behavior which you say is your error.
    Lee Justice
  • OK, I'll try to explain it better...
    The DI "EMERG/STOP", will activate an interrupt with a TRAP routine. 
    After entering the routine, I have 2 options to choose: Continue the program from the place where the interrupt happened, or restart the robot program, that is, return or should return to the "home position" and wait for a new start signal to start the process from scratch.

    Before placing the command "EXITCYCLE", after reaching the home position, the robot returns to the point where the interrupt was made, to finish the process that was interrupted. After I placed the "EXITCYCLE" command, the PP goes to main as intended, but the simulation does not continue and stops, and it is necessary to click play again!

    All my code is working the way I want it, with the exception of the restart option part...Thanks.
  • graemepaulin
    edited February 2022
    According to the RAPID reference manual ExitCycle will continue with the program execution if the run mode is in continuous, if it is in single cycle then it will stop...

  • That is how ExitCycle is supposed to work.  It is for use when a fatal, non-recoverable error, in which the programmer sees no safe way to resume, so the program must return to the beginning.   If you are not in continuous cycle mode, it will be stopped, if in continuous mode, it will be running.

    StartMain system input, as I suggested before should put you to the beginning of the main program, with the program running, regardless of continuous mode or not.
    Lee Justice
  • In continuous cycle? The program or the simulation? Because I had to put a "GOTO..." at the end of main so that the program is cyclic...

    "Start main system input... " Do I have to write something at the beginning of Mai, or just configure in the controller that an X input, makes a set to the startmain function? Sorry, I'm still learning robotics. As far as I know, it's still basic. We just don't learn when we don't try to do it.


  • As shown in the snip from RobotStudio you change the run mode from single cycle to continuous - on the Rapid tab.
    On a real controller this is in the quick set menu on the pendant.
  • Esta opção? 
  • Type your comment
  • According to the RAPID reference manual ExitCycle will continue with the program execution if the run mode is in continuous, if it is in single cycle then it will stop...

    Regardless of the option chosen, the program stops.  For this reason I had to put a GOTO at the end of main
  • Does the program stop at the end of the main procedure without the GOTO?
    Are you running the program from the Rapid tab or as a simulation?
  • If as a  simulation then you need to change the run mode in the simulation setup as below

  • Does the program stop at the end of the main procedure without the GOTO?
    Are you running the program from the Rapid tab or as a simulation?
    Yes stop. But I didn't have this option activated in the simulation configuration... But going back to my problem, even so, it wouldn't work with the camndo "EXITCYCLE"!? How could I make my interrupt stay only at home position? How do system input functions work?
  • The ExitCycle will work if the run mode is in continuous mode.
    You only have to change the mode in the simulation config if you are running the program from there.

    The system input is configured in the IO configuration, you need an input signal to connect with it.

  • OK.  And is it necessary to write something in rapid?  Or is the controller already automatically configured that whenever "di_test" is at 1, it automatically starts main?
  • graemepaulin
    edited March 2022
    Normally this is used by the PLC to start program execution at main.
    I have never used it like this but Lee was suggesting to use it and he has much more programing experience than me...
    When the input goes to 1 (high) the system input will try to start the program execution from main.
    To get the input to change you will probably need to cross connect an output to the input used for the system input...

  • I already changed the simulation mode to continuous, now everything is working OK, but now another question has arisen.  At the school I study, the robot abb irb-140 has a problem in the communication protocol, due to a file being corrupted.  To program the robot through robotstudio, we have to put the files with the .mod e.pgm extensions on a flash drive and load them to the robot from there.  I now ask: Even if I change the robot cycle to continuous in the flexpendant of the real robot, will everything work fine in reality?  Because in addition to simulating with software, everything needs to work in reality!  Thanks.
  • lemster68
    lemster68 ✭✭✭
    Also to note with StartMain, the program must not be executing.  The PLC must issue the Stop system input, then StartMain when the execution has stopped.  I advise changing the system parameter under the controller topic, RUN_MODE_SETTINGS, ManualToAuto, continuous.  Also, it makes it more user friendly to change AutoToManual to Single.
    Lee Justice
  • Thank you!  It's working perfectly!  Now we just need to know if the program will work on a real robot.
  • Yes it will work as it does in RobotStudio if you change the real robot to continuous run mode.

  • Thank you so much!