Hi,
I'm trying to do a procedure for homeing. (KRC5 KR16)
If the PLC resets the program OR someone manually resets the program, I'd like to get and save the recent tool that was used.
One option I've tried is from the .SPS , the other one is at the beginning of the program.
The problem is that the current tool (Hopefully $TOOL is the right variable to read from) is always null when I'm trying to read it.
This is why I've added VARSTATE to prevent error and hoped to read the current tool anyways but nono.
Any tips?
Code
(The .SPS-Method)
IF (diPLC_PPtoMain == TRUE) AND ($MODE_OP == #EX) AND ($ROB_STOPPED == TRUE) THEN
IF VARSTATE("$TOOL") == #INITIALIZED THEN
tHomeTool = $TOOL
ENDIF
CWRITE($CMD,STAT,MODE,"STOP 1")
CWRITE($CMD,STAT,MODE,"CANCEL 1")
CWRITE($CMD,STAT,MODE,"RUN /R1/Main()")
ENDIF
ENDIF
(And I've also tried to put the this before INIT at the beginning of Main)
IF VARSTATE("$TOOL") == #INITIALIZED THEN
tHomeTool = $TOOL
ENDIF
Display More