Rockwell Automation Publication 1756-RM003N-EN-P - October 2011 221
Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5
Compare (CMP)
The CMP instruction performs a comparison on the arithmetic operations you
specify in the expression.
Operands:
Relay Ladder
Structured Text
Structured text does not have a CMP instruction, but you can achieve the same
results by using an IF...THEN construct and expression.
IF BOOL_expression THEN
<statement>;
END_IF;
See Structured Text Programming
for information on the syntax of constructs
and expressions within structured text.
Description: Define the CMP expression by using operators, tags, and immediate values. Use
parentheses ( ) to define sections of more complex expressions.
The execution of a CMP instruction is slightly slower and uses more memory
than the execution of the other comparison instructions. The advantage of the
CMP instruction is that it allows you to enter complex expressions in
one instruction.
Arithmetic Status Flags: The CMP instruction affects only the arithmetic status flags if the expression
contains an operator (for example, +, −, *, /) that affects the arithmetic
status flags.
Fault Conditions: None
Operand Type Format Description
Expression SINT
INT
DINT
REAL
string
Immediate Tag An expression consisting of tags and/or
immediate values separated by operators.
A SINT or INT tag converts to a DINT value by sign-extension.