User's Manual

PMAC User Manual
Computational Features 161
Function Expression
Value
1- to 20-bit M-
Variable
* or 24-bit M-
Variable
32- or 48-bit M-
Variable
== All 1's 2 2 3
== All 0's 2 2 3
== Others 3 2 3
&= All 1's 0 (no-op) 0 (no-op) illegal
&= All 0's 2 2 illegal
&= Others 2 2 illegal
|= All 1's 2 2 illegal
|= All 0's 0 (no-op) 0 (no-op) illegal
|= Others 2 2 illegal
^= All 1's 2 2 illegal
^= All 0's 0 (no-op) 0 (no-op) illegal
^= Others 2 2 illegal
Comparators
A comparator evaluates the relationship between two values (constants or expressions). It is used to
determine the truth of a condition in a motion or PLC program. The valid comparators for PMAC are:
= (equal to)
!= (not equal to)
> (greater than)
!> (not greater than; less than or equal to)
< (less than)
!< (not less than; greater than or equal to)
~ (approximately equal to — within one)
!~ (not approximately equal to — at least one apart)
Notice that <= and >= are not valid 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. PMAC supports
both simple and compound conditions.
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)
Notice that parentheses are required around the condition itself.
Unlike in some high-level languages, a 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.