Reference Guide

PMAC Quick Reference Guide
PLC Programs 61
PLC PROGRAMS
PMAC will stop the scanning of the motion program lines when enough move commands have been
calculated ahead of time. This feature is called look-ahead and it is necessary to properly blend the
moves together and to observe the motion safety parameters. In the following example, PMAC calculates
up to the third move and will stop the program scanning until the first move is completed; that is, when
more move planning is required:
Example:
OPEN PROG 1 CLEAR ; Open program buffer
I13=0 ; Two moves ahead of calculation
LINEAR INC TA100 TS0 F50 ; Mode commands
X1 ; First Move
X1 ; Second Move
X1 ; Third Move
M1=1 ; This line will be executed only after the
; first move is completed
CLOSE ; Close written buffer, program one
In contrast, enabled PLCs are continuously executed from beginning to end regardless of what any other
PLC or Motion program is doing. PLCs are called asynchronous because they are designed for actions
that are asynchronous to the motion.
Also, they are called PLC programs because they perform many of the same functions as hardware
programmable logic controllers. PLC programs are numbered 0 through 31 for both the compiled and
uncompiled PLCs. This means that there can be both a compiled PLC n and an uncompiled PLC n stored
in PMAC. The faster execution of the compiled PLCs comes from two factors: first, from the elimination
of interpretation time, and second, from the capability of the compiled PLC programs to execute integer
arithmetic. However, the space dedicated to store up to 32 compiled PLC programs is limited to 15K
(15,360) 24-bit words of PMAC memory; or 14K (14,336) words if there is a user-written servo as well.
PLC programs 1-31 are executed in background. Each PLC program executes one scan (to the end or to
an ENDWHILE statement) uninterrupted by any other background task (although it can be interrupted by
higher priority tasks). In between each PLC program, PMAC will do its general housekeeping, and
respond to a host command, if any. In between each scan of each individual background interpreted PLC
program, PMAC will execute one scan of all active background compiled PLCs. This means that the
background compiled PLCs execute at a higher scan rate than the background interpreted PLCs. For
example, if there are seven active background interpreted PLCs, each background compiled PLC will
execute seven scans for each scan of a background interpreted PLC. At power-on\reset PLCC programs
run after the first PLC program runs. These are the suggested uses of all the available PLC buffers:
PLC0: PLC0 is a special fast program that operates at the end of the servo interrupt cycle with a
frequency specified by variable I8 (every I8+1 servo cycles). This program is meant for a few time-
critical tasks and it should be kept small, because its rapid repetition can steal time from other tasks.
A PLC 0 that is too large can cause unpredictable behavior and can even trip PMAC’s watchdog
timer by starving background tasks of time to execute.
PLCC0: The compiled PLCC0 should be used in the same instances as PLC0, taking advantage of
the faster execution rate that a compiled PLC provides. Both PLC0 and PLCC0 can be defined at the
same time.
PLC1: This is the first code that PMAC will run on power-up, assuming that I5 was saved with a
value of 2 or 3. This makes PLC1 the appropriate PLC to initialize parameters, perform commutated
motors phase search and run motion programs. PLC1 can also disable other PLCs before they start
running and can disable itself at the end of its execution.