(Always read these cautions before using the product)
Before using this product, please read this manual and the related manuals introduced in this manual,
and pay full attention to safety to handle the product correctly .
Please store this manual in a safe place and make it accessible when required. Always forward a copy of
the manual to the end user.
This manual confers no industrial property rights or any rights of any other kind, nor does it confer any patent
licenses. Mitsubishi Electric Corporation cannot be held responsible for any problems involving industrial property
rights which may occur as a result of using the contents noted in this manual.
Thank you for purchasing the Mitsubishi MELSEC-Q Series (Q mode) and MELSEC-QnA Series of
Programmable Logic Controllers.
Before using the product, please read this manual carefully to develop full familiarity with the functions and
performance of the Programmable Logic Controller Q Series (Q mode)/QnA Series you have purchased, so
as to ensure correct use.
A copy of this manual should be forwarded to the end User.
CONTENTS
1. GENERAL DESCRIPTION1 - 1 to 1 - 4
1.1 Related Programming Manuals .............................................................................................................1 - 1
1.2 Abbreviation and Generic Name............................................................................................................1 - 4
2. INSTRUCTION TABLES2 - 1 to 2 - 49
2.1 Types of Instructions ..............................................................................................................................2 - 1
2.2 How to Read Instruction Tables.............................................................................................................2 - 2
2.3.7 Other instructions.............................................................................................................................2 - 7
2.4.3 Data conversion instructions ...........................................................................................................2 - 19
2.4.4 Data transfer instructions................................................................................................................. 2 - 21
2.4.5 Program branch instruction .............................................................................................................2 - 23
2.4.6 Program execution control instructions........................................................................................... 2 - 23
2.5.17 Program instructions...................................................................................................................... 2 - 45
2.5.18 Other instructions...........................................................................................................................2 - 45
2.5.19 Instructions for data link.................................................................................................................2 - 46
3.2.1 Using bit data...................................................................................................................................3 - 2
3.2.2 Using word (16 bits) data.................................................................................................................3 - 3
3.2.3 Using double word data (32 bits).....................................................................................................3 - 5
3.2.4 Using real number data...................................................................................................................3 - 8
3.2.5 Using character string data .............................................................................................................3 - 9
3.3 Index Modification...................................................................................................................................3 - 10
5.6.1 End main routine program (FEND).................................................................................................5 - 46
5.6.2 End sequence program (END)........................................................................................................5 - 48
5.7 Other Instructions...................................................................................................................................5 - 50
5.7.1 Sequence program stop (STOP)....................................................................................................5 - 50
5.7.2 No operation (NOP, NOPLF, PAGE n)...........................................................................................5 - 52
6.3.7 Conversion from BIN 16 and 32-bit data to Gray code (GRY, GRY P, DGRY , DGRYP)...............6 - 67
6.3.8 Conversion of Gray code to BIN 16 and 32-bit data (GBIN, GBINP, DGBIN, DGBINP) ...............6 - 69
6.3.9 Complement of 2 of BIN 16- and 32-bit data (sign reversal) (NEG, NEGP, DNEG, DNEGP)......6 - 71
6.3.10 Sign reversal for floating decimal point data (ENEG, ENEGP)....................................................6 - 73
6.3.11 Conversion from block BIN 16-bit data to BCD 4-digit data (BKBCD, BKBCDP)........................6 - 74
6.3.12 Conversion from block BCD 4-digit data to block BIN 16-bit data (BKBIN, BKBINP)..................6 - 76
6.4 Data Transfer Instructions......................................................................................................................6 - 78
6.4.1 16-bit and 32-bit data transfers (MOV, MOVP, DMOV, DMOVP).................................................. 6 - 78
6.4.2 Floating decimal point data transfers (EMOV, EMOVP) ................................................................6 - 80
6.4.3 Character string transfers ($MOV, $MOVP)...................................................................................6 - 82
7.11.17 Character string search (INSTR, INSTRP)...............................................................................7 - 229
7.11.18 Floating decimal point to BCD (EMOD, EMODP).....................................................................7 - 231
7.11.19 From BCD format data to floating decimal point (EREXP, EREXPP)......................................7 - 233
7.12 Special Function Instructions .............................................................................................................7 - 235
7.12.1 SIN operation on floating decimal point data (SIN, SINP)..........................................................7 - 235
7.12.2 COS operation on floating decimal point data (COS, COSP)....................................................7 - 237
7.12.3 TAN operation on floating decimal point data (TAN, TANP)......................................................7 - 239
7.12.4 SIN
-1
operation on floating decimal point data (ASIN, ASINP)..................................................7 – 241
7.13 Data Control Instructions....................................................................................................................7 - 274
7.13.1 Upper and lower limit controls for BIN 16-bit and BIN 32-bit data
7.18 Other Instructions...............................................................................................................................7 - 315
The following table lists the manuals related to the Q/QnACPU.
Please order the one you need.
Manual Name
Basic model QCPU (Q mode) User's Manual (Hardw are design, Maintenance and Inspection)
Describes the specifications of the CPU module, power supply module, base unit, and extension cables.
(Sold separately)
Basic model QCPU (Q mode) User's Manual (Functions Ex planation, Programming
Fundamentals)
Describes the functions, programming method, and devices to create programs with Basic model QCPU
(Q mode). (Sold separately)
High Performance model QCPU (Q mode) User's Manual (Hardw are design, Maintenance and
Inspection)
Describes the specifications of the CPU module, power supply module, base unit, extension cables, and
memory c ard.(Sold separately)
High Performance model QCPU (Q mode) User's Manual (Functions Ex planation, Programming
Fundamentals)
Describes the functions, programming method, and devices to create programs with High Performance model
QCPU (Q mode). (Sold separately)
Process CPU User’s Manual (Hardware Design, Maintenance and Inspection)
Describes the specifications of the CPU module, power supply module, base unit, extension cables, and
memory c ard.(Sold separately)
Process CPU User’s Manual (Functions Explanation, Programming Fundamentals)
Describes the functions, programming method and devices that are required to create programs.
(Sold separately)
Manual Number
(Model Code)
SH-080187
(13JR43)
SH-080188
(13JR44)
SH-080037
(13JL97)
SH-080038
(13JL98)
SH-080314E
(13JR55)
SH-080315E
(13JR56)
QCPU (Q mode)/QnACPU Programming Manual (SFC)
Describes the system configuration, performance specifications, functions, programming, debugging, and error
codes for MELSAP3. (Sold separately)
QCPU (Q mode) Programming Manual (MELSAP-L)
Describes the system configuration, performance specifications, functions, programming, debugging, and error
codes for MELSAP-L.(Sold separately)
QCPU (Q mode)/QnACPU Programming Manual (PID Control Instructions)
Describes the dedicated instructions for PID control. (Sold separately)
QnPHCPU Programming Manual (Process Control Instructions)
Describes the dedicated instructions for performing process control.(Sold separately)
QnACPU Guidebook
Aimed at people using QnACPU for the first time. Describes procedures for everything from creating programs
and writing created programs to the CPU module, to debugging.
Also describes how to use the QnACPU most effectively.
Q2A(S1)/Q3A/Q4ACPU User's Manual
Describes the performance, functions, and handling of the Q2ACPU(S1), Q3ACPU, and Q4ACPU, and the
specifications and handling of memory cards and base units.(Sold separately)
Model Q2AS(H)CPU(S1) User's Manual
Describes performance, functions, and handling of the Q2ASCPU, Q2ASCPU-S1, Q2ASHCPU, and
Q2ASHCPU-S1, power supply module, memory card, specifications, and handling of the base unit.
Describes the Q4ARCPU features, functions, and usage. Also describes the specification and usage of the
bus switching module, system management module, power supply module, memory card, and base unit.
(Sold separately)
Manual Number
(Model Code)
IB-66685
(13J852)
QnACPU Programming Manual (Fundamentals)
Describes how to create programs, the names of devices, parameters, and types of program.
(Sold separately)
QnACPU Programming Manual (Special Function Module)
Describes the dedicated instructions for special function modules available when using the Q2ACPU(S1),
Q3ACPU, and Q4ACPU.(Sold separately)
QnACPU Programming Manual (AD57 Instructions)
Describes the dedicated instructions for controlling an AD57(S1) type CRT controller module available
when using the Q2ACPU(S1), Q3ACPU, or Q4ACPU.(Sold separately)
QnACPU Programming Manual (PID Control Instructions)
Describes the dedicated instructions for PID control available when using the Q2ACPU(S1), Q3ACPU, or
Q4ACPU.(Sold separately)
QnACPU Programming Manual (SFC)
Describes the system configuration, performance specifications, functions, programming, debugging, and
error codes for MELSAP3.(Sold separately)
For QnA/Q4AR MELSECNET/10 N etw ork Sy stem R eference M anual
Describes the general concept, specifications, and part names and settings for MELSECNET/10.
(Sold separately)
type MELSECNET, MELSECNET/B Data Link System Reference Manual
Describes the general concept, specifications, and part names and settings for MELSECNET (II) and
MELSECNET/B.(Sold separately)
GX Developer Version 7 Operating Manual
Describes the online functions of GX Developer Version 7 including the programming procedure, printing
out procedure, monitoring procedure, and debugging procedure.(Sold separately)
IB-66614
(13JF46)
SH-4013
(13JF56)
IB-66617
(13JF49)
IB-66618
(13JF50)
IB-66619
(13JF51)
IB-66690
(13JF78)
IB-66350
(13JF70)
SH-080166
(13JU14)
Type SW2IVD-GPPQ software package OPERATING MANUA L (Offline)
Describes how to create programs and print out data when using SW2IVD-GPPQ, and the offline functions
of SW2IVD-GPPQ such as file maintenance.(Included with product)
Type SW2IVD-GPPQ software package OPERATING MNUA L (Online)
Describes the online functions of SW2IVD-GPPQ, including the methods for monitoring and debugging.
(Included with product)
Type SW2IVD-GPPQ software package OPERATING MANUAL (SFC )
Describes SFC functions such as SFC program editing and monitoring.(Included with product)
This manual describes the common instructions for QCPU, QnACPU, and Q2AS(H)CPU(S1) that
are required when programming with a QCPU, QnACPU, and Q2AS(H)CPU(S1).
Common instructions are all instructions except those used for special function modules such as
AJ71QC24, AJ71PT32-S3, etc.; the instructions for AD57; the instructions for PID control, and
those for MELSAP3.
1.1 Related Programming Manuals
Before reading this manual, check the programs, I/O processes, and devices that can be used
with your CPU module in the CPU Module User's Manual or in the QnACPU Programming
Manual.
(1) Q02(H ) CP U, Q0 6 HC PU , Q1 2H CPU, Q25HCPU
High Performance
model
QCPU (Q mode)
User's Manual
(Functions Explanation,
Programm ing
fundamentals)
1
Describes the functions,
executable programs,
I/O processing, and
device names of High
Performance model QCPU.
Module Type NameAbbreviationAbbreviation in TablesGeneric Name
Q00JCPU PLC CPU
Q00CPU PLC CPU
Q01CPU PLC CPU
Q02CPU PLC CPU
Q02HCPU PLC CPU
Q06HCPU PLC CPU
Q12HCPU PLC CPU
Q25HCPU PLC CPU
Q12PHCPU PLC CPU
Q25PHCPU PLC CPU
Q00JCPU PLC CPU
Q00CPU PLC CPU
Q01CPU PLC CPU
Q02CPU PLC CPU
Q02HCPU PLC CPU
Q06HCPU PLC CPU
Q12HCPU PLC CPU
Q25HCPU PLC CPU
Q12PHCPU PLC CPU
Q25PHCPU PLC CPU
Q2ACPU(S1) PLC CPU
Q3ACPU PLC CPU
Q4ACPU PLC CPU
Q2ASCPU(S1) PLC CPU
Q2ASHCPU(S1) PLC CPU
Q4ARCPU PLC CPU
MELSECNET/H Network system
(MELSECNET/H mode)
MELSECNET/H Network system
(MELSECNET/10 mode)
MELSECNET/10 Network system
Ethernet interface module
Control and Communication Link System
Master/Local Module
The major types of CPU module instructions consist of sequence instructions, basic instructions,
application instructions, data link instructions, QCPU instructions and redundant system
instructions. These types of instructions are listed in Table 2.1 below.
Table 2.1 Types of Instructions
Types of InstructionsMeaning
Sequence
instructions
Basic
instructions
Application
instructions
Data link
instructions
QCPU
instructions
Redundant system
instructions
Contact instr uc t ionOperation star t, ser i es con ne cti on , pa ra ll el conn ec t ion
Connection instructions
Output instructionBit device output, pulse output, output reversal
Shift instructionBit device shift
Master cont ro l in st ru ct i onMaster cont ro l
Termination instructionProgram termination
Other instructions
Comparison operation instructionComparisons such as =, >, <
Arithmetic operation instructionAddition, subtraction, multiplication or division of BIN or BCD
BCD BIN conversion instruction
Data transfer instructionTransmits designated data
Program branch in stru ct ionProgram jumps
Program run control instructionEnable or prohibit interrupt programs
I/O refreshRun partial refresh
Other convenient instructions
Logical operation instructionsLogical operations such as logical sum, logical product, etc.
Rotation instructionRotation of designated data
Shift instructionShift of designated data
Bit processing instructionsBit set and reset, bit test, batch reset of bit devices
Data processing instructions16-bit data searches, data processing such as decoding and encoding
Structure creation instructions
Table operation instructionRead/Write of FIFO table
Buffer memory access instructionData read/write for special function modules
Display instructionsPrint ASCII code, LED character display, etc.
Debugging and failure diagnosis
instructions
Character string processing
instructions
Special funct ion ins tru ct ion s
Data control instructionsUpper and lower limit controls, dead band controls, zone controls
Switching instructionsFile register block No. switches, designation of file registers and comment files
Clock instructions
Peripheral device instructionsI/O to peripheral devices
Program in st ru ct io n sInstruct ion s to sw i t ch prog ra m execu t io n co nd i ti on s
Other instructions
Link refresh instructionsDesignated network refresh
Instructi on s de di ca te d to Qn A lin ks
Instructions for A-series-compatible
link
Routing information read/write
instructions
Instruction for QCPU
Instruct i on s fo r Q4 A R CPU
Ladder block connection, creation of pulses from operation results, store/read
operation results
Program stop, instructions such as no operation which do not fit in the above
categories
Conversion from BC D to BI N and fr o m BI N to BC D
Instructions for: Counter increment/decrement, teaching timer, special function
timer, rotary table shortest direction control, etc.
Repeated opera tio n, sub rou tin e pr ogr a m call s, In dex mod if ic ati on in ladder
units
Check, status check, sampling trace, program trace
Conversion betw e en BIN / BCD and AS CI I ; con vers io n be twee n BI N and
character st r ing; con ver s ion be tw ee n f loat in g de ci mal po int da ta and c har ac te r
strings, character string processing, etc.
Trigonometric functions, conversion between angles and radians, exponential
operations, automatic logarithms, square roots
Read/write of year, month, day, hour, minute, second, and day of the week;
conversion between time statement (hour, minute, second) and seconds
Instructions that do not fit in the above categories, such as watchdog timer
reset instructions and timing clock instructions
Read/write of dat a fr o m othe r s ta tion s ; d ata tran s mis si on sign al s to ot he r
stations; processing reques ts to other stations
Read/write for designated station word device, read/write data from remote I/O
station special function module
Reads, writes, and registers routing information.
Reading module i nf or mat ion ; tr ac e se t/re s et ; re adin g/w r it in g bina ry dat a;
load/unload/ lo ad + unlo ad prog ra m fro m me mory ca rd ; hi gh - speed blo c k
transfer of file register
Operation mode se tt ing dur ing C PU st ar tup; oper at i on mode sett in g
instruction s dur ing CPU sw i tch ; da ta tra c ki ng ; bu ffer memory batch refresh
The instruction tables found from Section 2.3 to 2.6 have been made according to the following
format:
Table 2.2 How to Read Instruction Tables
MELSEC-Q/QnA
2
Category
BIN 16-bit
addition
and
subtraction
operations
1
Symbol
Symbols
Instruction
+
+P
+
+P
23456
+SD
+P
+S1 S2 D
+P
SD
S1 S2
(D)+(S) (D)
(S1)+(S2) (D)
D
Processing Details
Execution
Condition
Description
1
...........Classifies instructions according to their application
2
...........Indicates the instruction symbol added to the instruction in a program
Instruction code is built around the 16-bit instruction. The following notations are used to
mark 32-bit instructions, instructions executed only at the leading edge of OFF to ON,
real number instructions, and character string instructions:
•
32-bit instruction......................... The letter "D" is added to the first line of the instruction
Example
+
D+
Subset
See for
Number of
Basic Steps
3
4
7
Description
6-16
6-18
8
16-bit instruction 32-bit instruction
•
Instruction s e xecut ed only at the leading edge of OFF t o ON
................................. The letter "P" is added to the end of the instruction
Example
Instructions
executed when ON
•
Real number instructions ........... The letter "E" is added to the first line of the instruction
Example
•
Character string instructions ...... A dollar sign “$” is added to the first line of the
Indicates destination
Indicates source
Indicates instruction symbol
Fig. 2.1 Shows Symbol Diagram on the La dd e r
Destination ....................Indicates where data will be sent after operation
Source...........................Stores data prior to operation
4
...........Indicates the type of processing that is performed by individual instructions
(D)+(S)(D)
Indicates 16 bits
(D+1, D)+(S+1, S)
16 bits16 bits
D+1D
The upper 16 bitsThe lower 16 bits
(D+1, D)
Indicates 32 bits
Fig. 2.2 Type o f Pro cessi ng Pe r for med by Individual Instru ctio n s
5
...........The details of conditions for the execution of individual instructions are as follows:
SymbolExecution Condition
Instruction executed under normal circumstances, w ith no regard to the O N/O FF
No symbol recorded
status of conditions prior to the instruction.
If the preconditions is OFF, the instruction will conduct O FF proces sing.
Executed during ON; instruction is executed only while the precondition i s O N.
If the preconditions is OFF, the instruction is not executed, and no proc essi ng is
conducted.
Executed once at ON; instruction executed only at leading ed ge w hen precondition
goes from OFF to ON. Following execution, instruction will not be executed and no
processing conducted even if condition remains ON .
Executed during OFF; instruction is executed only while the preconditio n is O FF.
If the precondition is ON, the instruction is not ex ecuted, and no proces sing is
conducted.
Executed once at OFF; instruction executed only at trailing edge when precondition
goes from ON to OFF. Following execution, instruction will not be executed and no
processing conducted even if condition remains OFF.
6
...........Indicates the basic number of steps for individual instructions.
See Section 3.8 for a description of the number of steps.
7
...........The “ ” mark indicates instructions for which subset processing is possible.
See Section 3.5 for details on subset processing.
8
...........Indicates the page numbers where the individual instructions are explained.
Table 2.22 Data Processing Instructions (Continued)
MELSEC-Q/QnA
Category
7-segment
decode
Separating
and linking
SymbolProcessing Details
Symbols
Instruction
SEG
SEGP
DIS
DISP
UNI
UNIP
NDIS
NDISP
NUNINUNIS1S2D
NUNIP
WTOB
WTOBP
BTOW
BTOWP
SEGSD
SEGPSD
DISnSD
DISPn
UNInSD
UNIPnSD
NDISS1S2D
NDISPS1S2D
NUNIPS1S2D
WTOBnSD
WTOBPnSD
BTOWnSD
BTOWPnSD
S
b3 to b0
(S)
• Separates 16-bit data designated by (S)
into 4-bit units, and stores at the lower 4
bits of n points from (D). (n
D
• Links the lower 4 bits of n points from the
device designated by (S) and stores at
the device designated by (D). (n
• Separates the data at the devices below
that designated by (S1) into bits
designated below (S2) and stores in
sequence from the device designated by
(D).
• Links the data at the devices below that
designated by (S1) in the bits designated
below (S2) and stores in sequence from
the device designated by (D).
• Breaks n-points of 16-bit data from the
device designated by (S) into 8-bit units,
and stores in sequence at the device
designated by (D).
• Links the lower 8 bits of 16-bit data of npoints from the device designated by (S)
into 16-bit units, and stores in sequence
at the device designated by (D).
7SEG
(D)
4)
4)
Execution
Condition
Subset
Number of
Basic Steps
37-60
47-62
47-64
47-66
47-71
See for
Description
• Searches the data of n-points from the
device designated by (S) in 16-bit units,
and stores the maximum value at the
device designated by (D).
• Searches the data of n-points from the
device designated by (S) in 16-bit units,
and stores the minimum value at the
device designated by (D).
• Searches the data of 2
the device designated by (S) in 32-bit
units, and stores the maximum value at
the device designated by (D).
• Searches the data of 2
the device designated by (S) in 32-bit
units, and stores the minimum value at
the device designated by (D).
• Forcibly ends the execution of the FOR
to NEXT cycle and jumps pointer to Pn.
D
• Executes sub-routine program Pn when
input condition is met.
(S1 to Sn are arguments sent to subroutine program. 0
• Returns from sub-routine program
• Performs non-execution processing on
sub-routine program Pn if input
conditions have not been met
• Executes sub-routine program Pn from
within designated program name when
input condition is met.
(S1 to Sn are arguments sent to subroutine program. 0
• Performs non-execution processing of
sub-routine program Pn from within
designated program name if input
condition is not met.
• Performs link refresh and general data
processing.
n5)
n5)
Execution
Condition
Subset
Number of
Basic Steps
2
1
37-89
1
2
+
n
17-94
1
2
+
n
2
3
+
n
2
3
+
n
17-016
See for
7-87
7-91
7-95
7-99
7-102
Description
IX2
Device modification ladder
IXEND
Fixed index modification
1 : n indicates number of arguments for sub-routine program.
2 : n indicates the total of the number of arguments used in the sub-routine program and the number of program name steps.
IXDEV
IXSET
Designates modification value
The number of program name steps is calculated as "number of characters in the program / 2" (decimal fraction is rounded up).
IX
IXEND
IXDEV
IXSETPn D
• Conducts index modification for
S
individual devices used in device
modification ladder.
• Stores modification value used for index
modification performed between IX
Table 2.28 Character String Processing Instructions
MELSEC-Q/QnA
Category
BIN to
decimal
ASCII
BIN to
hexadecimal
ASCII
BCD to
decimal
ASCII
Decimal
ASCII to
BIN
Symbols
Instruction
BINDA
BINDAP
DBINDA
DBINDAP
BINHA
BINHAP
DBINHA
DBINHAP
BCDDA
BCDDAP
DBCDDA
DBCDDAP
DABIN
DABINP
DDABIN
DDABINP
SymbolProcessing Details
BINDASD
BINDAPSD
DBINDASD
DBINDAP SD
BINHASD
BINHAPDS
DBINHASD
DBINHAP SD
BCDDASD
BCDDAPSD
DBCDDA SD
DBCDDAP SD
DABINSD
DABINPSD
DDABINSD
DDABINP SD
• Converts 1-word BIN value designated
by (S) to a 5-digit, decimal ASCII value,
and stores it at the word device
designated by (D).
• Converts 2-word BIN value designated
by (S) to a 10-digit, decimal ASCII value,
and stores it at word devices following
the word device number designated by
(D).
• Converts 1-word BIN value designated
by (S) to a 4-digit, hexadecimal ASCII
value, and stores it at a word device
following the word device number
designated by (D).
• Converts 2-word BIN value designated
by (S) to an 8-digit, hexadecimal ASCII
value, and stores it at word devices
following the word device number
designated by (D).
• Converts 1-word BCD value designated
by (S) to a 4-digit, decimal ASCII value,
and stores it at a word device following
the word device number designated by
(D).
• Converts 2-word BCD value designated
by (S) to an 8-digit, decimal ASCII value,
and stores it at word devices following
the word device number designated by
(D).
• Converts a 5-digit, decimal ASCII value
designated by (S) to a 1-word BIN value,
and stores it at a word device number
designated by (D).
• Converts a 10-digit, decimal ASCII value
designated by (S) to a 2-word BIN value,
and stores it at a word device number
designated by (D).
Execution
Condition
Subset
Number of
Basic Steps
37-173
37-173
37-176
37-176
37-179
37-179
37-182
37-182
See for
Description
• Converts a 4-digit, hexadecimal ASCII
value designated by (S) to a 1-word BIN
value, and stores it at a word device
number designated by (D).
• Converts an 8-digit, hexadecimal ASCII
designated by (S) value to a 2-word BIN
value, and stores it at a word device
number designated by (D).
Table 2.28 Character String Processing Instructions (Continued)
MELSEC-Q/QnA
Category
Decimal
ASCII to
BCD
Device
comment
read
operation
Character
string
length
detection
BIN to
decimal
character
string
Decimal
character
string to
BIN
Symbols
Instruction
DABCD
DABCDP
DDABCD
DDABCDP
COMRD
COMRDP
LEN
LENP
STR
STRP
DSTR
DSTRP
VAL
VALP
DVAL
DVALP
SymbolProcessing Details
DABCDSD
DABCDP SD
DDABCD SD
DDABCDP SD
COMRDSD
COMRDP SD
LENSD
LENPSD
STRS1 S2 D
STRPS1 S2 D
DSTRS1 S2 D
DSTRPS1 S2 D
VALD1 D2S
VALPD1 D2S
DVALD1 D2S
DVALPD1 D2S
• Converts a 4-digit, decimal ASCII value
designated by (S) to a 1-word BCD
value, and stores it at a word device
number designated by (D).
• Converts an 8-digit, decimal ASCII
designated by (S) value to a 2-word
BCD value, and stores it at a word
device number designated by (D).
• Stores comment from device designated
by (S) at a device designated by (D).
• Stores data length (number of
characters) in character string
designated by (S) at a device designated
by (D).
• Converts a 1-word BIN value designated
by (S2) to a decimal character string with
the total number of digits and the
number of decimal fraction digits
designated by (S1) and stores them at a
device designated by (D).
• Converts a 2-word BIN value designated
by (S2) to a decimal character string with
the total number of digits and the
number of decimal fraction digits
designated by (S1) and stores them at a
device designated by (D).
• Converts a character string including
decimal point designated by (S) to a 1word BIN value and the number of
decimal fraction digits, and stores them
at devices designated by (D1) and (D2).
• Converts a character string including
decimal point designated by (S) to a 2word BIN value and the number of
decimal fraction digits, and stores them
at devices designated by (D1) and (D2).
Execution
Condition
Subset
Number of
Basic Steps
37-187
37-187
37-190
37-194
47-196
47-196
47-202
47-202
See for
Description
Floating
decimal
point to
character
string
Character
string to
floating
decimal
point
ESTR
ESTRP
EVAL
EVALP
ESTRS1 S2 D
ESTRPS1 S2 D
EVALSD
EVALPSD
• Converts floating decimal point data
designated by (S1) to character string,
and stores them in a device designated
by (D).
• Converts character string designated by
(S) to floating decimal point data, and
stores them in a device designated by
(D).
Table 2.28 Character String Processing Instructions (Continued)
MELSEC-Q/QnA
Category
Hexadecimal BIN to
ASCII
ASCII to
hexadecimal BIN
Character
string
processing
Floating
decimal
point to
BCD
BCD to
floating
decimal
point data
Instruction
ASC
ASCP
HEX
HEXP
RIGHT
RIGHTP
LEFT
LEFTP
MIDR
MIDRP
MIDW
MIDWP
INSTR
INSTRP
EMOD
EMODP
EREXP
EREXPP
Symbol
Symbols
ASCnSD
ASCPnSD
HEXnSD
HEXPnSD
RIGHTnSD
RIGHTPnSD
LEFTnSD
LEFTPnSD
MIDRS1S2D
MIDRPS1S2D
MIDWS1S2D
MIDWPS1S2D
INSTRnS1 S2 D
INSTRPnS1 S2 D
EMODS1 S2 D
EMODPS1 S2 D
EREXPS1 S2 D
EREXPP S1 S2 D
• Converts 1-word BIN values of the device
number and later designated by (S) to
ASCII, and stores only n characters of
them at the device number designated by
(D).
• Converts only n ASCII characters of the
device number and later designated by (S)
to BIN values, and stores them at the
device number designated by (D).
• Stores n characters from the end of a
character string designated by (S) at the
device designated by (D).
• Stores n characters from the beginning of
a character string designated by (S) at the
device designated by (D).
• Stores the designated number of
characters in the character string
designated by (S1) from the position
designated by (S2) at the device
designated by (D).
• Stores the designated number of
characters in the character string
designated by (S1) from the position
designated by (S2) at the device
designated by (D).
• Searches character string (S1) from the
nth character of character string (S2), and
stores matched positions at (D).
• Converts floating decimal point data (S1)
to BCD data with number of decimal
fraction digits designated by (S2) , and
stores at device designated by (D).
• Converts BCD data (S1) to floating
decimal point data with the number of
decimal fraction digits designated by (S2),
and stores at device designated by (D).
QnA link
instruction:
Reading
data from
special
function
modules at
remote I/O
stations
QnA link
instruction:
Writing data
to special
function
module at
remote I/O
station
A-series
compatible
link instruction:
Reading
device data
from other
stations
A-series
compatible
link instruction: Writing
device data
to other
stations
A-series
compatible
link instruction:
Reading
data from
special
function
module at
remote I/O
station.
A-series
compatible
link instruction: Writing
data to
special
function
modules at
remote I/O
stations.
Reading
routing
information
Instruction
ZNFR
ZNTO
ZNRD
ZNWR
RFRP
RTOP
RTREAD
SymbolProcessing Details
Symbols
Execution
Condition
Number of
Basic Steps
Subset
See for
Description
D1S2S1JnJP.ZNFR
Reads data from the special
function modules at remote I/O
88-64
stations.
D1S2S1UnGP.ZNFR
DS2S1JnJ.ZNTO
DS2S1JnJP.ZNTO
Writes data to the special
J.ZNWR
Jn n1
function module at remote I/O
D
S2S1UnG.ZNTO
S2S1UnGP.ZNTO
station
D
D2n2SD1J.ZNRDJn n1
Reads the word device data of
other station to host station.
D2n2SD1JP.ZNRDJn n1
n2
D2
SD1
Writes the data of host station
to the word device of other
stations.
D2n2SD1JP.ZNWRJn n1
88-69
32
32
8-74
8-78
8-81
8-85
D2n2D1n1G.RFRP Un
Reads data from the special
function module at remote I/O
118-88
station.
D2n2D1n1GP.RFRP Un
Dn2D1n1G.RTOP Un
Writes data to the special
function module at remote I/O
data to
designated
file
Reading
data from
designated
file
Loading
program
from
memory
Unloading
program
from
program
memory
Load +
unload
Highspeed
block
transfer of
file register
Writ e to
host station
CPU
shared
memory
Read from
another
station
CPU
shared
memory
Automatic
refresh of
CPU
shared
memory
UNIRD
UNIRDP
SP.FWRITE
SP.FREAD
PLOADP
PUNLOADP
PSWAPP
RBMOV
RBMOVP
S. TO
SP. TO
FROM
FROMP
COM
SymbolProcessing Details
UNIRD n1n2D
UNIRDP n1n2D
TRACE
SP.FWRITES1 S2S0 D0D1U0
SP.FREADS1 S2S0 D0D1U0
PLOADPSD
PUNLOADP SD
PSWAPP S1 S2 D
RBMOV SnD
RBMOVP SnD
COM
Execution
Condition
Number of
Basic Steps
• Reads the module information stored in
the area starting from the I/O No.
designated by (n) by the points
designated by (n2), and stores it in the
area starting from the device
designated by (d).
• Stores trace data set at a peripheral
device to trace file in IC memory card
by the designated number when
SM800, SM801, and SM802 turns ON.
• Resets the data set by TRACE
instruction.
• Writes data to the designated file.119-7
• Reads data from the designated file.119-15
• Transfers the program stored in a
memory card or standard memory
(other than drive 0) to drive 0 and
places the program in standby status.
• Deletes the standby program stored in
standard memory (drive 0).
• Deletes standby program stored in
standard memory (drive 0) designated
by (S1). Then, transfers the program
stored in a memory card or standard
memory (other than drive 0) designated
by (S2) to drive 0 and places it in
standby status.
• Transfers n points of 16-bit data from
the device designated by (S) to the
location starting from the device
designated by (D).
Dn4n3n2S.TOn1
• Writes the device data of the host
station to the shared memory area of
the host station CPU module.
Dn4n3n2SP.TOn1
n3Dn2n1FROM
• Reads device data from the CPU
shared memory area of another station
CPU module to the host station.
n3Dn2n1FROMP
• Performs the automatic refresh of the
intelligent function module, general data
processing, and the automatic refresh
of the CPU shared memory.
2.5.21 Redundant system instructions (For Q4ARCPU)
Table 2.38 Redundant system instructions (For Q4ARCPU)
MELSEC-Q/QnA
Category
Operation
mode
setting
during
CPU start
up
Operation
mode
setting
instructions
during
CPU
switch
Data
tracking
Buffer
memory
batch
refresh
Symbols
Instruction
S.STMODE
S.CGMODE
S.TRUCK
S.SPREF
SymbolProcessing Details
• Designates the operation mode at (S1)
whether to clear the Q4ARCPU devices
S.STMODE S1 S2
S.CGMODE S
S.TRUCKS
S.SPREFS
before startup or not to clear them
before startup when the power supply is
turned on for CPU startup.
• Designates the operation mode at (S1)
whether to clear the Q4ARCPU devices
before startup or not to clear them
before startup when control is switched
from the control system to the standby
system.
• Conducts device memory tracking in
accordance with the parameter block
data contents stored in the area starting
from the device designated by (S)
during END processing.
• Batch reads/writes the contents of
special function module buffer memory
in accordance with the contents of
parameter block data stored in the area
starting from the device designated by
(S).
Most CPU module instructions consist of an instruction part and a device part.
• Instruction part.....Indicates the function of the instruction
• Device part ..........Indicates the data that is to be used with the instruction.
The device part is classified into source data, destination data, and number of devices.
3
(1) Source
(a) Source is the data used for operations.
(b) The following source types are available, depending on the designated device:
S
• Constants.....................................Designates the numeric value to be used in the
operation.
This is set when the program is written, and cannot
be changed during the execution of the program.
Constants should be indexed when using them as
variable data.
• Bit devices and Word devices.....Designates the device that stores the data to be
used for the operation.
Data must be stored in the designated device until
when the operation is executed.
By changing the data stored in a designated device
during program execution, the data to be used in
the instruction can be chan g ed.
MELSEC-Q/QnA
(2) Destination
D
(a) The destination stores the data after the operation has been conducted.
However, some instructions require storing the data to be used in an operation at the
destination prior to the operation execution.
Example: A n addition in struction involving BIN 16-bit data
S1
DSD
Stores the data needed for operation
prior to the actual operation.
++
Stores only the operation results.
S2
(b) A device for the data storage must always be set to the destination.
(b) Word device bit designation is done by designating ” Word Device Bit No. ” .
(Designation of bit numbers is done in hexadecimal.)
For example, bit 5 (b5) of D0 is designated as D0.5, and bit 10 (b10) of D0 is designated as
D0.A.
However, there can be no bit designation for timers (T), retentive timers (ST), counters (C)
or index register (Z). (Example Z0.0 is not available)
X0
SETD0.5
D0.5
SETY10
3.2.2 Using word (16 bits) data
Word data is 16-bit numeric data used by basic instructions and application instructions.
The following two types of word data can be used with CPU module:
• Decimal constants..........................K-32768 to K32767
• Hexadecimal constants..................H0000 to HFFFF
MELSEC-Q/QnA
Word device bit designation.
(Bit 5 (b5) of D0 designated as
ON (1).)
Word device bit designation.
(Turned ON or OFF according
to the 1/O status of bit 5 (b5)
of D0.)
Word devices and bit devices designated by digit can be used as word data.
For direct access input (DX) and direct access output (DY), word data cannot be designated by
digit output (DY). (For details of direct access input and direct access output, refer to the User’s
Manual (Function Explanation, Program Fundamentals) of the CPU module in use, or the
QnACPU Programming Manual (Fundamentals).).
(1) When using bit devices
(a) Bit devices can deal with word data when digits are designated.
Digit designation of bit devices is done by designating ” Number of digits
Initial number o f bi t dev i ce ” .Digit designation of bit devices can be done in 4-point (4-bit)
units, and designation can be made for K1 to K4.
(For link direct devices, designation is done by ”J Network No.
Initial number o f bi t dev i ce
” . When X100 to X10F are designated for Network No.2, it is
\ Digit designation
done by J2\K4X100.)
For example, if X0 is designated for digit designation, the following points would be
designated:
• K1X0.........The 4 points X0 to X3 are designated
• K2X0.........The 8 points X0 to X7 are designated
• K3X0.........The 12 points X0 to XB are designated
• K4X0.........The 16 points X0 to XF are designated
Fig 3.1 Digit Designation Setting Range for 16-Bit Instruction
XC
totototo
K4 designation range
MELSEC-Q/QnA
X8 X7X4 X3X0
K1 designation
range
(4 points)
K2 designation range
(8 points)
K3 designation range
(12 points)
(16 points)
(b) In cases where digit designation has been made at the source
S
shown in Table 3.1 are those which can be dealt with as source data.
Table 3.1 List of Numeric Values that Can Be Dealt with as Digit Designation
Number of Digits DesignatedWith 16-Bit Instruction
K1 (4 points)0 to 15
K2 (8 points)0 to 255
K3 (12 points)0 to 4095
K4 (16 points)-32768 to 32767
In cases where the source is a bit device designated by digit designation, and the
destination is a word device, the word device for the destination becomes 0 following
the bit designated by digit designation at the source.
Ladder ExampleProcessing
With 16-bit instruction
X010
MOV K1X0D0
S
Source data
b15b4
0 0X3
D0
Become 0
0000000000 X2X1X0
Fig 3.2 Ladder Example and Processing Conducted
, the numeric values
K1X0
X3X2X1X0
b0
b1b2b3
(c) In cases where digit designation is made at the destination
D
, the number of points
designated are used as the destination. Bit devices below the number of points designated
as digits do no t ch an ge .
Word devices are designated in 1-point (16 bits) units.
M0
MOV K100D0
POINTS
(1) When digit designation processing is conducted, a random value can be used
for the bit device ini tial devi ce numbe r.
(2) Digit designation cannot be made for the direct device designation DX and DY.
3.2.3 Using double word data (32 bits)
Double word data is 32-bit numerical data used by basic instructions and application instructions.
The two types of double word data that can be dealt with by CPU module are as follows:
• Decimal constants...............K-2147483648 to K2147483647
• Hexadecimal constants.......H00000000 to HFFFFFFFF
MELSEC-Q/QnA
1 D0 point (16 bits) is word device
Word devices and bit devices designated by digit designation can be used as double word data.
For direct access input (DX) and direct access output (DY), designation of double word data is not
possible by digit designation.
(1) When using bit devices
(a) Digit designation can be used to enable a bit device to deal with double word data.
Digit designation of bit devices is done by designating ” Number of digits
Initial number o f bi t dev i ce ”.
Digit designation of bit devices can be done in 4-point (4-bit) units, and designation can be
made for K1 to K8.
(For link direct devices, designation is done by ”J Network No.
Initial number o f bi t dev i ce
done by J2\K8X100.)
For example, if X0 is designated for digit designation, the following points would be
designated:
• K1X0.........The 4 points X0 to X3 are designated
• K2X0.........The 8 points X0 to X7 are designated
• K3X0.........The 12 points X0 to XB are designated
• K4X0.........The 16 points X0 to XF are designated
• K5X0.........The 20 points X0 to X13 are designated
• K6X0.........The 24 points X0 to X17 are designated
• K7X0.........The 28 points X0 to X1B are designated
• K8X0.........The 32 points X0 to X1F are designated
” . When X100 to X11F are designated for Network No.2, it is
Fig 3.4 Digit Designation Setting Range for 32-Bit Instructions
MELSEC-Q/QnA
K1 designation
range
(4 points)
K2 designation range
(8 points)
K3 designation range
(12 points)
K4 designation range
(16 points)
K5 designation range
(20 points)
K6 designation range
(24 points)
(28 points)
(b) In cases where digit designation has been made at the source
S
, the numeric values
shown in Table 3.2 are those which can be dealt with as source data.
Table 3.2 List of Numeric Values that Can Be Dealt with as Digit Designation
Number of Digits
Designated
K1 (4 points)0 to 15K5 (20 points)0 to 1048575
K2 (8 points)0 to 255K6 (24 points)0 to 16777215
K3 (12 points)0 to 4095K7 (28 points)0 to 268435455
K4 (16 points)0 to 65535K8 (32 points)-2147483648 to 2147483647
With 32 bit
Instructions
Number of Digits
Designated
With 32 bit Instructions
In cases where the source is a bit device designated by digit designation, and the
destination is a word device, the word device for the destination becomes 0 following the bit
designated by digit designation at the source.
(c) In cases where digit designation is made at the destination D, the number of points
designated are used as the destination.
Bit devices after the number of points designated as digits do not change.
Ladder ExampleProcessing
When source S data is a numerical value
X10
DMOV H78123456 K5M0
Destination
When source S data is a word device
X10
DMOV D0K5M10
Destination
MELSEC-Q/QnA
H78123456
10 01010010011100
3456
10000011
7
K5M0
M15M8M7M0
D
M31M20
b15b8
10011100
D0
b15b8
D1
D
10000011
M25M18
10011100
M41M30M29M26
812
Do not change
001 00011
10 010100
b7b0
1001 1 101
0b7011 0 1 11
M17M10
1001 1 101
10011100
M19M16
1000
b0
1101
Do not change
Fig 3.6 Ladder Example and Processing Conducted
POINTS
(1) When digit designation processing is conducted, a random value can be used
for the bit device ini tial devi ce numbe r.
(2) Digit designation cannot be made for the direct device designation DX and DY.
(2) When using word devices
A word device designates devices used by the lower 16 bits of data.
A 32-bit instruction uses (designation device number) and (designation device number + 1).
M0
DMOV K100D0
The 2 points D0 and D1 are used
32-bit data transfer instruction
Real number data is 32-bit floating decimal point data used with basic instructions and application
instructions.
Only word devices are capable of storing real number data.
Instructions which deal with real numbers designate devices which are used for the lower 16 bits
of data. Real numbers are stored in the 32 bits which make up (designated device number) and
(designated device number + 1).
M0
EMOV R100D0
REMARK
MELSEC-Q/QnA
The 2 points D0 and D1 (32 bits) are used
The 2 points R100 and R101
(32 bits) are used
Real number data transfer
1) In sequence programs, real numbers are designated by E .
Floating decimal point data uses two word devices and is expressed in the following manner:
1. [Variable part] × 2 [exponent part]
The bit configuration and meaning of the internal representation of floating decimal point data is as
follows:
b31b30
b31
Sign for variable part
to
b23 to b30
Expon en t part
b22b16tob15b0
b23
b0 to b22
Variable part
to
• Sign for variable partThe sign for the variable part is represented at b31.
0: Positive
1: Negative
n
• Exponent partThe n of 2
is represented from b23 to b30.
Depending on the BIN value of b23 to b30, the value of n is as follows.
b23 to b30FFHFEHFD
Nonnumeric
n
127 126210-1-125 -126
H
81H80H7FH7E
H
02H01H00
H
Nonnumeric
• Exponent partThe 23 bits from b0 to b22, represents the XXXXXX... at binary
1.XXXXXX....
POINT
• The CPU module floating decimal point data can be monitored using the
monitoring function of a peripheral device.
• When this is expressed as 0, all data from b0 to b31 will be 0.
Character string data is character data used by basic instructions and application instructions.
It encompasses all data from the designated character to the NULL code (00
(1) When designated character is the NULL code.
One word is used to store the NULL code.
M0
(2) When character string is even
Uses (number of characters/2 + 1) words, and stores character string and NULL code.
For example, if "ABCD" is transferred to D0, the character string ABCD is stored at D0 and D1,
and the NULL code is stored at D2.
M0
$MOVD0
" "
$MOV "ABCD"
D0
MELSEC-Q/QnA
D0 NULL
NULL code (00H) designation
Character string data transfer
H
).
H
H
NULL
41
43
H
H
D0
42
44
D1
D2
Designation of an even number
character string
Character string data transfer
(3) When number of characters is odd
Uses (number of characters/2) words (rounds up decimal fractions) and stores the character
string and NULL code.
For example, if "ABCDE" is transferred to D0, the character string (ABCDE) and the NULL
code are stored from D0 to D2.
(a) Index modification is an indirect setting made by using an index register.
When an index modification is used in a sequence program, the device to be used will
become the device number designated directly plus the contents of the index register.
For example, if D2Z2 has been designated the designated device is calculated as follows:
D(2+3)=D5 and the content of Z2 is 3 become the designated device.
(b) There are 16 index registers, from Z0 to Z15.
Each index register can be set between -32768 and 32767.
X0
MOV K-1Z0
MELSEC-Q/QnA
The value -1 is stored at Z0
X0
MOV D10Z0D0
Index modification
The data D10Z0
D9, is stored at D0
=
D {10 + (-1)}
Example
A case where index modification has been performed, and the actual process device, would be
as follows: (When Z0 = 20 and Z1 = -5)
With the exception of the restrictions noted below, index modification can be used with devices
used with contacts, coils, basic instructions, and application instructions.
(a) Devices which cannot use index modification
DeviceMeaning
K, H32-bit constant
EFloating decimal point data
$Character-string data
, Bit designated for word device
FX, FY, FDFunction devices
PPointers used as label s
IInterrupt pointers used as labels
ZIndex register
SStep relay
TRSFC transfer devices 1
BLSFC block devices 1
T, STValue set for timer
CValue set for counter
MELSEC-Q/QnA
(b) Devices with limits for use with index registers
DeviceMeaningApplication Example
T
C
• Only Z0 and Z1 can be used for timer
contacts and coils
• Only Z0 and Z1 can be used for counter
contacts and coils
T0Z0
C0Z1
K100
T1Z1
K100
C1Z0
REMARKS
1) 1: SFC transfer devices and SFC block devices are devices for SFC use.
Refer to the QCPU (Q mode)/QnACPU Programming Manual (SFC) for information on
how to use these devices.
2) For timer and counter present values, there are no limits on index register numbers used.
Set value of timer
X0
SM400
X1
SM400
K100
T0
T0Z4K4Y30BCD
K10
C100
C100Z6K2Y40BCD
(Index modification not possible)
Present value of timer
Set value of counter
(Index modification not possible)
1) Bit data
Device numbers can be index modified when performing digit designation.
However, inde x mod i fi cati on is no t possible by digit designa ti on .
BIN K4X0Z2D0
BIN K4Z3X0D0
2) Both I/O numbers and buffer memories can be index modified with special function
module devices.
MOV U10Z1\G0Z2 D0
MELSEC-Q/QnA
Setting that enables device
number index modification
If Z2 = 3, then X (0+3) = X3.
Setting t hat canno t enable
digit designation index
modification
If Z1 = 2 and Z2 = 8, then
U (10+2)\G (0+8) = U12\G8.
3) Both network numbers and device numbers can be index modified with link direct
devices.
MOV J1Z1\K4X0Z2 D0
If Z1 = 2 and Z2 = 8, then
J (1+2)\K4X (0+8) = J3\K4X8.
REMARKS
1) 1: Refer to the User's Manual (Functions Explanation, Programming Fundamentals) of the
used CPU module or QnACPU Programming Manual (Fundamentals) for special
function module device.
2)
2: Refer to the User's Manual (Functions Explanation, Programming Fundamentals) of the
used CPU module or QnACPU Programming Manual (Fundamentals) for link direct
devices.
1) 1: Refer to the User's Manual (Functions Explanation, Programming Fundamentals) of the
used CPU module or QnACPU Programming Manual (Fundamentals) for device names.
2)
2: Indicates index modification by index register
3)
3: The device can be designated indirectly, however the address cannot be written in the
ADRSET instruction.
Example of Indirect
Designation
• @D100
• @D100Z2
• @J1\W10
• @J1Z1\W10Z2
• @U10\G0
• @U10Z1\G0Z2
• @R0, @ZR20000
• @R0Z1, @ZR20000Z1
2
2
2
2
(3) Cautions
The address for indirect designation is designated using two words.
Therefore, to substitute indirect designation for index modification, the addition/subtraction of
32-bit data is req ui r ed .
The following is the ladder used for the addition/subtraction of the address of the device stored
in D1 and D0 for indirect designation.
[To add "1" to the address of the device for indirect designation]
DINCPD0
Device used for indirect designation
32-bit instruction
[To subtract "1" from the address of the device for indirect designation]
Subset processing is used to place limits on bit devices used by basic instructions and application
instructions in order to increase processing speed.
However, the instruction symbol does not change.
To shorten scans, run instructions under the conditions indicated below.
(1) Conditions which each device must meet for subset processing
(a) When using word data
DeviceCondition
• Designates a bit device number in a factor of 16
Bit device
Word device• Internal device (File register ZR is not included)
Constants• No limitations
(b) When using double word data
DeviceCondition
Bit device
Word device• Internal device (File register ZR is not included)
Constants• No limitations
• Only K4 can be designated for digit designation
• Does not conduct index modification
• Designates a bit device number in a factor of 32
• Only K8 can be designated for digit designation
• Does not conduct index modification
MELSEC-Q/QnA
(2) Instructions for which subset processing can be used
(addition, subtraction,
multiplication, and division)
Data conversion instructions• BCD, BIN, DBCD, DBIN
Data transfer instruction
Program branch instruction• CJ, SCJ, JMP
Logic operations • WAND, DAND, WOR, DOR, WXOR, DXOR, WXNR, DXNR
Rotation instruction• RCL, DRCL, RCR, DRCR, ROL, DROL, ROR, DROR
Shift instructions• SFL, DSFL, SFR, DSFR
Data processing instructions• SUM, SEG
Structured program instructions• FOR, CALL
• +, -,
• B+, B-, B
• MOV, DMOV, CML, DCML, XCH, DXCH
• FMOV, BMOV, EMOV (with QCPU only)
, /, INC, DEC, D+, D-, D , D/, DINC, DDEC
, B/
REMARK
1) : It is only QCPU that can use three devices to conduct subset processing of the logic
operation instructions WAND, DAND, WOR, DOR, WXOR, DXOR, WXNR, or DXNR.
Operation errors are returned in the following cases when executing basic instructions and
application instructions with CPU module:
• An error listed on the explanatory page for the individual instruction occurred.
• No intelligent function module or special function module is installed at the designated I/O No.
position when using the buffer register.
• The relevant network does not exist when using a link device.
• No network module is installed at the designated I/O No. when using a link device.
POINT
(1) When a file register setting has been made but no memory card has been
installed, or when no file register setting has been made, no error will be
returned even if an attempt is made to write to the file register.
However, "FFFF
register at which this write operation was attempted.
H
" will be stored if an attempt is made to read from the file
MELSEC-Q/QnA
(1) Device range check
Device range checks for the devices used by basic instructions and application instructions in
CPU module are a s indi ca te d below :
(a) No device range check is made for instructions dealing with fixed-length devices (MOV,
DMOV, etc.).
In cases where the corresponding device range is exceeded, data is written to other
devices.
For example, in a case whe re the da ta regi st e r has be en allo ca te d 12 k poi nts, th e re w ill be
no error even if it exceeds D12287.
DMOV K100D12287
D12287 and D12288 have been
indicated here, but because
D12288 does not exist, the
contents of some other device
will be destroyed.
Device range checks are not conducted also in cases where index modification is being
performed.
(b) Device range checks are conducted for instructions dealing with variable-length devices
(BMOV, FMOV, and others which designate transfer numbers).
In cases where the corresponding device range has been exceeded, an operation error will
be returned.
For example, in a case wh ere the da ta regi st e r has be en alloca te d 12 k po i nt s, the re will be
an error if it exceeds D12287.
K100 D12287K2
BMOV
D12287 and D12288 have been
indicated here, but because
D12288 does not exist, an
operation error is returned.
REMARK
1) : See section 3.4 (3) for the internal user device allocation order.
Device range checks are also conducted when index modification is performed.
However, if i nde x modi fi ca ti on ha s been con du ct ed , t he re wi ll be no er ro r re tu rn ed if t he
initial device number exceeds the relevant device range.
K2Z1MOV
K100 D12285Z1 K2
BMOV
K100 D12287Z1 K2
BMOV
(c) Because all character string data is of variable length, device range checks are performed.
In cases where the corresponding device range has been exceeded, an operation error will
be returned.
For example, in a case whe re the da ta regi st e r has be en allo ca te d 12 k poi nts, th e re w ill be
an error if it exceeds D12287.
MELSEC-Q/QnA
D12287 and D12288 have been indicated here, but because
D12288 does not exist, an operation error is returned.
Because the initial device number is D12289 and that exceeds
the device range, the initial device number is made W0,
the operation is conducted, and no error is returned.
$MOV "ABC"D12287
D12287 and D12288 have been indicated here, but because
D12288 does not exist, an operation error is returned.
Note that an operation error does not occur even if the head device number exceeds the
device range as the result of index modification.
(d) Device range checks are conducted when index modification is performed by direct access
output (DY).
(2) Device data check
Device data checks for the devices used by basic instructions and application instructions in
CPU module are a s indi ca te d below :
(a) When using BIN data
• No error is returned even if the operation results in overflow or underflow.
The carry flag does not go on at such times, either.
(b) When using BCD data
1) Each digi t i s che c k for BCD valu e ( 0 / to 9 ).
An operation error is returned if individual digits are outside the 0 to 9 (A to F) range.
2) No error is returned even if the operation results in overflow or underflow.
The carry flag does not go on at such times, either.
(c) When using floating decimal point data
Operation errors are returned in the following cases:
• When value of floating decimal point data is 0
• When the absolute value of the floating decimal point data is 1.0 × 2
• When absolute value of floating decimal point data is 1.0 × 2
(3) If internal user device allocation is changed by parameter device allocation, such allocations
are made in the device order indicated below:
If the allocation of the device used is less than 28.75 k words, the area following the device
used will be empty.
Initial address
(fixed)
SM
SD
X
Y
M
L
B
F
SB
V
S
T contact and coi l
ST contact and coil
C contact and coil
Present value of T
Present value of ST
Present value of C
D
W
SW
Empty area
File register
(32 k points)
MELSEC-Q/QnA
Empty area created when device
used is less than 28.75 k words.
REMARK
1) Refer to the User's Manual (Functions Explanation, Programming Fundamentals) of the used
CPU module or the QnA CP U P rog r ammi n g Man ual (F u nda men t al s), fo r how to chan ge th e
internal user device allocation.
The following four types of execution conditions exist for the execution of CPU module sequence
instructions, basic instructions, and application instructions:
• Non-conditional execution...................Instructions executed without regard to the ON/OFF status
of the device
Example: LD X0, OUT Y10
• Executed at ON...................................Instructions executed while input condition is ON
Example: MOV instruction, FR OM instru cti on
• Executed at leading edge...................Instructions executed only at the leading edge of the input
condition (when it goes from OFF to ON)
Example: PLS instruction, MOVP instruction
• Executed at trailing edge ....................Instructions executed only at the trailing edge of the input
condition (when it goes from ON to OFF)
Example: PLF instruction
For coil or equivalent basic instructions or application instructions, where the same instruction can
be designated for either execution at ON or leading edge execution, a "P" is added after the
instruction name to specify the condition for execution.
MELSEC-Q/QnA
• Instruction to be executed at ON Instruction name
• Instruction to be executed at leading edge Instruction name + P
Execution at ON and execution at leading edge for the MOV instruction are designated as follow:
The number of steps in CPU module sequence instructions, basic instructions, and application
instructions differs depending on whether indirect setting of the device used is possible or not.
The basic number of steps for basic instructions and application instructions is calculated by
adding the device number and 1.
For example, the "+ instruction" would be calculated as follows:
MELSEC-Q/QnA
+D0R0
1
+
D0R0D10
23
1
2
Indicates the number of devices
3 steps
4 steps
(1) Conditions for increasing the number of steps
The number of steps is increased over the number of basic steps in cases where a device is
used that is designated indirectly or for which the number of steps is increased.
(a) When device is designated indirectly
In cases where indirect designation is done by @
, the number of steps is increased
1 step over the number of basic steps.
For example, when a 3-step MOV instruction is designated indirectly (example: MOV K4X0
@D0), one step is added and the instruction becomes 4 steps.
(b) Devices where number of steps increases
Devices Where Number of Steps
Increases
Intelligent function module
device/special function module
device
Link direct devicesMOV J3\B20 D0
Serial number access file registersMOV ZR123 D0
32-bit constantsDMOV K123 D0
Real number constant
For even numbers:
Character string constant
(number of characters)/2
For odd numbers:
(number of characters + 1)/2
Added StepsExample
MOV U4\G10 D0
1
EMOV E0.1 D0
$MOV "123" D0
(c) In cases where the conditions described in (a) and (b) above overlap, the number of steps
becomes a culmination of the two.
For example, if MOV U1\G10 ZR123
has been designated, 1 step is added for buffer
register designation and 1 step is added for serial number access file register designation,
making a total of 2 step s ad de d.
3.9 Operation when OUT, SET/RST, or PLS/PLF Instructions Use
the Same Device
The following describes the operation for executing multiple instructions of OUT, SET/RST, or
PLS/PLF that use the same device in one scan.
(1) OUT 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 determined when each OUT instruction is executed,
the device may tu r n ON and OFF rep ea tedly during one scan.
The following diagram shows an example of a circuit that turns the same internal relay (M0)
with inputs X0 and X1 ON and OFF.
[Circuit]
[Timing Chart]
M0
X0
M0
X1
M0
X0
END
ON
OFF
0
ON
1
OFF
ON
OFF
M0 turns OFF because X1 is OFF.
M0 turns ON because X0 is ON.
M0
X1X1
M0
ENDEND
M0 remains OFF because X0 is OFF.
X0
M0
M0
M0 turns ON because
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.
(a) The SET instruction turns ON the specified device when the SET command is ON and
does not do anything when the SET command is OFF.
For this reason, when two or more SET instructions use the same device in one scan,
the specified device will be ON if any one of the SET commands is ON.
(b) The RST instruction turns OFF the specified device when the RST command is ON and
does not anything when the RST command is OFF.
For this reason, when two or more RST instructions use the same device in one scan,
the specified device will be OFF if any one of the RST commands is ON.
(c) 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 command
is ON and the RST instruction turns OFF the specified device when the RST command
is ON.
When both the SET and RST commands are OFF, the ON/OFF status of the specified
device will not be changed.
The PLS instruction turns ON the specified device when the PLS command turns ON from
OFF. It turns OFF the specified device at any other time (OFF
OFF).
When two or more PLS instructions using the same device are programmed in one scan, each
PLS instruction turns ON the specified device when the corresponding PLS command turns
ON from OFF and it turns OFF the specified device at any other time.
For this reason, when two or more PLS instructions using the same device are programmed in
one scan, the device that has been turned ON by the PLS command may not turn ON again
throughout the scan.
[Circuit]
X0
M0
PLS
X1
PLS
M0
MELSEC-Q/QnA
OFF, ON ON, and ON
[Timing Chart]
• The ON/OFF timing of the X0 and X1 is different. (The specified device does not turn ON
throughout the scan.)
X0
X1
M0
OFF
OFF
OFF
END
ON
M0 turns ON because X0 turns
ON from OFF.
X0
PLS
M0
X1
M0 turns OFF because
X1 is not turning ON from OFF.
M0
PLS
END
ON
M0 turns OFF because X0 is not turning
ON from OFF. (M0 stays OFF.)
X0
PLS
M0
X1
M0PLS
END
ON
M0 turns ON because X1
turns ON from OFF.
• The X0 and X1 turn ON from OFF at the same time.
END
X0
PLS
M0
X1
M0PLS
ENDEND
X0
M0PLS
X1
M0PLS
OFF
X0
OFF
OFF
ON
ON
M0 turns ON because X1 turns
ON from OFF. (M0 stays ON.)
M0 turns ON because
X0 turns ON from OFF.
M0 turns OFF because X1 is
not turning ON from OFF.
M0 turns OFF because X0
is not turning ON from OFF.
The PLF instruction turns ON the specified device when the PLF command turns ON from
OFF. It turns OFF the specified device at any other time (OFF
ON).
When two or more PLF instructions using the same device are programmed in one scan, each
PLF instruction turns OFF the specified device when the corresponding PLF command turns
OFF from ON and it turns OFF the specified device at any other time.
For this reason, when two or more PLF instructions using the same device are programmed in
one scan, the device that has been turned ON by the PLF command may not turn ON again
throughout the scan.
[Circuit]
X0
M0
PLF
X1
PLF
M0
MELSEC-Q/QnA
OFF, OFF ON, and ON
[Timing Chart]
• The ON/OFF timing of the X0 and X1 is different. (The specified device does not turn ON
throughout the scan.)
X0
X1
M0
OFF
OFF
END
OFF
M0 turns ON because X0
turns OFF from ON.
X0
ON
M0 turns OFF because X1 is
not turning OFF from ON.
M0
PLF
X1
ENDEND
ON
M0PLF
M0 turns OFF because X0 is not turning
OFF from ON. (M0 stays OFF.)
X0
M0 turns OFF because X1
turns OFF from ON.
(M0 stays OFF.)
M0PLF
X1
M0PLF
• The X0 and X1 turn OFF from ON at the same time.
END
X0
M0
PLF
X1
M0PLF
END
X0
M0PLF
X1
M0PLF
END
OFF
X0
ON
X1
M0
OFF
OFF
M0 turns ON because
X0 turns OFF from ON.
ON
M0 turns ON because X1 turns
OFF from ON. (M0 stays ON.)
M0 turns OFF because X1
is not turning OFF from ON.
M0 turns OFF because X0 is not turning
OFF from ON.
Discusses the data set for each in st ru ction and the da ta ty pe.
Data TypeMeaning
BitBit data or first number in bit data
BIN 16 bitsBIN 16-bit data or first number in word device
BIN 32 bitsBIN 32-bit data or first number in double word device
BCD 4 digits4-digit BCD data
BCD 8 digits8-digit BCD data
Real numberFloating decimal point data
Character stringCharacter string data
Device nameDevice name data
6
Indicates the function of the instruction.
7
Indicates conditions under which error is returned, and error number.
See Section 3.6 for errors not included here.
8
Indicates whether the instruction can be used with each CPU module type.
: Can be used
: Can be used with restrictions (function version, software version)
: Cannot be used
9
Indicates both ladder and list for simple program example.
Also indicates the types of individual devices used when the program is executed.
5.1.1 Operation start, series connection, parallel connection
(LD, LDI, AND, ANI, OR, OR I)
Usable Devices
Set
Data
S
Internal Devices
(System, User)
BitWord
File
Register
[Instruction Symbol] [Execution Condition]
LD
LDI
MELSECNET/10(H)
Direct J \
BitWord
Bit device number/Bit designation of word device ( )
X1/D0.1
X1/D0.1
Special
Function
Module
U \G
Index
Register
Zn
rocess
Constant
S
K, H
QnAQ4AR
Other
DX, BL
5
[Set Data]
[Functions]
X2/D0.2
AND
ANI
OR
X3/D0.3
ORI
X3/D0.3
Set DataMeaningData Type
S
Devices used as connectionsBit
X2/D0.2
LD, LDI
(1) LD is the A contact operation start instruction, and LDI is the B contact operation start
instruction. They read ON/OFF information from the designated device (if a word device bit
has been designated, this becomes the 1/0 status of the designated bit), and use that as an
operation result.
(1) AND is the A contact series connection instruction, and ANI is the B contact series connection
instruction. They read the ON/OFF data of the designated bit device (if a bit designation has
been made for a word device, the 1/0 status of the designated bit is read), perform an AND
operation on that data and the operation result to that point, and take this value as the
operation result.
(2) There are no restrictions on the use of AND or ANI, but the following applies with a peripheral
device used in the ladder mode:
(a) Write............When AND and ANI are connected in series, a ladder with up to 21 stages
can be generated.
(b) Read ...........When AND and ANI are connected in series, a ladder with up to 24 stages
can be displayed.
If the number exceeds 24 stages, up to 24 will be displayed.
OR, ORI
(1) OR is the A contact single parallel connection instruction, and ORI is the B contact single
parallel connection instruction. They read ON/OFF information from the designated device (if a
word device bit has been designated, this becomes the 1/0 status of the designated bit), and
perform an OR operation with the operation results to that point, and use the resulting value as
the operation result.
MELSEC-Q/QnA
(2) There are no limits on the use of OR or ORI, but the following applies with a peripheral device
used in the ladder mode.
(a) Write................OR and ORI can be used to create connections of up to 23 ladders.
(b) Read................Up to 23 ladders connected with OR or ORI can be displayed.
The 24th or subsequent ladders cannot be displayed properly.
REMARK
Word device bit designations are made in hexadecimal
Bit b11 of D0 would be D0.0B.
See Section 3.2.1 for more information on word device bit designation.