Beginner’s Manual for the programmable logic controllers of the
MELSEC FX family FX
1S,FX1N,FX2N,FX2NC,FX3G,FX3GC,FX3GE,FX3S,FX3U und FX3UC
Art. no.: 166388
VersionRevisions / Additions / Corrections
A01/2006pdp-trFirst edition
B01/2007pdp-dkAddition of chapter 7
Considering of the extended product range for the base units of the FX
and 2.4.
C07/2009pdp-dkConsideration of the controllers of the FX
New adapter modules FX
D——Version skipped for internal reasons
E08/2013pdp-dkConsideration of the FX
New adapter module FX
New intelligent function module FX
Consideration of the programming software GX Works2 FX
3U-4AD-PNK-ADP and FX3U-4AD-PTW-ADP
3GC, FX3GE and the FX3S series controllers
3U-3A-ADP
3U-4LC
3U series in chapters 2.3
3G and the FX3UC series
Safety Guidelines
Safety Guidelines
For use by qualified staff only
This manual is only intended for use by properly trained and qualified electrical technicians
who are fully acquainted with the relevant automation technology safety standards. All work
with the hardware described, including system design, installation, configuration, mainten
ance, service andtesting of the equipment,may only be performed by trained electrical techni
cians with approved qualifications who are fully acquainted with all the applicable automation
technology safety standards and regulations.Any operations or modifications to the hardware
and/or software of our products not specifically described in this manual may only be
performed by authorised Mitsubishi Electric staff.
Proper use of the products
-
-
The programmable logic controllers of the FX
FX
3S,FX3U and FX3UC series are only intended for the specific applications explicitly
described in this manual. All parameters and settings specified in this manual must be
observed. The products described have all been designed, manufactured, tested and docu
mented in strict compliance with the relevant safety standards. Unqualified modification of the
hardware or software or failure to observe the warnings on the products and in this manual
may result in serious personal injury and/or damage to property. Only peripherals and expan
sion equipment specifically recommended and approved by Mitsubishi Electric may be used
with the programmable logic controllers of the FX
FX
3GE,FX3S,FX3U and FX3UC series.
All and any other uses or application of the products shall be deemed to be improper.
Relevant safety regulations
All safety and accident prevention regulations relevant to your specific application must be
observed in the system design, installation, configuration, maintenance, servicing and testing
of these products. The regulations listed below are particularly important in this regard. This
list does not claim to be complete, however; you are responsible for being familiar with and
conforming to the regulations applicable to you in your location.
쎲
VDE Standards
–
VDE 0100
Regulations for the erection of power installations with rated voltages below 1000 V
–
VDE 0105
Operation of power installations
–
VDE 0113
Electrical installations with electronic equipment
–
VDE 0160
Electronic equipment for use in power installations
–
VDE 0550/0551
Regulations for transformers
–
VDE 0700
Safety of electrical appliances for household use and similar applications
–
VDE 0860
Safety regulations for mains-powered electronic appliances and their accessories for
household use and similar applications.
1S,FX1N,FX2N,FX2NC,FX3G,FX3GC,FX3GE,
1S,FX1N,FX2N,FX2NC,FX3G,FX3GC,
-
-
쎲
Fire safety regulations
FX Beginners ManualI
Safety Guidelines
쎲
Safety warnings in this manual
In this manual warnings that are relevant for safety are identified as follows:
DANGER:
Failure to observe the safety warnings identified with this symbol can result in health
P
E
and injury hazards for the user.
WARNING:
Failure to observe the safety warnings identified with this symbol can result in damage
to the equipment or other property.
Accident prevention regulations
VBG Nr.4
–
Electrical systems and equipment
IIMITSUBISHI ELECTRIC
P
Safety Guidelines
General safety information and precautions
The following safety precautions are intended as a general guideline for using PLC systems
together with other equipment. These precautions must always be observed in the design,
installation and operation of all control systems.
DANGER:
Observe all safety and accident prevention regulations applicable to your spe
쎲
cific application. Always disconnect all power supplies before performing
installation and wiring work or opening any of the assemblies, components and
devices.
Assemblies, components and devices must always be installed in a shockproof
쎲
housing fitted with a proper cover and fuses or circuit breakers.
Devices with a permanent connection to the mains power supply must be inte
쎲
grated in the building installations with an all-pole disconnection switch and a
suitable fuse.
-
-
Check power cables and lines connected to the equipment regularly for breaks
쎲
and insulation damage. If cable damage is found immediately disconnect the
equipment and the cables from the power supply and replace the defective
cabling.
Before using the equipment for the first time check that the power supply rating
쎲
matches that of the local mains power.
쎲
Take appropriate steps to ensure that cable damage or core breaks in the signal
lines cannot cause undefined states in the equipment.
쎲
You are responsible for taking the necessary precautions to ensure that programs interrupted by brownouts and power failures can be restarted properly
and safely. In particular, you must ensure that dangerous conditions cannot
occur under any circumstances, even for brief periods.
쎲
EMERGENCY OFF facilities conforming to EN 60204/IEC 204 and VDE 0113
must remain fully operative at all times and in all PLC operating modes. The
EMERGENCY OFF facility reset function must be designed so that it cannot
ever cause an uncontrolled or undefined restart.
쎲
You must implement both hardware and software safety precautions to prevent
the possibility of undefined control system statescaused by signal line cable or
core breaks.
쎲
When using modules always ensure that all electrical and mechanical specifi
cations and requirements are observed exactly.
This manual will help you to familiarise yourself with the use of the MELSEC FX family of pro
grammable logic controllers. It is designed for users who do not yet have any experience with
programming programmable logic controllers (PLCs).
Programmers who already have experience with PLCs from other manufacturers can also use
this manual as a guide for making the transition to the MELSEC FX family.
The symbol "쏔" is used as a placeholder to identify different controllers in the same range.For
example, the designation "FX
begins with FX
FX
1S-10 MT-ESS/UL.
1S-10, i.e. FX1S-10MR-DS, FX1S-10 MR-ES/UL, FX1S-10 MT-DSS and
1.2More Information
You can find more detailed information on the individual products in the series in the operating
and installation manuals of the individual modules.
See the MELSEC FX Family Catalogue, art. no. 167840, for a general overview of all the controllers in the MELSEC FX family. This catalogue also contains information on expansion
options and the available accessories.
For an introduction to using the programming software package see the various beginner’s or
training manuals for the software in use.
You can find detailed documentation of all programming instructions in the Programming Manual for the MELSEC FX family, art. no. 132738.
-
1S-10쏔-쏔쏔" is used to refer to all controllers whose name
The communications capabilities and options of the MELSEC FX controllers are documented
in detail in the Communications Manual, art. no. 070143.
All Mitsubishi manuals and catalogues can be downloaded free of charge from the Mitsubishi
website at
www.mitsubishi-automation.com
.
FX Beginners Manual1–1
More InformationIntroduction
1–2MITSUBISHI ELECTRIC
Programmable Logic ControllersWhat is a PLC?
2Programmable Logic Controllers
2.1What is a PLC?
In contrast to conventional controllers with functions determined by their physical wiring the
functions of programmable logic controllers orPLCs are defined by a program. PLCs also have
to be connected to the outside world withcables,but the contents of their program memory can
be changed at any time to adapt their programs to different control tasks.
Programmable logic controllers input data, process it and then output the results. This process
is performed in three stages:
an input stage,
쎲
a processing stage
쎲
and
an output stage
쎲
Programmable Logic Controller
Input
Switch
Input Stage
The input stage
The input stage passes control signals from switches, buttons or sensors on to the processing
stage.
The signals from these components aregenerated as part of the control process and are fed to
the inputs as logical states. The input stage passes them on to the processing stage in a
pre-processed format.
The processing stage
Processing Stage
Output
Contactors
Output Stage
In the processing stage the pre-processed signals from the input stage are processed and
combined with the help of logical operations and other functions. The program memory of the
processing stage is fullyprogrammable. The processing sequence canbe changed at any time
by modifying or replacing the stored program.
The output stage
The results of the processing of the input signals by the program are fed to the output stage
where they control connected switchable elements such as contactors, signal lamps, solenoid
valves and so on.
FX Beginners Manual2–1
How PLCs Process ProgramsProgrammable Logic Controllers
....
....
....
2.2How PLCs Process Programs
A PLC performs its tasks by executing a program that is usually developed outside the control
ler and then transferred to the controller’s program memory. Before you start programming it is
useful to have a basic understanding of how PLCs process these programs.
A PLC program consists of a sequence of instructions that control the functions of the control
ler.The PLC executes these control instructions sequentially, i.e. one after another.The entire
program sequence is cyclical, which means that it is repeated in a continuous loop. The time
required for one program repetition is referred to as the program cycle time or period.
Process image processing
The program in the PLC is not executed directly on the inputs and outputs, but on a “process
image” of the inputs and outputs:
Switch on PLC
Delete output memory
Input signals
Input terminals
Poll inputs and signal states
and save them in the process
image of the inputs
-
-
PLC program
Process image
of inputs
Process image
of outputs
Output terminals
Output signals
Instruction 1
Instruction 2
Instruction 3
Instruction n
Transfer process image
to outputs
Input process image
At the beginning of each program cycle the system polls the signal states of the inputs and
stores them in a buffer, creating a “process image” of the inputs.
2–2MITSUBISHI ELECTRIC
Programmable Logic ControllersHow PLCs Process Programs
M6
M2
M1 M8013
4
X000 X001
0
9
M0
Y000
M0
Y001
Program execution
After this the program is executed, during which the PLC accesses the stored states of the
inputs in the process image.This means that any subsequent changes in the input states will
not be registered until the next program cycle!
The program is executed from top to bottom, in the order in which the instructions were pro
grammed.Results of individual programming steps are stored and can be used during the cur
rent program cycle.
Program execution
Store result
Control output
Process stored result
-
-
Output process image
Results of logical operations that arerelevant for the outputsare stored in an output buffer – the
output process image. The output process image is stored in the output buffer until the buffer is
rewritten. After the values have been written to the outputs the program cycle is repeated.
Differences between signal processing in the PLC and in hard-wired controllers
In hard-wired controllers the program is defined by the functional elements and their connec
tions (the wiring). All control operations are performed simultaneously (parallel execution).
Every change in an input signal state causes an instantaneous change in the corresponding
output signal state.
In a PLC it is not possible to respond to changes in input signal states until the next program
cycle after the change.Nowadays this disadvantage is largely compensated by very short pro
gram cycle periods. The duration of the program cycle period depends on the number and type
of instructions executed.
-
-
FX Beginners Manual2–3
The MELSEC FX FamilyProgrammable Logic Controllers
2.3The MELSEC FX Family
The compact micro-controllers of the MELSEC FX series provide the foundation for building
economical solutions for small to medium-sized control and positioning tasks requiring 10 to
256 integrated inputs and outputs in applications in industry and building services.
With the exception of the FX
pace with the changes in the application and the user’s growing requirements.
Network connections are also supported. This makes it possible for the controllers of the FX
family to communicate with other PLCs and controller systems and HMIs (Human-Machine
Interfaces and control panels). The PLC systems can be integrated both in MITSUBISHI net
works as local stations and as master or slave stations in open networks like PROFIBUS DP.
In addition to this you can also build multi-drop and peer-to-peer networks with the controllers
of the MELSEC FX family.
The FX
ities, making them the right choice for complex applications and tasks requiring special func
tions like analog-digital and digital-analog conversion and network capabilities.
All the controllers in the series are part of the larger MELSEC FX family and are fully compati
ble with one another.
Specifications
Max integrated
I/O points
Expansion capability
(max. possible I/Os)
Program memory
(steps)
Cycle time per
log. instruction (ms)
No. of instructions
(standard / step ladder /
special function)
Max. special function
modules connectable
1S all the controllers of the FX series can be expanded to keep
1N,FX2N,FX3G,FX3GC,FX3GE,FX3S,FX3U or FX3UC have modular expansion capabil
Programmable Logic ControllersSelecting the Right Controller
2.4Selecting the Right Controller
The base units of the MELSECFX family are available in a number of different versions with dif
ferent power supply options and output technologies. You can choose between units designed
for power supplies of100–240 V AC, 24 V DC or 12–24 VDC, and between relay and transistor
outputs.
SeriesI/OsType
FX
1S
1N
FX
2N
FX
2NC
FX
3G
FX
FX
3GC32
FX3GE
FX
3S
3U
FX
3UC
FX
10
14
20
30
14
24
40
60
16
32
48
64
80
128
16
32
64
96
14
24
40
60
24FX3GE-24MR/ES168
40FX
10
14
20
30
16
32
48
64
80
128
16
32
64
96
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
FX
No. of
inputs
1S-10 M쏔-쏔쏔
1S-14 M쏔-쏔쏔
1S-20 M쏔-쏔쏔
1S-30 M쏔-쏔쏔
1N-14 M쏔-쏔쏔
1N-24 M쏔-쏔쏔
1N-40 M쏔-쏔쏔
1N-60 M쏔-쏔쏔
2N-16 M쏔-쏔쏔
2N-32 M쏔-쏔쏔
2N-48 M쏔-쏔쏔
2N-64 M쏔-쏔쏔
2N-80 M쏔-쏔쏔
2N-128 M쏔-쏔쏔
2NC-16 M쏔-쏔쏔
2NC-32 M쏔-쏔쏔
2NC-64 M쏔-쏔쏔
2NC-96 M쏔-쏔쏔
3G-14 M쏔/쏔쏔쏔
3G-24 M쏔/쏔쏔쏔
3G-40 M쏔/쏔쏔쏔
3G-60 M쏔/쏔쏔쏔
3GC-32MT/D쏔쏔
3GE-40MR/ES1614
3S-10 M쏔/ES쏔
3S-14 M쏔/ES쏔
3S-20 M쏔/ES쏔
3S-30 M쏔/ES쏔
3U-16 M쏔-쏔쏔
3U-32 M쏔-쏔쏔
3U-48 M쏔-쏔쏔
3U-64 M쏔-쏔쏔
3U-80 M쏔-쏔쏔
3U-128 M쏔-쏔쏔
3UC-16 M쏔/쏔쏔쏔
3UC-32 M쏔/쏔쏔쏔
3UC-64 M쏔/쏔쏔쏔
3UC-96 M쏔/쏔쏔쏔
68
86
128
1614
86
1410
2416
3624
88
1616
2424
3232
4040
6464
88
1616
3232
4848
86
1410
2416
3624
161624 V DCTransistor
64
86
128
1614
88
1616
2424
3232
4040
6464100 – 240 V AC
88
1616
3232
4848
No. of
outputs
Power supplyOutput type
24 V DC
or
100 – 240 V AC
12 – 24 V DC
or
100 – 240 V AC
24 V DC
or
100 – 240 V AC
24 V DC
Transistor
or relay
Transistor
or relay
Transistor
or relay
Transistor
or relay
Optional
100 – 240 V AC
Transistor
or relay
100 – 240 V ACRelay
Optional
100 – 240 V AC
Transistor
or relay
24 V DC
or
100 – 240 V AC
Transistor
or relay
Transistor
or relay
24 V DCTransistor
-
FX Beginners Manual2–5
Selecting the Right ControllerProgrammable Logic Controllers
To choose the right controller for your application you need to answer the following questions:
How many signals (external switch contacts, buttons and sensors)do you need to input?
쎲
What types of functions do you need to switch, and how many of them are there?
쎲
What power supply options are available?
쎲
How high are the loads that the outputs need to switch? Choose relay outputs for switching
high loads and transistor outputs for switching fast, trigger-free switching operations.
2–6MITSUBISHI ELECTRIC
Programmable Logic ControllersController Design
0123
4567
0123
45
IN
OUT
POWER
FX -14MR
1S
RUN
ERROR
X7
X5
X3
X1
S/S
X6
X4
X2
X0
N
L
100-240
VAC
14MR
-ES/UL
Y4
Y2
Y1
Y0
COM0
COM1
COM2
Y3
Y5
24V
0V
MITSUBISHI
2.5Controller Design
All the controllers in the series have the same basic design. The main functional elements and
assemblies are described in the glossary in section 2.5.7.
2.5.1Input and output circuits
The input circuits use floating inputs. They are electrically isolated from the other circuits of
the PLC with optical couplers. The output circuits use either relay or transistor output techno
logy.The transistor outputs are also electrically isolated from the other PLC circuits withoptical
couplers.
-
The switching voltage at all the digital inputs must have a certain value (e.g.24 V DC). This volt
age can be taken from the PLC’s integrated power supply unit. If the switching voltage at the
inputs is less than the rated value (e.g. <24 V DC) then the input will not be processed.
The maximum output currents are 2 A on 250 V three-phase AC and non-reactive loads with
relay outputs and 0.5 A on 24 V DC and non-reactive loads.
2.5.2Layout of the MELSEC FX1S base units
Mounting hole
Power supply
connection
Interface for expansion
adapter boards
Cutout for adapters or
control panel
2 analog potentiometers
Connection for
programming units
Connection for the
service power supply
Terminals for
digital outputs
-
Protective cover
Terminal cover
Terminals for
digital inputs
LEDs for indicating
the input status
RUN/STOP switch
LEDs for indicating
the operating status
LEDs for indicating
the output status
Protective cover
FX Beginners Manual2–7
Controller DesignProgrammable Logic Controllers
0123
4567
8 9 10 11
1213 14 15
0123
4567
1011
IN
OUT
POWER
FX -24MR
1N
RUN
ERROR
100-240
VAC
X7
X11
X13
X15
X5
X3
X1
S/S
X6
X10
X12
X14
X4
X2
X0
N
L
24MR
-ES/UL
Y10
Y6
Y5
Y3
COM3
Y4
COM4
Y7
Y11
COM2
COM1
COM0
24+
Y2
Y1
Y0
0V
MITSUBISHI
2.5.3Layout of the MELSEC FX1N base units
Protective cover
Terminals for
Terminal cover
Mounting hole
digital inputs
Connection of the
power supply
RUN/STOP switch
Slot for memory cassettes,
adapters and displays
2 analog
potentiometers
Connection for
programming units
Connection for the
service power supply
Terminals for
digital outputs
Terminal cover
Protective cover
2.5.4Layout of the MELSEC FX
Connection for the
service power supply
Extension bus
LEDs for indicating
the input status
LEDs for indicating
the operating status
LEDs for indicating
the output status
Housing cover
Lid
2N base units
Terminal cover
Mounting hole
Connection for
expansion adapter boards
Memory battery
Connection for
programming units
RUN/STOP switch
Removable terminal
strip for digital outputs
Housing cover
Slot for memory
cassettes
Terminals for
digital inputs
LEDs for indicating
the input status
LEDs for indicating
the operating status
Connection for
extensions
Protective cover des
Erweiterungsbusses
LEDs for indicating
the output status
Protective cover
2–8MITSUBISHI ELECTRIC
Programmable Logic ControllersController Design
POWER
RUN
BATT
ERROR
X0
1
2
3
X4
5
6
7
Y0
1
2
3
Y4
5
6
7
RUN
STOP
MITSUBISHI
FX -16MR-T-DS
2
N
C
MELSEC
COM
X7
X6
X5
X4
•
COM
X3
X2
X1
X0
Y4
•
COM1
Y3
Y2
Y1
Y0
2.5.5Layout of the MELSEC FX2NC base units
Protective cover
Memory battery
Battery
compartment
RUN/STOP switch
Operating status LEDs
2nd interface
for CNV adapter
Cover
Memory cassette
(optional)
Memory cassette slot
Terminals for
digital inputs
Terminals for
digital outputs
2.5.6Layout of the MELSEC FX
Extension bus
(on side)
Protective cover
for expansion bus
LEDs for indicating
the output status
LEDs for indicating
the input status
Connector for
terminal strips
3G base units
Protective cover
Slots for memory
cassette, display and
expansion adapter
2 analog setpoint
potentiometers
RUN/STOP switch
Mount for
optional battery
Connection for program
ming unit (RS422)
Connection for program
ming unit (USB)
Cover for programming
unit connections, poten
tiometer and
RUN/STOP switch
Cover of the left
expansion slot
Shock protection
Terminal strip for
digital inputs
LEDs for indicating
input status
LEDs for indicating
operating mode
Cover for expansion
-
bus
LEDs for indicating
output status
-
Output terminals
Shock protection
-
Protective cover
Cover of the right
expansion slot and
the optional battery
FX Beginners Manual2–9
Controller DesignProgrammable Logic Controllers
2.5.7Layout of the MELSEC FX3GC base units
LEDs for indicating
the operating status
Protective cover for
Peripheral device connector
(USB)
LEDs for indicating
the input status
Special adapter connector
cover
Special adapter
connector
Terminals for digital inputs
expansion bus
RUN/STOP-Schalter
Peripheral device connector
(RS-422)
LEDs for indicating the
output status
Terminals for digital outputs
Battery connector
Battery
2.5.8Layout of the MELSEC FX
Slot for memory
cassette, display and
expansion adapter
Terminals for analog inputs
2 analog potentiometers
RUN/STOP switch
Special adapter connector
RS-422 Interface
USB Interface
RJ45 connector
(10BASE-T/100BASE-TX)
Terminals for analog
output
Battery cover
3GE base units
Protective cover
Shock protection
Terminals for digital
inputs
LEDs for indicating
input status
Battery holder
LEDs for indicating
operating mode
Cover for expansion
bus
LEDs for output status
Terminals for digital
outputs
Shock protection
Protective cover
Cover for interfaces,
potentiometer and
RUN/STOP switch
Cover of the expansion
slot and the optional
battery
2–10MITSUBISHI ELECTRIC
Programmable Logic ControllersController Design
2.5.9Layout of the MELSEC FX3S base units
Protective cover
Shock protection
Power supply terminals
Slot for memory cassette and
expansion adapter
LEDs for input status
LEDs for indicating
operating mode
LEDs for indicating
output status
Terminals for digital outputs
Terminals for digital inputs
2 analog potentiometers
RUN/STOP switch
USB Interface
RS-422 Interface
Cover for interfaces, potentiometer and RUN/STOP switch
Cover of the expansion slot
Shock protection
Protective cover
FX Beginners Manual2–11
Controller DesignProgrammable Logic Controllers
2.5.10Layout of the MELSEC FX3U base units
Battery cover
Memory battery
Installation place for the
FX3U-7DM display
Blind cover for
expansion board
RUN/STOP switch
Connection for
programming unit
To p c o ve r
(used if FX3U-7DM
is not installed)
Protective cover
Terminal cover
Terminals for
digital inputs
LEDs for indicating
the input status
LEDs for indicating
the operating status
Protective cover for
expansion bus
LEDs for indicating
the output status
Output terminals
Terminal cover
Protective cover
2.5.11Layout of the MELSEC FX
RUN/STOP switch
LEDs for indicating
operating mode
Slot for memory
cassettes
Memory cassette
(optional)
Cover of the adapter
board terminal
3UC base units
LEDs for indicating
input status
LEDs for indicating
output status
Protective cover for
expansion bus
Expansion bus
(to the side)
Connection for
programming unit
Buffer battery
Cover for battery
compartment
Te rmi n al s f o r
digital outputs
Te rmi n al s f o r
digital inputs
2–12MITSUBISHI ELECTRIC
Programmable Logic ControllersController Design
2.5.12PLC components glossary
The following table describes the meaning and functionality of the single components und
parts of a Mitsubishi PLC.
ComponentDescription
Connection for
expansion
adapter boards
Connection for pro
gramming units
EEPROM
Memory cassette slot
Extension bus
Analog
potentiometers
Service power supply
Digital inputs
Digital outputs
LEDs for indicating
the input status
LEDs for indicating
the output status
LEDs for indicating
the operating status
Memory battery
RUN/STOP switch
-
Optional expansion adapter boards can be connected to this interface. A variety of differ
ent adapters are available for all FX lines (except the FX
adapters extend the capabilities of the controllers with additional functions or communica
tions interfaces. The adapter boards are plugged directly into the slot.
This connection can be used for connecting the FX-20P-E hand-held programming unit or
an external PC or notebook with a programming software package (e.g. GX Works2 FX).
Read/write memory in which the PLC program can be stored and read with the program
ming software. This solid-state memory retains its contents without power, even in the
event of a power failure, and does not need a battery.
Slot for optional memory cassettes. Inserting a memory cassette disables the controller’s
internal memory – the controller will then only execute the program stored in the cassette.
Both additional I/O expansion modules and special function modules that add additional
capabilities to the PLC system can be connected here. See chapter 6 for an overview of
the available modules.
The analog potentiometers are used for setting analog setpoint values. The setting can be
polled by the PLC program and used for timers, pulse outputs and other functions (see
Section 4.6.1).
The service power supply (not for FX
DC power supply source for the input signals and the sensors. The capacity of this power
supply depends on the controller model (e.g. FX
400 mA; FX
2N-64M쏔-쏔쏔: 460 mA)
FX
The digital inputs are used for inputting control signals from the connected switches, buttons or sensors. These inputs can read the values ON (power signal on) and OFF (no
power signal).
You can connect a variety of different actuators and other devices to these outputs,
depending on the nature of your application and the output type.
These LEDs show which inputs are currently connected to a power signal, i.e. a defined
voltage. When a signal is applied to an input the corresponding LED lights up, indicating
that the state of the input is ON.
These LEDs show the current ON/OFF states of the digital outputs. These outputs can
switch a variety of different voltages and currents depending on the model and output
type.
The LEDs RUN, POWER and ERROR show the current status of the controller. POWER
shows that the power is switched on, RUN lights up when the PLC program is being exe
cuted and ERROR lights up when an error or malfunction is registered.
The battery protects the contents of the MELSELC PLC’s volatile RAM memory in the
event of a power failure (FX
latched ranges for timers, counters and relays. In addition to this it also provides power for
the integrated real-time clock when the PLC’s power supply is switched off.
MELSEC PLCs have two operating modes, RUN and STOP. The RUN/STOP switch
allows you to switch between these two modes manually.
In RUN mode the PLC executes the program stored in its memory.
In STOP mode program execution is stopped.
2N-16M쏔-쏔쏔 through FX2N-32M쏔-쏔쏔: 250 mA, FX2N-48M쏔-쏔쏔 through
2N, FX2NC, FX3GC, FX3U and FX3Uc only). It protects the
2NC, FX3GC and FX3UC) provides a regulated 24V
2NC and the FX3GC). These
1S, FX1N, FX3G, FX3GE and FX3S:
-
-
-
-
FX Beginners Manual2–13
Controller DesignProgrammable Logic Controllers
2–14MITSUBISHI ELECTRIC
An Introduction to ProgrammingStructure of a Program Instruction
X0
3An Introduction to Programming
A program consists of a sequence of program instructions. These instructions determine the
functionality of the PLC and they are processed sequentially, in the order in which they were
entered by the programmer. To create a PLC program you thus need to analyse the process to
be controlled and break it up into steps that can be represented by instructions. A program
instruction, represented by a line or “rung” in ladder diagram format, is the smallest unit of a
PLC application program.
3.1Structure of a Program Instruction
A program instruction consists of the instruction itself (sometimes referred to as a command)
and one or more (in the case of applied instructions) operands, which in a PLC are references
to devices. Some instructions are entered on their own without specifying any operands –
these are the instructions that control program execution in the PLC.
Every instruction you enter is automatically assigned a step number that uniquely identifies its
position in theprogram.This is important because it is quite possible to enter the same instruc
tion referring to the same device in several places in the program.
-
The illustrations below show how program instructions are represented in the Ladder Diagram
(LD, left) and Instruction List (IL, right) programming language formats:
Device
Device
AND X0
Instruction
Instruction
The instruction describes what is to be done, i.e. the function you want the controller to per
form. The operand or device is what you want to perform the function on. Its designation con
sists of two parts, the device name and the device address:
X0
Device addressDevice name
Examples of devices:
Device nameTypeFunction
X
Y
M
T
C
D
InputInput terminal on the PLC (e.g. connected to a switch)
OutputOutput terminal on the PLC (e.g. for a contactor or lamp)
RelayA buffer memory in the PLC that can have two states, ON or OFF
TimerA “time relay” that can be used to program timed functions
CounterA counter
Data register
Data storage in the PLC in which you can store things like measured
values and the results of calculations.
-
-
See Chapter 4 for a detailed description of the available devices.
The specific device is identified by its address.For example, since every controller has multiple
inputs you need to specify both the device name and the address in order to read a specific
input.
FX Beginners Manual3–1
Bits, Bytes and WordsAn Introduction to Programming
0000000000000000
3.2Bits, Bytes and Words
As in all digital technology, the smallest unit of information in a PLC is a “bit”. A bit can only have
two states: “0” (OFF or FALSE) and “1” (ON or TRUE). PLCs have a number of so-called bitdevices that can only have two states, including inputs, outputs and relays.
The next larger information units are the “byte”, which consists of 8 bits, and the “word”, which
consists of two bytes. In the PLCs of the MELSEC FX families the data registers are “word
devices”, which means that they can store 16-bit values.
Bit 15Bit 0
1 Byte1 Byte
1 Word
Since a data register is 16 bits wide it can store signed values between -32,768 and +32,767
(see Chapter 3.3). When larger values need to be stored two words are combined to form a
32-bit long word, which can store signedvalues between -2,147,483,648 and +2,147,483,647.
Counters make use of this capability, for example.
3.3Number Systems
The PLCs of the MELSEC FX family use several different number systems for inputting and
displaying values and for specifying device addresses.
Decimal numbers
The decimal number system is the system we use most commonly in everyday life.It is a “positional base 10” system, in which each digit (position) in a numeral is ten times the value of the
digit to its right. After the count reaches 9 in each position the count in the current position is
returned to 0 and the next position is incremented by 1 to indicate the next decade (9 à 10, 99
à 100, 199 à 1,000 etc).
–
Base: 10
–
Digits:0,1,2,3,4,5,6,7,8,9
In the MELSEC FX family of PLCs decimal numbers are used for entering constants and the
setpoint values for timers and counters. Device addresses are also entered in decimal format,
with the exception of the addresses of inputs and outputs.
Binary numbers
Like all computers aPLC can only really distinguish between two states, ON/OFF or 0/1.These
“binary states” are stored in individual bits. When numbers need to be entered or displayed in
other formats the programming software automatically converts the binary numbers into the
other number systems.
–
Base: 2
–
Digits: 0 and 1
3–2MITSUBISHI ELECTRIC
An Introduction to ProgrammingNumber Systems
0000000000000000
2
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
2
10
2
11
2
12
2
13
2
14
2
15
When binary numbers are stored in a word (see above) the value of each digit (position) in the
word is one power of 2 higher than that of the digit to its right. The principle is exactly the same
as in decimal representation, but with increments of 2 instead of 10 (see graphic):
Base 2 NotationDecimal ValueBase 2 NotationDecimal Valuet
0
2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
128256
229512
42101024
82112048
162
322
642
1282
12
13
14
15
4096
8192
16384
32768*
In binary values bit 15 is used to represent the sign (bit 15=0: positive value, bit 15=1: negative value)
*
To convert a binary value to a decimal value you just have to multiply eachdigit with a value of 1
by its corresponding power of 2 and calculate the sum of the results.
Hexadecimal numbers are easier to handle than binary and it is very easy to convert binary
numbers to hexadecimal. This is why hexadecimal numbers are used so often in digital tech
nology and programmable logic controllers. In the controllers of the MELSEC FX family hexa
decimal numbers are used for the representation of constants. In the programming manual
and other manuals hexadecimal numbers are always identified with an H after the number to
avoid confusion with decimal numbers (e.g. 12345
–
Base: 16
–
Digits:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F(thelettersA,B,C,D,EandFrepresentthe
decimal values 10, 11, 12, 13, 14 and 15)
The hexadecimal system works in the same way as the decimal system – you just count to F
(15) instead of to 9 before resetting to 0 and incrementing the next digit (FH à 10H,1FH à 20H,
2F
H à 30H,FFH à 100H etc). The value of digit is a power of 16, rather than a power of 10:
9
+1x24+1x23+1x2
H).
0
-
-
H
1A7FH
160= 1(in this example: 15 x 1= 15)
161= 16(in this example: 7 x 16= 112)
162= 256(in this example: 10 x 256= 2560)
3
= 4096(in this example: 1 x 4096= 4096)
16
6783 (decimal)
FX Beginners Manual3–3
Number SystemsAn Introduction to Programming
1111 0110 101 10011
15
5119
F
5B9
The following example illustrates why it is so easy to convert binary values hexadecimal
values:
Binary
Decimal*
Hexadecimal
Converting the 4-bit blocks to decimal values does not directly produce a value that corresponds to the complete
*
16-bit binary value! In contrast, the binary value can be converted directly to hexadecimal notation with exactly the
same value as the binary value.
Octal numbers
Inputs X8 and X9 and outputs Y8 and Y9 do not exist on thebase units of the MELSEC FX fam
ily. This is because the inputs and outputs of MELSEC PLCs are numbered using the octal
number system, in which the digits 8 and 9 don’t exist. Here, the current digit is reset to 0 and
the digit in the next position is incremented after the count reaches 7 (0 – 7, 10 – 17, 70 – 77,
100 – 107 etc).
–Base: 8
–Digits: 0, 1, 2, 3, 4, 5, 6, 7
Summary
The following table provides an overview of the four different number systems:
An Introduction to ProgrammingThe Basic Instruction Set
3.4The Basic Instruction Set
The instructions of the PLCs of the MELSEC FX family can be divided into two basic catego
ries, basic instructions and applied instructions, which are sometimes referred to as “applica
tion instructions”.
The functions performed by the basicinstructions are comparable to the functionsachievedby
the physical wiring of a hard-wired controller. All controllers of the MELSEC FX family support
the instructions in the basic instruction set, but the applied instructions supported vary from
model to model (see Chapter 5).
Basic instruction set quick reference
InstructionFunctionDescriptionReference
LD
LDI
OUT
AND
ANI
OR
ORI
ANB
ORB
LDP
LDF
ANDP
ANDF
ORP
ORF
SET
RST
MPS
MRD
MPP
PLS
PLF
MC
MCR
INV
LoadInitial logic operation, polls for signal state “1” (normally open)
Load inversInitial logic operation, polls for signal state “0” (normally closed)
Output instructionAssigns the result of a logic operation to a device
Logical ANDLogical AND operation, polls for signal state “1”
AND NOTLogical AND NOT operation, polls for signal state “0”
Logical ORLogical OR operation, polls for signal state “1”
OR NOTLogical OR NOT operation, polls for signal state “0"
AND Block
OR BlockConnects a serial block of circuits to the preceding serial block, in parallel.
Pulse signal
instructions
Set device
Reset device
Store, read and delete
intermediate operation
results
Pulse instructions
Master Control
Master Control Reset
InvertInverts the result of an operation
Connects a parallel branch circuit block to the preceding parallel block, in
series.
Load Pulse, load on detection of rising edge of device signal pulse
Load Falling Pulse, load on falling device signal pulse
AND Pulse, logical AND on rising device signal pulse
AND Falling Pulse, logical AND on falling device signal pulse
OR Pulse, logical OR on rising device signal pulse
OR Falling Pulse, logical OR on falling device signal pulse
Assigns a signal state that is retained even if after input condition is no
longer true
Memory Point Store, store an operation result in the stack
Memory Read, read a stored operation result from the stack
Memory POP, read a stored operation result and delete it from the stack
Pulse, sets a device for one operation cycle on the rising pulse of the input
condition (input turns ON)
Pulse Falling, sets a device* for one operation cycle on the falling pulse of
the input condition (input turns OFF)
Instructions for activating or deactivating the execution of defined parts of
the program
Chapter 3.4.1
Chapter 3.4.2
Chapter 3.4.4
Chapter 3.4.5
Chapter 3.4.6
Chapter 3.4.7
Chapter 3.4.8
Chapter 3.4.9
Chapter
3.4.10
Chapter
3.4.11
Chapter
3.4.12
-
-
FX Beginners Manual3–5
The Basic Instruction SetAn Introduction to Programming
X000
0
Y000
Y0
X0
OFF
ON
OFF
ON
t
(0)
(1)
(0)
(1)
F5
F6
F7
3.4.1Starting logic operations
InstructionFunctionSymbolGX Works2 FX
Load instruction, starts a logic operation
LD
LDI
and polls the specified device for signal
state “1”
Load instruction, starts a logic operation
and polls the specified device for signal
state “0”
A circuit in a program always begins with an LD- or LDI instruction. These instructions can be
performed on inputs, relays, timers and counters.
For examples of using these instructions see the description of the OUT instruction in the next
section.
3.4.2Outputting the result of a logic operation
InstructionFunctionSymbolGX Works2 FX
OUT
Output instruction, assigns the result of
an operation to a device
The OUT instruction can be used to terminate a circuit.You can also program circuits that use
multiple OUT instructions as their result. This is not necessarily the end of the program, however. The device set with the result of the operation using OUT can then be used as an input
signal state in subsequent steps of the program.
Example (LD and OUT instructions)
Ladder Diagram
Instruction List
0LDX000
1OUTY000
These two instructions result in the following signal sequence:
The condition of the LD instruction (poll for signal state “1”) is true so the result of the
operation is also true (“1”) and the output is set.
3–6MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
X005
X003
M10
X004
X001
X000
0
Y000
Y0
X0
t
(0)
(1)
(0)
(1)
OFF
ON
OFF
ON
X005
X003
M10
M10
X004
X001
Example (LDI and OUT instructions)
Ladder Diagram
Instruction List
0LDIX000
1OUTY000
The condition of the LDI instruction (poll for signal state “0”) is no
longer true so the output is reset.
Double assignment of relays or outputs
Never assign the result of an operation to the same device in more than one place in the
program!
The program is executed
sequentially from top to bottom, so in this example the
second assignment of M10
would simply overwrite the
result of the first assignment.
You can solve this problem
with modification shown on
the right. This takes all the
required input conditions
into account and sets the
result correctly.
FX Beginners Manual3–7
The Basic Instruction SetAn Introduction to Programming
Y000
X000
0
24 V
X0
Y0
X0
OFF
ON
OFF
ON
t
Y000
X000
0
24 V
X0
Y0
X0
OFF
ON
OFF
ON
t
LD X000
OUT Y000
OUT Y000
LDI X000
Switch operated
Switch operated
3.4.3Using switches and sensors
Before we continue with the description of the rest of the instructions we should first describe
how signals from switches, sensors and so on can be used in your programs.
PLC programs need to be able respond to signals from switches, buttons and sensors to per
form the correct functions. It is important to understand that program instructions can only poll
the binary signal state
of the specified input – irrespective of the type of input and how it is
controlled.
As you can imagine, this means that when
Make
contact
When a make contact is ope
rated the input is set (ON, sig
nal state “1”)
you are writing your program you need to be
-
aware whether the element connected to the
-
input of your PLC is a make or abreak device.
An input connected toa make device must be
treated differently to an input connected to a
break device. The following example illustra
-
tes this.
Break
contact
When a break contact is ope
rated the input is reset (OFF,
signal state “0”)
Usually, switches with make contacts are used. Sometimes, however, break contacts are used
for safety reasons – for example for switching off drives (see section 3.5).
The illustration below shows two program sequences in which the result is exactly the same,
even though different switch types are used: When the switch is operated the output is set
(switched on).
-
-
3–8MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
X0000X001
Y000
Y0
X0
OFF
ON
t
(0)
(1)
(0)
(1)
X1
(0)
(1)
OFF
ON
OFF
ON
F5
F6
3.4.4AND operations
InstructionFunctionSymbolGX Works2 FX
AND
ANI
Logical AND (AND operation with poll for
signal state “1” or ON)
Logical AND NOT (AND operation with
poll for signal state “0” or OFF)
An AND operation is logically the same as a
serial connection of two or more switches in
an electrical circuit. Current will only flow if all
the switches are closed.If one or more of the
switches are open no current flows – the AND
condition is false.
Note that the programming software uses the same icons and function keys for the AND and
ANI instructions as for the LD and LDI instructions. When you program in Ladder Diagram for
mat the software automatically assigns the correct instructions on the basis of the insertion
position.
When you program in Instruction List format remember that you can’t use the AND and ANI
instructions at the beginning of circuit (a program line in ladder diagram format)! Circuits must
begin with an LD or LDI instruction (see Chapter 3.4.1).
-
Example of an AND instruction
Ladder Diagram
Instruction List
AND instruction
0LDX000
1ANDX001
2OUTY000
In the example output Y0 is only switched on when inputs X0 and X1 are both on:
FX Beginners Manual3–9
The Basic Instruction SetAn Introduction to Programming
Y0
X0
t
(0)
(1)
(0)
(1)
X1
(0)
(1)
OFF
ON
OFF
ON
OFF
ON
X0000X001
Y000
Example of an ANI instruction
Ladder Diagram
Instruction List
ANI instruction
0LDX000
1ANIX001
2OUTY000
In the example output Y0 is only switched on when input X0 is on and input X1 is off:
3–10MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
X000
0
X001
Y000
Y0
X0
t
(0)
(1)
(0)
(1)
X1
(0)
(1)
OFF
ON
OFF
ON
OFF
ON
F5
F6
3.4.5OR operations
InstructionFunctionSymbolGX Works2 FX
OR
ORI
Logical OR (OR operation with poll for
signal state “1” or ON)
Logical OR NOT (OR operation with poll
for signal state “0” or OFF)
An OR operation is logically the same as the
parallel connection of multiple switches in an
electrical circuit. As soon as any of the
switches is closed current will flow.Current will
only stop flowing when all the switches are
open.
Example of an OR instruction
Ladder Diagram
OR instruction
Instruction List
0LDX000
1ORX001
2OUTY000
In the example output Y0 is switched on when either input X0 or input X1 is on:
FX Beginners Manual3–11
The Basic Instruction SetAn Introduction to Programming
Y0
X0
t
(0)
(1)
(0)
(1)
X1
(0)
(1)
OFF
ON
OFF
ON
OFF
ON
F9
X000
0
X001
Y000
Example of an ORI instruction
Ladder Diagram
Instruction List
0LDX000
1ORIX001
2OUTY000
ORI instruction
In the example output Y0 is switched on when either input X0 is on or input X1 is off:
3.4.6Instructions for connecting operation blocks
InstructionFunctionSymbolGX Works2 FX
AND Block (serial connection of blocks of
parallel operations/circuits)
OR Block (parallel connection of blocks
of serial operations/circuits)
ANB
ORB
Although ANB- and ORB arePLC instructions they are only displayed and entered asconnect
ing lines in the Ladder Diagram display. They are only shown as instructions in Instruction List
format, where you must enter them with their acronyms ANB and ORB.
Both instructions are entered without devices and can be used as often as you like in a pro
gram.However, the maximum number of LD and LDI instructions is restricted to 8, whicheffec
tively also limits the number of ORB or ANB instructions you can use before an output instruc
tion to 8 as well.
-
-
-
-
3–12MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
Y007
X000
0
M2
X001
M10
Y007
X000
0
M2
X001
M10
Example of an ANB instruction
Ladder Diagram
ANB instruction
Instruction List
0 LDX000
1ORI M2
2 LDIX001
3ORM10
4ANB
st
1
parallel connection (OR operation)
nd
2
parallel connection (OR operation)
ANB instruction connecting both OR operations
5 OUTY007
In this example output Y07 is switched on ifinput X00 is “1”, orif relay M2 is “0” and input X01 is
“0”, or if relay M10 is “1”.
Example of an ORB instruction
Ladder Diagram
ORB instruction
Instruction List
0 LDX000
1 ANIX001
2LDI M2
3AND M10
4ORB
st
1
serial connection (AND operation)
nd
2
serial connection (AND operation)
ORB instruction connecting both AND operations
5 OUTY007
In this example output Y07 is switched on ifinput X00 is “1” and inputX01 is “0”, or ifrelay M2 is
“0” and relay M10 is “1”.
FX Beginners Manual3–13
The Basic Instruction SetAn Introduction to Programming
M0
X001
0
M0
X1
OFF
ON
t
(0)
(1)
0
1
3.4.7Pulse-triggered execution of operations
InstructionFunctionSymbolGX Works2 FX
LDP
LDF
ANDP
ANDF
ORP
ORF
Load Pulse, loads on the rising edge of
the device’s signal
Load Falling Pulse, loads on the falling
edge of the device’s signal
AND Pulse, logical AND operation on the
rising edge of the device’s signal
AND Falling Pulse, logical AND operation
on the falling edge of the device’s signal
OR Pulse, logical OR operation on the
rising edge of the device’s signal
OR Falling Pulse, logical OR operation
on the falling edge of the device’s signal
In PLC programs you will often need to detect and respond to the rising or falling edge of a bit
device’s switching signal. A rising edge indicates a switch of the device value from “0” to “1”, a
falling edge indicates a switch from “1” to “0”.
During program execution operations that respond to rising and falling pulses only deliver a
value of “1” when the signal state of the referenced device changes.
When do you need to use this? For example, suppose you have a conveyor belt with a sensor
switch that activates to increment a counter every time a package passes it on the belt. If you
don’t use a pulse-triggered function you will get incorrect results because the counter will
increment by 1 in every program cycle in which the switch registers as set. If you only register
the rising pulse of the switch signal the counter will be incremented correctly, increasing by 1
for each package.
NoteMostapplied instructions can also be executed by pulse signals. For details see chapter .5).
Evaluating a rising signal pulse
Ladder Diagram
Instruction List
0LDPX001
1OUT M0
Relay M0 is only switched on for the duration of a single
program cycle
3–14MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
M374
M235X010
0
M374
M235
t
0
1
0
1
X10
OFFON(0)
(1)
F8
F8
Evaluating a falling signal pulse
Ladder Diagram
Instruction List
0LDM235
1ANDFX010
2OUTM374
If X10 is off (0) and M235 is on (1) relay M374 is switched on for the
duration of a single program cycle.
With the exception of the pulse trigger characteristic the functions of the LDP, LDF, ANDP,
ANDF, ORP and ORF instructions are identical to those of the LD, AND and OR instructions.
This means that you can use pulse-trigger operations in your programs in exactly the same
way as the conventional versions.
3.4.8Setting and resetting devices
InstructionFunctionSymbolGX Works2 FX
,
,
SET
RST
햲
The SET instruction can be used to set outputs (Y), relays (M) and state relays (S).
햳
The RST instruction can be used to reset outputs (Y), relays (M), state relays (S), timers (T), counters (C) and re
gisters (D, V, Z).
Set a device
(assign signal state “1”)
Reset a device
(assign signal state “0”)
The signal state of an OUT instruction will normally only remain “1” as long as the result of the
operation connected to the OUT instruction evaluates to “1”. For example, if you connect a
pushbutton to an input and a lamp to the corresponding output and connect them with an LD
and an OUT instruction the lamp will only remain on while the button remains pressed.
The SET instruction can be used to use a brief switching pulse to switch an output or relay on
(set) and leave them on. The device will then remain on until you switch it off (reset) with a RST
instruction. This enables you to implement latched functions or switch drives on and off with
pushbuttons. (Outputs are generally also switched off when the PLC is stopped or the power
supply is turned off. However, some relays also retain their last signal state under these condi
tions – for example a set relay would then remain set.)
To enter a SET or RST instruction in Ladder Diagram format just click on the icon shown in the
table above in GX Works2, or press the F8 key. Then enter the instruction and the name of the
device you want to set or reset, for example
SET Y1
SET 첸
RST 첸
-
-
.
FX Beginners Manual3–15
The Basic Instruction SetAn Introduction to Programming
X001
X003
X002
RSTY000
SETY000
0
2
X2
X1
M0
t
X001
X002
SETM0
RSTM0
0
2
Ladder Diagram
Instruction List
0LDX001
1SETM0
2LDX002
3RST M0
If the set and reset instructions for the same
device both evaluate to “1” the last operation
performed has priority. In this example that
is the RST instruction, and so M0 remains
off.
This example is a program for controlling a pump to fill a container. The pump is controlled
manually with two pushbuttons, ON and OFF.For safety reasons a break contact is used for the
OFF function. When the container is full a level sensor automatically switches the pump off.
Ladder Diagram
Pump
ON
Pump
OFF
Pump
Pump
Instruction List
0LDX001
1SETY000
2LDIX002
3ORX003
4RSTY000
Level
sensor
3–16MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
X000
X001
X003
X002
Y000
Y002
Y001
0
X000X001
X000
X003
X000
X002
Y000
Y001
Y002
0
3
6
3.4.9Storing, reading and deleting operation results
InstructionFunctionSymbolGX Works2 FX
MPS
MRD
MPP
Memory Point Store, stores the result of
an operation
Memory Read, reads a stored operation
result
Memory POP, reads a stored operation
result and deletes it
—
—
—
—
—
—
The MPS, MRD and MPP instructions are used to store the results of operations and interme
diate values in a memory called the “stack”, and to read and delete the stored results. These
instructions make it possible to program multi-level operations, which makes programs easier
to read and manage.
When you enter programs in Ladder Diagram format these instructions are inserted automati
cally by the programming software. The MPS, MRD and MPP instructions are only actually
shown when you display your program in Instruction List format, and they must also be entered
manually when you program in this format.
Ladder Diagram
Instruction List
0LDX000
1MPS
2ANDX001
MPS
3OUTY000
4MRD
5ANDX002
MRD
6OUTY001
7MPP
8ANDX003
MPP
9OUTY002
To make the advantage of these instructions clearer the example below shows the same program sequence programmed without MPS, MRD and MPP:
When you use this approach you must program the devices (X0 in this example) repeatedly.
This results in more programming work, which can make quite a difference in longer programs
and complex circuit constructions.
In the last output instructionyou must use MPP instead of MRD to delete the stack.You can use
multiple MPS instructions to create operations with up to 11 levels. For more examples of how
to use the MPS, MRD and MPP instructions see theProgrammingManual for the FX Family.
FX Beginners Manual3–17
The Basic Instruction SetAn Introduction to Programming
X000
X001
M0
M1
PLSM0
PLFM1
SETY000
RSTY000
0
2
4
6
F8
F8
M1
X1
M0
Y0
X0
t
3.4.10Generating pulses
InstructionFunctionSymbolGX Works2 FX
Pulse, sets an device* for the duration of
PLS
PLF
PLC and PLF instructions can be used to set outputs (Y) and relays (M).
*
These instructions effectively convert a static signal into a brief pulse, the duration of which
depends on the length of the program cycle. If you use PLS instead of an OUT instruction the
signal state of the specified device will only be set to “1” for a single program cycle, specifically
during the cycle in which the signal state of the device before the PLS instruction in the circuit
switches from “0” to “1” (rising edge pulse).
The PLF instruction responds to a falling edge pulse and sets the specified device to “1” for a
single program cycle, during the cycle in which the signal state of the device before the PLF
instruction in the circuit switches from “1” to “0” (falling edge pulse).
a single program cycle on the rising edge
of the switching pulse of the input condi
tion / device
Pulse Falling, sets a device* for the dura
tion of a single program cycle on the fal
ling edge of the switching pulse of the
input condition / device
-
-
-
PLS 첸
PLF 첸
To enter a PLS or PLF instruction in Ladder Diagram format click in the GX Works2 toolbar on
the tool icon shown above or press
F8
. Then enter the instruction and the corresponding
The rising edge of the device X0
signal triggers the function.
In the case of device X1 the falling
edge of the signal is the trigger.
Relays M0 and M1 are only
switched on for the duration of a
single program cycle.
3–18MITSUBISHI ELECTRIC
An Introduction to ProgrammingThe Basic Instruction Set
F8
X002
X001
X003
N0
MCN0M10
MCRN0
Y003
Y004
0
4
6
8
M10
X002
M155
10
X004
F8
3.4.11Master control function (MC and MCR instructions)
InstructionFunctionSymbolGX Works2 FX
Master Control, sets a master control
MC
MCR
햲
The MC instruction can be used on outputs (Y) and relays (M). n: N0 through N7
햳
n: N0 through N7
The Master Control Set (MC) and Reset (MCR) instructions can be used to set conditions on
the basis of which individual program blocks can be activated or deactivated. In Ladder Dia
gram format a Master Control instruction functions like a switch in the left-hand bus bar that
must be closed for the following program block to be executed.
Ladder Diagram
condition, marking the beginning of a
program block
Master Control Reset, resets a master
control condition, marking the end of a
program block
MC n 첸
MCR n
-
The “switch” does not have to
be programmed manually and
it is only actually displayed
during program execution in
Monitor mode.
In the example above the program lines between the MC and MCR instructions are only exe
cuted when input X001 is on.
The section of the program to be executed can be specified with the nesting address N0
through N7, which allows you to enter multiple MC instructions before the closingMCR instruc
tion. (See the FX Programming Manual for an example of nesting.) Addressing a Y or M device
specifies a make contact.This contact activates the program section when the input condition
for the MC instruction evaluates true.
-
-
FX Beginners Manual3–19
The Basic Instruction SetAn Introduction to Programming
Y000
X001X002
0
Y000
X001
t
0
1
0
1
X002
0
1
0
1
If the input condition of the MC instructionevaluates false the states of the devices between the
MC and MCR instructions change as follows:
Latched timers and counters and devices that are controlled with SET an RST instructions
–
retain their current state.
Unlatched timers and devices that are controlled with OUT instructions are reset.
–
(See chapter 4 for details on these timers and counters.)
3.4.12Inverting the result of an operation
InstructionFunctionSymbolGX Works2 FX
INV
Invert, reverses the result of an operation
The INV instruction is used on its own without any operands. It inverts the result of the opera
tion that comes directly before it:
If the operation result was “1” it is inverted to “0”
–
If the operation result was “0” it is inverted to “1”.
–
Ladder Diagram
Instruction List
0LDX001
1ANDX002
INV instruction
2INV
3OUTY000
The above example produces the following signal sequence:
-
Operation result before the
INV instruction
Operation result after the
INV instruction
The INV instruction can be used when you need to invert the result of a complex operation.It
can be used in the same position as the AND and ANI instructions.
The INV instruction cannot be used at the beginning of an operation (circuit) like an LD, LDI,
LDP or LDF instruction.
3–20MITSUBISHI ELECTRIC
An Introduction to ProgrammingSafety First!
X000 X001
COM Y000
X002
Y001
X001
X002
RST Y000
SET Y000
0
2
3.5Safety First!
PLCs have many advantages over hard-wired controllers. However, when it comes to safety it
is important to understand that you cannot trust a PLC blindly.
Emergency STOP devices
It is essential to ensure that errors in the control system or program cannot cause hazards for
staff or machines.Emergency STOP devices must remain fully functional even when the PLC
is not workingproperly – for example to switch off the power to the PLC outputs if necessary.
Never implement an Emergency STOP switch solely as an input that is processed by the PLC,
with the PLC program activating the shutdown. This would be much too risky.
Safety precautions for cable breaks
You must also take steps to ensure safety in the event that the transmission of signals from the
switches to the PLC are interrupted by cable breaks. When switching equipment on and off via
the PLC always use switches or pushbuttons with make contacts for switching on and with
break contacts for switching off.
+24 V
In this example the contactor for a drive sys
tem can also be switched off manually with
ONOFF
EMERG.
OFF
0V
an Emergency OFF switch.
In the program for this installation the make
contact of the ON switch is polled with an LD
Motor ON
Motor ON
instruction, the break contact of the OFF
switch with an LDI instruction. The output,
and thus also the drive, is switched off when
the input X002 has a signal state of “0”. This
is the case when the OFF switch is operated
or when the connection between the switch
Motor OFF
Motor ON
and input X002 is interrupted.
This ensures that if there is a cable break the drive is switched off automatically and it is not
possible to activate the drive. In addition to this, switching off has priority because it is pro
cessed by the program after
the switch on instruction.
-
-
Interlock contacts
If you have two outputs that should never both be switched on at the same time – for example
outputs for selecting forward or reverse operation for a motor – the interlock for the outputs
must also be implemented with physical contacts in the contactors controlled by the PLC.This
is necessary because only an internal interlock is possible in the program and an error in the
PLC could cause both outputs to be activated at the same time.
FX Beginners Manual3–21
Safety First!An Introduction to Programming
X000 X001
COM Y000
X002
Y001
X000 X001
COM Y000
X002
Y001
The example on the right shows such an inter
lock with contactor contacts. Here it is physi
-
cally impossible for contactors K1 and K2 to be
switched on at the same time.
K2
K1
K1K2
Automatic shutdown
When a PLC is used to control motion sequences in which hazards can arise when compo
nents move past certain pointsadditional limit switches must be installed to interrupt the move
ment automatically. These switches must function directly and independently of the PLC. See
Chapter 3.6.2 for an example of such an automatic shutdown facility.
Output signal feedback
Generally, the outputs of PLCs are not monitored. When an output is activated the program
assumes that the correct response has taken place outside the PLC. In most cases no addi
tional facilities are required. However, in critical applications you should also monitor the out
put signals with the PLC – for example when errors in the output circuit (wire breaks, seized
contacts) could have serious consequences for safety or system functioning.
-
-
-
-
In the example on the right a make contact in
contactor K1 switches input X002 on when output Y000 is switched on. This allows the program to monitor whether the output and the
connected contactor are functioning properly.
Note that this simple solution does not
check
whether the switched equipment is functioning
properly (for example if a motor is really turning). Additional functions would be necessary
to check this, for example a speed sensor or a
voltage load monitor.
+24 V
K1
3–22MITSUBISHI ELECTRIC
An Introduction to ProgrammingProgramming PLC Applications
3.6Programming PLC Applications
Programmable logic controllers provide an almost unlimited number of ways to link inputs with
outputs. Your task is to choose the right instructions from the many supported by the control
lers of the MELSEC FX family to program a suitable solution for your application.
-
This chapter provides two simple examples that demonstrate the development of a PLC appli
cation from the definition of the task to the finished program.
3.6.1An alarm system
The first step is to have a clear concept of what you want to do. This means that you need to
take a “bottom-up” approach and write aclear description of what it is you want the PLC to do.
Task description
The objective is to create an alarm system with several alarm circuits and a delay function for
arming and disarming the system.
The system will be armed with a key switch, with a 20-second delay between turning the
–
switch and activation. This provides enough time for the user to leave the house without
tripping the alarm. During this delay period a display will show whether the alarm circuits
are closed.
–An alarm will be triggered when one of the circuits is interrupted (closed-circuit system,
also triggers an alarm when a circuit is sabotaged). In addition to this we want to show
which circuit triggered the alarm.
–When an alarm is triggered a siren and a blinking alarm lamp are activated after a delay of
10 seconds. (The acoustic and visual alarms are activated after a delay to make it possible
to disarm the system after entering the house. This is also why we want to use a special
lamp to show that the system is armed.)
-
–The siren will only be sounded for 30 seconds, but the alarm lamp will remain activated
until the system is disarmed.
–
A key-operated switch will also be used to deactivate the alarm system.
Assignment of the input and output signals
The next step is to define the input and output signals we need to process. On the basis of the
specifications we know that we are going to need 1 key-operated switch and 4 alarm lamps. In
addition to this we need atleast 3 inputs for the alarmcircuits and 2 outputs for the siren and the
blinking alarm lamp. This makes a total of 4 inputs and 6 outputs. Then we assign these signals
to the inputs and outputs of the PLC:
FunctionNameAdressRemarks
S1X1
S11, S12X2
S21, S22X3
S31, S32X4
H0Y0
E1Y1
H1Y2
H2Y3
H3Y4
H4Y5
Make contact (key-operated switch)
Break contacts (an alarm is triggered
when the input has the signal state “0”)
The outputs functions are activated when
the corresponding outputs are switched
on (set). For example, if Y1 is set the
acoustic alarm will sound.
Input
Output
Arm system
Alarm circuit 1
Alarm circuit 2
Alarm circuit 3
Display “system armed”
Acoustic alarm (siren)
Optical alarm (rotating beacon)
Alarm circuit 1 display
Alarm circuit 2 display
Alarm circuit 3 display
FX Beginners Manual3–23
Programming PLC ApplicationsAn Introduction to Programming
0
4
T0
Y000
K200
X001
T0
X002
X003
X004
Y000
Y000
Y000
6
10
14
M1
M1
Y003
Y004
M1
SET
SET
SET
SET
SET
SET
Y005
Programming
Now we can start writing the program. Whether relay devices are going to be needed and if so
how many usually only becomes clear once you actually start programming. What is certain in
this project is that we are going to need three timers for important functions.If we were using a
hard-wired controller we would use timer relays for this.In a PLC you have programmable elec
tronic timers (see section4.3).Thesetimers can also be defined before we start programming:
FunctionAdressRemarks
T0
T1
T2
Time: 20 seconds
Time: 10 seconds
Time: 30 seconds
Timer
Arming delay
Alarm triggering delay
Siren activation duration
Next we can program the individual control tasks:
Delayed arming of the alarm system
쎲
-
Ladder Diagram
Instruction List
0LDX001
1OUTT0K200
4LDT0
5OUTY000
When the key-operated switch is turned to ON the delay implemented with timer T0 starts to
run. After 20 seconds (K200 = 200 x 0.1s = 20s) the indicator lamp connected to output Y000
lights up, indicating that the system is armed.
Output Y000 is polled in this routine to check whether the alarm system is armed. You could
also use a relay here that would then be set and reset together with Y000. An interruption of an
alarm circuit willonly set relay M1 (indicating that an alarm has been triggered) if the alarmsys
tem is actually armed. In addition to this outputs Y003 through Y005 are used to indicate which
alarm circuit triggered the alarm. Relay M1 and the corresponding alarm circuit output will
-
remain set even when the alarm circuit is closed again.
3–24MITSUBISHI ELECTRIC
An Introduction to ProgrammingProgramming PLC Applications
T2
T1
T1
26
29
Y001
Y002
T2
T1
Y1
M1
10 s
t
OFF
ON
0
1
0
1
30 s
0
1
Y2
OFF
ON
M1
T1
18
22
T1
T2
K100
K300
Alarm activation delay
쎲
Ladder Diagram
Instruction List
18 LDM1
19 OUTT1K100
22 LDT1
23 OUTT2K300
When an alarm is triggered (M1 switches to “1”) the 10s delay timer starts. After the 10 seconds
T1 then starts timer T2, which is set to 30 seconds, and the siren activation time begins.
Alarm display (switch on siren and rotating beacon)
쎲
Ladder Diagram
Instruction List
26 LDT1
27 ANIT2
28 OUTY001
29 LDT1
30 OUTY002
The siren is activated after the 10s activation delay (T1) and remains on while timer T2 is running. After the end of the 30s activation period (T2) the siren deactivates. The rotating beacon
is also switched on after the 10s delay. The following illustration shows the signal sequence
generated by this section of the program:
FX Beginners Manual3–25
Programming PLC ApplicationsAn Introduction to Programming
When the alarm system is switched off with the key-operated switch all the outputs used by the
program and the relay M1 are all reset. If an alarm was triggered the interrupted alarm circuit
which was released until the system was switched off is displayed.
3–26MITSUBISHI ELECTRIC
An Introduction to ProgrammingProgramming PLC Applications
S1
S/S
0V
N
PE
H1
H2
H3
H4
H0
E1
L1
S21
S11
S31
S32
S22
S12
MITSUBISHI
POWER
RUN
ERROR
FX -14MR1S
0123
4567
0123
45
IN
100-240
VAC
14MR
-ES/UL
LN
S/SX0X1X2X3X4X5X6X7
OUT
24V COM0
Y00V
COM1Y1COM2Y2Y3Y4Y5
Connection of the PLC
The sketch below shows how easy it is to implement this alarm system with a PLC of the FX
family. The example shows a FX
1N-14MR.
FX Beginners Manual3–27
Programming PLC ApplicationsAn Introduction to Programming
STOP
3.6.2A rolling shutter gate
Task description
We want to implement a control system for a warehouse’s rolling shutter gate that will enable
easy operation from both outside and inside. Safety facilities must also be integrated in the
system.
WarninglampH1
S7
S0S2S4
쎲 Operation
– It must be possible to open the gate fromoutside with the key-operated switch S1 and to
close it with pushbutton S5. Inside the hall it should be possible to open the gate with
pushbutton S2 and to close it with S4.
– An additional time switch must close the gate automatically if it is open for longer than
20 s.
–
The states “gate in motion”and “gate in undefined position” must be indicated by a blin
king warning lamp.
쎲
Safety facilities
S3
S1
S6
S5
-
–
A stop button (S0) must be installed that can halt the motion of the gate immediately at any
time, stopping the gate in its current position. This Stop switch is not an Emergency OFF
function, however! The switch signal is only processed by the PLC and does not switch any
external power connections.
–
A photoelectric barrier (S7) must be installed to identify obstacles in the gateway.Ifit regis
ters an obstacle while the gate is closing the gate must open automatically.
–
Two limit switches must be installed to stop the gate motor when the gate reaches the fully
open (S3) and fully closed (S6) positions.
3–28MITSUBISHI ELECTRIC
-
An Introduction to ProgrammingProgramming PLC Applications
PLS
SET
SET
PLS
M100
M1
M2
M200
X001
0
4
7
11
M100
M200
X004
M2
M1
X002
X005
Assignment of the input and output signals
The task description clearly defines the number of inputs and outputs needed. The gate drive
motor is controlled with two outputs. The signals required are assigned to the PLC inputs and
outputs as follows:
FunctionNameAdressRemarks
STOP button
OPEN key-operated switch
(outside)
OPEN button (inside)
Inputs
Outputs
TimerDelay for automatic close
Upper limit switch (gate open)
CLOSE button (inside)
CLOSE button (outside)
Lower limit switch (gate closed)
Photoelectric barrier
Warning lamp
Motor contactor (motor reverse)
Motor contactor (motor forward)
S0X0
S1X1
S2X2
S3X3
S4X4
S5X5
S6X6
S7X7
H1Y0
K1Y1
K2Y2
—T0
Break contact (when the switch is opera
ted X0 = “0” and the gate stops)
Make contacts
Break contact (X2 =”0” when the gate is
up and S3 is activated)
Make contacts
Break contact (X6 = “0” when the gate is
down and S6 is activated)
X7 is set to “1” when an obstacle is
registered
—
Reverse = OPEN gate
Forward = CLOSE gate
Time: 20 seconds
-
The program components
쎲 Operation of the rolling shutter gate with the pushbuttons
The program must convert the input signals for the operation of the gate into two commands for
the drive motor: “Open Gate” and “Close Gate”. Since these are signals from pushbuttons that
are only available briefly at the inputs they need to be stored. To do this we use two relays to
represent the inputs in the program and set and reset them as required:
The signals for opening the gate are processed first: When key-operated switch S1 or button
S2 are operated a signal is generated and M001 is set to a signal state of “1” for just one pro
-
FX Beginners Manual3–29
Programming PLC ApplicationsAn Introduction to Programming
SETM2
T0
K200
18
14
T0
X003
RST
RSTM1M2
20
X000
RST
SETM2M1
23
X007M2
gram cycle. This ensures that the gate cannot be blocked if the button sticks or of the operator
does not release it.
It must be ensured that the drive can only be switched on when it is not already turning in the
opposite direction. This is implemented by programming the PLC so that M1 can only be set
when M2 is not set.
NOTEThe motor direction interlock must also be complemented by an additional interlock with
physical contactors outside the PLC (see wiring diagram).
A similar approach is used to process the signals from buttons S4 and S5 for closing the gate.
Here, M1 is polled for a signal state of “0” to ensure that M1 and M2 cannot both be set at the
same time.
Close gate automatically after 20 seconds
쎲
Ladder Diagram
Instruction List
14 LDIX003
15 OUTT0K200
18 LDT0
19 SETM2
When the gate isopen limit switch S3 activates and input X3 is switched off.(For safety reasons
S3 is a break contact.) When this happens timer T0 starts the 20s delay (K200 = 200 x 0.1s =
20s). When the timer reaches 20s relay M2 is set and the gate is closed.
쎲 Stop gate with STOP switch
Ladder Diagram
Instruction List
20 LDIX000
21 RSTM1
22 RSTM2
Pressing the STOP button (S0) resets relays M1 and M2, stopping the gate motor.
3–30MITSUBISHI ELECTRIC
쎲
Identifying obstacles with the photoelectric barrier
Ladder Diagram
Instruction List
23 LDX007
24 ANDM2
25 RSTM2
26 SETM1
If an obstacle is registered by the photoelectric barrier while the gate is closing relay M2 is
reset and the close operation is halted. After this relay M1 is set, opening the gate again.
An Introduction to ProgrammingProgramming PLC Applications
RST
RSTM1M2
27
29
X003
X006
Y001
Y002
31
33
M1
M2
Y000
35
X003 X006 M8013
Switching the motor off with the limit switches
쎲
Ladder Diagram
Instruction List
27 LDIX003
28 RSTM1
29 LDIX006
30 RSTM2
When the gate is open limit switch S3 is activated and input X3 is switched off.This resets relay
M1, turning off the motor. When the gate is fully closed S6 is activated, X6 is switched off and
M2 is reset, turning off the motor. For safety reasons the limit switches are break contacts. This
ensures that the motor is also switched off automatically (or cannot be switched on) if the con
nection between the switch and the input is interrupted.
NOTEThe limit switches must be wired so that they also switch off the motor automatically without
support from the PLC (see wiring diagram).
Controlling the motor
쎲
Ladder Diagram
Instruction List
31 LDM1
32 OUTY001
33 LDM2
34 OUTY002
-
At the end of theprogram the signal states of relays M1 and M2 are transferred to outputs Y001
and Y002.
쎲
Warning lamp: “Gate in Motion” and “Gate in Undefined Position”
Ladder Diagram
Instruction List
35 LDX003
36 ANDX006
37 ANDM8013
38 OUTY000
If neither of the limit switches is activated this means that the gate is being opened or closed or
has been stopped in an intermediate position. In all these situations the warning lamp blinks.
The blink speed is controlled with special relay M8013, which is automatically set and reset at
1s intervals (see Chapter 4.2).
FX Beginners Manual3–31
Programming PLC ApplicationsAn Introduction to Programming
MITSUBISHI
POWER
RUN
ERROR
FX -14MR1S
0123
4567
0123
45
IN
100-240
VAC
14MR
-ES/UL
LN
S/SX0X1X2X3X4X5X6X7
OUT
24V COM0
Y00V
COM1Y1COM2Y2Y3Y4Y5
S/S
0V
24 V
N
PE
L1
S3S4
S2
S5S6S7
S0
K2
K1
S3
S6
K1K2H1
S1
Connection of the PLC
The rolling shutter gate control system can be implemented with a controller like the
FX
1N-14MR.
Lower limit switch
Photoelectric barrier
STOP
Open gate (outside)
Open gate (inside)
Upper limit switch
Close gate (inside)
Close gate (outside)
Interlock by contactor
Deactivation by limit switches
Open gate
Close gate
Warning lamp
3–32MITSUBISHI ELECTRIC
Devices in DetailInputs and Outputs
X000 X001
Y000 Y001
X002
Y002
4Devices in Detail
The devices in PLCs are used directly in control program instructions. Their signal states can
be both read and changed by the PLC program. A device reference has two parts:
the device name and
–
the device address.
–
Example of a device reference (e.g. input 0):
X0
Device addressDevice name
4.1Inputs and Outputs
The PLC’s inputs and outputs connect it to the process that it is controlling. When an input is
polled by the PLC program the voltage on the input terminal of the controller is measured.
Since these inputs are digital they can only have two signal states, ON or OFF. When the volt
age at the input terminal reaches 24V the input is on (state “1”). If the voltage is lower than 24V
the input evaluates as off (signal state “0”).
-
In MELSEC PLCs the identifier “X” is used for inputs. The same input can be polled as often as
necessary in the same program.
NOTEThe PLC cannotchange the state ofinputs.For example, it is not possible to executean OUT
instruction on an input device.
If an output instruction is executed on an output the result of the current operation (the signal
state) is applied to the outputterminal of the PLC.Ifit is a relay output the relay closes (all relays
have make contacts). If it is a transistor output the transistor makes the connection and activates the connected circuit.
The illustration on the left shows an example
of how you can connect switches to the
inputs and lamps and contactors to the out
puts of a MELSEC PLC.
-
The identifier for output devices is “Y”. Outputs can be used in logic operation instructions as
well as with output instructions. However, it is important toremember that you can never use an
output instruction on the same output more than once (see also section 3.4.2).
FX Beginners Manual4–1
Inputs and OutputsDevices in Detail
The following table provides a general overview of the inputs and outputs of the controllers of
the MELSEC FX family.
DeviceInputsOutputs
Device identifierXY
Device typeBit device
Possible values0 or 1
Device address formatOctal
4 (Y00–Y03)
6 (Y00–Y05)
8 (Y00–Y07)
14 (Y00–Y07, Y10–Y15)
6 (Y00–Y05)
10 (Y00–Y07, Y10, Y11)
16 (Y00–Y07, Y10–Y17)
24 (Y00–Y07, Y10–Y17, Y20–Y27)
8 (Y00–Y07)
16 (Y00–Y07, Y10–Y17)
24 (Y00–Y07, Y10–Y17, Y20–Y27)
32 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37)
40 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47)
64 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47, Y50–Y57,
Y60–Y67, Y70–Y77)
8 (Y00–Y07)
16 (Y00–Y07, Y10–Y17)
32 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37)
48 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47, Y50–Y57)
6 (Y00–Y05)
10 (Y00–Y07, Y10–Y11)
16 (Y00–Y07, Y10–Y17)
24 (Y00–Y07, Y10–Y17, Y20–Y27)
10 (Y00–Y07, Y10–Y11)
16 (Y00–Y07, Y10–Y17)
4 (Y00–Y03)
6 (Y00–Y05)
8 (Y00–Y07)
14 (Y00–Y07, Y10–Y15)
Number of devices and addresses (depends on
controller base
unit type)
FX
FX
FX
FX
FX
FX
FX
FX
6 (X00–X05)
8 (X00–X07)
1S
12 (X00–X07, X10, X11, X12, X13)
16 (X00–X07, X10–X17)
8 (X00–X07)
14 (X00–X07, X10–X15)
햲
1N
24 (X00–X07, X10–X17, X20–X27)
36 (X00–X07, X10–X17, X20–X27,
X30–X37, X40, X41, X42, X43)
8 (X00–X07)
16 (X00–X07, X10–X17)
24 (X00–X07, X10–X17, X20–X27)
32 (X00–X07, X10–X17, X20–X27,
2N
X30–X37)
40 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47)
64 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47, X50–X57,
X60–X67, X70–X77)
8 (X00–X07)
16 (X00–X07, X10–X17)
32 (X00–X07, X10–X17, X20–X27,
2NC
X30–X37)
48 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47, X50–X57)
8 (X00–X07)
14 (X00–X07, X10–X15)
햳
3G
24 (X00–X07, X10–X17, X20–X27)
36 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X43)
햳
3GC
16 (X00–X07, X10–X17)16 (Y00–Y07, Y10–Y17)
14 (X00–X07, X10–X15)
햳
3GE
24 (X00–X07, X10–X17, X20–X27)
6 (X00–X05)
8 (X00–X07)
햳
3S
12 (X00–X07, X10, X11, X12, X13)
16 (X00–X07, X10–X17)
햲
With expansion modules, the total number of inputs can be increased to max. 84 (X123) and the total number of
outputs can be increased to max. 64 (X77). However, the sum of all inputs and outputs cannot exceed 128.
햳
With expansion modules, the total number of inputs can be increased to max. 128 (X177) and the total number of
outputs can be increased to max. 128 (Y177). However, the sum of all inputs and outputs cannot exceed 128.
4–2MITSUBISHI ELECTRIC
Devices in DetailInputs and Outputs
DeviceInputsOutputs
8 (X00–X07)
16 (X00–X07, X10–X17)
24 (X00–X07, X10–X17, X20–X27)
32 (X00–X07, X10–X17, X20–X27,
햴
X30–X37)
40 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47)
64 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47, X50–X57,
X60–X67, X70–X77)
8 (X00–X07)
Number of
devices and
addresses
(depends on con
troller base unit
type)
FX
3U
-
16 (X00–X07, X10–X17)
햴
FX
32 (X00–X07, X10–X17, X20–X27,
3UC
X30–X37)
48 (X00–X07, X10–X17, X20–X27,
X30–X37, X40–X47, X50–X57)
햴
With expansion modules, the total number of inputs can be increased to max. 248 (X367) and the total number of
outputs can be increased to max. 248 (Y367). However, the sum of all inputs and outputs cannot exceed 256.
8 (Y00–Y07)
16 (Y00–Y07, Y10–Y17)
24 (Y00–Y07, Y10–Y17, Y20–Y27)
32 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37)
40 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47)
64 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47, Y50–Y57,
Y60–Y67, Y70–Y77)
8 (Y00–Y07)
16 (Y00–Y07, Y10–Y17)
32 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37)
48 (Y00–Y07, Y10–Y17, Y20–Y27,
Y30–Y37, Y40–Y47, Y50–Y57)
FX Beginners Manual4–3
RelaysDevices in Detail
M1
M1
M1
4.2Relays
In your PLC programs you will often need to store intermediate binary results (a signal state of
“0” or “1”) temporarily for future reference. The PLC has special memory cells available for this
purpose known as “auxiliary relays”, or “relays” for short (device identifier: "M").
You can store the binary result of an operation in a relay, for example with an OUT instruction,
and then use the result in future operations. Relays help to make programs easier to read and
also reduce the number of program steps:You can store the results of operations that need to
be used more thanonce in a relay and then poll it is oftenas you like in the restof the program.
Poll for signal state “1” (relay set)
Poll for signal state “0” (has the relay been reset?)
In addition to normal relays the FX controllers also have retentive or “latched” relays. The normal unlatched relays are all reset to a signal state of“0”when the PLC power supplyis switched
off, and this is also their standard state when the controller is switched on. In contrast to this,
latched relays retain their current states when the power is switched off and on again.
Relay types
524 (M500–M1023)
2048 (M1024–M3071)
1152 (M384–M1535)
128 (M384–M511)
524 (M500–M1023)
6656 (M1024–M7679)
Device
Device identifierM
Device typeBit device
Possible values für a device0 or 1
Device address formatDecimal
1S384 (M0–M383)128 (M384–M511)
FX
1N384 (M0–M383)1152 (M384–M1535)
FX
FX
2N
FX2NC
3G
Number of devices and
addresses
FX
FX3GC
FX3GE
FX
3S
FX
3U
FX3UC
Unlatched relaysLatched relays
500 (M0–M499)
384 (M0–M383)
6144 (M1536–M7679)
384 (M0–M383)
1024 (M512–M1535)
500 (M0–M499)
햲
You can also configure these relays as latched relays with the PLC parameters.
햳
You can also configure these relays as unlatched relays with the PLC parameters.
햴
If the optional battery is installed, the function of latched registers can be assigned to these registers in the PLC
parameters. They are then buffered by the battery.
4–4MITSUBISHI ELECTRIC
Devices in DetailRelays
4.2.1Special relays
In addition to the relays that you can switch on and off with the PLC program there is also
another class of relays known as special or diagnostic relays. These relays use the address
range startingwith M8000.Some contain information on system status and others can beused
to influence program execution.The following table shows a few examples of the many special
relays available.
Special
relay
M8000When the PLC is in RUN mode this relay is always set to “1”.
M8001When the PLC is in Run mode this relay is always set to “0”.
M8002
M8004PLC error
M8005Low battery voltage
M8013Clock signal pulse: 1 second
M8031
M8034
Function
Initialisation pulse (following activation of RUN mode this relay is set
to “1” for the duration of one program cycle.
Clear all devices (except data registers D) that are not registered as
battery-latched.
Disable outputs – the PLC outputs remain off but program execution
continues.
Program processing
options
Poll signal state
Poll signal state
Set signal state.
FX Beginners Manual4–5
TimersDevices in Detail
X0
T200
Y0
1,23 s
X0
T200
T200
Y0
K123
0
4
4.3Timers
When you are controlling processes you will often want to program a specific delay before
starting and stopping certain operations. In hard-wired controllers this is achieved with timer
relays. In PLCs this is achieved with programmable internal timers.
Timers are really just counters that count the PLCs internal clock signals (e.g. 0.1s pulses).
When the counter value reaches the setpoint value the timer’s output is switched on.
All timers function as make delay switches and are activated with a “1” signal. To start andreset
timers you program them in the same way as outputs. You can poll the outputs of timers as
often as you like in your program.
Ladder Diagram
In the above example timer T200 is started when input X0 is switched on. The setpoint value is
123 x 10ms = 1.23 s, so T200 switches on output Y0 after a delay of 1.23 s. The signal
sequence generated by the following program example is as follows:
The timer continues to count the internal
10ms pulses as long as X0 remains on.
When the setpoint value is reached the
output of T200 is switched on.
If input X0 or the power supply of the PLC
are switched off the timer is reset and its
output is also switched off.
Instruction List
0LDX0
1OUTT200K123
4LDT200
5OUT Y0
You can also specify the timer setpoint value indirectly with a decimal value stored in a data
register. See section 4.6.1 for details.
4–6MITSUBISHI ELECTRIC
Devices in DetailTimers
T250
t1t2
X1
Y1
X2
t1 + t2 = 34,5 s
X1
T250
T250
Y1
K345
X2
T250RST
0
4
6
Retentive timers
In addition to the normal timers described above, all controllers covered in this manual except
the FX
1S series also have retentive timers that retain their current time counter value even if
the device controlling them is switched off.
The current timer counter value is stored in a memory that is retained even in the event of a
power failure.
Example of a program using a retentive timer:
Ladder Diagram
Timer T250 is started when input X0 is switched on. The setpoint value is 345 x 0.1 s = 34.5s.
When the setpoint value is reached T250 switches output Y1 on. Input X2 resets the timer and
switches its output off.
When X1 is on the timer counts the internal
100ms pulses. When X1 is switched off the
current time counter value is retained. The
timer’s output is switched on when the current value reaches the setpoint value of the
timer.
Instruction List
0LDX0
1OUTT250K345
4LDT250
5OUT Y1
6LDX2
7RSTT250
A separate instruction must be programmed
to reset the timer since it is not reset by swit
ching off input X1 or the PLC’s power. Input
X2 resets timer T250 and switches off its
output.
-
FX Beginners Manual4–7
TimersDevices in Detail
Timers in the base units of the MELSEC FX family
Device
Normal TimersRetentive Timers
Device identifierT
Device type (for setting and polling)Bit device
Possible values (timer output)0 or 1
Device address formatDecimal
As a decimal integer constant. The setpoint can
Timer setpoint value entry
be set either directly in the instruction or indi
rectly in a data register.
Number of devices
and addresses
1S
FX
1N
FX
2N
FX
FX2NC
FX
3G
FX3GC
FX3GE
100 ms
(Range 0.1 to 3276.7 s)
10 ms
(Range 0.01 to 327.67 s)
1 ms
(Bereich 0.001 to 32.767 s)
100 ms
(Range 0.1 to 3276.7 s)
10 ms
(Range 0.01 to 327.67 s)
1 ms
(Range 0.001 to 32.767 s)
100 ms
(Range 0.1 to 3276.7 s)
10 ms
(Range 0.01 to 327.67 s)
1 ms
(Range 0.001 to 32.767 s)
100 ms
(Range 0.1 to 3276.7 s)
10 ms
(Range 0.01 to 327.67 s)
1 ms
(Range 0.001 to 32.767 s)
100 ms
(Range 0.1 to 3276.7 s)
63 (T0–T62)—
31 (T32–T62)
1 (T63)—
200 (T0–T199)6 (T250–T255)
46 (T200–T245)—
4 (T246–T249)—
200 (T0–T199)6 (T250–T255)
46 (T200–T245)—
—4 (T246–T249)
200 (T0–T199)6 (T250–T255)
46 (T200–T245)—
64 (T256–T319)4 (T246–T249)
32 (T0–T31)6 (T131–T137)
100 ms/10 ms
FX
(Range 0.1 to 3276.7 s/
3S
31 (T32–T62)—
0.01 to 327.67 s)
3U
FX
FX3UC
1 ms
(Range 0.001 to 32.767 s)
100 ms
(Range 0.1 to 3276.7 s)
10 ms
(Range 0.01 to 327.67 s)
1 ms
(Range 0.001 to 32.767 s)
65 (T63–T127)4 (T128–T131)
200 (T0–T199)6 (T250–T255)
46 (T200–T245)—
256 (T256–T511)4 (T246–T249)
Timer types
햲
-
—
햲
These timers are only available when special relay M8028 is set ("1"). The total number of 100 ms timers is then
reduced to 32 (T0–T31).
햳
When special relay M8028 is set ("1"), the timers T32 to T62 operate as 10 ms timers.
4–8MITSUBISHI ELECTRIC
Devices in DetailCounters
X1
C0
K10
X0
C0RST
C0
Y0
0
3
7
0
1
2
3
4
5
6
7
8
9
10
X0
X1
Y0
4.4Counters
The programmers of the FX family also have internal counters that you can use for program
ming counting operations.
Counters count signal pulses that are applied to their inputs by the program.The counter out
put is switched on when the current counter value reaches the setpoint value defined by the
program.Like timers, counter outputs can also be polled as often as you like in the program.
Example of a program using a counter:
Ladder Diagram
Instruction List
0LDX0
1RST C0
3LDX1
4OUTC0K10
7LDC0
8OUT Y0
Whenever input X1 is switched on the value of counter C0 is incremented by 1. Output Y0 is set
when X1 has been switched on and off ten times (the counter setpoint is K10).
The signal sequence generated by this program is as follows:
-
-
First the counter is reset with input X0 and a
RST instruction. This resets the counter value
to 0 and switches off the counter output.
Once the counter value has reached the set
point value any additional pulses on input X1
no longer have any effect on the counter.
There are two kinds of counters, 16-bit counters and 32-bit counters. As their names indicate,
they can count up to either 16-bit or 32-bit values and they use 16 bits and 32 bits, respectively,
to store their setpoint values. The following table shows the key features of these counters.
FX Beginners Manual4–9
CountersDevices in Detail
Feature16 Bit Counters32 Bit Counters
Count directionIncrementing
Setpoint value
range
Setpoint value entry
Counter overflow
behaviour
Counter output
ResettingAn RST instruction is used to delete the current value of the counter and turn off its output.
1 to 32767-2 147 483 648 to 2 147 483 647
Directly as a decimal constant (K) in the
instruction, or indirectly in a data register
Counts to a maximum of 32,767, after which
the counter value no longer changes.
Once the setpoint value has been reached
the output remains on.
Incrementing and decrementing (the direc
tion is specified by switching a special relay
on or off)
Directly as a decimal constant (K) in the
instruction or indirectly in a pair of data
registers
Ring counter: After reaching 2,147,483,647
the next incrementing value is
-2,147483,648. (When counting backwards
the jump is from -2,147483,648 to
2,147,483,647)
When incrementing the output remains on
once the setpoint value has been reached.
When decrementing the output is reset
(switched off) once the value drops below
the setpoint value.
-
In addition to normal counters the controllers of the MELSEC FX family also have high-speed
counters. These are 32-bit counters that can process high-speed external counter signals
read on inputs X0 to X7. In combination with some special instructions it is very easy to use
these counters to automate positioning tasks and other functions.
High-speed counters use an interrupt principle: The PLC program is interrupted and responds
immediately to the counter signal. For a detailed description of high-speed counters please
refer to the Programming Manual for the MELSEC FX family.
4–10MITSUBISHI ELECTRIC
Devices in DetailCounters
Counter overview
Device
Normal countersRetentive counters
Device identifierC
Device type (for setting and polling)Bit device
Possible device values (counter output)0 or 1
Device address formatDecimal
As a decimal integer constant. The setpoint can
Counter setpoint value entry
be set either directly in the instruction or indi
rectly in a data register (two data registers for
32-bit counters).
16 bit counter16 (C0–C15)16 (C16–C31)
1S
FX
32 bit counter——
32 bit high-speed counter—21 (C235–C255)
16 bit counter16 (C0–C15)184 (C16–C199)
1N
FX
32 bit counter20 (C200–C219)15 (C220–C234)
32 bit high-speed counter—21 (C235–C255)
16 bit counter100 (C0–C99)
2N
Number of devices
and addresses
FX
FX2NC
FX3G
FX3GC
FX3GE
32 bit counter20 (C200–C219)
32 bit high-speed counter21 (C235–C255)
16 bit counter16 (C0–C15)184 (C16–C199)
32 bit counter20 (C200–C219)15 (C220–C234)
32 bit high-speed counter—21 (C235–C255)
16 bit counter16 (C0–C15)16 (C16–C31)
3S
FX
32 bit counter35 (C200–C234)—
32 bit high-speed counter—21 (C235–C255)
16 bit counter100 (C0–C99)
3U
FX
FX3UC
32 bit counter20 (C200–C219)
32 bit high-speed counter21 (C235–C255)
Counter types
100 (C100–C199)
15 (C220–C234)
100 (C100–C199)
15 (C220–C234)
-
햲
The current counter values of retentive counters are retained when the power supply is switched off.
햳
You can set the PLC parameters to configure whether the current values of these counters should be retained
when the power supply is switched off.
FX Beginners Manual4–11
RegistersDevices in Detail
4.5Registers
The PLC’s relays are used to store the results of operations temporarily. However, relays can
only store values of On/Off or 1/0, which means that they are not suitable for storing measure
ments or the results of calculations. Values like this can be stored in the “registers” of the con
trollers of the FX family.
-
-
Registers are 16 bits or one word wide (see section 3.2). You can create “double word” regis
ters capable of storing 32-bit values by combining two consecutive data registers.
Register:
16 bit
Double word register:
32 bit
1 sign bit
1 sign bit
14 13 12 11 10 9876543210
22222222 22222 22
0: = positive value
1: = negative value
30 29 28
222
...
15 data bits
31 data bits
...
210
222
-
A normal register can store values from 0000
isters can store values from 00000000
The controllers of the FX family have a large number of instructions for using and manipulating
registers. You can write and read values to and from registers, copy the contents of registers,
compare them and perform math functions on their contents (see chapter 5).
4.5.1Data registers
Data registers can be used as memory in your PLC programs. A value that the program writes
to a data register remains stored there until the program overwrites it with another value.
When you use instructions for manipulating 32-bit data you only need to specify the address of
a 16-bit register.The more significant part of the 32-bit data is automatically written to the next
consecutive register. For example, if you specify register D0 to store a 32-bit value D0 will con
tain bits 0 through 15 and D1 will contain bits 16 through 31.
0: = positive value
1: = negative value
H – FFFFFFFFH (-2,147,483,648 – 2,147,483,647).
H – FFFFH (-32,768 – 32,767). Double-word reg
-
-
4–12MITSUBISHI ELECTRIC
Devices in DetailRegisters
What happens when the PLC is switched off or stopped
In addition to the normal registers whose contents are lost when the PLC is stopped or the
power supply is turned off, the FX PLCs also have latched registers, whose contents are
retained in these situations.
NOTEWhen special relay M8033 is set the contents of the unlatched data registers are also not
cleared when the PLC is stopped.
Data register overview
Device
Device identifierD
Device type (for setting and polling)
Possible device values
Device address formatDecimal
FX
1S128 (D0–D127)128 (D128–D255)
1N128 (D0–D127)7872 (D128–D7999)
FX
2N
FX
FX2NC
3G
Number of devices and
addresses
햲
You can also configure these registers as latched registers with the PLC parameters.
햳
You can also configure these registers as unlatched registers with the PLC parameters.
햴
If the optional battery is installed, the function of latched registers can be assigned to these registers in the PLC
parameters. They are then buffered by the battery.
FX
FX3GC
FX3GE
FX
3S
FX
3U
FX3UC
Normal registersLatched registers
Word device (two registers can be combined to store double-word
values)
16 bit registers: 0000
32 bit register: 00000000
200 (D0–D199)
128 (D0–D127)
6900 (D1100–D7999)
128 (D0–D127)
2744 (D256–D2999)
200 (D0–D199)
Data register types
H to FFFFH (-32768 to 32767)
2 147 483 647)
H to FFFFFFFFH (-2 147 483 648 to
312 (D200–D511)
7488 (D512–D7999)
972 (D128–D1099)
128 (D128–D255)
312 (D200–D511)
7488 (D512–D7999)
4.5.2Special registers
Just like the special relays (Chapter 4.2.1) starting at address M8000 the FX controllers also
have special or diagnostic registers, whose addresses start at D8000. Often there is also a
direct connection between the special relays and special registers. For example, special relay
M8005 shows that the voltage of the PLC’s battery is too low, and the corresponding voltage
value is stored in special register D8005. The following table shows a small selection of the
available special registers as examples.
Special
register
D8004Error relay address (shows which error relays are set)
D8010Current program cycle time
D8013–D8019Time and date of the integrated real-time clock
Read register contentsD8005Battery voltage (e.g. the value “36” means 3.6V)
Read register contents
Change register contents
FX
1N, FX3G, FX3GE and
FX
3S only)
1S,
RegistersDevices in Detail
Registers with externally modifiable contents
The controllers of the FX
ometers with which you can adjust the contents of special registers D8030 and D8031 in the
range from 0 to 255 (see section 4.6.1). These potentiometers can be used for a variety of pur
poses – for example to adjust setpoint values for timers andcounters without having to connect
a programming unit to the controller.
4.5.3File registers
The contents of file registers are also not lost when the power supply is switched off.File regis
ters can thus be used for storing values that you need to transfer to data registers when the
PLC is switched on, so that they can be used by the program for calculations, comparisons or
as setpoints for timers.
File registers have the same structure as data registers. In fact, they are data registers – they
consist of blocks of 500 addresses each in the range from D1000 to D7999.
DeviceFile registers
Device identifierD
Device type (for setting and polling)
Possible device values
Device address formatDecimal
Number of devices and
addresses
1S,FX1N,FX3G,FX3GE and FX3S series have two integrated potenti
Word device (two registers can be combined to store double-word
values)
16 bit register: 0000H to FFFFH (-32768 to 32767)
1S
FX
FX
1N
FX
2N
FX2NC
FX3G
FX3GC
FX3GE
FX3S
FX
3U
FX3UC
32 bit register: 00000000
2 147 483 647)
1500 (D1000–D2499)
A maximum of 3 blocks of 500 file registers each can be defined in
the PLC parameters.
7000 (D1000–D7999)
A maximum of 14 blocks of 500 file registers each can be defined in
the PLC parameters.
2000 (D1000–D2999)
A maximum of 4 blocks of 500 file registers each can be defined in
the PLC parameters.
7000 (D1000–D7999)
A maximum of 14 blocks of 500 file registers each can be defined in
the PLC parameters.
H to FFFFFFFFH (-2 147 483 648 to
-
-
-
For a detailed description of the file registers see the Programming Manual for the MELSEC
FX family.
4–14MITSUBISHI ELECTRIC
Devices in DetailProgramming Tips for Timers and Counters
X17
T31
K500
M50
C0
K34
0
4
X17
T31
D131
M8002
MOV D100 D131
M15
M50
C0
D5
MOV K34 D5
0
6
10
16
4.6Programming Tips for Timers and Counters
4.6.1Specifying timer and counter setpoints indirectly
The usual way to specify timer and counter setpoint values is directly, in an output instruction:
Ladder Diagram
In the example above T31 is a 100ms timer. The constant K500 sets the delay to 500 x 0.1s =
50s. The setpoint for counter C0 is also set directly, to a value of 34 with the constant K34.
The advantage of specifying setpoints like this is that you don’t have to concern yourself with
the setpoint value once you have set it. The values you use in the program are always valid,
even after power failures and directly after switching the controller on. However, there is also a
disadvantage: If you want to change the setpoint you need to edit the program. This applies
particularly for timer setpoint values, which are often adjusted during controller configuration
and program tests.
You can also store setpoint values for timers and counters in data registers and have the program read them from the registers. It is then possible to change the values quickly with a programming unit if necessary, or to specify setpoint values with switches on a control console or
a HMI control panel.
The following listing shows an example of how to specify setpoint values indirectly:
Instruction List
0LDX17
1OUTT31K500
4LDM50
5OUTC0K34
Ladder Diagram
–
When relay M15 is one the contents of dataregister D100 are copied to D131.This register
contains the setpoint value for T131. You could use a programming or control unit to adjust
the contents of D100.
–
The special relay M8002 is only set for a single program cycle directly after the PLC is swit
ched on. This is used to copy the constant value of 34 to data register D5, which is then
used as the setpoint value for counter C0.
You don’t have to write program instructions to copy the setpoint values to the data registers.
You could alsouse a programming unit to set them before the program is started, for example.
Programming Tips for Timers and CountersDevices in Detail
0123
4567
8 9 10 11
12 13 14 15
0123
4567
10 11
IN
OUT
POWER
FX -24MR
1N
RUN
ERROR
100-240
VAC
X7
X11
X13
X15
X5
X3
X1
S/S
X6
X10
X12
X14
X4
X2
X0
N
L
24MR
-ES/UL
Y10
Y6
Y5
Y3
COM3
Y4
COM4
Y7
Y11
COM2
COM1
COM0
24+
Y2
Y1
Y0
0V
MITSUBISHI
T1
T2
Y000
T2
T1
X001
T1
D8030
D8031
0
4
8
WARNING:
If you use normal registers the setpoint values will be lost when the power supply is
E
switched off and when the RUN/STOP switch is set to the STOP position. If this happens
hazardous conditions may be created next time the power is switched on and/or when
the PLC is started again, because all the setpoints will have a value of “0”.
If you don’t configure your program to copy the values automatically you should always
use latched data registers for storing the setpoint values for timers and counters. Also,
remember that even the contents of these registers will also be lost when the PLC is
switched off if the backup battery is empty.
Setting setpoints with the integrated potentiometers
The controllers of the FX
1S,FX1N,FX3G,FX3GE and FX3S series have two integrated analog
potentiometers with which you can adjust setpoint values for timers and otherfunctions quickly
and easily.
The image on the left shows a basic unit of the
1N series. The layout of the potentiometers is
FX
similar in the FX
1S,FX3G,FX3GE and FX3S series.
The value of the upper potentiometer (VR1) can
be read from special data register D8031, the
value of the lower potentiometer (VR2) from register D8031. To use one of the potentiometers as the
setpoint value source for a timer you just specify
the corresponding register in your program instead of a constant.
In the program example above Y0 is switched on after the delay specified for timer T1, for the
time specified for timer T2 (delayed pulse generation).
4–16MITSUBISHI ELECTRIC
Devices in DetailProgramming Tips for Timers and Counters
T2
T1
Y0
X1
[D8030]
t
OFF
ON
OFF
ON
0
1
0
1
[D8031]
Signal sequence
FX Beginners Manual4–17
Programming Tips for Timers and CountersDevices in Detail
Y000
X001
X001
Y000
T0
T0
K300
0
5
Y0
X1
T0
30 s
t
X001
T0
RSTY000
X001
SETY000
T0
K300
0
6
2
4.6.2Switch-off delay
By default, all the timers in MELSEC PLCs are delayed make timers, i.e. the output is switched
ON after the defined delay period. However, you will often also want to program a delayed
break operation (switch OFF after a delay). A typical example of this is a ventilation fan in a
bathroom that needs tocontinue running for several minutes after the lights are switched off.
Program version 1 (latching)
Ladder Diagram
As long as input X1 (e.g. a light switch) is on output Y0 (fan) is also on. However, the latching
function ensures that Y0 also remains on after X1 has been switched off, because timer T0 is
still running.T0 is started when X1 is switched off. At the end of the delay period (300 x 0.1s =
30s in the example) T0 interrupts the Y0 latch and switches the output off.
When X1 is switched on output Y0 is set (switched on). When X1 is switched off timer T0 is
started. After the delay period T0 then resets output Y0. The resulting signal sequence is iden
tical with that produced by program version 1.
Devices in DetailProgramming Tips for Timers and Counters
T1
X000
Y000
X000
T2
T1
T2
Y000
K25
K50
0
8
4
T2
T1
Y0
X0
t1
t
OFF
ON
OFF
ON
0
1
0
1
t2
4.6.3ON- and OFF-Delay
Sometimes you will want to switch an output on after a delay and then switch it off again after
another delay. This is very easy to implement with the controller’s basic logical instructions.
Output Y000 is latched with the help of T1, keeping the output switched on until the end of the
break delay period.
FX Beginners Manual4–19
Programming Tips for Timers and CountersDevices in Detail
T1
T2
Y000
T2
X001
T1
K10
K20
0
5
T2
T1
Y1
X0
t1
t
OFF
ON
OFF
ON
0
1
0
1
t2
4.6.4Clock signal generators
The controllers have special relays that make it very easy to program tasks requiring a regular
clock signal (for example for controlling a blinking error indicator light). Relay M8013 switches
on and off at 1-second intervals, for example. For full details on all special relays see the Pro
gramming Manual for the FX family.
If you need a different clock frequency or different on and off times you can program your own
clock signal generator with two timers, like this:
Input X1 starts the clock generator. If you want, you can omit this input – then the clock genera
tor is always on. In the program you could use the output of T1 to control a blinking warning
light. The on period is determined by T2, the off period by T1.
The output of timer T2 is only switched on for a single program cycle.This time is shown much
longer than it really is in the signal sequence illustration below.T2 switches T1 off and immediately after this T2 itself is also switched off. In effect this means that the duration of the on
period is increased by the time that it takes to execute a program cycle. However, since the
cycle is only a few milliseconds long it can usually be ignored.
Signal sequence
-
4–20MITSUBISHI ELECTRIC
More Advanced ProgrammingApplied Instructions Reference
5More Advanced Programming
The basic logic instructions listed in Chapter 3 can be used to emulate the functions of a
hard-wired contactor controller with a programmable logic controller. However, this only
scratches the surface of the capabilities of modern PLCs. Since every PLC is built around a
microprocessor they can also easily perform operations like mathematical calculations, com
paring numbers, converting from one number system to anotheror processing analog values.
-
Functions like these thatgo beyond the capabilities oflogic operations are performed with spe
cial instructions, which are referred to as
appliedorapplication instructions
5.1Applied Instructions Reference
Applied instructions have short names that are based on the English names of their functions.
For example, the instruction for comparing two 16-bit or 32-bit numbers is called CMP, which is
short for
When you program an applied instruction you enter the instruction name followed by the
device name. The following table shows all the applied instructions currently supported by the
MELSEC FX family of controllers. This listmay look alittle overwhelming at first, but don’t worry
– you don’t have to memorise them all! When you are programming you can use the powerful
Help functions of GX Works2 to find the instructions you need.
In this chapter we will only cover the more frequently-used instructions, which are shown with a
grey shaded background in the reference table. For full documentation of all the instructions
with examples please refer to the Programming Manual for the FX family.
Category
Program flow
functions
compare
.
Instruc-
tion
CJ
CALL
SRET
IRET
EI
DI
FEND
WDT
FOR
NEXT
Function
Conditional Jump to a program
position
Calls (executes) a subroutine
Subroutine Return, marks the end of a
subroutine
Interrupt Return, marks the end of an
interrupt routine
Enable Interrupt, enables processing
of interrupt routines
Disable Interrupt, disables processing
of interrupt routines
Instructions for
communication
with frequency
inverters
MODBUS
communication
Data exchange
with special func
tion modules
High-speed coun
ter instruction
Instructions for
extension file
registers
-
-
Instruc-
tion
LD=
LD>
LD<
LD<>
LD<=
LD>=
AND=
AND>
AND<
AND>=
OR=
OR>
OR<
OR<>
OR<=
OR>=
LIMIT
BAND
ZONE
SCL
DABIN
BINDA
SCL2
IVCK
IVDR
IVRD
IVWR
IVBWR
IVMC
ADPRW
RBFM
WBFM
HSCT
LOADR
SAVER
INITR
LOGR
RWER
INITER
Function
Compare data within operations
Limits the output range of values
Define input offset
Define output offset
Scale values
Convert an ASCII number to a binary
value
Convert a binary value to ASCII code
Scale values (different value table
structure to SCL)
Check status of frequency inverter
Control frequency inverter
Read frequency inverter parameter
Write parameter to frequency inverter
Write parameters to frequency inverter
in blocks
Writes operation command and set
frequency to the inverter and reads
the inverter status and the output fre
-
quency (speed) from the inverter
Communication of the MODBUS mas
ter with slaves (read/write data)
Read from module buffer memory
Write to module buffer memory
Compare current value of a
high-speed counter with data in data
tables
Read data from extension file registers
Write data to extension file registers
Initialise extension registers and
extension file registers
Read values from devices in extension
registers and extension file registers
Write data from extension registers to
extension file registers
Initialise extension file registers
FX1S FX1N
쏹쏹쏹쏹쏹쏹
-
FX2N
FX2NC
FX3G
FX3GC
FX3GE
쏹쏹쏹
쏹쏹쏹
쏹쏹쏹
쏹쏹
쏹쏹
FX3S
FX3U
FX3UC
쏹
쏹
쏹
쏹
쏹
쏹
쏹
쏹
5–6MITSUBISHI ELECTRIC
More Advanced Programming Applied Instructions Reference
MOV K5 D12
M457
Controller
Category
Insructions for a
CF memory card
mounted in a
special adapter
FX
3U-CF-ADP
Instruc-
tion
FLCRT
FLDEL
FLWR
FLRD
FLCMD
FLSTRD
Function
Create/check file
Delete file/CF card format
Write data to CF card
Read data from CF card
FX3U-CF-ADP command
FX3U-CF-ADP status read
FX1S FX1N
FX2N
FX2NC
FX3G
FX3GC
FX3GE
FX3S
FX3U
FX3UC
쏹
5.1.1Entering applied instructions
Programming applied instructions in GX Works2 FX is simple. Just position the cursor in the
place in the program line where you want to insert the instruction and type the abbreviations for
the instruction and its operand(s). GX Work2 will automatically register that you are entering
an instruction and will open the input dialog (see below).Alternatively, you can also position the
cursor and then click on the insert instruction tool in the toolbar .
Yo u c a n a l s o s e l e c t t h e i n s t r u c t io n f r o m t h e
drop-down list, which you can display by
clicking on the "쑽" icon.
Then enter the abbreviations for the instruction and its operand(s) in the input field, separating
them by spaces.
All numbers must be preceded by a letter character, which either identifies the device type or –
in the case of constants – specifies the number format. The letter “K” identifies decimal con
stants and “H” identifies hexadecimal constants.
In the example on the left a MOV instruction
is used to write the value 5 to data register
D12.
The Help button opens a dialog in which you can search for a suitable instruction for the func
tion you want to perform.The help also contains information on how the functions work and the
type and number of devices that they take as operands.
-
-
Then you just click on
OK
to insert the
applied instruction into the program.
If you are programming in Instruction List format enter the instruction and its operand(s) in a
single line, separated by spaces.
FX Beginners Manual 5–7
Instructions for Moving DataMore Advanced Programming
MOV D10 D200
0
D10
D200
X001
t
5384
5384
2271
963
963
125
5.2Instructions for Moving Data
The PLC uses data registers for storing measurements, output values, intermediate results of
operations and table values.The controller’s math instructions can read their operands directly
from the data registers and can also write their results back to the registers if you want. How
ever, these instructions are also supported by additional “move" instructions, with which you
can copy data from one register to another and write constant values to data registers.
5.2.1Moving individual values with the MOV instruction
The MOV instruction “moves” data from the specified source to the specified destination.
NOTENote that despite its name this is actually a copy process – it does not delete the data from
the source location.
-
Ladder Diagram
쐃
Data source (this can also be a constant)
쐇
Data destination
In the example the value in data register D10 will be copied to register D200 when input X1 is
on. This results in the following signal sequence:
Instruction List
0 MOVD10D200
The contents of the data source will be
copied to the data destination as long as the
input condition evaluates true. The copy ope
5–8MITSUBISHI ELECTRIC
ration does not change the contents of the
data source.
Pulse-triggered execution of the MOV instruction
In some applications it is better if the value is written to the destination in one program cycle
only. For example, you will want to do this if other instructions in the program also write to the
same destination or if the move operation must be performed at a defined time.
Ifyouadda“P”totheMOVinstruction(MOVP)itwillonlybeexecutedonce, on the rising edge
of the signal pulse generated by the input condition.
-
When the input condition is no lon
ger true the instruction will no lon
ger change the contents of the data
destination.
-
-
More Advanced ProgrammingInstructions for Moving Data
MOVP D20 D387
M110
0
D20
D387
M110
t
4700
4700
6800
3300
3300
DMOV C200 D40
X010
0
DMOVP D10 D610
M10
0
In the example below the contents of D20 are written to data register D387 when the state of
M110 changes from “0" to ”1".
Ladder Diagram
After this single operation has been performed copying to register D387 stops, even if the
M110 remains set. The signal sequence illustrates this:
The contents of the data source are only copied to the destination on the rising pulse of the input condition.
Instruction List
0 LDM110
1 MOVPD20D387
Moving 32-bit data
To move 32-bit data just prefix a D to the MOV instruction (DMOV):
Ladder Diagram
When input X010 is on the current value of 32-bit counter C200 is written to data registers D40
and D41. D40 contains the least significant bits.
As you might expect, there is also a pulse-triggered version of the 32-bit DMOV instruction:
Ladder Diagram
When relay M10 is set the contents of registers D10 and D11 are written to registers D610 and
D611.
Instruction List
0 LDX010
1 DMOVC200D40
Instruction List
0LDM10
1 DMOVP D10D610
FX Beginners Manual5–9
Instructions for Moving DataMore Advanced Programming
M0
Y010
M1
Y011
M2
Y012
M3
Y013
MOV K1M0 K1Y010
M8000
M15M8M7M0
0101010101010101
01010101
0000000001010101
M6M5M12 M11 M10M9M4M3M2M1
M14 M13
5.2.2Moving groups of bit devices
The previous section showed how you can use the MOV instruction to write constants or the
contents of data registers to other data registers. Consecutive sequences of relays and other
bit devices can also be used to store numerical values, and you can copy them as groups with
applied instructions. To do this you prefixing a “K” factor to the address of the first bit device,
specifying the number of devices you want to copy with the operation.
Bit devices are counted in groups of 4, so the K factor specifies the number of these groups of
4. K1 = 4 devices, K2 = 8 devices, K3 = 12 devices and so on.
For example, K2M0 specifies the 8 relays from M0 through M7. The supported range is K1 (4
devices) to K8 (32 devices).
Examples for addressing groups of bit devices:
K1X0:4 inputs, start at X0(X0 to X3)
–
K2X4:8 inputs, start at X4(X4 to X13, octal notation)
–
K4M16: 16 relays, start at 16(M16 to M31)
–
K3Y0:12 outputs, start at Y0(Y0 to Y13, octal notation)
–
K8M0:32 relays, start at M0(M0 to M31)
–
Addressing multiple bit devices with a single instruction makes programming quicker and pro
duces more compact programs. The following two examples both transfer the signal states of
relays M0 – M3 to outputs Y10 – Y13:
If the destination range is smaller than the source range the excess bits are simply ignored
(see the following illustration, top example). If the destination is larger than the source “0” is
written to the excess devices. Note that when this happens the result is always positive
because bit 15 is interpreted as the sign bit (lower example in the following illustration).
Bit 15
Sign bit (0: positive, 1: negative)
MOVD0K2M0
These relays will not be changed
Bit 0
-
MOVK2M0D1
Sign bit (0: positive, 1: negative)
5–10MITSUBISHI ELECTRIC
Bit 15
Bit 0
More Advanced ProgrammingInstructions for Moving Data
BMOV D10 D200 K5
0
D 10
D 11
D 12
D 13
D 200
D 201
D 202
D 203
D 14
D 204
1234
5678
-156
8765
4321
1234
5678
-156
8765
4321
BMOV D10 D200 K5
M0
M1
M2
M3
Y000
Y001
Y002
Y003
0
1
1
0
0
1
1
0
BMOV K1M0 K1Y0 K2
M4
M5
M6
M7
Y004
Y005
Y006
Y007
1
0
1
0
1
0
1
0
5.2.3Moving blocks of data with the BMOV instruction
The MOV instruction described in section 5.2.1 can only write single 16 or 32 bit values to a
destination. If you want, you can program multiple sequences of MOV instructions to move
contiguous blocks of data. However, it is more efficient to use the BMOV (Block MOVe) instruc
tion, which is provided specifically for this purpose.
-
Ladder Diagram
쐃
Data source (16-bit device, first device in source range)
쐇
Data destination (16-bit device, first device in destination range)
쐋
Number of elements to be moved (max. 512)
The example above works as follows:
BMOV also has a pulse-triggered version, BMOVP (see section 5.1.2 for details on pulse-triggered execution).
Instruction List
0 BMOVD10D200K5
5 data registers
7 data words
Blocks of bit devices: When you move blocks of bit devices with BMOV the K factors of the data
source and the data destination must always be identical.
Example
This copies 2 blocks with 4 bit
devices each.
FX Beginners Manual5–11
Instructions for Moving DataMore Advanced Programming
FMOV D4 D250 K20
0
D 10
D 11
D 12
D 13
D 14
0
FMOV K0 D10 K7
0
0
0
0
0
0
0
D 15
D 16
5.2.4Copying source devices to multiple destinations (FMOV)
The FMOV (Fill MOVe) instruction copies the contents of a word or double word device or a
constant to multiple consecutive word or double word devices. It is generally used to delete
data tables and to set data registered to a predefined starting value.
Ladder Diagram
쐃
Data to be written to the target devices (constants can also be used here)
쐇
Data destination (first device of the destination range)
쐋
Number of elements to be written in the destination range (max. 512)
The following example writes the value “0” to 7 elements:
Instruction List
0 FMOVD4D250K20
Here too, FMOV has a pulse-triggered version, FMOVP (see section 5.1.2 for details on
pulse-triggered execution).
You can alsotransfer 32-bit data by prefixing theinstruction with “D” (DFMOV and DFMOVP).
5–12MITSUBISHI ELECTRIC
More Advanced ProgrammingInstructions for Moving Data
5.2.5Exchanging data with special function modules
You can add expansion modules to increase the number of inputs and outputs available to all
base units of the MELSEC FX series except the FX
you can also supplement the controller’s functions by adding so-called “special function mod
ules” – for example for reading analog signals for currents and voltages, for controlling temper
atures and for communicating with external equipment.
The digital I/O expansion modules do not require specialinstructions; the additionalinputs and
outputs are handled in exactly the same way as those in the base unit. Communication
between the base unit and special function modules is performed with two special applied
instructions: the FROM and TO instructions.
Each special function module has a memory range assigned as a buffer for temporary storage
of data, such as analog measurement values or received data. The base unit can access this
buffer and both read the stored values from it and write new values to it, which the module can
then process (settings for the module’s functions, data for transmission etc).
1S and the FX3S models. In addition to this
-
-
Base unit
Device memory
FROM
The buffer memory can have up to 32,767 indi
vidual addressable memory cells, each of
which can store 16 bits of data.The functions of
the buffer memory cells depends on the indi
vidual special function module – see the mod
ule’s documentation for details.
TO
-
-
-
Special function module
Buffer memory
Buffer memory address 0
Buffer memory address 1
Buffer memory address 2
:
:
Buffer memory address n-1
Buffer memory address n-1
The following information is required when you use the FROM and TO instructions:
–
The special function module to be read from or written to
–
The address of the first buffer memory cell to be read from or written to
–
The number of buffer memory cells to be read from or written to
–
The location in the base unit where the data from the module is to be stored or containing
the data to be written to the module
FX Beginners Manual5–13
Instructions for Moving DataMore Advanced Programming
24-
24+
SLD
SLD
SLD
L-
L-
SLD
L-
L-
L+
L+
L+
L+
FX2N-4AD-TC
FX -4AD-PT
2N
24-
24+
FX2N-4DA
V+
V+
V+
I+
I+
V+
I+
I+
VI-
VI-
VI-
VI-
FX -4DA
2N
D
/
A
24-
V+
V+
V+
I+
I+
V+
I+
I+
24+
VI-
VI-
FG
FG
VI-
VI-
FG
Special function module address
Since you can attach multiple special function modules to a single controller each module
needs to have a unique identifier so that you can address it to transfer data to and from it. Each
module is automatically assigned a numerical ID in the range from 0 to 7 (you can connect a
maximum of 8 special function modules). The numbers are assigned consecutively, in the
order in which the modules are connected to the PLC.
Special function
module 0
Module 1
Module 2
Starting address in the buffer memory
Every single one of the 32,767 buffer addresses can be addressed directly in decimal notation
in the range from 0 to 32,767 (FX
1N: 0 to 31). When you access 32-bit data you need to know
that the memory cell with the lower address stores the less significant 16 bits and the cell with
the higher address stores the more significant bits.
Buffer address n+1Buffer address n
More significant 16 bits
Less significant 16 bits
32-bit data
This means that the starting address for 32-bit data is always the address containing the less
significant 16 bits of the double word.
Number of data units to be transferred
The quantity ofdata is defined by the number ofdata unitsto be transferred. When youexecute
a FROM or TO instruction as a 16-bit instruction this parameter is the number of words to be
transferred. In the case of the 32-bit versions DFROM and DTO the parameter specifies the
number of double words to be transferred.
16-bit instruction
Units of data: 5
D100
D101
D102
D103
D104
5–14MITSUBISHI ELECTRIC
Adr. 5
Adr. 6
Adr. 7
Adr. 8
Adr. 9
32-bit instruction
Units of data: 2
D100
D101
D102
D103
D104
Adr. 5
Adr. 6
Adr. 7
Adr. 8
Adr. 9
More Advanced ProgrammingInstructions for Moving Data
FROM K0 K9 D0 K1
0
DFROM K2 K8 D8 K4
0
FROMP K0 K0 D10 K4
0
The value you can enter for the number of data units depends on the PLC model you are using
and whether you are using the 16-bit or 32-bit version of the FROM instruction:
Valid range for no. of data units to be transferred
1 to 321 to 16
1 to 321 to 16
1 to 327671 to 16383
Data destination or source in the base unit
In most cases you will read data from registers and write it to a special function module, or copy
data from the module’s buffer to data registers in the base unit. However, you can also use out
puts, relays and the current values of timers and counters as data sources and destinations.
Pulse-triggered execution of the instructions
If you add a P suffix to the instructions the data transfer is initiated by pulse trigger (for details
see the description of the MOV instruction in section 5.2.1).
How to use the FROM instruction
The FROM instruction is used to transfer data from the buffer of a special function module to
the controller base unit. Note that this is a copy operation – the contents of the data in the mod
ule buffer are not changed.
Ladder Diagram
Instruction List
-
-
0FROMK0K9D0K1
쐃
Special function module address (0 to 7)
쐇
Starting address in buffer (FX
1N: 0 to 31, FX2NC,FX3G,FX3GC,FX3GE,FX3U und FX3UC:0
to 32,766). You can use a constant or a data register containing the value.
쐋
Data destination in the controller base unit
쐏
Number of data units to be transferred
The example above uses FROM to transfer data from an FX
2N-4AD analog/digital converter
module with the address 0. The instruction reads the current value of channel 1 from buffer
address 9 and writes it to data register D0.
The next example shows how the 32-bit version of the instruction is used to read data from
address 2 in the special function module. The instruction reads 4 double words starting at
buffer address 8 and writes them to data registers D8 to D15.
The next example illustrates the use of the pulse triggered version, FROMP.Here the contents
of the four buffer addresses 0–3areonlytransferredtodataregistersD10–D13whenthesig
nal state of the input condition changes from “0” to “1”.
-
FX Beginners Manual5–15
Compare InstructionsMore Advanced Programming
TO K0 K1 D0 K1
0
CMP D0 K100 M0
0
How to use the TO instruction
The TO instruction transfers data from the controller base unitto thebuffer of a special function
module.Note that this is a copy operation, it does not changethe data inthe source location.
Ladder Diagram
쐃
Special function module address (0 to 7)
쐇
Starting address in buffer (FX
FX
3UC: 0 to 32,766). You can use a constant or a data register containing the value.
쐋
Data source in the controller base unit
쐏
Number of data units to be transferred
1N: 0 to 31, FX2N,FX2NC,FX3G,FX3GC,FX3GE,FX3U and
In the example above the contents of data register D0 is copied to the buffer address 1 of spe
cial function module number 0.
5.3Compare Instructions
Checking the status of bit devices like inputs and relays can be achieved with basic logic
instructions because these devices can only have two states, “0” and “1”. However, you will
also often want to check the contents of word devices before doing something – for example
switching on a cooling fan when a specified setpoint temperature is exceeded. The controllers
of the MELSEC FX family provide a number of different ways to compare data.
Instruction List
0TOK0K1D0K1
-
5.3.1The CMP instruction
CMP compares two numerical values, which can be constants or the contents of data registers. You can also compare the current values of timers and counters.Depending on the result
of the comparison (greater than, less than or equal) one of three bit devices is set.
Ladder Diagram
쐃
Input condition
쐇
First value to be compared
쐋
Second value to be compared
쐏
First of three consecutive relays or outputs, which are set (signal status “1”) depending on
the result of the comparison:
1. Device 1: ON if Value 1 > Value 2
2. Device 2: ON if Value 1 = Value 2
3. Device 3: ON if Value 1 < Value 2
Instruction List
0 LD....
1 CMPD0K100M0
5–16MITSUBISHI ELECTRIC
More Advanced ProgrammingCompare Instructions
DCMP D0 D2 M0
0
CMP D20 K22 M20
M8000
RST Y000
M22
M20
SET Y000
0
8
10
In this example the CMP instruction controls relays M0, M1and M2.M0 is “1” if the contents
of D0 is greater than 100; M1 is “1” if the contents of D0 isprecisely 100 and M2is “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
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 theresult 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:
In this example the CMP instruction isexecuted 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 temperature 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 Manual5–17
Compare InstructionsMore Advanced Programming
>= D40 D50
0
D> D10 D250
0
5.3.2Comparisons within logic operations
In the CMP instruction described in the last section the result of the comparison is stored in
three bit devices. Often, however, you only want to execute an output instruction ora logic oper
ation on the basis of the result of a comparison, and you generally won’t want to have to use
three bit devices for this.You can achieve this with the “load compare” instructions and the AND
and OR bitwise logic comparisons.
Comparison at the beginning of a logic operation
-
Ladder Diagram
Instruction List
0 LD>=D40D50
쐃
Compare condition
쐇
First compare value
쐋
Second compare value
If the condition evaluates true the signal state after the comparison is set to “1”.A signal state of
“0” shows that the comparison evaluated as false. The following comparisons are possible:
–Compare for "equals":=(value1=value2)
The output of the instruction is only set to "1" if the values of both devices are identical.
–Compare for "greater than":>(value1>value2)
The output of theinstruction is only set to "1" if thefirst value is greater than the second value.
–Compare for "less than":<(value1<value2)
The output of theinstruction is only set to "1" if thefirst value is smaller thanthe second value.
–Compare for "not equal":<>(value 1 <> value 2)
The output of the instruction is only set to "1" if the two values are not equal.
–
Compare for "less than or equal to":<=(value 1 울 value 2)
The output of the instruction is only set to "1" if the first value is less than or equal to the se
cond value.
–
Compare for "greater than or equal to": >=(value 1 욷 value 2)
The output of the instruction is only set to "1" if the first value is greater than or equal to the
second value.
To compare 32-bit data prefix a D (for double word) to the compare condition:
Ladder Diagram
Instruction List
0 LDD>D10D250
This "D" specifies 32-bit data
-
5–18MITSUBISHI ELECTRIC
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.