User's Manual

PMAC User Manual
Getting Started with PMAC 21
Writing and Executing a PLC Program
PLC programs are useful for doing monitoring and calculations in background, asynchronously to any
motion programs. They are written much like motion programs, and have much of the same language
(although no motion commands). There can be up to 32 PLC programs, which can be enabled and disabled
individually. The enabled programs cycle through continually in background, as time allows.
Start by writing a simple PLC program that increments a variable each time through. Using either
Terminal mode or (preferably) the Program Editor in the Executive Program, type the following:
CLOSE
OPEN PLC 1
CLEAR
P1=P1+1
CLOSE
If using the Editor, download what has been written to PMAC by selecting the Download Editor to PMAC
menu option, or by typing <ALT-D>.
Now, see if the program got to PMAC properly. From the Terminal mode, type LIST PLC 1<CR>. The
following response should appear:
P1=P1+1
RETURN
PMAC adds a RETURN statement {short form: RET} automatically to the end of a program when it gets a
CLOSE command. The OPEN, CLOSE, and CLEAR commands are not actually part of the program; they
are on-line commands to control the program buffer operation.
Starting the PLC Program
Now type I5=2<CR>. This permits PLCs 1 to 31 to be enabled. Next, type ENABLE PLC 1. This
should actually start operation of the PLC program. The variable P1 should be incrementing steadily.
Verify this by repeatedly typing P1<CR>. The reported value should be greater each time. If it is not,
recheck the value of I5, the listing of the program, and try re-enabling the PLC.
Other things can be happening in between cycles of the PLC program. Reset the value of P1 by typing
P1=0<CR>. PMAC will execute this command, and then PLC 1 will start incrementing the value again
from that point.
Motion programs can be run simultaneously. Re-run the motion program and notice that P1 keeps
incrementing during the operation of the motion program.
Stopping the PLC Program
To halt operation of the PLC program, type DISABLE PLC 1. Note that repeated queries of P1’s value
yield the same answer. ENABLE PLC 1 will re-enable operation of the program.
Each time a PLC program buffer is opened for editing, the program is automatically disabled. Closing the
buffer does not automatically re-enable the program. When working on a PLC program with the program
editor, follow the CLOSE command with an ENABLE PLC 1 command, so that this command does not
need to be re-typed every time the edited PLC program is downloaded to PMAC.