10: DATA COMPARISON INSTRUCTIONS
10-2 « FC4A MICROSMART USER’S MANUAL »
Applicable CPU Modules
Valid Operands
For the valid operand number range, see pages 6-1 and 6-2.
▲ Internal relays M0 through M1277 can be designated as D1. Special internal relays cannot be designated as D1.
When T (timer) or C (counter) is used as S1 or S2, the timer/counter current value is read out.
Valid Data Types
Special Internal Relays M8150, M8151, and M8152 in CMP=
Slim type CPU modules FC4A-D20RK1, -D20RS1, -D40K3, and -D40S3 have three special internal relays to indicate the
comparison result of the CMP= instruction. Depending on the result, one of the three special internal relays turns on.
When more than one CMP= or ICMP>= instruction is used, M8150, M8151, or M8152 indicates the result of the instruc-
tion that was executed last.
Examples: CMP>=
The following examples are described using the CMP≥ instruction. Data comparison operation for all other data compari-
son instructions is the same for the CMP≥ instruction.
• Data Type: Word
• Data Type: Integer
FC4A-C10R2/C FC4A-C16R2/C FC4A-C24R2/C FC4A-D20K3/S3 FC4A-D20RK1/RS1 & FC4A-D40K3/S3
XXX X X
Operand Function I Q M R T C D Constant Repeat
S1 (Source 1) Data to compare XXXXXXX X 1-99
S2 (Source 2) Data to compare XXXXXXX X 1-99
D1 (Destination 1) Comparison output — X ▲ ———— — 1-99
W (word) I (integer)
XX
When a bit operand such as I (input), Q (output), M (internal relay), or R (shift register) is
designated as the source, 16 points are used. When repeat is designated for a bit operand, the
quantity of operand bits increases in 16-point increments.
When a word operand such as T (timer), C (counter), or D (data register) is designated as the
source, 1 point is used. When repeat is designated for a word operand, the quantity of oper-
and words increases in 1-point increments.
The destination uses only 1 point of output or internal relay. When repeat is designated for
the destination, outputs or internal relays as many as the repeat cycles are used.
When S1 > S2, M8150 (greater than) turns on.
When S1 = S2, M8151 (equal to) turns on.
When S1 < S2, M8152 (less than) turns on.
S2 Value M8150 M8151 M8152
D1
Status
(1) S1 > S2 ON OFF OFF OFF
(2) S1 = S2 OFF ON OFF ON
(3) S1 < S2 OFF OFF ON OFF
S2
S1
(2)(1) (3)
Small Large
When repeat is designated, the comparison result of the last
repeat cycle turns on one of the three special internal relays.
I0
REPS1 –
D10
D1 –
Q0
CMP>=(W) S2 –
D20
56
D20
50
D20
Q0 turned off
Q0 turned on
S2 D1
42
D10
127
D10
S1
I1
REP
S1 –
D30
D1 –
Q1
CMP>=(I) S2 –
D40
–3
D40
–3
D40
Q1 turned off
Q1 turned on
S2 D1
–4
D30
12
D30
S1