Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 223
Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5
CMP Expressions
You program expressions in CMP instructions the same as expressions in FSC
instructions. Use the following sections for information on valid operators,
format, and order of operation, which are common to both instructions.
Valid Operators
Format Expressions
For each operator that you use in an expression, you have to provide one or two
operands (tags or immediate values). Use this table to format operators and
operands within an expression
.
Operator: Description Optimal
+Add DINT, REAL
- Subtract/negate DINT, REAL
* Multiply DINT, REAL
/ Divide DINT, REAL
= Equal DINT, REAL
< Less than DINT, REAL
<= Less than or equal DINT, REAL
> Greater than DINT, REAL
>= Greater than or equal DINT, REAL
<> Not equal DINT, REAL
** Exponent (x to y) DINT, REAL
ABS Absolute value DINT, REAL
ACS Arc cosine REAL
AND Bitwise AND DINT
ASN Arc sine REAL
ATN Arc tangent REAL
COS Cosine REAL
DEG Radians to degrees DINT, REAL
FRD BCD to integer DINT
LN Natural log REAL
LOG Log base 10 REAL
MOD Modulo-divide DINT, REAL
NOT Bitwise complement DINT
OR Bitwise OR DINT
RAD Degrees to radians DINT, REAL
SIN Sine REAL
SQR Square root DINT, REAL
TAN Tangent REAL
TOD Integer to BCD DINT
TRN Truncate DINT, REAL
XOR Bitwise exclusive OR DINT
Operator: Description Optimal
Operators that
operate on
Use this format Examples
One operand Operator (operand) ABS(tag_a)
Two operands Operand_a operator operand_b
·tag_b + 5
·tag_c AND tag_d
·(tag_e ** 2) MOD (tag_f /
tag_g)