Reference Guide

PMAC Quick Reference Guide
62 PLC Programs
PLC2: Since PLC1 is suggested as an initialization PLC (and can run potentially 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 useful particularly 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 compared 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 to 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 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.
Entering a PLC Program
PLCs are programmed in the same way as motion programs are in a text editor window for later
downloading to PMAC.
Before starting to write the PLC, make sure that memory has not been tied up in data gathering or
program trace buffers, by issuing DELETE GATHER and DELETE TRACE commands.
1. Open the buffer for entry with the OPEN PLC n statement, where n is the buffer number. Next, if
there is anything currently in the buffer that should not be kept, it should be emptied with the CLEAR
statement (PLC buffers may not be edited on the PMAC itself; they must be cleared and re-entered).
If the buffer is not cleared, new statements will be added onto the end of the buffer.
2. When finished, close the buffer with the CLOSE command. Opening a PLC program buffer
automatically disables that program. After it is closed, it remains disabled, but it can be re-enabled
again with the ENABLE PLC n command, where n is the buffer number (0--31). I5 must also be set
properly for a PLC program to operate.
3. At closing, PMAC checks to make sure all IF branches and WHILE loops have been terminated
properly. If not, it reports an error, and the buffer is inoperable. Then correct the PLC program in
the host and re-enter it (clearing the erroneous block in the process, of course). This process is
repeated for all of the PLC buffers to be used.
Because all PLC programs in PMAC’s memory are enabled at power-on/reset, it is good practice to have
I5 saved as 0 in PMAC’s memory when developing PLC programs. This will allow PMAC to be reset
and have no PLCs running (an enabled PLC only runs if I5 is set properly) and recover more easily from a
PLC programming error.
Structure Example:
CLOSE
DELETE GATHER
DELETE TRACE
OPEN PLC n CLEAR
{PLC statements}
CLOSE
ENABLE PLC n