Mitsubishi Electric FX2N Beginners Manual page 99

Hide thumbs Also See for FX2N:
Table of Contents

Advertisement

More Advanced Programming
In this example the CMP instruction controls relays M0, M1 and M2. M0 is "1" if the contents
of D0 is greater than 100; M1 is "1" if the contents of D0 is precisely 100 and M2 is "1" if D0 is
less than 100. The state of the three bit devices is maintained even after the input condition
has been switched off because their last state is stored.
To compare 32-bit data you just use DCMP instead of CMP:
Ladder Diagram
0
In the example above the contents of D0 and D1 are compared with the contents of D2 and D3.
The handling of the three bit devices indicating the result of the comparison is exactly the same
as for the 16-bit version of the instruction.
Application example
It is easy to create a two-point control loop with the CMP instruction:
Ladder Diagram
M8000
0
M20
8
M22
10
In this example the CMP instruction is executed cyclically. M8000 is always "1" when the PLC is
executing the program. Register D20 contains the value for the current room temperature.
Constant K22 contains the setpoint value of 22°C. Relays M20 and M22 show when the tem-
perature goes higher or lower than the setpoint. If the room is too warm output Y0 is switched
off. If the temperature is too low M22 switches output Y0 on again. This output could be used to
control a pump for adding hot water, for example.
FX Beginners Manual
DCMP D0 D2 M0
CMP D20 K22 M20
RST Y000
SET Y000
Compare Instructions
Instruction List
0 LD
....
1 DCMP
D0
D2
Instruction List
0 LD
M8000
1 CMP
D20
K22
8 LD
M20
9 RST
Y000
10 LD
M22
11 SET
Y0001
M0
M20
5 – 17

Advertisement

Table of Contents
loading

Table of Contents