Is CWRITE($CMD, STAT, MODE, "CANCEL... used to deselect a program?
CWRITE deselect program?
-
Jon_G -
July 14, 2015 at 4:55 PM -
Thread is marked as Resolved.
-
-
To cancel the selected program and free the robot interpreter (gray R):
To select the "main()" robot program (yellow R)To start the program you need the $EXT_START signal in EXT mode or play fwd button in AUT mode.
diglo
-
Thank you.
If you cancel in that way and then select "main()" let's say in the sps.sub, do all initializations reoccur in the sps?
-
No, the $CMD commands (Select, Stop, Cancel) simply emulate the actions of an operator pushing those same buttons on the pendant.
It should be noted that $CMD commands in each interpreter can only affect the other interpreter, not themselves. So $CMD commands from the SPS (Level 0 interpreter) can only affect the Robot (Level 1) Interpreter, and vice-versa.
-
Okay so any $CMD statements made in my sps.sub would have to be of "RUN 1, SELECT 1, STOP 1, CANCEL 1"? Or am I confused. The way I have it set now it works to an extent, but I'm having a problem with switching the selected file it seems or maybe it's my logic.
I made my own sps.sub file to eliminate the GM logic and assigned it in STEU\MADA\custom.dat: $PRO_I_O[]="/R1/SPS()"
I was working on adding START, STOP, RESET logic and a HOME PB for my HMI.
sps.sub:
;Start program
IF NOT $PRO_MOVE AND ($MODE_OP==#EX) THEN
IF STARTPB THEN
CWRITE($CMD, STAT, MODE, "RUN /R1/test()")
$OUT[20]=FALSE ;At home position monitoring
ENDIF
ENDIF;Move Home
IF NOT $PRO_MOVE AND ($MODE_OP==#EX) THEN
IF HOMEPB AND ($OUT[20]==FALSE) THEN
$OUT[21]=TRUE ;Moving to home position monitoring
CWRITE($CMD, STAT, MODE, "CANCEL /R1/test()"
CWRITE($CMD, STAT, MODE, "RUN /R1/home()"
$OV_PRO=25
WAIT FOR $PRO_STATE1==#P_END
$OUT[21]=FALSE
$OUT[20]=TRUE
CWRITE($CMD, STAT, MODE, "CANCEL /R1/home()"
ENDIF
ENDIF ;STARTPB will restart the program if this has completed;Stop
IF $PRO_MOVE AND ($MODE_OP==#EX) THEN
IF STOPPB AND ($OUT[21]==TRUE) THEN
CWRITE($CMD, STAT, MODE, "STOP /R1/home()"
$OUT[21]=FALSE
ENDIF
ENDIF
IF $PRO_MOVE AND ($MODE_OP==#EX) THEN
IF STOPPB AND ($OUT[21]==FALSE) THEN
CWRITE($CMD, STAT, MODE, "STOP /R1/test()"
ENDIF
ENDIF;Out to PLC current state
IF (($PRO_STATE1==#P_ACTIVE) AND ($MODE_OP==#EX)) THEN
$OUT[81]=TRUE
ELSE
$OUT[81]=FALSE
ENDIF**Similar code for #P_END, P_STOP, P_RESET
PLC Logic is a pretty basic exchange from HMI to KRC: XIO ---- OTE and vice versa.
HOMEPB is latched out from HMI with a handshake tag to reset:HOMEPB HOME POSITION(out20) HOME MOVE(out21)
---] [----------------]/[-------------------------------------(L)------HOME POSITION HOME MOVE HOME HANDSHAKE
-------] [-------------------------(U)---------------------( )---------If 'test' is running and I stop it with my STOPPB I can either hit STARTPB again to resume or I can hit HOMEPB and it will switch and move home. The RESETPB logic is working fine as well. But if I hit HOMEPB while test() is running it seems to skip over the condition NOT $PRO_MOVE, sets $OUT[21]=TRUE and test() continues to run but none of the PB's will now function.
My initial thought was to not have it do anything when pushed while a program was being executed but I figured I would add something in it to have it function whether test() was stopped or running. Is $PRO_MOVE not the condition to check or is it the logic?
-
Well, CANCEL and STOP don't need the module names specified. Only RUN needs that.