Reference Guide

PMAC Quick Reference Guide
Troubleshooting 71
PLC Programs
PLCs and PLCCs are one of the most common sources for communication or watchdog timer failures.
Any SEND, COMMAND, or DISPLAY action statement should be done only on an edge-triggered
condition, because the PLC can cycle faster than these operations can process their information, and the
communications channels can get overwhelmed if these statements are executed on consecutive scans
through the PLC.
IF (M11=1) ; input is ON
IF (P11=0) ; input was not ON last time
COMMAND"#1J+" ; JOG motor
P11=1 ; set latch
ENDIF
ELSE
P11=0 ; reset latch
ENDIF
PLC0 or PLCC0 should be used for only a few tasks (usually a single task) that must be done at a higher
frequency than the other PLC tasks. The PLC 0 will execute every real-time interrupt as long as the tasks
from the previous RTI have been completed. PLC 0 is potentially the most dangerous task on PMAC as
far as disturbing the scheduling of tasks is concerned. If it is too long, it will starve the background tasks
for time. The first thing noticed is that communications and background PLC tasks will become sluggish.
In the worst case, the watchdog timer will trip, shutting down the card, because the housekeeping task in
background did not have the time to keep it updated.
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,
no PLCs running (an enabled PLC only runs if I5 is set properly) and recover more easily from a PLC
programming error.
As an example, type these commands in the terminal window. After that, open a watch window and
monitor for P1 to be counting up:
OPEN PLC1 CLEAR ; Prepare buffer to be written
P1=P1+1 ; P1 continuously incrementing
CLOSE ; Close written buffer, PLC1
I5=2
Press <CTRL+D> and type ENA PLC1