User`s manual

Page - 57
6.0 - PLC Programs
PMAC will stop the scanning of the motion program lines when enough move commands are 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 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 you
can have 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: PLC program 0 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 cases as PLC0, taking advantage of the faster execution rate
that a compiled PLC provides. Both PLC0 and PLCC0 could 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. PLC1could also disable other PLCs before they start running and could disable itself at the end of its
execution.
- PLC2: Since PLC1is suggested as an initialization PLC (and could potentially run only once on power-up), PLC2 is
the first PLC in the remaining sequence from 2 to 31. This makes PLC2 the ideal place to copy digital input
information from I\O expansion boards like the ACC-34 into its image variables. This way, PLCs 3 to 30 could use the
input information, writing the necessary output changes to the outputs image variables.
- PLC3 to PLC30: PLC programs are particularly useful for monitoring analog and digital inputs, setting outputs,
sending messages, monitoring motion parameters, issuing commands as if from a host, changing gains, and starting and
stopping moves. By their complete access to PMAC variables and I/O and their asynchronous nature, they become
very powerful adjuncts to the motion control programs.
- PLCC3 to PLCC30: compiled PLCs are convenient for its faster execution in compare to regular PLCs. Since the
execution rate of compiled PLCs is the same as some of the safety checks (following error limits, hardware overtravel
limits, software overtravel limits, and amplifier faults), PLCCs are ideal for replace or complement them. However, due
to its limited allocated memory space, PLCCs should be reserved only for faster execution critical tasks.
- PLC31: this is the last executed PLC in the sequence from 1 to 31. PLC31 is then recommended for copying the
output image variable (changed in lower number PLCs executed previously) into the actual outputs of an I\O
expansion board like, for example, the ACC-34A.