Mitsubishi
Mitsubishi
Mitsubishi
When designing the system, always read the relevant manuals and give sufficient consideration to
safety.
During the exercise, pay full attention to the following points and handle the product correctly.
[EXERCISE PRECAUTIONS]
WARNING
Do not touch the terminals while the power is on to prevent electric shock.
Before opening the safety cover, make sure to turn off the power or ensure the safety.
CAUTION
Follow the instructor's direction during the exercise.
Do not remove the module of the demonstration machine or change wirings without permission.
Doing so may cause failures, malfunctions, personal injuries and/or a fire.
When the demonstration machine (such as X/Y table) emits abnormal odor/sound, press "Power
switch" or "Emergency switch" to turn off.
This textbook confers no industrial property rights or any rights of any other kind, nor does it confer any patent
licenses. Mitsubishi Electric Corporation cannot be held responsible for any problems involving industrial property
rights which may occur as a result of using the contents noted in this textbook.
1.1 Program··········································································································································· 1- 1
1.2 Program Processing Procedure ······································································································ 1- 4
1.3 MELSEC-QnUD Module Configuration ··························································································· 1- 5
1.4 External I/O Signal and I/O Number······························································································· 1-11
1.5 System Configuration and I/O Number of Demonstration Machine··············································· 1-14
3.1 Device·············································································································································· 3- 1
3.2 Parameter········································································································································ 3- 3
(1)
CHAPTER 4 SEQUENCE AND BASIC INSTRUCTIONS -PART 1- 4- 1 to 4-42
(2)
CHAPTER 6 HOW TO USE OTHER FUNCTIONS 6- 1 to 6-36
(3)
CHAPTER 8 SIMULATION FUNCTION 8- 1 to 8- 4
CHAPTER 9 MAINTENANCE 9- 1 to 9- 8
(4)
4.25 Application example of data shift························································································App.-41
4.26 Example of operation program calculating square root of data··········································App.-44
4.27 Example of operation program calculating n-th power of data···········································App.-45
4.28 Program using digital switch to import data········································································App.-46
4.29 Displaying number of faults and fault numbers using fault detection program ·················· App.-47
Appendix 5 Memory and File to be Handled by CPU Module························································· App.-51
Appendix 6 Comparison with GX Developer (changes) ································································· App.-53
Appendix 7 Customizing Shortcut Keys ··························································································App.-62
Appendix 8 Indexing························································································································ App.-64
Appendix 9 FB ································································································································· App.-68
9.1 FB ········································································································································· App.-68
9.1.1 Conversion into components ·························································································· App.-68
9.1.2 Advantages of using FBs································································································ App.-69
9.1.3 FB Libraries ···················································································································· App.-71
9.1.4 Development tool············································································································ App.-73
9.1.5 FB specifications and precautions·················································································· App.-73
9.2 Creating a program by using an FB library···········································································App.-74
9.2.1 Programs to be created ··································································································App.-74
9.2.2 Preparations prior to use of FB libraries········································································· App.-75
9.2.3 Importing an FB library to projects ················································································· App.-76
9.2.4 Pasting FBs ···················································································································· App.-77
9.2.5 Setting names of the pasted FBs ··················································································· App.-78
9.2.6 Creating input and output ladders ·················································································· App.-79
9.2.7 Performing conversion/compilation ················································································ App.-79
9.2.8 Writing sequence programs ··························································································· App.-80
9.2.9 Operation check ············································································································· App.-80
(5)
INTRODUCTION
This textbook explains the programmable controller, the program editing methods
with GX Works2, the sequence instructions and the application instructions for
understanding the MELSEC-Q series programming.
The multiple CPU system is available for the MELSEC-Q series with multiple CPU
modules, but this textbook explains the case in which one CPU module is used.
(6)
CHAPTER 1 BASICS OF PROGRAMMABLE CONTROLLER
1.1 Program
PLC
PB1 X6 T1
Y70
X0 Y74 PL
Y71
LS1 X1 Output relay
Y74
Y72
X2
Y73 Electromagnetic
PB2 X3 K30 valve
Y74 X6
Y74
X4 T1 MC
Y75 Magnet
X5 Timer
contactor
Sensor Y76
X6
Turns on/off the Activates the Transmits the on/off Activates the
input relay with internal sequential operations of the external loading.
external signal. operation by the output relay.
contact of the input relay.
"Relay", which is also called an electromagnetic relay, is a switch to relay signals. The relay is a key component to
make up a logic ladder.
1) Energizing the coil Magnetization Coil off Coil on
• The normally open contact closes. (always) (in operation)
(Conducted) Normally open Not conducted Conducted
• The normally closed contact opens. Coil contact
Common
(Not conducted) Normally
2) De-energizing the coil closed contact Conducted Not conducted
Demagnetization
• The normally open contact opens.
Normally Normally
(Not conducted)
closed contact
• The normally closed contact closes. open contact
(Conducted)
1-1
Internal Sequential Operation
The following shows the signal flow of the internal sequential operation of
figure 1.1.
1) When the sensor turns on, the coil of the input relay X6 is magnetized.
2) Magnetizing the coil of the input relay X6 conducts the normally open
contact X6 and magnetizes the coil of the output relay Y74.
(As the timer is not magnetized at this time, the normally closed
contact remains conducted.)
3) Once the coil of the output relay Y74 is magnetized, the external
output contact Y74 is conducted and the magnetic contactor (MC) is
turned on.
4) Turning off the sensor demagnetizes the coil of the input relay X6 and
the normally open contact X6 becomes non-conductive.
As the self-maintaining normally open contact Y74 is conducted, the
coil remains magnetized. (Self-maintaining operation)
5) When the coil of the output relay Y74 is magnetized (with the normally
open contact Y74 conducted), turning off the sensor (with normally
closed contact X6 conducted) magnetizes the coil of the timer T1 and
the timer starts measuring the time.
After three sec. (K30 indicates 3.0sec.), the normally open contact of
the timer becomes conducted and the normally closed contact
becomes non-conductive.
6) As a result, the coil of the output relay Y74 demagnetizes and the load
magnet contactor drops.
Also, the output relay self-maintenance is released.
Operation diagram
The following time chart explains the input/output relays and timer
operations.
Input X6
Output Y74
Timer T1 (Coil)
Timer T1 (Contact)
3 sec.
1-2
The internal sequential operation can be regarded as the program of
the programmable controller. The program is saved in the program
memory as similar to the instruction list
Instruction
X6 T1 Step number Device
word
0 Y74
0 LD X6
Y74 1 OR Y74
2 ANI T1
K30 Repeat
Y74 X6 3 OUT Y74
operation
4 T1 4 LD Y74
5 ANI X6
10 END
6 OUT T1 K30
10 END
(a) Ladder diagram (b) Instruction list (program list)
• The number of steps from the step number 0 to the END instruction
is the length or size of the program.
• The program is stored in the program memory inside the CPU. The
operation is executed in a ladder block unit.
One ladder block ranges from the operation start instruction (LD,
LDI) to the OUT instruction (including the data instruction).
1-3
1.2 Program Processing Procedure
The operation process is executed in series from the start step of the program
memory left to right and top to bottom (in the order of 1), 2) ... 17)) in a ladder block
unit as shown below.
1) 2) 3)
X0 X1
0 Y10
4) 5) 7)
X2 X3
3 Y11
6)
X4
8) 9) 10)
X5 X6
7 Y12
11) 12)
X7
Y13
13) 14)
X8
Y14
1-4
1.3 MELSEC-QnUD Module Configuration
Memory card
Q8BAT-SET
1-5
Base Unit
Power supply
Power supply
CPU
With three
I/O modules Q52B
(For two modules)
Q33B Q63B
Power supply
Power supply
CPU
With five
I/O modules
Q35B Q65B Q55B
Power supply
Power supply
CPU
With eight
I/O modules
Q38B Q68B
Power supply
Power supply
CPU
With 12
I/O modules
Q312B Q612B
With eight
I/O modules
Q38DB
Power supply
CPU
With 12
I/O modules
Q312DB
• The main roles of the base unit are; fixing the power supply module,
CPU module, and I/O modules, supplying 5VDC power from the
power supply module to the CPU module and I/O modules, and
transmitting the control signals to each module.
1-6
Power Supply Module
CPU Module
Maximum I/O points for
Program capacity Basic instruction
CPU type connecting to a
(maximum) processing speed
programmable controller
Q00UJCPU 10K steps 120ns 256 points
Q00UCPU 10K steps 80ns 1024 points
Q01UCPU 15K steps 60ns 1024 points
Q02UCPU 20K steps 40ns 2048 points
Q03UD(E)CPU 30K steps 20ns
Q04UD(E)HCPU 40K steps
Q06UD(E)HCPU 60K steps
Q10UD(E)HCPU 100K steps
Q13UD(E)HCPU 130K steps 4096 points
9.5ns
Q20UD(E)HCPU 200K steps
Q26UD(E)HCPU 260K steps
Q50UDEHCPU 500K steps
Q100UDEHCPU 1000K steps
I/O Module
I/O points
8 points 16 points 32 points 64 points
Format
120VAC – – –
240VAC – – –
Input module
Independent contact
– – –
output
Triac output – – –
Transistor output (sink)
Transistor output (source) – –
I/O mixed – –
1-7
Memory Card
A QCPU equips a built-in memory as standard for storing parameters and
programs, therefore, the programs can be executed without a memory card.
The memory cards are required for the situations in the table below.
Type Description
Data can be written or changed within the memory capacity.
<Example of the usage>
• For the boot operation
SRAM card
• For storing the sampling trace data
• For storing the SFC trace data
• For storing the error history data
The contents of the program memory or the specified file can be written at a time.
The newly written data replaces all original data. Data can be read by the READ instruction of
the sequence program.
Flash card
<Example of the usage>
• For the boot operation
• When the changing the data is unnecessary
Data can be written or changed within the program capacity.
Programmable controller user data of an ATA card can be accessed by the file access
instruction (such as the FWRITE instruction) in a sequence program through a CSV format or
ATA card binary format.
<Example of the usage>
• For the boot operation
• For programmable controller user data (general-purpose data)
1-8
<Reference: Universal model QCPU memory system configuration>
The memory of the Universal model QCPU consists of the following blocks.
Program memory
RAM
(program cache memory)
Parameter Program Parameter Program
Device comment Device initial value Device comment Device initial value
Standard
RAM *2
File register Local device
• Program memory: A memory for storing programs and parameters for a CPU module
operation
A program operation is executed by transferring a program stored in
the program memory to the program cache memory.
• Program cache memory: A memory for operating programs
A program operation is executed by transferring a program stored in
the program memory to the program cache memory.
• Standard RAM: A memory for using file registers, local devices, and sampling trace
files without a memory card
Using the standard RAM as the file registers enables the high-speed
access as well as data registers.
The standard RAM is also used for storing the module error
collection file.
• Standard ROM: A memory for storing data such as parameters and programs
• Memory card (RAM): A card for storing the local device, debug data, SFC trace data, and
error history data with the parameters and program.
• Memory card (ROM): A Flash card for storing parameters, programs, and file registers.
An ATA card stores parameters, programs, and the programmable
controller user data (general-purpose files).
1-9
POINT
Device data
Backup Latch data
Device memory execution Backup
condition is file
ON (Standard ROM)
File register
(Standard RAM)
1 - 10
1.4 External I/O Signal and I/O Number
0 1 2 3 4 Slot numbers
(Power (CPU)
supply)
(QY)
(QX) Base unit
Input numbers Output numbers
Y10
PB1 V1
X0
CS1 Y11
X1 V2
CS2 Input numbers are hexadecimal numbers that start
X2 with 0. Input/output numbers share the same numbers.
Y12
PB2 V3
"X" at the beginning of the number represents "Input",
X3
and "Y" indicates "Output".
PB3 Y13
X4 RL
The maximum number of the QCPU (Q mode)
LS1 input/output number is 4,096.
X5 Y14
GL
LS2 The input/output number is sometimes referred
X6
Y15 to as the I/O number (IN/OUT).
LS3 MC1
X7
LS4 Y16
X8
MC2
PB4
X9
Y17
PB5 MC3
XA
CS3 COM1
XB
XC
Y18
XD
Y1F
XE
XF COM2
COM
Output module
Input module
1 - 11
(2) I/O numbers of a main base unit
The I/O numbers of I/O modules which are attached to a main base unit are
assigned as follows. This configuration applies to both I/O modules and
intelligent function modules.
0 1 2 3 4 5 6 7 8 9 10 11 Slot numbers
Power supply module
I/O numbers
00 to 0F
10 to 1F
20 to 2F
30 to 3F
40 to 4F
50 to 5F
60 to 6F
70 to 7F
90 to 9F
B0 to BF
80 to 8F
A0 to AF
CPU
H
• The I/O numbers of one slot (one module) are assigned in ascending order in 16-point unit (0 to F ).
As a standard, 16-point modules should be attached to all slots.
For example, the following figure shows the I/O numbers of when a 32-point module is attached to the fifth slot.
Main base unit
0 1 2 3 4 5 6 7 Slot numbers
The I/O numbers of the
Power supply module
50 to 5F / 60 to 6F
70 to 7F
80 to 8F
changed.
(The numbers are
assigned in order from
lower numbers.)
• The I/O numbers are also assigned to a vacant slot (a slot with no I/O module installed).
For example, if the third slot is vacant, the I/O numbers are assigned as shown below. (in the initial setting)
The number of assigned points can be changed by the setting.
Main base unit
0 1 2 3 4 5 6 7 Slot numbers
Power supply module
Vacant slot
00 to 0F
10 to 1F
20 to 2F
40 to 4F
50 to 5F
60 to 6F
70 to 7F
(30 to 3F)
CPU
• For the multiple CPU configuration (two to four CPUs), the I/O numbers are assigned from a slot next to a slot where
a CPU is attached.
1 - 12
(3) I/O numbers of an extension base unit
Connect an extension base unit when the number of slots of the main base unit
is insufficient.
The I/O numbers are assigned as follows in the initial setting.
This configuration applies to both I/O modules and intelligent function modules.
0 1 2 3 4 5 6 7 Slot numbers
Power supply module
00 to 0F
10 to 1F
30 to 3F
40 to 4F
60 to 6F
20 to 2F
50 to 5F
70 to 7F
CPU
Extension cable
8 9 10 11 12 13 14 15
Power supply module
C0 to CF
D0 to DF
A0 to AF
B0 to BF
E0 to EF
F0 to FF
80 to 8F
90 to 9F
(Note)
First extension
Parameters allow the setting different from the
base unit
actual number of slots.
For example, a base unit for 12 slots can be set as
a base unit for 3 slots and vice versa.
(Q65B) This is in order to handle the future extension, and
to prevent the gap of I/O numbers which is likely to
happen when a conventional system is shifted to the
16 17 18 19 20 new one.
For details, refer to the QnUCPU User's Manual
Power supply module
100 to 10F
110 to 11F
120 to 12F
130 to 13F
140 to 14F
Second
extension base
unit
21 22 23 24 25 26 27 28
Power supply module
1C0 to 1CF
1A0 to 1AF
1B0 to 1BF
150 to 15F
160 to 16F
170 to 17F
180 to 18F
190 to 19F
Third extension
base unit
• The slots of the extension base unit are also assigned in ascending order in 16-point unit.
• The start I/O number of the extension base unit is assigned from the last number of the main base unit or of the
previous extension base unit.
• Setting "0" to the parameter can assign the I/O number to the vacant slot or areas with no slot.
The following table shows the number of available extension base units.
CPU type Number of stages (including the ones
connected with GOT in bus connection)
Universal model Q00UJCPU 2
Q00UCPU, Q01UCPU, Q02UCPU 4
Other than the above 7
1 - 13
1.5 System Configuration and I/O Number of Demonstration Machine
X0 Y40
to to
USB cable X3F Y7F
Peripheral device
I/O panel
Y6F Y60 Y5F Y50 Y4F Y40
Y77 Y76 Y75 Y74 Y73 Y72 Y71 Y70
ON
OFF
1 - 14
CHAPTER 2 OPERATING GX Works2
Programming
Programs can be created in a Simple project in a similar way with existing
GX Developer.
Structured programming in a Structured project is also available with GX
Works2.
Setting parameters
The parameters for programmable controller CPUs and network
parameters can be set with GX Works2.
Intelligent function module parameter can be set as well.
Reading data
Writing data
2-1
Monitoring/debugging
Created sequence programs can be written to the programmable controller
CPU and device values at operation can be monitored online/offline.
Diagnostics
The current error status and error history of the programmable controller
CPU can be diagnosed.
With the diagnostics function, the recovery work is completed in a short
time.
With the System monitor function (for QCPU (Q mode)/LCPU), detailed
information on such as intelligent function modules can be obtained. This
helps to shorten the recovery work time at error occurrence.
Diagnosing the
programmable controller
CPU status
2-2
2.1 Features of GX Works2
Program block B
Function block 2
Program block C Program SUB1
Function 1 Program block D
2-3
(2) Enhanced use of program assets
Projects created with existing GX Developer can be utilized in a Simple project.
Utilizing the past assets improves the efficiency of program design.
<GX Developer> <GX Works2>
Project created
with GX Developer
Can be used in
GX Works2.
Project A
Project B
Project C
Project D
Library file
2-4
(4) Wide variety of programming languages
The wide variety of programming languages available with GX Works2 enables
to select the optimum programming language according to control.
<Ladder> <SFC>
Programming similar to existing GX Developer Programming to clarify the procedure
Simulation function
2-5
(b) The screen layout can be customized to the user's preference
The docking windows enable to change the screen layout of GX Works2
without restriction.
2-6
2.1.1 MELSOFT iQ Works
MELSOFT iQ Works
GX Works2 MT Developert2
GT Designer3
(Programmable controller (Motion controller
(GOT drawing software)
programming software) programming software)
MELSOFT Navigator
(System configuration management tool)
POINT
To start MELSOFT Navigator and each engineering software, click the Start button and follow
the procedure below.
• MELSOFT Navigator: [MELSOFT Application] → [MELSOFT iQ Works] → [MELSOFT
Navigator]
• GX Works2: [MELSOFT Application] → [GX Works2] → [GX Works2]
• MT Developer2: [MELSOFT Application] → [MT Works2] → [MT Developer2]
• GT Designer3: [MELSOFT Application] → [GT Works3] → [GT Designer3]
2-7
[Purpose of the engineering environment]
ERP
(Enterprise Resource Planning)
MES
(Manufacturing Execution System)
Engineering environment
POINT
2-8
2.2 Basic Knowledge Required for Operating GX Works2
1) Title bar
2) Menu bar
3) Toolbar
4) Tab
9) Status bar
2-9
1) Title bar
Title bar displays the name of the active project.
2) Menu bar
Menu bar is the most frequently used item when operating GX Works2.
Click the menu bar to select a variety of functions from the drop-down menu.
3) Toolbar
Toolbar equips buttons to easily access the commonly-used functions.
This enables a quicker operation.
4) Tab
When multiple work windows are open, they are displayed in the tab browser
format. Clicking a tab activates the corresponding work window.
8) Output window
Output window displays compilation and check results (such as errors and
warnings).
9) Status bar
Status bar displays the status information of GX Works2.
Displays the
state of Caps Lock.
Displays the current mode.
2 - 10
2.2.2 Ladder editor
This section explains the screen display of the GX Works2 ladder editor and its
basic operations.
2 - 11
(3) Changing the text size on the edit screen
The text size displayed on the edit screen can be changed.
1) Select [View] → [Text Size] →
[Bigger]/[Smaller].
POINT
Displaying/hiding comments
Comments also can be displayed or hidden by the following operation.
[Tool] → [Option] → "Program Editor" → "Ladder" → "Comment"
2 - 12
(5) Setting the number of rows and columns for displaying comments
The option setting allows switching the number of rows and columns for
displaying a device comment.
1) Click [Tool] → [Option].
2 - 13
(From the previous page)
Example)
4 rows × 8 columns 2 rows × 5 columns
2 - 14
(6) Setting the number of contacts to be displayed in ladder programs
The option setting allows switching the number of contacts to be displayed in a
single row.
1) Click "Program Editor" → "Ladder" → "Ladder
Diagram" in the Options screen.
2 - 15
(7) Switching the label name display and device display
The display of a program that uses labels can be switched between the label
name display and device display.
If label comments or device comments are set, the corresponding comments
are displayed.
Devices assigned by the compilation can be checked by switching the program
display from the label name display to the device display.
Example)
Label name display Device display
POINT
Displaying/hiding label comments and device comments
To check the set label comments and device comments, set the setting to display
comments. (Refer to section 2.2.2 (4))
2 - 16
(8) Hiding a ladder block
The ladder block after the ladder conversion can be hidden.
The ladder block in which the statements are set is hidden with the statements
displayed.
2 - 17
(From the previous page)
2 - 18
(From the previous page)
POINT
Displaying/hiding ladder blocks
• Multiple ladder blocks also can be displayed and hidden.
• All ladder blocks can be displayed and hidden by the operation of [View] →
[Display All Ladder Block]/[Non-Display All Ladder Block].
• Ladder blocks also can be displayed and hidden by Right-click →
[Displaying/hiding ladder blocks].
2 - 19
2.2.3 Project
This section explains the configurations of a project that is displayed in a tree format
in the Project view. The display contents differ according to the programmable
controller type and the project type. The following is an example for a Simple project
of QCPU (Q mode).
Create programs.
GX Works2 Version 1 Operating Manual Simple Project
Create programs.
GX Works2 Version 1 Operating Manual Simple Project
2 - 20
1) One project per GX Works2
One GX Works2 can edit only one project unit.
To edit two or more projects at a time, run as many GX Works2 as the
number of projects.
2) Device comments
Device comment of GX Works2 is categorized into global device
comment and local device comment.
2 - 21
2.3 Operation Before Creating Ladder Program
1) Click!
2 - 22
2.3.2 Creating a new project
1) Click!
1) Click on the toolbar or select [Project] →
[New Project] ( Ctrl + N ).
2 - 23
(From the previous page)
2 - 24
2.4 Preparation for Starting Up CPU
Setting switches and formatting the built-in memory are required before writing a
program to the CPU.
Connect or set the connectors and the switches of (1) to (3) shown below.
(The figures below are example of Q06UDHCPU.)
Q06UDHCPU
(2)
(3)
(1)
2 - 25
(4) Setting the connection destination
This section explains how to set the connection destination for accessing the
programmable controller CPU.
1) Click!
3) Double-click!
2 - 26
(From the previous page)
7) Click!
2 - 27
(5) Formatting the built-in memory of the CPU
This section explains how to format the program memory of the QCPU.
1) Click!
3) Click!
4) Click!
5) Click!
6) Click!
2 - 28
(6) Clearing all the device memory from the CPU
This section explains how to clear the device memory of the QCPU.
1) Click [Online] → [PLC Memory Operation] →
[Clear PLC Memory].
1) Click!
4) Click!
5) Click!
7) Click!
2 - 29
(7) Clearing the error history in the CPU
This section explains how to clear the error history data stored in the QCPU.
1) Click!
4) Click!
2 - 30
(8) Setting the clock on the programmable controller CPU
Setting a year, month, date, time, minute, second, and day of the week to the
clock on the programmable controller CPU is available.
To use the clock function, use GX Works2 or a sequence program.
Set or read the clock data in GX Works2.
1) Click!
2) Enter time!
3) Click!
2 - 31
2.5 Creating Ladder Program
A ladder program to be created Follow the steps below to create the ladder program
as shown on the left.
X2 X0
Y70
Y70
X3
Y71
X0
2 - 32
(From the previous page)
Y70
X3
16) The entered symbol ( ) is displayed.
16) The symbol is displayed!
18) Press "Enter"! 17) Press the F7 key, and enter "Y71".
2 - 33
2.5.2 Creating a ladder program using the tool buttons
A ladder program to be created Follow the steps below to create the ladder program
as shown on the left.
X2 X0
Y70
Y70
X3
Y71
X2
3) The entered symbol ( ) is displayed.
3) The symbol is displayed!
X0
6) The entered symbol ( ) is displayed.
6) The symbol is displayed!
7) Click , 8) Click!
then enter "X70". 8) Click the OK button.
2 - 34
(From the previous page)
11) Click!
11) Click the OK button.
10) Click ,
then enter "X0".
Y70
12) The entered symbol ( ) is displayed.
X3
16) The entered symbol ( ) is displayed.
2 - 35
2.6 Converting Program (Ladder Conversion)
1) Click!
2 - 36
2.7 Writing/Reading Data to/from Programmable Controller CPU
3) Click!
5) Click!
2 - 37
(From the previous page)
8) Click!
9) Click!
2 - 38
(2) Reading data from the CPU
1) Click!
3) Click!
4) Click!
6) Click!
2 - 39
2.8 Monitoring Ladder Program Status
3) Click!
Operation Practice
1) Confirm that the LED indicator Y70 lights up by turning on the snap switch X2,
and that the indicator remains lit after the snap switch is turned off.
2) Confirm that the LED indicator Y70 turns off by pressing (turning on) the push
button (snap switch) X0, and that the indicator does not light up when the button
(snap switch) is released (turned off).
3) Turning on the snap switch X3 turns on the LED indicator Y71.
2 - 40
(1) In the monitor mode, the Monitor Status dialog box shown below is displayed
regardless of the monitor status.
1) 2) 3) 4) 5)
1) Connection status
Displays the connection status between a programmable controller
CPU and personal computer in which the simulation function is started.
2) RUN/STOP status
Displays the programmable controller CPU status operated by the key
switch on the programmable controller CPU or the remote operation
from GX Works2.
5) Scan time
Displays the maximum scan time of the monitored programmable
controller CPU.
The Q-series programmable controller displays the scan time in units
of 0.1msec.
2 - 41
(3) Ladder conversion during the monitoring
This section explains the procedure to convert Y70 into Y72 during the
monitoring.
1) Double-click ( Y70 ).
1) Double-click!
Y70
4) Double-click ( ) and change "Y70" to "Y72".
4) Enter "Y72"!
2 - 42
2.9 Diagnosing Programmable Controller CPU
1) Click!
1)
3)
5)
4)
7)
6)
2 - 43
Item Description
1) Monitor Status Displays the current monitor status.
Connection Channel
2) Displays the connection route which has been set.
List
For single CPU system
Displays the operation status and switch status of the programmable controller CPU.
3) CPU operation status For multiple CPU system
Displays the operaton status and the switch status of CPU No. 1 to No. 4.
• "Uninstallable/Blank" is displayed for a slot with no module mounted.
Image of
4) programmable Perform online operations of the programmable controller CPU. (refer to POINT)
controller CPU
Error Information Select this to display the current error information of the programmable controller CPU.
Select this to display the status information of the programmable controller CPU.
5) PLC Status
Information
6) Error History Displays the latest error history by clicking the button.
7) Status Icon Legend Displays the status icons on the screen.
POINT
Online operations
The PLC Memory Operation function and the Remote Operation function can be executed from the
image of the programmable controller CPU.
When the cursor is moved to the image of the programmable controller CPU, the function menu is
expanded. Click the image of the programmable controller CPU to display the items to be set.
<Remote Operation>
<PLC Memory Operation>
2 - 44
2.10 Editing Ladder Program
A ladder program to be created This section explains how to modify a part of the
ladder program shown on the left.
X2 X0
(OUT Y71 → OUT Y72)
Y70
Y70
Y72
X3
Y71
1) Check!
If "Insert" is shown on the screen, click the Ins key
to change the display to "Ovrwrte".
If "Insert" is shown on the screen, contacts or coils are
added to the diagram.
<When correcting X2 to X5>
Added!
X5 X2
SET M3
RST M3
Added!
2) Double-click!
2 - 45
(From the previous page)
2 - 46
2.10.2 Drawing/deleting lines
A ladder program to be created This section explains how to add a line to the
ladder program shown on the left.
X2 X0
Y70
Y70
Y73
X3
Y72
1) Click!
3) A line is created!
2 - 47
(From the previous page)
4) Click , 5) Click!
then enter "Y73"!
2 - 48
(2) Deleting lines
A ladder program to be created Perform the following steps to delete the line
from the ladder shown on the left.
X2 X0
Y70
Y70
Y73
X3
Y72
1) Click!
4) Press "Delete"!
5) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 49
2.10.3 Inserting/deleting rows
A ladder program to be modified This section explains how to add a row to the
X7 ladder program shown on the left.
Y77
X2 X0
Y70
Y70
X3
Y72
2) The menu
is displayed!
2 - 50
(From the previous page)
5) Click , 6) Click!
then enter "X7"!
2 - 51
(From the previous page)
X7
2 - 52
(2) Deleting rows
A ladder program to be modified This section explains how to delete the row
X7 from the ladder program shown on the left.
Y77
X2 X0
Y70
Y70
X3
Y72
2) The menu
is displayed!
2 - 53
(From the previous page)
3) Click!
2 - 54
2.10.4 Cutting/copying ladder program
A ladder program to be modified This section explains how to copy and cut the
X7 ladder program shown on the left.
Y77
X2 X0
Y70
Y70
2 - 55
(From the previous page)
2 - 56
(From the previous page)
8) Click!
9) Completed!
2 - 57
2.11 Verifying Data
This section explains how to verify the open project against the data on the
programmable controller CPU.
The verification function is used to compare the contents of two projects or to locate
program changes made in the programs.
1) Click!
3) Click!
5) Display!
2 - 58
2.12 Saving Ladder Program
6) Click!
2 - 59
POINT
• Workspace
Workspace enables GX Works2 to manage several projects with one name.
• When the save destination exists
When the save destination (workspace and project) exists, the folder where the workspace is saved
can be specified in "Workspace/Project List".
• Number of the characters for a workspace name, project name, and title
Specify a workspace name, project name, and title within 128 characters each.
However, the total number of the characters of the save destination path name + workspace name
+ project name must be within 150.
1) Click!
3) Set a workspace name! 6) Click the Save button to accept the entry.
6) Click!
2 - 60
2.13 Reading the saved project
1) Click!
3) Double-click!
3) Double-click the workspace to be read.
5) Click!
2 - 61
2.14 Opening Projects in Different Format
2) Click!
2 - 62
POINT
• Status after a project in a different format are opened
When a project in a different format is opened, the project is in the uncompiled status.
Compile all programs in the project before executing online operations such as writing data and
monitoring.
When a compile error occurs, correct the corresponding program according to the programming
manual.
1) Click!
3) Click!
2 - 63
MEMO
2 - 64
CHAPTER 3 DEVICE AND PARAMETER OF PROGRAMMABLE CONTROLLER
3.1 Device
3-1
Type Description Remark
Function Register for the exchange data between a subroutine call
FD
register source and a subroutine program
Register for modification to the devices (X, Y, M, L, B, F, T, C,
Z Index register
D, W, R, K, H, and P)
N Nesting Shows the nesting (nested structure) of the master control.
Locates the jump addresses of the branch instructions (CJ,
P Pointer
SCJ, CALL and JMP).
Interruption Locates a jump address that corresponds to the factor of the
I
pointer interruption when an interruption occurs.
Network No.
Used to specify the network number in the data link
J specification
instructions.
device
I/O No.
Used to specify the I/O number in the intelligent function
U specification
module dedicated instructions.
device
Used to specify the following; timer counter set value, pointer
Decimal
K number, interruption pointer number, number of digits of bit
constant
device, and basic/application instruction values.
Hexadecimal
H Used to specify the basic/application instruction values.
constant
E Real number
Used to specify real numbers as instructions.
constant
"Character Character string
Used to specify character strings as instructions.
String" constant
Jn\X • Bit device
Jn\Y • Mainly handles on/off
Jn\B Link direct Device that can access directly to a link device of a network signals.
Jn\SB device module (The refresh parameter setting is not required.)
Jn\W • Word device
Jn\SW • Mainly handles data.
Intelligent • One word consists of
Device that can access directly to the buffer memory of a
Un\G function module 16 bits.
intelligent function module
device
3-2
3.2 Parameter
* A shaded area in the following table indicates the items to be set in this textbook.
Item Description
Label Sets a label (name and application) of a programmable controller CPU.
PLC name
Comment Sets a comment for the label of a programmable controller CPU.
Timer limit setting Sets the time limit of the low-speed or high-speed timer.
RUN-PAUSE contacts Sets contacts for controlling RUN and PAUSE of a programmable controller CPU.
Latch data backup operation Sets contact devices in order to execute the latch data backup operation.
valid contact (Only for Universal model QCPU)
Remote reset Sets whether to allow a remote reset operation from GX Works2.
Output mode at STOP to Sets the status of an output (Y) when the programmable controller is switched from STOP
RUN to RUN.
Floating point arithmetic Sets whether to execute floating-point processing in double precision.
processing (Only for high performance model QCPU)
Intelligent function module • Sets the interruption pointer assignment of a module.
setting • Sets the start I/O number and start SI number.
Common pointer No. Sets the start number of the pointer used as a common pointer.
PLC system Points occupied by empty
Sets the number of empty slots for the main or extension base unit.
slot
• Sets the start number of the interrupt counters.
System interrupt settings
• Sets the execution interval for the interrupt pointers.
Interrupt program/fixed scan
Set whether to execute high-speed execution of an interrupt program.
program setting
Set whether to synchronize the start-up of the programmable controller CPU with that of the
Module synchronization
intelligent function module.
PLC parameter
A-PLC compatibility setting Set whether to use the MELSEC-A series special relays/special registers.
Sets the processing time and the number of times of service processing. (Only for Universal
Service processing setting
model QCPU)
Set this parameter to replace the CPU module using a memory card (Only for Universal
PLC module change setting
model QCPU).
• Sets the file register file to be used in a program.
File register • Sets whether to transfer data to the standard ROM at a latch data backup operation.
(Only for Universal model QCPU)
Comment file used in a
Sets the device comment file to be used in a program.
command
PLC file
Initial device value Sets the device initial value file to be used on the programmable controller CPU.
File for local device Sets the local device file to be used in a program.
File used for
Sets the device data ROM write/read instruction file to be used in a program.
SP.DEVST/S.DEVLD
(Only for Universal model QCPU)
instruction
WDT (watchdog timer)
Sets the WDT of the programmable controller CPU.
setting
Error check Sets whether to detect specified errors.
Operation mode when there
Sets the programmable controller CPU operation mode when an error is detected.
is an error
PLC RAS
Constant scanning Sets the constant scan time.
Sets the storage destination for error histories of the programmable controller CPU. (Only
Breakdown history
for high performance model QCPU)
Low speed program Sets the execution time of a low-speed program in every scan. (Only for high performance
execution time model QCPU)
3-3
Item Description
Boot option Sets whether to clear the program memory when booting up.
Boot file Sets the type, data name, transfer source drive, and transfer destination drive of the boot
Boot file setting
file.
Sets the file name and execution type (execution condition) of the program when several
Program
programs are written to the programmable controller CPU
Sets the startup mode and startup condition of an SFC program and the output mode at
SFC
block stop
Device points Sets the number of points used for each device of the programmable controller CPU.
Sets the latch range (start device number/end device number) clearable with the
Latch (1) start/end
RESET/L.CLR switch or a remote latch clear operation.
Sets the latch range (start device number/end device number) not clearable with the
Latch (2) start/east
RESET/L.CLR switch or a remote latch clear operation.
Device
Local device start/end Sets the range (start device number/end device number) of devices used as a local device.
File register extended Sets the extended data register and extended link register. (Only for Universal model
setting QCPU)
Indexing setting for ZR Sets the start number of Z to be 32-bit indexed, or use the index register ZZ for 32-bit index
device setting. (Only for Universal model QCPU)
Sets the type, model, number of occupied I/O points, and start I/O number of each module
I/O assignment
mounted on the base unit.
I/O assignment
Sets the model and the number of slots of the base unit, the model of the power supply
PLC parameter
Basic setting
module, and the model of the extension cable.
No. of PLC Sets the number of programmable controller CPUs used in the multiple CPU system.
Sets the operation mode of the multiple CPU system when a stop error occurs in any of the
Operation mode
programmable controller CPU No. 2 to No. 4.
Host station Sets the CPU number for the host CPU.
Multiple CPU synchronous
Selects the CPU modules to be started up synchronously.
startup setting
Multiple CPU
Online module change Sets whether to allow the online module change in the multiple CPU system.
setting
I/O sharing when using Sets whether to retrieve the I/O status of the I/O module or intelligent function module
multiple CPUs controlled by other programmable controller CPUs.
Communication area setting
Sets the CPU shared memory to enable data sharing among multiple CPUs.
(refresh setting)
Multiple CPU high speed
Sets the user setting area, auto refresh, assignment confirmation, and system area.
transmission area setting
IP address setting Sets the IP address and the input format of the IP address.
Built-in Communication data code Selects the Binary code or ASCII code for communication.
Ethernet port Open setting button Sets the protocol, open system, and host station port number.
setting FTP setting button Selects whether to use the FTP function
Time setting button Sets whether to use the SNTP function and the timing of setting the time.
Transmission speed Sets the transmission speed.
Serial Sum check Sets the sum check.
communication Transmission wait time Sets the transmission wait time.
Online change Sets whether to allow the online program change.
Sets the network parameters for Ehternet, MELSECNET/10, MELSECNET/H, and CC-Link
parameter
Network
Ehternet/CC IE/MELSECNET
IE controller network.
Remote password Sets the password that limits the access via the Ethernet or serial communication modules.
3-4
• When GX Works2 starts, it employs the preset values as the parameters. These
values are called the default (initial values).
• The programmable controller can run with those values unchanged, however,
modify them within a specified range as necessary.
1) Double-click!
4) Click!
3-5
MEMO
3-6
CHAPTER 4 SEQUENCE AND BASIC INSTRUCTIONS -PART 1-
This chapter explains the sequence instructions and basic instructions as shown
below.
Instruction Instruction
symbol Function Drawing (devices to be used) symbol Function Drawing (devices to be used)
(Name) (Name)
MCR
Master Terminating MCR Nn Calling subroutine CALL Pn
CALL
control master control n = 0 to 14 program n = 0 to 4095
Nesting Pointer
reset
Calling a
SET
SET subroutine CALLP Pn
Setting devices CALLP
Set program (pulsing n = 0 to 4095
Specifies a bit of a bit device
Pointer
or word device. operation)
Pulse
Generating the
PLS Terminating a
PLS pulses for one
FEND main routine FEND
Pulse program cycle
Specifies a bit of a bit device program
when a input or word device.
signal turns off
Pulf
Generating the
PLF pulses for one PLF
*1: In GX Works2, the on/off status of the master control is displayed in the title tag
on the monitor screen.
4-1
<List of instructions not explained in this chapter: part 1>
"Introduction: PLC Course" covers the instructions shown below. The conventional A
series also support them.
Refer to "MELSEC-Q/L Programming Manual Common Instruction" for more details.
Instruction Instruction
symbol Function Drawing (devices to be used) symbol Function Drawing (devices to be used)
(Name) (Name)
Starting a logical
operation
LD Starting to operate MRD Intermediate
Load a normally open Specifies a bit of a bit device Lead branching
contact or word device.
Starting a logical
LDI inverse operation
Starting to operate MPP Terminating
Load
a normally closed Pop branching
inverse Specifies a bit of a bit device
contact or word device.
Logical AND
operation
AND Series connection NOP For a space or deleting a
Ignored
And of normally open Nop program
Specifies a bit of a bit device
contacts or word device.
Logical AND
ANI inverse operation END processing of
Series connection END Must be used as an end of a
And terminating a
of normally closed End program.
inverse Specifies a bit of a bit device program
contacts or word device.
Logical OR
operation
OR Parallel connection
STOP Stopping operation STOP
Or of normally open
Specifies a bit of a bit device
contacts
or word device.
Logical OR inverse
operation
ORI SFT 1-bit shift for SFT
Parallel connection
Or inverse of normally closed Shift devices Specifies a bit of a bit device
contacts Specifies a bit of a bit device
or word device. or word device.
AND operation
between logical 1-bit shift for SFTP
ANB blocks SFTP
devices (pulsing
And block Series connection Shift P Specifies a bit of a bit device
operation)
of blocks or word device.
OR operation
between logical Ignored
ORB
blocks NOPLF (for a page break NOPLF
Or block Parallel connection
at printing)
of blocks
Ignored
MPS
Starting a branch PAGE (Recognized as PAGE n
Push
zero step of n-page)
4-2
<List of instructions not explained in this chapter: part 2>
The instructions listed below are intended for the Q series and not supported by the
A series.
Some of them are explained in "Q Programming Applied Course".
Refer to "MELSEC-Q/L Programming Manual Common Instruction" for more details.
Instruction Instruction
symbol Function Drawing (devices to be used) symbol Function Drawing (devices to be used)
(Name) (Name)
Converting a
LDP Starting to operate
MEF result into a falling
Load P a rising pulse Specifies a bit of a bit device pulse Specifies a bit of a bit device
or word device. or word device.
Vn
Converting a result
ANDP Series connection EGP
into a rising pulse
And P of rising pulses Specifies a bit of a bit device Edge P
(Memorized by Vn) Specifies a bit of a bit device
or word device. or word device.
Vn
Converting a result
ANDF Series connection EGF
into a falling pulse
And F of falling pulses Specifies a bit of a bit device Edge F
(Memorized by Vn) Specifies a bit of a bit device
or word device. or word device.
Parallel FF
ORP Inverting a device
connection of FF
Or P output
rising pulses Specifies a bit of a bit device Specifies a bit of a bit device
or word device. or word device.
Parallel Converting a
ORF DELTA
connection of direct output into a DELTA
Or F Delta DY
falling pulses Specifies a bit of a bit device pulse
or word device.
Converting a Converting a
DELTAP
MEP result into a rising direct output into a DELTAP
Delta P DY
pulse Specifies a bit of a bit device pulse
or word device.
4-3
4.2 Differences between OUT and SET / RST
X0
0 Y70
• The OUT instruction turns the specified device on when the input condition turns
on, and turns the device off when the condition turns off.
[Timing chart]
X0
Y70
X0
0 SET Y70
X1
2 RST Y70
• The SET instruction turns the specified device on when the input condition turns
on, and holds the on status of the device even when the condition turns off.
To turn off the device, use the RST instruction.
[Timing chart]
X0
X1
Y70
4-4
4.3 Measuring Timer
K30
X5
0 T0
T0
7 Y71
[Timing chart]
• The timer contact
Contact X5
operates delaying by a set
time after the coil is
energized. (On delay
Coil T0
timer)
3.0sec. • The timer setting range is
Normally open contact T0,
coil Y70
from K1 to K32767.
Low-speed (100ms) timer
Normally closed contact 0b,
coil Y71 0.1 to 3276.7sec.
High-speed (10ms) timer
0.01 to 327.67sec.
• When the timer setting
value is set to 0, it turns on
(time-out) by the execution
of the instruction.
4-5
4.4 Counting by Counter
K12
X1
0 C20
X7
7 RST C20
[Timing chart]
• The counter counts when
Contact X1 an input signal rises.
• After the count, the
subsequent input signals
are not counted.
Coil C20
• Once the counter counts,
1 2 3 11 12 0
(Current value of counter) the contact status and the
current counter value do
Contact C20, coil Y72 not change until the RST
instruction is executed.
• Executing the RST
instruction before the count
Contact X7 (input of RST instruction)
returns the counter to 0.
• The counter setting range
is from K0 and K32767. (K0
turns on (counts up) by the
execution of the
instruction.)
4-6
Project name QEX1
Program name MAIN
Ladder example
When the conveyor belt operation start switch (X0) is turned on, the buzzer (Y70)
beeps for three seconds and the conveyor belt (Y71) starts to operate.
The conveyor belt automatically stops when the sensor (X1) detects that six
packages have passed through.
Sensor
(X1)
Conveyor
Motor
Control panel
Operating panel
MC
Operation Buzzer
(X0) (Y70)
(Y71)
X0 C0
0 M0 During operation
M0
M0 Y71
4 Y70 Buzzer
M0 K30
7 T0 3-sec. timer
T0
12 Y71 Operating the conveyor
X1 K6
14 C0 Counter for counting
Y71 the number of packages
19 RST C0
4-7
Operating Procedure
(1) Creating a new project
(a) Click on the toolbar.
Click
Click
(c) If the project in preparation exists, the confirmation dialog box for saving
the project is displayed.
Click the No button.
Click
4-8
(2) Creating a program
[Using the keyboard]
F5 X 0 Shift + F5 C 0 F7 M 0
F4
Conversion
Click
(g) When creating the circuit is finished,
click [Compile] → [Build].
4-9
(3) Writing the project to the programmable controller
(a) Write the created ladder to the memory on the programmable controller.
Set the RUN/STOP switch
of the CPU to STOP.
Click
(b) Click the Parameter + Program button. Checkboxes for the target
program and the target parameter displayed in the window are
automatically marked ( ).
Click
4 - 10
(d) If parameters have been already written, the confirmation dialog box for
overwriting the parameters is displayed. Click the Yes button.
Click
(f) If a program has already been written, the confirmation dialog box for
overwriting the program is displayed. Click the Yes button.
Click
4 - 11
(g) Writing the program to the programmable controller is finished.
4 - 12
(4) Monitoring the ladder
Monitor the ladder.
Hold the RESET/STOP/RUN switch on the CPU
at the RESET position for one second or more,
then set the switch to RUN.
Click
Operation Practice
1) Turning on the push button switch (X0) turns on Y70 and starts T0 at the
same time.
2) When the timer T0 counts three seconds (time-out), Y70 turns off and Y71
turns on at the same time.
3) Turn on or off (push or release) the push button switch (X1). The counter
C0 counts the number of ON to turn off Y71 after counting on six times.
4 - 13
4.5 PLS Pulse (turns on the specified device for one scan at rising edge of an input condition.)
PLF Pulf (turns on the specified device for one scan at falling edge of an input condition.)
X0 1
0 PLS M5
X1 2
3 PLF M0
1 • The PLS instruction turns on the specified device only for one scan when the
execution command is turned on from off.
[Timing chart]
X0
M5
One scan One scan
2 • The PLF instruction turns on the specified device only for one scan when the
execution command is turned off from on.
[Timing chart]
X1
M0
One scan One scan
4 - 14
Application
• The instructions can be used in the standby program that waits for the operation
condition.
Execution command
X0
PLS M0
M0
SET M5
M5
Y70
TO
TO
RST M5
[Timing chart]
X0
(trigger)
M0
M5
Y70
5sec.
(operation)
Applicable device
Constant
steps
Level
File Index
Digit
4 - 15
• The instructions can be used for a program that detects passage of moving
objects.
After the passage of a product is detected, the next process for the product is
started.
X0
PLF M0
M0
SET Y70 Product
Y70 Sensor
Sensor
(Detection of input from X0) Conveyor
[Timing chart]
X0
M0
Y70
[Timing chart]
Input
(X0)
Output
(Y76) Set time limit
Pulse duration
10sec.
[Program example]
Project name QB-6
Program name MAIN
X0
0 PLF M1
M1 T16 K100
3 T16
Y76
Y76
4 - 16
Other Useful Ways of PLS and PLF Part 2
• The program for the repeated operation such as switching on/off status alternately
by pressing the push button switch can be made with the instructions.
If the PLS instruction is used in the above program, the rising edge caused when
the push button switch is pressed triggers the program. If the PLF instruction is
used, the falling edge caused when the switch is released is the trigger.
[Timing chart]
X0
Y70
Y71
[Program example]
Project name QB-7
Program name MAIN
X0
0 PLS M0
PLF M1
M0 Y70
5 Y70
M0 Y70
M1 Y71
11 Y71
M1 Y71
4 - 17
Project name QEX2
Program name MAIN
Ladder example
Create the following ladder and check that it operates properly.
X2
0 PLS M0
M0 X0
3 Y70
Y70
X3
7 PLF M1
M1 X1
10 Y71
Y71
[Timing chart]
X2
M0
PLS
Y70
X0
X3
M1
PLF
Y71
X1
REFERENCE
The following is a timing chart of a lockup ladder programmed using the OUT
instruction. Compare this with the lockup ladder created using the PLS
instruction.
X2
Y70
X0
X2 X0
Y70
Y70
4 - 18
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
Operation Practice
• Turning on X2 turns on Y70, and turning on X0 turns off Y70. (Even when X2 stays
on, turning on X0 turns off Y70.)
• Turning on X3 turns on Y71, and turning on X1 turns off Y71.
REMARK
Input pulse processing is not required for the QCPU as it uses a derivative
contact ( / ).
[For A/AnSCPU]
X0
PLS M0
M0
SET M5
[For QCPU]
X0
SET M5
Supported instructions are; LDP, LDF, ANDP, ANDF, ORP, and ORF.
4 - 19
4.6 MC Master Control (Start)
MCR Master Control Reset (End)
X7
0 MC NO M98
X2
3 Y70
X3
5 Y71
7 MCR NO
Application
• The instructions can be used for a program for switching between manual and
automatic operations. (Refer to Ladder example.)
Applicable device
Number of basic
Constant
steps
Level
File Index
Digit
The number of basic steps of the MC instruction is two, and that of the MCR instruction is one.
4 - 20
Nested "MC to MCR" Program Example
X5
0 Y70
X2
2 MC N0 M6
N0 M6 K5
X6
5 C0
X3
10 MC N1 M7
1
N1 M7 K100
N1 N0
X7 b a
13 TO
18 MCR N1
X8
19 Y71
21 MCR N0
X0
22 SET Y72
X4
24 MC N0 M8 2
N0 M8
X1 N0
27 c
RST Y72
29 MCR N0
X9
30 Y73
3
M6
32 Y74 d
1 • The "MC to MCR" program a is nested under the "MC to MCR" program b . (It
is called "nested structure".)
In this case;
1) Assign the nesting number (N) of the MC instructions in ascending order.
2) Assign the nesting number (N) of the MCR instructions used for the MC in
descending order.
2 • The "MC to MCR" program a can be independent from the c program. The
same nesting numbers (N) can be used in the both programs.
• The internal relay number (M) must be changed for each MC instruction.
Note) In GX Works2, the on/off status of the master control is displayed in the title tag on
the monitor screen.
4 - 21
Project name QEX3
Program name MAIN
Ladder example
The following program switches between manual and automatic operations using
the MC and MCR instructions.
• When the manual operation is selected by turning off X7;
1) Turning X2 sets the system to the low-speed operation mode.
2) Turning X3 sets the system to the high-speed operation mode.
• When the automatic operation is selected by turning on X7, the system operates in
the low-speed mode for 3sec. after X0 is turned on. Then the system operates in
the high-speed mode for 10sec. and stops.
High speed
Low speed
3sec. 10sec.
Manual
X7
0 MC N0 M10
N0 M10
X2 M82
3 M81 Instruction for manual low-speed
X3 M81
6 M82 Instruction for manual high-speed
9 MCR N0
Automatic
X7
10 MC N0 M11
N0 M11
X0 T1
13 Y70 Automatic start
Y70
MC N1 M12
N1 M12
Y70 M72
19 M71 Instruction for auto low-speed
M71 K30
T0
T0
27 M72 Instruction for auto high-speed
M72 K100
T1
34 MCR N0
M71
35 Y71 Low-speed operation
M81
M72
38 Y72 High-speed operation
M82
Note) In GX Works2, the on/off status of the master control is displayed in the title tag on the
monitor screen.
4 - 22
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
Operation Practice
• The manual operation is selected by turning off the X7 switch.
When the X2 switch is turned on, Y71 lights and the low-speed operation is
executed. To select the high-speed operation, turn on the X3 switch. Y72 lights
and the high-speed operation starts.
• The automatic operation is selected by turning on the X7 switch.
When the X0 switch is turned on, Y70 lights indicating that the automatic operation
is activated.
At the same time, Y71 also lights for 3sec. indicating the system is in the
low-speed mode. After the 3sec. have elapsed, Y72 lights for 10sec. indicating
that the system is in high-speed mode. Then the operation is stopped. (Y70, Y71,
and Y72 have stopped lighting at the end.)
NOTE
For the MCR instructions in one nested program block, all master controls in
the program can be terminated with the lowest nesting (N) number only.
4 - 23
4.7 FEND / CJ / SCJ / CALL / RET
• Use the FEND instruction as the END instruction under the following conditions;
1) When a sequence program must be executed and terminated in each program
block.
For example, use the FEND instruction with the CJ and SCJ instructions.
2) When using subroutine programs (CALL and RET instructions)
3) When using an interrupt program
• After each execution of the FEND instruction, the programmable controller
processes the current value of the timer and counter and executes self-diagnostic
check, and then re-operates from the step 0.
0
CALL P**
FEND I**
Interrupt program
P**
Sequence program
END
END
(a) When operating in each program block (b) When using the subroutine
by the CJ instruction and interrupt programs
NOTE
• There is no limit on the number of the FEND instructions in a sequence program,
however, they cannot be used in the subroutine and interrupt programs.
• The FEND instruction cannot be used to terminate the main or sub sequence
program.
Make sure to use the END instruction for the end of a whole program.
REFERENCE
The interrupt program stops the current process and processes an interrupt
upon receiving an interrupt request while a normal program is being processed.
4 - 24
Project name QEX6
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the FEND instruction operates properly.
X3
0 CJ P10
X4
3 Y70
5 FEND
P10 X5
6 Y72
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
4 - 25
Operation Practice
Verify the operation of the ladder, which was created with GX Works2 and written to
the CPU of the demonstration machine, by monitoring the ladder on the screen.
X3
0 CJ P10
X4
3 Y70
5 FEND
P10 X5
6 Y72
9 END
4 - 26
4.7.2 CJ (Conditional jump: instantaneous execution condition jump)
SCJ (S conditional jump: execution condition jump after one scan)
1
X0
0 CJ P10
2
X1
3 SCJ P10
X0 X1
6 Y70
9 FEND
Pointer
P10
X3
10 Y71
2 • The SCJ instruction executes a program without jumping it for the scan when the
execution command is turned on. From the next scan, the instruction executes the
program jumping it to the specified address (pointer number).
When the command is off, the program is not jumped.
• The SCJ instruction is used when some operations must be executed before
jumping the program.
For example, when the output needs to be on or reset in advance.
[Timing chart]
Input condition
(X0, X1)
Executes
CJ Executes every scan every scan
Executes Executes
SCJ every scan every scan
4 - 27
NOTE
• The pointer numbers available for both CJ and SCJ instructions are P0 to P4095.
• Use the FEND instruction as shown below when a program using the CJ and SCJ
instructions must be concluded in each program block. (Refer to section 4.7.1 for
FEND.)
Is input YES
condition on? FEND FEND
P
P Sequence program C
NO
X0 X0
1100 CJ P10 1100 CJ P10
X2 X2
1103 Y72 1103 Y72 Because X0 is on, all instructions
within this area are not executed.
Hence Y72 remains on even
P10 X1 P10 X1 after X2 is turned off.
1330 PLS M1 1330 PLS M1
• After the timer coil has turned on, jumping the timer of a coil that is on using the
CJ, SCJ, or JMP instruction interrupts an accurate measurement.
Applicable device
Number of basic
Constant
steps
Level
File Index
Digit
4 - 28
Project name QEX4
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check the difference between the CJ and SCJ
instructions.
X0
0 CJ P10
X1
3 SCJ P10
X0 X1
6 Y70
9 FEND
P10 X3
10 Y71
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
4 - 29
Operation Practice
(1) When X0 and X1 are off, the CJ and SCJ (2) When X0 is turned on, the CJ instruction is
instructions are not executed. executed and the program jumps to P10.
Therefore, Y70 is on. Therefore, Y70 remains on.
[Before CJ and SCJ execution] [During CJ execution] First scan and subsequent
scans
X0 X0
CJ P10 CJ P10
X1 X1
SCJ P10 SCJ P10
X0 X1 X0 X1
Y70 Y70
FEND FEND
P10 X3 P10 X3
Y71 Y71
(3) Turning off X0 and on X1 executes the SCJ instruction and jumps the program to P10 from the second
scan. Therefore, Y70 turns off.
[During SCJ execution] First scan [During SCJ execution] Second scan and
subsequent scans
X0 Second scan X0
CJ P10 and CJ P10
subsequent
X1 scans
X1
First scan SCJ P10 SCJ P10
after ON
after ON
X0 X1 X0 X1
Y70 Y70
FEND FEND
P10 X3 P10 X3
Y71 Y71
(4) Y71 is turned on or off when the CJ and SCJ instructions are executed.
• The following lists explain the difference between the CJ and SCJ instructions.
Second scan and
subsequent scans
after X1 ON
First scan only
0 LD X0 0 LD X0
1 CJ P10 1 CJ P10
3 LD X1 3 LD X1
4 SCJ P10 4 SCJ P10
6 LDI X0 6 LDI X0
7 ANI X1 7 ANI X1
8 OUT Y70 8 OUT Y70
9 FEND 9 FEND
10 P10 10 P10
11 LD X3 11 LD X3
12 OUT Y71 12 OUT Y71
13 END 13 END
4 - 30
4.7.3 CALL(P) Call
Executing a subroutine program
RET Return
M0
0 CALL P10
M5 X2 Sequence
50 CALL P10
program
103 FEND
1
P10
2 X1
104 Y70
Subroutine
program
157 RET
• The above program is a basic style to execute the subroutine program using the
CALL and RET instructions.
Keep this structure, otherwise an error occurs and the programmable controller
stops.
1 • A subroutine program consists of the ladders for executing the same data many
times in one program.
A subroutine program starts at a pointer P and ends with the RET instruction.
2 • The pointer P number is from 0 to 4095. (Same as the pointer numbers used for
the CJ and SCJ instructions.)
• A subroutine program is executed as shown in the following diagrams.
Sequence program
Subroutine program
Sequence program
Execution of
subroutine program
RET
RET
END
4 - 31
Nesting
• The CALL (P) instructions can be nested up to 16 levels.
CALL P3
CALL P5
CALL P1 CALL P4
RET
RET
RET
FEND
CALL P1
Sequence program
FEND
P1
RET
Subroutine program P5
Applicable device
Number of basic
Constant
Level
steps
File Index
Digit
4 - 32
Project name QEX5
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the CALL and RET instructions operate
properly.
X2
0 CALL P10
X3
3 Y70
5 FEND
P10 X4
6 Y71
9 RET
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
4 - 33
Operation Practice
Verify the operation of the ladder, which was created with GX Works2 and written to
the CPU of the demonstration machine, by monitoring the ladder on the screen.
X2
0 CALL P10
X3
3 Y70
5 FEND
P10 X4
6 Y71
9 RET
10 END
4 - 34
Project name QTEST1
Program name MAIN
4.8 Exercise
4.8.1 Exercise 1
LD to NOP
When X0 turns on, Y70 is self-maintained, and Y74 and Y77 flicker alternately every
0.5sec.
When X1 turns on, Y70 turns off and flickering of Y74 and Y77 also stops.
[Timing chart]
X0
Y70
TO
Y74
T1
Y77
X1
Create the following program with GX Works2 filling in the blanks . Then,
check the operation using the demonstration machine.
X0 2)
0 Y70
1)
Y70 3) K5
4 T0
4) K5
10 T1
Y74
5) Y70
16 Y77
4 - 35
Project name QTEST2
Program name MAIN
4.8.2 Exercise 2
SET, RST
When X0 is turned on, Y70 starts to flicker at one-second intervals and stops the
flickering for five seconds after flickering 10 times, then restarts flickering.
The flickering of Y70 can be stopped by turning on X1.
Create the following program with GX Works2 filling in the blanks . Then,
check the operation using the demonstration machine.
X0
0 1)
M0 M1 T1 K10
2 T0
T0 K10
T1
T0
Y70
K10
C0
2) 3)
23 4)
K50
T2
T2
30 RST M1
5)
X1
36 6)
7)
8)
1) 5)
2) 6)
3) 7)
4) 8)
4 - 36
Hint
(1) The following shows the timing chart of the program.
X0
M0
X1
Restart
Contact T0
1sec.
Contact T1
1sec
One scan
Y70
1sec. 1sec. 5sec.
Contact C0
(2) The following shows the basic flickering ladder and its timing chart.
[Ladder] [Timing chart]
K10 Start
T1 Contact
T0 T0
1sec.
K10
T0
T1 Contact
T1 1sec.
One scan
REFERENCE
• The flickering ladder can be created using the special relay that generates
clock as shown below.
SM413 (2-sec. clock) In addition to the SM413 (2-sec. clock) on
Y70 the left, the following can be used.
SM409 (0.01-sec. clock)
SM410 (0.1-sec. clock)
[Timing chart] SM411 (0.2-sec. clock)
SM412 (1-sec. clock)
Y70
1sec. 1sec.1sec. SM414 (2n-sec. clock)
SM415 (2n-msec. clock)
The clock starts from OFF when the
programmable controller is reset or the
power is turned on.
4 - 37
Project name QTEST3
Program name MAIN
4.8.3 Exercise 3
PLS, PLF
Y70 starts to switch between ON and OFF alternately when X0 is turned on, and
turning off X0 triggers Y71 to operate in the same way as Y70 does.
[Timing chart]
X0
Y70
Y71
Create the following program with GX Works2 filling in the blanks . Then,
check the operation using the demonstration machine.
X0
0 1) M0
2) M1
M0 Y70
5 Y70
M0 Y70
M1 Y71
11 Y71
M1 Y71
1)
2)
4 - 38
Project name QTEST4
Program name MAIN
4.8.4 Exercise 4
Fill in the blanks . Then, check the operation using the demonstration machine.
X7
CJ 1)
SM401
RST Y72
RST Y73
T11 K5
T10
T10 K5
T11
Flip flop
Y70 ladder
T10
Y71
X0
2) P10
3)
SM401
P0 RST Y70
RST Y71
T20 K10
T21
T21 K10
T20
Flip flop
Y72 ladder
T21
Y73
X0
4) P10
5)
SM401
P10 RST Y70
RST Y71
RST Y72
RST Y73
6)
4 - 39
Hint
START 1)
2)
<CJ P0>
3)
Y
X7 ON? 4)
N 5)
P0 6)
Y72,Y73 Y70,Y71
Reset Reset
Y70,Y71 Y72,Y73
0.5-sec. flickering 1-sec. flickering
Y Y
X0 ON? X0 ON?
N N
P10
Y70Y73 Subroutine
Reset program
<FEND>
<FEND>
END
4 - 40
Answers for the exercises in Chapter 4
Exercise No. Answer
1) Y70
2) X1
1 3) T1
4) T0
5) Y74
1) SET M0
2) C0
3) Y70
4) SET M1
2
5) RST C0
6) RST M0
7) RST C0
8) RST M1
1) PLS
3
2) PLF
1) P0
2) CALL
3) FEND
4
4) CALL
5) FEND
6) RET
4 - 41
MEMO
4 - 42
CHAPTER 5 BASIC INSTRUCTION -PART 2-
The programmable controller CPU converts all input signals into ON or OFF signals
(logical 1 or 0, respectively) to store and process them. Therefore, the
programmable controller executes the numeric operation using the numeric values
stored with the logical 1 or 0 (binary numbers = BIN).
In daily life, a decimal number is regarded as the most commonly and the easiest
system. Therefore, the decimal-to-binary conversion or the reverse conversion is
required when values are written or read (monitored) to or from the programmable
controller. The programming system and some instructions have the function for the
decimal-to-binary conversion and the binary-to-decimal conversion.
This section explains how to express values (data) in decimal, binary, hexadecimal
and binary-coded decimal notation (BCD), and how to convert them.
Decimal
A decimal number system consists of ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
which represent the order and size (amount).
After a digit reaches 9, an increment is reset to 0 and the next increment of the
next digit (to the left) is incremented.
The following shows how a decimal number (in this case 153) is represented.
153 = 100+50+3
= 1 100+5 10+3 1
= 1 102+5 101+3 100
Decimal symbol (0 to 9)
"Power of digit"
5-1
Binary (BIN)
The binary number system consists of two symbols: 0 and 1 which represent
the order and size (amount). After a digit reaches 1, an increment is reset to 0
and the next digit (to the left) is incremented. The two digits 0 and 1 are called
bits.
Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
…
…
The following example explains how to convert a binary number into a decimal
number.
"10011101"
The diagram below shows the binary number with the powers of two.
7 6 5 4 3 2 1 0 Bit number
1 0 0 1 1 1 0 1 Binary
Base number raised
2 7 26 2 5 2
4 2 3 2 2 2
1 2 0
to the power of digit = Bit weights
128 64 32 16 8 4 2 1 ("Binary")
The binary number can be calculated by adding each weight of bits whose
codes are 1.
5-2
Hexadecimal
The hexadecimal number system consists of 16 symbols: 0 to 9 and A to F
which represent the order and size (amount). After a digit reaches F, an
increment is reset to 0 and the next digit (to the left) is incremented.
19101 4A9D …
0100 1010 1001 1101
3 2 1 0 Digit number
"Power of digit"
4 A 9 D Hexadecimal
n: Digit number
3 2 1
= (4) × 16 + (A) × 16 + (9) × 16 + (D) × 16 0 16: Hexadecimal
= 4 × 4096 + 10 × 256 + 9 × 16 + 13 × 1
= 19101
5-3
Binary Coded Decimal (BCD)
The binary-coded decimal is "a numerical system using a binary number to
represent a decimal number".
A decimal number 157, for example, is expressed as shown below.
2 1 0 Digit number
1 5 7 Decimal
(100) (10) (1) Power of digit
0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 1
8000
4000
2000
1000
80
40
20
10
1
800
400
200
100
0 1 2 3 4 5 6 7 8 9
1(0) (1) (0) (1) (0) (1) (0) (1) (0) (1)
2(0) (0) (1) (1) (0) (0) (1) (1) (0) (0)
4(0) (0) (0) (0) (1) (1) (1) (1) (0) (0)
8(0) (0) (0) (0) (0) (0) (0) (0) (1) (1)
COM
5-4
How to convert the decimal number into the binary number
In the example below, a decimal number 157 is converted into the binary number.
1)
1 0 0 1 1 1 0 1
128 64 32 16 8 4 2 1 Bit
157 weights
128
29
16
13
8
5
4
1
1
0
2)
Quotient
2 157 Remainder
2 78 1
2 39 0
2 19 1
2 9 1
2 4 1
2 2 0
1 0
1 0 0 1 1 1 0 1
128 64 32 16 8 4 2 1
5-5
Numerical values used by MELSEC-Q series programmable controller
● Usually, 8 bits are called 1 byte, and 16 bits (2 bytes) are called 1 word.
1 bit
1 0 0 1 1 1 0 1
1 byte
0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1
1 word (2 byte)
● Registers of each word device in the MELSEC-Q series programmable controller consist of 16
bits.
• Data register D D0
• Current value of
32768
16384
1
8192
4096
2048
1024
64
32
16
2
512
256
128
timer T (Binary bit weight)
• Current value of
counter C
• File register R
• Link register W
● The following two ranges of numbers can be processed in 16 bits (1 word).
1) 0 to 65535
2) -32768 to +32767
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
5-6
BCD (binary coded decimal) BIN (binary) K (decimal) H (hexadecimal)
00000000 00000000 00000000 00000000 0 0000
00000000 00000001 00000000 00000001 1 0001
00000000 00000010 00000000 00000010 2 0002
00000000 00000011 00000000 00000011 3 0003
00000000 00000100 00000000 00000100 4 0004
00000000 00000101 00000000 00000101 5 0005
00000000 00000110 00000000 00000110 6 0006
00000000 00000111 00000000 00000111 7 0007
00000000 00001000 00000000 00001000 8 0008
00000000 00001001 00000000 00001001 9 0009
00000000 00010000 00000000 00001010 10 000A
00000000 00010001 00000000 00001011 11 000B
00000000 00010010 00000000 00001100 12 000C
00000000 00010011 00000000 00001101 13 000D
00000000 00010100 00000000 00001110 14 000E
00000000 00010101 00000000 00001111 15 000F
00000000 00010110 00000000 00010000 16 0010
00000000 00010111 00000000 00010001 17 0011
00000000 00011000 00000000 00010010 18 0012
00000000 00011001 00000000 00010011 19 0013
00000000 00100000 00000000 00010100 20 0014
00000000 00100001 00000000 00010101 21 0015
00000000 00100010 00000000 00010110 22 0016
00000000 00100011 00000000 00010111 23 0017
5-7
System configuration and I/O number of demonstration machine
X0 Y40
to to
USB cable X3F Y7F
Peripheral device
I/O panel
ON
OFF
5-8
5.2 Transfer Instruction
K50
X7 T0
0 T0
K1500
T0
C10
X1
13 RST C10
S D 1
X2
18 MOV T0 D0
X3
21 MOVP C10 D1
X4 2
24 MOVP K157 D2
X5 3
27 MOVP H4A9D D3
1 ● When the input condition turns on, the current value of the timer T0 is transferred
to the data register D0.
S ... Source, D ... Destination
● The current value of T0 is stored in the register in binary (BIN code). And the
value is transferred to the data register D0 in binary (The code is not converted at
the transfer.)
T0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 45
128 64 32 16 8 4 2 1
D0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1
128 64 32 16 8 4 2 1
2 ● When the input condition turns on, the decimal number 157 is transferred to the
data register D2. And the value is stored in the register in binary. The decimal
number (K) is converted into binary automatically, then transferred.
K157
D2 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1
128 64 32 16 8 4 2 1
5-9
3 ● When the input condition turns on, the hexadecimal number 4A9D is transferred
to the data register D3.
H4A9D
64
32
16
32768
16384
512
256
128
8
4
2
1
8192
4096
2048
1024
Bit weights
Input condition
● Use the MOV instruction when reading the changing data for all the time.
Use the MOVP instruction to transfer data instantaneously such as setting
data or reading data at an error.
● Both of the following ladder programs function similarly.
X4 X4
MOVP K157 D2 PLS M1
M1
MOV K157 D2
Applicable device
Number of basic
Internal
Intelligent
Pointer
Level
steps
function Constant
(system or register (H) Direct Jn\ register
module
user)
Un\G
Bit Word R Bit Word Z K H P I N
S
MOV S D *
D
*: The number of steps varies depending on the device to be used.
5 - 10
Check The CPU is running.
The inputs X2, X3, X4, X5, and X7 are on.
• Enter "D0" in the Device Name column of the Device/Buffer Memory Batch
Monitor dialog box and press the Enter key.
Enter "D0".
Press the Enter key after
entering the device.
5 - 11
Current values of a timer
and counter are monitored.
(They are changing.)
Indicates that a decimal
number 157 (K157) is stored.
16
64
32
256
512
8192
4096
2048
128
1024
16384
1
weights
Sign bit
19101
5 - 12
• Click the Display Format button.
• Change the display of the numerical value in the monitor to the hexadecimal
notation.
• Select "HEX" for the device batch monitoring.
• Change the display of the numerical value in the monitor to the binary
notation.
Select "Word Multi-point" in Monitor Format for the device batch monitoring.
5 - 13
Project name QEX7
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the MOV instruction works properly.
X0
0 MOV K200 D0
MOV D0 D1
X1
5 RST D0
RST D1
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
5 - 14
Operation Practice
Check that "200" is displayed under both D0 and D1 on the monitor screen when X0
on the control panel of the demonstration machine is turned on.
X0
0 MOV K200 D0
200
MOV D0 D1
200 200
X1
5 RST D0
RST D1
10 END
5 - 15
Project name QB-12
Program name MAIN
5.2.2 BIN (P) BCD → BIN data conversion instruction
K1500
T0
C10
S D
X0
30 BINP K4X20 D5
X0
34 MOV K4X20 D6
• When the input condition is turned on, the data in the device specified in S is
recognized as a BCD code, converted into binary (BIN code), and transferred to
the device specified in D .
8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1
S side BCD 9999 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
Becomes 0.
• The ordinary digital switches generate BCD codes. Therefore, the BIN instruction
is required for writing data from the digital switches to the programmable
controller.
4096
512
32
1 2 3 4 Digital switch
16
4 8 4 2 1) 8 4 2) 1 8 4 2) 1) 8 4) 2 1
K4X20
X2D
X2C
X2E
X2B
X2A
X2F
4660
X29
X28
X27
X26
X25
X24
X23
X22
X21
X20
D6
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 When the BCD code
is input without converted.
32
16
64
256
512
8192
4096
2048
128
1024
16384
1024
128
64 D5
16 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0 When the BCD code is input after
2 converted into the binary code.
32
64
16
256
512
8192
4096
2048
128
1024
16384
2
4
1234
5 - 16
K4X20
Word devices D (data register), T (timer current value), and C (counter current
value) consist of 16 bits (1 word), and data is basically transferred among the
units of one device.
Collecting 16 bit devices (such as X, Y, and M) means processing the word
device. The device numbers allocated to the bit devices must be in consecutive
order.
In the bit device, data are processed in units of four.
Number
1 2 3 4 of digits
8 4 2 1) 8 4 2) 1 8 4 2) 1) 8 4) 2 1 K4 X20
X2D
X2C
X2E
X2B
X2A
X2F
X29
X28
X27
X26
X25
X24
X23
X22
X21
X20
Start number
Specify these devices to K2X28 K1X20
Read one-digit data "4".
read two-digit data "12". (X2F toX28) (X23 to X20)
K2X20
Read two-digit data "34".
(X27 to X20)
K3X20
Read three-digit data "234".
(X2B to X20)
K4X20
Read four-digit data "1234".
(X2F to X20)
As long as four bit devices are in consecutive order, any bit device can be specified as the first.
Other bit devices can be processed in the same way as described above.
M M M M M M M M M M M M M M M M M M M M
(Internal relay M) 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
K2M6 K1M0
K3M5
Applicable device
Number of basic
Level
steps
File Index
Digit
5 - 17
Project name QB-13
Program name MAIN
5.2.3 BCD (P) BIN → BCD data conversion instruction
K50
X7 T0
0 T0
K1500
T0
C10
S D
X6
37 BCD T0 K2Y40
When the input condition is turned on, the data in the device specified in S is
recognized as a binary (BIN code), converted into a binary coded decimal
(BCD code), and transferred to the device specified in D .
163848192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
S side BIN 9999 0 0 1 0 0 1 1 1 0 0 0 0 1 1 1 1
The ordinary digital displays display numbers in the BCD code. Therefore, the
BCD instruction is required for displaying data of the programmable controller
(current values of timers and counters, data resister values of operation
results).
16384
4096
8192
2048
1024
256
512
128
64
32
16
2
4
1024
128 C10
32 0 0 0 0 0 1 0 0 1 0 1 1 1 1 0 1
16 (BIN)
8
4
+ 1
1213 0 0 0 1 0 0 1 0 0 0 0 1 0 0 1 1
(BCD)
Y5D
Y5C
Y5E
Y5B
Y5A
Y5F
Y59
Y58
Y57
Y56
Y55
Y54
Y53
Y52
Y51
Y50
K4Y50
8 4 2 1) 8 4 2) 1 8 4 2 1) 8 4 2) 1)
Digital display
5 - 18
Displayable Range with BCD Instruction
The displayable range of data with the BCD instruction (to be converted from
BIN into BCD) is between 0 and 9999. Any data which is outside the range
causes an error.
(Error code 4100: OPERATION ERROR)
To display a timer current value more than 9,999, use the DBCD instruction.
The instruction can handle 8-digit values (up to 99,999,999).
COM
Y4D
Y4C
Y4E
Y4B
Y4A
Y4F
Y53
Y52
Y51
Y50
Y49
Y48
Y47
Y46
Y45
Y44
Y43
Y42
Y41
Y40
80000
40000
20000
10000
8000
4000
2000
1000
800
400
200
100
80
40
20
10
8
4
2
1
Output power supply
0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 0 1
K18000
X3
H
0 T5
SM400
(always on)
2 DBCD T5 K5Y40
Applicable device
Number of basic
MELSECNET/ Intelligent
Pointer
Level
steps
Internal device File Index
Digit
10 (H) Direct function Constant
(system or user) register register
Jn\ module
Un\G
Bit Word R Bit Word Z K H P I N
S K1
BCD S D to 3
D
K4
5 - 19
Project name QEX8
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the BCD instruction works properly.
X0 K10
0 C0
BCD C0 K2Y40
X1
8 RST C0
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
Operation Practice
Check that turning on X0 on the control panel for several times displays the value of
C0 on the BCD digital displays of Y40 to Y47. Turning on X1 resets C0.
0 to 10
BCD digital display Displays the value of C0.
5 - 20
5.2.4 Example of specifying digit for bit devices and transferring data
Becomes 0.
• Source: Source device
B15 B4 B3 B2 B1 B0
• Destination: Destination device
D0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1
K2M100 1 0 0 0 1 1 0 1
No change
M15 M8 M7 M0
K2M0 0 0 1 1 0 1 0 0
No change 3 4
K2M100 0 0 0 0 1 1 0 1
5 - 21
Project name QB-14
Program name MAIN
5.2.5 FMOV (P) FMOV (Batch transfer of the same data)
S D n
X3
0 FMOVP K365 D0 K8
X4
5 FMOVP K7000 D8 K16
S D n
X5
10 BMOVP D0 D32 K16
X6
15 FMOVP K0 D0 K48
Operation Explanation
Input S D n
condition
FMOVP K365 D0 K8
FMOV
When the input condition is turned on, the FMOV instruction transfers the data in
the device specified in S to the devices starting from the device specified in D
(the number of target devices is specified by n ).
365 D7
The FMOV instruction is useful for clearing many data sets in batch.
Example
Input Input
Same
condition condition
FMOV K0 D0 K8 RST D0
RST D1
RST D7
The FMOV instruction can substitute the RST instructions as shown above.
5 - 22
Input S D n
condition
BMOVP D0 D32 K16
BMOV
When the input condition is turned on, the BMOV instruction transfers the data in
the devices starting from the device specified in S to the devices starting from
the device specified in D in batch (the numbers of source devices and target
devices are specified by n ).
Applicable device
Number of basic
Intelligent
Pointer
Level
steps
Internal device File MELSECNET/10 Index
Digit
function Constant
(system or user) register (H) Direct Jn\ register
module
Un\G
Bit Word R Bit Word Z K H P I N
(Note) (Note) (Note)
S K1
FMOV S D n
to 4
BMOV S D n D
K4
n
5 - 23
Operation Practice
Write the program on the previous page to the CPU, then run the CPU.
Follow the procedures below to execute the device batch monitoring. The
contents of D0 to D47 can be monitored.
Write the program to the programmable controller Click [Online] →
[Monitor] → [Device/Buffer Memory Batch].
Enter "D0" in the Device/Buffer Memory Batch Monitor dialog box and press the
Enter key.
Click the Display Format button and select "Word Multi-point" for Monitor
Format.
→ Click the OK button.
[Monitor screen]
1) Turn on X3.
The numeric data 365 is
sent to eight registers of D0
to D7 in batch.
2) Turn on X4.
The numeric data 7000 is
sent to 16 registers of D8 to
D23 in batch.
3) Turn on X5.
The contents of the 16
registers of D0 to D15 are
sent to the 16 registers of
D32 to D47 in batch.
4) Turn on X6.
"0" is sent to the all 48
registers of D0 to D47 in
batch. This means that all
the 48 registers are cleared.
5 - 24
Reference
If D is a bit device, the operation becomes as follows;
FMOV instruction
Input S D n
condition
FMOV D0 K2Y40 K4
As D specifies
a two-digit number,
these data are S
ignored. D D
D0 (Example: when the content is 365)
Y4F Y48 Y47 Y40
0 1 1 0 1 1 0 1 0 1 1 0 1 1 0 1
n
0 0 0 0 0 0 0 1 0 1 1 0 1 1 0 1 4 devices (K4)
D D
0 1 1 0 1 1 0 1 0 1 1 0 1 1 0 1
Among the device of Y40 to Y5F, the devices specified as "1" are output first.
In the program shown below, turning on the input condition 1) turns on all the
outputs Y40 to Y5F and turning on the input condition 2) turns them off.
Input
condition 1)
FMOV K255 K2Y40 K4
Input Bit pattern of K255 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
condition 2)
FMOV K0 K2Y40 K4
In the example above, the devices D0 to D3 store the product code (16 bits). The
BMOV instruction is useful for displaying and monitoring the last two digits
representing their types.
5 - 25
Project name QEX9
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the FMOV instruction works properly.
X0
0 FMOV K200 D0 K5
X1
5 FMOV K0 D0 K5
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
Operation Practice
Check that the contents of the devices of D0 to D4 become 200 on the batch
monitor screen by turning on X0 on the control panel of the demonstration machine.
Turning on X1 clears the data in the devices.
Change the setting of the device batch monitor as shown below to display the
numbers in decimal, hexadecimal, or binary notation.
Value: DEC ·····································displays numbers in decimal.
Value: HEX ·····································displays numbers in hexadecimal.
Monitor Format: Bit Multi-point ·······displays numbers in binary.
5 - 26
Project name QB-15
Program name MAIN
5.3 Comparison Operation Instruction
Size
comparison
K100
X3 SM413 (2-sec. clock)
0 C10
X4
6 BCD C10 K4Y40
S1 S2
10 > K10 C10 Y70
S1 S2
15 <= K10 C10 Y71
K40 C10
5 - 27
Operation Practice
Write the program to the CPU.
Turn on X3 and X4.
C10 starts to count. (one count every two sec.) The current counter value is
displayed on the digital display (Y40 to Y4F).
Make sure that the devices Y70 to Y76 turn on as follows.
Y70
Y71
Y72
Output
Y73
Y74
Y75
Y76
012345 10 15 20 25 30 35 40 45 50
Count (the current value of the counter C10)
Applicable device
Number of basic
MELSECNET Intelligent
Pointer
Level
steps
Internal device File Index
Digit
/10 (H) Direct function Constant
(system or user) register register
Jn\ module
Un\G
Bit Word R Bit Word Z K H P I N
S1 K1
Comparison S1 S2
instruction to 3
S2 K4
5 - 28
Project name QEX10
Program name MAIN
Ladder example
Read the following ladder and write it to the CPU of the demonstration machine.
Then check that the > and < instructions work properly.
0sec. ≤ T0 < 3sec. → Y70: ON, 2.7sec. < T0 < 3.3sec. →
Y71: ON, 3sec. < T0 ≤ 6sec. → Y72: ON
T0:
0 2.8 2.9 3.0 3.1 3.2 6.0 sec.
X0
0 SET M0
M0 M10 K60
2 T0
T0
8 M10
Operating Procedure
(1) Reading data
Read the project data.
● Click on the toolbar.
Click
5 - 29
● The Open dialog box is displayed. Specify the save destination.
● Double-click the displayed workspace "SCHOOL".
Double-click
Click
Click
The following procedures are the same as the Operating Procedure in section 4.4.
5 - 30
Operation Practice
Turn on X0 and check that the program works properly.
X0
0 SET M0
M0 M10 K60
2 T0
30
T0
8 M10
10 K30 T0 Y70
30
21 K30 T0 Y72
30
SM400
25 BCD T0 K2Y40
30
X1
29 RST M0
31 END
5 - 31
5.4 Arithmetic Operation Instruction
1 ● Every time the input condition is turned on, the content of the device specified in
D is added to the content of the device specified in S and the result is stored in
the device specified in D .
D S D
D0 + (5) D0
→
(Input condition)
First ON 0 (example) + 5 → 5
Second ON 5 + 5 → 10
Third ON 10 + 5 → 15
The content of
D0 is changed.
2 ● When the input condition is turned on, the content of the device specified in S1 is
added to the content of the device specified in S2 and the result is stored in the
device specified in D .
S1 S2 D
D0 + (100) D1
→
(Input condition)
ON 15 (example) + 100 → 115
CAUTION
• +P or -P must be used for the addition or subtraction instructions.
• When + or - is used, an addition or subtraction operation is executed every
scanning. To use + or - , operands must be converted into pulse in advance.
X2 X2
+P K5 D0 PLS M0
M0
+ K5 D0
REFERENCE
• The following two instructions work on the same principle in the addition or subtraction
operation.
(Addition) +P K1 D0 INCP D0
(Subtraction) -P K1 D2 DECP D2
5 - 32
Project name QB-17
Program name MAIN
X4
0 MOVP K1000 D2
S D
X5
3 -P K10 D2
3
S1 S2 D
X6
7 -P D2 K50 D3
4
3 ● Every time the input condition is turned on, the content of the device specified in
S is subtracted from the device specified in D and the result is stored in the
device specified in D .
D S D
D2 - (10) → D2
(Input condition)
First ON 1000 (example) - 10 → 990
Second ON 990 - 10 → 980
Third ON 980 - 10 → 970
The content of
D2 is changed.
4 ● When the input condition is turned on, the content of the device specified in S2 is
subtracted from the content of the device specified in S1 and the result is stored
in the device specified in D .
S1 S2 D
D2 - (50) → D3
(Input condition)
ON 970 - 50 → 920
(Assumption)
Applicable device
Number of basic
Internal
MELSECNET/ Intelligent
Pointer
Level
steps
5 - 33
Project name QEX11
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the addition and subtraction instructions
operate properly.
X0
0 BINP K4X30 D0
BINP K4X20 D1
+P D0 D1
X1
10 BINP K4X30 D0
BINP K4X20 D1
-P D0 D1
20 D1 K0 DBCD D1 K5Y40
26 D1 K0 Y70
DMOVK0 K5Y40
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
5 - 34
Operation Practice
(1) When X0 is turned on, the data in X30 to 3F and X20 to 2F are added, and the
result is output to Y40 to Y53.
(2) When X1 is turned on, the data in X30 to 3F is subtracted from the data in X20
to 2F, and the result is output to Y40 to Y53. When the result is a negative value,
Y70 is turned on and Y40 to Y53 are cleared to 0.
X0
0 BINP K4X30 D0
300
BINP K4X20 D1
400
+P D0 D1
300 400
X1
10 BINP K4X30 D0
300
BINP K4X20 D1
400
-P D0 D1
300 400
20 >= D1 K0 DBCD D1 K5Y40
400 400
26 < D1 K0 Y70
400
DMOV K0 K5Y40
34 END
+ D0 D1 = D1+D0 D1
100+30 400
5 - 35
Project name QB-18
Program name MAIN
5.4.2 * (P) BIN 16-bit data multiplication
/ (P) BIN 16-bit data division
X0
0 MOVP K2000 D0
S1 S2 D
X2 1
3 *P K30 D0 D10
S1 S2 D
X3 2
7 /P D0 K600 D20
1 ● When the input condition is turned on, the content of the device specified in S1 is
multiplied by the content of the device specified in S2 and the result is stored in
the device specified in D .
S1 S2 D
K30 D0 D11 D10
30 2000 = 60000
To store the result of 16-bit data × 16-bit data, This device is regarded as a 32-bit register to
16 bits (1 word) is not enough. hold the result. Left-most bit of D10 (B15) is
Therefore, D10 which is specified in the not a bit to determine positive and negative.
program and the next number D11 work as It is regarded as a part of the data.
the holder of the result.
The instructions must be regarded as 32 bits for programming with the calculation result of the
*(P) instruction. (such as the DMOV instruction and the DBCD instruction)
5 - 36
2 ● When the input condition is turned on, the content of the device specified in S1 is
divided by the content of the device specified in S2 and the result is stored in the
device specified in D .
S1 S2 D
D0 K600 D20 D21
2000 600 = 3 200
Quotient Remainder
and
The quotient is stored to D20, which is The remainder is stored to D21, which
specified in the program. is the next device number.
Values after the decimal point of the operation result are ignored.
● When a bit device is specified in D , the quotient is stored, but the remainder is
not stored.
● The following shows examples for processing negative values.
Example -5 / (-3) = 1, remainder: -2
5 / (-3) = -1, remainder: 2
● The following shows examples for dividing a number by 0, or dividing 0 by a
number.
Example 0/0
Error "OPERATION ERROR"
1/0
0 / 1, Both quotient and remainder are 0.
Operation Practice
● Write the program to the CPU and run it.
● Turn on X0 and store "2000" (BIN value) in D0.
● Turn on X2. The following operation is executed.
If "60000" (operation result of D11 and D10 is regarded as a 16-bit
integral number and only D10 is monitored, "-5536" is displayed. To prevent this,
follow the procedures in the following pages.
S1 S2 D
● Turn on X3.
S1 S2 D
D0 K600 = D21 D20
(2000) (600) (200) (3)
Remainder Quotient
Applicable device
Number of basic
Level
steps
Digit
File Index
(system or 10 (H) Direct function Constant
register register
user) Jn\ module
Bit Word R Bit Word Un\G Z K H P I N
S1 K1
Multiplication/division S1 S2 *
instruction D S2 to
4
D K4
The number of basic steps for the multiplication instruction is three or four, and that for division instruction is four.
*: The multiplication instruction varies depending on the device to be used.
5 - 37
● How to monitor 32-bit integral number data
When the operation result of the multiplication instruction is outside the range from 0 to 32,767, the
result cannot be displayed properly even though the number is regarded as 16-bit integral number and
the contents of the lower register are monitored in ladder.
To monitor those numbers properly, follow the procedures below.
• Click the Display Format button on the Device/Buffer Memory Batch Monitor dialog box and
select "32bit Integer" of "Display".
Click the OK button.
5 - 38
Project name QEX12
Program name MAIN
Ladder example
Create the following ladder with GX Works2 and write it to the CPU of the
demonstration machine. Then check that the multiplication and division instructions
operate properly.
X0
0 BINP K4X30 D0
BINP K4X20 D1
*P D0 D1 D10
BINP K4X20 D1
/P D0 D1 D20
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
5 - 39
Operation Practice
(1) When X0 is turned on, the data in X20 to X2F is multiplied by the data in X30 to
3F, and the result is output to Y40 to 5F.
(2) When X1 is turned on, the data in X30 to X3F is divided by the data in X20 to 2F.
The quotient is output to Y50 to 5F, and the remainder is output to Y40 to 4F.
X0
0 BINP K4X30 D0
6
BINP K4X20 D1
3
*P D0 D1 D10
6 3 18
BINP K4X20 D1
3
/P D0 D1 D20
6 3 0
30 END
D0 D1=D10
6 3=18
5 - 40
5.4.3 32-bit data instructions and their necessity
The minimum unit in the data memory of the Q-series programmable controller is
1 word which consists of 16 bits. Therefore, in general, data is processed in
1-word basis at the transfer, comparison, and arithmetic operation.
The Q-series programmable controller can process data in 2-word (32-bit) basis.
In that case, "D" is added at the head of each instruction to indicate that the
instruction is regarded as 2-word. The following shows the examples.
MOV(P) DMOV(P)
Transfer BIN(P) DBIN(P)
BCD(P) DBCD(P)
<, >, <= D<, D>, D<=
Comparison
>=, =, <> D>=, D=, D<>
+ (P) D + (P)
Arithmetic - (P) D - (P)
operations * (P) D * (P)
/(P) D/(P)
-32,768 0 -2,147,483,648
to to to
32,767 9,999 2,147,483,647
Available range for Values in parentheses are for 0
values BIN(P), BCD(P) instructions. to
99,999,999
Values in parentheses are for
DBIN(P), DBCD(P) instructions.
Available range for
K1 to K4 K1 to K8
digits
67108864
33554432
16777216
8388608
4194304
2097152
1048576
131072
65536
32768
16384
8192
4096
2048
1024
512
256
128
524288
262144
64
32
16
1073741824
536870912
268435456
134217728
8
4
2
1
As the case of 16-bit data processing, the programmable controller processes a 32-bit
negative value in two's complement. Therefore, the most significant bit B31 (B15 for 16-bit
data), is a sign bit.
B31 B0 Available range for numbers
-2147483648 to 0 to 2147483647
5 - 41
Whether the data is processed in 2-word (32-bit) basis or not depends on the
size of the data.
In the following cases, 2-word instructions must be used.
1) When the data size exceeds the range (-32768 to 32767) in which data can
be processed as 1-word
S D
DMOV K50000 D0
D1 D0 Stored in two
adjacent devices.
50,000 50000
Transferred
* D0 D1 D10
Converted
into BCD.
D43 D42
(Remainder)
5 - 42
Project name QB-19
Program name MAIN
5.4.4 Calculation examples for multiplication and division including decimal points (when the multiplication
or division is used)
• Programming method
Handle the circular constant as 314 (3.14 × 100), and divide the result by 100
afterward.
• Programming method
To handle 0.006 as an integer 6, multiply both the dividend and divisor by 1000.
The calculation of X0 X1
Example1 is BINP K4X30 D0 Imports the set value of the digital switch into D0.
commanded.
*P D0 K314 D1 D0 314 D2 D1
MOV K0 K2Y40
The calculation of X1 X0
Example2 is BINP K4X30 D20 Imports the set value of the digital switch into D20.
commanded.
REMARK
QCPU has instructions which can process actual number (floating decimal
point) operation data for highly accurate operations.
As long as the instructions are used, careful attentions for the place of the
decimal point as shown above are unnecessary.
5 - 43
5.5 Index Register and File Register
The index register (Zn) is used to indirectly specify the device number. The
result of an addition of data in the index register and the directly specified device
number can be specified as the device number.
Example
REMARK
When the index register is used with 32-bit data instructions
Zn and Zn+1 are targets to be processed.
The lower 16 bits correspond to the specified index register number (Zn), and the
higher 16 bits correspond to the specified index register number + 1.
32-bit indexing
(Only for Universal model QCPU (except for Q00UJCPU))
A method for specifying index registers for 32-bit indexing can be selected from
following two methods.
● Specifying the index range used for 32-bit indexing
● Specifying the 32-bit indexing using "ZZ" specification
Refer to appendix 8 for the detail of indexing.
5 - 44
Application Example
• Write the data to the data register with number which is specified with the digital
switch.
K3000
T2
0 T2
X0
5 BINP K2X20 Z0
MOVP T2 D0Z0
• Check the operation of the ladder executing the device batch monitoring.
The operation procedure is the same as the one in section 5.2.1.
Set any two-digit number in the digital switch column (X27 to X20) and turn on
X0.
5 0
X27 to X20
Z0= 50
D0Z0=D50
5 - 45
5.5.2 How to use file register R
The file register (R) consists of 16 bits as well as the data register (D).
Set the file register in the standard RAM of the QCPU or a memory card (SRAM
card and Flash card). The file register to be stored in the Flash card can be read
from the program only. The data cannot be changed with the program.
Stores parameters, programs, device
Program memory comments, and device initial values.
(File registers cannot be stored.)
The data in the file register remains after the reset operation or after the power is
turned off.
To clear the data, write 0 to the file register with the MOV(P) instruction or GX
Works2.
Use [Write to PLC] of GX Works2 or a sequence program to write data to the
standard RAM or SRAM card.
Use [Export to ROM Format] of GX Works 2 to copy data in the standard ROM
or Flash card.
Specify the area of the file register in 1K (1024 point) basis with the parameter.
Application Example
• Set 32K points of the file register R0 to R32767 to use in the program.
Follow the procedures below to register the file register to the parameter.
1) Double-click!
5 - 46
(From the previous page)
3) Click!
[Setting contents]
File Name :R
Capacity : 32
6) Click!
5 - 47
(From the previous page)
7) Select!
8) Click the Execute button to write the
data.
8) Click!
• To clear the file register data with the program, write the following program.
For the operation procedure, refer to section 4.4.
Turning on X0 can write the data, and turning on X1 can clear the data.
X0
0 MOV K173 R5
5 - 48
5.6 External Setting of Timer/Counter Set Value and External Display of Current Value
X0 Digital switch
0 BINP K4X20 D5 X2F to X20
D5 1 2 3 4
X4
4 T10
T10 D5 1 2 3 4
9 Y70 D5
SM400 T10
11 BCD T10 K4Y40
X1
Digital display
15 BINP K4X30 D6
Y4F to Y40
D6
X5
19 C10
Displays the current
value of T10.
C10
24 Y71
X6
26 RST C10
SM400
31 BCD C10 K4Y50
Operating Procedure
The step (1) of the following procedure is the same as Operating Procedure in
section 5.3.
The steps (2) to (4) of the following procedure are the same as Operating Procedure
in section 4.4.
5 - 49
Operation Practice
(1) External setting of the timer set value and display of the current value
• Set the timer set value in the digital switch (X20 to 2F), and turn on the switch
X0.
• When the switch X4 is turned on, Y70 turns on after the time specified with
the digital switch. (For example, Y70 turns on after 123.4sec.
when 1 2 3 4 is set.)
• The digital display (Y40 to 4F) displays the current value of the timer T10.
(2) External setting of the counter set value and display of the current value
• Set the counter set value in the digital switch (X30 to 3F), and turn on the
switch X1.
• Turn on and off the switch X5 repeatedly. When X5 has turned on for the
times specified with the digital switch (count up), Y71 turns on.
• The digital display (Y50 to 5F) displays the current value of the counter C10
(the number of times that X5 is turned on).
• Turning on the switch X6 clears the counter C10 to 0. When the contact C10
is already turned on (count up), the contact is released.
5 - 50
Project name QTEST5
Program name MAIN
5.7 Exercise
Transfer the eight input statuses (X0 to X7) to D0 once then output them to Y70 to
Y77. (For example, Y70 turns on when X0 turns on.)
X0 Y70
X1 Y71
X2 Y72
X3 Y73
X4 Y74
X5 Y75
X6 Y76
X7 Y77
SM401
0 MOV 1) D0
MOV D0 2)
Hint
CPU
(Input module) (Output module) 1)
D0
2)
X0 0/1 0/1 0/1 Y70
X1 0/1 0/1 0/1 Y71
X2 0/1 0/1 0/1 Y72
X3 0/1 0/1 0/1 Y73
K2X0 K2Y70
X4 0/1 0/1 0/1 Y74
X5 0/1 0/1 0/1 Y75
X6 0/1 0/1 0/1 Y76
X7 0/1 0/1 0/1 Y77
MOV MOV The CPU imports the input signal as "1" when it is on,
and imports as "0" when it is off.
The output module turns on when the CPU outputs "1",
and turns off when the CPU outputs "0".
Comparison
The following shows a program which is created with the sequence instructions, not
with the MOV instruction.
X0
0 Y70
X1
2 Y71
X2
4 Y72
X3
6 Y73
X4
8 Y74
X5
10 Y75
X6
12 Y76
X7
14 Y77
5 - 51
Project name QTEST6
Program name MAIN
5.7.2 Exercise 2 BIN and BCD conversion
Output the number of times that X1 is turned on on the display connected to Y40 to
Y4F in BCD. As a precondition, the set value of the counter (C0) can be input with
the digital switch (X20 to X2F) and the setting will be available by turning on X0.
X1 1)
0 C0
X0
5 BINP 2) D0
SM401
9 3) C0 4)
X2
13 RST C0
C0
18 Y70
Hint
CPU
BIN D0
BCD value
C0 BCD
X1:ON/OFF
BIN value BCD digital display
Y40 to Y4F (K4Y40)
1)
2)
3)
4)
5 - 52
Project name QTEST7
Program name MAIN
5.7.3 Exercise 3 FMOV
Create a program in which turning on X0 turns on the 64 outputs Y40 to Y7F and
turning off X0 turns off the 64 outputs Y40 to Y7F.
X0
0 FMOV K255 1) 2)
X0
5 FMOV 3) K2Y40 K8
Hint
CPU The constant is output from the CPU in the binary notation.
(Output card)
255
1 Y40 When 255 is output from Y40,
1
Y41 128 64 32 16 8 4 2 1
1
1 Y42 1 1 1 1 1 1 1 1 =1+2+4+8+16+32+64+128=255
1 Y43
1 Y47 Y46 Y45 Y44 Y43 Y42 Y41 Y40
1 Y44
1 Y45 In this exercise, a 64-point output module is used (Y40 to Y7F).
How many blocks are required for 255 on the output basis?
Y46
Y47
MOV
1)
2)
3)
Comparison
The following shows a program which is created with the sequence instructions, not
with the FMOV instruction. The 130 steps are used.
X0
0 Y40
Y41
Y42
Y7F
5 - 53
Project name QTEST8
Program name MAIN
5.7.4 Exercise 4 Comparison instruction
Using the two BCD digital switches, execute the calculation of (A - B) and display
the result on the BCD digital display (Y40 to Y4F).
2) K4X30 D1
-P D0 D1
3) K0 D1 SET Y70
MOV K0 K4Y40
4) K0 D1 BCD D1 K4Y40
RST Y70
Hint
The operation result is always output from the CPU in binary.
- D0 D1 =D1-D0 D1
1)
2)
3)
4)
5 - 54
Project name QTEST9
Program name MAIN
5.7.5 Exercise 5 Addition and subtraction instructions
1)
2)
Reference
Complement (deny transfer)
M1 D1 D0
D> K0 D0 DCML D0 D8 Before DCML B31 B30 B18 B17 B16 B15 B14 B2 B1 B0
execution
(negative number) 1 1 1 0 1 1 0 0 1 0
D+P K1 D8
D9 D8
The absolute value is determined After DCML
by a calculation of two's complement execution 0 0 0 1 0 0 1 1 0 1
of D0 and D1 (32-bit data).
D9 D8
After D + P execution
(absolute value) 0 0 0 1 0 0 1 1 1 0
REMARK
The CML instruction inverts the bit pattern of S and transfers the data to D
when the input condition is turned on.
Input condition S D
CML D0 D10
5 - 55
Project name QTEST10
Program name MAIN
5.7.6 Exercise 6 Multiplication and division instructions
Create the program with GX Works2 filling in the blanks in the following.
Then, check the operation using the demonstration machine.
X0
0 >= H9 K1X30 >= H9 K1X34 1) K2X30 D0
= D1 K0 DMOVP K0 D2
SM401
43 >= K9999 D2 5) D2 K4Y40
Hint
D0 D1 D3 D2
BIN-
multiplication BIN value BIN value 0 BIN value
D0 D1 D2 D3
BIN-division BIN value BIN value BIN value BIN value
1)
2)
3)
4)
5)
6)
5 - 56
Project name QTEST11
Program name MAIN
5.7.7 Exercise 7 D-multiplication and D-division
Create the program with GX Works2 filling in the blanks in the following. Then,
check the operation using the demonstration machine.
X2 X3
0 DBINP K5X20 D0
1) K1100 D2
2) D0 D2 D4
4) K40000 D12
1)
2)
3)
4)
5)
6)
7)
5 - 57
Answers for the exercises in Chapter 5
Exercise
Answer
No.
1) K2X0
1
2) K2Y70
1) D0
2) K4X20
2
3) BCD
4) K4Y40
1) K2Y40
3 2) K8
3) K0
1) BINP
2) BINP
4
3) >
4) <=
1) D+P
5
2) D-P
1) BINP
2) BINP
3) *P
6
4) /P
5) BCD
6) BCD
1) DMOVP
2) D*P
3) DBINP
7 4) DMOVP
5) D/P
6) D14
7) D16
5 - 58
CHAPTER 6 HOW TO USE OTHER FUNCTIONS
X6 X1
0 Y70 For details on the operation method, refer to
Y70 chapter 2.
6-1
6.1.1 Turning on and off the device "Y" forcibly
1) Click!
2) Enter "Y70"!
2) The Modify Value dialog box is displayed.
Enter "Y70" in the "Device/Label" list box.
NOTE
When the CPU is in the RUN state, the operation results of programs are
displayed preferentially. Therefore, stop the CPU first before the confirmation
with the demonstration machine.
6-2
POINT
The test function during ladder monitoring of GX Works2 is also available for
setting and resetting contacts, changing current values, and outputting forcibly
word devices.
Double-clicking a contact (pressing the Enter key) holding the Shift
key in the ladder monitoring screen of GX Works2 switches the contact open or
close forcibly.
To display the Modify Value dialog box, double-click a word device (press the
Enter key) holding the Shift key in the ladder monitoring screen of GX
Works2.
6-3
6.1.2 Setting and resetting the device "M"
1) Click!
3) Click!
POINT
With the same procedure, bit devices other than the internal relay (M) also can
be set or reset forcibly.
6-4
6.1.3 Changing the current value of the device "T"
1) Click!
POINT
With the same procedure, the current values of word devices other than the
timer (T) also can be changed.
6-5
6.1.4 Reading error steps
1) Click!
6-6
6.1.5 Remote STOP and RUN
1) Click!
3) Click!
6-7
6.2 Forced I/O Assignment by Parameter Settings
1) Double-click!
6-8
Check with demonstration machine
Stop the CPU and click on the toolbar.
The Online Data Operation dialog box is displayed. Click the parameter of the
currently edited data, and click the Execute button to write only the parameters
to the CPU. Then, activate the CPU and check the following.
1) The current value of the timer T0 disappears from the digital display (Y50 to Y5F).
Then, the LEDs of Y70 to Y77 start flashing until the set values of Y70 to Y77
reach each set device value.
2) Turning on X6 to output the signal to Y70 and Y74 does not turn the LEDs of Y70
and Y74.
POINT
• The address 7 is replaced with the address 5. Therefore, the current value of
the timer T0 is output to the newly assigned address 5, and LEDs of Y70 to
Y77 which are connected to the address 5 flash.
• Results of outputting the signals to Y70 or Y74 are not displayed on any
displays since the address 7 of the output modules no longer exists.
• To display the device numbers normally, change the device number K4Y50
K4Y30, and Y70 to Y77 Y50 to Y57.
6-9
6.3 How to Use Retentive Timers
When an input condition is turned on, the coil is energized. Then the value of a
retentive timer starts increasing. When the current value reaches the set value, the
retentive timer goes time-out and the contact turns on. When the input condition is
turned off during the increasing, the coil is de-energized but the current value is kept.
When the input condition is turned on again, the coil is re-energized and the current
value is accumulated.
Project name Retentive timer
Program name MAIN
Contact X6
X6 K50
ST1
Coil ST1
ST1
Y73 3.0sec. 2.0sec.
Normally open contact ST1
X7
RST ST1
Contact X7 (for input RST instruction)
Current
0 3 3 5 5 0
value of ST1
When using the program as a Only the RST instruction is available for turning off the contact
retentive timer, specify the points and clearing the current value after the retentive timer goes time-out.
in parameters in advance.
1) Double-click!
6 - 10
(From the previous page)
3) Click!
4) Enter "32"!
5) Click!
6 - 11
6.4 Device Batch Replacement
This section explains how to replace Y40 to Y7F (64 devices) with Y20 to Y5F
(64 devices) in batch.
1) Click!
5) Click!
(Before) (After)
X6 X1 X6 X1
6) Confirm that the target device numbers are
0 Y70 0 Y50
Y70 Y50 replaced.
X4 M10 K1500 X4 M10 K1500
4 T0 4 T0
BCD TO K4Y50 BCD TO K4Y30
X6 T1 X6 T1
13 Y74 13 Y54
Y74 Y54
Y74 X6 K30 Y54 X6 K30
17 T1 17 T1
6 - 12
6.4.2 Batch change of specified devices between normally open contacts and normally closed contacts
This section explains how to change the normally open contacts of the specified
devices to the normally closed contact and vice versa in batch.
1) Click!
3) Click!
NOTE
Before exercising section 6.5 after this section, write the program in the
personal computer to the CPU.
For the write operation, refer to section 2.7.
6 - 13
6.5 Online Program Change
3) Click!
NOTE
Online program change cannot be executed when the program in the
programmable controller CPU and the program in GX Works2 before the
modification do not match. Therefore, when whether the programs match or not
is unclear, verify them before the modification with GX Works2, and execute the
online program change.
6 - 14
6.6 Registering Devices
This section explains how to register multiple devices or labels in one screen and to
monitor them at the same time.
1) Click!
4) Displayed!
6 - 15
6.7 How to Create Comments
Use the keyboard to input the program above or read it from a folder on the desktop.
6 - 16
(1) Flowchart of when creating comments
Create comments.
POINT
Comments are used for displaying functions or applications of each device.
Up to 32 characters are available.
6 - 17
(2) Creating comments
2) Enter comments!
6 - 18
(From the previous page)
6 - 19
(3) Saving comments
1) Click!
2) Click!
6 - 20
(4) Displaying a ladder with comments on GX Works2 screens
1) Click!
6 - 21
POINT
In addition to device comments, statements and notes can be created on the ladder screen.
• Statement : Comment for explaining functions or applications for the ladder block. Up to 64
characters are available.
• Note : Comment for explaining functions or applications for outputs and commands. Up to 32
characters are available.
Statement
Note
• Creating statements
Click and double-click a symbol where a comment is to be attached.
The Enter Line Statements dialog box is displayed. Enter a comment and click the OK button.
• Creating notes
Click and double-click an output or a command where a comment is to be attached.
The Enter Symbol dialog box is displayed. Enter a comment and click the OK button.
6 - 22
6.8 Setting Security for Projects
This section explains how to set security for projects to protect the projects and the
data in the projects.
Setting security restricts accesses to projects.
Also, setting security prevents data such as POUs, device comments, and
parameters, which are created by the user, from erroneous modifications or
disclosures to unauthorized users.
POINT
<Operator level>
Users Only access to project data is possible.
Data cannot be read from the programmable controller CPU.
Lower
<Example>
The data with access authority of Developers(Level 2) can be edited by login users
with the access level of Developers(Level 2) or higher (Administrators,
Developers(Level 3), or Developers(Level 2)).
6 - 23
6.8.1 Setting and resetting security for projects
This section explains how to set security for an open project and how to reset the
security.
1) Click!
6 - 24
6.8.2 Managing (adding, deleting, and changing) users
This section explains how to manage the registered statuses of users for a project
with security and how to add, delete, and change users.
This function is available only when a user logs in a project with the access level of
"Administrators" or "Developers".
1) Click!
6 - 25
[Adding users]
Add a user to a project with security.
A user whose access level is higher than that of the login user cannot be added.
1) Click!
3) Click!
6 - 26
[Changing user information]
Change the access level of the user added on the previous page from
"Developers(Level3)" to "Users".
The information of the login user and of a user whose access level is higher than
that of the login user cannot be changed.
1) Select!
2) Click!
4) Click!
6 - 27
[Changing passwords]
Change the password of a user selected in the list on the User Management screen.
The password of the login user and of a user whose access level is higher than that
of the login user cannot be changed.
To change the password of the login user, click [Project] → [Security] → [Change
Password].
1) Select!
2) Click!
[Deleting users]
Delete a user selected in the list with the button on the User
Management dialog box.
The current login user cannot be deleted.
However, when the registered user is only "Administrators" and no other users to be
deleted exist, the current login user can be deleted.
When all users are deleted, security is reset.
6 - 28
6.8.3 Logging in projects
6 - 29
6.8.4 Changing access authority for each access level
This section explains how to set an authorization of displaying and saving data for
each access level.
The access authority of access levels higher than that of the login user cannot be
changed.
When the access level of the current login user is "Users", the access authority
cannot be changed.
1) Click!
4) Set!
3) Select a target item from Access Object.
5) Click!
6 - 30
6.9 Sampling Trace Function
This function is used to acquire data at the specified timing to find how device values
change during program operation and to trace the changes displayed in time series.
For details of the sampling trace function, refer to the manuals of each CPU module.
6 - 31
(1) Setting the sampling trace
1) Click!
3) Click!
6 - 32
(From the previous page)
6) Check!
6) Click!
6 - 33
(From the previous page)
Device/Label : SM0
Condition : -P-
11) Check!
12) "SD0" is displayed in the trend graph area on the Sampling Trace screen.
6 - 34
(2) Starting the sampling trace
6 - 35
(3) Checking the trace result
POINT
6 - 36
CHAPTER 7 PROGRAMMING INTELLIGENT FUNCTION MODULE
4
I/O slot number 2 3
0 1
7-1
7.2 Data Communication between Intelligent Function Modules and CPUs
An intelligent function module and a CPU exchange mainly two formats of data.
Bit data ------------Signals that use input Xs and output Ys
Word data --------16-bit data or 32-bit data
External I/F
X/Y
X, Y, M, T, C, D
CPU
Output Y (Bit data)
Program
Buffer memory
Reading data
7-2
7.2.1 I/O signals to CPUs
For 1-bit signals exchanged between a QCPU and an intelligent function module,
input Xs and output Ys are used.
Xs and Ys here do not mean external I/Os but symbols that are used in a sequence
program to exclusively represent I/O signals of intelligent function modules. Also
note that I/O numbers are assigned according to the slot where the intelligent
function module is installed.
[X]
Intelligent
function module
Xs in a sequence program represent signals
QCPU
X that are input to a QCPU from an intelligent
READY signal
X Operating condition function module. These signals are
setting completed
X generated on an intelligent function module.
A/D conversion completed
X
Error Note that the Xs are used as contacts in a
program. The following is examples of the
signals.
(1) READY signal
Figure 7.3 This signal notifies a QCPU that an
X from intelligent function module intelligent function module started up
normally at power-on and is ready for
operation.
(2) Operating condition setting completed
This signal is used as an interlock
condition for turning Operating condition
setting request (Y9) on/off when the
following settings are changed.
• A/D conversion enable/disable setting
(buffer memory address 0: Un\G0)
• CH Average time/average number of
times
(buffer memory addresses 1 to 8:
Un\G1 to Un\G8)
• Averaging process setting
(buffer memory address 9: Un\G0)
[Y]
Intelligent
SETs, RSTs, or OUT-Ys represent output
QCPU function module
signals transmitted from a QCPU to an
intelligent function module. These signals
Y are generated on a QCPU. Note that they
Output enable
Y
are used as coils or contacts in a program.
User range
writing
Y
Channel change (Example) D/A converter modules output an
Synchronous Y
output enable instruction (output enable)
Figure 7.4 Y from CPU before outputting analog values
that were converted from digital
values.
7-3
7.2.2 Data communication with intelligent function modules
(1) QCPUs can read and write data to and from the buffer memory. Also note that
some modules can write data to buffer memory from peripheral device via an
interface.
(2) In a buffer memory, space of one word (16 bits) is reserved for each intelligent
function module's unique address.
The smallest address is 0, and these addresses are used to specify a target
module to read or write. The minimum unit is one word. Data of 17 bits to 32
bits is treated as 2-word (32-bit) data.
0 0 0 1 0 0 0 1 0 1 0 0
Data part
Sign bit
1: Negative Indicated here is +276.
0: Positive (Negative digital values are represented
in two's complement.)
Figure 7.6 Example image of buffer memory content (D/A converter module)
Figure 7.6 shows 16 bits of the buffer memory of a D/A converter module where
a digital quantities have been written. The number is obtained from digital
quantity that a QCPU wrote to the buffer memory within the range from -4096 to
+4095 in signed binary (16 bits long).
7-4
7.3 Communication with Intelligent Function Module
The following table shows the communication methods between a QCPU and an
intelligent function module.
7-5
7.4 Intelligent Function Module System in Demonstration Machine
Use an A/D or D/A converter module to convert analog signals/digital data that are
input with the volume or digital switch on the demonstration machine.
QX QY Q64 Q62
Q61P QCPU Vacant 42 42P AD DAN
slot (64 (64 (16 (16
points) points)points) points)
X/Y90 to X/Y9F
X/Y80 to X/Y8F
X0 to X3F
Y40 to Y7F
(Channel 1) (Channel 1)
V V
7-6
7.5 Q64AD Analog/Digital Converter Module
Q64AD
1) RUN
2) ERROR
V+ 1
C V- 2
H
1
I+ 3
SLD 4
V+ 5
C
H
V- 6
2 I+
7
SLD
8
V+
9
C V-
H
3
10
I+
11
SLD
V+
12
C V-
13
H
4 I+ 14
SLD 15
A.G.
16
17
(FG)
A/D
18
0-±10V
0-20mA
Name and
No. Description
appearance
Indicates the operation status of the A/D converter module.
ON : In normal operation
1) RUN LED
Flicker : In offset/gain setting mode
OFF : 5V power failure or watchdog timer error occurred
Indicates errors and the status of the A/D converter module.
ON : Error occurred
OFF : In normal operation
2) ERROR LED
Flicker : Switch setting error occurred
Values other than 0 has been set to the switch 5
on the intelligent function module.
7-7
7.5.2 A/D conversion characteristics
4000
2004
2003
Digital output
Digital output value
2002
0 2001
2000
2.5mV
5.0000V
5.0025V
-4000
-10V 0 10V
Analog input voltage Input voltage
A/D converter modules convert analog values input from other devices to digital
quantities so that CPUs can operate those values. On voltage inputs, for
example, A/D converter modules convert -10V to a quantity of -4000 and 10V to
4000. This means that the modules convert an input voltage of 2.5mV to a
digital quantity of 1, and abandon values smaller than 2.5mV.
4000
2005
2004
Digital output value
2003
Digital output
2002
2001
0 2000
5 A
10.000mA
10.005mA
The modules convert current an input of 0mA to 0 for an output, and 20mA to
4000. This means that the modules convert an input current of 5μA to a digital
quantity of 1, and abandon values smaller than 5μA.
REMARK
A voltage or current value that is equivalent to a digital value of 1 through A/D
conversion (maximum resolution) differs depending on the setting of the
resolution mode (1/4000, 1/12000, 1/16000) or the output range.
7-8
7.5.3 List of I/O signals and buffer memory assignment
Signal direction: CPU ← A/D converter module Signal direction: CPU → A/D converter module
Device No. (input) Signal name Device No. (output) Signal name
X0 Module READY Y0
X1 Temperature drift compensation flag Y1
X2 Y2
X3 Y3
*1
X4 *1 Y4 Use prohibited
Use prohibited
X5 Y5
X6 Y6
X7 Y7
X8 High resolution mode status flag Y8
Operating condition setting Operating condition setting
X9 Y9
completed flag request
XA Offset/gain setting mode flag YA User range writing request
XB Channel change completed flag YB Channel change request
*1 *1
XC Use prohibited YC Use prohibited
Maximum value/minimum value reset Maximum value/minimum
XD YD
completed flag value reset request
*1
XE A/D conversion completed flag YE Use prohibited
XF Error flag YF Error clear request
POINT
*1: These signals cannot be used by the user since they are for system use only.
If these are turned on/off by the sequence program, the functioning of the A/D
converter module cannot be guaranteed.
7-9
(2) Buffer memory assignment (Q64AD)
This section explains the assignment of the Q64AD buffer memory.
POINT
Do not write data to the system areas or areas to which writing data from a
sequence program is disabled. Doing so may cause malfunction.
Address Read/
Description Default *1
Hexadecimal Decimal write
...
System area - -
8H 8
9H 9 Averaging process setting 0 R/W
AH 10 A/D conversion completed flag 0 R
BH 11 CH1 Digital output value 0 R
CH 12 CH2 Digital output value 0 R
DH 13 CH3 Digital output value 0 R
EH 14 CH4 Digital output value 0 R
FH 15
...
...
System area - -
12H 18
13H 19 Error code 0 R
14H 20 Setting range (CH1 to CH4) 0 R
15H 21 System area - -
16H 22 Offset/gain setting mode Offset specification 0 R/W
17H 23 Offset/gain setting mode Gain specification 0 R/W
*1: Indicates whether reading from and writing to a sequence program are enabled.
R: Read enabled
W: Write enabled
7 - 10
Buffer memory assignment (Q64AD) (2/2)
Address Read/
Description Default *1
Hexadecimal Decimal write
18H 24
...
...
System area - -
1DH 29
1EH 30 CH1 Maximum value 0 R/W
1FH 31 CH1 Maximum value 0 R/W
20H 32 CH2 Maximum value 0 R/W
21H 33 CH2 Maximum value 0 R/W
22H 34 CH3 Maximum value 0 R/W
23H 35 CH3 Maximum value 0 R/W
24H 36 CH4 Maximum value 0 R/W
25H 37 CH4 Maximum value 0 R/W
26H 38
...
...
System area - -
9DH 157
9EH 158
Mode switching setting 0 R/W
9FH 159
A0H 160
...
...
System area - -
C7H 199
*2
C8H 200 Pass data classification setting 0 R/W
C9H 201 System area - -
*2
CAH 202 CH1 Industrial shipment settings offset value 0 R/W
*2
CBH 203 CH1 Industrial shipment settings gain value 0 R/W
*2
CCH 204 CH2 Industrial shipment settings offset value 0 R/W
*2
CDH 205 CH2 Industrial shipment settings gain value 0 R/W
*2
CEH 206 CH3 Industrial shipment settings offset value 0 R/W
*2
CFH 207 CH3 Industrial shipment settings gain value 0 R/W
*2
D0H 208 CH4 Industrial shipment settings offset value 0 R/W
*2
D1H 209 CH4 Industrial shipment settings gain value 0 R/W
*2
D2H 210 CH1 User range settings offset value 0 R/W
*2
D3H 211 CH1 User range settings gain value 0 R/W
*2
D4H 212 CH2 User range settings offset value 0 R/W
*2
D5H 213 CH2 User range settings gain value 0 R/W
*2
D6H 214 CH3 User range settings offset value 0 R/W
*2
D7H 215 CH3 User range settings gain value 0 R/W
*2
D8H 216 CH4 User range settings offset value 0 R/W
*2
D9H 217 CH4 User range settings gain value 0 R/W
*1: Indicates whether reading from and writing to a sequence program are enabled.
R: Read enabled
W: Write enabled
*2: Areas used to restore the user range settings offset/gain values when online module change is
made.
7 - 11
7.5.4 Adding or setting intelligent function module data
This section explains how to set the intelligent function module data.
After an intelligent function module is added to a project, the data settings
(parameters and switch settings) of the intelligent function module can be set.
1) Click!
3) Set!
5) Add!
7 - 12
(From the previous page)
6) Double-click!
8) Click!
9) Double-click Parameter.
9) Double-click!
7 - 13
(From the previous page)
11) Double-click!
12) Set!
13) Click!
7 - 14
(From the previous page)
15) Click!
7 - 15
7.5.5 Exercise with the demonstration machine
(a) Turn on X3, and change input voltages for an A/D converter module with
the volume on the demonstration machine.
Analog values that have been input to the channel 1 (CH1) of Q64AD are
stored to the buffer memory (in digital value). With the auto refresh settings,
the QCPU reads the stored digital values and stores them in its data
register D10.
(b) Whenever an analog value is "-1" or smaller, 0 is set.
(c) The digital values are displayed on the digital display (Y50 to Y5F).
7 - 16
7.6 Q62DAN Digital/Analog Converter Module
Q62DAN
1)
2)
3)
Name and
No. Description
appearance
Indicates the operation status of the D/A converter module.
ON : In normal operation
1) RUN LED
Flicker : In offset/gain setting mode
OFF : 5V power failure or watchdog timer error occurred
Indicates errors and the status of the D/A converter module.
ON : Error occurred
OFF : In normal operation
2) ERROR LED
Flicker : Switch settings error occurred
Values other than 0 has been set to the switch 5
on the intelligent function module.
External power
3) Terminal for connecting a 24VDC external power supply
supply terminal
7 - 17
7.6.2 D/A conversion characteristics
10V
5.0025V
2.5mV
5.0000V
D/A converter modules convert digital quantities that are input from a QCPU
into analog values, and then output them. For example, the modules convert a
digital quantity of -4000 to a analog quantity of -10V and 4000 to 10V before
output. This means that the modules convert the digital input value of 1 to an
analog quantity of 2.5mV, and abandon digital input values in decimal places.
20mA
Analog output current
0
10.005mA
5 A
10.000mA
-20mA 200020012002 2003
-4000 0 4000 Input
Digital input value
For current outputs, the modules convert a digital value 0 to 0mA and 4000 to
20mA. This means that the modules convert the digital input value of 1 to an
analog quantity of 5μA, and abandon digital input values in decimal places.
REMARK
A voltage or current value that is equivalent to a digital value of 1 through D/A
conversion (maximum resolution) differs depending on the setting of the
resolution mode (1/4000, 1/12000, 1/16000) or the output range.
7 - 18
7.6.3 List of I/O signals and buffer memory assignment
POINT
*1: These signals cannot be used by the user since they are for system use only.
If these are turned on/off by the sequence program, the functioning of the D/A
converter module cannot be guaranteed.
*2: For the Q62DAN and Q62DA, the use of Y3 to Y8 is prohibited.
For the Q64DAN and Q64DA, the use of Y5 to Y8 is prohibited.
7 - 19
(2) Buffer memory assignment (Q62DAN)
This section explains the assignment of the Q62DAN buffer memory.
POINT
Do not write data to the system areas or areas to which writing data from a
sequence program is disabled.
Doing so may cause malfunction.
Address *1 Read/
Description Default *2
Hexadecimal Decimal write
0H 0 D/A conversion enable/disable 3H R/W
1H 1 CH1 Digital value 0 R/W
2H 2 CH2 Digital value 0 R/W
3H 3
...
...
System area - -
AH 10
BH 11 CH1 Set value check code 0 R
CH 12 CH2 Set value check code 0 R
DH 13
...
...
System area - -
12H 18
13H 19 Error code 0 R
14H 20 Setting range (CH1 to CH2) 0H R
15H 21 System area - -
16H 22 Offset/gain setting mode Offset specification 0 R/W
17H 23 Offset/gain setting mode Gain specification 0 R/W
18H 24 Offset/gain adjustment value specification 0 R/W
19H 25
...
...
System area - -
9DH 157
9EH 158 0 R/W
Mode switching setting
9FH 159 0 R/W
A0H 160
...
...
System area - -
C7H 199
*3
C8H 200 Pass data classification setting 0 R/W
C9H 201 System area - -
*3
CAH 202 CH1 Industrial shipment settings offset value 0 R/W
*3
CBH 203 CH1 Industrial shipment settings gain value 0 R/W
*3
CCH 204 CH2 Industrial shipment settings offset value 0 R/W
*3
CDH 205 CH2 Industrial shipment settings gain value 0 R/W
*3
CEH 206 CH1 User range settings offset value 0 R/W
*3
CFH 207 CH1 User range settings gain value 0 R/W
*3
D0H 208 CH2 User range settings offset value 0 R/W
*3
D1H 209 CH2 User range settings gain value 0 R/W
*1: This is the initial value set after the power is turned on or the programmable controller CPU is
reset.
*2: Indicates whether reading from and writing to a sequence program are enabled
R: Read enabled
W: Write enabled
*3: Areas used to restore the user range settings offset/gain values when online module change is
made.
7 - 20
7.6.4 Adding or setting intelligent function module data
1) Click!
3) Set!
5) Add!
7 - 21
(From the previous page)
6) Double-click!
8) Click!
9) Double-click Parameter.
9) Double-click!
7 - 22
(From the previous page)
11) Double-click!
12) Set!
13) Click!
7 - 23
(From the previous page)
15) Click!
7 - 24
7.6.5 Exercise with the demonstration machine
X2
0 Y91
X90 X3
2 MOVP K0 D30
X4
MOVP K2000 D30
X5
MOVP K4000 D30
15 END
7 - 25
MEMO
7 - 26
CHAPTER 8 SIMULATION FUNCTION
The simulation function is for debugging a sequence program using the virtual
programmable controller on a personal computer.
The created sequence program can be immediately debugged without connecting a
programmable controller CPU.
NOTE
Safety and handling precautions of the simulation function
1) Click!
8-1
8.3 Debugging with Example Program
<<Example program>>
X0 X1
0 Y70
Y70
M0
4 Y71
SM412 K9999
6 C0
SM400
11 MOV C0 K4Y80
14 END
8-2
8.3.1 Monitoring and testing device status
This section explains how to monitor device status, turn bit devices on/off forcibly,
and change word device values.
1) Click!
3) Click!
8-3
(2) Changing the word device value
In the example operation below, the word device value "C0" is changed to "5".
1) Click!
2) Enter "C0"!
2) The Modify Value dialog box is displayed.
Input "C0" to the "Device/Label" list box.
3) Select!
4) Enter "5"! 3) Select the "Word[Signed]" from the "Data
Type" list box.
5) Click!
4) Input "5" to the "Value" column.
6) Reflected!
8-4
CHAPTER 9 MAINTENANCE
The following bar graph shows the ratio of faulty parts and causes of programmable
controller errors.
[Source: Inspection made by JEMA (The Japan Electrical Manufacture's
Association)]
(%)
80 Collected from 223 factories
73.1
60
40 34.1
20.6 19.3
20
14.3
9.4
2.7
0.9
0
I/O
Others
Memory
No answer
CPU
Peripheral device
Communication
Power supply
40.4
40
30
26.0 24.7 24.2
20 19.3
12.6 12.1
10
6.3
1.3
0
Noise
Short of load
Poor connection
Unknown cause
Others
Vibration shock
Manufacturer's fault
Incorrect programming
No answer
9-1
9.2 Maintenance
9-2
(2) Periodic inspection
The following table lists the items that must be inspected one or two times every
half year to a year. When the equipment has been relocated or modified, or
wiring layout has been changed, perform this inspection.
Ambient environment
Ambient
Measure the 0 to 55 °C When the
temperature
temperature and programmable
humidity with a *1 controller is used in the
1 Ambient humidity thermometer and a 5 to 95% RH board, the ambient
hygrometer. humidity in the board is
Measure corrosive gas. Corrosive gas must not the ambient humidity.
Ambience
be present.
Measure the voltage 85 to 132VAC Change the power
2 Power supply voltage across the terminals of
170 to 264VAC supply.
100/200VAC.
Retighten the screws.
Move the module to
The module must be If the CPU, I/O, or
Installation
Looseness of Retighten screws with a Screws must not be Retighten the terminal
Connection conditions
9-3
9.4 Service Life of Output Relay
The output relays of the modules are consumed by the switching operation.
A relay which is directly mounted on the print board of the output module is required
to be replaced the output module itself after the consumption.
1000
500
200
Limit number of switching (unit: 10,000)
100
50
20
10
DC30V
t=0ms
5 DC100V
t=7ms
1
0.1 0.2 0.5 1 2 5 10
Switching current (unit: A)
9-4
9.5 Spare Product
Alternative products are easily purchased through Mitsubishi service centers or local
Mitsubishi representatives in Japan. Thus the alternative products can be prepared
even after an accident. However, note that for foreign-related products such as
exported products, alternative products must be sent beforehand.
Considering the following tips at design work makes the maintenance easier.
9-5
(7) Spare product
Table 9.3 Spare products
Product name Quantity Remark
Storage lives of lithium batteries are about five years.
Therefore, the stock should not be kept all the time but
1 Battery One or two
batteries should be purchased when required. However,
keep stock of one or two for accidental situation.
Note that I/O modules tend to be faulty during a test
One per each operation.
2 I/O module
module type Also note that the contacts of output modules are
consumed in long-term use.
One for each
3 CPU module CPU modules and memory cards are the core parts of a
used model
programmable controller, which means that an error of
One for each them result in the system down.
4 Memory card
used model
Same as above. As the temperature of the power supply
Power supply One for each
5 modules rises easily, and high ambient temperature may
module used model
shorten their service lives.
9-6
9.6 Using Support Equipment
Connect the error lamp to the output module of the programmable controller so
that the lamp flashes when an error is detected.
Lamp flicker
Control panel
SM1 SM412
The lamp (Y50) flashes
Y50
when an error is detected.
(Error detection) (1-sec. clock)
Connect the digital display to the output module of the programmable controller
so that the error code number of the detected error is indicated on the digital
display.
Numerical display
Control panel
NOTE
The above programs cannot be executed when a stop error occurs.
9-7
3. Displaying the contents of the detected error on the screen
9-8
APPENDIX
The CPU supports two types of I/O control modes; the direct mode and refresh
mode.
In the direct mode, input signals are imported to a programmable controller every
time they are input and treated as input information. The operation results of a
program are output to the output data memory and the output modules. The
following diagram shows the flow of I/O data in the direct mode.
Programmable controller
CPU
(Operation processing)
X0
Y75
Y70 Executing the OUT instruction in the Output
sequence program module
5)
Test operation using peripheral device
Writing from serial communication
modules, etc.
App. - 1
Appendix 1.2 Refresh mode
In the refresh mode, all changes caused in an input module are imported to the input
data memory in a programmable controller CPU before every scan. The data in the
data memory is used for an operation.
The operation results made in a program for output (Y) are stored to the output data
memory at every operation. All the data stored in the output data memory is
batch-output to the output module after the execution of the END instruction.
The following diagram shows the flow of I/O data in the refresh mode.
Programmable controller
CPU
(Operation processing)
When inputs
3) Data memory for are refreshed Input
inputs (X) module
1)
X0
4)
When outputs
Y75 Data memory for are refreshed Output
Y70 outputs (Y) module
5) 2)
• Input refresh
Input data in the input module is batch-read 1) before the execution of the step 0,
and stored to the data memory for input (X).
• Output refresh
Data 2) in the data memory for output (Y) is batch-output to the output module
before the execution of the step 0.
• When the input contact instruction is executed:
The input data is read from the data memory for input (X) 3), and a sequence
program is executed.
• When the output contact instruction is executed:
The output data 4) is read from the data memory for output (Y), and a sequence
program is executed.
• When the output OUT instruction is executed:
The operation result of the sequence program 5) is stored in the data memory for
output (Y).
App. - 2
Appendix 1.3 Comparisons between the direct mode and refresh mode
In the example ladder given below, turning on input X0 turns on output Y70.
DX0 X0
1. Ladder example Y70 Y70
App. - 3
Appendix 2 Special Relay
The special relay (SM) is an internal relay whose application is fixed in the
programmable controller. For this reason, the special register cannot be used in the
same way as other internal registers are used in sequence programs. However, the
bit of the special relay can be turned on or off as needed to control the CPU module.
The following shows how to read the items in the list.
For details of special relays, refer to QCPU User's Manual Hardware Design,
Maintenance and Inspection.
Item Description
Number •
Indicates the special relay number.
Name •
Indicates the special relay name.
Meaning •
Indicates the contents of the special relay.
Explanation •
Explains the contents of the special relay in detail.
•
Indicates the setting side and setting timing of the special register.
<Set by>
S : Set by the system
U : Set by user (in sequence program or test operation at a peripheral
device)
S/U : Set by both system and user
<When set> indicated only if setting is done by system.
Every END processing : Set during every END processing
Set by
Initial : Set during initial processing (after power-on or
(When set)
status change from STOP to RUN)
Status change : Set when the operating status is changed
Error : Set if an error occurs
Instruction execution : Set when an instruction is executed
Request : Set when requested by a user (using the
special relay)
When system is switched : Set when the system is switched (between the
control system and the standby system)
• Indicates a special relay (M9□□□) supported by the ACPU.
("M9□□□ format change" indicates the one whose application has been
Corresponding
ACPU
M9□□□
changed. Incompatible with the Q00J/Q00/Q01, and QnPRH.)
• "New" indicates the one added for the Q-series CPU.
Indicates the CPU module supporting the special relay.
QCPU : All the Q-series CPU modules
Q00J/Q00/Q01 : Basic model QCPU
Corresponding Qn(H) : High Performance model QCPU
CPU QnPH : Process CPU
QnPRH : Redundant CPU
QnU : Universal model QCPU
CPU module name : Only the specified CPU model (Example: Q02U)
POINT
Do not change the values of special relays set by the system using a program
or by test operation.
Doing so may result in a system down or communication failure.
App. - 4
Appendix 3 Special Register
The special register (SD) is an internal register whose application is fixed in the
programmable controller. For this reason, the special register cannot be used in the
same way as other internal registers are used in sequence programs. However,
data can be written to the special register to control the CPU module as needed.
Data is stored in binary format if not specified.
The following shows how to read the items in the list.
For details of special registers, refer to QCPU User's Manual Hardware Design,
Maintenance and Inspection.
Item Description
Number • Indicates the special register number.
Name • Indicates the special register name.
Meaning • Indicates the contents of the special register.
Explanation • Indicates the detailed contents of the special register.
• Indicates the setting side and setting timing of the special register.
<Set by>
S : Set by the system
U : Set by user (in sequence program or test operation at a peripheral
device)
S/U : Set by both system and user
<When set> indicated only if setting is done by system.
Every END processing : Set during every END processing
Set by
Initial : Set during initial processing (after power-on or
(When set)
status change from STOP to RUN)
Status change : Set when the operating status is changed
Error : Set if an error occurs
Instruction execution : Set when an instruction is executed
Request : Set only when there is request from a user
(through SM, etc.)
When system is switched : Set when the system is switched (between the
control system and the standby system)
• Indicates special register (D9□□□) supported by the ACPU.
("D9□□□ format change" indicates the one whose application has been
Corresponding
ACPU
D9□□□
changed. Incompatible with the Q00J/Q00/Q01, and QnPRH.)
• "New" indicates the one added for the Q-series CPU.
Indicates the CPU module supporting the special relay.
QCPU : All the Q-series CPU modules
Q00J/Q00/Q01 : Basic model QCPU
Corresponding Qn(H) : High Performance model QCPU
CPU QnPH : Process CPU
QnPRH : Redundant CPU
QnU : Universal model QCPU
CPU module name : Only the specified CPU model (Example: Q02U)
POINT
Do not change the values of special registers set by the system using a
program or by test operation.
Doing so may result in a system down or communication failure.
App. - 5
Appendix 4 Application Program Example
(1) Y70 turns on when X0 is turned on, and turns off when X1 is turned on.
X0
0 SET Y70
X1
2 RST Y70
(2) When X2 is turned on, Y71 turns off if Y70 is on, and turns on if Y70 is off. This
flip-flop operation is repeated.
X2 T1 K5
0 T0
T0 K5
6 T1
Y70
T0
12 Y71
X02
Contact
T0
Contact
T1
Y70
Y71
App. - 6
(3) The flip-flop operation starts when X2 is turned on. In this operation, Y70 turns
on if the timer T0 is on, and Y71 turns on if the timer T1 is on. (Cycle: 10sec.)
X2 T1 K50
0 T0
T1
T0
7 PLS M0
Y70
M0
11 RST T1
T0 K50
16 T1
T1
T1
22 Y71
PLS M1
M1
26 RST T0
X2
Contact
T0
Contact
T1
Y70
Y71
App. - 7
Appendix 4.2 One shot ladder
(1) Output starts and continues for a certain time after the input X1 is turned on.
(Time for the input being on must be longer than the set time limit.)
X1 K70
0 T15
T15
Y75
X1
Normally closed
contact T15
Y75
Set time limit
7sec.
(2) When the input X0 is turned on momentarily, Y76 turns on for a certain time.
X0 T16 K100
0 T16
Y76
Y76
(3) Output starts and continues for a certain time when the input X0 is switched
from on to off.
X0
0 PLF M1
M1 T16 K100
3 T16
Y76
Y76
X0
Y76
Set time limit
Pulse duration
10sec.
App. - 8
Appendix 4.3 Long-time timer
X2
Normally open
contact T9
Normally open
contact T10 3000sec. 2000sec.
Y72
5000sec.
T14 K4
12 C7
M56
C7
18 RST C7
One scan
X2
Coil T14
Normally open
contact T14 (M56)
C7
Y73
900sec. × 4 = 3600sec. = 1 hour
(Note) Sufficient time is obtained with the counter C7 which counts the number of
time-outs of the timer T14.
M56 resets T14 after time-out. With C7, the output Y73 is self-energized
while count up is in progress. With Y73, T14 is reset and the following time
count is stopped.
App. - 9
Appendix 4.4 Off delay timer
MELSEC-Q does not provide off delay timers. Configure an off delay timer as
follows.
X5
Coil T6
Normally closed
contact T6
Y70
Set time limit
0.8sec.
X6 Y71 K41
4 T8
M45
M45
X5
X6
Y71
Set time limit
4.1sec
(Note) The above ladder operates as an off delay ladder by momentarily turning on
inputs X5 and X6.
M45 is equivalent to a momentary contact of T8.
App. - 10
Appendix 4.5 On delay timer (momentary input)
X1 X2 K62
0 T4 Timer starts after X1
M50 turns on, and continues
M50 to be activated.
T4
8 Y70 Turns on 6.2sec. later
T4
10 Y71 Turns off 6.2sec. later
X1
X2
T4,M50
Y70
Y71
App. - 11
Appendix 4.6 ON-OFF repeat ladder
In an ON-OFF repeat ladder, Y70 turns on when X1 is turned on, and turns off when
X1 is turned on again.
X1
0 FF Y70
The timer is set so that it starts output when the input keeps being on for 0.2sec.
X0 K2
0 T1
T1
5 M1
App. - 12
Appendix 4.8 Ladders with a common line
The following ladder cannot be operated as it is. To make such ladders controllable,
use master control instructions (MC, MCR) in the program.
Manual Automatic
X0 X1 X4 X3 Y71
Y70
Relay ladder X2
X7 Y79 X2
Y71
X6
X7
Y71
X2
4 M10 Manual circuit
X6 X7
6 M11
9 MCR N0
X1 X0
10 MC N0 M2
X4 X3
14 M20 Automatic circuit
X7 Y79
17 M21
20 MCR N0
M10 Y71
21 Y70
M20
M11 X2
25 Y71 Common circuit
M21
Y71
Note) In GX Works2, the on/off status of the master control is displayed in the title tag on the monitor screen.
App. - 13
Appendix 4.9 Time control program
The time value is set in the two digits of a digital switch. The currently elapsed time
is displayed on Y40 to Y47 while the outputs Y70 to Y72 turn on after the set time
limit has elapsed.
This operation is repeated.
X20 to 27 Y40 to 47
X3
0 PLS M5
M5 Reads set time
3 BIN K2X20 D1
2 digits in 0.1sec. units
X4 T4 D1
7 <> K0 D1 T3 Starts timer
T3 K10 Repeats flicker
16 T4
X5
21 BCD T3 K2Y40 Outputs time value to exterior
Turns on when T3 is from
> K20 T3 Y70 0.1 to 1.9sec.
= K30 T3 Y71 Turns on when T3 is 3.0sec.
Turns on when T3 is 4.1sec.
< K40 T3 Y72 or more.
App. - 14
Appendix 4.10 Clock ladder
The clock data such as hour, minute, and second is output to a digital display.
T1 K5
0 T0
T0 K5 0.5-sec. flickering
5 T1
T1 K60
10 C11 Counts seconds
C11
15 RST C11
K60
C12 Counts minutes
C12
24 RST C12
K99
C13 Counts hours
C13
33 RST C13
SM400
38 BCD C11 K2Y40
0
Ones 1 Ones
47 seconds digit 2
3
digit 64 hours
K2Y40 K2Y50
4
Tens 5 Tens
digit 6 digit
7
8
Ones 9
18 minutes digit A
B
K2Y48
C
Tens
D
digit
E
F
ON ON ON ON ON ON ON ON ON
Y57 Y56 Y55 Y54 Y53 Y52 Y51 Y50 Y4F Y4E Y4D Y4C Y4B Y4A Y49 Y48 Y47 Y46 Y45 Y44 Y43 Y42 Y41 Y40
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
Tens digit Ones digit Tens digit Ones digit Tens digit Ones digit
K2Y50 hour, Output K2Y48 minute, Output K2Y40 second, Output
App. - 15
Appendix 4.10.1 Clock function (supplement)
The following ladder displays the time setting set in GX Works2 to the Q
demonstration machine.
Project name QEX13
App. - 16
App. - 17
Appendix 4.11 Starting - operation of electrical machinery
Turning on the start switch starts the operation. After the operation time has
elapsed, the operation mode is activated through an arc interlock state.
X0 X1
0 Y70 During operation
Y70 Y72 K20
T5 period timer
Y70 T5 Y72
9 Y71 operation
T5 K5
13 T6 Arc interlock
T6 Y70 Y71
18 Y72 operation
Y72
Start X0
Stop X1
Operation Y70
operation
Y71
Y72 operation
T5 = 2sec.
App. - 18
Appendix 4.12 Displaying elapsed time and outputting before time limit
The following ladder outputs the time elapsed in the timer on the LED display, and
indicates that the set time limit has been reached. This system can also be applied
to counters.
Output module
1234
X2 Y6C to 6F
× 100
Y68 to 6B
× 10
Starts when turned on Y64 to 67
Stops when turned off ×1
Y60 to 63
× 0.1
App. - 19
Appendix 4.13 Retentive timer
X2
0 M0 Timer starts when
X2 is turned on
M0
2 PLS M1
K600
T195
M1 Writes D7 to timer
9 MOV D7 T195 when X2 is turned on
M0 Saves current value
12 MOV T195 D7 of timer to D7
T195
15 MOV K0 D7 Clears D7 by time-out
(2) When retentive timers are assigned in the device setting of the PLC parameter
Retentive timer (ST): 224 points (ST0 to ST223)
X2 K600
0 ST195 Timer starts when
ST195 X2 is turned on
5 Y72 Cannot be cleared
X1 by turning off
7 RST ST195 Can be cleared by
turning on X1
App. - 20
Appendix 4.14 Switching timer set value externally
(1) With an external switch, a value to be set in one timer can be selected from
three patterns; 1sec., 10sec., and 100sec.
A timer is activated and reset with a push button switch.
OL
1sec. Indicates the timer
X0 Y70 is in operation.
SC 10sec. RL
X1 Indicates the timer
100sec. Y70 has gone time out.
X2
PB Starts timer
X3 Y70 MC Load
PB Resets timer
X4
X0
0 MOV K10 D0 Set value 1sec.
X1
3 MOV K100 D0 Set value 10sec.
X2
6 MOV K1000 D0 Set value 100sec.
X3
9 SET M0 Starts timer
X4
11 RST M0 Stops timer
M0 D0
12 T8
Y72
App. - 21
Appendix 4.15 Setting counters externally
With an external digital switch having 4 digits, a counter can be set remotely and
their current values are displayed in 4 digits. In addition to every count-up, the timer
outputs data when it reaches a value 100 short of the set value and a value 50 short
of the set value.
Note that a setting error is indicated if the set value of the counter is less than 100.
DC12V
AC100V
PB
Setting signal X0
Y70
PB RL Setting error
Start X5
Y71 ON during
PB RL
X1 operation
Reset or stop
Y72 Turns on 100
DC12V R1
Count pulse short of set value
X3 Current value display
BCD × 4 digits Y73 Turns on 50
R2
short of set value
DC24V
Y74 Turns on at
R3 counter stop
Setting value
Maximum setting value 9999
App. - 22
Project name QA-4
Program name MAIN
X0
0 SET M0 Setting
X1
2 RST M0
M0
4 BIN K4X20 D0 Reads set value
Y71
28 MC N0 M3
X3 D0
31 C0 Counter that turns on
at stop
D1
C1 Counter that turns on
100 short of set value
D2
C2 Counter that turns on
50 short of set value
44 MCR N0
X1
45 RST C0 Counter is reset by
turning on X1
RST C1
RST C2
M0
58 BCD C0 K4Y60 Displays counted
values to exterior
C1
62 Y72 Turns on at 100 before
C2 the set value
64 Y73 Turns on at 50 before
C0 set value
66 Y74 Turns on by count up
Note) In GX Works2, the on/off status of the master control is displayed in the title
tag on the monitor screen.
App. - 23
Appendix 4.16 Measuring operation time
Setting an operation time to a control target is useful for judging the timing of a
component replacement and lubrication. The timer ST and data register D must
have a backup power source so that they can continue operating at a power failure.
With the contents of D31 (in one hour units) displayed externally, the program can
work as an operation timer.
X2 K3600
0 ST250 6-minute timer
ST250
5 RST ST250
+ K1 D30
1-hour timer
= K10 D30 MOV K0 D30
+ K1 D31 Measures in
SM400 (always ON) 1 hour units
21 BCD D31 K4Y60 Outputs operation
time to exterior
25 <= K1000 D31 Y70 Indicates timing
to replace
Measuring the operation time of a control target (from its start to end) allows
displaying the cycle time-out and managing a control time lag.
The following ladder in which the <, >, and = instructions are used to determine the
state of T200 indicates a cycle time-out and measures a time lag with the counter.
X0 X1
0 M56 In cycle
M56
App. - 24
Complement
Appendix 4.18 Application example of (D) C M L (P)
The following explains how to obtain absolute values of negative values -32768 or
smaller (to -2147483648, 32 bit data).
D1 D0
B B B B B B B B
15 14 1 0 15 14 1 0
Before DCML 1 0 1 1 0 1 0 0 0 1 1 1 0 0 1 0
DCML D0 D20 execution (Negative number)
After DCML 0 1 0 0 1 0 1 1 1 0 0 0 1 1 0 1
execution
D21 D20
After D+ execution 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 0
(Absolute value)
(Example)
Every time X1 is turned on, 999 is subtracted from a set value and the result is
displayed.
When the result value is negative, the output Y70 turns on, and the absolute value of
the result is displayed.
Negative number NO
obtained?
YES
Y70 setting
DCML execution
+1 execution
Result display
X0
0 DBIN K4X20 D0 Inputs data
X1
4 D-P K999 D0 Subtracts 999
App. - 25
Appendix 4.19 Program showing divided value of 4-digit BIN value to 4 places of decimals
(1) Example 1
The program displays the operation result using a dividend and a divisor which
are individually specified in two 4-digit digital switches on two 4-digit displays
(integral part and decimal part).
Digital display
Digital switch
Y5F to Y50 Y4F to Y40
QCPU QX QY
42 42P
X3F to X30
X2F to X20
X0
Y48 to 4B
Y44 to 47
Y40 to 43
INC Z1
NO Last- Last- Last- Last-
4 obtained? 1st 2nd 3rd 4th
NEXT
digit digit digit digit
YES
END
App. - 26
Sequence program of example 1
The FOR-NEXT instruction is executed to divide each decimal place individually and
4 decimal places are displayed in K4Y40.
X0
0 BINP K4X30 D0 Reads data
BINP K4X20 D1
/P D0 D1 D2 Division
PLS M0
22 FOR K4
M0
24 * K4 Z1 D10
- H0C D10 Z0
* D3 K10 D3
Repeats for 4 times
/ D3 D1 D2
BCD D2 K1Y40Z0
INC Z1
45 NEXT
App. - 27
(2) Example 2
In example 2, D0 is divided by D1 to obtain D5 in 4 decimal places.
The dividend D0 is multiplied with 10000. The result of the dividing calculation
using this multiplied value is converted to a BCD value and output to an external
digital display.
K4Y60 K4Y50 K4Y40
X0
0 BINP K4X30 D0
BINP K4X20 D1
MOVP K0 D2 Clears D2
*P D0 K10000 D3 10000-fold
D/P D3 D1 D5
DBCDP D5 D5
DBCDP D7 D7
App. - 28
Appendix 4.20 Carriage line control
LS backward
limit (X3)
Push (Y73)
Carriage
Carriage moves
forward (Y71)
Operating panel
LS forward
limit (X2)
Operation Start button (X0)
indicator (Y70)
MELSEC-Q
Input Output
Start button
X0 Y70 Operation indicator
Switch (LS work present)
X1 Y71 M Carriage moves forward
Switch (LS forward limit)
X2 Y72 M Carriage moves back
Switch (LS backward limit)
X3 Y73 Push
Switch (LS open complete)
X4 Y74 Push back
App. - 29
Project name QA-10
Program name MAIN
X0 M2
0 Y70 Operation indicator
Y70 X1 X3
PLS M1
M1
SET Y71 Carriage moves forward.
Y71 X2
RST Y71
M2 Completion flag
Timing chart
Start button X0
Switch (LS work present) X1
Switch (LS forward limit) X2
Switch (LS backward limit) X3
Switch (LS open complete) X4
Operation indicator Y70
Carriage moves forward. Y71
Carriage moves back. Y72
Push Y73
Push back Y74
3sec
App. - 30
Appendix 4.21 Compressor sequential operation using ring counters
MELSEC-Q
Compressor A B C
Pressure switch
MELSEC-Q
Start Input Output
PB0 MC
X0 Y70 Compressor A
A
Stop
PB1
X1 MC
Y71 Compressor B
Pressure switch B
PX1
X2
MC
PX2 Y72 Compressor C
C
X3
PX3
X4 Y73 Sufficient pressure
App. - 31
Operation explanation
(1) The pressure switches (X2, X3, and X4) are initially off. In this state, turning on
the start switch (X0) activates the three compressors all together, and when
sufficient pressure is obtained (X2, X3, and X4 turn on), the three compressors
stop. This is the basic operation of this system.
If all the compressors are at stop with sufficient pressure or the pressure
shortage "Minor" is detected (X4 turns off), one compressor is activated to
supply pressure until sufficient pressure is obtained.
The compressor activated at this time activates in order from A to C each time
compressors are reactivated in reaction to pressure shortage.
Note that the stop switch (X1) is available for stopping compressors at any time.
(2) If one compressor does not supply sufficient pressure and the pressure
shortage level goes up to "Medium" (X3 turns off), the second compressor is
activated to support the first compressor. This second compressor will be
compressor C if compressor A has been in operation, A if B has been in
operation, and B if C has been in operation.
(3) If two compressors do not supply sufficient pressure and pressure shortage
level goes up to "Major" (X2 turns off), the last compressor is also activated.
When only one compressor is in operation and pressure shortage level goes
from "Minor" to "Major" directly, the rest two compressors are activated
simultaneously.
(4) When two or three compressors are in operation, they continue operating
together until sufficient pressure is obtained. Then they stop together when
sufficient pressure is obtained (X4 turns on).
Timing chart
Start - (X0)
PX3 - (X4)
Pressure switch PX2 - (X3)
PX1 - (X2)
A - (Y70)
Compressor B - (Y71)
C - (Y72)
Pressure shortage Major Minor Minor Medium Major Minor Minor Minor Medium
App. - 32
Project name QA-11
Program name MAIN
X0 X1
0 M0 During operation
M0
X4
4 Y73 Indicates pressure status
X4 X3 X4 Y76 Y75
6 Y74 Pressure shortage "Minor"
Y74 Pressure shortage "Minor" is indicated
when the pressure switch X4 turns off.
X3 X2 X4 Y76
13 Y75 Pressure shortage "Medium"
Y75 Pressure shortage "Medium" is indicated
when the pressure switch X3 (Medium) turns off.
X2 X4
19 Y76 Pressure shortage "Major"
Y76 Pressure shortage "Major" is indicated
when the pressure switch X2 (Minor) turns off.
M0
23 PLS M1 Turns on M9 at startup
Y74
26 PLS M2 Shifts by pressure
M1 shortage "Minor"
29 SET M9
M0
31 RST M9
RST M12
Resets when
RST M11 X1 (stop) turns on
RST M10
M2
36 SFT M13
SFT M12
Shift register
SFT M11
SFT M10
M10
45 RST M13
M0
M13
48 SET M10 Returns shift to M10
X4 M0 M10
50 Y70 Compressor A
Y75 M11
Y76
M11
Y71 Compressor B
Y75 M12
Y76
M12
Y72 Compressor C
Y75 M10
Y76
App. - 33
After the basic operation, one compressor is activated in reaction to pressure
shortage detected. To use the three compressors equally, they are activated
according to the set order. This control is enabled by the 3-stage ring counter
(ring-shaped shift registers) M10 to M12.
A shift signal is generated when pressure shortage is detected (X04 switches from
on to off).
Compressor
A B C
X4, (PX3)
OFF
Shift operation
X4
M10
M11
M12
App. - 34
Appendix 4.22 Application example of positioning control
Home position
Forward Reverse
Pulse rotation rotation Motor Brake
generator
Home
position MELSEC-Q
X2
Start Forward
rotation Reverse
X0 Y70
rotation
Y71 Brake
X1 Y72
Command value setting switch Current value display
5 4 0 0 3 6 2 8
mm mm
X20 to 23 Y4C to 4F
X1 X1000
X24 to 27 Y48 to 4B
X10 X100
X28 to 2B Y44 to 47
X100 X10
X2C to 2F Y40 to 43
X1000 X1
X0 M2
0 M0 During operation
M0
Y72 Releases brake
App. - 35
Appendix 4.23 Application example using index Z
(1) The number of manufactured products is counted every day in one month cycle,
and the resulting number is stored to the corresponding register of the date (D1
to D31).
(2) The planned number of products to be manufactured is inputted with the
external digital switch. Production stops when this number is accomplished.
(3) The date is also specified with the external digital switch.
(4) The accumulated number of products manufactured in the current month as
well as the number of manufactured products on the current day is displayed to
exterior.
K2X20 K2Y58
Date 3 0 3 0 Date display
X02 K4Y60
Count value 3 7 8 2 Accumulated number
Accumulated number
Date
App. - 36
Project name QA-7
Program name MAIN
RST C6
Clears all at end of month
FMOV K0 D0 K32
FMOV K0 K4Y40 K3
App. - 37
Appendix 4.24 Application example of FIFO instruction
Manual coating work and its working time can be stored and duplicated by
machinery later.
FIFO table
37 0
FIFO table 39 0
2) 22 150 42 150
Data is backed up when X03 is turned on 43
3) 23 120 120
Cleaning
time
4) 24 100 44 100
Backed up data is read 45
5) 25 20 when X05 is turned on 20
6) 26 135 46 135
Current value of T1 0
App. - 38
Operation pattern from manual to automatic operation
X00 = Manual right moving button Y70 = Conveyor, Moving right X20 = Coating bath-1 (K2X20 = K1)
X01 = Manual left moving button Y71 = Conveyor, Moving left X21 = Coating bath-2 (K2X20 = K2)
X02 = Manual cleaning button Y72 = Conveyor, Cleaning X22 = Coating bath-3 (K2X20 = K4)
X03 = Recording data button X23 = Coating bath-4 (K2X20 = K8)
X05 = Reading data button X24 = Coating bath-5 (K2X20 = K16)
X06 = Automatic operation button X25 = Coating bath-6 (K2X20 = K32)
X07 = Operation stop button
Y73 = Automatic operation
indication LED
A
The same operation is repeated from (A).
App. - 39
Project name QA-9
Program name MAIN
SM403
0 FMOV K0 D0 K50 Resets data to 0 only once at RUN
X6 X7 M2 SM403
5 > D10 K0 Y73 Outputs to automatic operation indication LED
(Automatic operation mode is also indicated.)
Y73
Y73 T0
14 PLS M1 FIF0 reading pulse in automatic operation
M1
>= KO D10 M2 Finishes automatic operation
18
if data is not present
M1 M2
FIFRP K2Y74 D10 Reads position data of coating bath
23
if data is present
M3 T0 Y73 K10
Completes the movement and
51 = K2Y74 K2X20 T2 starts cleaning (preventing chattering)
T2 T2 D1
T0 Auto-cleaning timer
X0 X1 Y73 Y71
67 Y70 Moves conveyor to right
M4
X1 X0 Y73 Y70
73 Y71 Moves conveyor to left
M5
X2 Y73 SM403
79 > K2X20 KO M6 In auto-cleaning
M6
T2
87 Y72 Cleaning from conveyor
M6
M6 K3200
90 T1 Measures manual cleaning time
125 END
App. - 40
Appendix 4.25 Application example of data shift
Works are conveyed along with their code numbers, and the data register of the
processing machinery is analyzed to machine the work according to its code
number.
X0
Start During
X1 operation
Stop Y70
Input Output
Code number K1X20 module module
1 to 8 Type detection
X2
Shift
Movement of work
instruction
Data
Machinery register Code 1 Code 2 Code 3 Code 4 Code 5 Code 6 Code 7 Code 8
A D30 M1 M2 M3 M4 M5 M6 M7 M8
B D31 M11 M12 M13 M14 M15 M16 M17 M18
C D32 M21 M22 M23 M24 M25 M26 M27 M28
D D33 M31 M32 M33 M34 M35 M36 M37 M38
E D34 M41 M42 M43 M44 M45 M46 M47 M48
F D35 M51 M52 M53 M54 M55 M56 M57 M58
A code number is stored in the data register, and M corresponding to the stored
number is activated to machine the work.
Machinery A Machinery B Machinery C Machinery D Machinery E Machinery F
App. - 41
Project name QA-12
Program name MAIN
X0 X1
0 Y70 During operation
Y70
= K2 D30 M2
= K3 D30 M3
= K4 D30 M4
Machinery A
= K5 D30 M5
= K6 D30 M6
= K7 D30 M7
= K8 D30 M8
Y70
53 = K1 D31 M11
= K2 D31 M12
= K3 D31 M13
= K4 D31 M14
Machinery B
= K5 D31 M15
= K6 D31 M16
= K7 D31 M17
= K8 D31 M18
Y70
94 = K1 D32 M21
= K2 D32 M22
= K3 D32 M23
= K4 D32 M24
Machinery C
= K5 D32 M25
= K6 D32 M26
= K7 D32 M27
= K8 D32 M28
App. - 42
Y70
135 = K1 D33 M31
= K2 D33 M32
= K3 D33 M33
= K4 D33 M34
Machinery D
= K5 D33 M35
= K6 D33 M36
= K7 D33 M37
= K8 D33 M38
Y70
176 = K1 D34 M41
= K2 D34 M42
= K3 D34 M43
= K4 D34 M44
Machinery E
= K5 D34 M45
= K6 D34 M46
= K7 D34 M47
= K8 D34 M48
Y70
217 = K1 D35 M51
= K2 D35 M52
= K3 D35 M53
= K4 D35 M54
Machinery F
= K5 D35 M55
= K6 D35 M56
= K7 D35 M57
= K8 D35 M58
App. - 43
Project name QA-14
Program name MAIN
The data stored in D5 is calculated to its square root and the result is stored in D6
and D7.
X0
0 MOVP K4X20 D5 Sets data
Square root
BSQR D5 D6 operation
MOVP D7 K4Y50 Square root
(integral part)
MOVP D6 K4Y60 Square root
(decimal part)
Integral part Decimal part A value in 5th decimal digit is rounded off.
D5 D6 D7 Therefore, a value in 4th decimal place
= has error of ±1.
0 to 9999 0 to 9999 0 to 9999
(BCD value) (BCD value) (BCD value)
REMARK
QCPUs provide square root operation instructions for data in a real number
(floating point) format.
App. - 44
Project name QA-15
Program name MAIN
A value stored in D10 is calculated to its n-th power ("n" is a value stored in D14)
and the result is stored in D10.
X1
0 FMOVP K0 D10 K10 Clears data
SCJ P0
X1
18 CJ P0
21 FOR D14
X1 Multiplies value
23 D* D10 D15 D10
n times
28 NEXT
P0 X1
29 D/ D10 K10000 D16
BCD-outputs value
DBCD D16 K6Y50
in 10 digits to exterior
DBCD D18 K4Y40
NOTE
An operation error occurs if a value in D10 exceeds 2147483647.
App. - 45
Appendix 4.28 Program using digital switch to import data
When a set value of the digital switch is always input and stored to D10 of the
programmable controller
1 2 3 4
X20 Data
to register
X2F Converted into BIN D10
In the above program, changing a value of the digital switch while the programmable
controller is in RUN may cause codes other than 0 to 9 depending on the timing of
the change, which may cause an operation error of the CPU.
To avoid this, write a program as follows.
4 FOR K8
+ K4 Z0
31 NEXT
SM400
32 DBIN K8M100 D10
App. - 46
Appendix 4.29 Displaying number of faults and fault numbers using fault detection program
The following program sequentially displays the number of turned-on bit devices
(such as X, M, and F) among many bit devices being used continuously, together
with their device numbers.
[Application example]
When M or F is used as an output device of a fault detection program, use the
following program to obtain a certain fault number from the faults.
Device F is used in
Fault detection ladder
the program example.
X2 ON OFF
Display B Display A
(Y60 to Y6F)
X0 ON OFF
Displays the fault
Displaying the first number on display C.
fault number
Condition of program
X1 ON OFF
Displaying the number of
remaining faulty devices
including currently Displays the number of remaining
displayed number and faulty devices on display A.
the next fault number Displays the next fault number on display C.
App. - 47
Project name QA-31
Program name MAIN
X20
0 F3
X24
4 F5
X28
8 F8
X2C
12 F13
X30
16 F33
X34
20 F35
X38 Faulty circuit
24 F37
X3C
28 F39
X4
32 F1
X5
36 F11
X6
40 F16
X7
44 F40
X2 M200
48 DSUMP K8F1 D0
+P D0 D10
SET M400
RST M700
X000 M200 M400
73 PLS M500
SET M700
M500
80 SET M200
RST M600
Specifies start number
MOV K0 Z0 of faulty circuit
(F1 to 0)
DMOV K8F1 D0
M600
95 DMOVP K8F33 D0
App. - 48
M100 M200
103 DROR D0 K1
Searches for ON
SM700
SET M100 devices shifting
32-bit data to right
INC Z0
BCD Z0 K4Y60
X1 M700
120 PLS M300
M300
125 RST M100 Searches for
K0 D10 - K1 D10 next ON devices
<
DSUMP K8F1 D0
DSUMP K8F33 D0
32 bits
F F F F F F
3231 4 3 2 1
S before
execution (K8F1) 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1
B15 B0
A0 after
execution 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
Turning on X2 stores the number of turned-on bits among F1 to F64 to D10 and
display it.
App. - 49
F F Transferred by the MOVP instruction
16 1
D0 D10
1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1
16 16
1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1
F F
32 17
F F
48 33
D0
0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1 Added by a
7
+P instruction
0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0
F F F
64 50 49
D10
Number of ON inputs among X20 to 5B 23
F F F F F F
DMOV K8F1 D0 32 31 3 2 1 0
1 1 0 0 1
DMOV K8F33 D0
32 bits
DMOV instruction
D1,D0 1 1 1 0 0 0 1
D1 D0
(16 bits) (16 bits)
DROR D0 K1
D1 D0
Contents of To B31
B0 before Carry flag
execution (SM700)
After 1 1 1 1 0 0 0 1 1 1 0 1 1 1 0 0 1
execution
To B31
(a) Turning on X0 sets the above shift data (D0 and D1). After that, the data is
shifted right by 1 bit at each scan until a turned-on bit is detected.
When a turned-on bit is detected, shifting stops in that scan (SM700 turns
on), and the accumulated number of shifts (equivalent to a device number)
is displayed.
(b) Each time X1 is turned on, the next turned-on bit is detected and the
detected device number is displayed. At the same time, 1 is subtracted
from the number of turned-on bits which have been obtained in advance to
display the remaining number of turned-on bits.
App. - 50
Appendix 5 Memory and File to be Handled by CPU Module
Memory
CPU module built-in memory Memory card (ROM)
card (RAM)
File name and
Item Program Standard Standard Remarks
SRAM card Flash card ATA card extension
memory RAM ROM
*1 *1 *1 *1 *1
Drive 0 Drive 3 Drive 4 Drive 1 Drive 2
Parameter PARAM.QPA 1 data/drive
Intelligent function
module IPARAM.QPA 1 data/drive
*2
parameter
Program *3 *4 *4 *4 ***.QPG -
Device comment *5 *6 *6 *6 *6 ***.QCD -
Device initial value ***.QDI -
Device data ***.QST -
File register *7*8 *9 ***.QDR -
*7 1 data/CPU
Local device ***.QDL
module
Sampling trace file *7 ***.QTD -
Error history data ***.QFD -
Device data DEVSTORE.
storage file QST -
Module error IERRLOG.
collection file QIE -
MEMBKUP0.
Backup data file -
QBP
Programmable
controller user *10
***.*** -
data
User setting
*11 - -
system area
: Required, : Storable, : Not storable
*1: A drive number is used to specify a memory to be written/read by the external device using a sequence program or MC protocol.
Since the memory name is used to specify the target memory in GX Works2, the drive number needs not to be considered.
*2: Store the intelligent function module parameters in the same drive with the parameters.
When they are stored in different drives, the intelligent function module parameters do not become valid.
*3: A program stored in the standard ROM cannot be executed.
Store the program to the program memory before execution.
*4: To execute a program stored in the memory card, make the setting in the Boot File tab of the Q Parameter Setting window.
*5: The device comments cannot be read by instructions in a sequence program.
*6: Reading from a sequence program requires several scans.
*7: Only each one of file register, one local device, and sampling trace file can be stored in the standard RAM.
*8: For the number of storable file registers, refer to QnUCPU User's Manual Function Explanation, Program Fundamentals.
*9: A sequence program allows reading only. No data can be written from the sequence program.
*10: Data can be written or read with the following instructions.
• SP.FREAD (batch-reads data from the specified file in the memory card.)
• SP.FWRITE (batch-writes data to the specified file in the memory card.)
*11: Set an area used by the system.
App. - 51
Memory capacities and necessity of formatting
The following tables list the memory capacities and necessity of formatting
of each memory.
Q00UJCPU Q00UCPU Q01UCPU Q02UCPU Q03UD(E)CPU Formatting
10K steps 15K steps 20K steps 30K steps
Program memory *1
(40K byte) (60K byte) (80K byte) (120K byte)
Standard ROM 256K byte 512K byte 1024K byte Unnecessary
Standard RAM - 128K byte 192K byte *1
Q2MEM-1MBS: 1M byte
SRAM Q2MEM-2MBS: 2M byte Necessary (use
-
card Q3MEM-4MBS: 4M byte GX Works2.)
Q3MEM-8MBS: 8M byte
Flash Q2MEM-2MBF: 2M byte
- Unnecessary
Memory card Q2MEM-4MBF: 4M byte
card
Q2MEM-8MBA: 8M byte
ATA Necessary (use
- Q2MEM-16MBA: 16M byte
card GX Works2.)
Q2MEM-32MBA: 32M byte
*1: When the memory contents become indefinite in the initial status or due to the end of battery life, the memory is automatically formatted after the
programmable controller is powered off and then on or is reset. Make sure to format the memory in GX Works2 before using.
App. - 52
Appendix 6. Comparison with GX Developer (changes)
Programmable controller
Programmable controller type
series
QCPU (Q mode) High Performance model QCPU
(Q02, Q02H, Q06H, Q12H, Q25H)
Universal model QCPU
(Q00UJ, Q00U, Q01U, Q02U, Q03UD, Q03UDE,
Q04UDH, Q04UDEH, Q06UDH, Q06UDEH, Q10UDH,
Q10UDEH, Q13UDH, Q13UDEH, Q20UDH, Q20UDEH,
Q26UDH, Q26UDEH, Q50UDEH, Q100UDEH)
The following table lists the CPU modules that are not supported in GX Works2.
Use GX Developer for the following CPU modules.
Programmable controller
Programmable controller type
series
QCPU (Q mode) Basic model QCPU (Q00J, Q00, Q01)
Process CPU (Q02PH, Q06PH, Q12PH, Q25PH)
Redundant CPU (Q12PRH, Q25PRH)
Remote I/O master (QJ71LP21, QJ71BR11)
QCPU (motion) All programmable controller types
QCPU (A mode) All programmable controller types
QSCPU All programmable controller types
QnACPU All programmable controller types
ACPU All programmable controller types
Motion controller (SCPU) All programmable controller types
CNC (M6, M7) All programmable controller types
App. - 53
(2) Unsupported features
The following table lists the features that are not supported in GX Works2.
Use GX Developer, GX Simulator, or GX Configurator for the following features.
App. - 54
(3) Supported project types
The following table lists the project types that are supported in GX Works2.
1) When a project created in "Use label" with ST of GX Developer is read with GX Works2,
the project becomes "Structured Project"
2) The projects created in "Structured Project" of GX Works2 cannot be read with GX
Developer.
App. - 55
(4) Programming languages supported by each project type
The following table lists the programming languages that are supported by each
project type of GX Works2.
App. - 56
(b) Using SFC (MELSAP3) language
Before using the SFC (MELSAP3) language in GX Works2, review the
following precautions.
* Changing the "Setting of Zoom Display" option can switch the display in a window in the
same way as GX Developer.
App. - 57
(d) Using function blocks
Before using function blocks in GX Works2, review the following
precautions.
Function Description
Use function blocks created with Function blocks created with ladder can be used for ladder program, ST program,
ladder and SFC program operation outputs.
* When using function blocks created with ladder for ST programs, select [Tool] →
[Options] → [Compile] → [Basic Setting] → "Enable function block call 'from
ladder to Structured Ladder/FBD' and 'from Structured Ladder/FBD or ST to
ladder".
Use function blocks created with Function blocks created with structured ladder can be used for ladder programs,
structured ladder structured ladder programs and ST programs.
Use function blocks created with Function blocks created with ST can be used for ladder programs, structured
ST ladder programs, and ST programs.
* When using function blocks created with ST for ladder programs, select [Tool] →
[Options] → [Compile] → [Basic Setting] → "Enable function block call 'from
ladder to Structured Ladder/FBD' and 'from Structured Ladder/FBD or ST to
ladder".
When the option "Enable function When the VAR_IN_OUT input variable and output variable have different
block call 'from ladder to label/device, the input variable value is always equal to the output variable value.
Structured Ladder/FBD' and
'from Structured Ladder/FBD or
ST to ladder" is set
Function Description
Device memory display Multiple device ranges can be displayed in a window.
* By selecting "All Range" when devices are input, all the device ranges can be displayed
in a window in the same way as that of GX Developer.
Copy and past device To copy and paste device memory data to Excel, select [Tool] → [Read from Excel
memory data to Excel File]/[Write to Excel File].
App. - 58
(7) Using device initial values
Before using device initial values in GX Works2, review the following
precautions.
Function Description
Read from PLC Symbolic information in GX Developer format does not include SFC programs. Read
symbolic information on "Simple project (without labels)".
If symbolic information of GX Developer or GX IEC Developer is read out, the project
becomes uncompiled.
App. - 59
(9) Using monitor/debug function
Before using the monitor/debug function in GX Works2, review the following
precautions.
Function Description
Entry device monitor The "entry device monitor" function is now a docking window as a "watch" function so that it
can be displayed without overlapping with the program editor.
Device/label is now enabled to be entered by dragging and dropping from the program
editor and the on/off status of bit devices and current values of word devices can be
modified on the monitor window.
Device batch The "device batch monitoring" and "buffer memory batch monitoring" functions are now
monitoring integrated to realize the same operability.
Buffer batch monitoring The on/off status of bit devices and current values of word devices can be modified on the
monitor window.
Monitor and test To use the monitoring or test function to FL-net (OPCN-2) interface unit and AS-i master
intelligent function unit, execute the "watch" and "Device/Buffer memory batch monitor" function.
modules
App. - 60
(13) Compatibility with GX IEC Developer
For the compatibility between GX IEC Developer and GX Works2, review the
following precautions.
Function Description
Open projects in other Function names of ST language are different between GX IEC Developer and GX
formats Works2.
Compile the program and correct errors.
User library Before using GX IEC Developer user libraries which a password is set to, cancel the
password in GX IEC Developer.
Convert (all programs being edited) Converts all programs being edited. Ctrl + Alt + F4 -
Switch between the project data list Switches between the project data list
Alt + 7 -
and window and each window.
Switches between the ladder window
Switch between ladder and list Alt + F1 -
and list window.
Monitors ladders of all the opened
Monitor (all the windows) Ctrl + F3 -
programs.
Monitor
*1: In GX Works2, switching the ladder editor to the read mode/write mode is
unnecessary. The ladder can be edited any time.
*2: In GX Works2, switching the ladder editor to the monitor (write mode) during the
ladder monitoring is unnecessary.
Even during the ladder monitoring, the ladder can be edited and written to the
programmable controller in the RUN status.
App. - 61
Appendix 7 Customizing Shortcut Keys
Screen display
Select [Tool] → [Key Customize].
Item Description
Shortcut Key -
Category Select a category from the group list categorized by window.
Command Select a function name whose shortcut key is to be changed.
Current Key Displays the shortcut key assigned to the selected command.
Specify a new shortcut key to be assigned. Pressing a key(s) on the
Press the keys to assign keyboard assigns the key(s).
Example)
Displays the menu name to which the entered shortcut key is assigned.
Current When the key is already assigned to another function, the function name is
displayed.
Select a template of shortcut keys from the list box.
• Default Setting
The default setting is set.
Template
• GPPA Format Setting
The shortcut key setting at ladder programming is changed to the same
setting as that at GPPA.
App. - 62
Screen button
Assigns the shortcut key. The assigned shortcut key is displayed in "Current Key".
App. - 63
Appendix 8 Indexing
In the Universal model QCPU (excludes Q00UJCPU), expanding the index register
to 32 bits enables the indexing for all the file register areas.
Serial number access SM400
format file register DM0V K1042431 Z0
Conventional area
ZR0
to which indexing
can be used
To index the serial number access format file
ZR32767 register (ZR) with 32-bit, use the index register (Z).
ZR32768
ZR4184063
A method for specifying index registers for 32-bit indexing can be selected from
following two methods.
(1) When specifying the index range used for 32-bit indexing
(a) Each index register can be set between -2147483648 and 2147483647.
The following shows an example of indexing.
X0
DMOV K40000 Z0 Stores 40000 in Z0.
X0
Stores the data of
MOV ZR10Z0 D0
ZR10Z0 = ZR{10+40000}
= ZR40010 in D0.
Indexing
POINT
When the start number of the index register used is changed on the Device tab
of the PLC parameter setting screen, do not change the parameters only or do
not write only the parameters into the programmable controller. Be sure to write
the parameters into the programmable controller with the program.
When the parameter is forced to be written into the programmable controller,
an error of CAN'T EXE. PRG. occurs. (Error code: 2500)
App. - 64
(c) Device for which indexing can be used
Indexing can be used only for the devices shown below.
• ZR: Serial number access format file register
• D: Extended data register
• W: Extended link register
Setting value Index registers to be used Setting value Index registers to be used
Z0 Z0, Z1 Z10 Z10, Z11
Z1 Z1, Z2 Z11 Z11, Z12
Z2 Z2, Z3 Z12 Z12, Z13
Z3 Z3, Z4 Z13 Z13, Z14
Z4 Z4, Z5 Z14 Z14, Z15
Z5 Z5, Z6 Z15 Z15, Z16
Z6 Z6, Z7 Z16 Z16, Z17
Z7 Z7, Z8 Z17 Z17, Z18
Z8 Z8, Z9 Z18 Z18, Z19
Z9 Z9, Z10 Z19 Cannot be specified.
(e) The following shows an example of indexing and the actual process device.
(When Z0 (32-bit) is 100000 and Z2 (16-bit) is -20)
X0
DMOV K100000 Z0 X1
MOV ZR101000 D10
MOV K-20 Z2
Description
X1 ZR1000Z0 ZR(1000+100000)=ZR101000
MOV ZR1000Z0 D30Z2 D30Z2 D(30-20)=D10
App. - 65
(2) When specifying the 32-bit indexing using "ZZ" specification
(a) One index register can specify 32-bit indexing using "ZZ" specification such
as "ZR0ZZ4".
The following shows the 32-bit indexing with "ZZ" specification.
M0
DMOVP K100000 Z4 Stores 100000 at Z4 and Z5.
"ZZ" "ZZ"
Index registers to be used Index registers to be used
specification* specification*
□ZZ0 Z0, Z1 □ZZ10 Z10, Z11
□ZZ1 Z1, Z2 □ZZ11 Z11, Z12
□ZZ2 Z2, Z3 □ZZ12 Z12, Z13
□ZZ3 Z3, Z4 □ZZ13 Z13, Z14
□ZZ4 Z4, Z5 □ZZ14 Z14, Z15
□ZZ5 Z5, Z6 □ZZ15 Z15, Z16
□ZZ6 Z6, Z7 □ZZ16 Z16, Z17
□ZZ7 Z7, Z8 □ZZ17 Z17, Z18
□ZZ8 Z8, Z9 □ZZ18 Z18, Z19
□ZZ9 Z9, Z10 □ZZ19 Cannot be specified.
App. - 66
(e) The following shows an example of the 32-bit indexing with "ZZ"
specification and the actual processing device.
(When Z0 (32-bit) is 100000 and Z2 (16-bit) is -20)
POINT
For details, refer to the QnUCPU User's Manual Function Explanation, Program
Fundamentals and MELSEC-Q/L Programming Manual (Common Instruction).
App. - 67
Appendix 9 FB
Appendix 9.1 FB
FB is an abbreviation for a Function Block that is designed to convert a ladder block,
which is used repeatedly in a sequence program, into a component (FB) to be
utilized in a sequence program.
This not only increases the efficiency of program development but also reduces
programming mistakes to improve program quality.
Converted into FB
a component
X1
Count_Num1
Y12
i_Count o_C_UP
Count_Num
i_Count o_C_UP
Count process 2
X2
Count_Num2
Y22
i_Count o_C_UP
App. - 68
Appendix 9.1.2 Advantages of using FBs
App. - 69
(3) Reusing
Converting a standard program into a component allows the program to be
reused any number of times.
As a result, operations such as copying a sequence program and modifying a
device, which have often been required in the past, will be unnecessary.
Converted FB for
into a component start control
Common
FB
Developer A Developer B
App. - 70
(5) Protecting assets
By setting up a block password, the created FB can be protected so that it
cannot be viewed.
CC-Link
Ethernet
App. - 71
<Example of partner product>
CC-Link
Ethernet
URL http://www.mitsubishielectric.co.jp/fa/index.html
For the procedure to obtain the FB libraries, refer to App. 9.2.2 "Preparations
prior to use of FB libraries".
App. - 72
Appendix 9.1.4 Development tool
POINT
The following specifications and precautions must be understood prior to using FBs.
App. - 73
Appendix 9.2 Creating a program by using an FB library
Example) Reading an analog value to D10 from the analog input module (Q64AD)
when the switch (X2) is turned on.
Execution
command
Analog value
is input.
POINT
The FB created by a user is also available other than the FB in the FB library.
For the creation method of a new FB, refer to "MELSOFT GX Works2 FB Quick
Start Guide".
App. - 74
Appendix 9.2.2 Preparations prior to use of FB libraries
The following explains operation procedures using the FB library for Q64AD as an
example.
1) As the file obtained from your distributor is a zip format file, unzip
"q64ad_v100a.zip".
Double-click!
3) The screen for installation is displayed. Follow the instructions to complete the
installation.
4) The following dialog is displayed when the installation is completed. Click the
OK button to close the dialog.
Click!
App. - 75
Appendix 9.2.3 Importing an FB library to projects
This section explains how to import an FB library for analog input module (Q64AD)
to be pasted to the program into a project.
Create a new project before the following operation.
(refer to section 2.3.2)
1) Click!
5) Check!
4) Click the Refresh FB List button.
7) The imported FBs are displayed under FB_Pool in the Project view and displayed in the Selection
window.
App. - 76
Appendix 9.2.4 Pasting FBs
Drag and drop FBs to be pasted to the program window from the Project view or
Selection window. (Drag and drop from the Project view is possible from GX Works2
1.24A or later.)
Operating Procedure
1) Paste "M+Q64AD_ReadADVal" to the program window.
Selection window
Project window
App. - 77
Appendix 9.2.5 Setting names of the pasted FBs
When an FB library is pasted to the program window, a dialog to input a name of the
pasted FB (FB instance name) is displayed.
A temporary name is automatically set to the instance name. To use the name as it
is, close the dialog by clicking OK .
Make sure that the same name does not exist in the same program when changing
the name.
Operating Procedure
1) Enter the FB instance name ("ReadADVal_1" in the example) and click the
OK button.
Click
POINT
App. - 78
Appendix 9.2.6 Creating input and output ladders
Create the input ladder section and the output ladder section of the pasted FB to
complete the program.
Refer to the following figure and enter the information.
1) Click!
2) Click!
3) Display!
App. - 79
Appendix 9.2.8 Writing sequence programs
For the procedure to write sequence programs, refer to section 2.7 (1) "Writing data
to the CPU".
For the procedure to check the operation of the created program, refer to section 2.8
Monitoring Ladder Program Status.
Turn on the switch (X2) and confirm that the analog value is read.
App. - 80
SH-081123ENG-A