Chapter 4. Ladder Diagram (LD) Programming
4.12.1
Compare
When the Compare (CMP) function receives power flow, it compares
the value IN1 to the value IN2.
If IN1 < IN2, CMP energizes the LT (Less Than) output.
■
If IN1 = IN2, CMP energizes the EQ (Equal) output.
■
If IN1 > IN2, CMP energizes the GT (Greater Than) output.
■
IN1 and IN2 must be the same data type.
CMP compares data of the following types: DINT, INT, REAL, LREAL, and UINT.
Tip:
To compare values of different data types, first use conversion functions to make the types
the same.
When it receives power flow, CMP always passes power flow to the right, unless IN1 and/or IN2 is
NaN (Not a Number).
Operands
Parameter
Description
IN1
The first value to compare.
IN2
The second value to compare.
LT
Output LT is energized when I1 < I2.
EQ
Output EQ is energized when I1 = I2.
GT
Output GT is energized when I1 > I2.
Example
When %I00001 is ON, the integer variable SHIPS is compared
with the variable BOATS. Internal coils %M0001, %M0002, and
%M0003 are set to the results of the compare.
212
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
Allowed Operands
All except S, SA, SB, SC
All except S, SA, SB, SC
Power flow
Power flow
Power flow
Mnemonics:
CMP_DINT
CMP_INT
CMP_REAL
CMP_LREAL
CMP_UINT
Optional
No
No
No
No
No
GFK-2950C