User's Manual

Turbo PMAC User Manual
252 Turbo PMAC Computational Features
Note:
<= and >= are not valid Turbo PMAC comparators. The comparators !> and !<,
respectively, should be used in their place.
Conditions
A condition can be used to control program flow in motion or PLC programs. It is evaluated as either
true or false. It can be used in an IF branching statement or WHILE looping statement. Turbo PMAC
supports both simple and compound conditions.
Note:
A condition in a command line – IF or WHILE – must be surrounded by
parentheses.
Simple Conditions
A simple condition consists of three parts:
{expression} {comparator} {expression}
If the relationship between the two expressions defined by the comparator is valid, then the condition is
true; otherwise, the condition is false. Examples of simple conditions in commands are:
WHILE (1<2) (always true)
IF (P1>5000)
WHILE (SIN(P2-P1)!>P300/1000)
Note that parentheses are required around the condition itself.
Note:
Unlike in some programming languages, a Turbo PMAC condition may not be
simply a value, evaluated for zero or non-zero (e.g. IF (P1) is not valid). It
must explicitly be a condition with two expressions and a comparator.
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 Turbo PMAC, AND has execution precedence over OR (that is, ORs operate on blocks of
ANDed simple conditions). Turbo 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)
Note:
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 Turbo 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