User`s manual

6.0 - PLC Programs
Page - 60
6.6 - COMMAND and SEND statements
One of the most common uses of PLCs is to start motion programs and Jog motors by means of command statements.
Some COMMAND action statements should be followed by a WHILE condition to ensure they have taken effect before
proceeding with the rest of the PLC program. This is always true if a second COMMAND action statement that requires the
first COMMAND action statement to finish will follow. (Remember, COMMAND action statements are only processed during
the communications section of the background cycle.) Suppose you want an input to stop any motion in a Coordinate
System and start motion program 10. The following PLC could be used.
M187->Y:$0817,17,1 ; &1 In-position bit (AND of motors)
OPEN PLC3 CLEAR
IF (M11=1) ; input is ON
IF (P11=0) ; input was not ON last time
P11=1 ; set latch
COMMAND"&1A" ; ABORT all motion
WHILE (M187=0) ; wait for motion to stop.
ENDW
COMMAND"&1B10R" ; start program 10
ENDIF
ELSE
P11=0 ; reset latch
ENDIF
CLOSE
Any SEND, COMMAND, or DISPLAY action statement should be done only on an edge-triggered condition, because the
PLC can cycle faster than these operations can process their information, and the communications channels can get
overwhelmed if these statements get executed on consecutive scans through the PLC.
IF (M11=1) ; input is ON
IF (P11=0) ; input was not ON last time
COMMAND"#1J+" ; JOG motor
P11=1 ; set latch
ENDIF
ELSE
P11=0 ; reset latch
ENDIF
6.7 - Timers
Timing commands like DWELL or DELAY are only reserved to motion programs and cannot be used for timing purposes
on PLCs. Instead, PMAC has four 24-bit timers that you can write to, and count down once per servo cycle. These timers
are at registers X:$0700, Y:$0700, X:$0701, and Y:$0701. Usually a signed M-variable is assigned to the timer; a value is
written to it representing the desired time in servo cycles (multiply milliseconds by 8,388,608/I10); then the PLC waits until
the M-variable is less than 0.
Example: M90->X:$0700,0,24,S ; Timer register 1 (8388608/I10 msec)
M91->Y:$0700,0,24,S ; Timer register 2 (8388608/I10 msec)
M92->X:$0701,0,24,S ; Timer register 3 (8388608/I10 msec)
M93->Y:$0701,0,24,S ; Timer register 4 (8388608/I10 msec)
OPEN PLC3 CLEAR
M1=0 ; Reset Output1 before start
M90=1000*8388608/I10 ; Set timer to 1000 msec, 1 second
WHILE (M90>0) ; Loop until counts to zero
ENDWHILE
M1=1 ; Set Output 1 after time elapsed
DIS PLC3 ; disables PLC3 execution (needed in this example)
CLOSE