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.