Q L Series Programming Manual
Q L Series Programming Manual
Q L Series Programming Manual
Programming Manual
The texts, illustrations, diagrams, and examples contained in this manual are
intended exclusively as support material for the explanation, handling,
programming, and operation of the programmable logic controllers of the
MELSEC System Q and L series.
If you have any questions concerning the programming and operation of the
equipment described in this manual, please contact your relevant sales office or
department (refer to back of cover).
Current information and answers to frequently asked questions are also
available through the Internet (www.mitsubishi-automation.com)
© 07/2011
Contents
Contents
1 Introduction
1.1 Further manuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.2 CPU types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.4 Finding an instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
1.5 PLC parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
1.6 Comparison between the software packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
2 Instruction Tables
2.1 Subdivision of instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.2 Overview of instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.2.1 Description of the overview tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.3 Sequence instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.3.1 Input instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6
2.3.2 Connection instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
2.3.3 Output instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
2.3.4 Shift instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.3.5 Master control instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.3.6 Program termination instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.3.7 Miscellaneous instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9
2.4 Application instructions, Part 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
2.4.1 Comparison operation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
2.4.2 Arithmetic operation instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
2.4.3 Data conversion instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20
2.4.4 Data transfer instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23
2.4.5 Program branch instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
2.4.6 Interrupt program execution control instructions. . . . . . . . . . . . . . . . . . . . . 2-25
2.4.7 Data refresh instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-25
2.4.8 Other convenient instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-26
2.5 Application instructions, Part 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
2.5.1 Logical operation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-27
2.5.2 Rotation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-30
2.5.3 Shift instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31
2.5.4 Bit processing instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-32
2.5.5 Data processing instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-33
2.5.6 Structured program instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-36
2.5.7 Data table operation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
2.5.8 Buffer memory access instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
2.5.9 Display instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-39
2.5.10 Debugging and failure diagnosis instructions . . . . . . . . . . . . . . . . . . . . . . . 2-40
2.5.11 Character string processing instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . 2-41
2.5.12 Special function instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-44
3 Configuration of Instructions
3.1 The structure of an instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.1 Source of data (s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.1.2 Destination of data (d) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
3.1.3 Number (n) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
3.2 Notation of instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
3.2.1 16/32-bit and pulse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
3.2.2 MELSEC and IEC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
3.2.3 Further characteristics of the instruction notation . . . . . . . . . . . . . . . . . . . . . 3-5
3.2.4 Specification of the notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
3.3 Programming of dedicated instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
3.4 Programming of variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
3.4.1 Programming with the GX IEC Developer. . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
3.5 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
3.5.1 Processing of data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
3.5.2 Addressing of arrays and registers in the GX IEC Developer. . . . . . . . . . . 3-22
3.5.3 Usage of character string data (STRING). . . . . . . . . . . . . . . . . . . . . . . . . . 3-25
3.6 Index qualification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-27
3.7 Indirect designation (GX Works2 only). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-39
3.8 Reducing instruction processing time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
3.8.1 Subset processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-42
3.8.2 Operation processing with standard device registers (Z)
(Universal model QCPU and LCPU only) . . . . . . . . . . . . . . . . . . . . . . . . . . 3-43
VIII
Contents
5 Sequence Instructions
5.1 Input instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5.1.1 LD, LDI, AND, ANI, OR, ORI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5.1.2 LDP, LDF, ANDP, ANDF, ORP, ORF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7
5.1.3 LDPI, LDFI, ANDPI, ANDFI, ORPI, ORFI . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
5.2 Connection instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13
5.2.1 ANB, ORB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13
5.2.2 MPS, MRD, MPP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15
5.2.3 INV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-18
5.2.4 MEP, MEF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
5.2.5 EGP, EGF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
X
Contents
XII
Contents
XIV
Contents
XVI
Contents
13 Error Codes
13.1 Error code list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.1.1 How to read the error code list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1
13.1.2 Types of error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
13.1.3 Clearing an error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-2
13.2 Error code list (1000 to 1999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3
13.3 Error code list (2000 to 2999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-19
13.4 Error code list (3000 to 3999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-39
13.5 Error code list (4000 to 4999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-57
13.6 Error code list (5000 to 5999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-71
13.7 Error code list (6000 to 6999). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-73
13.8 Error code list (7000 to 10000). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-81
13.9 Error codes returned to request source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-85
A Appendix A
A.1 Definition of the processing times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
A.2 Processing times for MELSEC System Q CPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2
A.2.1 Table of Processing Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
A.2.2 Instructions executable by the product with the first 5 digits
of the serial No. "04122" or higher (Basic model QCPU) . . . . . . . . . . . . . . A-22
A.2.3 Table of the time to be added (Basic model QCPU). . . . . . . . . . . . . . . . . . A-25
A.2.4 Instructions availabe from function version B
(High Performance model QCPU/Process CPU/Redundant CPU). . . . . . . A-26
A.2.5 Table of the time to be added
(High Performance model QCPU/Process CPU/Redundant CPU). . . . . . . A-27
A.2.6 Redundant system instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-27
A.3 Operation Processing Time of Universal Model QCPU . . . . . . . . . . . . . . . . . . . . . . A-28
A.3.1 Subset instruction processing time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-28
A.3.2 Processing time of instructions other than subset instruction . . . . . . . . . . . A-42
A.4 Operation Processing Time of LCPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-79
A.4.1 Subset instruction processing time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-79
A.4.2 Processing time of instructions other than subset instruction . . . . . . . . . . . A-86
A.5 Comparison of the CPUs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-102
A.5.1 Available devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-102
A.5.2 I/O control modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-104
A.5.3 Data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-104
A.5.4 Timer comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-105
A.5.5 Comparison of counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-109
A.5.6 Comparison of display instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-110
A.5.7 QCPU, LCPU instructions whose designation format
has been changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-111
A.5.8 AnACPU and AnUCPU dedicated instructions . . . . . . . . . . . . . . . . . . . . . A-112
XVIII
Contents
XX
Introduction Further manuals
1 Introduction
This manual describes the programming and processing of the sequence and application
instructions that are provided by the CPUs of the MELSEC System Q and L series.
NOTE You can download all manuals as PDF from the MITSUBISHI ELECTRIC homepage (www.mit-
subishi-automation.com).
If, e.g. in tables, QCPU or LCPU is mentioned, all CPU types of the MELSEC System Q and L
series are included. Exceptions are marked separately.
1.3 Software
All the described instructions can be applied with the available software packages:
– GX Developer
– GX IEC Developer
– GX Works2
The program examples contained in this manual were created with the GX Works2.
Corresponding to the selected CPU only those instructions are available within the GX Works2
dialog box that can actually be processed by the CPU.
NOTE The programming tool GX IEC Developer does not support the CPU modules of the L series.
1–2
Introduction Finding an instruction
Beginners
If you are not really familiar with the handling of the instructions, proceed as follows:
● Read through chapter 3 regarding the differing representation of instructions within the
MELSEC and the IEC editor.
● Read through chapter 4 regarding the consistent layout and structure of each description
of instruction.
● Use
–- the tabular overview of instruction categories with brief descriptions in chapter 2
–- the index containing the entire instructions
NOTE All the instructions contained in this manual are also included within the online help of the
GX Works2 as detailed as here.
1–4
Introduction PLC parameters
Example: L series
1–6
Instruction Tables Subdivision of instructions
2 Instruction Tables
2.1 Subdivision of instructions
The instructions are subdivided into the following categories:
● Sequence instructions
● Application instructions (Part 1 and Part 2)
● Data link instructions
● Multiple CPU dedicated instruction
● Multiple CPU high-speed transmission dedicated instructions
● Redundant system instruction
● Instructions for special function modules
Reference
Category of Instruction Description
Section
Input instructions Operation start, 5.1
series and parallel connection of contacts
Refresh instructions Refreshes bit devices, links, and I/O interfaces 6.7
Reference
Category of Instruction Description Section
Logical operation Logical AND / OR, logical exclusive OR / exclusive NOR 7.1
instructions
Rotation instructions 16-bit and 32-bit data right / left rotation 7.2
Data processing Search, encode, and decode data at specified devices 7.5
instructions Disunite and unite data
Structured program Repeated operation, subroutine program calls,
instructions subroutine calls between program files, switching
between main and subprogram parts, micro computer 7.6
program calls, index qualification of entire ladders, store
index qualification values in data tables
Data table operation Write to and read data from a data table, delete and 7.7
instructions insert data blocks in a data table
Buffer memory access Buffer memory access of special function modules or 7.8
instructions remote modules
Display instructions Output ASCII characters to the outputs of a module or to 7.9
an LED display
Debugging and failure Failure checks, setting and resetting status latch, 7.10
diagnosis instructions sampling trace, program trace
Application Character string Character string (ASCII code) processing
instructions 7.11
Part 2 processing instructions
File register switching Switching between file register blocks and files 7.14
instructions
Clock instructions Reading/writing of the values of year, month, day, hour,
minute, second, and day of the week; addition/
subtraction of the values of hour, minute, and second;
conversion of the values of hour, minute, and second 7.15
into second; comparison between the values of year,
month, and day; and comparison between the values of
hour, minute, and second.
Expansion clock Reading of the values of year, month, day, hour, minute,
instructions second, millisecond, and day of the week; addition/ 7.16
subtraction of the values of hour, minute, second, and
millisecond
2–2
Instruction Tables Subdivision of instructions
Reference
Category of Instruction Description Section
Multiple CPU high-speed transmission Writes/reads devices to/from another CPU. chapter 10
dedicated instructions
Instruction for a redundant system System switching (Active system/standby system) chapter 11
Instructions for special function modules Instructions for serial communication modules,
PROFIBUS/DP interface modules, ETHERNET interface chapter 12
modules, MELSECNET/H and CC-Link
The following sections 2.3 through 2.6 include an overview of all instructions described in this
manual.
In the following the layout of the overview table is described in detail:
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning
Condition Section
+
s, d (d)+(s) → (d) 3 6.2.1
Addition and +P
subtraction
of 16-bit
binary data +
s1, s2, d1 (s1)+(s2) → (d1) 4 6.2.1
+P
Pulse instructions, i.e. instructions that are only executed at leading edge of a signal are
indicated by an appended "P".
Example: Execution when ON: +
Execution at leading edge: +P
1)
2) 2)
1
Execution condition of instruction
P 2 One program scan
3 One execution
3) 3)
2–4
Instruction Tables Overview of instructions
1)
(d)
d+1
{ 4)
3)
d
5)
1 Indicates
2
16 bits
16 bits
3 Indicates 32 bits
4 upper 16 bits
5
lower 16 bits
The instruction is executed as long as the precondition is ON. If the precondition is OFF,
the instruction is not executed and no processing is conducted.
This instruction is a pulsed instruction. It is only executed once and at leading edge of
the input signal (when the precondition alters from OFF to ON). Afterwards, the
instruction will not be executed any longer even if the input signal is still ON.
Executed during OFF; instruction is executed only while the precondition is OFF. If the
precondition is ON, the instruction is not executed, and no processing is conducted.
This instruction is a pulsed instruction as well. It is only executed once and at trailing
edge of the input signal (when the precondition alters from ON to OFF). Afterwards, the
instruction will not be executed any longer even if the input signal is still OFF.
(7) The mark indicates instructions for which subset processing is possible.
Refer to section 3.8.1 for details on subset processing.
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
Operation start
LD (Load (normally open
contact))
s
Operation start
LDI (Load (normally closed
contact))
Series connection
AND (of NO contacts) 5.1.1
s
ANI Series connection
(of NC contacts)
Parallel connection
OR
(of NO contacts)
s
Input Parallel connection
ORI (of NC contacts)
instruction
LDP Pulse operation start
(leading edge)
s
LDF Pulse operation start
(trailing edge)
Pulse series connection
ANDP s
(leading edge)
5.1.2
Pulse series connection
ANDF s (trailing edge)
ANDPI s
Leading edge pulse NOT 4
Input series connection
5.1.3
instruction
ANDFI s
Trailing edge pulse NOT 4
series connection
ORFI s
Trailing edge pulse NOT 4
parallel connection
The number of program steps depends on the devices used.
For the use of internal devices or file registers (R0 through R32767) :1
For the use of a direct access input (DX) :2
For the use of other devices :3
The number of program steps depends on the devices and types of CPU modules used.
For the use of internal devices or file registers (R0 through R32767) :1
For the use of a direct access input (DX) :1
For the use of other devices :3
The number of program steps depends on the devices used.
For the use of internal devices or file registers (R0 through R32767) : Number of basic steps
Serial number access format file register (ZR), Extended data register (D),
Extended link register (W), Multiple CPU shared device (U3En\G10000) : Number of basic steps + 1
For the use of a direct access input (DX) : Number of basic steps + 1
For the use of other devices : Number of basic steps + 2
2–6
Instruction Tables Sequence instructions
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
DELTA
Generating pulses at 2 5.3.10
d direct access outputs
DELTAP
The number of program steps depends on the devices and types of CPU modules used.
When using internal device or file register (R): 1
When using direct access outputs DY: 2
When using serial number access format file register:
(Universal model QCPU and LCPU): 2
(Basic Model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU): 3
Devices other than above: 3
This execution condition is only applied, if the annunciator (F) is used.
The number of program steps depends on the devices and types of CPU modules used.
When using internal device or file register (R0 to R32767): 1
When using direct access outputs DY or SFC program device (BL): 2
When using serial number access format file register:
(Universal model QCPU and LCPU): 2
(Basic Model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU): 3
Devices other than above: 3
The number of program steps depends on the devices and types of CPU modules used.
- For bit processing
internal device (bit to be specified by bit device or word device): 1
Direct access output: 2
Timer, counter: 4
- For word processing
internal device: 2
Index register: 2
- For bit/word processing
When using serial number access format file register:
(Universal model QCPU and LCPU): 2
(Basic Model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU): 3
Devices other than above: 3
2–8
Instruction Tables Sequence instructions
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
SFT
Shift instruction d Shifting bit devices 2 5.4.1
SFTP
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
Activating indicated 2
MC n, d
Master control program parts
5.5.1
instruction Deactivating indicated
MCR n 1
program parts
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
Ignored
NOPLF — (To change pages during
Other printouts) 1 5.7.2
instructions
Ignored
(Subsequent programs
PAGE n
will be controlled from
step 0 of page n)
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
LD=
LD<>
AND<> s1, s2 Sets the output, if 3
s1 ≠ s2
OR<>
LD>
LD<
Sets the output, if 3
AND< s1, s2 s1 < s2
OR<
LD>=
Sets the output, if 3
AND>= s1, s2 s1 >= s2
OR>=
LDD=
Sets the output, if
ANDD= s1, s2
s1 = s2
ORD=
LDD<>
Sets the output, if
ANDD<> s1, s2
s1 ≠ s2
ORD<>
LDD>
Sets the output, if
ANDD> s1, s2
s1 > s2
ORD>
BIN 32-bit data 6.1.2
comparison
LDD<=
Sets the output, if
ANDD<= s1, s2
s1 <= s2
ORD<=
LDD<
Sets the output, if
ANDD< s1, s2
s1 < s2
ORD<
LDD>=
Sets the output, if
ANDD>= s1, s2
s1 >= s2
ORD>=
2 – 10
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
LDE=
Sets the output, if 3
ANDE= s1, s2 s1 = s2
ORE=
LDE<>
Sets the output, if 3
ANDE<> s1, s2 s1 ≠ s2
ORE<>
LDE>
Sets the output, if 3
ANDE> s1, s2 s1 > s2
Floating point
data ORE>
comparison 6.1.3
(Single LDE<=
precision)
Sets the output, if 3
ANDE<= s1, s2 s1 <= s2
ORE<=
LDE<
Sets the output, if 3
ANDE< s1, s2 s1 < s2
ORE<
LDE>=
Sets the output, if 3
ANDE>= s1, s2
s1 >= s2
ORE>=
LDED=
Sets the output, if
(s1 + 3, s1 + 2, s1 + 1, s1) 3
ANDED= s1, s2
=
(s2 + 3, s2 + 2, s2 + 1, s2)
ORED=
LDED<>
Sets the output, if
(s1 + 3, s1 + 2, s1 + 1, s1) 3
ANDED<> s1, s2
≠
(s2 + 3, s2 + 2, s2 + 1, s2)
ORED<>
LDED>
Sets the output, if
(s1 + 3, s1 + 2, s1 + 1, s1) 3
ANDED> s1, s2
Floating point >
(s2 + 3, s2 + 2, s2 + 1, s2)
data ORED>
comparison 6.1.4
(Double LDED<=
Sets the output, if
precision) (s1 + 3, s1 + 2, s1 + 1, s1)
ANDED<= s1, s2 3
<=
(s2 + 3, s2 + 2, s2 + 1, s2)
ORED<=
LDED<
Sets the output, if
(s1 + 3, s1 + 2, s1 + 1, s1) 3
ANDED< s1, s2
<
(s2 + 3, s2 + 2, s2 + 1, s2)
ORED<
LDED>=
Sets the output, if
(s1 + 3, s1 + 2, s1 + 1, s1) 3
ANDED>= s1, s2
>=
(s2 + 3, s2 + 2, s2 + 1, s2)
ORED>=
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
2 – 12
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
+
s, d (d)+(s) → (d) 3
+P
+
s1, s2, d1 (s1)+(s2) → (d1) 4
BIN 16-bit +P
addition and 6.2.1
subtraction
operations -
s, d (d)-(s) → (d) 3
-P
-
s1, s2, d1 (s1)-(s2) → (d1) 4
-P
D+
(d+1, d)+(s+1, s)
s, d
→ (d+1, d)
D+P
D+
((s1)+1, s1)+((s2) +1, s2)
s1, s2, d1
→ ((d1)+1, d1)
BIN 32-bit D+P
addition and 6.2.2
subtraction
operations D-
(d+1, d)-(s+1, s)
s, d → (d+1, d)
D-P
D-
((s1)+1, s1)-((s2)+1, s2)
s1, s2, d1
→ ((d1)+1, d1)
D-P
x
s1, s2, d1 (s1)x(s2) → ((d1)+1, d1)
xP
BIN 16-bit
multiplication 6.2.3
and division
/
(s1)/(s2) →
s1, s2, d1 Quotient (d1), 4
remainder ((d1)+1)
/P
2 – 14
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
B+
s, d (d)+(s) → (d) 3
B+P
B+
s1, s2, d1 (s1)+(s2) → (d1) 4
B-P
B-
s1, s2, d1 (s1)-(s2) → (d1) 4
B-P
DB+
(d+1, d)+(s+1, s)
s, d → 3
(d+1, d)
DB+P
DB+
((s1)+1, s1)+((s2)+1, s2)
s1, s2, d1 → 4
((d1)+1, d1)
BCD 8-digit DB+P
addition and 6.2.6
subtraction
operations DB-
(d+1, d)+(s+1, s)
s, d → 3
(d+1, d)
DB-P
DB-
((s1)+1, s1)+((s2)+1, s2)
s1, s2, d1 → 4
((d1)+1, d1)
DB-P
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
B×
s1, s2, d1 (s1)x(s2) → ((d1)+1, d1) 4
E+
(d+1, d)+(s+1, s)
s, d → 3
(d+1, d)
E+P
E+
((s1)+1, s1)+((s2)+1, s2)
s1, s2, d1 → 4
Floating point
data addition ((d1)+1, d1)
E+P
and
subtraction 6.2.9
operations
(Single E-
(d+1, d)-(s+1, s)
precision) s, d → 3
(d+1, d)
E-P
E-
((s1)+1, s1)-((s2)+1, s2)
s1, s2, d1 → 4
((d1)+1, d1)
E-P
2 – 16
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
ED+
(d+3, d+2, d+1, d)
s, d +(s+3, s+2, s+1, s) → 3
(d+3, d+2, d+1, d)
ED+P
Ex
((s1)+1, s1)x((s2)+1, s2)
s1, s2, d1 → 3
Floating point ((d1)+1, d1)
data ExP
multiplication
and division 6.2.11
operations
(Single E/
((s1)+1, s1)/((s2)+1, s2)
precision) s1, s2, d1 → 4
Quotient ((d1)+1, d1)
E/P
BK+
Adds the nth 16-bit block
s1, s2, d, n in s1 to the nth 16-bit 5
block in s2.
BIN block BK+P
addition and 6.2.13
subtraction
operations BK-
Subtracts the nth 16-bit
s1, s2, d, n block in s2 from the nth 5
16-bit block in s1.
BK-P
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
DBK+
Adds the nth 32-bit block
s1, s2, d, n in s1 to the nth 32-bit 5
BIN 32-bit block in s2.
DBK+P
block addition
and 6.2.14
subtraction
operations DBK-
Subtracts the nth 32-bit
s1, s2, d, n block in s2 from the nth 5
32-bit block in s1.
DBK-P
INC
d (d)+1→ (d) 2 6.2.16
INCP
BIN increment
operations
DINC
d (d+1, d)+1 → (d+1, d) 6.2.17
DINCP
DEC
d (d)-1→ (d) 2 6.2.16
DECP
BIN
decrement
operations
DDEC
d (d+1, d)-1 → (d+1, d) 6.2.17
DDECP
2 – 18
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) : 5 (NOTE 1)
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification : 5 (NOTE 1)
– Constant; No limitations : 5 (NOTE 1)
Devices other than the above : 3 (NOTE 2)
Basic model QCPU, Universal model QCPU, LCPU
– All devices that can be used : 3 (NOTE 2)
NOTE 1: For these models the number of steps increases but processing speed becomes faster.
NOTE 2: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) : 6 (NOTE 1)
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification : 6 (NOTE 1)
– Constant; No limitations : 6 (NOTE 1)
Devices other than the above : 4 (NOTE 2)
Basic model QCPU
– All devices that can be used : 4 (NOTE 2)
Universal model QCPU, LCPU
– All devices that can be used : 3 (NOTE 2)
NOTE 1: For these models the number of steps increases but processing speed becomes faster.
NOTE 2: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
The number of program steps depends on the devices used and the type of CPU.
QCPU, LCPU
– Word device: internal word devices (except for file register ZR) :3
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification :3
– Constant; No limitations :3
Devices other than the above : 4 (NOTE 1)
NOTE 1: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
The number of steps is three for the Universal model QCPU and LCPU only.
The subset is effective only with Universal model QCPU and LCPU.
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) : 3 (NOTE 1)
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification : 3 (NOTE 1)
– Constant; No limitations : 3 (NOTE 1)
Devices other than the above : 2 (NOTE 2)
Basic model QCPU, Universal model QCPU, LCPU
– All devices that can be used : 2 (NOTE 2)
NOTE 1: For these models the number of steps increases but processing speed becomes faster.
NOTE 2: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
BCD
BCD conversion
s, d (s) (d) 3
BIN
BIN conversion
s, d (s) (d) 3
DINTP
2 – 20
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
INTD
Conversion to BIN
s, d (s+3, s+2, s+1, s) (d ) 3
Conversion Real number ( 32768 to
from floating INTPD 32767)
point data into 6.3.6
BIN data
(Double DINTD Conversion
precision) to BIN
s, d (s+3, s+2, s+1, s) (d+1,d) 3
Real number
DINTPD (–2147483648 to 2147483647)
Conversion DBL
from BIN 16- Conversion
bit data into s, d (s) (d+1, d) 3 6.3.7
BIN 32-bit
data DBLP BIN (-32768 to 32767)
Conversion WORD
from BIN 32- Conversion
bit data into s, d (s+1, s) (d) 3 6.3.8
BIN 16-bit
WORDP BIN (-32768 to 32767)
data
GRY Conversion
into Gray code
s, d (s) (d) 3
Binary value
Conversion GRYP (-32768 to 32767)
from BIN 16-/
32-bit data into 6.3.9
Gray code
data DGRY Conversion
into Gray code
s, d (s+1, s) (d+1, d) 3
Binary value
DGRYP (-2147483648 to 214748364 7)
NEG
(d) (d)
d 2
Sign reversal BIN data
NEGP
for BIN
16-/32-bit data 6.3.11
(complement
of 2) DNEG
(d+1, d) (d+1, d)
d 2
BIN data
DNEGP
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
ENEG
(d+1, d) (d+1, d)
d 2 6.3.12
Floating point value
ENEGP
Sign reversal
for floating
point data
EDNEG Floating point number
2 – 22
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
MOV s, d
BIN 16-bit data
transfer (s) (d)
MOVP s, d
6.4.1
DMOV s, d
BIN 32-bit data
transfer (s+1, s) (d+1, d)
DMOVP s, d
$MOV s, d
Character
Transfers character string 3 6.4.4
string data data in s to d.
transfer
$MOVP s, d
CML s, d
BIN 16-bit data
inversion (s) (d)
CMLP s, d
6.4.5
DCML s, d
BIN 32-bit data
inversion (s+1, s) (d1+1, d1)
DCMLP s, d
FMOV s, n, d
Identical BIN (d)
block data (s) 4 6.4.7
transfer n
FMOVP s, n, d
DFMOV s, n, d
Identical 32-bit (d+1, d)
block data (s+1, s) 4 6.4.8
transfer n
DFMOVP s, n, d
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
XCH d1, d2
BIN 16-bit data 3
exchange (d1) (d2)
XCHP d1, d2
6.4.9
DXCH d1, d2
BIN 32-bit data 3
((d1)+1, d1) ((d2)+1, d2)
exchange
DXCHP d1, d2
BXCH n, d1, d2
(d1) (d2)
BIN block data 4 6.4.10
exchange n
BXCHP n, d1, d2
SWAP s
Upper and
lower byte 3 6.4.11
exchanges
SWAPP s
The number of program steps depends on the devices used and the type of CPU.
QCPU, LCPU
– Word device: internal word devices (except for file register ZR) :2
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification :2
– Constant; No limitations :2
Devices other than the above : 3 (NOTE 1)
NOTE 1: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) :3
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification :3
– Constant; No limitations :3
Devices other than the above : 3 (NOTE 1)
Basic model QCPU
– Word device: internal word devices (except for file register ZR) :2
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification :2
– Constant; No limitations :2
Devices other than the above : 3 (NOTE 1)
Universal model QCPU, LCPU
– All devices that can be used : 2 (NOTE 1)
NOTE 1: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
2 – 24
Instruction Tables Application instructions, Part 1
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
Conditional jump
CJ p
(p = jump destination)
2 6.5.1
Conditional jump from
SCJ p next program scan
Jump (p = jump destination)
instructions
Jump instruction 2 6.5.1
JMP p (p = jump destination)
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
Return from an
interrupt End of an interrupt 1 6.6.2
program to the IRET — program
main program
Subset
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
s+0
1-Phase Input s+1
count-up/-down UDCNT1 s, n, d Current
4 6.8.1
Counter count
0 1 2 3 4 5 6 7 6 5 4 3 2 1 0 -1 -2 -3 -2 -1 0 1 1
Switching period
of counter contact
s+0
2-Phase Input s+1
count-up/-down UDCNT2 s, n, d 4 6.8.2
Current
Counter count
0 1 2 3 4 5 4 3 2 1 0 -1 -2 -1
Switching period
of counter contact
2 – 26
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
WAND
s, d (d) ∧ (s) → (d) 3
WANDP
WAND
s1, s2, d1 (s1) ∧ (s2) → (d1) 4
WANDP
7.1.1
DAND
(d+1, d) ∧ (s+1, s)
Logical product s, d
→ (d+1, d)
DANDP
DAND
((s1)+1, s1) ∧ ((s2)+1, s2)
s1, s2, d → (d+1, d)
DANDP
WOR
s, d (d) ∨ (s) → (d) 3
WORP
WOR
s1, s2, d1 (s1) ∨ (s2) → (d1) 4
WORP
7.1.3
DOR
(d+1, d) ∨ (s+1, s)
Logical sum s, d
→ (d+1, d)
DORP
DOR
s1, s2, d ((s1)+1, s1) ∨ ((s2)+1, s2)
→(d+1, d)
DORP
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
WXOR
s, d (d) ∨ (s) → (d) 3
WXORP
WXOR
s1, s2, d1 (s1) ∨ (s2) → (d1) 4
WXORP
7.1.5
DXOR
Logical (d+1, d) ∨ (s+1, s)
s, d
exclusive OR → (d+1, d)
DXORP
DXOR
s1, s2, d ((s1)+1, s1) ∨ ((s2)+1, s2)
→ (d+1, d)
DXORP
WXNR
s, d (d) ∨ (s)→ (d) 3
WXNRP
WXNRP
7.1.7
DXNR (d+1, d) ∨ (s+1, s)
Logical s, d 5 (d+1, d)
exclusive NOR
DXNRP
DXNR
((s1)+1, s1) ∨ ((s2)+1, s2)
s1, s2, d
5 (d+1, d)
DXNRP
BKXNR
(s1) (s2) (d)
s1, s2, n, d 5 7.1.8
∨ n
BKXNRP
2 – 28
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
The number of steps is three for the Universal model QCPU and LCPU only.
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) : 5 (NOTE 1)
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification : 5 (NOTE 1)
– Constant; No limitations : 5 (NOTE 1)
Devices other than the above : 3 (NOTE 2)
Basic model QCPU, Universal model QCPU, LCPU
– All devices that can be used : 3 (NOTE 2)
NOTE 1: For these models the number of steps increases but processing speed becomes faster.
NOTE 2: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
The number of program steps depends on the devices used and the type of CPU.
High Performance model QCPU, Process CPU, Redundant CPU
– Word device: internal word devices (except for file register ZR) : 6 (NOTE 1)
– Bit device: whose device numbers are multiplies of 16, whose digit designation is K8,
and which use no index qualification : 6 (NOTE 1)
– Constant; No limitations : 6 (NOTE 1)
Devices other than the above : 4 (NOTE 2)
Basic model QCPU
– All devices that can be used : 4 (NOTE 2)
Universal model QCPU, LCPU
– All devices that can be used : 3 (NOTE 2)
NOTE 1: For these models the number of steps increases but processing speed becomes faster.
NOTE 2: The number of steps may increase due to the conditions described in section 3.11 "Number of program steps".
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
n, d 3
n, d 3
ROL
SM700 b15 (d) b0
n, d 3
DRCLP
rotates by n bits to the left
2 – 30
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
SFR b15 bn b0
n, d 3
n
BSFR
(d)
n, d 3
BSFRP SM700
0
Shift n bit 7.3.2
devices by 1 bit
n
BSFL
(d)
n, d 3
BSFLP SM700
0
SFTBR n1
n2
n
DSFR
(d)
n, d 3
DSFRP
Shift n word 0
devices by 7.3.4
one digit n
DSFL
(d)
n, d 3
DSFLP
0
n1
SFTWR n2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
BSET (d)
b15 bn b0 3
n, d
BSETP 1
Set / reset 7.4.1
single bits
BRST (d)
b15 bn b0 3
n, d
BRSTP 0
TEST (s1)
b15 to b0 (d)
s1, s2, d 4
2 – 32
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
SER (s2)
(s1)
n
s1, s2, d, n 5
SERP (d) : identical No.
(d+1) : Number of
matches
Search 16-bit 7.5.1
data
DSER 32 bits (s2)
(s1)
n
s1, s2, d, n 5
DSERP (d) : identical No.
(d+1) : Number of
matches
SUM (s)
b15 b0
s, d 3
(d): Binary coded
SUMP number of
Check data set bits
bits 7.5.2
(16-/32-bit)
DSUM (s+1) (s)
s, d 3
(d): Binary coded
DSUMP number of
set bits
DECO
(d)
Decoding data s, d, n (s) decode 4 7.5.3
n
2 Bit
n
DECOP
SEG
b3 to b0
7-segment (s) (d) 3 7.5.5
s, d
decoding
7SEG
SEGP
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
2 – 34
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
2 – 36
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
FDEL
Delete
specified data
blocks from
data table FDELP
s, n, d 4 7.7.4
2 – 38
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
2 – 40
Instruction Tables Application instructions, Part 2
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning Condition Section
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning Condition Section
2 – 42
Instruction Tables Application instructions, Part 2
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
Sine SIN
calculation SIN(s+1, s)
(Floating point s, d → 3 7.12.1
single (d+1, d)
precision) SINP
Cosine COS
calculation COS(s+1, s)
(Floating point s, d → 3 7.12.3
single (d+1, d)
precision) COSP
Tangent TAN
calculation TAN(s+1, s)
(Floating point s, d → 3 7.12.5
single (d+1, d)
precision) TANP
Sine SIND
calculation SIN(s+3, s+2, s+1, s)
(Floating point s, d → 3 7.12.2
double (d+3, d+2, d+1, d)
precision) SINDP
Cosine COSD
calculation COS(s+3, s+2, s+1, s)
(Floating point s, d → 3 7.12.4
double (d+3, d+2, d+1, d)
precision) COSDP
Tangent TAND
calculation TAN(s+3, s+2, s+1, s)
(Floating point s, d → 3 7.12.6
double (d+3, d+2, d+1, d)
precision) TANDP
2 – 44
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
RAD (s+1, s)
→
s, d (d+1, d) 3 7.12.13
Conversion from degrees
RADP into radian
Conversion
from degrees
into radian (s+3, s+2, s+1, s)
RADD
→
s, d (d+3, d+2, d+1, d) 3 7.12.14
Conversion from degrees
RADDP into radian
DEG
(s+1, s) → (d+1, d)
s, d Conversion from radian 3 7.12.15
into degree
DEGP
Conversion
from radian
into degree (s+3, s+2, s+1, s)
DEGD
→
s, d (d+3, d+2, d+1, d) 3 7.12.16
Conversion from radian
DEGDP into degree
POW
(s1+1, s1)(s2+1, s2)
s1, s2, d → 4 7.12.17
(d+1, d)
POWP
Exponentiation
POWD (s1+3, s1+2, s1+1,
s1, s2, d s1)(s2+3, s2+2, s2+1, s2) 4 7.12.18
→
POWDP (d+3, d+2, d+1, d)
SQR
√(s+1, s)
s, d → 3 7.12.19
(d+1, d)
SQRP
Square root
calculation
SQRD
√(s+3, s+2, s+1, s)
s, d → 3 7.12.20
(d+3, d+2, d+1, d)
SQRDP
EXP
s, d e(s+1, s) → (d+1, d) 3 7.12.21
EXPP
Floating point
value as
exponent of e
EXPD
e(s+3, s+2, s+1, s)
s, d → 3 7.12.22
(d+3, d+2, d+1, d)
EXPDP
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
LOG
LOG e(s+1, s)
s, d → 3 7.12.23
(d+1, d)
LOGP
Logarithm
(natural)
calculation
LOGD
LOG e(s+3, s+2, s+1, s)
s, d → 3 7.12.24
(d+3, d+2, d+1, d)
LOGDP
LOG10
log10 (s+1, s)
s, d → 3 7.12.25
(d+1, d)
LOG10P
Common
logarithm
LOG10D
log10 (s+3, s+2, s+1, s)
s, d → 3 7.12.26
(d+3, d+2, d+1, d)
LOG10DP
RND
Randomize Stores the generated 2
d
value random value in d.
RNDP
7.12.27
SRND
Updates the series of
Update s random values stored 2
random values
in s.
SRNDP
BSIN
Sine
calculation s, d 3 7.12.29
from BCD data
BSINP
BCOS
Cosine
calculation s, d 3 7.12.30
from BCD data
BCOSP
BTAN
Tangent
calculation s, d 3 7.12.31
from BCD data
BTANP
2 – 46
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
BASIN
Arcus sine
calculation s, d 3 7.12.32
from BCD data
BASINP
BACOS
Arcus cosine
calculation s, d 3 7.12.33
from BCD data
BACOSP
BATAN
Arcus tangent
calculation s, d 3 7.12.34
from BCD data
BATANP
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning Condition Section
If (s3)<(s1)
the data value
LIMIT in s1 is stored in d.
If (s1)≤(s3)≤(s2)
s1, s2, s3, d the data value in
s3 is stored in d.
LIMITP If (s2)<(s3)
the data value in
s2 is stored in d.
2 – 48
Instruction Tables Application instructions, Part 2
of steps
Number
Execution Reference
Subset
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
n = (number of program name characters)/2 = Number of additional steps (Decimal fractions are rounded up)
2 – 50
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
DATE+ s1 s2 d
Adding Hour Hour Hour
4 7.15.3
s1, s2, d +
clock data Minute Minute Minute
Second Second Second
DATE+P
DATE-
s1 s2 d
Subtracting 4 7.15.4
s1, s2, d Hour Hour Hour
clock data Minute - Minute Minute
Second Second Second
DATE-P
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
LDDT=
s1 Year s2 Year
→
ANDDT= s1, s2, n s1+1 Month = s2+1 Month Comparison 4
operation
ORDT= s1+2 Day s2+2 Day result
LDDT<>
s1 Year s2 Year
→
ANDDT<> s1, s2, n s1+1 Month <> s2+1 Month Comparison 4
operation
ORDT<> s1+2 Day s2+2 Day result
LDDT>
s1 Year s2 Year
→
ANDDT> s1, s2, n s1+1 Month < s2+1 Month Comparison 4
operation
ORDT> s1+2 Day s2+2 Day result
Date 7.15.6
comparison LDDT<=
s1 Year s2 Year
→
ANDDT<= s1, s2, n s1+1 Month <= s2+1 Month Comparison 4
operation
ORDT<= s1+2 Day s2+2 Day result
LDDT<
s1 Year s2 Year
→
ANDDT< s1, s2, n s1+1 Month > s2+1 Month Comparison 4
operation
ORDT< s1+2 Day s2+2 Day result
LDDT>=
s1 Year s2 Year
→
ANDDT>= s1, s2, n s1+1 Month >= s2+1 Month Comparison 4
operation
ORDT>= s1+2 Day s2+2 Day result
LDTM=
s1 Hour s2 Hour
→
ANDTM= s1, s2, n s1+1 Minute = s2+1 Minute Comparison 4
operation
ORTM= s1+2 Second s2+2 Second result
LDTM<>
s1 Hour s2 Hour
→
ANDTM<> s1, s2, n s1+1 Minute <> s2+1 Minute Comparison 4
operation
ORTM<> s1+2 Second s2+2 Second result
LDTM>
s1 Hour s2 Hour
→
ANDTM> s1, s2, n s1+1 Minute < s2+1 Minute Comparison 4
operation
ORTM> s1+2 Second s2+2 Second result
Clock 7.15.7
comparison LDTM<=
s1 Hour s2 Hour
→
ANDTM<= s1, s2, n s1+1 Minute <= s2+1 Minute Comparison 4
operation
ORTM<= s1+2 Second s2+2 Second result
LDTM<
s1 Hour s2 Hour
→
ANDTM< s1, s2, n s1+1 Minute > s2+1 Minute Comparison 4
operation
ORTM< s1+2 Second s2+2 Second result
2 – 52
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
2 – 54
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
Turns ON device
specified by (d) if
measured ON time of 4 7.18.3
Time check TIMCHK s1, s2, d
input condition is longer
than preset time
continuously.
ZRRDB 0 ZR0
1 Higher 8 bits
Direct read of n, d 2 ZR1 3 7.18.4
one byte 3 Higher 8 bits
ZRRDBP
n 8 bits (d)
ZRWRB 0 ZR0
1 Higher 8 bits
ZRWRBP n 8 bits
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
Writing data to
a designated SP.FWRITE u0, s0, d0, s1, s2, d1 Writes data to a 11 7.18.12
designated file
file
Reading data
from a SP.FREAD u0, s0, d0, s1, d1, d2 Reads data from a 11 7.18.13
designated file
designated file
S.DEVLD
Reading data Reads data from the
from standard n1, d, n2 device data storage file 8 7.18.15
ROM in the standard ROM.
SP.DEVLD
2 – 56
Instruction Tables Application instructions, Part 2
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
RBMOV s, d, n
Highspeed (s) (d)
block transfer 4 7.18.19
of file register n
RBMOVP s, d, n
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
S.ZCOM
Jn
Link SP.ZCOM
instruction: Refreshes the 5 8.2.1
Network designated network.
refresh S.ZCOM
Un
SP.ZCOM
of steps
Number
Subset
Category Instruction Variables Meaning Execution Reference
Condition Section
S.RTREAD
Reads data set at routing 7 8.3.1
n, d parameters.
SP.RTREAD
Read/Write
routing
information
S.RTWRITE
Writes routing data to the
n, s area designated by 8 8.3.2
routing parameters.
SP.RTWRITE
2 – 58
Instruction Tables Multiple CPU dedicated instruction
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
S.TO
Writes device data of the
n1, n2, n3, n4, d host station to the host 5 9.1.1
CPU shared memory.
SP.TO
TO
Write to CPU Writes device data of the
shared host station to the host 5
memory CPU shared memory.
TOP
n1, n2, s, n3 9.1.2
DTO Writes device data of the
host station to the host 5
CPU shared memory in
DTOP 32-bit units
2.7.2 Instructions for reading from the CPU shared memory of another CPU
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
2 – 60
Instruction Tables System switching instruction for a redundant system
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
GETE
Reading of User registered frames
user regis- Un, s1, s2, d are read from a serial 12.1.2
tered frames communication module
GETEP
Subset
2 – 62
Instruction Tables Instructions for special function modules
of steps
Number
Subset
Execution Reference
Category Instruction Variables Meaning
Condition Section
Re-initial processing of
Re-initializa-
UINI Un, s1, d1 an ETHERNET interface 12.3.8
tion
module
Subset
Execution Reference
Category Instruction Variables Meaning Condition Section
of steps
Number
Execution Reference
Category Instruction Variables Meaning
Condition Section
RLPASET
Transfer of the parameter
Parameter Un, s1 to s5, d1 settings to the master sta- 12.5.1
setting
tion of CC-Link
RLPASET_P
2 – 64
Configuration of Instructions The structure of an instruction
3 Configuration of Instructions
3.1 The structure of an instruction
Most of the instructions consist of an instruction part and a device part. Other instructions do
not require a device part and thus only consist of the instruction part.
PLUS sd
{
{
Instruction Device
part part
Instruction part
The instruction part describes the functions of the instruction.
^ Addition
PLUS =
Device part
The device part describes the constants or variables to be specified. The device part can com-
prise three items: the source of data (s), the destination of data (d), and the number (n).
Constants
Constants specify a constant numerical value to be processed by the instruction. This value is
constantly set by the user written program and cannot be altered during program execution. It
is recommended to index qualify each variable to be used as constant.
Variables
Variables specify a device storing data to be processed by the instruction (also refer to section
3.4 "Programming of variables").
Before an instruction is executed, the data must be stored in the device. The data stored in vari-
ables can be altered during program execution.
● The data destination designates the devices to store the data after being processed by the
instruction.
For 16-bit instructions the notation of the data destination is d.
For 32-bit instructions its notation is d+1 and d. However, some instructions with 2 devices
require a value to be processed stored in the data destination d before the instruction is
executed. In this case, the result of the operation will be stored in the same device as well.
Example: The addition instruction for BIN 16-bit data.
Here, d first stores data for the operation and then the operation result:
s+d=d
s1 + s2 = d1
● A device for the storage of data has always to be set as data destination.
● The number n specifies how many devices are to be used or how often an instruction is to
be executed.
Example: The BMOV instruction for block data transfer:
● The value n may range from 0 to 32767. If n is specified 0, the instruction will not be executed.
3–2
Configuration of Instructions Notation of instructions
The functions of the "pure" and "adapted" instructions are identical. Only their notation differs.
_M MELSEC instruction
3–4
Configuration of Instructions Notation of instructions
The table below contains the symbols that represent several functions within the MELSEC
editor. The column on the right shows the according instruction names within the IEC editor.
The chapters 5 through 12 that give a detailed description of the instructions contain illustra-
tions of both editors, i.e. both notations. The header line contains the "pure" MELSEC instruc-
tion as it occurs in the MELSEC instruction list.
NOTE The tabular overview at the beginning of each instruction category always represents both
notations.
Refer to the following manuals for further information on the programming of dedicated instruc-
tions:
GX IEC Developer Reference Manual
Programming Manual (Dedicated Instructions)
3–6
Configuration of Instructions Programming of variables
The majority of instructions besides the instruction part also require a device part with specified
variables. These variables contain the values for the execution of the instruction.
According to the selected editor in the GX IEC Developer a different method of programming
of the variables is required.
var_D100 and var_D10 are entered here as identifiers. The PLC actually does not assign the devices D100 and D10 but inernally allocates free register areas for the variables.
Example: DWSUMP
The variable var_D100 is of type DINT (32-bit). The variable var_D10 is of type ARRAY. The
array contains four 16-bit registers of type INT (also refer to section 3.5.2 "Addressing of arrays
and registers in the GX IEC Developer").
NOTE As identifier any name can be entered (e.g. Motor1, Indicator). The names var_D100 or var_D10
were selected here for a clear comparison to the programming in the MELSEC editor.
The table of variables at the beginning of any instruction gives an overview of the data types
of the devices for each instruction (the example shows the DWSUM instruction in section
7.5.14).
Variables Data Type
Set Data Meaning
MELSEC IEC
s First number of device storing data to be added. BIN 32-bit ANY32
Array [1..4] of
d First number of device storing result. BIN 64-bit
ANY16
n Number of data blocks to be added. BIN 16-bit ANY16
In GX Works2
The data registers D100 and D10 can be assigned directly to the variable designation D100
and D10.
The connected PLC automatically detects that the following devices are designated:
D100 = D100 and D101
D10 = D10, D11, D12, D13
3–8
Configuration of Instructions Data types
Number of
Data Type Value Range bits
Single precision:
32 bits
-2128 < Value ≤ -2-126, 0, 2-126 ≤ Value < 2128
REAL Floating point number
Double precision:
64 bits
-21024 < Value ≤ -2-1022, 0, 2-1022 ≤ Value < 21024
T#-24d-0h31m23s648.00ms
TIME Time value through 32 bits
T#24d20h31m23s647.00ms
ANY
ANY_SIMPLE ARRAY
BOOL
WORD
DWORD
ANY_REAL ANY_INT
REAL INT
DINT
ANY_16 ANY_32
TIME Time
ARRAY Array
3 – 10
Configuration of Instructions Data types
M0 is a bit device
b15 to b0
Word device 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0 1/0
The bits have to be addressed in hexadecimal format. For example, the bit 5 (b5) in D0 is
addressed D0.5. Bit 10 in D0 is addressed D0.A.
Single bits of timers, counters, and retentive timers can not be addressed.
K1
4 bits
K2
8 bits
K3
12 bits
K4
16 bits
K1 (4 digits) 0 to 15
K2 (8 digits) 0 to 255
set to 0
b15 b4 b3 b2 b1 b0
D0 0 0 0 0 0 0 0 0 0 0 0 0 X3 X2 X1 X0
→
Source data
NOTE For the block by block addressing of bit devices the number of the first bit device (initial device
number) can be designated at any random value.
Block by block addressing cannot be made for the direct access I/Os (DX, DY).
3 – 12
Configuration of Instructions Data types
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
K2M0 0 0 1 1 0 1 0 0
Data destination (d) is not changed 3 4
b15 b8 b7 b0
D0 1 1 1 0 1 0 1 0 1 0 0 1 1 1 0 1
K1
4 addresses
K2
8 addresses
K3
12 addresses
K4
16 addresses
K5
20 addresses
K6
24 addresses
K7
28 addresses
K8
32 addresses
K1 (4 digits) 0 to 15
K2 (8 digits) 0 to 255
3 – 14
Configuration of Instructions Data types
set to 0
b15 b4 b3 b2 b1 b0
D0 0 0 0 0 0 0 0 0 0 0 0 0 X3 X2 X1 X0
← Source data D1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
(s) b31 b16
set to 0
NOTE For the block by block addressing of bit devices the number of the first bit device (initial device
number) can be designated at any random value.
Block by block addressing cannot be made for the direct access I/Os (DX, DY).
0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0
3 4 5 6
0 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0
7 8 1 2
K5M0
M15 M8 M7 M0
0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0
Data destination (d) M31 M20 M19 M16
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
is not changed
b15 b8 b7 b0
D1 0 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0
3 – 16
Configuration of Instructions Data types
M0
EMOV R100 D0
Two word devices are required for storing a single precision floating-point number. Therefore,
it is divided into the following components:
[Sign] 1.[Mantissa] x 2[Exponent]
The bit configuration of the registers and their contents are shown in the figure below:
b23 to b30 FFH FEH FD H 81H 80H 7FH 7EH 02H 01H 00H
n free 127 126 2 1 0 -1 -125 -126 free
– Mantissa: The 23 bits from b0 to b22, represents the XXXXXX... at binary 1.XXXXXX....
"
! . "
NOTE Post decimal positions for binary data are represented as follows:
Example: (0.1101)2
0, 1 1 0 1
3 – 18
Configuration of Instructions Data types
M0
EDMOV R100 D0
Four word devices are required for storing a double precision floating-point number.
Therefore, it is divided into the following components:
[Sign] 1.[Mantissa] x 2[Exponent]
The bit configuration of the registers and their contents are shown in the figure below:.
b52 b62 7FFH 7FEH 7FDH 400H 3FFH 3FEH 3FDH 3FCH 02H 01H 00H
Free
n Free
1023 1022 2 1 0 1 2 1021 1022
– Mantissa: The 52 bits from b0 to b51, represents the XXXXXX... at binary 1.XXXXXX....
NOTES The CPU module floating decimal point data can be monitored using the monitoring function of
a peripheral device.
When floating-point data is used to express 0, the following bits are turned to 0:
Single precision floating-point data: bits b0 to b31
Double precision floating-point data: bits b0 to b63
The setting range of floating decimal point data is as follows:
Single precision floating-point data: -2128 < Value ≤ -2 -126, 0, 2 -126 ≤ Value < 2128
Double precision floating-point data: -21024 < Value ≤ -2 -1022, 0, 2 -1022 ≤ Value < 21024
For operations when a real number is out of range and operations when an invalid value is input,
an error occurs. For more informations refer to the QnUCPU User's Manual (Function Expla-
nation, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Expla-
nation, Program Fundamentals).
Do not specify "-0" in floating-point data. (In this case the most significant bit of the floating-point
real number is "1"). An operation error will occur with the following CPU modules, if floating-point
operation is performed with "–0".
– Basic model QCPU (CPUs with first five digits of serial No. are "04122 or higher can perform
floating-point operation)
– High Performance model QCPU where internal operation is set to single precision (setting in
PLC parameter dialog box of the PLC system)
– Process CPU of the MELSEC System Q
– Redundant CPU of the MELSEC System Q
– Universal model QCPU of the MELSEC System Q
– L-series CPUs
The High Performance model QCPU with the internal processing set to "double precision" (dou-
ble precision is set by default for the floating-point operation processing) internally convert the
value "–0" to 0 to perform a floating-point operation. Therefore an operation error does not occur.
3 – 20
Configuration of Instructions Data types
The conversion from the IEC data type REAL into the MELSEC data type is performed by
the instruction REAL_TO_M_REAL (REAL_TO_M_REAL_E).
The conversion from the MELSEC data type into the IEC data type is performed by the
instruction M_REAL_TO_REAL (M_REAL_TO_REAL_E).
Example: For the application of dedicated instructions that process the data type REAL and
for IEC instructions the REAL to REAL conversion ist required.
32-bit 32-bit
MITSUBISHI-REAL IEC-REAL
(DINT) (REAL)
MLIB SLIB
When programming in in GX IEC Developer the BMOV_E instruction can be used to switch
off the variable check. No additional code is created.
Any type of data can be specified in s, even arrays are possible. n holds the number of 16-
bit data to copy.
3 – 22
Configuration of Instructions Data types
Addressing of arrays
For the programming of instructions that use an array with array elements as input or output
devices (16-bit registers) the variables in the header of the program organisation unit have to
be defined according to the header of the instruction.
The individual array elements are addressed by specifying the array and the array element in
square parentheses (var_xx[x]).
The figures below show the addressing via arrays for the positioning instruction for rotary tables
(ROTC):
You can infer from the header of the ROTC instruction that the input device range s consists of
3 array elements of the type ANY16 and the output device range consists of 8 array elements
of the type BOOL.
In the GX Works2 and in the MELSEC editor of the GX IEC Developer for the input/output
device ranges s and d only each of the initial devices D200 and M0 is specified. The compiler
addresses the registers D200 through D202 for s and M0 through M7 for d.
In the IEC editors arrays must be defined for s and d. The input array s is defined as var_D200.
It consists of 3 array elements (var_D200[0] – var_D200[2]) of the type INT (16-bit integer). The
output array d is defined as var_M0. It consists of 8 array elements (var_M0[0] – var_M0[7]) of
the type BOOL (bit). For these variables the compiler assigns corresponding addresses inter-
nally.
NOTE Arrays can also be addressed variably. In this case instead of the array element number in
square brackets any identifier for example [Number] is entered. "Number" must be declared in
the header of the program organisation unit. Then a value corresponding to the according array
element can be moved to the register "Number".
After the conversion the array elements can be processed as individual devices. Therefore, the
variable definition in the header of the program organisation unit is not required.
In the program with the ROTC instruction shown above instead of the array elements
var_M0[0] – var_M0[7] the relays M0 through M7 can be used.
The methods of addressing devices in GX Works2 and the GX IEC Developer are identical.
These instructions only convert output arrays. Input arrays must be addressed and declared
as previously described.
3 – 24
Configuration of Instructions Data types
Entered Instruction
D0 00H
NULL code for moving
(00H) character
strings
If for example the character string "ABCD" is to be moved to D0, the registers D0 through
D1 are required for the string and the register D2 is required for the NULL code indicating
the end of string.
Entered Instruction
chracter string for moving D0 42H 41H
with 4 characters character D1 44H 43H
strings D2 00H
If for example the character string "ABCDE" is to be moved to D0, the registers D0 through
D2 are required for the character string. The NULL code indicating the end of string is written
to the upper byte of D2.
3 – 26
Configuration of Instructions Index qualification
X0
The constant -1 is stored in the index
MOV K 1 Z0
register Z0.
X0
MOV D10Z0 D0 The data from the index register
designated Z0 (D10+Z0(-1)=D9) are
stored under D0.
Indexing
Device Meaning
E Floating point number
$ Character string
. Bit addressing of word devices
FX, FY, FD Function devices
P Pointers used as label
I Interrupt pointers used as label
Z Index registers
S Step relays
TR SFC transfer devices 1)
BL SFC block devices 1)
1 SFC transfer devices and SFC block devices are devices for SFC use.
Refer to the following manual for how to use these devices: MELSEC-Q / L / QnA Programming Manual
(SFC)
NOTES There are no restrictions on the addressing of current values of timers and counters.
● A case where indexing has been performed, and the actual process device, would be as
follows:
(When Z0 = 20 and Z1 = 5)
X0
MOV K20 Z0 X1
MOV K2X64 K1M33
Description
MOV K 5 Z1
K2X50Z0 K2X(50 + 14) = K2X64
X0
MOV K20 Z0 X1
MOV D20 K3Y12A
Description
MOV K 5 Z1
D0Z0 D (0 + 20) = D20
K3Y12FZ1 K3Y(12F - 5) = K3Y12A
X1
MOV D0Z0 K3Y12FZ1
Hexadecimal number
3 – 28
Configuration of Instructions Index qualification
Indexing with 32-bit (Universal model QCPU (excluding Q00UJCPU) and LCPU)
A method of speciyfing index registers in indexing with 32-bit can be selected from the following
two methods.
● Specifing the index registers’ range used for indexing with 32-bit.
● Specifing the 32-bit indexing using “ZZ” specification.
NOTES 32-bit indexing with the "ZZ" specification is only available for the following CPU modules. See
the programming tool operating manual for the available programming tools:
The first five digits of the serial No. for QnU(D)(H)CPU is “10042” or higher (excluding
Q00UJCPU)
QnUDE(H)CPU
LCPU
● Example of specifying the range of index registers for use of 32-bit indexing.
Each index register can be set between -2147483648 and 2147483647.
X0
DMOV K40000 Z0 Stores 40000 at Z0.
X0
MOV ZR10Z0 D0 Stores the data of
ZR10Z0 = ZR{10+40000} = ZR40010 at D0.
Indexing
– Specification method
For indexing with a 32-bit index register, specify the head number of an index register to
be used on the Device tab of the Q parameter setting screen.
GX Works2
NOTES When the head number of the index register used is changed on the Device tab of the Q param-
eter setting screen, do not change the parameters only or do not write only the parameters into
the programmable controller. Be sure to write the parameter 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)
Device Meaning
ZR Serial number access format file register
D Extended data register (D)
W Extended link register (W)
X0
DMOV K100000 Z0
Description
MOV K-20 Z2
X1
MOV ZR1000Z0 D30Z2
3 – 30
Configuration of Instructions Index qualification
M0
DMOVP K100000 Z4 Stores 100000 at Z4 and Z5.
M0
MOVP K100 ZR0ZZ4 Indexing ZR device with 32-bit index
registers (Z4 and Z5)
ZR (0+100000) =ZR100000
– Specification method
To perform 32-bit indexing by using “ZZ” specification, select “Use of ZZ” in “Indexing
Setting for ZR Device” in PC parameter.
Device Meaning
ZR Serial number access format file register
D Extended data register (D)
W Extended link register (W)
– Following example shows the 32-bit indexing using the “ZZ” specification and the actual
processing device:
(When Z0 (32-bit) = 100000 and Z2 (16-bit) = –20)
X1
X0 MOV ZR101000 D10
DMOV K100000 Z0
END
MOV K-20 Z2
Description
X1
MOV ZR1000ZZ0 D30Z2 ZR1000ZZ0 ZR(1000+100000)=ZR101000
D30Z2 D(30-20)=D10
NOTES 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~Z19).
ZZn alone cannot be used as target for data transfer.
3 – 32
Configuration of Instructions Index qualification
Index modification using extended data register (D) and extended link register (W)
(Universal model QCPU (excluding Q00UJCPU) and LCPU)
Like index modification using data register (D) and link register (W) of internal user device, a
device can be specified by index modification within the range of the extended data register (D)
and extended link register (W).
Z0=0
D100 IInternal user
device
MOV K1234
D1100
Z0=1000
D22000
Z1=2000
Index modification in
extended data register
● Index modification where the device number crosses over the boundary between the internal
user device and the extended data register (D) or extended link register (W)
The specification of index modification where the device number crosses over the boundary
between the internal user device and the extended data register (D) or extended link register
(W) cannot be made. If doing so, an error occurs when the device range check is enabled
at index modification (Error code 4101).
Z0=0
D100 Internal user
device
MOV K1234
Extended data
D20100
Z0=20000 register
● Index modification where the device number crosses over the boundary among the file
register (ZR), extended data register (D), and extended link register (W)
Index modification where the device number crosses over the boundary among the file
register (ZR), extended data register (D), and extended link register (W) will not cause an
error. However, an error occurs if the index modification result of file register (ZR), extended
data register (D), and extended link register exceeds the file register range (Error code 4101).
File register (8 k)
ZR100
Z0=0
MOV K1234
Z0=10000
D14196
Extended data
register (D)
D20000
Z1=0 (8 k)
D12288–
MOV K1234 Z20000Z1
3 – 34
Configuration of Instructions Index qualification
BIN K4X0Z2 D0
Input of device numbers via index registers.
If Z2=3 then X(0+3) = X3.
BIN K4Z3X0 D0
This input would designate the block length of the digit
designation.
This designation is not supported.
● Both I/O numbers and buffer memory number can be performed indexing with intelligent
function module devices1)
MOV U10Z1\G0Z2 D0
● Both network numbers and device numbers can be performed indexing with link direct
devices1)
MOV J1Z1\K4X0Z2 D0
● When indexing is used for multiple CPU shared devices, indexing for the head I/O numbers
of CPU modules and indexing for the CPU shared memory address are automatically
executed.
MOV U3E0Z1\G0Z2 D0
NOTE For the intellingent function module device, link direct device and the multiple CPU shared
device refer to the QnUCPU User’s Manual (Function Explanation, Program Fundamentals) or
Qn(H)/QnPH/QnPRHCPU User’s Manuall (Function Explanation, Program Fundamentals).
● Index modification using extended data register (D) and extended link register (W) by 32
bits (Universal model QCPU(except Q00UJCPU) and LCPU)
Like index modification using file register (ZR), index modification using extended data
register (D) and extended link register (W) by 32 bits can be performed by the following two
methods:
– Specifing the index registers’ range used for indexing with 32-bit.
– Specifing the 32-bit indexing using “ZZ” specification.
NOTES 32-bit indexing with the "ZZ" specification is only available for the following CPU modules
(also refer to the User’s manuals of the programming tool used):
QnU(D)(H)CPU with first five digits of the serial No. is “10042” or higher (excluding
Q00UJCPU)
QnUDE(H)CPU
LCPU
3 – 36
Configuration of Instructions Index qualification
SM400 SM400
MOV K0 Z1 MOV K0 Z1
NEXT NEXT
NOTES The ON/OFF data of X0Z1 is stored by the edge relay V0Z1. For example, the ON/OFF data of
X0 is stored by V0, and that of X1 by V1.
SM400 SM400
MOV K0 Z1 MOV K0 Z1
CALL P0 CALL P0
SM400 SM400
MOV K1 Z1 MOV K1 Z1
CALL P0 CALL P0
FEND FEND
X0Z1 V0Z1 X0Z1
P0 M0Z1 P0 PLS M0Z1
RET RET
3 – 38
Configuration of Instructions Indirect designation (GX Works2 only)
D0
D1
Reads the contents of
D100 and D101
D100 W100
D101 W100 1234
To store an address for indirect designation, two words are used. Therefore, to decrease or
increase a stored adress for indirect designation by arithmetic instructions, the addition or sub-
traction of 32-Bit data is required.
In the following program examples the device which stores the device for indirect designation
is incremented and decremented by 32-Bit instructions. By doing so, the address of the device
for indirect designation is increased resp. decreased by 1.
3 – 40
Configuration of Instructions Indirect designation (GX Works2 only)
Indirect designation of extended data register (D) and extended link register (W)
Indirect designation can be performed in the extended data register (D) and extended link reg-
ister (W).
Note that when indirect designation is performed to the extended data register (D) and data
register (D) in internal device or to the extended link register (W) and link register (W) in internal
device, the areas of the internal user device and extended data register (D) or extended link
register (W) are not treated as a sequence.
File register
D12288
Extended data
register (D)
D13000
Since the areas of the data register
and extended data register are not
D63487 Extended link
sequence, D13000 is inaccessible.
register (W)
Subset processing is used to place limits on bit devices used by basic instructions and appli-
cation instructions in order to increase processing speed. However, the instruction symbol
does not change.
To shorten scans, run instructions under the conditions indicated below.
3 – 42
Configuration of Instructions Reducing instruction processing time
Operation processing time can be reduced with standard device registers (Z).
The following figure shows an example program with standard device registers.
+ D0 D10 D20 Using data registers takes three steps and the
operation processing time of 28.5 ns.
(With the Q4/Q06/Q10/Q13/Q20/
Q26UD(E)HCPU or Q50/Q100UDEHCPU)
Operation processing time is reduced with the instructions that the subset processing is pos-
sible.
For the number of steps, refer to section 3.11.
For the operation time for each instruction, refer to Appendix A.
NOTE Because standard device registers are the same devices as index registers, do not use device
numbers of the standard device registers for the index registers.
NOTE When file register is set but a memory card is not installed or when file register is not set, writing/
reading to/from file register is as follows:
For the High Performance model QCPU, Process CPU, and Redundant CPU
An error does not occur even when writing/reading to/from file register is performed. How-
ever, “0H” is stored when reading from file register is performed.
For the Universal model QCPU and LCPU
The OPERATION ERROR (error code 4101) occurs when writing/reading to/from file register
is performed.
3 – 44
Configuration of Instructions Operation errors
The device range is checked even though indexing is executed. With changing the settings
of the PLC parameter, the device range is not checked.
For changing the settings of the PLC parameter of the programming tool, refer to the User’s
Manual of the corresponding programming tool.
3 – 46
Configuration of Instructions Operation errors
The device range is verified for an index qualification too. An error occurs when the head
device number of the devices with indexing exceeds the device range.
With changing the settings of the PLC parameter, the device range is not checked.
For changing the settings of the PLC parameter of the programming tool, refer to the User’s
Manual of the corresponding programming tool.
However, with the Basic Model QCPU, High Performance model QCPU, Process CPU, and
Redundant CPU, when indexing is executed and the head device number is outside the device
range, no error occurs and the other devices are accessed.
When performing the following access in Universal model QCPU or LCPU, an error (error code
4101) occurs.
Access crossing the boundary of devices caused by indexing (range of A area)
SM
SD
X
Y
M
L
B
F
SB
V Area A
S
Contact and coil of T
Contact and coil of ST
Contact and coil of C
Present value of T
Present value of ST
Present value of C
D
W
SW
Empty area Boundary B
File register (32k points)
3 – 48
Configuration of Instructions Operation errors
Presetting PLC parameter not to check indexing device range enables the Universal model
QCPU not to detect an error in the above accesses from to . Detecting an error in the
above accesses however, depends on the serial No. of Universal model QCPU.
Setting device range First 5 digits of serial No. for Universal model QCPU
in indexing "10021" or lower "10022" or higher
Set Detected errors in accesses to
Not set Detected errors in accesses to Not detected
For changing the settings of the PLC parameter, refer to the User’s Manual of the programming
tool.
NOTE When indexing is executed only with Universal model QCPU or LCPU, devices between internal
user devices (SW) and file registers (R) cannot be skipped. (Error code 4101)
Precautions for using the extended data register (D) or extended link register (W) (for
the Universal model QCPU (except Q00UJCPU), and LCPU)
With the following specification methods, data cannot be specified crossing over the boundary
of the internal user device and extended data register (D) or extended link register (W). Doing
so causes an "OPERATION ERROR" (Error code 4101).
● Index modification
● Indirect designation
● Specification with the instructions that handle data blocks
Data block indicates the following data:
– Data used in the instructions, such as FMOV, BMOV, BK+, where multiple words are
targeted for operation
– Control data, composed of two or more words, specified in the instructions, such as
SP.FWRITE, SP.FREAD
– Data whose data type is 32-bit or more (BIN 32-bit, real number, indirect address of the
device)
D199
D20100
D20299
3 – 50
Configuration of Instructions Operation errors
For accessing buffer memories, using instructions with intelligent function module devices
(from Un\G0) is recommended.
For accessing multiple CPU shared memories, using instructions with multiple CPU shared
devices (from U3En\G10000) is recommended.
3 – 52
Configuration of Instructions Execution conditions of the instructions
The following example shows the execution of the MOV instruction with the execution condition
set ON and the execution at leading edge from the execution condition:
Execution at
execution condition set ON
All instructions described in this manual are provided in the manufacturer library of the GX IEC
Developer. These instructions in addition to the input and output variables provide an EN input
and an ENO output.
The figure below shows several MELSEC instructions from the GX IEC Developer manufac-
turer library:
In the IEC standard library nearly all instructions appear twice. They just differ in the suffix "_E".
These instructions provide an EN input and an ENO output.
The figure below shows two IEC instructions from the standard library of the GX IEC Devel-
oper:
The following examples show the differing execution of the instruction with and without EN
inputs and ENO outputs.
NOTE The ENO output must not compulsorily be connected. The signal at the EN input is looped-
through to the ENO output. If the EN input is "TRUE", the ENO output is "TRUE" as well.
3 – 54
Configuration of Instructions Number of program steps
3 Program steps
The numbers in brackets specify the
cumulative number of program steps for the
devices.
4 Program steps
● Devices with additional steps (Universal model QCPU(except Q00UJCPU) and LCPU)
– Instructions applicable to subset processing
The following table shows steps depending on the devices.
Added Steps
(Number of Basic Number
Instruction Symbols Devices With Additional Steps
Instruction of Steps
Steps)
Timer/Counter 3(4)
3 – 56
Configuration of Instructions Number of program steps
Added Steps
Instruction Symbols Devices With Additional Steps (Number of Basic Number
Instruction of Steps
Steps)
LDD=, LDD<>, LDD<, LDD<=, Serial number access format file register,
LDD>, LDD>=, Extended data register (D),
ANDD=, ANDD<>, ANDD<, Extended link register (W)
3
ANDD<=, ANDD>, AND>=,
1
ORD=, ORD<>, ORD<, Multiple CPU shared device 3)
ORD<=, ORD>, ORD>=
Decimal constant, hexadecimal constant,
real constant
Added Steps
Instruction Symbols Devices With Additional Steps (Number of Basic Number
Instruction of Steps
Steps)
1 If the same device is used for s1 and s2, the number of basic steps increases by one.
2
The number of steps decreases with a standard device register.
3
Not available with LCPU.
3 – 58
Configuration of Instructions Number of program steps
When multiple standard device registers are used in an instruction applicable to subset
processing, the number of steps decreases.
The following table shows the number of steps for each instruction.
s1 and s2
(only when that device that the
Dx, DxP, D/, D/P, Ex, ExP ±0(3) 3
number of steps does not increase is
specified for d)
s1 and s2
(only when a serial number access +2(5)
format file register is specified for d)
1 If the same device is used for s1 and d, the number of basic steps increases by one.
In cases where several of these factors apply the number of steps sums up.
If for example, MOV U1\G10 ZR123 is programmed, 1 step is added for the buffer memory and
1 step for the file register addressed in series, resulting in a total of 2 steps (see the following
figure):
Example: MOV
If U1\G10 ZR123 has been designated, a total of 2 steps is added.
U1\
MOV G10 ZR123
3 – 60
Configuration of Instructions Multiple Instructions using the same device
Do not program more than one OUT instruction using the same device in one scan. If the OUT
instructions using the same device are programmed in one scan, the specified device will turn
ON or OFF every time the OUT instruction is executed, depending on the operation result of
the program up to the relevant OUT instruction. Since turning ON or OFF of the device is deter-
mined when each OUT instruction is executed, the device may turn ON and OFF repeatedly
during one scan.
The following diagrams show an example of a ladder that turns the same internal relay (M0)
with inputs X0 and X1 ON and OFF.
Ladder diagram
X0
M0
X1
M0
Timing chart
X0 X0
M0 M0
X1 X1
M0 M0
END END END
ON
X0 OFF
ON
X1 OFF
ON
M0 OFF
M0 turns ON because
M0 turns OFF because X1 is OFF. X1 is ON.
With the refresh type CPU module, when the output (Y) is specified by the OUT instruction, the
ON/OFF status of the last OUT instruction of the scan will be output.
The SET instruction turns ON the specified device when the execution command is ON and
performs nothing when the execution command is OFF. For this reason, when the SET instruc-
tions using the same device are executed two or more times in one scan, the specified device
will be ON if any one of the execution commands is ON.
The RST instruction turns OFF the specified device when the execution command is ON and
performs nothing when the execution command is OFF. For this reason, when the RST instruc-
tions using the same device are executed two or more times in one scan, the specified device
will be OFF if any one of the execution commands is ON.
When the SET instruction and RST instruction using the same device are programmed in one
scan, the SET instruction turns ON the specified device when the SET execution command is
ON and the RST instruction turns OFF the specified device when the RST execution command
is ON. When both the SET and RST execution commands are OFF, the ON/OFF status of the
specified device will not be changed.
Ladder diagram
X0
SET M0
X1
RST M0
Timing chart X0 X0
SET M0 SET M0
X1 X1
RST M0 RST M0
END END END
ON
X0 OFF
ON
X1 OFF
ON
M0 OFF
When using a refresh type CPU module and specifying output (Y) in the SET/RST instruction,
the ON/OFF status of the device at the execution of the last instruction in the scan is returned
as the output (Y).
3 – 62
Configuration of Instructions Multiple Instructions using the same device
The PLS instruction turns ON the specified device when the execution command is turned ON
from OFF. It turns OFF the device at any other time (OFF to OFF, ON to ON, or ON to OFF).
If two or more PLS instructions using the same device are executed in one scan, each instruc-
tion turns ON the device when the corresponding execution command is turned ON from OFF
and turns OFF the device in other cases. For this reason, if multiple PLS instructions using the
same device are executed in a single scan, a device that has been turned ON by the PLS
instruction may not be turned ON during one scan.
Ladder diagram
X0
PLS M0
X1
PLS M0
Timing chart
ON
X0 OFF
ON
X1 OFF
ON ON
M0 OFF M0 turns ON because X1 goes
M0 turns OFF be- ON (OFF → ON).
M0 turns ON because X0 goes cause X1 status is oth- M0 turns OFF because X0 status is other
ON (OFF → ON). er than OFF → ON. than OFF → ON. (M0 remains OFF.)
1
X0 X0
PLS M0 PLS M0
X1 X1
PLS M0 PLS M0
END END END
ON
X0 OFF
ON
X1 OFF
ON
M0 OFF
When using a refresh type CPU module and specifying output (Y) in the PLS instructions, the
ON/OFF status of the device at the execution of the last PLS instruction in the scan is returned
as the output (Y).
The PLF instruction turns ON the specified device when the execution command is turned OFF
from ON. It turns OFF the device at any other time (OFF to OFF, OFF to ON, or ON to ON).
If two or more PLF instructions using the same device are executed in one scan, each instruc-
tion turns ON the device when the corresponding execution command is turned OFF from ON
and turns OFF the device in other cases. For this reason, if multiple PLF instructions using the
same device are executed in a single scan, a device that has been turned ON by the PLF
instruction may not be turn ON during one scan.
3 – 64
Configuration of Instructions Multiple Instructions using the same device
Ladder diagram
X0
PLF M0
X1
PLF M0
Timing chart
The ON/OFF timing of the X0 and X1 is different.
(The specified device does not turn ON throughout the scan.)
X0 X0
PLF M0 PLF M0
X1 X1
PLF M0 PLF M0
END END END
ON
X0 OFF
ON
X1 OFF
ON
M0 OFF
M0 turns OFF because M0 turns OFF because X1
X1 status is other than status is other than ON →
ON → OFF OFF. (M0 remains OFF.)
M0 turns ON because X0
goes OFF (ON → OFF). M0 turns OFF because X0 status is other
than ON → OFF. (M0 remains OFF.)
X0 X0
PLF M0 PLF M0
X1 X1
PLF M0 PLF M0
END END END
ON
X0 OFF
ON
X1 OFF
ON
M0 OFF
When using a refresh type CPU module and specifying output (Y) in the PLF instructions, the
ON/OFF status of the device at the execution of the last PLF instruction in the scan is returned
as the output (Y).
NOTE Even when file registers to be used are not set in the PLC parameter, a program that uses file
registers can be created.
For the CPU module other than the Universal model QCPU and LCPU, an error does not occur
when that program is written to the CPU module.
However, note that the correct data cannot be written/read to/from the file register.
For the Universal model QCPU and LCPU, an error occurs if the program where file registers are
used is executed.
The following table indicates the memories that can use the file registers in each CPU module.
Standard RAM
1) 2)
Memory card
Can be registered
Cannot be registered
1 When the flash memory is used, only read from the file registers can be performed. (Write to the flash
ROM cannot be performed.)
2 Unusable for the Q00UCPU and Q01UCPU.
3 – 66
Configuration of Instructions Precautions for use of file registers
NOTE For the file register setting method and file register area securing method, refer to User’s Manual
(Functions Explanation, Program Fundamentals) for the CPU module used.
Standard RAM/
Memory card
RSET K1 Specifying
R0 for block 1 R0
to Block 0
MOV D0 R0
R32767
RSET K2 Specifying R0
R0 for block 2 Block 1
to
MOV D0 R0 R32767
R0 Block 2
to
Standard RAM/
Memory card
MOV D0 ZR32768
ZR0
Block 0
to
ZR32767
MOV D0 ZR65536 ZR32768
Block 1
to
ZR65535
ZR65536
Block 2
to
● Restrictions
The restrictions when specifying file registers to refresh devices are as follows.
– On QCPU, Refresh cannot be performed correctly if the use of file register which has the
same name as the program is specified by the PLC parameter. When the file register which
has the same name as the program is used, refresh is performed to the data of the file
register having the same name as the program that is set at the last number in the
[Program] tab page of PLC parameter.
To read/write the refresh data, specify the file register to the refresh device after switching
the file register to the corresponding one with the QDRSET instruction.
– Refresh cannot be performed correctly if the file name of file register or the drive number
is changed by the QDRSET instruction. (QDRSET instructions are not available with
LCPU.)
If the file name of file register or the drive number is changed by the QDRSET instruction,
link refresh is performed to the data of the setting file at the time of the END instruction
execution.
To read/write the refresh data, specify the file register of the setting file at the time of the
END instruction execution.
3 – 68
Configuration of Instructions Precautions for use of file registers
If the drive number is changed by the QDRSET instruction when "ZR" is specified for the
device in the CPU modules other than the Universal model QCPU, an error (LINK PARA
ERROR (3101)) occurs. (Note that an error does not occur when "R" is specified for the
device.)
– When a block number is switched by the RSET instruction, refresh is performed to the
data of the file register (R) in the switched block number.
When a block number is switched by the RSET instruction, refresh is performed to the
data of the file register (R) in the block number at the time of the END instruction execution.
To read/write the refresh data, specify the file register of the block number at the time of
the END instruction execution.
Write
BMOV D100 R0 K10
File
register
BMOV R100 D0 K10
Read
When using the flash memory for the file registers, write data in advance. Using GX Works2,
write data to the flash card.
3 – 70
Layout and Structure of the Chapters
Each subdivided topic is described in the following according chapter and illustrated by pro-
gram examples.
Each subdivided topic starts with a table that lists all individual instructions described in this
section. As the figure below shows, all variations of the instructions are represented in
MELSEC and IEC editor notation.
When using the GX IEC Developer, always choose the IEC instruction when different notations
are offered.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The serial number (upper five digits) is "04122" or higher.
Any particular processing details of a certain CPU are commented in a footnote (e.g. extended
instructions, refer to section 3.3 "Programming of dedicated instructions".
4–2
Layout and Structure of the Chapters Devices
4.3 Devices
The table "Devices" lists all usable devices that can be used for the internal variables (e.g. s1,
s2, d).
The devices are not listed separately; only a distinction is drawn whether the instruction is
capable of designating bit and/or word devices.
Whether the instruction supports file register access is indicated in the column "File Register".
The column "MELSECNET/H Direct J\“ specifies whether the instruction supports read/
write operations of bit and/or word data from/to stations connected to the MELSECNET/H.
"J\" specifies the station number and "“ the device number.
The column "Special Function Module U\G“ specifies whether the instruction supports read/
write operations of data from/to the buffer memory of an installed special function module.
"U\“ specifies the head address of the special function module and "G“ the buffer memory
address.
Whether the instruction can apply an index qualification is indicated in the column "Index
Register Zn".
Whether decimal (K) or hexadecimal (H, 16#) constants can be processed by the instruction is
indicated in the column "Constant K, H (16#)".
The column "Other" specifies whether the instruction uses any other devices and constants.
Any particular details are commented in footnotes below the table.
The device tables are followed by the representation format of the instruction in the GX IEC
Developer.
The figure below from the left to the right shows the representation of the instruction LD_EQ_M
in the MELSEC editor (MELSEC instruction list) and in the IEC editor (ladder diagram and IEC
instruction list).
The representation format for the instruction in the GX IEC Developer is followed by the repre-
sentation format of the instruction in GX Works2.
4–4
Layout and Structure of the Chapters Variables
4.5 Variables
The table of variables lists all internal variables of the instruction.
The column "Meaning" describes the functions of the devices and device elements.
The column "Data Type" lists the data types of the devices. Provided that there are differences
between the data types of the MELSEC and the IEC editor, these are listed as well. Refer to
the sections 3.4 "Programming of variables" and 3.5 "Data types" for further details on
variables.
4.6 Functions
The section "Functions" describes the functions of the instruction in detail.
The figure below shows the description of the functions of the LDF/LDP instruction.
4.7 Notes
The section "NOTE" points out particular details, errors, and sources of malfunction in the pro-
gramming of the instruction.
NOTE The MEP and MEF instructions will occasionally not function when pulse conversion is ap-
plied to contacts that are indexed by a subroutine or by a FOR/NEXT instruction. In this ca-
se, the EPG/EGF instruction has to be applied.
The MEP/MEF instruction operates with the ooperation results immediately prior to the
MEP and MEF instructions. For this reason, an AND instruction should be used at the
same position. The MEP and MEF instructions cannot be used at the LD or OR position.
Operation In the following cases an operation error occurs, the error flag (SM0) turns
Errors ON, and an error code is stored into SD0.
The number of output designated by d exceeds the output range.
(Error code: 4101)
4–6
Layout and Structure of the Chapters Program examples
In the following figure a program example for the RBMOVP instruction is shown. The represen-
tation of the instructions is that of the GX Works2.
4–8
5 Sequence Instructions
Sequence instructions, besides conventional instructions to program input and output con-
tacts, also include program jump commands, block connection instructions and bit shift instruc-
tions, master control, program termination and other instructions. These are the fundamental
instructions for programming the MELSEC series.
The following table shows the division of the fundamental instruction set:
Instruction Meaning
Input instruction Operation start,
series and parallel connection of contacts.
Connection instruction Series and parallel block connection,
storage and processing of operation results,
inversion of operation results,
conversion of operation results into pulses,
setting of edge relays.
Output instruction Bit devices, counter and timer contacts,
output, setting, and resetting of annunciators,
setting and resetting of devices,
leading edge and trailing edge output,
bit device output inversion,
generating pulses.
Shift instruction Shifting bit devices.
Master control instruction Setting and resetting single parts of a program.
Termination instruction End of a part of program,
end of sequence and routine programs.
Miscellaneous instructions Sequence program stop,
no operation.
NOTE The following table, besides the MELSEC instructions in the different editors, also contains the
according IEC instructions:
MELSEC Instruction
in IEC Editor IEC Instruction in
in MELSEC Editor IEC Editor
Instruction List Ladder Diagram
LD — — LD
LDI — — LDN
AND — AND
ANI — ANDN
OR — — OR
ORI — — ORN
LDP LDP_M — — —
LDF LDF_M — — —
ANDP ANDP_M — —
ANDF ANDF_M — —
ORP ORP_M — —
ORF ORF_M — —
LDPI
LDFI
ANDPI
ANDFI
ORPI
ORFI
AND (
ANB — — ...
)
OR (
ORB — — ...
)
MPS MPS_M —
MRD MRD_M —
MPP MPP_M —
MEP MEP_M — —
MEF MEF_M — —
EGP EGP_M — —
EGF EGF_M — —
OUT OUT_M ST
OUT T TIMER_M — —
OUTH T TIMER_H_M — —
OUT C COUNTER_M — —
5–2
MELSEC Instruction
IEC Instruction in
in IEC Editor IEC Editor
in MELSEC Editor
Instruction List Ladder Diagram
OUT F
SET SET_M S
RST RST_M R
SET F
RST F
FF FF_M — —
DELTA DELTA_M — —
DELTAP
SFTP
MC MC_M — —
MCR MCR_M — —
FEND FEND_M — 2)
END END_M — 2)
STOP STOP_M — —
NOP — — —
NOPLF
PAGE
1
These are IEC function blocks.
2
FEND and END are set automatically by GX Works2 and the GX IEC Developer.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
5–4
Input instructions LD, LDI, AND, ANI, OR, ORI
Series connection
AND of NO contacts
ANI of NC contacts
Contacts are connected in series via an AND instruction as NO contact or via an ANI instruc-
tion as NC contact.
The device designated by the instruction sets the operation condition for the following instruc-
tion.
Both commands are logical connections and must not be programmed at the beginning of an
operation.
Parallel connection
OR of NO contacts
ORI of NC contacts
Parallel connection of contacts is established via an OR instruction as NO contact or via an
ORI instruction as NC contact.
The device designated by the instruction sets the operation condition for the following instruc-
tion.
Both commands are logical connections and must not be programmed at the beginning of an
operation.
NOTE The devices designated by the instructions can also be word devices. In this case, the condition
of a specified bit is read as contact.
Word devices are designated in hexadecimal code. Bit b11 in D0 for example is designated as
D0.0B.
For further information on addressing bits in word devices refer to chapter 3 "Configuration of In-
structions".
5–6
Input instructions LDP, LDF, ANDP, ANDF, ORP, ORF
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
The following table shows the results of an LDP, LDF, ANDP, ORP, ANDF and ORF instruction:
0→1 1
0 0
1 0
1→0 1
5–8
Input instructions LDP, LDF, ANDP, ANDF, ORP, ORF
NOTE Word devices are designated in hexadecimal code. Bit b11 in D0 for example is designated as
D0.0B.
Program ORP
Example
With leading edge from X0 or by setting (leading edge) bit 10 (b10) in data register D0, the fol-
lowing program executes a MOV instruction.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Availability depending on serial number:
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Bit device number / Word device bit designation (s)
X1/D0.1
LDP
X1/D0.1
LDF
X2/D0.2
ANDP
X2/D0.2
ANDF
ORP
X3/D0.3
ORF
X3/D0.3
5 – 10
Input instructions LDPI, LDFI, ANDPI, ANDFI, ORPI, ORFI
0→1 1
0 0
1 0
1→0 1
Ladder Diagram
Program ANDPI
Example 2
The following program stores 0 into D0 when X0 is on and b10 (bit 11) of D0 is on, off, or turns
from on to off.
Ladder Diagram
5 – 12
Connection instructions ANB, ORB
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
ANB
The ORB connection is an independent instruction and does not require any device.
Within one program the ORB instruction can be applied any number of times.
If more than two blocks are connected consecutively, the number of ORB instructions is limited
to 15 (= 16 blocks). Exceeding these limits results in malfunction.
5 – 14
Connection instructions MPS, MRD, MPP
NOTE These instructions should not be used within the IEC editors.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer
MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
The MPS, MRP and MPP instructions are independent instructions and do not require any
device.
In ladder programming mode the MPS, MRD and MPP instructions are not displayed explicitly.
Whether connections are of the MPS, MRD or MPP type depends on the structure of the ladder
diagram.
The example on the left shows a ladder diagram applying MPS, MRD or MPP instructions. The
example on the right shows a ladder diagram without MPS, MRD or MPP instructions.
The number of MPS instructions in a program must equal the number of MPP instructions. Fail-
ure to observe this will not correctly display the ladder in the ladder mode of the peripheral
device.
5 – 16
Connection instructions MPS, MRD, MPP
5.2.3 INV
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer
MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
5 – 18
Connection instructions INV
Program The following program inverts the status of X0 and outputs the inverted signal at Y10.
Example
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer
MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 20
Connection instructions MEP, MEF
NOTE The MEP and MEF instructions will occasionally not function properly when pulse conversion is
applied to contacts that are indexed by a subroutine or by a FOR/NEXT instruction. In this case,
the EGP/EGF instruction has to be applied.
The MEP/MEF instruction operates with the operation results immediately prior to the MEP and
MEF instructions. For this reason, an AND instruction should be used at the same position. The
MEP and MEF instructions cannot be used at the LD or OR position.
Program MEP
Example
With leading edge from the series connection result at X0 and X1, the following program sets
the relay M0.
Ladder Diagram
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer
MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 22
Connection instructions EGP, EGF
Program EGP
Example
The following program first resets the index register Z0 to 0 and then calls the subroutine UP1 (1).
With leading edge X0Z0 is set to X0 and V0Z0 is set to V0. Further, D0Z0 is set to D0 and incre-
mented by 1.
After returning, the index register Z0 stores 1, and the subroutine is called again (2). With leading
edge from X1, V1 is set and D1 is incremented.
Ladder Diagram
CPU High
Basic Performance Process Redundant Universal LCPU
1
Except T, C, F
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
5 – 24
Output instructions OUT
OUT Instruction
Bit Device or Word Contact Type
Input Condition Output Contact Device Bit Designa-
tion NO Contact NC Contact
0 OFF 0 Non-continuity Continuity
1 ON 1 Continuity Non-continuity
NOTE See section 3.12.1 for the operation to be performed when the OUT instruction for the same
device is executed more than once during one scan.
Program OUT
Example 1
The following program shows the programming of an OUT instruction using bit devices as out-
puts (Y33 through Y35).
Program OUT
Example 2
The following program shows the programming of an OUT instruction using bits of the word
device D0 (bits b5 through b7).
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
MELSEC Instruction List Ladder Diagram
Developer
GX Works2
5 – 26
Output instructions OUT T, OUTH T
To clear the present value of a retentive timer and turn the contact OFF after time up, use the
RST instruction.
A negative number (–32768 to –1) cannot be set as the setting value for the timer. If the setting
value is 0, the timer will time out when the OUT(H) T instruction is executed. Please note: When
specifying a setting value for the timer using a word device the value is not checked whether it is
in the setting range. Check the value in the user program so that a negative number is not set.
The execution of the OUT(H) T instruction performs as follows:
– The timer coil designated by d is set or reset.
– The according timer contact is set or reset.
– The time settings are refreshed.
If a program jumps to an OUT(H) T instruction while it is executed, the contact conditions and
timer settings are maintained.
If one instruction is executed repeatedly within one cycle, the value of the repetitions is
refreshed.
Indexing for timer coils or contacts can be conducted only by Z0 or Z1. Timer setting value has
no limitation for indexing.
Program OUT T
Example 1
10 seconds after setting X0, the following program sets the outputs Y10 and Y14. A low speed
timer (T1, 100 ms) is used.
Program OUT T
Example 2
The following program reads the time setting via the inputs X10 to X1F in BCD data format.
With leading edge from X0 BCD data is converted into BIN data first and stored in D10. After
setting X2 the time setting is read. After the set time has passed Y15 is set. A low speed timer
(T2, 100 ms) is used.
5 – 28
Output instructions OUT T, OUTH T
Program OUTH T
Example 3
250 ms after setting X10 the following program sets the output Y10. A high speed timer (10 ms)
is used.
5.3.3 OUT C
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 30
Output instructions OUT C
NOTE Please refer to section A.5.5 of this manual for more information about counters.
Program OUT C
Example 1
After X0 has been set for 10 times, the following program sets Y30 and if X1 is set resets Y30.
Program OUT C
Example 2
The following program sets the setting value in C10 to 10 (D0 =10) with leading edge from X0,
and to 20 (D0 =20) with leading edge from X1.
If X3 is set, the counter starts counting and sets Y30 when it reaches the setting value in D0.
5 – 32
Output instructions OUT F
5.3.4 OUT F
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
Program OUT F
Example
If X0 is set, the following program sets the annunciator F7. The number 7 is stored in the reg-
isters SD64 through SD79. The value in register SD63 is incremented by 1 (i.e. 1 number of
annunciator stored).
1
X0 is set
5 – 34
Output instructions SET
5.3.5 SET
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction
GX Works2
:#
5-6 ;
:%
456 ;
NOTE See section 3.12.2 for the operation to be performed when the SET instruction for the same
device is executed more than once during one scan.
Program SET
Example 1
If X8 is set, the following program sets the output Y8B. If X9 is set, Y8B is reset.
Program SET
Example 2
If X8 is set, the following program sets bit 5 (b5) in D0 from 0 to 1. If X9 is set, this bit is reset.
5 – 36
Output instructions RST
5.3.6 RST
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
IEC Instruction List
Developer MELSEC Instruction List Ladder Diagram (IEC Instruction)
GX Works2
NOTE See section 3.12.2 for the operation to be performed when the RST instruction for the same de-
vice is executed more than once during one scan.
Program RST
Example 1
With leading edge from X0, the following program stores the content at X10 through X1F in the
data register D8. If X5 is set, the content of D8 is reset to 0.
5 – 38
Output instructions RST
Program RST T, C
Example 2
The following program illustrates resetting of retentive timers and counters.
In the first program step T225 is set, if X4 has been set for 30 minutes (18000 seconds).
In the second program step C23 counts the number of times T225 is set.
If this timer is set for 16 times (setting value of C23 = 16) the output Y55 is set.
If X5 is set, the counter will be reset to 0.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
5 – 40
Output instructions SET F, RST F
5 – 42
Output instructions PLS, PLF
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
X5
PLS M0
1
One scan
NOTE See section 3.12.3 for the operation to be performed when the PLS instruction for the same de-
vice is executed more than once during one scan.
If the RUN/STOP key switch on the CPU unit is set to STOP while a PLS instruction is
executed, the PLS instruction will not be executed further on after the switch is set back to RUN
even if the input condition is still set.
2 2
1
1
One scan of PLS M0
2
RUN/STOP switch of the CPU switched from RUN to STOP
3 RUN/STOP switch of the CPU switched from STOP to RUN
If a latch relay is designated by a PLS instruction, and the power is turned OFF while a latch
relay is set, after turning ON the power again the designated latch relay is set for one scan.
5 – 44
Output instructions PLS, PLF
X5
PLF M0
1
One scan
NOTE See section 3.12.4 for the operation to be performed when the PLF instruction for the same
device is executed more than once during one scan.
If the RUN/STOP switch of the CPU unit is set to STOP while a PLS instruction is executed,
the PLS instruction will not be executed further on after the switch is set back to RUN even if
the input condition is still set.
NOTE The device d designated by a PLS or PLF instruction remains set for more than one program
scan if a CJ or similar instruction was applied to jump to the PLS or PLF instruction and the part
of program was not executed.
Program PLS
Example 1
With leading edge from X9, the following program sets the internal relay M9 for one program
scan.
1
One scan
Program PLF
Example2
With trailing edge from X9, the following program sets the internal relay M9 for one program scan.
1
One scan
5 – 46
Output instructions FF
5.3.9 FF
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Program FF
Example 1
With leading edge from X9, the following program inverts the output condition of Y10.
Program FF
Example 2
With leading edge from X9, the following program inverts bit 10 (b10) of D10.
5 – 48
Output instructions DELTA, DELTAP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of output designated by d exceeds the output range.
(Error code 4101)
Program DELTAP
Example
With leading edge from X20, the following program presets CH1 of the AD61 output unit
mounted at slot 0 of the main base unit. The preset value 0 is stored at addresses 1 and 2 of
the AD61 buffer memory. The DELTAP instruction outputs the preset instruction at DY11.
5 – 50
Shift instructions SFT, SFTP
CPU High
Basic Process Redundant Universal LCPU
Performance
1 Except T and C
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
If bits in word devices are shifted, the condition (0/1) of the bit d-1 is shifted to d. The bit d-1 is
reset after the SFT instruction. In the following illustration bit 5 (b5) in D0 is shifted. Bit 4 (b4)
is reset after execution of the instruction.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU and LCPU only.)
(Error code 4101)
5 – 52
Shift instructions SFT, SFTP
Program SFT
Example
With leading edge from X8, the following program shifts the condition of Y57 to Y5B. With lead-
ing edge from X7, Y57 is set.
NOTE These instructions should not be used within the IEC editors.
CPU High
Basic Process Redundant Universal LCPU
Performance
d — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 54
Master control instructions MC, MCR
General notes
The MC instruction is applied to create highly efficient ladder switching sequence programs.
After setting the input condition, the program part between the destination d and the MCR
instruction is executed. The master control regions are distinguished by nesting (N). Nesting
can be performed from N0 through N14.
Since the GX IEC Developer Software does not allow a vivid programming of the MC/MCR
instruction, here the ladder diagrams of the GX Works2 Software are shown as an illustration.
The ladder diagram illustrates the function of the MC instruction. If the input X0 is reset, the
program part in level 1 (designated by N1) is skipped (1). If X0 is set, the program part from N1
to the MCR instruction is executed (2).
When programming in the ladder mode, it is not necessary to input MC contacts on the vertical
bus. These are displayed automatically.
Devices Processing
10 ms timer Count value setting is reset to 0.
100 ms timer Input and output contacts are reset (0).
Retentive 10 ms timer
Retentive 100 ms timer Count value setting and condition of input contacts remai-
ned. Output contact is reset (0).
Counter
Devices in the OUT instruction All outputs are reset.
Devices in the SET, RST, and SFT instruction Actual status remained.
NOTE If an instruction that does not require any input condition (e.g. FOR/NEXT, EI, DI) is placed bet-
ween the MC and MCR instructions, this instruction is executed by the PLC without regard to the
input condition of the MC instruction.
For one MC instruction, identical nesting levels n are allowed, provided that different numbers
(addresses) of devices are set.
After setting the MC instruction the device designated by d is set. If this device is designated
as input condition elsewhere in the program, the contacts are processed as double contacts
and set or reset in parallel. Therefore, the device designated by d should not be used within
other instructions.
5 – 56
Master control instructions MC, MCR
If several MCR instructions are progammed consecutively, the program can be shortened by
placing one MCR instruction only with the lowest nesting address to finish all MC program
parts.
5 – 58
Master control instructions MC, MCR
NOTE This instruction should not be used within the IEC editors.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 60
Termination instructions FEND
1
Main routine program
2
Subroutine program
3 Interrupt program
NOTE In the instruction list of the GX Works2 the FEND instruction has to be programmed by the user.
After this program organization unit has been processed no further one will be executed be-
cause it would follow the FEND instruction.
Alternatively to this programming the IEC editor can be used. In that case the FEND instruction
would be set by the GX IEC Developer compiler automatically.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The FEND instruction is executed after a CALL, FCALL, ECALL, or EFCALL instruction and
before a RET instruction. (Error code 4211)
● The FEND instruction is executed after a FOR instruction and before a NEXT instruction.
(Error code 4200)
● The FEND instruction is executed during an interrupt program and before an IRET instruction.
(Error code 4221)
● The FEND instruction is executed after a CHKCIR instruction and before a CHKEND instruc-
tion. (Error code 4230)
● The FEND instruction is executed after an IX instruction and before an IXEND instruction.
(Error code 4231)
5 – 62
Termination instructions END
5.6.2 END
NOTE This instruction should not be used within the IEC editors.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
1
Sequence program
The END instruction cannot be applied in a program routine. A program routine is terminated
by the FEND instruction.
If the END instruction is missing in a program an error message is returned when starting the
program, and the program execution is terminated by the PLC. Without the END instruction
operation errors even occur, if the capacity of a subprogram is set by parameters.
The following diagram illustrates appropriate programming of the END and FEND instruction:
1
Main routine program
2
Subroutine program
3 Interrupt program
4 Sequence program
NOTE The FEND instruction will be set by both the GX IEC Developer and GX Works2 automatically.
5 – 64
Termination instructions END
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The jump destination of a CJ, SCJ, or JMP instruction is allocated after the END instruction.
● A subprogram or interrupt routine allocated after the END instruction is called.
● The END instruction is executed after a CALL, FCALL, ECALL, or EFCALL instruction and before
a RET instruction. (Error code 4211)
● The END instruction is executed after a FOR instruction and before a NEXT instruction.
(Error code 4200)
● The END instruction is executed during an interrupt program and before an IRET instruction.
(Error code 4221)
● The END instruction is executed after a CHKCIR instruction and before a CHKEND instruction.
(Error code 4230)
● The END instruction is executed after an IX instruction and before an IXEND instruction.
(Error code 4231)
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
5 – 66
Miscellaneous instructions STOP
1 Binary value 3
In order to restart the operation of the PLC the RUN/STOP switch has to be switched to STOP
and then to RUN again.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The STOP instruction is executed after a CALL, FCALL, ECALL, EFCALL or XCALL instruction
and before a RET instruction. (Error code 4211)
● The STOP instruction is executed after a FOR instruction and before a NEXT instruction.
(Error code 4200)
● The STOP instruction is executed during an interrupt program and before an IRET instruction.
(Error code 4221)
● The STOP instruction is executed after a CHKCIR instruction and before a CHKEND instruc-
tion.
(Error code 4230)
● The STOP instruction is executed after an IX instruction and before an IXEND instruction.
(Error code 4231)
● The STOP instruction was executed during the fixed scan execution type program.
(For the Universal model QCPU and LCPU only) (Error code 4223)
Program STOP
Example
If X8 is set the following program terminates operation. All following program steps are
executed after switching the RUN/STOP switch to STOP and to RUN again.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
NOTE The NOP instruction does not work with the IEC editors. The only way to program this instruc-
tions is by using the MELSEC instruction list.
GX Works2
In the ladder display, NOP is not displayed.
5 – 68
Miscellaneous instructions NOP, NOPLF, PAGE n
NOTE After finishing program editing the NOP instructions should be deleted where possible in order
to shorten program scan time.
Program NOP
Example 1
The following program contains a NOP instruction to replace the contact connection AND for
debugging purposes.
Program NOP
Example 2
The following program example contains a NOP instruction to replace an LD instruction.
Program NOP
Example 3
The following program example contains a NOP instruction to replace an LD instruction.
NOTE Input contacts (LD, LDI) should be replaced by a NOP instruction carefully, because the logical
structure of the program is changed considerably.
5 – 70
Miscellaneous instructions NOP, NOPLF, PAGE n
Program NOPLF
Example 4
The following program example shows the results of a NOPLF instruction.
X0
0 MOV K1 D30
MOV K2 D40
8 END
Printing an instruction list with the NOPLF instruction will result in the following:
0 LD X0
1 MOV K1 D30
3 MOV K2 D40
6 LD X1
7 OUT Y40
8 END
Program PAGE n
Example 5
NOP
5 – 72
6 Application Instructions, Part 1
The application instructions, part 1 comprise instructions that process numerical 16-bit and
32-bit data, floating point data, and character string data. Commonly, these basic instructions
perform comparison and arithmetic operations.
Instruction Meaning
Comparison operation instruction Compares data to data (e.g. =, >, ≥)
Arithmetic operation instruction Adds, subtracts, multiplies, divides, increments, and
decrements BIN and BCD data, floating point data, and
BIN block data
Links character strings
Data conversion instruction Converts data types (e.g. BCD → BIN, BIN → BCD)
Data transfer instruction Transmits designated data
Program branch instruction Program jump commands
Program execution control instruction Enables and disables program interrupts
Refresh instruction Refreshes bit devices, links, and I/O interfaces
Other convenient instructions Count 1- or 2-phase input up or down,
teaching timer, special function timer,
rotary table near path rotation control, ramp signal,
pulse density measurement, fixed cycle pulse output,
pulse width modulation, matrix input
Comparison operation instructions compare data values (e.g. equal to =, greater than >, less
than <). Programming the comparison operation instructions is similar to the corresponding
basic instructions:
LD, LDI ⇒ LD=, LDD=
AND, ANI ⇒ AND=, ANDD=
OR, ORI ⇒ OR=, ORD=
= LDED= ≤ LDED<=
ANDED= ANDED<=
equal less equal
ORED= ORED<=
6–2
Comparison operation instructions
≠ LDED<>
< LDED<
ANDED<> ANDED<
not equal less than
ORED<> ORED<
LD_STRING LD_STRING
LD$<> _NE_M LD$< _LT_M
AND_STRING AND_STRING
AND$<> AND$<
_NE_M _LT_M
> LDED>
≥ LDED>=
ANDED> ANDED>=
greater greater equal
ORED> ORED>=
LD_STRING LD_STRING
LD$> LD$>=
_GT_M _GE_M
NOTE Within the IEC editors please use the IEC commands.
IEC Commands
Function IEC Command Meaning
= EQ Equal
<> NE Not equal
<= LE Less equal
< LT Less than
>= GE Greater equal
> GT Greater than
Execution Conditions
The following illustration shows the execution conditions for the various comparison operation
instructions.
= 1 = ON
= 0 = OFF
LDORI0B1
NOTE When s1 and s2 are assigned by a hexadecimal constant and the numerical value (8 to F) whose
most significant bit (b15) is "1" is designated as a constant, the value is considered as a negative
BIN value in comparison operation.
The result of the comparison operation 16#8000 > 16#7999 is FALSE (0), although TRUE (1)
would be expected. The values are converted to BIN data and therefore bit 15 (b15) is set. If bit
15 is set, the value becomes negative.
EINLAB1
8731H is processed as -30927 and 568H as 1384. The comparison operation then is
-30927 > 1384 and Y10 is not set.
6–4
Comparison operation instructions
NOTE For comparison operation instructions with 32-bit data, the numerical input value has to be
determined by a 32-bit instruction like DMOV. The instruction will not be carried out correctly, if
the value was determined by a 16-bit instruction like MOV, because a 32-bit instruction always
applies the n and (n+1) data value.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
V
_
___ME1, V____KE1, V____IE1
GX Works2
VVVV__
6–6
Comparison operation instructions =, < >, >, < =, <, > =
NOTE When s1 and s2 are assigned by a hexadecimal constant and the numerical value (8 to F) whose
most significant bit (b15) is "1" is designated as a constant, the value is considered as a negative
BIN value in comparison operation.
6–8
Comparison operation instructions D=, D<>, D>, D<=, D<, D>=
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn K, H (16#) Other
Bit Word Bit Word U\G
s1 —
s2 —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
D
_
___ME1, D____KE1, D____IE1
GX Works2
D___KE1
NOTE When s1 and s2 are assigned by a hexadecimal constant and the numerical value (8 to F) whose
most significant bit (b15) is "1" is designated as a constant, the value is considered as a negative
BIN value in comparison operation.
6 – 10
Comparison operation instructions D=, D<>, D>, D<=, D<, D>=
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn E Other
Bit Word Bit Word U\G
s1 — — 1) —
1)
s2 — — —
1
Available only in multiple Universal model QCPU and LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
E
_
___ME1, E____KE1, E____IE1
GX Works2
E___KE1
6 – 12
Comparison operation instructions E=, E<>, E>, E< =, E<, E>=
NOTE In some cases, rounding errors appear and floating point values that were equal before the com-
parison operation are not equal afterwards. In the following example M0 is not switched ON:
E___
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the designated device is –0. (For the Basic model QCPU, High Performance
model QCPU, Process CPU, Redundant CPU) (Error code 4100)
NOTE: There are CPU modules that will not result in an operation error if –0 is specified.
Refer to section 3.5.1 for details.
● The value of the specified device is outside the following range:
0, ±2–126 ≤ (Value) < ±2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ± ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
6 – 14
Comparison operation instructions E=, E<>, E>, E< =, E<, E>=
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Other
Register Module Zn E
Bit Word Bit Word U\G
s1 — — — — — —
s2 — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ED /ED /ED /E /E /E
LD s1 s2
AND s1 s2
OR
s1 s2
E___KE1
6 – 16
Comparison operation instructions ED=, ED<>, ED>, ED< =, ED<, ED>=
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the specified device is not within the following range:
0, ±2 -1022 ≤ (Value of specified device) < ±21024
(Error code 4140)
● The value of the designated device is –0.
(Error code 4140)
6 – 18
Comparison operation instructions ED=, ED<>, ED>, ED< =, ED<, ED>=
NOTE Since the number of digits of the real number that can be input by a programing tool is up to 15
digits, the comparison with the real number whose number of significant digits is 16 or more can-
not be made by the instruction shown in this section.
When judging match/mismatch with the real number whose significant digits is 16 or more by the
instruction in this section, compare it with the approximate values of the real number to be com-
pared and judge by the sizes.
EXAMPLE 1 When judging the match of E1.234567890123456+10 (number of significant digits is 16) and the
double-precision floating-point data:
EXAMPLE 2 When judging the mismatch of E1.234567890123456+10 (Number of significant digits is 16)
and the double-precision floating-point data:
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn $ Other
Bit Word Bit Word U\G
s1 — — — — — —
s2 — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
S___KE1
6 – 20
Comparison operation instructions $ =, $ < >, $ >, $ < =, $ <, $ > =
SSSS_0E1
If the character strings are different, the character string with the larger character code will be
the larger one.
Below, the comparison result for the operations $<>, $>, $>= is 1.
SSSS_0E2
If the character strings are different, the first different sized character code determines whether
the character string is larger or smaller.
Below, the comparison result for the operations $<>, $>, $>= is 1.
SSSS_0E3
If the character strings are of different lengths, the data with the longer character string will be
larger.
Below, the comparison result for the operations $<>, $>, $>=, is 1.
SSSS_0E4
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The code "00H" does not exist within the relevant device range of s1 and s2.
(Error code 4101)
● The character string of s1 and s2 exceeds 16383 characters.
(Error code 4101)
NOTE The character string data comparison instruction also checks the device range.
Even though, in cases where one character string exceeds the device range, character string
data is being compared and non-matching characters within the device range are detected. The
comparison operation results are output without returning an error code.
S____AB1, SSSS_0E5
In the example shown above, the s1 character string exceeds the device range, and the most sig-
nificant 16 bits (D12288) were renamed W0. Nevertheless, the comparison result is 0, because
the second character in s1 is detected as different from that in s2. In this case no error code
regarding the device range is returned.
This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 22
Comparison operation instructions $ =, $ < >, $ >, $ < =, $ <, $ > =
Ladder Diagram
Ladder Diagram
Ladder Diagram
Ladder diagram
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 24
Comparison operation instructions BKCMP, BKCMPP
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn K, H (16#) Other
Bit Word Bit Word U\G
s1 — — — — — —
s2 — — — — — — —
d — — — — — —
n —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKCMPGE1
BKCMP0E1
BKCMP0E2
The results of the comparison operations for the individual instructions are as follows:
If all comparison results stored in d are 1, the block comparison signal SM704 is set.
If the device designated by d is already set (1), that device will not change. If the conditions
designated by s1 and s2 are changed and the BKCMP_P instruction is executed, the device
designated by d should be reset (0) before.
6 – 26
Comparison operation instructions BKCMP, BKCMPP
Operation In following case an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The BIN block data at s1, s2, or d exceeds the relevant device range.
(Error code 4101)
● The device range from [s1 to (s1) + (n-1)] overlaps with the device range [d to (d) + (n-1)].
(Error code 4101)
● The device range from [s2 to (s2) + (n-1)] overlaps with the device range [d to (d) + (n-1)].
(Error code 4101)
● The device range from [s1 to (s1) + (n-1)] overlaps with the device range [s2 to (s2) + (n-1)].
(Error code 4101)
1
Bits already in this state do not change (see function).
BKCMPMB2, BKCMPKB2, BKCMPIB2, BKCMP0B2
6 – 28
Comparison operation instructions BKCMP, BKCMPP
Ladder Diagram
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn K, H (16#) Other
Bit Word Bit Word U\G
s1 — — — — — —
s2 — — — — — — —
d — — — — — — —
n — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
=, <>, >, <=, <, >=
DBKCMP DBKCMP s1 s2 d n
DBKCMP P DBKCMP P s1 s2 d n
6 – 30
Comparison operation instructions DBKCMP, DBKCMPP
b31 b0 b31 b0
(s1)+1, (s1) 1090 (BIN) (s2)+1, (s2) 1000 (BIN) (d) OFF (0)
(s1)+3, (s1)+2 2080 (BIN) (s2)+3, (s2)+2 2000 (BIN) (d)+1 OFF (0)
(s1)+5, (s1)+4 5060 (BIN) n (s2)+5, (s2)+4 5060 (BIN) n (d)+2 ON (1) n
(s1)+n–1, (s1)+n–2 1106 (BIN) (s2)+n–1, (s2)+n–2 1106 (BIN) (d)+n–1 ON (1)
b31 b0
(s2)+1, s2 32700 (BIN) d ON (1)
b31 b0 (s2)+3, (s2)+2 40000 (BIN) d +1 OFF (0)
(s1)+1, s1 32800 (BIN) (s2)+5, (s2)+4 32800 (BIN) n d +2 ON (1) n
The results of the comparison operations for the individual instructions are as follows:
Comparison operation results for nth 32-bit Block
Instruction Symbol
1 0
DBKCMP= s1 = s2 s1 ≠ s2
DBKCMP<> s1 ≠ s2 s1 = s2
DBKCMP> s1 > s2 s1 ≤ s2
DBKCMP<= s1 ≤ s2 s1 > s2
DBKCMP< s1 < s2 s1 ≥ s2
DBKCMP>= s1 ≥ s2 s1 < s2
If all comparison results stored into the devices starting from the device specified by d to nth
device are ON (1), or one of the results is OFF (0), the special relays will be ON or OFF in
accordance with the conditions as follows.
All results of comparison operation are on (1) All results of comparison operation are off (0)
Interrupt Interrupt
Relay (other than (other than
Initial executi- Initial executi-
on/scan I45)/ Interrupt (I45) on/scan I45)/ Interrupt (I45)
Fixed scan Fixed scan
execution execution
SM704 ON ON ON OFF OFF OFF
SM716 ON — — OFF — —
SM717 — ON — — OFF —
SM718 — — ON — — OFF
In a standby program, a special relay depending on the caller program turns on or off.
If the value specified by n is 0, the instruction will be not processed.
Operation In following case an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● A negative value is specified for n.
(Error code 4100)
● The BIN block data at s1, s2, or d exceeds the relevant device range.
(Error code 4101)
● The device range of the n-point devices starting from the device specified by s1 overlaps
with the range of the n-point devices starting from the device specified by d.
(Error code 4101)
● The device range of the n-point devices starting from the device specified by s2 overlaps
with the range of the n-point devices starting from the device specified by d.
(Error code 4101)
b31 b0 b31 b0
R1,R0 -2147483000 D21,D20 -2147483000 Y0 OFF (0)
R3,R2 0 D23,D22 1 Y1 ON (1)
R5,R4 2147483000 D25,D24 2147482999 Y2 ON (1)
6 – 32
Comparison operation instructions DBKCMP, DBKCMPP
b31 b0
D1,D0 -70000 D10.5 ON (1)
b31 b0 D3,D2 50000 D10.6 OFF (0)
-60000 D5,D4 -32768 D10.7 OFF (0)
D7,D6 32767 D10.8 OFF (0)
D9,D8 0 D10.9 OFF (0)
NOTE When certain bits are specified in a word device, bits other than the certain bits that store the
operation result do not change.
D10.F D10.0
Before execution 0 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0
D10.F D10.0
After execution
0 0 1 0 1 1 0 0 0 0 1 1 1 0 0 0
No change No change
b31 b0 b31 b0
D1,D0 -2147483000 D11,D10 -2147483000 M20 ON (1)
D3,D2 60000 D13,D12 60001 M21 ON (1)
D5,D4 -900000 D15,D14 -899999 M22 ON (1)
When all operation results are on (1), the special relays (1)
SM704 ON
corresponding to each program turn on (1).
(Since this program examples refer to scan programs, SM716 ON (1)
SM704 and SM716 turn on (1), SM717 and SM718 do SM717 OFF (0)
not change in the scan program)
SM718 OFF (0)
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 34
Arithmetic operation Instructions
+
PLUSP_M, BPLUSP_M,
+P B+P
PLUSP_3_M BPLUSP_3_M
Addition D+ DPLUS_M, DB+ DBPLUS_M,
DPLUS_3_M DBPLUS_3_M
DPLUSP_M, DBPLUSP_M,
D+P DB+P
DPLUSP_3_M DBPLUSP_3_M
- MINUS_M, B- BMINUS_M,
MINUS_3_M BMINUS_3_M
−
MINUSP_M, BMINUSP_M,
-P MINUSP_3_M B-P BMINUSP_3_M
Subtraction DMINUS_M, DBMINUS_M,
D- DB-
DMINUS_3_M DBMINUS_3_M
NOTE Within the IEC editors please use the IEC commands.
+ E+P
EPLUSP_M,
BK+P BKPLUSP_M
EPLUSP_3_M
Addition
ED+ DBK+
ED+P DBK+P
− E-P
EMINUSP_M,
BK-P BKMINUSP_M
EMINUSP_3_M
Subtraction
ED- DBK-
ED-P DBK-P
E× EMUL_M
× E×P EMULP_M
Multiplication EDx
EDxP
E/ EDIV_M
/ E/P EDIVP_M
Division ED/
ED/P
+
STRING_PLUS_M,
$+
STRING_PLUS_3_M
Addition $+P STRING_PLUSP_M,
STRING_PLUSP_3_M
NOTE Within the IEC editors please use the IEC commands.
6 – 36
Arithmetic operation Instructions
1 Carry ignored
BCD_0E1
If the result of the subtraction falls below 0000 (underflow), the carry is processed as shown:
2
Carry
BCD_0E2
6.2.1 +, +P, -, -P
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant Other
Register Module Zn K, H (16#)
Bit Word Bit Word U\G
s —
d — —
s1 —
s2 —
d1 — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
PLUS_GE1
6 – 38
Arithmetic operation Instructions +, +P, -, -P
PLUSP0E1
● Varation 2:
BIN 16-bit data in s1 is added to BIN 16-bit data in s2. The result of the addition is stored in d1.
PLUSP0E2
BIN 16-bit data designated by s, d, s1, s2, and d1 have to range within -32768 and 32767.
The most significant bit (b15) determines, whether data in s, d, s1, or d1 are positive (bit = 0)
or negative (bit = 1).
If the least significant bit (b0) is fallen below or the most significant bit (b15) is exceeded, the
carry flag is not set.
MINUP0E1
● Variation 2:
BIN 16-bit data in s2 is subtracted from BIN 16-bit data in s1. The result is stored in d1.
MINUP0E2
BIN 16-bit data designated by s, d, s1, s2, and d1 have to range within -32768 and 32767.
The most significant bit (b15) determines, whether data in s, d, s1, or d1 are positive (bit = 0)
or negative (bit = 1).
If the least significant bit (b0) is fallen below or the most significant bit (b15) is exceeded, the
carry flag is not set.
6 – 40
Arithmetic operation Instructions +, +P, -, -P
Program +P
Example 1
WIth leading edge from X5, the following program adds data in D3 to data in D0. The result is
stored from Y38 to Y3F.
Program -
Example 2
The following program outputs the difference between the nominal and the actual value of timer
T3 to Y40 through Y53 in BCD.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn K, H (16#) Other
Bit Word Bit Word U\G
s —
d — —
s1 —
s2 —
d1 — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
D
P
DPLUSME1, DPLUSKE1, DPLUSIE1
GX Works2
DPLUSGE1
6 – 42
Arithmetic operation Instructions D+, D+P, D-, D-P
DPLUS0E1
● Variation 2:
BIN 32-bit data in s1 is added to BIN 32-bit data in s2. The result of the addition is stored in d1.
DPLUS0E2
BIN 32-bit data designated by s, d, s1, s2, and d1 have to range within -2147483648 and
2147483647.
The most significant bit (b31) determines, whether data in s, d, s1, or d1 are positive (bit = 0)
or negative (bit = 1).
If the least significant bit (b0) is fallen below or the most significant bit (b31) is exceeded, the
carry flag is not set.
DMINU0E1
● Variation 2:
BIN 32-bit data in s2 is subtracted from BIN 32-bit data in s1. The result is stored in d1.
DMINU0E2
BIN 32-bit data designated by s, d, s1, s2, and d1 have to range within -2147483648 and
2147483647.
The most significant bit (b31) determines, whether data in s, d, s1, or d1 are positive (bit = 0)
or negative (bit = 1).
If the least significant bit (b0) is fallen below or the most significant bit (b31) is exceeded, the
carry flag is not set.
Program D+P
Example 1
With leading edge from X0, the following program adds data in X10 through X2B to D9 and
D10. The result is stored in Y30 through Y4B.
Program D-P
Example 2
With leading edge from XB, the following program subtracts data in M0 through M23 from data
in D0 and D1. The result is stored in D10 and D11.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 44
Arithmetic operation Instructions x, xP, /, /P
6.2.3 x, xP, /, /P
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) Direct J\ Function
File Module Index Register Constant Other
Register Zn K, H (16#)
Bit Word Bit Word Index Register
U\G
s1 —
s2 —
d1 — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MULTIGE1
XXPP0E1
If the result in d1 is a bit device, designation is made from the lower bits.
Example:
K1: lower 4 bits (b0 to b3)
K4: lower 16 bits (b0 to b15)
K8: 32 bits (b0 to b31)
BIN 16-bit data designated by s1 and s2 have to range within -32768 and 32767.
The most significant bit (b15 or b31) in d1 determines, whether data in s1, s2 or d1 are positive
(bit = 0) or negative (bit = 1).
XXPP0E2
If a word device is used, the result of the operation is stored as 32-bits, and both, the quotient
and remainder are stored. The quotient is stored in the least significant 16-bits. The remainder
is stored in the most significant 16-bits.
If a bit device is used, 16-bits are used and only the quotient is stored.
BIN 16-bit data designated by s1 and s2 have to range within -32768 and 32767.
The most signigicant bit (b15) in d1 determines, whether data in s1, s2, d1 or (d1)+1 is positive
(bit = 0) or negative (bit = 1).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Division by 0 (Error code 4100)
6 – 46
Arithmetic operation Instructions x, xP, /, /P
Program xP
Example 1
With leading edge from X5, the following program multiplies 5678 and 1234. The result is
stored in D3 and D4.
Program x
Example 2
The following program multiplies BIN data at X8 through XF and BIN data at X10 through X1B.
The result is output at Y30 through Y3F.
Program /P
Example 3
With leading edge from X3, the following program divides data at X8 through XF by 3.14. The
result is output at Y30 through Y3F.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 48
Arithmetic operation Instructions Dx, DxP, D/, D/P
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) Direct J\ Function Index
File ModuleSpecia RegisterIndex ConstantConst
ant Other
Register l Function Register K, H (16#)
Bit Word Bit Word Module Zn
U\G
s1 —
s2 —
d1 — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
D
M
DMULTME1, DMULTKE1, DMULTIE1
GX Works2
DMULTGE1
DXP_0E1
If the result in d1 is a bit device, designation is made from the lower bits.
Example:
K1: lower 4 bits (b0 to b3)
K4: lower 16 bits (b0 to b15)
K8: 32 bits (b0 to b31)
If the upper 32 bits of the bit device are required for the result of the multiplication operation,
first temporarily store the data in a word device, then transfer the word device data to the bit
device designated by (d1)+2 and (d1)+3.
BIN 32-bit data designated by s1 and s2 has to range within -2147483648 and 2147483647.
The most significant bit (b31 or b63) in d1 determines, whether data in s1, s2 or d1 is positive
(bit = 0) or negative (bit = 1).
DXP_0E2
If a word device is used, the result of the division operation is stored as array of DINT (64-bit),
and both the quotient and remainder are stored. The quotient is stored in the lower array ele-
ments (32-bit). The remainder is stored in the upper array elements (32-bit).
If a bit device is used, 32 bits are used and only the quotient is stored.
BIN 32-bit data designated by s1 and s2 has to range within -2147483648 and 2147483647.
The most significant bit (b31) in d1 determines, whether data in s1, s2, d1 or (d1)+2 is positive
(bit = 0) or negative (bit = 1).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Division by 0 (Error code 4100)
6 – 50
Arithmetic operation Instructions Dx, DxP, D/, D/P
Program DxP
Example 1
With leading edge from X5, the following program multiplies BIN data in D7 and D8 with BIN
data in D18 and D19. The result is stored in D1 through D4.
Program xP
Example 2
With leading edge from X3, the following program multiplies data at X8 through XF and 3.14.
The result is output at Y30 through Y3F.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
6 – 52
Arithmetic operation Instructions B+, B+P, B-, B-P
BBP_0E1
● Variation 2:
BCD 4-digit data in s1 is added to BCD 4-digit data in s2. The result is stored in d1.
BBP_0E2
BCD 4-digit data designated by s, d, s1, s2, and d1 have to range within 0 and 9999. Undesig-
nated digits are read as 0 (e.g. 12 = 0012).
If the result of the addition exceeds 9999, the higher bits are ignored (overflow). The carry flag
in this case is not set.
BBP_0E3
1
Undesignated digits are read as 0.
BBP_0E4
● Variation 2:
BCD 4-digit data in s2 is subtracted from BCD 4-digit data in s1. The result is stored in d1.
BBP_0E6
In the further course of a program, make sure that either positive or negative results are treated
adequately.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The BCD 4-digit data designated by s, d, s1, s2, or d1 exceed the relevant device range of
0 to 9999. (Error code 4100)
6 – 54
Arithmetic operation Instructions B+, B+P, B-, B-P
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
G
E
1
6 – 56
Arithmetic operation Instructions DB+, DB+P, DB-, DB-P
1
Undesignated digits are read as 0.
DBP_0E1
● Variation 2:
BCD 8-digit data in s1 is added to BCD 8-digit data in s2. The result is stored in d1.
BCD 8-digit data designated by s, d, s1, and d1 have to range within 0 and 99999999. Undesig-
nated digits are read as 0 (e.g. 12345 = 00012345).
If the result of the addition exceeds 99999999, the higher bits are ignored (overflow). The carry
flag in this case is not set.
DBP_0E3
1
Undesignated digits are read as 0
DBP_0E4
● Variation 2:
BCD 8-digit data in s2 is subtracted from BCD 8-digit data in s1. The result is stored in d1.
1
Undesignated digits are read as 0
DBP_0E5
BCD 8-digit data designated by s, d, s1, and d1 have to range within 0 and 99999999. Undesig-
nated digits are read as 0 (e.g. 12345 = 00012345).
If the result of the subtraction operation is negative, the minuend is reduced by the number of
steps determined by the subtrahend. The carry flag in this case is not set.
DBP_0E6
In the further course of a program, make sure that either positive or negative results are treated
adequately.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The BCD 8-digit data designated by s, d, s1, s2, or d1 exceed the relevant device range of
0 to 99999999. (Error code 4100)
6 – 58
Arithmetic operation Instructions DB+, DB+P, DB-, DB-P
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BMULTGE1
6 – 60
Arithmetic operation Instructions Bx, BxP, B/, B/P
BXP_0E1
BCD 4-digit data designated by s1 and s2 have to range within 0 and 9999.
BXP_0E2
The result of the division is stored in two 16-bit WORD arrays. The lower array stores the quo-
tient (BCD 4-digit) and the upper array stores the remainder (BCD 4-digit).
If d is a bit device, the remainder of the division is not stored.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The s1 or s2 BCD data is outside the 0 to 9999 range. (Error code 4101)
● Division by 0 (Error code 4100)
Program BxP
Example 1
With leading edge from XB, the following program multiplies BCD data at X0 through XF with
BCD data in D8. The result is stored in D0 and D1.
1
Multiplicand
2 Multiplier
3 Result of multiplication
Program B/P
Example 2
The following program divides BCD data 5678 by BCD data 1234. The result is stored in D502
and the remainder is stored in D503. The last program step outputs the quotient in D502 at Y30
through Y3F.
1 Dividend
2
Divisor
3 Quotient
4 Remainder
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 62
Arithmetic operation Instructions DBx, DBxP, DB/, DB/P
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
D
B
MULME1, DBMULKE1, DBMULIE1
GX Works2
DBMULGE1
DBXP_0E1
If the result in d1 is a bit device, designation is made from the lower bits.
Example:
K1: lower 4 bits (b0 to b3)
K4: lower 16 bits (b0 to b15)
K8: 32 bits (b0 to b31)
BCD 8-digit data designated by s1 and s2 have to range within 0 and 99999999. Undesignated
digits are read as 0 (e.g. 12345 = 00012345).
DBXP_0E2
The result of the division is stored in two 32-bit WORD arrays. The lower array stores the quo-
tient (BCD 8-digit) and the upper array stores the remainder (BCD 8-digit).
If d is a bit device, the remainder of the division is not stored.
6 – 64
Arithmetic operation Instructions DBx, DBxP, DB/, DB/P
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The s1 or s2 BCD data is outside the 0 to 99999999 range. (Error code 4101)
● Division by 0 (Error code 4100)
Program DBxP
Example 1
The following program multiplies BCD data 68347125 with BCD data 576682. The result is
stored in D502 through D505. The following program step outputs the upper eight digits (D504,
D505) at Y30 through Y4F.
Ladder Diagram
Program DB/P
Example 2
With leading edge from XB, the following program divides BCD data at X20 through X3F by
BCD data in D8 and D9. The result is stored in D765 through D768.
1
Dividend
2 Divisor
3
Quotient
4 Remainder
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 66
Arithmetic operation Instructions E+, E+P, E-, E-P
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EPLUSGE1
NOTE Within the IEC editors please use the IEC commands.
Functions Floating point data addition and subtraction operations (single precision)
E+ 32-bit floating point data addition
● Variation 1:
Floating point data in d is added to floating point data in s. The result is stored in d.
1
32-bit floating point data, data type real number
EP_0E1
● Variation 2:
Floating point data in s1 is added to floating point data in s2. The result is stored in d1.
Floating point data designated by s, d, s1, s2, and d1 have to range within:
0, ±2-126 ≤ (s, d, s1, s2, d1) < ±2128
1
32-bit floating point data, data type real number
EP_0E2
6 – 68
Arithmetic operation Instructions E+, E+P, E-, E-P
● Variation 2:
Floating point data in s2 is subtracted from floating point data in s1. The result is stored in d1.
Floating point data designated by s, d, s1, s2, and d1 have to range within:
0, ±2-126 ≤ (s, d, s1, s2, d1) < ±2128
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the addition are not zero and not within
the following range (Error code 4100):
±2-126 ≤ (Contents of designated device) < ±2128
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
● The value of the designated device is –0.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU) (Error code 4100)
NOTE: There are CPU modules that will not result in an operation error if –0 is specified.
Refer to section 3.5.1 for details.
● The result of addition and subtraction exceeds the following range (overflow occurs):
(For the Universal model QCPU, LCPU)
–2128 ≤ (Result of addition and subtraction) ≤ 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ± ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
6 – 70
Arithmetic operation Instructions E+, E+P, E-, E-P
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ED+/ED-
s d
E
P
P s d
L
U
S
G
E
1
ED+/ED-
s1 s2 d
P s1 s2 d
NOTE Within the IEC editors please use the IEC commands.
6 – 72
Arithmetic operation Instructions ED+, ED+P, ED-, ED-P
Functions Floating point data addition and subtraction operations (double precision)
ED+ 64-bit floating point data addition
● Variation 1:
Floating point data in d is added to floating point data in s. The result is stored in d.
d +3 d +2 d +1 d s +3 s +2 s +1 s d +3 d +2 d +1 d
1 1 1
1
64-bit floating point data, data type real number
EP_0E1
● Variation 2:
64-bit floating point data in s1 is added to floating point data in s2. The result is stored in d1.
1 1 1
1
64-bit floating point data, data type real number
EP_0E3
Floating point data designated by s, d, s1, s2, and d1 have to range within:
0, ±2-1022 ≤ (s, d, s1, s2, d1) < ±21024
d +3 d +2 d +1 d s +3 s +2 s +1 s d +3 d +2 d +1 d
–
1 1 1
1
64-bit floating point data, data type real number
● Variation 2: EP_0E2
Floating point data in s2 is subtracted from floating point data in s1. The result is stored in d1.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the addition are not zero and not within
the following range:
±2-1022 ≤ (Contents of designated device) < ±21024
(Error code 4140)
● The value of the designated device is –0.
(Error code 4140)
● The result of addition and subtraction exceeds the following range (overflow occurs):
–21024 ≤ (Result of addition and subtraction) ≤ 21024
(Error code 4141)
6 – 74
Arithmetic operation Instructions ED+, ED+P, ED-, ED-P
D23 D22 D21 D20 D13 D12 D11 D10 D23 D22 D21 D20
97365.203 76059.797 21305.406
D13 D12 D11 D10 D23 D22 D21 D20 D33 D32 D31 D30
97365.203 76059.797 21305.406
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 76
Arithmetic operation Instructions Ex, ExP, E/, E/P
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EMULTGE1
Functions Floating point data multiplication and division operations (single precision)
Ex 32-bit floating point data multiplication
Floating point data in s1 is multiplied with floating point data in s2. The result is stored in d1.
1
32-bit floating point data, data type real number
EXP_0E1
Floating point data designated by s1, s2, and d1 have to range within:
0, ±2-126 ≤ (s1, s2, d1) < ±2128
1
32-bit floating point data, data type real number
EXP_0E2
Floating point data designated by s1, s2, and d1 have to range within:
0, ±2-126 ≤ (s1, s2, d1) < ±2128
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the operation is not zero and not within
the following range:
±2-126 ≤ (Contents of designated device or operation result) < ±2128
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU) (Error code 4100)
● The value of the specified device is –0.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU) (Error code 4100)
NOTE: There are CPU modules that will not result in an operation error if –0 is specified.
Refer to page 3-17 for details.
● Division by 0 (Error code 4100)
● The result of multiplication and division exceeds the following range (overflow occurs):
(For the Universal model QCPU, LCPU)
–2128 ≤ (Result of multiplication and division) ≤ 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ± ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
6 – 78
Arithmetic operation Instructions Ex, ExP, E/, E/P
Program ExP
Example 1
With leading edge from X20, the following program multiplies floating point data in D3 and D4
with floating point data in D10 and D11. The result is stored in R0 and R1.
Program E/P
Example 2
The following program divides floating point data in D10 an D11 by floating point data in D20
and D21. The result is stored in D30 and D31.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ED*, ED/
s1 s2 d
E
M
U P s1 s2 d
L
T
G
E
1
NOTE Within the IEC editors please use the IEC commands.
6 – 80
Arithmetic operation Instructions EDx, EDxP, ED/, ED/P
Functions Floating point data multiplication and division operations (double precision)
EDx 64-bit floating point data multiplication
Floating point data in s1 is multiplied with floating point data in s2. The result is stored in d1.
1
64-bit floating point data, data type real number
EXP_0E1
Floating point data designated by s1, s2, and d1 have to range within:
0, ±2-1022 ≤ (s1, s2, d1) < ±21024
1
64-bit floating point data, data type real number
EXP_0E2
Floating point data designated by s1, s2, and d1 have to range within:
0, ±2-1022 ≤ (s1, s2, d1) < ±21024
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the operation is not zero and not within
the following range:
±2-1022 ≤ (Contents of designated device or result of operation) < ±21024
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4140)
● The value of the designated device is –0.
(Error code 4140)
● Division by 0
(Error code 4100)
● The result of multiplication or division exceeds the following range. (The overflow occurs.)
(For the Universal model QCPU, LCPU)
–21024 ≤ (Result of multiplication or division) ≤ 21024
(Error code 4141)
Program EDxP
Example 1
With leading edge from X20, the following program multiplies 64-bit floating point data in D3 to
D6 with 64-bit floating point data in D10 to D13. The result is stored in R0 to R3.
Program ED/P
Example 2
The following program divides 64-bit floating point data in D10 to D13 by 64-bit floating point
data in D20 to D23. The result is stored in D30 to D33.
D13 D12 D11 D10 D23 D22 D21 D20 D33 D32 D31 D30
52171.39 9.73521 5359.041
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 82
Arithmetic operation Instructions BK+, BK+P, BK-, BK-P
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKPLUGE1
BKP_0E1
The addition operation is conducted in 16-bit units.
The constant designated by s2 must be BIN 16-bit data ranging from -32768 to 32767.
BKP_0E2
The most significant bit of each block determines, whether data in s1, s2 or d are positive
(bit = 0) or negative (bit = 1).
If the least significant bit of a block is fallen below or the most significant bit of a block is
exceeded, the carry flag is not set.
6 – 84
Arithmetic operation Instructions BK+, BK+P, BK-, BK-P
BKP_0E3
The subtraction operation is conducted in 16-bit units.
The constant designated by s2 must be BIN 16-bit data ranging from -32768 to 32767.
BKP_0E4
The most significant bit of each block determines, whether data in s1, s2 or d are positive
(bit = 0) or negative (bit = 1).
If the least significant bit of a block is fallen below or the most significant bit of a block is
exceeded, the carry flag is not set.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks in s1, s2 or d exceeds the relevant device range.
(Error code 4101)
● The device ranges of s1 and s2 overlap.
(Except when the same device is assigned to s1 and d)
(Error code: 4101)
● The device ranges of s2 and d overlap.
(Except when the same device is assigned to s2 and d)
(Error code: 4101)
Program BK+P
Example 1
With leading edge from X20, the following program adds BIN block data beginning from D100
to BIN block data beginning from R0. The result of the operation is stored beginning from D200.
The number of blocks (4) added is stored in D0.
Program BK-P
Example 2
With leading edge from X1C, the following program subtracts a constant 8765 from BIN block
data beginning from D100. The result of the operation is stored beginning from R0. The number
of data blocks (3) subtracted is designated by a constant K3.
6 – 86
Arithmetic operation Instructions DBK+, DBK+P, DBK-, DBK-P
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BK+, BK-
s1 s2 d n
B
K
P P s2 s2 d n
L
U
G
E
1
NOTE Within the IEC editors please use the IEC commands.
(s1)+n 1, (s1)+n 2 60000 (BIN) (s2)+n 1, (s2)+n 2 -20000 (BIN) d +n 1, d +n 2 40000 (BIN)
BKP_0E1
The addition operation is conducted in 32-bit units.
The constant designated by s1 must be BIN 32-bit data ranging from -2147483648 to
2147483647.
b31 b0 b31 b0
(s1) +1, s1 -30000 (BIN) d +1, d 20000 (BIN)
(s1) +3, (s1) +2 40000 (BIN) b31 b0 d +3, d +2 90000 (BIN)
(s1) +5, (s1) +4 -50000 (BIN) n + (s2)+1, s2 50000 (BIN) d +5, d +4 0 (BIN) n
BKP_0E2
If the value specified by n is 0, the instruction will be not processed.
The most significant bit of each block determines, whether data in s1, s2 or d are positive
(bit = 0) or negative (bit = 1).
If the least significant bit of a block is fallen below or the most significant bit of a block is
exceeded, the carry flag is not set.
6 – 88
Arithmetic operation Instructions DBK+, DBK+P, DBK-, DBK-P
(s1)+n 1, (s1)+n 2 13579 (BIN) (s2)+n 1, (s2)+n 2 12345 (BIN) d +n 1, d +n 2 1234 (BIN)
BKP_0E3
The subtraction operation is conducted in 32-bit units.
The constant designated by s2 must be BIN 32-bit data ranging from –2147483648 to
2147483647.
b31 b0 b31 b0
(s1) +1, s1 -99999 (BIN) d +1, d -109998 (BIN)
(s1) +3, (s1) +2 99999 (BIN) b31 b0 d +3, d +2 90000 (BIN)
(s1) +5, (s1) +4 -59999 (BIN) n (s2)+1, s2 9999 (BIN) d +5, d +4 69998 (BIN) n
BKP_0E4
If the value specified by n is 0, the instruction will be not processed.
The most significant bit of each block determines, whether data in s1, s2 or d are positive
(bit = 0) or negative (bit = 1).
If the least significant bit of a block is fallen below or the most significant bit of a block is
exceeded, the carry flag is not set.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● A negative value is specified for n. (Error code 4100)
● The range of the n-point devices starting from the device specified by s1, s2, or d exceeds
the specified device range.
(Error code: 4101)
● The range of the n-point devices starting from the device specified by s1 overlaps with the
range of the n-point devices starting from the device specified by d.
(Except when s1 and d specify the same device.)
(Error code: 4101)
● The range of the n-point devices starting from the device specified by s2 overlaps with the
range of the n-point devices starting from the device specified by d.
(Except when s2 and d specify the same device.)
(Error code: 4101)
Program DBK+P
Example 1
The following program adds the value data stored at R0 to R5 to the constant, and then stores
the operation result into D30 to D35, when M0 is turned on.
b31 b0 b31 b0
R1,R0 600000 D31,D30 723456
R3,R2 -800000 + 123456 D33,D32 -676544
R5,R4 -123456 D35,D34 0
Program DBK-P
Example 2
The following program subtracts the value data stored at D50 to D59 from the value data stored
at D100 to D109, and then stores the operation result into R100 to R109, when M0 is turned on.
6 – 90
Arithmetic operation Instructions $+, $+P
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SPLUSGE1
SSP_0E1
The code "00H" indicates the end of a character string. When two strings are linked, in the first
string this code is ignored and the "00H" of the second string marks the end of the linked string.
● Variation 2:
Character string data in s2 is appended to character string data in s1. The linked character
string is stored in d1.
The linked character string begins with the character at the least significant byte in s1 and ends
with the code "00H" in s2.
SSP_0E2
The code "00H" indicates the end of a character string. When two strings are linked, in the first
string this code is ignored and the "00H" of the second string marks the end of the linked string.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The linked character string cannot be stored.
(Error code 4100)
● The storage device numbers designated by s, d, s1, s2, and d1 overlap.
(Error code 4101)
● The character string of s, d, s1, s2, and d1 exceeds 16383 characters.
(Error code 4101)
6 – 92
Arithmetic operation Instructions $+, $+P
Program $+P
Example 1
With leading edge from X0, the following program links character string data in D10 through
D12 to the character string "ABCD". The linked character string is stored in D10 through D14.
1
"00H" indicates the end of character strings and is stored automatically.
SPLUSMB1, SPLUSKB1, SPLUSIB1, SSP_0B1
Program $+
Example 2
While X0 is set (1), the following program links character string data in D10 through D12 to a
character string "ABCD". The linked character string is stored from D101 through D104.
Ladder Diagram
1
"00H" indicates the end of character strings and is stored automatically.
SPLUSMB2, SPLUSKB2, SPLUSIB2, SSP_0B2
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
I
N
C__ME1, INC__KE1, INC__IE1
GX Works2
INC_GE1
6 – 94
Arithmetic operation Instructions INC, INCP, DEC, DECP
DEC_0E1
If the content of d is 32767, the result after incrementing is -32768.
DEC_0E2
If the content of d is 0, the result after decrementing is -1.
If the content of d is -32768, the result after decrementing is 32767.
Program INCP
Example 1
With leading edge from X8, the following program outputs the actual value of the counter (nom-
inal value = 9999) C0 through C20 (C0 plus Z1) at Y30 through Y3F as BCD data. Z1 is reset
(RST Z1), if Z1 is equal to 21 (LD = K21 Z1) or if the reset input X7 is set.
Program DECP
Example 2
The following example shows a down counter program. With leading edge from X7, this pro-
gram stores a value 100 in D8. While M38 is not set, data in D8 is decremented by 1 with lead-
ing edge from X8. At D8 = 0, M38 is set.
6 – 96
Arithmetic operation Instructions DINC, DINCP, DDEC, DDECP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DINC_GE1
DDEC0E1
If the content of d is 2147483647, the result after incrementing is -2147483648.
DDEC0E2
If the content of d is 0, the result after decrementing is -1.
If the content of d is -2147483647, the result after decrementing is 2147483647.
Program DINCP
Example 1
With leading edge from X0, the following program adds 1 to data in D0.
Program DINCP
Example 2
With leading edge from X0, the following program adds 1 to data at X10 through X27. The
result is stored in D3 and D4.
6 – 98
Arithmetic operation Instructions DINC, DINCP, DDEC, DDECP
Program DDECP
Example 3
With leading edge from X0, the following program subtracts 1 from data in D0.
Program DDECP
Example 4
With leading edge from X0, the following program subtracts 1 from data in X10 through X27.
The result is stored in D3 and D4.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 100
Data conversion instructions
GRY GRY_M
BIN (16-/32-bit) GRYP GRYP_M
⇓
GRAY CODE Data DGRY DGRY_M
DGRYP DGRYP_M
GBIN GBIN_M
GRAY CODE Data GBINP GBINP_M
⇓
BIN (16-/32-bit) DGBIN DGBIN_M
DGBINP DGBINP_M
6 – 102
Data conversion instructions BCD, BCDP, DBCD, DBCDP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BCD__GE1
BCD_0E3
DBCD Conversion from BIN 32-bit data into BCD 8-digit data
BIN data in s (0 to 99999999) is converted into BCD data. The result is stored in d. The most
significant five bits of BIN data in s must be reset (0) when converted to BCD 8-digit data.
DBCD0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● BIN 16-bit data in s exceeds the relevant device range of 0 to 9999.
(Error code 4100)
● BIN 32-bit data in s+1 or s exceed the relevant device range of 0 to 99999999.
(Error code 4100)
6 – 104
Data conversion instructions BCD, BCDP, DBCD, DBCDP
Program BCDP
Example
The following program outputs the current value in C4 (5678) to Y20 through Y2F. The output
module displays the value on the display unit.
1
Output power supply
2 Output module
BCD__MB1, BCD__KB1, BCD__IB1, BCD_0B1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BIN__GE1
6 – 106
Data conversion instructions BIN, BINP, DBIN, DBINP
BIN_0E1
DBIN Conversion from BCD 8-digit data into BIN 32-bit data
BCD data in s (0 to 99999999) is converted to BIN data. The result is stored in d.
The most significant five bits of BIN data in d must be reset (0) when converting from BCD
8-digit data.
BIN_0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The individual digits in s do not range within 0 to 9. (Error code 4100)
This error can be suppressed by turning SM722 ON. However, the instruction is not executed
regardless of the status of SM722 if the specified value in s is out of range.
For the BINP/DBINP instruction, the next operation will not be performed until the command
(execution condition) is turned from OFF to ON regardless of the presence/absence of an
error.
BIN_AB1, BIN_AB2
Program BINP
Example 1
The following program converts BCD data in X10 through X1B into BIN data. The result is
stored in D8.
1
Input power supply
2
Input module
3 Available inputs
6 – 108
Data conversion instructions BIN, BINP, DBIN, DBINP
Program DBINP
Example 2
With leading edge from X8, the following program converts BCD data at X10 through X37 into
BIN data. The result is stored in D0 through D1.
NOTE BCD data at X10 through X37 exceeding the relevant device range of 2147483647 cannot be
processed by 32-bit devices! In this case the values in D0 and D1 become negative. For further
datails see section 3.4 "Programming of variables" in the Programming Manual.
This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FLT__GE1
6 – 110
Data conversion instructions FLT, FLTP, DFLT, DFLTP
Functions Conversion from BIN 16-bit/32-bit data into floating point data (Single precision)
FLT Conversion from BIN 16-bit data into floating point data
BIN 16-bit data in s is converted into 32-bit floating point data. The result is stored in d.
BIN 16-bit data designated by s has to range within -32768 and 32767.
DFLT Conversion from BIN 32-bit data into floating point data
BIN 32-bit data in s is converted into 32-bit floating point data. The result is stored in d.
1
32-bit floating point data, data type real number
FLT_0E2
BIN 32-bit data designated by s and s+1 have to range within -2147483648 and 2147483647.
Due to the fact that floating point data (data type real number) is processed by simple 32-bit
procedures, the number of significant bits is 24 for a binary display, or approx. 7 digits for a dec-
imal display.
The result of the conversion is rounded off at the 25th bit. All higher bits are eliminated. For this
reason, if the resulting integer exceeds a range of -16777216 to 16777215 (BIN 24-bit value),
errors may occur in the conversion.
1 Rounded off
2 Eliminated
FLT_0E3
Program FLTP
Example 1
The following program converts BIN 16-bit data in D20 into 32-bit floating point data. The result
is stored in D0 and D1.
1
BIN 16-bit data
2
32-bit floating point data, data type real number
FLT__MB1, FLT__KB1, FLT__IB1, FLT_0B1
Program DFLTP
Example 2
The following program converts BIN 32-bit data in D20 and D21 into 32-bit floating point data.
The result is stored in D0 and D1.
NOTE These programs will not run without variable definition in the header of the program organization
unit (POU). They would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 112
Data conversion instructions FLTD, FLTPD, DFLTD, DFLTPD
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FLTD/DFLTD
s d
F
L
T
_
G
E
1
P s d
Functions Conversion from BIN 16-bit/32-bit data into floating point data (Double precision)
FLTD Conversion from BIN 16-bit data into floating point data
BIN 16-bit data in s is converted into 64-bit floating point data. The result is stored in d.
1
64-bit floating point data, data type real number
BIN 16-bit data designated by s has to range within -32768 and 32767.
DFLTD Conversion from BIN 32-bit data into floating point data
BIN 32-bit data in s is converted into 64-bit floating point data. The result is stored in d.
BIN 32-bit 1
1
64-bit floating point data, data type real number
FLT_0E2
FLT_0E3
Program FLTDP
Example 1
The following program converts BIN 16-bit data in D20 into 64-bit floating point data. The result
is stored in D0 to D3.
D20 D3 D2 D1 D0
15923 15923
1
BIN 16-bit data
2
64-bit floating point data, data type real number
FLT__MB1, FLT__KB1, FLT__IB1, FLT_0B1
6 – 114
Data conversion instructions FLTD, FLTPD, DFLTD, DFLTPD
Program DFLTDP
Example 2
The following program converts BIN 32-bit data in D20 and D21 into 64-bit floating point data.
The result is stored in D0 to D3.
D21 D20 D3 D2 D1 D0
16543521 16543521
1
BIN 32-bit data
2 64-bit floating point data, data type real number
FLT__MB2, FLT__KB2, FLT__IB2, FLT_0B2
NOTE These programs will not run without variable definition in the header of the program organiza-
tion unit (POU). They would cause compiler or checker error messages. For details see section
3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
INT__GE1
6 – 116
Data conversion instructions INT, INTP, DINT, DINTP
Functions Conversion from floating point data into BIN 16-bit/32-bit data (Single precision)
INT Conversion from 32-bit floating point data into BIN 16-bit data
32-bit floating point data in s is converted into BIN 16-bit data. The result is stored in d.
1
32-bit floating point data, data type real number
INT_0E1
Floating point data in s and s+1 have to range within -32768 and 32767.
The converted integer value is stored as BIN 16-bit data.
The converted integer value is rounded off at the first digit after the decimal point.
DINT Conversion from 32-bit floating point data into BIN 32-bit data
32-bit floating point data in s is converted to BIN 32-bit data. The result is stored in d.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the addition are not zero and not within
the following range:
2-126 ≤ (Contents of designated device) < 2128
(For the Universal model QCPU, LCPU) (Error code 4140)
● The value of the specified device is –0, unnormalized number, nonnumeric, and ∞.
(For the Universal model QCPU, LCPU) (Error code 4140)
● Performing an INT instruction, floating point data designated by s exceeds the relevant
device range of -32768 to 32767.
● Performing a DINT instruction, floating point data designated by s exceeds the relevant
device range of -2147483648 to 2147483647.
Program INTP
Example 1
The following program converts 32-bit floating point data in D20 and D21 into BIN 16-bit data.
The result is stored in D0.
1
32-bit floating point data, data type real number
2 BIN 16-bit data
3
No result. Value exceeds relevant device range of INT instruction. Error code is returned.
6 – 118
Data conversion instructions INT, INTP, DINT, DINTP
1
32-bit floating point data, data type real number
2
BIN 32-bit data
3 No result. Value exceeds relevant device range of DINT instruction. Error code is returned.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
INTD/DINTD
s d
IN
T
_
G
E
1
P s d
6 – 120
Data conversion instructions INTD, INTPD, DINTD, DINTPD
Functions Conversion from floating point data into BIN data (Double precision)
INTD Conversion from 64-bit floating point data into BIN 16-bit data
64-bit floating point data in s is converted into BIN 16-bit data. The result is stored in d.
1
64-bit floating point data, data type real number
INT_0E1
Floating point data in s+3, s+2, s+1 and s have to range within -32768 and 32767.
The converted integer value is stored as BIN 16-bit data.
The converted integer value is rounded off at the first digit after the decimal point.
DINTD Conversion from 64-bit floating point data into BIN 32-bit data
64-bit floating point data in s is converted to BIN 32-bit data. The result is stored in d.
1 BIN 32-bit
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the designated device is not zero and not within the following range:
2-1022 ≤ (Contents of designated device) < 21024
(Error code 4140)
● The value of the specified device is –0. (Error code 4140)
● Performing an INTD instruction, floating point data designated by s exceeds the relevant
device range of -32768 to 32767. (Error code 4100)
● Performing a DINTD instruction, floating point data designated by s exceeds the relevant
device range of -2147483648 to 2147483647. (Error code 4100)
Program INTDP
Example 1
The following program converts 64-bit floating point data in D20 to D23 into BIN 16-bit data.
The result is stored in D0.
1 2
D23 D22 D21 D20
33562.3211
1 3
1
64-bit floating point data, data type real number
2
BIN 16-bit data
3 No result. Value exceeds relevant device range of INTD instruction. Error code is returned.
Program DINTDP
Example 2
The following program converts 64-bit floating point data in D20 to D23 into BIN 32-bit data.
The result is stored in D0 and D1.
6 – 122
Data conversion instructions DBL, DBLP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DBL__GE1
Functions Conversion from BIN 16-bit data into BIN 32-bit data
DBL Conversion from BIN 16-bit data into BIN 32-bit data
BIN 16-bit data in s is converted into BIN 32-bit data with sign. The result is stored in d.
DBL_0E1
Program DBLP
Example
With leading edge from X20, the following program converts BIN 16-bit data in D100 into BIN
32-bit data. The result ist stored in R0 and R1.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 124
Data conversion instructions WORD, WORDP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
WORD_GE1
Functions Conversion from BIN 32-bit data into BIN 16-bit data
WORD Conversion from BIN 32-bit data into BIN 16-bit data
BIN 32-bit data in s is converted into BIN 16-bit data. The result is stored in d.
WORD0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The BIN data designated by s and s+1 exceed the relevant device range of -32768 to 32767.
(Error code 4100)
Program WORDP
Example
With leading edge from X20, the following program converts BIN 32-bit data in D100 and D101
into BIN 16-bit data. The result is stored in R0.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 126
Data conversion instructions GRY, GRYP, DGRY, DGRYP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
GRY__GE1
GRY_0E1
DGRY Conversion from BIN 32-bit data into Gray code data
BIN 32-bit data in s is converted into Gray code data. The result is stored in d.
GRY_0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Data in s is negative. (Error code 4100)
6 – 128
Data conversion instructions GRY, GRYP, DGRY, DGRYP
Program GRYP
Example 1
With leading edge from X10, the following program converts BIN 16-bit data in D100 into Gray
code data. The result is stored in D200.
Program DGRYP
Example 2
With leading edge from X1C, the following program converts BIN 32-bit data in D10 and D11
into Gray code data. The result is stored in D100 and D101.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
GBIN_GE1
6 – 130
Data conversion instructions GBIN, GBINP, DGBIN, DGBINP
GBIN0E1
DGBIN Conversion from Gray code data into BIN 32-bit data
Gray code data in s is converted into BIN 32-bit data. The result is stored in d.
GBIN0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Performing a GBIN instruction, data in s exceeds the relevant device range of 0 to 32767.
(Error code 4100)
● Performing a DGBIN instruction, data in s exceeds the relevant device range of 0 to
2147483647. (Error code 4100)
Program GBINP
Example 1
With leading edge from X10, the following program converts Gray code data in D100 into BIN
16-bit data. The result is stored in D200.
Program DGBINP
Example 2
With leading edge from X1C, the following program converts Gray code data in D10 and D11
into BIN 32-bit data. The result is stored in D0 and D1.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 132
Data conversion instructions NEG, NEGP, DNEG, DNEGP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
NEG__GE1
1
Inversion with following addition
NEG_0E1
The function of this instruction is to change a negative sign into a positive one, or to change a
positive sign into a negative one.
6 – 134
Data conversion instructions NEG, NEGP, DNEG, DNEGP
Program NEGP
Example
With leading edge from XA, the following program subtracts data in D10 from data in D20. M3
is set, if D10 is less than D20. If M3 is set, the result in D10 is the absolute value (complement
of 2) and becomes positive.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The serial number (upper five digits) is "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ENEG_GE1
6 – 136
Data conversion instructions ENEG, ENEGP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the addition are not zero and not within
the following range:
2-126 ≤ (Contents of designated device) < 2128
(For the Universal model QCPU, LCPU) (Error code 4140)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU) (Error code 4140)
Program ENEGP
Example
With leading edge from X20, the following program negates floating point data in D100 and
D101. The result is stored in D100 and D101.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EDNEG d
4
EDNEGP d
E
N
E
G
_
G
E
1
6 – 138
Data conversion instructions EDNEG, EDNEGP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The contents of the designated device or the result of the addition are not zero and not within
the following range:
2-1022 ≤ (Contents of designated device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
Program EDNEGP
Example
With leading edge from X20, the following program negates 64-bit floating point data in D0 to
D3. The result is stored in D0 to D3.
D3 D2 D1 D0 D3 D2 D1 D0
1.2345
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKBCDGE1
6 – 140
Data conversion instructions BKBCD, BKBCDP
Functions Conversion from BIN block data into BCD block data
BKBCD Conversion from BIN 16-bit block data into BCD 4-digit block data
This instruction converts each nth BIN 16-bit block in s into the nth BCD 4-digit block. Con-
verted data is stored in d.
BIN 16-bit block data in s has to range within 0 and 9999.
The most significant two bits of the BIN 16-bit data blocks in s must be reset (0).
BKBCD0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s and d. (Error code 4101)
● BIN block data in s exceeds the relevant device range of 0 to 9999.
(Error code 4100)
● The storage device numbers designated by s and d overlap.
(Error code 4101)
For details on index qualification refer to section 3.6 of this manual.
Program BKBCDP
Example
With leading edge from X20, the following program converts BIN 16-bit block data in D100 into
BCD 4-digit block data. Converted data is stored in D200. The number of data blocks (3) con-
verted is stored in D0.
6 – 142
Data conversion instructions BKBIN, BKBINP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKBINGE1
Functions Conversion from BCD block data into BIN block data
BKBIN, BKBINP Conversion from BCD 4-digit block data into BIN 16-bit block data
This instruction converts each nth BCD 4-digit block in s into the nth BIN 16-bit block. Con-
verted data is stored in d.
BIN 16-bit block data in s has to range within 0 to 9999.
BKBIN0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s and d. (Error code 4101)
● BCD block data in s exceeds the relevant device range of 0 to 9999.
(Error code 4100)
● The storage device numbers designated by s and d overlap.
(Error code 4101)
For details on index qualification refer to section 3.6 of this manual.
6 – 144
Data conversion instructions BKBIN, BKBINP
Program BKBINP
Example
With leading edge from X20, the following program converts BCD 4-digit block data in D100
into BIN 16-bit block data. Converted data is stored in D200. The number of data blocks (3)
converted is stored in D0.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ECON s d
ECONP s d
B
K
B
IN
G
E
1
6 – 146
Data conversion instructions ECON, ECONP
S +1 S d +3 d +2 d +1 d
1 2
BKBIN0E1
1 32-bit floating-point real number
2
64-bit floating-point real number
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the designated device is not zero and not within the following range:
2-126 ≤ (Value of designated device) < 2128
(Error code 4140)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(Error code 4140)
Program ECON
Example
With leading edge from X0, the following program converts 32-bit floating-point real number of
the devices D10 to D11, into 64-bit floating-point real number. Converted data is stored to the
devices D0 to D3.
Ladder Diagram
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EDCON s d
EDCONP s d
B
K
B
IN
G
E
1
6 – 148
Data conversion instructions EDCON, EDCONP
1 2
BKBIN0E1
1
64-bit floating-point real number
2
32-bit floating-point real number
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the designated device is not zero and not within the following range:
2-1022 ≤ (Value of designated device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The conversion result is not within the following range:
–2128 ≤ (Conversion result) ≤ 2128
(Error code 4141)
Program EDCON
Example
With leading edge from X0, the following program converts 64-bit floating-point real number of
the devices D10 to D13, into 32-bit floating-point real number. Converted data is stored to the
devices D0 and D1.
Ladder Diagram
NOTE Transferred data remain stored until they are replaced. Therefore, data even remain stored if the
input condition of the transfer instruction is reset.
NOTE Within the IEC editors please use the IEC commands.
6 – 150
Data transfer instructions MOV, MOVP, DMOV, DMOVP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MOV__GE1
MOV_0E1
MOV_0E2
Program MOVP
Example 1
The following program transfers data at X0 through XB to D8.
Program MOVP
Example 2
With leading edge from X8, the following program transfers the constant 155 as BIN value to
D8.
6 – 152
Data transfer instructions MOV, MOVP, DMOV, DMOVP
Program DMOVP
Example 3
The following program transfers data in D0 and D1 to D7 and D8.
Program DMOVP
Example 4
The following program transfers data at X0 through X1F to D0 and D1.
NOTE The program examples 3 and 4 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EMOVGE1
6 – 154
Data transfer instructions EMOV, EMOVP
1
32-bit floating point number, data type real number
EMOV0E1
Program EMOVP
Example 1
The following program transfers 32-bit floating point data in D10 and D11 to D0 and D1.
Program EMOVP
Example 2
With leading edge from X8, the following program transfers the real number –1.23 to D10 and
D11.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MOV/DMOV.
s d
E
M
O
V
G
E
1
P s d
6 – 156
Data transfer instructions EDMOV, EDMOVP
1
64-bit floating point number, data type real number
EMOV0E1
Program EDMOVP
Example 1
The following program transfers 64-bit floating point data in D10 to D13 to D0 to D3.
Program EDMOVP
Example 2
With leading edge from X8, the following program transfers the real number –1.23 to D10 to
D13.
NOTE These programs will not run without variable definition in the header of the program organization
unit (POU). They would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SMOV_ME1
6 – 158
Data transfer instructions $MOV, $MOVP
1
Indicates end of character string
2
1st character
3
nth character
SMOV0E1
The $MOV instruction is even performed without error messages, if the range of devices stor-
ing character string data to be transferred (s through s+n) overlaps with the range of devices
storing transferred data (d through d+n). The $MOV instruction performs as follows, if character
string data in D10 through D13 is transferred to D11 through D14:
SMOV0E2
If the code "00H" is stored at lower bytes of s+n, the characters following at the higher bytes are
omitted. In d+n, the transferred code "00H" will be stored at both, the higher bytes and the lower
bytes:
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The code "00H" does not exist in character string data designated by s. (Error code 4101)
● Character string data in s cannot be transferred completely to d. (Error code 4101)
● The character string of s exceeds 16383 characters. (Error code 4101)
Program With leading edge from X0, the following program transfers character string data at D10
Example through D12 to D20 through D22.
Ladder Diagram
MELSEC Instruction List
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 160
Data transfer instructions CML, CMLP, DCML, DCMLP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
Program CML
Example 1
While SM402 is set, the following program transfers data at X0 through X7 inverted to D0.
1
Undesignated bits are read as 0.
CML__MB1, CML__KB1, CML__IB1, CML_0B1
In this example the number of bits in s is smaller than the number of bits in d.
6 – 162
Data transfer instructions CML, CMLP, DCML, DCMLP
Program CML
Example 2
While SM402 is set, the following program transfers data in M16 through M23 inverted to K3
Y40 (Y40 through Y4F). Y48 through Y4B are all set (1), because they were read as 0.
1
Undesignated bits are read as 0.
In this example the number of bits in s is smaller than the number of bits in d.
Program CMLP
Example 3
With leading edge from X3, the following program transfers data in D0 inverted to D16.
Program DCML
Example 4
While SM402 is set, the following program transfers data at X0 through X1F inverted to D0 and
D1.
1
Undesignated bits are read as 0.
CML__MB4, CML__KB4, CML__IB4, CML_0B4
In this example the number of bits in s is smaller than the number of bits in d.
Program DCML
Example 5
While SM402 is set, the following program transfers data in M16 through M35 inverted to Y40
and Y57.
In this example the number of bits in s is smaller than the number of bits in d.
CML__MB5, CML__KB5, CML__IB5, CML_0E4
6 – 164
Data transfer instructions CML, CMLP, DCML, DCMLP
Program DCMLP
Example 6
With leading edge from X3, the following program transfers data in D0 and D1 inverted to D16
and D17.
NOTE The program examples 4 and 6 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BMOV_GE1
6 – 166
Data transfer instructions BMOV, BMOVP
V0E1B
M
O
A transfer can even be performed without operation errors, if the source and the destination
devices overlap. Transfer to the smaller device number begins from s. Transfer to the larger
device number begins from s+(n-1).
However, as shown in the example below, when transferring data from R to ZR, or from ZR to
R, the range to be transferred (source) and the range of destination must not overlap. Transfer
from R to R, or from ZR to ZR can be performed without any problem.
– ZR transfer range
(specified head No. of ZR) to
(specified head No. of ZR + the number of transfers -1)
– R transfer range
((specified head No. of R + file register block No. 32768) to
(specified head No. of R + file register block No. 32768 + the number of transfers -1))
Example Transfer ranges of ZR and R overlap when transferring 10000 blocks of data from ZR30000
to R10 (block no. 1 of destination).
Die Übertragungsbereiche von ZR und R überlappen sich, wenn 10000 Datenblöcke von
ZR30000 nach R10 (Block-Nr. 1 des Datenziels) übertragen werden.
– ZR transfer range: (30000) to (30000 + 10000 -1) = (30000) to (39999)
– R transfer range: (10 + (1 x 32768)) to (10 + (1 x 32768) + 10000 -1)
= (32778) to (42777)
Therefore the range 32778 to 39999 overlaps and the data is not transferred correctly.
Source Destination
ZR0 R0
ZR30000 R32767
ZR39999 R10
R10009 Block No. 1
If s is a word device and d is a bit device, the number of bits designated by digit designation for
the bit device will be the object bits for the word device. If K1Y30 is designated by d, the object
bits for the word device s are the lower 4 bits.
V0E2B
M
O
If s and d are bit devices, the number of bits in s and d must equal.
When using a link direct device and an intelligent function module device for s and d, only either
of s or d can be used.
Whether to check a device range during execution of the BMOV instruction can be selected
with the device range check inhibit flag (SM237) (only when the conditions for subset process-
ing are established). While SM237 is ON, whether s to s + (n) -1 and d to d + (n) - 1 are within
the device range or not are not checked.
NOTES SM237 can be used only for the Universal model QCPU whose first 5 digits of serial number is
10012 or higher and for LCPU.
While SM237 is on, do not make the following access.
– The indexing target exceeds the device range.
– The value obtained from "d to d+(n)- 1" is over the boundaries of the device ranges.
– Accessing the file register with file register not set.
– Accessing the area where the multiple CPU high speed transmission area device is not avail-
able (only for the QCPU).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s and d.
(Error code 4101)
6 – 168
Data transfer instructions BMOV, BMOVP
Program BMOVP
Example 1
With leading edge from SM402, the following program transfers the lower 4 bits of data (b0
through b3) in D66 through D69 to the outputs Y30 through Y3F. The number of blocks (4) to
be transferred is determined by the constant K4.
The bit patterns show the structure of bits before and after the transfer.
1
These bits are ignored.
BMOV_MB1, BMOV_KB1, BMOV_IB1, BMOV0B1
Program BMOVP
Example 2
With leading edge from SM402, the following program transfers data at X20 through X2F to
D100 through 103. The number of blocks (4) to be transferred is determined by the constant
K4.
The bit patterns show the structure of bits before and after the transfer.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FMOV_ME1
6 – 170
Data transfer instructions FMOV, FMOVP
FMOV0E1
If s is a word device and d is a bit device, the number of bits designated by digit designation for
the bit device will be the object bits for the word device.
1
These bits are ignored.
FMOV0E2
If s and d are bit devices, the number of bits in s and d must equal.
Whether to check a device range during execution of the FMOV instruction can be selected
with the device range check inhibit flag (SM237) (only when the conditions for subset process-
ing are established). While SM237 is ON, whether d to d + (n) - 1 is within the device range or
not is not checked.
NOTES SM237 can be used only for the Universal model QCPU whose first 5 digits of serial number is
10012 or higher and for LCPU.
While SM237 is on, do not make the following access.
– The indexing target exceeds the device range.
– The value obtained from "d to d+(n–1)" is over the boundaries of the device ranges.
– Accessing the file register with file register not set.
– Accessing the area where the multiple CPU high speed transmission area device is not avail-
able (only for the QCPU).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by d. (Error code 4101)
Program FMOVP
Example 1
With leading edge from XA, the following program transfers the lower 4 bits of data (b0 through
b3) in D0 to the outputs Y10 through Y23. The number of blocks (5) is determined by the con-
stant K5.
The bit patterns show the structure of bits before and after the transfer.
1
These bits are ignored.
FMOV_MB1, FMOV_KB1, FMOV_IB1, FMOV0B3
Program FMOVP
Example 2
With leading edge from XA, the following program transfers data at X20 through X23 to D100
through D103. The number of blocks (4) to be transferred is determined by the constant K4.
The bit patterns show the structure of bits before and after the transfer.
1
These bits are ignored.
6 – 172
Data transfer instructions DFMOV, DFMOVP
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DFMOV s d n
DFMOVP s d n
F
M
O
V
_
M
E
1
b31 b0
Transfer 1234567H
b31 b0 d+1 , d
s+1, s 1234567H d+3 , d+2 1234567H
d+5 , d+4 1234567H n
FMOV0E1
If s is a word device and d is a bit device, the number of bits designated by digit designation for
the bit device will be the object bits for the word device.
If K5Y0 is specified by s, the lower 20 bits (five digits) of the word device specified by s will be
the object.
0 d+3 d+2
FMOV0E2
If d specifies data of a device with digit specification, the amount of data stored in the device
specified by d will be transferred.
If K5Y0 is specified by d, the lower 20 bits of the word device specified by s will be the object.
If both s and d specify data of a device with digit specification, the amount of data specified by
d will be transferred regardless of the number of digits.
Transfer 4
d+n d+1 d
6 – 174
Data transfer instructions DFMOV, DFMOVP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified by n is negative.
(Error code 4100)
● The number of data blocks determined by n exceeds the storage device numbers designated
by d.
(Error code 4101)
Program DFMOVP
Example
With leading edge from M0, the following program transfers the value of data (Y0 to Y13 (20
bits) into D10 to D17.
Transfer 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 D13,D1
0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 D15,D1
0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 D17,D1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
XCH__GE1
6 – 176
Data transfer instructions XCH, XCHP, DXCH, DXCHP
XCH_0E1
XCH_0E2
Program XCHP
Example 1
With leading edge from X8, the following program exchanges data in D0 and the actual value
in T0.
Program XCHP
Example 2
With leading edge from X10, the following program exchanges data in D0 and data in M16
through M31.
Program DXCHP
Example 3
With leading edge from X10, the following program exchanges data in D0 and D1 and data in
M16 through M47.
Program DXCHP
Example 4
With leading edge from M0, the following program exchanges data in D0 and D1 and data in
D9 and D10.
NOTE The program examples 3 and 4 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
6 – 178
Data transfer instructions BXCH, BXCHP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BXCH_GE1
BXCH0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by d1 and d2. (Error code 4101)
● The storage device numbers designated by d1and d2 overlap. (Error code 4101)
6 – 180
Data transfer instructions BXCH, BXCHP
Program BXCHP
Example
With leading edge from X1C, the following program exchanges data blocks beginning from
D200 and data blocks beginning from R0. The number of blocks (3) to be exchanged is deter-
mined by the constant K3.
The bit patterns show the structure of bits before and after the transfer.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BXCH_GE1
6 – 182
Data transfer instructions SWAP, SWAPP
SWAP0E1
Program SWAPP
Example
With leading edge from X10, the following program exchanges the upper and lower 8 bits in
R10.
6 – 184
Program branch instructions
A jump destination is designated by a pointer P (GX Works2) or a label (GX IEC Developer).
For details on programming a label in GX IEC Developer see the Programming Manual for the
GX IEC Developer.
GX IEC Developer
CJ___IB3, CJ___IB1
GX Works2
CJ___GB1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
CJ___GE1
6 – 186
Program branch instructions CJ, SCJ, JMP
CJ Conditional jump
Executes the program specified by the pointer number within the same program file, when the
execution command is ON.
When the execution command is OFF, the program at the next step is executed.
1
Input condition
2
CJ instruction
3 Executed each scan
CJ__0E1
1
Input condition
2 SCJ instruction
3 One scan
4
Executed each scan
CJ__0E2
NOTE If a set timer is skipped by a CJ, SCJ, or JMC instruction it will nevertheless keep its timing
accurately.
If an OUT instruction is skipped by a jump instruction, the condition of the output remains un-
changed.
Executing a jump instruction shortens the scan time of a program in relation to the skipped pro-
gram steps (see tables in appendices).
The CJ, SCJ, and JMP instruction can even jump back to a lower jump destination. However, a
program must exit the program loop before the watchdog timer times out (the following program
example exits the loop, when X7 is set).
CJ___AB1
The condition of a device skipped by a jump instruction remains unchanged. This is illustrated
by the following program example:
CJ___AB2
After XB is set, this program jumps to the jump destination Label19. The conditions of the out-
puts Y43 and Y49 even remain unchanged, if XC or XD are set or reset.
The jump destination (e.g. Label9) occupies one program step.
CJ___AB3
The CJ, SCJ, or JMP instruction only jumps to destinations within one single program.
If a jump destination is located within the skip range during a skip operation (operation skipping
parts of a program), program execution proceeds from the first available address following the
jump destination.
6 – 188
Program branch instructions CJ, SCJ, JMP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● A common pointer has been designated. (Error code 4210)
● The jump destination of the jump instruction is not defined in a program (jump destination
or pointer is missing). (Error code 4210)
● The jump destination is located after an END instruction.
(Error code 4210)
Program CJ
Example 1
The following program jumps to the destination Label_3 when X9 is set.
Program SCJ
Example 2
The following program jumps to the destination Label_3 from the next scan when XC is set.
6.5.2 GOEND
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
G
OENDME1, GOENDKE1, GOENDIE1
GX Works2
GOENDGE1
6 – 190
Program branch instructions GOEND
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● A GOEND instruction was executed after a CALL or ECALL instruction and before a RET
instruction. (Error code 4211)
● A GOEND instruction was executed after a FOR instruction and before a NEXT instruction.
(Error code 4200)
● A GOEND instruction was executed during an interrupt program but before an IRET
instruction. (Error code 4221)
● A GOEND instruction was executed between a CHKCIR and a CHKEND instruction.
(Error code 4230)
● A GOEND instruction was executed between an IX and an IXEND instruction.
(Error code 4231)
Program GOEND
Example
The following program jumps to the END instruction when data in D0 is negative.
Program execution control instructions invoke interrupt routines. The interrupts can be enabled
or disabled individually or via bit patterns.
The following table gives an overview of these instructions:
6 – 192
Program execution control instructions DI, EI, IMASK
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DI___GE1
s Bit pattern storing execution conditions of interrupts or first number of device BIN 16-bit
storing bit pattern.
EI Enable interrupt
The EI instruction enables invoking an interrupt program designated by an interrupt address
Ixx, or enables the execution of an IMASK instruction.
Even though an interrupt condition might be generated between the DI and EI instructions, the
interrupt program is suspended until the entire cycle from DI to EI has been processed. The fol-
lowing diagram illustrates such an execution:
1
Sequence program
2
Interrupt program
DI__0E1
NOTE The GX IEC Developer inserts the FEND instruction automatically. The event Ixx has to be allo-
cated to a task.
6 – 194
Program execution control instructions DI, EI, IMASK
System Q The allocation of bits in s through s+7 to the corresponding interrupt addresses is shown
CPU (Basic below:
Model
QCPU)
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
s I15 I14 I13 I12 I11 I10 I9 I8 I7 I6 I5 I4 I3 I2 I1 I0
s +1 I31 I30 I29 I28 I27 I26 I25 I24 I23 I22 I21 I20 I19 I18 I17 I16
s+2 I47 I46 I45 I44 I43 I42 I41 I40 I39 I38 I37 I36 I35 I34 I33 I32
s+3 I63 I62 I61 I60 I59 I58 I57 I56 I55 I54 I53 I52 I51 I50 I49 I48
s+4 I79 I78 I77 I76 I75 I74 I73 I72 I71 I70 I69 I68 I67 I66 I65 I64
s+5 I95 I94 I93 I92 I91 I90 I89 I88 I87 I86 I85 I84 I83 I82 I81 I80
s+6 I111 I110 I109 I108 I107 I106 I105 I104 I103 I102 I101 I100 I99 I98 I97 I96
s+7 I127 I126 I125 I124 I123 I122 I121 I120 I119 I118 I117 I116 I115 I114 I113 I112
IMASK0E3
When the power supply of the CPU is switched on or when the CPU has been reset, the exe-
cution of interrupt programs I0 through I31, I48 to I127 is enabled.
The bit patterns designated by s through s+2 are stored in the special registers SD715 through
SD717. The bit patterns designated by s+3 through s+7 are stored in the special registers
SD781 through SD785.
The bit patterns are designated as s through s+7 successively although the special registers
are separated (SD715 through SD717 and SD781 through SD785).
System Q The allocation of bits in s through s+15 to the corresponding interrupt addresses is shown
CPU (other below:
than Basic
Model b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
QCPU) and s I15 I14 I13 I12 I11 I10 I9 I8 I7 I6 I5 I4 I3 I2 I1 I0
L-series s +1 I31 I30 I29 I28 I27 I26 I25 I24 I23 I22 I21 I20 I19 I18 I17 I16
CPU
s+2 I47 I46 I45 I44 I43 I42 I41 I40 I39 I38 I37 I36 I35 I34 I33 I32
s+3 I63 I62 I61 I60 I59 I58 I57 I56 I55 I54 I53 I52 I51 I50 I49 I48
s+4 I79 I78 I77 I76 I75 I74 I73 I72 I71 I70 I69 I68 I67 I66 I65 I64
s+5 I95 I94 I93 I92 I91 I90 I89 I88 I87 I86 I85 I84 I83 I82 I81 I80
s+6 I111 I110 I109 I108 I107 I106 I105 I104 I103 I102 I101 I100 I99 I98 I97 I96
s+7 I127 I126 I125 I124 I123 I122 I121 I120 I119 I118 I117 I116 I115 I114 I113 I112
s+8 I143 I142 I141 I140 I139 I138 I137 I136 I135 I134 I133 I132 I131 I130 I129 I128
s+9 I159 I158 I157 I156 I155 I154 I153 I152 I151 I150 I149 I148 I147 I146 I145 I144
s +10 I175 I174 I173 I172 I171 I170 I169 I168 I167 I166 I165 I164 I163 I162 I161 I160
s + 11 I191 I190 I189 I188 I187 I186 I185 I184 I183 I182 I181 I130 I129 I128 I127 I126
s + 12 I207 I206 I205 I204 I203 I202 I201 I200 I199 I198 I197 I196 I195 I194 I193 I192
s + 13 I223 I222 I221 I220 I219 I218 I217 I216 I215 I214 I213 I212 I211 I210 I209 I208
s + 14 I239 I238 I237 I236 I235 I234 I233 I232 I231 I230 I229 I228 I227 I226 I225 I224
s + 15 I255 I254 I253 I252 I251 I250 I249 I248 I247 I246 I245 I244 I243 I242 I241 I240
IMASK0E2
When the power supply of the CPU is switched on or when the CPU has been reset with the
RUN/STOP switch, the execution of interrupt programs are as follows:
● High Performance model QCPU, Process CPU, and Redundant CPU
Execution of interrupt programs I0 to I31 and I48 to I255 is enabled, and execution of interrupt
programs I32 to I47 is disabled.
● Universal model QCPU and LCPU
Execution of interrupt programs I0 to I31 and I45 to I255 is enabled, and execution of interrupt
programs I32 to I44 is disabled.
The bit patterns designated by s through s+2 are stored in the special registers SD715 through
SD717. The bit patterns designated by s+3 through s+15 are stored in the special registers
SD781 through SD793.
Although the special registers are separated (SD715 through SD717 and SD781 through
SD793), the bit patterns are designated as s through s+15 successively.
6 – 196
Program execution control instructions DI, EI, IMASK
NOTES The interrupt address (interrupt pointer) designating the interrupt program occupies one pro-
gram step.
DI___AB1
With the GX Works2 or with the GX IEC Developer in MELSEC mode the instructions FEND and
IRET have to be programmed by the user.
Alternatively to the MELSEC editor the IEC editor can be used. The interrupt is allocated to a
task and the FEND and IRET instructions are placed automatically by the compiler of the GX IEC
Developer MEDOC (see program example).
For the information on interrupt conditions, link direct devices, refer to the QnUCPU User’s Ma-
nual(Function Explanation, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User’s Ma-
nuall(Function Explanation, Program Fundamentals).
During the execution of an interrupt program the DI status is internally set, so that no other in-
terrupt program can be executed simultaneously. Another interrupt program can only be invoked
after setting an EI instruction.
If an EI or DI instruction is placed within an MC instruction, the EI or DI instruction is executed
without regard to the MC instruction.
DI___AB2
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 198
Program execution control instructions DI, EI, IMASK
Ladder Diagram
Instruction List
6.6.2 IRET
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
IRET_GE1
NOTE Within the IEC editors the IRET instruction is placed automatically in the program.
6 – 200
Program execution control instructions IRET
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● There is no corresponding interrupt address for the interrupt call.
(Error code 4220)
● If the IRET instruction is placed prior to an interrupt program, the CPU quits processing at
that point. (Error code 4223)
● An END, FEND, GOEND, or STOP instruction was placed between an interrupt call and an
IRET instruction.
● The IRET instruction was executed during the fixed scan execution type program.
(For the Universal model QCPU, LCPU) (Error code 4223)
1
Sequence program
2
Interrupt program
DI__0E2
Program For the application of an IRET instruction in a program refer to the program examples for the
Example EI, DI, and IMASK instructions (refer to section 6.6.1).
6 – 202
Link refresh instructions RFS, RFSP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
RFS__GE1
RFS__AB1, RFS__AB2
The program example on the left refreshes the input X0 and the output Y20 via an RFS instruc-
tion.
The program example on the right performs the same functions via DX and DY without a
refresh instruction.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of points determined by n exceeds the input/output device range.
(Error code 4101)
Program RFSP
Example
With leading edge from M0, the following program refreshes the inputs X100 through X11F and
the outputs Y200 through Y23F.
6 – 204
Other convenient instructions
6.8.1 UDCNT1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
UDCN1GE1
6 – 206
Other convenient instructions UDCNT1
1
Counting up
2
Counting down
UDCNT0E1
The UDCNT1 instruction is started when the execution condition is set and stopped when the
execution condition is reset. If the counter is started once again, it counts on from the value
before it was stopped.
An RST instruction resets the counter designated by d and the according counter contact.
NOTE The counting process of a UDCNT1 instruction is performed during a CPU interrupt (1 ms). For
this reason only pulses with set/reset times over 1 ms can be counted accurately.
The setting value cannot be changed during the counting process (in this case the input desi-
gnated by s+0 (Array_s [0]) is set). In order to change the setting, the input designated by s+0
(Array_s [0]) has to be reset.
Counters designated by a UDCNT1 instruction cannot be used by other instructions at the same
time. In this case they would not return an accurate count.
The UDCNT1 instruction can be used as many as 6 times within all the programs being exe-
cuted. The seventh and the subsequent UDCNT1 instructions are not processed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by s exceeds the range of the corresponding device.
(Error code 4101)
Program UDCNT1
Example
If X20 is set, the following program designates counter C0 (up/down counter) to count the
number of leading edges from X0.
1
Count
2
Counter contact of counter C0
UDCN1MB1, UDCN1KB1, UDCN1IB1, UDCNT0B1
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 208
Other convenient instructions UDCNT2
6.8.2 UDCNT2
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
UDCN2GE1
1
Counting up
2
Counting down
UDCNT0E2
The UDCNT2 instruction is started when the execution condition is set and stopped when the
execution condition is reset. If the counter is started once again, it counts on from the value
before it was stopped.
An RST instruction resets the counter designated by d and the according counter contact.
NOTE The counting process of a UDCNT2 instruction is performed during a CPU interrupt (1 ms). For
this reason only pulses with set/reset times over 1 ms can be counted accurately.
The setting value cannot be changed during the counting process (-> the input designated by
s+0 (Array_s [0]) is set). In order to change the setting, the input designated by s+0 (Array_s [0])
has to be reset.
Counters designated by a UDCNT2 instruction cannot be used by other instructions at the same
time. In this case they would not return an accurate count.
The UDCNT2 instruction can be used as many as 5 times within all the programs being exe-
cuted. The sixth and the subsequent UDCNT2 instructions are not processed.
6 – 210
Other convenient instructions UDCNT2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by s exceeds the range of the corresponding device.
(Error code 4101)
Program UDCNT2
Example
If X20 is set, the following program designates counter C0. The count and the count direction
(up/down) depend on the conditions of X0 and X1.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6.8.3 TTMR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
TTMR_GE1
6 – 212
Other convenient instructions TTMR
NOTE Time measurement is performed during the execution of a TTMR instruction. Applying a JMP in-
struction or a similar instruction to the TTMR instruction causes inaccurate time measurement.
The multiplier n must not be changed during the execution of a TTMR instruction. A change
would cause inaccurate measurement.
The TTMR instruction can also be used in low speed type programs.
The device designated by d+1 (array_d [1]) is used by the CPU. A change would cause inac-
curate measurement.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
Program TTMR
Example
If X0 is set, the following program measures the time in seconds (n = 0, multiplier = 1). The
result is stored in D0.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6.8.4 STMR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
STMR_GE1
6 – 214
Other convenient instructions STMR
The timer coil of the timer designated by s is set (0) with leading edge from the execution con-
dition and starts measuring the time designated by n.
The timer coil measures time until the measurement value matches the time setting n and then
drops out.
If the execution condition is reset before the time setting n has passed, the timer coil remains
set and time measurement is suspended at that point.
If the execution condition is set again the measurement value is cleared to 0 and time meas-
urement starts again.
The timer contact designated by s is either set by trailing edge from the execution condition and
set timer coil or by trailing edge from the timer coil and set execution condition. The timer con-
tact is reset by trailing edge from the execution condition and reset timer coil. The timer contact
is supplied for CPU internal use only.
1 Execution condition
2
Timer coil designated by s
3
Timer contact designated by s
4 Time setting n
STMR_0E1
Time measurement is performed during the execution of an STMR instruction. Applying a JMP
instruction or a similar instruction to the STMR instruction causes inaccurate time measure-
ment.
The realtime designated by d can be calculated by multiplying the time setting n with the time
unit for low speed timers (default value = 100 ms).
The constant n has to range within 0 and 32767.
The timer designated by s cannot be used by an OUT instruction. If an OUT instruction and an
STMR instruction use the same timer, the STMR instruction cannot be performed accurately.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
6 – 216
Other convenient instructions STMR
Program STMR
Example
If X20 is set, the following program alternately sets the outputs Y0 and Y1 for 1 second each.
The used timer is a 100 ms timer. The time period of 1 second is calculated by multiplying K10
with 100 ms.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6.8.5 ROTC
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ROTC_ME1
6 – 218
Other convenient instructions ROTC
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by s or d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
Program ROTC
Example
In the following program the contacts X0, X1 (incremental encoder), and X2 address the
internal relays for detection of the rotating direction and zero position M0 (var_M0 array [0])
through M2 (var_M0 array [2]). The contact X2 is activated, if sector 0 is located at position 0
(zero position detection).
The rotary table shown below is divided into 10 sectors.
Which item (sector) will be moved to which station (position) has to be specified in D201
(var_D200 array [1]) and D202 (var_D200 array [2]) before the execution of the ROTC instruc-
tion.
Due to the value n1=10 the contact of the counter register outputs 10 pulses each rotation
(division). The value n2=2 specifies the number of low speed divisions.
For example, if register D201 (var_D200 array [1]) stores the value 0 and register D202
(var_D200 [2]) stores the value 3, the rotary table moves item 3 (sector 3) to station 0
(position 0) travelling the shortest distance (clockwise). The sectors 1 through 3 rotate at low
speed.
For an allocation of single registers and internal relays or array elements respectively to the
corresponding functions see the table following the example.
1
Station 0 (position 0)
2
Station 1 (position 1)
3 Detection switch
6 – 220
Other convenient instructions ROTC
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6.8.6 RAMP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
RAMP_GE1
6 – 222
Other convenient instructions RAMP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d1 or d2 exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
NOTE When the digit specification of bit device is made to d1, the digit specification of bit device can
only be used when the specification of digits is "K8".
Program RAMP
Example
The following program increases the content in D0 within 6 moves from 10 to 100 and stores
the content in D0 when the operation is completed.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
6 – 224
Other convenient instructions SPD
6.8.7 SPD
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SPD_GE1
1 Execution condition.
2
The result of the measurement is stored in d.
3
Begin of measurement.
SPD_0E1
While the execution condition is set, the measurement begins again from 0 after the measure-
ment time has passed. In order to stop the SPD measurement the execution condition has to
be reset.
The SPD instruction stores the data from the designated devices in the CPU work area, and
performs the current count operation during a 5 ms system interrupt. For this reason, the
number of times the instruction can be used is limited. The SPD instructions exceeding this
limit are not processed.
NOTES The count processing for pulses used with the SPD instruction is conducted during an interrupt.
Therefore, to count the pulses, it is necessary to provide their ON and OFF time as long as the
interrupt time of the CPU or longer. The interrupt time is 1 ms.
When the High Performance model QCPU or Process CPU is used, the SPD instruction is not
processed if n = 0.
The SPD instruction can be used as many as 6 times within all the programs being executed.
The seventh and the subsequent SPD instructions are not processed.
While the measurement is in execution (while the command input is ON) by the SPD instruction,
the setting value cannot be changed. Turn OFF the command input before changing the setting
value.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
6 – 226
Other convenient instructions SPD
Program SPD
Example
If X10 is set, the following program counts the pulses at X0 during a period of time of 500 ms.
The result is stored in D0.
6.8.8 PLSY
CPU High
Basic Process Redundant Universal LCPU
Performance
1 Y only
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
PLSY_GE1
6 – 228
Other convenient instructions PLSY
NOTE The PLSY instruction stores the data from the designated devices in the CPU work area, and
and counting operation is processed as a system interrupt. The pulses that can be output must
have longer ON and OFF times than the interrupt interval of the CPU module. The interrupt in-
terval of individual modules is 1 ms.
Do not change the argument for the PLSY instruction during pulse output directed by the PLSY
instruction (while the execution command is ON). To change the argument, turn OFF the exe-
cution command.
The PLSY instruction can be used only once in all programs executed by the CPU module. The
second and the subsequent PLSY instructions are not processed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
Program PLSY
Example
If X0 is set, the following program outputs five 10 Hz pulses to Y20.
6.8.9 PWM
CPU High
Basic Process Redundant Universal LCPU
Performance
1 Only Y
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
PWM_GE1
6 – 230
Other convenient instructions PWM
PWM_0E1
The times in n1and n2 can be specified from 1 to 65535 ms. The value set in n1 has to be less
than that in n2.
NOTES The PWM instruction registers the data from the designated devices in the work area of the CPU,
and performs the current output operation during a system interrupt (1 ms).
For this reason, the PWM instruction can only be used once in a program.
The instruction is not processed in the following cases:
– When both n1 and n2 are 0
– When n2 is smaller or equal to n1
– When the PWM instruction is executed twice or more.
Do not change the argument for the PLSY instruction during pulse output directed by the PLSY
instruction (while the execution command is ON). To change the argument, turn OFF the exe-
cution command.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
Program PWM
Example
If X0 is set, the following program outputs pulses at a cycle time of 1 second and with an ON
time of 100 ms to Y20.
6.8.10 MTR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MTR__GE1
6 – 232
Other convenient instructions MTR
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device other than the input (X) was specified at s. (Error code 4101)
● The device other than the output (Y) was specified at d1. (Error code 4101)
Program MTR
Example
If X0 is set, the following program reads the inputs X10 through X1F three times and stores the
results in M30 through M77. A matrix is built with 16 bits x 3 rows. The rows are addressed via
the outputs Y20 through Y22.
1
1st row
2
2nd row
3
3rd row
MTR_MB1, MTR_KB1, MTR_IB1, MTR_0B1
6 – 234
7 Application Instructions, Part 2
The application instructions, part 2 are specific instructions for several special functions.
The following table shows the division of these functions:
Instruction Meaning
Logical operation instructions Logical AND / OR, logical exclusive OR / exclusive NOR
Rotation instructions 16-bit and 32-bit data right / left rotation
Shift instructions Shift data by bit or word
Bit processing instructions Set, reset, and test bits
Data processing instructions Search, encode, and decode data at specified devices
Disunite and unite data
Structured program instructions Repeated operation, subroutine program calls,
subroutine calls between program files, switching
between main and subprogram parts, micro computer
program calls, index qualification of entire ladders, store
index qualification values in data tables
Data table operation instructions Write to and read data from a data table, delete and
insert data blocks in a data table
Buffer memory access instructions Buffer memory access of special function modules
Display instructions Output ASCII characters to the outputs of a module or to
an LED display
Debugging and failure diagnosis instructions Failure checks, setting and resetting status latch,
sampling trace, program trace
Character string processing instructions Character string (ASCII code) processing
Special function instructions Trigonometrical functions, square root and exponential
calculation with BCD data and floating point data
Data control instructions Upper and lower limit control and storage of checked
data
File register switching instructions Switching between file register blocks and files
Clock instructions Reading/writing of the values of year, month, day, hour,
minute, second, and day of the week; addition/
subtraction of the values of hour, minute, and second;
conversion of the values of hour, minute, and second into
second; comparison between the values of year, month,
and day; and comparison between the values of hour,
minute, and second.
Expansion clock instruction Reading of the values of year, month, day, hour, minute,
second, millisecond, and day of the week; addition/
subtraction of the values of hour, minute, second, and
millisecond
Peripheral device instructions Message output and key input on peripheral units
Program instructions Select different program execution modes
Other instructions Reset watchdog timer (WDT), pulse generation, direct
read from indirect access file registers, numerical key
input from keyboard, batch save or recovery of index
registers, reading module information/model name, trace
set/trace reset, writing to and reading from files/standard
ROM, program instructions, data transfer, user message
Via the logical operation instructions logical connections such as logical sum or logical product
are programmed.
The following table gives an overview of these instructions:
NOTE Within the IEC editors please use the IEC instructions.
Logical instructions are processed bit by bit as binary data. The two conditions (0 and 1) are
connected and the result of the connection is output to a destination address.
7–2
Logical operation instructions
The following table shows the logical connection results of the conditions 0 and 1. A and B are
input variables and Y is the output variable.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
WAND_GE1
7–4
Logical operation instructions WAND, WANDP, DAND, DANDP
WAND0E1
● Variation 2:
16-bit data designated by s1 and s2 form the logical product bit by bit. The result is output to
the device designated by d1.
WAND0E2
Bits exceeding the digit designation are set to 0. For example, if the digit designation is speci-
fied by K2, the higher 8 bits (b8 through b15) are processed as 0.
DAND0E1
● Variation 2:
32-bit data designated by s1 and s2 form the logical product bit by bit. The result is output to
the device designated by d.
DAND0E2
After executing the connection, all bits exceeding the digit designation are set to 0.
7–6
Logical operation instructions WAND, WANDP, DAND, DANDP
X1B X8 X7 X3 X10
B10 - X1B 0 0 0 0 1 0 0 1 0 0 1 1 1 1 0 0
0 WANDP
b15 b8 b7 b0
D33 0 1 0 1 1 1 0 1 1 1 1 1 0 0 0 0
b15 b8 b7 b0
D40 0 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0
1
These bits are set to 0.
WAND_MB3, WAND_KB3, WAND_IB3, WAND0B2
7–8
Logical operation instructions WAND, WANDP, DAND, DANDP
1
These bits remain unchanged.
WAND_MB5, WAND_KB5, WAND_IB5, DAND0B2
NOTE The program examples 2 and 5 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKANDGE1
s2 First number of data or first number of device storing data for logical operation.1)
BIN 16-bit
d First number of device storing result of logical operation.1)
n Number of data blocks forming the logical product.
1
The same device number can be specified for s1 and d or s2 and d.
7 – 10
Logical operation instructions BKAND, BKANDP
BKAND0E1
The constant in s2 must range within -32768 and 32767.
BKAND0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s1, s2, or d.
(Error code 4101)
● The device range for n points starting from the device designated by s1 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s1 and d).
(Error code: 4101)
● The device range for n points starting from the device designated by s2 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s2 and d).
(Error code: 4101)
Program BKANDP
Example
With leading edge from X20, the following program forms the logical product of data in registers
D100 through D102 and data in registers R0 through R2. The result is stored in registers D200
through D202. The number of 16-bit data blocks (3) to be processed is stored in D0.
7 – 12
Logical operation instructions WOR, WORP, DOR, DORP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
WOR__GE1
Functions Logical OR
WOR 16-bit data
The logical OR forms the logical sum of two input variables.
● Variation 1:
16-bit data designated by s and d are added bit by bit. The result is output to the device desig-
nated by d.
WOR_0E1
● Variation 2:
16-bit data designated by s1 and s2 are added bit by bit. The result is output to the device des-
ignated by d1.
WOR_0E2
Bits exceeding the digit designation are set to 0. For example, if the digit designation is speci-
fied by K2, the higher 8 bits (b8 through b15) are processed as 0.
7 – 14
Logical operation instructions WOR, WORP, DOR, DORP
DOR_0E1
● Variation 2:
32-bit data designated by s1 and s2 are added bit by bit. The result is output to the device des-
ignated by d.
DOR_0E2
After executing the connection, all bits exceeding the digit designation are set to 0.
7 – 16
Logical operation instructions WOR, WORP, DOR, DORP
1
These bits are set to 0.
2
These bits remain unchanged.
WOR__MB3, WOR__KB3, WOR__IB3, WOR_0B2
NOTE The program examples 2 and 4 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKOR_GE1
s2 First number of data, or first number of device storing data for logical sum.1)
BIN 16-bit
d First number of device storing result of logical operation.1)
n Number of data blocks forming the logical sum.
1 The same device number can be specified for s1 and d or s2 and d.
7 – 18
Logical operation instructions BKOR, BKORP
BKOR0E1
The constant in s2 must range within -32768 and 32767.
BKOR0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s1, s2, or d.
(Error code 4101)
● The device range for n points starting from the device designated by s1 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s1 and d).
(Error code: 4101)
● The device range for n points starting from the device designated by s2 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s2 and d).
(Error code: 4101)
Program BKORP
Example
With leading edge from X20, the following program forms the logical sum of data in registers
D100 through D102 and data in registers R0 through R2. The result is stored in registers D200
through D102. The number of 16-bit data blocks (3) to be processed is stored in D0.
7 – 20
Logical operation instructions WXOR, WXORP, DXOR, DXORP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
W
X
O
R
_
G
E
1
WXOR0E1
● Variation 2:
16-bit data designated by s1 and s2 form a logical exclusive OR connection. The result is out-
put to the device designated by d.
WXOR0E2
Bits exceeding the digit designation are set to 0. For example, if the digit designation is speci-
fied by K2, the higher 8 bits (b8 through b15) are processed as 0.
7 – 22
Logical operation instructions WXOR, WXORP, DXOR, DXORP
DXOR0E1
● Variation 2:
32-bit data designated by s1 and s2 form a logical exclusive OR connection. The result is out-
put to the device designated by d.
DXOR0E2
After executing the connection, all bits exceeding the digit designation are set to 0.
7 – 24
Logical operation instructions WXOR, WXORP, DXOR, DXORP
NOTE The program examples 2 and 4 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKXORGE1
s2 First number of data, or first number of device storing data for logical operation.1)
BIN 16-bit
d First number of device storing result of operation.1)
n Number of data blocks forming the exclusive OR operation.
1 The same device number can be specified for s1 and d or s2 and d.
7 – 26
Logical operation instructions BKXOR, BKXORP
BKXOR0E1
The constant in s2 must range within -32768 and 32767.
BKXOR0E2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s1, s2, or d. (Error code 4101)
● The device range for n points starting from the device designated by s1 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s1 and d).
(Error code: 4101)
● The device range for n points starting from the device designated by s2 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s2 and d).
(Error code: 4101)
Program BKXORP
Example
With leading edge from X20, the following program performs an exclusive OR operation with
data in registers D100 through D102 and data in registers R0 through R2. The result is stored
in registers D200 through D202. The number of 16-bit data blocks (3) to be processed is stored
in D0.
7 – 28
Logical operation instructions WXNR, WXNRP, DXNR, DXNRP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
W
X
N
R
_ GE1
WXNR0E1
● Variation 2:
16-bit data designated by s1 and s2 form a logical exclusive NOR connection. The result is out-
put to the device designated by d.
The WXNRP operation instruction outputs the result to the device designated by d1.
WXNR0E2
Bits exceeding the digit designation are set to 0. For example, if the digit designation is speci-
fied by K2, the higher 8 bits (b8 through b15) are processed as 0.
7 – 30
Logical operation instructions WXNR, WXNRP, DXNR, DXNRP
DXNR0E1
● Variation 2:
16-bit data designated by s1 and s2 form a logical exclusive NOR connection. The result is out-
put to the device designated by d.
DXNR0E2
After executing the connection, all bits exceeding the digit designation are set to 0.
7 – 32
Logical operation instructions WXNR, WXNRP, DXNR, DXNRP
NOTE The program examples 2 and 4 will not run without variable definition in the header of the pro-
gram organization unit (POU). They would cause compiler or checker error messages. For
details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this
manual.
7 – 34
Logical operation instructions BKXNR, BKXNRP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKXNRGE1
s2 First number of data, or first number of device storing data for logical operation1)
BIN 16-bit
d First number of device storing result of logical operation 1)
n Number of data blocks to be processed
1
The same device number can be specified for s1 and d or s2 and d.
BKXNR0E1
The constant in s2 must range within -32768 and 32767.
BKXNR0E2
7 – 36
Logical operation instructions BKXNR, BKXNRP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks determined by n exceeds the storage device numbers designated
by s1, s2, or d. (Error code 4101)
● The device range for n points starting from the device designated by s1 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s1 and d).
(Error code: 4101)
● The device range for n points starting from the device designated by s2 overlaps with the
device range for n points starting from the device designated by d (except when the same
device is specified for s2 and d).
(Error code: 4101)
Program BKXNRP
Example
With leading edge from X20, the following program performs an exclusive NOR operation with
data in registers D100 through D102 and with data in registers R0 through R2. The result of
the operation is stored in the registers D200 through D202. The number of 16-bit blocks (3) to
be processed is stored in D0.
The following rotation instructions rotate data stored in devices bit by bit. Data can be rotated
to the right as well as to the left.
Example for a rotation to the right.
ROT_0E1
Rotation instructions can alternatively be applied with or without carry flag. The rotation instruc-
tions are suitable for 16-bit and 32-bit data. In total, 16 different rotation instructions are sup-
plied:
NOTE Within the IEC editors please use the IEC instructions.
7 – 38
Data rotation instructions ROR, RORP, RCR, RCRP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ROR__GE1
ROR_0E1
1
Rotation by n bits
2
Carry flag SM700
RCR_0E1
1 Rotation by n bits
2 Carry flag SM700
NOTE If a bit device is designated by d, the rotation operation is performed with a device supplying the
specified number of digits. The number of digits the bits are rotated by is determined by the
remainder of the following quotient:
Number of rotations n / number of bits
For example, 16 rotations of 12 bits correspond to a rotation by 4 bits, since the remainder of the
quotient 16/12 equals 4. The reason for this is that a bit x in 12 bits after 12-fold rotation again
reaches the same position prior to the rotation.
For this reason, specify a value in the range from 0 to 15 as n.
7 – 40
Data rotation instructions ROR, RORP, RCR, RCRP
Program RORP
Example 1
With leading edge from XC, the following program rotates the contents of D0 by 3 bits to the
right.
5
Carry flag SM700
Program RCRP
Example 2
With leading edge from XC, the following program rotates the contents of D0 by 3 bits to the
right; the carry flag SM700 is included. The condition of SM700 (0/1) prior to the rotation is
moved to the right by 3 digits.
4
Contents of bit b3 before the rotation
5 Contents of bit b2 before the rotation
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ROL__GE1
7 – 42
Data rotation instructions ROL, ROLP, RCL, RCLP
ROL_0E1
1
Rotation by n bits
2
Carry flag SM700
RCL_0E1
1
Rotation by n bits
2
Carry flag SM700
NOTE If a bit device is designated by d, the rotation operation is performed with a device supplying the
specified number of digits. The number of digits the bits are rotated by is determined by the
remainder of the following quotient:
Number of rotations n / number of bits
For example, 16 rotations of 12 bits correspond to a rotation by 4 bits, since the remainder of the
quotient 16/12 equals 4. The reason for this is that a bit x in 12 bits after 12-fold rotation again
reaches the same position prior to the rotation.
For this reason, specify a value in the range from 0 to 15 as n.
Program ROLP
Example 1
With leading edge from XC, the following program rotates the contents of D0 by 3 bits to the left.
4
Contents of bit b12 before the rotation
5
Carry flag SM700
Program RCLP
Example 2
With leading edge from XC, the following program rotates the contents of D0 by 3 bits to the
left; the carry flag SM700 is included. The condition of SM700 (0/1) prior to the rotation is
moved to the left by 3 digits.
4
Contents of bits b14 and b15 before the rotation
5
Contents of carry flag SM700 before the rotation
6
Carry flag SM700
7 – 44
Data rotation instructions DROR, DRORP, DRCR, DRCRP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DROR_GE1
DROR0E1
1 Rotation by n bits
2
Carry flag SM700
DRCR0E1
1 Rotation by n bits
2 Carry flag SM700
NOTE If a bit device is designated by d, the rotation operation is performed with a device supplying the
specified number of digits. The number of digits the bits are rotated by is determined by the
remainder of the following quotient:
Number of rotations n / number of bits
For example, 31 rotations of 24 bits correspond to a rotation by 7 bits, since the remainder of the
quotient 31/24 equals 7. The reason for this is that a bit x in 24 bits after 24-fold rotation again
reaches the same position prior to the rotation.
For this reason, specify a value in the range from 0 to 31 as n.
7 – 46
Data rotation instructions DROR, DRORP, DRCR, DRCRP
Program DRORP
Example 1
With leading edge from XC, the following program rotates the contents of D0 and D1 by 4 bits
to the right.
1
Contents of bits b3-b0 before the rotation
2
Contents of bits b31-b4 before the rotation
3
Contents of bit b3 before the rotation
4
Carry flag SM700
DROR_MB1, DROR_KB1, DROR_IB1, DROR0B1
Program DRCRP
Example 2
With leading edge from XC, the following program rotates the contents of D0 and D1 by 4 bits
to the right; the carry flag SM700 is included. The condition of SM700 (0/1) prior to the rotation
is moved to the right by 4 digits.
1
Contents of bits b2–b0 before the rotation
2
Contents of carry flag SM700 before the rotation
3
Contents of bits b5–b31 before the rotation
4
Contents of bit b4 before the rotation
5
Contents of bit b3 before the rotation
6 Carry flag SM700
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DROL_GE1
7 – 48
Data rotation instructions DROL, DROLP, DRCL, DRCLP
DROL0E1
1 Rotation by n bits
2
Carry flag SM700
DROL0E1
1 Rotation by n bits
2 Carry flag SM700
NOTE If a bit device is designated by d, the rotation operation is performed with a device supplying the
specified number of digits. The number of digits the bits are rotated by is determined by the
remainder of the following quotient:
Number of rotations n / number of bits
For example, 31 rotations of 24 bits correspond to a rotation by 7 bits, since the remainder of the
quotient 31/24 equals 7. The reason for this is that a bit x in 24 bits after 24-fold rotation again
reaches the same position prior to the rotation.
For this reason, specify a value in the range from 0 to 31 as n.
Program DROLP
Example 1
With leading edge from XC, the following program rotates the contents of D0 and D1 by 4 bits
to the left.
3
Contents of bit b28 before the rotation
4
Carry flag SM700
Program DRCLP
Example 2
With leading edge from XC, the following program rotates the contents of D0 and D1 by 4 bits
to the left; the carry flag (SM700) is included. The condition of SM700 (0/1) prior to the rotation
is moved to the left by 4 digits.
5
Carry flag SM700
NOTE These programs will not run without variable definition in the header of the program organization
unit (POU). They would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 50
Data shift instructions
The shift instructions move data by bits or blocks of data within one data word. Data can be
shifted to the right as well as to the left.
The following table gives an overview of these instructions:
NOTE Within the IEC editors please use the IEC instructions.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SFR__GE1
7 – 52
Data shift instructions SFR, SFRP, SFL, SFLP
SFR_0E1
1
These bits are set to 0.
2 Carry flag SM700
The most significant n bits beginning from bit b15 on are set to 0. The nth bit (b(n-1)) to be
shifted is moved to the carry flag (SM700).
For timers and counters, the actual value (count) is shifted. The setting value cannot be shifted.
For bit devices, shifting within a device with a specified number of bits is feasible (see program
example 1).
SFL_0E1
1
These bits are set to 0.
2 Carry flag SM700
The least significant n bits beginning from bit b0 on are set to 0. The nth bit (b(15-n)) to be
shifted is moved to the carry flag (SM700).
For timers and counters, the actual value (count) is shifted. The setting value cannot be shifted.
For bit devices, shifting within a device with a specified number of bits is feasible (see program
example 1).
Program SFRP
Example 1
With leading edge from X20, the following program shifts the content of Y10 through Y1B by
the number of bits specified by D0 to the right. The condition of Y13 is stored in the carry flag
(SM700).
Program SFLP
Example 2
With leading edge from X1C, the following program shifts the content of Y10 through Y18 by 3
bits to the left. The condition of Y15 is stored in the carry flag (SM700).
7 – 54
Data shift instructions BSFR, BSFRP, BSFL, BSFLP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BSFR_GE1
BSFR0E1
1
This bit is set to 0.
2
Carry flag SM700
BSFL0E1
1 This bit is set to 0.
2 Carry flag SM700
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n exceeds the available number of bits in the device designated by d.
(Error code 4101)
7 – 56
Data shift instructions BSFR, BSFRP, BSFL, BSFLP
Program BSFRP
Example 1
With leading edge from X8F, the following program shifts data of the internal relays M668
through M676 by one bit to the right. M668 retains the value of M669, M669 that of M670 etc.
The contents of the first device (M668) is written to the carry flag (SM700), and the last device
(M676) retains the value 0.
Program BSFLP
Example 2
With leading edge from X4, the following program shifts the contents of the outputs Y60
through Y6F by one device to the left. The contents of the last output (Y6F) is stored in the carry
flag (SM700), and the first output (Y60) is reset to 0.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SFTBR/SFTBL
d n1 n2
B
S
F
R
_
G
E
1 P n1 n2
d
7 – 58
Data shift instructions SFTBR, SFTBRP, SFTBL, SFTBLP
n1=10, n2=4
n1
n2
1)
1
These bits are set to 0.
2
Carry flag SM700
n1 and n2 are specified under the condition that n1 is larger than n2. If the value of n2 is equal
to or larger than the value of n1, the remainder of n2 / n1 (n2 devided by n1) is used for a shift.
This instruction specifies n1 ranged from 1 to 64.
Bits starting from the highest bit to n2th bit are filled with 0s. If the value of n2 is larger than the
value of n1, the remainder of n2 / n1 will be 0.
If the value specified by n1 or n2 is 0, the instruction will be not processed.
n1=10, n2=4
n1
n2
2)
1
d+9 d+8 d+7 d+6 d+5 d+4 d+3 d+2 d+1 d
1 1 1 1 0 1 0 0 0 0
1)
1
These bits are set to 0.
2 Carry flag SM700
n1 and n2 are specified under the condition that n1 is larger than n2. If the value of n2 is equal
to or larger than the value of n1, the remainder of n2 / n1 (n2 devided by n1) is used for a shift.
However, if the remainder of n2 / n1 is 0, the instruction will be not processed.
This instruction specifies n1 ranged from 1 to 64.
Bits starting from the highest bit to n2th bit are filled with 0s. If the value of n2 is larger than the
value of n1, the remainder of n2 / n1 will be 0.
If the value specified by n1 or n2 is 0, the instruction will be not processed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified by n1 is other than 0 to 64. (Error code 4100)
● The value in n2 is negative. (Error code 4100)
● The value in n1 exceeds the available number of bits in the device designated by d.
(Error code 4101)
Program SFTBRP
Example 1
The following program shifts the data of Y10 to Y17 (8 bits) specified by d to the right by 2 bits
(n2), when M0 is turned on.
1
Carry flag SM700
Program SFTBLP
Example 2
The following program shifts the data of Y21 to Y2C (12 bits) specified by d to the left by 5 bits
(n2), when M0 is turned on.
Y2C Y2B Y2A Y29 Y28 Y27 Y26 Y25 Y24 Y23 Y22 Y21
1 0 1 1 0 1 0 1 1 0 0 1
1)
0 Y2C Y2B Y2A Y29 Y28 Y27 Y26 Y25 Y24 Y23 Y22 Y21
1 0 1 1 0 0 1 0 0 0 0 0
1
Carry flag SM700
7 – 60
Data shift instructions DSFR, DSFRP, DSFL, DSFLP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DSFR_GE1
DSFR0E1
1
This device is set to 0.
DSFL0E1
1
This device is set to 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n exceeds the available number of points in the device designated by d.
(Error code 4101)
7 – 62
Data shift instructions DSFR, DSFRP, DSFL, DSFLP
Program DSFRP
Example 1
With leading edge from XB, the following program shifts data in the data registers D683 through
D689 by one address to the right. D683 retains the value of D684, D684 that of D685 etc. The
contents of the last data register (D689) retains the value 0.
Program DSFLP
Example 2
With leading edge from XB, the following program shifts data in the data registers D683 through
D689 by one address to the left. D689 retains the value of D688, D688 that of D687 etc. The
contents of the first data registers (D683) retains the value 0.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SFTWR/SFTWL
d n1 n2
D
S
F
R
_
G P d n1 n2
E
1
7 – 64
Data shift instructions SFTWR, SFTWRP, SFTWL, SFTWLP
n1=9, n2=4
n1
n2
1)
1 Set to 0H
The n2 words data in the devices starting from the highest device are filled with 0s.
If the value specified by n1 or n2 is 0, the instruction will be not processed.
If the value of n2 is equal to or larger than the value of n1, the n1 words data in the devices
starting from the device specified by d will be filled with 0s.
n1=9, n2=4
n1
n2
3AH 1F H 30 H 0H FFH 0H 0H 0H 0H
1)
1
Set to 0H
The n2 words data in the devices starting from the lowest device are filled with 0s.
If the value specified by n1 or n2 is 0, the instruction will be not processed.
If the value of n2 is equal to or larger than the value of n1, the n1 words data in the devices
starting from the device specified by d will be filled with 0s.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n1 or n2 is negative. (Error code 4100)
● The range of devices specified by n1 exceeds the range of devices specified by d.
(Error code 4101)
Program SFTWRP
Example 1
The following program shifts the 8 words (n1 = 8) data stored in the devices starting from D10
specified by d to the right by 2 words (n2 = 2), when M0 is turned on.
1
Set to 0H
Program SFTWLP
Example 2
The following program shifts the 12 words (n1 = 12) data stored in the devices starting from
D21 specified by d to the left by 5 words (n2 = 5), when M0 is turned on.
D2C D2B D2A D29 D28 D27 D26 D25 D24 D23 D22 D21
FFH EH 5H 0H 2AH FFH 3AH 1H 0H 0H 10 H 7FFH
D2C D2B D2A D29 D28 D27 D26 D25 D24 D23 D22 D21
FFH 3AH 1H 0H 0H 10 H 7FFH 0H 0H 0H 0H 0H 1)
1
Set to 0H
7 – 66
Bit processing instructions SFTWR, SFTWRP, SFTWL, SFTWLP
The bit processing instructions change the condition (set and reset) of single bits or entire sec-
tions of bits. The condition of bits in data words can as well be tested with the bit processing
instructions.
The following table gives an overview of these instructions:
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BSET_GE1
7 – 68
Bit processing instructions BSET, BSETP, BRST, BRSTP
BSET0E1
1
This bit is set.
BRST0E1
1 This bit is reset.
Program BRSTP/BSETP
Example
The following program resets the 8th bit of D8 (b8) to 0 when the input XB is switched OFF,
and sets the 3rd bit of D8 (b3) to 1 when XB is switched ON.
b15 b8 b3 b0
D8 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1
b15 b8 b3 b0
D8 0 0 1 1 0 1 0 0 1 1 1 1 1 0 0 1
NOTE Single bits in bit devices can be set or reset via a SET or an RST instruction as well. In this case
the bits of the word device must be specified. For example, the bit (b8) in data word D5 is
addressed as D5.8.
7 – 70
Bit processing instructions TEST, TESTP, DTEST, DTESTP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
TEST_GE1
TEST0E1
1
Tested bit
DTEST0E1
1
Tested bit
7 – 72
Bit processing instructions TEST, TESTP, DTEST, DTESTP
Program TESTP
Example 1
Depending on the test result of the bit (b10) in the 16-bit data word in D0, the following program
either resets or sets relay M0.
Program DTESTP
Example 2
Depending on the test result of the bit (b19) in the 32-bit data word in W0 and W1, the following
program either resets or sets output Y40.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
Instead of applying the TEST instruction, a bit to be tested can also be specified as an input con-
tact (see diagram).
TEST_AB1
7 – 74
Bit processing instructions BKRST, BKRSTP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BKRSTGE1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n exceeds the number of bits of the devices designated by s.
(Error code 4101)
Program BKRSTP
Example 1
With leading edge from X0, the following program resets the relays M0 through M7.
7 – 76
Bit processing instructions BKRST, BKRSTP
Program BKRSTP
Example 2
With leading edge from X20, the following program resets bits from the bit (b2) in D10 to the
bit (b1) in D11.
7 – 78
Data processing instructions
7 – 80
Data processing instructions SER, SERP, DSER, DSERP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SER_GE1
3 6
2 7
1 Entry code
2
Start of search
3 Search range (n blocks)
4 Matching data
5
Search results
6 Position of match
7 Number of matches
SER_0E1
If the value in n is less than or equal to 0, the search operation will not be executed.
If no matching data is found, the content of d and d+1 (array_d[1] and array_d[2]) is 0.
7 – 82
Data processing instructions SER, SERP, DSER, DSERP
NOTE Provided the data to be searched through is stored in ascending order, the searching time can
be shortened by setting the special relay SM702.
SM702 ON:
The search range is halved and the size of the entry code determines in what half the code must
be stored. This half is devided once again for another decision. This operation is proceeded until
the matching value is found.
1 Entry code
2
Search range
3
Comparison to entry code
4 Processing sequence
5
Search data
DSER0E2
SM702 OFF:
The data search comparing the entry code to each data value starts from the beginning of the
search range.
If the search range is not sorted in ascending order, there will be no accurate result with SM702
set.
6
7
1
Entry code
2 Start of search
3 Search range (2 x n)
4
Matching data
5 Search results
6 Position of match
7
Number of matches
DSER0E1
If the value in n is less than or equal to 0, the search operation will not be executed.
If no matching data is found, the content of d and d+1 is 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The search range designated by n beginning from s2 exceeds the relevant device range.
(Error code 4101)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
For details on index qualification refer to section 3.6.
7 – 84
Data processing instructions SER, SERP, DSER, DSERP
Program SERP
Example 1
With leading edge from X20, the following program compares data in D100 through D105 to
the data value in D0. The first matching position is stored in W0. The number of matches is
stored in W1.
2 4
2 5
1
Entry code
2
Search range
3 Search results
5
Number of matches
SER__MB1, SER__KB1, SER__IB1, SER_0B1
Program DSERP
Example 2
With leading edge from X20, the following program compares data in D100 through D111 to
the data value in D11 and D10. The first matching position is stored in W0. The number of
matches is stored in W1.
2 4
3 5
1
Entry code
2
Search range
3 Search results
5
Number of matches
SER__MB2, SER__KB2, SER__IB2, DSER_0B1
NOTE These programs will not run without variable definition in the header of the program organiza-
tion unit (POU). They would cause compiler or checker error messages. For details see section
3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 86
Data processing instructions SUM, SUMP, DSUM, DSUMP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SUM_GE1
1
Counting set bits
2
Binary coded number of bits (In this example 8 bits are set.)
SUM_0E1
DSUM 32-bit
The DSUM instruction determines the number of bits set in a 32-bit data word. The device
range to be checked is specified by s. The number of set bits is stored in d.
1
Counting set bits
2
Binary coded number of bits (In this example 16 bits are set.)
DSUM0E1
7 – 88
Data processing instructions SUM, SUMP, DSUM, DSUMP
Program SUMP
Example 1
With leading edge from X10, the following program determines the number of set inputs within
X8 through X10. The result is stored in D0.
1
Storing the number of set bits in D0
SUM__MB1, SUM__KB1, SUM__IB1, SUM_0B1
Program DSUMP
Example 2
With leading edge from X10, the following program determines the number of set bits in D100
and D101. The result is stored in D0.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DECO_GE1
7 – 90
Data processing instructions DECO, DECOP
1
2
1 Binary value of s: 6
2
Bit b6 in d is set.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The variable n is not set between 0 and 8. (Error code 4100)
● The bit x exceeds the relevant device range. (Error code 4101)
Program DECOP
Example
With leading edge from X20, the following program decodes data at X0 through X2. The result
is stored in M10 through M17. The binary coded number 6 is contained in X0 through X2, so
bit b6 (M16) in M10 through M17 is set.
1
Binary coded value 6
2
If the binary coded value is specified as 3 bits, 8 bits are occupied.
DECO_MB1, DECO_KB1, DECO_IB1, DECO0B1
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 92
Data processing instructions ENCO, ENCOP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ENCO_GE1
& % $ # " !
I 1
@ 2
1 Bit b6 In s is set.
2 Binary value of d: 6
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The variable n is not set between 0 and 8. (Error code 4100)
● All data 2n bits from s are "0". (Error code = 4100)
● The range 2n bits from s exceeds the range of the relevant device. (Error code 4101)
7 – 94
Data processing instructions ENCO, ENCOP
Program ENCOP
Example
With leading edge from X20, the following program reads data in M10 through M17 and stores
it binary encoded in D8.
1
If the encoded value is stored in 3 bits in d, 8 bits are occupied in s.
2
Binary encoded number 3 for set bit 3 (M13)
ENCO_MB1, ENCO_KB1, ENCO_IB1, ENCO0B1
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SEG_GE1
7 – 96
Data processing instructions SEG, SEGP
1
Bit device
2 Word device
3 8 bits
4
These bits are always reset to 0.
5 7-segment data
SEG_0E1
7-segment data
The following table contains an overview of 7-segment data in relation to the bit pattern of the
source data. The first bit (b0) of 7-segment data either represents the status of the first bit
device or the status of the least significant bit in a word device respectively.
s d
Assignment of Segments Display
HEX Bit Pattern B7 B6 B5 B4 B3 B2 B1 B0
0 0000 0 0 1 1 1 1 1 1 0
1 0001 0 0 0 0 0 1 1 0 I
2 0010 0 1 0 1 1 0 1 1 2
3 0011
b0
0 1 0 0 1 1 1 1 3
4 0100 0 1 1 0 0 1 1 0 4
5 0101 b5
b1 0 1 1 0 1 1 0 1 5
b6
6 0110 0 1 1 1 1 1 0 1 6
7 0111 b4
b2
0 0 1 0 0 1 1 1 7
8 1000 0 1 1 1 1 1 1 1 8
9 1001 b3 0 1 1 0 1 1 1 1 9
A 1010 0 1 1 1 0 1 1 1 A
B 1011 0 1 1 1 1 1 0 0 B
C 1100 0 0 1 1 1 0 0 1 C
D 1101 0 1 0 1 1 1 1 0 D
E 1110 0 1 1 1 1 0 0 1 E
F 1111 0 1 1 1 0 0 0 1 F
7 – 98
Data processing instructions SEG, SEGP
Program SEGP
Example
With leading edge from X0, the following program outputs the condition of inputs XC through
XF as 7-segment code to the outputs Y38 through Y3F. The conditions of outputs Y38 through
Y3F are maintained until they are overwritten with new data.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DIS__GE1
7 – 100
Data processing instructions DIS, DISP
1
These bits are reset to 0.
2 Storage area
DIS_0E1
The upper 12 bits of the destination devices beginning from device number in d, are reset to 0.
The variable n can be set from 1 to 4 (corresponding 4 to 16 bits).
For n = 0 no operation is executed and the specified number of device remains unchanged.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n is not set between 0 and 4.
(Error code 4100)
● The storage range d specified by n exceeds the relevant device range.
(Error code 4101)
Program DISP
Example
With leading edge from X0, the following program disunites the 16-bit data value in D0 and
stores the bit pattern in groupings of 4 bits in series in D10 through D13.
1
These bits are reset to 0.
2
Storage area
DIS__MB1, DIS__KB1, DIS__IB1, DIS_0B1
7 – 102
Data processing instructions UNI, UNIP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
UNI_GE1
1
These bits are ignored.
2 4-bit groupings to be stored in d
UNI_0E1
The lower 4 bits of the source devices beginning from device number in d, are reset to 0.
The variable n can be set from 1 to 4.
For n = 0 no operation is executed and the specified number of device remains unchanged.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n is not set within 0 and 4.
(Error code 4100)
● The storage range s specified by n exceeds the relevant device range.
(Error code 4101)
7 – 104
Data processing instructions UNI, UNIP
Program UNIP
Example
With leading edge from X0, the following program unites each lowest 4 bits (b0 through b3) of
data registers D0 through D2 successively to one 16-bit data value (the highest 4 digits are "0")
in D10.
1
4-bit groupings to be stored in D10
UNI__MB1, UNI__KB1, UNI__IB1, UNI_0B1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
NDIS_GE1
7 – 106
Data processing instructions NDIS, NDISP, NUNI, NUNIP
1
Size of bit grouping
2
The 0 indicates the end of processing.
NDIS0E1
The size of bit groupings specified by s2 can be set within 1 and 16 bits.
Values in s2 are processed from the first device address in s2 on and up to the address with
the entry 0.
Do not overlap the device range for data to be dissociated (s1 to end range of s1) with the
device range which stores the dissociated data (d to end range of d). If overlapped, the correct
operation result may not be obtained.
Do not specify the same device number for s1, s2, and d. In this case the operation does not
work correctly.
1
Size of bit groupings
2
The 0 indicates the end of processing.
NUNI0E1
The size of bit groupings specified by s2 can be set within 1 and 16 bits.
Values in s2 are processed from the first device address in s2 on and up to the address with
the entry 0.
Do not overlap the device range for data to be linked (s1 to end range of s1) with the device
range which stores the linked data (d to end range of d). If overlapped, the correct operation
result may not be obtained.
Do not overlap the device numbers to be designated at s1, s2, and d. In this case the operation
does not work correctly.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The bit groupings of a size specified by s2 in the devices specified by s1 or d exceed the
relevant storage device range.
(Error code 4101)
● The size of bit groupings specified by s2 exceeds the valid range of 1 to 16 bits.
(Error code 4100)
7 – 108
Data processing instructions NDIS, NDISP, NUNI, NUNIP
Program NDISP
Example 1
The following program separates the bit groupings b0 to b3 (4), b4 to b6 (3), and b7 to b12 (6)
from D0 and stores each single bit grouping beginning from bit grouping b0 to b3 in D10
through D12.
The values in brackets indicate the size of bit groupings in D20 through D22. D23 must store
the value 0 (see functions).
1
These bits are ignored.
2 These bits are reset to 0.
NDIS_MB1, NDIS_KB1, NDIS_IB1, NDIS0B1
Program NUNIP
Example 2
The following program separates the bit groupings b0 to b3 (4), b0 to b2 (3), and b0 to b5 (6)
from D10 through D12 and stores the bit groupings successively in D0 beginning from bit
grouping b0 to b3.
The values in brackets indicate the size of bit groupings in D20 through D22. D23 must store
the value 0 (see functions).
1
These bits are ignored.
2 These bits are reset to 0.
NDIS_MB2, NDIS_KB2, NDIS_IB2, NUNI0B1
7 – 110
Data processing instructions WTOB, WTOBP, BTOW, BTOWP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
WOB_GE1
1
Highest bytes
2
Lowest bytes
3
Data of the according lowest bytes
4 Data of the according highest bytes
WTOB0E1
For example, if n = 5, 5 bytes are disunited from the device specified by s through s+2 and
stored successively in the lowest bytes of the devices specified by d through d+4.
7 – 112
Data processing instructions WTOB, WTOBP, BTOW, BTOWP
BTOW0E1
For example, if n = 5, the 5 lowest bytes are disunited from the device specified by s through
s+4 and stored successively in the devices specified by d through d+2.
1
This byte is set to "00H".
BTOW0E2
The number of byte units specified by n automatically determines the range of byte data in s
and the storage range of the byte data in d.
If n = 0, the instruction is not executed and the specified device addresses remain unchanged.
The highest bytes in the devices specified by s are ignored on processing.
The operation is even processed correctly in cases where the storage ranges of s through s+n
and d through d+n overlap. The following diagram shows a case where the lowest bytes are
separated from D11 through D16 and stored again succcessively in D12 through D14.
BTOW0E3
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of byte units specified by n, that are stored in the device specified by s, exceeds
the relevant storage device range.
(Error code 4101)
● The number of byte units specified by n, that are stored in the device specified by d, exceeds
the relevant storage device range.
(Error code 4101)
Program WTOBP
Example 1
With leading edge from X0, the following program separates 6 bytes in D10 through D12 suc-
cessively and stores these bytes in the lowest bytes in D20 through D25.
7 – 114
Data processing instructions WTOB, WTOBP, BTOW, BTOWP
Program BTOWP
Example 2
With leading edge from X0, the following program separates the 6 lowest bytes in registers D20
through D25 and unites these bytes successively in D10 through D12.
1
These bytes are ignored.
WTOB_MB2, WTOB_KB2, WTOB_IB2, BTOW0B1
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MAX__GE1
7 – 116
Data processing instructions MAX, MAXP, DMAX, DMAXP
1
Found maximum value
2
First position the value has been found at
3 Number of identical maximum values
DMAX_0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks specified by n stored in the devices specified by s exceeds the
relevant storage device range.
(Error code 4101)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program MAXP
Example 1
With leading edge from X1C, the following program subtracts data in R0 through R3 from data
in D100 through D103 and stores the result in D150 through D153. The number of 16-bit data
blocks (4) is specified in D0.
In the following step, as well with leading edge from X1C, the registers D150 through D153 are
searched through for the maximum value. The value found is stored in D200, its position is
stored in D201, and the number of identical maximum values is stored in D202.
Program DMAXP
Example 2
With leading edge from X20, the following program searches for the maximum value of 32-bit
data in D100 and D101. The position of the value is stored in D102, the number of identical
maximum values is stored in D103.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 118
Data processing instructions MIN, MINP, DMIN, DMINP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MIN__GE1
1
Found minimum value
2
First position the value has been found at
3
Number of identical minimum values
DMIN_0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of data blocks specified by n stored in the devices specified by s exceeds the
relevant storage device range.
(Error code 4101)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 120
Data processing instructions MIN, MINP, DMIN, DMINP
Program MINP
Example 1
With leading edge from X1C, the following program adds data in D100 through D103 to data in
R0 through R3 and stores the result in D150 through D153. The number of 16-bit data blocks
(4) is specified in D0.
In the following step, as well with leading edge from X1C, the registers D150 through D153 is
searched through for the minimum value. The value found is stored in D200, its position is
stored in D201, and the number of identical minimum values is stored in D202.
Program DMINP
Example 2
With leading edge from X20, the following program searches for the minimum value of 32-bit
data in D0 through D7 and stores the value in D100 and D101. The position of the value is
stored in D102, the number of identical minimum values is stored in D103.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SORT_GE1
7 – 122
Data processing instructions SORT, DSORT
1
Data to be sorted
2
Data sorted in ascending order (SM703 = OFF)
3
Data sorted in descending order (SM703 = ON)
SORT_0E1
For finishing the SORT instruction several scans are required. The number of required scans
can be calculated by the division of the maximum number of scans by the number of 16-bit data
specified in s2, to be compared each scan (decimal fractions are rounded up). Increasing the
number of 16-bit data specified in s2 reduces the number of required scans for sorting but
increases the processing time per scan.
The required number of sorting scans until finishing the sort operation is calculated via the fol-
lowing equation:
Required number of sorting scans = ((n) x (n-1)) / (2 x (s2))
For example, for n = 10 and s2 = 1 the result is 45 sort scans until finishing the sort operation.
For n = 10 and s2 = 2 the result is 22.5. Rounded up, 23 sort scans are required.
The bit specified in d1 is reset during the sort operation and will be set again when the sort
operation is finished. This bit remains set and must be reset by appropriate programming.
The devices specified in d2 and (d2)+1 are used for internal system processing during the sort
operation. So, these devices must not be changed by programming.
If the value in n is changed during the operation, the operation is processed with the currently
set number of 16-bit data.
By resetting the execution condition, the operation will be terminated. Upon setting the execu-
tion condition again, the sort operation will be restarted.
To execute another sort operation immediately after the completion of the previous sort, turn
OFF the execution command once, then turn it ON.
1 Data to be sorted
2
Data sorted in ascending order (SM703 = OFF)
3
Data sorted in descending order (SM703 = ON)
DSORT0E1
For finishing the DSORT instruction several scans are required. The number of required scans
can be calculated by the division of the maximum number of scans by the number of 32-bit data
specified in s2, to be compared each scan (decimal fractions are rounded up). Increasing the
number of 32-bit data specified in s2 reduces the number of required scans for sorting but
increases the processing time per scan.
The required number of sorting scans until finishing the sort operation is calculated via the fol-
lowing equation:
Required number of sorting scans = ((n) x (n-1)) / (2 x (s2))
For example, for n = 10 and s2 = 1 the result is 45 sort scans until finishing the sort operation.
For n = 10 and s2 = 2 the result is 22.5. Rounded up, 23 sort scans are required.
The bit specified in d1 is reset during the sort operation and will be set again when the sort
operation is finished. This bit remains set and must be reset by appropriate programming.
The devices specified in d2 and (d2)+1 are used for internal system processing during the sort
operation. So, these devices must not be changed by programming.
If the value in n is changed during the operation, the operation is processed with the currently
set number of 32-bit data.
By resetting the execution condition, the operation will be terminated. Upon setting the execu-
tion condition again, the sort operation will be restarted.
To execute another sort operation immediately after the completion of the previous sort, turn
OFF the execution command once, then turn it ON.
7 – 124
Data processing instructions SORT, DSORT
Operation In the following cases an operation occurs, the error flag (SM0) turns ON, and an error code is
Errors stored into SD0.
● The range specified by n (SORT, SORTP) or 2 x n (DSORT, DSORTP) in the device specified
by s1 exceeds the relevant storage device range.
(Error code 4101)
● s2 is 0 or is a negative value.
(Error code: 4100)
● The device range of the (n/2 x n) points starting from the device designated by s1 overlaps
with the device range of the 2 points starting from the device designated by d2.
(Error code: 4101)
Program SORT
Example
While X3 is set, the following program sorts 16-bit data in D1 through D4. In a first step with
leading edge from X2, the values 35, -10, 500, and -124 are written to the registers D1 through
D4. Then sorting starts. The sorting order is determined via X0 (set SM703) and X1 (reset
SM703). After finishing the sort operation the output Y10 is set.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
WSUM_GE1
7 – 126
Data processing instructions WSUM, WSUMP
WSUM0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The range specified by n in the device specified by s exceeds the relevant storage device
range.
(Error code 4101)
Program WSUMP
Example
With leading edge from X1C, the following program adds BIN 16-bit data blocks in D10 through
D14 and stores the result in D100 and D101.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DWSUMGE1
7 – 128
Data processing instructions DWSUM, DWSUMP
DWSUM0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The range specified by n in the device specified by s exceeds the relevant storage device
range.
(Error code 4101)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program DWSUMP
Example
With leading edge from X20, the following program adds 32-bit BIN data blocks in D100
through D107 and stores the result in D10 through D13.
NOTE This program will not run without variable definition in the header of the program organization
unit (POU). It would cause compiler or checker error messages. For details see section 3.5.2
"Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MEAN/DMEAN
4
s d n
P s d n
6
7 – 130
Data processing instructions
s
Average value d
s+1
s+2 n
s+(n–1)
If the value calculated is not integer, this instruction will drop the number of decimal places.
If the value specified by n is 0, the instruction will be not processed.
s +2n 1, s +2n 2
If the value calculated is not integer, this instruction will drop the number of decimal places.
If the value specified by n is 0, the instruction will be not processed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified by n is other than 0 to 32767.
(Error code 4100)
● The range of the n-point devices starting from the device specified by s exceeds the range
of the devices specified by d.
(Error code 4101)
Program MEAN
Example 1
The following program stores the average value of 16-bit data stored from D0 to D2 into D10,
when M0 is turned on.
D0 105 (BIN)
D1 555 (BIN) D10 550 (BIN)
D2 990 (BIN)
Program DMEAN
Example 2
The following program stores the average value of 32-bit data stored from D0 to D5 into D10
and D11, when M0 is turned on.
7 – 132
Structured program instructions
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FOR_GE1
7 – 134
Structured program instructions FOR, NEXT
FOR__AB1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The END/FEND or GOEND instruction is executed after a FOR instruction and before the
NEXT instruction.
(Error code 4200)
● The NEXT instruction is executed before the FOR instruction.
(Error code 4201)
● A STOP instruction is programmed within a FOR/NEXT loop.
(Error code 4200)
● The maximum number of nesting levels is exceeded.
(Error code 4202)
NOTES In order to terminate the execution of a FOR/NEXT loop before it is finished, a BREAK instruction
must be programmed.
Apply the EGP/EGF instruction, to connect a switch condition to the FOR/NEXT instruction.
Branching into a FOR to NEXT loop using a JMP or other branch instruction from the outside of
the FOR to NEXT loop is not possible.
Program The following program processes the program sequence between FOR and NEXT for four
Example times, if X8 is OFF. The FOR/NEXT loop is skipped, if X8 is ON.
7 – 136
Structured program instructions BREAK, BREAKP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
(IEC Instruction)
GX Works2
BREAKGE1
BREAKAB1
The number of remaining FOR/NEXT loops to be executed is stored in the device specified
by d. Note that the remaining number includes the operation when the BREAK instruction is
executed.
The BREAK instruction can only be applied during the execution of a FOR/NEXT loop.
The BREAK instruction can only be applied to one nesting level. For several nesting levels the
appropriate number of BREAK instructions must be executed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The BREAK instruction was executed without a FOR/NEXT loop.
(Error code 4203)
● The jump destination for the pointer designated by Pn does not exist.
(Error code: 4210)
● The pointer of another program file is designated for Pn.
(Error code: 4210)
7 – 138
Structured program instructions BREAK, BREAKP
Program BREAKP
Example
The following program terminates the execution in the 30th FOR/NEXT loop and jumps to the
program part specified with label_0. The number of remaining FOR/NEXT loops (70) is stored
in D1.
CPU High
Basic Process Redundant Universal LCPU
Performance
s1
– 1) —
s5
1
Annunciators (F) cannot be used
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
CALL_ME1, CALL_KE1
GX Works2
CALL_GE1
NOTE The CALL instruction should not be used with the IEC editor because the subroutine structure
is generated bx the GX IEC Developer.
7 – 140
Structured program instructions CALL, CALLP
When function devices (FX, FY, FD) are used by a subroutine program, specify a device with
s1 to s5 corresponding to the function device. The contents to the devices specified by s1 to
s5 are as indicated below.
Prior to execution of the subroutine program, bit data is transmitted to FX, and word data is
transmitted to FD.
After the execution of the subroutine program, the contents of FY and FD are transmitted to the
corresponding devices.
The processing units for the function devices are as follows:
● FX, FY: Bits
● FD: 4-word units
The size of the data to be dealt with will differ depending on the device specified in the argu-
ment. The device specified as a function device should be secured for the data size. An error
will occur if it cannot be secured for the data size.
When digit designation of a bit device is used 1) 4 words The data size varies depen-
FD ding on the instruction to be
Word device 4 words used.
1 An error will not occur even when the device number specified by s1 to s5 is not a multiple of 16 at the
digit designation of the bit device.
X0
CALL P0 M0 D0 D30
7 – 142
Structured program instructions CALL, CALLP
D0 0 D0 0 D0 0 D0 33 *2
D1 10 D1 10 D1 110 *1 D1 110 *3
D2 100 D2 100 D2 100 D2 100 *2
Transfer Transfer
D3 1000 D3 1000 D3 1000 D3 1000 *2
Indefinite 0 33 *1 Indefinite
Indefinite 10 1 *1 Indefinite
FD0 FD0 FD0 FD0
Indefinite 100 100 Indefinite
Indefinite 1000 1000 Indefinite
1
Stores the execution result of the subroutine program.
2
Replaced by the value of the function device.
3
D1 does not reflect the value of the function device.
D0 0 D0 0 D0 0 D0 33 *2
D1 10 D1 10 D1 10 D1 1 *2
D2 100 Transfer D2 100 D2 100 D2 100 *2
D3 1000 D3 1000 D3 1000 Transfer D3 1000 *2
D4 0 D4 0 D4 100 *1 D4 100
Indefinite 0 33 *1 Indefinite
Indefinite 10 1 *1 Indefinite
FD0 FD0 FD0 FD0
Indefinite 100 100 Indefinite
Indefinite 1000 1000 Indefinite
The CALL instruction calls a subroutine program specified by pointer (label) addresses. In
total, up to 16 subprogram nesting levels can be addressed.
END
Devices that were set during the execution of a subroutine program remain set, even if the rou-
tine is not executed any longer. In order to reset these devices the FCALL instruction has to be
applied.
7 – 144
Structured program instructions CALL, CALLP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified for the argument cannot be secured for the data size. (Error code 4101)
● After execution of a CALL instruction an END, FEND, GOEND, or STOP instruction is
executed, without a prior RET instruction. (Error code 4211)
● A RET instruction is executed before a CALL instruction.
(Error code 4212)
● More than 16 nesting levels are executed.
(Error code 4213)
● There is no subroutine program stored at the specified pointer/label.
(Error code 4210)
Program CALL
Example
While X20 is set, the following program executes the subroutine program at pointer/label P_0.
CALL_MB1, CALL_KB1
NOTES In MELSEC-mode, the FEND, END, and RET instructions have to be programmed by the user.
After the program organization unit has been processed no further one will be executed because
it would follow the FEND instruction.
Alternatively to this programming, the IEC editor can be used. In that case the FEND instruction
would be set by the compiler of the GX IEC Developer automatically.
7.6.4 RET
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
RET__ME1, RET__KE1
GX Works2
RET__GE1
7 – 146
Structured program instructions RET
RET_0E1
1
Main routine program
2
Subroutine program
NOTE In the MELSEC-mode the FEND, END, and RET instructions have to be programmed by the
user. After the program organization unit has been processed no further one will be executed
because it would follow the FEND instruction.
Alternatively to this programming, the IEC editor can be used. In that case the FEND instruction
would be set by the compiler of the GX IEC Developer automatically.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● After execution of a CALL(P), FCALL(P), ECALL(P), EFCALL(P) or XCALL instruction an
END, FEND, GOEND, or STOP instruction is executed, without a prior RET instruction.
(Error code 4211)
● An RET instruction is executed before a CALL(P), FCALL(P), ECALL(P), EFCALL(P) or
XCALL instruction.
(Error code 4212)
CPU High
Basic Process Redundant Universal LCPU
Performance
s1
– 1) —
s5
1
Annunciators (F) cannot be used
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
FCALLME1, FCALLKE1
GX Works2
FCALLGE1
7 – 148
Structured program instructions FCALL, FCALLP
FCALL0E1
1
Main routine program
2
Subroutine program
The condition of coils and contacts after execution of the FCALL instruction or the respective
condition of coils and contacts with the according execution condition not set is listed below:
1
Forced OFF by FCALL instruction
FCALLAB1, FCALL0E2, FCALL0E3
When function devices (FX, FY, FD) are used by a subroutine program, specify a device with
s1 to s5 corresponding to the function device. The contents to the devices specified by s1 to
s5 are as indicated below.
Prior to execution of the subroutine program, bit data is transmitted to FX, and word data is
transmitted to FD.
After the execution of the subroutine program, the contents of FY and FD are transmitted to the
corresponding devices.
The processing units for the function devices are as follows:
● FX, FY: Bits
● FD : 4-word units
The size of the data to be dealt with will differ depending on the device specified in the argu-
ment. The device specified as a function device should be secured for the data size. An error
will occur if it cannot be secured for the data size.
7 – 150
Structured program instructions FCALL, FCALLP
1
An error will not occur even when the device number specified by s1 to s5 is not a multiple of 16 at the
digit designation of the bit device.
X0
FCALL P0 M0 D0 D30
CALL P0
END
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified for the argument cannot be secured for the data size.
(Error code 4101)
● After execution of an FCALL instruction an END, FEND, GOEND, or STOP instruction is
executed, without a prior RET instruction.
(Error code 4211)
● A RET instruction is executed before an FCALL instruction.
(Error code 4212)
● More than 16 nesting levels are executed.
(Error code 4213)
● There is no subroutine program stored at the specified pointer/label.
(Error code 4210)
Program FCALL
Example
While X20 is set, the following program executes the subroutine program at pointer address
(label) P_0. If X20 is reset, the FCALL instruction resets the output Y11 as well (1).
7 – 152
Structured program instructions ECALL, ECALLP
CPU High
Basic Process Redundant Universal LCPU
Performance
n 1) — — — — — —
pn — — — — — — — —
s1
– 2) — —
s5
1 File name
2
Annunciators (F) cannot be used
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
ECALLME1, ECALLKE1
GX Works2
ECALLGE1
ECALL0E1
1 Main routine program (file name: "MAIN")
2 Subroutine program (file name: "ABC")
Only files stored in internal memory (drive 0) can be specified by the file name.
When calling program files no file extension is required. (Only ".QPG" files will be acted on.)
When function devices (FX, FY, FD) are used by a sub-routine program, specify a device with
s1 through s5 corresponding to the function device. The contents to the devices specified by
s1 to s5 are as indicated below.
[MAIN]
[ABC]
Prior to execution of the sub-routine program, bit data is transmitted to FX, and word data is
transmitted to FD.
After the execution of the sub-routine program, the contents of FY and FD are transmitted to
the corresponding device.
7 – 154
Structured program instructions ECALL, ECALLP
When digit designation of a bit device is used 1) 4 words The data size varies
FD depending on the
Word device 4 words instruction to be used.
1 An error will not occur even when the device number specified by s1 to s5 is not a multiple of 16 at the
digit designation of the bit device.
X0
ECALL "A-LINE" P0 M0 D0 D30
D0 0 D0 0 D0 0 D0 33 *2
D1 10 D1 10 D1 110 *1 D1 110 *3
D2 100 D2 100 D2 100 Transfer D2 100 *2
Transfer
D3 1000 D3 1000 D3 1000 D3 1000 *2
Indefinite 0 33 *1 Indefinite
Indefinite 10 1 *1 Indefinite
FD0 FD0 FD0 FD0
Indefinite 100 100 Indefinite
Indefinite 1000 1000 Indefinite
1
Stores the execution result of the subroutine program.
2
Replaced by the value of the function device.
3 D1 does not reflect the value of the function device.
7 – 156
Structured program instructions ECALL, ECALLP
[MAIN]
[ABC]
D0 0 D0 0 D0 0 D0 33 *2
D1 10 D1 10 D1 10 D1 1 *2
D2 100 Transfer
Transfer D2 100 D2 100 D2 100 *2
D3 1000 D3 1000 D3 1000 D3 1000 *2
D4 0 D4 0 D4 100 *1 D4 100
Indefinite 0 33 *1 Indefinite
Indefinite 10 1 *1 Indefinite
FD0 FD0 FD0 FD0
Indefinite 100 100 Indefinite
Indefinite 1000 1000 Indefinite
1
Stores the execution result of the subroutine program.
2
Replaced by the value of the function device.
The devices specified in s1 through s5 must not overlap. If they do overlap, it will not be possi-
ble to obtain accurate calculations.
Up to 16 levels of nesting can be used with the ECALL(P) instruction. However, this 16 levels
is the total number of levels in the CALL(P), FCALL(P), ECALL(P), EFCALL(P), and XCALL
instructions.
END
Devices which are turned ON within subroutine programs will be latched even if the subroutine
program is not executed. Devices turned ON during the execution of a subroutine program can
be turned OFF by the EFCALL(P) instruction.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified for the argument cannot be secured for the data size.
(Error code 4101)
● After execution of an ECALL instruction an END, FEND, GOEND, or STOP instruction is
executed, without a prior RET instruction.
(Error code 4211)
● An RET instruction is executed before an ECALL instruction.
(Error code 4212)
● More than 16 nesting levels are executed.
(Error code 4213)
● There is no subroutine program stored at the specified pointer/label.
(Error code 4210)
● The specified program file does not exist.
(Error code 4210)
● The specified program file cannot be executed.
(Error code 2411)
Program ECALL
Example
While X20 is set, the following program executes the subroutine program at pointer/label P_0
in the program file "ABC".
7 – 158
Structured program instructions EFCALL, EFCALLP
CPU High
Basic Process Redundant Universal LCPU
Performance
n1) — — — — — —
pn — — — — — — — —
s1
– 2) — —
s5
1 File name
2
Annunciators (F) cannot be used
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
EFCALME1, EFCALKE1
GX Works2
EFCALGE1
7 – 160
Structured program instructions EFCALL, EFCALLP
EFCALAB1, EFCALAB2
Only the file name of a program file stored in the drive 0 (program memory/internal RAM) can
be designated for a file name.
It is not necessary to designate the extension (".QPG") with the file name. (Only ".QPG" files
will be acted on.)
When function devices (FX, FY, FD) are used by a sub-routine program, specify a device with
s1 through s5 corresponding to the function device (see following figure).
[ABC]
Prior to execution of the sub-routine program, bit data is transmitted to FX, and word data is
transmitted to FD.
After the execution of the sub-routine, the contents of FY and FD are transmitted to the corre-
sponding device.
The processing units for the function devices are as follows:
● FX, FY: Bits
● FD : 4-word units
The size of the data to be dealt with will differ depending on the device specified in the argu-
ment. The device specified as a function device should be secured for the data size. An error
will occur if it cannot be secured for the data size.
Function Devices Device Data Size Remark
X0
EFCALL "ABC" P0 M0 D0 D30
ECALL "ABC" P0
7 – 162
Structured program instructions EFCALL, EFCALLP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified for the argument cannot be secured for the data size.
(Error code 4101)
● After execution of an EFCALL instruction an END, FEND, GOEND, or STOP instruction is
executed, without a prior RET instruction.
(Error code 4211)
● An RET instruction is executed before an EFCALL instruction.
(Error code 4212)
● More than 16 nesting levels are executed.
(Error code 4213)
● There is no subroutine program stored at the specified pointer/label.
(Error code 4210)
● The specified program file does not exist.
(Error code 4210)
● The specified program file cannot be executed.
(Error code 2411)
Program EFCALL
Example
While X20 is set, the following program executes the subroutine program at pointer address
(label) P_0 in the program file "ABC". If X20 is reset, the EFCALL instruction resets the output
Y11 as well (1).
7.6.8 XCALL
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
s1
– 1) —
s5
1 Annunciators (F) cannot be used.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
E
F
C
A
L
M
E
1
,
E
F
C
A
1L
K
E
GX Works2
XCALL Pn s1 to s5
EFCALGE1
7 – 164
Structured program instructions XCALL
Operation of XCALL instruction varies according to the CPU module type. The following pro-
gram example shows the operation of XCALL instruction for each CPU module.
P1 subroutine program
ON/OFF timing of X0
:
EFCALAB1, EFCALAB2
1
Time during X0 is ON (2) does not include the time when turning X0 ON (1).
When function devices (FX, FY, FD) are used by a subroutine program, specify a device with
s1 through s5 corresponding to the function device. The contents to the devices specified by
s1 to s5 to are as indicated below.
7 – 166
Structured program instructions XCALL
Prior to execution of the sub-routine program, bit data is transmitted to FX, and word data is
transmitted to FD.
After the execution of the subroutine, the contents of FY and FD are transmitted to the corre-
sponding device.
The processing units for the function devices are as follows:
● FX, FY: Bits
● FD : 4-word units
The size of the data to be dealt with will differ depending on the device specified in the argu-
ment. The device specified as a function device should be secured for the data size. An error
will occur if it cannot be secured for the data size.
Function Devices Device Data Size Remark
When digit designation of a bit device is used 1) 4 words The data size varies
FD depending on the
Word device 4 words instruction to be used.
1 An error will not occur even when the device number specified by s1 to s5 is not a multiple of 16 at the
digit designation of the bit device.
X0
XCALL P0 M0 D0 D30
XCALL P0 X0 P0 P20
END
The device used for the argument of the XCALL instruction must not be used in a subroutine
program. If used, it will not be possible to perform correct calculations. (Refer to the following
program example.)
The processing to be executed when D1 is used in a subroutine program with D0 designated
for FD0 in a subroutine program is shown below.
D0 0 D0 0 D0 0 D0 1 *2
D1 10 D1 10 D1 110 *1 D1 10 *2
D2 100 D2 100 D2 100 Transfer D2 100 *2
Transfer
D3 1000 D3 1000 D3 1000 D3 1000 *2
Indefinite 0 1 *1 Indefinite
Indefinite 10 10 Indefinite
FD0 FD0 FD0 FD0
Indefinite 100 100 Indefinite
Indefinite 1000 1000 Indefinite
1
Stores the execution result of the subroutine program.
2
Replaced by the value of the function device.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified for the argument cannot be secured for the data size.
(Error code 4101)
● After execution of an XCALL instruction an END, FEND, GOEND, or STOP instruction is
executed, without a prior RET instruction.
(Error code 4211)
● An RET instruction is executed before an XCALL instruction.
(Error code 4212)
● More than 16 nesting levels are executed.
(Error code 4213)
● There is no subroutine program stored at the specified pointer/label.
(Error code 4210)
7 – 168
Structured program instructions XCALL
Program XCALL
Example
The following program executes a subroutine program with argument when X20 is turned ON.
EFCALMB1, EFCALKB1, EFCALIB1
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 2) 3) 4) 4) 4)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 170
Structured program instructions COM (Refresh)
• Refresh of MELSECNET/H
• CC-Link refresh
• Auto refresh of intelligent function modules.
On execution of a COM instruction the CPU temporarily interrupts the sequence program, per-
forms general data processing (END processing), as well as auto refresh of intelligent function
modules (including link refreshes). However, the low speed cyclic refresh of MELSECNET/H is
not performed.
1
COM instruction
2 General data processing/ auto refresh (including link refresh) of intelligent function module
A COM instruction may be used any number of times in the sequence program. In this respect,
note that the sequence program scan time is increased by the time taken for communication
with peripheral device and the auto refresh (including the link refresh) of the intelligent function
modules.
1
Master station program
2
Data communication
3
Local station program
4 Remote I/O station, I/O refresh
Data communication between links is speeded up in the sequence program of the master
station via the COM instruction, because the number of communication events with the remote
I/O station increases.
Data may not be received properly as shown above, if the scan time of the local station
sequence program is longer than that of the master station. In this case, secure data commu-
nication is achieved with the COM instruction applied in the sequence program of the local sta-
tion.
If a COM instruction is programmed in the sequence program of a local station, a link refresh
is performed every time the local station receives the master station command between the
following instructions:
– Step 0 and COM instruction
– COM instruction and COM instruction
– COM instruction and END instruction
If the link scan time of the link is longer than the sequence program scan time of the master
station, data communication cannot be speeded up even if a COM instruction was pro-
grammed in the master station.
1
Sequence program of the master station
2
Link scan time in the slave station
7 – 172
Structured program instructions COM (Selective Refresh)
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 2) 3)
1 Basic model QCPU: The first five digits of the serial No. are "04122" or higher.
2
High Performance model QCPU: The first five digits of the serial No. are "04012" or higher.
3
Process CPU: The first five digits of the serial No. are "07032" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
COM__GE1
CC-Link refresh
b15 b14 to b6 b5 b4 b3 b2 b1 b0
SD778 1/0 0 1/0 1/0 1/0 1/0 1/0 1/0 1/0
I/O refresh
CC-Link refresh
CC-Link IE controller network, MELSECNET/H refresh
Auto refresh of intelligent function module
Auto refresh using QCPU standard area of multiple CPU
system
Reading inputs/outputs from the outside of the multiple
CPU system group
Auto refresh using the multiple CPU high speed
transmission area of multiple CPU system
CC-Link IE field network refresh
Communication with peripheral devices
7 – 174
Structured program instructions COM (Selective Refresh)
NOTE Refresh between the multiple CPUs by the COM instruction is performed under the following
condition.
Receiving operation from other CPUs : When b4 of SD778 (auto refresh in the CPU shared
memory) is 1.
Sending operation from host CPU : When b15 of SD778 (communication with peripheral de-
vice is executed/not executed) is 0.
● For LCPU
Bit of SD778 Executed Not executed
b0 to b3, b14 1 0
b15 0 1
● Turning OFF SM775 refreshes all refresh items except I/O refresh.
● With SM775 turned to ON, select refresh items by SD778.
The following table shows the refresh items that can be designated by turning SM775 ON/OFF
and with SD778.
QCPU LCPU
Refresh items When SM775 When SM775 When SM775 When SM775
is OFF is ON is OFF is ON
I/O refresh Not executed Not executed Execution/
non-execution
CC-Link refresh Executed selectable
CC-Link IE controller network refresh — —
CC-Link IE field network refresh — —
MELSECNET/H refresh — —
Execution/ Execution/
Auto refresh of intelligent function modules non-execution Executed non-execution
Executed selectable selectable
Auto refresh using QCPU standard area of multiple
— —
CPU system
Reading input/output data of all modules other than
— —
the multiple CPU system group
Auto refresh using the multiple CPU high speed
— —
transmission area of multiple CPU system
Communication with display unit — —
Execution/
Execution/ Executed non-execution
Service process (communication with peripheral
Executed non-execution selectable
device)
selectable
Upon the execution of the COM instruction, the CPU module suspends the processing of the
sequence program, and refreshes the designated refresh item.
0 END 0 END 0
A COM instruction may be used any number of times in the sequence program. However, note
that the sequence program scan time will be lengthened by the time taken for refresh time of
the communication with peripheral devices and refresh item that are selected in SD778.
Only with the Universal model QCPU and LCPU, interruption is enabled during the execution
of the COM instruction. However, note that the data can be separated if the refresh data is used
by an interrupt program etc.
With the Built-in Ethernet port QCPU and LCPU, processing time may be increased if the serv-
ice process was executed by the COM instruction while the built-in Ethernet ports are in Ether-
net connection.
7 – 176
Structured program instructions CCOM, CCOMP
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
CCOM
4
CCOMP
Operation When the CCOM(P) instruction is executed in the QnUD(H)CPU whose serial number (first five
Errors digits) is "10101" or lower, an error occurs.
(Error code 4100)
Program CCOMP
Example
Turning on M0 enables the program to execute the select refresh, while turning off M0 disables
the program to execute the select refresh.
7 – 178
Structured program instructions IX, IXEND
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
IX___GE1
7 – 180
Structured program instructions IX, IXEND
PLS, PLF, and pulsed instructions that are executed once only on set input condition, cannot
be addressed by index qualification via the IX/IXEND instruction
In cases where the new address, resulted from the addition exceeds the relevant address
range, the instruction cannot be processed accurately.
If the IX and IXEND instructions are executed during a change between program sequences
in the online mode (modifying in RUN mode) the instruction cannot be processed neither.
The values added to the addresses of word devices of which each bit can be accessed are
stored as binary data. The initial addresses of the devices these values are specified for are
stored in s.
In a program, between the IX and the IXEND instruction no index qualification can be per-
formed.
When a program is expanded, the indexed addresses of devices in a program part located
between the IX and the IXEND instruction are transformed to addresses using index registers
(Zn). The assignment of indexed addresses to the corresponding index registers is shown
below:
Index Index
s Device s Device
Register Register
Qualification value of Qualification value of
s Z0 s+8 data register (D) Z8
timer (T)
Qualification value of Qualification value of
s+1 Z1 s+9 link register (W) Z9
counter (C)
Qualification value of Qualification value of
s+2 Z2 s+10 file register (R) Z10
input (X)
Qualification value of Qualification value of
s+3 Z3 s+11 buffer register I/O (U) Z11
output (Y)
Qualification value of Qualification value of
s+4 Z4 s+12 buffer register (G) Z12
internal relay (M)
The index registers Z10 to Z15 are not available for the Q00JCPU, Q00CPU, and Q01CPU.
Depending on the programming software used the user has to add the index registers in the
sequence program between the IX and the IXEND instructions manually.
Example GX Works2
The index registers used between the IX and the IXEND instructions (Z0 to Z15) do not affect
the index registers used by other instructions elsewhere in the program.
NOTES When using the IX and IXEND instructions in both a normal sequence program and an interrupt
sequence program, establish an interlock to avoid simultaneous execution. The interlock
assumes the area between the IX and IXEND instructions in the normal sequence program as
DI, disabling the interruption.
The IXDEV and IXSET instructions can be used to specify modification values. Refer to section
7.6.13 for details.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The IX and IXEND instructions are not programmed in conjunction.
(Error code 4231)
● After execution of the IX instruction an END, FEND, GOEND or STOP instruction is executed
before the IXEND instruction is executed.
(Error code 4231)
7 – 182
Structured program instructions IX, IXEND
IX___MB1
CPU High
Basic Process Redundant Universal LCPU
Performance
d — — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
IXDEVME1, IXDEVKE1
GX Works2
IXDEVGE1
7 – 184
Structured program instructions IXDEV, IXSET
If in the offset designation area two identical device types are specified, the offset value of the
latter device is valid.
The IXDEV and IXSET instructions have to be programmed in conjunction.
The offset value of the device ZR.XX may range from 0 to 32767. The offset value is the
remainder of the quotient of the device number divided by 32767, and is written to the corres-
ponding register.
For the dummy contacts in the offset designation area only LD and AND instructions are valid.
All other instructions are ignored.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The IXDEV and IXSET instructions are not programmed in conjunction.
(Error code 4231)
Ladder diagram
Index modification
table
D0 4 T
0 C
5 X
3 Y
0 M
0 L
0 B
0 V
8 D
0 W
0
0
D15 0 P
IXDEVMB1, IXDEV0B1
1
Refer to the instructions IX and IXEND (section 7.6.12) for the assignment of device types to their
corresponding registers.
7 – 186
Data table operation instructions
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FIFW_GE1
7 – 188
Data table operation instructions FIFW, FIFWP
1
Data table
2
Position pointer
3
Data table range
FIFW0E1
Prior to the first FIFW instruction the contents of the device specified in d have to be cleared.
The number of data records to be recorded and the address range of the data table have to be
controlled on programming by the user.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data table range of the FIFO table exceeds the relevant storage device range when
executing the FIFW instruction.
(Error code 4101)
Program FIFWP
Example 1
The following program specifies the storage range of the data table via the data registers R0
through R5. The initital address of the storage range (R0) contains the position pointer, indicat-
ing the number of stored data records. With leading edge from X10, data in D0 are stored at
the next available storage position of the data table (R5).
1
Data table
2
Position pointer
3 Data table range
7 – 190
Data table operation instructions FIFW, FIFWP
Program FIFWP
Example 2
The following program specifies the storage range of the data table via the data registers D38
through D44. The initital address of the storage range (D38) contains the position pointer, indi-
cating the number of stored data records. With leading edge from X1B, data at the inputs X20
through X2F are stored at the next available storage position of the data table (D44). The data
table specified here stores at maximum 6 data records. Therefore, Y60 is programmed as a
limiter of the FIFW instruction. The output is set, if the contents of D38 are greater than or equal
to 6.
1
Data table
2
Position pointer
3
Data table range
4
Highest available storage address
FIFW_MB2, FIFW_KB2, FIFW_IB2, FIFW0B2
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FIFR_GE1
7 – 192
Data table operation instructions FIFR, FIFRP
1 Data table
2
Position pointer
3
This register is reset to 0
FIFR0E1
NOTE Make sure this instruction is not executed, while d (position pointer) contains the value 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● An FIFR instruction is executed while the position pointer contains the value 0.
(Error code 4100)
● The device table range exceeds the corresponding device range when executing the FIFR
instruction.
(Error code 4101)
Program FIFRP
Example 1
With leading edge from X10, the following program reads the data value in R1 (first entered
value) of the data table from R0 through R7 and stores the value in the register D0. At the
beginning the value of the position pointer is 5 and after the execution 4. The preceding com-
parison operation avoids the execution of the FIFR instruction, if the position pointer (R0) con-
tains the value 0.
1
Data table
2
Position pointer
3
Data table range
FIFR_MB1, FIFR_KB1, FIFR_IB1, FIFR0B1
7 – 194
Data table operation instructions FIFR, FIFRP
Program FIFRP
Example 2
With leading edge from X1C, the following program writes a value from D0 to the data table
from D38 through D43. If the value of the position pointer is 5, the first value of the FIFO table
is read and passed on to R0. This process is repeated with every leading edge from X1C.
1
Data table
2
Position pointer
3
Data table range
FIFR_MB2, FIFR_KB2, FIFR_IB2, FIFR0B2
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FPOPGE1
7 – 196
Data table operation instructions FPOP, FPOPP
1
Data table
2
Position pointer
3
This register is reset to 0
FPOP0E1
NOTE Make sure this instruction is not executed, while d (position pointer) contains the value 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● An FPOP instruction is executed while the position pointer contains the value 0.
(Error code 4100)
● The data table range exceeds the corresponding device range when executing the FPOP
instruction.
(Error code 4101)
Program FPOPP
Example 1
With leading edge from X10, the following program reads the data value in R5 (value entered
last) of the data table from R0 through R7 and stores the value in the register D0. At the begin-
ning the value of the position pointer is 5 and after the execution 4. The preceding comparison
operation avoids the execution of the FPOPP instruction, if the position pointer (R0) contains
the value 0.
1
Data table
2
This register is reset to 0
FPOPMB1, FPOPKB1, FPOPIB1, FPOP0B1
7 – 198
Data table operation instructions FPOP, FPOPP
Program FPOPP
Example 2
With leading edge from X1C, the following program writes a value from D0 to the data table
from D38 through D43. If the value of the position pointer is 5, with leading edge from X1D the
value in register D43 is read and passed on to R0.
1
Data table
2 Leading edge from X1C
3
Leading edge from X1D
4 Position pointer
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FDEL_GE1
7 – 200
Data table operation instructions FDEL, FDELP, FINS, FINSP
1 Data table
2
For n=3 the data block d+3 is deleted.
3
This register is reset to 0
FDEL0E1
FINS/FINSP Inserting specified data blocks
The FINS instruction inserts a 16-bit data block specified by s at the nth position after the posi-
tion pointer into the data table specified by d.
The data blocks following the inserting position are shifted on by one address. After inserting,
the value of the position pointer (first address in d) is increased by 1.
1
Data table
2 Position pointer
3 For n=2 the data block is inserted at d+2
FINS0E1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The nth position from d is larger than the data storage number at the execution of the FDEL
instruction.
(Error code 4101)
● The inserting position in d specified by n via the FINS instruction exceeds the address range
of existing data blocks plus 1.
(Error code 4101)
● The value of n exceeds the device range of the table d.
(Error code 4101)
● The FDEL or FINS instruction was executed when n = 0.
(Error code 4100)
● The FDEL was executed when the value of d was 0.
(Error code 4100)
● The data table range exceeds the corresponding device range when the FDEL or FINS
instruction is executed.
(Error code 4101)
Program FDELP
Example 1
When X10 goes ON, the data from the 2nd position (R2) of the data table ranging from R0 to
R7 will be deleted and the data stored in D0.
1 1
R0 5 R0 5
R1 -123 2 R1 -123
R2 4444 R2 3210
R3 3210 R3 1234
R4 1234 R4 5432
R5 5432 R5 0
R6 0 R6 0
R7 0 R7 0
D0 4444
1
Data table
2 Leading edge of X10
7 – 202
Data table operation instructions FDEL, FDELP, FINS, FINSP
Program FINSP
Example 2
The following program inserts the data at D0 at the 3rd position of the data table ranging from
R0 to R7 when X10 goes ON.
1 1
R0 4 R0 4
R1 1234 2 R1 1234
R2 4444 R2 4444
R3 -123 R3 -3210
R4 5000 R4 -123
R5 0 R5 5000
R6 0 R6 0
R7 0 R7 0
D0 -3210
1
Data table
2
Leading edge of X10
FDELMB2, FDELKB2, FDELIB2, FINS0B1
7 – 204
Buffer memory access instructions
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
n2 —
d — — — — — —
n3 —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
FROM_GE1
7 – 208
Buffer memory access instructions FROM, FROMP, DFRO, DFROP
Functions Reading 1-word and 2-word data from a special function module
FROM Reading 1-word data (16-bit)
The FROM instruction reads 1-word data from the buffer memory of a special function module
and stores it in a specified memory address area of the CPU. The first address of data to be
read is specified by n2, the number of data words is specified by n3, and the head address of
the special function module, resulting from the position of the module on the base unit is spec-
ified by n1. The memory address area of the CPU storing the data is specified by d.
1 2
0 - n2
s
n3 n3
1
Buffer memory of special function module
2
Memory of the CPU
FROM0E1
NOTE The FROM instruction can also be used to read data from shared memory of another station in
a multi CPU system. Refer to section 9.2.1 for more details.
1 2
d
n2
n3 n3
(n3 x 2) (n3 x 2)
n3 n3
NOTE Data read from special function modules is also possible with the use of a special function mod-
ule device. In this case the devices are specified as U\G (U (Headadress of the special func-
tion module)/G (Buffer memory adress)).
For the special function module device, refer to the QnUCPU User's Manual (Function Expla-
nation, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Expla-
nation, Program Fundamentals).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● No signals have been exchanged with the special function module at the execution of the
instruction.
(Error code 1412)
● An error has occured in the special function module at the the execution of the instruction.
(Error code 1402)
● The I/O number specified by n1 is not a special function module.
(Error code 2110)
● The number of data words specified in n3 (2 x n3 for DFRO) exceeds the storage range of
the device specified by d.
(Error code 4101)
● The address specified by n2 is outside the buffer memory range.
(Error code 4101)
Program FROMP
Example 1
With leading edge from X0, the following program reads the digital values of channel CH1 from
address 10 of the buffer memory of an Q68ADV module. The memory address area of the
module is 040 through 05F. The read data is stored in D0.
Program DFROP
Example 2
With leading edge from X0, the following program reads the x-axis data at the addresses 602
and 603 in the buffer memory of an QD75P4 module. The memory address area of the module
is 040 through 05F. The read data is stored in D0 and D1.
7 – 210
Buffer memory access instructions FROM, FROMP, DFRO, DFROP
NOTES The value of n1 is specified by the upper 3 digits of hexadecimal 4-digit representation of the
head I/O number of the slot in which an intelligent function module is mounted.
QCPU System Q
MELSEC
Q68 QY41
1) CPU QX10 QX10 QX10 QX10 QY10 QY10
ADV P
3)
LCPU
LCPU
(L26CPU-BT)
0000H 0010H 0030H 0040H 0050H 0060H 0070H 0090H 00A0H 00B0H 2)
6)
1
Power supply module
2 Head I/O number configured in the I/O assignment setting
3 Head address of special function module: 0040H --> n1 = K4 or H4
4 Built-in I/0
5
Built-in CC-Link
6 Head address of special function module: 0060H --> n1 = K6 or H6
QCPU and LCPU establish the automatic interlock of the FROM/DFRO instructions.
CPU High
Basic Process Redundant Universal LCPU
Performance
n2 —
s — — — — —
n3 —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
TO___GE1
s Data to be written or first number of memory address area of the CPU storing BIN 16-/32-bit
data to be written
n3 Number of data words to be written BIN 16-bit
7 – 212
Buffer memory access instructions TO, TOP, DTO, DTOP
Functions Writing 1-word and 2-word data to the buffer memory of a special function module
TO Writing 1-word data (16-bit)
The TO instruction writes 1-word data from the memory of the CPU to the buffer memory of a
special function module. The first address of the memory area data is to be written to is spec-
ified by n2, the number of data words is specified by n3, and the address of the special function
module, resulting from the position of the module on the base unit is specified by n1. The first
address of the memory address area the data is to be read from is specified by s.
1 2
0 - n2
s
n3 n3
2)
1) 0
s 5
n2 5
5 3)
5
1 CPU module
2
Buffer memory of special function module
3
n3 words (same data is written)
1 2
0 - n2
n3 n3
s (n3 x 2) (n3 x 2)
n3 n3
1
Memory of the CPU
2 Buffer memory of special function module
DTO_0E1
When a constant is designated to s, the instruction writes the same data (value designated to
s) to the area of n3 x 2 points starting from the specified buffer memory address. s can be des-
ignated in the following range: -2147483648 to 2147483647 or 0H to FFFFFFFFH.
Following figure shows an example when the constant 70000 is designated to s.
2)
1)
0
S 70000
n2
70000
n2+1
70000 3)
70000
1
CPU module
2
Buffer memory of special function module
3
n3 x 2 words (same data is written)
NOTE Data read from intelligent function modules is also possible with the use of a special function
module device. In this case the devices are specified as U\G (U (Headadress of the special
function module)/G (Buffer memory adress)).
For the special function module device, refer to the QnUCPU User's Manual (Function Expla-
nation, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Expla-
nation, Program Fundamentals).
7 – 214
Buffer memory access instructions TO, TOP, DTO, DTOP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● No signals have been exchanged with the special function module at the execution of the
instruction.
(Error code 1412)
● An error has occured in the special function module at the execution of the instruction.
(Error code 1402)
● The I/O number specified by n1 is not a special function module.
(Error code 2110)
● The number of data words specified by n3 (2 x n3 for DTO) exceeds the storage range of
the device specified by d.
(Error code 4101)
● The address specified by n2 is outside the buffer memory range.
(Error code 4101)
Program TOP
Example 1
With leading edge from X0, the following program sets the channels CH1 and CH2 on an
Q68AD module to execute A/D conversion. The special function module is at address 040
through 05F. The value 3 is written to the buffer memory at address 0.
Program DTOP
Example 2
With leading edge from X0, the following program resets the x-data values at the buffer mem-
ory addresses 41 and 42 of a QD75P4 module to 0. The special function module is at address
040 through 05F.
NOTE The program example 2 will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
NOTE The value of n1 is specified by the upper 3 digits of hexadecimal 4-digit representation of the
head I/O number of the slot in which an intelligent function module is mounted.
QCPU System Q
MELSEC
Q68 QY41
1) CPU QX10 QX10 QX10 QX10 QY10 QY10
ADV P
3)
LCPU
LCPU
(L26CPU-BT)
0000H 0010H 0030H 0040H 0050H 0060H 0070H 0090H 00A0H 00B0H 2)
6)
1
Power supply module
2 Head I/O number configured in the I/O assignment setting
3 Head address of special function module: 0040H --> n1 = K4 or H4
4 Built-in I/0
5
Built-in CC-Link
6 Head address of special function module: 0060H --> n1 = K6 or H6
QCPU and LCPU establish the automatic interlock of the TO/DTO instructions.
7 – 216
Display instructions
The CPU modules of the MELSEC System Q and the L series supply several instructions that
output ASCII characters at the outputs of an output module or on a LED display on the front
panel of suitable CPU modules.
If one of the first three displays is indicated, the execution of a display instruction does not
change the current reading.
7.9.1 PR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
PR___GE1
7 – 218
Display instructions PR
1
Device storing ASCII code
2
Sequence program
3
Flag indicating that PR instruction is in progress (used as interlock)
4
Start of output
5
Outputs Y
6
Output of ASCII code
7
Output of strobe signal
8
Printer or display device
● SM701 not set (0) (function 2) PR_0E1
Output of ASCII character string data up to the character code "00H" in hexadecimal format
from the address area s to the outputs specified by d.
1
Device storing ASCII code
2
Sequence program
3
Flag indicating that PR instruction is in progress (used as interlock)
4
Start of output
5
End of character string (end of transmission)
6
Outputs Y
7
Output of ASCII code
8
Output of strobe signal
9
Printer or display device
PR_0E2
If the content of the devices storing ASCII code is overwritten during the output, the current
data is output.
Following the execution of the PR instruction, the PR instruction execution flag (d+9 device)
remains ON until the completion of the transmission of the designated number of characters.
For the execution of a PRC instruction an output module with 10 successive binary outputs is
needed. The address area begins at the output number specified by d. The 10 output
addresses of the output module are processed independently from an I/O refresh after the END
instruction in the program sequence.
Output signals from the output module are transmitted at the rate of 30 ms per character. Thus,
processing n characters takes n x 30 ms. The output transmission is controlled via 10 ms inter-
rupts, so the sequence program is processed continuously.
Data output
ON
OFF
Strobe signal
10 ms 10 ms 10 ms 10 ms 10 ms
30 ms
In addition to the ASCII code a strobe signal (ON = 10 ms, OFF = 20 ms) is output at address
Y= d+8.
The PR and PRC instructions can be executed multiple times. Yet, an interlock should be
established via the PR instruction execution flag (output device Y= d+9) so the PR and PRC
instructions are not executed simultaneously.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● There is no 00H code within the range of the device specified by s when SM701 is OFF.
(Error code 4101)
7 – 220
Display instructions PR
Program PR
Example
With leading edge from X0, the following program converts the character string "ABCDEFGH-
IJKLMNOP" into ASCII code and stores it in data registers D0 through D7. After setting X3 ON,
the ASCII code in D0 through D7 is output to the outputs Y14 through Y1D.
Ladder Diagram
1
Storage of character string "ABCDEFGH" in D0 through D3
2
Storage of character string "IJKLMNOP" in D4 through D7
3 ASCII code
4
Strobe signal
5 PR instruction execution flag
NOTES If SM701 is not set, the value "00H" has to be written to register D8. Without this character code
an operation error would occur in the program example above.
This program example will not run without variable definition in the header of the program organ-
ization unit (POU). It would cause compiler or checker error messages. For details see section
3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 222
Display instructions PRC
7.9.2 PRC
CPU High
Basic Process Redundant Universal LCPU
Performance
d 1) — — — — — — — —
1
Y only
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
PRC__GE1
1
Comment (ASCII code) from X1 onwards
2
Start of output
3 Outputs Y
4
Sequence program
5
PR instruction execution flag (used as interlock)
6
Output of ASCII code
7
Output of strobe signal
8
Printer or display device
PRC__AB1, PRC0E1
7 – 224
Display instructions PRC
The processing of the PRC instruction is shown in the following timing chart:
A B C N O
Y30 - Y37 Preprocessing 41H 42H 43H 4EH 4FH
30ms
ON
PRC OFF
ON
OFF
1 Y38
10 10 10
ms msms
ON
2 Y39 OFF
3
ON
4 SM721 OFF
ON 5
6 SM 720 OFF
7 8
1
Strobe signal
2 PRC instruction execution flag
3
Processing time (16 x 30 ms = 480 ms) for the PRC instruction
4 File access in process flag
7
No other instruction can be executed
8 Instructions other than PRC, SP.FREAD, SP.FWRITE, PLOAD, PUNLOAD and PSWAPP can be
executed
PRC0E3
There are 10 binary outputs of a digital output module assigned. The address area begins at
the output address Y specified by d.
Output signals from the output module are transmitted at the rate of 30 ms per character. Thus,
processing n characters takes n x 30 ms. The output transmission is controlled via 10 ms inter-
rupts, so the sequence program is processed continuously.
Data output
ON
OFF
Strobe signal
10 ms 10 ms 10 ms 10 ms 10 ms
30 ms
In addition to the ASCII code a strobe signal (ON = 10 ms, OFF = 20 ms) is output at address
Y= d+8.
During the output of 16 characters of ASCII code, the PRC instruction execution flag d+9 is set
ON. Thus, the output Y at address d+9 is set as long as the PRC instruction is executed. The
PR and PRC instructions can be executed multiple times. Yet, an interlock should be established
via the PRC instruction execution flag (output device Y= d+9) so the PR and PRC instructions
are not executed simultaneously.
If the address area s does not contain data, the instruction is not executed.
The PRC instruction can only access comments already stored in the PLC. For conversion
from alphanumeric data into ASCII code an ASC instruction has to be applied.
After the execution of the PRC instruction is finished, SM720 turns ON for one scan. SM721
turns ON during the execution of the PRC instruction. The PRC instruction cannot be executed
when SM721 is already ON. If an attempt is made, the processing will not be performed.
NOTES The PRC instruction can only access comments stored in a memory card. The PRC instruction
can not access comments stored in the internal memory.
The comment file accessed by the PRC instruction is set at the "PC File Setting" in the Param-
eter mode. The output of a comment file with the PRC instruction is not possible if no comment
file has been set.
Do not execute the PRC instruction during an interrupt program. Otherwise, malfunction may
result.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The PRC instruction is executed while a comment is written during RUN.
(Error code 4100)
Program PRC
Example
If X0 is set ON, the following program sets output Y35 ON and outputs the comment at Y35 in
ASCII code simultaneously at the outputs Y60 through Y69. After setting X3 ON, Y35 is reset
OFF.
7 – 226
Display instructions LEDR
7.9.3 LEDR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Operation of the LEDR instruction with an annunciator F set on a CPU without LED
display:
After execution of the LEDR instruction the following operations are executed:
– The "USER" LED on the front panel of the CPU flickers and then turns off.
– The annunciator F stored in SD62 and SD64 are reset and the annunciators stored in SD65
through SD79 are shifted for further processing.
– The new number of annunciator F shifted to SD64 is written to SD62.
– The accumulator of the annunciator in SD63 is decremented by 1. If SD63 is already at 0,
this value remains unchanged.
7 – 228
Display instructions LEDR
Operation of the LEDR instruction with an annunciator F set on a CPU with LED display:
After execution of the LEDR instruction, the following operations are executed:
– The annunciator displayed on the LED display of the CPU is cleared.
– The "USER" LED on the front panel of the CPU flickers and then turns off.
– The annunciators F stored in SD62 and SD64 are cleared and the annunciators stored in
SD65 through SD79 are shifted for further processing.
– The new number of annunciator F shifted to SD64 is written to SD62.
– The accumulator of the annunciator in SD63 is decremented by 1. If SD63 is already at 0,
this value remains unchanged.
– The current number of annunciator stored in SD62 is displayed. If SD63 is already at 0, there
is nothing displayed.
1
Since SD63 is at value 0, no annunciator is displayed on the LED display.
2
Number of stored annunciators
Program LEDR
Example
If X9 is set and the value in register SD63 is not equal to 0, the following program executes a
LEDR instruction.
NOTE The defaults for the error item numbers set in special register SD207 to SD209 and the order of
priority is shown in the table below:
Factor
Order of number
Description Remark QCPU LCPU
priority (Hexadeci-
mal)
AC DOWN Power supply cut
Redundant base unit power supply
1 1 SINGLE PS.DOWN
voltage drop
SINGLE PS.ERROR Redundant power supply module fault
UNIT VERFY ERR. I/O module verify error
FUSE BREAK OFF Blown fuse
If the highest priority is given to the annunciator, it can be reset with priority by the LEDR instruc-
tion. (Basic model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU)
7 – 230
Failure diagnosis and debugging
These instructions are for failure diagnosis and debugging support failure checks.
The following table gives an overview of these instructions:
NOTE Please check, whether these functions are available and supported by your version of the GX
IEC Developer.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
CHKSTGE1
7 – 232
Failure diagnosis and debugging CHKST, CHK
C
H
K
S
CHKSTME2, CHKSTKE2, CHKSTIE2
1
Contact 62; coil number 3 (during failure check)
2
Before failure check
3
After failure check
CHK_0E3
The input contacts programmed prior to the CHK instruction do not serve as execution con-
dition for the CHK instruction but as specification of the check conditions.
In the following, the failure check programming via the CHK instruction is illustrated with a con-
crete example. The following illustration shows a conveyor belt that moves from the left to the
right travel limit. The corresponding travel limits are detected via limit switches (X0 and X1).
The start contact for advance movement is X4 and for retract movement is X5.
1 Advance movement
2 Retract movement
3
Advance command
4 Retract command
SWITHCES_0E2
7 – 234
Failure diagnosis and debugging CHKST, CHK
The diagrams below show a sample program for the operation and failure check of the con-
veyor belt shown above.
During error free operation the program jumps to the program step following the CHK instruc-
tion. With leading edge from X4, the conveyor belt is advanced, and Y0 is set for failure check.
With leading edge from X5, the conveyor belt is retracted, and Y0 is reset.
The timer T0 watches the duty cycle time. If the duty cycle time is exceeded the CHKST instruc-
tion is set via the contact TS0. In the next program step the CHK instruction is executed, and
the error code is stored in the special register SD80.
The operations of the CHK instruction can be illustrated through the following ladder diagrams,
of which the functions are similar to the execution of the CHK instruction.
The contact numbers of the limit switches for advance movement X and retract movement
X+1 have to be designated successively. The number of the advance limit switch X must
be less than the number of the retract limit switch X+1. The contact number of the advance
limit switch is assigned to an output Y with the same address. According to the program
example, this output is set during advance movement and reset during retract movement.
For better comprehensibility of the program example above, the contacts X0 (X), X1 (X+1)
and Y0 (Y) are applied directly for specification of the coil number. Depending on the program
they can be replaced by any other number.
NOTE The outputs Y are treated as internal relays and cannot be output to external devices.
The following diagrams concerning the CHK instructions and the 6 generated failure check cir-
cuits (error conditions) are arranged in pairs.
In the following, the CHK instructions are illustrated. The contact indicated X serves as vari-
able for maximum 150 contacts (150 conveyor belts or similar applications).
CHKA_AB1, CHKQ_AB1
Failure check circuit 1 (coil number 1):
Both limit switches respond to the advance movement of the conveyor belt.
CHKA_AB2, CHKQ_AB2
Failure check circuit 2 (coil number 2):
Both limit switches respond to the retract movement of the conveyor belt.
CHKA_AB3, CHKQ_AB3
7 – 236
Failure diagnosis and debugging CHKST, CHK
CHKA_AB4, CHKQ_AB4
CHKA_AB5, CHKQ_AB5
CHKA_AB6, CHKQ_AB6
CHKQ_AB7
The CHK instruction can designate a maximum of 150 contact numbers for advance limit
switches. For the designation of contact numbers any contact number of the retract limit switch
is skipped.
CHKSTAB2
The relay SM80 and the special register SD80 have to be reset after execution of the CHK
instruction because they retain their condition after being set. If they are not reset prior to
another CHK instruction, the instruction cannot be executed.
The CHKST instruction has to be programmed prior to the CHK instruction. An error will be
returned if an instruction other than the LD, LDI, AND or ANI instruction is used between the
CHK instruction and the CHKST instruction.
The CHK instruction can be programmed in any program step of the sequence program. The
CHK instruction can be used up to two times in all program files being executed. In a single
program file a CHK instruction may be used only once.
The coil numbers have to be programmed via a LD or AND instruction prior to the CHK instruc-
tion. Other input instructions are not supported. If an LDI or ANI instruction is programmed, the
failure check of the CHK instruction cannot be executed. The contact numbers designated for
the failure check however can be designated via the LDI and ANI instructions. In the diagram
below the switch with the number X9 is ignored because it is an NC contact (normally closed).
CHKSTAB3
The failure detection method depends on the status of the special relay SM710 as follows.
● SM710 is reset (0):
The failure check is performed in coil number (failure check circuit) sequence from contact
1(limit switch) to contact n (limit switch).
The first contact is checked from coil number 1 through coil number 6. Then the next contact
is checked from coil number 1 through coil number 6. The operation is completed after the
nth contact is checked from coil number 1 through coil number 6.
● SM710 ist set (1):
The failure check is performed in contact number (limit switch) sequence from coil 1 (failure
check circuit) through coil 6 (failure check circuit).
The first coil is checked from contact number 1 through contact number n. Then the next
coil is checked from contact number 1 through contact number n. The operation is completed
after the 6th coil is checked from contact number 1 through contact number n.
If more than one failure is detected, the number of the first failure detected is stored. Further
detected failures are ignored.
The CHK instruction cannot be used by a low speed execution type program. If a low speed
execution type program has been set in a program file containing the CHK instruction, an oper-
ation error will be returned, and the CPU module operation will be suspended.
7 – 238
Failure diagnosis and debugging CHKST, CHK
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Two failure check input contacts within one failure check circuit are connected in parallel.
(Error code 4235)
● There is an NOP instruction.
(Error code 4235)
● More than 150 input devices are specified.
(Error code 4235)
● A CHKST instruction is not followed by a CHK instruction.
(Error code 4235)
● A CHK instruction is executed without a prior CHKST instruction.
(Error code 4235)
● The CHKST and CHK instruction are used in a low speed execution type program.
(Error code 4235)
● There is an instruction other than the LD, LDI, AND or ANI instruction between the CHK
instruction and the CHKST instruction.
(Error code 4235)
● The CHK instruction is used at three places or more in all of programs being executed.
(Error code 4235)
● The CHK instruction is used at two places or more in a single program.
(Error code 4235)
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
CHKCIGE1
7 – 240
Failure diagnosis and debugging CHKCIR, CHKEND
NOTE If the check circuit format for the CHK instruction was altered via the CHKCIR and CHKEND
instructions, connected peripheral devices have to be started up in "General Mode", and a pro-
gram expansion has to be performed.
From the error check circuits between the CHKCIR and CHKEND instructions altered error
check circuits are generated through index qualification. The error check circuits programmed
between these instructions can be assigned 9 annunciators (F1 - F9). Index qualification is per-
formed through the addition of contact numbers designated prior to the CHK instruction and
contact numbers of the error check circuits. For example, the contact X10 in the error check
circuits shown below will be assigned X12 and X18 in the index qualified check circuits due to
the contacts X2 and X8, programmed prior to the CHK instruction.
The error check algorithm depends on the status of the special relay SM710 as follows:
● SM710 is reset (0):
First in this case, each contact number in the error check circuit programmed between the
CHKCIR and CHKEND instruction is index qualified with the first contact number designated
prior to the CHK instruction. Then, each programmed check circuit is index qualified again
with the second contact number designated prior to the CHK instruction. This operation is
completed as for any programmed check circuit with assigned annunciator (F) a total of new
check circuits equivalent to the number of input contacts of the CHK instruction exists.
During error check of the index qualified error check circuits, the outputs (F) that can only be
set via the OUT F instruction are checked for their status. If an output (F) is set, the special
relay SM80 is set. The error code consisting of contact number and error check circuit (F1 to
F9) is stored in special register SD80 in BCD data format.
The error check circuits between the CHKCIR and CHKEND instruction can be programmed
with the following instructions.
● Contacts:
LD, LDI, AND, ANI, OR, ORI, ANB, ORB, MPS, MPP, MRD, comparison operation instruc-
tions.
● Coils:
OUT F
The inputs X and outputs Y have to be programmed as devices for the contacts.
Only annunciators (F) can be programmed as outputs of error check circuits. The error check
circuits can be specified any random designation from F0 on, since these outputs are pro-
cessed as dummy contacts. For this reason, no errors occur with annunciators (F) overlapping.
The status of annunciators (F) can even be checked accurately, if one annunciator (F) is pro-
grammed twice beyond the CHK instruction, because both of these annunciator functions are
processed separately.
Since the status (0/1) of annunciators (F) applied by the CHK instruction is not updated, the
annunciators even remain reset, if they are monitored by a peripheral device.
7 – 242
Failure diagnosis and debugging CHKCIR, CHKEND
The error check circuits programmed between the CHKCIR and CHKEND instructions can be
created with maximum 256 program steps (contact branches) and 9 outputs (annunciators F1
to F9) addressed by OUT F instructions.
The error check circuits between the CHKCIR and CHKEND instructions are designated from
top error check circuit 1 (F0) to bottom error check circuit 9 (F8).
CHKCIAB5
The CHKCIR and CHKEND instructions can be programmed at any program step of the
sequence program. In total, these instructions may only exist twice in all program files to be
executed and once within one program file.
The CHKCIR and CHKEND instructions cannot be applied in low-speed programs, otherwise
an operation error occurs and the CPU terminates processing.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The CHKCIR and CHKEND instructions appear more than twice in all program files.
(Error code 4235)
● The CHKCIR and CHKEND instructions appear more than once within one program file.
(Error code 4235)
● The CHKEND instruction is not executed after the CHKCIR instruction.
(Error code 4230)
● The CHKEND instruction is executed without a preceding CHKCIR instruction.
(Error code 4230)
● The CHKCIR and CHKEND instructions are programmed in a low-speed program.
(Error code 4235)
● 10 or more annunciators (F) (error check circuits) are addressed.
(Error code 4235)
● The created error check circuits contain more than 256 program steps (contact branches).
(Error code 4235)
● The error check circuits contain invalid devices.
(Error code 4235)
● The error check circuits contain devices already index qualified.
(Error code 4235)
7 – 244
Character string processing instructions
7 – 246
Character string processing instructions
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BINDAGE1
7 – 248
Character string processing instructions BINDA, BINDAP, DBINDA, DBINDAP
Functions Conversion of 16-/32-bit binary data into decimal values in ASCII code
BINDA Conversion of 16-bit binary data
The BINDA instruction converts a 16-bit binary value specified by s into a decimal value in
ASCII code and stores it in the device specified in d (Array_d[1]) through d+3 (Array_d[4]).
b15 b8b7 b0
d 2
b15 b0
s d+1 3
d+2 4
1 d+3 0 5
5
With the relay SM701 not set
BINDA0E1
The value specified by s is stored as decimal value in ASCII code beginning from d (Array_d[1])
through d+3 (Array_d[4]).
b15 b8b7 b0
d 31H (1) 2DH(-)
b15 b0
d+1 33H (3) 32H (2)
s - 1 2 3 4 5
d+2 35H (5) 34H (4)
1 d+3 00H
BINDA0E2
1
Binary value
b15 b8b7 b0
d 4
d+1 5
s+1 s
d+2 6
1 2
d+3 7
3 d+4 8
d+5 9
10
1
Upper 16 bits
2
Lower 16 bits
3
32-bit binary data
4
Sign character/ digit of billions in ASCII code
5
Digit of ten millions/ digit of one hundred millions in ASCII code
6
Digit of one hundred thousands/ digit of millions in ASCII code
7
Digit of thousands/ digit of ten thousands in ASCII code
8 Digit of tens/ digit of hundreds in ASCII code
10
With the relay SM701 not set (0)/ with the relay SM701 set (20H)
DBINDA0E1
The value specified by s and s+1 is stored beginning from d (Array_d[1]) through d+5
(Array_d[6]) as decimal value in ASCII code.
b15 b8b7 b0
d 20 H 2D H (-)
s+1 d+1 31 H (1) 20 H
d+2 33 H (3) 32 H (2)
-12 3 4 5 6 7 8
d+3 35 H (5) 34 H (4)
d+4 37 H (7) 36 H (6)
d+5 0/20 H 38 H (8)
DBINDA0E2
The 32-bit binary value specified by s may range from -2147483648 to 2147483647.
The results of the conversion operation are stored in d (Array_d[1]) through d+5 (Array_d[6])
as follows:
– If the binary value is positive, the sign character is stored as "20H".
– If the binary value is negative, the sign character is stored as "2DH".
7 – 250
Character string processing instructions BINDA, BINDAP, DBINDA, DBINDAP
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program BINDAP
Example 1
The following program outputs the value of the 16-bit binary data in W0 as decimal value in
ASCII code via the BINDAP instruction. The PR instruction outputs the characters at Y40
through Y48.
b15 b8b7 b0
D0 20 H 20 H
W0 PR
D1 31 H 35 H (5) Y40 – Y48
5126
D2 36 H 32 H “ 5126“
1
D3 00 H 2
1 Binary value
2
Output
BINDAMB1, BINDAKB1, BINDAIB1, DBINDA0B1
Program DBINDAP
Example 2
The following program outputs the value of the 32-bit binary data in W10 and W11 as decimal
value in ASCII code via the DBINDAP instruction. The PR instruction outputs the characters at
Y40 through Y48.
b15 b8b7 b0
D0 20 H 2D H (-)
W11 W10 D1 20 H 20 H
D2 38 H (8) 33 H (3) PR
- 3 8 4 2 5 6 3 Y40 – Y48
D3 32 H (2) 34 H (4)
1 “ 3842563“
D4 36 H (6) 35 H (5) 2
D5 00 H 33 H (3)
1 Output
2
Binary value
BINDAMB2, BINDAKB2, BINDAIE2, DBIND0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 252
Character string processing instructions BINHA, BINHAP, DBINHA, DBINHAP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BINHAGE1
Functions Conversion of 16-/32-bit binary data into hexadecimal values in ASCII code
BINHA Conversion of 16-bit binary data
The BINHA instruction converts 16-bit binary data specified by s into a hexadecimal value in
ASCII code and stores it in the devices specified by d (Array_d[1]) through d+2 (Array_d[3]).
b15 b8b7 b0
b15 b0 d 2
s d+1 3
d+2 0 4
1
1
16-bit binary data
2
ASCII code of the 3rd digit/ ASCII code of the 4th digit
3 ASCII code of the 1st digit/ ASCII code of the 2nd digit
4
With the relay SM701 not set
BINHA0E1
The value specified by s is stored in ASCII code in d (Array_d[1]) through d+2 (Array_d[3]).
b15 b8b7 b0
d 32 H (2) 30 H (0)
b15 b0
d+1 36 H (6) 41 H (A)
s 02A6H
d+2 00 2
1
1
16-bit binary data
2
With the relay SM701 not set
BINHA0E2
7 – 254
Character string processing instructions BINHA, BINHAP, DBINHA, DBINHAP
b15 b8b7 b0
d 4
s+1 s d+1 5
d+2 6
1 2
d+3 7
3 d+4 0 8
1 Upper 8 bits
2
Lower 8 bits
3
32-bit binary data
4 ASCII code of the 7th digit/ ASCII code of the 8th digit
5
ASCII code of the 5th digit/ ASCII code of the 6th digit
6
ASCII code of the 3th digit/ ASCII code of the 4th digit
7 ASCII code of the 1st digit/ ASCII code of the 2nd digit
DBINH0E1
b15 b8b7 b0
d 33 H (3) 30 H (0)
s+1 d+1 43 H (C) 41 H (A)
d+2 32 H (2) 36 H (6)
03AC 625EH
d+3 45 H (E) 35 H (5)
1 d+4 00 H
1
BIN 32-bit data
DBINH0E2
The 32-bit binary value specified by s and s+1 may range from 0H to FFFFFFFFH.
The conversion result is stored as 8-digit hexadecimal value in d (Array_d[1]) through d+4
(Array_d[5]).
If one of the digits is 0, this digit is processed as value 0 (zeroes are not suppressed).
The storage of the data in the device specified by d+4 (Array_d[5]) depends on the status of
the relay SM701 as follows:
● If this relay is not set, a zero "00H" is stored in the area d+4 (Array_d[5]).
● If this relay is set, the value in d+4 (Array_d[5]) remains unchanged.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program BINHAP
Example 1
The following program outputs the value of the 16-bit binary data in W0 as decimal value in
ASCII code via the BINHAP instruction. The PR instruction outputs the characters at Y40
through Y48.
b15 b8b7 b0
W0 D0 43 H (C) 39 H (9)
PR
9C06H D1 36 H (6) 30 H (0) Y40 – Y48
1 D2 00
“9C06”
2
1
Output
2
Binary data
BINHAMB1, BINHAKB1, BINHAIB1, DBINH0B1
7 – 256
Character string processing instructions BINHA, BINHAP, DBINHA, DBINHAP
Program DBINHAP
Example 2
The following program outputs the value of the 32-bit binary data in W10 and W11 via the
DBINHAP instruction as decimal value in ASCII code. The PR instruction outputs the characters
at Y40 through Y48.
b15 b8b7 b0
D0 42 H (B) 37 H (7)
W11 W10 D1 43 H (C) 33 H (3) PR
7 B 3 C 5 8 1 FH D2 38 H (8) 35 H (5) Y40 – Y48
D3 46 H (F) 31 H (1)
1 “7B3C581F”
D4 00 H 2
1
Output
2 Binary value
BINHAMB2, BINHAKB2, BINHAIB2, DBINHA0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
BCDDAGE1
7 – 258
Character string processing instructions BCDDA, BCDDAP, DBCDDA, DBCDDAP
b15 b7b8 b0
b15 b12 b11 b8 b7 b4b3 b0 d 6
s d+1 7
d+2 0
1 2 3 4
5
1 Digit of thousands
2
Digit of hundreds
3
Digit of tens
4 Digit of ones
5
With the relay SM701 not set
6
ASCII code of the 3rd digit/ ASCII code of the 4th digit
7 ASCII code of the 1st digit/ ASCII code of the 2nd digit
BCDDA0E1
b15 b8b7 b0
b15 b12 b11 b8b7 b4b3 b0 d 31 H (1) 39 H (9)
9 1 0 5 d+1 35 H (5) 30 H (0)
d+2 00 H
BCDDA0E2
The BCD value specified in s may range from 0 to 9999.
The conversion result is stored in d (Array_d[1]) through d+2 (Array_d[3]).
If one of the digits is 0, this digit is processed as "30H" (zeroes are not suppressed).
The storage of the data in the device specified by d+2 (Array_d[3]) depends on the status of
the relay SM701 as follows:
● If this relay is not set, a zero "00H" is stored in the area d+2 (Array_d[3]).
● If this relay is set, the value in d+2 (Array_d[3]) remains unchanged.
b15 b7b8 b0
s+1 s d 9
b31 b16 b15 b0 d+1 10
d+2 11
2 3 4 5 6 7 8 d+3 12
1
0 13
1
Digit of ten millions
2
Digit of millions
3
Digits of hundred thousands
4
Digit of ten thousands
5
Digit of thousands
6
Digit of hundreds
7
Digit of tens
8 Digit of ones
9 ASCII code of the 7th digit/ ASCII code of the 8th digit
10
ASCII code of the 5th digit/ ASCII code of the 6th digit
11ASCII code of the 3rd digit/ ASCII code of the 4th digit
12ASCII code of the 1st digit/ ASCII code of the 2nd digit
13
With the relay SM701 not set
DBCDDA0E1
b15 b7b8 b0
d 31 H (1) 30 H (0)
b31 b16 b15 b0 d+1 33 H (3) 32 H (2)
0 1 2 3 4 0 5 6 d+2 30 H (0) 34 H (4)
d+3 36 H (6) 35 H (5)
s+1 s
d+4 00 H
DBCDDA0E2
The BCD value specified by s and s+1 may range from 0 to 99999999.
The conversion result is stored in d (Array_d[1]) through d+4 (Array_d[5]).
If one of the digits is 0, this digit is processed as "30H" (zeroes are not suppressed).
The storage of the data in the device specified by d+4 (Array_d[5]) depends on the status of
the relay SM701:
● If this relay is not set, a zero "00H" is stored in the area d+4 (Array_d[5]).
● If this relay is set, the value in d+4 (Array_d[5]) remains unchanged.
7 – 260
Character string processing instructions BCDDA, BCDDAP, DBCDDA, DBCDDAP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The BCD data in s exceed the range of 0 to 9999 during the execution of the BCDDA
instruction.
(Error code 4100)
● The BCD data in s exceed the range of 0 to 99999999 during the execution of the DBCDDA
instruction.
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program BCDDAP
Example 1
The following program outputs the value of the 4-digit BCD data in W0 as decimal value in
ASCII code via the BCDDAP instruction. The PR instruction outputs the characters at Y40
through Y48.
b15 b7b8 b0
W0 D0 32 H (2) 31 H (1) PR
1 2 9 5 D1 35 H (5) 39 H (9) Y 40 – Y48
D2 00 H “1295”
Program DBCDDAP
Example 2
The following program outputs the value of the 8-digit BCD data in W10 and W11 as decimal
value in ASCII code via the PR instruction. The PR instruction outputs the characters at Y40
through Y48.
b15 b7b8 b0
D0 35 H (5) 33 H (3)
W11 W10 D1 37 H (7) 34 H (4) PR
3 5 4 7 8 3 5 2 D2 33 H (3) 38 H (8) Y40 – Y48
D3 32 H (2) 35 H (5)
“35478352”
D4 00 H
DBCDDA0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 262
Character string processing instructions DABIN, DABINP, DDABIN, DDABINP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Ladder Diagram IEC Instruction List
Developer MELSEC Instruction List
GX Works2
DABINGE1
Functions Conversion of decimal ASCII data into BIN 16-/32-bit binary data
DABIN Conversion of BIN 16-bit binary data
The DABIN instruction converts the decimal ASCII data specified in the area s (Array_s[1])
through s+2 (Array_s[3]) into the BIN 16-bit format and stores it in the devices specified by d.
b15 b8b7 b0
s 1 b15 b0
s+1 2 d
s+2 3 4
DABIN0E1
The value specified in the area s (Array_s[1]) through s+2 (Array_s[3]) is stored in d as -25018
as follows:
b15 b8b7 b0
s 32 H (2) 2DH (-) b15 b0
s+1 31 H (1) 35 H (5) d - 2 5 1 0 8
s+2 38 H (8) 30 H (0)
DABIN0E2
The ASCII value specified by s (Array_s[1]) through s+2 (Array_s[3]) may range from -32768
to 32767.
The sign character is stored as "20H" if the binary value is positive. For a negative result the
sign character "2DH" is stored.
Each stored digit of the ASCII code may range from "30H" to "39H".
If a digit contains the value "20H" or "00H", this value will be overwritten automatically with the
value "30H".
7 – 264
Character string processing instructions DABIN, DABINP, DDABIN, DDABINP
b15 b8b7 b0
s 4
s+1 5 d+1 d
6 b31 b16 b15 b0
s+2
3 2
s+3 7
s+4 8 1
s+5 9
5
ASCII code of the digit of ten millions / ASCII code of the digit of hundred millions
6
ASCII code of the digit of hundred thousands / ASCII code of the digit of millions
7 ASCII code of the digit of thousands / ASCII code of the digit of ten thousands
8 ASCII code of the digit of tens / ASCII code of the digit of hundreds
9
Is ignored / ASCII code of the digit of tens
DDABI0E1
The value specified in the area s (Array_s[1]) through s+5 (Array_s[6]) is stored in d as
-1234543210 as follows:
b15 b8b7 b0
s 31H (1) 2DH (-)
s+1 33 H (3) 32 H (2)
35 H (5) 34 H (4) d+1 d
s+2
-12345 43210
s+3 33H (3) 34 H (4)
s+4 31H (1) 32 H (2)
s+5 30 H (0)
DDABI0E2
The ASCII value specified in s (Array_s[1]) through s+5 (Array_s[6]) may range from
-2147483648 to 2147483647.
The sign character is stored as "20H" if the binary value is positive. For a negative result the
sign character "2DH" is stored.
Each stored digit of the ASCII code may range from "30H" to "39H".
If a digit contains the value "20H" or "00H", this value will be overwritten automatically with the
value "30H".
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The sign character stored in the lower 16 bits of the device s (Array_s[1]) contains a value
different from "30H" to "39H, "20H" or "00H".
(Error code 4100)
● The ASCII code stored in the area s (Array_s[1]) through s+5 (Array_s[6]) contains values
different from "30H" to "39H, "20H" to "00H".
(Error code 4100)
● The ASCII code stored in the area s (Array_s[1]) through s+5 (Array_s[6]) exceeds the
following range of values:
For the DABIN instruction -32768 to 32767
For the DDABIN instruction -2147483648 to 2147483647.
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program DABINP
Example 1
The following program converts the five-digit decimal ASCII value in D20 (var_D20 Array [0])
through D22 (var_D20 Array [2]) into a binary value and stores it in D0.
b15 b8b7 b0
D20 20 H 2DH (-) D0
D21 32 H (2) 20 H - 276
1
D22 36 H (6) 37 H (7) 2
“ 276“
1
Is read as -00276
2
Binary value
DABINMB1, DABINKB1, DABINIB1, DDABI0B1
7 – 266
Character string processing instructions DABIN, DABINP, DDABIN, DDABINP
Program DDABINP
Example 2
The following program converts the ten-digit decimal ASCII value in D20 (var_D20 Array [0])
through D25 (var_D20 Array [5]) into a binary value and stores it in D10 and D11.
b15 b8b7 b0
D20 20 H 20 H
D21 20 H 20 H
D11 D10
D22 39 H (9) 33 H (3)
D23 38 H (8) 36 H (6) 3 9 6 8 3 7 0
1
37 H (7) 33 H (3) 2
D24
D25 30 H (0)
“ 3968370“
1
Is read as +0003968370
2
Binary value
DABINMB2, DABINKB2, DABINIB2, DDABI0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
HABINGE1
7 – 268
Character string processing instructions HABIN, HABINP, DHABIN, DHABINP
Functions Conversion of hexadecimal ASCII data into BIN 16-/32-bit binary data
HABIN Conversion into BIN 16-bit data
The HABIN instruction converts the hexadecimal ASCII data in the device specified by s and
s+1 into the BIN 16-bit binary format and stores it in the devices specified by d.
b15 b8b7 b0
s 1 b15 b0
s+1 2 d
3
1
ASCII code for the 3rd digit/ ASCII code for the 4th digit
2
ASCII code for the 1st digit/ ASCII code for the 2nd digit
3
BIN 16-bit binary data
HABIN0E1
The value "5A8DH" specified in s through s+1 is stored in d after being processed as follows:
b15 b8b7 b0
s b15 b0
41H (A) 35H (5)
d 5A8D H
s+1 44 H (D) 38H (8)
HABIN0E2
The ASCII value specifed in s through s+1 may range from 0000H to FFFFH.
Each stored digit of the ASCII code may range from "30H" to "39H" and from "41H" to "46H".
b15 b8b7 b0
s 1 d+1 d
b31 b16 b15 b0
s+1 2
5 6
s+2 3
s+3 4 7
1
ASCII code of the 7th digit / ASCII code of the 8th digit
2
ASCII code of the 5th digit / ASCII code of the 6th digit
3 ASCII code of the 3rd digit / ASCII code of the 4th digit
4
ASCII code of the 1st digit / ASCII code of the 2nd digit
5
Upper 16 bits
6 Lower 16 bits
DHABI0E1
The value "5CB807E1" specified in s (Array_s[1]) through s+3 (Array_s[4]) is stored in d and
d+1 after being processed as follows:
b15 b8b7 b0
s 43 H (C) 35 H (5) d+1 d
b31 b16 b15 b0
s+1 38 H (8) 42 H (B)
5 C B 8H 0 7 E 1H
37 H (7) 30 H (0)
31 H (1) 45 H (E)
DHABI0E2
The ASCII value specified in s (Array_s[1]) through s+3 (Array_s[4]) may range from
00000000H and FFFFFFFFH.
Each stored digit of the ASCII code may range from "30H" to "39H" and from "41H" to "46H".
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The ASCII code stored in the area s (Array_s[1]) through s+3 (Array_s[4]) exceeds the
relevant range of "30H" to "39H" and from "41H" to "46H".
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 270
Character string processing instructions HABIN, HABINP, DHABIN, DHABINP
Program HABINP
Example 1
The following program converts the 4-digit ASCII value in D20 (var_D20 Array [0]) through D21
(var_D20 Array [1]) into a binary value and stores it in D0.
b15 b8b7 b0 D0
D20 36 H (6) 41 H (A)
- 22977
D21 46 H (F) 33 H (3)
“A63F”
Program DHABINP
Example 2
The following program converts the 8-digit ASCII value in D20 (var_D20 Array [0]) through D23
(var_D20 Array [3]) into a binary value and stores it in D10 and D11.
b15 b8b7 b0
D20 46H (F) 34 H (4)
D11 D10
D21 32H (2) 44 H (D)
13391 97264
D22 37H (7) 38 H (8)
D23 30 H (0) 35 H (5)
“4FD28750”
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DABCDGE1
7 – 272
Character string processing instructions DABCD, DABCDP, DDABCD, DDABCDP
b15 b7b8 b0
s b15 b12 b11 b8b7 b4b3 b0
1
d
s+1 2
3 4 5 6
1 ASCII code of the digit of hundreds / ASCII code of the digit of thousands
2
ASCII code of the digit of ones / ASCII code of the digit of tens
3
Digit of thousands
4 Digit of hundreds
5
Digit of tens
6
Digit of ones
DABCD0E1
b15 b7b8 b0
s b15 b12b11 b8b7 b4 b3 b0
37 H (7) 38 H (8)
d 8 7 6 5
s+1 35 H (5) 36 H (6)
DABCD0E2
The ASCII value specified in s through s+1 may range from 0 to 9999.
Each stored digit of the ASCII code may range from "30H" to "39H".
If a digit contains the value "20H" or "00H", this value will be overwritten automatically with the
value "30H".
b15 b7b8 b0
s 1 d+1 d
s+1 2 b31 b16 b15 b0
s+2 3
s+3 4
5 6 7 8 9 10 11 12
1
ASCII code of the digit of millions / ASCII code of the digit of ten millions
2
ASCII code of the digit of ten thousands / ASCII code of the digit of hundred thousands
3
ASCII code of the digit of hundreds / ASCII code of the digit of thousands
4
ASCII code of the digit of ones / ASCII code of the digit of tens
5
Digit of ten millions
6
Digit of millions
7
Digit of hundred thousands
8 Digit of ten thousands
9 Digit of thousands
10
Digit of hundreds
11Digit of tens
12Digit of ones
DDABC0E1
The value 87654321 specified in s (Array_s[1]) through s+3 (Array_s[4]) is stored in d and d+1
as follows:
b15 b8b7 b0
s 37 H (7) 38 H (8)
s+1 35 H (5) 36 H (6) b31 b16 b15 b0
s+2 33 H (3) 34 H (4) 8 7 6 5 4 3 2 1
s+3 31 H (1) 32 H (2)
d+1 d
DDABC0E2
The ASCII value specified in s (Array_s[1]) through s+3 (Array_s[4]) may range from 0 to
99999999.
Each stored digit of the ASCII code may range from "30H" to "39H".
If a digit contains the value "20H" or "00H", this value will be overwritten automatically with the
value "30H".
7 – 274
Character string processing instructions DABCD, DABCDP, DDABCD, DDABCDP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● There are characters within the data at s (Array_s[1]) to s+3 (Array_s[4]) that are outside
the range from "30H" to "39H".
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program DABCDP
Example 1
The following program converts the ASCII value in D20 (var_D20 Array [0]) through D21
(var_D20 Array [1]) into a 4-digit BCD value and outputs it at Y40 through Y4F.
b15 b7b8 b0
Y4F Y40
D20 34H (4) 20 H
0 4 9 4
D21 34H (4) 39 H (9)
b15 b7b8 b0
D20 34 H (4) 20 H
D11 DMOV Y5F
D10 Y50Y4F Y40
D21 37 H (7) 39 H (9)
0 4 9 7 2 9 4 9 0 4 9 7 2 9 4 9
D22 39 H (9) 32 H (2)
D23 39 H (9) 34 H (4)
CPU High
Basic Process Redundant Universal LCPU
Performance
d — — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
COMRDGE1
7 – 276
Character string processing instructions COMRD, COMRDP
b15 b7b8 b0
d 2
d+1 3
s d+2 4
d+3 5
8
1
6
7
00 H
1
Comment data
2 ASCII code of the 2nd character / ASCII code of the 1st character
3
ASCII code of the 4th character / ASCII code of the 3rd character
4
ASCII code of the 6th character / ASCII code of the 5th character
5 ASCII code of the 8th character / ASCII code of the 7th character
6 ASCII code of the 30th character / ASCII code of the 29th character
7
ASCII code of the 32th character / ASCII code of the 31th character
8 Stores at maximum 32 characters.
COMRD0E1
For example, the comment data stored in s with the character string "NO.1 LINE START" will
be stored from d (Array_d[1]) on, as follows:
b15 b7b8 b0
d F H (0) 4E H (N)
d+1 31 H (1) 2E H (.)
d+2 4C H (L) 20 H
NO.1 LINE START d+3 4E H (N) 49 H (I)
d+4 20 H 45 H (E)
d+5 54 H (T) 53 H (S)
d+6 52 H (R) 41 H (A)
d+7 00 H 54 H (T)
COMRD0E2
The address area of the devices specified by s must be located within the address area for
comment data.
If no comment is specified by s, the characters are converted into blank characters.
A comment must not exceed the maximum length of 32 characters.
The content of the byte following the last character depends on the status of the special relay
SM701 as follows:
● If SM701 is not set, a zero is stored
● If SM701 is set, no changes are made.
SM720 is set for one scan after the execution of the COMRD instruction has been finished.
SM721 is ON during the execution of the COMRD instruction. If SM721 is already set, when
the COMRD instruction is started, no processing will be performed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The comment is not registered to the device number specified by s.
(Error code 4100)
● The device number specified by d is not a word device.
(Error code 4101)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
NOTE The device comment used in the COMRD(P) instruction uses a comment file stored in a memory
card and the standard ROM. Comment files stored in the program memory cannot be used.
Set the comment file used for the COMRD(P) instruction in "PLC file setting" in the PLC para-
meter dialog box. If the comment file to be used is not set in the PLC file setting, device com-
ments cannot be output with the COMRD(P) instruction.
When a comment file is set in the "PLC File" tab of the PLC Parameter dialog box, but the file
does not exist at power-on or reset, "FILESET ERROR" (error code: 2400) will occur.
The COMRD(P) instruction cannot be executed during the interrupt program. No operation if
executed.
The processing of the COMRD (P) completes after several scans.
Two or more file comments cannot be accessed simultaneously.
The starting signal (command) of the COMRD(P) instruction is disabled when it is turned ON be-
fore an other COMRD(P) instruction is completed (while SM721 is ON). Execute the
COMRD(P)/PRC instruction when SM721 is OFF.
The following instructions cannot be executed simultaneously because they use SM721 in com-
mon:
ON during ON for one scan after the executi- ON after the execution of the instruction is
Instruction execution on of the instruction is complete complete with error
SP.FREAD
Bit designated by instruction Bit designated by instruction + next Bit
SP.FWRITE
SM721
PRC
SM720 —
COMRD
For the LCPU, when a comment file stored on an SD memory card is used, this instruction can-
not be executed while SM606 (SD memory card forced disable instruction) is ON. Even if the in-
struction is attempted to be executed, the command will be ignored.
7 – 278
Character string processing instructions COMRD, COMRDP
Program COMRDP
Example
With leading edge from X1C, the following program stores a comment specified in D100, as
ASCII code in W0 (var_W0 Array [0]) through W7 (var_W0 Array [7]).
b15 b8b7 b0
W0 4C H 41 H
W1 4E H 49 H
W2 20 H 45 H
ALINE TARGET W3 41 H 54 H
W4 57 H 52 H
W5 54 H 55 H
W6 20 H 20 H
W7 00 H
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
LEN_GE1
7 – 280
Character string processing instructions LEN, LENP
b15 b8b7 b0
s 1
s+1 2
b15 b0
s+2 3
d
6
s+n 00 H n 4
1
2nd character / 1st character
2
4th character / 3rd character
3 6th character / 5th character
4
nth character
5
End of character string
6 Length of character string
LEN__0E1
For example, the character string "ABCDEFGHI" stored in s is stored in d as "9" as follows:
b15 b8b7 b0
s 42 H (B) 41 H (A)
s+1 44 H (D) 43 H (C) “ABCDEFGHI“ b15 b0
s+2 46 H (F) 45 H (E) d 9
s+3 48 H (H) 47 H (G)
s+4 00 H 49 H (I)
LEN__0E2
The character string stored in s is being processed until the character code "00H" is read.
The result is stored in d.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The character code "00H" is missing in the last byte in s.
(Error code 4101)
Program LENP
Example
The following program processes the character string stored in D0, detects its length and out-
puts the character string as 4-digit BCD data at Y40 through Y4F.
b15 b8b7 b0
D0 49 H (I) 4D H (M)
D1 53 H (S) 54 H (T) D10 Y4F Y40
D2 42 H (B) 55 H (U) 10 0 0 1 0
D3 53 H (S) 49 H (I) BCD
D4 49 H (I) 48 H (H)
D5 41 H (A) 00 H 1
D6 43 H (C) 42 H (B)
1
Characters following the character code "00H" are omitted
(only the length of the character string "MITSUBISHI" is detected)
LEN_MB1, LEN_KB1, LEN_IB1, LEN__0B1
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 282
Character string processing instructions STR, STRP, DSTR, DSTRP
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
STR__GE1
1
s1 b8b7
(s1)+1 b15 b0
2
d 6
d+1 7
3 d+2 8 10
d+3 9
s2
4 D0 H
d+4
1
Total of all digits
2 Decimal places
3 Sign
4
Binary value
5 End of character string indication, automatically placed.
6 ASCII code for the (total number of digits -1)th digit / ASCII code of the sign
7
ASCII code for the (total number of digits -3)th digit / ASCII code for the (total number of digits -2)th digit
8 ASCII code for the (total number of digits -5)th digit / ASCII code for the (total number of digits -4)th digit
9 ASCII code for the (total number of digits -7)th digit / ASCII code for the (total number of digits -6)th digit
10
Total of all digits
STR__0E1
s1 5
(s1)+1 1
b15 b8b7 b0
d 31 H (1) 2D H
- 1 2 . 3 d+1 2E H (.) 32 H
d+2 00 H 33 H
s2 - 1 2 3
STR__0E2
The number of digits that can be stored in the device specified by s1 ranges from 2 to 8.
The number of decimal places that can be stored in the devices specified by (s1)+1 ranges
from 0 to 5 and must not exceed the number of digits minus 3.
The BIN 16-bit data that can be stored in the device specified by s2 must range from -32768
to 32767.
After the conversion into a character string, the string is stored in the devices specified by d
(Array_d[1]) through d+4 (Array_d[5]) as follows:
– A positive sign of the binary data is stored as ASCII character "20H" (blank).
– A negative sign of the binary data is stored as ASCII character "2DH" ("minus"- character).
7 – 284
Character string processing instructions STR, STRP, DSTR, DSTRP
If the number of decimal places is greater than zero, the decimal point "2EH" (.) is placed
automatically before the first digit specified.
1
6 1 Total of all digits
2
2 2 Number of decimal places
1 2 . 3 4 3
Binary value
1234 3 5 4
Decimal point placed automatically
4 5
Decimal places
STR__0B1
If the number of decimal places equals zero, the decimal point character "2DH" (.) is not placed.
If the number of decimal places is greater than the number of digits of the binary value, the
missing digits are replaced by zeroes, the binary value is shifted to the right, and the decimal
point is placed accordingly (0.).
1
6 1 Total of all digits
2Number of decimal places
3 2
0 .0 1 2 3Binary value
1 2 3 4
Zeroes and decimal point placed automati-
4
cally
STR__0B2
If the number of digits, sign and decimal point included, is greater than the number of digits in
the binary value, the missing digits between sign and numerical value are replaced by "20H"
(blanks) automatically.
1Total
of all digits
8 1 2Number
of decimal places
1 2
- 1 2 .3 3
Binary value
- 1 2 3 3 4 4Blank characters placed automatically.
STR__0B3
At the end of the converted character string the character code "00H" is stored automatically.
1
s1
(s1)+1
2 b15 b8b7 b0
d 8
d+1 9
3 d+2 10
(s2)+1 s2
14
b31 b16 b15 b0 d+3 11
4 5
d+4 12
6
d+5 00 H 13
1
Total of all digits
2
Decimal places
3
Sign
4 Upper 16 Bit
5
Lower 16 Bit
6
Binary value
7 End of character string indication, automatically placed.
8
ASCII code for the (total number of digits -1)th digit / ASCII code of the sign
9
ASCII code for the (total number of digits -3)th digit / ASCII code for the (total number of digits -2)th digit
10ASCII code for the (total number of digits -5)th digit / ASCII code for the (total number of digits -4)th digit
11
ASCII code for the (total number of digits -7)th digit / ASCII code for the (total number of digits -6)th digit
12
ASCII code for the (total number of digits -9)th digit / ASCII code for the (total number of digits -8)th digit
13End of character string indication / ASCII code for the (total number of digits -10)th digit
14
Total of all digits
DSTR0E1
s1 8
(s1)+1 3 b15 b8b7 b0
d 36 H (6) 2D H (-)
d+1 34 H (4) 35 H (5)
- 6 5 4 . 3 2 1 d+2 33 H (3) 2E H (.)
d+3 31 H (1) 32 H (32)
(s2)+1 s2
d+4 00 H
-6 5 4 3 2 1
DSTR0E2
The number of digits that can be stored in the device specified by s1 ranges from 2 to 13.
The number of decimal places that can be stored in the devices specified by (s1)+1 ranges
from 0 to 10 and must not exceed the number of digits minus 3.
The BIN 32-bit data that can be stored in the device specified by s2 and (s2)+1 must range
from -2147483648 and 32147483647.
7 – 286
Character string processing instructions STR, STRP, DSTR, DSTRP
After the conversion into a character string, the string is stored in the devices specified by
d (Array_d[1]) to d+5 (Array_d[6]) as follows:
– A positive sign of the binary data is stored as ASCII character "20H" (blank).
– A negative sign of the binary data is stored as ASCII character "2DH" ("minus"- character).
If the number of decimal places is greater than zero, the decimal point "2EH" (.) is placed
automatically before the first digit specified.
1
10 1 Total of all digits
2Number of decimal places
3 2
12345.678 3
1234 5678 3
Binary value
5 4
Decimal point placed automatically
4 5Decimal places
DSTR0E3
If the number of decimal places equals zero, the decimal point character "2DH" (.) is not placed.
If the number of decimal places is greater than the number of digits of the binary value, the
missing digits are replaced by zeroes, the binary value is shifted to the right, and the decimal
point is placed accordingly (0.).
If the number of digits, sign and decimal point included, is greater than the number of digits in
the binary value, the missing digits between sign and numerical value are replaced by "20H"
(blanks) automatically.
1
13 1 Total of all digits
2 . 2 2Number of decimal places
- 5432.10
3
- 5 4 3210 3 Binary value
4
Blank characters placed automatically.
4 DSTR0E5
At the end of the converted character string the character code "00H" is stored automatically.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of digits stored in s1 exceeds the range of values specified below:
(Error code 4100)
Range of values for the STR instruction: ........ 2 to 8
Range of values for the DSTR instruction: ..... 2 to 13
● The number of decimal places stored in (s1)+1 exceeds the range of values specified below:
(Error code 4100)
Range of values for the STR instruction: ........ 0 to 5
Range of values for the DSTR instruction: ..... 0 to 10
● The values stored in s1 and (s1)+1 do not correspond to the following relation:
The total of all digits minus 3 is greater than or equal to the number of decimal places.
(Error code 4100)
● The number of digits stored in s1 and (s1)+1 is less than the digits of the binary values in
s2 and (s2)+1.
(Error code 4100)
● The area storing the character string specified from d (Array_d[1]) onwards exceeds the relevant
device range.
(Error code 4100)
Program STRP
Example 1
With leading edge from X0, the following program converts the binary value specified by D10
corresponding to the number of digits specified in D0 and D1. The result is stored in the area
from D20 (var_D20 Array [1]) through D23 (var_D20 Array [4]).
b15 b8b7 b0
D10 12672 D20 31 H (1) 20 H
D21 36 H (6) 32 H (2)
D0 6 D22 32 H (2) 37H (7)
D1 0 D23 00 H “ 12672“
7 – 288
Character string processing instructions STR, STRP, DSTR, DSTRP
Program DSTRP
Example 2
With leading edge from X0, the following program converts the binary value specified in D10
and D11corresponding to the number of digits specified in D0 and D1. The result is stored in
the area from D20 (var_D20 Array [1]) through D26 (var_D20 Array [7]).
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
s — — — — — —
d1 — — — — — —
d2 — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
VAL__GE1
7 – 290
Character string processing instructions VAL, VALP, DVAL, DVALP
d1 10
(d1)+1 11
b15 b8b7 b0
s 1
s+1 2
s+2 3 - . d2 12
s+3 4
s+4 H
6 7 8 9
13
5
VAL_0E1
1 ASCII code for the 1st character / ASCII code for the sign
2
ASCII code for the 3rd character / ASCII code for the 2nd character
3 ASCII code for the 5th character / ASCII code for the 4th character
4 ASCII code for the 7th character / ASCII code for the 6th character
5
Indicates the end of the character string
6 Sign character
7 1st character
8
2nd character
9 7th character
12
Integer value, the decimal point is not processed
13BIN 16-bit
The character string "-123.45" in the area s (Array_s[1]) through s+4 (Array_s[5]) is to be con-
verted. The result will be stored in d1, (d1)+1 and d2 as follows:
d1 7
(d1)+1 2
b15 b8b7 b0
s 31 H (1) 2D H (-)
s+1 33 H (3) 32 H (2)
- 1 2 3 . 4 5 d2 - 1 2 3 4 5
s+2 34 H (4) 2E H (.)
s+3 00 H 35 H (5)
VAL_0E2
The number of all characters stored in s (Array_s[1]) through s+4 (Array_s[5]) may range from
2 to 8.
The number of possible decimal places stored in the area s (Array_s[1]) through s+4
(Array_s[5]) may range from 0 to 5. In general the number of decimal places must not exceed
the total of all digits minus 3.
The numerical value of a character string to be converted with the decimal point ignored must
range from -32768 to 32767. The numerical value of the ASCII character string with the sign
character and decimal point ignored must range from "30H" to "39H".
A positive sign of the binary data is stored as ASCII character "20H" (blank).
A negative sign of the binary data is stored as ASCII character "2DH" ("minus"- character).
The ASCII character "2EH" is stored as decimal point.
The total of all digits stored in d1, (d1)+1, and d2 contains all characters that represent the
numerical value as well as the sign character d1 and the decimal places (d1)+1.
In the binary data stored in d2 after the conversion the decimal point is ignored.
If the characters "20H" (blank) or "30H" (zero) are stored between character sign and first
numerical value, these are ignored for the conversion.
2 8 7 7
123.45 3 2 0 .0 0 1 2 8 4
1 4 -12345 9 12
5 6
VAL_0E3
1
These characters are not processed
2 Total of all digits
4
Binary value
5 Sign character
7
Total of all digits
8 Number of decimal places
9
Binary value
7 – 292
Character string processing instructions VAL, VALP, DVAL, DVALP
d1 13
b15 b8b7 b0
(d1)+1 14
s 1
s+1 2
s+2 3 (d2)+1 d2
s+3 4 - 15
s+4 5
s+5 6 9 10 11 12 16
s+6 H 7
DVAL0E1
1 ASCII code for the 1st character / ASCII code for the sign character
2
ASCII code for the 3rd character / ASCII code for the 2nd character
3 ASCII code for the 5th character / ASCII code for the 4th character
4 ASCII code for the 7th character / ASCII code for the 6th character
5
ASCII code for the 9th character / ASCII code for the 8th character
6 ASCII code for the 11th character / ASCII code for the 10th character
7 ASCII code for the zero character / ASCII code for the 12th character
8
Indicates the end of the character string
9 Sign character
101st character
11
2nd character
1212th character
14
Number of decimal places
15Integer value, the decimal point is not processed
16BIN 32-bit
d1 10
b15 b8b7 b0
(-) (d1)+1 3
s 31 H (1) 2D H
s+1 33 H (3) 32 H (2)
s+2 35 H (5) 34 H (4)
s+3 36 H (6) 2E H (.) - 1 2 3 4 5 . 6 7 8 -1 2 3 4 5 6 7 8
s+4 38 H (8) 37 H (7) (d2)+1 d2
s+5 H
DVAL0E2
The total of all characters stored in s (Array_s[1]) through s+6 (Array_s[7]) may range from 2
to 13.
The number of possible decimal places stored in the area s (Array_s[1]) through s+6
(Array_s[7]) may range from 0 to 10. In general the number of decimal places must not exceed
the total of all digits minus 3.
The numerical value of a character string to be converted with the decimal point ignored must
range from -2147483648 to 2147483647. The numerical value of the ASCII character string
with the sign character and decimal point ignored must range from "30H" to "39H".
A positive sign of the binary data is stored as ASCII character "20H" (blank).
A negative sign of the binary data is stored as ASCII character "2DH" ("minus"- character).
The ASCII character "2EH" is stored as decimal point.
The total of all digits stored in d1, (d1)+1, d2, and (d2)+1 contains all characters that represent
the numerical value as well as the sign character d1 and the decimal places (d1)+1.
In the binary data stored in d2 and (d2)+1 after the conversion the decimal point is ignored.
If the characters "20H" (blank) or "30H" (zero) are stored between character sign and first
numerical value, these are ignored for the conversion.
1
These characters are not processed
2
Total of all digits
2 12 3
3 2 Number of decimal places
6543. 21 4 BIN 32-bit binary value
4 -654 321 DVAL0E3
1
1
Sign character
2 These characters are not processed
3 11
3 Total of all digits
0. 0 0 0 5 4 3 2 1 4 8
4
Number of decimal places
5 5 4 3 2 1 5 BIN 32-bit binary value
1 2
DVAL0E4
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The total of all digits stored from s (Array_s[1]) onwards exceeds the range of values from
2 to 8 (VAL) or 2 to 13 (DVAL) respectively. (Error code 4101)
● The number of decimal places stored in (d1)+1 exceeds the range of values from 0 to 5
(VAL) or 0 to 10 (DVAL) respectively. (Error code 4100)
● The total of all digits minus 3 is greater than or equal to the number of decimal places.
(Error code 4100)
● An ASCII code other than "20H" or "2DH" were stored for the character sign.
(Error code 4100).
● An ASCII code other than from "30H" to "39H", or "2EH" were stored as a digit for one of the
individual numbers. (Error code 4100)
● More than one decimal point is stored in one value. (Error code 4100)
● The binary value exceeds the range of values from -32768 to 32767 (VAL) or -2147483648
to 2147483647 (DVAL) after the conversion. (Error code 4100)
● The ASCII character "00H" is placed to the wrong digit. (Error code 4100)
7 – 294
Character string processing instructions VAL, VALP, DVAL, DVALP
Program VALP
Example 1
With leading edge from X0, the following program converts the character string stored in the
area D20 (var_ D20 Array [1]) through D23 (var_ D20 Array [4]) into an integer value, converts
this value into a BIN 16-bit binary value, and stores it in D0.
b15 b8b7 b0
D20 31 H (1) 2D H (-) D0 -1654
D21 2E H (.) 36 H (6)
(5) D10 6
D22 34 H (4) 35 H
D23 D11 2
H
b15 b8b7 b0 D1 D0
D20 37 H (7) 20 H 7 9 1 0 0 6 1 1
D21 31 H (1) 39 H (9)
D22 30 (0) (0) D10 6
H 30 H
36 (6) 2E H (.) D11 2
D23 H
D24 31 H (1) 31 H (1)
D25 H
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ESTR_GE1
7 – 296
Character string processing instructions ESTR, ESTRP
s2 1 1
4 Data format (decimal format "0"/
(s2)+1 2
(s2)+2 3
exponential format "1")
2Total of all digits
ESTR_0E1
s2 1
(s2)+1 2
(s2)+2 3 b15 b8b7 b0
d1 7
(d1)+1 8
. (d1)+2 9
(d1)+3 10
4 (d1)+4 00 H
(s1)+1 s1
6
1
Data format (decimal format "0" / exponential format "1")
2
Total of all digits
3 Number of decimal places
4
Sign character
5
Floating point data (real number)
6 End of character string, placed automatically
7
ASCII code for the (total number of digits -1)th digit / ASCII code of the sign
8
ASCII code for the (total number of digits -3)th digit / ASCII code for the (total number of digits -2)th digit
9 ASCII code for the (total number of digits -5)th digit / ASCII code for the (total number of digits -4)th digit
10
ASCII code for the (total number of digits -7)th digit / ASCII code for the (total number of digits -6)th digit
ESTR0E2
Decimal format
The real number -1.23456 is converted into a character string with a total of 8 digits (3 decimal
places included). The result is stored from d onwards.
s2 0
(s2)+1 8
b15 b8b7 b0
(s2)+2 3 d1 20 H 2D H (-)
(d1)+1 31 H (1) 20 H
(d1)+2 32 H (2) 2E H (.)
1 . 2 3 4
(d1)+3 34 H (4) 33 H (3)
(d1)+4 00 H
1
(s1)+1 s1
-1.2 3 4 5 6 3
1
Sign character
2
Floating point number (real number)
3
End of character string, automatically placed
ESTR0E3
The total number of all digits of the number in (s2)+1 (Array_s2[2]) to be converted is
represented as follows:
– If the number of decimal places is zero, the total number of digits is >= 2.
– If the number of the decimal places is a different value, the total number of all digits is 3 plus
the number of decimal places.
The number of decimal places that has to be specified must range within 0 and 7. In general,
the number of decimal places must be less than or equal to the total number of all digits
minus 3.
After the conversion the character string in d is stored as follows:
– A positive sign of the floating point data is stored as ASCII character "20H" (blank).
– A negative sign of the floating point data is stored as ASCII character "2DH" ("minus"-
character).
In cases where the actual number of decimal places of the floating point data exceeds the
specified number of decimal places, the surplus digits are cut off.
ESTR0E4
If the number of decimal places is specified a value different from zero, the decimal point "2EH"
(.) is placed automatically in the specified digit.
If the number of decimal places is specified zero the decimal point "2EH" (.) is not placed.
7 – 298
Character string processing instructions ESTR, ESTRP
s2 4
(s2)+1 5 3
(s2)+2 6 1
Number of decimal places
- 1 . 2 3
2
(s1)+1 s1
Decimal point is placed and stored
1
automatically
-1.2 3 4 5 6 2 3
Total of all digits
ESTR0E5
If the total number of digits, excluding the sign, the decimal point and the decimal fraction part,
is greater than the integer part of the 32-bit floating point type real number data, "20H (space)"
will be stored between the sign and the integer part.
s2 0
(s2)+1 8 1
(s2)+2 2
- 1 . 2 3
(s1)+1 s1 3 1
2 Total of all digits
-1.2 3 4 5 6
2
Blanks "20H" are stored
3
Number of decimal places
ESTR0E6
The character code "00H" is stored automaticallly at the end of the character string.
Exponential format
s2 1 b15 b8b7 b0
(s2)+1 2
d1 9
(s2)+2 3
(d1)+1 10
. E (d1)+2 11
5 (d1)+3 12
7
(s1)+1 s1 (d1)+4 13
6 (d1)+5 14
4 (d1)+6 00 H
1
Data format (Exponential format) (1)
2
Total number of all digits
3
Number of decimal places
4
Floating point number (real number)
5
Sign of the integer value
6 The "E" is placed automatically
7
Sign of the exponent
8 End of character string indication, placed automatically
9 ASCII code for the (total number of digits -1)th digit / ASCII code of the sign
10ASCII code for the (total number of digits -3)th digit / ASCII code for the (total number of digits -2)th digit
11
ASCII code for the (total number of digits -5)th digit / ASCII code for the (total number of digits -4)th digit
12ASCII code for the (total number of digits -7)th digit / ASCII code for the (total number of digits -6)th digit
14
ASCII code for the (total number of digits -11)th digit (exponent)/ASCII code for the (total number of
digits -10)th digit (exponent)
ESTR0E7
7 – 300
Character string processing instructions ESTR, ESTRP
Example The real number -12.34567 is to be represented in exponential notation. The total number of
all digits is 12. The number of decimal digits is specified 4. The result is stored from d1
onwards.
s2 1
(s2)+1 12
(s2)+2 4 b15 b8b7 b0
d1 20 H 2D H (-)
(d1)+1 2E H (.) 31 H (1)
- 1 . 2 3 4 5 E + 0 1 (d1)+2 33 H (3) 32 H (2)
(d1)+3 35 H (5) 34 H (4)
2 3 (d1)+4 2C H (+) 45 H (E)
(s1)+1 s1 (d1)+5 31 H (1) 30 H (0)
(d1)+6 00 H
-1 2 . 3 4 5 6 7
1 4
1
Floating point number (real number)
2
Sign of the integer value
3
Sign of the exponent
4
End of character string indication, placed automatically
ESTR0E8
The total number of all digits of the number in (s2)+1 (Array_s2[2]) to be converted is
represented as follows:
– If the number of decimal places is zero, the total number of digits is >= 2.
– If the number of the decimal places is a different value, the total number of all digits is 7 plus
the number of decimal places.
The number of decimal places that has to be specified must range within 0 and 7. In general,
the number of decimal places must be less than or equal to the total number of all digits
minus 7.
After the conversion the character string in d is stored as follows:
– A positive sign of the floating point data is stored as ASCII character "20H" (blank).
– A negative sign of the floating point data is stored as ASCII character "2DH" ("minus"-
character).
The integer range is fixed to 2 digits. If the integer range contains one digit only, a blank in
ASCII code is placed and stored between the sign character and the integer digit.
s2 1 1
(s2)+1 12
(s2)+2 4
- 1 . 2 3 4 5 E + 0 1
(s1)+1 s1
-1 2 . 3 4 5 6 7 2 1
Total of all digits (12)
2
Becomes a blank
ESTR0E9
If the floating point value of the decimal range is longer than the relevant storage range, the
digits that cannot be stored are cut off.
s2 1 1
(s2)+1 12
(s2)+2 4
- 1 . 2 3 4 5 6 7 E + 0 1
(s1)+1 s1 2 3
-1 2 . 3 4 5 6 7
ESTR0E10
If the number of decimal places is specified a value different from zero, the decimal point "2EH"
(.) is placed automatically in the specified digit.
s2 1 1
(s2)+1 12
(s2)+2 4
- 1 . 2 3 4 5 E + 0 1
1
(s1)+1 s1 3 Total of all digits (12)
-1 2 . 3 4 5 6 7 2
2 Is placed automatically
3 Number of digits in the decimal range (4)
ESTR0E11
If the number of decimal places is specified zero the decimal point "2EH" (.) is not placed.
The ASCII code "2CH" (+) is placed and stored for a positive exponent.
The ASCII code "2DH" (-) is placed and stored for a negative exponent.
The exponential range is fixed to 2 digits. If the exponential range contains one digit only, the
ASCII code "30H" (0) is placed and stored between the exponent sign and the exponent.
s2 1 1
(s2)+1 12 2
(s2)+2 4
- 1 . 2 3 4 5 E + 0 1
(s1)+1 s1 1 Total of all digits (12)
-1 2 . 3 4 5 6 7 3 2
Is fixed to 2 digits
3
Is set to zero automatically
ESTR0E12
The character code "00H" is stored automaticallly at the end of the character string.
7 – 302
Character string processing instructions ESTR, ESTRP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The devices specified in s1 and (s1)+1 are not within the following range:
0, + 2-126 < s1 < + 2 128.
(Error code 4100)
● The format in s2 (Array_s2[1]) is neither 0 nor 1.
(Error code 4100)
● The total number of digits in (s2)+1 (Array_s2[2]) exceeds the range of values:
(Error code 4100)
Program ESTRP
Example 1
With leading edge from X0, the following program converts a floating point value (real number)
specified by the devices R0 and R1 into the format specified by R10 (var_R10 Array [1])
through R12 (var_R10 Array [3]) and stores the result in D0 through D3.
b15 b8b7 b0
R10 0 20 H
D0 20 H
R11 7 1
D1 2E H (.) 30 H (0)
R12 3 0 . 3 2 7 D2 32 H (2) 33 H (3)
D3 00 H 37 H (7)
R1 R0 2 3
0 .0 3 2 7 4 5 7
4
4 Is stored automatically
7 – 304
Character string processing instructions ESTR, ESTRP
Program ESTRP
Example 2
With leading edge from X0, the following program converts a floating point value (real number)
specified by D0 and D1 into the format specified by R10 (var_R10 Array [1]) through R12
(var_R10 Array [3]) and stores the result in D10 through D16.
R10 1 1
R11 12 2 4
R12 4 3 3 . 2 7 4 5 E - 0 2
R1 R0 5 6
0 .0 3 2 7 4 5 7 8 b15 b8b7 b0
D10 20 H 20 H
D11 2E H (.) 33 H (3)
D12 37 H (7) 32 H (2)
D13 35 H (5) 34 H (4)
D14 2D H (-) 45 H (E)
D15 32 H (2) 30 H (0)
D16 00 H
1
Data format (Exponential representation) (1)
2
Total number of all digits
3 Number of decimal places
5
Blanks
6 Number of decimal places in the decimal part
7 Is stored automatically
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EVAL_GE1
7 – 306
Character string processing instructions EVAL, EVALP
Functions Conversion of character string data into decimal floating point data
EVAL Conversion of character strings
The EVAL instruction converts the character string in s through s+4 into a decimal floating point
number (real number). The result is stored in d.
The characer string can be converted into decimal floating point format as well as into the expo-
nential format.
1 Decimal floating point data
b15 b8b7 b0 (data type REAL)
s 2 2 ASCII code of the 1st character/
s+1 3 d+1 d ASCII code of sign character
s+2 4 3 ASCII code of the 3rd character/
s+3 5
1 ASCII code of the 2nd character
s+4 H 4 ASCII code of the 5th character/
Decimal format
b15 b8b7 b0
s 31 H (1) 2D H (-)
s+1 30 H (0) 2E H (.) d+1 d
s+2 38 H (8) 37 H (7) -1. 0 7 8 1 2
s+3 32 H (2) 31 H (1)
1
s+4 H
- 1 . 0 7 8 1 2
1
Decimal floating point data (real number)
EVAL0E2
Exponential format
b15 b8b7 b0
s 20 H 2D H (-)
s+1 2E H (.) 31 H (1)
s+2 32 H (2) 33 H (3) d+1 d
s+3 31 H (1) 30 H (0) -1.3 2 0 1 E+10
s+4 2C H (+) 45 H (E)
s+5 (0) (1) 1
30 H 31 H
s+6 H
- 1 . 3 2 0 1E + 1 0
1
Decimal floating point data (data type REAL)
EVAL0E3
In the example below, six digits (without sign, decimal point, and exponent digits of the result)
of the character string from s onwards are converted into a decimal floating point number. The
digits from the 7th digit on are cut off from the result.
Decimal format
b15 b8b7 b0
s 20 H 2D H (-)
s+1 31 H (1) 20 H
s+2 33 H (3) 2E H (.) d+1 d
s+3 31 H (1) 30 H (0) -1. 3 0 1 5 6
s+4 36 H (6) 35 H (5)
s+5 31 H (1) 38 H (8) 2
s+6 00 H 32 H (2)
- 1 . 9 0 1 5 6 8 1 2
1
These digits are omitted
2 Decimal floating point data (data type REAL)
EVAL0E4
Exponential format
b15 b8b7 b0
s 20 H 2D H (-)
s+1 2E H (-) 31 H (1)
s+2 35 H (5) 33 H (3) d+1 d
s+3 33 H (3) 30 H (0) -1 . 3 5 0 3 4 E -2
s+4 31 H (1) 34 H (4)
s+5 45 H (E) 32 H (2) 2
s+6 30 H (0) 2D H (-)
s+7 00H 32 H (2)
- 1 . 3 5 0 3 4 1 2 E - 0 2
1
These digits are omitted
2
Decimal floating point data (data type REAL)
EVAL0E5
7 – 308
Character string processing instructions EVAL, EVALP
Leading blanks (ASCII code "20H") or zeroes (ASCII code "30H") in the character string from s
onwards are ignored by the conversion, except for the initial zero (e.g. 0.123).
b15 b8b7 b0
s 20 H 2D H (-) d+1 d
s+1 31 H(1) 30 H (0) 1 . 2 3 1
s+2 32 H(2) 2E H (.)
2
s+3 31 H(1) 33 H (3)
s+4 H
0 1 . 2 3 1
b15 b8b7 b0
20 H 2D H (-)
2E H (.) 31 H (1)
34 H (4) 30 H (0) d+1 d
33 H (3) 35 H (5) - 1 . 0 4 5 3 E +3
2C H (+) 45 H (E)
2
33 H (3) 30 H (0)
H
- 1 . 0 4 5 3 E + 0 3
1
These characters are ignored by the conversion
2
Decimal floating point data (data type REAL)
EVAL0E7
A character string to be converted may contain a maximum of 24 characters.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The digits prior to the decimal point or the decimal places contain characters exceeding the
range of values from "30H" (0) to "39H" (9).
(Error code 4100)
● The character "2EH" is used more than once within the character string. (Error code 4100)
● The exponent part contains characters different from "45H (E), 2BH (+)" or "45H (E), 2DH (-)"
or contains more than one exponent portion.
(Error code 4100)
● Data after conversion is not within the following range:
0, + 2-126 < (data after conversion) < + 2 128
(Error code 4100)
● The end of string indicator "00H" exceeds the relevant storage device range.
(Error code 4100)
● The number of characters in the string is 0 or greater than 24.
(Error code 4100)
Program EVALP
Example 1
With leading edge from X20, the following program converts the character string specified in
R0 through R5 into a decimal floating point number (real number) and stores the result in D0
and D1.
b15 b8b7 b0
R0 20 H 2D H (-)
R1 31 H (1) 30 H (0)
D1 D0
R2 32 H (2) 2E H (.)
-1. 2 3 4 5 2
R3 34 H (4) 33 H (3)
R4 32 H (2) 35 H (5)
R5 00 H 31 H (1)
- 0 1 . 2 3 4 5 2 1
1 2
1
This digit is not processed
2
This number is cut off
EVALMB1, EVALKB1, EVALIB1, EVAL0B1
7 – 310
Character string processing instructions EVAL, EVALP
Program EVALP
Example 2
With leading edge from X20, the following program converts the character string specified in
D10 through D16 into a floating point number (data type REAL) and stores the result in D100
and D101.
b15 b8b7 b0
D10 20 H 20 H
D11 2E H 31 H
D101 D100
D12 33 H 32 H
- 1 . 2 3 4 5 E -2
D13 35 H 34 H
D14 2D H 45 H
D15 32 H 30 H
D16 00 H
1 . 2 3 4 5 E - 0 2
1 1
1
These digits are not processed
EVALMB2, EVALKB2, EVALIB2, EVAL0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
NOTE The ASC and the ASCP instructions do not work with the IEC editors. The only way to program
these instructions is by using the MELSEC instruction list.
Remedy: Move the hexadecimal ASCII format direct into the target registers.
,,
ASC__ME1, ASC__KE1, ASC_IE1
GX Works2
ASC__GE1
7 – 312
Character string processing instructions ASC, ASCP
4 9
1
First digit / second digit / third digit / fourth digit
2
First digit / second digit / third digit / fourth digit
3
First digit / second digit / third digit / fourth digit
4
Binary data
5
ASCII code of the 1st digit / ASCII code of the 2nd digit
6
ASCII code of the 3rd digit / ASCII code of the 4th digit
7 ASCII code of the 5th digit / ASCII code of the 6th digit
8
ASCII code of the 7th digit / ASCII code of the 8th digit
9
ASCII code of the 9th digit / ASCII code of the 10th digit
10Number of digits specified in n
ASC_0E1
ASC_0E2
The number of characters specified in n determines the ranges of values of the devices speci-
fied from s and d onwards. The devices specified from s onwards contain the binary data to be
converted. The converted character string is stored in the devices specified from d onwards.
The program is even processed accurately and without an error message, if the storage area
of the binary data to be converted overlaps with that of the converted ASCII data.
ASC_0E3
If n specifies an odd number of characters, the ASCII character "00H" is placed automatically
into the upper 8 bits of the highest address of the area, storing the character string.
ASC_0E4
If the number of characters specified by n is zero, the program will not be executed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of characters specified by n and therefore the required number of registers from
s onwards exceeds the relevant storage device range.
(Error code 4101)
● The number of characters specified by n and therefore the required number of registers from
d onwards exceeds the relevant storage device range.
(Error code 4101)
Program ASCP
Example
With leading edge from X0, the following program reads in the binary data stored in D0 as hexa-
decimal values and converts it into a character string. The result is stored in D10 through D14.
ASC_0B1
7 – 314
Character string processing instructions HEX, HEXP
CPU High
Basic Process Redundant Universal LCPU
Performance
s — — — — — — —
d — — — — — — —
n —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
HEX__GE1
1
4th digit / 3rd digit / 2nd digit / 1st digit
2
Binary data
3 ASCII code of the 2nd digit / ASCII code of the 1st digit
4
ASCII code of the 4th digit / ASCII code of the 3rd digit
5
ASCII code of the 2nd digit / ASCII code of the 1st digit
6 ASCII code of the 4th digit / ASCII code of the 3rd digit
HEX_0E1
b15 b8b7 b0
s 33 H (3) 34 H (4)
s+1 31 H (1) 32 H (2) b15 b12b11 b8b7 b4b3 b0
2 s+2 42 H (B) 36 H (6) d 1H 2H 3H 4H
s+3 41 H (A) 39 H (9) d+1 AH 9H BH 6H
s+4 38 H (8) 45 H (E) d+2 0 H 0 H 0H EH
1 Since the character string contains 9 characters, the "38H" is not changed or moved.
2 n=9
HEX_0E2
The number of characters specified in n determines the range of values of the character string
from s and of the binary data from d onwards automatically.
Although the range of values of the ASCII code to be converted and that of the converted
binary values overlap, this instruction processes the data accurately.
D11 43 H 37 H D12 0H 5H AH F H
D12 41 H 46 H D13 0H 0H 2 H 2 H
D13 30 H 35 H
D14 32 H 32 H
HEX_0E3
7 – 316
Character string processing instructions HEX, HEXP
If the number of characters in n is not divisible by 4, a zero is written after the specified number
of characters automatically to the highest registers storing the converted binary values.
1
The value zero is stored automatically
HEX_0E4
If the number of characters in n is zero, the conversion will not be executed.
The ASCII code from s onwards may range from "30H" through "39H" and from "41H" through
"46H".
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The devices specified from s onwards contain characters exceeding the ranges from "30H"
through "39H", or from "41H" to "46H".
(Error code 4100)
● The number of characters specified by n and therefore the required number of registers from
s onwards exceeds the relevant storage device range.
(Error code 4101)
● The number of characters specified by n and therefore the required number of registers from
d onwards exceeds the relevant storage device range.
(Error code 4101)
● The value n is negative.
(Error code 4101)
Program HEXP
Example
With leading edge from X0, the following program converts the character string "6B52A71379"
stored in D0 through D4 into binary data. The result is stored in D10 through D14.
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 318
Character string processing instructions RIGHT, RIGHTP, LEFT, LEFTP
CPU High
Basic Performance Process Redundant Universal LCPU
s — — — — — — —
d — — — — — — — —
n — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
RIGHTGE1
Functions Extraction of character string data from the right or from the left
RIGHT Extract character string data from the right
The RIGHT instruction stores n characters from the right side of the character string (end of
character string) from s onwards. The characters are stored from d onwards.
b15 b8b7 b0
s b15 b8b7 b0
1
d 7
s+1 2
d+1 8
3
4 9
00 H 10
5
00 H 6
1 ASCII code of the 2nd characters / ASCII code of the 1st chracter
2
ASCII code of the 4th character / ASCII code of the 3rd character
3
ASCII code of the last character minus n+2 / ASCII code of the last character minus n+1
4 ASCII code of the last character minus n+4 / ASCII code of the last character minus n+3
5
ASCII code of the last character minus 1 / ASCII code of the last character minus 2
6
"00H" / ASCII code of the last character
7 ASCII code of the last character minus n+2 / ASCII code of the last character minus n+1
8 ASCII code of the last character minus n+4 / ASCII code of the last character minus n+3
9
ASCII code of the last character minus 1 / ASCII code of the last character minus 2
10 "00H" / ASCII code of the last character
RIGH0E1
– With n = 5
b15 b8b7 b0
s b15 b8b7 b0
42 H (B) 41 H (A)
d 32 H (2) 31 H (1)
s+1 44 H (D) 43 H (C)
d+1 34 H (4) 33 H (3)
s+2 46 H (F) 45 H (E)
d+2 00 H 35 H (5)
s+3 32 H (2) 31 H (1)
s+4 34 H (4) 33 H (3) “1 2 3 4 5“
s+5 00 H 35 H (5) 1
“A B C D E F 1 2 3 4 5”
7 – 320
Character string processing instructions RIGHT, RIGHTP, LEFT, LEFTP
b15 b8b7 b0
s b15 b8b7 b0
1
d 7
s+1 2
d+1 8
3
4 9
00 H 10
5
00 H 6
1
ASCII code of the 2nd character / ASCII code of the 1st character
2
ASCII code of the 4th character / ASCII code of the 3rd character
3
ASCII code of the character n-1 / ASCII code of the character n-2
4
ASCII code of the character n+1 / ASCII code of the nth character
5
"00H" / ASCII code of the last character
6
ASCII code of the 2nd character / ASCII code of the 1st character
7
ASCII code of the 4th character / ASCII code of the 3rd character
8 ASCII code of the character n-1 / ASCII code of the character n- 2
LEFT0E1
– With n=7
b15 b8b7 b0
b15 b8b7 b0
s 42 H (B) 41 H (A)
d 42 H (B) 41H (A)
s+1 44 H (D) 43 H (C)
d+1 44 H (D) 43 H (C)
s+2 46 H (F) 45 H (E)
d+2 46 H (F) 45 H (E)
s+3 32 H (2) 31 H (1)
H
1
ASCII code of the 7th character
LEFT0E2
If the number of characters in n is zero, the character code "00H" is stored from d onwards.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in n exceeds the number of existing characters stored from s onwards.
(Error code 4101)
● The area specified by n exceeds the relevant device range of the device specified by d.
(Error code 4101)
Program RIGHTP
Example 1
With leading edge from X0, the following program extracts 4 characters of the data from the
right side of the character string stored in R0 through R4 and stores it in D0 through D2.
b15 b8b7 b0
b15 b8b7 b0
R0 41 H (A) 42 H (B)
D0 45 H (E) 30 H (0)
R1 31 H (1) 32 H (2)
R2 D1 41H (A) 45 H (F)
45 H (E) 30 H (0)
D2 00 H
R3 41 H (A) 46 H (F)
“DEFA“
R4 00 H
“BA210EFA” 1
1
ASCII code of the 4th character
RIGHTMB1, RIGHTKB1, RIGHTIB1, RIGH0B1
Program LEFTP
Example 2
With leading edge from X1C, the following program extracts the number of characters specified
in D0 from the left side of the character string specified in D100 through D104. The result is
stored in R10 through R13.
b15 b8b7 b0
b15 b8b7 b0
D100 51 H (Q) 53 H (S)
R10 51 H 53 H
D101 4E H (N) 4F H (O)
R11 4E H 4F H
D102 44 H (D) 48 H (H)
R12 44 H 48 H
D103 42 H (B) 41 H
D104 R13 00 H
00 H
“SQONHD”
“SQONHDAB”
1 D0 6
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 322
Character string processing instructions MIDR, MIDRP, MIDW, MIDWP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
MIDR_GE1
b15 b8b7 b0
s1 42 H (B) 41 H (A) b15 b8b7 b0
(s1)+1 44 H (D) 43 H (C) d 46 H (F) 45 H (E)
(s1)+2 46 H (F) 45 H (E) d+1 48 H (H) 47 H (G)
(s1)+3 48 H (H) 47 H (G) 1 d+2 00 H 49 H (I)
(s1)+4 4A H (J) 49 H (I) “EFGHI”
(s1)+5 D0 H 4B H (K) 2
“ABCDEFGHIJK”
s2 5
(s2)+1 5
1
Position of the 1st character (s2), 5th character of the character string
2
Position of the last character to be stored
MIDR0E1
b15 b8b7 b0
b15 b8b7 b0
d 46 H (F) 45 H (E)
s1 42 H (B) 41 H (A)
d+1 48 H (H) 47 H (G)
(s1)+1 44 H (D) 43 H (C)
d+2 4A H (J) 49 H (I)
(s1)+2 46 H (F) 45 H (E)
00 H 4B H (K)
(s1)+3 48 H (H) 47 H (G)
(s1)+4 4A H (J) 49 (I) 1
H
(s1)+5 00 H 4B H (K)
“ABCDEFGHIJK”
s2 5
(s2)+1 -1
1
Position of the 1st character (s2), 5th character of the character string
MIDR0E2
7 – 324
Character string processing instructions MIDR, MIDRP, MIDW, MIDWP
MIDW0E1
MIDW0E2
If the value -1 is stored in (s2)+1 (Array_s2[2]), the characters are stored from s1 onwards.
MIDW0E3
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
For the MIDR instruction
● The initital device number of the characters to be stored specified in s2 (Array_s2[1]) exceeds
the range from s1 to (s1)+n.
(Error code 4101)
● The initital device number of the characters to be stored specified in (s2)+1 (Array_s2[2])
exceeds the range from d to d+n.
(Error code 4101)
● The s2+0 value is 0.
(Error code 4101)
● "00H" does not exist in the specified devices that follow the device specified for s1.
(Error code 4101)
7 – 326
Character string processing instructions MIDR, MIDRP, MIDW, MIDWP
Program MIDRP
Example 1
With leading edge from X0, the following program stores characters in D0 through D2 from a
character string in D10 through D13. The number of characters to be stored is specified in R1
(var_R0 Array [2]). The starting position within the source string is specified in R0 (var_R0
Array [1]).
b15 b8b7 b0
D10 41 H (A) 42 H (B) b15 b8b7 b0
D11 31 H (1) 32 H (2) 31 H (1) 32 H (2)
D12 46 H (E) 33 H (3) 46 H (E) 33 H (3)
D13 00 H 45 H (D) 00 H
“213E”
“BA213ED”
R0 3
R1 4
Program MIDWP
Example 2
With leading edge from X1C, the following program stores characters in D100 through D104
from the beginning of a character string in D0 through D3. The number of characters to be
stored is specified in R1 (var_R0 Array [2]). The starting position where the characters are
stored is specified by R0 (var_R0 Array [1]).
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 328
Character string processing instructions INSTR, INSTRP
CPU High
Basic Performance Process Redundant Universal LCPU
s1 — — — — — — —
s2 — — — — — — —
d — — —
n — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
INSTRGE1
d 5 3
INST0E1
If no matching character string is found, a zero is stored in d.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The initial search position stored in n exceeds the range of (s2) through (s2)+n.
(Error code 4100)
● 00H (NULL) does not exist within the corresponding device range after the device designated
by s1, s2.
(Error code 4100)
● The value of n is negative number or “0”.
(Error code 4100)
7 – 330
Character string processing instructions INSTR, INSTRP
Program INSTRP
Example 1
With leading edge from X0, the following program searches in R0 onwards beginning with the
5th character for the character string specified in D0 through D2. The result (0) is stored in
D100.
b15 b8b7 b0
b15 b8b7 b0
R0 49 H (I) 43 H (C) 1 D0 49 H (I) 43 H (C)
R1 33 H (3) 32 H (2)
2 D1 33 H (3) 32 H (2)
R2 32 H (2) 31 H (1)
D2 00 H
R3 49 H (I) 43 H (C)
R4 00 H 4D H (M) “C123”
“C12312CIM”
D100 0
1
This area is not searched through.
2
The search begins with the 5th character.
INSTRMB1, INSTRKB1, INSTRIE2, INST0B1
Program INSTRP
Example 2
With leading edge from X0, the following program searches in D0 onwards beginning with the
3rd character for the character string "AB". The search result (5) is stored in D100.
b15 b8b7 b0
D0 32 H (2) 31 H (1)
D1 34 H (4) 33 H (3) 1 D100 5
D2 42 H (B) 41 H (A) 2
D3 36 H (6) 35 H (5)
D4 42 H (B) 41 H (A)
D5 00 H
“1234AB56AB”
1
The search begins with the 3rd character.
2
The searched character string begins at the 5th character.
INSTRMB2, INSTRKB2, INSTRIB2, INST0B2
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 332
Character string processing instructions STRINS, STRINSP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
STRINS s d n 4
STRINSP d n
6
s
– For n=3
b15 b8b7 b0
s 31 H (1) 30 H (0) b15 b8b7 b0
s +1 33 H (3) 32 H (2) d 42 H (B) 41H (A)
s +2 00 H 34 H (4) d +1 ( s )
31 H (1) 30H (0)
1) d +2 33 H (3) 32H (2) ( s +1)
d +3 43 H (C) 34H (4) ( s +2)
b15 b8b7 b0
d d +4 45 H (E) 44H (D)
42 H (B) 41H (A)
d +1 2) d +5 47 H (G) 46H (F)
44 H (D) 43H (C)
d +2 d +6 00 H 48H (H)
46 H (F) 45H (E)
d +3 d +7 66 H (f) 65H (e)
48 H (H) 47H (G)
d +4 00 H 3)
d +5 62 H (b) 61H (a)
d +6 64 H (d) 63H (c)
d +7 66 H (f) 65H (e)
1 Shifts the third character and up by the number of characters specified by s to the left and inserts the
character string data specified by s
2
Third character insertion position
3
The character data stored after d+4 will be written over in accordance with the number of characters
to be inserted.
This instruction stores the NULL code (00H) into the device (1 word) that positions in d after
the last device where the character string data are stored, if the character string (s+d) value is
even after the insertion.
This instruction stores the NULL code (00H) into the last device (high 8 bits) in d where the
character string data are stored, if the character string (s+d) value is odd after the insertion.
This instruction links the device, where the character string data are stored, specified by s with
the last device specified by d, if n is specified by the number of devices specified by d plus one.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of characters in the devices specified by s, d, or the devices specified by (s+d)
after the insertion exceeds 16383 characters. (Error code 4100)
● The value specified by n is not within the specified range (1 < n < 16383).
(Error code 4100)
● The value specified by n exceeds the number of the devices specified by d plus one.
(Error code 4100)
● The devices, that store character strings, specified by s overlaps with even one of the devices
specified by d. (Error code 4101)
● The range of the devices specified by (s+d) in which character strings data have been
inserted exceeds the specified device range. (Error code 4101)
● The NULL code (00H) does not exist within the specified device range after the device
specified by s or d. (Error code 4101)
● The range of the devices specified by (s+d) in which character strings data have been
inserted overlaps with the range of the devices specified by s that store the character string
data. (Error code 4101)
7 – 334
Character string processing instructions STRINS, STRINSP
Program STRINS
Example 1
With leading edge from M0, the following program inserts the character string data stored in
the devices D0 and up to the fourth device from the initial character string data stored in D20
and up.
3)
4) PROGRAMABCD
2)
5)
6)
4) PRO584GRAMABCD
1
D0 character string
2
D20 character string inserted between"O"and"G"
3 Before insertion
5
Fourth character from the left (Insert position)
6
After insertion
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
STRDEL d n1 n2 4
STRDELP n1 n2
6
d
7 – 336
Character string processing instructions STRDEL, STRDELP
3) 4)
b15 b8b7 b0 b15 b8b7 b0 b15 b8b7 b0
d 42 H (B) 41H (A) d 42 H (B) 41H (A) d 42 H (B) 41H (A)
d +1 44 H (D) 43H (C) d +1 d +1 49 H (I) 48H (H)
d +2 46 H (F) 45H (E) d +2 d +2 4BH (K) 4AH (J)
d +3 48 H (H) 47H (G) 2) d +3 48 H (H) d +3 00 H 4CH (L)
d +4 4AH (J) 49H (I) d +4 4AH (J) 49H (I) d +4 00 H
d +5 4CH (L) 4BH (K) d +5 4CH (L) 4BH (K) d +5 00 H
d +6 00 H d +6 00 H d +6 00 H
d +7 31 H (1) 30H (0) d +7 31 H (1) 30H (0) d +7 31 H (1) 30H (0)
d +8 33 H (3) 32H (2) d +8 33 H (3) 32H (2) d +8 33 H (3) 32H (2)
d +9 35 H (5) 34H (4) 1) d +9 35 H (5) 34H (4) d +9 35 H (5) 34H (4)
5)
1
n1th character to be deleted
2
Deletes n2 characters from the n1th device and up
3 Shifts the n1+n2th characters and up, which are stored after the devices whose characters were
5
Characters of the devices other than the shifted devices do not change.
This instruction stores the NULL code (00H) into the device (1 word) that positions after the last
device where the character string data are stored, if the character string specified by d is even,
after the characters are deleted.
This instruction stores the NULL code (00H) into the last device (high 8 bits) where the charac-
ter string data are stored, if the character string specified by d is odd, after the characters are
deleted.
This instruction shifts the characters stored in the devices positioned after the deleted devices
by n2 characters to the left - and then stores the NULL code (00H) into the empty device.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of characters in the devices specified by d exceeds 16383.
(Error code 4100)
● The value specified by n1 is not within the specified range (1 < n1 < 16383).
(Error code 4100)
● The value specified by n1 exceeds the number of characters in the devices specified by d.
(Error code 4100)
● The value specified by n2 exceeds the number of characters in the devices starting from
n1th to the last devices position.
(Error code 4100)
● The value specified by n2 is negative.
(Error code 4100)
Program STRDEL
Example
With leading edge from M0, the following program deletes the seven characters starting with
the fourth character in the character string data stored in the devices from D0 onward.
1) PROGRAMABCD 1) PROGRAMABCD
2) 3)
1
D0 character string
2
Fourth character to be deleted
3 Seven characters to be deleted
7 – 338
Character string processing instructions EMOD, EMODP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EMOD_GE1
EMOD0E1
(s1)+1 s1 d1 0
3 .2 5 4 27 8 d1+1
3254278 H
1 d1+2
d1+3 1
s2 3 1
d1+4 3
1
Floating point data (data type REAL)
EMOD0E2
(s1)+1 s1 d1 1
-0 . 0 3 5 4 2 7 6 8 d1+1
3542768 H
d1+2
s2 d1+3 1
4
d1+4 4
EMOD0E3
(s1)+1 s1 d1 0
1 . 5 4 3 2 1 E+2 d1+1
H154321
d1+2
s2 3 d1+3 0
d1+4 0
EMOD0E4
7 – 340
Character string processing instructions EMOD, EMODP
The floating point number in s1 and (s1)+1 is rounded up to 7 digits and stored in (d1)+1 and
(d1)+2.
(s1)+1 s1 d1 0
1. 2 3 4 5 6 7 8 9 d1+1
1234568H
d1+2
s2 d1+3 1 123456789
3
d1+4 5 1
1234568
1
Rounded up
EMOD0E5
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of digits of the decimal point shift (s2) exceeds the range of 0 to 7.
(Error code 4100)
● The value entered in d1 through (d1)+4 exceeds the relevant storage device area.
(Error code 4101)
● The 32-bit floating point real number specified in s1 is not zero and not within the following
range:
2-126 < (s1) < 2 128
(Error code 4100)
● The device specified by d1 exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
Program EMOD
Example
While X0 is set, the following program converts the floating point data (data type REAL) spec-
ified in D0 and D1 considering the decimal point shift specified in R10. The result is stored in
D100 through D104.
D1 D0 0
D100
1 .2 3 4 5 6 7 8 9 D101
1234568 H
D102
D103 1
R10 3
D104 5
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 342
Character string processing instructions EREXP, EREXPP
CPU High
Basic Process Redundant Universal LCPU
Performance
s1 — — — — — — —
s2 —
d1 — — 1) — —
1
Available only in multiple Universal model QCPU and LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EREXPGE1
s1 2
(d1)+1 d1
(s1)+1
3
1 (s1)+2
(s1)+3 4 7
(s1)+4 5
s2 6
1
Floating point data in BCD data format
2
Sign bit (0 = positive / 1 = negative)
3
7 BCD digits
4
Exponent sign (0 = positive / 1 = negative)
5
BCD exponent (value range 0 to 38)
6
Number of decimal places (value range 0 to 7)
7 Floating point data (real number)
EREX0E1
The sign in s1 and the sign of the exponent in (s1)+3 is set to 0 for a positive value. For a
negative value the sign bit is 1.
The value of the BCD exponent (s1)+4 may range from 0 to 7.
The decimal places in s2 may range from 0 to 7.
s1 1 (d1)+1 d
(s1)+1
3215423 H -3. 2 1 5 4 2 3 E+2
(s1)+2
(s1)+3 0
(s1)+4 2
s2 6
EREX0E2
7 – 344
Character string processing instructions EREXP, EREXPP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The sign designation in s1 is not 0 or 1.
(Error code 4100)
● The BCD data in (s1)+1 and (s1)+2 contains more than 8 digits.
(Error code 4100)
● The exponent sign in (s1)+3 is not 0 or 1.
(Error code 4100)
● The exponent data in (s1)+4 exceeds the range from 0 to 38.
(Error code 4100)
● The number of decimal places in s2 exceeds the range of 0 to 7.
(Error code 4101)
● The device specified by s1 exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program EREXPP
Example
With leading edge from X0, the following program calculates the floating point value (real num-
ber) in decimal format from the floating point value in BCD format specified in D0 through D4
considering the decimal places specified in D10. The result is stored in D100 and D101.
EREXPMB1, EREXKB1, EREXIB1
D0 1
D1 4567H D101 D100
D2 1234567H 1)
0123H 1. 2 3 4 5 6 7
D3 1
D4 3
D10 3
1
BCD 7 digits
7 – 346
Special functions
COS_MD
COS
Single precision COS_E_MD
(32-bit floating-point
number) COS_P_MD
COSP
COS_P_E_MD
Cosine calculation
COSD
Double precision
(64-bit floating-point
number)
COSDP
TAN_MD
TAN
Single precision TAN_E_MD
(32-bit floating-point
number) TAN_P_MD
TANP
TAN_P_E_MD
Tangent calculation
TAND
Double precision
(64-bit floating-point
number)
TANDP
ASIN_MD
ASIN
Single precision ASIN_E_MD
(32-bit floating-point
number) ASIN_P_MD
ASINP
ASIN_P_E_MD
Arcus sine calculation
ASIND
Double precision
(64-bit floating-point
number)
ASINDP
ACOS_MD
ACOS
Single precision ACOS_E_MD
(32-bit floating-point
number) ACOS_P_MD
ACOSP
ACOS_P_E_MD
Arcus cosine calculation
ACOSD
Double precision
(64-bit floating-point
number)
ACOSDP
RAD_MD
RAD
Single precision RAD_E_MD
(32-bit floating-point
number) RAD_P_MD
RADP
Conversion from degrees RAD_P_E_MD
into radian
RADD
Double precision
(64-bit floating-point
number)
RADDP
DEG_MD
DEG
Single precision DEG_E_MD
(32-bit floating-point
number) DEG_P_MD
DEGP
Conversion from radian into DEG_P_E_MD
degree
DEGD
Double precision
(64-bit floating-point
number)
DEGDP
POW
Single precision
(32-bit floating-point
number)
POWP
Exponentiation
POWD
Double precision
(64-bit floating-point
number)
POWDP
SQR_MD
SQR
Single precision SQR_E_MD
(32-bit floating-point
number) SQR_P_MD
SQRP
SQR_P_E_MD
Square root
SQRD
Double precision
(64-bit floating-point
number)
SQRDP
7 – 348
Special functions
LOG_MD
LOG
Single precision LOG_E_MD
(32-bit floating-point
number) LOG_P_MD
LOGP
Logarithm (natural) LOG_P_E_MD
calculation
LOGD
Double precision
(64-bit floating-point
number)
LOGDP
LOG10
Single precision
(32-bit floating-point
number)
LOG10P
Common logarithm
LOG10D
Double precision
(64-bit floating-point
number)
LOG10DP
RND RND_M
Randomize value
RNDP RNDP_M
SRND SRND_M
Update random values
SRNDP SRNDP_M
BSQR_MD
BSQR
Square root calculation from BSQR_K_MD
4-digit BCD data BSQR_P_MD
BSQRP
BSQR_K_P_MD
BDSQR_MD
BDSQR
Square root calculation from BDSQR_K_MD
8-digit BCD data BDSQR_P_MD
BDSQRP
BDSQR_K_P_MD
BSIN_MD
BSIN
BSIN_K_MD
Sine calculation from BCD data
BSIN_P_MD
BSINP
BSIN_K_P_MD
BCOS_MD
BCOS
BCOS_K_MD
Cosine calculation from BCD data
BCOS_P_MD
BCOSP
BCOS_K_P_MD
NOTE Within the IEC editors please use the IEC instructions.
7 – 350
Special functions SIN, SINP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
SIN
1 1
The angle in s and s+1 must be specified in radian measure (degrees x π/180). The conversion
from degrees into radian is described in the sections on the RAD and DEG instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is –0.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU) (Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (overflow occurs):
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 352
Special functions SIN, SINP
Program SIN
Example
The following program calculates the sine value from the 4-digit BCD angle specification in X20
through X2F. The result is stored as 32-bit floating-point value (real number) in D0 and D1.
D30
X2F X20 2 b15 b0
0 15 0 150
1 BIN 3
4 FLT
1
BCD value
2
Conversion into the BIN format
3
BIN value
4
Conversion into the floating-point format
5
32-bit floating point value (real number)
6
Conversion into the radian measure
7
Calculation of the sine value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SIND s d
SINDP s d
7 – 354
Special functions SIND, SINDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
SIN ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (Operation results in an overflow):
–21024 < (Operation result) < 21024
(Error code 4141)
Program SIND
Example
The following program calculates the sine value from the 4-digit BCD angle specification in X20
through X2F. The result is stored as 64-bit floating-point value (real number) in D0 to D3.
D30
X2F X20 2) b15 b0 4) D23 D22 D21 D20
0 1 5 0 150 150
1) BIN 3) FLTD 5)
6)
RADD
1
BCD value
2
Conversion into the BIN format
3
BIN value
4
Conversion into the floating-point format
5
64-bit floating-point value (real number)
6
Conversion into the radian measure
7
Calculation of the sine value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 356
Special functions COS, COSP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
COS
1 1
The angle in s and s+1 must be specified in radian measure (degrees x π/180). The conversion
from degrees into radian is described in the sections on the RAD and DEG instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is –0.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (overflow occurs):
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 358
Special functions COS, COSP
Program COS
Example
The following program calculates the cosine value from the 4-digit BCD angle specification in
X20 through X2F. The result is stored as 32-bit floating-point value (real number) in D0 and D1.
D30
X2F X20 2 b15 b0
0 0 6 0 60
1 BIN 3
4 FLT
1
BCD value
2 Conversion into the BIN format
3
Binary value
4
Conversion into the floating-point format
5 32-bit floating point value (real number)
6
Conversion into the radian measure
7
Calculation of the cosine value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
COSD s d
COSDP s d
7 – 360
Special functions COSD, COSDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
COS ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result)< 21024
(Error code 4141)
Program COSD
Example
The following program calculates the cosine value from the 4-digit BCD angle specification in
X20 through X2F. The result is stored as 64-bit floating-point value (real number) in D0 to D3.
D30
X2F X20 2) b15 b0 4) D23 D22 D21 D20
0 0 60 60 60
1) BIN 3) FLTD 5)
6)
RADD
1
BCD value
2
Conversion into the BIN format
3
Binary value
4
Conversion into the floating-point format
5
64-bit floating-point value (real number)
6
Conversion into the radian measure
7
Calculation of the cosine value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 362
Special functions TAN, TANP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
TAN
1 1
The angle in s and s+1 must be specified in radian measure (degrees x π/180). The conversion
from degrees into radian is described in the sections on the RAD and DEG instructions.
If the angle in s and s+1 retains the values π/2 rad or (3/2)xπ rad, an error message is returned
from the radian measure calculation.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The operation result is not zero and not within the range from +2-126 to +2128.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
● The value of the specified device is –0.
(For the Basic model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (overflow occurs):
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 364
Special functions TAN, TANP
Program TAN
Example
The following program calculates the tangent value from the 4-digit BCD angle specification in
X20 through X2F. The result is stored as 32-bit floating-point value (real number) in D0 and D1.
D30
X2F X20 2 b15 b0
0 13 5 135
1 3
BIN
4 FLT
1
BCD value
2
Conversion into the BIN format
3
Binary value
4
Conversion into the floating-point format
5
32-bit floating point value (real number)
6
Conversion into the radian measure
7
Calculation of the tangent value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
TAND s d
TANDP s d
7 – 366
Special functions TAND, TANDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
TAN ( )
1) 1)
The angle in s must be specified in radian measure (degrees x π/180). The conversion from
degrees into radian is described in the sections on the RADD and DEGD instructions.
If the angle in s retains the values π/2 rad or (3/2)xπ rad, an error message is returned from
the radian measure calculation.
When the operation results in -0 or an underflow, the result is processed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program TAND
Example
The following program calculates the tangent value from the 4-digit BCD angle specification in
X20 through X2F. The result is stored as 64-bit floating-point value (real number) in D0 to D3.
D30
X2F X20 2) b15 b0 4) D23 D22 D21 D20
0 1 3 5 135 135
1) BIN 3) FLTD 5)
6)
RADD
1
BCD value
2
Conversion into the BIN format
3
Binary value
4
Conversion into the floating-point format
5
64-bit floating-point value (real number)
6
Conversion into the radian measure
7
Calculation of the tangent value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 368
Special functions ASIN, ASINP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
-1
SIN
1 1
The sine value in s and s+1 may range within the value range of -1 to 1.
The angle (operation result) at d is stored in radian measure (degrees x π/180). The conver-
sion from degrees into radian is described in the sections on the RAD and DEG instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in s and s+1 exceeds the value range of -1 to 1. (Error code 4100)
● The contents of the specified device is not zero and not within the range from +2-126 to +2128.
(For the Universal model QCPU, LCPU) (Error code 4100)
● The value of the specified device is –0.
(For the High Performance model QCPU, Process CPU, Redundant CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (Operation results in an overflow)
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 370
Special functions ASIN, ASINP
Program ASIN
Example
The following program calculates the arcus sine value from the 32-bit floating-point data (real
number) in D0 and D1. The resulting angle in radian measure is output at Y40 through Y4F as
4-digit BCD value.
D1 D0 2 D11 D10
0 .5 0.5235988
1 3
ASIN
4 DEG
D30
D21 D20 b15 b0 Y4F Y40
6 8
30 30 0 0 3 0
5 7 9
INT BCD
1
32-bit floating point value (real number)
2
Arcus sine calculation
3
32-bit floating point value (real number)
4
Conversion of the angle measures
5
32-bit floating point value (real number)
6
Conversion into the BIN format
7
Binary value
8 Conversion into the BCD format
9
BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ASIND s d
ASINDP s d
7 – 372
Special functions ASIND, ASINDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
SIN –1 ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The value specified by s is within the double-precision floating-point range and outside the
range of -1.0 to 1.0. (Error code 4100)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program ASIND
Example
The following program calculates the arcus sine value from the 64-bit floating-point data (real
number) in D0 to D3. The resulting angle in radian measure is output at Y40 through Y4F as
4-digit BCD value.
D30
D23 D22 D21 D20 4) b15 b0 6) Y4F Y40
30 30 0 0 3 0
1) INTD 5) BCD 7)
1
64-bit floating-point value (real number)
2
Arcus sine calculation
3
Conversion of the angle measures
4
Conversion into the BIN format
5
Binary value
6
Conversion into the BCD format
7
BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 374
Special functions ACOS, ACOSP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
-1
COS
1 1
The cosine value in s and s+1 may range within the value range of -1 to 1.
The angle (operation result) at d is stored in radian measure (degrees x π/180). The conver-
sion from degrees into radian is described in the sections on the RAD and DEG instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in s and s+1 exceeds the value range of -1 to 1. (Error code 4100)
● The contents of the specified device or the operation result is not zero and not within the
range from +2-126 to +2128.
(For the Universal model QCPU, LCPU)
(Error code 4100)
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (operation results in an overflow)
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 376
Special functions ACOS, ACOSP
Program ACOS
Example
The following program calculates the arcus cosine value from the 32-bit floating-point data (real
number) in D0 and D1. The resulting angle in radian measure is output at Y40 through Y4F as
4-digit BCD value.
D1 D0 2 D11 D10
0 .5 1 . 0 4 7 1 9 8
1 3
ACOS
4 DEG
D30
D21 D20 6 b15 b0 8 Y4F Y40
60 60 0 0 6 0
5 7 BCD 9
INT
5
32-bit floating point value (real number)
6
Conversion into the BIN format
7
Binary value
8
Conversion into the BCD format
9 BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ACOSD s d
ACOSDP s d
7 – 378
Special functions ACOSD, ACOSDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
COS –1 ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The value specified by s is within the double-precision floating-point range and outside the
range of -1.0 to 1.0.
(Error code 4100)
● The result exceeds the following range (Operation results in an overflow):
–21024 < (Operation result) < 21024
(Error code 4141)
Program ACOSD
Example
The following program calculates the arcus cosine value from the 64-bit floating-point data (real
number) in D0 to D3. The resulting angle in radian measure is output at Y40 through Y4F as
4-digit BCD value.
D30
D23 D22 D21 D20 4) b15 b0 6) Y4F Y40
60 60 0 0 6 0
1) INTD 5) BCD 7)
5
Binary value
6
Conversion into the BCD format
7
BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 380
Special functions ATAN, ATANP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
-1
TAN
1 1
The angle (operation result) at d is stored in radian measure (degrees x π/180). The conver-
sion from degrees into radian is described in the sections on the RAD and DEG instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The contents of the specified device or the operation result is not zero and not within the
range from +2-126 to +2128.
(For the Universal model QCPU, LCPU)
(Error code 4100)
● The value of the specified device is –0.
(For the High Performance model QCPU, Process CPU, Redundant CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (Operation results in an overflow)
(For the Universal model QCPU, LCPU)
–2128 < (Operation result) < 2128
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 382
Special functions ATAN, ATANP
Program ATAN
Example
The following program calculates the arcus tangent value from the 32-bit floating-point data
(real number) in D0 and D1. The resulting angle in radian measure is output at Y40 through
Y4F as 4-digit BCD value.
D1 D0 2 D11 D10
1 0 .7 8 5 3 9 8
1 3
ATAN
4 DEG
D30
D21 D20 6 b15 b0 8 Y4F Y40
45 45 0 0 4 5
5 7 BCD 9
INT
1
32-bit floating point value (real number)
2
Arcus tangent calculation
3 32-bit floating point value (real number)
4
Conversion of the angle measures
5
32-bit floating point value (real number)
6 Conversion into the BIN format
7
Binary value
8
Conversion into the BCD format
9 BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
ATAND s d
ATANDP s d
7 – 384
Special functions ATAND, ATANDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
TAN –1 ( )
1) 1)
The angle (operation result) at d is stored radian measure (degrees x π/180). The conversion
from degrees into radian is described in the sections on the RADD and DEGD instructions.
When the operation results in -0 or an underflow, the result is processed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program ATAND
Example
The following program calculates the arcus tangent value from the 64-bit floating-point data
(real number) in D0 to D3. The resulting angle in radian measure is output at Y40 through Y4F
as 4-digit BCD value.
D30
D23 D22 D21 D20 4) b15 b0 6) Y4F Y40
45 45 0 0 4 5
1) INTD 5) BCD 7)
1
64-bit floating-point value (real number)
2
Arcus tangent calculation
3 Conversion of the angle measures
4
Conversion into the BIN format
5
Binary value
6 Conversion into the BCD format
7
BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 386
Special functions RAD, RADP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Functions Conversion from degrees into radian as floating-point value (Single precision)
RAD Conversion from degrees into radian
The RAD instruction calculates the radian value (rad) from the degree value (°) in s and s+1.
The result is stored in d and d+1.
s+1 s d+1 d
°
rad
1 1
The conversion from degrees into radiant applies to the following equation:
Radian value = degree value x π / 180
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The contents of the specified device or the operation result is not zero and not within the
range from +2-126 to +2128.
(For the Universal model QCPU, LCPU)
(Error code 4100)
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (operation results in an overflow):
–2128 < (Operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 388
Special functions RAD, RADP
Program RAD
Example
The following program calculates the radian value from the degree value of the 4-digit BCD
value in X20 through X2F. The result is stored in D20 and D21 as 32-bit floating-point value.
D0
X2F X20 1 b15 b0 2 D11 D10 3 D21 D20
01 2 0 120 120 2 . 0 9 4 3 9 5 ...
4 BIN 5 FLT 6 RAD 7
1
Conversion into the BIN format
2
Conversion into the floating-point format
3
Conversion into radian measure
4
BCD value
5 Binary value
6
32-bit floating point value (real number)
7
32-bit floating point value (real number)
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
RADD s d
RADDP s d
7 – 390
Special functions RADD, RADDP
Functions Conversion from degrees into radian as floating-point value (Double precision)
RADD Conversion from degrees into radian
The RADD instruction calculates the radian value (rad) from the degree value (°) specified by
s. The result is stored in the device specified by d.
s +3 s +2 s +1 s d +3 d +2 d +1 d
( )° ( ) rad
1) 1)
The conversion from degrees into radiant applies to the following equation:
Radian value = degree value x π / 180
When the operation results in -0 or an underflow, the result is processed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (Operation results in an overflow):
–21024 < (Operation result) < 21024
(Error code 4141)
Program RADD
Example
The following program calculates the radian value from the degree value of the 4-digit BCD
value in X20 through X2F. The result is stored in D20 to D23 as 64-bit floating-point value.
D0
X2F X20 2) b15 b0 4) D13 D12 D11 D10 5) D23 D22 D21 D20
0 1 2 0 120 120 2.094395···
1) BIN 3) FLTD RADD 6)
1
BCD value
2
Conversion into the BIN format
3 Binary value
5
Conversion into radian measure
6 64-bit floating-point value (real number)
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 392
Special functions DEG, DEGP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Functions Conversion from radian in floating-point format into degrees (Single precision)
DEG Conversion from radian into degrees
The DEG instruction calculates the degree value (°) from the radian value (rad) in s and s+1.
The result is stored in d and d+1.
s+1 s d+1 d
°
rad
1 1
The conversion from radian into degrees applies to the following equation:
Degree value = radian value x 180 / π
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (overflow occurs):
–2128 < (Operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 394
Special functions DEG, DEGP
Program DEG
Example
The following program calculates the degree value from the radian value stored in D20 and D21
as 32-bit floating-point value. The result is stored in Y40 to Y4F as BCD value.
D0
D21 D20 D11 D10
1 2 b15 b0 3 Y4F Y40
1 .4 3 5 7 9 2 8 2 .2 6 4 8 2 82 0 0 8 2
4 5 6 7
DEG BIN BCD
1
Conversion into degrees
2
Conversion into the BIN format
3 Conversion into the BCD format
5
32-bit floating point value (real number)
6 Binary value
7 BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
DEGD s d
DEGDP s d
7 – 396
Special functions DEGD, DEGDP
Functions Conversion from radian in floating-point format into degrees (Double precision)
DEGD Conversion from radian into degrees
The DEGD instruction calculates the degree value (°) from the radian value (rad) specified by
s. The result is stored in the device specified by d.
s +3 s +2 s +1 s d +3 d +2 d +1 d
( ) rad ( )°
1) 1)
The conversion from radian into degrees applies to the following equation:
Degree value = radian value x 180 / π
When the operation results in -0 or an underflow, the result is processed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2-1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program DEGD
Example
The following program calculates the degree value from the radian value stored in D20 to D23
as 64-bit floating point value. The result is stored in Y40 to Y4F as BCD value.
D0
D23 D22 D21 D20 2) D13 D12 D11 D10 3) b15 b0 5) Y4F Y40
1.435792 82.26482 82 0 0 8 2
1) DEGD 1) INTD 4) BCD 6)
1
64-bit floating-point value (real number)
2
Conversion to angle
3
Conversion into the BIN format
4 Binary value
5
Conversion into the BCD format
6
BCD value
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 398
Special functions POW, POWP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
POW s1 s2 d
POWP s1 s2 d
1)
s2 +1 s2
s1 +1 s1 d +1 d
2)
s1 +1 s1 s1 +1 s1 s1 +1 s1 s1 +1 s1
s1 +1 s1 s2 +1 s2
3) 4)
1
Exponentiation data
2 Exponentiation recipient data
3
32-bit floating-point value (real number)
4 32-bit floating-point value (real number)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The values specified by s1 or s2 are not zero and not within the following range:
2–126 < (Specified value (storage values)) < 2128
(Error code 4140)
● The value of s1 or s2 is –0.
(Error code 4140)
● The result exceeds the following range:
–2126 < (Operation result) < 2126
(Error code 4141)
7 – 400
Special functions POW, POWP
Program POW
Example
The following program raises the 32-bit floating-point data type real number data specified by
D0 and D1 to the data specified by (D10 and D11)th power, when X10 is turned on. The oper-
ation result is stored into D20 and D21.
D11 D10
1.2
D1 D0 1) D21 D20
0.22 0.163
1
Exponentiation operation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
POWD s1 s2 d
POWDP s1 s2 d
7 – 402
Special functions POWD, POWDP
The POW instruction raises the 64-bit floating-point data type real number specified by s1 to
the number nth power specified by s2, and then stores the operation result into the device
specified by d.
1)
S2 +3 S2 +2 S2 +1 S2
S1 +3 S1 +2 S1 +1 S1 d +3 d +2 d +1 d
2)
S1 +3 S1 +2 S1 +1 S1 S1 +3 S1 +2 S1 +1 S1 S1 +3 S1 +2 S1 +1 S1
S1 +3 S1 +2 S1 +1 S1 S2 +3 S2 +2 S2 +1 S2
3) 4)
1
Exponentiation data
2
Exponentiation recipient data
3
64-bit floating-point value (real number)
4
64-bit floating-point value (real number)
The instruction raises the real number 3) to the power of 4).
The following shows the values to be specified by and stored into s1 or s2:
0, 2–1022 < (Set values (storage values)) < 21024.
If the value resulted from the operation is –0 or an underflow occurs, the result will be pro-
cessed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Error code is stored into SD0.
● The values specified by s1 or s2 are not zero and not within the following range:
2–1022 < (Specified value (storage values)) < 21024
(Error code 4140)
● The value of s1 or s2 is –0.
(Error code 4140)
● The result exceeds the following range:
–21024 < (Operation result) < 21024
(Error code 4141)
Program POWD
Example
The following program raises the 64-bit floating-point data type real number data specified by
D200 to D203 to the number nth specified by (D0 to D3) power, when X10 is turned on. The
operation result is stored into D100 to D103.
D3 D2 D1 D0
3
D203 D202 D201 D200 1) D103 D102 D101 D100
15.6 3796.416
5
Exponentiation operation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 404
Special functions SQR, SQRP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
1 1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value entered in s is negative. (Error code 4100)
● The contents of the specified device or the operation result is not zero and not within the
range from +2-126 to +2128.
(For the Universal model QCPU, LCPU)
(Error code 4140)
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (Operation results in an overflow):
–2128 < (Operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
●
7 – 406
Special functions SQR, SQRP
Program SQR
Example
The following program calculates the square root of the 4-digit BCD value in X20 through X2F.
The result is stored in D0 and D1.
D20
X2F X20 1 b15 b0 2 D11 D10 3 D1 D0
0 6 5 0 650 650 2 5 .4 9 5 1
4 BIN 5 FLT 6 SQR 7
1
Conversion into the BIN format
2
Conversion into the floating-point format
3
Square root calculation
4
BCD value
5 Binary value
6
32-bit floating point value (real number)
7
32-bit floating point value (real number)
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SQRD s d
SQRDP s d
7 – 408
Special functions SQRD, SQRDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value entered in s is negative. (Error code 4100)
● The value of the specified device is not zero and not within the following range:
2–1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program SQRD
Example
While X0 is set, the following program calculates the square root of the 4-digit BCD value in
X20 through X2F. The result is stored in D0 to D3.
D20
X2F X20 2) b15 b0 4) D13 D12 D11 D10 5) D3 D2 D1 D0
0 6 5 0 650 650 25.4951
1) BIN 3) FLTD SQRD 6)
1
BCD value
2
Conversion into the BIN format
3
Binary value
4
Conversion into the floating-point format
5 Square root calculation
6
64-bit floating-point value (real number)
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 410
Special functions EXP, EXPP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
e
1 1
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The operation result is outside the range shown below:
2-126 < (Operation result) < 2128 for the High Performance model QCPU and
2-126 < (Operation result) < 2128 for the Basic Model QCPU, Process CPU, Redundant
CPU
(Error code 4100)
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if –0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (overflow occurs):
–2128 < (Operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 412
Special functions EXP, EXPP
Program EXP
Example
The following program calculates the result of the exponential function to the base e with the
2-digit BCD value at X20 through X27. The result is stored in D0 and D1 in 32-bit floating-point
format.
D20
X27 X20 1 b15 b0 2 D11 D10 3 D1 D0
1 3 13 13 4 4 2 4 1 3 .4
4 BIN 5 FLT 6 EXP 7
1
Conversion into the BIN format
2
Conversion into the floating-point format
3 Exponential calculation
4 BCD value
5
Binary value
6
32-bit floating point value (real number)
7 32-bit floating point value (real number)
NOTES The operation result will be under 2129 if the BCD value of X20 to X27 is less than 89, from the
calculation ln 2129 = 89.4.
Because setting a value of over 89 will return an operation error, M0 is turned ON in this example
if a value of over 89 has been set to avoid the error.
Conversion from natural logarithm to common logarithm:
In the CPU module, calculation is made using a natural logarithm.
To obtain a common logarithm value, enter in s a common logarithm value divided by 0.43429:
10x = ex/0.43429.
This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
EXPD s d
EXPDP s d
7 – 414
Special functions EXPD, EXPDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
e ( ) ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value of the specified device is not zero and not within the following range:
2–1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program EXPD
Example
The following program calculates the result of the exponential function to the base e with the
2-digit BCD value at X20 through X31. The result is stored in D0 to D3 in 64-bit floating-point
format.
D20
X31 X20 2) b15 b0 4) D13 D12 D11 D10 6) D3 D2 D1 D0
0 1 3 13 13 442413.4
1) BIN 3) FLTD 5) EXPD 5)
1
BCD value
2
Conversion into the BIN format
3 Binary value
5
64-bit floating-point value (real number)
6
Exponential calculation
NOTES The operation result will be under 21024 if the BCD value of X20 to X31 is less than 709, from the
calculation ln 21024 = 709.7832.
Because setting a value of over 709 will return an operation error, M0 is turned ON in this ex-
ample if a value of over 709 has been set to avoid the error.
Conversion from natural logarithm to common logarithm:
In the CPU module, calculation is made using a natural logarithm.
To obtain a common logarithm value, enter in s a common logarithm value divided by 0.43429:
10x = ex/0.43429.
This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 416
Special functions LOG, LOGP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s+1 s d+1 d
log
1 1
Only positive values can be specified in s and s+1. Negative values cannot be calculated.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified in s is negative. (Error code 4100)
● The value specified in s is 0. (Error code 4100)
● The contents of the specified device or the operation result are not zero and not within the
following range:
2-126 <= (Contents of device or operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4100)
● The value of the specified device is –0.
(For the Basic Model QCPU, High Performance model QCPU, Process CPU, Redundant
CPU)
(Error code 4100)
There are CPU modules that will not result in an operation error if -0 is specified.
For details, refer to section 3.5.1.
● The result exceeds the following range (operation results in an overflow):
–2128 < (Operation result) < 2128
(For the Universal model QCPU, LCPU)
(Error code 4141)
● The value of the specified device is –0, unnormalized number, nonnumeric, or ∞.
(For the Universal model QCPU, LCPU)
(Error code 4140)
7 – 418
Special functions LOG, LOGP
Program LOG
Example
The following program calculates the natural logarithm from the value 10. The result is stored
in D30 and D31.
D50
b15 b0 1 D41 D40 2 D31 D30
10 10 10 2 .3 0 2 5 8 5
MOV 3 FLT 4 LOG 5
1
Conversion into the floating-point format
2
Logarithm calculation
3 Binary value
5
32-bit floating point value (real number)
NOTES The LOG instruction calculates the natural logarithm (base e). The following formula converts
the natural logarithm to normal logarithm (base 10):
log10 X = 0.43429 x logeX
Universal model QCPU and LCPU can also calculate the normal logarithm (base 10) (refer to
section 7.12.25 "LOG10, LOG10P" and section 7.12.26 "LOG10D, LOG10DP").
This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
LOGD s d
LOGDP s d
7 – 420
Special functions LOGD, LOGDP
s +3 s +2 s +1 s d +3 d +2 d +1 d
log ( ) ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified in s is negative. (Error code 4100)
● The value specified in s is 0. (Error code 4100)
● The value of the specified device is not zero ro not within the following range:
2–1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program LOGD
Example
The following program calculates the natural logarithm from the value 10 set by D50. The result
is stored in D30 to D33.
D50
b15 b0 2) D43 D42 D41 D40 4) D33 D32 D31 D30
10 10 10 2.302585
MOV 1) FLTD 3) LOGD 3)
1
Binary value
2
Conversion into the floating-point format
3 64-bit floating-point value (real number)
4 Logarithm calculation
NOTES The LOGD instruction calculates the natural logarithm (base e). The following formula converts
the natural logarithm to normal logarithm (base 10):
log10 X = 0.43429 x logeX
Universal model QCPU and LCPU can also calculate the normal logarithm (base 10) (refer to
section 7.12.25 "LOG10, LOG10P" and section 7.12.26 "LOG10D, LOG10DP").
This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 422
Special functions LOG10, LOG10P
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
LOG10 s d
LOG10P s d
s+1 s d+1 d
log 10 ( ) ( )
1) 1)
Only positive values can be specified in s and s+1. Negative values cannot be calculated.
If the value resulted from the operation is –0 or an underflow occurs, the result will be pro-
cessed as 0.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified in s is negative. (Error code 4100)
● The value specified in s is 0. (Error code 4100)
● The value of the specified device is not zero and not within the following range:
2–126 < (Value of specified device) < 2128
(Error code 4140)
● The value specified in s is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–2128 < (Operation result) < 2128
(Error code 4141)
7 – 424
Special functions LOG10, LOG10P
Program LOG10
Example
The following program obtains the value for common logarithm of the 32-bit floating-point data
type real number specified by D600 and D601, when M0 is turned on. The result is stored into
D123 and D124.
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
QnU(D)(H)CPU: The serial number (first five digits) is "10102" or higher.
QnUDE(H)CPU: The serial number (first five digits) is "10102" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
LOG10D s d
LOG10DP s d
7 – 426
Special functions LOG10D, LOG10DP
s +3 s +2 s +1 s d +3 d +2 d +1 d
log10 ( ) ( )
1) 1)
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value specified in s is negative. (Error code 4100)
● The value specified in s is 0. (Error code 4100)
● The value of the specified device is not zero and not within the following range:
2–1022 < (Value of specified device) < 21024
(Error code 4140)
● The value of the specified device is –0.
(Error code 4140)
● The result exceeds the following range (overflow occurs):
–21024 < (Operation result) < 21024
(Error code 4141)
Program LOG10D
Example
The following program obtains the value for common logarithm of the 64-bit floating-point data
type real number specified by D600 to D603, when M0 is turned on. The result is stored into
D123 to D126.
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 428
Special functions RND, RNDP, SRND, SRNDP
CPU High
Basic Performance Process Redundant Universal LCPU
1)
1
Basic model QCPU: The upper five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
Program RND
Example 1
While X10 is set, the following program stores the generated random value in D100.
Program SRND
Example 2
While X10 is set, the following program updates the series of random values in D0.
7 – 430
Special functions BSQR, BSQRP, BDSQR, BDSQRP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
d d+1
s = .
1 2
1
Integer part
2
Decimal places
The data in s must be a BCD value with at maximum 4 digits. The value range from 0 to 9999
must not be exceeded.
The calculation result stored in d and d+1 must not exceed the value range from 0 to 9999.
The result is calculated with a 5-digit accuracy and rounded to a 4-digit value.
d d+1
s+1 s =
1
2 3 Two-word data
1 2Integer
part
3Decimal places
The data in s and s+1 must be a BCD value with at maximum 8 digits. The value range from 0
to 99999999 must not be exceeded.
The calculation result stored in d and d+1 must not exceed the value range from 0 to 9999.
The result is calculated with a 5-digit accuracy and rounded up to a 4-digit value.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data stored in s (s+1) is no BCD data.
(Error code 4100)
7 – 432
Special functions BSQR, BSQRP, BDSQR, BDSQRP
Program BSQR
Example 1
The following program calculates the square root of the BCD value 1325 and outputs the inte-
ger part of the result as 4-digit BCD value at Y50 through Y5F. The decimal places are output
as 4-digit BCD value at Y40 through Y4F.
D0 1 D1 Y5F Y50
1325 H 1 3 2 5 0 0 3 6 0 0 3 5
MOV BCD BCD MOV BCD
BSQR D2 Y4F Y40
4 0 0 5 4 0 0 5
BCD MOV BCD
Program BDSQR
Example 2
The following program calculates the square root of the BCD value 74625813 and outputs the
integer part of the result as 4-digit BCD value at Y50 through Y5F. The decimal places are out-
put as 4-digit BCD value at Y40 through Y4F.
D1 D0 1 D2 Y5F Y50
74625813
7 4 6 2 5 8 1 3 8 6 3 8 8 6 3 8
BCD
DMOV BCD BCD MOV BCD
BDSQR D3 Y4F Y40
6 2 3 3 6 2 3 3
BCD MOV BCD
1
Square root calculation
NOTE These program examples will not run without variable definition in the header of the program
organization unit (POU). They would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 434
Special functions BSIN, BSINP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
d d+1 d+2
SIN(s) =
1
1 2 3 Sign bit
2
Integer part
3
Decimal places
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s is no BCD data. (Error code 4100)
● The data specified in s exceeds the value range from 0° to 360°. (Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 436
Special functions BSIN, BSINP
Program BSIN
Example
The following program calculates the sine value of the 3-digit BCD value at X20 through X2B.
If the value at X20 through X2B exceeds 360 (degrees), it will be corrected to suit the required
value range of 0° to 360°.
The sign is output at Y60. The integer part is output at Y50 through Y53 as 1-digit BCD value.
The decimal places are output at Y40 through Y4F as 4-digit BCD value.
1
Sine calculation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 438
Special functions BCOS, BCOSP
d d+1 d+2
COS(s) =
1 2 3 1
Sign bit
2
Integer part
3
Decimal places
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s is no BCD data.
(Error code 4100)
● The data specified in s exceeds the value range from 0° to 360°.
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program BCOS
Example
The following program calculates the cosine value of the 3-digit BCD value at X20 through X2B.
If the value at X20 through X2B exceeds 360 (degrees), it will be corrected to suit the required
value range of 0° to 360°.
The sign is output at Y60. The integer part is output at Y50 through Y53 as 1-digit BCD value.
The decimal places are output at Y40 through Y4F as 4-digit BCD value.
1
Cosine calculation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 440
Special functions BTAN, BTANP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
d d+1 d+2
TAN(s) = .
1 2 1
3 Sign bit
2
Integer part
3
Decimal places
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s is no BCD data.
(Error code 4100)
● The data specified in s exceeds the value range from 0° to 360°.
(Error code 4100)
● The value in s is 90° or 270°.
(Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 442
Special functions BTAN, BTANP
Program BTAN
Example
The following program calculates the tangent value of the 3-digit BCD value at X20 through
X2B. If the value at X20 through X2B exceeds 360 (degrees), it will be corrected to suit the
required value range of 0° to 360°.
The sign is output at Y60. The integer part is output at Y50 through Y53 as 1-digit BCD value.
The decimal places are output at Y40 through Y4F as 4-digit BCD value.
1
Tangent calculation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 444
Special functions BASIN, BASINP
-1 s s+1 s+2
SIN = ( . ) =d
1 2 3 1
Sign bit
2
Integer part
3
Decimal places
The sign of the result in s is 0 for a positive value and 1 for a negative value.
The integer part prior to the decimal point and the decimal places must be BCD values ranging
from 0 to 1.0000.
The value or the result in d must be a BCD value ranging from 0° to 90° or from 270° to 360°.
The calculation result will be rounded from the 5th digit on.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s through s+2 is no BCD data.
(Error code 4100)
● The data specified in s through s+2 exceeds the value range from -1.0000 to 1.0000.
(Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU.)
(Error code 4101)
Program BASIN
Example
The following program calculates the arcus sine value from the sign bit at X0 (positive when X0
is OFF, and negative when X0 is ON), the 1-digit BCD integer part at X30 through X33, and the
decimal places of the 4-digit BCD value at X20 through X2F. The resulting angle value is output
in 4-digit BCD format at Y40 through Y4F.
X0 0 0 0 0
BCD
X33 X30 1 Y4F Y40
0 0 0 0 0 0 0 2 8
MOV BCD BASIN BCD
X2F X20
4 75 3 4 7 5 3
BCD MOV BCD
1
Arcus sine calculation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 446
Special functions BACOS, BACOSP
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
s s+1 s+2
-1
COS = ( . ) =d
1 2 3 1
Sign bit
2
Integer part
3
Decimal places
The sign of the result in s is 0 for a positive value and 1 for a negative value.
The integer part prior to the decimal point and the decimal places must be BCD values ranging
from 0 to 1.0000.
The value or the result in d must be a BCD value ranging from 0° to 180.
The calculation result will be rounded from the 5th digit on.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s through s+2 is no BCD data.
(Error code 4100)
● The data specified in s through s+2 exceeds the value range from -1.000 to 1.000.
(Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 448
Special functions BACOS, BACOSP
Program BACOS
Example
The following program calculates the arcus cosine value from the sign bit at X0 (positive when
X0 is OFF and negative when X0 is ON), the 1-digit BCD integer part at X30 through X33, and
the decimal places of the 4-digit BCD value at X20 through X2F. The resulting angle value is
output in 4-digit BCD format at Y40 through Y4F.
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Performance Process Redundant Universal LCPU
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 450
Special functions BATAN, BATANP
-1 s s+1 s+2
TAN = ( . ) =d
1 2 3 1
Sign bit
2
Integer part
3
Decimal places
The sign bit of the result in s is 0 for a positive value and 1 for a negative value.
The integer part prior to the decimal point and the decimal places must be BCD values ranging
from 0 to 9999.9999.
The value of the result in d must be a BCD value ranging from 0° to 90° or 270° or from 270°
and 360°.
The calculation result will be rounded from the 5th digit on.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data specified in s through s+2 is no BCD data. (Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program BATAN
Example
The following program calculates the arcus tangent value from the sign bit at X0 (positive when
X0 is OFF and negative when X0 is ON), the 4-digit BCD integer part at X20 through X2F, and
the decimal places of the 4-digit BCD value at X30 through X3F.
The resulting angle value is output in 4-digit BCD format at Y40 through Y4F.
D0
X0 0 0 00
BCD
X2F X20 D1 Y4F Y40
0 0 0 1 0 0 0 1 0 0 5 2
BCD MOV BCD BATAN BCD
X3F X30 D2
2 6 54 26 5 4
BCD MOV BCD
1
Arcus tangent calculation
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 452
Data control instructions
Scaling SCLP
(Point-by point coordinate data) DSCL
DSCLP
SCL2
Scaling SCL2P
(X or Y coordinate data) DSCL2
DSCL2P
NOTE Within the IEC editors please use the IEC instructions.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 454
Data control instructions LIMIT, LIMITP, DLIMIT, DLIMITP
Functions Limitation of output values for BIN 16-bit and BIN 32-bit data
LIMIT Limitation instruction for BIN 16-bit data
The LIMIT instruction controls whether data in the device specified by s3 ranges within the
lower limits specified by s1 and the upper limits specified by s2. Depending on the control oper-
ation result the values are stored as follows in the device specified by d:
● If the data value in s3 is less than the lower limit value in s1, the lower limit value is stored in d.
● If the data value in s3 is greater than the upper limit value in s2, the upper limit value is
stored in d.
● If the data value in s3 ranges within the lower and the upper limit value, the data value is
stored in d.
1 3
2 4
6
1 Output value
2
Input value
3
Output value (d)
4 Input value (s3)
6
Lower limit value (s1)
The values specified by s1, s2, and s3 have to range within -32768 and 32767.
If only the upper limit value is to be checked, the lower limit value in s1 has to be set to -32768.
If only the lower limit value is to be checked, the upper limit value in s2 has to be set to 32767.
1 3
2 4
6
1
Output value
2
Input value
3
Output value (d+1, d)
4 Input value ((s3)+1, s3)
5
Upper limit value ((s2)+1, s2)
6
Lower limit value ((s1)+1, s1)
The values specified by s1 and (s1)+1, s2 and (s2)+1, and s3 and (s3)+1 have to range within
-2147483648 and 2147483647.
If only the upper limit value is to be checked, the lower limit value in s1 and (s1)+1 has to be
set to -2147483648.
If only the lower limit value is to be checked, the upper limit value in s2 and (s2)+1 has to be
set to 2147483647.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in s1 ((s1)+1) is greater than that in s2 ((s2)+1).
(Error code 4100)
7 – 456
Data control instructions LIMIT, LIMITP, DLIMIT, DLIMITP
Program LIMITP
Example 1
With leading edge from X0, the following program controls whether BCD data at X20 through
X2F ranges between the lower limit of 500 and the upper limit of 5000. The result of the control
operation is stored in D1.
– If the value in D0 is greater than 5000, the value 5000 is stored in D1.
– If the value in D0 is less than 500, the value 500 is stored in D1.
– If the value ranges within 500 and 5000, the data value is stored in D1.
Program DLIMIT
Example 2
With leading edge from X0, the following program controls whether BCD data at X20 through
X3F ranges within the lower limit of 10000 and the upper limit of 1000000. The result of the
control operation is stored in D10 and D11.
– If the value in D0 and D1 is greater than 1000000, the value 1000000 is stored in D10 and
D11.
– If the value in D0 and D1 is less than 10000, the value 10000 is stored in D10 and D11.
– If the value ranges within 10000 and 1000000, the data value is stored in D10 and D11.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 458
Data control instructions BAND, BANDP, DBAND, DBANDP
1 3
2 4
7
6
1 Output value
2
Input value
3
Output value (d)
4 Input value (s3)
6
Output value = 0
7 Upper limit value (s2)
The values in s1, s2, and s3 have to range within -32768 and 32767.
If the subtraction result leaves the relevant device range of -32768 and 32767 the output value
is controlled as follows:
● If the value -32768 is fallen below, the remaining subtraction is proceeded beginning from
32767. For example, if s3 stores the value -32768 and the value 10 in s1 is subtracted, the
result is
-32768 - 10 = 8000H - AH = 7FF6H = 32758.
● If the value 32767 is exceeded, the remaining subtraction is proceeded beginning from
-32768.
1
Output value
2
Input value
3
Output value (d+1, d)
4 Input value ((s3)+1, s3)
5
Lower limit value ((s1)+1, s1)
6
Output value = 0
7 Upper limit value ((s2)+1, s2)
The values in s1 and (s1)+1, s2 and (s2)+1, and s3 and (s3)+1 have to range within
-2147483648 and 2147483647.
If the subtraction result leaves the relevant device range of -2147483648 and 2147483647 the
output value is controlled as follows:
● If the value -2147483648 is fallen below, the remaining subtraction is proceeded beginning
from 2147483647. For example, if s3 and (s3)+1 store the value -2147483648 and the value
1000 in s1 is subtracted, the result is
-2147483648 - 1000 = 80000000H - 3E8H = 7FFFFC18H = 2147482648.
● If the value 2147483647 is exceeded, the remaining subtraction is proceeded beginning
from -2147483648.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The value in s1 ((s1)+1) is greater than that in s2 ((s2)+1).
(Error code 4100)
7 – 460
Data control instructions BAND, BANDP, DBAND, DBANDP
Program BANDP
Example 1
With leading edge from X0, the following program subtracts the lower limit value -1000 and the
upper limit value 1000 from the BCD data at X20 through X2F. The result is stored in D1.
– If the value in D0 is greater than 1000, the value D0 - 1000 is stored in D1.
– If the value in D0 is less than -1000, the value D0 - (-1000) is stored in D1.
– If the value in D0 ranges within -1000 and 1000, the value 0 is stored in D1.
Program DBANDP
Example 2
With leading edge from X0, the following program subtracts the lower limit value -10000 and
the upper limit value 10000 from the BCD data at X20 through X3F. The result is stored in D10
and D11.
– If the value in D0 and D1 is greater than 10000, the value D0, D1 - 1000 is stored in D10
and D11.
– If the value in D0 and D1 is less than -10000, the value D0, D1 - (-10000) is stored in D10
and D11.
– If the value in D0 and D1 ranges within -10000 and 1000, the value 0 is stored in D10 and
D11.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 462
Data control instructions ZONE, ZONEP, DZONE, DZONEP
1
Output value
2
Input value
3 Output value (d)
5
Upper (positive) zone control value (s2)
6 Input value = 0
The values in s1, s2, and s3 have to range within -32768 and 32767.
If the addition result leaves the relevant device range of -32768 and 32767, the output value is
controlled as follows:
● If the value -32768 is fallen below, the remaining addition is proceeded beginning from
32767. For example, if s3 stores the value -32768 and the value -100 in s1 is added, the
result is
-32768 + (-100) = 8000H + FF9CH = 7F9CH = 32668.
● If the value 32767 is exceeded, the remaining addition is proceeded beginning from -32768.
1
Output value
2
Input value
3
Output value (d+1, d)
4 Input value ((s3)+1, s3)
5
Upper (positive) zone control value ((s2)+1, s2)
6
Input value = 0
7 Lower (negative) zone control value ((s1)+1, s1)
The values in s1 and (s1)+1, s2 and (s2)+1, and s3 and (s3)+1 have to range within
-2147483648 and 2147483647.
If the addition result leaves the relevant device range of -2147483648 and 2147483647 the out-
put value is controlled as follows:
● If the value -2147483648 is fallen below, the remaining addition is proceeded beginning from
2147483647. For example, if s3 and (s3)+1 store the value -2147483648 and the value -1000
in s1 is added, the result is
-2147483648 + (-1000) = 80000000H + FFFFFC18H = 7FFFFC18H = 2147482648.
● If the value 2147483647 is exceeded, the remaining addition is proceeded beginning from
-2147483648.
7 – 464
Data control instructions ZONE, ZONEP, DZONE, DZONEP
Program ZONEP
Example 1
With leading edge from X0, the following program adds the negative zone control value -100
and the positive zone control value 100 to BCD data at X20 through X2F. The result is stored
in D1.
– If the value in D0 is greater than 0, the value D0 + 100 is stored in D1.
– If the value in D0 is less than 0, the value D0 + (-100) is stored in D1.
– If the value D0 is equal to 0, the value 0 is stored in D1.
Program DZONEP
Example 2
With leading edge from X0, the following program adds the negative zone control value -10000
and the positive zone control value 10000 to BCD data at X20 through X3F. The result is stored
in D10 and D11.
– If the value in D0 and D1 is greater than 0, the value D0, D1 + 10000 is stored in D10 and D11.
– If the value in D0 and D1 is less than 0, the value D0, D1 + (-10000) is stored in D10 and D11.
– If the value D0 and D1 is equal to 0, the value 0 is stored in D10 and D11.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SCL s1 s2 d
7 – 466
Data control instructions SCL, SCLP, DSCL, DSCLP
3)
4)
1) d
5)
6)
2)
X
7) s1
8) 9) 8)
1
Output value (d)
2
Point 1
3
Point 2
4
Point 3
5
Point n–1
6
Point n
7
Input value (s1)
8
Operation error
9
Operable range
If the value does not result in an integer, this instruction rounds the value to the whole number.
Set the X coordinate of the scaling conversion data in ascending order.
Set the input value s1 within the range of the scaling conversion data (within the range of s2
devices).
If some specified points have same X coordinates, the Y coordinate data of the highest point
number will be output.
Specify the number of coordinate points of scaling conversion data from 1 to 32767.
7) 8) 7)
6) s1
X
4)
1) d 5)
2)
3)
5
Point n
6
Input value (s1)
7 Operation error
8 Operable range
If the value does not result in an integer, this instruction rounds the value to the whole number.
Set the X coordinate of the scaling conversion data in ascending order.
Set the input value s1 within the range of the scaling conversion data (within the range of s2
and ((s2)+1) devices).
If some specified points have same X coordinates, the Y coordinate data of the highest point
number will be output.
Specify the number of coordinate points of scaling conversion data from 1 to 32767.
7 – 468
Data control instructions SCL, SCLP, DSCL, DSCLP
NOTE There are two searching methods that depend on whether SM750 is on or off.
When the scaling conversion data are set in ascending order, the searching methods change
from one to the other depending on the SM750 status. Therefore, the processing speed also
changes. The number of searches determines the processing speed. Fewer number of serches
make the processing run faster.
If the data processing speed with the sequential search rises:
If the number of coordinates is highest and the input value s1 is within the coordinate range
from 1 to 15 point, the number of sequential searches will be 15 or smaller. Therefore, the
data processing speed with the sequential search will rise.
If the data processing speed with the binary search rises:
If the maximum number of searches is 15 and the input value s1 is out of the coordinate ran-
ge, 16 or over, the number of binary searches will be equal to the number of sequential num-
bers or smaller. Therefore, the data processing speed with the binary search will rise.
s1 s1
Number of sequential searches=1
Number of binary searches=15
The processing speed with sequential searches rises
since the number of binary searches is larger than the
number of sequential searches.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The X coordinates of the scaling conversion data positioned before the point specified by
s1 are not set in ascending order. (However, this error is not detected when SM750 is on.)
(Error code 4100)
● The input value specified by s1 is out of the range of the scaling conversion data set.
(Error code 4100)
● The number of X and Y coordinates of the device specified by s2 is out of the range from 1
to 32767.
(Error code 4100)
Program SCLP
Example
The following program executes scaling for the scaling conversion data of which the devices
specified at D100 and up are set with the input value specified at D0. The result is stored in
D20.
Setting
Setting Item Device
Contents
Number of coordinate points D100 K5
Y
X coordinate D101 K5 Point 5
Point 1
Y coordinate D102 K13 (25, 22)
Point 2
X coordinate D103 K10
Point 2 Point 1 (10, 15) Point 3
Y coordinate D104 K15 (5, 13) (17, 13)
D20=11
X coordinate D105 K17 Output
Point 3 value
Y coordinate D106 K13 (20, 8)
Point 4
X coordinate D107 K20
Point 4
Y coordinate D108 K8 X
D0=18
X coordinate D109 K25 Input value
Point 5
Y coordinate D110 K22
7 – 470
Data control instructions SCL2, SCL2P, DSCL2, DSCL2P
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
instruction symbol SCL2/DSCL2
s1 s2 d
P s1 s2 d
Point n 1) (s2)+2n
1
n indicates the number of coordinates specified by s2.
3)
4)
1) d
5)
6)
2)
X
7) s1
8) 9) 8)
1
Output value (d)
2 Point 1
3
Point 2
4
Point 3
5 Point n–1
6
Point n
7
Input value (s1)
8 Operation error
9
Operable range
If the value does not result in an integer, this instruction rounds the value to the whole number.
Set the X coordinate of the scaling conversion data in ascending order.
Set the input value s1 within the range of the scaling conversion data (within the range of s2
devices).
If some specified points have same X coordinates, the Y coordinate data of the highest point
number will be output.
Specify the number of coordinate points of scaling conversion data from 1 to 32767.
7 – 472
Data control instructions SCL2, SCL2P, DSCL2, DSCL2P
7) 8) 7)
6) s1
X
4)
1) d 5)
2)
3)
1
Output value (d)
2 Point 1
3
Point 2
4
Point n–1
5 Point n
6
Input value (s1)
7
Operation error
8 Operable range
If the value does not result in an integer, this instruction rounds the value to the whole number.
Set the X coordinate of the scaling conversion data in ascending order.
Set the input value s1 within the range of the scaling conversion data (within the range of s2
and ((s2)+1) devices).
If some specified points have same X coordinates, the Y coordinate data of the highest point
number will be output.
Specify the number of coordinate points of scaling conversion data from 1 to 32767.
NOTE When the scaling conversion data are set in ascending order, the searching methods change
from one to the other depending on the SM750 status. Therefore, the processing speed also
changes. The number of searches determines the processing speed. Fewer number of serches
make the processing run faster.
For details refer to section 7.13.4.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The X coordinates are not set in ascending order.
(Error code 4100)
● The input value specified by s1 is out of the range of the scaling conversion data set.
(Error code 4100)
● The number of X and Y coordinates of the device specified by s2 is out of the range from 1
to 32767.
(Error code 4100)
Program SCL2P
Example
The following program executes scaling for the scaling conversion data of which the devices
specified at D100 and up are set with the input value specified at D0. The result is stored in
D20.
Setting
Setting Item Device Contents
Number of coordinate points D110 K5
Y
Point 1 D111 K7
X coordinate
Point 1
Point 2 D117 K-7 (7, -14)
7 – 474
File register switching instructions
The switching instructions enable switching between file register blocks and between file
names in file registers.
The table below gives an overview of the instructions:
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 476
File register switching instructions RSET, RSETP
3
2
R0 4 R0 5 R0 6
5 Block 1
6
Block n
NOTE When a file register (R) is refreshed and the block No. of the file register is switched with the
RSET instruction, follow restrictions. For restrictions on file registers, refer to section 3.13.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The block number specified by s does not exist.
(Error code 4100)
● There are no file registers in the block specified by s.
(Error code 4101)
Program RSETP
Example
The following program compares the file register R0 in register block 0 to the file register R0 in
register block 1. The file register blocks 0 and 1 are addressed via the RSET instruction. Both
file registers R0 are read via the MOV instruction.
If the value in R0 (block 0) is equal to the value in R0 (block 1), the output Y40 is set.
If the value in R0 (block 0) is less than the value in R0 (block 1), the output Y41 is set.
If the value in R0 (block 0) is greater than the value in R0 (block 1), the output Y42 is set.
1
Block 0
2 Block 1
3 Y41 is set because D0 is less than D1.
7 – 478
File register switching instructions QDRSET, QDRSETP
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
1
Processing with file register access
2
Setting the drive and file(s)
3
Drive 1, file A
4
Drive 1, file B
5 Drive 1, file C
6
Drive 2, file A
7
Drive 3, file A
8 Drive 4, file A
In total, 4 drives can be assigned (1–4). The drive number 0 cannot be assigned; this range is
reserved for internal memory. Note that available drives vary depending on the CPU module
used. Refer to the manual of the CPU module and check the drives that can be specified.
The extension .QDR is not needed to be entered for file specification.
A file name setting can be cleared by specifying the NULL character (00H) for the file name.
File register files selected by the QDRSET instruction are given priority even if a drive number
and file name were specified by the parameters.
NOTES If the file name is changed with the QDRSET instruction, the file name returns to the name spe-
cified by the parameter when the CPU module is switched from STOP to RUN. To maintain the
file name even after the CPU mode is changed from STOP to RUN, execute the QDRSET in-
struction with the SM402 special relay, which turns ON during one scan when the CPU enters
from STOP to RUN mode.
For refreshing a file register, do not change the file name of the file register with the QDRSET
instruction. For restrictions on file registers, refer to section 3.13.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The file register file does not exist on the drive specified by s.
(Error code 2410)
7 – 480
File register switching instructions QDRSET, QDRSETP
Program QDRSET/QDRSETP
Example
With leading edge from X0, the following program switches to the file register file ABC.QDR on
drive 1. While X1 is set, the file register file DEF.QDR on drive 3 is accessed.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 482
File register switching instructions QCDSET, QCDSETP
1
Processing with comment data access
2
Setting the drive and comment file (s)
3 Drive 1, file A
4
Drive 1, file B
5 Drive 1, file C
6 Drive 2, file A
7
Drive 3, file A
8 Drive 4, file A
In total, 4 drives can be assigned (1–4). The drive number 0 cannot be assigned; this range is
reserved for internal memory. Note that available drives vary depending on the CPU module
used. Refer to the manual of the CPU module and check the drives that can be specified.
The extension .QCD is not needed to be entered for file specification.
A file name setting can be cleared by specifying the NULL character (00H) for the file name.
Comment files selected by the QCDSET instruction are given priority even if a drive number
and file name were specified by the parameters.
NOTE If the file name is changed with the QCDSET instruction, the file name returns to the name spe-
cified by the parameter when the CPU module is switched from STOP to RUN.
To maintain the file name even after the CPU mode is changed from STOP to RUN, execute the
QCDSET instruction with the SM402 special relay, which turns ON during one scan when the
CPU enters from STOP to RUN mode.
NOTES This instruction will not be executed even when the execution command of this instruction is ON
while SM721 (file access in execution) is ON for the Universal model QCPU and LCPU.
Execute this instruction when SM721 is OFF.
For the LCPU, when drive 2 (SD memory card) is specified as the drive number, this instruction
cannot be executed while SM606 (SD memory card forced disable instruction) is ON. Even if the
instruction is attempted to be executed, the command will be ignored.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The comment file does not exist on the drive specified by s.
(Error code 2410)
Program QCDSET/QCDSETP
Example
With leading edge from X0, the following program switches to the comment file ABC.QCD on
drive 1. While X1 is set, the comment file DEF.QCD on drive 3 is accessed.
7 – 484
Clock instructions
NOTE The expansion clock instructions described in section 7.16 can process the milliseconds of the
internal CPU clock as well.
7 – 486
Clock instructions DATERD, DATERDP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
The following table contains the value range of clock data in d+0 (Array_d[0]) through d+6
(Array_d[6]):
Day of the
Clock data Year Month Day Hour Minute Second
week
Input range 1980–2079 1–12 1–31 0–23 0–59 0–59 0–6
Devices d+0 d+1 d+2 d+3 d+4 d+5 d+6
(Array_d[0]) (Array_d[1]) (Array_d[2]) (Array_d[3]) (Array_d[4]) (Array_d[5]) (Array_d[6])
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 488
Clock instructions DATERD, DATERDP
Program DATERD
Example
The following program reads clock data from the internal CPU clock and outputs it in BCD for-
mat at the outputs as follows:
Y70 - Y7F = year Y68 - Y6F = month
Y60 - Y67 = day Y58 - Y5F = hour
Y50 - Y57 = minute Y48 - Y4F = second
Y44 - Y47 = day of the week
Clock data Year Month Day Hour Minute Second Day of the
week
Devices D0 D1 D2 D3 D4 D5 D6
BCD
Y7F-------Y78 Y77-------70
2 0 0 0
D0 2000
Y6F-------Y68 Y67-------Y60
D1 12
1 D2 24
1 2 2 4 3
2000, 12, 24, 12 : 57 : 39, Sunday D3 12
Y5F-------Y58 Y57-------Y50
D4 57
1 2 5 7 4
D5 39
D6 0
Y4F-------Y48 Y47-------Y40
BIN 3 9 0 5
1 Clock data
2 Year
3
Month, day
4 Hour, minute
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 490
Clock instructions DATEWR, DATEWRP
The following table contains the value range of clock data in s+0 (Array_s[0]) through s+6
(Array_s[6]):
Day of the
Clock data Year Month Day Hour Minute Second
week
Input range 1980–2079 1–12 1–31 0–23 0–59 0–59 0–6
Devices s+0 s+1 s+2 s+3 s+4 s+5 s+6
(Array_s[0]) (Array_s[1]) (Array_s[2]) (Array_s[3]) (Array_s[4]) (Array_s[5]) (Array_s[6])
f
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data specified in s+0 (Array_s[0]) through s+6 (Array_s[6]) exceed the relevant
value range.
(Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program DATEWRP
Example
With leading edge from X40, the following program writes the clock data in binary format at the
inputs to the internal CPU clock. The inputs are assigned to the clock data as follows:
X30 - X3F = year X18 - X1F = hour
X28 - X2F = month X10 - X17= minute
X20 - X27 = day X8 - XF = second
Day of the
Clock data Year Month Day Hour Minute Second week
Devices D0 D1 D2 D3 D4 D5 D6
BIN
X3F-------X38 X37-------X30
1 2 0 0 0
D0 2000
X2F-------X28 X27-------x20
D1 12
2 1 2 2 4
D2 24 5
D3 12 2000, 12, 24, 12 : 57 : 39, Sunday
X1F-------X18 X17-------X10
D4 57
3 1 2 5 7
D5 39
D6 0
XF-------X8 X7-------X4
BIN
4 3 9 0
1 Year
2 Month, day
3
Hour, minute
4 Second, day of the week
5
Clock data
7 – 492
Clock instructions DATE+, DATE+P
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices UsableDevices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register
Register Module Zn Constant Other
Bit Word Bit Word U\G
s1 — — — — — — —
s2 — — — — — — —
d — — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
Day of the
Clock Data Year Month Day Hour Minute Second
week
Input range — — — 0–23 0–59 0–59 —
Devices s1+0 s1+1 s1+2
— — — —
(Array_s1[0]) (Array_s1[1]) (Array_s1[2])
Devices s2+0 s2+1 s2+2
— — — —
(Array_s2[0]) (Array_s2[1]) (Array_s2[2])
Devices d+0 d+1 d+2
— — — —
(Array_d[0]) (Array_d[1]) (Array_d[2])
1
Hour
2
Minute
3 Second
1 Hour
2
Minute
3 Second
7 – 494
Clock instructions DATE+, DATE+P
If the addition result of clock data exceeds 24 hours, 24 hours are subtracted automatically to
achieve a correct time value.
The following diagram illustrates the addition of
14 hours, 20 minutes, and 30 seconds
to 20 hours, 20 minutes, and 20 seconds.
The result would be 34 hours, 40 minutes, and 50 seconds.
Since this result is not a correct time format, after the subtraction of 24 hours, the correct result
is 10 hours, 40 minutes, and 50 seconds (10:40:50 the next day).
1 Hour
2
Minute
3 Second
NOTE Refer to section 7.15.2 "DATEWR, DATEWRP" for further information on that topic.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data in (s1)+0 through (s1)+2 (Array_s1[0] through Array_s1[2]) and (s2)+0
through (s2)+2 (Array_s2[0] through Array_s2[2]) exceed the input range.
(Error code 4100)
● The device specified by s1, s2 or d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program DATE+P
Example
With leading edge from X20, the following program reads the clock data from the internal CPU
clock via the DATERDP instruction and stores it in the registers D0 through D6 (see first dia-
gram after the program example below).
The DATE+P instruction adds one hour (D10, D11, D12) to the read data. The result is stored
in D100 through D102 (see second diagram after the program example below).
Day of the
Clock Data Year Month Day Hour Minute Second week
Devices D0 D1 D2 D3 D4 D5 D6
(var_D0[0]) (var_D0[1]) (var_D0[2]) (var_D0[3]) (var_D0[4]) (var_D0[5]) (var_D0[6])
Devices D20 D21 D22
— — — —
(var_D20[0]) (var_D20[1]) (var_D20[2])
Devices D10 D11 D12
— — — —
(var_D10[0]) (var_D10[1]) (var_D10[2])
Devices D100 D101 D102
— — — —
(var_D100[0]) (var_D100[1]) (var_D100[2])
NOTE This program example will not run without variable definition in the header of the program or-
ganization unit (POU). It would cause compiler or checker error messages. For details see sec-
tion 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 496
Clock instructions DATE+, DATE+P
The diagram below illustrates reading clock data via the DATERDP instruction.
1 Clock element
2
Year
3
Month (January = 1, December = 12)
4 Day
5
Hour (24-hour format)
6
Minute
7 Second
8
Day of the week
9
Clock data
The diagram below illustrates the addition via the DATE+P instruction.
1
Hour
2
Minute
3
Second
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 498
Clock instructions DATE-, DATE-P
Day of the
Clock Data Year Month Day Hour Minute Second
week
Input range — — — 0–23 0–59 0–59 —
Devices s1+0 s1+1 s1+2
— — — —
(Array_s1[0]) (Array_s1[1]) (Array_s1[2])
Devices s2+0 s2+1 s2+2
— — — —
(Array_s2[0]) (Array_s2[1]) (Array_s2[2])
Devices d+0 d+1 d+2
— — — —
(Array_d[0]) (Array_d[1]) (Array_d[2])
1
Hour
2
Minute
3
Second
The following diagram illustrates the subtraction of 3 hours, 50 minutes, and 10 seconds
((s2)+0 through (s2)+2, (Array_s2[0] through Array_s2[2])) from 10 hours, 40 minutes, and 20
((s1)+0 through (s1)+2, (Array_s1[0] through Array_s1[2]) ). The result, 6 hours, 50 minutes,
and 10 seconds is stored in d+0 through d+2 (Array_d[0] through Array_d[2]).
1
Hour
2
Minute
3
Second
If the subtraction result of clock data becomes negative, 24 hours are added automatically to
achieve a correct time value.
The following diagram illustrates the subtraction of
10 hours, 42 minutes, and 12 seconds
from 4 hours, 50 minutes, and 32 seconds.
The result would be -6 hours, 8 minutes, and 20 seconds.
Since this result is not a correct time format, after the addition of 24 hours, the correct result is
18 hours, 8 minutes, and 20 seconds (18:08:20 the day before).
1 Hour
2
Minute
3 Second
NOTE Refer to section 7.15.2 "DATEWR, DATEWRP" for further information on that topic.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data in (s1)+0 through (s1)+2 (Array_s1[0] through Array_s1[2]) and (s2)+0
through (s2)+2 (Array_s2[0] through Array_s2[2]) exceed the input range.
(Error code 4100)
● The device specified by s1 or s2 or d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
7 – 500
Clock instructions DATE-, DATE-P
Program DATE-P
Example
With leading edge from X1C, the following program reads the clock data from the internal CPU
clock via the DATERDP instruction and stores it in the registers D100 through D106 (see first
diagram after the program example below).
The DATE-P instruction subtracts 10 hours (D10), 40 minutes (D11) and 10 seconds (D12)
from the read data. To the negative subtraction result, -8 hours, 41 minutes and 10 seconds is
added 24 hours automatically. The correct result, 16 hours, 41 minutes and 10 seconds
(16:41:10 the day before) is stored in R10 through R12 (see second diagram after the program
example below).
Day of the
Clock Data Year Month Day Hour Minute Second week
Devices D100 D101 D102 D103 D104 D105 D106
(var_D100[0]) (var_D100[1]) (var_D100[2]) (var_D100[3]) (var_D100[4]) (var_D100[5]) (var_D100[6])
Devices D1000 D1001 D1002
— — — —
(var_D1000[0]) (var_D1000[1]) (var_D1000[2])
Devices D10 D11 D12
— — — —
(var_D10[0]) (var_D10[1]) (var_D10[2])
Devices R10 R11 R12
— — — —
(var_R10[0]) (var_R10[1]) (var_R10[2])
NOTE This program example will not run without variable definition in the header of the program or-
ganization unit (POU). It would cause compiler or checker error messages. For details see sec-
tion 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
The diagram below illustrates reading clock data via the DATERDP instruction.
1 Clock element
2
Year
3
Month (January = 1, December = 12)
4 Day
5
Hour (24-hour format)
6
Minute
7 Second
8
Day of the week
9
Clock data
The diagram below illustrates the subtraction via the DATE-P instruction.
1
Hour
2
Minute
3
Second
7 – 502
Clock instructions SECOND, SECONDP, HOUR, HOURP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
Clock Data Year Month Day Hour Minute Second Day of the
week
Input range — — — 0–23 0–59 0–59 —
Devices s+0 s+1 s+2
— — — —
(Array_s[0]) (Array_s[1]) (Array_s[2])
Devices d+0
(Array_d[0])
— — — — — through —
d+1
(Array_d[1])
d+1 d
s 1
s+1 2 4
1
s+2 3 Hour
2Minute
3Second
4
Time value in seconds
The following diagram shows the conversion of 4 hours, 29 minutes, and 31 seconds into
16171 seconds.
d+1 d
s 4 1
s+1 29 2 16171 4
1
s+2 31 3 Hour
2
Minute
3
Second
4
Time value in seconds
7 – 504
Clock instructions SECOND, SECONDP, HOUR, HOURP
Day of the
Clock Data Year Month Day Hour Minute Second
week
Input range — — — 0 - 23 0 - 59 0 - 59 —
Devices d+0 d+1 d+2
— — — —
(Array_d[0]) (Array_d[1]) (Array_d[2])
Devices s+0
(Array_s[0])
— — — — — through —
s+1
(Array_s[1]
s+1 s
d 2
1 d+1 3
d+2 4 1Time
value in seconds
2
Hour
3
Minute
4Second
The following diagram shows the conversion of 45325 seconds into 12 hours, 35 minutes, and
25 seconds.
s+1 s
d 12 2
1 45325 d+1 35 3
d+2 25 4 1
Time value in seconds
2Hour
3Minute
4
Second
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data in s+0 (Array_s[0]) through s+2 (Array_s[2]) for the SECOND instruction or
in s+0 and s+1 for the HOUR instruction exceed the input range.
(Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU.)
(Error code 4101)
Program SECONDP
Example 1
With leading edge from X20, the following program reads clock data from the internal CPU
clock via the DATERDP instruction and stores it in the registers D10 through D16 (see first dia-
gram after the program example below).
The hours, minutes, and seconds of clock data are converted into seconds only via the
SECONDP instruction. The result is stored in D100 and D101 (see second diagram after the
program example below).
Day of the
Clock Data Year Month Day Hour Minute Second week
Devices D10 D11 D12 D13 D14 D15 D16
(var_D10[0]) (var_D10[1]) (var_D10[2]) (var_D10[3]) (var_D10[4]) (var_D10[5]) (var_D10[6])
Devices D20 D21 D22
— — — —
(var_D20[0]) (var_D20[1]) (var_D20[2])
Devices D100
(var_D10[0])
— — — — — to —
D101
(var_D10[1])
7 – 506
Clock instructions SECOND, SECONDP, HOUR, HOURP
The diagram below illustrates reading clock data via the DATERDP instruction.
1 D10 95 2
D11 4 3
D12 20 4
D13 20 5
D14 21 6 9
D15 23 7
D16 5 8
1 Clock element
2
Year
3
Month (January = 1, December = 12)
4 Day
5
Hour (24-hour format)
6
Minute
7 Second
8
Day of the week
9
Clock data
The diagram below illustrates the conversion into seconds via the SECONDP instruction.
D13 20 1 4
D14 21 2 D101, D100 73283
D15 23 3
1
Hour
2
Minute
3
Second
4
Converted seconds
Program HOURP
Example 2
With leading edge from X20, the following program converts the seconds stored in D0 and D1
into hours, minutes, and seconds. The result is stored in D100 through D102.
Day of the
Clock Data Year Month Day Hour Minute Second week
Devices D0 D1 D2
— — — —
(var_D0[1]) (var_D0[2]) (var_D0[3])
Devices D100
(var_D100[0])
— — — — — to —
D101
(var_D100[1])
1 D100 11 2
D1, D0 40000 D101 6 3
D102 40 4
4 Second
NOTE These program examples will not run without variable definition in the header of the program or-
ganization unit (POU). It would cause compiler or checker error messages. For details see sec-
tion 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
7 – 508
Clock instructions DT=, DT<>, DT>, DT<=, DT<, DT>=
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
DT=/DT<>/DT</DT<=/DT>/DT>=
LD s1 s2 n
AND s1 s2 n
OR
s1 s2 n
Data range
(s1) Year 1980–2079
NOTE When either s1 or s2 corresponds to any of the following conditions in comparing given or current
date data with given date data, an operation error (error code 4101) or a malfunction may occur.
The range of the devices to be used for the index modification is specified over the range of
the device specified by s1 or s2.
File registers are specified by by s1 or s2 without a register set.
7 – 510
Clock instructions DT=, DT<>, DT>, DT<=, DT<, DT>=
This instruction specifies the following values at n so that the data to be compared can be spec-
ified.
The bit configuration specified at n is as follows.
b15 b14 b3 b2 b1 b0
0/1 0 0/1 0/1 0/1
Day
If this instruction specifies 1 (on) at bit b15, the Month
instruction compares s1 with the current date in
Year
accordance with the bit condition specified at bit b0
to b2.
If the data stored in the devices to be compared are not recognized as date data, SM709 will
be turned on after the instruction execution and no-conductive status will be made. Even if they
are not recognized as date data but the range of the devices is within the setting range, SM709
will not be turned on.
Moreover, if the range of devices specified by s1 to s1+2 or s2 to s2+2 exceeds the range of
specified devices, SM709 will be turned on after the instruction execution and no-conductive
status will be made.
Once SM709 is turned on, on-status will be retained till when the CPU modules are reset or
powered off. Therefore, turn off SM709 if necessary.
The following table shows the comparison operation results for each instruction:
A B C
The following table shows the conductive states resulting from performing the comparison
operation of the dates A, B, and C shown above. Even if the objects to be compared are
under the same condition, the comparison operation results vary depending on the objects
selected.
Comparison Condition
Comparison Objects
A<B B<C A<C
Day
Month
Month, day
Year
Year, day
Year, month
Year, month, day
No objects
Conductive
Non-conductive
● Even if the dates to be compared do not exist practically, this instruction executes the
comparison operation for the objects with the settable dates in accordance with the following
condition.
– Date A: 2006/02/30 (This date is settable, though it does not exist.)
– Date B: 2007/03/29
– Date C: 2008/02/31 (This date is settable, though it does not exist.)
Comparison Condition
Comparison Objects
A<B B<C A<C
Day
Month
Month, day
Year
Year, day
Year, month
Year, month, day
No objects
Conductive
Non-conductive
7 – 512
Clock instructions DT=, DT<>, DT>, DT<=, DT<, DT>=
Program LDDT=
Example 1
The following program compares the data stored in D0 with the data (year, month, and day)
stored in D10, and turns Y33 ON when the data stored in D0 meet the data stored in D10.
Program ANDDT<>
Example 2
The following program compares the data stored in D0 with the current date data (year and
month), and turns Y33 ON when the data stored in D0 do not meet the current date data, when
M0 is turned on.
Program ANDDT>
Example 3
The following program compares the data stored in D0 with the data (year and day) stored in
D10, and turns Y33 ON when the data value stored in D10 is smaller than the data value stored
in D0, when M0 is turned on.
Program ORDT<=
Example 4
The following program compares the data stored in D0 with the current date data (year), and
turns Y33 ON when the value of the current date data is the data value stored in D0 or larger.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
TM=/TM<>/TM</TM<=/TM>/TM>=
LD s1 s2 n
AND s1 s2 n
OR
s1 s2 n
7 – 514
Clock instructions TM=, TM<>, TM>, TM<=, TM<, TM>=
Data range
(s1) Hour 0–23
NOTE When either s1 or s2 corresponds to any of the following conditions in comparing given or current
time data with given clock data, an operation error (error code 4101) or a malfunction may occur.
The range of the devices to be used for the index modification is specified over the range of
the device specified by s1 or s2.
File registers are specified by by s1 or s2 without a register set.
This instruction specifies the following values at n so that the data to be compared can be spec-
ified.
The bit configuration specified at n is as follows.
b15 b14 b3 b2 b1 b0
0/1 0 0/1 0/1 0/1
Second
If this instruction specifies 1 (ON) at bit b15 the Minute
instruction compares s1 with the current time in
Hour
accordance with the bit condition specified at bits
b0 to b2.
If the data stored in the devices to be compared are not recognized as clock data, SM709 will
be turned on after the instruction execution and no-conductive status will be made.
Moreover, if the range of devices specified by s1 to s1+2 or s2 to s2+2 exceeds the range of
specified devices, SM709 will be turned on after the instruction execution and no-conductive
status will be made.
Once SM709 is turned on, on-status will be retained until the CPU modules are reset or pow-
ered off. Therefore, turn off SM709 if necessary.
7 – 516
Clock instructions TM=, TM<>, TM>, TM<=, TM<, TM>=
The following table shows the comparison operation results for each instruction.
A B C
The following table shows the conductive states resulting from performing the comparison
operation of the clock data A, B, and C shown above. Even if the objects to be compared
are under the same condition, the comparison operation results vary depending on the
objects selected.
Comparison Condition
Comparison Objects
A<B B<C A<C
Second
Minute
Minute, second
Hour
Hour, second
Hour, minute
No objects
Conductive
Non-conductive
Program LDTM=
Example 1
The following program compares the data stored in D0 with the data (hour, minute, and second)
stored in D10, and turns Y33 ON when the data stored in D0 meet the data stored in D10.
Program ANDTM<>
Example 2
The following program compares the data stored in D0 with the current time data (hour and
minute), and turns Y33 ON when the data stored in D0 do not meet the current date data, when
M0 is turned on.
Program ANDTM>
Example 3
The following program compares the data stored in D0 with the data (hour and second) stored
in D10, and turns Y33 ON when the data value stored in D10 is smaller than the data value
stored in D0, when M0 is turned on.
Program ORTM<=
Example 4
The following program compares the data stored in D0 with the current time data (hour), and
turns Y33 ON when the value of the current time data is the data value stored in D0 or larger.
7 – 518
Expansion clock instructions TM=, TM<>, TM>, TM<=, TM<, TM>=
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 1) 1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
S.DATERD d
SP.DATERD d
7 – 520
Expansion clock instructions S.DATERD, SP.DATERP
d 1
d+1 2
d+2 3
The following table contains the value range of clock data in d+0 through d+7 (Array_d[0])
through (Array_d[7]):
Day of the
Clock data Year Month Day Hour Minute Second Millisecond
week
Input range 1980–2079 1–12 1–31 0–23 0–59 0–59 0–6 0–999
Devices d+0 d+1 d+2 d+3 d+4 d+5 d+6 d+7
(Array_d[0]) (Array_d[1]) (Array_d[2]) (Array_d[3]) (Array_d[4]) (Array_d[5]) (Array_d[6]) (Array_d[7])
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
Program SP.DATERD
Example
The following program reads clock data from the internal CPU clock and outputs it in BCD for-
mat at the outputs as follows:
Y70 - Y7F = year Y68 - Y6F = month
Y60 - Y67 = day Y58 - Y5F = hour
Y50 - Y57 = minute Y48 - Y4F = second
Y44 - Y47 = day of the week Y38 - Y43 = millisecond
Clock data Year Month Day Hour Minute Second Day of the Millisecond
week
Devices D0 D1 D2 D3 D4 D5 D6 D7
D0 2005
Y6F Y68 Y67 Y60
D1 12
1) 1 2 2 4 3)
D2 24
2005, 12, 24 12:57:39 Sunday 530 D3 12
Y5F Y58 Y57 Y50
D4 57
1 2 5 7 4)
D5 39
D6 0
Y4F Y48 Y47 Y44
D7 530
3 9 0 5)
BIN
Y43 Y38
5 3 0 6)
1 Clock data
2 Year
3
Month, day
4 Hour, minute
6
Millisecond
7 – 522
Expansion clock instructions S.DATERD, SP.DATERP
NOTES This instruction reads clock data and stores those to a specified device even if a wrong clock
data is set to the CPU module (example: Feb. 30th). When setting clock data with the DATEWR
instruction or witha programming tool, make sure to set a correct data.
Time error of reading a clock data of millisecond is a maximum of 2 ms. (Difference between the
data memorized by clock element inside of the CPU module and the data read by this function.)
Specifying digit for the bit device can be used only when the following two conditions are met:
Digit specification: K4
Head of device: multiple of 16
When the above conditions are not met, INSTRCT CODE ERR. (Error code 4004) will occur.
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 1) 1)
Devices UsableDevices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register
Register Module Zn Constant Other
Bit Word Bit Word U\G
s1 — — — — — — —
s2 — — — — — — —
d — — — — — — —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
4
S.DATE+ s1 s2 d
SP.DATE+ s1 s2 d
7 – 524
Expansion clock instructions S.DATE+, SP.DATE+
Day of the
Clock Data Year Month Day Hour Minute Second Millisecond
week
Input range — — — 0–23 0–59 0–59 — 0–999
Devices (s1)+0 (s1)+1 (s1)+2 (s1)+4
— — — —
(Array_s1[0]) (Array_s1[1]) (Array_s1[2]) (Array_s1[4])
Devices (s2)+0 (s2)+1 (s2)+2 (s2)+4
— — — —
(Array_s2[0]) (Array_s2[1]) (Array_s2[2]) (Array_s2[4])
Devices d+0 d+1 d+2 d+4
— — — —
(Array_d[0]) (Array_d[1]) (Array_d[2]) (Array_d[4])
⇒
(s1)+1 Minute (s2)+1 Minute d+1 Minute
(s1)+2 Second + (s2)+2 Second d+2 Second
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond (s2)+4 Millisecond d+4 Millisecond
For example, adding the time 7:48:10:500 to 6:32:40:875 would result in the following opera-
tion:
⇒
(s1)+1 Minute: 32 (s2)+1 Minute: 48 d+1 Minute: 20
(s1)+2 Second: 40 + (s2)+2 Second: 10 d+2 Second: 51
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond: 875 (s2)+4 Millisecond: 500 d+4 Millisecond: 375
If the addition result of clock data exceeds 24 hours, 24 hours are subtracted automatically to
achieve a correct time value.
For example, when the time 20:20:20:500 is added to 14:20:30:875, the result is not
34:40:51:375, but 10:40:51:375.
⇒
(s1)+1 Minute: 20 (s2)+1 Minute: 20 d+1 Minute: 40
(s1)+2 Second: 30 + (s2)+2 Second: 20 d+2 Second: 51
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond: 875 (s2)+4 Millisecond: 500 d+4 Millisecond: 375
NOTE Devices s1+3, s2+3, and d+3 are not used for operation.
A clock data read by the S(P).DATERD instruction can be directly added.
d Hour
d+1 Minute
d+2 Second
When the clock data is read by the S(P).DATERD instruction, day of week is inserted between
"second" and "millisecond". If the S(P).DATE+ instruction is used to add the clock data, the data
can be directly used for addition since it does not perform the calculation for the day of a week.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data in s1 and s2 exceed the input range.
(Error code 4100)
● The device specified by s1, s2 or d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
NOTE Specifying digit for the bit device can be used only when the following two conditions are met:
Digit specification: K4
Head of device: multiple of 16
When the above conditions are not met, INSTRCT CODE ERR. (Error code 4004) will occur.
7 – 526
Expansion clock instructions S.DATE+, SP.DATE+
Program SP.DATE+P
Example
With leading edge from X20, the following program adds 1 hour to the clock data read from the
clock element, and stores the results into the area starting from D100.
Clock element ⇒ D0
D1
05
5
Year
Month
D2 17 Day
}
D3 10 Hour
D4 23 Minute Time data
D5 41 Second
D6 2 Day of week
⇒
D4 Minute: 23 D11 Minute: 0 D101 Minute: 23
D5 Second: 41 + D12 Second: 0 D102 Second: 41
D6 2 (Tuesday) D13 — D103 —
D7 Millisecond: 100 D14 Millisecond: 0 D104 Millisecond: 100
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 1) 1)
1 High performance model QCPU, Process CPU, Redundant CPU with serial number (first five digits) of
"07032" or higher
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
4
S.DATE– s1 s2 d
SP.DATE– s1 s2 d
6
Variables Data Type
Set Data Meaning
MELSEC IEC
s1 First number of device storing clock data to be subtracted from
Array [0..4]
s2 First number of device storing clock data to be subtracted BIN 16-bit
of ANY16
d First number of device storing the clock data of the subtraction result
7 – 528
Expansion clock instructions S.DATE-, SP.DATE-
⇒
(s1)+1 Minute (s2)+1 Minute d+1 Minute
(s1)+2 Second – (s2)+2 Second d+2 Second
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond (s2)+4 Millisecond d+4 Millisecond
For example, subtracting the clock time 3:50:10:500 from 10:40:20:875 would result in the fol-
lowing operation:
⇒
(s1)+1 Minute: 40 (s2)+1 Minute: 50 d+1 Minute: 50
(s1)+2 Second: 20 – (s2)+2 Second: 10 d+2 Second: 10
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond: 875 (s2)+4 Millisecond: 500 d+4 Millisecond: 375
If the subtraction result of clock data becomes negative, 24 hours are added automatically to
achieve a correct time value.
For example, when the clock time 10:42:12:500 is subtracted from 4:50:32:875, the result is
not -6:8:20:375, but 18:8:20:375.
⇒
(s1)+1 Minute: 50 (s2)+1 Minute: 42 d+1 Minute: 8
(s1)+2 Second: 32 – (s2)+2 Second: 12 d+2 Second: 20
(s1)+3 — (s2)+3 — d+3 —
(s1)+4 Millisecond: 875 (s2)+4 Millisecond: 500 d+4 Millisecond: 375
NOTE Devices (s1)+3, (s2)+3, and d+3 are not used for operation.
A clock data read by the S(P).DATERD instruction can be directly subtracted.
d Hour
d+1 Minute
d+2 Second
When the clock data is read by the S(P).DATERD instruction, day of week is inserted between
"second" and "millisecond". If the S(P).DATE– instruction is used to read the clock data, the data
can be directly used for subtraction since it does not perform the calculation for the day of a
week.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The clock data in (s1)+0 through (s1)+4 ((Array_s1[0] through Array_s1[4])) and (s2)+0
through (s2)+4 ((Array_s2[0] through Array_s2[4])) exceed the input range.
(Error code 4100)
● The device specified by s1, s2 or d exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU)
(Error code 4101)
NOTE Specifying digit for the bit device can be used only when the following two conditions are met:
Digit specification: K4
Head of device: multiple of 16
When the above conditions are not met, INSTRCT CODE ERR. (Error code 4004) will occur.
7 – 530
Expansion clock instructions S.DATE-, SP.DATE-
Program SP.DATE–
Example
With leading edge from X1C, the following program subtracts the time data stored in the area
starting from D10 from the clock data read from the clock element, and stores the results into
the area starting from D100.
1)
2)
1
Reads out the clock element data to D0 or later.
2 Sets the time to D10 or later.
Clock element ⇒ D0
D1
05
2
Year
Month
D2 23 Day
}
D3 8 Hour
D4 42 Minute Time data
D5 1 Second
D6 3 Day of week
⇒
D4 Minute: 42 D11 Minute: 40 D101 Minute: 1
D5 Second: 1 – D12 Second: 10 D102 Second: 51
D6 3 (Wednesday) D13 — D103 —
D7 Millisecond: 997 D14 Millisecond: 500 D104 Millisecond: 497
8:42:1:997 – 10:40:10:500 = –2:1:51:497
(+24) = 22:1:51:497
NOTE Please check, whether these functions are available and supported by your version of the GX
IEC Developer.
Processing when the execution type is converted with the program control instruction is as fol-
lows:
NOTE Once the fixed scan execution type program is changed to another execution type, it cannot be
returned to the fixed scan execution type.
7 – 532
Program control instructions S.DATE-, SP.DATE-
As program execution type conversions by PSCAN and PSTOP instructions occur at the END
processing, such conversions are impossible during program execution.
When different execution types have been set for the same program in the same scan, the exe-
cution type will be that specified by the execution switching command that was executed last.
1 The order of "GHI" and "DEF" program execution is determined by the program settings parameters.
Switching from the fixed scan execution type program to the execution type program is per-
formed in the following timing.
● For the Universal model QCPU, LCPU
The execution type is changed when the execution of the fixed scan execution type is stopped
at the END processing after the program control instruction execution.
● Basic model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU
The execution of the fixed scan execution type is stopped at the execution of the program
control instruction, and the execution type is changed at the END processing.
When the POFF instruction is executed, the output is turned OFF at the next scan, and the exe-
cution type will be the stand-by type at the second next scan and later.
If executed prior to the output OFF processing, the program control instruction is ignored.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 534
Program control instructions PSTOP, PSTOPP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified program file does not exist.
(Error code 2410)
● The program type of the file name specified by s is an SFC program.
(Error code 2412)
● The file name storage destination device of s exceeds the range of the corresponding device.
(Error code 4101)
Program PSTOPP
Example
With leading edge from X0, the following program sets a program named "ABC" into the stand-
by mode.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 536
Program control instructions POFF, POFFP
Functions Setting a program into the stand-by mode including reset of the outputs
POFF Switch instruction for the stand-by mode with reset outputs
The POFF instruction sets the program specified by the device in s into the stand-by mode and
resets the outputs addressed by the program.
● Scan execution type:
Turns OFF outputs at the next scan (Non-execution processing). Programs are set as the
stand-by type after the subsequent scan.
● Low speed execution type:
Stops the execution of the low speed execution type program and turns OFF outputs at the
next scan. Programs are set as the stand-by type after the subsequent scan.
Only program files stored in the internal memory (drive 0) can be set into the stand-by mode.
The POFF instruction is even given priority if the execution mode is specified via parameters.
The file extension .QPG is not needed to be entered for file specification since the type of file
is recognized automatically.
NOTE Non-execution processing is identical to the processing that is conducted when the condition
contacts for the individual coil instructions are in the OFF state.
The operation results for the individual coil instructions following non-execution processing will
be as follows, regardless of the ON/OFF status of the individual contacts:
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified program file does not exist.
(Error code 2410)
● The file name storage destination device of s exceeds the range of the corresponding device.
(Error code 4101)
Program POFFP
Example
With leading edge from X0, the following program sets a program named "ABC" into the stand-
by mode. First in this mode all outputs, addressed by the program "ABC" are reset to the same
status as if the execution conditions for the instructions addressing them were not set. Then
the program "ABC" enters the stand-by mode.
7 – 538
Program control instructions PSCAN, PSCANP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified program file does not exist.
(Error code 2410)
● The file name storage destination device of s exceeds the range of the corresponding device.
(Error code 4101)
● The specified file name is an SFC program, and the SFC program for the other file name
has been already started. (Dual activation error of the SFC program)
(For the Universal model QCPU, LCPU: Error code 4131)
(For the High Performance model QCPU, Process CPU, Redundant CPU: Error code 2504)
Program PSCANP
Example
With leading edge from X0, the following program sets a program named "ABC" into the scan
execution mode.
7 – 540
Program control instructions PLOW, PLOWP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified program file does not exist.
(Error code 2410)
● The program file contains a CHK instruction.
(Error code 4235)
Program PLOWP
Example
With leading edge from X0, the following program sets a program named "ABC" into the low-
speed execution mode.
7 – 542
Program control instructions PCHK
7.17.5 PCHK
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
LDPCHK PCHK s
ANDPCHK PCHK s
ORPCHK
PCHK s
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified program file does not exist.
(Error code 2410)
Program PCHK
Example
Program that keeps Y10 ON when the program file "ABC.QPG" is being executed.
Execution
Non-execution
7 – 544
Program control instructions PCHK
NOTE The PCHK instruction is in conduction when the program of the specified file name (target pro-
gram) is in execution, and the instruction is in non-conduction when the program is in non-exe-
cution.
When the target program is set to non-execution (stand-by type) with the POFF instruction, the
PCHK instruction is in conduction while the non-execution processing of the target program is
being performed. At the END processing of the scan where the non-execution processing is
completed, the target program is put into non-execution (stand-by type), and the PCHK instruc-
tion is brought into non-conduction.
Therefore, note that if the PCHK instruction is executed for the program where the non-execution
processing has been completed by the POFF instruction, the PCHK instruction may be brought
into conduction.
The following chart shows the operation performed when program A executes the POFF in-
struction of program B and program C executes the PCHK instruction of program B with the pro-
grams being executed in order of program A, program B and program C.
NOTE The instructions ADRSET and ADRSETP are not supported by the GX IEC Developer.
7 – 546
Other convenient instructions WDT, WDTP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
1Step 0
The WDT instruction can be set any number of times within one program scan. Nevertheless,
for programming remind that the outputs are not reset (0) at once.
The values of the program scan time stored in the registers are not cleared via the WDT
instruction. Therefore, the stored values may be greater than the WDT values set through
parameters.
7 – 548
Other convenient instructions DUTY
7.18.2 DUTY
CPU High
Basic Process Redundant Universal LCPU
Performance
n2
d 1) — — — — — — — —
1 SM420 through SM424 and SM430 through SM434
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
1
Number of program scans with execution
2 Number of program scans without execution
Programs being executed once per program scan apply the relays SM420 through SM424.
Low-speed execution programs apply the relays SM430 through SM434.
At the beginning of the execution (initializing) the relays (SM420 through SM424 and SM430
through SM434) are reset.
If the value in n1 = 0, the relays remain reset.
If the value in n2 = 0 and the value in n1 is greater than 0, the relays will be and remain set.
The values in n1, n2, and d are set when the DUTY instruction is invoked. The scan pulse
(relay) is set ON or OFF when the END instruction is reached.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by d is not from SM420 to SM424 or SM430 to SM434.
(Error code 4101)
● The values in n1 and n2 are less than 0.
(Error code 4100)
7 – 550
Other convenient instructions DUTY
Program DUTY
Example
With leading edge from X0, the following program sets SM420 for one program scan and resets
it for 3 program scans. This operations are repeated as long as the program is executed (see
NOTE below).
1
One program scan ON
2
Three program scans OFF
NOTE After the execution condition is reset (X0 = OFF) the output of scan pulse of the DUTY instruction
and the cyclic setting / resetting of the specified relay are proceeded. In order to stop the con-
tinued output of scan pulses the following program part has to be inserted.
7.18.3 TIMCHK
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Basic model QCPU: The first five digits of the serial No. are "04122" or higher.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
TIMCHK s1 s2 d
7 – 552
Other convenient instructions TIMCHK
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device that cannot be specified has been specified.
(Error code 4100)
Program TIMCHK
Example
Program where the ON time of X0 is set to 5 s, the current value storage device to D0, and the
device that will turn ON at time-out to Y10.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 554
Other convenient instructions ZRRDB, ZRRDBP
ZR0
2
ZR32767
ZR32768
3
b15 b8b7 b0
n 1 d 00H
ZR65535 5
ZR65536
4
1
Serial byte number
2
File register area for block 0
3 File register area for block 1
4
File register area for block 2
5 Read byte
The assignment of file register numbers to the according serial byte numbers is shown below:
1
Storage area for even byte numbers (here: address 0 through address 5006)
2
Storage area for odd byte numbers (here: address 1 through address 5007)
If the byte number 23560 is specified, the lower byte of the file register ZR11780 is read.
1 Address
2
Storage
If the byte number 43257 is specified, the lower byte of the file register ZR21628 is read.
1
Address
2
Storage
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of device (serial byte address) exceeds the relevant storage device range.
(Error code 4101)
7 – 556
Other convenient instructions ZRRDB, ZRRDBP
Program ZRRDBP
Example
With leading edge from X0, the following program reads the lower byte of file registers R16000
(byte number 32000) and the upper byte of the file register R16003 (byte number 32007). The
bytes are stored in D100 and D101.
1
Serial byte number 32000 (lower byte in file register R16000)
2
Serial byte number 32007 (upper byte in file register R16003)
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 558
Other convenient instructions ZRWRB, ZRWRBP
1
Serial byte number
2
Address
3 File register area for block 0
4
File register area for block 1
5 File register area for block 2
6 Write data
7
This byte is ignored
8 Byte to be written
The assignment of file register numbers to the according serial byte numbers is shown below:
1 Storage area for even byte numbers (here: address 0 through address 5006)
2 Storage area for odd byte numbers (here: address 1 through address 5007)
If the byte number 22340 is specified, the lower byte of the device specified by s is written to
the lower byte of the file register ZR11170.
1 Address
2
Write byte
3 This byte is ignored.
If the byte number 43257 is specified, the lower byte of the device specified by s is written to
the upper byte of the file register ZR21628.
1
Address
2
Write byte
3
This byte is ignored.
Operation In the following case an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The number of device (serial byte number) specified by n exceeds the relevant storage
device range.
(Error code 4101)
7 – 560
Other convenient instructions ZRWRB, ZRWRBP
Program ZRWRBP
Example
With leading edge from X0, the following program writes the contents of the lower bytes of the
registers D100 and D101 to the lower byte of the file register R16000 (byte number 32000) and
to the upper byte of the file register R16003 (byte number 32007).
1
Serial byte number 32000 (lower byte of file register R16000)
2
Serial byte number 32007 (upper byte of file register R16003)
3 These bytes are ignored.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
NOTE The instructions ADRSET and ADRSETP are not supported by the GX IEC Developer.
GX Works2
7 – 562
Other convenient instructions ADRSET, ADRSETP
7.18.7 KEY
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 564
Other convenient instructions KEY
2
n 1
S
S+1
S+2
S+3 "0" (30H) - "9" (39H)
b15--b12 b11----b8 b7-----b4 b3-----b0 S+4 "A" (41H) - "F" (46H)
d1 3 S+5
S+6
(d1)+1 5 4 S+7
(d1)+2 S+8 8
7 6
1
Number of values to be entered
2
Input module
3
Number of entered values
4 8th entered character
6
4th entered character
7 1st entered character
8 Strobe signal
In the following diagram n is specified 5 and the values 1 (31H) through 5 (35H) are entered at
the inputs X10 through X18 of the input module.
1
Input module
2
Strobe signal
The ASCII characters entered at the inputs (X) specified in s+0 (Array_s[0]) through s+7
(Array_s[7]) are encoded in 8-bit binary format as illustrated below:
1 Input module
After the input of an ASCII character at s+0 (Array_s[0]) through s+7 (Array_s[7]) the strobe
signal (s+8, Array_s[8]) is set, to link the input data internally. The time period the strobe signal
remains set or reset must exceed one program scan time to ensure accurate linking of input
data.
6
Reading "1"
7 Reading "2"
8
Reading "3"
9
Reading "4"
The KEY instruction can only be executed with the execution condition set. The execution con-
dition must remain set until the input of the number of characters specified by n is completed.
7 – 566
Other convenient instructions KEY
The number of entered values is stored in (d1)+0 (Array_d[0]). The entered ASCII characters
are actually stored in the devices specified in (d1)+1 (Array_d[1]) and (d1)+2 (Array_d[2]) and
(d1)+2 (Array_d[2]) as hexadecimal binary values; i.e. there are 4 bits per character supplied.
The hexadecimal binary values of the characters 0H through FH range from "0000" through
"1111".
1
Execution condition for the KEY instruction
2
Strobe signal (s+8, Array_s[8])
3
ASCII input data (s+0 through s+7, Array_s[0] through Array_s[7])
1
Execution condition for the KEY instruction
2
Strobe signal (s+8, Array_s[8])
3 ASCII input data (s+0 through s+7, Array_s[0] through Array_s[7])
4
Input of characters completed (the device specified by d2 is set)
Prior to a new input of characters the contents of the devices specified in (d1)+0 (Array_d[0])
through (d1)+2 (Array_d[2]) have to be cleared and the device specified by d2 has to be reset;
otherwise a new input of characters is not possible.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The device specified by s is not an input (X).
(Error code 4100)
● The number of characters specified by n does not range within 1 and 8.
(Error code 4100)
7 – 568
Other convenient instructions KEY
Program KEY
Example
The following program enables key input of up to 5 numerical values via the inputs X20
(var_X20[0]) through X27 (var_X20[7]).
The values are stored in the registers D1 (var_D0[1]) and D2 (var_D0[2]) binary coded in hex-
adecimal format. The number of values already entered is stored in D0 (var_D0[0]).
Prior to the execution of the KEY instruction the registers D0 (var_D0[0]) through D2
(var_D0[2]) are cleared and the number of input values (5) is stored. After execution of the KEY
instruction the relay M10 (input completed) is reset. The strobe signal is supplied at the inputs
X28 (var_X20[8]).
1
Numerical key pad
2 Input module
3
Strobe signal
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
, GX Works2
7 – 570
Other convenient instructions ZPUSH, ZPUSHP, ZPOP, ZPOPP
d+0 1
d+1 Z0
d+2 Z1
3
d+10 Z9
d+11
2 1
Number of saved register contents
d+15
2Five
d+16 Z0 data words (internal system use)
d+17 Z1 4 3
First nesting level (15 data words max.)
4
Second nesting level
d+0 1
d+1 Z0
d+2 Z1
3
d+16 Z15
d+17
2 1
Number of saved register contents
d+18
2
d+19 Z0 Two data words (internal system use)
d+20 Z1 4 3
First nesting level (18 data words max.)
4
Second nesting level
d+0 1
d+1 Z0
d+2 Z1
3
d+20 Z19
d+21
2 1Number of saved register contents
d+22
2Two data words (internal system use)
d+23 Z0
d+24 Z1 4 3
First nesting level (22 data words max.)
4Second nesting level
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The storage area specified from d on exceeds the relevant storage device range.
(Error code 4101)
● The content of the device specified in d+0 (number of saved registers is 0 in the ZPOP(P)
instruction.).
(Error code 4100)
7 – 572
Other convenient instructions ZPUSH, ZPUSHP, ZPOP, ZPOPP
Program ZPUSH/ZPOP
Example
The following program saves the contents of the index register to the fields following D0 before
calling the subroutine following P0 that uses the index register.
CPU High
Basic Process Redundant Universal LCPU
Performance
, GX Works2
7 – 574
Other convenient instructions UNIRD, UNIRDP
NOTE The value of n1 is consists of the higher three digits of the head I/O number of the slot from
which the module information is read. The head I/O number is expressed in 4 digits in hexa-
decimal notation.
QCPU System Q
MELSEC
Q68 QY41
1) CPU QX10 QX10 QX10 QX10 QY10 QY10
ADV P
3)
LCPU
LCPU
(L26CPU-BT)
0000H 0010H 0030H 0040H 0050H 0060H 0070H 0090H 00A0H 00B0H 2)
6)
5 Built-in CC-Link
6
Head address in n1: K6 or H6
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 bit
Individual module information
Meaning
Bit Item
QCPU LCPU
0 000: 16 001: 32
010: 48 011: 64
1 Number of I/O points
100: 128 101: 256
2 110: 512 111: 1024
3 000: Input module 000: Input module
001: Output module 001: Output module
4 Module type
010: l/O mixed module 011: Intelligent function module
5 011: Intelligent function module 111: CPU Built-in I/O
External power supply
1: External power supply is connected
6 status Fixed to 0
0: External power supply is not connected
(For future expansion)
1: Blown fuse
7 Fuse status Fixed to 0
0: Normal, no blown fuse
1: Module information on the extension base
Online module unit is tried to be read during online
replacement status/ module change or from the CPU module
8 of standby system in the redundant Fixed to 0
execution from the
standby system system.1)
0: Other than above
Light/medium
9 1: Light/medium error has occurred 0: Normal
error status
10 00: No module error 01: Light error
Module error status
11 10: Medium error 11: Serious error
7 – 576
Other convenient instructions UNIRD, UNIRDP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● High Performance model QCPU, Process CPU, Redundant CPU and Universal model
QCPU, L26CPU-BT:
When n1 is other than 0 to FFH. (Error code 4100)
When n2 is other than 0 to 256. (Error code 4100)
When a total of n1 and n2 is greater than 256. (Error code 4100)
● Q00/Q01CPU/L02CPU:
When n1 is other than 0 to 3FH. (Error code 4100)
When n2 is other than 0 to 64. (Error code 4100)
When a total of n1 and n2 is greater than 64. (Error code 4100)
● Q00JCPU:
When n1 is other than 0 to FH. (Error code 4100)
When n2 is other than 0 to 16. (Error code 4100)
When n1 and n2 is greater than 16. (Error code 4100)
● MELSEC System Q CPU/LCPU:
When the number of points specified by n2 for the devices specified in (d) and up is outside
the range of that device.
(Error code 4101)
Program UNIRD
Example
The following program stores the informations of the modules with the head I/O numbers 10H
through 20H to D0 and D1, when X10 is turned ON.
Device
~ ~
~ ~
In this program example the module information is stored in D0 and D1. Readout results can be:
● For a 32-point intelligent function module of the System Q. With a 48- or 64-point module
the same contents as stored in D1 is stored in D2 or D2 and D3 respectively.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D0
32-point module
Vacant
Module installed
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D1
7 – 578
Other convenient instructions UNIRD, UNIRDP
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D0
● Module information on the extension base unit is tried to be read from the standby system
of the redundant system in separate mode:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
D0
32-point module
Intelligent function module
(Vacant)
(Vacant)
(Vacant)
No module errors
D1
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1 Universal model QCPU: The serial number (first five digits) is "11043" or higher.
, GX Works2 3
TYPERD n d
4
TYPERDP n d
7 – 580
Other convenient instructions TYPERD, TYPERDP
Input module
Output module
Supported
Not supported
Specify the start I/O number of a module whose model name is to be read by "n" as follows: •
Specify the value obtained by dividing the start I/O number of the target module by 16.
Q68 QY41
1) CPU QX10 QX10 QX10 QX10 ADV P QY10 QY10
3)
2)
LCPU (L26CPU-BT)
0000H 0010H 0030H 0040H 0050H 0060H 0070H 0090H 00A0H 00B0H 4)
8)
7)
1
Power supply module
2
When the target module is a CPU module itself, specify the start I/O number by H3E0
3
Specify the start I/O number by K3 or H3
4
Head I/O number configured in the I/O assignment setting
5
Built-in I/0
6
Built-in CC-Link
7 Specify H3E0 to read the module name of the CPU module
8
Specify the start I/O number by K6 or H6
NOTE On the LCPU, if the built-in I/O or first I/O on the built-in CC-Link is specified, then the model
name of the CPU module is read.
3)
1
Power supply module
2
Empty
3
Specify the start I/O number by K1 or H1
4 Start I/O number configured in the I/O assignment setting
2)
1
Power supply module
2
Specify the start I/O number by H3E3
3
Start I/O number configured in the I/O assignment setting
Or, the model name can be read by specifying the start I/O number of a module controlled
by another CPU.
7 – 582
Other convenient instructions TYPERD, TYPERDP
d+0 stores the execution result of the instruction and d+1 to d+9 store the module model name.
A value stored in d is as follows:
● When the model name has been read from the target module (example: QJ71GP21-SX)
modul
bit 15 to 8 7 to 0
(indicating that the model name that has been
d+0 0 Stores 0 read from the target module is stored)
d+3 50H (P) 47H (G) Stores the model name that has been read from
d+4 31H (1) 32H (2) the target module (stored in ASCII)
The following table shows the examples of model names stored in d+1 to d+9.
Target Module Stored Model Name
CPU module Q06UDEHCPU
Intelligent function module QJ71GP21-SX
GOT GOT1000
● When the model name has not been written to the target module (example: QX40)
bit 15 to 8 7 to 0
(indicating that the character string (module
d+0 1 Stores 1
type and number of points) is stored)
d+1 4AH (N) 49H (I)
d+2 55H (U) 50H (P) Stores the character string consisting of module
type and number of points
Nine words are used
The following table shows the examples of character strings stored in d+1 to d+9.
1 The character strings consist of a string indicating the module type (for example: INPUT for the Input
module) and a string indicating the number of I/O-points (16, 32, 48, 64, 128, 256, 512, 1024).
● Others
– The specified slot is empty or the target module is during online module change.
– The specified value (n) is not the start I/O number.
– The specified value (n) is within the allowable setting range, but cannot be set in the I/O
assignment setting screen of the PLC parameter dialog box.
bit 15 to 8 7 to 0
d+0 –1 Stores –1 (indicating that model name is not stored)
d+1 00H 00H
d+2 00H 00H
Nine words are used
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The target module cannot be communicated due to a failure.
(Error code 2110)
● Devices by 10 words starting from the device specified by d exceed the device range.
(Error code 4101)
● The specified value n is not within the range from 00H to FFH and from 3E0 to 3E3H.
(Universal model QCPU)
(Error code 4101)
● The specified value n is not within the range from 00H to FFH and is not 3E0H.
(LCPU)
(Error code 4101)
7 – 584
Other convenient instructions TYPERD, TYPERDP
Program TYPERD
Example
The following program stores the model name of a module having the start I/O number 0020H
in the area starting from the device specified by when X0 is turned on.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX Works2
7 – 586
Other convenient instructions TRACE, TRACER
NOTE Please refer to the QnUCPU User's Manual (Function Explanation, Program Fundamentals) or
Qn(H)/QnPH/QnPRHCPU User's Manual (Function Explanation, Program Fundamentals) for
more informations about trace.
Please refer to the operating manuals for the GX Works2 and GX IEC Developer for the exe-
cution of the trace with peripheral devices.
7.18.12 SP.FWRITE
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 588
Other convenient instructions SP.FWRITE
00000001H to FFFFFFFEH:
From the specified address.
The unit for the value is
determined by word/byte unit
designation.
d0 BIN 16-bit
FFFFFFFFH:
Add to the ending of the file.
(d0)+4 00000000H
Location in file When data writing after CSV for- to User
(d0)+5 mat conversion is selected FFFFFFFFH
(d0 = 0100H):
For the High Performance model
QCPU with serial number „01111“
or lower (first 5 digits), always set
the beginning of the file
(00000000H).
For the High Performance model
QCPU with serial number „01112“
or higher (first 5 digits)/Process
CPU/Redundant CPU/Universal
model QCPU set the file position.
00000000H to FFFFFFFEH:
From the beginning of the file.
FFFFFFFFH:
Add to the ending of the file.
Sets the number of columns to
write data in CSV format.
Number of 0: No column setting.
(d0)+6 0 to 65535 User
columns Data is shown in a single row.
> 0: Data is shown in the specified
number of columns
Word/Byte 0: Word
(d0)+7 0, 1 User
designation 1: Byte
NOTES For QCPU: Only the ATA card drive (2) can be set as s0 (drive designation).
Note that when the Flash card is loaded, the SP.FWRITE instruction cannot be used to per-
form writing. The SRAM card, standard RAM or standard ROM drive cannot be set.
For LCPU: Only the SD memory card drive (2) can be set as s0 (drive designation).
The data written in CSV format is expressed as decimal value by the programming software.
For example, the character „A“ (41H) is written as 65. The available range is from -32768 to
32767.
For binary write, the word-specified file position setting range is 00000000H to 7FFFFFFFH
and FFFFFFFFH.
For the LCPU, this instruction cannot be executed while SM606 (SD memory card forced
disable instruction) is ON. Even if the instruction is attempted to be executed, the command
will be ignored.
7 – 590
Other convenient instructions SP.FWRITE
Control data
7 – 592
Other convenient instructions SP.FWRITE
D12 K0
D13 - Not used
D14 K0
D15 K0
D16 K0 Number of columns
D105 K50
D106 K100
0 , 10 , 20 , 30 , 40 , -50 , 100 CR LF
A B C D E F G
1 0 10 20 30 40 -50 100
When data is written after CSV format conversion and the designated number of columns is
other than „0“, the data is stored as table data with the specified number of columns in a CSV
format file. The following figure shows an example:
A B C
1 0 10 20
2 30 40 -50
3 100
7 – 594
Other convenient instructions SP.FWRITE
The following two figures are showing examples of writing data with the following CPU modu-
les:
– High Performance model QCPU with serial number „01112“ and higher (first 5 digits)/
Process CPU/Redundant CPU/Universal model QCPU
– LCPU
Settings::
CSV format, 4 columns, Word data, Location in file: 0H (a new file is created)
Number of
K6 D0
write points
K1 D1
Starting row 1 , 2 , 3 , 4 CR LF K2 D2
K3 D3
K4 D4
K5 D5
3 , 4 CR LF
K6 D6
K5 D7
Unless the “number of write points” is set to a integral multiple of
“Number of columns”, the last row will not be filled completly. K7 D8
K8 D9
K9 D10
K10 D11
K11 D12
K12 D13
Settings::
CSV format, 3 columns, Word data, Location in file: FFFFFFFFH (add data to the end of the file)
If, in the addition mode, the number of columns is changed from that in previous write, the column numbers will be shifted..
K6 D0
Column 1 Column 2 Column 3 Column 4 K1 D1
1 , 2 , 3 , 4 CR LF K2 D2
K3 D3
K4 D4
Since the last row is always ended K5 D5
with „CR LF“, addition normally 3 , 4 CR LF
starts at the beginning of a new row. K6 D6
Number of
K8 D7
write points
K7 D8
Starting row 7 , 8 , 9 CR LF K8 D9
K9 D10
K10 D11
10 , 11 , 12 CR LF K11 D12
K12 D13
K13 D14
Unless the “number of write points”
is set to a integral multiple of K14 D15
“Number of columns”, the last 13 , 14 CR LF
row will not be filled completly.
Method for calculating the file size (total number of bytes) when a CSV format file is
written to the ATA card
Total number of bytes = Total bytes excluding final line + bytes of final line
Number of bytes on a line = number of columns1) + 1 + total bytes of all data values on line2)
1
For all lines but the final line, this is the specified number of columns. The number of columns on the
final line depends on the number of columns specified via the amount of data written. It is calculated as
follows.
(1) The number of lines excluding the final line is calculated.
Number of lines excluding final line = Amount of data in write request
+ number of columns (remainders discarded)
(2) The number of columns in the final line is calculated.
Number of columns in final line = Amount of data in write request
- number of lines excluding final line
* number of columns)
2 The number of bytes for each data value is calculated as shown below.
Sign of Data Value Bytes per Data Value Byte Count Range Examples
1 to 5 (word specified) 12345: 5 bytes
Positive Number of digits
1 to 3 (byte specified) 67: 2 bytes
2 to 6 (word specified) -12345: 6 bytes
Negative Number of digits + 1
2 to 4 (byte specified) -67: 3 bytes
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The drive specified by s0 contains a medium other than an ATA card.
(for QCPU) (Error code 4100)
● The drive specified by s0 contains a medium other than the SD Memory card.
(for LCPU) (Error code 4100)
● Values specified in the areas for control data are out of the setting range.
(Error code 4100)
● The value „number of data to be written“ in (s2)+0 is out of the setting range, or is larger
than the data stored in the area beginning with (s2)+1.
(Error code 4101)
● Free space in the ATA card is insufficient.
(for QCPU) (Error code 4100)
● Free space in the SD Memory card is insufficient.
(for LCPU) (Error code 4100)
● No free space is found when an attempt is made to create a new file. (Error code 4100)
● An invalid device is designated. (Error code 4004)
● Access error occurred in the ATA card.
(for QCPU) (Error code 4100)
● Access error occurred in the SD Memory card.
(for LCPU) (Error code 4100)
● An unusable value is set for a file name (s1). (Error code 4100)
● The attribute of a file name (s1) is "read only". (Error code 4100)
● The device specified by d0 or d1 exceeds the range of the corresponding device.
(For the Universal model QCPU, LCPU) (Error code 4101)
7 – 596
Other convenient instructions SP.FWRITE
1)
2)
3)
4)
5)
6)
7)
1
Setting of the execution/completion type (In this example: binary data)
2
Setting of the location in the file (In this example: data is added)
3
Setting of the file name, the extension „.BIN“ is added automatically.
4 Number of data to be written.
5 The data (00H, 01H, 02H, and 03H) is moved to the control data area.
6
Normal completion display
7
Error completion display
1)
2)
3)
4)
5)
6)
7)
8)
0 , 1 , CR LF
, , Contents of the file to be written
2 3 CR LF
A B
1 0 1
2 2 3
1
Setting of the execution/completion type (In this example: CSV format)
2
Setting of the number of columns
3
Sets the data type specified
4 Setting of the file name, the extension „.CSV“ is added automatically.
6
The data (00H, 01H, 02H, and 03H) is moved to the control data area.
7
Normal completion display
8 Error completion display
7 – 598
Other convenient instructions SP.FREAD
7.18.13 SP.FREAD
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
s0 — — — — — —
d0 — — — — — — — —
s1 — — — — — — — —
d1 — — — — — — —
d2 1) 1) 1) — — — — — — —
1
Local devices and the devices designated for individual programs cannot be used.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
00000000H:
From the beginning of the file
00000001H to FFFFFFFCH:
From the specified address.
The unit for the value is
determined by word/byte unit
designation.
FFFFFFFDH:
Setting disabled
d0 BIN 16-bit
When data reading after CSV
format conversion is selected
(d0)+4 (d0 = 0100H): 00000000H
Location in file For the High Performance model to User
(d0)+5
QCPU with serial number "01111" FFFFFFFFH
or lower (first 5 digits), always set
the beginning of the file
(00000000H).
For the High Performance model
QCPU with serial number "01112"
or higher (first 5 digits) / Process
CPU / Redundant CPU / Universal
model QCPU/LCPU set the file
position.
00000000H:
From the beginning of the file.
00000001H: to FFFFFFFEH:
From the specified address.
FFFFFFFFH:
Read continues, starting at the
previous read position
Sets the number of columns for the
data to be read.
0: No column setting.
Number of col- Data is considered to be in a
(d0)+6 0 to 65535 User
umns single row.
> 0: Data is considered to be a table
with the specified number of
columns
Word/Byte desig- 0: Word
(d0)+7 0, 1 User
nation 1: Byte
7 – 600
Other convenient instructions SP.FREAD
NOTE For QCPU: Only the ATA card drive (2) can be set as s0 (drive designation).
Note that when the Flash card is loaded, the SP.FREAD instruction cannot be used to per-
form reading. The SRAM card, standard RAM or standard ROM drive cannot be set.
For LCPU: Only the SD memory card drive (2) can be set as s0 (drive designation).
The data written in CSV format is expressed as decimal value by the programming software.
For example, the character „A“ (41H) is written as 65. The available range is from -32768 to
32767.
For binary read, the word-specified file position setting range is 00000000H to 7FFFFFFFH.
For the LCPU, this instruction cannot be executed while SM606 (SD memory card forced
disable instruction) is ON. Even if the instruction is attempted to be executed, the command
will be ignored.
Control data
D0+6 -
Number of columns
D0+7 K0 Word/byte designation
D1+0 K3 H00
H11
Number of
actually D1+1 H33 22 H22
read data H33
7 – 602
Other convenient instructions SP.FREAD
A B C
1 Main/sub item Measured value
2 1 3
3 Temperature -21
, , Measured value CR LF
Length , 1 , 3 CR LF
Temperature , -21 , CR LF
D11 - Reserved
D14 K0
D15 K0
D22 H0000
Main/sub item D100 K0 Since this is not a numerical value, “0” is stored.
Data between , and , D101 K0 ““ Since this is not a numerical value, “0” is stored.
Measured value D102 K0 “Measured value” Since this is not a numerical value, “0” is stored.
Length D103 K0 “Length” Since this is not a numerical value, “0” is stored.
Temperature D106 K0 “ Temperature” Since this is not a numerical value, “0” is stored.
K-21 D107 K-21 -21 The numerical value is converted and stored.
Data between , and CR D108 K0 ““ Since this is not a numerical value, “0” is stored.
7 – 604
Other convenient instructions SP.FREAD
If the number of columns varies in each row, the data is also read by ignoring the rows. (EXCEL
does not create such files. This happens when a user modifies a CSV file.)
Control data
D11 - Reserved
D14 K0
D15 K0
D22 H0000
Main/sub item D100 K0 “Main/sub item” Since this is not a numerical value, “0” is stored.
Data between , and , D101 K0 ““ Since this is not a numerical value, “0” is stored.
Length D102 K0 “Length” Since this is not a numerical value, “0” is stored.
Read data
No data D103 K0 No data Since no element exists here, “0” is stored.
Temperature D104 K0 “Temperature” Since this is not a numerical value, “0” is stored.
K-21 D105 K-21 -21 The numerical value is converted and stored.
When data is read after CSV format conversion and the designated number of columns is other
than „0“, the data is expected to be in a table with the specified number of columns. The ele-
ments being outside the specified columns are ignored.
The following figure illustrates such a case:
A B C
1 Main/sub item Measured value
2 Length 1 3
3 Temperature -21
Length , 1 , 3 CR LF
Temperature , -21 , CR LF
Elements being outside of designated
columns are ignored .
Control data
D11 - Reserved
D14 K0
D15 K0
D22 H0000
Main/sub item D100 K0 “Main/sub item” Since this is not a numerical value, “0” is stored.
Data between , and , D101 K0 ““ Since this is not a numerical value, “0” is stored.
Length D102 K0 “Length” Since this is not a numerical value, “0” is stored.
Read data
1 D103 K0 1 The numerical value is converted and stored.
Temperature D104 K0 "Temperature” Since this is not a numerical value, “0” is stored.
K-21 D105 K-21 -21 The numerical value is converted and stored.
7 – 606
Other convenient instructions SP.FREAD
If the number of columns varies in each row, the elements ouside of the designated columns
are ignored and „0“ is added to the places where elements do not exist.
If the number of rows in the file is less than specified by (d0)+2 (Number of data to be read) „0“
is added to the places where rows do not exist.
D11 -
D14 K0
D15 K0
D22 H0000
Main/sub item D100 K0 “Main/sub item” Since this is not a numerical value, “0” is stored.
Data between , and , D101 K0 ““ Since this is not a numerical value, “0” is stored.
Length D102 K0 “Length” Since this is not a numerical value, “0” is stored.
Read data
No data D103 K0 No data Since no element exists, “0” is stored.
Temperature D104 K0 “Temperature” Since this is not a numerical value, “0” is stored.
K-21 D105 K-21 -21 The numerical value is converted and stored.
The following figures are to illustrate the case, when data is read separately several times from
the same file (continuation mode) using following CPU modules:
– High Performance model QCPU with serial number "01112" or higher (first 5 digits), Process
CPU, Redundant CPU or Universal model QCPU
– LCPU
Settings:
CSV format, 4 columns, word data, start of reading: at 2nd row, reading of 6 words and storing the data from D0 onwards
Settings:
CSV format, 4 columns, word data, start of reading: continue (FFFFFFFFH),
5 words are read and the data will be stored from D7 onward
K6 D0
K5 D1
Column 1 Column 2 Column 3 Column 4
K6 D2
Row 1 1 , 2 , 3 , 4 CR LF K7 D3
K8 D4
K9 D5
Row 2 5 , 6 , 7 , 8 CR LF K10 D6
K5 D7 Number of read data
Reading starts here K11 D8
K12 D9
Row 3 9 , 10 , 11 , 12 CR LF K13 D10
K14 D11
K15 D12
Row 4 13 , 14 , 15 , 16 CR LF K12 D13
Row 5 17 , 18 , 19 , 20 CR LF
When read is performed in the continuation mode, the settings for data format, number of co-
lumns and word/byte designation must not differ from the settings for the previous reading.
During reading in the continuation mode the execution of other SP.FREAD or SP.FWRITE in-
structions must be disabled.
7 – 608
Other convenient instructions SP.FREAD
When data is read after CSV format conversion, numerical values are read and converted as
follows:
Word Device
Numerical Values in CSV Format
Without Sign With Sign
-32768 32768 -32768
| | |
-1 65535 -1
0 0 0
1 1 1
| | |
32767 32767 32767
32768 32768 -32768
| | |
65535 65535 -1
Numerical values which are out of range and elements other than numerical values in the
object CSV file are converted into „0“.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The drive specified by s0 contains a medium other than an ATA card.
(for QCPU) (Error code 4100)
● The drive specified by s0 contains a medium other than the SD Memory card.
(for LCPU) (Error code 4100)
● Values specified in the areas for control data are out of the setting range (excluding d0+2).
(Error code 4100)
● The value „number of data to be read“ [(d0)+0] is out of the setting range.
(Error code 4101)
● An invalid device is designated. (Error code 4004)
● The file name specified by s1 does not exist in the designated drive. (Error code 2410)
● Size of read data exceeds the size of the reading device. (Error code 4101)
● When binary data is read, the number of data in the file is less than the size designated by
the number of data to read [(d0)+2].
(for High Performance model QCPU with serial number '01111' or lower (first 5 digits))
(Error code 4100)
● Access error occurred in the ATA card.
(for QCPU) (Error code 4100)
● Access error occurred in the SD Memory card.
(for LCPU) (Error code 4100)
● The device specified by d0 or d2 exceeds the range of the corresponding device.
(for Universal model QCPU, LCPU) (Error code 4101)
Program SP.FREAD
Example 1
When X10 is turned ON, four bytes of binary data are read from the beginning of the file
„ABCD.BIN“. The file „ABCD.BIN“ is stored at a memory card which is inserted in drive 2.
From D0 onward, eight points are reserved for control data.
100 bytes are reserved from D20 for the read data.
1)
2)
3)
4)
5)
6)
1
Setting of the execution/completion type
2 Setting of the number of data to read
3
Head address in the file (start reading at the beginning of the file)
4
Transfer of the file name to the control data
5 Normal completion display
6
Error completion display
7 – 610
Other convenient instructions SP.FREAD
Program SP.FREAD
Example 2
The following program reads data from the file „ABCD.CSV“, which is stored at the memory
card in drive 2 when X10 is turned ON. The contents of the file is two-column table data in CSV
format. The file contains numerical values only.
From D0 onward, eight points are reserved for control data.
For the read data, 100 bytes are reserved from D20.
1)
2)
3)
4)
5)
6)
1
Setting of the execution/completion type (CSV format for this example)
2
Setting of the number of data to read
3 Setting of the number of columns
4
Transfer of the file name to the control data
5
Normal completion display
6 Error completion display
7.18.14 SP.DEVST
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SP.DEVST n1 s n2 d
7 – 612
Other convenient instructions SP.DEVST
Standard ROM
Write
16-bit
offset
Number of +0
(n2) points +1
+2
Since the device data write position completion device (d+0) in the standard ROM automati-
cally turns ON at execution of the END instruction, which detects the completion of this instruc-
tion, and turns OFF with the END instruction of next scan, it is used as an execution completion
flag of this instruction.
When this instruction is completed in error, the error completion device (d+1) turns ON/ OFF
at the same timing with the completion device (d+0). This device is used as an error completion
flag of this instruction.
SM721 turns ON during execution of this instruction. When SM721 has already turned ON, this
instruction can not be executed (if executed, no processing is performed). When an error is
detected at execution of this instruction, the completion device (d+0), error completion device
(d+1) and SM721 do not turn ON.
NOTE The value written to the standard ROM is the value at execution of this instruction.
The standard ROM write count index (SD687 and SD688) is increased by the execution of the
SP.DEVST instruction. If the standard ROM write count index exceeds hundred thousand
times, FLASH ROM ERROR (error code 1610) occurs.
To prevent the number of ROM writes from increasing due to executing instruction carelessly,
set the specification of writing to standard ROM instruction count (SD695) to restrict the num-
ber of writes a day. Exceeding the number of writes (the default values are 36 times.) set cau-
ses OPERATION ERROR (error code 4113).
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The write offset specified at n1 is out of the device data storage file range.
(Error code 4100)
● The number of n2 points from the write offset specified at n1 is out of the device data storage
file range.
(Error code 4100)
● The range for the number of n2 points from the device s exceeds the corresponding device.
(Error code 4141)
● The device data storage file is not set at "PLC file" of PLC parameter.
(Error code 2410)
● The device specified by d exceeds the range of the corresponding device.
(Error code 4101)
Program SP.DEVST
Example
The following program writes the ten points of data from D100 to the device data storage file in
the standard ROM when M0 turns ON.
Ladder diagram
7 – 614
Other convenient instructions S.DEVLD, SP.DEVLD
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
S.DEVLD n1 d n2
Standard ROM
Device data
Head device Read offset (n1) storage file
number (d) Read offset of device
data storage file
Read
16-bit
offset
Number of +0
points (n2) +1
+2
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The address specified at n1 is out of the standard ROM range.
(Error code 4100)
● The number of n2 points from the address specified at n1 is out of the standard ROM range.
(Error code 4100)
● The range for the number of n2 points from the device d exceeds the corresponding device.
(Error code 4101)
● The device data storage file is not set at "PLC file" of PLC parameter.
(Error code 2410)
Program SP.DEVLD
Example
The program which reads the ten points of data from D100 from the device data storage file in
the standard ROM when M0 turns ON.
7 – 616
Other convenient instructions PLOADP
7.18.16 PLOADP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
When there are multiple open program numbers, the program designated by the PLOADP
instruction is added to the lowest number among them to be added. (The open program num-
bers are made when programs are deleted by the PUNLOADP instruction.) When programs
No. 2 and 4 are open, the new program is added as program No. 2.
7 – 618
Other convenient instructions PLOADP
The PLC file settings of the loaded program are set as follows:
● File usage for each program: All usage of the file register, device initial value, comment, and
local device of the loaded program is set at „Use PLC file setting“.
However, if „Use local device“ is designated in the PLC file setting and programs are loaded,
an error occurs every time the number of executed programs exceeds the number of
parameter-set programs.
To use local devices in the loaded program, register a dummy file in the parameter, delete
the dummy file with the PUNLOADP instruction, then load the program with the PLOADP
instruction.
● I/O refresh setting:
The I/O refresh setting for the loaded program is „Disabled“ for both input and output.
Writing during RUN is not executed during the execution of the PLOADP instruction, but ece-
cuted after the instruction is completed. Conversely, the PUNLOADP instruction is not exe-
cuted during the writing during RUN, but executed after the writing during RUN is completed.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The file name does not exist at the drive number specified by s.
(Error code 2410)
● The drive number specified by s is invalid.
(Error code 4100)
● There is not enough memory to load the specified program in drive 0.
(Error code 2413)
● The number of programs shown below are already registered in the program memory.
(Error code 4101)
● The program number stored in SD720 is already used, or larger than the largest program
number shown below.
(Error code 4101)
Type of CPU Program Memory (Number of files) Largest Program Number
Q02(H) 28 28
Q06H 60 60
Q12H
Q25H 124 124
Q12PH
Q25PH
● A program file which has the same name as the program file to be loaded already exists.
(Error code 2410)
● The file size of the local devices cannot be reserved.
(Error code 2401)
Program PLOADP
Example
When M0 is ON in the following program, the program „ABCD.QPG“ is transferred from drive
4 to drive 0 and placed in standby status.
7 – 620
Other convenient instructions PUNLOADP
7.18.17 PUNLOADP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 622
Other convenient instructions PUNLOADP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The file name specified by s does not exist.
(Error code 2410)
● The program designated by s is not in standby status or is being executed.
(Error code 4101)
● The program specified by s is the only one in the program memory.
(Error code 4101)
7.18.18 PSWAPP
CPU High
Basic Process Redundant Universal LCPU
Performance
d 1) — — — — — — — —
1
Local devices cannot be used.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
7 – 624
Other convenient instructions PSWAPP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The drive number or the file specified by s1 or s2 does not exist. (Error code 2410)
● The drive number specified by s1 is invalid. (Error code 4100)
● There is not enough capacity in the program memory (drive 0) to load the specified program.
(Error code 2413)
● The program designated by s1 is not in standby status or is being executed.
(Error code 4101)
Instruction List
Ladder Diagram
7 – 626
Other convenient instructions RBMOV, RBMOVP
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
The transfer is possible even if there is an overlap between the source and destination devices.
For the transmission to the smaller devices, the data is transferred from s. For the transmission
to the larger device number, the data is transferred from s+(n-1).
However, as shown in the example below, when transferring data from R to ZR, or from ZR to
R, the range to be transferred (source) and the range of destination must not overlap.
– ZR transfer range:
((specified head No. of ZR) to
(specified head No. of ZR + the number of transfers -1))
– R transfer range:
((specified head No. of R + file register block No. x 32768) to
(specified head No. of R + file register block No. x 32768 + the number of transfers -1))
Example: Transfer ranges of ZR and R overlap when transferring 10000 points of data from ZR30000
(source) to R10 (block No.1 of the destination).
– ZR transfer range: (30000) to (30000+10000-1) = (30000) to (39999)
– R transfer range: (10+ (1 x 32768)) to (10+(1 x 32768) +10000-1)
= (32778) to (42777)
Therefore, the range 32778 to 39999 overlaps and data are not transferred correctly.
ZR30000 R32767
ZR39999 R10
7 – 628
Other convenient instructions RBMOV, RBMOVP
If s is a word device and d is a bit device, the object for the word device will be the number of
bits designated by the bit devive digit designation. For example, when „K1Y30“ is specified by
d, the lower four bits of the word device specified by s are the object.
If bit devices are specified by s and d, the number of digits must be the same for s and d.
NOTE The RBMOV and the RBMOVP instructions are useful to batch transfer a large quantity of file
register data with the QnHCPU/QnPHCPU/QnPRHCPU. With the QnUCPU, this instruction is
similar to the BMOV instruction.
The comparision of processing speed between RBMOV and BMOV instructions is as follows:
Transfer from file registers to internal devices/internal devices to file registers
Target 1 Word 1000 Words 10000 Words
memory
CPU Instruction where File
Register is Min. Max. Min. Max. Min. Max.
stored
Standard RAM 20.0 µs 91.0 µs 775.0 µs
RBMOV SRAM card 22.0 µs 305.0 µs 2900.0 µs
QnHCPU Flash card 1) 22.5 µs 405.0 µs 3950.0 µs
QnPHCPU
QnPRHCPU Standard RAM 7.5 µs 76.2 µs 720.0 µs
BMOV SRAM card 384.0 µs 3900.0 µs
8.0 µs
1) 418.0 µs 4250.0 µs
Flash card
Standard RAM 45.5 µs 215.0 µs 1850.0 µs
RBMOV SRAM card
49.5 µs 540.0 µs 5150.0 µs
Flash card 1)
QnCPU
Standard RAM 17.5 µs 177.0 µs 1700.0 µs
BMOV SRAM card 500.0 µs 5050.0 µs
18.0 µs
1) 572.0 µs 5800.0 µs
Flash card
Standard RAM 12.2 µs 34.9 µs 121.5 µs 145.1 µs 1111.5 µs 1135.1 µs
2) — — — — — —
RBMOV SRAM card
2) — — — — — —
Q00UCPU Flash card
Q01UCPU Standard RAM 7.3 µs 13.8 µs 116.5 µs 124.2 µs 1106.5 µs 1114.2 µs
2) — — — — — —
BMOV SRAM card
Flash card 2) — — — — — —
Standard RAM 9.4 µs 31.3 µs 118.5 µs 141.3 µs 1108.5 µs 1131.3 µs
RBMOV SRAM card 9.4 µs 31.4 µs 178.5 µs 201.3 µs 1708.5 µs 1731.3 µs
1) 9.4 µs 32.1 µs 278.5 µs 301.3 µs 2708.5 µs 2731.3 µs
Flash card
Q02UCPU
Standard RAM 5.0 µs 11.6 µs 114.5 µs 122.3 µs 1104.5 µs 1112.3 µs
BMOV SRAM card 5.1 µs 11.7 µs 174.5 µs 182.3 µs 1704.5 µs 1712.3 µs
1) 5.0 µs 11.6 µs 274.5 µs 282.3 µs 2704.5 µs 2712.3 µs
Flash card
Standard RAM 11.3 µs 16.8 µs 120.7 µs 127.1 µs 1110.7 µs 1117.1 µs
RBMOV SRAM card 11.2 µs 16.7 µs 180.7 µs 187.1 µs 1710.7 µs 1717.1 µs
1) 11.3 µs 16.8 µs 280.7 µs 287.1 µs 2710.7 µs 2717.1 µs
Flash card
Q03UD(E)CPU
Standard RAM 4.8 µs 6.6 µs 114.7 µs 117.1 µs 1104.7 µs 1107.1 µs
BMOV SRAM card 4.8 µs 6.6 µs 147.7 µs 177.1 µs 1704.7 µs 1707.1 µs
1) 4.8 µs 6.5 µs 274.7 µs 277.1 µs 2704.7 µs 2707.1 µs
Flash card
Standard RAM 9.2 µs 15.1 µs 61.0 µs 68.6 µs 531.0 µs 538.6 µs
Q04UD(E)HCPU
Q06UD(E)HCPU RBMOV SRAM card 9.4 µs 15.6 µs 165.0 µs 172.6 µs 1576.0 µs 1583.6 µs
Q10UD(E)HCPU 1)
Q13UD(E)HCPU Flash card 9.4 µs 15.7 µs 260.0 µs 267.6 µs 2526.0 µs 2533.6 µs
Q20UD(E)HCPU Standard RAM 4.1 µs 5.6 µs 56.0 µs 58.6 µs 526.0 µs 528.6 µs
Q26UD(E)HCPU
Q50UDEHCPU BMOV SRAM card 4.5 µs 6.1 µs 160.0 µs 162.6 µs 1571.0 µs 1573.6 µs
Q100UDEHCPU 1)
Flash card 4.3 µs 6.2 µs 255.0 µs 257.6 µs 2521.0 µs 2523.6 µs
1
When file registers are stored in the Flash card, no processing is performed for transfer from internal
devices to file registers.
2
Unusable for the Q00UCPU and Q01UCPU.
7 – 630
Other convenient instructions RBMOV, RBMOVP
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● The device range of „n“ points starting from s or d exceeds the available device.
(Error code 4101)
● The file register is not designated for both s and d.
(Error code 4101)
Program RBMOVP
Example 1
The following program transfers the lower four bits (b0 through b3) of data in D66 through D69
to the outputs Y30 through Y3F with the rising edge of SM402. The number of data (4 blocks)
is specified by n.
The bit patterns show the structure of bits before and after the transfer.
Instruction List
Ladder Diagram
1
These bits are ignored.
7 – 632
Other convenient instructions RBMOV, RBMOVP
Program RBMOVP
Example 2
With leading edge from SM402, the following program transfers data at X20 through X2F to
D100 through D103. The number of blocks (4) to be transferred is determined by the constant
K4.
The bit patterns show the structure of bits before and after the transfer.
Instruction List
Ladder Diagram
7.18.20 UMSG
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
UMSG s
7 – 634
Other convenient instructions UMSG
b15 b8 b7 b0
s 2nd char 1st char
s +1 4th char 3rd char
User message
s +2 6th char 5th char
Process A complete
s +3 8th char 7th char
s +4 10th char 9th char
Run UMSG
instruction
Message appears
00H on display unit
Indicates end
of string
See the MELSEC-L CPU Module User's Manual (Function Explanation, Program Fundamen-
tals) for details about the display unit.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error code
Errors is stored into SD0.
● When there is no NULL code (00H) within the range of the target device following the device
number specified by s.
(Error code 4101)
● When more than 128 single-byte characters are specified in the s string.
(Error code 4100)
Program UMSG
Example 1
This program displays the string stored after D10 on the display unit, when X10 is set to "on".
b15 b8 b7 b0
D10 4CH (i) 69H (L)
D11 6EH (e) 65H (n)
D12 2DH (A) 41H (-) User message
D13 20H (w) 77H ( )
Line-A working
D14 6FH (r) 72H (o)
D15 6BH (i) 69H (k)
Run UMSG
D16 6EH (g) 67H (n) instruction
D17 00H
Program UMSG
Example 2
This program displays "Line-A Working" on the display unit when M0 is set to "on".
"Line-A Working"
b15 b8 b7 b0
60H 82H
89H 83H
43H 83H
"Line-A working"
User message
93H 83H
40H 81H Line-A working
5EH 89H
5DH 93H Run UMSG
86H 92H instruction
0000 H
7 – 636
Other convenient instructions UMSG
Program UMSG
Example 3
This program displays "Line-B stop" on the display unit when X10 is set to "on", and clears the
message when X10 is set to "off".
"Line-B stop"
User message
Line-B stop
7 – 638
Categories of instructions
Category Meaning
Network refresh instructions Instructions for data refresh operations in network modules.
Read/Write routing information Read and write routing parameters (network number and station
number of relay station, station number of routing station).
MELSEC-Instruction MELSEC-Instruction
Function in in
MELSEC-Editor IEC-Editor
S.ZCOM
SP.ZCOM
Instructions for Network refresh
S.ZCOM
SP.ZCOM
The ZCOM instruction is used to perform refresh at any timing during execution of a sequence
program.
The targets of refresh performed by the ZCOM instruction are indicated below.
● Refresh of CC-Link IE (when refresh parameters are set) (QCPU only)
● Refresh of MELSECNET/H (when refresh parameters are set) (QCPU only)
● Auto refresh of CC-Link (when refresh device is set)
● Auto refresh of intelligent function module (when auto refresh is set)
NOTE In this section, instruction names are abbreviated as follows if not specified particularly:
S(P).ZCOM ==> ZCOM.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
8–2
Data refresh instructions S.ZCOM, SP.ZCOM
1
Execution of the ZCOM instruction
2
Data refresh
The ZCOM instruction does not perform the following processing.
● Communication processing between CPU module and programming tool
● Monitor processing of other station
● Read processing of buffer memory of other intelligent function module by serial communi-
cation module.
● Low-speed cyclic data transmission of MELSECNET/H
PLC to PLC network (Controller network in CC-Link IE controller network) (QCPU only)
In cases where the scan time of the sequence program of the host station exceeds the scan
time of the other stations, the ZCOM instruction ensures that the data from the other station is
incorporated properly.
The following figure shows an example for data communication without applying the ZCOM
instruction:
The following figure shows an example for data communication applying the ZCOM instruction:
1
Program of the control station
2
Program scan of the linked station
3
Program of the normal station
For details of the transmission delay time on the PLC to PLC network (Controller network in
CC-Link IE controller network), refer to the corresponding manuals of the network modules.
In cases where the scan time of the object station exceeds the scan time of the sequence pro-
gram, the ZCOM instruction does not improve data communication.
END
2)
1 Sequence program
2
Scan time of the object station
2)
Link refresh
3)
I/O refresh
4)
Auto refresh
5)
1
Program of the remote master station
2
Link scan
3
Remote I/O station network refresh
4
I/O module
5
Intelligent function module
8–4
Data refresh instructions S.ZCOM, SP.ZCOM
The following figure shows an example for data communication applying the ZCOM instruction:
Link
2)
refresh
Link refresh
3)
I/O refresh
4)
Auto refresh
5)
1
Program of the remote master station
2 Link scan
3
Remote I/O station network refresh
4
I/O module
5
Intelligent function module
The ZCOM instruction may be executed any times within a sequence program. However, note
that each execution increases the scan time of the sequence program by the execution time of
the data refresh.
Designating "Un" in the argument enables the access not only to network modules but also to
intelligent function modules. In this case, the automatic refresh is performed for the buffer
memory of the intelligent function module (replaces the FROM/TO instructions).
Only with the Universal model QCPU and LCPU, interruption of processing is enabled during
the execution of the ZCOM instruction. However, when refresh data are used in an interrupted
program, the data can split.
NOTES The ZCOM instruction cannot be used in a fixed cycle execution type program or interrupt pro-
gram.
The Redundant CPU has restrictions on use of the ZCOM instruction. Refer to the manual of the
redundant system for details.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The specified network number is not connected to the host station.
(Error code 4102)
● The module for the specified I/O number is not a network unit or link unit.
(Basic model QCPU, High Performance model QCPU, Process CPU, and Redundant CPU)
(Error code 2111)
● The module for the specified I/O number is not a network unit or link unit.
(Universal model QCPU, LCPU)
(Error code 4102)
NOTE To conduct only communication with peripheral device, use the COM instruction.
Program S.ZCOM
Example 1
While X0 is set, the following program refreshes data in the network module with the network
number 6.
Ladder Diagram
Program S.ZCOM
Example 2
While X0 is set, the following program refreshes data in the network module at the I/O numbers
X/Y30 through X/Y4F.
Ladder Diagram
8–6
Reading and writing routing information
NOTE In this section, instruction names are abbreviated as follows if not specified particularly:
S(P).RTREAD ==> RTREAD
S(P).RTWRITE ==> RTWRITE
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
8–8
Reading and writing routing information S.RTREAD, SP.RTREAD
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data value specified for n does not range within 1 and 239. (Error code 4100)
● The device specified by d exceeds the range of the corresponding device.
(For the Universal model QCPU only) (Error code 4101)
Program S.RTREAD
Example
While X0 is set, the following program reads the routing information from the network specified
by D0.
Ladder Diagram
D1 10 1 10 3
D2 3 2 10 2
D3 Dummy 3 10 1
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
8 – 10
Reading and writing routing information S.RTWRITE, SP.RTWRITE
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● The data value specified for n does not range within 1 and 239. (Error code 4100)
● The data specified by s exceed the relevant ranges. (Error code 4100)
● When the total number of routing information registered in the routing parameter of the
network parameters and routing information registered with the RTWRITE instruction
exceeds 64. (Error code 4100)
● The device specified by s exceeds the range of the corresponding device.
(For the Universal model QCPU only.) (Error code 4101)
Program S.RTWRITE
Example
While X0 is set, the following program writes the routing information stored in D1 through D3
as routing parameters to the network specified by D0.
Ladder Diagram
D1 20 1 20 1
D2 3 2 10 2
D3 Dummy 3 10 1
NOTE This program example will not run without variable definition in the header of the program
organization unit (POU). It would cause compiler or checker error messages. For details see
section 3.5.2 "Addressing of arrays and registers in the GX IEC Developer" of this manual.
8 – 12
9 Multiple CPU Dedicated Instructions
Following instructions are available for use in a multi-CPU system:
MELSEC-Instruction MELSEC-Instruction
Function in in
MELSEC-Editor IEC-Editor
S.TO TO_S_M
SP.TO TO_SP_M
Q02CPU, Q02HCPU,
High Performance model
Q06HCPU, Q12HCPU, —
QCPU
Q25HCPU
Q02PHCPU, Q06PHCPU,
Process CPU —
Q12PHCPU, Q25PHCPU
Redundant CPU Q12PRHCPU, Q25PRHCPU — —
Q00UJCPU — —
Q00UCPU, Q01UCPU,
Q02UCPU, Q03UDCPU,
Q04UDHCPU, Q06UDHCPU,
Q10UDHCPU, Q13UDHCPU,
Q20UDHCPU, Q26UDHCPU,
Universal model QCPU Q03UDECPU, Q04UDEHCPU,
Q06UDEHCPU,
Q10UDEHCPU,
Q13UDEHCPU,
Q20UDEHCPU,
Q26UDEHCPU,
Q50UDEHCPU,
Q100UDEHCPU
LCPU L02CPU, L26CPU-BT — —
Usable
— Not usable
Intelligent function
CPU No.1 CPU No. 2 module
[ SP.TO H3E0 n2 n3 n4 d ]
9–2
Writing to the CPU shared memory of host CPU
Intelligent function
CPU No.1 CPU No. 2 module
Writes data
[ TO H3E0 n2 s n3 ]
[ TO H0 n2 s n3 ]
NOTE Both of the S.TO and TO instructions can be used for the Basic model QCPU (Q00CPU or
Q01CPU) and Universal model QCPU to write data to the CPU shared memory. However, use
of the TO instruction is recommended, since use of S.TO instruction increases the number of
steps and processing time.
Refer to section 7.8.2 when writing to the buffer memory of the intelligent function module by the
TO instruction.
CPU High
Basic Process Redundant Universal LCPU
Performance
1) 2)
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
9–4
Writing to the CPU shared memory of host CPU S.TO, SP.TO
n3 n2
n4
1
Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
● CPU shared memory address of the High Performance model QCPU, Process CPU and
Universal model QCPU (Data cannot be written to the multiple CPU high speed transmission
area of the Universal model QCPU with the S(P).TO instruction)
1 Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
When the number of write points is entered in n4 as „0“, processing of the instruction is not
performed and the completion device, specified in d, does not turn on, either.
Only one S.TO instruction may be executed in one scan by each CPU. However, automatic
handshaking makes sure that only the instruction called first will be processed, if two or more
S.TO instructions are enabled simultaneously.
The number of data that can be written varies depending on the target CPU module.
CPU Module Number of Write Points
Basic model CPU 1–320
High Performance model QCPU, Process CPU 1–256
Universal model QCPU 1–2048
The head I/O number of the CPU is determined by the slot in which the CPU module is loaded.
Only the first 3 digits of the head I/O number are entered in n1.
Slot of the base unit CPU 0 1 2
Number of the CPU in multi-CPU system 1 2 3 4
Head I/O number 3E00 3E10 3E20 3E30
Contents of n1 3E0 3E1 3E2 3E3
NOTE Writing data to CPU shared memory can be performed using the intelligent function module de-
vice.
For intelligent function module device, refer to the QnUCPU User's Manual (Function Explana-
tion, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Explana-
tion, Program Fundamentals).
9–6
Writing to the CPU shared memory of host CPU S.TO, SP.TO
Operation In the following cases an operation error occurs, the error flag is set, and the corresponding error
Errors code is stored in SD0:
● When the specified data is outside the following range. (Error code 4101)
– The number of write points specified in n4 is outside the specified range of the setting data.
– The beginning of the CPU shared memory specified in n2 is larger than the CPU shared
memory adress range.
– The beginning of the CPU shared memory specified in n2 plus the number of write points
specified in n4 exceeds the CPU shared memory adress range.
– The first device number (n3) where the data to be written is stored plus the number of
write points specified in n4 exceeds the device range.
● When the host CPU operation information area, system area or host CPU refresh area is
specified to the CPU shared memory address (n2) of the write destination
(High Performance model QCPU, Process CPU) (Error code 4101)
(Basic model QCPU, Universal model QCPU) (Error code 4111)
● The value stored in n1 is not the head I/O-number of the CPU performing the S.TO
instruction.
(High Performance model QCPU, Process CPU) (Error code 2107)
(Basic model QCPU, Universal model QCPU) (Error code 4112)
● No CPU module is installed at the position specified by the head I/O number of the CPU
module. (Error code 2110)
● The number stored in n1 is other than a correct head I/O number (3E0H, 3E1H, 3E2H or
3E3H). (Error code 4100)
● The specified instruction is improper. (Error code 4002)
● The specified number of devices is wrong. (Error code 4003)
● An unusable device was specified. (Error code 4002)
Program SP.TO
Example
The data stored in CPU1 in the data registers D0 to D9 is written into the shared memory of
the same CPU, beginning at adress Adresse 800H when X0 turns ON.
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
n2 —
s — — — — —
n3 —
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
TO/DTO n1 n2 s n3
9–8
Writing to the CPU shared memory of host CPU TO, TOP, DTO, DTOP
s n2
n3
When a constant is designated to s, the instruction writes the same data (value designated to
s) to the area of n3 words starting from the specified CPU shared memory.
Following figure shows an example when the constant 5 is designated to s.
2)
1) 0
s 5
n2 5
5 3)
5
1 Constant
2
CPU shared memory of host CPU (n1)
3
n3 words (same data is written)
The head I/O number of the CPU is determined by the slot in which the CPU module is loaded.
Only the first 3 digits of the head I/O number are entered in n1.
Slot of the base unit CPU 0 1 2
Number of the CPU in multi-CPU system 1 2 3 4
Head I/O number 3E00 3E10 3E20 3E30
Contents of n1 3E0 3E1 3E2 3E3
NOTE Writing data to CPU shared memory can be performed using the intelligent function module
device.
For intelligent function module device, refer to the QnUCPU User's Manual (Function Explana-
tion, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Explana-
tion, Program Fundamentals).
1 Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
24335 (5F0FH)
1
Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
2 Data cannot be written to the multiple CPU high speed transmission area with the Q02UCPU
When the number of write points in n3 is „0“, processing of the instruction is not performed.
The number of data that can be written varies depending on the target CPU module.
CPU Module Number of Write Points
Basic model CPU 1–320
Universal model QCPU 1–14336
9 – 10
Writing to the CPU shared memory of host CPU TO, TOP, DTO, DTOP
s n2
n3x2
When a constant is designated to s, the instruction writes the same data (value designated to
s) to the area of n3x2 words starting from the specified CPU shared memory.
Following figure shows an example when the constant 5 is designated to s.
2)
1) 0
s 5
n2 5
5 3)
5
1
Constant
2
CPU shared memory of host CPU (n1)
3 n3x2 words (same data is written)
When the number of write points in n3 is „0“, processing of the instruction is not performed.
The number of data that can be written varies depending on the target CPU module.
CPU Module Number of Write Points
Basic model CPU 1–160
Universal model QCPU 1–7168
NOTE Writing data to CPU shared memory can be performed using the intelligent function module de-
vice.
For intelligent function module device, refer to the QnUCPU User's Manual (Function Explana-
tion, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function Explana-
tion, Program Fundamentals).
Operation In the following cases an operation error occurs, the error flag is set, and the corresponding error
Errors code is stored in SD0:
● When the specified data is outside the following range.
(Error code 4101)
– The number of write points specified in n3 is outside the specified range of the setting data.
– The beginning of the CPU shared memory specified in n2 plus the number of write points
specified in n3 exceeds the CPU shared memory adress range.
– The first device number (s) where the data to be written is stored plus the number of write
points specified in n3 exceeds the device range.
– When the head of CPU shared memory address (n2) of the write destination host CPU is
outside the write permitted area.
● When the head of CPU shared memory address (n2) of the write destination host CPU is
an invalid value. (Error code 4111)
● The value stored in n1 is not the head I/O-number of the host CPU. (Exclude the case when
the multiple CPU high speed transmisson area of other CPU is used.)
(Error code 4112)
● No CPU module is installed at the position specified by the head I/O number of the CPU
module.
(Error code 2110)
Program TOP
Example 1
The following program stores 10 points of data from D0 into address 10000 of the CPU shared
memory of CPU No. 1 when X0 is turned ON.
Program DTOP
Example 2
The following program stores 20 points of data from D0 into address 10000 of the CPU shared
memory of CPU No. 4 when X0 is turned ON.
9 – 12
Read from CPU shared memory of another station
Intelligent function
CPU No.1 CPU No. 2 module
Reads data
[ FROM H0 n1 n2 d n3]
NOTE Refer to section 7.8.1 for reading the buffer memory of the intelligent function module with the
FROM/DFRO instruction.
CPU High
Basic Performance Process Redundant Universal LCPU
1) 2)
1
Basic model QCPU:The first 5 digits of serial No is "04122" or higher.
2
High performance model QCPU: Function version B or later.
n2 — —
d — — — — — — —
n3 — —
GX IEC
1
GX Works2
9 – 14
Read from CPU shared memory of another station FROM, FROMP, DFRO, DFROP
d n2
n3
Reads the data
of n3 words
The head I/O number of the CPU is determined by the slot in which the CPU module is loaded.
Only the first 3 digits of the head I/O number are entered in n1.
Slot of the base unit CPU 0 1 2
Number of the CPU in multi-CPU system 1 2 3 4
Head I/O number 3E00 3E10 3E20 3E30
Contents of n1 3E0 3E1 3E2 3E3
511(1FFH)
1 Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
● CPU shared memory address of the High Performance model QCPU and Process CPU
4095 (0FFFH)
1 Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
4096 (1000H)
10000 (2710H) Unusable
24335 (5F0FH)
1
Usable as a user free area when auto refresh setting is not made. In addition, even when auto refresh
setting is made, the auto refresh send range or later is usable as a user free area.
2
Data cannot be read from the multiple CPU high speed transmission area with the Q02UCPU
Processing of the instruction is not performed when the number of read data is entered in n3
as „0“.
The number of data that can be read varies depending on the target CPU module.
CPU Module Number of Read Points
Basic model CPU 1–512
Universal model QCPU 1–14336
9 – 16
Read from CPU shared memory of another station FROM, FROMP, DFRO, DFROP
d n2
n3
Reads the data
of (n3x2)
words
Processing of the instruction is not performed when the number of read data is entered in n3
as „0“.
The number of data that can be read varies depending on the target CPU module.
CPU Module Number of Read Points
Basic model CPU 1–256
Universal model QCPU 1–7168
NOTES Reading data from CPU shared memory can be performed using the intelligent function module
device. (For intelligent function module device, refer to the QnUCPU User's Manual (Function
Explanation, Program Fundamentals) or Qn(H)/QnPH/QnPRHCPU User's Manual (Function
Explanation, Program Fundamentals).)
The QCPU provides automatic interlocks for the FROM and TO instructions.
Operation In the following cases an operation error occurs, the error flag (SM0) is set, and the correspon-
Errors ding error code is stored in SD0:
● When the specified data is outside the following range.
(Error code 4101)
– The beginning of the CPU shared memory adress (n2) from where read will be performed
is greater than the CPU shared memory range.
– The in n2 specified beginning of the CPU shared memory plus the number of read points
(n3) exceeds the CPU shared memory range.
– The read data storage device number (d) plus the number of read points (n3) is greater
than the specified device range.
● No CPU module exists in the position specified with the head I/O number in n1.
(Error code 2110)
● When the head of CPU shared memory address (n2) which performs reading is an invalid
value. (Error code 4101)
Program FROM
Example 1
When XO is set, 10 datawords are read from the shared memory of CPU No. 2, starting from
address 800H. The data is stored in the data registers D0 to D9 of the CPU processing the
FROM instruction.
Program DFROP
Example 2
When XO is set, 20 datawords are read from the shared memory of CPU No. 4, starting from
address 10000. The data is stored in the area starting from D0 of the CPU processing the in-
struction.
9 – 18
Overview
MELSEC-Instruction MELSEC-Instruction
Function in in
MELSEC-Editor IEC-Editor
D.DDWR
Writing devices to another CPU
DP.DDWR
D.DDRD
Reading devices from another CPU
DP.DDRD
10.1 Overview
The multiple CPU high-speed transmission dedicated instruction directs the Universal model
QCPU to write/read device data to/from another Universal model QCPU.
The following shows an operation when CPU No. 1 writes device data to CPU No. 2 with the
multiple CPU high-speed transmission dedicated instruction.
D0 D0
D100
D200
Writing
NOTE The multiple CPU high-speed transmission dedicated instruction in either host CPU or another
CPU (target CPU module of instruction) is available only for the following CPU modules.
Q03UDCPU, Q04UDHCPU, Q06UDHCPU
The first five digits of serial number is 10012 or higher.
Q10UDHCPU, Q13UDHCPU, Q20UDHCPU, Q26UDHCPU
QnUDE(H)CPU
Parameter setting and system configuration to execute the multiple CPU high-speed
transmission dedicated instruction
The multiple CPU high-speed transmission dedicated instruction can be executed in the follo-
wing parameter setting and system configuration.
● CPU No. 1 is a QnUD(H)CPU or QnUDE(H)CPU.
● The multiple CPU high speed main base unit (Q3DB) is used.
● "Use multiple CPU high speed transmission" is selected in the Multiple CPU settings screen
of PLC parameter.
Writable/readable devices
The following table shows the devices that can be written to/read from the Universal model
QCPU in another CPU with the multiple CPU high-speed transmission dedicated instruction.
Setting of Target
Category Type Device Name Remarks
Device
Requirements for the setting
Digits are specified by 16 bits
Internal user Bit device X, Y, M, L, B, F, SB (4 digits).
device The start bit device is multiples of
16(10H).
Word device T, ST, C, D, W, SW —
Requirements for the setting
Digits are specified by 16 bits
Internal system Bit device SM (4 digits).
device The start bit device is multiples of
16(10H).
Word device SD —
File register Word device R, ZR —
Settable
Settable with conditions
NOTE SB, SW, SM, and SD include system information area. Take care not to destroy the system in-
formation when writing data to the devices above with the D.DDWR/DP.DDWR instruction of the
multiple CPU high-speed transmission dedicated instruction.
10 – 2
Overview
X0
DP.DDWR H3E1 D0 D100 D200 M0
In the device specification, data can be written/read within the device range of host CPU.
For example, when data register in host CPU is 12k points and data register in another CPU
is 16k points, data can be written/read by 12k points from the start of the data register in
another CPU.
D12287 D12287
D12288
Not writable/
not readable
D16383
● String specification
The string specification is a method to specify a device in another CPU to be written/ read
by character string.
In the string specification, data can be written to/read from all device ranges of another CPU.
For example, when data register in host CPU is 12k points and data register in another CPU
is 16k points, data can be written/read by 16k points from the start of the data register in
another CPU.
D12287
D16383
10 – 4
Overview
System Area 1)
Number of CPU Modules
1k Points 2k Points
2 46 110
3 22 54
4 14 35
1
For setting of the system area, refer to the QCPU User's Manual (Multiple CPU System).
The following shows configuration of the multiple CPU high speed transmission area when the
multiple CPU system is configured with three CPU modules and the system area size is 1k
word.
22 Receive 22
blocks Send area area blocks
22 22
blocks Send area Receive
area blocks
Receive 22
Send area blocks
area
22 Receive 22
blocks Send area blocks
area
22 Receive 22
blocks area Send area blocks
1–4 1
5–20 2
21–36 3
37–52 4 1
53–68 5
69–84 6
85–100 7
When the number of blocks used for the multiple CPU high-speed transmission dedicated in-
structions exceeds the total number of blocks in the multiple CPU high speed transmission
area, the instruction will not be executed in the scan (no processing) but executed at the next
scan.
Note that the instruction will be completed abnormally when the number of empty blocks in the
multiple CPU high speed transmission area is less than the setting values of SD796 to SD799
(maximum number of used blocks for multiple CPU high-speed transmission dedicated instruc-
tion setting) at the execution of the instruction.
The following table shows execution possibility of the multiple CPU high-speed transmission
dedicated instructions when the number of empty blocks in the multiple CPU high speed trans-
mission area is less than the number of blocks used for the multiple CPU high-speed transmis-
sion dedicated instructions or the setting values of SD796 to SD799.
Magnitude relation between SD Magnitude relation between the number of blocks used for the
setting value and the number of instructions (N1) 1) and the number of empty relation blocks (N2) 2)
empty blocks N1 <= N2 N1 > N2
Setting values from SD796–SD799
<= Executed Not executed (no processing)
Number of empty blocks 2)
Setting values from SD796–SD799
> Completed abnormally
Number of empty blocks 2)
1
The number of blocks used for the multiple CPU high-speed transmission dedicated instruction.
2
The number of empty blocks in the multiple CPU high-speed transmission area.
10 – 6
Overview
NOTE When using special relays SM796 to SM799, set the maximum number of blocks for the in-
struction used for each CPU to special registers SD796 to SD799. (For example, when the ma-
ximum number of blocks for the multiple CPU high-speed transmission dedicated instruction to
be executed to CPU No.3 is 5, set 5 to SD798.)
When the number of empty blocks in the multiple CPU high speed transmission area becomes
equal to or less than the number of blocks set at SD796 to SD799, the corresponding special re-
lay (SM796 to SM799) turns on.
4)
Turns on when the number of empty blocks is
less than the number of blocks used for the
DP.DDWR instruction.
(Instruction is not executed). Insufficient for writing a request from the
DP.DDWR instruction.
CPU No. 1 Empty area of request blocks in send area increased CPU No. 2
3) 3)
1
Execution command
2 Number of request blocks: 4
3
Multiple CPU high speed transmission area
4 Number of empty blocks: 2
Maximum number of used blocks for multiple CPU high speed transmission dedicated instructions
and No. of write points
SM402
0 MOV K7 SD797
Turn-on for Max. no. of
one scan used blocks
after RUN (CPU No. 2)
MOV K7 SD798
Max. no. of
used blocks
(CPU No. 3)
SM402
8 MOV K100 D1
Turn-on for No. of write
one scan points to
after RUN CPU No. 2
MOV K100 D3
No. of write
points to
CPU No. 3
The DDWR instruction is executed to CPU No. 2 at the rise of X0
X0
11 SET M0
Execution command of the DDWR instruction to CPU No. 2 During
execution of
the DDWR
instruction to
M0 SM797 CPU No. 2
14 D.DDWRH3E1 D0 ZR0 ZR0 M1
During No. of used Control Source of Destination Completion
execution of block data data in CPU No. 2 device
the DDWR information CPU No. 2
instruction to CPU No. 2
CPU No. 2
RST M0
During
execution of
the DDWR
instruction to
The DDWR instruction is executed to CPU No. 3 at the rise of X1 CPU No. 2
X1
29 SET M3
Execution command of the DDWR instruction to CPU No. 3 During
execution of
the DDWR
instruction to
M3 SM798 CPU No. 3
32 D.DDWRH3E2 D2 ZR1000 ZR1000 M4
During No. of used Control Source of Destination Completion
execution of block data data in CPU No. 3 device
the DDWR information CPU No. 3
instruction to CPU No. 3
CPU No. 3
RST M3
During
execution of
the DDWR
instruction to
CPU No. 3
10 – 8
Overview
Program Program example when the multiple CPU high-speed transmission dedicated instructions are
Example executed to CPU modules by turns
When the multiple CPU high-speed transmission dedicated instructions are executed to Uni-
versal model QCPUs by turns, release an interlock to prevent the concurrent execution. Use
the cyclic transmission area device (from U3E\G10000) as an interlock.
The following shows a program example when the multiple CPU high-speed transmission de-
dicated instructions are executed at CPU No.s 1 and 2 by turns.
Program example when the multiple CPU high-speed transmission dedicated instruction is
executed at CPU No. 1:
SM402
MOV K7 SD797
Turn-on for Max. no. of
one scan used blocks
after RUN (CPU No. 2)
X0
SET M0
Write command During execution of
the DDWR instruction
U3E0\G10000.0 is turned on while CPU No.1 is executing the DP.DDWR
instruction.
MOV K100 D1
No. of write
points
RST M0
During execution of
the DDWR instruction
U3E0\G10000.0 is turned OFF while CPU No.1 is executing the DP.DDWR
instruction.
M1 U3E0\
RST G10000.0
Completion CPU No.1 is
device during
execution of the
instruction
Program Program example when the multiple CPU high-speed transmission dedicated instruction is
Example executed at CPU No. 2:
SM402
MOV K1 SD796
Turn-on for Max. no. of
one scan used blocks
after RUN (CPU No. 1)
X20
SET M0
During execution of
Read instruction the DDRD instruction
U3E1\G10000.0 is turned on while CPU No. 2 is executing the DP.DDRD instruction.
MOV K50 D1
No. of read
points
RST M0
During execution of
the DDRD instruction
U3E1\G10000.0 is turned off at the completion of the DP.DDRD instruction.
M1 U3E1\
RST G10000.0
Completion CPU No. 2 is
device during execution n
of the instruction
Program Program example when data exceeding 100 words are written/read with the multiple CPU
Example high-speed transmission dedicated instruction
The maximum number of write/read points that can be processed with the multiple CPU high-
speed transmission dedicated instruction is 100 words. Data exceeding 100 words can be writ-
ten/read by executing the multiple CPU high-speed transmission dedicated instruction at seve-
ral times.
The following shows a program example using the D.DDWR/DP.DDWR instruction of the mul-
tiple CPU high-speed transmission dedicated instruction. The similar program can be used
when using the D.DDRD/DP.DDRD instruction of the multiple CPU high-speed transmission
dedicated instruction.
10 – 10
Overview
The maximum number of used blocks for multiple CPU high speed
transmission dedicated instruction setting is set to CPU No. 2
SM402
0 MOV K7 SD797
Turn-on for Max. no. of
one scan used blocks
after RUN (CPU No. 2)
MOV K100 D1
No. of write
points
X0 M0
37 RST Z2
Write During
command writing
SET M0
During writing
M0
68 SET M1
During During
writing execution of
the DDWR
instruction
M4
Execution request of the
next DDWR instruction
173 END
Program Program example when the D.DDWR/DP.DDWR instructions are executed concurrently
Example
The following shows a program example that writes ZR0 to ZR999 (1000 points) in CPU No. 1
to ZR0 to ZR999 in CPU No. 2 with the D.DDWR instruction. As shown on the program examp-
le, multiple CPU device write/read instructions can be executed concurrently.
When reading/writing devices with the multiple CPU high-speed transmission dedicated in-
structions concurrently, the more the total number of blocks in the multiple CPU high speed
transmission area (send area), the more the time taken to complete reading/writing with the
multiple CPU high-speed transmission dedicated instruction can be shortened.
The maximum number of used blocks for multiple CPU high speed
transmission dedicated instruction setting is set to CPU No. 2
SM402
0 MOV K7 SD797
Max. no. of used
Turn-on for blocks (CPU No. 2)
one scan
after RUN MOV K100 D1
No. of write
points 1
MOV K100 D3
Data writing is started at the rise of the write command (X0) No. of write
points 2
X0 M0
39 RST Z2
Write During
command writing
SET M0
During writing
First DDWR instruction, Second DDWR instruction
M0
70 SET M1
During During execution
writing of the DDWR
instruction 1
M7
SET M2
Execution request of the next DDWR instruction During execution
of the DDWR
instruction 2
The first DDWR instruction is executed
M1 SM797
94 D.DDWR H3E1 D0 ZR0Z2 ZR0Z2 M3
During execu- No. of used blocks Control source/write Write Completion
tion of the information data 1 destination device 1
DDWR instr. 1 (CPU No. 2) RST M1
The second DDWR instruction is executed During execution
of the DDWR
M2 SM797 instruction 1
126 D.DDWR H3E1 D2 ZR100Z2 ZR100Z2 M5
During execu- No. of used blocks Control source/write Write Completion
tion of the information data 2 destination device 2
DDWR instr. 2 (CPU No. 2)
RST M2
During execution of the DDWR instruction 2
When the DDWR instruction is completed abnomally, the annunciator is turned on and data writing is stopped
M3 M4
158 SET F0
Completion Error DDWR instruction
device 1 completion error display
device 1
M5 M6
RST M0
Completion Error
device 2 completion During writing
device 2
Next data writing is requested at nomal completion of the second DDWR instruction
M5 M6
197 + K200 Z2
Completion Error
device 2 completion PLS M7
device 2 < Z2 K1000
Execution request of the
next DDWR instruction
= Z2 K1000 RST M0
During writing
241 END
10 – 12
Multiple CPU high-speed transmission instructions D.DDWR, DP.DDWR
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Q03UDCPU, Q04UDHCPU, Q06UDHCPU: first 5 digits of serial number is 10012 or higher
QnUDE(H)CPU
n 1) — — — — — — —
2) 3) 4)
s1 — — — — — — —
s2 2) — — — — — — —
d1 2) — — — — — — —
2) 6) 4)
d2 — — — — — — —
1 Index modification cannot be made to setting data n.
2
Index modification cannot be made to setting data from s1 to d2.
3
Local devices cannot be used.
4 File registers cannot be used per program.
6
FX and FY cannot be used.
GX IEC
Developer
MELSEC Instruction Ladder Diagram IEC Instruction List
GX Works2
D.DDWR n s1 s2 d1 d2
DP.DDWR n s1 s2 d1 d2
Device 1)
d1 Start device of another CPU that stores write data
Character string 2,3)
d2 Completion device Bit
1 By specifying a file register (R, ZR), data can be written to devices in another CPU, outside the range
of host CPU.
2 By specifying the start device by " ", devices can be written to devices in another CPU, outside the
10 – 14
Multiple CPU high-speed transmission instructions D.DDWR, DP.DDWR
Number of
write points
((s1)+1)
Whether to complete the D.DDWR/DP.DDWR instruction normally can be checked by the com-
pletion device ((d2)+0) and completion status display device ((d2)+1).
● Completion device ((d2)+0)
Turns on at END processing in the scan where the instruction has been completed, and
turns off at the next END processing.
● Completion status display device ((d2)+1)
This device turns on/off depending on the status upon completion of the instruction.
Error completion: Turns on at END processing in the scan where the instruction has been
completed, and turns off at the next END processing
(At error completion, an error code is stored at control data ((s1)+0): Completion status).
The number of blocks used for the instruction depends on the number of write points (refer to
section 10.1). The following table shows the number of blocks used for the instruction:
The instruction will be completed abnormally when there are no empty blocks in the multiple
CPU high speed transmission area.
Set the number of blocks used for the instruction at special registers (SD796 to SD799), and
use the special relays (SM796 to SM799)as an interlock prevent error completion (refer to sec-
tion 10.1).
NOTES Digit specification of bit device is possible for n, s2, and d1. Note that when the digit specifica-
tion of bit device is made to s2 or d1, the following conditions must be met.
Digits are specified by 16 bits (4 digits).
The start bit device is multiples of 16 (10H).
Execute this instruction after checking that the write target CPU is powered on. Not doing so
may end up no processing.
If changing a range of the device specified at setting data between after execution of the
instruction and turn-on of the completion device, data to be stored by system (completion sta-
tus, completion device) cannot be stored normally.
SB, SW, SM, and SD include system information area. Take care not to destroy the system
information when writing data to the devices above with the D.DDWR/DP.DDWR instruction of
the multiple CPU high-speed transmission dedicated instruction.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Specified another CPU is wrong or the multiple CPU high-speed transmission dedicated
instruction cannot be used in the setting.
(Error code 4350)
– A reserved CPU has been specified.
– Unmounted CPU has been specified.
– The value in n (the start I/O number of the other CPU divided by 16) is out of the range
of 3E0H to 3E3H.
– The instruction was executed without setting "Use multiple CPU high speed transmissi-
on".
– The instruction was executed with the Q02UCPU.
– Host CPU has been specified.
– The CPU where the instruction cannot be executed has been specified.
● The instruction cannot be executed with the CPU.
(Error code 4351)
The other CPU does not support this instruction.
● The number of devices is wrong. (Error code 4352)
● A device that cannot be used for the instruction has been specified. (Error code 4353)
● A device has been specified by the character string that cannot be used. (Error code 4354)
● The number of write points ((s1)+1)) is other than 1 to 100. (Error code 4355)
10 – 16
Multiple CPU high-speed transmission instructions D.DDWR, DP.DDWR
In any of the following cases, the instruction is completed abnormally, and an error code is
stored into a device specified at completion status storage device ((s1)+0)).
● The request of the instruction to the target CPU is more than the acceptable value (no empty
blocks exist in the multiple CPU high speed transmission area).
(Error code 0010H)
● A device for another CPU specified at s2 cannot be used at another CPU, or is out of device
range.
(Error code 1001H)
● The number of write points set with the D.DDWR/DP.DDWR instruction is 0.
(Error code 1080H)
● The response of the instruction from another CPU cannot be returned (no empty blocks
exist in the multiple CPU high speed transmission area). (Error code 1003H)
Program DP.DDWR
Example
This program stores data by 10 words starting from D0 in host CPU into W10 or later in CPU
No. 2 when X0 turns on.
Ladder diagram
CPU High
Basic Process Redundant Universal LCPU
Performance
1)
1
Q03UDCPU, Q04UDHCPU, Q06UDHCPU: first 5 digits of serial number is 10012 or higher
QnUDE(H)CPU
n 1) — — — — — — —
s1 2) — 3) 4) — — — — — —
s2 2) — — — — — — —
d1 2) — — — — — — —
2) 6) 4)
d2 — — — — — — —
1
Index modification cannot be made to setting data n.
2
Index modification cannot be made to setting data from s1 to d2.
3 Local devices cannot be used.
5
FD @ (indirect specification) cannot be used.
6 FX and FY cannot be used.
GX IEC
Developer
MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
D.DDRD n s1 s2 d1 d2
DP.DDRD n s1 s2 d1 d2
10 – 18
Multiple CPU high-speed transmission instructions D.DDRD, DP.DDRD
Device 1)
d1 Start device of host CPU that stores read data
Character string 2,3)
d2 Completion device Bit
1 By specifying a file register (R, ZR), data can be read to devices in another CPU, outside the range of
host CPU.
2 By specifying the start device by " ", devices can be read to devices in another CPU, outside the range
of host CPU.
3 Indexed devices cannot be specified (e.g. D0Z0).
Number of
read points
((s1)+1)
Whether to complete the D.DDRD/DP.DDRD instruction normally can be checked by the com-
pletion device ((d2)+0) and completion status display device ((d2)+1).
● END processing in scan data that CPU completed the instruction turns on the device ((d2)+0)
and the next END processing turns off the device.
● This device ((d2)+1) turns on/off depending on the status upon completion of the instruction.
Error completion: Turns on at END processing in the scan where the instruction has been
completed, and turns off at the next END processing. (At error completion, an error code is
stored at control data ((s1)+0): Completion status).
The number of blocks used for the instruction is independent of the number of read points (refer
to section 10.1). The following table shows the number of blocks used for the instruction:
The instruction will be completed abnormally when there are no empty blocks in the multiple
CPU high speed transmission area.
Set the number of blocks used for the instruction at special registers (SD796 to SD799), and
use the special relays (SM796 to SM799) as an interlock prevent error completion (refer to sec-
tion 10.1).
10 – 20
Multiple CPU high-speed transmission instructions D.DDRD, DP.DDRD
NOTES Digit specification of bit device is possible for n, s2, and d1. Note that when the digit specifica-
tion of bit device is made to s2 or d1, the following conditions must be met.
Digits are specified by 16 bits (4 digits).
The start bit device is multiples of 16 (10H).
Execute this instruction after checking that the read target CPU is powered on. Not doing so
may end up no processing.
If changing a range of the device specified at setting data between after execution of the
instruction and turn-on of the completion device, data to be stored by system (completion sta-
tus, completion device) cannot be stored normally.
Operation In the following cases an operation error occurs, the error flag (SM0) turns ON, and an error
Errors code is stored into SD0.
● Specified another CPU is wrong or the multiple CPU high-speed transmission dedicated
instruction cannot be used in the setting.
(Error code 4350)
– A reserved CPU has been specified.
– Unmounted CPU has been specified.
– The value in n (the start I/O number of the other CPU divided by 16) is out of the range
of 3E0H to 3E3H.
– The instruction was executed without setting "Use multiple CPU high speed transmissi-
on".
– The instruction was executed with the Q02UCPU.
– Host CPU has been specified.
– A CPU where the instruction cannot be executed has been specified.
● The instruction cannot be executed with the CPU.
(Error code 4351)
The other CPU does not support this instruction.
● The number of devices is wrong. (Error code 4352)
● A device that cannot be used for the instruction has been specified. (Error code 4353)
● A device has been specified by the character string that cannot be used. (Error code 4354)
● The number of read points ((s1)+1)) is other than 1 to 100. (Error code 4355)
In any of the following cases, the instruction is completed abnormally, and an error code is
stored into a device specified at completion status storage device ((s1)+0).
● The request of the instruction to the target CPU is more than the acceptable value (no empty
blocks exist in the multiple CPU high speed transmission area).
(Error code 0010H)
● A device for another CPU specified at s2 cannot be used at another CPU, or is out of device
range.
(Error code 1001H)
● The number of read points set with the D.DDRD/DP.DDRD instruction is 0.
(Error code 1081H)
● The response of the instruction from another CPU cannot be returned (no empty blocks
exist in the multiple CPU high speed transmission area).
(Error code 1003H)
Program DP.DDRD
Example
This program stores data by 10 words starting from D0 in host CPU No. 2 into W10 or later in
host CPU when X0 turns on.
Ladder diagram
10 – 22
Instruction for a redundant system
NOTE For more information of a redundant system refer to the User‘s manuals of the redundant CPU
modules Q12PRHCPU and Q25PRHCPU.
11.1.1 SP.CONTSW
CPU High
Basic Process Redundant Universal LCPU
Performance
Devices Devices
Internal Devices MELSECNET/H Special
(System, User) File Direct J\ Function Index Register Constant
Register Module Zn K, H Other
Bit Word Bit Word U\G
s — — — — — —
1) 1)
d — — — — — —
1
The bit specification for the word device is available.
GX IEC
Developer MELSEC Instruction List Ladder Diagram IEC Instruction List
GX Works2
SP.CONTSW s d
11 – 2
Instruction for a redundant system SP.CONTSW
Use a user program or a programming tool to turn OFF the error completion bit that has turned
ON.
If normal system switching is performed by the execution of the SP.CONTSW instruction with
the error completion device ON, the error completion device of the new standby system CPU
module is also turned OFF. When system switching is performed due to a factor other than the
SP.CONTSW instruction, however, the error completion device is not turned OFF.
Operation In the following cases an operation error occurs, the error flag (SM0) is turned ON and an error
Errors code is stored into SD0:
● The value specified at s is 0 at execution of the SP.CONTSW instruction.
(Error code: 4100)
● The manual switching enable flag (SM1592) is OFF (disable) at execution of the
SP.CONTSW instruction.
(Error code: 4120)
● The SP.CONTSW instruction was executed by the standby system CPU module in the
separate mode.
(Error code: 4121)
● The SP.CONTSW instruction was executed in the debug mode.
(Error code: 4121)
If system switching was unsuccessful, the error flag (SM0) is turned ON and the error code
6220 is stored into SD0.
● The tracking cable is disconnected or faulty.
● Hardware fault, power-off, reset or watchdog timer error occurred in the standby system.
● Watchdog timer error occurred in the control system.
● Preparations are being made for tracking transfer.
● Communication time-out occurred.
● Stop error, excluding watchdog timer error, occurred in the standby system.
● The operating status differs between the control system and standby system.
● Memory copy is being executed from the control system to the standby system.
● Write during RUN is being executed.
● Network fault was detected by the standby system.
11 – 4
Instruction for a redundant system SP.CONTSW
Program SP.CONTSW
Example
The following program executes system switching on the leading edge of the system switching
command (M100).
If the system switching command (M100) remains ON, the SP.CONTSW instruction is also exe-
cuted by the new control system CPU module after system switching. Therefore, M101 is
added to the execution conditions as a consecutive switching prevention flag.
11 – 6
12 Instructions for Special Function
Modules
Instructions Function
Reading of received data in an interrupt program;
Instructions for serial communication modules Reading, registration or deletion of user frames;
Transmission of data using user frames
Reading or writing of data from and to the buffer memory of a
Instructions for PROFIBUS/DP interface modules
PROFIBUS/DP interface module
Writing and reading of data to and from fixed buffer;
Instructions for ETHERNET interface modules Opening and closing of connections, Clearing of error codes;
Re-initialization of the ETHERNET interface module
Instructions for MELSECNET/H Setting of stations for duplex network
Parameter setting,
Setting of automatic refresh parameters
Reading of data from the buffer memory of an station connected
to CC-Link or from the PLC CPU of this station;
Instructions for CC-Link
Writing of data to the buffer memory of an station connected to
CC-Link or to the PLC CPU of this station;
Reading and writing from and to the automatic updated buffer
memory
12 – 2
Instructions for serial communication modules BUFRCVS
12.1.1 BUFRCVS
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
Scan
Sequence END processing
program
Interrupt program
BUFRCVS Execution
instruction
NOTES When received data is read with a BUFRCVS instruction in an interrupt program, the data of the
same interface can not be read again in the main program. Thus the BUFRCVS instruction can-
not used together with the following instructions:
- the INPUT instruction
- the BIDIN instruction
- the FROM instruction in combination with input/output signals of the communication module
The BUFRCVS and the CSET instruction cannot be executed at the same time.
The area specified with d1 in the PLC CPU must be large enough to store all data sent from the
external device. If this area is to small, the data that can not be stored, is lost.
Operation When the BUFRCVS instruction is completed abnormally, the error flag SM0 is set, and an error
Errors code is stored in SD0. For more information about the error codes please refer to the following
manuals:
● When the error code is 4FFFH or less, please refer to chapter 13 of this manual for error
diagnostics.
● When the error code is 7000H or higher, please refer to the user’s manual of the serial
communication module QJ71C24.
If an error occurs during data reception (indicated by the input signals X4 and XB), the error
code is written to the buffer memory addresses 258H and 268H of the communication module
and can be used for diagnostics.
12 – 4
Instructions for serial communication modules BUFRCVS
Program BUFRCVS
Example
The following program reads the data received via channel 1 of a QJ71C24 with the head
address X/Y0 and stores the data from D200 onward. Only channel 1 issues an interrupt.
When data is received, the interrupt program 50 (I50) is processed. The internal relays M100
and M101 are used as interface with the main program. If data was received correctly, M100 is
set. When an error occurs during reception of the data, M101 is set. Both relays are reset in
the main program.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 6
Instructions for serial communication modules GETE, GETEP
User frame
b15 b8 b7 b0
(S2)+0 B A A
Read
+1 D C B
+2 F E C Number of bytes
D to read
E
F
During GETE instruction execution, another GETE or PUTE instruction cannot be executed. If
an attempt is made to execute a GETE or PUTE instruction during execution of a GETE instruc-
tion, the system waits until the execution of the instruction already being processed is com-
pleted.
Whether the execution of the GETE instruction has been finished can be checked with the
devices (d)+0 and (d)+1:
● The bit device (d)+0 turns ON at the END processing of the scan in which the GETE
instruction has been completed and turns OFF at the next END processing.
● The bit device (d)+1 indicates an error during execution of the GETE instruction. When the
instruction is completed normal, this device stays OFF. When an error occurs during
execution of the GETE instruction, (d)+1 turns ON at the END processing of the scan in
which the GETE instruction has been completed and turns OFF at the next END processing.
The following figure shows the timing when the GETE instruction is being executed:
GETE instruction
Instruction
Bit device (d)+0 completed
Error
Bit device (d)+1
One scan
Operation When an error occurs during execution of the GETE instruction, the bit device (d)+1 is set and
Errors an error code is written to (s1)+1. For more information about the error codes please refer to
the following manuals:
● When the error code is 4FFFH or less, refer to chapter 13 of this manual for error diagnostics.
● When the error code is 7000H or higher, you will find more information in the user’s manual
of the serial communication module.
12 – 8
Instructions for serial communication modules GETE, GETEP
Program GETE
Example
The following program reads data of the user frame with the number 3E8H from a QJ71C24
and stores the data in the QCPU from data register D4 onward. The communication module
occupies the input/output signals from X/Y80 to X/Y9F.
● IEC editors
At this position, write the instructions that should be executed when the GETE
instruction has been completed normally.
At this position, write the instructions that should be executed when the GETE
instruction has been completed abnormally.
An instruction at his position will be executed when the GETE instruction has been completed normally.
An instruction at this position will be executed when the GETE instruction has been completed with an error.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the GETE instruction
has been completed normally.
At this position, write the instructions that should be executed when the GETE instruction
has been completed not normally.
An instruction at this position will be executed when the GETE instruction has been completed normally
An instruction at this position will be executed when the GETE instruction has been completed with an error.
12 – 10
Instructions for serial communication modules PUTE, PUTEP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 12
Instructions for serial communication modules PUTE, PUTEP
b15 b8 b7 b0
User frame
(S2)+0 B A Register A
+1 D C B
+2 F E C Number of bytes
D to be registered
E
F
The following figure shows the timing for the PUTE instruction:
PUTE instruction
Registration/
deletion request
Instruction
completed
One scan
Operation When an error occurs during execution of the PUTE instruction, the bit device (d)+1 is set and
Error an error code is written to (s1)+1. For more information about the error codes please refer to
the following manuals:
● When the error code is 4FFFH or less, please refer to chapter 13 of this manual for error
diagnostics.
● When the error code is 7000H or higher, please refer to the user’s manual of the serial
communication module.
12 – 14
Instructions for serial communication modules PUTE, PUTEP
Program PUTE
Example
The following program registers data to the user frame with the number 3E8H. A QJ71C24 is
used as communication module. It occupies the input/output signals from X/Y80 to X/Y9F.
NOTE When using the IEC editors it is neccessary to define the variables in the header of the program
organization unit (POU). Without variable definition it would cause compiler or checker error
messages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC De-
veloper" of this manual.
● IEC editors
At this position, write the instructions that should be executed when the PUTE
instruction has been completed normally.
At this position, write the instructions that should be executed when the PUTE
instruction has been completed with an error.
An instruction at this position will be executed when the PUTE instruction has been completed normally.
An instruction at this position will be executed when the PUTE instruction has been completed with an error.
At this position, write the instructions that should be executed when the PUTE instruction
has been completed normally.
At this position, write the instructions that should be executed when the PUTE instruction
has been completed with an error.
12 – 16
Instructions for serial communication modules PUTE, PUTEP
An instruction at this position will be executed when the PUTE instruction has been completed normally.
At this position, write the instructions that should be executed when the PUTE instruction has been completed
with an error.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 18
Instructions for serial communication modules PRR, PRRP
The following figure shows the timing for the PRR instruction:
Instruction
Bit device (d)+0 completed
Error
Bit device (d)+1
One scan
Operation When an error occurs during execution of the PUTE instruction, the bit device (d)+1 is set and
Error an error code is written to (s1)+1. For more information about the error codes please refer to
the following manuals:
● When the error code is 4FFFH or less, please refer to chapter 13 of this manual for error
diagnostics.
● When the error code is 7000H or higher, please refer to the user’s manual of the serial
communication module.
12 – 20
Instructions for serial communication modules PRR, PRRP
Program PRR
Example
The program for this example transmits data and the first five user frames. The communication
module QJ71C24 is used. It occupies the input/output signals from X/Y80 to X/Y9F. The follow-
ing data registers are used in the program:
Data register Contents Meaning
D0 0004H Number of bytes to send
D1 3412H
Data to be send
D2 AB56H
D5 03F2H
D6 03F3H
D7 8001H
Numbers of the user frames
D8 8000H
D9 041BH
D10 0000H
D11 0001H (s)+0 Interface: CH1
0000H or
D12 (s)+1 Transmission result
error code
D13 0000H (s)+2 CR/LF is not added
D14 0001H (s)+3 Transmission pointer
D15 0005H (s)+4 Number of data frames to transmit
NOTE When using the IEC editors it is neccessary to define the variables in the header of the program
organization unit (POU). Without variable definition it would cause compiler or checker error
messages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC De-
veloper" of this manual.
● IEC editors
Ladder Diagram of the GX IEC Developer (part 1)
12 – 22
Instructions for serial communication modules PRR, PRRP
Interface (channel) 1
Transmit data
At this position, write the instructions that should be executed when the PRR
instruction has been completed normally.
At this position, write the instructions that should be executed when the PRR
instruction has been completed with an error.
An instruction at this position will be executed when the PRR instruction has been completed normally.
An instruction at this position will be executed when the processing of the PRR instruction has been completed with
an error.
At this position, write the instructions that should be executed when the PRR instruction
has been completed normally.
At this position, write the instructions that should be executed when the PRR instruction
has been completed with an error.
12 – 24
Instructions for serial communication modules PRR, PRRP
An instruction at this position will be executed when the PRR instruction has been completed normally.
At this position, write the instructions that should be executed when the PRR instruction has been completed
with an error.
12 – 26
Instructions for PROFIBUS/DP interface modules BBLKRD, BBLKRDP
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
Functions Reading of data from the buffer memory of a PROFIBUS interface module
BBLKRD / BBLKRDP Reading of data
The BBLKRD instruction is used to read data from the buffer memory of the PROFIBUS inter-
face modules QJ71PB92D and QJ71PB93D. While reading, data separation is prevented.
The QJ71PB93 must be prepared for the BBLKRD instruction by setting of the output signal
Y0A. When the PROFIBUS module in turn sets the input signal X0A, the BBLKRD instruction
can be executed. The output signal Y0A must be reset when the reading of the buffer memory
is completed.
Allowable ranges and designation of the devices:
● Un (Head I/O address of the PROFIBUS interface module): 0 to FFH
(Only the upper two digits of the 3-digit-address are used. E. g. the head address X/Y100
is set as 10H.)
● n1 (Head address in the buffer memory): The specified address must be exist.
● d (Head address of the target area): The designated device must be exist.
● n2 (Number of data to read)
For a QJ71PB92D: 1 to 960 words (1 to 3C0H)
For a QJ71PB93D: 1 to 122 words (1 to 7AH)
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When a value that exceeds the specificable range is set for the set data. (Error code: 4101)
● By the addition of the head address of the buffer memory designated by n1 and the number
of data to be read designated by n2 the size of the buffer memory is exceeded.
(Error code: 4101)
● The number of data to be read (designated by n2) is larger than the available device area
starting with the head address designated by d. (Error code: 4101)
12 – 28
Instructions for PROFIBUS/DP interface modules BBLKRD, BBLKRDP
Program BBLKRDP
Example
When the relay M10 is set, 122 words of data are read from the buffer memory of the PROFI-
BUS interface module with the head I/O address X/Y0. The reading is started at the buffer
memory address 0 while the storage of the data is started from register D0 onward.
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 30
Instructions for PROFIBUS/DP interface modules BBLKWR, BBLKWRP
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When a value that exceeds the specificable range is set for the set data. (Error code: 4101)
● By the addition of the head address of the buffer memory designated by n1 and the number
of data to write (designated by n2) the size of the buffer memory is exceeded.
(Error code: 4101)
● The number of data to be write (designated by n2) is larger than the available device area
starting with the head address designated by d. (Error code: 4101)
Program BBLKWRP
Example
After the relay M10 is set, the contents of the data registers D0 to D121 (122 words) is written
to the input area of the PROFIBUS/DP slave module QJ71PB93D. The input area starts at the
buffer memory address 100H. Please note that the head address designated by n1 is specified
with „0H“ in this case. The head I/O number of the PROFIBUS/DP slave module is X/Y0.
12 – 32
Instructions for ETHERNET interface modules
12.3.1 BUFRCV
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 34
Instructions for ETHERNET interface modules BUFRCV
s1 Connection number 1 to 16
Head number of the devices where control data for execution of this instruction is stored.
Functions Reading of received data from fixed buffer (Execution of the instruction in the main
program)
BUFRCV Data read
With the BUFRCV instruction, Data sent by an external Station to an ETHERNET interface
module via fixed buffer communication can be read from the ETHERNET module and stored
in the PLC CPU. The BUFRCV instruction is executed in the main program, whereas the
BUFRCVS instruction is used in an interrupt program. Where the data should be stored is
specified with d1:
Data
BUFRCV
Number n
Data Number 16
Whether the execution of the BUFRCV instruction has been finished can be checked with the
devices (d2)+0 and (d2)+1:
● The bit device (d2)+0 turns ON with the END processing of the scan in which the BUFRCV
instruction has been completed and turns OFF at the next END processing.
● The bit device (d2)+1 indicates an error during execution of the BUFRCV instruction. When
the instruction is completed normal, this device stays OFF. When an error occurs during the
execution of the BUFRCV instruction, (d2)+1 turns ON at the END processing of the scan
in which the BUFRCV instruction has been completed and turns OFF at the next END
processing.
The timing for the PRR instruction is shown in the following figure:
Data receive
The BUFRCV instruction can be executed when the ETHERNET interface module indicates
that data has been received. One bit is reserved in the buffer memory address 5005H for each
of the 16 possible connections and is set when data has been received.
NOTE It is not possible to read received data of the same connection with the BUFRCV instruction in
the main programm and the BUFRCVS instruction in an interrupt program.
Operation When the BUFRCV instruction is completed abnormally, the bit device (d2)+1 is set, and an er-
Error ror code is stored in (s2)+1. For more information about the error codes please refer to the fol-
lowing manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
12 – 36
Instructions for ETHERNET interface modules BUFRCV
Program BUFRCV
Example
The following program reads received data from the fixed buffer for connection number 1. The
input/output points X/Y0 to X/Y1F are occupied by the ETHERNET module.
● IEC editors (This program example is shown on the next page for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
At this position, write the instructions that should be executed when the BUFRCV
instruction has been completed normally.
At this position, write the instructions that should be executed when the
execution of the BUFRCV instruction has been resulted in an error.
At this position, write the instructions that should be executed when the BUFRCV
instruction has been completed normally.
At this position, write the instructions that should be executed when the execution
of the BUFRCV instruction has been resulted in an error.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the
BUFRCV instruction has been completed normally.
At this position, write the instructions that should be executed when the
execution of the BUFRCV instruction has been resulted in an error.
At this position, write the instructions that should be executed when the BUFRCV
instruction has been completed normally.
At this position, write the instructions that should be executed when the execution
of the BUFRCV instruction has been resulted in an error.
12 – 38
Instructions for ETHERNET interface modules BUFRCVS
12.3.2 BUFRCVS
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
s1 Connection number 1 to 16
Head number of the device area where the received data is stored.
Contents is
Set Data Meaning Description Range stored by
1 to 1017
With procedure (binary data):)
Length of the words
received data
d1 (d1)+0 (Number of word With procedure (ASCII data): 1 to 508 BIN 16-bit
words
or bytes read from
the fixed buffer) 1 to 2016 System
Without procedure (binary data): bytes
(d1)+1 In this area the data read from the
to Received data fixed buffer is stored sequentially in —
(d1)+n ascending order.
Functions Reading of received data from fixed buffer (Execution of the instruction in an interrupt
program)
BUFRCVS Data read
With the BUFRCVS instruction, Data sent by an external Station to an ETHERNET interface
module via fixed buffer communication can be read from the ETHERNET module and stored
in the PLC CPU. The BUFRCVS instruction is executed in an interrupt program, whereas the
BUFRCV instruction is used in the main program. Where the data should be stored is specified
with d1:
Data
BUFRCVS
Number n
Data Number 16
The processing of the BUFRCVS instruction is completed within one scan. The following figure
shows the timing of the BUFRCVS instruction:
Scan
Processig of the
Sequence END instruction
program
Interrupt program
BUFRCVS Execution
instruction
In order to read receive data with an interrupt program, it is necessary to perform both the inter-
rupt settings and interrupt pointer settings with parameter settings of GX (IEC) Developer.
NOTES It is not possible to read received data of the same connection with the BUFRCV instruction in
the main programm and the BUFRCVS instruction in an interrupt program.
The BUFRCVS instruction can also used for an serial communication module QJ71C24 (see
chapter 11.1.1).
Operation When the BUFRCV instruction is completed abnormally, the error flag SM0 is set, and an error
Error code is stored in SD0. For more information about the error codes please refer to the following
manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
12 – 40
Instructions for ETHERNET interface modules BUFRCVS
Program BUFRCVS
Example
The following program reads received data from the fixed buffer for connection number 2. The
head I/O number of the ETHERNET module is X/Y0.
12.3.3 BUFSND
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 42
Instructions for ETHERNET interface modules BUFSND
s1 Connection number 1 to 16
Head number of the devices where control data for execution of this instruction is stored.
Whether the execution of the BUFSND instruction has been finished can be checked with the
devices (d)+0 and (d)+1:
● The bit device (d)+0 turns ON at the END processing of the scan in which the BUFSND
instruction has been completed and turns OFF at the next END processing.
● The bit device (d)+1 indicates an error during execution of the BUFSND instruction. When
the instruction is completed normal, this device stays OFF. When an error occurs during
execution of the BUFSND instruction, (d)+1 turns ON at the END processing of the scan in
which the BUFSND instruction has been completed and turns OFF at the next END
processing.
The following figure shows the timing when the BUFSND instruction is being executed:
Instruction
Bit device (d1)+0 completed
Error
Bit device (d1)+1
One scan
The BUFSND instruction is executed when the command for this instruction switches from off
to on.
Operation When the BUFRCV instruction is completed abnormally, the bit device (d1)+1 is set, and an er-
Error ror code is stored in (s2)+1. For more information about the error codes please refer to the fol-
lowing manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
12 – 44
Instructions for ETHERNET interface modules BUFSND
Program BUFSND
Example
The following program writes data to the fixed buffer for connection 1. The head I/O number of
the ETHERNET module is X/Y0.
● IEC editors (On the next page the same program example is shown for the MELSEC
instruction list and the ladder diagram of the GX Works2.)
Pulse forming
(X19 = 1: Start up of the module has been completed
sucessfully; M0 = 1: Opening of connection 1 com-
pleted)
At this position, write the instructions that should be executed when the BUFSND
instruction has been completed normally.
At this position, write the instructions that should be processed when the execution
of the BUFSND instruction has been resulted in an error.
At this position, write the instructions that should be executed when the BUFSND
instruction has been completed normally.
At this position, write the instructions that should be processed when the execution
of the BUFSND instruction has been resulted in an error.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the
BUFSND instruction has been completed normally.
At this position, write the instructions that should be processed when the
execution of the BUFSND instruction has been resulted in an error.
At this position, write the instructions that should be executed when the BUFSND
instruction has been completed normally.
At this position, write the instructions that should be processed when the execution
of the BUFSND instruction has been resulted in an error.
12 – 46
Instructions for ETHERNET interface modules OPEN
12.3.4 OPEN
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
s1 Connection number 1 to 16
12 – 48
Instructions for ETHERNET interface modules OPEN
Instruction
Bit device (d1)+0 completed
Error
Bit device (d1)+1
One scan
The OPEN instruction is executed when the command for this instruction switches from off to
on.
NOTE Never execute the open/close processing using input/output signals and the OPEN or CLOSE
dedicated instructions simultaneously for the same connection. It will result in malfunctions.
Operation When an error occurs during the processing of the OPEN instruction, the bit device (d1)+1 is
Error set, and an error code is stored in (s2)+1. For more information about the error codes please refer
to the following manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
12 – 50
Instructions for ETHERNET interface modules OPEN
Program OPEN
Example
The following program active opens the connection number 1 for TCP/IP communication. The
head I/O address of the is X/Y0.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
Setting of the parameters is done using the GX Works2 or the GX IEC Developer
1
Reading of the connection status (M0 = 1: Opening of connection 1 has been completed)
2 Reading of the open request (M20 = 1: Opening of connection 1 is requested)
3 The signal to open the connection is converted to a pulse.
4
The source for the parameters is set (0000H = External setting).
5 Opening of connection 1
6 M150 is set when the opening of the connection has been completed without an error.
7
M151 is set when an error has occured during the opening of the connection.
The settings for the connection are stored in the devices designated by (s2)+2 to (s2)+9
10
11
1
Reading of the connection status (M0 = 1: Opening of connection 1 has been completed)
2 Reading of the open request (M20 = 1: Opening of connection 1 is requested)
3 The signal to open the connection is converted to a pulse.
4
The source for the parameters is set (8000H = Parameters are stored in (s2)+2 to (s2)+9))
5
The application setting is stored in (s2)+2.
6 The port No. of the ETHERNET module is written to (s2)+3.
7
The IP address (10.97.85.223) of the external device is stored in (s2)+4 and (s2)+5.
8 In (s2)+6 the port No. of the external device is stored.
9 Opening of connection 1
10
M150 is set when the opening of the connection has been completed without an error.
11 M151 is set when an error has occured during the opening of the connection.
12 – 52
Instructions for ETHERNET interface modules OPEN
Setting of the parameters is done using the GX Works2 or the GX IEC Developer
1
2
4
9
10
11
The settings for the connection are stored in the devices designated by (s2)+2 to (s2)+9
1
2
3
4
5
6
7
8
9
10
11
1 Reading of the connection status (M0 = 1: Opening of connection 1 has been completed)
2
Reading of the open request (M20 = 1: Opening of connection 1 is requested)
3 The signal to open the connection is converted to a pulse.
4 The source for the parameters is set (0000H = External, 8000H = Devices (s2)+2 to(s2)+9))
5
The application setting is stored in (s2)+2.
6 The port No. of the ETHERNET module is written to (s2)+3
7 The IP address (10.97.85.223) of the external device is stored in (s2)+4 and (s2)+5.
8
In (s2)+6 the port No. of the external device is stored.
9 Opening of connection 1
10 M150 is set when the opening of the connection has been completed without an error.
11
M151 is set when an error has occured during the opening of the connection.
Setting of the parameters is done using the GX Works2 or the GX IEC Developer
10
11
The settings for the connection are stored in the devices designated by (s2)+2 to (s2)+9
10
11
1
Reading of the connection status (M0 = 1: Opening of connection 1 has been completed)
2
Reading of the open request (M20 = 1: Opening of connection 1 is requested)
3
The signal to open the connection is converted to a pulse.
4
The source for the parameters is set (0000H = External, 8000H = Devices (s2)+2 to(s2)+9))
5
The application setting is stored in (s2)+2.
6
The port No. of the ETHERNET module is written to (s2)+3
7
The IP address (10.97.85.223) of the external device is stored in (s2)+4 and (s2)+5.
8
In (s2)+6 the port No. of the external device is stored.
9
Opening of connection 1
10 M150 is set when the opening of the connection has been completed without an error.
11
M151 is set when an error has occured during the opening of the connection.
12 – 54
Instructions for ETHERNET interface modules OPEN
Setting of the parameters is done using the GX Works2 or the GX IEC Developer
1
2
4
9
10
11
The settings for the connection are stored in the devices designated by (s2)+2 to (s2)+9
1
2
3
4
5
6
7
8
9
10
11
1
Reading of the connection status (M0 = 1: Opening of connection 1 has been completed)
2
Reading of the open request (M20 = 1: Opening of connection 1 is requested)
3
The signal to open the connection is converted to a pulse.
4 The source for the parameters is set (0000H = External, 8000H = Devices (s2)+2 to(s2)+9))
5
The application setting is stored in (s2)+2.
6
The port No. of the ETHERNET module is written to (s2)+3
7 The IP address (10.97.85.223) of the external device is stored in (s2)+4 and (s2)+5.
9
Opening of connection 1
10
M150 is set when the opening of the connection has been completed without an error.
11 M151 is set when an error has occured during the opening of the connection.
12.3.5 CLOSE
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 56
Instructions for ETHERNET interface modules CLOSE
CLOSE instruction
Instruction
Bit device (d1)+0 completed
Error
Bit device (d1)+1
One scan
The CLOSE instruction is executed when the command for this instruction switches from off to
on.
NOTE Never execute the open/close processing using input/output signals and the OPEN or CLOSE
dedicated instructions simultaneously for the same connection. It will result in malfunctions.
Operation When an error occurs during the processing of the CLOSE instruction, the bit device (d1)+1 is
Error set, and an error code is stored in (s2)+1. For more information about the error codes please refer
to the following manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
12 – 58
Instructions for ETHERNET interface modules CLOSE
Program CLOSE
Example
The following program closes the connection number 1 of the ETHERNET module with the
head I/O address X/Y0.
● IEC editors (On the next page the same program example is shown for the MELSEC
instruction list and the ladder diagram of the GX Works2.)
Closing of connection 1
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
● MELSEC instruction list and ladder diagram of the GX Works2
For explanation of the devices and instructions used please see the program example for
the ladder diagram of the GX IEC Developer on the previous page.
12 – 60
Instructions for ETHERNET interface modules ERRCLR
12.3.6 ERRCLR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 62
Instructions for ETHERNET interface modules ERRCLR
Whether the execution of the ERRCLR instruction has been finished can be checked with the
devices (d1)+0 and (d1)+1:
● The bit device (d1)+0 turns ON at the END processing of the scan in which the ERRCLR
instruction has been completed and turns OFF at the next END processing.
● The bit device (d1)+1 indicates an error during execution of the ERRCLR instruction. When
the instruction has been completed normal, this device stays OFF. When an error occurs
during execution of the ERRCLR instruction, (d1)+1 turns ON at the END processing of the
scan in which the ERRCLR instruction has been completed and turns OFF at the next END
processing.
The timing when executing the ERRCLR instruction is shown below:
Instruction
Bit device (d1)+0 completed
Error
Bit device (d1)+1
One scan
Operation When an error occurs during the processing of the ERRCLR instruction, the bit device (d1)+1
Error is set, and an error code is stored in (s1)+1. For more information about the error codes please
12 – 64
Instructions for ETHERNET interface modules ERRCLR
Program ERRCLR
Example
The following program is used to clear the error code issued for connection 1. The ETHERNET
module occupies the inputs and outputs from X/Y0.
● IEC editors (On the next page this program example is shown for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
12 – 66
Instructions for ETHERNET interface modules ERRRD
12.3.7 ERRRD
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 68
Instructions for ETHERNET interface modules ERRRD
Instruction
Bit device (d1)+0 completed
Error
Bit device (d1)+1
One scan
Operation When an error occurs during the processing of the ERRRD instruction, the bit device (d1)+1 is
Error set, and an error code is stored in (s1)+1. For more information about the error codes please refer
to the following manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please refer to the user’s manual of the ETHERNET
interface module.
Program ERRRD
Example
The following program reads the error code which is issued if the opening of connection 1 has
failed. The ETHERNET module has the head I/O address X/Y0.
● IEC editors (On the next page this program example is shown for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
12 – 70
Instructions for ETHERNET interface modules ERRRD
12.3.8 UINI
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 72
Instructions for ETHERNET interface modules UINI
NOTE When performing re-initial processing of the ETHERNET module only, i.e., without changing the
local station IP address and operation settings, the control data should be specified so that the
value (0H) is stored in (s1)+2, the specification of target of change, before executing the UINI in-
struction.
The ETHERNET module clears external device address information that it has been maintaining
and performs re-initial processing in order to allow data communication to restart. (The initial
normal completion signal (X19) is on.)
12 – 74
Instructions for ETHERNET interface modules UINI
NOTES Please keep the following points in mind when reinitializing an ETHERNET module. (Failure to
do so may cause errors in the data communication with the external devices.)
- Be sure to end all current data communication with external devices and close all connections
before performing a re-initial process.
- Do not mix a re-initial processing done by writing directly into buffer memory, for instance by
using a TO instruction, with a re-initial processing via UINI instruction.
Also, do not request another re-initial processing while an UINI instruction is already being
executed.
- Be sure to reset external devices if the IP address of the ETHERNET module has been
changed. (If an external device maintains the ETHERNET address of a device with which it
communicates, the communication may not be continued after the IP address of the
ETHERNET module has been changed.)
Operation When an error occurs during the processing of the UINI instruction, the bit device (d1)+1 is set,
Error and an error code is stored in (s1)+1. For more information about the error codes please refer to
the following manuals:
● When the error code is 4FFFH or less, you will find more information in chapter 13 of this
manual.
● When the error code is C001H or higher, please see the user’s manual of the ETHERNET
interface module.
Program UINI
Example
For the ETHERNET module with the head I/O address X/Y0 (Range from X/Y0 to X/Y1F) a
re-initial process is performed.
NOTES Only the connections 1 and 2 are used for this program example. When other connections are
used the corresponding signals must be used.
For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
12 – 76
Instructions for ETHERNET interface modules UINI
12 – 78
Instructions for MELSECNET/H PAIRSET
12.4.1 PAIRSET
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
Bits
Set Data
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
(s1)+0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
(s1)+1 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17
(s1)+2 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33
(s1)+3 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49
NOTES The pairing setting instruction is valid only on control stations. Any settings on normal stations
are voided.
If in a redundant system consisting of Q4ARCPUs the control systems network module fails to
data-link due to cable connection breakage, switching from control system to standby system is
done only when pairing setting has been performed.
Program PAIRSET
Example
Pairing is performed for the stations 1 and 2 as well as for the stations 4 and 5 of a redundant
system:
A61RP AJ71 AS92R Q4RCPU A6RAF Q4RCPU AS92R AJ71 A61RP QnACPU AJ71
QLP21 QLP21 QLP21
Network No. 1
QnACPU AJ71 A61RP AJ71 AS92R Q4RCPU A6RAF Q4RCPU AS92R AJ71 A61RP
QLP21 QLP21 QLP21
12 – 80
Instructions for MELSECNET/H PAIRSET
The settings are stored in the data registers D0 to D3. Bit 1 (b1) of D0 is set for the pairing of
the stations 1 and 2 whereas b4 is set for the pairing of the stations 4 and 5:
Bits
Set Data
b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
D0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
D1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
12 – 82
Instructions for CC-Link RLPASET
12.5.1 RLPASET
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 84
Instructions for CC-Link RLPASET
(s5)+75
size
Receive
(s5)+76
buffer size The same as for the 1st module.
Automatic
(s5)+77 refresh buffer
size
Bit device which is set for one scan after completion of the RLPASET instruction. (d)+1
indicates that an error has occured during execution of the instruction.
12 – 86
Instructions for CC-Link RLPASET
The default parameter settings for (s2)+0 to (s2)+63 are „0101H“ to „0140H“. (Station number
1 to 64, one station occupied, remote I/O station)
The numbers 1 to 64 in the table indicate a station number. When a bit is set the corresponding
station is selected.
Functions Parameter setting for a CC-Link Network and start of the data link
RLPASET Parameter setting instruction
RLPASET Network
parameter
1.
Device 2.
memory
4. Execution result
1. The network parameters stored in (s1) to (s5) are send to master module of the CC-Link
designated by Un using the RLPASET instruction.
2. The received settings are checked by the master module.
3. If the settings are correct, the data link is started.
4. The device specified by (d) is set.
It is only possible to execute one RLPASET instruction at a time.
12 – 88
Instructions for CC-Link RLPASET
Whether the execution of the RLPASET instruction has been finished can be checked with the
devices (d1)+0 and (d1)+1:
● The bit device (d1)+0 turns ON at the END processing of the scan in which the RLPASET
instruction has been completed and turns OFF at the next END processing.
● The bit device (d1)+1 indicates an error during execution of the RLPASET instruction. When
the instruction has been completed normal, this device stays OFF. When an error occurs
during execution of the UINI instruction, (d1)+1 turns ON at the END processing of the scan
in which the RLPASET instruction has been completed and turns OFF at the next END
processing.
The following figure shows the timing when the RLPASET instruction is executed and all sta-
tions are normal:
Refresh instruction
(SB03)
Instruction completed
with error [(d)+1]
One scan
The timing for the RLPASET instruction in the case of a faulty station is shown below:
Completion of the
Host data link status RLPASET instruction
(X01)
Refresh instruction
(SB03)
Instruction completed
with error [(d)+1]
One scan
Return to system
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module designated by (Un) is not a special function module. (error code: 2112)
● When an attempt was made to execute an unsupported instruction. (error code: 4002)
● When the number of devices in the instruction is incorrect. (error code: 4003)
● When the instruction specifies a device that cannot be used. (error code: 4004)
● When the instruction contains data that cannot be used. (error code: 4100)
● When the number of points for data used in the instruction exceeds the available range, or
storage data and constants of a device specified by the instruction exceeds the available
range (including dummy devices). (error code: 4101)
12 – 90
Instructions for CC-Link RLPASET
Program RLPASET
Example
This program transfers the network parameter to the master station occupying the head I/O
number X/Y000. The CC-Link network consists of three slave stations:
Station No. 1
The devices designated by (s1) to (s5) are holding the following values:
Allocated
Parameter Setting Set value
device
(s1)+1 Validation of the settings All settings are valid. 15 D1
(s1)+2 Number of connected modules 3 slave modules 3 D2
(s1)+3 Number of retries 3 times 3 D3
Control data
for the (s1)+4 Number of automatic return modules 1 module 1 D4
execution of
the instruction (s1)+5 Operation specification when the Stop 0 D5
PLC CPU has stopped
(s1)+6 Scan mode specification Asynchonous 0 D6
(s1)+7 Delay time setting 0 µs 0 D7
Local station,
(s2)+0 Settings for the first station occupies 1 station, 2101H D10
Station No. 1
Remote I/O station,
Settings for
(s2)+1 Settings for the second station occupies 1 station, 102H D11
slave stations
Station No. 2
Remote I/O station,
(s2)+2 Settings for the third station occupies 1 station, 103H D12
Station No. 3
(s3)+0 4 D80
The contents of the data registers D1 to D102 must be set according to the above table before
the RLPA instruction is called.
● IEC editors (On the next page this program example is shown for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
The required settings are moved to the devices used for (s1) to (s5).
Parameter setting
At this position, write the instructions that should be executed when the RLPASET instruction
has been completed normally.
At this position, write the instructions that should be executed when the RLPASET instruction
has been completed with an error.
12 – 92
Instructions for CC-Link RLPASET
An instruction at this position will be executed when the RLPASET instruction has been completed normally.
An instruction at this position will be executed when the processing of the RLPASET instruction has been completed
with an error.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
The required settings are written to the devices designated by (s1) to (s5)
using MOV instructions.
At this position, write the instructions that should be executed when the RLPASET
instruction has been completed normally.
At this position, write the instructions that should be executed when the RLPASET
instruction has been completed with an error.
An instruction at this position will be executed when the RLPASET instruction has been completed normally.
An instruction at this position will be executed when the processing of the RLPASET instruction has been
completed with an error.
12 – 94
Instructions for CC-Link RIRD
12.5.2 RIRD
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 96
Instructions for CC-Link RIRD
From software version J of the master module two codes (both stored in s+2) are used to spec-
ify the data to read: The access code selects whether access is made to the buffer memory
of a CC-Link module or the device memory in the CPU module. With the device code the area
of the buffer memory or the device is designated:
● Access to the buffer memory of a CC-Link module (Access code: 04H)
Access to Device code
Buffer memory in an intelligent device station 00H
Random access buffer 20H
Remote inputs 21H
Remote outputs 22H
Buffer memory in a master or local station
Remote register 24H
Link special relays 63H
Link special register 64H
12 – 98
Instructions for CC-Link RIRD
Functions Read from buffer memory of intelligent device station or from device memory of PLC CPU
RIRD Data read
The RIRD instruction reads data from the buffer memory of an intelligent device connected to
the CC-Link. When a master module with a software version from J onward or a CC-Link mod-
ule of the MELSEC System Q is used, it is also possible to access the PLC CPU device mem-
ory of another station connected to the CC-Link network.
The head address of the buffer memory or the head device is designated by (s)+3. The station
number of the other station is designated by (s)+1. This station is connected to the master/local
station specified at Un. The read data is stored in the CPU which executes the RIRD instruction
to the devices starting from d1. The number of data to read is designated by (s)+4.
● Accessing the buffer memory of an CC-Link module
RIRD
instruction Request
(s)+3
CC-Link Buffer
memory
d1 Data from
Read buffer memory
data
● Accessing the device memory in the PLC CPU of another station on CC-Link
Master/local
SPS-CPU Station (Un) Station (s)+1 PLC CPU
Request
RIRD
CC-Link
(s)+3
Device
Data from the memory
d1 device memory
Read
Data
Whether the execution of the RIRD instruction has been finished can be checked with the
devices (d2)+0 and (d2)+1:
● The bit device (d2)+0 turns ON at the END processing of the scan in which the RIRD
instruction has been completed and turns OFF at the next END processing.
● The bit device (d2)+1 indicates an error during execution of the RIRD instruction. When the
instruction has been completed normal, this device stays OFF. When an error occurs during
execution of the RIRD instruction, (d2)+1 turns ON at the END processing of the scan in
which the RIRD instruction has been completed and turns OFF at the next END processing.
The following figure shows the timing when the RIRD instruction is being executed:
RIRD instruction
Instruction
Bit device (d2)+0 completed
Error
Bit device (d2)+1
One scan
It is possible to execute RIRD instructions for multiple stations at the same time, but it is not
possible to access the same intelligent device station or local station simultaneously from more
than one station.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the area designated by s contains data that cannot be used. (Error code: 4100)
● When the number of data set to be used exceeds the allowable range. (Error code: 4101)
● When the storage data or constants of the device specified with the instruction exceeds the
allowable range. (Error code: 4101)
12 – 100
Instructions for CC-Link RIRD
Program RIRD
Example
The following program is executed in the PLC CPU of the master station. When the input X0 is
set the contents of 10 buffer memory addresses is read from the intelligent device station with
the station number, starting with the buffer memory address 100H. The read data is stored in
the PLC CPU from data register D0 onward. The head I/O number of the master module of CC-
Link is X/Y40.
● IEC editors (On the next page this program example is shown for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
Read instruction
At this position, write the instructions that should be executed when the RIRD instruction
has been completed normally.
At this position, write the instructions that should be executed when the RIRD instruction
has been completed with an error.
An instruction at this position will be executed when the RIRD instruction has been completed normally.
An instruction at this position will be executed when the RIRD instruction has been completed annormally.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the
RIRD instruction has been completed normally.
At this position, write the instructions that should be executed when the
RIRD instruction has been completed with an error.
An instruction at this position will be executed when the RIRD instruction has been completed normally.
An instruction at this position will be executed when the RIRD instruction has been completed annormally.
12 – 102
Instructions for CC-Link RIWT
12.5.3 RIWT
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 104
Instructions for CC-Link RIWT
From software version J of the master module two codes (both stored in (d1)+2) are used to
specify the target for the data: The access code selects whether data is written to the buffer
memory of a CC-Link module or the device memory in the CPU module. With the device code
the area of the buffer memory or the devices, which will be overwritten, is designated:
● Access to the buffer memory of a CC-Link module (Access code: 04H)
Access to Device code
Buffer memory in an intelligent device station 00H
Random access buffer 20H
Remote inputs 21H
Remote outputs 22H
Buffer memory in a master or local station
Remote register 24H
Link special relays 63H
Link special register 64H
12 – 106
Instructions for CC-Link RIWT
Functions Write to buffer memory of intelligent device station or to device memory of PLC CPU
RIWT Data write
The RIWT instruction writes data to the buffer memory of an intelligent device connected to the
CC-Link. When a master module with a software version from J onward or a CC-Link module
of the MELSEC System Q is used, it is also possible to write to the PLC CPU device memory
of another station connected to the CC-Link network.
The station number of the other station is designated by (s)+1. This station is connected to the
master/local station specified at Un. Where the write data are is stored is designated by d1. At
(s)+2 a code is stored which specifies whether to write to a buffer memory or to the device
memory of a CPU module. The head address of the buffer memory or the head device is des-
ignated by (s)+3. The number of data to write is designated by (s)+4.
● Accessing the buffer memory of an CC-Link module
RIWT
instruction
Writing of data
(s)+3
CC-Link Buffer
memory
d1
Stored
data
● Accessing the device memory in the PLC CPU of another station on CC-Link
Master/local
PLC CPU Station (Un) Station (s)+1 PLC CPU
RIWT
Whether the execution of the RIWT instruction has been finished can be checked with the
devices (d2)+0 and (d2)+1:
● The bit device (d2)+0 turns ON at the END processing of the scan in which the RIWT
instruction has been completed and turns OFF at the next END processing.
● The bit device (d2)+1 indicates an error during execution of the RIWT instruction. When the
instruction has been completed normal, this device stays OFF, but when an error occurs
during execution of the RIWT instruction, (d2)+1 turns ON at the END processing of the
scan in which the RIWT instruction has been completed and turns OFF at the next END
processing.
The following figure shows the timing when the RIWT instruction is being executed:
RIWT instruction
Instruction
Bit device (d2)+0 completed
Error
Bit device (d2)+1
One scan
Please note, that it’s possible to execute RIWT instructions for multiple stations at the same
time, but the same intelligent device station or local station cannot be accessed simultaneously
from more than one station.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the area designated by s contains data that cannot be used. (Error code: 4100)
● When the number of data set to be used exceeds the allowable range. (Error code: 4101)
● When the storage data or constants of the device specified with the instruction exceeds the
allowable range. (Error code: 4101)
12 – 108
Instructions for CC-Link RIWT
Program RIWT
Example
The following program is processed in the PLC CPU of the master station. When the input X0
is set, the contents of the data registers D0 to D9 is moved to the intelligent device station
number 1 and stored to the buffer memory addresses 100H to 109H. The head I/O number of
the master module of CC-Link is X/Y40.
● IEC editors
(On the next page this program example is shown for the MELSEC instruction list and the
ladder diagram of the GX Works2.)
At this position, write the instructions that should be executed when the RIWT instruction
has been completed normally.
At this position, write the instructions that should be executed when the RIWT instruction
has been completed with an error.
An instruction at this position will be executed when the RIWT instruction has been completed normally.
An instruction at this position will be executed when the RIWT instruction has been completed annormally.
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the
RIWT instruction has been completed normally.
At this position, write the instructions that should be executed when the
RIWT instruction has been completed with an error.
An instruction at this position will be executed when the RIWT instruction has been completed normally.
An instruction at this position will be executed when the RIWT instruction has been completed annormally.
12 – 110
Instructions for CC-Link RIRCV
12.5.4 RIRCV
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 112
Instructions for CC-Link RIRCV
Functions Reading of data from the buffer memory of an intelligent device station (with handshake)
RIRCV Data read (with handshake)
The execution of a RIRCV instruction is only possible in the PLC CPU of the master station.
This instruction is used to read data from the buffer memory on an intelligent device station.
The data exchange is controlled by handshaking devices:
Master Station
station (s1)+1
RX
Receive 2. RY
Device buffer
memory
3.
1. The buffer memory address specified by (s1)+3 of the station specified by (s1)+1 is
accessed. The devices specified in s2 are used for the handshake.
2. The contents of the number of buffer memory addresses specified in (s1)+4 is read to the
receive buffer of the master module.
3. The read data is stored in the PLC CPU to the devices starting with the one specified in d1.
After that, the bit device specified in (d2)+0 is set for one scan.
Whether the execution of the RIRCV instruction has been finished can be checked with the
devices (d2)+0 and (d2)+1:
● The bit device (d2)+0 turns ON at the END processing of the scan in which the RIRCV
instruction has been completed and turns OFF at the next END processing.
● The bit device (d2)+1 indicates an error during execution of the RIRCV instruction. When
the instruction has been completed normal, this device stays OFF. When an error occurs
during execution of the RIRCV instruction, (d2)+1 turns ON at the END processing of the
scan in which the RIRCV instruction has been completed and turns OFF at the next END
processing.
12 – 114
Instructions for CC-Link RIRCV
The following figure shows the timing when the RIRCV instruction is being executed:
RIRCV instruction
RYn
RXn
Although it’s possible to execute RIRCV instructions for multiple intelligent device stations at
the same time, it’s not possible to access the same intelligent device station simultaneously
from more than one station.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the area designated by s contains data that cannot be used. (Error code: 4100)
● When the number of data set to be used exceeds the allowable range. (Error code: 4101)
● When the storage data or constants of the device specified with the instruction exceeds the
allowable range. (Error code: 4101)
Program RIRCV
Example
The following program is executed in the PLC CPU of the master station. When M1 is set, the
contents of 11 buffer memory addresses is read from the intelligent device station with the sta-
tion number 63. Reading starts at the buffer memory address 400H. The data will be stored in
the CPU module from data register D40 onward. To the master module of CC-Link the head
I/O number X/Y00 is assigned. The remote devices RX2, RY2 and RWr2 are used for hand-
shake. The completion of the reading is indicated by two devices. ((s2)+2 is set to „1“.)
● IEC editors
(On the next page this program example is shown for the MELSEC instruction list and the
ladder diagram of the GX Works2.)
At this position, write the instructions that should be executed when the RIRCV instruction
has been completed normally.
At this position, write the instructions that should be executed when the RIRCV instruction
has been completed with an error.
An instruction at this position will be executed when the RIRCV instruction has been completed normally.
An instruction at this position will be executed when the RIRCV instruction has been completed annormally
12 – 116
Instructions for CC-Link RIRCV
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the RIRCV instruction
has been completed normally.
At this position, write the instructions that should be executed when the RIRCV instruction
has been completed with an error.
An instruction at this position will be executed when the RIRCV instruction has been completed normally.
An instruction at this position will be executed when the RIRCV instruction has been completed annormally.
12 – 118
Instructions for CC-Link RISEND
12.5.5 RISEND
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 120
Instructions for CC-Link RISEND
Functions Write (with handshake) to the buffer memory of an intelligent decive station
RISEND Sending of data (with handshake)
The RIRCV instruction can only be performed in the PLC CPU of the master station and is used
to write data to the buffer memory on an intelligent device station. The data exchange is con-
trolled by handshaking devices:
Master Station
station (s1)+1
1. 2. RX
Send 3. RY
Device buffer
memory
4.
1. The data for the intelligent device station is moved to the send buffer of the master station.
2. The data is written to the buffer memory address specified by (s1)+3 of the station specified
by (s1)+1. The devices specified in s2 are used for the handshake.
3. A write complete response is send to the master station.
4. The device specified in (d2)+0 is set.
Whether the execution of the RISEND instruction has been finished can be checked with the
devices (d2)+0 and (d2)+1:
● The bit device (d2)+0 turns ON at the END processing of the scan in which the RISEND
instruction has been completed and turns OFF at the next END processing.
● The bit device (d2)+1 indicates an error during execution of the RISEND instruction. When
the instruction has been completed normal, this device stays OFF. When an error occurs
during execution of the RISEND instruction, (d2)+1 turns ON at the END processing of the
scan in which the RISEND instruction has been completed and turns OFF at the next END
processing.
12 – 122
Instructions for CC-Link RISEND
The following figure shows the timing when the RIRCV instruction is being executed:
RIRCV instruction
RYn
RXn
Although it’s possible to execute RISEND instructions for multiple intelligent device stations at
the same time, it’s not possible to access the same intelligent device station simultaneously
from more than one station.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the area designated by s contains data that cannot be used. (Error code: 4100)
● When the number of data set to be used exceeds the allowable range. (Error code: 4101)
● When the storage data or constants of the device specified with the instruction exceeds the
allowable range. (Error code: 4101)
Program RISEND
Example
The following program, which is executed in the PLC CPU of the master station, writes 1 word
of data to the buffer memory address 111H of the intelligent device station with the station
number 63. To the master module of CC-Link, the head I/O number X/Y000 is assigned. The
devices RX4, RY4 and RWr4 are used for handshaking. The completion of the reading is indi-
cated by two devices. ((s2)+2 is set to „1“.)
● IEC editors (On the next page this program example is shown for the MELSEC instruction
list and the ladder diagram of the GX Works2.)
At this position, write the instructions that should be executed when the RISEND instruction
has been completed normally.
At this position, write the instructions that should be executed when the RISEND instruction
has been completed with an error.
An instruction at this position will be executed when the RISEND instruction has been completed normally.
An instruction at this position will be executed when the RISEND instruction has been completed annormally
12 – 124
Instructions for CC-Link RISEND
NOTE For the IEC editors it is neccessary to define the variables in the header of the program organ-
ization unit (POU). Without variable definition it would cause compiler or checker error mes-
sages. For details see section 3.5.2 "Addressing of arrays and registers in the GX IEC Devel-
oper" of this manual.
At this position, write the instructions that should be executed when the RISEND instruction
has been completed normally.
At this position, write the instructions that should be executed when the RISEND instruction
has been completed with an error.
An instruction at this position will be executed when the RISEND instruction has been completed normally.
An instruction at this position will be executed when the RISEND instruction has been completed annormally.
12.5.6 RITO
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 126
Instructions for CC-Link RITO
Master Destination
station station (n1)
Automatic
Automatic updated
updated
buffer
buffer memory
memory
Devices n2
(d) Transferred when
data is updated
The RITO instruction cannot be executed at more than one station for the same intelligent
device station.
Up to 4096 words may be written by the RITO instruction.
The assignment of the automatic updated buffers is performed using the „station information
settings“ of the network parameters of the GX Works2 or GX IEC Developer.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the station number specified at n1 does not exist. (Error code: 4100)
● When the number of words to write specified in n3 is outside of the setting range.
(Error code: 4100)
12 – 128
Instructions for CC-Link RITO
Program RITO
Example
When the input X0 is set, the contents of 10 data registers (D0 to D10) is moved to the auto-
matic updated buffer memory for the station set to station number 1 in the master module. This
buffer begins at the address 300H. The data is stored from address 400H onward (offset = 100).
300H
Automatic
updated
buffer memory
5FFH
12.5.7 RIFR
CPU High
Basic Process Redundant Universal LCPU
Performance
GX Works2
12 – 130
Instructions for CC-Link RIFR
Master Station
station (n1)
Automatic Automatic
updated
updated buffer memory
buffer
Devices n2
(d) Transferred when
data is updated
The RIFR instruction cannot be executed at more than one station for the same intelligent
device station.
Up to 4096 words may be read by the RIFR instruction.
The assignment of the automatic updated buffers is performed using the „station information
settings“ of the network parameters of the GX Works2 or GX IEC Developer.
Operation In the following cases an operation error occurs, the error flag SM0 is set, and an error code is
Error stored in SD0:
● When the module specified by Un is not an intelligent function module or a special function
module. (Error code: 2112)
● When an attempt was made to execute an unsupported instruction. (Error code: 4002)
● When the number of devices in the instruction is incorrect. (Error code: 4003)
● When the instruction specifies a device that cannot be used. (Error code: 4004)
● When the station number specified at n1 does not exist. (Error code: 4100)
● When the number of words to read specified in n3 is outside of the setting range.
(Error code: 4100)
12 – 132
Instructions for CC-Link RIFR
Program RIFR
Example
When the input X0 is set, the following program reads the contents of 10 points of the automatic
updated buffer set to station number 1 in the master module and stores this data in the PLC
CPU to D0 and the successive registers. The automatic updated buffer begins at the address
300H. Reading starts at the address 400H (offset = 100). The master module of CC-Link is allo-
cated to the I/O numbers X/Y040 to X/Y41F.
300H
Automatic
updated
buffer memory
5FFH
12 – 134
Error Codes Error code list
13 Error Codes
13.1 Error code list
If an error occurs when the PLC is turned ON, set into RUN mode, or during operation, the self-
diagnostic functions of the CPU returns an error (LED indication or message on LED display)
and store the error information in special relays (SM) and special registers (SD).
When an error occurs at communication request from a programming tool, intelligent function
module, or network system to the CPU module, the CPU module returns the error code (4000H
to 4FFFH) to the request source.
This section describes errors that may occur in the CPU module and corrective actions for the
errors.
The following describes how to read section 13.2 "Error code list (1000 to 1999)" to section
13.8 "Error code list (7000 to 10000)". The list contains errors in QCPU and LCPU.
● Error code, common information, and individual information
The error code is stored in SD0. The common information is stored in SD5 to SD15. The
individual information is stored in SD16 to SD26.
● Corresponding CPU
– QCPU: All the System Q series CPU modules
– Q00J/Q00/Q01: Basic model QCPU
– Qn(H): High Performance model QCPU
– QnPH: Process CPU
– QnPRH: Redundant CPU
– QnU: Universal model QCPU
– Q00UJ/Q00U/Q01U: Q00UJCPU, Q00UCPU, and Q01UCPU
– LCPU: All the L series CPU modules
– CPU module model: Only the specified model (Example: Q02UCPU, L26CPU-BT)
There are two types of errors: errors detected by the self-diagnostic function of the CPU mod-
ule and errors detected during communication with the CPU module.
The relation between the error detection pattern, error detection location and error code is
shown in the following table.
An error can be cleared as far as the CPU module continues its operation regardless of the
error.
1. Remove the error cause.
2. Store the error code to be cleared in SD50.
3. Turn on SM50.
4. The error is cleared.
When the error in the CPU module is cleared, the special relay and special register or LEDs
relating to the error return to the status before the error. If the same error occurs after clearing
the error, the error will be registered to the error history again.
When multiple annunciators are detected, only the first annunciator detected can be cleared.
For details on clearing errors, refer to the following manual:
User's manual (Function Explanation, Program Fundamentals) for the CPU module used
13 – 2
Error Codes Error code list (1000 to 1999)
13 – 4
Error Codes Error code list (1000 to 1999)
13 – 6
Error Codes Error code list (1000 to 1999)
13 – 8
Error Codes Error code list (1000 to 1999)
13 – 10
Error Codes Error code list (1000 to 1999)
13 – 12
Error Codes Error code list (1000 to 1999)
13 – 14
Error Codes Error code list (1000 to 1999)
13 – 16
Error Codes Error code list (1000 to 1999)
13 – 18
Error Codes Error code list (2000 to 2999)
13 – 20
Error Codes Error code list (2000 to 2999)
13 – 22
Error Codes Error code list (2000 to 2999)
13 – 24
Error Codes Error code list (2000 to 2999)
13 – 26
Error Codes Error code list (2000 to 2999)
13 – 28
Error Codes Error code list (2000 to 2999)
13 – 30
Error Codes Error code list (2000 to 2999)
13 – 32
Error Codes Error code list (2000 to 2999)
13 – 34
Error Codes Error code list (2000 to 2999)
13 – 36
Error Codes Error code list (2000 to 2999)
13 – 38
Error Codes Error code list (3000 to 3999)
13 – 40
Error Codes Error code list (3000 to 3999)
13 – 42
Error Codes Error code list (3000 to 3999)
13 – 44
Error Codes Error code list (3000 to 3999)
13 – 46
Error Codes Error code list (3000 to 3999)
13 – 48
Error Codes Error code list (3000 to 3999)
13 – 50
Error Codes Error code list (3000 to 3999)
13 – 52
Error Codes Error code list (3000 to 3999)
13 – 54
Error Codes Error code list (3000 to 3999)
13 – 56
Error Codes Error code list (4000 to 4999)
13 – 58
Error Codes Error code list (4000 to 4999)
13 – 60
Error Codes Error code list (4000 to 4999)
13 – 62
Error Codes Error code list (4000 to 4999)
13 – 64
Error Codes Error code list (4000 to 4999)
13 – 66
Error Codes Error code list (4000 to 4999)
13 – 68
Error Codes Error code list (4000 to 4999)
13 – 70
Error Codes Error code list (5000 to 5999)
13 – 72
Error Codes Error code list (6000 to 6999)
13 – 74
Error Codes Error code list (6000 to 6999)
13 – 76
Error Codes Error code list (6000 to 6999)
13 – 78
Error Codes Error code list (6000 to 6999)
13 – 80
Error Codes Error code list (7000 to 10000)
13 – 82
Error Codes Error code list (7000 to 10000)
13 – 84
Error Codes Error codes returned to request source
4022H The file with the specified file name or file No. does
Check the specified file name and file No.
not exist.
4023H The file name and file No. of the specified file do not
Delete the file and then recreate the file.
match.
4024H The specified file cannot be handled by a user. Do not access the specified file.
4025H The specified file is processing the request from Complete the current processing and then send the
another programming tool. request again.
CPU file related error
Any of the file password, drive keyword, or file Specify any of the file password, drive keyword, or
4026H password 32 set in advance to the target drive file password 32 set in advance to the target drive
(memory) must be specified. (memory) and then access.
The specified range is larger than the file size Check the specified range and access within that
4027H
range. range.
4028H The same file already exists. Reexecute after changing the file name.
Revise the specified file contents. Or reexecute
4029H The specified file capacity cannot be obtained. after cleaning up and reorganizing the specified
drive memory.
After backing up the data in the CPU module,
402AH The specified file is abnormal.
execute programmable controller memory format.
4044H A control bus error occurred during access to the Check the specified intelligent function module and
intelligent function module. other modules and base units for a hardware fault.
The request contents cannot be executed because
4050H Turn off the memory card write protect switch.
the memory card write protect switch is on.
Check the following and take countermeasures.
4051H The specified device memory cannot be accessed. Is the memory one that can be used?
Is the specified drive memory correctly installed?
4052H The specified file attribute is read only so the data Do not write data in the specified file. Or change the
Protect error cannot be written. file attribute.
Check the specified drive memory. Or reexecute
4053H An error occurred when writing data to the
write after changing the corresponding drive
specified drive memory.
memory.
An error occurred when deleting the data in the Check the specified drive memory. Or re-erase after
4054H
specified drive memory. replacing the corresponding drive memory.
13 – 86
Error Codes Error codes returned to request source
4063H The registered number of locked files exceeded the Finish the file access from another programming
maximum value. tool, and then execute again.
Check the settings for the online debug
Settings for the online debug function (such as function (such as online change, sampling
trace, and monitoring condition setting) and
4064H online change, sampling trace, and monitoring data logging function.
condition setting) and for the data logging function
Execute again after checking the
are incorrect. communication route such as the
Online registration error
communication cable.
Check the device assignment parameters of the
The device allocation information differs from the
4065H CPU module or the device assignment of the
parameter.
request data.
Correct the drive keyword of the specified
drive.
The specified drive keyword, file password, or file
4066H Correct the file password of the specified file.
password 32 is incorrect.
Correct the file password 32 of the specified
file.
Check the system area capacity of the user
setting specified for programmable controller
memory format.
4067H Monitor communication was unsuccessful.
Execute again after checking the
communication route such as the
communication cable.
4068H Operation is disabled because it is being performed Finish the operation of another programming tool
with another programming tool. and then execute again.
The drive (memory) number that cannot be Check the specified drive and specify the correct
406AH
handled (other than 0 to 4) was specified. drive.
Read the program from the CPU module to match it
The program not yet corrected and the one
4070H Circuit inquiry error with that of the programming tool, and then
corrected by online program change are different.
execute online change again.
4085H Pointer P, I cannot be specified because the Specify pointer P, I after registering the program to
program is not specified in the parameter. be executed in the parameter.
Check the pointer No. to be added and make
4086H Pointer P, I has already been added.
correction.
40A1H A number of blocks that exceeds the range was Check the number of settings and make a
specified. correction.
40A2H A step No. that is outside the range was specified. Check the setting contents and make a correction.
Check the number of settings and make a
40A3H Step range limit exceeded
SFC device specification error correction.
40B2H The program specified in SFC file operation is not Check the specified file name and make a
SFC file related error an SFC program. correction.
Using online program change of SFC, an attempt
was made to execute rewrite operation of the "SFC
dedicated instruction", such as the "STEP start Write the program after setting the CPU module to
40B3H
instruction or transition start instruction", that the STOP status.
shows an SFC chart. (SFC dedicated instruction
cannot be written during RUN.)
13 – 88
Error Codes Error codes returned to request source
4102H An attempt was made to erase the Flash ROM Execute again after setting the CPU module to the
during use of the file register. STOP status.
Execute online program change again, or write the
The instruction written during RUN is wrong or
4103H program after setting the CPU module to the STOP
illegal.
status.
4105H CPU module internal memory hardware fault Change the CPU module.
The command cannot be executed since the CPU
4106H Execute the operation again after the CPU module
module is performing system initialization
has started.
processing.
Other errors
An attempt was made to perform the operation of a
4107H Do not execute the function unsupported by the
function unavailable for the target CPU module
target CPU module.
model name.
Execute device monitor/test again. Before
4108H Operation cannot be made normally by device
execution, check that access is not made to the
monitor/test.
access prohibited area.
The specified operation cannot be executed since
4109H Execute the request again after deregistering the
the monitoring, set the condition for other
monitoring condition on the same screen.
application in same computer, is in execution.
410AH The specified command cannot be executed Execute the request again after the online program
because of online program change. change.
The registration of monitoring condition was Execute the registration of monitoring condition
410BH
canceled because of online program change. again after the online program change.
Since the CPU module is in a stop error status, it Execute the request again after resetting the CPU
4110H
cannot execute the request. module.
CPU module error The requested operation cannot be performed
4111H Execute the request again after the other CPU
since the other CPU modules have not yet started
modules have started.
in the multiple CPU system.
412AH Cannot be executed since the specified drive Execute again after changing the target drive
(memory) is ROM. (memory).
Execute again after changing the write inhibit
412BH The specified drive (memory) is write-inhibited.
condition or drive (memory).
412FH The drive (memory) capacity differs between the Execute again after checking the drive (memory)
drive (memory) copy destination and copy source. copy destination and copy source.
The drive (memory) type differs between the drive Execute again after checking the drive (memory)
4130H
(memory) copy destination and copy source. copy destination and copy source.
The file name of the file copy destination is the
4131H Execute again after checking the file names.
same as that of the copy source.
413EH Operation is disabled for the specified drive Execute again after changing the target drive
(memory). (memory).
4150H An attempt was made to format the drive protected Do not format the target drive (memory) as it
by the system. cannot be formatted.
File-related errors
An attempt was made to delete the file protected by
4151H Do not delete the target file as it cannot be deleted.
the system.
The registered number of forced inputs/outputs
4160H Deregister the unused forced inputs/outputs.
exceeded the maximum value.
Execute again after securing the area that enables
4165H The multiple-block online change system file does
multiple-block online change at the time of
not exist.
programmable controller memory format.
Due to unsuccessful online change (files)
previously occurred for some reason (example:
Online change (files) is disabled because it is being
4166H communication failure), the processing is kept
executed from the same source.
incomplete. Forcibly perform another online
change (files).
Due to unsuccessful online change (files) from
another source previously occurred for some
reason (example: communication failure), the
Online change (files) is disabled because it is being
4167H processing is kept incomplete. If online change
performed from another source.
Online registration error (files) is not being performed by any other
programming tool, forcibly perform another online
change (files).
Deregister the device test with executing condition
The registered number of device test with executing in CPU module, or decrease the number of
4168H
condition exceeds 32. registering device test with executing condition at
one time.
Deregister the device test with executing condition
The device test with executing condition has never
4169H after checking the registered number of device test
been registered.
with executing condition in CPU module.
Check whether the specified executing conditions
The specified executing condition does not exist.
416AH (program, step No. operation timing, device name)
(Device test with executing condition)
in deregistering are registered.
416BH The specified program is SFC program. (Device test Check the specifying program name in de/
with executing condition) registering the device test with executing condition.
13 – 90
Error Codes Error codes returned to request source
4171H The port for communication use is at remote Execute communication after unlocking the remote
password locking status. password processing.
Stop transmitting from several modules
simultaneously when setting a remote
password and using User Datagram Protocol
4174H Requested for a wrong module to unlock remote (UDP) in MELSOFT connection.
password. The MELSOFT connection can be used with
Transmission Control protocol (TCP) when
setting a remote password.
Do not specify the direct connection when
Communication error occurred in direct using other connection setting.
4176H Do not turn off the CPU power during
connection. communication, reset the power, and plug out
the cable in direct connection.
File operation is disabled because the File
Transfer Protocol (FTP) function is in
operation.
Retry after the operation for FTP function is
4178H Online operation requiring a file access is completed.
performed with a programming tool while the
File Transfer Protocol (FTP) function is in
operation.
Ensure that the power supply module and the
CPU module are properly installed to the base
unit.
Ensure that the operating environment for the
system is met the general specifications of the
CPU module.
4180H Ethernet I/F Error System error.(The setting data in OS is abnormal.)
Check whether the power capacity is sufficient.
Reset the CPU module. If the same error code
is displayed again, the cause is a hardware
failure of the CPU module. Please consult your
local Mitsubishi representative, explaining a
detailed description of the problem.
Check the receiving module operation.
Check the status of the lines, such as cables,
hubs and routes, connected to receiving
modules.
Some line packets may be engaged. Retry to
communicate a little while later.
The receiving module may have no free space
Transmission to the receiving modules is in receive area (TCP window size is small).
4181H
unsuccessful. Check whether the receiving module processes
receive data, or whether the CPU module does
not send unnecessary data.
Check whether the settings of the subnet mask
pattern and the default router IP address of the
CPU module and the receiving modules are
correct, or whether the class of the IP address
is correct.
Check the receiving module operation.
Communication with receiving modules caused a Check the status of the lines such as a cable, a
4182H hub and a route to receiving modules.
time-out error.
Some line packets may be engaged. Retry to
communicate a little while later.
Check the receiving module operation.
4183H Communication with receiving modules was Check the status of the lines such as cables,
interrupted. hubs and routes connected to receiving
modules.
13 – 92
Error Codes Error codes returned to request source
For UDP/IP, the same Host station port No. is Specify a port number that is not duplicated
specified as MC protocol. with that of MC protocol.
41A4H
For UDP/IP, the specified host station No. is Correct the port number of the CPU module to
duplicated. avoid duplication.
Ethernet I/F socket The IP address setting of the target device for Correct the IP address. Specify A, B, or C for the
41A5H communication error OPEN processing is invalid. class.
Check the behavior of the target device.
Check OPEN processing of the target device.
Connection was not established in OPEN Correct the port number of the CPU module
41A6H and the IP address, port number, and open
processing for TCP connection. processing method of the target device.
Check whether the cables are securely
connected.
Correct the data length.
Data length is out of permissible range (2046 bytes If the data is longer than the range, split the
for the Built-in Ethernet port QCPU whose serial data and send them.
41A8H When the data length is 2047 to 10238 bytes,
number (first five digits) is "12051" or lower and
use the Built-in Ethernet port QCPU whose
10238 bytes for "12052" or higher) serial number (first five digits) is "12052" or
higher.
41CFH The specified drive (memory) has been used Execute again after checking the drive (memory)
exceeding the capacity. capacity.
The specified drive (memory) has no free space. Or Execute again after increasing the free space of
the drive (memory).
41D0H the number of files in the directory of the specified
Execute again after deleting file(s) in the drive
drive (memory) has exceeded the maximum. (memory).
13 – 94
Error Codes Error codes returned to request source
41FBH The specified file is already being manipulated from Execute again after the currently performed
the programming tool. operation is completed.
An attempt was made to erase the drive (memory) The specified drive (memory) is being used and
41FCH
being used. cannot be erased.
41FDH There are no data written to the Flash ROM. Write a file by executing write to PLC (Flash ROM).
The memory card has not been inserted.
Or the SD memory card lock switch is not slid Insert or re-insert the memory card.
41FEH down. Slide the SD memory card lock switch down.
The SD memory card is being disabled by Cancel the SD memory card forced disable
SM606 (SD memory card forced disable instruction.
instruction).
41FFH The memory card type differs. Check the memory card type.
13 – 96
Error Codes Error codes returned to request source
4213H The specified head I/O number differs from the one When making a request, specify the head I/O
Online module change-related
registered for online module change. number of the module being changed online.
error
4214H The specified module differs from the one changed Make a request again after mounting the module
online. that is the same as the one changed online.
When making a request, specify the head I/O
4215H number of the module that will be changed online,
The specified module does not exist.
or make a request again after mounting the
module.
4216H The specified module is faulty. Make a request again after changing the module.
4217H There is no response from the specified module. Continue the online module changing operation.
Do not make a request where an error occurred, or
4218H The specified module is incompatible with online
make a request again to the module compatible
module change.
with online module change.
The specified module is mounted on the extension Do not make a request to any modules mounted on
4219H base unit of the type that requires no power supply the extension base unit of the type that requires no
module. power supply module and the main base unit.
Make a request to the CPU module that controls the
421AH The specified module is not in a control group.
specified module.
An error occurred in the setting of the initial setting Resume processing after checking the contents of
421BH
parameter of the intelligent function module. the intelligent function module buffer memory.
421CH Cannot be executed as the parameter file has been Operation cannot be performed. Operation is
rewritten. interrupted.
Connect the programming tool to the new control
421DH System switching occurs during the online module system to check the status of the online module
change. change. According to the status of online module
change, take procedures for it.
The tracking cable may be faulty or the standby
The information of the online module change system may have an error.
cannot be sent to the standby system. When the Check the mounting status of the tracking cable
421EH system switching occurs during the online module or replace the tracking cable.
change, the online module change may not be Check the status of the standby system. When a
continued. stop error was detected by the standby system,
Online module change-related perform troubleshooting.
error
Set the connection destination of a
The module mounted on the extension base unit programming tool to the present control
421FH cannot be replaced online when the connection system.
destination is set to the standby system in the Perform the online module change to the
separate mode. module mounted on the extension base unit
again.
13 – 98
Error Codes Error codes returned to request source
424EH The control system/standby system specifying This function cannot be executed since it is not
method is not supported. supported.
Although system switching was executed from the
System switching was executed by the other programming tool, system switching was executed
424FH condition during execution of system switching by first by the other condition. Check the system for
the programming tool. any problem and execute the operation again as
Redundant system-related error necessary.
Execute communication again after changing the
tracking cable. If the same error recurs after the
4250H Sum check error occurred in tracking tracking cable is changed, the cause is the
communication. hardware fault of the CPU module. (Please consult
your local Mitsubishi representative, explaining a
detailed description of the problem.)
The command cannot be executed in the separate
4251H Execute again after changing to the backup mode.
mode.
By monitoring SD1690 (other system network
System switching was not executed since an error module No. that issued system switching request),
4252H occurred in the redundant system compatible identify the faulty redundant-compatible intelligent
network module of the standby system. module of the standby system, then remove the
module fault, and execute again.
Since a communication error or system switching
occurred during execution of online program
change to the control system CPU module, online
program change redundant tracking was
Since a communication error or system switching suspended. Execute online program change again
occurred during online program change to the after confirming that communication with the
4253H control system CPU module, online program control system CPU module and standby system
change to the standby CPU module cannot be CPU module can be normally made. If it takes time
executed. for the communication between the programming
tool and either the control system CPU module or
standby system CPU module, change the value in
SD1710 (standby system online start waiting time)
so that errors may be avoided.
13 – 100
Error Codes Error codes returned to request source
4335H The specified function cannot be executed because Complete the latch data backup function and then
latch data are being backed up. execute again.
The specified function cannot be executed because
4336H Disconnect all FTP connections to the CPU module
a FTP client is being FTP-connected to the CPU
and then execute again.
module via the built-in Ethernet port.
4337H Power off and then on or reset the CPU module and
Module error collection file does not exist.
then execute again.
Readout of module error collection data has been
Retry the operation. Increase the number of
4338H failed when opening the screen to display the data
module error collections to be stored.
or when updating the data.
Readout of module error collection data was failed
Enable the module error collection function by
4339H because the function is disabled by parameter
parameter settings and then execute again.
settings.
4C08H There are a total of 33 or more DDWR and DDRD Execute again after reducing the number of DDWR
Multiple CPU-related error
requests. and DDRD requests to be executed simultaneously.
The specification of the requested CPU module No.
4C09H Check the request data contents.
is illegal.
13 – 102
Appendix A Definition of the processing times
A Appendix A
A.1 Definition of the processing times
The operation processing time is the total of the following:
● Total of each instruction processing time.
● The END processing time. This time consists of the time to execute the END instruction, the
MELSECNET related refresh time, the processing time for the communication with periphe-
ral devices, and the time for serial communication.
● Processing time for the function that increases the scan time
Refer to the following manual(s) for the END processing time, I/O refresh time, and processing
time for the function that increases the scan time.
● QnUCPU User's Manual (Functions Explanation, Program Fundamentals)
● Qn(H)/QnPH/QnPRHCPU User's Manual (Functions Explanation, Program Fundamentals)
● MELSEC-L CPU Module User's Manual (Functions Explanation, Program Fundamentals)
The tables on the following pages contain the processing times of all instructions.
The according processing times depend on the values of source and destination data. The va-
lues contained in the following tables should therefore be taken as a set of general guidelines
to processing time rather than as being strictly accurate.
When the instruction is not executed the processing time is calculated as follows:
Type of CPU Processing time when the instruction is not executed (μs)
Q00JCPU 0.20 x (Number of steps for each instruction + 1)
Q00CPU 0.16 x (Number of steps for each instruction + 1)
Q01CPU 0.10 x (Number of steps for each instruction + 1)
Q02CPU) 0.079 x (Number of steps for each instruction + 1)
Q02HCPU
Q06HCPU
Q12HCPU
Q25HCPU
Q02PHCPU
0.034 x (Number of steps for each instruction + 1)
Q06PHCPU
Q12PHCPU
Q25PHCPU
Q12PRHCPU
Q25PRHCPU
A–2
Appendix A Processing times for MELSEC System Q CPUs
Following tables show the processing time for the instructions of Basic Model QCPU, High Per-
formance Model QCPU/Process CPU/Redundant CPU.
NOTE When using a file register (ZR), module access device (Un\G, U3En\G0 to G511 (for Basic
model QCPU) resp. U3En\G0 to G4095 (for High Performance Model QCPU/Process CPU/
Redundant CPU), and link direct device (Jn\), add the processing time shown in tables A-12
(for Basic model QCPU) and A-14 (other CPU modules) to that of the instruction.
Tab. A-9: Processing times for QCPU (except Universal model CPU)
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A–4
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A–6
Appendix A Processing times for MELSEC System Q CPUs
A–8
Appendix A Processing times for MELSEC System Q CPUs
A – 10
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A – 12
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A – 14
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A – 16
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A – 18
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A – 20
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-9: Processing times for QCPU (except Universal model CPU)
A.2.2 Instructions executable by the product with the first 5 digits of the serial
No. "04122" or higher (Basic model QCPU)
Tab. A-10:Processing times for Basic model QCPU with serial no. 04122... or higher
A – 22
Appendix A Processing times for MELSEC System Q CPUs
Tab. A-10:Processing times for Basic model QCPU with serial no. 04122... or higher
For a system which consists of a base unit and extension base units:
Instruction processing time increase [µs] = 4 x 1,30 x (number od points processed) x (number of CPU modules)
Tab. A-11: Processing times for Basic model QCPU with serial no. 04122... or higher
A – 24
Appendix A Processing times for MELSEC System Q CPUs
When using a file register (ZR), module access device (Un\G and U3En\G0 to G511), and
link direct device (Jn\), add the processing time shown in the following table to that of the
instruction.
For a system which consists of a base unit and extension base units:
Instruction processing time increase [µs] = 1,30 x (number of points processed) x (number of CPU modules)
2
The instruction processing time for special function modules under control of the CPU which is executing the
instruction is identical to the instruction processing time for special function modules under control of another
CPU of the multi-CPU system.
3
Products with the first 5 digits of the serial No. "07032" or higher are applicable.
Tab. A-13: Instructions for CPU modules availabe from function version B
A – 26
Appendix A Processing times for MELSEC System Q CPUs
When using a file register (ZR), module access device (Un\G and U3En\G0 to G4096), and
link direct device (Jn\), add the processing time shown in the following table to that of the
instruction.
Tab. A-14: Processing time to be added (High Performance model QCPU/Process CPU/
Redundant CPU)
A – 28
Appendix A Operation Processing Time of Universal Model QCPU
A – 30
Appendix A Operation Processing Time of Universal Model QCPU
A – 32
Appendix A Operation Processing Time of Universal Model QCPU
NOTE For the instructions for which a leading edge instruction (P) is not described, the processing
time is the same as an ON execution instruction.
Example: MOVP instruction, WANDP instruction etc.
ANDPI
ANDFI
executed 0.080 0.038 0.038 0.038
ORPI
ORFI
changed
OUT 0.020 0.0095 0.0095 0.0095
not changed
SET
not executed 0.020 0.0095 0.0095 0.0095
RST
continuity
LD= 0.060 0.0285 0.0285 0.0285
no continuity
not executed
AND= continuity 0.060 0.0285 0.0285 0.0285
executed
no continuity
not executed
OR= continuity 0.060 0.0285 0.0285 0.0285
executed
no continuity
continuity
LD<> 0.060 0.0285 0.0285 0.0285
no continuity
A – 34
Appendix A Operation Processing Time of Universal Model QCPU
A – 36
Appendix A Operation Processing Time of Universal Model QCPU
NOTE For the instructions for which a leading edge instruction (P) is not described, the processing
time is the same as an ON execution instruction.
Example: MOVP instruction, WANDP instruction etc.
A – 38
Appendix A Operation Processing Time of Universal Model QCPU
Table of the time to be added when file register, extended data register, extended link
register and module access device are used
● Q00UJCPU, Q00UCPU, Q01UCPU and Q02UCPU
Device Processing time (μs)
Device Name Data Specification
Location Q00UJ Q00U Q01U Q02U
Source 0.100 0.100 0.100 0.100
Bit
Destination 0.220 0.220 0.220 0.220
When standard RAM is Source 0.100 0.100 0.100 0.100
Word
used Destination 0.100 0.100 0.100 0.100
Source 0.200 0.200 0.200 0.200
Double word
Destination 0.200 0.200 0.200 0.200
Source –– –– –– 0.220
Bit
Destination –– –– –– 0.420
When SRAM card is used Source –– –– –– 0.220
File register (R) (Q2MEM-1MBS, Q2MEM- Word
2MBS) Destination –– –– –– 0.180
Source –– –– –– 0.440
Double word
Destination –– –– –– 0.380
Source –– –– –– 0.160
Bit
Destination –– –– –– 0.320
When SRAM card is used Source –– –– –– 0.160
(Q3MEM-4MBS, Q3MEM- Word
8MBS) Destination –– –– –– 0.140
Source –– –– –– 0.320
Double word
Destination –– –– –– 0.300
Source 0.220 0.180 0.160 0.140
Bit
Destination 0.280 0.320 0.300 0.280
When standard RAM is Source 0.220 0.180 0.160 0.140
Word
used Destination 0.220 0.180 0.160 0.140
Source 0.320 0.280 0.260 0.240
Double word
Destination 0.320 0.280 0.260 0.240
Source –– –– –– 0.260
Bit
Destination –– –– –– 0.480
File register (ZR), When SRAM card is used Source –– –– –– 0.260
Extended data register (D), (Q2MEM-1MBS, Q2MEM- Word
Extended link register (W) 2MBS) Destination –– –– –– 0.220
Source –– –– –– 0.480
Double word
Destination –– –– –– 0.420
Source –– –– –– 0.200
Bit
Destination –– –– –– 0.380
When SRAM card is used Source –– –– –– 0.200
(Q3MEM-4MBS, Q3MEM- Word
8MBS) Destination –– –– –– 0.180
Source –– –– –– 0.360
Double word
Destination –– –– –– 0.340
Source –– –– –– ––
Bit
Destination –– –– –– ––
Module access device Source –– –– –– ––
(Multiple CPU high speed transmission area) Word
(U3En\G10000) Destination –– –– –– ––
Source –– –– –– ––
Double word
Destination –– –– –– ––
Tab. A-18: Processing times to be added for subset instructions for Universal model CPU (1)
Tab. A-19: Processing times to be added for subset instructions for Universal model CPU (2)
A – 40
Appendix A Operation Processing Time of Universal Model QCPU
Table of the time to be added when F/T(ST)/C device is used in OUT/SET/RST instruction
● Q00UJCPU, Q00UCPU, Q01UCPU and Q02UCPU
Processing time (μs)
Instruction Name Device Name Condition
Q00UJ Q00U Q01U Q02U
not executed 2.900 2.900 2.900 2.100
F when displayed 116.000 116.000 116.000 68.800
executed
display completed 116.000 116.000 116.000 61.600
OUT
not executed 0.360 0.240 0.180 0.120
T(ST), C after time up 0.360 0.240 0.180 0.120
executed
when added 0.360 0.240 0.180 0.120
not executed 0.120 0.080 0.006 0.004
SET F when displayed 116.000 116.000 116.000 68.600
executed
display completed 116.000 116.000 116.000 65.700
not executed 0.120 0.080 0.006 0.004
F when displayed 55.800 55.800 55.800 26.500
executed
RST display completed 29.200 29.200 29.200 21.600
not executed 0.360 0.240 0.180 0.120
T(ST), C
executed 0.360 0.240 0.180 0.120
Tab. A-20: Processing times to be added for Universal model CPU and OUT/SET/RST instructions (1)
Tab. A-21: Processing times to be added for Universal model CPU and OUT/SET/RST instructions (2)
NOTES The processing time shown in tables A-22 and A-23 applies when the device used in an in-
struction does not meet the device condition for subset processing (For device condition that
does not trigger subset processing, refer to section 3.8.1).
For instructions not shown in the following table, refer to tables A-16 and A-17 in section A.3.1.
When using a file register (R, ZR), extended data register (D), extended link register (W), mo-
dule access device (Un\G and U3En\G0 to G4095), and link direct device (Jn\), add the
processing time shown in tables A-24 and A-25 to that of the instruction.
Since the processing time of an instruction varies depending on that of the cache function,
both the minimum and maximum values are described in the table.
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 42
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 44
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 46
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 48
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 50
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 52
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 54
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
A – 56
Appendix A Operation Processing Time of Universal Model QCPU
DTO Writing to host n3 = 1 13.500 62.300 13.500 62.300 13.500 62.300 8.600 58.300
CPU shared
(n1, n2, s, n3) memory n3 = 320 112.900 160.800 112.900 160.800 112.900 160.800 106.800 157.300
Reading from n3 = 1 12.100 58.700 12.100 58.700 12.100 58.700 8.400 52.600
host CPU
shared n3 = 320 56.000 101.700 56.000 101.700 56.000 101.700 51.700 96.600
FROM memory
(n1, n2, d, n3) Reading from n3 = 1 24.400 82.900 24.400 82.900 24.400 82.900 16.600 37.000
other CPU n3 = 320 152.000 243.000 152.000 243.000 152.000 243.000 153.000 185.000
shared
memory n3 = 1000 418.000 518.000 418.000 518.000 418.000 518.000 432.000 485.000
Reading from n3 = 1 12.100 58.700 12.100 58.700 12.100 58.700 8.800 53.400
host CPU
shared n3 = 320 97.400 143.700 97.400 143.700 97.400 143.700 94.900 139.600
DFRO memory
(n1, n2, d, n3) Reading from n3 = 1 24.800 94.200 24.800 94.200 24.800 94.200 16.600 47.300
other CPU n3 = 320 276.000 367.000 276.000 367.000 276.000 367.000 278.000 339.000
shared
memory n3 = 1000 799.000 892.000 799.000 892.000 799.000 892.000 841.000 892.000
Tab. A-22: Processing times for instructions other than subset instructions for Universal model QCPU (1)
NOTE For the instructions for which a leading edge instruction (P) is not described, the processing
time is the same as an ON execution instruction.
Example: WORDP instruction, TOP instruction etc.
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 58
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 60
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 62
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 64
Appendix A Operation Processing Time of Universal Model QCPU
ECALL * pn s1 to s5
–– 101.000 114.000 91.800 105.000 91.800 105.000 91.800 105.000
*: Program name
EFCALL * pn
–– 70.700 82.800 66.200 78.100 66.200 78.100 66.200 78.100
*: Program name
EFCALL * pn s1 to s5
–– 86.500 107.000 78.800 91.600 78.800 91.600 78.800 91.600
*: Program name
XCALL –– 3.800 5.700 3.700 5.200 3.700 5.200 3.700 5.200
When selecting I/O refresh only 12.800 29.100 12.400 28.600 12.400 28.600 12.400 28.600
When selecting CC-Link refresh only (master station side) 16.000 39.500 15.500 39.100 15.500 39.100 15.500 39.100
When selecting CC-Link refresh only (local station side) 16.100 39.500 15.500 39.100 15.500 39.100 15.500 39.100
• When selecting MELSECNET/ H refresh only
(Control station side) 34.700 70.400 34.400 69.800 34.400 69.800 34.400 69.800
• When selecting CC-Link IE refresh only
(Control station/ Master station side)
• When selecting MELSECNET/ H refresh only
(Normal station side)
COM • When selecting CC-Link IE refresh only 34.700 70.400 34.400 69.800 34.400 69.800 34.400 69.800
CCOM (Normal station/ Local station side)
When selecting intelli auto refresh only 12.800 33.200 12.800 33.200 12.800 33.200 12.800 33.200
When selecting I/O outside the group only (Input only) 7.900 21.100 7.700 20.700 7.700 20.700 7.700 20.700
When selecting I/O outside the group only (Output only) 16.900 44.800 16.500 44.200 16.500 44.200 16.500 44.200
When selecting I/O outside the group only (Both I/O) 22.600 52.600 22.400 52.600 22.400 52.600 22.400 52.600
When selecting refresh of multiple CPU high speed transmission
area only 13.000 33.800 12.700 33.200 12.700 33.200 12.700 33.200
When selecting communication with peripheral device 7.250 18.800 7.100 18.500 7.100 18.500 7.100 18.500
Number of data points = 0 3.700 5.300 3.200 4.600 3.200 4.600 3.200 4.600
FIFW
Number of data points = 96 3.800 4.400 3.300 3.800 3.300 3.800 3.300 3.800
Number of data points = 01 4.300 5.000 3.800 4.400 3.800 4.400 3.800 4.400
FIFR
Number of data points = 96 33.500 35.500 24.800 25.700 24.800 25.700 24.800 25.700
Number of data points = 01 4.300 5.900 3.800 5.300 3.800 5.300 3.800 5.300
FPOP
Number of data points = 96 4.300 5.900 3.700 5.400 3.700 5.400 3.700 5.400
Number of data points = 0 4.800 5.900 3.700 5.300 3.700 5.300 3.700 5.300
FINS
Number of data points = 96 4.300 5.900 3.700 5.300 3.700 5.300 3.700 5.300
Number of data points = 01 4.900 6.500 4.200 5.800 4.200 5.800 4.200 5.800
FDEL
Number of data points = 96 34.200 35.900 25.400 25.900 25.400 25.900 25.400 25.900
n3 = 1 10.800 24.100 10.700 23.600 10.700 23.600 10.700 23.600
FROM (n1, n2, d, n3)
n3 = 1000 392.600 413.300 390.900 410.200 390.900 410.200 390.900 410.200
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 66
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 68
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 70
Appendix A Operation Processing Time of Universal Model QCPU
Comparison of continuity 7.300 11.500 6.700 10.800 6.700 10.800 6.700 10.800
specified clock no continuity 7.300 11.500 6.700 10.800 6.700 10.800 6.700 10.800
LDTM<>
Comparison of continuity 5.800 9.900 5.400 9.500 5.400 9.500 5.400 9.500
current clock no continuity 5.800 9.900 5.400 9.500 5.400 9.500 5.400 9.500
not executed 0.008 0.038 0.038 0.038
Comparison of continuity 7.000 11.500 6.300 10.800 6.300 10.800 6.300 10.800
ANDTM<> specified clock no continuity 7.000 11.500 6.300 10.800 6.300 10.800 6.300 10.800
Comparison of continuity 5.500 9.900 5.100 9.500 5.100 9.500 5.100 9.500
current clock no continuity 5.500 9.900 5.100 9.500 5.100 9.500 5.100 9.500
not executed 0.008 0.038 0.038 0.038
Comparison of continuity 7.300 11.500 6.600 10.800 6.600 10.800 6.600 10.800
ORTM<> specified clock no continuity 7.300 11.500 6.600 10.800 6.600 10.800 6.600 10.800
Comparison of continuity 5.900 9.900 5.300 9.500 5.300 9.500 5.300 9.500
current clock no continuity 5.900 9.900 5.300 9.500 5.300 9.500 5.300 9.500
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 72
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
Tab. A-23: Processing times for instructions other than subset instructions for Universal model QCPU (2)
A – 74
Appendix A Operation Processing Time of Universal Model QCPU
Table of the time to be added when file register, extended data register, extended link
register, module access device, and link direct device are used
● Q03UD(E) Q00UJCPU, Q00UCPU, Q01UCPU and Q02UCPU
Device Processing time (μs)
Device Name Data Specification
Location Q00UJ Q00U Q01U Q02U
Source 0.100 0.100 0.100 0.100
Bit
Destination 0.100 0.100 0.100 0.100
When standard RAM is Source 0.100 0.100 0.100 0.100
Word
used Destination 0.100 0.100 0.100 0.100
Source 0.100 0.100 0.100 0.200
Double word
Destination 0.100 0.100 0.100 0.200
Source –– –– –– 0.220
Bit
Destination –– –– –– 0.180
When SRAM card is used Source –– –– –– 0.220
File register (R) (Q2MEM-1MBS, Q2MEM- Word
2MBS) Destination –– –– –– 0.180
Source –– –– –– 0.440
Double word
Destination –– –– –– 0.380
Source –– –– –– 0.160
Bit
Destination –– –– –– 0.140
When SRAM card is used Source –– –– –– 0.160
(Q3MEM-4MBS, Q3MEM- Word
8MBS) Destination –– –– –– 0.140
Source –– –– –– 0.320
Double word
Destination –– –– –– 0.300
Source 0.120 0.120 0.120 0.120
Bit
Destination 0.120 0.120 0.120 0.120
When standard RAM is Source 0.120 0.120 0.120 0.120
Word
used Destination 0.120 0.120 0.120 0.120
Source 0.120 0.120 0.120 0.220
Double word
Destination 0.120 0.120 0.120 0.220
Source –– –– –– 0.240
Bit
Destination –– –– –– 0.200
File register (ZR), When SRAM card is used Source –– –– –– 0.240
Extended data register (D), (Q2MEM-1MBS, Q2MEM- Word
Extended link register (W) 2MBS) Destination –– –– –– 0.200
Source –– –– –– 0.460
Double word
Destination –– –– –– 0.400
Source –– –– –– 0.180
Bit
Destination –– –– –– 0.160
When SRAM card is used Source –– –– –– 0.180
(Q3MEM-4MBS, Q3MEM- Word
8MBS) Destination –– –– –– 0.160
Source –– –– –– 0.340
Double word
Destination –– –– –– 0.320
Source –– –– –– 12.000
Bit
Destination –– –– –– 17.300
Module access device Source –– –– –– 9.700
(Multiple CPU high speed transmission area) Word
(U3En\G10000) Destination –– –– –– 33.000
Source –– –– –– 24.200
Double word
Destination –– –– –– 34.800
Tab. A-24: Processing times to be added for instructions other than subset instructions for Universal model
CPU (1)
Tab. A-24: Processing times to be added for instructions other than subset instructions for Universal model
CPU (1)
A – 76
Appendix A Operation Processing Time of Universal Model QCPU
Tab. A-25: Processing times to be added for instructions other than subset instructions for Universal model
CPU (2)
Tab. A-25: Processing times to be added for instructions other than subset instructions for Universal model
CPU (2)
A – 78
Appendix A Operation Processing Time of LCPU
A – 80
Appendix A Operation Processing Time of LCPU
A – 82
Appendix A Operation Processing Time of LCPU
NOTE For the instructions for which a leading edge instruction (P) is not described, the processing
time is the same as an ON execution instruction.
Example: MOVP instruction, WANDP instruction etc.
Table of the time to be added when file register, extended data register, and extended
link register are used
Device Specification Processing time (μs)
Device Name Data
Location L02CPU L26CPU-BT
Source 0.100 0.048
Bit
Destination 0.220 0.038
Source 0.100 0.048
File register (R) When standard RAM is used Word
Destination 0.100 0.038
Source 0.200 0.095
Double word
Destination 0.200 0.086
Source 0.140 0.057
Bit
Destination 0.280 0.048
File register (ZR), Source 0.140 0.057
Extended data register (D), When standard RAM is used Word
Extended link register (W) Destination 0.140 0.048
Source 0.240 0.105
Double word
Destination 0.240 0.095
Tab. A-27: Processing times to be added for instructions other than subset instruction for
LCPU
A – 84
Appendix A Operation Processing Time of LCPU
Table of the time to be added when F/T(ST)/C device is used in OUT/SET/RST instruction
Processing time (μs)
Instruction Name Device Name Condition
L02CPU L26CPU-BT
not executed 2.000 1.570
F when displayed 53.100 38.090
executed
display completed 53.000 37.980
OUT
not executed 0.120 0.030
T(ST), C when displayed 0.120 0.030
executed
display completed 0.120 0.030
not executed 0.040 0.010
SET F when displayed 52.000 40.600
executed
display completed 43.600 37.900
not executed 0.040 0.010
F when displayed 45.700 36.600
executed
RST display completed 19.000 16.190
not executed 0.120 0.030
T(ST), C
executed 0.120 0.030
Tab. A-28: Processing times to be added for LCPU and OUT/SET/RST instructions
NOTE The processing time shown in table A-29 applies when the device used in an instruction does
not meet the device condition for subset processing (for device condition that does not trigger
subset processing, refer to section 3.8.1).
For instructions not shown in the following table, refer to table A-26 in section A.4.1.
When using a file register (R, ZR), extended data register (D), extended link register (W), and
module access device (Un/G), add the processing time shown in table A-30 to that of the
instruction.
Since the processing time of an instruction varies depending on that of the cache function,
both the minimum and maximum values are described in the table.
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 86
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 88
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 90
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 92
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 94
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 96
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
A – 98
Appendix A Operation Processing Time of LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
Tab. A-29: Processing times for instructions other than subset instructions for LCPU
NOTE For the instructions for which a leading edge instruction (P) is not described, the processing
time is the same as an ON execution instruction.
Example: MOVP instruction, WANDP instruction etc.
A – 100
Appendix A Operation Processing Time of LCPU
Table of the time to be added when file register, extended data register, extended link
register, and module access device are used
Device Specification Processing time (μs)
Device Name Data
Location L02CPU L26CPU-BT
Source 0.100 0.048
Bit
Destination 0.220 0.038
Source 0.100 0.048
File register (R) When standard RAM is used Word
Destination 0.100 0.038
Source 0.200 0.095
Double word
Destination 0.200 0.086
Source 0.140 0.057
Bit
Destination 0.280 0.048
File register (ZR), Source 0.140 0.057
Extended data register (D), When standard RAM is used Word
Extended link register (W) Destination 0.140 0.048
Source 0.240 0.105
Double word
Destination 0.240 0.095
Source 11.700 11.200
Bit
Destination 15.400 15.300
Source 9.460 9.410
Module access device (Un\G) Word
Destination 19.000 19.000
Source 11.000 10.900
Double word
Destination 18.800 18.700
Tab. A-30: Processing times to be added for instructions other than subset instructions for
LCPU
Qn, QnH,
Device
Q00J, Q00, Q01 Q00UJ, Q00U, QnPH, QnPRH, L02CPU, AnU AnA AnN
Q01U, Q02U QnUD(E), L26CPU-BT
QnUD(E)H
Q00J: 256 Q00UJ: 256 L02CPU: A2U : 512 A2A : 512 A1N: 256
Number of Q00U: 1024 1024 A2U-S1: 1024 A2N: 512
Q00: 1024 4096 A2A-S1:1024
inputs/outputs 9) Q01: 1024
Q01U: 1024 L26CPU-BT: A3U: 2048
A3A: 2048
A2N-S: 1024
Q02U: 2048 4096 A4U : 4096 A3N: 2048
Same with I/O devices points of each
Number of I/O device points 8) 2048 1) 8192 1) 8192 1) 8192 1) 8192
CPU
Timers 1) 1) 1) 1)
512 2048 2048 2048
Total 2048 Total 2048 Total 256
Retentive Timers 0 1) 0 1) 0 1) 0 1)
16 16
Function inputs —
(FX0 to FXF) 7) (FX0 to FXF) 7)
16 16
Function output —
(FX0 to FXF) 7) (FY0 to FYF) 7)
Special relays 1000 2048 2048 2048 256 256 256
5 5
Function registers —
(FD0 to FD4) (FD0 to FD15)
Special registers 1000 2048 2048 2048 256 256 256
Direct access Designated by J\ — —
link devices
Direct access Designated by
special devices Designated by U\G U\G —
A – 102
Appendix A Comparison of the CPUs
32768 per block 32768 per block 32768 per block 8192 per block 8192 per block 8192 per block
File registers
(R0 to R32767) 5) (R0 to R32767) 10) (R0 to R32767) (R0 to R8191) (R0 to R8191) (R0 to R8191)
Accumulators 3) — — 2 2 2
Nesting 15 15 15 15 8 8 8
Pointer 300 512 4096 4096 256 256 256
Interrupt pointers 128 256 48 256 32 32 32
QCPUs.
4 Can only be used by the $MOV instruction with the Q00JCPU, Q00CPU and Q01CPU.
6
Applicable to products with the first 5 digits of the serial number 04122 or higher (Q00JCPU, Q00CPU, and Q01CPU).
7
Each 5 points of FX0 to FX4 and FY0 to FY4 can be used on the programs.
8 The number of points that can be used on the programs
9
The number of accessible points to actual I/O modules
10
The Q00UJCPU does not have file registers.
Type of CPU
I/O control mode
QCPU LCPU AnUCPU AnACPU AnNCPU
Partial refresh
instructions
Direct Dedicated
— — —
input/output instructions1)
mode
Direct access inputs — — —
Bit device
Bit Data
Word device (Bit designation re- (Bit designation re- — — —
quired) quired)
Bit device (Digit designation (Digit designation (Digit designa- (Digit designa- (Digit designa-
16-bit
required) required) tion required) tion required) tion required)
word data
Word device
Bit device (Digit designation (Digit designation (Digit designa- (Digit designa- (Digit designa-
32-bit
required) required) tion required) tion required) tion required)
word data
Word device
A – 104
Appendix A Comparison of the CPUs
Timer functions
100 ms (default)
Change of measurement unit at the
Measurement unit parameter is enabled. Fixed at 100 ms
QCPU/LCPU 1 to 1000 ms
(1 ms unit)
K100 K100
Designation method T0 T0
Programming TIMER_VALUE_M
Setting value
(GX IEC (dedicated timers
designation 2)
Developer) only)
TIMER_START_M
(dedicated timers Timer start 2)
only)
Programming
Setting value designation and timer start OUT Tn Setting value OUT Tn Setting value
(GX Works2)
10 ms (default)
Change of measurement unit at
the parameter is enabled.
Measurement unit QnUCPU/LCPU: Fixed at 100 ms
0.01 to 100ms (0.01 ms unit)
QCPU(Other than QnUCPU):
0.1 to 100 ms (0.1 ms unit)
High-speed timer
High speed timer specification
K100
H K100 T200
Designation method T0
High speed timer setting: High speed timer setting: Conducted at parameters
Conducted by sequence program
Programming TIMER_VALUE_M
Setting value
(GX IEC (dedicated timers 2)
designation
High-speed timer Developer) only)
TIMER_START_M
(dedicated timers Timer start 2)
only)
Programming
Setting value designation and timer start OUT Tn Setting value OUT Tn Setting value
(GX Works2)
K100 K100
Designation method ST0 T0
TIMER_START_M
(dedicated timers Timer start 2)
only)
Programming
Setting value designation and timer start OUT Tn Setting value OUT Tn Setting value
(GX Works2)
H K100
Designation method ST0 —
Programming TIMER_VALUE_M
Setting value
(GX IEC (dedicated timers
designation 2) — — —
Developer) only)
TIMER_START_M
(dedicated timers Timer start 2) — — —
only)
Programming
Setting value designation and timer start OUTH STn Set value — — —
(GX Works2
Setting range for setting value 1 to 32767 1 to 32767
Processing of setting value 0 ON momentarily No maximum (does not time out)
Coil Enabled (Z0 and Z1 usable only) Not capable Not capable
Index
qualification Setting value Enabled (Z0 to Z15 are usable) 1) Not capable Not capable
A – 106
Appendix A Comparison of the CPUs
Type of CPU
Name Function block
QCPU LCPU AnU AnA AnN
10 ms timer —
100 ms timer —
retentive timer —
Low-speed timer — — — —
High-speed timer — — — —
retentive
— — — —
High-speed timer
Assign the function block to the instance label specified in the header and assign the input and
output variables.
Example
For timers T0 to T2, the program is created in the order the timer operates later.
T1 K1
T2 T2 timer starts measurement from the next scan after turning the contact of T1 ON.
T0 K1
T1 T1 timer starts measurement from the next scan after turning the contact of T0 ON.
X0 K1
T0 T0 timer starts measurement when X0 is turned ON.
For timers T0 to T2, the program is created in the order of timer operation.
X0 K1
T0 T0 timer starts measurement when X0 is turned ON.
T0 K1
T1
A – 108
Appendix A Comparison of the CPUs
Type of CPU
Function
QCPU/LCPU AnU AnA AnN
Setting value
Counter_M designation and 2)
counter start
Programming
(GX IEC Developer) Setting value
Counter_Start_M
designation 2)
Setting value
Programming
(GX Works2)
OUT Cn Set value designation and 2)
counter start
K100 K100
Designation method C0 C0
Enabled
Contact Capable Not capable
(Z0 and Z1 usable only)
Type of CPU
Name Function blocks
QCPU LCPU AnU AnA AnN
Counter — —
When SM701is OFF: Output continued until 00H When M9049 is OFF: Output continued
1) encountered until 00H encountered
PR
When SM701 is ON: 16 characters output When M9049 is ON: 16 characters output
A – 110
Appendix A Comparison of the CPUs
A.5.7 QCPU, LCPU instructions whose designation format has been changed
Since QCPU, LCPU do not use accumulators (A0, A1), the format of the AnU, AnA, and AnN
CPU instructions that use accumulators has changed.
Partial refresh RFS (s, n) Added dedicated instruction SEG (d, n) Only when M9052 is ON
CHKST CJ (Pn)
CHK instruction 1) CHK
Added CHKST instruction
CHK (P254)
QCPU AnUCPU/AnACPU
A – 112
Appendix A Table of special relays
Item Meaning
Number Indicates the number of the special relay.
Name Indicates the name of the special relay.
Meaning Contains the function of the special relay in brief.
Description Contains a detailed description of the special relay.
Indicates whether the special relay is set by the system or the user.
<Set by>
S : Set by the system
U : Set by the user (using a program, programming tool, GOT,
or test operation from other external devices)
S/U : Set by the system or user
NOTE Do not change the values of special relay set by system using a program or by test operation.
Doing so may result in system down or communication failure.
A – 114
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Comes ON even if there is only one output module with
OFF: Normal a blown fuse and remains ON even after return to nor-
Blown fuse S
SM60 ON: Module with blown mal. M9000 QCPU
detection (Error)
fuse Blown fuse state is checked even for remote I/O station
output modules.
Comes ON if there is a discrepancy between the actual
I/O modules and the registered information when the
I/O module OFF: Normal power is turned on. S
SM61 M9002
Verification error ON: Error Remains ON even after return to normal. (Error)
I/O module verification is also conducted for remote I/O Q CPU
station modules. LCPU
S
Annunciator OFF: Not detected
SM62 Goes ON if at least one annunciator F goes ON. (Instruction M9009
detection ON: Detected
execution)
OFF: No error Turns ON when an overrun error (to much data) occured S
SM113 Overrun error
ON: Error during the serial communication. (Error)
OFF: No error Turns ON when a parity error occured during the serial S
SM114 Parity error
ON: Error communication. (Error)
OFF: No error Turns ON when a framing error occured during the S
SM115 Framing error
ON: Error serial communication. (Error)
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Turns on when data are written to the program
Program mem- cache memory.
ory batch trans-
OFF: Completed Turns off when program memory batch transfer is S QnU 1)
SM165 ON: Not being executed completed. New
fer execution (Status change) LCPU
or Not completed Remains on when data written to the program cache
status memory are not batchtransferred to the program
memory.
A – 116
Appendix A Table of special relays
ACPU
Number Name Meaning Description Set by (if set) Valid for:
M9
Qn(H)
QnPH
At change from OFF to ON, the LEDs corresponding to
SM202 LED off command OFF → ON: LED off U New QnPRH
the individual bits at SD202 go off.
QnU
LCPU
S
SM203 STOP contact STOP state Goes ON at STOP state. M9042
(Status change) Q CPU
S LCPU
SM204 PAUSE contact PAUSE state Goes ON at PAUSE state. M9041
(Status change)
OFF: PAUSE disabled PAUSE state is entered if this relay is ON when the Q CPU
SM206 PAUSE enable coil U M9040
ON: PAUSE enabled remote PAUSE contact goes ON. LCPU
When this relay goes from OFF to ON, clock data being
Clock data set OFF: Ignored stored from SD210 through SD213 after execution of
SM210 U M9025
request ON: Set request END instruction for changed scan is written to the clock Q CPU
device.
LCPU
OFF: No error ON when error is generated in clock data (SD210 S
SM211 Clock data error M9026
ON: Error through SD213) value and OFF if no error is detected. (Request)
Clock data read OFF: Ignored When this relay is ON, clock data is read to SD210 Q CPU
SM213 U M9028
request ON: Read request through SD213 as BCD values. LCPU
OFF: CPU No.1
Turns on when an access to CPU No.1 from another
preparation
CPU becomes possible after power-on or reset opera-
CPU No.1 prepara- uncompleted
SM220 tion. This relay is used as an interlock for accessing QCPU
tion completed ON: CPU No.1
CPU No.1 when the multiple CPU synchronous setting
preparation
is set to asynchronous.
completed
OFF: CPU No.2
Turns on when an access to CPU No.2 from another
preparation
CPU becomes possible after power-on or reset opera-
CPU No.2 prepara- uncompleted
SM221 tion. This relay is used as an interlock for accessing
tion completed ON: CPU No.2
CPU No.2 when the multiple CPU synchronous setting
preparation
is set to asynchronous. S
completed
(When status QnU 7)
OFF: CPU No.3 changed)
Turns on when an access to CPU No.3 from another
preparation
CPU becomes possible after power-on or reset opera-
CPU No.3 prepara- uncompleted
SM222 tion. This relay is used as an interlock for accessing
tion completed ON: CPU No.3
CPU No.3 when the multiple CPU synchronous setting
preparation
is set to asynchronous.
completed
New
OFF: CPU No.4
Turns on when an access to CPU No.4 from another
preparation
CPU becomes possible after power-on or reset opera-
CPU No.4 prepara- uncompleted
SM223 tion. This relay is used as an interlock for accessing QnU 5)
tion completed ON: CPU No.4
CPU No.4 when the multiple CPU synchronous setting
preparation
is set to asynchronous.
completed
OFF: Online module
change is not in
S
Online module progress This relay is on during online module change. (for host
SM235 (During online
change flag ON: Online module CPU)
module change)
change in
progress
QnPH
OFF: Online module
change This relay is on only for one scan after completion
Online module S (When online
incomplete of online module change.
SM236 change complete This relay can be used only in the scan execution module change is
ON: Online module
flag type program. (for host CPU) complete)
change
complete
OFF: Device range Selects whether to check a device range during execu-
Device range check checked tion of the BMOV, FMOV or DFMOV instruction (only QnU 6)
SM237 U New
inhibit flag ON: Device range when the conditions for subset processing are estab- LCPU
not checked lished).
ACPU
Number Name Meaning Description Set by (if set) Valid for:
M9
Q00/Q01 1)
OFF: No reset This flag comes ON when the CPU no. 1 has been reset Qn(H) 1)
ON: CPU 1 has been or has been removed from the base. The other CPUs of S
SM240 CPU No. 1 reset flag reset the multi-CPU system are also put in reset status. New QnPH
(Status change)
QnU 7)
Reset status Aways off (reset status) LCPU
This flag comes ON when the CPU no. 2 has been reset
OFF: No reset
or has been removed from the base. In the other CPUs S
SM241 CPU No. 2 reset flag ON: CPU 2 has been New Q00/Q01 1)
of the multi-CPU system the error code 7000 ("MULTI (Status change)
reset
CPU DOWN") will occur. Qn(H) 1)
This flag comes ON when the CPU no. 3 has been reset QnPH
OFF: No reset S
SM242 CPU No. 3 reset flag ON: CPU 3 has been
or has been removed from the base. In the other CPUs
New QnU 7)
of the multi-CPU system the error code 7000 ("MULTI (Status change)
reset
CPU DOWN") will occur.
OFF: No reset
This flag comes ON when the CPU no. 4 has been reset Qn(H) 1)
or has been removed from the base. In the other CPUs S
SM243 CPU No. 4 reset flag ON: CPU 4 has been New QnPH
of the multi-CPU system the error code 7000 ("MULTI (Status change)
reset QnU 5)
CPU DOWN") will occur.
Q00/Q01 1)
OFF: No error Qn(H) 1)
ON: CPU no. 1 is S
SM244 CPU No. 1 error flag New QnPH
stopped due to (Status change)
an error QnU 7)
LCPU
OFF: No error
ON: CPU no. 2 is The set flag indicates that an error has occured which S
SM245 CPU No. 2 error flag New Q00/Q01 1)
stopped due to has stopped the CPU. (Status change)
an error The flag goes OFF when the CPU is normal or when an Qn(H) 1)
OFF: No error error occurs which will not stop the CPU. QnPH
ON: CPU no. 3 is S QnU 7)
SM246 CPU No. 3 error flag New
stopped due to (Status change)
an error
OFF: No error Qn(H) 1)
ON: CPU no. 4 is S
SM247 CPU No. 4 error flag New QnPH
stopped due to (Status change)
an error QnU 5)
Qn(H)
Max. loaded I/O OFF: Ignored When this relay goes from OFF to ON, maximum loaded
SM250 U New QnPH
read ON: Read I/O number is read to SD250.
QnPRH
Effective for the batch refresh and the low-speed
cycle.
Designate whether to receive arrival stations only
or to receive all slave stations in the Qn(H)
MELSECNET/H.
QnPH
OFF: Refresh the Effective for the batch refresh and the low-speed
head station cycle. QnPRH
All stations refresh
SM254 only Designate whether to receive arrival stations only U New
command or to receive all slave stations in the CC-Link IE
ON: Refresh all
stations controller network.
Effective for the batch refresh and the low-speed
cycle.
Specify whether to receive only arrival station or all QnU
stations in the MELSECNET/H or CC-Link IE
controller network.
OFF: Operative
Goes ON for standby network.
network S
SM255 (If no designation has been made concerning active or New
ON: Standby (Initial)
MELSECNET/10, standby, active is assumed.) Qn(H)
network
MELSECNET/H
QnPH
module 1 informa- OFF: Reads For refresh from link to CPU (B, W, etc.) indicate
SM256 U New QnPRH
tion ON: Does not read whether to read from the link module.
OFF: Writes For refresh from CPU to link (B, W etc.) designate
SM257 U New
ON: Does not write whether to write to the link module.
A – 118
Appendix A Table of special relays
ACPU
Number Name Meaning Description Set by (if set) Valid for:
M9
OFF: Operative
Goes ON for standby network.
network S
SM260 (If no designation has been made concerning active or New
ON: Standby (Initial)
MELSECNET/10, standby, active is assumed.) Qn(H)
network
MELSECNET/H
QnPH
module 2 informa- OFF: Reads For refresh from link to CPU (B, W, etc.) indicate
SM261 U New QnPRH
tion ON: Does not read whether to read from the link module.
OFF: Writes For refresh from CPU to link (B, W etc.) designate
SM262 U New
ON: Does not write whether to write to the link module.
OFF: Operative
Goes ON for standby network.
network S
SM265 (If no designation has been made concerning active or New
ON: Standby (Initial)
MELSECNET/10, standby, active is assumed.) Qn(H)
network
MELSECNET/H
QnPH
module 3 informa- OFF: Reads For refresh from link to CPU (B, W, etc.) indicate
SM266 U New QnPRH
tion ON: Does not read whether to read from the link module.
OFF: Writes For refresh from CPU to link (B, W etc.) designate
SM267 U New
ON: Does not write whether to write to the link module.
OFF: Operative
Goes ON for standby network.
network S
SM270 (If no designation has been made concerning active or New
ON: Standby (Initial)
standby, active is assumed.) Qn(H)
MELSECNET/10 network
module 4 informa- QnPH
OFF: Reads For refresh from link to CPU (B, W, etc.) indicate
SM271 tion U New QnPRH
ON: Does not read whether to read from the link module.
OFF: Writes For refresh from CPU to link (B, W etc.) designate
SM272 U New
ON: Does not write whether to write to the link module.
ACPU
Number Name Meaning Description Set by (if set) Valid for:
M9
OFF: SFC program
ON if SFC program is correctly registered, and OFF if
Presence/absence absent S
SM320 not registered. M9100
of SFC program ON: SFC program (Initial)
Goes OFF if SFC dedicated instruction is not correct.
present
Initial value is set at the same value as SM900.
(Goes ON automatically if SFC program is present.)
OFF: SFC program SFC program will not execute if this goes OFF prior to
Start/stop SFC pro- stop SFC program processing. S M9101 Q00J/Q00/
SM321 Q01 1)
gram ON: SFC program Subsequently, starts SFC program when this goes from (Initial)/U format change
start OFF to ON. Qn(H)
Subsequently, stops SFC program when this goes from QnPH
ON to OFF.
QnPRH
Initial value is set at ON or OFF depending on parame- QnU
ters.
When OFF, all execution states are cleared from time LCPU
SFC program was stopped; starts from the initial step
SFC program start OFF: Initial start of block where the start request was made. S/U M9102
SM322
state ON: Restart When ON, starts from execution block and execution (Initial) format change
step active at time SFC program was stopped.
(ON is enabled only when resumptive start has been
designated at parameters.)
SM902 is not automatically designated for latch.
When OFF, transition occurs at one scan/one step, for
OFF: Continuous
all blocks. Q00J/Q00/
Presence/absence transition not
When ON, transition occurs continuously for all blocks Q01 1)
of continuous tran- effective
SM323 in one scan. U M9103 Qn(H)
sition for entire ON: Continuous
block In designation of individual blocks, priority is given to
transition QnPH
the continuous transition bit of the block.
effective QnPRH
(Designation is checked when block starts.)
S QnU
(Instruction M9104 LCPU
execution)
When continuous transition is effective, goes ON when
OFF: When transition Q00J/Q00/
continuous transition is not being executed; goes OFF
SM324
Continuous transi- is executed
when continuous transition is being executed. Q01 1)
tion prevention flag ON: When no Qn(H)
Normally ON when continuous transition is not effec- S
transition New
tive. (Status change) QnPH
QnPRH
QnU
When block stops, selects active step operation output. Q00J/Q00/
Output mode at OFF: OFF S
SM325 All coil outputs go OFF when OFF. M9196 Q01 1)
block stop ON: Preserves (Status change)
Coil outputs are preserved when ON. Qn(H)
QnPH
OFF: Clear device Selects the device status when the stopped CPU is run QnPRH
SFC device clear
SM326 ON: Preserves after the sequence profram or SFC program has been U New
mode QnU
device modified when the SFC program exists.
LCPU
Qn(H)
S QnPH
OFF: Hold step output
turned OFF If this relay is off, the coil output turns off when the (Initial) New QnPRH
Output during end U
SM327 (cleared) step held after transition (SC, SE, or ST) reaches the QnU
step execution
ON: Hold step end step. LCPU
output held
Q00J/Q00/
New
Q01 1)
Select whether clear processing will be performed or
not if active steps other than the ones being held exist
OFF: Clear processing in the block when the end step is reached. Q00J/Q00/
Clear processing is performed. When this relay turns OFF, all active steps are forcibly U Q01 1)
SM328 mode when end ON: Clear terminated to terminate the block. New
processing is When this relay is ON, the execution of the block is
QnU
step is reached
continued as-is. LCPU
not performed. If active steps other than the ones being held do not
exist when the end step is reached, the steps being
held are terminated to terminate the block.
A – 120
Appendix A Table of special relays
ACPU
Number Name Meaning Description Set by (if set) Valid for:
M9
Online change (inac-
OFF: Not executed This relay is on while online change (inactive block) is S
SM329 tive block) status New QnU 8)
ON: Being executed executed. (Status change)
flag
Asynchronous mode: Mode where the operations
OFF: Asynchronous for the low-speed execution type program are
Operation mode for continued during excess time. Qn(H)
mode
SM330 low-speed execution Synchronous mode: Mode where the operations U New
ON: Synchronous for the low-speed execution type program are QnPH
type programs
mode started from the next scan even when there is
excess time.
Normal SFC pro- This relay stores the information on whether the
OFF: Not executed normal SFC program is in execution or not.
SM331 gram execution sta-
ON: Being executed Used as an interlock for execution of the SFC
tus control instruction. Qn(H) 3)
S
This relay stores the information on whether the New QnPH 4)
Program execution (Status change)
management SFC OFF: Not executed SFC program for program execution management QnPRH
SM332 is in execution or not.
program execution ON: Being executed Used as an interlock for execution of the SFC
status control instruction.
This relay stores the status information on the
ON indicates intelligent function module access instruction that Qn(H)
Access execution completion of was just executed. (This data is overwritten if the S
SM390 New QnPH
flag intelligent function intelligent function module access instruction is (Status change)
module access executed again.) QnPRH
Used by the user in a program as a completion bit.
Stores the execution status of the S(P).GINT instruc-
GINT instruction OFF: Not executed S
tion.
SM391 execution comple- ON: Execution (Instruction New QnU
tion flag Turns off before execution of the instruction. execution)
completed
Turns on after completion of the instruction.
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
ON S
SM400 Always ON This flag is normally ON (Every END M9036
OFF processing) QCPU
ON S LCPU
SM401 Always OFF This flag is normally OFF (Every END M9037
OFF processing)
After RUN, ON for 1 scan only.
This connection can be used for scan
execution type programs only.
When an initial execution type program is Qn(H)
used, this relay turns off at the END QnPH
processing of the scan execution type
ON program in the first scan after the CPU S M9038 QnPRH
ON for 1 scan module enters the RUN status.
SM402 1 scan (Every END QnU
only after RUN
OFF ON processing) LCPU
OFF Initial 1 scan of scan
execution type execution type
program program
Q00J/Q00
After RUN, ON for 1 scan only. New
/Q01
After RUN, OFF for 1 scan only.
This connection can be used for scan
execution type programs only.
When an initial execution type program is Qn(H)
used, this relay turns on at the END QnPH
processing of the scan execution type
ON program in the first scan after the CPU S M9039 QnPRH
After RUN, 1 scan module enters the RUN status.
SM403 (Every END QnU
OFF for 1 scan only OFF ON processing) LCPU
OFF
Initial 1 scan of scan
execution type execution type
program program
Q00J/Q00
After RUN, OFF for 1 scan only. New
/Q01
ON After RUN, ON for 1 scan only. S
ON for 1 scan
SM404 This connection can be used for scan execution (Every END New
only after RUN OFF
1 scan
type programs only. processing)
Qn(H)
ON After RUN, OFF for 1 scan only. QnPH
S
After RUN, 1 scan
SM405 This connection can be used for scan execution (Every END New
OFF for 1 scan only OFF
type programs only. processing)
Qn(H)
Repeatedly changes between ON and OFF at 5-ms QnPH
0.005 s 0.005 s interval. S
SM409 0.01 second clock New QnPRH
When power supply is turned ON, or reset is per- (Status change)
formed, starts with OFF. QnU
LCPU
0.05 s 0.05 s
SM410 0.1 second clock M9030
0.1 s 0.1 s
SM411 0.2 second clock Repeatedly changes between ON and OFF at each M9031
designated time interval.
When power supply is turned ON, or reset is per-
0.5 s 0.5 s
formed, starts with OFF. S QCPU
SM412 1 second clock M9032
(Status change) LCPU
1s 1s
SM413 2 second clock M9033
n (s) n (s) Goes between ON and OFF in accordance with the M9034
SM414 2x n second clock
number of seconds designated by SD414. format change
A – 122
Appendix A Table of special relays
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
Qn(H)
QnPH
n (ms) n (ms) Goes between ON and OFF in accordance with the S
SM415 2 x n ms clock New QnPRH
number of milliseconds designated by SD415. (Status change)
QnU
LCPU
User timing clock
SM420 M9020
No. 0
Relay repeats ON/OFF switching at fixed scan
User timing clock
SM421 intervals. M9021
No.1
When power supply is turned ON, or reset is per-
User timing clock formed, goes from OFF to start.
SM422 M9022
No. 2 The ON/OFF intervals are set with the DUTY
instruction. S QCPU
User timing clock
SM423 (Every END
No. 3 LCPU
processing) M9023
User timing clock
SM424
No. 4 n2 n1 n2
scan scan scan
User timing clock
SM430
No. 5
M9024
User timing clock
SM431
No. 6
User timing clock
SM432
No. 7
S Qn(H)
User timing clock For use with SM420 through SM424 low speed
SM433 (Every END New
No. 8 programs. QnPH
processing)
User timing clock
SM434
No. 9
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
OFF: Completed or
S Qn(H)
Low speed program not executed Goes ON when low-speed execution type program
SM510 (Every END New
execution flag ON: Execution under is executed. QnPH
processing)
way
When this goes from OFF to ON, the module serv- Qn(H)
Reads module service OFF: Ignored
SM551 ice interval designated by SD550 is read to SD551 U New QnPH
interval ON: Read
through SD552. QnPRH
ACPU Valid
Number Name Meaning Description Set by (if set) M9 for:
When this relay is turned on, I/O refresh is per-
formed after execution of the first program, and
then the next program is executed. When a
Program to program I/O OFF: Not refreshed Q00J/Q00
SM580 sequence program and a SFC program are to be U New
refresh ON: Refreshed /Q01 1)
executed, the sequence program is executed, I/O
refresh is performed, and then the SFC program is
executed.
A – 124
Appendix A Table of special relays
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
Qn(H)
QnPH
ON when memory card is ready for use by user.
QnPRH
Memory card usable OFF: Unusable S QnU 1)
SM600 New
flags ON: Use enabled (Status change)
Turns ON when the SD memory card becomes
ready for use. (This relay turns on when a com-
LCPU
patible SD memory card is inserted and set to be
enabled with the SD memory card lock switch.)
Qn(H)
QnPH
Memory card protect OFF: No protect Goes ON when memory card protect switch is S
SM601 New QnPRH
flag ON: Protect ON. (Status change)
QnU 1)
LCPU
Qn(H)
OFF: No drive 1 Goes ON when drive 1 (card 1 RAM area) is S QnPH
SM602 Drive 1 flag New
ON: Drive 1 present present. (Status change) QnPRH
QnU 1)
Qn(H)
Goes ON when drive 2 (card 1 ROM area) is S QnPH
present. (Status change) QnPRH
OFF: No drive 2 QnU 1)
SM603 Drive 2 flag New
ON: Drive 2 present
Is ON while a SD memory card is being inserted.
(This relay is ON while a SD memory card is S
LCPU
being inserted, regardless of the availability and (Status change)
the type of the card.)
Qn(H)
QnPH
Memory card in-use OFF: Not in use S
SM604 Goes ON when memory card is in use. New QnPRH
flag ON: In use (Status change)
QnU 1)
LCPU
Qn(H)
Goes ON when memory card cannot be inserted QnPH
U New
or removed. QnPRH
OFF: Remove/insert QnU 1)
Memory card
enabled
SM605 remove/insert pro- Turns ON to disable the insertion and removal of
ON: Remove/insert
hibit flag a memory card. (Turns ON when a compatible
prohibited
SD memory card is inserted and set to be ena- S
New LCPU
bled with the SD memory card lock switch. This (Status change)
relay does not turn ON while "ICM.OPE.ERROR"
occurs.)
OFF: SD memory card This relay is turned on to execute the SD
forced disable cancel memory card forced disable instruction.
SD memory card
instruction When there are any functions accessing to
SM606 forced disable instruc- an SD memory card, the process of U New LCPU
ON: SD memory card disablement is held until it is completed.
tion
forced disable This relay is turned off to cancel the SD
instruction memory card forced disable instruction.
OFF: Not being disabled by This relay turns on when an SD memory
SD memory card card is disabled by turning on SM606 (SD
SD memory card forced disable memory card forced disable instruction). S
SM607 forced disable status instruction This relay turns off when the forced disable New LCPU
status of SD memory card is canceled by (Status change)
flag ON: Being disabled by SD
memory card forced turning off SM606 (SD memory card forced
disable instruction disable instruction).
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
This relay is turned ON to enable the Qn(H)
OFF: Remove/insert insertion and removal of a memory card.
Memory card QnPH
SM609 remove/insert enable
prohibited Turned OFF by the system after the memory S/U New
ON: Remove/insert card is removed. QnPRH
flag This relay can be used while both SM604
enabled
and SM605 are off. QnU 1)
Latch data backup to This relay turns on when latch data backup
OFF: Not completed to the standard ROM is completed. S QnU
SM671 standard ROM com- New
ON: Completed Time when the backup is completed is (Status change) LCPU
pletion flag stored in SD672 or later.
Goes ON when access is made to area outside Qn(H)
Memory card A file
OFF: Within access range the range of file register R of memory card A
SM672 register access range S/U New QnPH
ON: Outside access range (set within END processing).
flag QnPRH
Reset at user program.
A – 126
Appendix A Table of special relays
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
When latch data are backed up while this
Specification of relay is on, the backup data will be restored
OFF: Not specified at every power-on of the CPU module. QnU
SM676 restration repeated U New
ON: Specified The backup data will be restored at every LCPU
execution power-on until the latch data are deleted or
the latch data are backed up again.
This relay turns on if a write error is detected
OFF: Write not
Program memory during writing to the program memory (flash QnU
SM680 executed/normal S (At write) New
write error ROM). This relay turns off when a write LCPU
ON: Write error
command is given.
This relay is on during writing to the program
Program memory OFF: Write not executed QnU
SM681 memory (flash ROM) and turns off when the S (At write) New
writing flag ON: During writing LCPU
writing is completed.
OFF: Overwrite count is This relay turns on when overwrite count of the
Program memory
less than 100,000 program memory (flash ROM) reaches to QnU
SM682 overwrite count error S (At write) New
ON: Overwrite count is 100,000. (It is necessary to change CPU LCPU
flag
100,000 or more module.)
This relay turns on if a write error is detected
OFF: Write not
Standard ROM write during writing to the standard ROM (flash QnU
SM685 executed/normal S (At write) New
error ROM). This relay turns off when a write LCPU
ON: Write error
command is given.
OFF: Overwrite not This relay is on during writing to the standard
Standard ROM writing QnU
SM686 executed ROM (flash ROM) and turns off when the writing S (At write) New
flag LCPU
ON: During overwriting is completed.
OFF: Overwrite count is
Standard ROM This relay turns on when overwrite count of the
less than 100,000 QnU
SM687 overwrite count error standard ROM (flash ROM) reaches to 100,000. S (At write) New
ON: Overwrite count is LCPU
flag (It is necessary to change CPU module.)
100,000 or more
OFF: Backup start
preparation not
Backup start completed Turns on when the backup preparation is
SM691
preparation status flag ON: Backup start completed.
preparation S QnU 1)
completed New
(Status change) LCPU
OFF: Restoration not
Restoration complete completed This relay turns on when backup data in a
SM692
flag ON: Restoration memory card has been restored.
completed
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
S
OFF: Carry OFF QCPU
SM700 Carry flag Carry flag used in application instruction. (Instruction M9012
ON: Carry ON LCPU
execution)
Qn(H)
OFF: Outputs until NUL QnPH
Number of output Used for the PR, PRC, BINDA, DBINDA, BINHA,
SM701 ON: 16 characters U M9049 QnPRH
characters selection DBINHA, BCDDA, DBCDDA, or COMRD instruction
output QnU
LCPU
Designates method to be used by search instruc-
OFF: Search next
SM702 Search method tion. U New
ON: 2-part search
Data must be arranged for 2-part search.
The sort instruction is used to designate whether QCPU
OFF: Ascending order
SM703 Sort order data should be sorted in ascending order or in U New LCPU
ON: Descending order
descending order.
Goes ON when all data conditions have been met
for the BKCMP instruction. S
OFF: Non-match found
SM704 Block comparison (Instruction New
ON: All match This relay turns on when all data conditions are QnU 2)
execution)
met for the DBKCMP instruction. LCPU
This relay turns on when the data to be compared
OFF: Improper data not
DT/TM instruction by the DT or TM instruction cannot S QnU 2)
detected
SM709 improper data detec- be recognized as date or time data, when the (Instruction New
ON: Improper data LCPU
tion flag device (three words) to be compared is execution)/U
detected
exceeding the specified device range.
S Qn(H)
CHK instruction prior- OFF: Conditions priority Remains as originally set when OFF.
SM710 (Instruction New QnPH
ity ranking flag ON: Pattern priority CHK priorities updated when ON.
execution) QnPRH
OFF: During DI QCPU
SM715 EI flag ON when EI instruction is being executed.
ON: During EI LCPU
This relay turns on when all data conditions are
met for the DBKCMP instruction. (Initial execution
Block comparison
OFF: Mismatch found type program and scan execution type program or
SM716 (Except an interrupt
ON: No mismatch standby type program executed from initial execu-
program)
tion type program or scan execution type pro-
gram)
S QnU 2)
This relay turns on when all data conditions are (Instruction New LCPU
met for the DBKCMP instruction. execution)
Block comparison OFF: Mismatch found (Interrupt program, fixed scan execution type pro-
SM717
(Interrupt program) ON: No mismatch gram, or standby type program executed from
interrupt program or fixed scan execution type
program)
This relay turns on when all data conditions are
Block comparison
OFF: Mismatch found met for the DBKCMP instruction.
SM718 (Interrupt program QnU 3)
ON: No mismatch (Interrupt program (I45) or standby type program
(I45))
that was executed from interrupt program (I45))
SM720 is set for one scan after the execution of Qn(H)
OFF: Comment read not the COMRD or PRC instruction QnPH
Comment read com- completed S
SM720 This relay turns on only during first scan after the New QnPRH
pletion flag ON: Comment read (Status change)
completed processing of the COMRD instruction is com- QnU
pleted. LCPU
A – 128
Appendix A Table of special relays
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
This flag is ON while a file is being accessed by the Qn(H)
SP.FWRITE, SP.FREAD, COMRD, PRC, or LEDC
instruction QnPH
OFF: Performs link Select whether or not to perform link refresh Q00J/Q00
refresh processing in cases where only general data /Q01
ON: No link refresh processing will be conducted during the execution Qn(H)
performed of the COM instruction. QnPH
Selection of link Q00J/Q00
refresh processing /Q01 1)
SM775 U New
during COM/CCOM OFF: Performs refresh
instruction execution Qn(H) 7)
processes other Select whether to perform refresh processes other
than an I/O refresh than an I/O refresh set by SD778 when QnPH 4)
ON: Performs refresh the COM or CCOM instruction is executed. QnPRH
set by SD778
QnU
LCPU
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
OFF: Local device
This flag specifies whether to enable or disable the
Enable local device at disabled Qn(H)
SM776 local device in the program called at the CALL U New
CALL ON: Local device
instruction. QnPH
enabled
QnPRH
OFF: Local device
This flag specifies whether to enable or disable the QnU 10)
Enable local device in disabled
SM777 local device at the execution of an interrupt pro- U New LCPU
interrupt program ON: Local device
gram.
enabled
Q00J/Q00
S /Q01 1)
PID bumpless
OFF: Matched Specifies whether to match the set value (SV) with (When Qn(H) 8)
SM794 processing(for incom- New
ON: Not matched the process value (PV) or not in the manual mode. instruction/END QnPRH
plete derivative)
processing executed) QnU
LCPU
This relay turns on when the number of the
remaining blocks in the dedicated instruction
Block information
transmission area used for the multiple CPU high-
using multiple CPU S
OFF: Block is secured speed transmission dedicated instruction (target
high-speed transmis- (When
SM796 ON: Block set by SD796 CPU= CPU No.1) is less than the number of blocks New QnU 9)
sion dedicated instruction/END
cannot be secured specified in SD796. This relay is on when an
instruction (for CPU processing executed)
instruction is executed, and is off while an END
No.1)
processing is being executed or when free space
is available in the area.
This relay turns on when the number of the
remaining blocks in the dedicated instruction
Block information
transmission area used for the multiple CPU high-
using multiple CPU S
OFF: Block is secured speed transmission dedicated instruction (target
high-speed transmis- (When
SM797 ON: Block set by SD797 CPU= CPU No.2) is less than the number of blocks New QnU 9)
sion dedicated instruction/END
cannot be secured specified in SD797. This relay is on when an
instruction (for CPU processing executed)
instruction is executed, and is off while an END
No.2)
processing is being executed or when free space
is available in the area.
This relay turns on when the number of the
remaining blocks in the dedicated instruction
Block information
transmission area used for the multiple CPU high-
using multiple CPU S
OFF: Block is secured speed transmission dedicated instruction (target
high-speed transmis- (When
SM798 ON: Block set by SD798 CPU= CPU No.3) is less than the number of blocks New QnU 9)
sion dedicated instruction/END
cannot be secured specified in SD798. This relay is on when an
instruction (for CPU processing executed)
instruction is executed, and is off while an END
No.3)
processing is being executed or when free space
is available in the area.
This relay turns on when the number of the
remaining blocks in the dedicated instruction
Block information
transmission area used for the multiple CPU high-
using multiple CPU S
OFF: Block is secured speed transmission dedicated instruction (target
high-speed transmis- (When
SM799 ON: Block set by SD799 CPU= CPU No.) is less than the number of blocks New QnU 9)
sion dedicated instruction/END
cannot be secured specified in SD799. This relay is on when an
instruction (for CPU processing executed)
instruction is executed, and is off while an END
No.4)
processing is being executed or when free space
is available in the area.
A – 130
Appendix A Table of special relays
A.6.8 Debugging
ACPU Valid
Number Name Meaning Description Set by (if set)
M9 for:
Qn(H)
QnPH
OFF: Not prepared Goes ON when the trace preparation is com- S
SM800 Trace preparation New QnPRH
ON: Ready pleted. (Status change)
QnU 1)
LCPU
Qn(H)
QnPH
OFF: Suspend Trace is started when this goes ON.
SM801 Trace start U M9047 QnPRH
ON: Start Suspended when OFF (Related special M all OFF).
QnU 1)
LCPU
Qn(H)
QnPH
Trace execution in OFF: Suspend S
SM802 Goes ON during execution of trace. M9046 QnPRH
progress ON: Start (Status change)
QnU 1)
LCPU
Qn(H)
This relay turns on when the specified trigger QnPH
condition is met. S
SM803 Trace trigger OFF → ON: Start M9044 QnPRH
This relay is turned on to meet the trigger (Status change)/U
condition. QnU 1)
LCPU
Qn(H)
QnPH
OFF: Not after trigger S
SM804 After Trace trigger Goes ON after trace trigger is triggered. New QnPRH
ON: After trigger (Status change)
QnU 1)
LCPU
Qn(H)
QnPH
OFF: Not completed S
SM805 Trace completed Goes ON at completion of trace. M9043 QnPRH
ON: End (Status change)
QnU 1)
LCPU
Qn(H)
QnPH
OFF: Normal Goes ON if error occurs during execution of S
SM826 Trace error New QnPRH
ON: Error trace/sampling trace. (Status change)
QnU 1)
LCPU
When this relay is turned on and a sampling trace
OFF: Forced registration
Forced registration setting is registered using a programming tool, QnU 1)
disabled
SM829 specification of trace the sampling trace setting can be registered with U
ON: Forced registration LCPU
setting the CPU module even when the trigger condition
enabled
has been met.
New
This relay is on while auto logging is being exe-
cuted. This relay turns off when auto logging is
OFF: No auto logging S
SM841 Auto logging completed and the SD memory card lock switch LCPU
ON: Auto logging (Status change)
is slid toward the module top to stop access to
the SD memory card.
For a conversion from the MELSEC A series to the MELSEC System Q or L series the special
relays M9000 through M9255 (A series) correspond to the special relays SM1000 through
SM1255 for QCPU or LCPU after the A to Q/L conversion. (Note that the Basic model QCPU
and Redundant CPU do not support the A to Q/L conversion.)
These special relays are all set by the system and cannot be changed by a user-program.
Users intending to set or reset these relays should alter their programs so that only real QCPU
or LCPU special relays are applied. An exception are the special relays M9084 and M9200
through M9255. If a user can set or reset some of these special relays before conversion, the
user can also set and reset the corresponding relays among SM1084 and SM1200 through
SM1255 after the conversion.
Refer to the manuals of the CPUs and the networks MELSECNET and MELSECNET/B for
detailed information on the special relays of the A series.
NOTE To use the converted special relay in the High Performance model QCPU, Process CPU, Uni-
versal model QCPU, or LCPU, check "Use special relay/special register from SM/SD1000" un-
der "A-PLC Compatibility Setting".
Project window ⇒ [Parameter] ⇒ [PLC Parameter] ⇒ [PLC System]
Note that the processing time will increase when the converted special relay is used.
How to read the Special Relay for Modification column:
• If the special relay number for QCPU or LCPU is provided, correct the program using it.
• If no special relay is specified (–), the converted special relay can be used.
• If the special relay cannot be used in QCPU or LCPU, this is indicated as "No function for
QCPU/LCPU".
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
A – 132
Appendix A Table of special relays
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
DUTY n1 n2 SM1020
n1: ON scan interval
n2: OFF scan interval
n2 n2
scan scan
n1
When SM1020 to SM1024 are specified
scan for the DUTY instruction in programs, if
M9024 SM1024 — User timing clock No. 4 the CPU type is changed from the High
Performance model QCPU or Process Qn(H)
CPU to the Universal model QCPU or QnPH
LCPU, they are replaced with SM420 to QnU 1)
SM424. (For the Universal model QCPU
and LCPU, SM1020 to SM1024 cannot LCPU
be specified.)
Clock data stored in SD1025 to SD1028
OFF: Ignored are written to the CPU module after the
M9025 SM1025 — Clock data set request
ON: Set request present used END instruction execution in the scan
where SM1025 is turned on.
This relay turns on if an error occurs in the
OFF: No error
M9026 SM1026 — Clock data error clock data (SD1025 to SD1028), and is off
ON: Error
while there is no error.
This relay is turned on to read clock data
OFF: Ignored
M9028 SM1028 — Clock data read request and store them as BCD values into SD1025
ON: Read request
to SD1028.
When this relay is turned on in the
program, all the data communication
requests accepted during one scan are
processed in the END processing of
OFF: Batch processing not that scan.
No function for Batch processing of data conducted The batch processing of data Qn(H)
M9029 SM1029 communication requests can be turned
QCPU/LCPU communications request ON: Batch processing QnPH
conducted on or off during running.
The default is OFF (processed one at a
time for each END processing in the
order in which data communication
requests are accepted).
M9031 SM1031 — 0.2 second clock 0.1-, 0.2-, 1-, and 2-second clocks are
0.1 s 0.1 s generated. Qn(H)
The relay turns on or off not for each
scan, but also during a scan if the time QnPH
has elapsed. QnU 1)
When the CPU module is powered on
M9032 SM1032 — 1 second clock or reset, this relay is set to on from off LCPU
0.5 s 0.5 s to start the clock.
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
A – 134
Appendix A Table of special relays
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
A – 136
Appendix A Table of special relays
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
Tab. A-50: Special relays (9): Conversion from A series to System Q or L series
1
The relevant modules are as follows:
• The Universal model QCPU whose serial number (first five digits) is "10102" or higher.
• Q00UJCPU, Q00UCPU, Q01UCPU
2 1 minute clock indicates the name of the special relay (M9034) of the ACPU.
3
The A8UPU/A8PUJ is not available for the QCPU/LCPU.
A – 138
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
OFF: No time setting
function (SNTP This relay is turned on to perform the time setting
Time setting function (SNTP client) execution function (SNTP client). (Turns on only when "Use"
SM1270
client) execution ON: Time setting function has been set for the time setting function in the time
(SNTP client) setting parameter.) QnU 1)
execution LCPU
Tab. A-51: Special relays (10): Built-in Ethernet port and built-in Ethernet function
1
This applies to the Built-in Ethernet port QCPU.
2
This applies to the built-in Ethernet port QCPU whose first five digits of serial No. is "11082" or higher.
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Specifies whether or not to hold the output value
SM1500 when a range over occurs for the S.IN instruction
OFF: No-hold range check. QnPH
Hold mode U New
ON: Hold Specifies whether or not the output value is held QnPR
SM1501 when a range over occurs for the S.OUT instruction
range check.
The special relays SM1510 to SM1599 store information of the host CPU module.
These special relays are valid only for redundant systems. SM1510 to SM1599 are set to off
for stand-alone systems.
Set by ACPU
Number Name Meaning Description (if set) M9 Valid for:
Debug mode status OFF: Not in debug mode This relay is on while the system is operating in the debug
SM1513 New QnPRH
flag ON: Debug mode mode.
Tab. A-53: Special relays (12): Redundant system (host system CPU information)
A – 140
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Standby system to This relay turns on during one scan after the standby
ON system was switched to the control system.
SM1518 control system 1 scan New QnPRH
This relay can be used only in a scan execution type
switching status flag OFF
program. S
(Every END
When the previous control system is System B, this relay processing)
Previous Control
ON 1 scan turns on during one scan in System A, following the RUN
SM1519 System Identification New QnPRH
OFF state after both Systems A and B were simultaneously
Flag
turned on or were reset.
Tab. A-53: Special relays (12): Redundant system (host system CPU information)
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Tab. A-53: Special relays (12): Redundant system (host system CPU information)
A – 142
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Tab. A-53: Special relays (12): Redundant system (host system CPU information)
The special relays SM1600 to SM1649 store diagnostic information and system information of
other system CPU.
These special relays are valid only when the redundant system is in backup mode and is invalid
in separate mode. SM1600 to SM1649 are set to OFF for stand-alone systems.
Correspon
ding host
Set by
Number Name Meaning Description (if set) system Valid for:
special
relay
This relay turns on if an error is detected by error
OFF: No error check for redundant system. (This relay turns on
SM1600 Other system error flag when any of the SD1600 bits turns on.) — QnPRH
ON: Error
This relay turns off when an error is cleared.
This relay turns ON if a diagnostic error occurs in
the CPU module in the other system. (Also turns
Other system diagnostics OFF: No error ON when an annunciator turns ON and when an
SM1610 SM0 QnPRH
error ON: Error error is detected by the CHK instruction.)
The SM0 status for the CPU module in the other
system is reflected.
This relay turns on if a self-diagnostics error
OFF: No self diagnostics occurred in the CPU module in the other system. S
Other systems self error occurred (Excluding error detections by an annunciator and
SM1611 (Every END SM1 QnPRH
diagnostics error. ON: Self diagnostics error the CHK instruction.)
The SM1 status for the CPU module in the other processing)
occurred
system is reflected.
OFF: No common error This relay turns on when there is error common
Other system common information present information data for an error occurred in the CPU
SM1615 module in the other system. SM5 QnPRH
error information ON: Common error The SM5 status for the CPU module in the other
information present system is reflected.
OFF: No individual error This relay turns on when there is error individual
Error individual information for an error occurred in the CPU
information present
SM1626 information for other module in the other system. SM16 QnPRH
ON: Individual error The SM16 status for the CPU module in the other
systems
information present system is reflected.
OFF to ON: This relay is turned on from off to clear a continuation
Standby system cancel
SM1649 Cancels error of standby error occurred in the standby system. Use SD1649 to U — QnPRH
error flag
system specify the error code of the error to be canceled.
Tab. A-54: Special relays (13): Redundant system (other system CPU information)
A – 144
Appendix A Table of special relays
The special relays SM1700 to SM1799 are valid when the redundant system is in backup mode
or in separate mode. SM1700 to SM1799 are set to OFF for stand-alone systems.
A – 146
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
OFF: No redundant power Turns ON when one or more redundant power
supply module with supply modules with input power OFF are
input power OFF detected. Qn(H) 3)
Power supply off detection detected Turns on if any of SD1780 bits is on. S
QnPH 3)
SM1780 Turns off if all bits of SD1780 are off. (Every END New
flag ON: Redundant power This relay turns off when the main base unit is QnPRH
processing)
supply module with not the redundant main base unit (Q38RB). QnU 4)
input power OFF When the multiple CPU system is configured,
detected the flags are stored only to the CPU No.1.
Turns ON when one or more faulty redundant
OFF: No faulty redundant power supply modules are detected.
power supply module Turns on if any of SD1781 bits is on. Qn(H) 3)
S
Power supply failure detected Turns off if all bits of SD1781 are off. QnPH 3)
SM1781 This relay turns off when the main base unit is (Every END New
detection flag ON: Faulty redundant QnPRH
processing)
power supply module not the redundant main base unit (Q38RB). QnU 4)
detected When the multiple CPU system is configured,
the flags are stored only to the CPU No.1.
Tab. A-56: Special relays (15): Redundant power supply module information
1
The "power supply 1" indicates the redundant power supply module mounted on the POWER 1 slot of the redundant base unit
(Q38RB/Q68RB/Q65WRB).
2
The "power supply 2" indicates the redundant power supply module mounted on the POWER 2 slot of the redundant base unit (Q38RB/Q68RB/Q65WRB).
3
The module whose first 5 digits of serial No. is "04012" or higher. However, for the multiple CPU system configuration, this applies to all CPU modules
whose first 5 digits of serial No. are "07032" or higher.
4
The module whose first 5 digits of serial No. is "10042" or higher.
A – 148
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
This relay turns on when positioning control, OPR
control, JOG operation, or absolute position
restoration is started. This relay turns off when
each control is completed. In positioning control, S
OFF: Not busy this relay turns off when the axis 1 decelerates
SM1840 Axis 1 busy (Every END New LCPU
ON: Busy and stops, and then "dwell time" elapsed. (This
relay remains on while positioning control is processing)
being performed.)
This relay turns off when each control is ended
due to such as an error or stop operation.
This relay turns on when OPR control, position
control, or absolute position restoration is
completed. S
This relay turns off when OPR control, positioning (Instruction
Axis 1 positioning OFF: Not completed control, absolute position restoration, or JOG
SM1841 execution/ New LCPU
completion ON: Completed operation is started.
This relay remains off when JOG operation is Status
completed. change)
This relay remains off when position control is
stopped.
This relay turns on when the CPU module is
OFF: Machine OPR control powered on, is reset, or is set from STOP to RUN; S
completed or the drive unit ready signal turns off; or machine
SM1842 Axis 1 OPR request (Every END New LCPU
ON: Machine OPR control OPR control is started.
This relay turns off when machine OPR control is processing)
started
completed.
This relay turns on when machine OPR control is
completed. S
OFF: Not completed This relay turns off when OPR control, positioning (Instruction
SM1843 Axis 1 OPR completion control, absolute position restoration, or JOG execution/ New LCPU
ON: Completed operation is started; or the CPU module is set Status
from STOP to RUN; or the drive unit ready signal change)
turns off.
This relay turns on when JOG operation or speed
control in speed/position switching control set at
OFF: Operating at speed a speed of "0" is started.
SM1844 Axis 1 speed 0 other than 0 This relay turns on when speed is changed with a New LCPU
ON: Operating at speed 0 new speed value of "0", and turns off when speed
is changed with a new speed value other than "0".
This relay turns off when SM1840 turns off. S
(Every END
OFF: No error This relay turns on if an error occurs. processing)
SM1845 Axis 1 error The present error can be checked by SD1845. New LCPU
ON: Error This relay is turned off by turning on SM1850.
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Turning on this relay will turn off SM1845 and
OFF → ON: Resets the Axis SM1846 and will clear the SD1845 and SD1846
SM1850 Axis 1 error reset 1 error. values to "0".
Even if this relay is turned on, SM1845 will not
OFF: Clears the reset status. turn off and the SD1845 value will not be cleared
to "0" until SM1840 turns off. U
OFF → ON: Axis 1 OPR New LCPU
SM1851 Axis 1 OPR request off request Turning on this relay will forcibly turn off SM1842.
OFF: Cleared
This relay stores whether to enable switching from
Axis 1 speed/ position OFF: Disabled
SM1852 speed control to position control in speed/position
switching ON: Enabled
switching control.
This relay turns on when positioning control, OPR
control, JOG operation, or absolute position
restoration is started. This relay turns off when
each control is completed. In positioning control, S
OFF: Not busy this relay turns off when the axis 2 decelerates
SM1860 Axis 2 busy (Every END New LCPU
ON: Busy and stops, and then "dwell time" elapsed. (This
relay remains on while positioning control is processing)
being performed.)
This relay turns off when each control is ended
due to such as an error or stop operation.
This relay turns on when OPR control, position
control, or absolute position restoration is
completed. S
This relay turns off when OPR control, positioning (Instruction
Axis 2 positioning OFF: Not completed control, absolute position restoration, or JOG
SM1861 operation is started. execution/ New LCPU
completion ON: Completed
This relay remains off when JOG operation is Status
completed. change)
This relay remains off when position control is
stopped.
This relay turns on when the CPU module is
OFF: Machine OPR control powered on, is reset, or is set from STOP to RUN; S (Every
completed or the drive unit ready signal turns off; or machine
SM1862 Axis 2 OPR request END New LCPU
ON: Machine OPR control OPR control is started.
This relay turns off when machine OPR control is processing)
started
completed.
This relay turns on when machine OPR control is
completed. S
OFF: Not completed This relay turns off when OPR control, positioning (Instruction
SM1863 Axis 2 OPR completion control, absolute position restoration, or JOG execution/ New LCPU
ON: Completed operation is started; or the CPU module is set Status
from STOP to RUN; or the drive unit ready signal change)
turns off.
This relay turns on when JOG operation or speed
control in speed/position switching control set at
OFF: Operating at speed a speed of "0" is started. S (Every
SM1864 Axis 2 speed 0 other than 0 This relay turns on when speed is changed with a END New LCPU
ON: Operating at speed 0 new speed value of "0", and turns off when speed processing)
is changed with a new speed value other than "0".
This relay turns off when SM1860 turns off.
A – 150
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
Turning on this relay will turn off SM1865 and
OFF → ON: Resets the Axis SM1866 and will clear the SD1865 and SD1866
SM1870 Axis 2 error reset 2 error. values to "0". New LCPU
Even if this relay is turned on, SM1865 will not
OFF: Clears the reset status. turn off and the SD1865 value will not be cleared
to "0" until SM1860 turns off.
OFF → ON: Axis 2 OPR U
SM1871 Axis 2 OPR request off request Turning on this relay will forcibly turn off SM1862. New LCPU
OFF: Cleared
This relay stores whether to enable switching from
Axis 2 speed/ position OFF: Disabled
SM1872 speed control to position control in speed/position New LCPU
switching ON: Enabled
switching control.
OFF: Coincidence point This relay turns on when "current value of CH1 >
(No.1) or smaller coincidence output No.1 point setting value" is S
CH1 counter value greater met.
SM1880 ON: Greater than This relay turns off when "current value of CH1 <= (Every END New LCPU
(No.1)
coincidence point coincidence output No.1 point setting value" is processing)
(No.1) met.
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
SM1895
CH1 count enable
Starts counting. This relay is turned on to start counting. U New LCPU
command The command is valid while this relay is on.
This relay is turned on to start the selected
counter function.
When the count disabling function is selected, the
command is valid while this relay is on.
CH1 counter function Starts the selected counter When the latch counter function or the sampling
SM1896 counter function is selected, the command is U New LCPU
selection start command function. valid at the rise of this relay (from OFF to ON). The
on time must be held for at least 2 ms.
When the count disabling/preset function or the
latch counter/preset function is selected, the
command is invalid.
This relay is turned on to reset CH1 external
CH1 external preset preset (phase Z) request detection.
Resets CH1 external preset The command is valid at the rise of this relay
SM1897 (phase Z) request (from OFF to ON). U New LCPU
(phase Z) request detection.
detection reset command The on and off time must be held for at least
2 ms.
SM1898
CH1 pulse measurement
Starts pulse measurement. This relay is turned on to measure pulses. U New LCPU
start command The command is valid while this relay is on.
This relay is turned on to reset the CH1 error.
The command is valid at the rise of this relay
SM1899 CH1 error reset command Resets the CH1 error. (from OFF to ON). U New LCPU
The on and off time must be held for at least
2 ms.
OFF: Coincidence point This relay turns on when "current value of CH2 >
(No.1) or smaller coincidence output No.1 point setting value" is S (Every
CH2 counter value greater met.
SM1900 ON: Greater than END New LCPU
(No.1) This relay turns off when "current value of CH2 <=
coincidence point coincidence output No.1 point setting value" is processing)
(No.1) met.
This relay turns on when "current value of CH2 = S (Status
CH2 counter value OFF: Not detected coincidence output No.1 point setting value" is change/
SM1901 met. New LCPU
coincidence (No.1) ON: Detected This relay is turned off by turning on CH2 Every END
coincidence signal No.1 reset command. processing)
OFF: Coincidence point This relay turns on when "current value of CH2 <
(No.1) or greater coincidence output No.1 point setting value" is
CH2 counter value smaller met.
SM1902 ON: Smaller than
(No.1) This relay turns off when "current value of CH2 >=
coincidence point coincidence output No.1 point setting value" is S (Every
(No.1) met. END
processing) New LCPU
OFF: Coincidence point This relay turns on when "current value of CH2 >
(No.2) or smaller coincidence output No.2 point setting value" is
CH2 counter value greater met.
SM1903 ON: Greater than
(No.2) This relay turns off when "current value of CH2 <=
coincidence point coincidence output No.2 point setting value" is
(No.2) met.
This relay turns on when "current value of CH2 = S (Status
CH2 counter value OFF: Not detected coincidence output No.2 point setting value" is change/
SM1904 met. New LCPU
coincidence (No.2) ON: Detected This relay is turned off by turning on CH2 Every END
coincidence signal No.2 reset command. processing)
A – 152
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
OFF: Coincidence point This relay turns on when "current value of CH2 <
(No.2) or greater coincidence output No.2 point setting value" is
CH2 counter value smaller met.
SM1905 ON: Smaller than
(No.2) This relay turns off when "current value of CH2 >=
coincidence point coincidence output No.2 point setting value" is S (Every
(No.2) met. END New LCPU
This relay turns on when a preset request by processing)
CH2 external preset phase Z (preset) terminal of CH2 is detected.
OFF: Not detected
SM1906 (phase Z) request This relay is turned off by turning on CH2 external
ON: Detected preset (phase Z) request detection clear
detection
command.
This relay turns on if the CH2 error occurs.
OFF: No error This relay turns off when an error cause is
SM1907 CH2 Error removed and CH2 error reset command is turned
ON: Error
on. S (Every
END New LCPU
This relay turns on if a warning occurs in CH2. processing)
OFF: No warning This relay turns off when a warning cause is
SM1908 CH2 warning
ON: Warning removed and CH2 error reset command is turned
on.
This relay is turned on to reset CH2 counter value
CH2 coincidence signal Resets CH2 counter value coincidence No.1.
SM1910 U New LCPU
No.1 reset command coincidence No.1. The command is valid while this relay is on.
The on time must be held for at least 2ms.
This relay is turned on to reset CH2 counter value
CH2 coincidence signal Resets CH2 counter value coincidence No.2.
SM1911 The command is valid while this relay is on. U New LCPU
No.2 reset command coincidence No.2.
The on time must be held for at least 2ms.
SM1915
CH2 count enable
Starts counting. This relay is turned on to start counting. U New LCPU
command The command is valid while this relay is on.
This relay is turned on to start the selected
counter function.
When the count disabling function is selected, the
command is valid while this relay is on.
CH2 counter function Starts the selected counter When the latch counter function or the sampling
SM1916 counter function is selected, the command is U New LCPU
selection start command function. valid at the rise of this relay (from OFF to ON). The
on time must be held for at least 2 ms.
When the count disabling/preset function or the
latch counter/preset function is selected, the
command is invalid.
This relay is turned on to reset CH2 external
CH2 external preset preset (phase Z) request detection.
Resets CH2 external preset
SM1917 (phase Z) request The command is valid at the rise of this relay U New LCPU
(phase Z) request detection. (from OFF to ON).
detection reset command
The on and off time must be held for at least 2ms.
CH2 pulse measurement This relay is turned on to measure pulses.
SM1918 Starts pulse measurement. The command is valid while this relay is on. U New LCPU
start command
This relay is turned on to reset the CH2 error.
The command is valid at the rise of this relay
SM1919 CH2 error reset command Resets the CH2 error. (from OFF to ON). U New LCPU
The on and off time must be held for at least 2
ms.
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
This relay turns on when the system is ready for
data logging.
Data logging setting No.1 OFF: Not ready S
SM1940 This relay remains on even after data logging is sus- New LCPU
Data logging preparation ON: Ready (Initial)
pended. However, this relay turns off when data log-
ging is stopped.
This relay is turned on to start data logging and is
Data logging setting No.1 OFF: Pause
SM1941 turned off to suspend data logging. (The related U New LCPU
Data logging start ON: Start
special relays will all turn off.)
S
Data logging setting No.1 OFF: Not being collected
SM1942 This relay is on while data logging is being collected. (Status New LCPU
Data logging collection ON: Being collected
change)
This relay turns on when data logging is ended.
[Continuous is set for Logging type]
The corresponding bit turns on when data logging is
ended after data have been written by the number of
storable files (Stop is set for Operation occurring
when number of saved files is exceeded). [Trigger is
S
Data logging setting No.1 OFF: Not ended set for Logging type]
SM1943 (Status New LCPU
Data logging end ON: Ended The corresponding bit turns on when the trigger
change)
condition is met, data are collected by the number of
set times, and then the data are written to the SD
memory card.
This relay also turns on if an error occurs during
data logging (except data logging error occurred by
the execution of online change).
A – 154
Appendix A Table of special relays
Set by ACPU
Number Name Meaning Description Valid for:
(if set) M9
SM1950 to
Data logging setting No. 2
SM1957
SM1960 to
Data logging setting No. 3
SM1967
SM1970 to
Data logging setting No. 4
SM1977
SM1980 to
Data logging setting No. 5
SM1987 Same as in
data
SM1990 to Same as in data logging Same as in data logging setting No. 1
Data logging setting No. 6 logging New LCPU
SM1997 setting No. 1 (SM1940 to SM1947)
setting
SM2000 to No. 1
Data logging setting No. 7
SM2007
SM2010 to
Data logging setting No. 8
SM2017
SM2020 to
Data logging setting No. 9
SM2027
SM2030 to
Data logging setting No. 10
SM2037
Item Meaning
Number Indicates the number of the special register.
Name Indicates the name of the special register.
Meaning Contains the function of the special register in brief.
Description Contains a detailed description of the register.
Indicates whether the special relay is set by the system or the user.
<Set by>
S : Set by the system
U : Set by the user (using a program, programming tool, GOT,
or test operation frosm other external devices)
S/U : Set by the system or user
NOTE Do not change the values of special register set by system using a program or by test operation.
Doing so may result in system down or communication failure.
A – 156
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Error codes for errors found by diagnosis are stored as BIN
S D9008 QCPU
SD0 Diagnostic errors data.
(Error) format change LCPU
Contents identical to latest fault history information.
Year (last two digits) and month that SD0 data was updated
is stored as BCD 2-digit code.
Example: October 1995
SD1 H9510
b15 b8 b7 b0
Year (0 to 99) Month (1 to 31)
The day and hour that SD0 was updated is stored as BCD 2-
digit code.
Example: 10 p.m. on 25th
Clock time for diagnosis error occur- S QCPU
SD2 H2510 New
rence (Error) LCPU
b15 b8 b7 b0
Day (1 to 31) Hour (0 to 23)
The minute and second that SD0 data was updated is stored
as BCD 2-digit code.
Example: 35 min 48s
SD3 H3548
b15 b8 b7 b0
Minute (1 to 60) Second (1 to 60)
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Category codes which help indicate what type of informa-
tion is being stored in the common information areas (SD5
through SD15) and the individual information areas (SD16
through SD26) are stored here.
b15 b8 b7 b0
Individual error info. Common error info.
A – 158
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD5 Common information corresponding to the error codes
(SD0) is stored here.
SD6 The following ten types of information are stored here.
The error common information type can be determined
SD7
by "common information category code" stored in SD4.
SD8 (Values stored in "common information category code"
correspond to the following (1) to (8).)
SD9 (1) Module No.
SD10
Number Meaning
SD11 SM5 Slot No./CPU No./Base No. 1, 2, 3, 4, 5)
SD12 SM6 I/O No. 6)
SD13 SM7
SM8
SD14
SM9
SM10
SM11 (Vacant)
SM12
SM13
SM14
SM15
1
For a multiple CPU system, the module No. or CPU No. is
stored according to an error. (To determine whether a
storage value is a module No. or CPU No., refer to each
error code.)
CPU No. 1: 1, CPU No. 2: 2, CPU No. 3: 3, CPU No. 4: 4
2 If a fuse has been blown or an I/O module verification error
occurs in a module on the MELSECNET/H remote I/O sta-
tion, the network No. is stored in the upper 8 bits and the
station No. is stored in the lower 8 bits. To determine a
fuseblown module or a module where an I/O module veri- S QCPU
Error common information fication error occurs, check the I/O No. New
(Error) LCPU
3
If an instruction is executed to the Basic model QCPU on
the slot where the module cannot be mounted, "255" is
stored in SD5.
4
The definitions of the base No. and slot No. are as follows:
[Base No.]
SD15
Base No. Definition
0 Indicates the main base unit where a CPU
module is mounted.
1 to 7 Indicates the extension base unit. The
stage number setting made by the stage
number setting connector on the
extension base unit is the base No.
When stage number setting is extension 1:
Base No. = 1
When stage number setting is extension 7:
Base No. = 7
[Slot No.]
This number is used to identify the slot No. of a module
where an error occurs. The "0" I/O slot (slot on the right of
the CPU slot) on the main base unit is defined as "Slot No.
= 0". The slot Nos. are assigned in sequence numbers in
order of the main base unit and then the first extension
base unit to 7th extension base unit. When the number of
slots on base units has been set in the I/O assignment tab
of the PLC Parameter dialog box, the slot Nos. are
assigned by the number of set slots.
5
If a module is not mounted on any slots as set, FFH is stored.
6
If FFFFH is stored in SD6 (I/O No.), this indicates that the I/O
No. cannot be identified due to such as overlap of an I/O No.
in the I/O assignment setting of the PLC Parameter dialog
box. In this case, identify the error location using SD5.
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD5 (2) File name/Drive name
Example:
SD6
File name = ABCDEFGH.IJK
SD7 Number Meaning
Drive
SD8 b15 b0
B A
SD9 File name
D C
(ASCII code: 8
F E
SD10 characters)
H G
SD11 I .
Extension 7)
(ASCII code: 3 characters) K J
SD12
SD13 Vacant
SD14
SD5
SD6 File name
SD8
SD9 Extension 7) 2E H (.)
SD10 (ASCII code: 3 characters)
SD11 Pattern *
15 14 4 3 2 1 0 ( Bit No. )
0 0 0 0 * * *
SFC block designation present (1) / absent (0)
not used SFC step designation present (1) / absent (0)
SFC transiton designation present (1) / absent (0)
7)
Meaning of the extensions:
SDn SDn+1
Extension Name File type
Higher 8 bits Lower 8 bits Higher 8 bits
51H 50H 41H QPA Parameters
51H 50H 47H QPG Program
51H 43H 44H QCD Device comment
51H 44H 49H QDI Initial device value
51H 44H 52H QDR File register
Local device (For High Performance model QCPU, Process CPU, Redundant
51H 44H 4CH QDL
CPU, Universal model QCPU, and LCPU)
Sampling trace data (For High Performance model QCPU, Process CPU, Redun-
51H 54H 44H QTD
dant CPU, Universal model QCPU, and LCPU)
Breakdown history data (For High Performance model QCPU, Process CPU, and
51H 46H 44H QFD
Redundant CPU)
51H 53H 54H QST SP.DEVST/S.DEVLD instruction file (for Universal model QCPU and LCPU)
A – 160
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD5 (5) Reason(s) for system switching
SD6 Number Meaning
SD5 System switching cause *
SD7
SD6 Control system switching instruction argument
SD8 SD7
SD8
SD9 SD9
SD10
SD10
SD11 Vacant
SD11 SD12
SD13
SD12
SD14
SD13 SD15
SD6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1
SD8 (SM1583) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (SM1568)
(Block64) (Block49)
SD9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD5 (7) Base No./power supply No.
SD6 Number Meaning
SD14
1: Power supply 1 fault
2: Power supply 2 fault
Redundant power supply module mounted on POWER
1 resp. POWER 2 slot of redundant base unit (Q38RB,
Q68RB, Q65WRB)
(8) Tracking transmission data classification
This register stores a data type during tracking.
Number Meaning
S
Error common information SD5 Data type * New
SD6 (Error)
SD7
SD8
SD9
SD10
Vacant
SD11
SD12
SD13
SD14
SD15 SD15
Device data
Signal flow
PIDINIT/S.
PIDINIT
instruction data
SFC execution
data
System switching
request
Operation mode
change request
System data
A – 162
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD16 Individual information corresponding to the error codes
(SD0) is stored here.
SD17 The following eight types of information are stored
here.
SD18
The error individual information type can be determined
SD19 by "individual information category code" stored in SD4.
(Values stored in "individual information category code"
SD20 correspond to the following (1) to (8), (12) and (13).
(1) Empty
SD21
(2) File name/Drive name
SD22 Example:
File name = ABCDEFGH.IJK
SD23
Number Meaning
SD24 Drive
SD25 b15 b0
File name
(ASCII code: 8 B A
characters)
D C
F E
Extension 1)
(ASCII code: 3 characters) H G
I .
K J
Vacant
SD16
SD17 File name
(ASCII code: 8 characters)
SD18
SD19
SD20 Extension 1) 2E H (.)
SD21 (ASCII code: 3 characters)
SD22 Pattern *
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
(5) Parameter number
(6) Annunciator number
(7) CHK instruction malfunction number
SD17 SD17
SD18 SD18
SD19 SD19
SD20 SD20
SD21 SD21
Vacant Vacant
SD22 SD22
SD23 SD23
SD24 SD24
SD25 SD25
SD26 SD26
A – 164
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
(9) Failure information
Number Meaning
SM16 Failure information 1
SM17 Failure information 2
SM18 Failure information 3
SM19 Failure information 4 S
SM20 Failure information 5 LCPU
(Error)
SM21 Failure information 6
SM22 Failure information 7
SM23 Failure information 8
SM24 Failure information 9
SM25 Failure information 10
SM26 Failure information 11
Number Meaning
SM16 Failure information (H) Drive No. (L)
SM17
SM18 File name
SM19 (ASCII: 8 characters)
SM20 QnU
SD26 Error individual information SM21 Extension 1) 2EH(.) New LCPU
SM22 (ASCII: 3 characters)
SM23 Failure information 2
SM24 (CRC value that is read)
SM25 Failure information 3
SM26 (CRC value that is calculated)
Number Meaning
SM16 Parameter No. *
SM17 CPU No. (1 to 4)
SM18
SM19
SM20
SM21 QnU
SM22 (Vacant)
SM23
SM24
SM25
SM26
* For details of the parameter No., refer to the following: User's Manual
(Function Explanation, Program Fundamentals) for the CPU module used
Bits 1 and 2 are not available for the Basic model QCPU and
LCPU.
If an alarm occurs, data can be held within the time speci-
fied for battery low.
The error indicates full discharge of a battery.
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Same configuration as SD51 above
Bit pattern indicating After an alarm is detected (the alarm bit turns on), the QCPU
alarm bit turns off if an error is detected (the error bit S
SD52 Battery low where battery voltage turns on). (Universal model QCPU only) New
(Error) LCPU
drop occurred Subsequently, goes OFF when battery voltage is
restored to normal.
A value stored in this register is incremented by 1
whenever the input voltage falls to or below 85% (AC
AC DOWN Number of times for power)/65% (DC power) of the rating during operation S QCPU
SD53 of the CPU module. D9005
detection AC DOWN The counter repeats increment and decrement of the (Error) LCPU
value;
(0 ==> 32767 ==> -32768 ==> 0)
Blown fuse Number of module Value stored here is the lowest station number of the mod- S
SD60 D9000 QCPU
number with blown fuse ule with the blown fuse, divided by 16. (Error)
I/O module I/O module QCPU
The lowest number of the module where the I/O module S
SD61 verification verification error D9002
verification number took place. (Error) LCPU
error module number
S
SD62 Annunciator number The first annunciator number to be detected is stored here. (Instruction D9009
execution) QCPU
S LCPU
SD63 Number of annunciators Stores the number of annunciators searched. (Instruction D9124
execution)
SD64 When F goes ON due to OUT F or SET F, the F numbers D9125
which go progressively ON from SD64 through SD79 are
SD65 D9126
registered.
SD66 F numbers turned OFF by RST F are deleted from SD64 to D9127
SD79, and are shifted to the data register following the data
SD67 register where the deleted F numbers had been stored. D9128
SD68 Execution of the LEDR instruction shifts the contents of D9129
SD64 to SD79 up by one.
SD69 After 16 annunciators have been detected, detection of the D9130
SD70 17th will not be stored from SD64 through SD79. D9131
SD71 D9132
SET SET SET SET SET SET SET SET SET SET SET
F50 F25 F19 F25 F15 F70 F65 F38 F110 F151F210 LEDR
SD72
Table of Number
SD74 detected S QCPU
detected Annunciator Number of (Instruction
SD75 annunciator detection number annunciators LCPU
detected execution)
numbers
SD76
SD77
SD78
New
Number
detected
SD79
S Qn(H)
Error codes detected by the CHK instruction are stored as
SD80 CHK number (Instruction New QnPH
BCD code.
execution) QnPRH
A – 166
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD81 This register stores a continuation error cause
SP.UNIT DOWN
AC/DC DOWN
BATTERY ERROR
FLASH ROM ERROR
SP.UNIT ERROR
ICM.OPE.ERROR S
Continuation error cause New LCPU
SD82 FILE OPE.ERROR (Error)
REMOTE PASS.FAIL
SNTP OPE.ERROR
DISPLAY ERROR
OPERATION ERROR
PRG.TIME OVER
F***(Annunciator)
Empty
Empty
Empty
ACPU
Number Name Meaning Description Set by (if set) register Valid
for:
D9
Corresponds to
SD90 D9108
SM90
Corresponds to
SD91 F numbers that are set ON at setting D9109
SM91
value of step transition watchdog
Corresponds to timer and watchdog timer over
SD92 D9110
SM92 errors.
Corresponds to
SD93 D9111
SM93
Step transition
watchdog timer Corresponds to
SD94 F number for timer D9112 Qn(H)
setting value SM94
Setting of timer
set value and time Setting of U QnPH
(Enabled only Corresponds to F-number limit value
SD95 over error (0 to 255) (1 to 255 s, in 1 s steps)
D9113 QnPRH
when SFC SM95
program exists)
Corresponds to Timer is started by turning SM90
SD96 D9114
SM96 through SM99 ON during active step,
Corresponds to and if the transition conditions for the
SD97 relevant steps are not met within the New
SM97
timer limits, the designated annunci-
Corresponds to ator (F) will go ON.
SD98 New
SM98
Corresponds to
SD99 New
SM99
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Stores the
transmission speed
Transmission K96: 9600 bps, K192: 19.2 kbps, K384: 38.4 kbps,
SD100 specified in the serial New
speed K576: 57.6 kbps, K1152: 115.2 kbps
communication
setting.
Bit 4 = OFF: Without sumcheck Q00/Q01
Bit 4 = ON: With sumcheck
Stores the settings Q00UJ
Communication S
SD101 for serial Bit 5 = OFF: Online program correction disabled New Q00U
settings (power on or reset)
communication Bit 5 = ON: Online program correction enabled Q01U
The other bits have no function. Q02U 4)
A – 168
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD130 The number of output modules whose fuses have
blown are input as a bit pattern in units of 16 points. If
SD131 the module numbers are set by parameter, the
parameter-set numbers are stored.
SD132
Blown fuses of remote station output modules will be
SD133 detected also.
The bit pattern A set bit is not automatically cleared when the module
SD134 (16 Bit) indicates the with the blown fuse is replaced. The flag is cleared by
modules with a an error reset operation.
SD135 Modules with S
blown fuse. New
blown fuse b15 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
(Error)
SD136 0: No blown fuse SD130 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0
(YC0) (Y80)
1: Blown fuse SD131 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
detected (Y1F0) (Y1A)
SD137 SD137 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0
(Y1F30)
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
The CPU switch state is stored in the following format:
b15 b12b11 b8 b7 b4 b3 b0
New QnU
(1) CPU switch (0): RUN
status (1): STOP
A – 170
Appendix A Table of special registers
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
The following bit patterns are used to store the statuses of
the LEDs of the CPU.
0: OFF, 1: ON, 2: Flicker
bF bC bB b8 b7 b4 b3 b0
Q00J/Q00/
(8) (7) (6) (5) (4) (3) (2) (1)
S Q01
(Status New Qn(H)
(1): RUN (5): BOOT change)
(2): ERROR (6): Vacant QnPH
(3): USER (7): Vacant QnPRH
(4): BAT.ALARM
(8): MODE (0: OFF, 1: Green, 2: Orange)
SD201 LED status State of CPU-LED (8) (7) (6) (5) (4) (3) (2) (1) S
(Status New QnU
(1): RUN (5): BOOT * change)
(2): ERROR (6): Empty
(3): USER (7): Empty
(4): BAT.ALARM (8): MODE
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
The CPU operating state is stored as indicated in the following
figure:
b15 b12 b11 b8 b7 b4 b3 b0
A – 172
Appendix A Table of special registers
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
The LED display color of the LED status shown in SD201 1) to
8).
b15 b12 b11 b8 b7 b4 b3 b0
1) RUN LED
0: OFF
1: Green
2) ERR. LED
0: OFF
1: Red
3) USER LED
0: OFF
1: Red
4) BAT. LED
QnU
0: OFF
1: Yellow
2: Green
5) BOOT LED*
0: OFF
1: Green
6) Empty
7) Empty
8) MODE LED
0: OFF
1: Green
S
LED display * For the Q00UJCPU, Q00UCPU, and Q01UCPU, 5) is left empty.
SD204 CPU-LED display color (Status New
color
The LED display color of the LED status shown in SD201 1) to change)
8).
b15 b12 b11 b8 b7 b4 b3 b0
1) RUN LED
0: OFF
1: Green
2) ERR. LED
0: OFF
1: Red
3) USER LED
0: OFF
1: Red
LCPU
4) BAT. LED
0: OFF
1: Yellow
2: Green
5) Empty
6) Empty
7) I/O ERR.LED
0: OFF
1: Red
8) MODE LED
0: OFF
1: Green
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
SD207 Priorities 1 to 4 The priority of the LED indication in the case of an error is D9038
set by a cause number. (For the Basic model QCPU, only D9039
SD208 Priorities 5 to 8 the annunciator (cause number 7) is available.) (format
For the Universal model QCPU and LCPU, specify whether
to enable or disable LED indication of the error that has change)
priority when an error occurs.
The setting areas for priorities are as follows:
The day and hour are stored as BCD code at SD211 as shown
below:
The minutes and seconds (after the hour) are stored as BCD
code at SD212 as shown below:
Clock data b15 b12 b11 b8 b7 b4 b3 b0
SD212 Clock data Example: D9027
(minute, second)
35 min., 48
Minute sec. = 3548H
Second
A – 174
Appendix A Table of special registers
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
LED display ASCII data (16 characters) stored here.
For the Basic model QCPU, an error message (up to 16 ASCII
SD220 characters) is stored. (Including a message for the case the
annunciator is on.)
b15 to b8 b7 to b0
15th character from 16th character from
SD221 SD220
the right the right
13th character from 14th character from
SD222 SD221
the right the right
11th character from 12th character from
SD223 SD222
the right the right
9th character from 10th character from S QCPU
SD224 LED display SD223
Display indicator data the right the right (Status New
data LCPU
change)
7th character from 8th character from
SD225 SD224
the right the right
5th character from 6th character from
SD225
the right the right
SD226
3rd character from 4th character from
SD226
the right the right
1st character from 2nd character from
SD227
the right the right
SD227 For the Basic model QCPU, Universal model QCPU or LCPU,
HMI data at the time of CHK instruction execution are not
stored.
Module to
which online (The header I/O number of S
The value of the header I/O number of which the online mod- QnPH
module the module to which online (During online
SD235 ule change is being performed is divided by 10H and stored New
change is module change is being per- module QnPRH
here.
being per- formed)/10H change)
formed
0: Automatic mode S
SD240 Base mode Stores the base mode New
1: Detail mode (Initial)
Number of 0: Basic only QCPU
S
SD241 extension 1 to 7: Number of Stores the number of extension bases being installed New
(Initial)
bases extension bases
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
b7 b2 b1 b0
Fixed to 0 to
b4 b3 b2 b1 b0
Fixed to 0
Main base
1st expansion base S Q00J/Q00/
SD242 New
(Initial) Q01
2nd expansion base
A – 176
Appendix A Table of special registers
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
When SM250 goes from OFF to ON, the upper 2 digits of the S Qn(H)
final I/O number plus 1 of the modules loaded are stored as (Request QnPH
Loaded BIN values. END) QnPRH
SD250 maximum Loaded maximum I/O No. New Q00J/Q00/
I/O The first two digits of the number, which is the last I/O number S Q01
of the mounted modules plus 1, are stored. (Initial) QnU
LCPU
Number of modules Indicates the number of mounted MELSECNET/10 modules or
SD254
installed MELSECNET/H modules.
Indicates the I/O number of mounted MELSECNET/10 mod-
SD255 I/O No.
ules or MELSECNET/H modules.
Indicates the network No. of mounted MELSECNET/10 mod-
SD256 Network No. QCPU
ules or MELSECNET/H modules.
Information
Group Indicates the group number of mounted MELSECNET/10 mod-
SD257 from 1st
Number ules or MELSECNET/H modules.
module
Indicates the station number of mounted MELSECNET/10
SD258 Station No.
modules or MELSECNET/H modules.
MELSECNET/ S
Standby In the case of standby stations, the module number of the New Qn(H)
SD259 10/H infor- (Initial)
mation information standby station is stored. (1 to 4)
QnPH
SD260
Information from 2nd QnPRH
– Configuration is identical to that for the first module.
module QnU 2)
SD264
SD265
Information from 3rd Qn(H)
– Configuration is identical to that for the first module.
module
SD269 QnPH
SD270 QnPRH
Information from 4th
– Configuration is identical to that for the first module. QnU 3)
module
SD274
(3) (2) (1)
Qn(H)
(1) When Xn0 of the installed CC-Link module goes ON, the S
SD280 bit corresponding to the station switches ON. New QnPH
(error)
(2) When either Xn1 or XnF of the installed CC-Link module QnPRH
switch OFF, the bit corresponding to the station switches
ON.
(3) Switches ON when the CPU cannot communicate with
the installed CC-Link module.
The above modules are numbered in order of the head I/O
numbers. (However, the one where parameter setting has not
been made is not counted.)
CC-Link error Error detection status (3) (2) (1)
b15 ... b12 b11 ... b8 b7 ... b4 b3 ... b0
5th module
6th module
7th module
8th module
Qn(H) 4)
S
SD281 (1) When Xn0 of the installed CC-Link module goes ON, the New QnPH 4)
(error)
bit corresponding to the station switches ON. QnPRH 5)
(2) When either Xn1 or XnF of the installed CC-Link module
switch OFF, the bit corresponding to the station switches
ON.
(3) Switches ON when the CPU cannot communicate with
the installed CC-Link module.
The above modules are numbered in order of the head I/O
numbers. (However, the one where parameter setting has not
been made is not counted.)
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
SD286 Points assigned to M The number of points assigned to M is stored with 32 bits.
SD287 Device (for extension) The number of 32k or less points can be assigned to M. S QnU 6)
New
SD288 assignment Points assigned to B The number of points assigned to B is stored with 32 bits. (Initial) LCPU
SD289 (for extension) The number of 32k or less points can be assigned to B.
Number of points
SD290 Stores the number of points currently set for X
allocated for X
Number of points
SD291 Stores the number of points currently set for Y
allocated for Y
Number of points
SD292 Stores the number of points currently set for M
allocated for M
Number of points
SD293 Stores the number of points currently set for L
allocated for L
Number of points
SD294 Stores the number of points currently set for B
allocated for B
Number of points
SD295 Stores the number of points currently set for F
allocated for F
Number of points
SD296 Device allo- Stores the number of points currently set for SB
allocated for SB
cation QCPU
Number of points S
SD297 (Same as Stores the number of points currently set for V New
allocated for V (Initial) LCPU
parameter
contents) Number of points
SD298 Stores the number of points currently set for S
allocated for S
Number of points
SD299 Stores the number of points currently set for T
allocated for T
Number of points
SD300 Stores the number of points currently set for ST
allocated for ST
Number of points
SD301 Stores the number of points currently set for C
allocated for C
Number of points
SD302 Stores the number of points currently set for D
allocated for D
Number of points
SD303 Stores the number of points currently set for W
allocated for W
Number of points
SD304 Stores the number of points currently set for SW
allocated for SW
Device
Stores the number of points of index register (Z) used for the QnU
assignment 16-bit modification Number
SD305 16-bit modification area. (Depending on the index modifica-
(Index regis- of points assigned for Z LCPU
tion setting for ZR in the parameter setting.)
ter)
SD306 Device The number of points for ZR is stored (except the number of
assignment points of extended data register (D) and extended link register
Number of points assigned
(Same as (W)). The number of points assigned to ZR is stored into this
SD307 for ZR (for extension)
parameter register only when 1k point or more is set for the extended
contents) data register (D) or extended link register (W).
SD308 Device Number of points assigned The total points of the data register (D) in the internal device S (Initial) New
assignment for D (for inside + for exten- memory area and the extended data register (D) are stored as
SD309 (assignment sion) a 32-bit binary value. QnU 7)
SD310 including the LCPU
number of
points set to
the extended Number of points assigned The total points of the link register (W) in the internal device
data register for W (for inside + for exten- memory area and the extended link register (W) are stored as
SD311 sion) a 32-bit binary value.
(D) and
extended link
register (W))
Reserves the designated time for communication
processing with a programming tool or other units.
Q00J/Q00/
Time The greater the value is designated, the shorter the
reserved for response time for communication with other devices Q01
Time reserved for commu- (programming tool, serial communication units)
SD315 communica- U New Qn(H)
nication processing becomes.
tion process- Setting range: 1 to 100 ms. QnPH
ing If the specified value is out of range, it is assumed to no
QnPRH
setting.
The scan time becomes longer by the specified time.
A – 178
Appendix A Table of special registers
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
Online
change
(inactive While online change (inactive block) is executed (SM329 S
SD329 SFC block number is on.), this register stores the target SFC block number. (Status New QnU 8)
block) target In other than the above status, this register stores FFFFH. change)
block
number
Number of modules
SD340 Indicates the number of modules installed on Ethernet.
installed
I/O
SD341 Ethernet I/O number of the first module installed.
number
Network
SD342 Ethernet network number of the first module installed. QCPU
number
Group
SD343 Ethernet group number of the first module installed.
Information number
from 1st Station
SD344 module Ethernet station number of the first module installed.
number
SD345
Ethernet Vacant (the Ethernet IP adress of the first module is stored in S
and Vacant New
information buffer memory. (Initial) Qn(H)
SD346
Vacant (the Ethernet error code of the first module is read QnPH
SD347 Vacant
with the ERRRD instruction. QnPRH
SD348 QnU 2)
Information from 2nd
to Configuration is identical to that for the first module.
module
SD354
SD355
Information from 3rd Qn(H)
to Configuration is identical to that for the first module.
module QnPH
SD361
SD362 QnPRH
Information from 4th
to Configuration is identical to that for the first module. QnU 3)
module
SD368
b15 b8 b7 b6 b5 b4 b3 b1 b0
0 … 0
Not used Status of channel 1
Status of channel 2
Status of channel 3
Instruction reception status Status of channel 4
SD380 Status of channel 5
of the 1st module
Status of channel 6
Ethernet Status of channel 7
instruction Status of channel 8 S
New QnPRH
reception ON: Received (Channel is used) (Initial)
status OFF: Not received (Channel is not used)
ACPU
Number Name Meaning Description Set by register Valid for:
(if set)
D9
The number of CPU modules that comprise the multiple CPU Q00/Q01 1)
SD393 Number of multiple CPUs
system is stored. (1 to 3, Empty also included) QnU
This register stores information on the CPU module types of
CPU No.1 to No.3 and whether or not the CPU modules are
mounted.
A – 180
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Following programmable controller CPU RUN, 1 is added each
1 second Number of counts S
SD412 second. D9022
counter in 1-second units (Status change) QCPU
Count repeats from 0 to 32767 to -32768 to 0.
LCPU
n = 1 second 2n second clock Stores value n of 2n second clock (Default is 30).
SD414 U New
steps units Setting can be made between 1 and 32767.
Stores value n of 2n ms clock (Default is 30). Qn(H)
SD415 n = 1 ms steps 2n ms clock units U New
Setting can be made between 1 and 32767.
QnPH
Incremented by 1 for each scan execution after the PC CPU is set QnPRH
to RUN. (Not incremented for each scan of an initial execution
QnU
type program.) S
Number of counts Count repeats from 0 to 32767 to -32768 to 0. LCPU
SD420 Scan counter (Every END New
in each scan
Incremented by 1 for each scan execution after the PC CPU is set processing)
Q00J/Q00
to RUN.
/Q01
Count repeats from 0 to 32767 to -32768 to 0.
Incremented by 1 for each scan execution after the PC CPU is set
S Qn(H)
Low speed scan Number of counts to RUN.
SD430 (Every END New
counter in each scan Count repeats from 0 to 32767 to -32768 to 0. QnPH
processing)
Used only for low speed execution type programs.
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Qn(H)
QnPH
Program number of program currently being executed is stored as S
SD500 Execution program No. New QnPRH
BIN value. (Status change)
QnU
LCPU
Program number of low speed program currently being executed is S QnH
SD510 Low speed program No. stored as BIN value. (Every END New
Enabled only when SM510 is ON. processing) QnPH
D9018
Current scan time Stores current scan time (in 1 ms units)
SD520 (format
(ms value) Range from 0 to 65535
change)
Stores current scan time (in 100 μs units, in increments of 1µs for
the Universal model QCPU and LCPU) S QCPU
Current scan
Range from 0 to 900 (0 to 999 for the Universal model QCPU and (Every END
time LCPU
Current scan time LCPU). processing)
SD521 New
(μs value) (Example)
A current scan of 23.6 ms would be stored as follows:
D520 = 23
D521 = 600
Initial scan time Stores scan time for first scan (in 1 ms units). Qn(H)
SD522
(ms value) Range from 0 to 65535
S QnPH
Initial scan Stores scan time for first scan (in 100 μs units, in increments of 1µs (First END New QnPRH
time Initial scan time for the Universal model QCPU and LCPU).
SD523 processing) QnU
(μs value) Range from 0 to 900 (0 to 999 for the Universal model QCPU and
LCPU). LCPU
Minimum scan
Stores minimum value of scan time (in 1 ms units).
SD524 time
Range from 0 to 65535 S
Minimum scan (ms value)
(Every END
time Minimum scan
Stores minimum value of scan time (in 100 μs units). processing)
SD525 time
Range from 0 to 900 Q00J/
(μs value)
New Q00/
Maximum scan Stores meximum value of scan time, excepting the first scan. (in 1 Q01
SD526 time ms units).
S
Maximum scan (ms value) Range from 0 to 65535
(Every END
time Maximum scan Stores maximum value of scan time, excepting the first scan. (in processing)
SD527 time 100 μs units).
(μs value) Range from 0 to 900
Minimum scan Stores minimum value of scan time except that of an initial execu- D9017
SD524 time tion type program (in 1 ms units). (format
(ms value) Range from 0 to 65535 change)
S
Minimum scan Stores minimum value of scan time except that of an initial execu- (Every END
time Minimum scan tion type program (in 100 μs units; in increments of 1µs for the Uni- processing)
SD525 time versal model QCPU and LCPU). New Qn(H)
(μs value) Range from 0 to 900
QnPH
(0 to 999 for the Universal model QCPU and LCPU)
QnPRH
Maximum scan Stores maximum value of scan time, except that of an initial execu- D9019
QnU
SD526 time tion type program (in 1 ms units). (format
(ms value) Range from 0 to 65535 change) LCPU
S
Maximum scan Stores maximum value of scan time, except that of an initial execu- (Every END
time Maximum scan tion type program (in 100 μs units, in increments of 1µs for the Uni- processing)
SD527 time versal model QCPU and LCPU).). New
(μs value) Range from 0 to 900
(0 to 999 for the Universal model QCPU and LCPU)
A – 182
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Stores current scan time for low speed execution type program (in 1
Current scan time
SD528 For low speed (ms value) ms units).
Range from 0 to 65535 S
execution type
(Every END New
programs cur- Stores current scan time for low speed execution type program (in processing)
SD529 rent scan time Current scan time 100 μs units).
(μs value)
Range from 0 to 900
Minimum scan Stores minimum value of scan time for low speed execution type
SD532 Minimum scan time program (in 1 ms units).
time for low (ms value) Range from 0 to 65535 S Qn(H)
speed execu- (Every END New
tion type pro- Minimum scan Stores minimum value of scan time for low speed execution type processing) QnPH
SD533 grams time program (in 100 μs units).
(μs value) Range from 0to 900
Stores the maximum scan time for all except low speed execution
Maximum scan Maximum scan
SD534 type program’s first scan (in 1 ms units).
time for low time (ms value) S
Range from 0 to 65535
speed execu- (Every END New
tion type pro- Maximum scan Stores the maximum scan time for all except low speed execution processing)
SD535 grams time type program’s first scan (in 100 μs units).
(μs value) Range from 0 to 900
Stores time from completion of scan program to start of next scan
END processing
SD540 (in 1 ms units).
time (ms value) S Q00J/
END process- Range from 0 to 65535
(Every END New Q00/
ing time END processing Stores time from completion of scan program to start of next scan processing) Q01
SD541 time (in 100 μs units).
(μs value) Range from 0 to 900
Stores time from completion of scan program to start of next scan
END processing
SD540 (in 1 ms units). Qn(H)
time (ms value)
Range from 0 to 65535
S QnPH
END process- Stores time from completion of scan program to start of next scan (Every END New QnPRH
ing time END processing (in 100 μs units, in increments of 1µs for the Universal model QCPU processing) QnU
SD541 time and LCPU).
(μs value) Range from 0 to 900 LCPU
(0 to 999 for the Universal model QCPU and LCPU)
Stores wait time when constant scan time has been set (in 1 ms
Constant scan wait
SD542 units).
time (ms value)
Range from 0 to 65535
S QCPU
Constant scan Stores wait time when constant scan time has been set (in 100 μs (First END New
wait time units, in increments of 1µs for the Universal model QCPU and LCPU
Constant scan wait processing)
SD543 LCPU).
time (μs value)
Range from 0 to 900
(0 to 999 for the Universal model QCPU and LCPU)
Cumulative execu- Stores cumulative execution time for low speed execution type pro-
tion time for low grams (in 1 ms units).
SD544 speed execution Range from 0 to 65535
Cumulative type programs Cleared to 0 after the end of one scan of a low-speed execution type
execution time (ms value) program. S
for low speed Cumulative execu- (Every END New
execution type tion time for low Stores cumulative execution time for low speed execution type pro- processing)
programs grams (in 100 μs units).
speed execution
SD545 Range from 0 to 900
type
programs Cleared to 0 after the end of one scan of a low-speed execution type Qn(H)
program. QnPH
(μs value)
Execution time for Stores low speed program execution time during 1 scan (in 1 ms
low speed execu- units).
SD546
Execution time tion type programs Range from 0 to 65535
S
for low speed (ms value) Stores each scan
(Every END New
execution type Execution time for Stores low speed program execution time during 1 scan (in 100 μs
processing)
programs low speed execu- units).
SD547
tion type programs Range from 0 to 900
(μs value) Stores each scan
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Stores execution time for scan execution type program during 1
Scan program exe- scan (in 1 ms units).
SD548 cution time
Range from 0 to 65535
(ms value) Q00J/
Stores each scan
S Q00/
Scan program Stores execution time for scan execution type program during 1 Q01
(Every END New
execution time scan (in 100 μs units, in increments of 1µs for the Universal model
Scan program exe- QCPU and LCPU). processing) QnU
SD549 cution time LCPU
Range from 0 to 900
(μs value)
(0 to 999 for the Universal model QCPU and LCPU)
Stores each scan
Stores execution time for scan execution type program during 1
Scan program exe- scan (in 1 ms units).
SD548 cution time
Range from 0 to 65535
(ms value) S Qn(H)
Scan program Stores each scan
(Every END New QnPH
execution time Stores execution time for scan execution type program during 1
Scan program exe- scan (in 100 μs units). processing) QnPRH
SD549 cution time
Range from 0 to 900
(μs value)
Stores each scan
Service interval
SD550 measurement Unit/module No. Sets I/O number for module that measures service interval. U New
module
Module service When SM551 is ON, stores service interval for module designated Qn(H)
SD551 interval by SD550 (in 1 ms units). QnPH
Service inter- (ms value) Range from 0 to 65535 S QnPRH
New
val time Module service When SM551 is ON, stores service interval for module designated (Request)
SD552 interval by SD550 (in 100 μs units).
(μs value) Range from 0 to 900
A – 184
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Indicates type of memory card installed.
b15 b8 b7 b4 b3 b0
0 0
Qn(H)
S QnPH
Drive 1 0: Does not exist (Initial and card New
(RAM) 1: SRAM QnPRH
removal)
Drive 2 QnU
0: Does not exist
(ROM) (1: SRAM)
2: ATA FLASH
3: FLASH ROM
b15 b8 b7 b4 b3 b0
0 0
S
Drive 1 0: Does not exist (Initial and card New LCPU
(RAM) (Fixed
1: SRAMto 0) removal)
Drive 2 0: Does not exist
(ROM) 4: SD memory
card
2: EEPROM
3: FLASH ROM
S
SD602 Drive 1 (RAM) capacity Drive 1 capacity is stored in 1 k byte units (Initial and card New
removal) Qn(H)
Drive 2 capacity is stored in 1 k byte units QnPH
S QnPRH
SD603 Drive 2 (ROM) capacity For the Q2MEM-8MBA, a value stored to this register depends on the (Initial and card New
product control number of the ATA card. For details, refer to the fol- QnU 2)
removal)
lowing manual: User's Manual (Hardware Design, Maintenance and
Inspection) for the CPU module used
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
The use conditions for memory card are stored as bit patterns (in
use when ON).
The significance of these bit patterns is indicated below:
The use conditions for memory card are stored as bit patterns (in
use when ON).
The significance of these bit patterns is indicated below:
1
This bit turns on at boot start and turns off at the completion.
2
This bit turns on when the writing of initial device values is started and
turns off at the completion.
3
Fixed at "0".
4
This bit turns on when data logging setting is registered and turns off
at the completion or stop of data logging.
Drive 2 storage
SD606 capacity (lower
Drive 2 (Memory bits) S
These registers store the drive 2 storage capacity (unit: 1M byte).
card ROM) (Initial and card New LCPU
Drive 2 storage (Free space value after formatting is stored.)
capacity removal)
SD607 capacity (upper
bits)
A – 186
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Free space in drive
SD616 Free space in 2 (lower bits) S
drive 2 (Mem- These registers store free space value in the drive 2 (unit: 1M byte). New LCPU
ory card ROM) Free space in drive (Status change)
SD617
2 (upper bits)
Indicates usage status of drives 3 and 4:
b15 ... b8 b7 ... b4 b3 ... b0
0
* For the Q00UJCPU, the drive 3 (Standard RAM) type is fixed at "0".
Q00J/
Drive 3 capacity is stored in 1k byte units Q00/
Q01
S Qn(H)
SD622 Drive 3 (RAM) capacity New QnPH
(Initial)
Drive 3 capacity is stored in 1k byte units.
QnPRH
(Free space value after formatting is stored.)
QnU
LCPU
Q00J/
Drive 4 capacity is stored in 1k byte units Q00/
Q01
S Qn(H)
SD623 Drive 4 (ROM) capacity New
(Initial) QnPH
Drive 4 capacity is stored in 1k byte units.
QnPRH
(Free space value after formatting is stored.)
QnU
LCPU
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
The use conditions for drives 3 and 4 are stored as bit patterns
b15 ... b5 b4 ... b0
0 0 0 0 0 0
Q00J/
Boot operation (QBT)
Q00/
0: Not used Q01
1: In use
File register (QDR)
0: Not used 1: In use
The use conditions for drives 3 and 4 are stored as bit patterns
(In use when ON)
The significance of these bit patterns is indicated below:
b0: Boot operation (QBT) b8: Not used
b1: Parameters (QPA) b9: CPU fault history (QFD) Qn(H)
b2: Device comments (QCD) b10: Not used QnPH
b3: Device initial value (QDI) b11: Local device (QDL) QnPRH
b4: File register (QDR) b12: Not used
b5: Sampling trace (QTD) b13: Not used
b6: Not used b14: Not used
b7: Not used b15: Not used
The use conditions for drives 3 and 4 are stored as bit patterns (in
use when ON).
The significance of these bit patterns is indicated below:
A – 188
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Q00J/
Q00/
Q01
Stores drive number being used by file register. * Qn(H)
S
SD640 File register drive Drive number New
(Status change) 4) QnPH
* For the LCPU, this register is fixed at drive 3.
QnPRH
QnU 3)
LCPU
SD641 Stores file register file name (MAIN.QDR) as ASCII code.
b15 b8 b7 b0
SD643 Stores file register file name (with extension) selected at parameters
or by use of QDRSET instruction as ASCII code.
b15 b8 b7 b0
Qn(H)
SD641 2nd character 1st character
S QnPH
SD642 4th character 3rd character
SD644 File register file name (Status change) New QnPRH
SD643 6th character 5th character
SD644 8th character 7th character QnU 3)
SD645 1st char. of extension 2EH (.)
SD646 3rd char. of extension 2nd char. of extension
SD645 Stores file register file name (with extension) selected at parameters
as ASCII code.
b15 b8 b7 b0
Qn(H)
QnPH
S
QnPRH
(Status change)
Stores the data capacity of the currently selected file register in 1 K QnU 3)
SD647 File register capacity New
word units. LCPU
Q00J/
S
Q00/
(Initial)
Q01
Q00J/
Q00/
Q01
Qn(H)
S
SD648 File register block number Stores the currently selected file register block number. D9035
(Status change) 4) QnPH
QnPRH
QnU 3)
LCPU
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Stores the comment drive number selected at the parameters or by S
SD650 Comment drive New
the QCDSET instruction. (Status change)
SD651 Stores the comment file name (with extension) selected at the
parameters or by the QCDSET instruction in ASCII code. Qn(H)
SD652
QnPH
SD653 b15 b8 b7 b0
QnPRH
SD654 SD651 2nd character 1st character S
Comment file name New QnU
SD652 4th character 3rd character (Status change)
SD655 LCPU
SD653 6th character 5th character
SD654 8th character 7th character
SD656 SD655 1st char. of extension 2EH (.)
SD656 3rd char. of extension 2nd char. of extension
Boot designation Stores the drive number where the boot designation file (*.QBT) is S
SD660 New
file drive number being stored. (Initial)
SD661 Stores the file name of the boot designation file (*.QBT).
Qn(H)
SD662
b15 b8 b7 b0 QnPH
SD663 Boot operation
SD661 2nd character 1st character QnPRH
designation file File name of boot S
SD664 SD662 4th character 3rd character New QnU 2)
designation file (Initial)
SD665
SD663 6th character 5th character LCPU
SD664 8th character 7th character
SD666
SD665 1st char. of extension 2EH (.)
SD666 3rd char. of extension 2nd char. of extension
This register stores the number of a drive where valid parameters
have been stored. *
•0: Drive 0 (program memory)
•1: Drive 1 (SRAM card)
•2: Drive 2 (Flash card/ATA card) QnU
•4: Drive 4 (standard ROM)
S
SD670 Parameter enable drive information * For the Q00UJCPU, Q00UCPU, and Q01UCPU, only drives 0 and 4 New
(Initial)
are parameter-valid drives.
This register stores the number of a drive where valid parameters
have been stored.
•0: Drive 0 (program memory) LCPU
•2: Drive 2 (SD memory card)
•4: Drive 4 (standard ROM)
This register stores the execution status of latch data backup in the
following bit pattern.
A – 190
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
This register stores the year (last two digits) and the month when
data were backed-up in 2-digit BCD.
Example: July, 1993 = 9307H
Year Month
This register stores the day and the hour when data were backed-up
in a 2-digit BCD.
Example: 31st, 10 a.m. = 3110H
Day Hour
This register stores the minute and the second when data were
backed-up in a 2-digit BCD.
Example: 35 min., 48 sec. = 3548H
Backup Backup time
information b15 to b12 b11 to b8 b7 to b4 b3 to b0 S QnU
SD674 (Minute and New
(At write) LCPU
second)
Minute Second
This register stores the year (first two digits) and the day of the week
when data were backed-up in 2-digit BCD.
Example: 1993, Friday = 1905H
This register stores the year (last two digits) and the month when
data were restored in 2-digit BCD.
Example: July, 1993 = 9307H
Year Month
Backup
restoration
information This register stores the day and the hour when data were restored in
a 2-digit BCD.
Example: 31st, 10 a.m. = 3110H
Day Hour
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
This register stores the minute and the second when data were
restored in a 2-digit BCD.
Example: 35 min., 48 sec. = 3548H
Backup Restore time QnU
b15 to b12 b11 to b8 b7 to b4 b3 to b0 S
SD674 restoration (Minute and sec- New
(Initial) LCPU
information ond)
Minute Second
This register stores the year (first two digits) and the day of the week
when data were restored in 2-digit BCD.
Example: 1993, Friday = 1905H
Program Write (transfer) This register stores the progress of writing (transfer) to the program
S QnU
SD681 memory write status display memory (flash ROM) in percentage (0 to 100%). (When a write New
(At write) LCPU
(transfer) status (percentage) (transfer) command is given, "0" is stored in this register.)
This register stores the index value of write count of the program
SD682 memory (flash ROM)* up to the present in 32-bit binary. When the
index value exceeds 100 thousand times, "FLASH ROM ERROR"
Program (error code: 1610) occurs. (The index value will be counted even
Write count index after it exceeds 100 thousand.) QnU
memory write S (At write) New
up to present LCPU
count index
SD683 * The write count does not equal to the index value. (Since the
maximum write count of the flash ROM has been increased by the
system, 1 is added about every two writing operations.)
Standard ROM Write (transfer) This register stores the progress of writing (transfer) to the standard
S QnU
SD686 write (transfer) status display ROM (flash ROM) in percentage (0 to 100%). When a write New
(At write) LCPU
status (percentage) (transfer) command is given, "0" is stored in this register.
SD687 This register stores the index value of write count of the standard
ROM (flash ROM)* up to the present in 32-bit binary. When the
index value exceeds 100 thousand times, "FLASH ROM ERROR"
(error code: 1610) occurs. (The index value will be counted even
Standard ROM Write count index after it exceeds 100 thousand.) S QnU
New
SD688 write count index up to present (At write) LCPU
* The write count does not equal to the index value. (Since the
maximum write count of the flash ROM has been increased by the
system, 1 is added to the index value when the total write data size
after the previous count-up reaches about 1M byte.)
This register stores the cause of an error that occurred during
backup.
0H: No error
100H: Memory card not inserted
200H: Backup data size exceeded
300H: Memory card write-protect setting
400H: Memory card write error
500H: Backup data read error (program memory) S QnU 1)
SD689 Backup error factor New
503H: Backup data read error (standard RAM) (Error) LCPU
504H: Backup data read error (standard ROM)
510H: Backup data read error (system data)
600H: Backup preparation was performed while latch data was
being backed up to the standard ROM.
601H: Backup preparation was performed during online change.
602H: Backup preparation was performed while a FTP client
connected to the CPU module in FTP connection is present.
A – 192
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Stores the current backup status.
0: Before backup
1: Being prepared S QnU 1)
SD690 Backup status 2: Ready (Status change)
New
LCPU
3: Being executed
4: Completed
FF: Backup error
Backup execution This register stores the progress of backup to the memory card
Backup S QnU 1)
SD691 status display in percentage (0 to 100%). New
execution status "0" is stored at the start of backup. (Status change) LCPU
(percentage)
Restoration
Restoration execution status This register stores the progress of restoration to the CPU QnU 1)
SD694 module in percentage (0 to 100%). S (Status change) New
execution status display "0" is stored at the start of restoration. LCPU
(Percentage)
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
SD705 Q00J/
Q00/
During block operations, turning SM705 ON makes it possible to use
Q01
the mask pattern being stored at SD705 (or at SD705 and SD706 if
Mask pattern U New Qn(H)
SD706 double words are being used) to operate on all data in the block with
the masked values. QnPH
QnPRH
SD715 Patterns masked by use of the IMASK instruction are stored in the fol-
lowing manner:
SD716
IMASK b15 ...................... b0
S
instruction Mask pattern SD715 I15 I14 I13 I12 I11 I10 I9 I8 I7 I6 I5 I4 I3 I2 I1 I0 New
(During execution) QCPU
mask pattern I31 I30 I29 I28 I27 I26 I25 I24 I23 I22 I21 I20 I19 I18 I17 I16
SD717 SD716
SD717 I47 I46 I45 I44 I43 I42 I41 I40 I39 I38 I37 I36 I35 I34 I33 I32
LCPU
SD718
Accumulator For use as replacement for accumulators used in A-series programs. S/U New
SD719
Program No. destination for Stores the program number of the program to be loaded by the PLOAD Qn(H)
SD720 U New
PLOAD instruction instruction when designated. The destination range is from 1 to 124. QnPH
SD738 Stores the message designated by the MSG instruction.
SD739
SD740
SD741 2nd character 1st character
4th character 3rd character
SD742
6th character 5th character
SD743
8th character 7th character
SD744 10th character 9th character
SD745 12th character 11th character
SD746 14th character 13th character
SD747 16th character 15th character
18th character 17th character
SD748
20th character 19th character
SD749 22nd character 21th character
SD750 24th character 23th character
SD751 26th character 25th character
SD752 28th character 27th character
A – 194
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Designate the limit for each PID loop as follows:
Q00J/Q00
SD774 b15 to b8 b7 ... b1 b0
/Q01 1)
SD774 Loop 8 Loop 2 Loop 1
PID limit
setting (for 0: Limit set
Designate the limit for each PID loop as follows: U New
complete 1: Limit not set Qn(H)
SD774 derivative)
b15 b1 b0 QnPRH
and
SD775 SD774 Loop
Loop 16
16 to Loop
Loop 22 Loop
Loop 11 QnU
SD775 Loop
Loop 32
32 to Loop
Loop 18
18 Loop
Loop 17
17 LCPU
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Selects whether or not the data is refreshed when the COM/CCOM
instruction is executed.
Designation of SD778 is made valid when SM775 turns ON.
b15 b14 ... b7 b6 b5 b4 b3 b2 b1 b0
SD778 0
b0 to b14:
(Default: 0) I/O refresh
CC-Link refresh
0: Do not refresh Refresh of MELSECNET/H
1: Refresh and CC-Link IE controller
network
b15 bit
Automatic refresh of
0: Communica- intelligent function
tion with CPU modules U New QnU
Auto refresh using QCPU
module is standard area of multiple
executed CPU system and reading
input/output from group
1: Communica- outside.
tion with CPU Auto refresh using the
Refresh module is multiple CPU high speed
transmission area of multiple
processing nonexecuted CPU system
selection CC-Link IE field network
refresh
SD778 when the
Execution/
COM/CCOM non-execution of
instruction is communication with
programming tool
executed
b0, b1, b3, b14: Selects whether or not the data is refreshed when the COM/CCOM
(Default: 0) instruction is executed.
Designation of SD778 is made valid when SM775 turns ON.
0: Do not refresh
1: Refresh b15 b14 ... b4 b3 b2 b1 b0
b15 bit SD778 0
0: Communica- I/O refresh
tion with CC-Link refresh
peripheral Fixed to 0 U New LCPU
Automatic refresh of
device is intelligent function
executed modules
Fixed to 0
1: Communica-
Communication with
tion with display unit
peripheral Execution/
non-execution of
device is non- communication with
executed programming tool
b15 b1 b0
SD781 l63 ... l49 l48
SD781
SD782 l79 ... l65 l64 Q00J/Q00
to
/Q01
SD785
... ...
Mask pattern
Stores the mask pattern masked by the IMASK instruction as follows: S
of IMASK Mask pattern New
(During execution)
instruction b15 b11 b0
SD781 I63 to I59 I48
Qn(H)
SD782 I79 to I65 I64
SD781 QnPH
to QnPRH
to
SD793 QnU
SD793 I255 I241 I240 LCPU
A – 196
Appendix A Table of special registers
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
Designate the limit for each PID loop as follows:
Q00J/Q00
SD794 b15 to b8 b7 ... b1 b0
/Q01 1)
SD794 Loop 8 Loop 2 Loop 1
PID limit set-
ting (for 0: With limit
U New
incomplete 1: Without limit Designate the limit for each PID loop as follows: Qn(H) 4)
SD794 derivative)
b15 b1 b0 QnPRH
to SD794 Loop 16 ... Loop 2 Loop 1 QnU
SD795
SD795 Loop 32 ... Loop 18 Loop 17 LCPU
Maximum
number of Specifies the maximum number of blocks used for the multiple CPU
blocks used high-speed transmission dedicated instruction
for the multi- (target CPU = CPU No. 1).
ple CPU high- When the multiple CPU high-speed transmission dedicated instruction
SD796 speed trans- is executed to the CPU No.1, and the number of empty blocks of the New QnU 5)
mission dedi- dedicated instruction transmission area is less than the setting value of
cated this register, SM796 is turned ON, which is used as the interlock signal
instruction for consecutive execution of the multiple CPU high-speed transmission
setting (for dedicated instruction.
CPU No.1)
Maximum
number of Specifies the maximum number of blocks used for the multiple CPU
blocks used high-speed transmission dedicated instruction
for the multi- (target CPU = CPU No. 2).
ple CPU high- When the multiple CPU high-speed transmission dedicated instruction
SD797 speed trans- is executed to the CPU No.2, and the number of empty blocks of the New QnU 5)
mission dedi- Maximum dedicated instruction transmission area is less than the setting value of
cated number of blocks this register, SM797 is turned ON, which is used as the interlock signal
instruction range for dedi- for consecutive execution of the multiple CPU high-speed transmission
setting (for cated instruc- dedicated instruction.
CPU No. 2) tions U
Range: 1 to 7 (At 1 scan after
Maximum (Default: 2 RUN)
number of or when setting Specifies the maximum number of blocks used for the multiple CPU
blocks used other than 1 to 7, high-speed transmission dedicated instruction
for the multi- the register oper- (target CPU = CPU No. 3).
ple CPU high- ates as 7).6) When the multiple CPU high-speed transmission dedicated instruction
SD798 speed trans- is executed to the CPU No.3, and the number of empty blocks of the New QnU 5)
mission dedi- dedicated instruction transmission area is less than the setting value of
cated this register, SM798 is turned ON, which is used as the interlock signal
instruction for consecutive execution of the multiple CPU high-speed transmission
setting (for dedicated instruction.
CPU No.3)
Maximum
number of Specifies the maximum number of blocks used for the multiple CPU
blocks used high-speed transmission dedicated instruction
for the multi- (target CPU = CPU No. 4).
ple CPU high- When the multiple CPU high-speed transmission dedicated instruction
SD799 speed trans- is executed to the CPU No.4, and the number of empty blocks of the New QnU 5)
mission dedi- dedicated instruction transmission area is less than the setting value of
cated this register, SM799 is turned ON, which is used as the interlock signal
instruction for consecutive execution of the multiple CPU high-speed transmission
setting (for dedicated instruction.
CPU No.4)
A.7.7 Debugging
ACPU
Valid
Number Name Meaning Description Set by (if set) register for:
D9
This register indicates the status of the debug function usage
as shown below.
ACPU Valid
Number Name Meaning Description Set by (if set) register
D9 for:
This register stores a value indicating the completion status of the lat-
History of est memory data copy from the control system to the standby system.
Latest status of The value same as the SD1596 value is stored at completion or
memory copy
memory copy abend of the memory data copy from the control system to the
from control S
SD952 from control standby system. New QnPRH
system to (Status change)
system to Since data have been backed up in case of power failure, this
standby register holds the value indicating the latest memory data copy
standby system
system status from the control system to the standby system.
This register is cleared to 0 by latch clear.
Tab. A-66: Special registers (8): Redundant CPU information (host system CPU information)
ACPU Valid
Number Name Meaning Description Set by (if set) register
D9 for:
Direct
SD979 MELSOFT
connection
Connection 1
SD980
to 16
MELSOFT
connection Count of unlock
SD997
using UDP processing fail-
These registers store the number of mismatched password entries. S
New QnU 1)
Range: 0 to 0FFFEH (0FFFFH when the range is exceeded) (Status change) LCPU
port ures
MELSOFT
connection
SD998
using TCP
port
FTP commu-
SD999
nication port
A – 198
Appendix A Table of special registers
For a conversion from the MELSEC A series to the MELSEC System Q or L series the special
registers D9000 through D9255 (A series) correspond to the diagnostic special registers
SD1000 to SD1255 for QCPU or LCPU after the A to Q/L conversion. (Note that the Basic
model QCPU and Redundant CPU do not support the A to Q/L conversion.)
These diagnostic special registers are all set by the system and cannot be changed by a user-
program. Users intending to change the contents of these registers should alter their programs
so that only real QCPU or LCPU diagnostic special registers are applied.
An exception are the special registers D9200 through D9255. The data in these registers can
be changed by the user. Therefore, the user can change the data in the diagnostic special reg-
isters SD1200 to SD1255 after the conversion.
Refer to the manuals of the CPUs and the networks MELSECNET and MELSECNET/B for
detailed information on the special registers of the A series.
NOTE To use the converted special register in the High Performance model QCPU, Process CPU, Uni-
versal model QCPU, or LCPU, check "Use special relay/special register from SM/SD1000" un-
der "A-PLC Compatibility Setting".
Project window ⇒ [Parameter] ⇒ [PLC Parameter] ⇒ [PLC System]
Note that the processing time will increase when the converted special register is used.
How to read the Special Register for Modification column.
● If the special register number for QCPU or LCPU is provided, correct the program using it.
● If no special register is specified (–), the converted special register can be used.
● If the special register cannot be used in QCPU or LCPU, this is indicated as "No function
for QCPU/LCPU".
Tab. A-68: Special registers (10): Conversion from A series to System Q or L series
1
For the High Performance model QCPU and Process
CPU, if the CPU module is running and SM1040 is off,
the CPU module remains in the RUN status even
though it is set to the PAUSE status.
Tab. A-68: Special registers (10): Conversion from A series to System Q or L series
A – 200
Appendix A Table of special registers
Day Hour
Tab. A-68: Special registers (10): Conversion from A series to System Q or L series
Minute Second
Qn(H)
Extension file Stores the block No. of the extension file register QnPH
D9035 SD1035 SD648 Use block No.
register being used in BCD code. QnU 1)
LCPU
Designate the device number for the extension file
register for direct read and write in 2 words at SD1036
and SD1037 in BIN data. Use consecutive numbers
D9036 SD1036 beginning with R0 of block No. 1 to designate device
Device number numbers.
Extension file when individual
Extension file register QnH
No function for register for devices from
0 Block No. 1 data
QCPU/LCPU designation of extension file reg- QnPH
device number ister are directly 16383
Tab. A-68: Special registers (10): Conversion from A series to System Q or L series
A – 202
Appendix A Table of special registers