Mitsubishi | Q62DAN | Specifications | Mitsubishi Q62DAN Specifications

SAFETY PRECAUTION
(Always read these instructions before using the products.)
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.
Do not touch the movable portion.
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.
Turn off the power before installing or removing the module.
Failure to do so may result in malfunctions of the module or electric shock.
When the demonstration machine (such as X/Y table) emits abnormal odor/sound, press "Power
switch" or "Emergency switch" to turn off.
When a problem occurs, notify the instructor as soon as possible.
REVISIONS
*The textbook number is written at the bottom left of the back cover.
Print date
*Textbook number
Revision
Oct., 2012 SH-081123ENG-A First edition
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.
© 2012 MITSUBISHI ELECTRIC CORPORATION
CONTENTS
CHAPTER 1
1.1
1.2
1.3
1.4
1.5
BASICS OF PROGRAMMABLE CONTROLLER
1- 1 to 1-14
Program··········································································································································· 1- 1
Program Processing Procedure ······································································································ 1- 4
MELSEC-QnUD Module Configuration ··························································································· 1- 5
External I/O Signal and I/O Number······························································································· 1-11
System Configuration and I/O Number of Demonstration Machine··············································· 1-14
CHAPTER 2
OPERATING GX Works2
2- 1 to 2-64
2.1 Features of GX Works2··················································································································· 2- 3
2.1.1 MELSOFT iQ Works················································································································· 2- 7
2.2 Basic Knowledge Required for Operating GX Works2 ··································································· 2- 9
2.2.1 Screen configuration in GX Works2 ························································································· 2- 9
2.2.2 Ladder editor···························································································································· 2-11
2.2.3 Project······································································································································ 2-20
2.3 Operation Before Creating Ladder Program ·················································································· 2-22
2.3.1 Starting up GX Works2············································································································ 2-22
2.3.2 Creating a new project············································································································· 2-23
2.4 Preparation for Starting Up CPU···································································································· 2-25
2.5 Creating Ladder Program··············································································································· 2-32
2.5.1 Creating a ladder program using the function keys································································· 2-32
2.5.2 Creating a ladder program using the tool buttons ··································································· 2-34
2.6 Converting Program (Ladder Conversion) ····················································································· 2-36
2.7 Writing/Reading Data to/from Programmable Controller CPU······················································· 2-37
2.8 Monitoring Ladder Program Status ································································································ 2-40
2.9 Diagnosing Programmable Controller CPU ··················································································· 2-43
2.10 Editing Ladder Program ··············································································································· 2-45
2.10.1 Modifying a part of the ladder program ················································································· 2-45
2.10.2 Drawing/deleting lines ··········································································································· 2-47
2.10.3 Inserting/deleting rows··········································································································· 2-50
2.10.4 Cutting/copying ladder program ···························································································· 2-55
2.11 Verifying Data······························································································································· 2-58
2.12 Saving Ladder Program ··············································································································· 2-59
2.12.1 Saving newly-created or overwritten projects ······································································· 2-59
2.12.2 Saving a project with another name ······················································································ 2-60
2.13 Reading the saved project ··········································································································· 2-61
2.14 Opening Projects in Different Format··························································································· 2-62
2.15 Saving Projects in Different Format ····························································································· 2-63
CHAPTER 3
DEVICE AND PARAMETER OF PROGRAMMABLE CONTROLLER
3- 1 to 3- 6
3.1 Device·············································································································································· 3- 1
3.2 Parameter········································································································································ 3- 3
(1)
CHAPTER 4
SEQUENCE AND BASIC INSTRUCTIONS -PART 1-
4- 1 to 4-42
4.1 List of Instruction Explained in this Chapter ···················································································· 4- 1
4.2 Differences between OUT and SET / RST ································································ 4- 4
4.3 Measuring Timer ····························································································································· 4- 5
4.4 Counting by Counter ······················································································································· 4- 6
4.5
PLS / PLF
·························································································································· 4-14
4.6
MC / MCR ·························································································································· 4-20
4.7
FEND / CJ / SCJ / CALL / RET ············································································ 4-24
4.7.1
FEND ······························································································································· 4-24
4.7.2
CJ / SCJ
·················································································································· 4-27
········································································································ 4-31
4.7.3
CALL(P) / RET
4.8 Exercise·········································································································································· 4-35
Project name
QTEST 1
4.8.1 Exercise 1 LD to NOP···········································································································
4-35
4.8.2 Exercise 2 SET, RST ············································································································
4-36
Project name
QTEST2
4.8.3 Exercise 3 PLS, PLF·············································································································
4-38
Project name
QTEST3
4.8.4 Exercise 4 CJ, CALL, RET, FEND························································································
4-39
Project name
QTEST4
CHAPTER 5
BASIC INSTRUCTION -PART 2-
5- 1 to 5-58
5.1 Notation of Values (Data) ················································································································ 5- 1
5.2 Transfer Instruction ························································································································· 5- 9
5.2.1
MOV (P)
··························································································································· 5- 9
5.2.2
BIN (P) ····························································································································· 5-16
5.2.3
BCD (P)
··························································································································· 5-18
5.2.4 Example of specifying digit for bit devices and transferring data ············································ 5-21
5.2.5
FMOV (P) / BMOV (P)
································································································ 5-22
5.3 Comparison Operation Instruction ································································································· 5-27
5.4 Arithmetic Operation Instruction····································································································· 5-32
5.4.1
+(P) / -(P)
···················································································································· 5-32
5.4.2
* (P) / / (P)
··················································································································· 5-36
5.4.3 32-bit data instructions and their necessity ············································································· 5-41
5.4.4 Calculation examples for multiplication and division including decimal points ······················· 5-43
5.5 Index Register and File Register···································································································· 5-44
5.5.1 How to use index register Z····································································································· 5-44
5.5.2 How to use file register R ········································································································ 5-46
5.6 External Setting of Timer/Counter Set Value and External Display of Current Value ··················· 5-49
5.7 Exercise·········································································································································· 5-51
5.7.1 Exercise 1 MOV ····················································································································
5-51
Project name
QTEST5
5.7.2 Exercise 2 BIN and BCD conversion ····················································································
5-52
Project name
QTEST6
5.7.3 Exercise 3 FMOV··················································································································
5-53
Project name
QTEST7
5.7.4 Exercise 4 Comparison instruction ·······················································································
5-54
Project name
QTEST8
5.7.5 Exercise 5 Addition and subtraction instructions ··································································
5-55
Project name
QTEST9
5.7.6 Exercise 6 Multiplication and division instructions································································
5-56
Project name
QTEST10
5.7.7 Exercise 7 D-multiplication and D-division ···········································································
5-57
Project name
QTEST11
(2)
CHAPTER 6
HOW TO USE OTHER FUNCTIONS
6- 1 to 6-36
6.1 Test Function at Online ··················································································································· 6- 1
6.1.1 Turning on and off the device "Y" forcibly ················································································ 6- 2
6.1.2 Setting and resetting the device "M"························································································· 6- 4
6.1.3 Changing the current value of the device "T" ··········································································· 6- 5
6.1.4 Reading error steps ·················································································································· 6- 6
6.1.5 Remote STOP and RUN ·········································································································· 6- 7
6.2 Forced I/O Assignment by Parameter Settings··············································································· 6- 8
6.3 How to Use Retentive Timers ········································································································ 6-10
6.4 Device Batch Replacement············································································································ 6-12
6.4.1 Batch replacement of device numbers ··················································································· 6- 12
6.4.2 Batch change of specified devices between normally open contacts
and normally closed contacts································································································· 6- 13
6.5 Online Program Change ················································································································ 6-14
6.6 Registering Devices ······················································································································· 6-15
6.7 How to Create Comments ·············································································································· 6-16
6.8 Setting Security for Projects ··········································································································· 6-23
6.8.1 Setting and resetting security for projects ··············································································· 6-24
6.8.2 Managing (adding, deleting, and changing) users ·································································· 6-25
6.8.3 Logging in projects ·················································································································· 6-29
6.8.4 Changing access authority for each access level ··································································· 6-30
6.9 Sampling Trace Function ··············································································································· 6-31
CHAPTER 7
PROGRAMMING INTELLIGENT FUNCTION MODULE
7- 1 to 7-26
7.1 Intelligent Function Module ············································································································· 7- 1
7.2 Data Communication between Intelligent Function Modules and CPUs ········································ 7- 2
7.2.1 I/O signals to CPUs ·················································································································· 7- 3
7.2.2 Data communication with intelligent function modules····························································· 7- 4
7.3 Communication with Intelligent Function Module············································································ 7- 5
7.3.1 Communication methods with intelligent function modules······················································ 7- 5
7.4 Intelligent Function Module System in Demonstration Machine ····················································· 7- 6
7.5 Q64AD Analog/Digital Converter Module ······················································································· 7- 7
7.5.1 Names of parts ························································································································· 7- 7
7.5.2 A/D conversion characteristics ································································································· 7- 8
7.5.3 List of I/O signals and buffer memory assignment ··································································· 7- 9
7.5.4 Adding or setting intelligent function module data··································································· 7-12
7.5.5 Exercise with the demonstration machine··············································································· 7-16
7.6 Q62DAN Digital/Analog Converter Module···················································································· 7-17
7.6.1 Names of parts ························································································································ 7-17
7.6.2 D/A conversion characteristics ································································································ 7-18
7.6.3 List of I/O signals and buffer memory assignment ·································································· 7-19
7.6.4 Adding or setting intelligent function module data··································································· 7-21
7.6.5 Exercise with the demonstration machine··············································································· 7-25
(3)
CHAPTER 8
SIMULATION FUNCTION
8- 1 to 8- 4
8.1 Simulation Function························································································································· 8- 1
8.2 Starting/Stopping Simulation ··········································································································· 8- 1
8.3 Debugging with Example Program·································································································· 8- 2
8.3.1 Monitoring and testing device status ························································································ 8- 3
CHAPTER 9
9.1
9.2
9.3
9.4
9.5
9.6
MAINTENANCE
9- 1 to 9- 8
Typical Trouble································································································································ 9- 1
Maintenance···································································································································· 9- 2
Consumable Product······················································································································· 9- 3
Service Life of Output Relay············································································································ 9- 4
Spare Product ································································································································· 9- 5
Using Support Equipment ··············································································································· 9- 7
APPENDIX
App.- 1 to App.- 80
Appendix 1 I/O Control Mode ··········································································································· App.- 1
1.1 Direct mode ··························································································································· App.- 1
1.2 Refresh mode ························································································································ App.- 2
1.3 Comparisons between the direct mode and refresh mode ···················································App.- 3
Appendix 2 Special Relay ················································································································ App.- 4
Appendix 3 Special Register ············································································································ App.- 5
Appendix 4 Application Program Example······················································································· App.- 6
4.1 Flip-flop ladder ······················································································································· App.- 6
4.2 One shot ladder ····················································································································· App.- 8
4.3 Long-time timer······················································································································ App.- 9
4.4 Off delay timer ······················································································································ App.-10
4.5 On delay timer (momentary input) ························································································ App.-11
4.6 ON-OFF repeat ladder·········································································································· App.-12
4.7 Preventing chattering input··································································································· App.-12
4.8 Ladders with a common line································································································· App.-13
4.9 Time control program············································································································ App.-14
4.10 Clock ladder························································································································ App.-15
4.10.1 Clock function (supplement) ························································································· App.-16
4.11 Starting
operation of electrical machinery····························································· App.-18
4.12 Displaying elapsed time and outputting before time limit ···················································App.-19
4.13 Retentive timer···················································································································· App.-20
4.14 Switching timer set value externally ··················································································· App.-21
4.15 Setting counters externally ································································································· App.-22
4.16 Measuring operation time ··································································································· App.-24
4.17 Measuring cycle time ·········································································································· App.-24
4.18 Application example of (D) CML (P) ··················································································· App.-25
4.19 Program showing divided value of 4-digit BIN value to 4 places of decimals ···················· App.-26
4.20 Carriage line control············································································································ App.-29
4.21 Compressor sequential operation using ring counters······················································· App.-31
4.22 Application example of positioning control ·········································································App.-35
4.23 Application example using index Z ····················································································· App.-36
4.24 Application example of FIFO instruction············································································· App.-38
(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.
The related manuals are shown below.
(1) QCPU User's Manual (Hardware Design, Maintenance and Inspection)
····························································································· SH-(NA)080483ENG
Explains the hardware.
(2) QnUCPU User's Manual (Function Explanation, Program Fundamentals)
····························································································· SH(NA)-080807ENG
Explains the functions and programming method.
(3) MELSEC-Q/L Programming Manual (Common Instruction)
····························································································· SH(NA)-080809ENG
Explains details of each instruction.
(4) GX Works2 Beginner's Manual (Simple Project)
····························································································· SH(NA)-080787ENG
(5) GX Works2 Version 1 Operating Manual (Common)
····························································································· SH(NA)-080779ENG
(6) GX Works2 Version 1 Operating Manual (Simple Project)
····························································································· SH(NA)-080780ENG
(7) Before Using the Product
··········································································································· BCN-P5782
(8) Analog-Digital Converter Module User's Manual
·····································································································SH(NA)-080055
(9) Digital-Analog Converter Module User's Manual
·····································································································SH(NA)-080054
(10) I/O Module Type Building Block User's Manual
·····································································································SH(NA)-080042
(11) MELSOFT GX Works2 FB Quick Start Guide
········································································································· L-08182ENG
(6)
CHAPTER 1 BASICS OF PROGRAMMABLE CONTROLLER
1.1
Program
If a programmable controller is assumed as a control ladder, it can be described by
an input ladder, output ladder, and internal sequential operation.
PLC
PB1
X6
T1
LS1
Y70
Y74
X0
X1
Output relay
Y74
Y72
X2
X3
PB2
Y74
Y73
K30
X6
X5
Electromagnetic
valve
Y74
T1
X4
Sensor
PL
Y71
MC
Y75
Timer
Magnet
contactor
Y76
X6
Input relay
(virtual coil)
Contacts for
external
outputs
COM
COM
(+)
Input module
Input circuit
Turns on/off the
input relay with
external signal.
(-)
Output circuit
Internal sequential operation
Activates the
internal sequential
operation by the
contact of the input relay.
Transmits the on/off
operations of the
output relay.
Output module
Activates the
external loading.
Figure 1.1 Programmable controller configuration
A programmable controller is an electronic device centered around microcomputers.
Actually, a programmable controller is assemblies of relays, timers, and counters.
As shown in figure 1.1, the internal sequential operation is executed by turning on or
off the coil. The on/off condition of the coil depends on the connection condition (in
series or in parallel) and results of the normally open or normally closed contacts
"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
• The normally open contact closes.
(Conducted)
• The normally closed contact opens.
(Not conducted)
Normally open
Coil
Common
Not conducted
Conducted
contact
closed contact
• The normally open contact opens.
• The normally closed contact closes.
Coil on
(in operation)
Normally
2) De-energizing the coil
Demagnetization
(Not conducted)
Coil off
(always)
Normally
closed contact
Normally
open contact
(Conducted)
1-1
Conducted
Not conducted
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
X6
Step number
T1
Y74
0
Y74
Instruction
word
Device
0
LD
X6
1
OR
Y74
2
ANI
T1
K30
3
OUT
Y74
4
T1
4
LD
Y74
10
END
Y74
X6
5
ANI
X6
6
OUT
T1 K30
10
END
(a) Ladder diagram
Repeat
operation
(b) Instruction list (program list)
Figure 1.2 Program
•
A program consists of a large number of instruction words and
devices.
•
The instructions contain instruction words and devices. In addition,
the instructions are numbered to represent the order of operations.
The numbers are called step numbers.
(Instruction words are also called instructions.)
•
The number of steps varies depending on the types of instructions
or the setting method for the values to be used for the I/O numbers
and operations. (The more steps are needed for the operation with
complicated operation.)
•
The instructions repeat from the step number 0 to the END
instruction. (This is called "repeat operation", "cyclic operation" or
"scanning".)
Amount of time necessary for one cycle is called operation cycle
(scan time).
•
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)
X0
3)
2)
X1
0
Y10
4)
X2
7)
5)
X3
3
Y11
6)
X4
8)
X5
9)
X6
7
10)
Y12
11)
X7
12)
Y13
13)
X8
14)
Y14
15)
X9
17)
16)
XA
17
Y15
1-4
1.3
MELSEC-QnUD Module Configuration
(1) Universal model
The Universal model QCPU is used for a training in this textbook, therefore,
"QCPU" indicates "Universal model QCPU" unless otherwise noted.
(2) Basic configuration of a programmable controller system
The following figure shows an actual programmable controller configuration.
Memory card
Battery for QCPU (Q6BAT)
Universal model QCPU
Q7BAT-SET
Q3
DB multiple CPU high speed main base unit
Battery for QCPU (Q7BAT)
Battery holder
Q8BAT-SET
Q8BAT connection cable
Battery for QCPU (Q8BAT)
Extension cable
Power supply module/I/O module/Intelligent function module/Special function module
Q5
Q6
B extension base unit
B extension base unit
Figure 1.3 MELSEC-QnUD module configuration (when Q3 DB is used)
1-5
Base Unit
Power supply
CPU
CPU
Extension base unit
(Requiring a power
supply module)
Power supply
Q33B
Power supply
Q35B
Q38B
Q312B
Power supply
Power supply
Power supply
With 12
I/O modules
CPU
With eight
I/O modules
Power supply
With five
I/O modules
CPU
With three
I/O modules
Power supply
Main base unit
(Not requiring a power
supply module)
Q52B
(For two modules)
Q63B
Q55B
Q65B
Q68B
Q612B
Power supply
CPU
With 12
I/O modules
CPU
With eight
I/O modules
Power supply
Multiple CPU high speed main base unit
Q38DB
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
Module name
Input
Output
Q61P
100V to 240VAC
5VDC 6A
Q62P
100V to 240VAC
5VDC 3A, 24VDC 0.6A
24VDC
5VDC 6A
Q63P
100V to 120V/AC200 to
Q64P(N)
5VDC 8.5A
240VAC
Q61P-D
100V to 240VAC
5VDC 6A
CPU Module
Maximum I/O points for
Program capacity
Basic instruction
(maximum)
processing speed
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
Q20UD(E)HCPU
200K steps
Q26UD(E)HCPU
260K steps
Q50UDEHCPU
500K steps
Q100UDEHCPU
1000K steps
CPU type
connecting to a
programmable controller
4096 points
9.5ns
I/O Module
I/O points
Format
Output module
Input module
120VAC
8 points
16 points
32 points
64 points
–
–
–
–
–
–
–
–
–
240VAC
24VDC (positive common)
24VDC (high-speed input)
24VDC
(negative common)
–
–
5/12VDC
–
Contact output
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>
SRAM card
• For the boot operation
• 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
Flash card
the sequence program.
<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)
• Memory cards are required when the data capacity exceeds
the capacity of the built-in program memory, standard RAM,
and standard ROM.
• Select the memory card according to the size of the program
or the type of the data to be stored.
Memory Card
• Install the enclosed backup battery before using the
SRAM-type RAM card first. The SRAM card data cannot be
baked up unless the battery is installed.
• Format the memory card before using it.
• Data can be written to a Flash card for 100,000 times, and
for an ATA card, data can be written for 1,000,000 times.
1-8
<Reference: Universal model QCPU memory system configuration>
The memory of the Universal model QCPU consists of the following blocks.
Program memory
(program cache memory)
RAM
Parameter
Program
Parameter
Program
Device comment
Device initial value
Device comment
Device initial value
File register
Local device
Standard
ROM
Parameter
Program
Device comment
Device initial value
Sampling
trace file
Memory card
ROM
*1
Programmable
controller user data
CPU module
Storage file used in latch
data backup function
Parameter
Program
Device comment
Device initial value
File register
File used in
SP.DEVST/S.DEVLD function
Standard
RAM *2
File register
Local device
Sampling
trace file
Module error
collection file
*1: A memory card cannot be used for Q00UJCPU, Q00UCPU, Q01UCPU.
*2: Q00UJCPU has no standard RAM.
• 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
Secure backup by long-term storage
Programs and parameter files are automatically backed up to the program
memory (Flash ROM) which does not require a battery backup. This prevents a
loss of the program and parameter data due to the flat battery.
The battery backup time is also reduced significantly.
In addition, the important data (such as device data) can be backed up to the
standard ROM to prevent a loss of the data due to the flat battery in case of
consecutive holidays.
The backup data is restored automatically when the power is turned on next
time.
CPU built-in memory
Program memory
(Flash ROM)
Write programs
Program
cache memory
(SRAM)
No battery
backup
needed!
For program
execution
Programming
tool
Device data
Backup
Latch data
Device memory execution
Backup
condition is
file
ON
(Standard ROM)
File register
(Standard RAM)
1 - 10
No battery
required
for data
protection
1.4
External I/O Signal and I/O Number
(1) Wiring of I/O devices
The signals output from the external input devices are substituted by the input
numbers which are determined by the installation positions and terminal
numbers of the connected input module and used in a program.
For the operation results output (coil), use the output numbers which are
determined by the installation position and the terminal number of the output
module to which the external output module is connected.
0
(Power
supply)
1
2
3
4
Slot numbers
(CPU)
(QY)
Input numbers
Base unit
(QX)
Output numbers
Y10
PB1
V1
X0
CS1
CS2
PB2
PB3
LS1
LS2
LS3
LS4
PB4
PB5
CS3
Y11
X1
X2
V2
Y12
Input numbers are hexadecimal numbers that start
with 0. Input/output numbers share the same numbers.
"X" at the beginning of the number represents "Input",
and "Y" indicates "Output".
V3
X3
Y13
X4
X5
RL
Y14
The maximum number of the QCPU (Q mode)
input/output number is 4,096.
GL
The input/output number is sometimes referred
to as the I/O number (IN/OUT).
X6
Y15
MC1
X7
Y16
X8
X9
MC2
Y17
MC3
XA
COM1
XB
XC
Y18
XD
Y1F
XE
XF
COM2
COM
Output module
Input module
Figure 1.4 Wiring of I/O devices
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.
9
80 to 8F
90 to 9F
8
10
A0 to AF
7
70 to 7F
6
60 to 6F
5
50 to 5F
4
30 to 3F
3
20 to 2F
2
40 to 4F
1
10 to 1F
00 to 0F
CPU
Power supply module
0
11
Slot numbers
B0 to BF
Main base unit(Q33B,Q35B,Q38D)B,Q312(D)B)
I/O numbers
Base unit with
three slots(Q33B)
Base unit with five slots(Q35B)
Base unit with eight slots(Q38(D)B)
Base unit with 12 slots(Q312(D)B)
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.
5
6
7
70 to 7F
80 to 8F
4
40 to 4F
20 to 2F
10 to 1F
00 to 0F
CPU
Power supply module
3
2
1
30 to 3F
0
The I/O numbers of the
slot next to the one with
32-point modules are
changed.
(The numbers are
assigned in order from
lower numbers.)
50 to 5F / 60 to 6F
Main base unit
Slot 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.
4
5
6
7
50 to 5F
60 to 6F
70 to 7F
3
40 to 4F
10 to 1F
2
20 to 2F
1
Vacant slot
(30 to 3F)
0
00 to 0F
CPU
Power supply module
Main base unit
Slot numbers
• 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.
6
7
70 to 7F
60 to 6F
5
50 to 5F
4
40 to 4F
3
13
14
15
D0 to DF
2
30 to 3F
1
10 to 1F
00 to 0F
CPU
Extension cable
Power supply module
0
20 to 2F
Main base unit (Q38(D)B)
Slot numbers
F0 to FF
C0 to CF
23
24
25
26
27
28
1C0 to 1CF
B0 to BF
20
E0 to EF
A0 to AF
19
1B0 to 1BF
90 to 9F
18
1A0 to 1AF
11 12
190 to 19F
10
180 to 18F
9
170 to 17F
8
80 to 8F
First extension
base unit
Power supply module
Extension base unit (Q68B)
140 to 14F
110 to 11F
130 to 13F
17
120 to 12F
16
100 to 10F
Second
extension base
unit
Power supply module
(Q65B)
(Note)
Parameters allow the setting different from the
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.
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
new one.
For details, refer to the QnUCPU User's Manual
(Function Explanation, Program Fundamentals).
21
22
150 to 15F
160 to 16F
Third extension
base unit
Power supply module
Extension base unit (Q68B)
• 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
Universal model
Number of stages (including the ones
connected with GOT in bus connection)
Q00UJCPU
2
Q00UCPU, Q01UCPU, Q02UCPU
4
Other than the above
7
1 - 13
1.5
System Configuration and I/O Number of Demonstration Machine
Output module
CPU module
Input module
Power supply module
Base unit Q38DB
Q61P QCPU Vacant
slot
QX
QY Q64 Q62
AD DAN
42
42P
(16
(16
(64
(64
points) points) points) points)
X0
to
X3F
USB cable
Y40
to
Y7F
Peripheral device
I/O panel
Y6F
Y77
Y76
Y75
Y74
Y73
Y72
Y71
Y70
Y7F
Y7E
Y7D
Y7C
Y7B
Y7A
Y79
Y78
Y60
X3F
X7
X6
X5
X4
X3
X2
X1
X30
Y5F
X2F
Y50
Y4F
Y40
X20
X0
ON
1 9 4 2
4 1 3 6
MELSEC-Q
OFF
XF
XE
XD
XC
XB
XA
X9
A/D INPUT
X8
ON
OFF
1 - 14
D/A OUTPUT
CHAPTER 2 OPERATING GX Works2
GX Works2 is a programming tool for designing, debugging, and maintaining
programs on Windows®.
GX Works2 has improved functionality and operability, with easier-to-use features
compared to existing GX Developer.
Main functions of GX Works2
GX Works2 can manage programs and parameters in units of projects for each
programmable controller CPU.
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
parameters can be set with GX Works2.
Intelligent function module parameter can be set as well.
and
network
Writing/reading data to/from a programmable controller CPU
Created sequence programs can be written to/read from a programmable
controller CPU using the Read from PLC/Write to PLC function. Also, with
the Online program change function, the sequence programs can be
changed even when the programmable controller CPU is in RUN.
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.
Programs can be monitored and debugged.
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 (PLC diagnostics screen)
Diagnosing the
programmable controller
CPU status
2-2
2.1
Features of GX Works2
This section explains the features of GX Works2.
(1) Project types in GX Works2
In GX Works2, the project type can be selected from either of Simple project or
Structured project.
(a) Simple project
The Simple project creates sequence programs using instructions for
Mitsubishi programmable controller CPU.
Programs in a Simple project can be created in a similar way to existing GX
Developer.
(b) Structured project
In a Structured project, programs can be created by structured
programming.
By segmenting a whole control process program into common program
parts, highly manageable and usable programming (structured
programming) is possible.
POU
Function block 1
Function block 2
Program file
Program block A
Program MAIN
Program block B
Program block C
Function 1
Program block D
Function 2
Program block E
Program SUB1
Sequence programs are created
by combining POU (Program
Organization Unit) s.
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.
(3) Sharing Program Organization Unit (POU) registered as libraries
In a Structured project, programs, global labels, and structures frequently used
can be registered as user libraries. Utilizing these user libraries reduces time
required for creating programs.
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>
Programming similar to existing GX Developer
<SFC>
Programming to clarify the procedure
<Structured ladder>
Programming a ladder program graphically
<ST>
Programming in a text language similar to
C language
(5) Other features
(a) Offline debugging
Offline debugging using the simulation function is possible with GX Works2.
This enables debugging to ensure the normal operation of created
sequence programs without connecting GX Works2 to the programmable
controller CPU.
Simulation function
Connecting the programmable
controller CPU is unnecessary.
Without connecting the programmable controller CPU, programs can be
monitored and debugged in the same way with debugging by the
programmable controller CPU.
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.
Screen layout can be
changed without restriction.
2-6
2.1.1
MELSOFT iQ Works
MELSOFT iQ Works integrates the engineering software (GX Works2, MT
Developer2, and GT Designer3).
Sharing the design information such as the system design and programming in the
whole control system improves the efficiency of program design and efficiency of
programming, which reduces costs.
MELSOFT iQ Works
GX Works2
(Programmable controller
programming software)
GT Designer3
(GOT drawing software)
MT Developert2
(Motion controller
programming software)
MELSOFT Navigator
(System configuration management tool)
Sharing the design information
between the software
Design information
data base
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
Controller and HMI
Network
1) Integrating development environment which was
independent of each device
2) Sharing the design information in whole development phases
(system designing, programming, test/startup, and operation/maintenance)
POINT
is a FA integrated concept of MITSUBISHI ELECTRIC.
Integrated Q/improved Quality/intelligent&Quick/innovation&Quest
2-8
2.2
2.2.1
Basic Knowledge Required for Operating GX Works2
Screen configuration in GX Works2
1) Title bar
2) Menu bar
3) Toolbar
4) Tab
7) Edit screen (work window)
5) View contents display area
6) View selection area
8) Output window
9) Status bar
2-9
1)
Title bar
Title bar displays the name of the active project.
Resizes or terminates GX Works2.
Displays the name and
the path of the project.
Maximizes or restores GX Works2.
Minimizes GX Works2.
Terminates
GX Works2.
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.
Point the cursor to the tool button
to show the function of each button.
4)
Tab
When multiple work windows are open, they are displayed in the tab browser
format. Clicking a tab activates the corresponding work window.
5)
View contents display area
View contents display area displays the contents of the currently selected view.
6)
View selection area
View selection area allows selection of the view to be displayed.
7)
Edit screen (work window)
Edit screen displays various screens such as ladder program creation screen
and comment creation screen for editing ladder diagrams, comments, and
parameters.
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 current mode.
Displays the
CPU type.
Displays the
Displays the current
connected CPU. cursor position.
2 - 10
Displays the
state of Caps Lock.
Displays the
state of Num Lock.
2.2.2
Ladder editor
This section explains the screen display of the GX Works2 ladder editor and its
basic operations.
(1) Edit screen
(2) Changing the display size of the edit screen
The display size of the edit screen can be changed.
1) Click [View] → [Zoom].
The Zoom dialog box is displayed.
Change the display size according to the
selected zoom ratio.
Change the display size according to the
specified zoom ratio. (available range: 50 to 150%)
Adjust the width of the ladder automatically to
display the entire ladder.
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].
The text size is changed one step at each
setting within the range of 10 steps.
(4) Displaying/hiding comments
Device comments (label comments), notes, and statements can be displayed
and hidden.
1) Select [View] → [Comment]/[Statement]/[Note].
POINT
Displaying/hiding comments
Comments also can be displayed or hidden by the following operation.
[Tool] → [Option] → "Program Editor" → "Ladder" → "Comment"
* The details of this operation are explained in the next page.
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].
The Options screen is displayed.
2) Click "Program Editor" → "Ladder" → "Comment".
The screen for setting Device Comment Display
Format is displayed.
Comments can be displayed or hidden by
this setting in addition to by the method
described on the previous page.
(To the next page)
2 - 13
(From the previous page)
Set the number of display
rows in the range from 1 to 4.
Set the number of display columns to 5 or 8.
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.
The screen for setting Display Format for the
ladder diagram is displayed.
Set the number of contacts to be displayed in
a single row to 9 or 11 contacts.
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.
1) Click [View] → [Device Display].
The screen for setting Display Format for the
ladder diagram is displayed.
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.
(a) Hiding a ladder block
1) Move the cursor to the ladder block to be
hidden.
1) Move the cursor!
2) Click [View] → [Non-Display Ladder Block].
(To the next page)
2 - 17
(From the previous page)
3) The selected ladder blocks are hidden.
The ladder block is hidden.
(b) Canceling the hidden ladder block.
1) Move the cursor to the hidden ladder block
displayed in gray.
1) Move the cursor!
2) Click [View] → [Display Ladder Block].
(To the next page)
2 - 18
(From the previous page)
3) The hidden ladder blocks are displayed.
The hidden ladder blocks are displayed.
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).
< Simple project (without labels) >
Set various parameters.
Make settings for the intelligent function modules.
Set global device comments.
Set an execution type of each program.
Create programs.
GX Works2 Version 1 Operating Manual Simple Project
Set local device comments.
Make settings for device memory.
Set device initial values.
< Simple project (with labels) >
Set various parameters.
Make settings for the intelligent function modules.
Set global device comments.
Set global labels.
GX Works2 Version 1 Operating Manual Simple Project
Set an execution type of each program.
Create programs.
GX Works2 Version 1 Operating Manual Simple Project
Set local device comments.
Make settings for device memory.
Set device initial values.
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.
Comment type
Number of comments
Description
A device comment created automatically
when a new project is created.
Global comment
1
Global comments are set to use common
device comment data among multiple
programs.
A device comment created by the user.
No local device comment exists when a
Local comment
Equals the number of
the programs.
new project is created. Therefore, create a
local device comment if necessary.
Set
the
programs.
2 - 21
same
names
as
sequence
2.3
2.3.1
Operation Before Creating Ladder Program
Starting up GX Works2
1) Click the
button.
2) Select [All Programs].
3) Select [MELSOFT Application].
4) Select [GX Works2].
3) Select!
5) Click!
2) Select!
Put the mouse cursor over the items to select
the menu.
(Clicking or double-clicking the mouse is not
required.)
5) Click [GX Works2].
4) Select!
1) Click!
6) GX Works2 starts up.
6) GX Works2 starts up.
2 - 22
2.3.2
Creating a new project
1) Click
on the toolbar or select [Project] →
[New Project] ( Ctrl + N ).
1) Click!
2) Click the "Project Type" list button.
2) Select!
3) The "Project Type" list is displayed. Select
"Simple Project".
3) Click and select!
4) Click the "PLC Series" list button.
5) The "PLC Series" list is displayed. Select
"QCPU (Q mode)".
4) Click!
5) Click and select!
(To the next page)
2 - 23
(From the previous page)
6) Click the "PLC Type" list button.
7) The "PLC Type" list is displayed. Select
"Q06UDH".
8) Click!
8) Click the
OK
button.
6) Click!
7) Click and select!
9) A new project is opened.
9) A new project is opened!
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)
(1) Connecting a battery
Connect the battery since the lead wire of the battery connector is disconnected
at the factory shipment.
(2) Setting the switches
Set the RUN/STOP/RESET switch to the STOP position.
(3) Connecting the USB cable
2 - 25
(4) Setting the connection destination
This section explains how to set the connection destination for accessing the
programmable controller CPU.
1) Click "Connection Destination" in the view
selection area on the navigation window.
1) Click!
2) The Connection Destination view is
displayed. Double-click "Connection1" in
Current Connection.
2) Double-click!
The Transfer Setup dialog box is displayed.
3) Double-click "Serial USB" of PC side I/F.
3) Double-click!
4) The PC side I/F Serial Setting dialog box is
displayed. Check "USB" and click the OK
button.
4) Click!
5) Double-click "PLC Module" of PLC side I/F.
5) Double-click!
(To the next page)
2 - 26
(From the previous page)
6) The PLC side I/F Detailed Setting of PLC
Module dialog box is displayed. Select
"QCPU (Q mode) " and click the OK
button.
6) Click!
7) Click the
7) Click!
2 - 27
OK
button.
(5) Formatting the built-in memory of the CPU
This section explains how to format the program memory of the QCPU.
1) Click [Online] → [PLC Memory Operation] →
[Format PLC Memory].
1) Click!
2) The Format PLC Memory dialog box is
displayed. Select "Program Memory" from the
Target Memory drop-down menu.
2) Select the target memory.
3) Click the
Execute
4) Click the
Yes
button.
3) Click!
button to start formatting.
4) Click!
5) When format is completed, the dialog box on
the left is displayed. Click the OK button.
5) Click!
6) Click the
box.
6) Click!
2 - 28
Close
button to close the dialog
(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!
2) The Clear PLC Memory dialog box is
displayed. Check that "Clear Device's whole
Memory" is checked.
2) Check.
3) Check "Include Latch".
3) Check.
4) Click the
Execute
5) Click the
device.
Yes
button.
4) Click!
button to clear the latch
5) Click!
6) When the clearing the latch device is
completed, the dialog box on the left is
displayed. Click the OK button.
6) Click!
7) Click the
box.
7) Click!
2 - 29
Close
button to close the dialog
(7) Clearing the error history in the CPU
This section explains how to clear the error history data stored in the QCPU.
1) Click [Diagnostics] → [PLC Diagnostics].
1) Click!
2) The PLC Diagnostics dialog box is displayed.
Click the Clear History button.
3) The confirmation dialog box is displayed.
Click the Yes button.
4) Click the
box.
2) Click!
4) Click!
2 - 30
Close
button to close the dialog
(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 [Online] → [Set Clock] to display the Set
Clock dialog box.
1) Click!
2) Enter a year, month, date, time, minute,
second, and day of the week in the Set Clock
dialog box.
3) Click the
2) Enter time!
3) Click!
2 - 31
Execute
button.
2.5
2.5.1
Creating Ladder Program
Creating a ladder program using the function keys
Follow the steps below to create the ladder program
A ladder program to be created
as shown on the left.
X2
X0
Y70
Y70
X3
Y71
1) Press the F5 key to open the Enter Symbol
window. Enter "X2".
If any other key is pressed by mistake, press the
2) Press "Enter"!
Esc
1) Enter "X2"!
key and retype.
2) Press the
Enter
key to confirm the entry.
• The OK or Exit button also can be used to confirm
or cancel the entry.
X2
3) The symbol is displayed!
3) The entered symbol (
) is displayed.
4) Press the Shift + F5 keys , and enter "X0".
5) Press "Enter"!
4) Enter "X0"!
5) Press the
Enter
key to confirm the entry.
X0
6) The entered symbol (
6) The symbol is displayed!
8) Press "Enter"!
) is displayed.
7) Press the F7 key, and enter "Y70".
7) Enter "Y70"!
8) Press the
(To the next page)
2 - 32
Enter
key to confirm the entry.
(From the previous page)
9) The entered symbol (
9) The symbol is displayed!
Y70
) is displayed.
10) Press the F6 key, and enter "Y70".
11) Press "Enter"!
10) Enter "Y70"!
11) Press the
Enter
key to confirm the entry.
Y70
12) The entered symbol (
12) The symbol is displayed!
13) Move the cursor!
) is displayed.
Y70
13) Move the cursor to the symbol under
15) Press "Enter"!
.
14) Press the F5 key, and enter "X3".
14) Enter "X3"!
15) Press the
Enter
key to confirm the entry.
X3
16) The entered symbol (
) is displayed.
16) The symbol is displayed!
18) Press "Enter"!
17) Press the F7 key, and enter "Y71".
18) Press the
Enter
key to confirm the entry.
17) Enter "Y71"!
19) The entered symbol (
Y71
19) The symbol is displayed!
20) The procedure is finished.
2 - 33
) is displayed.
2.5.2
Creating a ladder program using the tool buttons
Follow the steps below to create the ladder program
A ladder program to be created
as shown on the left.
X2
X0
Y70
Y70
X3
Y71
1) Click
on the toolbar to open the Enter Symbol
window. Enter "X2".
If any other button is pressed by mistake, click the
1) Click
,
then enter "X2".
2) Click!
Exit
button.
2) Click the
OK
button to confirm the entry.
X2
3) The entered symbol (
3) The symbol is displayed!
4) Click
4) Click
,
then enter "X0".
) is displayed.
on the toolbar, and enter "X0".
5) Click!
5) Click the
OK
button.
X0
6) The entered symbol (
6) The symbol is displayed!
7) Click
7) Click ,
then enter "X70".
on the toolbar, and enter "Y70".
8) Click!
8) Click the
(To the next page)
2 - 34
) is displayed.
OK
button.
(From the previous page)
9) The entered symbol (
9) The symbol is displayed!
10) Click
11) Click!
11) Click the
Y70
) is displayed.
on the toolbar, and enter "Y70".
OK
button.
10) Click
,
then enter "X0".
Y70
12) The entered symbol (
12) The symbol is displayed!
) is displayed.
Y70
13) Move the cursor to the symbol under
.
13) Move the cursor!
14) Click
14) Click
,
then enter "X3".
15) Click!
15) Click the
on the toolbar, and enter "X3".
OK
button.
X3
16) The entered symbol (
17) Click
16) The symbol is displayed!
18) Click the
17) Click
, then enter "Y71"!
) is displayed.
on the toolbar, and enter "Y71".
OK
button.
18) Click!
19) The entered symbol (
Y71
19) The symbol is displayed!
20) The procedure is finished.
2 - 35
) is displayed.
2.6
Converting Program (Ladder Conversion)
1) Click [Compile] → [Build] ( F4 ).
1) Click!
2) The ladder program has been converted.
If an error occurs during a conversion, the cursor
will automatically move to the defective point of
the ladder program. Check the point and correct
the program as necessary.
2 - 36
2.7
Writing/Reading Data to/from Programmable Controller CPU
(1) Writing data to the CPU
1) Suppose that the ladder program (sequence
program) has been created with GX Works2
to proceed to the next step.
2) Set the RUN/STOP/RESET switch on the
CPU to STOP.
2) Set the switch to "STOP"!
on the toolbar or click [Online]
3) Click
→ [Write to PLC].
3) Click!
4) From the "PLC Module" tab, click to select
the program and parameter to write to the
CPU. Or click Parameter + Program to
select the target program and parameter.
4) Select a program to be
written by clicking on data!
5) Click
Execute
to accept the selection.
5) Click!
6) If a parameter or program has already been
written, the confirmation dialog box for
overwriting the data is displayed. Click
Yes .
6) Click!
(To the next page)
2 - 37
(From the previous page)
7) The progress dialog box is displayed.
8) The message "Completed" is displayed when
the writing is completed. Click Close .
8) Click!
9) Click the
box.
9) Click!
2 - 38
Close
button to close the dialog
(2) Reading data from the CPU
1) Click
on the toolbar or click [Online]
→ [Read from PLC].
1) Click!
2) Select a program to be
read by clicking on data!
2) Select the
target memory!
2) From the "PLC Module" tab, click to select the
program and parameter to read from the CPU. Or
click Parameter + Program to select the target
program and parameter.
Select "Program Memory/Device Memory" for
"Target Memory".
3) Click
Execute
to accept the selection.
3) Click!
4) If a parameter or program exits, the confirmation
dialog box for overwriting the data is displayed.
Click Yes .
4) Click!
5) The progress dialog box is displayed.
6) The message "Completed" is displayed when the
reading is completed. Click Close .
6) Click!
2 - 39
2.8
Monitoring Ladder Program Status
1) Suppose that the ladder program (sequence
program) has been written into the
programmable controller CPU to proceed to
the next step.
2) Set the RUN/STOP/RESET switch on the
CPU to RESET once (for about one sec.),
return it to STOP, then set it to RUN.
2) Set the switch to "RUN"!
3) Click
on the toolbar or click [Online] →
[Monitor] →[Start Monitoring].
3) Click!
4) Selecting another menu ends the monitor
mode.
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.
3)
ERR. status (PLC diagnostics)
Displays the error status of the programmable controller CPU.
Clicking the icon displays the PLC Diagnostics screen (*1).
4)
USER status (PLC diagnostics)
Displays the user error status of the programmable controller CPU.
Clicking the icon displays the PLC Diagnostics screen (*1).
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.
*1: For the PLC diagnostics, refer to section 2.8.
(2) The statuses of the ladder are indicated as shown below.
1)
Display of a contact when X0 = OFF
X0
X0
Normally open contact Normally closed contact
(not conducting)
(conducting)
Display of a contact when X0 = ON
X0
X0
Normally open contact Normally closed contact
(conducting)
(not conducting)
2)
Display of a coil output instruction, contact-equivalent comparison
instruction, and coil-equivalent instruction
Not executed,
conditions not established
*
Executed,
conditions established
*
*: Available contact-equivalent comparison and coil-equivalent
instructions are SET, RST, PLS, PLF, SFT, SFTP, MC, FF, DELTA,
and DELTAP.
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!
2) The Enter Symbol window is displayed. Enter
"Y72".
3) Press the
2) Enter "Y72"!
Enter
4) Double-click (
Y70
key.
) and change "Y70" to "Y72".
4) Enter "Y72"!
5) Click [Compile] → [Build] ( F4 ).
5) Click!
6) The conversion is completed.
2 - 42
2.9
Diagnosing Programmable Controller CPU
1) Click [Diagnostics] → [PLC Diagnostics].
1) Click!
2) The PLC Diagnostics screen is displayed.
2)
1)
3)
5)
4)
7)
6)
2 - 43
Item
1)
2)
Description
Monitor Status
Connection Channel
List
Displays the current monitor status.
Displays the connection route which has been set.
For single CPU system
Displays the operation status and switch status of the programmable controller CPU.
For multiple CPU system
Displays the operaton status and the switch status of CPU No. 1 to No. 4.
3)
CPU operation status
4)
Image of
programmable
controller CPU
Perform online operations of the programmable controller CPU. (refer to POINT)
Error Information
Select this to display the current error information of the programmable controller CPU.
• "Uninstallable/Blank" is displayed for a slot with no module mounted.
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
7)
Status Icon Legend
Displays the status icons on the screen.
button.
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.
<Set Clock/Write Title>
<Remote Operation>
<PLC Memory Operation>
2 - 44
2.10
Editing Ladder Program
2.10.1
Modifying a part of the ladder program
This section explains how to modify a part of the
ladder program shown on the left.
(OUT Y71 → OUT Y72)
A ladder program to be created
X2
X0
Y70
Y70
Y72
X3
Y71
1) Confirm that "Ovrwrte" is shown at the
lower-right portion of the screen.
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
<When correcting SET to RST>
SET M3
RST M3
Added!
2) Double-click the point to be corrected.
2) Double-click!
(To the next page)
2 - 45
(From the previous page)
3) The Enter Symbol window is displayed.
3) The Enter Symbol window is displayed!
4) Click the edit box and enter "Y72".
5) Click the
4) Enter "Y72"!
OK
button to accept the change.
5) Click!
6) The modified diagram is displayed!
6) The modified ladder program is displayed.
7) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 46
2.10.2
Drawing/deleting lines
(1) Drawing lines
This section explains how to add a line to the
ladder program shown on the left.
A ladder program to be created
X2
X0
Y70
Y70
Y73
X3
Y72
1) Click
(
Alt
+ F10 ) on the toolbar.
1) Click!
2) Drag the mouse from the start position to the
end position.
2) Drag!
A vertical line is created to the left of the cursor.
3) A line is created when the left button of the
mouse is released.
3) A line is created!
(To the next page)
2 - 47
(From the previous page)
4) Click
5) Click the
4) Click
,
then enter "Y73"!
on the toolbar, and enter "Y73".
OK
button.
5) Click!
6) The entered symbol (
6) The symbol is displayed!
Y73
) is displayed.
7) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 48
(2) Deleting lines
Perform the following steps to delete the line
from the ladder shown on the left.
A ladder program to be created
X2
X0
Y70
Y70
Y73
X3
Y72
1) Click
(
Alt
+ F9 ) on the toolbar.
1) Click!
2) Drag the mouse from the start position to the
end position.
2) Drag!
3) The line is deleted when the left button of the
mouse is released.
The line drawn for the END instruction cannot be
removed.
3) The line is deleted!
4) Press the Delete key to delete
4) Press "Delete"!
Y73
5) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 49
.
2.10.3
Inserting/deleting rows
(1) Inserting rows
This section explains how to add a row to the
ladder program shown on the left.
A ladder program to be modified
X7
Y77
X2
X0
Y70
Y70
X3
Y72
1) Click on any point of the row to move the
cursor.
1) Click to move the cursor!
A new row is inserted above the row selected with the
cursor.
2) Right-click on any point on the ladder
program creation screen to display the
menu.
2) The menu
is displayed!
(To the next page)
2 - 50
(From the previous page)
3) Select the [Edit] → [Insert Row]
( Shift + Ins ).
3) Click!
4) A new row is inserted above the selected
row.
4) A new row is inserted!
5) Click
on the toolbar to open the Enter
Symbol window. Enter "X7".
6) Click the
5) Click
,
then enter "X7"!
6) Click!
(To the next page)
2 - 51
OK
button to accept the entry.
(From the previous page)
X7
7) The entered symbol (
7) The symbol is displayed!
8) Click
8) Click
,
then enter "Y77"!
9) Click the
9) Click!
on the toolbar, and enter "Y77".
OK
button.
10) The entered symbol (
displayed.
10) The symbol is displayed!
) is displayed.
Y77
) is
11) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 52
(2) Deleting rows
This section explains how to delete the row
from the ladder program shown on the left.
A ladder program to be modified
X7
Y77
X2
X0
Y70
Y70
X3
Y72
1) Click on any point of the row to be deleted to
move the cursor.
1) Click to move the cursor!
2) Right-click on any point on the ladder
program creation screen to display the
menu.
2) The menu
is displayed!
(To the next page)
2 - 53
(From the previous page)
3) Select the [Edit] → [Delete Row]
( Shift + Del ).
3) Click!
4) The selected row is deleted.
4) The row is deleted!
5) To convert the edited ladder program, click
[Compile] → [Build] ( F4 ).
2 - 54
2.10.4
Cutting/copying ladder program
This section explains how to copy and cut the
ladder program shown on the left.
A ladder program to be modified
X7
Y77
X2
X0
Y70
Y70
1) Click on the start point of the ladder program
to be cut to move the cursor.
Range of cut or copy
1) Click to move the cursor!
2) Drag the mouse over the ladder to specify the
area.
The selected area is highlighted.
2) Drag to specify the area!
Click the step numbers and drag the mouse vertically
to specify the area in ladder block units.
3) Click
3) Click
on the toolbar or select [Edit] →
[Cut] ( Ctrl + X ) to cut the specified
area.
to cut!
(To the next page)
2 - 55
(From the previous page)
4) Click on the start point of the ladder program
to be copied to move the cursor.
5) Drag the mouse over the ladder to specify
the area.
The selected area is highlighted.
Click the step numbers and drag the mouse vertically
to specify the area in ladder block units.
6) Click
6) Click
on the toolbar or select [Edit] →
[Copy] ( Ctrl + C ) to copy the specified
area.
!
7) Click any ladder block to move the cursor to
the ladder. The copied ladder is pasted
above the row with the cursor.
The ladder is pasted above this block!
7) Click to move the cursor!
(To the next page)
2 - 56
(From the previous page)
8) Click
on the toolbar or select [Edit] →
[Paste] ( Ctrl + V ) to paste the cut or
copied area.
8) Click!
9) The cut or copied ladder is pasted.
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 [Online] → [Verify with PLC].
1) Click!
2) The Online Data Operation dialog box is displayed.
Click the Parameter + Program button.
3) Click the
2) Click!
Execute
button.
3) Click!
4) The verification result is displayed in the Verify
Result window.
To check the detail of the data, double-click the
corresponding row.
4) Double-click!
5) The detail of the result is displayed.
5) Display!
2 - 58
2.12
2.12.1
Saving Ladder Program
Saving newly-created or overwritten projects
on the toolbar or select [Project]
1) Click
→ [Save] ( Ctrl + S ).
Saving the existing project is completed at this
step.
1) Click!
(Only when a newly-created project is saved)
2) Specify the location to store the project.
3) Set a workspace name.
4) Set a project name.
2) Specify the location to
store the project!
5) Set a title as necessary.
4) Set a project name!
6) Click the
Save
button to accept the entry.
3) Set a workspace name!
5) Set a title as necessary!
6) Click!
7) Click the Yes button.
The new project is saved.
7) 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.
2.12.2
Saving a project with another name
1) Click [Project] → [Save as].
1) Click!
2) Specify the location to store the project.
3) Set a workspace name.
4) Set a project name.
2) Specify the location to
store the project!
5) Set a title as necessary.
4) Set a project name!
6) Click the
3) Set a workspace name!
Save
button to accept the entry.
5) Set a title as necessary!
6) Click!
7) Click the Yes button.
The new project is saved.
7) Click!
2 - 60
2.13
Reading the saved project
1) Click
on the toolbar or select [Project]
→ [Open] ( Ctrl + O ).
1) Click!
2) Specify the location where the project to be
read is stored.
3) Double-click the workspace to be read.
3) Double-click!
4) Click the project to be read.
4) Click!
5) Click the button to start reading the specified
project.
5) Click!
Each confirmation dialog box below is displayed in the following cases;
(When another project has been open)
Yes ·········Terminates the project.
No ··········Keeps the project open.
(When another project has been open without being converted)
Yes
No
·········Terminates the project without
converting the project.
··········Keeps the project open.
(Continue editing the ladder program.)
(When another project has been open without being saved)
Yes ·········Terminates the project after saving it.
No ··········Terminates the project without
saving it.
Cancel ····Keeps the project open.
2 - 61
2.14
Opening Projects in Different Format
This section explains how to open a project created with GX Developer in
GX Works2.
1) Click [Project] → [Open Other Data]
→ [Open Other Project].
2) The Open Other Project dialog box is
displayed. Specify the project and click the
Open button.
2) Click!
3) The message on the left is displayed.
Click the Yes button.
4) The project created with GX Developer is
read.
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.
2.15
Saving Projects in Different Format
This section explains how to save a Simple project of GX Works2 in the GX
Developer format.
1) Click [Project] → [Export to GX Developer
Format File].
1) Click!
2) The Export to GX Developer Format File
dialog box is displayed. Specify the
destination to save the project.
2) Select!
3) Enter a project name and click the
button.
Save
3) Click!
4) The message on the left is displayed. Click
the Yes button.
5) The project is saved in the GX Developer
format.
2 - 63
MEMO
2 - 64
CHAPTER 3 DEVICE AND PARAMETER OF PROGRAMMABLE CONTROLLER
3.1 Device
A device is an imaginary element for programming in the programmable controller
CPU, as well as the components (such as contacts and coils) that compose a
program.
X6
T2
Y74
Y
Type
X
Y
M
L
B
F
V
SM
SB
FX
FY
T(ST)
C
D
W
R
SD
SW
FD
Z
74
Device No.
Device symbol
Y74
Description
Remark
Sends commands and data to a programmable controller
Input
through external devices such as push buttons, selector
switches, limit switches, and digital switches.
Outputs control results to solenoids, electromagnetic switches,
Output
signal lights, and digital indicators.
Auxiliary relay inside a programmable controller that cannot
Internal relay
output directly to external devices
Uninterruptible auxiliary relay inside the programmable
Latch relay
controller that cannot output directly to external devices
Internal relay for data link that cannot output directly to external
Link relay
devices The area not assigned by initial link information setting
can be used as an internal relay.
• Bit device
Used for failure detection. Create a failure detection program
• Mainly handles on/off
beforehand and turn on the program while the programmable
signals.
Annunciator
controller is running to store numerical values in the special
register D.
Internal relay that stores an operation result (on/off information)
Edge relay
from the top of a circuit block
Special relay
Internal relay that stores CPU statuses
Internal relay for data link that indicates a communication
Special link relay
status and errors
Internal relay that captures the on/off data specified by a
Function input
subroutine call instructions with arguments in a subroutine
program
Internal relay that passes an operation result (on/off data) in a
Function output
subroutine program to a subroutine program call source
Accumulative timers of four types: low-speed timer, high-speed
timer, low-speed integrator, and high-speed integrator
Accumulative counters of two types: counters for sequence
Counter
programs and counters for interruption sequence programs
Data register
Memory that stores data in the programmable controller
Link register
Data register for data link
Register for an extensive use of data registers, which uses the
File register
standard RAM or memory card
Special register Register that stores CPU statuses
Data register for data link that stores a communication status
Link data register
and failure information
Register for the exchange data between a subroutine call
Function register
source and a subroutine program
Register for modification to the devices (X, Y, M, L, B, F, T, C,
Index register
D, W, R, K, H, and P)
Timer
3-1
• Word device
• Mainly handles data.
• One word consists of
16 bits.
• Can be specified by
entering ~.* (* = 0 to F
(hexadecimal)).
Type
FD
Function
register
Z
Index register
N
Nesting
P
Pointer
I
J
U
K
Interruption
pointer
Network No.
specification
device
I/O No.
specification
device
Decimal
constant
Description
Remark
Register for the exchange data between a subroutine call
source and a subroutine program
Register for modification to the devices (X, Y, M, L, B, F, T, C,
D, W, R, K, H, and P)
Shows the nesting (nested structure) of the master control.
Locates the jump addresses of the branch instructions (CJ,
SCJ, CALL and JMP).
Locates a jump address that corresponds to the factor of the
interruption when an interruption occurs.
Used to specify the network number in the data link
instructions.
Used to specify the I/O number in the intelligent function
module dedicated instructions.
Used to specify the following; timer counter set value, pointer
number, interruption pointer number, number of digits of bit
device, and basic/application instruction values.
Hexadecimal
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
Jn\Y
Link direct
Device that can access directly to a link device of a network
Jn\B
module (The refresh parameter setting is not required.)
Jn\SB device
Jn\W
Jn\SW
Intelligent
Device that can access directly to the buffer memory of a
Un\G
function module
intelligent function module
device
H
3-2
• Bit device
• Mainly handles on/off
signals.
• Word device
• Mainly handles data.
• One word consists of
16 bits.
3.2 Parameter
The parameters are basic setting values applied to a programmable controller in
order to control objects as planned.
The parameters are divided into the PLC parameter, network parameter, and remote
password as shown below.
* A shaded area in the following table indicates the items to be set in this textbook.
Item
PLC name
PLC system
Sets a label (name and application) of a programmable controller CPU.
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.
Points occupied by empty
slot
System interrupt settings
Interrupt program/fixed scan
program setting
Module synchronization
PLC parameter
Description
Label
A-PLC compatibility setting
Service processing setting
PLC module change setting
Sets the number of empty slots for the main or extension base unit.
• Sets the start number of the interrupt counters.
• Sets the execution interval for the interrupt pointers.
Set whether to execute high-speed execution of an interrupt program.
Set whether to synchronize the start-up of the programmable controller CPU with that of the
intelligent function module.
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
model QCPU)
Set this parameter to replace the CPU module using a memory card (Only for Universal
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
PLC file
command
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
SP.DEVST/S.DEVLD
instruction
WDT (watchdog timer)
setting
Error check
Operation mode when there
PLC RAS
Sets the device comment file to be used in a program.
is an error
Constant scanning
Breakdown history
Sets the device data ROM write/read instruction file to be used in a program.
(Only for Universal model QCPU)
Sets the WDT of the programmable controller CPU.
Sets whether to detect specified errors.
Sets the programmable controller CPU operation mode when an error is detected.
Sets the constant scan time.
Sets the storage destination for error histories of the programmable controller CPU. (Only
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
Boot option
Boot file
Boot file setting
Sets the startup mode and startup condition of an SFC program and the output mode at
block stop
Device points
Latch (1) start/end
Latch (2) start/east
PLC parameter
RESET/L.CLR switch or a remote latch clear operation.
Sets the latch range (start device number/end device number) not clearable with the
RESET/L.CLR switch or a remote latch clear operation.
Sets the range (start device number/end device number) of devices used as a local device.
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
I/O assignment
Basic setting
No. of PLC
Operation mode
Host station
Multiple CPU synchronous
startup setting
setting. (Only for Universal model QCPU)
Sets the type, model, number of occupied I/O points, and start I/O number of each module
mounted on the base unit.
Sets the model and the number of slots of the base unit, the model of the power supply
module, and the model of the extension cable.
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
programmable controller CPU No. 2 to No. 4.
Sets the CPU number for the host CPU.
Selects the CPU modules to be started up synchronously.
Online module change
Sets whether to allow the online module change in the multiple CPU system.
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
(refresh setting)
Multiple CPU high speed
transmission area setting
Network
Sets the latch range (start device number/end device number) clearable with the
File register extended
I/O assignment
parameter
Sets the number of points used for each device of the programmable controller CPU.
Local device start/end
device
setting
file.
programs are written to the programmable controller CPU
SFC
Multiple CPU
Sets the type, data name, transfer source drive, and transfer destination drive of the boot
Sets the file name and execution type (execution condition) of the program when several
Program
Device
Description
Sets whether to clear the program memory when booting up.
Sets the CPU shared memory to enable data sharing among multiple CPUs.
Sets the user setting area, auto refresh, assignment confirmation, and system area.
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.
Ehternet/CC IE/MELSECNET
CC-Link
Remote password
Sets the network parameters for Ehternet, MELSECNET/10, MELSECNET/H, and CC-Link
IE controller network.
Sets the parameters for CC-Link.
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.
Operation example: Changing the operation mode when an error exists
When a computation error is caused, the programmable controller CPU changes to
the STOP status at the default value, however, changing the parameters continues
the programmable controller CPU to run.
Computation error example
• In the division instruction, the processing to divide by 0 is executed.
1) Double-click "PLC parameter" on the navigation
window.
1) Double-click!
2) The Q Parameter Setting dialog box is displayed.
Click the "PLC RAS" tab.
2) Click!
3) Change the setting of "Computation Error" in
"Operation Mode When There Is an Error" to
"Continue"
4) Click the
3) Change!
4) Click!
3-5
End
button.
MEMO
3-6
CHAPTER 4 SEQUENCE AND BASIC INSTRUCTIONS -PART 14.1
List of Instruction Explained in this Chapter
This chapter explains the sequence instructions and basic instructions as shown
below.
Instruction
symbol
Instruction
Function
Drawing (devices to be used)
(Name)
OUT
Out
MC
Master
control
symbol
Function
Drawing (devices to be used)
(Name)
CJ
Coil output
Specifies a bit of a bit
device or word device.
Specifies a bit of a bit device
or word device.
Starting master
control
*1
Nn
MC Nn
n = 0 to 14
Nesting
Conditional jump
(non-delay)
CJ
Pn
n = 0 to 4095
Pointer
Conditional jump
SCJ
Jumps after one
scan
SCJ
Pn
n = 0 to 4095
Pointer
MCR
Master
Terminating
control
master control
reset
MCR
Nn
n = 0 to 14
Nesting
CALL
Calling subroutine
program
CALL
Pn
n = 0 to 4095
Pointer
Calling a
SET
Set
RST
Reset
PLS
Pulse
PLF
Pulf
SET
CALLP
Setting devices
Specifies a bit of a bit device
or word device.
RST
Specifies a bit of a bit device
or word device.
Pulse
Generating the
pulses for one
program cycle
when a input
signal turns off
Pulf
Generating the
pulses for one
program cycle
when a input
signal turns off
program (pulsing
operation)
RET
Resetting devices
subroutine
Return
CALLP Pn
n = 0 to 4095
Pointer
Returning from a
subroutine
RET
program
Terminating a
PLS
FEND
Specifies a bit of a bit device
or word device.
main routine
FEND
program
PLF
Specifies a bit of a bit device
or word device.
*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
symbol
(Name)
LD
Load
LDI
Load
inverse
AND
And
ANI
And
inverse
OR
Or
Instruction
symbol
(Name)
Function
Starting a logical
operation
Starting to operate
a normally open
Specifies a bit of a bit device
contact
or word device.
MRD
Intermediate
Lead
branching
Starting a logical
inverse operation
Starting to operate
a normally closed
contact
MPP
Terminating
Pop
branching
Function
Logical AND
operation
Series connection
of normally open
contacts
Logical AND
inverse operation
Series connection
of normally closed
contacts
Drawing (devices to be used)
Specifies a bit of a bit device
or word device.
NOP
Nop
Specifies a bit of a bit device
or word device.
END
End
Specifies a bit of a bit device
or word device.
Logical OR
operation
Parallel connection
of normally open
Specifies a bit of a bit device
contacts
or word device.
ANB
And block
ORB
Or block
MPS
Push
END processing of
terminating a
program
STOP
Stopping operation
SFT
1-bit shift for
Shift
devices
Logical OR inverse
operation
ORI
Parallel connection
Or inverse of normally closed
Specifies a bit of a bit device
contacts
or word device.
AND operation
between logical
blocks
Series connection
of blocks
Ignored
SFTP
Shift P
OR operation
between logical
blocks
Parallel connection
of blocks
NOPLF
Starting a branch
PAGE
1-bit shift for
Drawing (devices to be used)
For a space or deleting a
program
Must be used as an end of a
program.
STOP
SFT
Specifies a bit of a bit device
or word device.
SFTP
devices (pulsing
operation)
Specifies a bit of a bit device
or word device.
Ignored
(for a page break
NOPLF
at printing)
Ignored
(Recognized as
zero step of n-page)
4-2
PAGE
n
<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
symbol
(Name)
Function
LDP
Starting to operate
Load P
a rising pulse
LDF
Starting to operate
INV
Inverting the
Load F
a falling pulse
Inverse
operation results
Drawing (devices to be used)
Instruction
symbol
(Name)
Function
Drawing (devices to be used)
Converting a
MEF
Specifies a bit of a bit device
or word device.
Specifies a bit of a bit device
or word device.
result into a falling
pulse
Specifies a bit of a bit device
or word device.
Specifies a bit of a bit device
or word device.
Vn
ANDP
Series connection
EGP
And P
of rising pulses
Edge P
ANDF
Series connection
And F
of falling pulses
Specifies a bit of a bit device
or word device.
Converting a result
into a rising pulse
(Memorized by Vn)
Specifies a bit of a bit device
or word device.
Vn
ORP
Or P
ORF
Or F
EGF
Specifies a bit of a bit device
or word device.
Parallel
connection of
rising pulses
FF
Specifies a bit of a bit device
or word device.
Parallel
DELTA
connection of
falling pulses
DELTAP
result into a rising
pulse
Delta
Specifies a bit of a bit device
or word device.
Converting a
MEP
Edge F
Specifies a bit of a bit device
or word device.
Delta P
4-3
Converting a result
into a falling pulse
(Memorized by Vn)
Specifies a bit of a bit device
or word device.
FF
Inverting a device
output
Specifies a bit of a bit device
or word device.
Converting a
DELTA
direct output into a
pulse
DY
Converting a
DELTAP
direct output into a
pulse
DY
4.2
Differences between
OUT
and
SET / RST
Project name
Program name
QB-1
MAIN
OUT instruction
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
Project name
Program name
QB-2
MAIN
SET/RST instruction
X0
0
SET
Y70
RST
Y70
X1
2
• 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
Project name
Program name
QB-3
MAIN
K30
X5
T0
0
Timer setting value (time limit: 3.0sec.)
T0
Y70
5
T0
7
Y71
*: OUT T is a 4-step instruction.
[Timing chart]
• The timer contact
operates delaying by a set
time after the coil is
energized. (On delay
timer)
• The timer setting range is
from K1 to K32767.
Low-speed (100ms) timer
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.
Contact X5
Coil T0
3.0sec.
Normally open contact T0,
coil Y70
Normally closed contact 0b,
coil Y71
• The following four types of timer are available.
Type
Low-speed
timer·············
High-speed
timer·············
Low-speed
retentive
timer·············
Timer No. (default)
Counts time in
units of 100ms.
Counts time in
units of 10ms.
Accumulates
time in units of
100ms.
High-speed Accumulates
retentive
time in units of
timer············· 10ms.
Default
T0 to T2047 (2048)
Default: 0
The value can be
changed using the
parameter.
• Change the output
instruction (OUT) to
OUTH to select the
high-speed timer or
high-speed retentive timer.
• To use the retentive timer,
set the device points for
the retentive timer in the
device setting of the PLC
parameter.
Refer to section 6.4 for explanation on the retentive timers.
4-5
4.4
Counting by Counter
Project name
Program name
QB-4
MAIN
K12
X1
C20
0
Set value in counter
C20
Y72
5
X7
RST
7
C20
*: OUT C is a 4-step instruction.
[Timing chart]
Contact X1
Coil C20
1
2
3
(Current value of counter)
11
12
0
Contact C20, coil Y72
Contact X7 (input of RST instruction)
• The counter counts when
an input signal rises.
• After the count, the
subsequent input signals
are not counted.
• Once the counter counts,
the contact status and the
current counter value do
not change until the RST
instruction is executed.
• Executing the RST
instruction before the count
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.)
• In addition to the direct specification using K, indirect specification using D (data
register) is available.
Set value
Digital switch
D10
X0
0
2
4
0
C30
C30
D10
24
Y71
5
4-6
• The counter C30 counts
when the number of rising
edges on the input signal
X0 becomes the same as
the number (such as 24)
specified by the data
register D10.
• This indirect specification is
useful for applying a value
specified with an external
digital switch to the counter.
The indirect specification
using the data register D is
also available for the timer.
Project name
Program name
QEX1
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
Operation
Buzzer
(X0)
(Y70)
MC
(Y71)
Create the following ladder and check that it operates properly.
0
X0
C0
M0
During operation
Y70
K30
T0
Buzzer
Y71
K6
C0
Operating the conveyor
M0
4
7
12
14
19
M0 Y71
M0
T0
X1
Y71
RST
4-7
C0
3-sec. timer
Counter for counting
the number of packages
Operating Procedure
(1) Creating a new project
(a) Click
on the toolbar.
Click
(b) The New Project dialog box is displayed.
Set "Project Type" to "Simple Project", "PLC Series" to "QCPU (Q mode)",
and "PLC Type" to "Q06UDH". Then click the OK button.
Click
(c) If the project in preparation exists, the confirmation dialog box for saving
the project is displayed.
Click the No button.
Click
(d) The screen shifts to the new project creation mode.
4-8
(2) Creating a program
[Using the keyboard]
F5
X
Shift + F5
0
C
F7
0
M
0
F4
Conversion
[Using the tool buttons]
Enter "X0" after
clicking
.
(a) Click
Click
on the toolbar to open the
Enter Symbol window.
(b) Enter "X0" with the keyboard and click
the
Enter "C0" after
clicking
.
OK
on the toolbar to open the
(c) Click
Click
button.
Enter Symbol window.
(d) Enter "C0" with the keyboard and click
the
Enter "M0" after
clicking
.
OK
button.
on the toolbar to open the
(e) Click
Enter Symbol window.
(f) Enter "M0" with the keyboard and click
the
OK
button.
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
on the toolbar.
The Online Data Operation dialog box is displayed.
Click
(b) Click the Parameter + Program button. Checkboxes for the target
program and the target parameter displayed in the window are
automatically marked ( ).
(c) Click the
Execute
button.
Click
Click this button after the
program name (MAIN) and
PLC parameter appear and
their checkboxes are marked.
4 - 10
(d) If parameters have been already written, the confirmation dialog box for
overwriting the parameters is displayed. Click the Yes button.
Click
(e) The Write to PLC dialog box is displayed.
(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.
(a) Click
on the toolbar.
Click
(b) The ladder (write) screen is used to monitor the ladder.
Operation Practice
1)
2)
3)
Turning on the push button switch (X0) turns on Y70 and starts T0 at the
same time.
When the timer T0 counts three seconds (time-out), Y70 turns off and Y71
turns on at the same time.
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.)
Project name
Program name
1
X0
0
PLS
M5
PLF
M0
2
X1
3
1
QB-5
MAIN
• 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
2
One scan
• 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
4 - 14
One scan
Application
• The instructions can be used in the standby program that waits for the operation
condition.
Execution command
X0
PLS
M0
SET
M5
M0
M5
Y70
Execution condition
K50
TO
TO
RST
M5
[Timing chart]
X0
(trigger)
M0
M5
Y70
(operation)
5sec.
Time to wait for
condition met
user)
Bit
PLS
D
PLF
D
Word
File
register
R
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Bit
Word
Un\G
Index
register
Z
K
H
P
Level
(system or
Pointer
Internal device
Constant
Applicable device
I
N
Digit
Number of basic
steps
Execution
condition
2
D
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
SET
Y70
M0
Product
Sensor
Y70
Sensor
(Detection of input from X0)
Conveyor
[Timing chart]
X0
M0
Y70
Other Useful Ways of PLS and PLF
Part 1
• The instructions can be used for a program that executes the output operation for
a set period of time when the input signal changes from on to off.
[Timing chart]
Input
(X0)
Output
(Y76)
Set time limit
10sec.
Pulse duration
[Program example]
Project name
Program name
0
3
X0
M1
PLF
T16
Y76
QB-6
MAIN
M1
K100
T16
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
Program name
0
5
X0
M0 Y70
QB-7
MAIN
PLS
M0
PLF
M1
Y70
M0 Y70
11
M1 Y71
Y71
M1 Y71
4 - 17
Project name
Program name
QEX2
MAIN
Ladder example
Create the following ladder and check that it operates properly.
0
3
X2
M0
PLS
X0
M0
Y70
Y70
7
10
X3
M1
PLF
X1
M1
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.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
Related Exercise –––– Exercise 3
REMARK
Input pulse processing is not required for the QCPU as it uses a derivative
contact ( / ).
[For A/AnSCPU]
X0
PLS
M0
SET
M5
SET
M5
M0
[For QCPU]
X0
Supported instructions are; LDP, LDF, ANDP, ANDF, ORP, and ORF.
4 - 19
Master Control
MC
MCR
(Start)
Master Control Reset
(End)
Project name
Program name
QB-8
MAIN
X7
0
MC
NO
M98
X2
Y70
3
X3
Y71
5
7
MCR
NO
• The above program is a basic one.
• MC N
M
to MCR N
(indicated as "MC to MCR" hereafter.)
The available nesting (N) numbers for "MC to MCR" are from N0 and N14.
• The scan time skipped by "MC to MCR" hardly changes.
The device status of the program skipped by "MC to MCR" becomes as follows;
All the devices in the OUT instruction are turned off.
The devices in the SET, RST, and SFT instructions, the counter, and retentive
timer keep their statuses.
The 100ms timer and 10ms timer are reset to 0.
Applicable device
user)
Bit
MC
MCR
n
D
n
Word
register
R
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Bit
n
Word
Un\G
Index
register
Z
K
H
P
Level
(system or
File
Pointer
Internal device
I
N
Digit
Number of basic
steps
Application
• The instructions can be used for a program for switching between manual and
automatic operations. (Refer to Ladder example.)
Constant
4.6
2
D
1
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
• The MC and MCR instructions can be nested as shown below.
Project name
Program name
0
2
N0
5
10
QB-9
MAIN
X5
Y70
X2
MC N0 M6
M6
X6
K5
C0
X3
MC N1 M7
1
N1
13
M7
X7
K100
TO
18
19
MCR N1
X8
Y71
21
22
24
N0
27
MCR N0
X0
SET Y72
X4
MC N0 M8
2
M8
X1
N0
c
RST Y72
29
30
N1 N0
b a
MCR N0
X9
Y73
3
32
M6
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.
3
• As shown in the
as a contact.
d
program, the internal relay number M
of MC can be used
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
Program name
QEX3
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.
0
Manual
X7
10sec.
MC
N0
N0 M10
X2 M82
3
X3 M81
6
9
10
Automatic
X7
N0 M11
X0
13
Y70
T1
N1 M12
Y70
19
M71
M72
27
MCR
MC
N0
M81
Instruction for manual low-speed
M82
Instruction for manual high-speed
N0
M11
Y70
MC
N1
T0
M72
34
35
M10
MCR
M71
Automatic start
M12
M71
K30
T0
Instruction for auto low-speed
M72
K100
T1
Instruction for auto high-speed
N0
Y71
Low-speed operation
Y72
High-speed operation
M81
38
M72
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.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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
Project name
Program name
4.7.1
FEND
QB-10
MAIN
F end
FEND
FEND is a 1-step instruction.
• 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
Operation
when CJ is
not executed
Sequence program
Sequence program
Jump by CJ
CJ
FEND
P**
Sequence program
P**
Operation when
CJ is executed
P**
Subroutine program
I**
FEND
Interrupt program
P**
Sequence program
END
END
(a) When operating in each program block
by the CJ instruction
(b) When using the subroutine
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
Program name
QEX6
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.
0
3
X3
CJ
X4
Y70
5
P10
6
P10
FEND
X5
Y72
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
0
3
X3
CJ
X4
Y70
5
P10
6
P10
FEND
X5
Y72
9
END
(1) When X3 is off
(a) The operation is executed from 0
to FEND.
(b) Turning on or off X4 turns on or
off Y70.
(c) Turning on or off X5 does not
change Y72.
(2) When X3 is on
(a) The program jumps to the pointer
P10 by the CJ instruction.
(b) Turning on or off X4 does not
change Y70.
(c) Turning on or off X5 turns on or
off Y72.
Related Exercise –––– Exercise 4
4 - 26
Operation when X3 is off
0 LD
X3
1 CJ
P10
3 LD
X4
4 OUT
Y70
Jump by CJ
5 FEND
6 P10
7 LD
X5
8 OUT
Y72
9 END
Operation when X3 is on
4.7.2
CJ
SCJ
(Conditional jump: instantaneous execution condition jump)
(S conditional jump: execution condition jump after one scan)
1
X0
CJ
0
P10
2
X1
SCJ
3
X0
P10
X1
6
Y70
FEND
9
Pointer
P10
X3
10
Y71
1
• The CJ instruction instantaneously executes a program jumping it to the specified
address (pointer number) when the execution command is on.
When the command is off, the program is not jumped.
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)
CJ
Executes every scan
Executes
every scan
SCJ
One scan
Executes
every scan
Executes
every scan
One 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.)
Start
0
When CJ is not
executed
Sequence program A
Step 0
Input condition
Sequence
program A
When CJ is
executed
CJ
Step 0
P
CJP
Sequence program B
YES
Is input
condition on?
FEND
P
NO
Sequence
program B
FEND
P
Sequence program C
END
Sequence
program C
END
• The status of ladders skipped by the CJ instruction remains unchanged.
(Before CJ execution)
(During CJ execution)
X0
X0
CJ
1100
P10
X2
P10
X2
Y72
1103
PLS
Y72
1103
X1
P10
1330
CJ
1100
P10
1330
M1
X1
PLS
Because X0 is on, all instructions
within this area are not executed.
Hence Y72 remains on even
after X2 is turned off.
M1
user)
Bit
CJ
P**
SCJ
P**
Word
File
register
R
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Bit
P
Word
Un\G
Index
register
Z
K
H
P
Level
(system or
Pointer
Internal device
Constant
Applicable device
I
N
Digit
Number of basic
steps
• 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.
2
4 - 28
Project name
Program name
QEX4
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.
0
3
6
P10
9
10
X0
X1
X0
X1
CJ
P10
SCJ
P10
Y70
FEND
X3
Y71
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
4 - 29
Operation Practice
(1) When X0 and X1 are off, the CJ and SCJ
instructions are not executed.
Therefore, Y70 is on.
(2) When X0 is turned on, the CJ instruction is
executed and the program jumps to P10.
Therefore, Y70 remains on.
[During CJ execution] First scan and subsequent
scans
[Before CJ and SCJ execution]
X0
X0
CJ P10
CJ P10
X1
X1
SCJ P10
SCJ P10
X0 X1
X0 X1
Y70
Y70
FEND
P10
FEND
X3
P10
Y71
X3
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
and
subsequent
scans
after ON
CJ P10
First scan
after ON
X1
SCJ P10
X0 X1
X0
CJ P10
X1
SCJ P10
X0 X1
Y70
Y70
FEND
P10
FEND
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
X1
3
LD
X1
3
LD
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
Related Exercise –––– Exercise 4
4 - 30
4.7.3
CALL(P)
Call
Executing a subroutine program
Return
RET
M0
0
M5
CALL
P10
CALL
P10
X2
50
Sequence
program
FEND
103
1
P10
X1
2
Y70
104
Subroutine
program
157
1
2
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.
• 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.
• 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.
(When CALL P10 is not executed)
0
0
(When CALL P10 is executed)
0
Sequence program
CALL P10
Input condition
CALL
Next step
after CALL
P10
Sequence program
FEND
P10
FEND
P10
FEND
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.
Sequence program
0
Subroutine
program
Subroutine
program
Subroutine
program
Subroutine
program
Subroutine
program
P1
P2
P3
P4
P5
CALL P3
CALL P1
CALL P5
CALL P4
CALL P2
RET
RET
RET
RET
RET
FEND
The following ladder circuit shows the above nested program.
0
CALL
P1
Sequence program
FEND
P1
CALL
P2
Subroutine program P1
RET
P2
CALL
P3
Subroutine program P2
RET
P3
CALL
P4
Subroutine program P3
RET
P4
CALL
P5
Subroutine program P4
RET
P5
user)
Bit
CALL(P)
P**
Word
File
register
R
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Bit
Word
P
Un\G
Index
register
Z
K
H
P
Level
(system or
Pointer
Internal device
Constant
Applicable device
I
N
Digit
Number of basic
steps
Subroutine program P5
RET
2
1
RET
The number of basic steps of CALL (P) is 2 tn, and that of the RET instruction is one.
("n" is an argument passed to the subroutine.)
4 - 32
Project name
Program name
QEX5
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.
0
3
5
P10
6
X2
CALL
X3
P10
Y70
FEND
X4
Y71
RET
9
Operating Procedure
The following procedures are the same as the Operating Procedure in section
4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
0
3
X2
CALL
X3
Y70
5
P10
6
P10
FEND
X4
Y71
9
RET
10
END
(1) When X2 is off
(a) The operation is executed from 0 to
FEND.
(b) Turning on or off X3 turns on or off
Y70.
(c) Turning on or off X4 does not change
Y71.
(2) When X2 is on
(a) After the subroutine of P10 is
executed, the operation from step 3
to FEND is executed.
(b) Turning on or off X3 turns on or off
Y70.
(c) Turning on or off X4 turns on or off
Y71.
Related Exercise –––– Exercise 4
4 - 34
Operation when X2 is off
0 LD
1 CALL
3
LD
4
OUT
5
FEND
6
P10
7
LD
8
OUT
9
RET
X2
P10
X3
Y70
X4
Y71
Operation when X2 is on
Project name
Program name
4.8
4.8.1
QTEST1
MAIN
Exercise
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
0.5sec. 0.5sec. 0.5sec. 0.5sec.
Create the following program with GX Works2 filling in the blanks
check the operation using the demonstration machine.
0
X0
2)
Y70
1)
4
Y70
3)
T0
4)
10
T1
K5
K5
Y74
5)
16
Y70
Y77
4 - 35
. Then,
Project name
Program name
4.8.2
QTEST2
MAIN
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
check the operation using the demonstration machine.
X0
1)
0
2
M0
M1
T1
T0
T0
T1
T0
2)
K10
Y70
K10
C0
3)
4)
23
T2
30
K10
T2
RST
M1
5)
X1
6)
36
7)
8)
1)
2)
3)
4)
5)
6)
7)
8)
4 - 36
K50
. Then,
Hint
(1) The following shows the timing chart of the program.
X0
M0
X1
Restart
Contact T0
1sec.
Contact T1
Y70
1sec
One scan
1sec. 1sec.
5sec.
Contact C0
Counter of C0 1.
2.
10.
1.
2.0.
(2) The following shows the basic flickering ladder and its timing chart.
[Ladder]
T1
[Timing chart]
K10
T0
T0
Contact
T0
1sec.
K10
T1
Start
Contact
T1
1sec.
One scan
REFERENCE
• The flickering ladder can be created using the special relay that generates
clock as shown below.
In addition to the SM413 (2-sec. clock) on
SM413 (2-sec. clock)
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
SM414 (2n-sec. clock)
1sec. 1sec.1sec.
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
Program name
4.8.3
QTEST3
MAIN
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
check the operation using the demonstration machine.
0
5
X0
M0 Y70
1)
M0
2)
M1
Y70
M0 Y70
11
M1 Y71
Y71
M1 Y71
1)
2)
4 - 38
. Then,
Project name
Program name
4.8.4
QTEST4
MAIN
Exercise 4
CJ, CALL, RET, FEND
Y70 and Y71 flicker for 0.5sec. alternately when X7 is off, and when X7 is on, Y72
and Y73 flicker for 1.0sec. alternately. Turning on X0 resets the currently flickering
Y70 to Y73.
Fill in the blanks
. Then, check the operation using the demonstration machine.
X7
SM401
CJ
1)
RST
Y72
RST
Y73
T11
T10
T10
K5
K5
T11
Y70
T10
Flip flop
ladder
Y71
X0
2)
P10
3)
P0
SM401
RST
Y70
RST
Y71
T20
T21
T21
K10
T20
K10
Y72
T21
Y73
X0
4)
P10
5)
P10
SM401
RST
Y70
RST
Y71
RST
Y72
RST
Y73
6)
4 - 39
Flip flop
ladder
Hint
1)
2)
3)
4)
5)
6)
START
X7 ON?
<CJ P0>
Y
N
P0
Y72,Y73
Reset
Y70,Y71
Y72,Y73
1-sec. flickering
0.5-sec. flickering
X0 ON?
Y70,Y71
Reset
Y
X0 ON?
Y
N
N
P10
Y70Y73
Reset
Subroutine
program
<FEND>
<FEND>
END
4 - 40
Answers for the exercises in Chapter 4
Exercise No.
1
2
3
4
Answer
1)
Y70
2)
X1
3)
T1
4)
T0
5)
Y74
1)
SET M0
2)
C0
3)
Y70
4)
SET M1
5)
RST C0
6)
RST M0
7)
RST C0
8)
RST M1
1)
PLS
2)
PLF
1)
P0
2)
CALL
3)
FEND
4)
CALL
5)
FEND
6)
RET
4 - 41
MEMO
4 - 42
CHAPTER 5 BASIC INSTRUCTION -PART 25.1
Notation of Values (Data)
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"
n
10
: Digit number (0, 1, 2...)
: Decimal
In the MELSEC-Q series programmable controller, symbol "K" is used for
expressing values in decimal.
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
2
2
2
4
2
2
3
2
2
1
2
2
64
32
16
8
4
2
1
Binary
Base number raised
to the power of digit
("Binary")
7
128
6
5
0
= Bit weights
The binary number is broken as follows.
= 1 × 128 + 0 × 64 + 0 × 32 + 1 × 16 + 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1
= 128 + 16 + 8 + 4 + 1
= 157
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.
Decimal
Hexadecimal
Binary
0
0
0
1
1
1
2
2
10
3
3
11
4
4
100
5
5
101
6
6
110
7
7
111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111
16
10
10000
17
11
10001
18
12
10010
…
…
…
19101
4A9D
0100 1010 1001 1101
3
2
1
0
Digit number
4
A
9
D
Hexadecimal
3
2
"Power of digit"
n: Digit number
1
= (4) × 16 + (A) × 16 + (9) × 16 + (D) × 16
= 4 × 4096 + 10 × 256 + 9 × 16 + 13 × 1
= 19101
0
16: Hexadecimal
Four bits of a binary number equal to one digit of a hexadecimal number.
In the MELSEC-Q series programmable controller, symbol "H" is used for
indicating a hexadecimal number.
The hexadecimal system is used to represent the following device numbers.
• Input and output (X, Y)
• Function input and output (FX, FY)
• Link relay (B)
• Link register (W)
• Link special relay (SB)
• Link special register (SW)
• Link direct device (Jn\X, Jn\Y, Jn\B, Jn\SB, Jn\W, Jn\SW)
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)
0001
842
0101
8
1
2
4
Power of digit
0111
1
8
BCD
Binary bit weights
4 2 1
In BCD, decimal numbers 0 to 9999 (the biggest 4-digit number) can be
represented by 16 bits.
The diagram below shows the bit weights of BCD.
Thousand digits
Hundred digits
Ten digits
1
0
1
1
1
2
1
0
4
1
8
200
0
10
400
1
20
0
40
0
80
0
100
0
800
4000
0
1000
0
2000
0
8000
Unit digit
BCD is used for the following signals.
1) Output signals of digital switches
2) Signals of seven-element display (digital display)
0
1(0)
2(0)
4(0)
8(0)
COM
1
2
(1)
(0)
(0)
(0)
3
(0)
(1)
(0)
(0)
4
(1)
(1)
(0)
(0)
5
(0)
(0)
(1)
(0)
6
(1)
(0)
(1)
(0)
BCD code digital switch
5-4
7
(0)
(1)
(1)
(0)
8
(1)
(1)
(1)
(0)
9
(0)
(0)
(0)
(1)
(1)
(0)
(0)
(1)
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
157
128
Bit
weights
29
16
13
8
5
4
1
1
0
2)
Quotient
Remainder
2
157
2
78
1
2
39
0
2
19
1
2
9
1
2
4
1
2
0
1
0
2
1
0
0
1
1
1
0
1
128
64
32
16
8
4
2
1
How to convert the decimal number into the hexadecimal number
In the example below, a decimal number 157 is converted into the hexadecimal number.
1)
16
157
9
1
0
0
1
1
1
0
13(D)
9
5-5
D
1
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
0
1
1 byte
0
0
0
0
0
0
0
0
1
0
0
1
1
1 word (2 byte)
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
● Registers of each word device in the MELSEC-Q series programmable controller consist of 16
bits.
• Data register D D0
• Current value of
(Binary bit weight)
timer T
• 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
● The range 2) is available for the MELSEC-Q programmable controller.
The negative numbers adopt two's complement against the positive numbers (1 to +32767).
● In the two's complement, each binary bit is inverted, and 1 is added to the least significant bit.
Example)
How to calculate the two's complement against 1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
Invert all bits.
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
The most significant bit of "1" means negative.
The most significant bit corresponds to the sign of a signed binary number.
5-6
Add 1 to the least
significant bit.
BCD (binary coded decimal)
BIN (binary)
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
00000001 00000000
00000000 01100100
100
0064
00000001 00100111
00000000 01111111
127
007F
00000010 01010101
00000000 11111111
255
00FF
00010000 00000000
00000011 11101000
1000
03E8
00100000 01000111
00000111 11111111
2047
07FF
01000000 10010101
00001111 11111111
4095
0FFF
00100111 00010000
10000
2710
01111111 11111111
32767
7FFF
11111111 11111111
-1
FFFF
11111111 11111110
-2
FFFE
10000000 00000000
-32768
8000
5-7
K (decimal)
H (hexadecimal)
System configuration and I/O number of demonstration machine
Output module
CPU module
Input module
Power supply module
Base unit Q38DB
Q61P QCPU Vacant
slot
QX
QY Q64 Q62
42
42P
AD DAN
(64
(64
(16
(16
points) points) points) points)
X0
to
X3F
USB cable
Y40
to
Y7F
Peripheral device
I/O panel
Y6F
Y77
Y76
Y75
Y74
Y73
Y72
Y71
Y70
Y7F
Y7E
Y7D
Y7C
Y7B
Y7A
Y79
Y78
X7
X6
X5
X4
X3
X2
X1
X0
Y60
X3F
ON
X30
1 9 4 2
Y5F
X2F
Y50
Y4F
Y40
X20
4 1 3 6
MELSEC-Q
OFF
XF
XE
XD
XC
XB
XA
X9
A/D INPUT
X8
ON
OFF
5-8
D/A OUTPUT
5.2
5.2.1
Transfer Instruction
MOV (P)
Project name
QB-11
Program name
MAIN
16-bit data transfer
X7
K50
T0
0
T0
K1500
T0
C10
X1
13
RST
C10
S
D
MOV
T0
D0
MOVP
C10
D1
MOVP
K157
D2
X2
18
1
X3
21
2
X4
24
3
X5
27
1
MOVP
H4A9D
D3
● 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
(4)
(A)
(9)
(D)
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
D3 0 1 0 0 1 0 1 0 1 0 0 1 1 1 0 1
Hexadecimal
numbers
Binary numbers
Bit weights
Difference between MOV and MOVP
The P of MOVP stands for a pulse.
Input condition
MOV
Data is transferred every scan
while the input condition is on.
MOVP
Data is transferred only one scan
after the input condition turns on.
(For only once)
Executed only once.
● Use the
MOV
Use the
instruction when reading the changing data for all the time.
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
K157
D2
MOV
device
File
MELSECNET/10
(system or
register
(H) Direct Jn\
user)
Bit
MOV
S
D
Word
Intelligent
function
module
Index
register
Constant
Level
Internal
Pointer
Applicable device
Un\G
R
Bit
Word
S
Z
K
H
P
I
Digit
Number of basic
steps
M1
N
*
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.
Monitor the contents of the data registers D0 to D3.
• After writing the data to the programmable controller, click [Online] →
[Monitor] → [Device/Buffer Memory Batch].
The Device/Buffer Memory Batch Monitor dialog box is displayed.
• 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.
This is a decimal number
equivalent to a hexadecimal 4A9D.
Indicates the word devices in the on/off of the bit units.
: OFF (0 in binary)
: ON (1 in binary)
1
0
1
1
1
2
1
4
0
8
0
16
1
(D)
32
0
64
1
128
0
(9)
256
1
1024
0
2048
0
4096
1
8192
0
16384
D3
(A)
512
(4)
Hexadecimal
numbers
H4A9D
Binary bit
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.
[Device/Buffer Memory Batch Monitor screen]
• 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.
[Device/Buffer Memory Batch Monitor screen]
Values
in D0
5 - 13
Values
in D1
Values
in D2
Values
in D3
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.
0
5
X0
MOV
K200
D0
MOV
D0
D1
X1
RST
D0
RST
D1
Operating Procedure
The following procedures are the same as the
Operating Procedure
in section 4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
• How to modify the
transfer instruction
To modify the transfer instruction, follow the procedures below.
Example: Change the transfer data K200 of [MOV K200 D0] to K100
1) Double-click the instruction to be modified.
2) The Enter Symbol window is displayed.
3) Write "1" over "2" of "MOV K200 D0".
4) Click the
OK
button on the Enter Symbol window.
All data in
can be modified with the above method.
When "Insert" is displayed, press the Insert key to change it to "Ovrwrte"
before modifying.
5) After finishing modifications, click [Compile] → [Build].
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.
0
X0
MOV
K200
D0
MOV
D0
D1
200
200
5
200
X1
10
RST
D0
RST
D1
END
When X0 turns on, the current values
of D0 and D1 become 200.
Related Exercise ---- Exercise 5
5 - 15
QB-12
MAIN
BCD → BIN data conversion instruction
BIN (P)
Operations to read and write data after step 35
X7
K50
T0
T0
0
K1500
T0
C10
S
D
BINP
K4X20
D5
MOV
K4X20
D6
X0
30
X0
34
Check the difference
from the BIN instruction.
• 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
S side BCD 9999
0
1
0
1
1
Thousand digits
0
0
80
40
20
10
8
4
2
1
1
0
0
1
1
0
0
1
1
Hundred digits
Ten digits
Unit digits
Converted into BIN
16384 8192 4096 2048 1024 512 256 128 64 32 16
D side BIN 9999
0
0
1
0
0
1
1
1
0
0
0
0
8
4
2
1
1
1
1
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.
1)
4
8
2) 1)
4)
2
1
0
1
0
0
0
1
1
0
1
0
0
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
0
0
0
0
1
0
0
1
1
0
1
0
0
1
0
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
0
X20
0
X21
1
X24
0
X25
0
X28
0
X29
X22
8
X23
1
X26
2)
X27
4
Digital switch
X2A
8
4
X2B
X2C
2
X2D
4
3
X2E
8
2
16384
1024
128
64
16
2
1234
1
16384
4096
512
32
16
4
4660
X2F
5.2.2
Project name
Program name
5 - 16
K4X20
D6
When the BCD code
is input without converted.
D5
When the BCD code is input after
converted into the binary code.
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.
X21
4) 2
X22
8
X23
2) 1)
X24
4
X25
8
X26
X29
2) 1
Number
of digits
4
1
K4 X20
X20
3
X27
4
X2A
8
X2B
1)
X2C
2
X2D
4
X2E
X2F
8
2
X28
1
Start number
K2X28
Specify these devices to
read two-digit data "12".
K1X20
(X23 to X20)
(X2F toX28)
K2X20
(X27 to X20)
Read one-digit data "4".
Read two-digit data "34".
K3X20
(X2B to X20)
Read three-digit data "234".
K4X20
(X2F to X20)
Read four-digit data "1234".
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
(system or
user)
File
register
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Index
register
Constant
Level
Internal device
Pointer
Applicable device
Un\G
Bit
Word
R
Bit
Word
S
K
H
P
I
N
K1
S
MOV
Z
Digit
Number of basic
steps
* A sample program using a digital switch to import data is provided
in page App. - 46.
D
to
D
K4
5 - 17
3
QB-13
MAIN
BIN → BCD data conversion instruction
BCD (P)
X7
K50
T0
T0
0
K1500
T0
C10
S
D
BCD
T0
K2Y40
BCD
C10
K4Y50
X6
37
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
S side BIN 9999
0
0
1
0
0
1
1
1
1
0
0
1
1
Thousand digits
32
16
8
4
2
1
0
0
0
1
1
1
1
Converted into BCD.
8000 4000 2000 1000 800 400 200 100
D side BCD 9999
64
0
Must be set to "0".
0
0
1
80
40
20
10
8
4
2
1
1
0
0
1
1
0
0
1
Hundred digits
Ten digits
Unit digits
2
1
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
1
1
8
4
2
1)
8
4 2)
1
8
4
2 1)
8
Y50
4
1
Y51
8
1
Y52
16
1
Y53
32
1
Y54
64
0
Y55
128
1
Y56
256
0
Y57
512
0
Y58
1024
1
Y59
2048
0
Y5A
4096
0
Y5B
8192
0
Y5C
0
Y5D
0
Y5E
+
1024
128
32
16
8
4
1
1213
16384
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).
Y5F
5.2.3
Project name
Program name
C10
(BIN)
(BCD)
K4Y50
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).
Y43
Y42
Y41
Y40
8
4
2
1
800
400
200
100
80
40
20
10
Y47
Y46
Y45
Y44
Y4B
Y4A
Y49
Y48
Y4F
Y4E
Y4D
Y4C
8000
4000
2000
1000
80000
40000
20000
10000
COM
Y53
Y52
Y51
Y50
Programmable controller Output module
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)
DBCD
T5
K5Y40
File
(system or user) register
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
Index
register
Constant
Level
Internal device
Pointer
Applicable device
Un\G
Bit
Word
R
Bit
S
Z
K
H
P
I
N
K1
S
BCD
Word
Digit
Number of basic
steps
2
D
to
D
K4
5 - 19
3
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.
0
X0
C0
BCD
8
C0
X1
K10
K2Y40
RST
C0
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
Y5C
Y58
Y54
Y50
to Y5F to Y5B to Y57 to Y53
Y4C
Y48
Y44
Y40
to Y4F to Y4B to Y47 to Y43
0 to 10
BCD digital display
Related Exercise ---- Exercise 6
5 - 20
Displays the value of C0.
5.2.4
Example of specifying digit for bit devices and transferring data
Program example
Process
When the destination data D is a word device
S
X3X2X1X0
D
K1X0 1 1 0 1
MOVP
K1X0
D0
Becomes 0.
• Source: Source device
• Destination: Destination device
B15
B4 B3 B2 B1 B0
D0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1
When the source data S is a word device
MOV
S
D
D0
K2M100
B15
B8 B7
B0
D0 1 1 1 0 1 0 1 0 1 0 0 0 1 1 0 1
M115
M108M107
M100
1 0 0 0 1 1 0 1
K2M100
No change
When the source data S is a constant
MOV
S
D
H1234
K2M0
1
2
3
4
H1234 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
M15
M8 M7
M0
0 0 1 1 0 1 0 0
K2M0
No change
3
4
When the source data S is a bit device
S
MOV
M15
D
M8 M7
M4M3
M0
K1M0 1 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
K1M0 K2M100
0
M108 M107
M115
M100
0 0 0 0 1 1 0 1
K2M100
No change
5 - 21
M104 M103
Zero is Data of M3
transferred to M0 are
transferred.
5.2.5
FMOV (P)
FMOV (Batch transfer of the same data)
BMOV (P)
BMOV (Batch transfer of the block data)
S
D
n
FMOVP
K365
D0
K8
FMOVP
K7000
D8
K16
S
D
n
BMOVP
D0
D32
K16
FMOVP
K0
D0
K48
X3
0
Project name
QB-14
Program name
MAIN
X4
5
X5
10
X6
15
Operation Explanation
Input
condition
FMOVP
S
D
n
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 ).
Example
The FMOV instruction executes the following operation when X3 is
turned on.
D
S
K365
365
365
D0
365
D1
365
D2
365
D7
n
8 devices (K8)
The FMOV instruction is useful for clearing many data sets in batch.
Example
Input
condition
Same
FMOV
K0
D0
K8
Input
condition
RST
D0
RST
D1
RST
D7
The FMOV instruction can substitute the RST instructions as shown above.
5 - 22
Input
condition
BMOVP
S
D
n
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 ).
Example
The BMOV instruction executes the following operation when X5 is
turned on.
S
D
365
D0
365
D32
D7
365
365
D39
D8
7000
7000
D40
D15
7000
7000
D47
File
(system or user) register
MELSECNET/10
(H) Direct Jn\
Intelligent
function
module
Index
register
Constant
Level
Internal device
Pointer
Applicable device
Un\G
Bit
FMOV
S
D
n
BMOV
S
D
n
Word
R
Bit
Word
Z
K
H
(Note) (Note) (Note)
S
P
I
Digit
Number of basic
steps
The BMOV instruction is useful for the following:
• Filing logging data
• Saving important data (such as automatic operation data and measured data)
into the latch area. This can prevent a data loss caused by a power failure.
N
K1
to
D
4
K4
n
(Note) Not available in the BMOV instruction.
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
condition
As D specifies
a two-digit number,
these data are
ignored.
FMOV
S
D
n
D0
K2Y40
K4
S
D
D0 (Example: when the content is 365)
D
Y4F
Y48
0 1 1 0 1 1 0 1
Y47
Y40
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
D
4 devices (K4)
D
Y5F
Y58
0 1 1 0 1 1 0 1
Y57
Y50
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
condition 2)
Bit pattern of K255
FMOV
K0
K2Y40
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
K4
In units of four bits, to turn off;
16 bit devices or less
MOV instruction
Example
MOV
K0
K4M0
32 bit devices or less
DMOV instruction
Example
DMOV
K0
K8M0
More than 32 bit devices
FMOV instruction
Example
FMOV
K0
K4M0
K4
(Turns off 64 bit devices)
BMOV instruction
Input
condition
As D specifies
BMOV
a two-digit number,
these data are
ignored.
D0
3
0
5
S
D
n
D0
K2Y40
K4
D
1
D
Y4F Y48
D1
3
0
5
7
5
7
Y47 Y40
1
5
n
D2
3
0
5
6
D3
3
0
5
5
D
D
Y5F Y58
5
4 devices (K4)
5
Y57 Y50
5
6
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.
0
5
X0
X1
FMOV K200
D0
K5
FMOV K0
D0
K5
Operating Procedure
The following procedures are the same as the
Operating Procedure
in section 4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
Related Exercise ---- Exercise 7
5 - 26
5.3
Project name
QB-15
Program name
MAIN
Comparison Operation Instruction
Size
comparison
K100
X3 SM413 (2-sec. clock)
C10
0
X4
BCD C10 K4Y40
6
>
S1
K10
S2
C10
Y70
15
<=
S1
K10
S2
C10
Y71
19
=
K20
C10
Y72
23
<>
K30
C10
Y73
27
>
K20
C10
Y74
<
K40
C10
34
<=
K25
C10
>=
K35
C10
Y75
41
<=
K10
C10
>=
K20
C10
Y76
<=
K40
C10
>
K50
C10
10
=
55
K100 C10
RST C10
X0
The comparison operation instruction compares the data of source 1 ( S1 )and
source 2 ( S2 ), and brings the devices into conduction when the conditions are
met.
The instruction can be regarded as one normally open contact (
) since it is
conducted only when the conditions are met.
K20
C10
K40
C10
Y74
Y74
●
S1
S2
······ Becomes conducted when source 1 and source 2 match.
●
S1
S2
······ Becomes conducted when source 1 is smaller than source 2.
●
S1
S2
······ Becomes conducted when source 1 is larger than source 2.
●
S1
S2
······ Becomes conducted when source 1 and source 2 match or
●
S1
S2
when source 1 is smaller than source 2.
······ Becomes conducted when source 1 and source 2 match or
when source 1 is larger than source 2.
●
S1
S2
······ Becomes conducted when source 1 and source 2 do not match.
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.
The range where Y70 to Y76 turn on
Y70
Output
Y71
Y72
Y73
Y74
Y75
Y76
012345
10
15
20
25
30
35
40
45
50
Count (the current value of the counter C10)
Differences between
>
and > =
>
K50
C10 equals to 49.
>=
K50
C10 equals to 50.
File
(system or user) register
MELSECNET Intelligent
/10 (H) Direct
function
Jn\
module
Index
register
Constant
Level
Internal device
Pointer
Applicable device
Un\G
Bit
Comparison
instruction
Word
R
Bit
Z
K
H
P
I
N
K1
S1
S1
Word
Digit
Number of basic
steps
The counter is designed to be reset every 200sec.
In this way, the comparison instruction does not only compare one data but
also specifies the range. This function is commonly used for the program to
judge the acceptances of products.
S2
to
S2
K4
5 - 28
3
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
Y70:ON
T0:
0
0
2
8
2.8
3.1
3.2
6.0 sec.
SET
M0
T0
T0
K60
M10
K30
T0
14
<
K27
T0
<
K30
SM400
T0
29
3.0
M0 M10
>
25
2.9
Y72:ON
X0
10
21
Y71:ON
Y70
>
K33
T0
Y71
Y72
BCD
X1
T0
RST
Operating Procedure
(1) Reading data
Read the project data.
● Click
on the toolbar.
Click
5 - 29
K2Y40
M0
● The Open dialog box is displayed. Specify the save destination.
● Double-click the displayed workspace "SCHOOL".
Double-click
● Click "QEX10" and click the
Open
button.
Click
Click
The following procedures are the same as the Operating Procedure in section 4.4.
(2) Writing the project to the programmable controller
(3) Monitoring the ladder
5 - 30
Operation Practice
Turn on X0 and check that the program works properly.
X0
0
SET
M0
M0
K60
M10
2
T0
30
T0
8
M10
K30
10
T0
Y70
30
K27
14
T0
K33
T0
30
K30
21
Y71
30
T0
Y72
30
SM400
25
BCD
T0
K2Y40
30
X1
29
RST
31
M0
END
Related Exercise ---- Exercise 8
5 - 31
5.4
5.4.1
Arithmetic Operation Instruction
+(P)
BIN 16-bit data addition
-(P)
BIN 16-bit data subtraction
S
D
+P
K5
D0
S1
S2
D
D0
K100
D1
X2
0
X3
4
1
+P
Project name
QB-16
Program name
MAIN
1
2
● 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
D0
(Input condition)
First ON
Second ON
Third ON
0 (example)
5
10
D
+
(5)
→
+
+
+
5
5
5
→
→
→
D0
5
10
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
(Input condition)
ON
D
S2
D0
15 (example)
+
(100)
→
+
100
→
D1
115
The content of D0 is not changed.
CAUTION
•
+P
• When
or
+
-P
must be used for the addition or subtraction instructions.
or
-
scanning. To use
is used, an addition or subtraction operation is executed every
+
or
- , operands must be converted into pulse in advance.
X2
X2
+P
K5
D0
PLS
M0
K5
D0
M0
+
REFERENCE
• The following two instructions work on the same principle in the addition or subtraction
operation.
(Addition)
+P
K1
D0
INCP
(Subtraction)
-P
K1
D2
DECP D2
5 - 32
D0
Project name
QB-17
Program name
MAIN
X4
0
MOVP
K1000
D2
S
D
-P
K10
D2
S1
S2
D
D2
K50
D3
X5
3
X6
7
3
-P
3
4
● 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 .
S
D
D2
(Input condition)
First ON
Second ON
Third ON
1000 (example)
990
980
D
-
(10)
→
-
10
10
10
→
→
→
D2
990
980
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 .
S2
S1
D2
(Input condition)
ON
970
(Assumption)
D
-
(50)
→
-
50
→
D3
920
device
File
(system or
register
MELSECNET/ Intelligent
10 (H) Direct
function
Jn\
module
user)
Bit
Word
Index
register
Constant
Un\G
R
Bit
Word
Z
K
H
S
Addition/subtraction S D
instruction
Addition/subtraction S1 S2
instruction
Level
Internal
Pointer
Applicable device
P
I
Digit
Number of basic
steps
The content of D2 is not changed.
N
K1
S1 S2
to
D
D
K4
The number of basic steps is four for
5 - 33
S1 S2
3
4
D
.
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
BINP K4X30 D0
0
BINP K4X20 D1
+P
D0
D1
X1
BINP K4X30 D0
10
BINP K4X20 D1
-P
20
D1
K0
26
D1
K0
D0
DBCD D1
D1
K5Y40
Y70
DMOVK0
K5Y40
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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.
0
X0
BINP
K4X30
D0
300
BINP
K4X20
D1
+P
D0
D1
400
300
10
X1
BINP
K4X30
400
D0
300
BINP
K4X20
D1
400
20
>=
D1
K0
-P
D0
DBCD
D1
400
26
<
D1
K0
D1
300
400
400
K5Y40
Y70
400
DMOV
34
K0
K5Y40
END
+
D0
D1 = D1+D0
100+30
D1
400
Related Exercise ---- Exercise 9
5 - 35
5.4.2
* (P)
BIN 16-bit data multiplication
/ (P)
BIN 16-bit data division
Project name
QB-18
Program name
MAIN
X0
0
X2
3
*P
X3
7
1
/P
MOVP
K2000
D0
S1
S2
D
K30
D0
D10
S1
S2
D
D0
K600
D20
1
2
● 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
K30
30
S2
D0
2000
To store the result of 16-bit data × 16-bit data,
16 bits (1 word) is not enough.
Therefore, D10 which is specified in the
program and the next number D11 work as
the holder of the result.
=
D
D11
D10
60000
This device is regarded as a 32-bit register to
hold the result. Left-most bit of D10 (B15) is
not a bit to determine positive and negative.
It is regarded as a part of the data.
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
D0
2000
K600
600
D
=
D20
3
Quotient
D21
200
Remainder
and
The remainder is stored to D21, which
is the next device number.
The quotient is stored to D20, which is
specified in the program.
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
K30
(30)
D0
(2000)
D
=
D11
D10
(60000)
● Turn on X3.
S2
D0
(2000)
K600
(600)
D
=
D21
D20
(200)
(3)
Remainder Quotient
Multiplication/division S1 S2
instruction
D
I
Digit
Level
MELSECNET/ Intelligent
Internal device
Index
File
10 (H) Direct function
(system or
Constant
register
register
Jn\
user)
module
Un\G
Z
K H P
Bit
Word
R
Bit
Word
Pointer
Applicable device
N
S1
K1
S2
to
D
K4
Number of basic
steps
S1
*
4
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.
• The data is monitored properly.
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
*P
BINP
K4X30 D0
BINP
K4X20 D1
D0
D1
DBCDP D10
13
D10
K8Y40
X1
/P
BINP
K4X30 D0
BINP
K4X20 D1
D0
D1
D20
BCDP
D20
K4Y50
BCDP
D21
K4Y40
Operating Procedure
The following procedures are the same as the Operating Procedure in section 4.4.
(1) Creating a new project
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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
BINP
K4X20
D1
6
3
*P
D0
D1
D10
6
DBCDP
3
D10
18
K8Y40
18
X1
13
BINP
K4X30
D0
6
BINP
K4X20
D1
3
/P
D0
D1
6
BCDP
D20
3
D20
0
K4Y50
0
BCDP
D21
K4Y40
0
30
END
D0 D1=D10
6 3=18
Related Exercise ---- Exercise 10, Exercise 11
5 - 40
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.
Data
1 word
16 bits
2 words
32 bits
MOV(P)
DMOV(P)
BIN(P)
DBIN(P)
Instruction
Transfer
Comparison
BCD(P)
DBCD(P)
<, >, <=
D<, D>, D<=
>=, =, <>
D>=, D=, D<>
+ (P)
D + (P)
Arithmetic
- (P)
D - (P)
operations
* (P)
D * (P)
/(P)
D/(P)
Available range for
-2,147,483,648
0
-32,768
to
to
to
32,767
9,999
2,147,483,647
Values in parentheses are for
0
BIN(P), BCD(P) instructions.
to
values
99,999,999
Values in parentheses are for
DBIN(P), DBCD(P) instructions.
Available range for
K1 to K4
digits
K1 to K8
The bit weights of the 32-bit configuration are as follows:
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
B0
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
B16 B15
1073741824
B31
-2147483648
5.4.3
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
Most significant bit
(Sign bit)
Available range for numbers
-2147483648 to 0 to 2147483647
When the bit is 0, the number is interpreted as a positive number.
When the bit is 1, the number is interpreted as a negative number.
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
DMOV
S
D
K50000
D0
D1
D0
50000
50,000
Stored in two
adjacent devices.
Transferred
2) When the result of the 16-bit multiplication instruction (1-word instruction) is
transferred
*
S1
S2
D
D0
D1
D10
D0
D1
DBCD
D11
D10
K8Y40
D11
D10
D10
The multiplication
result is stored in
two adjacent devices.
8-digit display 0 to 99,999,999)
Converted
into BCD.
*: The result of the 32-bit data multiplication is 64 bits.
3) When the result of 32-bit division instruction is used
D/
D20
D21
D30
D20
D40
D31
D30
D41
D40
(Quotient)
D43
D42
(Remainder)
DBCD
D40
K8Y40
Displays a quotient.
DBCD
D42
K8Y60
Displays a remainder.
5 - 42
5.4.4
Project name
QB-19
Program name
MAIN
Calculation examples for multiplication and division including decimal points (when the multiplication
or division is used)
Example 1 Calculation example to determine a circumference
Digitalswitch value
(K4X30)
× 3.14 →
(Circular constant)
Integral part
and
Decimal part
(K2Y48)
(K8Y50)
• Programming method
Handle the circular constant as 314 (3.14 × 100), and divide the result by 100
afterward.
Example 2 Calculation example to handle values after decimal point (division
example)
Digitalswitch value
/ 0.006 →
(K4X30)
Quotient
and
Remainder
(K8Y50)
(K4Y40)
• Programming method
To handle 0.006 as an integer 6, multiply both the dividend and divisor by 1000.
The calculation of
Example1 is
commanded.
The calculation of
Example2 is
commanded.
X0
X1
X1
BINP
K4X30
D0
Imports the set value of the digital switch into D0.
*P
D0
K314
D1
D0
D/P
D1
K100
D10
D2
DBCD
D10
K8Y50
D11 D10 D13 D12
Quotient Remainder
(Decimal part)
Displays the integral part (quotient).
BCD
D12
K2Y48
Displays the decimal part (remainder).
MOV
K0
K2Y40
BINP
K4X30
D20
Imports the set value of the digital switch into D20.
*P
D20
K1000
D21
D20
D/P
D21
K6
D30
D22 D21
DBCD
D30
K8Y50
Displays a quotient.
BCD
D32
K4Y40
Displays a remainder.
D2
314
D1
D1
100
X0
D22 D21
1000
6
D31 D30 D33 D32
Quotient Remainder
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
5.5.1
Index Register and File Register
How to use index register Z
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
D0Z0 → Can be interpreted as D (0+Z0)
Device number
For example, when Z0 is 0, the device number becomes D0.
when Z0 is 50, the device number becomes D50.
Z0 to Z19 can be used as the index register.
The index register (Zn) is a word device which consists of 16 bits. Therefore, the
available data size range is -32768 to +32767.
The following devices can be used for the indexing.
Bit device ········ X, Y, M, L, S, B, F, Jn\X, Jn\Y, Jn\B, Jn\SB
Word device···· T
(Note)
,C
(Note)
(such as K4Y40Z0)
, D, R, W, Jn\W, Jn\SW, Jn\G
(such as D0Z0)
Constant ········· K, H
(such as K100Z0)
Pointer ············ P
(Note) Only the current value can be used for timer and counter.
The following restrictions are provided for using the index register for contact or
coil.
Device
Description
• Only Z0 and Z1 are available for a
T
contact and coil of a timer.
• Only Z0 and Z1 are available for a
C
Application example
T0Z0
C0Z1
contact and coil of a counter.
K100
T1Z1
K100
C1Z0
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.
Project name
Index register
Program name
MAIN
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
The current value of T2 is
transferred to 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
comments, and device initial values.
(File registers cannot be stored.)
Program memory
Standard RAM
Stores file registers of 1K to 640K
(the capacity depends on the CPU type).
Standard ROM
Stores parameters, programs, device
comments, and device initial values.
(File registers cannot be stored.)
Stores file registers of 1K to 4086K.
(The maximum number of storable file
registers depends on the memory card to be used.)
Memory card
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 "Parameter" in the project list.
1) Double-click!
2) "PLC Parameter", "Network Parameter", and
"Remote Password" are displayed.
Double-click "PLC Parameter"
2) Double-click!
(To the next page)
5 - 46
(From the previous page)
3) The Q Parameter Setting dialog box is
displayed. Click the PLC File tab.
3) Click!
4) Check the "Use the following file" check box
and select "Memory Card (RAM) (Drive 1)"
for "Corresponding Memory".
Enter the following items in "File Name" and
"Capacity".
4) Select!
[Setting contents]
File Name
:R
Capacity
: 32
5) After the setting is completed, click the
button.
End
5) Click!
6) The message on the left is displayed. Click
the
6) Click!
(To the next page)
5 - 47
Yes
button.
(From the previous page)
7) Click [Online] → [Write to PLC] to display the
Online Data Operation dialog box. Select
"Parameter" in the PLC Module tab.
7) Select!
8) Click the
data.
Execute
button to write the
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.
Project name
File register
Program name
MAIN
X0
0
MOV
K173
R5
MOV
K0
R5
The file register data of the standard RAM
is kept by the battery.
Resetting or turning off the power cannot
clear the data. To clear the data, write "0".
MOV
K173
D5
For comparison
X1
3
X0
6
5 - 48
5.6
External Setting of Timer/Counter Set Value and External Display of Current Value
The timer and counter can be specified by K (decimal constant) directly or by D
(data register) indirectly. In the program shown below, the external digital switch can
change the set value.
Project name
QTC
Program name
MAIN
X0
0
BINP
K4X20
D5
X4
4
Digital switch
X2F to X20
D5
1
2
3
4
T10
T10
D5 1 2 3 4
Y70
9
T10
SM400
11
BCD
T10
K4Y40
BINP
K4X30
D6
X1
15
D5
Digital display
Y4F to Y40
D6
X5
19
C10
Displays the current
value of T10.
C10
24
Y71
X6
26
RST
C10
C10
K4Y50
SM400
31
BCD
• After reading the program to GX Works2, write it to the programmable controller to
check that it works properly.
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.
(1) Reading the data
(2) Creating a program
(3) Writing the project to the programmable controller
(4) Monitoring the ladder
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
5.7
5.7.1
Project name
QTEST5
Program name
MAIN
Exercise
MOV
Exercise 1
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
X1
X2
X3
X4
X5
X6
X7
Y70
Y71
Y72
Y73
Y74
Y75
Y76
Y77
Create the following program with GX Works2 filling in the blanks
Then, check the operation using the demonstration machine.
.
SM401
MOV
0
MOV
1)
D0
D0
2)
Hint
CPU
(Input module)
K2X0
X0
X1
X2
X3
X4
X5
X6
X7
(Output module)
D0
0/1
0/1
0/1
0/1
0/1
0/1
0/1
0/1
0/1 Y70
0/1 Y71
0/1 Y72
0/1 Y73
K2Y70
0/1 Y74
0/1 Y75
0/1 Y76
0/1 Y77
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".
0/1
0/1
0/1
0/1
0/1
0/1
0/1
0/1
MOV
1)
2)
MOV
Comparison
The following shows a program which is created with the sequence instructions, not
with the MOV instruction.
0
2
4
6
8
10
12
14
X0
Y70
X1
Y71
X2
Y72
X3
Y73
X4
Y74
X5
Y75
X6
Y76
X7
Y77
5 - 51
5.7.2
Exercise 2
Project name
QTEST6
Program name
MAIN
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.
Create the following program with GX Works2 filling in the blanks
Then, check the operation using the demonstration machine.
.
1)
C0
X1
0
X0
BINP
5
2)
D0
SM401
3)
9
C0
4)
X2
13
RST
C0
C0
Y70
18
Hint
CPU
BIN value
BCD value
BIN
D0
BCD digital switch
X20 to X2F (K4X20)
Set
value
BCD value
C0
BCD
X1:ON/OFF
BIN value
1)
2)
3)
4)
5 - 52
BCD digital display
Y40 to Y4F (K4Y40)
5.7.3
Exercise 3
Project name
QTEST7
Program name
MAIN
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.
Create the following program with GX Works2 filling in the blanks
Then, check the operation using the demonstration machine.
.
X0
FMOV K255
0
1)
2)
X0
FMOV
5
K2Y40
3)
K8
Hint
CPU
(Output card)
255
1
1
1
1
1
1
1
1
Y40
Y41
Y42
Y43
The constant is output from the CPU in the binary notation.
When 255 is output from Y40,
128 64
1
1
32
16
8
4
2
1
1
1
1
1
1
1 =1+2+4+8+16+32+64+128=255
Y47 Y46 Y45 Y44 Y43 Y42 Y41 Y40
Y44
Y45
Y46
MOV
In this exercise, a 64-point output module is used (Y40 to Y7F).
How many blocks are required for 255 on the output basis?
Y47
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.
0
X0
Y40
Y41
Y42
Y7F
5 - 53
5.7.4
Exercise 4
Project name
QTEST8
Program name
MAIN
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).
(X30 to X3F)
(X20 to X2F)
A
B
(Y40 to Y4F)
Displays the result of the calculation of A - B
on the BCD display of Y40 to Y4F.
When the result is a negative number, make sure that
the display displays 0 and the LED of Y70 turns on.
Fill in the blanks
.
Then, check the operation using the demonstration machine.
X0
0
1)
K4X20
D0
2)
K4X30
D1
D0
D1
-P
3)
4)
K0
K0
SET
D1
D1
MOV
K0
K4Y40
BCD
D1
K4Y40
RST
Hint
The operation result is always output from the CPU in binary.
-
D0
D1
=D1-D0
D1
1)
2)
3)
4)
5 - 54
Y70
Y70
5.7.5
Exercise 5
Project name
QTEST9
Program name
MAIN
Addition and subtraction instructions
Create a program that:
1) Imports the values specified by the digital switches (X20 to X2F) to D3 and D2
(32-bit data) when X0 is turned on, adds them to D1 and D0, and displays the
result on the displays (Y40 to Y5F).
2) Imports the values specified by the digital switches (X20 to X2F) to D5 and D4
when X1 is turned on, subtracts them from D1 and D0, and displays the result.
3) When the result is a negative number, Y77 is turned on, the two's complement is
determined from the result to obtain the absolute value, and displayed.
Fill in the blanks
in the following.
Then, check the operation using the demonstration machine.
X0
DBIN
0
9
17
D<=
X1
K0
D0
K4X20
D2
1)
D2
D0
DBCD
D0
K8Y40
DBIN
K4X20
D4
D4
D0
2)
Adds the external
set value to D0.
Displays the result when
it is a positive number.
Subtracts the external
set value from D0.
X0
26
PLS
M1
X1
When the result is a
negative number, it is
converted into a positive
number and displayed.
(The negative absolute
value is determined.)
M1
30
D>
K0
D0
DCML
D0
D8
D+P
K1
D8
DBCD
D8
K8Y40
Y77
Outputs that the number
is negative.
D0
Clears D0 and D1.
X7
DMOV K0
50
1)
2)
Reference
Complement (deny transfer)
D1
M1
D>
K0
D0
DCML D0
D+P
K1
D8
D8
Before DCML
B31 B30
execution
1
(negative number) 1
D0
B18 B17 B16 B15 B14
1
0
1
1
0
D9
The absolute value is determined
by a calculation of two's complement
of D0 and D1 (32-bit data).
After DCML
execution
0
0
D8
0
1
0
0
1
D9
After D + P execution
(absolute value)
0
0
Input condition
CML
5 - 55
1
0
1
1
1
0
D8
0
REMARK
The CML instruction inverts the bit pattern of
when the input condition is turned on.
B2 B1 B0
0
1
0
S
S
D
D0
D10
1
0
0
1
and transfers the data to
D
5.7.6
Exercise 6
Project name
QTEST10
Program name
MAIN
Multiplication and division instructions
Create a program that:
1) Sets data for multiplication and division when X0 is turned on.
2) Multiplies the value specified by the digital switches X20 to X27 by the value
specified by the digital switches X30 to X37 in binary when X2 is turned on.
3) Divides the value specified by the digital switches X30 to X37 by the value
specified by the digital switches X20 to X27 in binary when X3 is turned on.
4) Outputs the result of the multiplication or division to the BCD displays Y40 to Y4F
and the remainder to the BCD displays Y60 to Y67.
(X30 to X37) × (X20 to X27)
(Y40 to Y4F)
(X30 to X37) / (X20 to X27)
(Y40 to Y4F) ... (Y60 to Y67)
Create the program with GX Works2 filling in the blanks
Then, check the operation using the demonstration machine.
in the following.
X0
>=
H9
K1X30
>=
H9
K1X34
1)
K2X30
D0
>=
X3
H9
K1X20
>=
H9
K1X24
2)
K2X20
D1
X2
X3
X2
0
21
26
<>
D1
K0
=
D1
K0
3)
D0
D1
D2
4)
D0
D1
D2
DMOVP K0
D2
SM401
43
>=
K9999 D2
5)
D2
K4Y40
>=
K99
6)
D3
K2Y60
D3
Hint
D0
BINmultiplication BIN value
D0
BIN-division BIN value
D1
BIN value
D3
0
D2
BIN value
D1
D2
D3
BIN value
BIN value
BIN value
1)
2)
3)
4)
5)
6)
5 - 56
5.7.7
Exercise 7
Project name
QTEST11
Program name
MAIN
D-multiplication and D-division
Create a program that:
1) Multiplies the value set by the 5-digit digital switches (X20 to X33) by 1,100 in
binary when X2 is turned on. When the result is 99,999,999 or less, it is
displayed on the displays (Y40 to Y5F).
2) Divides the value set by the 8-digit digital switches (X20 to X3F) by 40,000 in
binary when X3 is turned on. When X4 is on, the quotient is displayed on the
displays (Y40 to Y5F). When X4 is off, the remainder is displayed on the displays
(Y40 to Y5F).
(X20 to X33) × 1100
(X20 to X3F) / 40000
(Y40 to Y5F)
Quotient (Y40 to Y5F) ... X4: ON
Remainder (Y40 to Y5F) ... X4: OFF
Create the program with GX Works2 filling in the blanks
check the operation using the demonstration machine.
X2
X3
0
DBINP K5X20
D0
K1100
D2
D2
D4
1)
2)
D<
Y77
K99999999
D0
D4
Y77
DBCDP D4
X3
in the following. Then,
K8Y40
X2
24
5)
3)
K8X20
D10
4)
K40000
D12
D12
D14
D10
X4
DBCD
6)
K8Y40
DBCD
7)
K8Y40
X4
1)
2)
3)
4)
5)
6)
7)
5 - 57
Answers for the exercises in Chapter 5
Exercise
Answer
No.
1
2
3
4
5
6
7
1)
K2X0
2)
K2Y70
1)
D0
2)
K4X20
3)
BCD
4)
K4Y40
1)
K2Y40
2)
K8
3)
K0
1)
BINP
2)
BINP
3)
>
4)
<=
1)
D+P
2)
D-P
1)
BINP
2)
BINP
3)
*P
4)
/P
5)
BCD
6)
BCD
1)
DMOVP
2)
D*P
3)
DBINP
4)
DMOVP
5)
D/P
6)
D14
7)
D16
5 - 58
CHAPTER 6 HOW TO USE OTHER FUNCTIONS
6.1
Test Function at Online
As a preparation, follow the procedure below.
Project name
Program name
X6
X1
0
For details on the operation method, refer to
chapter 2.
Y70
Y70
X4
K1500
TO
0
M10
4
BCD
TO
X6
1) Read a project with GX Works2.
2) Write the parameter and program of the read
project to the CPU (programmable controller).
(The CPU must be stopped.)
K4Y50
0
T1
13
QEX14
MAIN
Y74
Y74
Y74
3) Set GX Works2 to the monitor mode.
K30
X6
17
T1
23
END
0
4) Confirm the program displayed on the screen.
6-1
6.1.1
Turning on and off the device "Y" forcibly
Stop the CPU before this operation.
1) Click [Debug] → [Modify Value].
1) Click!
2) Enter "Y70"!
2) The Modify Value dialog box is displayed.
Enter "Y70" in the "Device/Label" list box.
3) Click the ON or OFF
on or off "Y70" forcibly.
button to turn
3) Click!
Check with demonstration machine
1) Confirm that the on and off statuses on the Execution Result area switches
according to the clicking of the ON or OFF button. Also, confirm that
the LED of Y70 on the demonstration machine turns on and off according to the
operation.
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"
Activate the CPU before this operation.
1) Click [Debug] → [Modify Value].
1) Click!
2) The Modify Value dialog box is displayed.
Enter "M10" in the "Device/Label" list box.
2) Enter "M10"!
3) Click the ON
reset "M10".
or
OFF
button to set or
3) Click!
Check with demonstration machine
X4 M10
4
K1500
T0
K4
BCD T0 Y50
(Monitor screen when M10 is set)
Turn off X4 and check the following.
M10
1) When M10 is set,
becomes non-conductive and the current value
of the timer T0 is cleared to 0.
Check that the value on the digital display (Y50-Y5F) does not change.
M10
2) When M10 is reset,
is conducted and the timer T0 starts counting
from 0. This count value increases every 10 seconds.
Confirm that the value on the display (Y50-Y5F) increases every 10
seconds.
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"
Activate the CPU before this operation.
1) Click [Debug] → [Modify Value].
1) Click!
2) The Modify Value dialog box is displayed.
Enter "T0" in the "Device/Label" list box.
2) Enter "T0"!
3) Select!
3) Select "Word[Signed]" from the "Data Type"
list box.
4) Enter "1000"!
4) Enter "1000" in the "Value" column.
5) Click!
5) After the setting is completed, click the
Set button to change the current value of
T0 to 1000 forcibly.
Check with demonstration machine
1) Confirm that the value on the digital display (Y50-Y5F) is 1000 when the
key is pressed.
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
Activate the CPU before this operation.
1) Click [Diagnostics] → [PLC Diagnostics].
1) Click!
2) The PLC Diagnostics dialog box is displayed.
Click the Error JUMP button to jump to the
highlighted sequence program step number
where the selected error occurred.
• An error number is displayed if an error occurred.
• "No Error" is displayed if no error occurred.
2) Jump to the step number
with the error!
6-6
6.1.5
Remote STOP and RUN
Activate the CPU before this operation.
1) Click [Online] → [Remote Operation].
1) Click!
2) The Remote Operation dialog box is
displayed. Select "STOP" from the list in the
Operation area.
3) After the setting is completed, click the
Execute button.
2) Select!
3) Click!
4) The message "Do you want to execute the
operation(STOP)?" is displayed. Click the
Yes button.
The operation of the CPU stops.
4) Click!
5) Select "RUN" in step 2), and perform steps
2) to 4) again.
The CPU, which was stopped in the above
operation, starts the operation again.
6-7
6.2
Forced I/O Assignment by Parameter Settings
1) Double-click "Parameter" in the project list.
1) Double-click!
2) "PLC Parameter", the "Network Parameter"
folder, and "Remote Password" are
displayed. Double-click the "PLC
Parameter".
2) Double-click!
3) The Q Parameter Setting dialog box is
displayed. Click the "I/O Assignment" tab.
3) Click!
4) Select!
4) Select "Input" from the list box of the "Type"
column.
5) Enter "QX42" in the "Model Name" column.
6) Select "32Points" from the list box of "Points"
column.
7) Enter "0000" in the "Start XY" column.
8) After the setting is completed, click the
End button.
6) Select!
5) Enter "QX42"!
After this exercise is finished, initialize the
settings by the following procedure.
1) Click the Default button in the Q
Parameter Setting dialog box to initialize the
parameter settings.
2) Click
on the toolbar and write only the
parameters to the CPU.
7) Enter "0000"!
8) 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.
[I/O numbers before the forced assignment]
[Slot 1]
[Slot 0]
Address 0, Address 2, Address 4, Address 6,
Address 1, Address 3 Address 5, Address 7
QX42
QY42P
Address
Address
Q61P
4
0
Q06 Vacant
Address
Power UD(E)H slot Address
5
1
supply CPU
module
Address
Address
6
2
Address
3
Sixteen points occupy one address.
Sixty-four points occupy four addresses.
Digital display
[BCD T0 K4Y50]
Y5F-Y50
Name plate
Address
7
Y77 Y76 Y75 Y74 Y73 Y72 Y71 Y70
Name plate
[I/O numbers after the forced assignment]
Address 0
Address 1
QX42
Address
0
Q61P
Q06 Vacant
Power
UD(E)H slot Address
supply
1
CPU
module
X is set to 32 points, therefore only two addresses are available.
Hereafter, the addresses become smaller by two.
Address 4, Address 6,
Digital display
Address 5, Address 7
QY42P
Address
2
Address
3
Y5F-Y50
Address
4
Name plate
[BCD T0 K4Y50]
Address
5
Y77 Y76 Y75 Y74 Y73 Y72 Y71 Y70
Name plate
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
K50
X6
ST1
Coil ST1
ST1
Y73
3.0sec. 2.0sec.
Normally open contact ST1
X7
RST ST1
Contact X7 (for input RST instruction)
Current
0
value of ST1
When using the program as a
retentive timer, specify the points
in parameters in advance.
3 3
5
5 0
Only the RST instruction is available for turning off the contact
and clearing the current value after the retentive timer goes time-out.
In the example below, the retentive timer is set to ST0 to ST31.
1) Double-click "Parameter" in the project list.
1) Double-click!
2) Double-click!
2) "PLC Parameter", the "Network Parameter"
folder, and "Remote Password" are displayed.
Double-click the "PLC Parameter".
(To the next page)
6 - 10
(From the previous page)
3) The Q Parameter Setting dialog box is
displayed. Click the "Device" tab.
3) Click!
4) Click "Device Points" in the "Retentive Timer"
row, and enter "32".
5) After the setting is completed, click the
End button.
4) Enter "32"!
5) Click!
6 - 11
6.4
Device Batch Replacement
6.4.1
Batch replacement of device numbers
This section explains how to replace Y40 to Y7F (64 devices) with Y20 to Y5F
(64 devices) in batch.
1) Click [Find/Replace] → [Device Batch Replace].
1) Click!
2) The Find/Replace dialog box is displayed.
Enter "Y40" in the "Find Device" column.
3) Enter "Y20" in the "Replace Device" column.
2) Enter "Y40"!
4) Enter "64" in the "Points" column.
4) Enter "64"!
3) Enter "Y20"!
5) After the setting is completed, click the
Execute button.
5) Click!
(Before)
0
X6
X1
(After)
Y70
0
Y70
4
X4
X6
X1
M10
K1500
T0
4
X4
M10
BCD TO K4Y50
13
X6
T1
Y74
Y74
K1500
T0
BCD TO K4Y30
13
Y74
17
6) Confirm that the target device numbers are
replaced.
Y50
Y50
X6
T1
Y54
Y54
X6
K30
T1
17
Y54
X6
K30
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 [Find/Replace] → [Change Open/Close
Contact].
1) Click!
2) The Find/Replace dialog box is displayed.
Enter "X4" in the "Replace Device" list box.
3) After the setting is completed, click the
All Replace button.
2) Enter "X4"!
3) Click!
(Before)
0
X6
X1
Y50
0
K1500
T0
4
Y50
4
X4
X1
Y50
Y50
M10
X4
M10
BCD TO K4Y30
13
X6
T1
Y54
Y54
K1500
T0
BCD TO K4Y30
13
X6
T1
Y54
Y54
Y54
17
4) Confirm that the normally open contact is
changed to the normally closed contact and
vice versa.
(After)
X6
X6
K30
T1
17
Y54
X6
K30
T1
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
This function is used to write programs to the CPU that is running.
Activate the CPU before this operation.
1) Change the ladder.
(In the example, change "X1" to "X0".)
1) Change the ladder!
2) After the change, click [Compile]
→ [Online Program Change].
2) Click!
3) The dialog box for "Caution" is displayed.
Click the Yes button to accept the
change.
3) Click!
4) The message "Online change has
completed." is displayed. Click the
button.
4) Click!
OK
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 [View] → [Docking Window]
→ [Watch(1 to 4)].
* In this example, select "1".
1) Click!
2) The Watch 1 window is displayed. Select a
row to be edited. Enter "T0" in the Device
Label column.
2) Enter "T0"!
3) The input device or label is registered.
4) Click [Online] → [Watch] → [Start Watching].
The current value of the registered device or
label is displayed in the window.
4) Displayed!
6 - 15
6.7
How to Create Comments
Project name
Program name
The following is an example of a printed out ladder with comments.
Use the keyboard to input the program above or read it from a folder on the desktop.
6 - 16
QEX15
MAIN
(1) Flowchart of when creating comments
Set the device range on which comments are attached.*
Double-click the comment file on the workspace.
Create comments.
When attaching comments to other devices
Save the project.
Read and confirm the ladder with comments
*: This procedure is necessary for specifying the device comment range.
POINT
Comments are used for displaying functions or applications of each device.
Up to 32 characters are available.
6 - 17
(2) Creating comments
1) Double-click "Global Device Comment" in the
project list. The Device Comment screen is
displayed.
1) Double-click!
2) Click a comment area and enter a comment
as shown on the left.
2) Enter comments!
3) Enter "Y70" in the "Device Name" list box.
3) Enter "Y70"!
4) Press the
Enter
key.
5) Enter comments!
5) Click a comment area and enter a comment
as shown on the left.
(To the next page)
6 - 18
(From the previous page)
6) Enter "M1" in the "Device Name" list box.
6) Enter "M1"!
7) Press the
Enter
key.
8) Enter comments!
8) Click a comment area and enter a comment
as shown left.
9) Enter "T0" in the "Device Name" list box.
9) Enter "T0"!
10) Press the
11) Enter comments!
Enter
key.
11) Click a comment area and enter a comment
as shown left.
12) Enter "C2" in the "Device name" list box.
12) Enter "C2"!
13) Press the
Enter
key.
14) Enter comments!
14) Click a comment area and enter a comment
as shown left.
6 - 19
(3) Saving comments
1) Click [Project] → [Save As].
1) Click!
2) The Save As dialog box is displayed.
Specify (or select) a workspace name and
click the Save button.
2) Click!
6 - 20
(4) Displaying a ladder with comments on GX Works2 screens
1) Click [View] → [Comment].
1) Click!
2) Comments are displayed on the ladder screen.
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.
• Select "In PLC" or "In Peripheral" for statements and notes.
"In PLC"
: The data of statements and notes is stored as a part of a program. This enables the
data to be stored in CPUs at factories. However, a lot of program memory capacity
of the programmable controller CPU is required.
"In Peripheral" : The data of statements and notes is stored in the peripheral device (personal
computer) separated from the program. Since a program requires only one extra
step per one location, less program memory capacity is required on the
programmable controller CPUs. However, when programs are modified at factories,
programs in GX Works2 in the peripheral device (personal computer) and those in
programmable controller CPUs do not match. Carefully handle the data.
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
Access levels and access authority
Setting an access level to each user restricts accesses to each data.
An access level is an operating authority given to a login user of the project.
The following five levels are available as the access levels. Data that can be edited by
a user having lower access level can also be edited by a user having higher access
level.
Access level
Higher
Administrators
Operating authority
<Administrator level>
All operations are possible.
Developers (Level 3)
Developers (Level 2)
<Developer level>
Security setting, data access, and a part of operations are restricted.
Developers (Level 1)
Users
Lower
<Operator level>
Only access to project data is possible.
Data cannot be read from the programmable controller CPU.
<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) Setting security for projects
Set a security for a project.
Once security is set for a project, user authentication is required when the
project is opened again.
1) Click [Project] → [Security] → [User
Management].
1) Click!
2) The Use Addition dialog box is displayed.
Enter the following items.
User Name
Password
Re-enter Password
2) Enter items!
: MITSUBISHI
: MITSUBISHI
: MITSUBISHI
* When the user name or login password is lost,
logging in to the project is disabled. Do not
enter any other user name or password other
than the above.
3) Click!
3) After entering them, click the
OK
button.
Security is set for the project.
(2) Resetting security for projects
Deleting all users resets the set security of a project and returns the project to
the status without security. (Refer to section 6.8.2.)
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".
[Displaying the User Management screen]
1) Click [Project] → [Security] → [User
Management].
1) Click!
2) The User Management dialog box is
displayed.
The methods for adding users, changing user
information, changing passwords, and
deleting users are explained from the next
page.
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 the Add... button on the User
Management screen.
1) Click!
2) The User Addition dialog box is displayed.
Enter the following items.
User Name
Access Level
Password
Re-enter Password
2) Enter items!
: Developers
: Developers(Level3)
: Developers
: Developers
3) After entering them, click the
OK
button.
3) Click!
4) The user (Developers(Level3)) is added.
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 the user name "Developers".
2) Click the
Change
button.
1) Select!
2) Click!
3) The Change User Data dialog box is
displayed. Select "Users" from the "Access
Level" list box.
3) Select!
4) After selecting it, click the
OK
button.
4) Click!
5) The access level of the user "Developers" is
changed.
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 the user name "Developers".
2) Click the
Password Setup
button.
1) Select!
2) Click!
3) The Change Password dialog box is
displayed. Enter the following items.
3) Enter password!
New Password
Re-enter Password
: Users1
: Users1
4) After entering them, click the
OK
button.
The password of the user "Developers" is
changed.
4) 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
A user authentication is required for opening a project with security.
1) Enter items!
1) When a project with security is opened, the
User Authentication screen is displayed.
Enter a user name and a password for log-in,
and click the OK button.
Enter the following user name and password,
which are set in section 6.8.1.
1) Click!
User Name
Password
: MITSUBISHI
: MITSUBISHI
2) The project is displayed.
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 [Project] → [Security] → [Data Security
Setting].
1) Click!
2) The Data Security Setting dialog box is
displayed.
4) Set!
3) Select a target item from Access Object.
4) Set "Enable" or "Disable" for reading and
writing data from Access Authority for each
access level by moving the slider.
3) Select!
5) Click the
5) Click!
6 - 30
OK
button.
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.
In this example, the device value at an error occurrence is acquired.
Project name
Program name
TRACE
MAIN
As a preparation, follow the procedure below.
1) Click the "PLC RAS" tab on the Q Parameter
Setting dialog box.
1) Click!
2) Select "Continue" from the Computation
Error list box in the Operating Mode When
There is an Error area.
3) Click the
2) Change!
End
button.
4) Write parameters and programs to the CPU.
3) Click!
6 - 31
(1) Setting the sampling trace
1) Click [Debug] → [Sampling Trace] →
[Open Sampling Trace].
1) Click!
2) The Sampling Trace screen is displayed.
3) Click [Debug] → [Sampling Trace] →
[Trace Setting].
3) Click!
(To the next page)
6 - 32
(From the previous page)
4) The Trace Setting dialog box is displayed.
Select "Standard RAM" from the "Target
Memory" list box.
5) Click!
4) Select!
5) Click the Condition Setting tab.
6) Check "Detail Setting" in the Trigger
Condition Setting area and click the
Setting Change button.
6) Check!
6) Click!
(To the next page)
6 - 33
(From the previous page)
7) The Detail Setting - Trigger Condition dialog
box is displayed. Set the following items.
In this example, set error occurrence as
trigger condition.
7) Enter item and set!
Device/Label : SM0
Condition
: -P8) Click the
8) Click!
End Setting
button.
9) The Detail Setting - Trigger Condition dialog
box disappears. Click the End Setting
button to close the Trace Setting dialog box.
10) Set devices to be traced on the Sampling
Trace screen as shown on the left.
11) Check the check box to display the trend
graph of SD0.
11) Check!
12) "SD0" is displayed in the trend graph area on the Sampling Trace screen.
6 - 34
(2) Starting the sampling trace
1) Click [Debug] → [Sampling Trace] → [Start
Trace].
1) Click!
2) The message shown on the left is displayed.
Click the Yes button.
3) The Trace Data Storage Status screen is
displayed when the sampling trace is started.
After confirming that the total data reaches
100%, operate digital switches to generate
an error.
4) The trace result is displayed on the Sampling
Trace screen.
6 - 35
(3) Checking the trace result
1) Scroll the trend graph screen to the trigger
point to check the device value at an error
occurrence.
POINT
Saving trace data to a personal computer
Click [Debug] → [Sampling Trace] → [Export CSV Data]. The following dialog box is displayed.
After entering a file name, click the
Save
button.
6 - 36
CHAPTER 7
7.1
PROGRAMMING INTELLIGENT FUNCTION MODULE
Intelligent Function Module
(1) Intelligent function module type
On programmable controller CPUs (hereinafter referred to as QCPUs), some
functions are not supported or are limited in use. Intelligent function modules
support those functions instead of QCPUs.
Therefore users need to select an intelligent function module that is appropriate
for the purpose involved.
QCPUs are compatible with QCPU-compatible intelligent function modules.
The following table shows examples of the intelligent function modules.
Table 7.1
Example of intelligent function module
Number of I/O
Name
Module current
Function
occupied points
consumption
Input module that converts;
Analog-digital converter
module (Q64AD)
0 to 20mA → 0 to 4000
16 points
5VDC
(in standard resolution mode),
0 to ±10V → 0 to ±4000
0.63A
(in standard resolution mode)
Output module that converts;
Digital-analog converter
module (Q62DAN)
5VDC
0 to 4000 → 0 to 20mA
16 points
(in standard resolution mode),
0 to ±4000 → 0 to ±10V
0.33A
24VDC
(in standard resolution mode)
0.12A
(2) Using intelligent function modules with CPUs
An intelligent function module can be installed on any I/O slots on a main base
unit and extension base unit.
I/O slot number
4
2 3
0 1
Power QCPU
supply
Figure 7.1
Intelligent function module
[Used number]
16 points of X/Y80 to 8F,
16 points of X/Y90 to 9F
Installation of intelligent function module
7-1
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
QCPU
Internal configuration of the intelligent function module
Figure 7.2
X/Y
Function
CPU
Input X
Output Y
(Bit data)
External I/F
Device memory such as
X, Y, M, T, C, D
(Programmable controller CPU)
Program
7.2
Buffer memory
Reading data
Writing data
(Word data)
Internal configuration of the intelligent function module
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
QCPU
X
READY signal
Operating condition
setting completed
X
X
A/D conversion completed
X
Error
Figure 7.3
X from intelligent function module
Xs in a sequence program represent signals
that are input to a QCPU from an intelligent
function module. These signals are
generated on an intelligent function module.
Note that the Xs are used as contacts in a
program. The following is examples of the
signals.
(1) READY signal
This signal notifies a QCPU that an
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
function module
QCPU
Output enable
User range
writing
Channel change
Synchronous
output
Figure 7.4
Y
Y
Y
Y
Y from CPU
7-3
SETs, RSTs, or OUT-Ys represent output
signals transmitted from a QCPU to an
intelligent function module. These signals
are generated on a QCPU. Note that they
are used as coils or contacts in a program.
(Example) D/A converter modules output an
enable instruction (output enable)
before outputting analog values
that were converted from digital
values.
7.2.2
Data communication with intelligent function modules
Data is transmitted or received in 16-bit or 32-bit units. Intelligent function modules
have a buffer memory to store those data.
Intelligent function module
Buffer memory address
0
1
2
3
to
10
11
12
QCPU
Reading data
Buffer
memory
Data
Writing data
D/A conversion enable/disable
CH1 Digital value
CH2 Digital value
Readable and
writable by QCPU
System area (use prohibited)
CH1 Set value check code
CH2 Set value check code
Example of memory map: Q62DAN D/A converter module
Figure 7.5
Buffer memory
(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.
B15 B14 B13 B12 B11 B10 B9 B8 B7 B6 B5 B4 B3 B2 B1 B0
0
0
0
1
0
0
0
1
0
1
0
0
Data part
Sign bit
1: Negative
0: Positive
Figure 7.6
Indicated here is +276.
(Negative digital values are represented
in two's complement.)
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).
(3) A buffer memory is a RAM.
7-4
7.3
Communication with Intelligent Function Module
7.3.1
Communication methods with intelligent function modules
The following table shows the communication methods between a QCPU and an
intelligent function module.
Table 7.2
Communication method with intelligent function modules
Communication
Function
method
Initial setting,
Performs initial settings and auto refresh settings of intelligent function modules.
Auto refresh
These settings allow writing/reading data to/from intelligent function modules regardless
setting
of communication program creation or buffer memory address.
Setting method
Ex.) When A/D converter module Q64AD is used
• Initial setting
: • A/D conversion enable/disable setting
• Sampling/averaging processing specification,
• Time average/number of times average specification,
• Average time/average number of times specification
Use GX Works2.
(Set data in auto refresh settings is stored to the
intelligent function module parameter on a QCPU.)
• Auto refresh setting
: Set a device on a QCPU to store the following data to.
• Digital output from Q64AD
• Maximum and minimum values of Q64AD
• Error code
(Set data in auto refresh settings is stored to the
intelligent function module parameter on a QCPU.)
Device initial
Writes set data in device initial settings of intelligent function modules to the intelligent
Use GX Works2 to
value
function modules at the following timings.
specify the range
• At power-on of a QCPU
for intelligent
• At reset
function module
• At switching from STOP to RUN
devices (U \G ).
FROM/TO
Use this instruction
instruction
Read or write data from or to the buffer memory on an intelligent function module.
in a sequence
Intelligent
Directly handles the buffer memory on an intelligent function module as a device of a
Specify this device
function module
QCPU.
as a device in a
device (U \G )
Unlike "FROM/TO instruction", this requires only one instruction for processing data that
sequence
is read from an intelligent function module.
program.
program.
Intelligent
function module
dedicated
Use this instruction
Used to simplify programming for using the functions of intelligent function modules.
in a sequence
program.
instruction
7-5
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.
D/A converter module
A/D converter module
QX
QY Q64 Q62
42
42P AD DAN
slot
(16
(64
(64
(16
points) points)points) points)
(Channel 1)
V
X/Y90 to X/Y9F
X/Y80 to X/Y8F
Y40 to Y7F
Q61P QCPU Vacant
X0 to X3F
7.4
(Channel 1)
V
Voltmeter for input voltage
Voltmeter for output voltage
Input volume
7-6
7.5
7.5.1
Q64AD Analog/Digital Converter Module
Names of parts
The following explains the parts of Q64AD.
For details, refer to the User's Manual.
Q64AD
Q64AD
1)
RUN
2)
ERROR
V+
V-
C
H
1
I+
SLD
V+
V-
C
H
2
I+
SLD
V+
V-
C
H
3
I+
SLD
V+
10
11
12
13
V-
C
H
4
1
2
3
4
5
6
7
8
9
I+
SLD
A.G.
14
15
16
17
(FG)
A/D
0-±10V
0-20mA
No.
Name and
18
Description
appearance
Indicates the operation status of the A/D converter module.
1)
RUN LED
ON
: In normal operation
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.
2)
ERROR LED
ON
: Error occurred
OFF
: In normal operation
Flicker : Switch setting error occurred
Values other than 0 has been set to the switch 5
on the intelligent function module.
7-7
A/D conversion characteristics
(1) A/D conversion characteristics on voltage inputs
(For analog input range from -10 to 10V in a standard resolution mode)
4000
Digital output
0
2003
2002
2001
2000
-4000
-10V
0
Analog input voltage
Figure 7.12
10V
5.0025V
2.5mV
5.0000V
Digital output value
2004
Input voltage
A/D conversion characteristics (voltage input)
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.
(2) A/D conversion characteristics on current inputs
(For analog input range from 0 to 20mA in a standard resolution mode)
-4000
-20mA
0
Analog input current
Figure 7.13
20mA
5 A
10.005mA
0
2005
2004
2003
2002
2001
2000
10.000mA
Digital output
4000
Digital output value
7.5.2
Input current
A/D conversion characteristics (current input)
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
(1) List of I/O signals
The following shows a list of the I/O signals for the A/D converter modules.
Note that I/O numbers (X/Y) shown in this section and thereafter are the values
when the start I/O number for the A/D converter module is set to 0.
Signal direction: CPU ← A/D converter module
Device No. (input)
Signal name
Signal direction: CPU → A/D converter module
Device No. (output)
X0
Module READY
Y0
X1
Temperature drift compensation flag
Y1
X2
Y2
X3
Y3
X4
Use prohibited
X5
*1
*1
Y6
X7
X9
Use prohibited
Y5
X6
X8
Y4
Signal name
Y7
High resolution mode status flag
Operating condition setting
completed flag
Y8
Y9
Operating condition setting
request
XA
Offset/gain setting mode flag
YA
User range writing request
XB
Channel change completed flag
YB
Channel change request
XC
XD
Use prohibited
*1
Maximum value/minimum value reset
completed flag
YC
YD
XE
A/D conversion completed flag
YE
XF
Error flag
YF
Use prohibited
*1
Maximum value/minimum
value reset request
Use prohibited
*1
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.
Buffer memory assignment (Q64AD) (1/2)
Address
Description
Default
Read/
*1
Decimal
0H
0
A/D conversion enable/disable setting
0
R/W
1H
1
CH1 Average time/average number of times
0
R/W
2H
2
CH2 Average time/average number of times
0
R/W
3H
3
CH3 Average time/average number of times
0
R/W
4H
4
CH4 Average time/average number of times
0
R/W
5H
5
...
...
write
Hexadecimal
System area
-
-
8H
8
Averaging process setting
0
R/W
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
-
-
...
9
10
...
9H
AH
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
Description
Hexadecimal
Decimal
18H
24
...
...
1DH
29
Default
System area
-
Read/
*1
write
-
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
-
-
Mode switching setting
0
R/W
System area
-
-
0
R/W
-
-
0
R/W
0
R/W
9DH
157
9EH
158
9FH
159
A0H
160
...
...
C7H
199
C8H
200
Pass data classification setting
C9H
201
System area
CAH
CBH
202
203
*2
*2
CH1 Industrial shipment settings offset value
*2
CH1 Industrial shipment settings gain value
*2
CCH
204
CH2 Industrial shipment settings offset value
CDH
205
CH2 Industrial shipment settings gain value
CEH
206
CH3 Industrial shipment settings offset value
*2
*2
*2
CFH
207
CH3 Industrial shipment settings gain value
D0H
208
CH4 Industrial shipment settings offset value
D1H
209
*2
*2
CH4 Industrial shipment settings gain value
D2H
210
CH1 User range settings offset value
D3H
211
CH1 User range settings gain value
D4H
212
*2
*2
CH2 User range settings offset value
*2
*2
D5H
213
CH2 User range settings gain value
D6H
214
CH3 User range settings offset value
D7H
215
CH3 User range settings gain value
*2
*2
D8H
216
CH4 User range settings offset value
D9H
217
CH4 User range settings gain value
*2
*2
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
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 [Project] → [Intelligent Function Module]
→ [New Module].
1) Click!
2) The New Module dialog box is displayed.
3) Set the A/D converter module setting as follows.
Module Type
: Analog Module
Module Name
: Q64AD
Mounted Slot No. : 3
(Specify start XY address: 0080)
4) Click!
4) Click the
OK
button.
3) Set!
5) The specified intelligent function module data are
added to the Project window.
5) Add!
(To the next page)
7 - 12
(From the previous page)
6) Double-click Switch Setting.
6) Double-click!
7) Set!
7) The Switch Setting screen is displayed.
Set Input range for CH1 to "0 to 10V".
8) Click the
OK
button.
8) Click!
9) Double-click Parameter.
9) Double-click!
10) The Parameter screen is displayed.
Set "A/D conversion enable/disable setting" for CH2
to CH4 to "1:Disable". (Only CH1 is used.)
10) Set!
(To the next page)
7 - 13
(From the previous page)
11) Double-click Auto_Refresh.
11) Double-click!
12) The Auto_Refresh screen is displayed.
Set Digital output value for CH1 to "D10".
12) Set!
13) Click [Project] → [Intelligent Function Module]
→ [Intelligent Function Module Parameter List].
13) Click!
(To the next page)
7 - 14
(From the previous page)
14) Check that "Setting Exist" is checked in Initialization
(Count) and Auto Refresh (Count) for Q64AD in the
Intelligent Function Module Parameter List dialog box.
15) Click the
15) Click!
7 - 15
Close
button.
7.5.5
Exercise with the demonstration machine
(1) Sequence program
The sequence program executes a sampling processing on analog voltages
input through CH1 of Q64AD, and then converts the analog values to digital
values.
Set the start XY of Q64AD to 80 as explained before.
Project name
Program name
Q64AD
MAIN
A/D module READY
A/D conversion completed flag
X3 X80
0
X8E
>=
D10
K0
BCD
D10
K4Y50
Displays digital conversion value
of CH1 on LED
END
9
X80: Module READY signal
X8E: A/D conversion completed flag
At power-on or reset of a programmable controller CPU, this flag turns on if
A/D conversion is ready to be executed. A/D conversion is executed once this
flag turned on.
(2) Operation of the demonstration machine
Stop the CPU and click
on the toolbar.
The Online Data Operation dialog box is displayed. Click the
Parameter + Program
button, then click the
Execute
button to write data
to the CPU. After that, activate the CPU and check the following items.
(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
7.6.1
Q62DAN Digital/Analog Converter Module
Names of parts
The following explains the parts of Q62DAN.
For details, refer to the User's Manual.
Q62DAN
1)
2)
3)
No.
Name and
Description
appearance
Indicates the operation status of the D/A converter module.
1)
RUN LED
ON
: In normal operation
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.
2)
ERROR LED
ON
: Error occurred
OFF
: In normal operation
Flicker : Switch settings error occurred
Values other than 0 has been set to the switch 5
on the intelligent function module.
3)
External power
supply terminal
Terminal for connecting a 24VDC external power supply
7 - 17
D/A conversion characteristics
(1) D/A conversion characteristics on voltage outputs
(For analog output range from -10 to 10V in a standard resolution mode)
Analog output voltage
Analog output voltage
10V
0
-10V
- 4000
0
5.0025V
2.5mV
5.0000V
2000 20012002 2003 2004
4000
Digital input
Digital input value
Figure 7.14
D/A conversion characteristics (current output)
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.
(2) D/A conversion characteristics on current outputs
(For analog output range from 0 to 20mA in a standard resolution mode)
0
-20mA
-4000
0
4000
Analog output current
20mA
Analog output current
7.6.2
10.005mA
5 A
10.000mA
200020012002 2003
Input
Digital input value
Figure 7.15
D/A conversion characteristics (current output)
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
(1) List of I/O signals
The following shows a list of the I/O signals for the D/A converter modules.
The following explanation is mentioned based on the Q68DAVN, Q68DAIN,
Q68DAV and Q68DAI with 8-channel analog output (CH1 to CH8).
Note that I/O numbers (X/Y) shown in this section and thereafter are the values
when the start I/O number for the D/A converter module is set to 0.
Signal
direction
D/A converter module → CPU module
Signal
CPU module
direction
→ D/A converter module
Signal name
Device No.
Signal name
Device No.
X0
Module READY
Y0
Use prohibited
*1
X1
Y1
CH1 Output enable/disable flag
X2
Y2
CH2 Output enable/disable flag
*2
X3
Y3
Use prohibited
X4
*1
*2
Y4
*2
X5
Y5
*2
X6
Y6
*2
Y7
X7
Y8
*2
CH3 Output enable/disable flag
CH4 Output enable/disable flag
CH5 Output enable/disable flag
CH6 Output enable/disable flag
CH7 Output enable/disable flag
X8
High resolution mode status flag
X9
Operating condition setting completed flag
Y9
Operating condition setting request
CH8 Output enable/disable flag
XA
Offset/gain setting mode flag
YA
User range writing request
XB
Channel change completed flag
YB
Channel change request
XC
Set value change completed flag
YC
Set value change request
XD
Synchronous output mode flag
YD
Synchronous output request
XE
Use prohibited
XF
*1
YE
Error flag
YF
Use prohibited
*1
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 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
Description
Default
*1
Read/
write
*2
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
-
-
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
...
11
...
10
BH
...
AH
...
...
Decimal
...
Hexadecimal
System area
-
-
9DH
157
9EH
158
9FH
159
A0H
160
Mode switching setting
...
...
C7H
199
C8H
200
Pass data classification setting
C9H
201
System area
CAH
202
CH1 Industrial shipment settings offset value
CBH
203
CH1 Industrial shipment settings gain value
CCH
204
CH2 Industrial shipment settings offset value
System area
*3
CDH
205
CH2 Industrial shipment settings gain value
CEH
206
CH1 User range settings offset value
*3
CFH
207
CH1 User range settings gain value
D0H
208
CH2 User range settings offset value
D1H
209
CH2 User range settings gain value
*3
*3
*3
*3
*3
*3
*3
0
R/W
0
R/W
-
-
0
R/W
-
-
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
0
R/W
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 [Project] → [Intelligent Function Module]
→ [New Module].
1) Click!
2) The New Module dialog box is displayed.
3) Set the A/D converter module setting as follows.
Module Type
: Analog Module
Module Name
: Q62DAN
Mounted Slot No. : 4
(Specify start XY address: 0090)
4) Click!
4) Click the
OK
button.
3) Set!
5) The specified intelligent function module data are
added to the Project window.
5) Add!
(To the next page)
7 - 21
(From the previous page)
6) Double-click Switch Setting.
6) Double-click!
7) The Switch Setting screen is displayed.
Set Output range for CH1 to "0 to 5V".
7) Set!
8) Click the
OK
button.
8) Click!
9) Double-click Parameter.
9) Double-click!
10) The Parameter screen is displayed.
Set "D/A conversion enable/disable setting" for CH1
to "0:Enable". (Only CH1 is used.)
10) Set!
(To the next page)
7 - 22
(From the previous page)
11) Double-click Auto_Refresh.
11) Double-click!
12) The Auto_Refresh screen is displayed.
Set Digital value for CH1 to "D30".
12) Set!
13) Click [Project] → [Intelligent Function Module]
→ [Intelligent Function Module Parameter List].
13) Click!
(To the next page)
7 - 23
(From the previous page)
14) Check that "Setting Exist" is checked in Initialization
(Count) and Auto Refresh (Count) for Q62DAN in the
Intelligent Function Module Parameter List dialog
box.
15) Click the
15) Click!
7 - 24
Close
button.
7.6.5
Exercise with the demonstration machine
(1) Sequence program
The sequence program converts values of the digital switches to analog
signals.
Set the start XY to 90 and the digital value for CH1 to D30 for Q62DAN as
explained before.
Project name
Q62DAN
Program name
MAIN
X2
0
Y91
X90
2
X3
MOVP
K0
D30
MOVP
K2000
D30
MOVP
K4000
D30
X4
X5
END
15
X90: Module READY signal
At power-on or reset of a programmable controller CPU, this signal turns
on if D/A conversion is ready to be executed. D/A conversion is executed
once this signal turned on.
Y91: CH1 Output enable/disable flag
Turning this flag on or off selects on each channel whether to output D/A
converted values or offset values.
ON: D/A converted value, OFF: Offset value
(2) Operation of the demonstration machine
Stop the CPU and click
on the toolbar.
The Online Data Operation dialog box is displayed. Click the
Parameter + Program
button, then click the
Execute
button to write data
to the CPU. After that, activate the CPU and check the following items.
(a) Turn on X2 to enable D/A outputs of CH1.
(b) Voltage is output according to X3 to X5.
(c) The D/A OUTPUT voltmeter displays the voltage value that the D/A
converter module outputs.
7 - 25
MEMO
7 - 26
CHAPTER 8 SIMULATION FUNCTION
8.1
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) The simulation function simulates the actual programmable controller CPU
to debug a created sequence program. However, this function does not
guarantee the operation of the debugged sequence program.
2) The simulation function uses the memory for simulation to input and output
data to/from the I/O module and intelligent function module. Some
instructions, functions, and device memories are not supported. Therefore,
the operation results obtained from the virtual programmable controller may
differ from those obtained from the actual programmable controller CPU.
8.2
Starting/Stopping Simulation
1) Click [Debug] → [Start/Stop Simulation].
1) Click!
2) The GX Simulator2 screen is displayed, and the
simulation starts.
3) To stop the simulation, click [Debug] → [Start/Stop
Simulation] again.
8-1
8.3
Debugging with Example Program
Use the following example for exercise.
<<Example program>>
0
X0
X1
Y70
Y70
4
6
11
M0
Y71
K9999
C0
SM412
SM400
MOV
C0
K4Y80
END
14
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) Turning bit devices on/off forcibly
In the example operation below, "X0" is forcibly turned on.
1) Click [Debug] → [Modify Value].
1) Click!
2) The Modify Value dialog box is displayed.
Input "X0" to the "Device/Label" list box.
2) Enter "X0"!
3) Click the
on.
ON
button to forcibly turn "X0"
3) Click!
4) Reflected!
4) The result of the device being turned on is
reflected on the ladder monitor screen.
8-3
(2) Changing the word device value
In the example operation below, the word device value "C0" is changed to "5".
1) Click [Debug] → [Modify Value].
1) Click!
2) Enter "C0"!
2) The Modify Value dialog box is displayed.
Input "C0" to the "Device/Label" list box.
3) Select!
3) Select the "Word[Signed]" from the "Data
Type" list box.
4) Enter "5"!
5) Click!
4) Input "5" to the "Value" column.
5) After the setting is completed, click the
Set button to forcibly change the current
value of C0 to 5.
6) The change of the value of "C0" to "5" is
reflected on the ladder monitor screen.
6) Reflected!
8-4
CHAPTER 9 MAINTENANCE
Typical Trouble
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)]
Figure 9.1 Faulty parts on programmable controllers (multiple answers allowed)
(%)
80
Collected from 223 factories
73.1
60
40
34.1
20.6
20
19.3
14.3
9.4
0.9
No answer
Others
Memory
Communication
CPU
Power supply
I/O
Peripheral device
2.7
0
Figure 9.2 Causes of programmable controller faults (multiple answers allowed)
(%)
50
40
Collected from 223 factories
40.4
30
26.0
24.7
24.2
19.3
20
12.6
12.1
10
6.3
1.3
9-1
No answer
Vibration shock
Incorrect programming
Others
Manufacturer's fault
Poor connection
Short of load
Noise
0
Unknown cause
9.1
Maintenance
To keep programmable controllers in the best operating condition, conduct the
following daily inspection and periodic inspection.
(1) Daily inspection
The following table lists the items that must be inspected daily.
Table 9.1 Daily inspection
Item
Inspection item
Inspection contents
Judgment criterion
Measures
1
Installation of base
unit
Check that fixing
The screws and
screws are not loose
cover must be
and the cover is not
installed securely.
dislocated.
Retighten the
screws.
2
Installation of I/O
module
Check that the
module is not
dislocated and the
module fixing hook is
engaged securely.
Securely engage the
module fixing hook.
Or tighten the screw.
The module fixing
hook must be
engaged and
installed securely.
Check for loosening
Screws must not be
of the terminal
loose.
screws.
3
Connection
conditions
Retighten the
terminal screws.
The proper distance
Check for the
Set the proper
must be provided
distance between
between solderless distance.
solderless terminals.
terminals.
Retighten the
Check the connector Connectors must not
connector fixing
part of the cable.
be loose.
screws.
4
Module indication LED
9.2
The LED must be on.
(Error if the LED is
off)
Power supply
module
"POWER" LED
Check that the LED
is on.
CPU "RUN" LED
The LED must be on.
Check that the LED
(Error if the LED is
is on in RUN status.
off)
CPU "ERROR"
LED
Check that the LED
is off.
The LED must be off.
(Error if the LED is
on or flashing)
CPU "BAT.ARM" Check that the LED
LED
is off.
The LED must be off.
(Error if the LED is
on)
Input LED
Output LED
Check that the LED
turns on and off.
The LED must be on
when the input power
Refer to QCPU (Q
is turned on.
The LED must be off mode) User's
when the input power Manual.
is turned off.
(Error if the LED
does not turn on or
turn off as indicated
above)
Check that the LED
turns on and off.
The LED must be on
when the output
power is turned on.
The LED must be off
when the output
power is turned off.
(Error if the LED
does not turn on or
turn off as indicated
above)
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.
Table 9.2 Periodic inspection
3
4
Ambient
temperature
Ambient humidity
Ambience
Power supply voltage
Installation
2
Connection conditions
1
Inspection item
Ambient environment
Item
Inspection contents
Judgment criterion
0 to 55 °C
Measure the
temperature and
humidity with a
*1
5 to 95% RH
thermometer and a
hygrometer.
Measure corrosive gas. Corrosive gas must not
be present.
Measure the voltage
85 to 132VAC
across the terminals of
170 to 264VAC
100/200VAC.
Measures
When the
programmable
controller is used in the
board, the ambient
humidity in the board is
the ambient humidity.
Change the power
supply.
Move the module to
The module must be
Looseness, rattling check for looseness and
installed securely.
rattling.
Retighten the screws.
If the CPU, I/O, or
power supply module is
loose, fix it with screws.
Adhesion of dirt
Check visually.
and foreign matter
Remove and clean the
dirt and foreign matter.
Looseness of
terminal screws
Dirt and foreign matter
must not be present.
Retighten screws with a Screws must not be
screwdriver.
loose.
Retighten the terminal
screws.
Distance between
solderless
Check visually.
terminals
The proper distance
must be provided
between solderless
terminals.
Looseness of
connectors
Connectors must not be Retighten the connector
loose.
fixing screws.
5
Battery
6
Spare product
7
Check the stored
program
8
Fan (heat exchanger)
filter
9
Analog I/O
Check visually.
Set the proper distance.
Even if the lowering of a
battery capacity is not
Check that SM51 or
displayed, replace the
(Preventive
SM52 is turned off with
battery with a new one if
maintenance)
the specified service life
GX Works2.
of the battery is
exceeded.
Install the product on
Use the normal product
the actual
on the actual
The operation must
programmable
programmable
meet the specifications.
controller and check the
controller as a spare
operation.
product.
Compare the stored
The two programs must Correct if any difference
program with the
be identical.
is found.
running program.
The fan must rotate
Rotation status
without abnormal
Replace if any error is
Rotation sound
sounds.
found.
Clogging
The fan must rotate
Clean.
without clogging.
The value must be
Check the offset/gain
identical with the
Correct if any difference
value.
specifications (design is found.
value).
*1: When AnS Series Module is used in the system, the judgment criteria will be from 10 to 90% RH.
9.3
Consumable Product
Backup batteries on programmable controllers are consumable products.
9-3
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)
9.4
100
50
20
10
DC30V
t=0ms
5
DC100V
t=7ms
DC24V
t=7ms
2
1
0.1
0.2
0.5
1
2
Switching current (unit: A)
AC100V COS
=0.7
AC200V COS
AC100V COS
=0.7
=0.35
AC200V COS
=0.35
5
10
Figure 9.3 Life characteristics of output relay's contact (QY10, QY18A)
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.
(1) Easily replaceable type
Replacing building block-type modules is easy. Only replacing the faulty module
is required.
(2) Memory type
To use standard RAMs or SRAM memory cards, backup batteries are required.
The standard ROMs, Flash cards, and ATA cards do not require the battery for
use, besides, these memories prevent unintentional program changes due to
human-related mistakes. These memories are recommended to be employed in
products for export.
(3) Reducing the number of module types
Reducing the number of module types is efficient for reducing the number of
spare product types.
(4) Reserving I/O points
By not using all the I/O points on 16-, 32-, and 64-point I/O modules but
reserving 10% to 20% of them, it is possible to just make changes on wiring and
programs (I/O signals) instead of replacing the faulty module with a spare
module when there are no spare modules.
(5) Creating a document
Since sequence programs are easily modified, the inconsistency between an
operating program and documents may occur (i.e. ladder diagram, program list).
Keep updating the document.
To do this, using a printer is efficient.
(6) Mastering peripheral device
Mastering peripheral device such as a personal computer, GX Works2 helps
the quick recovery from an accident.
9-5
(7) Spare product
Table 9.3 Spare products
Product name
Quantity
Remark
Storage lives of lithium batteries are about five years.
1 Battery
One or two
Therefore, the stock should not be kept all the time but
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
2 I/O module
One per each
operation.
module type
Also note that the contacts of output modules are
consumed in long-term use.
3 CPU module
4 Memory card
5
One for each
used model
One for each
CPU modules and memory cards are the core parts of a
programmable controller, which means that an error of
them result in the system down.
used model
Power supply
One for each
module
used model
9-6
Same as above. As the temperature of the power supply
modules rises easily, and high ambient temperature may
shorten their service lives.
9.6
Using Support Equipment
The following shows examples of support equipment in which programmable
controller-used systems or devices automatically notify a detected failure or
operation status to an operator or maintenance personnel during an automatic
control operation.
Displaying an error using a commercial lamp
1.
Connect the error lamp to the output module of the programmable controller so
that the lamp flashes when an error is detected.
Lamp flicker
Output module (Y50 to Y6F)
Error indication lamp
Control panel
SM1
SM412
(Error detection)
(1-sec. clock)
Y50
2.
The lamp (Y50) flashes
when an error is detected.
Displaying an error code on a commercial digital display
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
Output module (Y70 to Y8F)
Error indication lamp
Error code Error code
0 0
3 2
Control panel
SM1
(Error detection)
BCD SD0
K2Y70
(Error code)
The error code number is
displayed on the digital display
when an error is detected.
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
The errors details of the programmable controller can be displayed on an
external CRT screen, plasma screen, and liquid crystal screen.
Screen display
Starting first step in progress
Arm
Conveyor
Error occurred! 00070
MELSEC-Q supports a wide variety of GOTs (Graphic Operation Terminals).
In addition to the error display function, GOTs have a lot of useful functions such as
the graphic monitoring, ladder monitoring, device monitoring, touch-panel switch,
and printing function.
(Refer to the catalogs for details.)
9-8
APPENDIX
Appendix 1
I/O Control Mode
The CPU supports two types of I/O control modes; the direct mode and refresh
mode.
Appendix 1.1
Direct 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)
Data memory for inputs (X)
2)
3)
Test operation using peripheral device
Link refresh of MELSECNET/H
Writing from serial communication
modules, etc.
1)
Input
module
X0
4)
Data memory for outputs (Y)
Y75
Y70
5)
Executing the OUT instruction in the
sequence program
Test operation using peripheral device
Writing from serial communication
modules, etc.
Output
module
• When the input contact instruction is executed:
An OR operation is executed in the input information 1) from the input module and
input information 2) in the data memory. Then the result is used as input
information 3) at sequence program execution.
• When the output contact instruction is executed:
Output information 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 5) of the sequence program is output to the output module,
and is stored in the data memory for output (Y).
• When the QCPU executes I/O in the direct mode, a sequence program uses DX
for inputs and DY for outputs.
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)
3)
Data memory for
inputs (X)
When inputs
are refreshed
1)
Input
module
X0
4)
Y75
Y70
5)
Data memory for
outputs (Y)
When outputs
are refreshed
2)
Output
module
• 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.
Item
Direct mode
Refresh mode
DX0
X0
Y70
1. Ladder example
Y70
Program execution
Program execution
Input instruction (LD X0)
Input instruction (LD X0)
Output instruction (OUT Y70)
Output instruction (OUT Y70)
0
2. Response lag
from when input
END
changed
accordingly
0
0
Y70
END
Minimum delay
X0
Internal input
Delay
(execution time of the instruction)
Maximum delay
X0
Y70
0
END
Minimum delay
X0
is changed to
when output is
0
0
END
0
Input refresh
Output refresh
Y70
Delay
(One scan)
Maximum delay
X0
Delay
(One scan)
Internal input
Y70
Delay
(Two scans)
• The delay time ranges from 0 (only execution
time of the instruction) to 1 scan.
3. Execution time
• The delay time ranges from 1 to 2 scans.
• The delay time is 0 to 1 scan.
• The delay time is 1 to 2 scans.
• The direct mode needs longer time than the
• Generally, only short time is needed since a
of the I/O
refresh mode since a programmable controller
programmable controller accesses data
instruction
accesses I/O modules.
memory.
• The scan time is longer for the execution time
4. Scan time
• The scan time is shorter for the execution time
of the I/O instructions.
of the I/O instructions.
• The actual scan time is the program execution • The actual scan time is the total time of a
program execution, input transfer, and output
time.
transfer.
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
Number
Name
Meaning
Explanation
Description
Indicates the special relay number.
Indicates the special relay name.
Indicates the contents of the special relay.
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.
Corresponding
("M9□□□ format change" indicates the one whose application has been
ACPU
changed. Incompatible with the Q00J/Q00/Q01, and QnPRH.)
M9□□□
• "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
: High Performance model QCPU
Corresponding Qn(H)
QnPH
: Process CPU
CPU
QnPRH
: Redundant CPU
QnU
: Universal model QCPU
CPU module name : Only the specified CPU model (Example: Q02U)
•
•
•
•
•
For details on the following items, refer to these manuals:
• For network related items
Manuals for each network module
• For SFC programs
MELSEC-Q/L/QnA Programming Manual (SFC)
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
Number
Name
Meaning
Explanation
Description
• Indicates the special register number.
• Indicates the special register name.
• Indicates the contents of the special register.
• 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.
Corresponding
("D9□□□ format change" indicates the one whose application has been
ACPU
changed. Incompatible with the Q00J/Q00/Q01, and QnPRH.)
D9□□□
• "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
: High Performance model QCPU
Corresponding Qn(H)
QnPH
: Process CPU
CPU
QnPRH
: Redundant CPU
QnU
: Universal model QCPU
CPU module name : Only the specified CPU model (Example: Q02U)
For details on the following items, refer to these manuals:
• For network related items
Manuals for each network module
• For SFC programs
MELSEC-Q/L/QnA Programming Manual (SFC)
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
Appendix 4.1
Application Program Example
Flip-flop ladder
(1) Y70 turns on when X0 is turned on, and turns off when X1 is turned on.
X0
0
SET
Y70
RST
Y70
X1
2
(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
Project name
QA-16
Program name
MAIN
K5
T1
T0
0
K5
T0
T1
6
Y70
T0
Y71
12
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
Project name
QA-17
Program name
MAIN
K50
T1
T0
0
T1
T0
PLS
7
M0
Y70
M0
RST
11
T1
K50
T0
T1
16
T1
T1
Y71
22
PLS
M1
RST
T0
M1
26
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.)
K70
X1
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
PLF
0
M1
M1
K100
T16
T16
3
Y76
Y76
X0
Y76
Set time limit
10sec.
App. - 8
Pulse duration
Appendix 4.3
Long-time timer
(1) Necessary time is obtained by connecting timers in serial.
0
5
11
K30000
3000.0sec.
T9
K20000
T10
2000.0sec.
X2
T9
T10
Y72
Turns on after
time limit elapses
X2
Normally open
contact T9
Normally open
contact T10
Y72
3000sec.
2000sec.
5000sec.
(2) Necessary time is obtained by using timers and counters.
Time limit of timer Set value of counter = Long-time timer (note that accuracy
of timers are accumulated.)
0
7
X2
M56
X2
C7
Project name
QA-18
Program name
MAIN
K9000
T14
Y73
Y73
Y73
12
T14
C7
Turns on after
time limit elapses
K4
M56
18
C7
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.
(1) The timer T6 starts operating when X5 is turned off.
Y70
K8
X5
T6
0
X5
T6
Y70
6
Y70
X5
Coil T6
Normally closed
contact T6
Y70
Set time limit
0.8sec.
(2) Turning on X5 momentarily sets the operation ready.
The timer T8 starts operating when X6 is momentarily turned on.
X5
T8
Y71
0
Y71
X6
K41
Y71
T8
4
M45
M45
X5
X6
Coil T8, M45
Normally closed
contact T8
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)
An on delay timer of a programmable controller operates easily with a continuous
input. A relay M must be used with a momentary input.
0
X1
X2
10
QA-19
Program name
MAIN
T4
T4
K62
M50
Timer starts after X1
turns on, and continues
to be activated.
Y70
Turns on 6.2sec. later
Y71
Turns off 6.2sec. later
T4
M50
8
Project name
X1
X2
T4,M50
Y70
Y71
Set time limit
6.2sec.
(Note) The above ladder operates as an on delay ladder by momentarily turning on
inputs X1 and X2.
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
Appendix 4.7
Y70
Preventing chattering input
The timer is set so that it starts output when the input keeps being on for 0.2sec.
K2
X0
T1
0
T1
M1
5
M1 turns on when X0 keeps being on for 0.2sec. or longer. Therefore, use M1
instead of X0 when creating a program.
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
Project name
QA-1
Program name
MAIN
Sequence program with master control instructions
0
4
6
X0
X1
MC
X2
14
17
X7
X1
X0
X4
X3
X7
Y79
M10
Y71
Manual circuit
M11
MCR
MC
N0
N0
M2
M20
Automatic circuit
M21
MCR
20
21
M1
M10
X6
9
10
N0
N0
Y70
M20
25
M11
X2
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.
0
3
7
16
21
Digital switch for setting time
Display for current time
59
26
0.1sec. units Programmable
controller
X20 to 27
Y40 to 47
Push button for
reading time
X3
Turns on when current
Y70 value is less than 2sec.
Switch for timer
X4
Turns on when current
Y71 value is just 3sec.
Switch for operation
X5
Y72 Turns on when current
value is 4.1sec. or more
X3
M5
X4
0.1sec. units
BIN
T4
<>
K0
PLS
M5
K2X20
D1
D1
T3
T3
T4
X5
BCD
T3
Project name
QA-2
Program name
MAIN
D1
K10
Reads set time
2 digits in 0.1sec. units
Starts timer
Repeats flicker
K2Y40
Outputs time value to exterior
>
K20
T3
Y70
Turns on when T3 is from
0.1 to 1.9sec.
=
K30
T3
Y71
Turns on when T3 is 3.0sec.
<
K40
T3
Y72
Turns on when T3 is 4.1sec.
or more.
App. - 14
Appendix 4.10
Clock ladder
The clock data such as hour, minute, and second is output to a digital display.
0
5
10
15
24
33
38
Project name
QA-3
Program name
MAIN
T1
T0
T0
T1
T1
C11
RST
C12
RST
C13
SM400
47
seconds
K2Y40
Tens
digit
18
Ones
digit
minutes
K2Y48
Tens
digit
0.5-sec. flickering
K5
K60
C11
Counts seconds
C11
K60
C12
Counts minutes
C12
K99
C13
Counts hours
RST
C13
BCD
C11
K2Y40
BCD
C12
K2Y48
BCD
C13
K2Y50
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
Ones
digit
K5
Ones
digit
64
hours
K2Y50
Tens
digit
LED of output module
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
Tens digit
1
8
4
2
Ones digit
K2Y50 hour, Output
1
8
4
2
1
8
Tens digit
4
K2Y48 minute, Output
App. - 15
2
Ones digit
1
8
4
2
Tens digit
1
8
4
2
Ones digit
K2Y40 second, Output
1
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
App. - 16
QEX13
App. - 17
Appendix 4.11
Starting
-
operation of electrical machinery
operation. After the
operation time has
Turning on the start switch starts the
elapsed, the
operation mode is activated through an arc interlock state.
0
X0
X1
Y70
9
13
18
Y70
Y72
Y70
Y71
Program name
MAIN
Y71
K5
T6
T5
T6
QA-20
Y70
K20
T5
Y72
T5
Project name
Y72
Y72
Start X0
Stop X1
Operation Y70
Y71
operation
operation
Y72
T5 = 2sec.
T6 = 0.5sec. Arc interlock
App. - 18
During operation
period timer
operation
Arc interlock
operation
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.
Elapsed time display
(Four digits of BCD)
Output module
Y6C to 6F
X2
Y68 to 6B
Starts when turned on
Stops when turned off
0
Y64 to 67
Y60 to 63
× 100
× 10
×1
× 0.1
K6000 Timer starts when
T53
X2 is turned on
X2
BCD
0
1234
T53
K4Y60
Outputs current
value of timer
=
Y76
K500
T53
Y76
Turns on when
current value is
50sec. or more
>
K120
T53
Y77
Turns on when
current value is
12sec. or less
X2
T4
BCD
T4
K3000 Timer starts when
K4Y60
>
K300
T4
Y70
<
K299
T4
>
K320
T4
Y71
<
K319
T4
>
K340
T4
Y72
<
K339
T4
Y73
<=
K600
T4
Y74
<=
K800
T4
Y75
App. - 19
X2 is turned on
Outputs current
value of timer
Turns on when current
value is 30sec. or less
Turns on when current
value is from 30 to 31.9sec.
Turns on when current
value is from 32 to 33.9sec.
Turns on when current
value is 34sec. or more
Turns on when current
value is 60sec. or more
Turns on when current
value is 80sec. or more
Appendix 4.13
Retentive timer
The input X2 switches between on and off continuously. The on-time of X2 is
accumulated and Y72 turns on according to this accumulated value n.
(1) For a ladder that accumulates a value without a retentive timer
0
2
X2
Project name
QA-21
Program name
MAIN
M0
M0
PLS
Timer starts when
X2 is turned on
M1
K600
T195
9
12
15
M1
M0
T195
MOV
D7
T195
MOV
T195
D7
Writes D7 to timer
when X2 is turned on
Saves current value
of timer to D7
MOV
K0
D7
Clears D7 by time-out
Y72
Y72 turns on 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)
0
5
7
Project name
QA-8
Program name
MAIN
K600
ST195
X2
ST195
Y72
X1
RST
App. - 20
ST195
Timer starts when
X2 is turned on
Cannot be cleared
by turning off
Can be cleared by
turning on X1
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.
1sec.
SC
10sec.
100sec.
PB
Starts timer
PB
Resets timer
Input power supply
0
3
6
9
11
12
OL
Indicates the timer
is in operation.
X0 Y70
X1
RL
Indicates the timer
has gone time out.
Y70
X2
MC
X3 Y70
Load
X4
Load power supply
X0
X1
X2
X3
X4
M0
Project name
QA-22
Program name
MAIN
MOV
K10
D0
Set value 1sec.
MOV
K100
D0
Set value 10sec.
MOV
K1000
D0
Set value 100sec.
SET
M0
Starts timer
RST
M0
T8
Stops timer
D0
Y70
19
T8
Y71
Y72
App. - 21
Turns on while timer
is in operation
Turns on by time-out
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.
I/O
UNIT1
I/O
UNIT0
I/O
UNIT3
I/O
UNIT4
X20 to 2F
X0 to 1F
Y60 to 6F
Y70 to 74
Digital switch (BCD × 4 digits)
1
2
3
4
DC12V
AC100V
PB
Setting signal
X0
Start
X5
Reset or stop
X1
Y70
PB
Y71
PB
Count pulse
X3
Y72
DC12V
Current value display
BCD × 4 digits
Y73
RL
Setting error
RL
ON during
operation
R1
Turns on 100
short of set value
R2
Turns on 50
short of set value
R3
Turns on at
counter stop
DC24V
Y74
Setting value
Maximum setting value 9999
Setting error range
Start
Turn on X5
Y71 ON
100 short of set value
Y72 ON
App. - 22
50 short of set value
Y73 ON
Count up
Y74 ON
0
2
4
12
24
X0
X1
M0
M0
X5
BIN
>
Y70
K100
Project name
QA-4
Program name
MAIN
SET
M0
RST
M0
K4X20
D0
Reads set value
Y70
Outputs error when
set value is 100 or less
D0
MOV
D0
D1
-
K100
D1
MOV
D0
D2
-
K50
D2
C0
Setting
Set value -100
(100 short of set value)
Y71
Set value -50
(50 short of set value)
ON during operation
Y71
28
31
Y71
MC
N0
X3
M3
C0
C1
C2
44
45
58
62
64
66
X1
M0
BCD
C1
MCR
N0
RST
C0
RST
C1
RST
C2
C0
D0
D1
D2
K4Y60
Y72
C2
Y73
C0
Y74
Counter that turns on
at stop
Counter that turns on
100 short of set value
Counter that turns on
50 short of set value
Counter is reset by
turning on X1
Displays counted
values to exterior
Turns on at 100 before
the set value
Turns on at 50 before
set value
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.
0
5
Project name
QA-23
Program name
MAIN
K3600
ST250
X2
ST250
RST
6-minute timer
ST250
+
K1
D30
MOV
K0
D30
+
K1
D31
BCD
D31
K4Y60
1-hour timer
=
21
25
K10
D30
SM400 (always ON)
<=
K1000
D31
Measures in
1 hour units
Outputs operation
time to exterior
Indicates timing
to replace
Y70
The management time is set to 100 hours.
Appendix 4.17
Measuring cycle time
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.
0
X0
X1
Project name
QA-24
Program name
MAIN
M56
In cycle
M56
K32760
Measures cycle time
T200
M56
T200
10
<
K400
T200
14
<
X7
K300
T200
4
24
>=
K400
SET
Cycle time run out
Y70
K32760
Number of cycle times
C10
RST
Y70
RST
C10
T200
App. - 24
of 3.01 to 4.00sec.
Clears time out display
and accumulated counts
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).
D0
D1
DCML
D0
D20
D+
K1
D20
B B
15 14
Before DCML 1 0 1 1
execution
B B B B
1 0 15 14
0 1 0 0 0 1 1
B B
1 0
1 0 0 1 0
(Negative number)
D21
After DCML 0 1 0 0
execution
D20
1 0 1 1 1 0 0
D21
After D+ execution 0 1 0 0
0 1 1 0 1
D20
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.
Reading the set value
Turn on X0
Subtraction (-999)
Turn on X1
Negative number
obtained?
NO
YES
Y70 setting
DCML execution
+1 execution
Result display
0
4
X0
X1
D>
18
K0
D+
31
K4X20
D0
Inputs data
D-P
K999
D0
Subtracts 999
SET
Y70
Turns on Y70 when
negative number is obtained
PLS
M0
D0
M0
Y70
DBIN
DCML D0
D20
K1
D30
When D0 is negative number,
two's complement is taken to
have positive number (absolute value)
DBCD D30
K8Y40
Outputs absolute value
DBCD D0
K8Y40
Outputs positive number
D20
App. - 25
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
QCPU
QX
42
Y5F to Y50
QY
42P
Y4F to Y40
X3F to X30
X2F to X20
X0
Dividend Digital switch X30 to X3F → D0
Divisor
Digital switch X20 to X2F → D1
Importing dividend and divisor
Division
(D0) / (D1) = (D2) ...... (D3)
Quotient Remainder
Displaying a quotient
Clearing index registers Z0
and Z1 and data register D10
4 × (Z1) → (D10)
HC-(D10) → (Z0)
1st time 4 × 0 → 0
HC-K0 → HC
2nd time 4 × 1 → 4
HC-K4 → H8
3rd time 4 × 2 → 8
HC-K8 → H4
4th time 4 × 3 → 12
HC-K12 → H0
(D3) × 10 → (D3)
(D3) / (D1) = (D2) ...... (D3)
FOR
Setting the display address
after decimal point
Multiplying the remainder with 10,
dividing the result, and taking a
quotient of lower 1 digit
Y40 to 43
Y44 to 47
Counting the number of times
(register Z1)
Y48 to 4B
Displaying the lower 1 digit
Y4C to 4F
Appendix 4.19
INC Z1
NO
NEXT
Last- Last- Last- Last1st 2nd 3rd 4th
digit digit digit digit
4 obtained?
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.
0
X0
/P
24
QA-5
Program name
MAIN
BINP
K4X30
D0
BINP
K4X20
D1
D1
D2
Division
BCDP D2
K4Y50
BCD-outputs a quotient
DMOVP K0
Z0
Clears index register Z0
MOVP K0
D10
Clears D10
D0
22
M0
Project name
PLS
M0
FOR
K4
*
K4
Z1
D10
-
H0C
D10
Z0
*
D3
K10
D3
/
D3
D1
D2
D2
K1Y40Z0
Reads data
Repeats for 4 times
BCD
INC
Z1
NEXT
45
Executing the
INC Z1
instruction adds one to Z1.
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.
0
K4Y60
K4Y50
K4Y40
D7, remainder of
a decimal number
D6, integral number
in 4 digits
D5, decimal number
in 4 digits
X0
Project name
QA-6
Program name
MAIN
BINP
K4X30
D0
BINP
K4X20
D1
MOVP K0
App. - 28
D2
Clears D2
10000-fold
*P
D0
K10000
D3
D/P
D3
D1
D5
DBCDP D5
D5
DBCDP D7
D7
MOVP D6
K4Y50
Integral part
MOVP D5
K4Y40
Decimal part
MOVP D7
K4Y60
Decimal number
remainder
Appendix 4.20
Carriage line control
The following is an example of a sequence control using a carriage to convey works
(materials).
Series of operations performed in one cycle is as follows; A work is set on the
carriage, the carriage moves forward, the carriage stops at the forward limit, the arm
pushes the work to the other conveyor side, and the carriage moves back to the
backward limit.
Container for work
LS open complete (X4)
LS work present (X1)
LS backward
limit (X3)
Push (Y73)
Carriage
Carriage moves
forward (Y71)
Carriage moves
back (Y72)
Push back
(Y74)
Operating panel
LS forward
limit (X2)
Start button (X0)
Operation
indicator (Y70)
MELSEC-Q
Input
Output
Start button
Operation indicator
X0
Y70
X1
Y71
M
Carriage moves forward
X2
Y72
M
Carriage moves back
X3
Y73
Push
X4
Y74
Push back
Switch (LS work present)
Switch (LS forward limit)
Switch (LS backward limit)
Switch (LS open complete)
App. - 29
0
X0
Y70
M2
Project name
QA-10
Program name
MAIN
Y70
X1
X3
M1
Y71 X2
PLS
M1
SET
Y71
RST
Y71
SET
Y73
K30
T0
RST
Y73
SET
Y74
RST
Y74
SET
Y72
RST
Y72
Y73
T0
Y74 X4
Y72 X3
M2
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
Operation indicator
Carriage moves forward.
Push
Push back
Carriage moves back.
Completion flag
Appendix 4.21
Compressor sequential operation using ring counters
This system provides pressure control using three compressors.
A pressure shortage is detected by the three pressure switches. The number of
compressors operating simultaneously depends on the degree of shortage. To equal
the number of usages of each compressor, compressors are activated according to
the set order.
System configuration of compressor control
MELSEC-Q
Compressor
A
B
C
Pressure switch
PX1
PX2
PX3
Operating panel
Pressure shortage "Major"
Sufficient
pressure
Pressure shortage "Medium"
Pressure shortage "Minor"
Start button
Stop button
MELSEC-Q
Start
PB0
Input
X0
Output
Y70
MC
A
Compressor A
Y71
MC
B
Compressor B
Y72
MC
C
Compressor C
Stop
PB1
Pressure switch
PX1
PX2
PX3
X1
X2
X3
X4
Y73
Sufficient pressure
Y74
Pressure shortage "Minor"
Y75
Pressure shortage "Medium"
Y76
Pressure shortage "Major"
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
Compressor
Major
Minor
A,B,C
B
App. - 32
Minor Medium
C
A,C
Major
Minor
Minor
A,B,C
A
B
Minor Medium
C
A,C
0
X0
X1
Project name
QA-11
Program name
MAIN
M0
During operation
Y73
Indicates pressure status
Y74
Pressure shortage "Minor"
Y75
Pressure shortage "Medium"
Y76
Pressure shortage "Major"
PLS
M1
Turns on M9 at startup
PLS
M2
Shifts by pressure
shortage "Minor"
SET
M9
RST
M9
RST
M12
RST
M11
RST
M10
SFT
M13
SFT
M12
SFT
M11
SFT
M10
RST
M13
SET
M10
Returns shift to M10
Y70
Compressor A
Y71
Compressor B
Y72
Compressor C
M0
4
6
X4
X4
X3
X4 Y76 Y75
Pressure shortage "Minor" is indicated
when the pressure switch X4 turns off.
Y74
13
X3
X2
X4 Y76
Pressure shortage "Medium" is indicated
when the pressure switch X3 (Medium) turns off.
Y75
19
X2
X4
Pressure shortage "Major" is indicated
when the pressure switch X2 (Minor) turns off.
Y76
23
26
29
31
36
M0
Y74
M1
M0
M2
Resets when
X1 (stop) turns on
Shift register
45
M10
M0
48
50
M13
X4
M0 M10
Y75 M11
Y76
M11
Y75 M12
Y76
M12
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
X0, Start
X1, Stop
SET
M9
RST
M10
B
M11
C
M12
X4, (PX3)
OFF
Shift operation
X4
M10
M11
M12
App. - 34
Appendix 4.22
Application example of positioning control
The following is an example of a positioning system with a pulse generator that
outputs pulses per motor, brake, and unit of distance.
In this system, a command value is set with the digital switch, and this set command
value is compared with the current value at start-up to determine in which direction,
forward or reverse, the motor rotates. The current value in the register D16 is
subtracted by 1 in forward direction, and incremented by 1 in reverse direction.
Positioning is completed when the command value matches the current value. The
current value is converted to a BCD value so that current position is represented in
4-digit decimal numbers.
Home position
Forward
rotation
Pulse
generator
Home
position
Start
Reverse
rotation
5
4
0
X2
Y70
Y71
Y72
X1
Forward
rotation
Reverse
rotation
3
6
2
mm
0
X0
X20 to 23
X24 to 27
X28 to 2B
X2C to 2F
Y4C to 4F
X1000
Y48 to 4B
X100
Y44 to 47
X10
Y40 to 43
X1
M0
BINP
20
M0
QA-26
Program name
MAIN
M0
During operation
Y72
Releases brake
D15
Reads command value
D16
Y70
Forward rotation
>
D15
X1 Y70
D16
Y71
Reverse rotation
=
41
K4X20
Project name
D15
Y71
38
8
mm
M2
<
Brake
Current value display
0
X1
X10
X100
X1000
Brake
MELSEC-Q
X0
Command value setting switch
Motor
D15
X2
SM400 (always ON)
-P
K1
D16
-1 during forward rotation
+P
K1
D16
+1 during reverse rotation
M2
Checks consistency with
command value
Executes home position return
D16
MOV
K0
D16
BCD
D16
K4Y40
App. - 35
Displays current value
to exterior
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.
Date
3
0
Planned number
of products
0
1
Count value
K2X20
8
0
K4X30
K2Y58
Input
module
Output
module
X02
K4Y40
K4Y60
3
0
0
1
8
0
Manufactured number
on current day
3
7
8
2
Accumulated number
Date display
The number of products manufactured on the current day is counted by C5.
The accumulated number of products manufactured is counted by C6.
The date is entered in the index Z to indirectly specify the data register
corresponding to the date using D0Z0.
When Z0 is 30, D0Z0 becomes 0 + 30, specifying D30.
[Device/Buffer Memory Batch Monitor screen]
Stores the resulting
number of each day
ranging from 1 to 31
in D1 to D31.
Accumulated number
Planed number of products
Date
Manufacturing results of each day ranging from 1 to 31 are stored in D1 to D31,
which are available as production data.
App. - 36
0
=
K0
K4X20
16
(0.1-sec. clock)
Tentative count
value is set
X0
K0
K4X20
<=
K32
D36
<=
K1
D36
>=
K31
Program name
MAIN
K32760
D35
D35
C5
K32760
C6
Digital switch
Writes 32760 to D35 and counts
products manufactured
when X20 to 2F are 0
BIN
K4X20
D35
Inputs production command
BIN
K2X30
D36
Inputs date
SET
M2
RST
M2
PLS
M3
C5
<>
QA-7
MOV
SM410 X2
5
Project name
D36
Y70 flashes to indicate error
when date exceeding 31 is set
M2 SM411
Y070
43
M3
<>
46
D36
Z0
RST
C5
MOV
D36
Z0
Specifies date indirectly
MOV
C5
D0Z0
BCD
Z0
K2Y58
BCD
D0Z0
K4Y40
BCD
C6
K4Y60
Stores number of products
manufactured to data register
Displays manufacture date
to exterior
Displays number of products
manufactured on current day
Displays number of products
manufactured in one month
MOV
C6
D33
-P
C5
C6
SM400 (always ON)
57
X6
71
79
X7
FMOV
K0
D0
K32
FMOV
K0
K4Y40
K3
RST
C5
RST
C5
RST
C6
FMOV K0
D0
K32
FMOV K0
K4Y40
K3
Clears number of products
manufactured on day anytime,
if necessary
Clears all at end of month
Simultaneously transfers data 0 to D0 to D31.
Simultaneously transfers data 0 to K4Y40, K4Y50, and K4Y60.
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.
Right
X01
X00
Cleaning
In automatic
operation
X02
Y73
Recording
Reading
X03
X05
Automatic
Stop
X06
X07
Left (Y71) (Y70) Right
Conveyor system
MELSEC-Q
Left
Cleaning
(Y72)
1)
3)
2)
5)
6)
Step
4)
Teaching panel
X 20
22 23
24
Coating bath
21
25
Position is detected by sensors of
X20 to 25
Magnified view of teaching panel
FIFO table
Pointer
Coating bath
pattern
6
D10
Step 1)
11
1
2)
12
2
3)
13
8
4)
14
4
5)
15
16
6)
16
32
32
K2X20
D30
6
31
1
32
2
33
8
34
4
35
16
36
32
37
0
38
0
39
0
D0 (timer constant of T0) 40
6
41
135
42
150
43
120
44
100
45
20
46
135
K2 Y74
Read using FIFRP
1
Data is backed up when X03 is turned on
Backed up data is read
when X05 is turned on
Write using FIFWP
FIFO table
Pointer
D20
6
Read using FIFRP
Cleaning
time
Step 1)
21
135
2)
22
150
3)
23
120
4)
24
100
5)
25
20
6)
26
135
135
Data is backed up when X03 is turned on
Backed up data is read
when X05 is turned on
0
Current value of T1
D0
135
Write using FIFWP
App. - 38
0
Operation pattern from manual to automatic operation
Coating bath
Teaching panel
Cleaning machine
X00 = Manual right moving button
X01 = Manual left moving button
X02 = Manual cleaning button
X03 = Recording data button
X05 = Reading data button
X06 = Automatic operation button
X07 = Operation stop button
Y73 = Automatic operation
indication LED
Y70 = Conveyor, Moving right
Y71 = Conveyor, Moving left
Y72 = Conveyor, Cleaning
Start moving to right (X00 = ON)
Stop moving to right (X00 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start moving to right (X00 = ON)
Stop moving to right (X00 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start moving to right (X00 = ON)
Stop moving to right (X00 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start moving to left (X01 = ON)
Stop moving to left (X01 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start moving to right (X00 = ON)
Stop moving to right (X00 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start moving to right (X00 = ON)
Stop moving to right (X00 = OFF)
Start cleaning (X02 = ON)
Finish cleaning (X02 = OFF)
Start automatic operation
(X06 = ON ? OFF)
Automatic operation indication LED
(Y73 = ON)
X20 = Coating bath-1 (K2X20 = K1)
X21 = Coating bath-2 (K2X20 = K2)
X22 = Coating bath-3 (K2X20 = K4)
X23 = Coating bath-4 (K2X20 = K8)
X24 = Coating bath-5 (K2X20 = K16)
X25 = Coating bath-6 (K2X20 = K32)
1)
Moving to right (Y70 = ON)
Standby position (K2X20 = 0)
Coating bath-1 (K2X20 = 1)
Stop moving (Y70 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
A
Moving to right (Y70 = ON)
2)
Coating bath-2 (K2X20 = 2)
Stop moving (Y70 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
3)
Moving to right (Y70 = ON)
Coating bath-4 (K2X20 = 8)
Stop moving (Y70 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
4)
Moving to left (Y71 = ON)
Coating bath-3 (K2X20 = 4)
Stop moving (Y71 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
5)
Moving to right (Y70 = ON)
Coating bath-5 (K2X20 = 16)
Stop moving (Y70 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
6)
Moving to right (Y70 = ON)
Coating bath-6 (K2X20 = 32)
Stop moving (Y70 = OFF)
Cleaning (Y72 = ON)
Stop cleaning (Y72 = OFF)
Moving to left (Y71 = ON)
Coating bath-1 (K2X20 = 1)
(Starts the automatic operation)
A
The same operation is repeated from (A).
App. - 39
Project name
QA-9
Program name
MAIN
SM403
FMOV
0
X6
X7
>
5
D10
M2
K0
D0
K50
Resets data to 0 only once at RUN
Y73
Outputs to automatic operation indication LED
(Automatic operation mode is also indicated.)
M1
FIF0 reading pulse in automatic operation
M2
Finishes automatic operation
if data is not present
SM403
K0
Y73
Y73
T0
PLS
14
M1
>=
18
M1
KO
D10
M2
23
M1
M2
T2
FIFRP
K2Y74 D10
Reads position data of coating bath
if data is present
FIFRP
D1
D20
Reads cleaning time
M3
Reading completed flag
M4
Moves conveyor to right
since current position is on left
M5
Moves conveyor to left
since current position is on right
K10
T2
Completes the movement and
starts cleaning (preventing chattering)
D1
T0
Auto-cleaning timer
Y70
Moves conveyor to right
Y71
Moves conveyor to left
M6
In auto-cleaning
Y72
Cleaning from conveyor
K3200
T1
Measures manual cleaning time
T1
DO
Records manual cleaning time
PLF
M7
Auto-cleaning end pulse
Y73
31
M3
M5
37
>
K2Y74
K2X20
K2X20
K2Y74
M3
M4
M4
44
>
M3
M5
M3
T0
=
51
K2Y74
Y73
K2X20
T2
T2
X0
X1
Y73
Y71
67
M4
X1
X0
Y73
Y70
73
M5
X2
79
>
K2X20
Y73
SM403
KO
M6
T2
87
M6
M6
90
M0V
M7
>
99
K6
X3
Y73
X5
Y73
109
115
D10
FIFWP K2X20 D10
Records position of coating bath
FIFWP
D0
D20
Records cleaning time
BM0V
D10
D30
K20
Saves recorded data
BM0V
D30
D10
K20
Reads saved data
BCD
D10
SM400
121
K1Y60
END
125
App. - 40
Displays number of recorded data
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
X1
Stop
Code number
1 to 8
Y70
K1X20
Type detection
Movement of work
Shift
instruction
During
operation
Input
module
Output
module
X2
Machinery
Data
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
D30
D31
D32
D33
D34
D35
A code number is
input by K1X20.
A code number shifts
when X2 is turned on.
App. - 41
0
X0
X1
Project name
QA-12
Program name
MAIN
Y70
During operation
D30
Imports code number
K6
Shifts code number
Y70
4
8
12
SM400 (always ON)
MOV
X2
Y70
K1X20
DSFLP D30
=
K1
D30
M1
=
K2
D30
M2
=
K3
D30
M3
=
K4
D30
M4
=
K5
D30
M5
=
K6
D30
M6
=
K7
D30
M7
=
K8
D30
M8
=
K1
D31
M11
=
K2
D31
M12
=
K3
D31
M13
=
K4
D31
M14
=
K5
D31
M15
=
K6
D31
M16
=
K7
D31
M17
=
K8
D31
M18
=
K1
D32
M21
=
K2
D32
M22
=
K3
D32
M23
=
K4
D32
M24
=
K5
D32
M25
=
K6
D32
M26
=
K7
D32
M27
=
K8
D32
M28
Machinery A
53
Y70
Machinery B
94
Y70
Machinery C
App. - 42
135
Y70
=
K1
D33
M31
=
K2
D33
M32
=
K3
D33
M33
=
K4
D33
M34
=
K5
D33
M35
=
K6
D33
M36
=
K7
D33
M37
=
K8
D33
M38
=
K1
D34
M41
=
K2
D34
M42
=
K3
D34
M43
=
K4
D34
M44
=
K5
D34
M45
=
K6
D34
M46
=
K7
D34
M47
=
K8
D34
M48
=
K1
D35
M51
=
K2
D35
M52
=
K3
D35
M53
=
K4
D35
M54
=
K5
D35
M55
=
K6
D35
M56
=
K7
D35
M57
=
K8
D35
M58
Machinery D
176
Y70
Machinery E
217
Y70
Machinery F
App. - 43
Appendix 4.26
Project name
QA-14
Program name
MAIN
Example of operation program calculating square root of data
The data stored in D5 is calculated to its square root and the result is stored in D6
and D7.
0
X0
MOVP K4X20
D5
Sets data
BSQR
D6
Square root
operation
Square root
(integral part)
Square root
(decimal part)
D5
MOVP D7
K4Y50
MOVP D6
K4Y60
Results of square root operation are stored as follows.
Integral part Decimal part
D6
0 to 9999
0 to 9999
(BCD value) (BCD value)
D5
=
D7
0 to 9999
(BCD value)
A value in 5th decimal digit is rounded off.
Therefore, a value in 4th decimal place
has error of ±1.
REMARK
QCPUs provide square root operation instructions for data in a real number
(floating point) format.
App. - 44
Appendix 4.27
Project name
QA-15
Program name
MAIN
Example of operation program calculating n-th power of data
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.
0
X1
FMOVP K0
BINP
D10
K10
Clears data
K4X30
D10
Sets data
MOVP D10
D15
BINP
K2X20
D14
-P
K1
D14
Sets n
18
X1
21
23
X1
D*
D10
D15
28
P0
29
SCJ
P0
CJ
P0
FOR
D14
D10
Multiplies value
n times
NEXT
X1
D/
D10
K10000
D16
DBCD D16
K6Y50
DBCD D18
K4Y40
NOTE
An operation error occurs if a value in D10 exceeds 2147483647.
App. - 45
BCD-outputs value
in 10 digits to exterior
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
Digital switch
1
2
3
Input module
CPU
X20
to
X2F
Data
register
D10
4
Converted into BIN
SM400 (always ON)
Wrong
configuration
BIN
K4X20
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.
(Example 1) For 4 digits of X20 to X2F
0
SM400
<=
K0
K1X20
>=
K9
K1X20
MOV
K1X20
K1M20
<=
K0
K1X24
>=
K9
K1X24
MOV
K1X24
K1M24
<=
K0
K1X28
>=
K9
K1X28
MOV
K1X28
K1M28
<=
K0
K1X2C
>=
K9
K1X2C
MOV
K1X2C
K1M32
BIN
K4M20
D10
(Example 2) For 8 digits of X20 to X3F
0
SM400
4
7
<=
K0
K1X20Z0
>=
K9
K1X20Z0
Z0
FOR
K8
MOV
K1X20Z K1M100Z
+
K4
Z0
NEXT
31
32
RST
SM400
DBIN
K8M100
DBCD D10
App. - 46
D10
K8Y40
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.
[Sequence program flow]
(Operating procedure)
Fault detection ladder
X2
ON
Device F is used in
the program example.
OFF
1) Searching for faulty
(ON) devices
2) Displaying the number
of faulty devices
Displays the number of
faulty devices on display A.
Display B
Display A
(Y50 to Y5F)
(Y40 to Y4F)
Display C
(Y60 to Y6F)
X0
ON
OFF
Displays the fault
number on display C.
Displaying the first
fault number
Condition of program
The total number
of faulty circuits
is set to 50.
X1
ON
OFF
Displaying the number of
remaining faulty devices
including currently
displayed number and
the next fault number
NO
Displaying the
last fault number
Displays the number of remaining
faulty devices on display A.
Displays the next fault number on display C.
YES
End
App. - 47
0
4
8
12
16
20
24
28
32
36
40
44
48
73
80
95
X20
Project name
QA-31
Program name
MAIN
F3
X24
F5
X28
F8
X2C
F13
X30
F33
X34
F35
Faulty circuit
X38
F37
X3C
F39
X4
F1
X5
F11
X6
F16
X7
F40
X2 M200
DSUMP
K8F1
D0
MOVP
D0
D10
DSUMP
K8F33 D0
+P
D0
D10
BCDP
D10
K4Y40
SET
M400
RST
M700
PLS
M500
SET
M700
SET
M200
RST
M600
MOV
K0
Z0
DMOV
K8F1
D0
DMOVP
K8F33 D0
X000 M200 M400
M500
M600
App. - 48
Searches for
ON devices
Specifies start number
of faulty circuit
(F1 to 0)
103
M100 M200
DROR D0
SM700
BCD
120
125
SET
M100
INC
Z0
Z0
X1 M700
K1
K4Y60
PLS
M300
RST
M100
M300
<
K0
D10
BCD
K1
D10
D10
K4Y40
144
=
K32
Z0
SET
M600
150
=
K50
Z0
RST
M200
MOVP K0
164
Searches for ON
devices shifting
32-bit data to right
M800
K4Y60
PLS
M800
RST
M400
Searches for
next ON devices
Resets when
search is finished
(1) Searching for ON devices
DSUMP K8F1
D0
DSUMP K8F33
D0
32 bits
F F
3231
F F F F
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
B0
B15
A0 after
execution
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
The total number of bits with 1 is stored in BIN.
(in this example, 16)
Turning on X2 stores the number of turned-on bits among F1 to F64 to D10 and
display it.
App. - 49
F
16
Transferred by the MOVP instruction
F
1
1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1
D0
D10
16
16
1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 1
F
32
F
48
F
17
F
33
D0
0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1
Added by a
+P instruction
7
0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0
F
64
F F
50 49
D10
23
Number of ON inputs among X20 to 5B
(2) Searching for ON devices shifting 32-bit data to right DROR
DMOV
K8F1
D0
DMOV
K8F33
D0
D0
F F
32 31
F
3
F
2
F
1
1
0
0
1
1
K1
F
0
32 bits
DMOV instruction
D1,D0 1
1
1
0
0
D1
(16 bits)
DROR
D0
K1
D0
B31B30B29 B28B27
1
1
D0
(16 bits)
D1
Before
execution
0
1
1
0
B17B16B15B14B13
0
0
1
1
1
B5 B4 B3 B2 B1 B0
0
1
1
1
0
0
1
To B31
Carry flag
(SM700)
Contents of
B0 before
execution
After
execution
1
1
1
1
0
0
0
1
1
1
0
1
1
1
0
0
1
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
Data to be stored in memories
The following table lists the data and drive numbers which can be stored in
the program memory, standard RAM, standard ROM, and memory card.
Memory
CPU module built-in memory
Memory card (ROM)
card (RAM)
File name and
Item
Program
Standard
Remarks
Standard
SRAM card
memory
*1
Drive 0
RAM
Flash card
ATA card
extension
ROM
*1
Drive 3
*1
Drive 4
*1
*1
Drive 1
Drive 2
Parameter
PARAM.QPA
1 data/drive
Intelligent function
module
*2
parameter
IPARAM.QPA
1 data/drive
Program
Device comment
*5
*3
*4
*4
*4
***.QPG
*6
*6
*6
*6
***.QCD
-
***.QDI
-
***.QST
-
Device initial value
Device data
*9
-
File register
*7*8
Local device
*7
***.QDL
Sampling trace file
*7
***.QTD
-
Error history data
***.QFD
-
Device data
storage file
Module error
collection file
DEVSTORE.
QST
IERRLOG.
QIE
MEMBKUP0.
QBP
-
***.***
-
***.QDR
Backup data file
Programmable
controller user
data
User setting
*11
system area
*10
1 data/CPU
module
: Required,
-
: 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
-
: Not storable
Memory capacities and necessity of formatting
The following tables list the memory capacities and necessity of formatting
of each memory.
Program memory
Standard ROM
Standard RAM
Memory
card
Q00UJCPU
Q00UCPU
10K steps
(40K byte)
256K byte
-
SRAM
card
-
Flash
card
-
ATA
card
-
Q04UD(E)H
CPU
Program memory
Standard ROM
Standard RAM
SRAM
card
Memory
card
Flash
card
ATA
card
Q06UD(E)H
CPU
40K steps
60K steps
(160K byte)
(240K byte)
1024K byte
256K byte
768K byte
Q2MEM-1MBS: 1M byte
Q2MEM-2MBS: 2M byte
Q3MEM-4MBS: 4M byte
Q3MEM-8MBS: 8M byte
Q2MEM-2MBF: 2M byte
Q2MEM-4MBF: 4M byte
Q2MEM-8MBA: 8M byte
Q2MEM-16MBA: 16M byte
Q2MEM-32MBA: 32M byte
Q01UCPU
15K steps
(60K byte)
512K byte
128K byte
Q02UCPU
20K steps
(80K byte)
Q03UD(E)CPU
30K steps
(120K byte)
1024K byte
192K byte
Q2MEM-1MBS: 1M byte
Q2MEM-2MBS: 2M byte
Q3MEM-4MBS: 4M byte
Q3MEM-8MBS: 8M byte
Q2MEM-2MBF: 2M byte
Q2MEM-4MBF: 4M byte
Q2MEM-8MBA: 8M byte
Q2MEM-16MBA: 16M byte
Q2MEM-32MBA: 32M byte
Q010UD(E)H
CPU
Q13UD(E)H
CPU
100K steps
130K steps
(400K byte)
(520K byte)
2048K byte
1024K byte
Q20UD(E)H
CPU
Formatting
*1
Unnecessary
*1
Necessary (use
GX Works2.)
Unnecessary
Necessary (use
GX Works2.)
Q26UD(E)H
CPU
200K steps
260K steps
(800K byte)
(1040K byte)
4096K byte
1280K byte
Formatting
*1
Unnecessary
*1
Necessary (use
GX Works2.)
Unnecessary
Necessary (use
GX Works2.)
*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)
(1) Supported CPU modules
The following table lists the CPU modules that are supported in GX Works2.
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.
Unsupported feature
Alternate S/W
Online function
TEL function
GX Developer
Debug function for ladder program
Monitor condition/Monitor stop condition setting
GX Simulator
function
Scan time measurement function
Skip/Parts/Step execution function
Debug function for ST program
Debug function
Breakpoint function
Intelligent function module
Protocol FB support function
GX Configurator-SC
programming function
Intelligent function module debug
Debug support function
function
Online function for positioning
Trace function
GX Configurator-QP
module
System monitor function
Test mode function
Device initial value function
Device memory registration function
GX Developer
Password function
Password registration function for data in project
GX Developer
Interaction with GX Explorer
Boot by GX Explorer
GX Developer
Interaction with PX Developer
Boot by PX Developer
GX Developer
Interaction with GX Converter
I/O function with GX Converter
GX Developer
MEDOC print format import
Import in MEDOC print format
GX Developer
Online function
Intelligent module diagnostics from system monitor
GX Developer
Printing function
GX Configurator
Sampling trace function
Sampling trace function conditionally on step number
App. - 54
GX Developer
(3) Supported project types
The following table lists the project types that are supported in GX Works2.
Project type
Simple project
(without labels)
Description
This is the equivalent of the "Do not use label" project of GX Developer.
1) When a project created in the "Do not use label" of GX Developer is read with GX
Works2, the project becomes the Simple project (without labels).
2) When a project created in the Simple project (without labels) of GX Works2 is read with
GX Developer, the project becomes the "Do not use label" project.
Simple project
(with labels)
This is the equivalent of the "Use label" project of GX Developer.
1) When a project created in "Use label" of GX Developer is read with GX Works2, the
project becomes the Simple project (with labels).
2) When a project created in the Simple project (with labels) of GX Works2 is read with GX
Developer, the project becomes the "Use label" project.
Structured project
In GX Works2, "structured programming" is available. The structured programming
proceeds while creating POUs and combining them (registering tasks in the program file).
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.
(a) Using project functions
Before using the project function in GX Works2, review the following
precautions.
Function
Description (differences between GX Developer and GX Works2)
GX Developer
Protect projects
Change project types
GX Works2
By installing projects as "monitoring
By setting projects as "read-only with the
only", the projects can be protected on
"Security" function, project-by-project protection
each personal computer.
is now available.
Project types cannot be changed from
The following project type changes are now
"Do not use label" to "Use label".
available.
1) From "Simple project (without labels)" to
"Simple project (with labels)"
2) From "Simple project (with labels)" to
"Structured Project"
* Project type cannot be changed directly from
"Simple project (without labels)" to "Structured
Project".
Read GX Developer
Selecting [Project] → [Open Other Project] can read GX Developer format projects.
format projects
Read GX
Selecting [Project] → [Intelligent Function Module] → [Import GX Configurator-QP Data] can
Configurator-QP format
read GX Configurator-QP format projects.
projects
Copy data in a project
It is enabled on the project copy dialog
Copy and paste is now available in the Project
to different projects
box.
window.
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.
Project type
Simple project
Supported programming language
Ladder, SFC (MELSAP3)
(without labels)
Simple project
Ladder, SFC (MELSAP3)
(with labels)
* Supported program element: label, structure, function block
Structured project
Ladder, SFC (MELSAP3), structured ladder, ST
* Supported program element: label, structure, function block, function block, library
The following programming languages are not supported in GX Works2.
Use GX Developer for the following programming languages.
Project type
List
Supported programming language
1) When GX Works2 reads out a program created with lists in GX Developer, it can be
displayed or edited in ladder.
2) When GX Developer reads out a program created with ladder in GX Works2, it can be
displayed or edited in list.
MELSAP-L
1) When GX Works2 reads out a program created with MELSAP-L in GX Developer, it can
be displayed or edited in ladder.
2) When GX Developer reads out a program created with SFC (MELSAP3) in GX Works2, it
can be displayed or edited in MELSAP-L.
(a) Using ladder language
Before using the ladder language in GX Works2, review the following
precautions.
Function
Description (differences between GX Developer and GX Works2)
GX Developer
Program giving devices
GX Works2
It is enabled by the "Alias" function.
Use "Label".
Segment a part of
It is enabled by the "Macro definition/
Use "Function Block".
program into POUs
import" function.
an alias
(macros)
Find/Replace
Find is enabled by directly typing an
Pressing the Space key on the ladder editor
instructions/devices/lab
instruction/device/label in "Read mode".
allows the simple find.
Check use status of
It is enabled by the "Cross Reference
Select [Find/Replace] → [Cross Reference], or
device/label
List" function and "List of Used Devices"
[Find/Replace] → [Device List].
Merge the programs
It is enabled by the "Merge Data"
Verify
No corresponding function
els
functions.
Use copy and paste on the label editor.
function.
The Verify Result window clearly shows the
following: "unmatched area of the programs",
"only verification source contains the program"
and "only verification destination contains the
program".
App. - 56
(b) Using SFC (MELSAP3) language
Before using the SFC (MELSAP3) language in GX Works2, review the
following precautions.
Function
Description (differences between GX Developer and GX Works2)
GX Developer
Change block number
GX Works2
It is enabled by the "copy and paste"
Each block data is displayed in the Project
function in block list.
window, and the block number can be
changed in the property of each block data.
* Selecting [View] → [Open SFC Blocklist]
can display the block list equivalent to that
of GX Developer.
Auto scroll
Open a start source block
A new block diagram can be opened by
Selecting [View] → [Open Zoom/Start
block start.
Destination Block] can open it.
No corresponding function
by block start
Selecting [View] → [Back to Start SFC
Block] can open it.
Open operation/transition
Moving a cursor on the SFC diagram can
Selecting [View] → [Open Zoom/Start
condition programs
display zoom (operation output /transition
Destination Block] can open it. Or
condition).
double-clicking while pressing the Ctrl key
also can open it.
Multiple zooms (operation output/transition condition) can be simultaneously displayed.
* Changing the "Setting of Zoom Display" option can switch the display in a window in the
same way as GX Developer.
(c) Using labels
Before using labels in GX Works2, review the following precautions.
Function
Description (differences between GX Developer and GX Works2)
GX Developer
GX Works2
Check devices
It is enabled by the "Show assigned
Check on the ladder editor by selecting [View]
automatically assigned to
device" function of label editor.
→ [Device Display].
Import/Export device
It is enabled by the "device comment
Use the copy and paste on the label editor
comments to labels
import" function and "device comment
and device comment editor.
labels
export" functions.
Use pointer-type labels
Local pointers are assigned.
Common pointers are now assigned.
For projects with labels, 2048 points are set
by default in "Common Pointer No." in the
"PLC System" tab of PLC Parameter.
Unusable reserved words
The definition of reserved words is different between GX Developer and GX Works2.
for label name
App. - 57
(d) Using function blocks
Before using function blocks in GX Works2, review the following
precautions.
Function
Description
Use function blocks created with
ladder
Function blocks created with ladder can be used for ladder program, ST program,
and SFC program operation outputs.
Use function blocks created with
structured ladder
Use function blocks created with
ST
* 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".
Function blocks created with structured ladder can be used for ladder programs,
structured ladder programs and ST programs.
Function blocks created with ST can be used for ladder programs, structured
ladder programs, and ST programs.
When the option "Enable function
block call 'from ladder to
Structured Ladder/FBD' and
'from Structured Ladder/FBD or
ST to ladder" is set
* 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 VAR_IN_OUT input variable and output variable have different
label/device, the input variable value is always equal to the output variable value.
(5) Using device comments
Before using device comments in GX Works2, review the following precautions.
Function
Description (differences between GX Developer and GX Works2)
GX Developer
GX Works2
Delete comments of
It is enabled by the "Delete unused
After checking the unused device by selecting
unused devices
comments" function.
[Find/Replace] → [Device List], delete the
device comment directly.
Sample comment
Sample comments of the special
Comments of the special relay/special register
relay/special register are provided in
and intelligent function module can be imported
project format.
by the "Import from Sample Comment" function
on the device comment editor.
(6) Using device memory
Before using the device memory in GX Works2, review the following
precautions.
Function
Device memory display
Description
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
Maximum amount of
device initial value data to
be created
Restriction of device
number
Write to PLC/read from
PLC
IC memory card
write/read
Description (differences between GX Developer and GX Works2)
GX Developer
GX Works2
Only one set of data can be created.
Up to 800 sets of data can be created.
The device number must be within the
maximum points of each
programmable controller of devices.
Only 1 data can be read and written.
The device number must be within the device
setting range of the PLC parameter.
Selected multiple data can be read and written.
(8) Using online function
Before using the online function in GX Works2, review the following
precautions.
Function
Connection destination
setting
Write/Read data to/from
intelligent function
modules
Write data to the Flash
ROM of the CPU module
Remote operation window
PLC diagnostics window
System monitor window
Function
Read from PLC
Description (differences between GX Developer and GX Works2)
GX Developer
GX Works2
A project can contain only one set of
A project can contain multiple sets of
"connection destination" information.
"connection destination" information.
To change the "connection destination"
information, select "Connection Destination" in
the Project window.
Selecting [Online] → [Write to PLC] writes data
Data can be written or read to/from
to CPU modules and intelligent function
CPU modules and intelligent function
modules simultaneously.
modules simultaneously.
Selecting [Online] → [Read from PLC] reads
data from CPU modules and intelligent function
modules simultaneously.
It is enabled by the "PLC write (Flash
The "PLC write (Flash ROM)" function is now
ROM)" function.
integrated in the "Write to PLC" function.
Select [Online] → [Write to PLC].
Selecting [Online] → [Remote Operation] and [Diagnostics] → [System Monitor]/[PLC
Diagnostics] can display the module image and the programmable controller CPU
operation status is now easy to see.
The remote operation, memory operation, and clock setup can be started from the PLC
Diagnostics window.
Description
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
Entry device monitor
Device batch
monitoring
Buffer batch monitoring
Monitor and test
intelligent function
modules
Description
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.
The "device batch monitoring" and "buffer memory batch monitoring" functions are now
integrated to realize the same operability.
The on/off status of bit devices and current values of word devices can be modified on the
monitor window.
To use the monitoring or test function to FL-net (OPCN-2) interface unit and AS-i master
unit, execute the "watch" and "Device/Buffer memory batch monitor" function.
(10) Using printing function
Before using the printing function in GX Works2, review the following
precautions.
Function
Additional information
print such as statement
and device comment
Description
The displayed image is printed or previewed.
To print additional information such as a statement and device comment, put the target
information on the screen and then select [Project] → [Print Window]/[Print Window
Preview].
(11) Copying saved project data
Before copying project data saved in GX Works2, review the following
precautions.
Function
Copy saved project data
Description (differences between GX Developer and GX Works2)
GX Developer
GX Works2
Saved project data can be copied by Copy all the workspace name folders and
copying files under the project name "workspacelist.xml" created in the same hierarchy
folder.
as the workspace name folders.
(12) Compatibility with GX Developer
For the compatibility between GX Developer and GX Works2, review the
following precautions.
Function
Open projects in other
formats
Export projects to GX
Developer format file
Description
Before opening a GX Developer "Use label" project of which a program and function
block have the same name, change the data name in GX Developer.
Function names of ST language are different between GX Developer and GX Works2.
Compile the program and correct errors.
Applicable projects are the following;
1) Simple project (without labels)
2) Compiled Simple project (with labels)
Projects using labels in SFC language are executed.
The project can be saved in GX Developer format when none of the following is applied.
1) No device is set.
2) The length of the label name exceeds 16 characters.
3) Label name contains a device name or reserved word.
4) An invalid character is used.
5) Data type which is not supported by GX Developer is used.
6) A value which is not constant is used in the constant.
Data registered to the global label is set as "Auto External" for all the local labels.
App. - 60
(13) Compatibility with GX IEC Developer
For the compatibility between GX IEC Developer and GX Works2, review the
following precautions.
Function
Open projects in other
formats
Description
Function names of ST language are different between GX IEC Developer and GX
Works2.
Compile the program and correct errors.
Before using GX IEC Developer user libraries which a password is set to, cancel the
password in GX IEC Developer.
User library
(14) Key operation
This section explains the differences of the key operation between GX
Developer and GX Works2.
Shortcut key
GX Developer
GX Works2
Read mode
Activates the read mode.
Shift + F2
- (*1)
Write mode
Activates the write mode.
F2
- (*1)
Cross reference
Displays the cross reference.
-
Device List
Displays the device list.
-
Convert (all programs being edited)
Converts all programs being edited.
Convert
Edit
Description
Find/Replace
Function
View
Project data list
Switch between the project data list
and window
Switch between ladder and list
Monitor
Monitor (all the windows)
Monitor (write mode)
Online
Stop monitor (all the windows)
Debug
Device test
Skip execution
Partial execution
Step execution
Remote operation
Switches display/non-display of the
project data list.
Switches between the project data list
and each window.
Switches between the ladder window
and list window.
Monitors ladders of all the opened
programs.
Activates the write mode during ladder
monitoring.
Stops the ladder monitoring for all the
opened programs.
Turns on or off the device forcibly or
modifies the current value.
Executes selected sequence
programs in skip execution.
Executes sequence programs
partially.
Executes the programmable controller
CPU in step execution.
Executes remote operations.
Ctrl + Alt + F4
-
Alt + O
-
Alt + 7
-
Alt + F1
-
Ctrl + F3
-
Shift + F3
- (*2)
Ctrl + Alt + F3
-
Alt + 1
-
Alt + 2
-
Alt + 3
-
Alt + 4
-
Alt + 6
-
*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
Shortcut keys of each function can be customized.
Customized shortcut keys can be registered as a template and utilized.
Screen display
Select [Tool] → [Key Customize].
Item
Shortcut Key
Category
Command
Current Key
Press the keys to assign
Description
Select a category from the group list categorized by window.
Select a function name whose shortcut key is to be changed.
Displays the shortcut key assigned to the selected command.
Specify a new shortcut key to be assigned. Pressing a key(s) on the
keyboard assigns the key(s).
Example)
Current
Template
Displays the menu name to which the entered shortcut key is assigned.
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.
• 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".
Deletes the shortcut key selected in "Current Key".
The Enter Template Name screen is displayed.
Register the assigned shortcut keys as a template with a name.
The registered template is displayed in "Template".
The selected template of shortcut keys is applied.
Deletes a template selected in "Template".
Imports a pre-saved template file (*.gks) and adds it to "Template".
Saves a template selected in "Template" as a template file (*.gks).
App. - 63
Indexing
In the Universal model QCPU (excludes Q00UJCPU), expanding the index register
to 32 bits enables the indexing for all the file register areas.
SM400
ZR0
ZR1
ZR32767
ZR32768
Area to which indexing can be
used of Universal model QCPU
Serial number access
format file register
Conventional area
to which indexing
can be used
Appendix 8
DM0V K1042431
Z0
M0V
D0
ZR0Z0
To index the serial number access format file
register (ZR) with 32-bit, use the index register (Z).
ZR4184063
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
(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
X0
MOV
ZR10Z0 D0
Stores 40000 in Z0.
Stores the data of
ZR10Z0 = ZR{10+40000}
= ZR40010 in D0.
Indexing
(b) Specification method
For indexing with a 32-bit index register, specify the start number of an
index register to be used on the Device tab of the PLC parameter setting
screen in GX Works2.
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
(d) Usable range of index registers
The following table shows the usable range of index registers for indexing
with 32-bit index registers.
For indexing with 32-bit index registers, the specified index register (Zn)
and the next index register of the specified register (Zn+1) are used. Be
sure not to overlap index registers to be used.
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)
Actual process device
Ladder example
X0
DMOV K100000
X1
Z0
MOV
MOV
K-20
Z2
MOV
ZR1000Z0 D30Z2
ZR101000
D10
Description
X1
App. - 65
ZR1000Z0
D30Z2
ZR(1000+100000)=ZR101000
D(30-20)=D10
(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.
MOVP
K100
ZR0ZZ4
Indexing ZR device with 32-bit
index registers (Z4 and Z5)
ZR (0+100000) =ZR100000
M0
(b) Specification method
For 32-bit indexing using "ZZ" specification, select "Use ZZ" in [Indexing
Setting for ZR Device] in the Device tab in PLC parameter setting screen.
(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
(d) Usable range of index registers
The following table shows the usable range of index registers in 32-bit
indexing with "ZZ" specification.
The 32-bit indexing with "ZZ" specification is specified as the format
ZRmZZn.
Specifying ZRmZZn enables Zn and Zn+1 of 32-bit values to index the
device number of ZRm.
"ZZ"
specification*
□ZZ0
□ZZ1
□ZZ2
□ZZ3
□ZZ4
□ZZ5
□ZZ6
□ZZ7
□ZZ8
□ZZ9
Index registers to be used
"ZZ"
specification*
□ZZ10
□ZZ11
□ZZ12
□ZZ13
□ZZ14
□ZZ15
□ZZ16
□ZZ17
□ZZ18
□ZZ19
Z0, Z1
Z1, Z2
Z2, Z3
Z3, Z4
Z4, Z5
Z5, Z6
Z6, Z7
Z7, Z8
Z8, Z9
Z9, Z10
*: □ indicates a device name (ZR, D, W) for indexing target
App. - 66
Index registers to be used
Z10, Z11
Z11, Z12
Z12, Z13
Z13, Z14
Z14, Z15
Z15, Z16
Z16, Z17
Z17, Z18
Z18, Z19
Cannot be specified.
(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)
Ladder example
Actual process device
X0
DMOV K100000
Z0
MOV
Z2
K-20
X1
MOV
(f)
D10
Description
ZR1000Z0
D30Z2
X1
MOV
ZR101000
ZR1000Z0 D30Z2
ZR(1000+100000)=ZR101000
D(30-20)=D10
Available functions for "ZZ" specification
The 32-bit indexing specification with "ZZ" specification applies to the
following functions of GX Works2.
No.
Function name and description
1
Specifying devices in program instruction
2
Entry device monitor
3
Device test
4
Device test with conditions
5
6
Monitor condition setting
Sampling trace
(Trace point (specifying devices), trace target device)
POINT
ZZn cannot be used alone as a device like "DMOV K100000 ZZ0".
When setting values of index registers to specify 32-bit indexing with "ZZ"
specification, set the value of Zn (Z0 to Z19).
ZZn alone cannot be input to each function of GX Works2.
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
a component
FB
Figure App. 9.1 Converting a sequence program into a component
Appendix 9.1.1
Conversion into components
The following section explains the process to convert a simple program into a
component.
1) Program to be converted into a
component
X1
INCP D1
Input
label
i_Count
Output
label
i_Count
INCP m_Cnt
m_Cnt K12
Y12
D1 K12
Input Internal device
2) Divide into input and output. In addition,
replace the internal device with an internal label.
Internal label
Output
3) When changed to an FB
o_C_UP
4) Pasting the FB to a program
Count process 1
X1
Count_Num1
i_Count
o_C_UP
Count_Num
i_Count
o_C_UP
Y12
Count process 2
X2
Count_Num2
i_Count
o_C_UP
Input label
Output label
Y22
Create input/output ladders (Setting parameter).
Figure App. 9.2 Flow of conversion into components
App. - 68
o_c_up
Appendix 9.1.2
Advantages of using FBs
This section introduces advantages of creating programs by using FBs.
(1) Easy programming
A sequence program can be created simply by pasting FBs. This significantly
reduces the program development man-hours. (FB libraries provided by
Mitsubishi Electric Corporation. makes programming easier.)
Only select an FB from the Selection window
and drag and drop it to paste.
(2) Easy reading
Using an FB creates a simple program with only a "box" (FB), an input, and an
output to create an easy-to-read sequence program.
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
into a component
FB for
start control
FB for
start control
FB for
start control
FB for
start control
(4) Improving quality
Converting a standard program into a component as an FB to reuse the
program allows development of programs of consistent quality, without relying
on the technological skill of the program developers.
When developers A and B are developing sequence programs for different
devices, using the same FB for the common processing enables the developers
to create consistent quality of sequence programs.
Common
FB
Developer A
Individual process
Developer B
Individual process
App. - 70
(5) Protecting assets
By setting up a block password, the created FB can be protected so that it
cannot be viewed.
Convert the program into an FB
and protect it with a password.
Sequence program related
to the technical know-how
Appendix 9.1.3
FB Libraries
An FB library is a collection of FBs that are usable in GX Works2 (Simple project).
Using an FB library enables easy setting and operation of MELSEC-Q/L modules
and partner products.
<Example of MELSEC-Q/L module>
FBs for partner products
Vision
sensor
FB
RFID
FB
Laser
displacement
sensor
FB
CC-Link
Ethernet
Vision sensor
RFID
Laser displacement sensor
Partner product family
App. - 71
<Example of partner product>
FBs for partner products
Vision
sensor
FB
RFID
FB
Laser
displacement
sensor
FB
CC-Link
Ethernet
Vision sensor
RFID
Laser displacement sensor
Partner product family
(1) FB library lineup
FB libraries include "FBs for MELSEC-Q/L modules" and "FBs for partner
products".
(2) How to obtain FB libraries
FB libraries can be obtained from Mitsubishi Electric FA site.
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
GX Works2 (Simple project) ver 1.12N or later is required to develop sequence
programs using FBs.
POINT
Depending on the FB library, supporting versions of GX Works2 may differ.
For details, refer to the download page of each FB.
Appendix 9.1.5
FB specifications and precautions
The following specifications and precautions must be understood prior to using FBs.
1.
An FB cannot be used in another FB.
2.
Because an FB specific process is added when an FB is arranged, the
number of steps increases when compared to a ladder created without an FB.
3.
FBs cannot be used in an interruption program.
4.
FBs whose execution does not complete within a scan cannot be used in the
FOR to NEXT instruction loops or subroutine programs.
App. - 73
Appendix 9.2
Creating a program by using an FB library
This section explains the procedure to create a program by using an FB library.
Appendx 9.2.1
Programs to be created
This section explains how to use an FB library with an example of importing an
analog value from an analog input module.
Example) Reading an analog value to D10 from the analog input module (Q64AD)
when the switch (X2) is turned on.
The program can easily be created by using an FB library as follows.
When the switch (X2) is turned on,
FB for reading AD conversion
data of the specified channel
Execution
command
Analog value
is input.
The analog value is stored in D10.
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
Before using an FB library, contact your distributor to obtain it.
(FB libraries will not be installed when installing GX Works2.)
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".
2) Double-click "setup.exe" in "q64ad_v100a".
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!
This completes the preparation prior to use of FB libraries.
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 [Project] → [Library] → [Install].
1) Click!
2) The Install dialog box is displayed.
3) Select!
4) Click!
5) Check!
3) Select "Q64AD"from Library List.
4) Click the
Refresh FB List
button.
5) Check the library to import.
6) Click!
6) Click the
OK
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
From the Selection window
or Project view, drag and
drop an FB to the place
where the FB will be pasted.
Project window
2)
The Input FB Instance Name dialog box is displayed.
For details of settings, refer to the next page.
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.
Instance name is a name to distinguish the FB.
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.
In this section, the default is used.
Operating Procedure
1)
Enter the FB instance name ("ReadADVal_1" in the example) and click the
OK button.
Enter the FB instance name.
Click
2)
The FB is pasted to the program window.
POINT
When entering an instance name, note the following points.
• Case-sensitive
• A number cannot be set for the first letter.
• The maximum number of characters for an instance name is 16.
An error occurs if
OK
is clicked with the following setting.
(When the first letter is a number).
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.
FB execution command
FB is running: ON
Normal end: ON
Module mounting XY address: 80
Channel number: 1
Error end: ON
Stores the error code.
Stores the analog value.
Appendix 9.2.7
Performing conversion/compilation
Conversion/compilation is required to execute the completed program.
The following explains how to convert/compile all programs.
1) Click [Compile] → [Rebuild All].
1) Click!
2) The message on the left is displayed. Click
the Yes button.
2) Click!
3) The compilation result is displayed in the
Output window.
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".
Appendix 9.2.9
Operation check
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.
Turn on the switch
(X10).
The current analog
value is displayed.
Double-clicking the FB in the sequence program on the screen enables monitoring
of the sequence program status in the FB.
App. - 80
SH-081123ENG-A
Download PDF