User's Manual

PMAC User Manual
162 Computational Features
Compound Conditions
A compound condition is a series of simple conditions connected by the logical operators AND and OR.
The compound condition is evaluated from the values of the simple conditions by the rules of Boolean
algebra. In the PMAC, AND has execution precedence over OR (that is, ORs operate on blocks of ANDed
simple conditions). PMAC will stop evaluating compound AND conditions after one false simple
condition has been found. Examples of compound conditions in command lines are:
IF(P1>-20 AND P1<20)
WHILE(P80=0 OR I120>300 AND I120<400)
IF(Q16!<Q17 AND Q16!>Q18 OR M136<256 AND M137<256)
The simple conditions contained within a compound condition on a single line must not be separated by
parentheses. For example, IF((P1>-20) AND (P1<20)) is an illegal condition and will be rejected
for illegal syntax.
Single-Line Condition Actions
In PMAC motion programs (but not in PLC programs), the action(s) to be executed on a true condition
can be put on the same line as the condition itself. In this case, no ENDIF or ENDWHILE is required to
mark the end of the conditional action, and none may be used; the end of the line is automatically the
marker for the end of the conditional action. Examples of this form are:
IF (P1<0) P1=0
WHILE (M11=0) DWELL 10
In PMAC rotary program buffers single-line condition actions are the only types of conditional statements
permitted. Multiple-line conditions are not permitted because it cannot be guaranteed that the line that
must be jumped to will be in the rotary buffer at that time.
Multiple-Line Conditions
In PMAC PLC programs (but not in motion programs), compound conditions over several program lines
are allowed. The first line of the condition must start with IF or WHILE; following lines of the condition
must start with AND or OR. Simple and compound conditions within a program line are always evaluated
before the conditions on separate lines are combined. Between the conditions on multiple lines, AND
takes precedence over OR. PMAC will stop evaluating a multi-line AND condition after one single-line
condition has been found false. An example is:
IF (M11=1 OR M12=1)
AND (M13=1 OR M14=1)
Timers
There are four timer registers at addresses X:$0700, Y:$0700, X:$0701, and Y:$0701. These four 24-bit
registers are general-purpose timers for user program use. PMAC decrements them once per servo cycle.
It is permitted to write to them as desired. Typically, read and write access is through M-variables.
Usually a value is written equal to the time to wait, scaled in servo cycles. Then the program waits for the
register to become less than 0. The registers will continue to count down until they reach -2
23
(-
8,388,608). They will not roll over back to positive values.
Since these timers have units of servo cycles, and it is preferred to work in milliseconds, a conversion
must be done. To convert from milliseconds to servo cycles, multiply by 2
23
(8,388,608) and divide by
the value of I10.
When looking for a zero-crossing on these registers, it is important to treat them as signed (two's-
complement) variables. Any M-variable definitions should be in S (signed format).
For example: M90->Y:$0700,0,24,S.