Download pmac users
Transcript
PMAC User Manual
; stops earlier
X(P1*SIN(P2))
P2=P2+1
ENDWHILE
X(P1*SIN(P2))
; Last move from
; inner loop
P1=P1+1
ENDWHILE
Looping to Wait
There are several methods for holding program execution while waiting for a certain condition to occur.
Usually this is done with a WHILE loop, but what is done inside the loop has an effect on responsiveness
and calculation load.
The fastest execution is the WHILE({condition}) WAIT loop. As soon as the WAIT command is
encountered, motion program calculations are suspended until the next real-time interrupt, at which time
they will re-evaluate the condition. The motion program effectively becomes like a one-line PLC
program. If the next RTI has already occurred, it will re-enter the interrupt service routine immediately
and re-evaluate the condition. If this occurs repeatedly, background routines will be starved for time,
slowing PLCs and communications, or in the worst case, tripping the watchdog timer. Usually this
happens only if multiple coordinate systems are in simultaneous WHILE...WAIT loops.
Of similar speed is an empty WHILE...ENDWHILE loop, or at least one with no motion commands
inside. Each RTI, this will execute twice, stopped by the double-jump-back rule. Calculations resume at
the next RTI, or if this has occurred already, they resume immediately, with the same possible
consequences for starving background calculations.
Using a WHILE({condition}) DWELL single-line loop helps to control the looping rate better,
giving time for background routines. The condition is evaluated only once after each DWELL.
Implications of Calculating Ahead
The need of the motion program to calculate ahead during a continuous sequence of moves means that
non-motion actions (particularly the setting of outputs) taken by the program happen before it is thought
they would by one or two moves. For variables that are only used within the program, this is no problem,
because everything happens sequentially within the program.
It is possible to move these non-motion actions to a point one or two moves later in the program to get the
actions to occur when they are desired. However, this makes the program extremely difficult to read as
far as the proper sequence of operations.
Synchronous M-Variable Assignment
The synchronous M-variable assignment statement is designed to get around this problem. This type of
statement uses a double equals sign (==) instead of a single equals sign. This is a flag to PMAC to hold
off the actual execution of the statement until the beginning of the move immediately following it, so the
actual action coincides with the actual motion.
Synchronous M-variable assignment statements are discussed in detail in the Computational Features
section of the User's Guide, with syntax instructions under M{constant}=={expression}.
Writing Programs for PMAC
14-57