Programming instructions
86
CMP – Compare
DCMP – 32-Bit Compare
DECMP – Floating Point Compare
The CMP compare instruction must be placed at the end of the rung. Its
destination is a group of 3 bit devices, which can be Y outputs, M relays or S
relays. The 3 result bits tell whether source data 1 is greater than, less than, or
equal to source data 2.
The instruction turns on M0, M1 or M2 based on the following criteria:
M0 if the value in D0 is greater than K10
M1 if the value in D0 equals K10
M2 if the value in D0 is less than K10
Two variants of this command are DCMP, which compares two 32-bit values to,
and DECMP, which compares two 32-bit floating point values.
ZCP – Zone Compare
DZCP – 32-Bit Zone Compare
DEZCP – Floating Point Zone Compare
The ZCP zone compare instruction must be placed at the end of the rung. Its
destination is a group of 3 bit devices, which can be Y outputs, M relays or S
relays. The 3 result bits tell whether source data 3 is greater than, less than, or
within the range specified by source data 1 and 2.
The instruction turns on M0, M1 or M2 based on the following criteria:
M0 if the value in D0 is less than K10
M1 if the value in D0 is K10 <= D0 <= K50
M2 if the value in D0 is greater than K50
The zone compare takes S3 (D0) and compares to the range specified by S1
(K10) and S2 (K50). The instruction checks to see if S3 is below the range,
inside the range, or above the range.
S1 needs to be less than S2. If it is not, the PLC will still accept the instruction,
but it will not function properly.
Two variants of this command are DZCP, which compares a 32-bit value to 32-bit
values, and DEZCP, which compares a 32-bit floating point value to two 32-bit
floating point values.