If b_ObjectReady=TRUE THEN
GoToPickPos;
WaitUntil b_PickPosReached=TRUE;
PickObject;
ELSE
WaitUntil b_ObjectReady=TRUE;
GoToPickPos;
WaitUntil b_PickPosReached=TRUE;
PickObject;
ENDIF
b_ObjectReady is set in a trap routine and everything works fine when its set TRUE
(trap routine waits for signal from sps to read coordinates;if there are new coord, then its set TRUE, if there’ same coord as before its set to FALSE)
but when it’s set FALSE and program waits for it to be set TRUE, i’m not able to ‘access’ the interrupt.
When stoping the program, it says “interrupt removed from queue”..
Ok, now I understand. An interrupt seems to be necessary for that. It’s not normal that the interrupt is removed from queue while in a wait-instruction. So something weird is going on. How is your interrupt defined?
Eric, but the “Program” is a procedure.. when its called by a trap routine, does it mean the trap routine is still active?
Can i cancel the interrupt when getting into “program” or smth like this?
PROC program
IDelete getKoords;
(Connect getKoords WITH Read_SPS_Koord;)
If b_ObjectReady=TRUE THEN
GoToPickPos;
WaitUntil b_PickPosReached=TRUE;
PickObject;
ELSE
WaitUntil b_ObjectReady=TRUE;
GoToPickPos;
WaitUntil b_PickPosReached=TRUE;
PickObject;
ENDIF
Or maybe use Return instead of calling the proc?
TRAP Read_SPS_Koord
pos1:=[...]
IF (same Coords as before) THEN
b_objectReady:=FALSE;
RETURN;
ELSE
b_objectReady:=TRUE;
target:=[...]
RETURN;
ENDIF
ENDTRAP
It is still inside a trap routine, therefore the next interrupts are skipped. You have two options:
define a situation in your main task to wait until the next valid coord is sent from the plc ( it is still possible that you dont have to wait, when the next coord is ready before the waypoint is reached.)
use a background task and handle there the digestion of the coords. I think this is also the idea that denis has.