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:

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.

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.

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.

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.

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.

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.

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

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

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?

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…