PMAC Product Guide • 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 (e.g., 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. • 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. • 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). In addition, I5 must be set properly for a PLC program to operate.
• At the 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. Correct the PLC program in the host and re-enter it (clearing the erroneous block in the process). 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, save I5 as 0 in PMAC’s memory when developing PLC programs. This will allow PMAC to be reset and not have PLCs running (an enabled PLC runs only 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 • To erase an uncompiled PLC program, open the buffer, clear the contents, and then close the buffer again. This can be done with three commands on one line: OPEN PLC 5 CLEAR CLOSE PLC Program Structure The important thing to remember in writing a PLC program is that each PLC program is effectively in an infinite loop; it will execute over and over again until told to stop. (These are called PLC because of the similarity in how they operate to hardware Programmable Logic Controllers -- the repeated scanning through a sequence of operations and potential operations.) 86 PLC Programs