![FATEK FBs Series Manual Download Page 159](http://html1.mh-extra.com/html/fatek/fbs-series/fbs-series_manual_3764826159.webp)
Basic Function Instruction
6 -3 4
FUN 17
D
P
CMP
COMPARE
(Compares the data of Sa and Sb and outputs the results to function Outputs)
FUN 17
D
P
CMP
Operand
Sa: The register to be compared
Sb: The register to be compared
Sa, Sb may combine with V, Z, P0~P9 to
serve indirect addressing
WX
WY
WM
WS
TMR CTR
HR
IR
OR
HR HSCR RTCR SR
ROR DR
K
Range
Ope-
rand
WX0
∣
WX240
WY0
∣
WY240
WM0
∣
WM1896
WS0
∣
WS984
T0
∣
T255
C0
∣
C255
R0
∣
R3839
R3804
∣
R3903
R3904
∣
R3919
R3920
∣
R4047
R4096
∣
R4127
R4128
∣
R4135
R4136
∣
R4167
R5000
∣
R8071
D0
∣
D4095
16/32 bit
+/-number
Sa
○
○
○
○
○
○
○
○
○
○
○
○
○
○
○
○
Sb
○
○
○
○
○
○
○
○
○
○
○
○
○
○
○
○
●
Compares the data of Sa and Sb when the compare control input "EN" =1 or "EN
↑
" (
P
instruction) from 0 to
1. If the data of Sa is equal to Sb, then set FO0 to 1. If the data of Sa>Sb, then set FO1 to 1. If the data of
Sa<Sb, then set FO2 to 1. If the data of Sa < Sb, then set the FO2 to 1.
Example
Compares the data of 16-bit register
Ladder diagram
Key operations
Mnemonic code
Sa :
Sb :
R
R
1
a=b
EN
X0
U/S
17.CMP
0
a>b
a<b
Y0
OUT
ORG
ORG X
0
FUN 17
Sa : R
0
Sb : R
1
FO 2
OUT Y
0
●
From the above example, we first assume the data of R0 is 1 and R1 is 2, and then compare the data by
executing the CMP instruction. The FO0 and FO1 are set to 0 and FO2 (a<b) is set to 1 since a<b.
●
If you want to have the compound results, such as
≧、≦、
< > etc., please send =
、
< and > results to relay first
and then combine the result from the relays.
●
M1919=0, when this command in not executed, FO0, FO1, FO2 will remain in the status at last execution.
●
M1919=1, when this command in not executed, FO0, FO1, FO2 are all cleared to 0.
●
Control M1919 properly to obtain memory-holding function for functional command output.