Sie sind auf Seite 1von 540

Programmable Controller

KV-700 Series
Instruction
Reference Manual
Preface
This document describes the instructions used in KV-700 programs. Be sure to
thoroughly read and fully understand this manual before making programs.
Descriptions relating to KV-700 Series hardware and basic descriptions for making
programs are described in "Before You Start Programming" in the KV-700 Series
User's Manual. Beginners to programming should also read this manual together with
the KV-700 Series User's Manual.
Store this manual in a safe place so that you can retrieve it whenever necessary.
See to it that this manual reaches the last person who is going to use the KV-700 Series.

■ KV-700 Series Related Manuals


Read the following manuals when you use the KV-700 Series.
If you require these manuals, contact your agent.

Type of Manual Description of Manual


KV-700 Series User's This manual describes the specifications of each of the
Manual units in the KV-700 Series, and their functions and
(PDF manual) method of operations. When using the KV-700 series,
refer mainly to this manual.
KV-700 Series Instruction This manual. This manual describes the instructions used
Reference Manual in programs run on the KV-700 Series.
(PDF manual)
KV BUILDER User's This manual describes the functions and methods of
Manual operation of Windows version Ladder Support Software
(PDF manual) KV BUILDER.
KV-D30 User's Manual This manual describes the specifications of Operator
Panel KV-D30, and its functions and methods of opera-
tion.
KV-L20 User's Manual This manual describes the specifications of Multi-
(PDF manual) communication Unit KV-L20, and its functions and
methods of operation.
KV-AD40/DA40 User's This manual describes the specifications of AD/DA
Manual Conversion Unit KV-AD40/DA40, and its functions and
(PDF manual) methods of operation.
KV-SC20 User's Manual This manual describes the specifications of High-speed
(PDF manual) Counter Unit KV-SC20, and its functions and methods of
operation.
KV-TF40 User's Manual This manual describes the specifications of Multi-input
(PDF manual) PID Temperature Control Unit KV-TF40, and its functions
and methods of operation.
KV-LE20 User's Manual This manual describes the specifications of Ethernet Unit
(PDF manual) KV-LE20, and its functions and methods of operations.
Safety Precautions
Symbols
This manual uses the following symbols to alert you to important information.
Failure to follow these instructions may lead to death or serious
DANGER injury.

WARNING Failure to follow these instructions may lead to injury.

Failure to follow these instructions may lead to physical dam-


CAUTION age (product malfunction, etc.).

Important: Provides additional information on precautions and restrictions that must


be followed in operation.

Note: Provides additional information on proper operation.

[Tip]
Indicates useful information or information that aids understanding of text descrip-
tions.

Indicates a reference item or page to be referred to in this manual and a separate


manual.

General Precautions
• Before you start using KV BUILDER, make sure that the Visual KV Series Basic Unit
and Visual KV Series CPU Unit functions and performance are normal.
• Before using the KV-700 Series, implement sufficient safety measures to prevent
various damage in the event that the KV Series malfunctions.
• Do not modify the KV-700 Series or use it in any way other than described in the
specifications. The functions and performance of products used or modified in this
way cannot be assured.
• When the KV-700 Series is used in combination with other equipment, functions and
performance may be degraded depending on operating conditions, surrounding
environment and other factors. Fully take this into consideration before using the KV-
700 Series in this way.
• Do not use the KV-700 Series for the purpose of protecting human life.

Requests
If the KV-700 Series is to be used in the following conditions or environments, make
sure that the actual operating conditions are well within the published ratings and
functional parameters. Take all necessary safety precautions, such as ensuring that
operation is fail-safe. Also, contact your agent about the following applications.
• Use under conditions and environment not described in this manual.
• Use of the KV-700 Series in nuclear power control, railroad facilities, aircraft facilities,
vehicles, combustion units, medical instruments, amusement machines, and safety
devices
• Use in applications where a major influence to human life and property is anticipated,
and where safety in particular is required

i
This page left intentionally blank.

ii
How This Manual Is Organized
Chapter 1 BRIEF EXPLANATION OF INSTRUCTIONS
This chapter provides an explanation of devices and conventions used in instructions in
this manual, and describes basic knowledge needed in handling instructions such as how
to handle data. (Detailed explanations of instructions in Chapters 2 to 5 assume that
readers of this manual have read and fully understood this chapter.)

Chapter 2 BASIC INSTRUCTIONS


This chapter explains the most basic instructions in writing a sequence program.
These instructions are sufficient for enabling mechanical control on the same level as that
1
of a general-purpose relay sequence circuit. Programs can be comprised entirely of basic
instructions. 2
Chapter 3 APPLIED INSTRUCTIONS
These instructions are for work progress, program control, and extended ladders. 3
These instructions allow you to structurally script basic ladders.

Chapter 4 ARITHMETIC OPERATION INSTRUCTIONS 4


These instructions are for executing comparisons, arithmetical calculations, logical
calculations, data move, and text processing.
These instructions allow you to simply script complex arithmetic calculation circuits. 5
Chapter 5 EXTENDED INSTRUCTIONS
These instructions are for data processing, clock processing, high-speed processing, and
positioning processing.

Appendices
This chapter presents error code tables, instruction execution times, differences between
the KV-300 and KV-10/16/24/40, text code lists (ASCII), special device tables, and an
instruction index.

iii
Contents
Preface
Safety Precautions ................................................................................ i
How This Manual Is Organized ........................................................... iii
Contents ............................................................................................... iv
Conventions Used In This Manual .................................................... xii

Chapter 1 BRIEF EXPLANATION OF INSTRUCTIONS

1-1 Configuration of Instructions .................................................. 1-2


Classification of Instructions ................................................................. 1-2
Conventions Used in This Instruction Reference Manual ..................... 1-3
About Programming of Instructions ....................................................... 1-4
Differences in Annotation According to Instruction Execution Type ..... 1-5
About Every Scan Execution Type and Differential Execution Type .... 1-5
About Suffixes ....................................................................................... 1-9
1-2 Configuration of Devices ....................................................... 1-10
Device List .......................................................................................... 1-10
About Bit Devices ................................................................................ 1-11
Input relays ........................................................................................... 1-11
Output relays ........................................................................................ 1-11
Internal auxiliary relays ......................................................................... 1-12
CR Control relays ............................................................................ 1-13
T Timers ....................................................................................... 1-13
C Counters .................................................................................... 1-14
CTC High-speed counter comparators .............................................. 1-14
About Word Devices ........................................................................... 1-15
DM Data memories .......................................................................... 1-15
CM Control memories ...................................................................... 1-16
TM Temporary data memories ........................................................ 1-16
CTH High-speed counters ................................................................. 1-17
About Internal Registers ..................................................................... 1-17
About Constants ................................................................................. 1-18
# Decimal constant ............................................................................... 1-18
$ Hexadecimal constant ....................................................................... 1-18
1-3 How Data Is Handled .............................................................. 1-20
About Numerical Values and Text ...................................................... 1-20
BIN Binary ............................................................................................. 1-22
Decimal (unsigned binary) .................................................................... 1-22
Decimal (signed binary) ........................................................................ 1-22
HEX (Hexadecimal) .............................................................................. 1-22
BDC (Binary Coded Decimal) ............................................................... 1-22
Floating point real numbers .................................................................. 1-23
About Internal Annotation of Floating Point Real Numbers ................ 1-23
ASCII code (American national Standard Code for
Information Interchange) ....................................................................... 1-24
About Handling 32-bit Data ................................................................. 1-24
About Handling Bit Devices in Word Units .......................................... 1-25
1-4 About Suffixes ........................................................................ 1-28
What Is a "Suffix?" .............................................................................. 1-28

iv
1-5 Configuration of Programs .................................................... 1-34
About Sequence Programs ................................................................. 1-34
1-6 Extended Ladder .................................................................... 1-38
Features of the Extended Ladder Language ...................................... 1-38
Advantages of the Extended Ladder Language.................................. 1-39
1-7 Indirect Specification ............................................................. 1-42
About Indirect Specification ................................................................ 1-42
Indirect specification method ................................................................ 1-42
Device ranges not available for indirect specification ........................... 1-42
Instructions that allow indirect specification in operands ...................... 1-43
1-8 List of Instructions ................................................................. 1-44
Basic Instructions ................................................................................ 1-44
Applied Instructions............................................................................. 1-49
Arithmetic Operation Instructions ........................................................ 1-51
Extended Instructions ......................................................................... 1-65

Chapter 2 BASIC INSTRUCTIONS

2-1 Contact Instructions................................................................. 2-2


Contact Instruction List ......................................................................... 2-2
LD Connecting a device to the bus line as an NO contact .......... 2-4
LDB Connecting a device to the bus line as an NC contact .......... 2-4
AND Connecting devices in series as NO contacts.. ..................... 2-6
ANB Connecting devices in series as NC contacts.. ...................... 2-6
OR Connecting devices in parallel as NO contacts.. ................... 2-8
ORB Connecting devices in parallel as NC contacts.. .................... 2-8
LDP Connecting devices to the bus line as NO contacts that turn
ON for one scan when a reference relay is ON ................... 2-10
LDF Connecting devices to the bus line as NO contacts that turn
ON for one scan when a reference relay is OFF ................. 2-10
ANP Connecting devices in series as NO contacts that turn ON
for one scan when a reference relay is ON ......................... 2-10
ANF Connecting devices in series as NO contacts that turn ON
for one scan when a reference relay is OFF ........................ 2-10
ORP Connecting devices in parallel as NO contacts that turn ON
for one scan when a reference relay is ON ......................... 2-10
ORF Connecting devices in parallel as NO contacts that turn ON
for one scan when a reference relay is OFF ........................ 2-10
2-2 Bit Contact Instructions ......................................................... 2-12
Bit Contact Instruction List .................................................................. 2-12
BLD Connect specified bits of reference word device to the bus
line as NO contacts .............................................................. 2-14
BLDB Connect specified bits of reference word device to the bus
line as NC contacts .............................................................. 2-14
BAND Connect specified bits of reference word device in series
as NO contacts .................................................................... 2-14
BANB Connect specified bits of reference word device in series
as NC contacts .................................................................... 2-14
BOR Connect specified bits of reference word device in parallel
as NO contacts .................................................................... 2-14
BORB Connect specified bits of reference word device in parallel
as NC contacts .................................................................... 2-14

v
2-3 Comparison Contact Instructions......................................... 2-16
Comparison Contact Instruction List ................................................... 2-16
LD= Connecting devices as NO contacts that turn when "A=B"
to the bus line ...................................................................... 2-20
LD< Connecting devices as NO contacts that turn when "A<B"
to the bus line ...................................................................... 2-20
LD> Connecting devices as NO contacts that turn when "A>B"
to the bus line ...................................................................... 2-20
LD<= Connecting devices as NO contacts that turn when "A<=B"
to the bus line ...................................................................... 2-20
LD>= Connecting devices as NO contacts that turn when "A>=B"
to the bus line ...................................................................... 2-20
LD<> Connecting devices as NO contacts that turn when "A<>B"
to the bus line ...................................................................... 2-20
AND= Connecting devices in series as NO contacts that turn when
"A<=B" ................................................................................. 2-20
AND< Connecting devices in series as NO contacts that turn when
"A<=B" ................................................................................. 2-20
AND> Connecting devices in series as NO contacts that turn when
"A<=B" ................................................................................. 2-20
AND<= Connecting devices in series as NO contacts that turn when
"A<=B" ................................................................................. 2-20
AND>= Connecting devices in series as NO contacts that turn when
"A>=B" ................................................................................. 2-20
AND<> Connecting devices in series as NO contacts that turn when
"A<>B" ................................................................................. 2-20
OR= Connecting devices in parallel as NO contacts that turn when
"A=B" ................................................................................... 2-20
OR< Connecting devices in parallel as NO contacts that turn when
"A<B" ................................................................................... 2-20
OR> Connecting devices in parallel as NO contacts that turn when
"A>B" ................................................................................... 2-20
OR<= Connecting devices in parallel as NO contacts that turn when
"A<=B" ................................................................................. 2-20
OR>= Connecting devices in parallel as NO contacts that turn when
"A>=B" ................................................................................. 2-20
OR<> Connecting devices in parallel as NO contacts that turn when
"A<>B" ................................................................................. 2-20
2-4 Output Instructions ................................................................ 2-22
Output Instruction List ......................................................................... 2-22
OUT Outputting the previous state ............................................... 2-24
OUB Outputting the previous state inverted ................................. 2-24
SET Holding the state of the target relay ON .............................. 2-26
RES Turning the target relay OFF ............................................... 2-26
KEEP Setting/resetting target relays according to the SET/RES
input ..................................................................................... 2-28
DIFU Turning the target relay ON for one scan at the up edge of
the previous state ................................................................ 2-30
DIFD Turning the target relay ON for one scan at the down edge
of the previous state ............................................................ 2-30
ONDL ON delay operation of the target relay ................................. 2-32
OFDL OFF delay operation of the target relay ............................... 2-32

vi
SHOT One-shot operation of the target relay ................................. 2-34
FLIK Flicker operation of the target relay ..................................... 2-36
ALT Alternate operation of the target relay ................................. 2-38
2-5 Bit Output Instructions .......................................................... 2-40
Bit Output Instruction List .................................................................... 2-40
BOUT Outputting the previous state to the specified bit of
a reference word device ...................................................... 2-42
BOUB Outputting the previous state to the specified bit of
a reference word device inverted ......................................... 2-42
BSET Turning the specified bit of a reference word device ON
and holding this state ........................................................... 2-44
BRES Turning the specified bit of a reference word device OFF ... 2-44
2-6 Timer/Counter Instructions ................................................... 2-46
Timer/Counter Instruction List ............................................................. 2-46
TMR 32-bit 100 ms countdown timer ............................................ 2-48
TMH 32-bit 10 ms countdown timer .............................................. 2-50
TMS 32-bit 1 ms countdown timer ................................................ 2-52
C 32-bit total counter ............................................................... 2-56
ITVL Pulse measurement/DM value measurement ...................... 2-60
UDC 32-bit up-down counter ........................................................ 2-64
UDT 32-bit up-down timer ............................................................ 2-66
2-7 Connect/End Instructions ...................................................... 2-68
Connect/End Instruction List ............................................................... 2-68
END Ending the main routine program ........................................ 2-70
ENDH Ending the sequence program ............................................. 2-70
CON Connecting a series of output instructions ........................... 2-72
MPS Storing the previous state to memory .................................. 2-74
MRD Reading a state stored to memory by the MPS instruction .. 2-74
MPP Clearing a state stored to memory by the MPP instruction .. 2-74
ANL Connecting contact blocks in series .................................... 2-76
ORL Connecting contact blocks in parallel .................................. 2-76

Chapter 3 APPLIED INSTRUCTIONS

3-1 Shift Instruction ........................................................................ 3-2


Shift Instruction List............................................................................... 3-2
SFT Shift register operation ........................................................... 3-6
3-2 Memory Switch instruction...................................................... 3-6
Memory Switch Instruction List ............................................................. 3-6
MEMSW Setting the memory switch ..................................................... 3-8
3-3 Step Instructions .................................................................... 3-12
Step Instruction List ............................................................................ 3-12
STP Starting a step ...................................................................... 3-14
STE Ending a step ....................................................................... 3-14
3-4 Stage Processing Instructions .............................................. 3-18
Stage Processing Instruction List ......................................................... 3-18
STG Starting a stage .................................................................... 3-20
JMP Jumping a stage .................................................................. 3-20
ENDS Ending a stage ..................................................................... 3-20
W-ON Turning the target relay ON and holding this state when the
previous state is ON and the detection relay is ON ............. 3-24

vii
W-OFF Turning the target relay ON and holding this state when the
previous state is ON and the detection relay is OFF ........... 3-24
W-UE Turning the target relay ON and holding this state at the up
edge of the detection relay when the previous state is ON .... 3-26
W-DE Turning the target relay ON and holding this state at the
down edge of the detection relay when the previous state
is ON .................................................................................... 3-26
3-5 Flow Instructions .................................................................... 3-28
Flow Instruction List ............................................................................ 3-28
MC Starting master control ......................................................... 3-30
MCR Ending master control .......................................................... 3-30
CALL Calling up a sub-routine ....................................................... 3-34
SBN Starting a sub-routine .......................................................... 3-34
RET Ending a sub-routine ............................................................ 3-34
FOR Starting a repeat .................................................................. 3-38
NEXT Ending a repeat block .......................................................... 3-38
BREAK Forcibly ending a repeat ...................................................... 3-38

Chapter 4 ARITHMETIC OPERATION INSTRUCTIONS

4-1 Data Move Instructions ............................................................ 4-2


Data Move Instruction List .................................................................... 4-2
DW Moving data ........................................................................... 4-4
LDA Moving data to internal registers from a move source ........... 4-6
STA Moving data from internal registers to a move destination .... 4-8
TMIN Moving 32-bit digital trimmer values to internal registers ..... 4-12
MOV Moving data from a move source to a move destination ..... 4-14
BMOV Moving blocks from a move source to a move destination .. 4-18
FMOV Batch-moving from a move source to a move destination ... 4-20
4-2 Arithmetic/Comparison Instructions .................................... 4-24
Arithmetic/Comparison Instruction List ............................................... 4-24
ADD Adding 16/32 binary data ..................................................... 4-28
SUB Subtracting 16/32 binary data .............................................. 4-32
MUL Multiplying 16/32 binary data ............................................... 4-36
DIV Dividing 16/32 binary data ................................................... 4-40
INC Incrementing target device values by 1 ............................... 4-44
DEC Decrementing target device values by 1 .............................. 4-48
ROOT Calculating the square root .................................................. 4-52
CMP Comparing data ................................................................... 4-54
ZCMP Comparing zones ................................................................. 4-58
4-3 Logical Arithmetic Operation Instructions ........................... 4-62
Logical Arithmetic Operation Instruction List....................................... 4-62
ANDA Performing logical operations on internal registers and
logical AND data .................................................................. 4-64
ORA Performing logical operations on internal registers and
logical OR data .................................................................... 4-66
EORA Performing logical operations on internal registers and
exclusive OR data ................................................................ 4-68
COM Inverting bits ........................................................................ 4-70
NEG Inverting signs ...................................................................... 4-72

viii
4-4 Data Shift Instructions ........................................................... 4-74
Data Shift Instruction List .................................................................... 4-74
SRA Shifting internal registers to the right ................................... 4-76
SLA Shifting internal registers to the left ..................................... 4-78
RRA Rotating internal registers to the right .................................. 4-80
RLA Rotating internal registers to the left .................................... 4-82
WSR Shifting word data to the right .............................................. 4-84
WSL Shifting word data to the left ................................................ 4-86
4-5 Data Conversion Instructions ............................................... 4-88
Data Conversion Instruction List ......................................................... 4-88
TBCD Converting binary to BCD data ............................................ 4-90
TBIN Converting BCD data to binary ............................................ 4-92
MPX Decoding 4 bits to 16 bits .................................................... 4-94
DMX Encoding 4 bits to 16 bits ..................................................... 4-94
GRY Converting binary to gray code ............................................ 4-96
RGRY Converting gray code to binary ............................................ 4-98
DISN Dispersing words (16 bits) to nibbles (4 bits) ..................... 4-100
UNIN Uniting nibbles (4 bits) to words (16 bits) ........................... 4-102
DISB Dispersing words (16 bits) to bytes (8 bits) ........................ 4-104
UNIB Uniting bytes (8 bits) to words (16 bits) ............................. 4-106
SWAP Swapping upper and lower data ........................................ 4-108
XCH Exchanging data ................................................................ 4-110
4-6 Floating Point Instructions .................................................. 4-112
Floating Point Instruction List ............................................................ 4-112
FLOAT Converting binary to a floating point real number .............. 4-114
INTG Converting a floating point real number to binary .............. 4-116
DW.F Moving data ....................................................................... 4-120
LDA.F Moving data to internal registers from a move source ....... 4-122
STA.F Moving data from internal registers to a move destination ... 4-124
MOV.F Moving data from a move source to a move destination ... 4-126
FMOV.F Batch-moving from a move source to a move destination ... 4-128
DISF Dispersing floating point real number into
mantissa/exponent ............................................................. 4-130
UNIF Uniting mantissa/exponent to a floating point real number .. 4-132
ADD.F Adding floating point real number values ........................... 4-134
SUB.F Subtracting floating point real number values ...................... 4-136
MUL.F Multiplying floating point real number values ....................... 4-138
DIV.F Dividing floating point real number values ......................... 4-140
ROOT.F Calculating the square root of floating point real number
values ................................................................................ 4-142
CMP.F Comparing floating point real number values ...................... 4-144
ZCMP.F Comparing a range of floating point real number values ... 4-146
EXP Calculating the exponent ................................................... 4-148
LOG Calculating logarithms ....................................................... 4-150
RAD Converting degrees to radians ........................................... 4-152
DEG Converting radians to degrees ........................................... 4-154
SIN Calculating the sine (sin) value from angles in radians ..... 4-156
COS Calculating the cosine (cos) value from angles in radians ... 4-158
TAN Calculating the tangent (tan) value from angles in radians .. 4-160
ASIN Calculating the angle in radians from the sine (sin) value .... 4-162
ACOS Calculating the angle in radians from the cosine (cos) value 4-164
ATAN Calculating the angle in radians from the tangent (tan) value 4-166

ix
4-7 Text Processing Instructions .............................................. 4-168
Text Processing Instruction List ........................................................ 4-168
ASC Converting binary to Hex ASCII code ................................ 4-170
RASC Converting Hex ASCII code to binary ................................ 4-172
DASC Converting binary to decimal ASCII code .......................... 4-174
RDASC Converting decimal ASCII code to binary .......................... 4-178
SMOV Moving text strings ............................................................. 4-182
SADD Adding text strings ............................................................. 4-184
SCMP Comparing text strings ....................................................... 4-186
DISS Dispersing text strings (byte units) to text strings (word units)4-188
UNIS Uniting text strings (word units) to text strings (byte units) ... 4-190
LEN Measuring the length of text strings ................................... 4-192
RCOM Reading text strings ........................................................... 4-194

Chapter 5 EXTENDED INSTRUCTIONS

5-1 Data Processing Instructions .................................................. 5-2


Data Processing Instruction List ........................................................... 5-2
HKEY Inputting Hex key data ........................................................... 5-4
BCNT Counting the number of bits currently ON in internal registers . 5-6
DCNT Counting the number of data items the same as internal
registers in a data block ......................................................... 5-8
SER Searching for a device No. for data the same as internal
registers in a data block ....................................................... 5-10
MAX Searching the maximum value in a data block ...................... 5-12
MIN Searching the minimum value in a data block ....................... 5-16
AVG Searching the average value in a data block ......................... 5-20
ZRES Resetting a specified range ................................................. 5-24
FIFOW Writing FIFO data ................................................................ 5-26
FIFOR Reading FIFO data .............................................................. 5-28
EXT Expanding 16-bit internal registers to 32-bit internal registers 5-32
5-2 Clock Processing Instructions .............................................. 5-36
Clock Processing Instruction List ........................................................ 5-36
WTIME Writing time data to the calendar timer ................................ 5-38
SEC Converting date/time format data to seconds format ........... 5-40
RSEC Converting seconds format data to date/time format ........... 5-42
AJST Adjusting the calendar timer by (30 seconds) ........................ 5-44
5-3 Alarm Instruction .................................................................... 5-46
Alarm Instruction List .......................................................................... 5-46
ARES Clearing the alarm relays/alarm log ..................................... 5-48
5-4 High-speed Processing Instructions .................................... 5-50
High-speed Processing Instruction List ............................................... 5-50
HSP Setting the input time constant to 10 µs .............................. 5-52
DI Disabling interrupts .............................................................. 5-54
EI Enabling interrupts ............................................................... 5-54
INT Executing interrupts ............................................................. 5-56
RETI Ending interrupts .................................................................. 5-56
CTH 32-bit high-speed counters .................................................. 5-68
CTC 32-bit high-speed comparator counters ............................... 5-68
5-5 Positioning Instructions ........................................................ 5-88
Positioning Instruction List .................................................................. 5-88
PLSX Starting X-axis positioning operation ................................... 5-90

x
PLSY Starting Y-axis positioning operation ................................... 5-90
JOGX X-axis jog operation ............................................................. 5-92
JOGY Y-axis jog operation ............................................................. 5-92
ORGX X-axis zero return ................................................................ 5-94
ORGY Y-axis zero return ................................................................ 5-94
TCHX Teaching X-axis operations ................................................. 5-98
TCHY Teaching Y-axis operations ................................................. 5-98

Appendices

1 About Storage of Arithmetic Operations


(Internal Registers/Temporary Memory) ................................ A-2
List of Internal Register/Temporary Data Memory Storage States .......... A-2
2 Error No. Tables........................................................................ A-8
3 Operation Processing Times List ......................................... A-11
Basic Instructions ................................................................................ A-11
Applied Instructions............................................................................. A-12
Arithmetic Operation Instructions ........................................................ A-12
Extended Instructions ......................................................................... A-14
4 Differences Between KV-300 & Visual KV Series ............... A-16
Differences in Instructions ................................................................... A-16
Changes in ITVL Instruction................................................................ A-17
5 Text Code Table ...................................................................... A-18
ASCII Code Table ............................................................................... A-18
6 Special Device List ................................................................. A-19
Control Relay CR ................................................................................ A-19
Control Memory CM ............................................................................ A-24
7 Index ........................................................................................ A-31
8 Instruction Index..................................................................... A-33

xi
Conventions Used In This Manual
Indicates the instruction and a 2-1 Contact Instructions Treats a device as a NO contact, and connects it serially to
AND AND
a circuit.
brief description of processing
by that instruction. ANB AND bar Treats a device as an NC contact, and connects it serially to
a circuit.

BASIC INSTRUCTIONS
Ladder program Input method
S
A N D S
A S
Indicates the basic format of X S
Marked with if the device is
S
an instruction by a ladder A N B S indirectly specified
diagram and coding list. B S

2 L
L
D
D N
I
O T
S
S
A N I S
Contact Instructions A N D N O T S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Indicates devices that can be Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM
CR
2009
CR
2010
CR
2011
CR
2012 Marked with if the operation
— — — — — — — — — — — — —
used in operands in the form S
flag changes state when an
S : Specifies the device to be connected to the circuit.
of a table. arithmetic calculation error
Explanation of Operation occurs.
Brief description of content
AND Connects the device specified by S serially to the circuit as a NO contact.
specified by the operand AND Connects the device specified by S serially to the circuit as an NC contact.

Explanation of operation
• In the ladder diagram, the device is shown in a serially connected state.
(processing) content of the
00000 00001 00500 LD 00000 instruction
AND 00001
OUT 00500

In this case, when input 00000 is ON, and (AND)00001 are ON, output 00500 turns ON.

• The number of contacts that can be serially connected in the program is not limited.

Operation flag
The operation flag does not change state.

Execution Timing Explanation of instruction


The instruction is executed at every scan.
execution condition and timing

2-6

2-1 Contact Instructions

Sample Program Explanation of instruction


BASIC INSTRUCTIONS

AND
operation (processing) using
When input relays 00000 and 00001 both are ON, output relay 00500 turns ON. When either (or both)
of input relays 00000 or 00001 is OFF, output relay 00500 turns OFF. an example
00000 00001 00500

ANB
When input relay 00000 is ON, and input relay 00001 is OFF, output relay 00500 turns ON.
Otherwise, output relay 00500 turns OFF.
2
Contact Instructions

00000 00001 00500

Note: Program the MPS and MPP instructions as a pair.


[Tip]
If these instructions are not programmed as a pair (number of programmed instructions
This describes related differ), a conversion error occurs when the program is edited on Ladder Support Software
Note:
information in more detail and
KV BUILDER, and the program cannot be executed. Describes cautions for
provides reference
LD
easily mistaken operations.
[Tip] LDB

information. • This instruction cannot be used in interrupt programs.


AND Be sure to read these.
ANB
• Care is required when programming this instruction between the STP and STE instructions, OR
and between the STG and JMP/ENDS instructions in a sub-routine program. ORB

Indicates the page or manual "Precautions when using differential execution type instructions" page 1-6 LDP

LDF

to refer to. The page or ANP

manual containing the related ANF

ORP

information is indicated here. ORF

2-7

* This page was made for the purpose of explaining page components,
and differs form an actual page.

xii
Terminology
This manual uses the following terminology excluding some instances.
Term Description
KV-700 Series Programmable Controller KV-700 Series unit made by Keyence
CPU Unit Corporation
PLC Overall term for a programmable controller system configured by
attaching respective units to the Basic Unit and the CPU Unit.
Indicates the overall system.
PC Stands for personal computer. Generally, refers to an NEC PC-
9800 Series, IBM PC and PC-AT compatible machine (DOS/V).
KV BUILDER KV BUILDER Ladder Support Software
Ladder program Program made by using the KV BUILDER Ladder Support Soft-
ware

Symbols
Menus or buttons in descriptions in this manual are expressed using the following
symbols.
Term Description
Indicates the page to refer to for supplementary explana-
tions.
About Data Annotation
# Values prefixed by "#" are expressed in decimal. Basi-
cally, all numerical values are expressed in decimal even
if they are not prefixed by "#".
$ Values prefixed by "$" are expressed in hexadecimal.
[DM00000/DM00001] When 32-bit numerical values are handled, two devices
are used. Programs are scripted using only device Nos.
(in the example on the left, DM00000) to which the lower
16 bits are stored. The example on the left indicates that
32-bit data is being handled.
Symbols used in "Instruction List" page 1-44 onwards
This indicates "(device turns ON) at the up edge of a
signal."
This indicates "for the duration that the signal is ON."
This indicates "(device turns ON) at the down edge of a
signal."

xiii
This page left intentionally blank.

xiv
1-1 Configuration of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
1

Configuration of Instructions
BRIEF EXPLANATION OF INSTRUCTIONS
This chapter provides an explanation of devices and conventions
used in instructions in this manual, and describes basic knowledge
needed in handling instructions such as how to handle data.
(Detailed explanations of instructions in Chapters 2 to 5 assume that
readers of this manual have read and fully understood this chapter.)
For description of functions that are reliant on PLC unit hardware,
refer to the KV-700 User's Manual.

1-1 Configuration of Instructions ............................................1-2

1-2 Configuration of Devices ................................................. 1-10

1-3 How Data Is Handled ........................................................ 1-20

1-4 About Suffixes .................................................................. 1-28

1-5 Configuration of Programs ..............................................1-34

1-6 Extended Ladder ...............................................................1-38

1-7 Indirect Specification ....................................................... 1-42

1-8 List of Instructions ...........................................................1-44

1-1
1-1 Configuration of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

1-1 Configuration of Instructions


This section describes the classification of instructions, conventions used for instructions in this
manual, and how to program instructions.

Classification of Instructions
181 types and 483 instructions can be used in programs run on the KV-700 CPU Unit.

1 Instruction are classified into the following types by function.


Configuration of Instructions

■ Basic instructions: 67 types, 122 instructions


These are the most basic instructions used in writing a sequence program.
These instructions are sufficient for enabling mechanical control on the same level as that of a
general-purpose relay sequence circuit. Programs can be comprised entirely of basic instruc-
tions.

■ Applied instructions: 19 types, 19 instructions


These instructions are for work progress, program control, and extended ladders, and allow you
to structurally script basic ladders.

■ Arithmetic instructions: 64 types, 294 instructions


These instructions are for executing comparisons, arithmetical calculations, logical calculations,
data move, and text processing. These instructions allow you to simply script complex arithmetic
calculation circuits.

■ Extended instructions: 31 types, 48 instructions


These instructions are for data processing, clock processing, high-speed processing, and
positioning processing.

1-2
1-1 Configuration of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Conventions Used in This Instruction Reference Manual
The KV-700 has 181 types and 483 instructions. Each of these instructions comprises an instruction
and an operand. The following shows the basic concept behind an instruction.

Instruction The 1st operand The 2nd operand The 3rd operand

Operand section

The number of operands differs according to the instruction. (The maximum number of operands
is three, and sometimes instructions do not have an operand.)
1

Configuration of Instructions
The following conventions are used in this manual for expressing instructions and operands.

■ Annotation of instructions
Instructions are each given a name according to differences in their operation. This is called an
"instruction word." For example, the instruction for moving 16-bit data is indicated as "MOV" while
the instruction for comparing two 16-bit data values is indicated as "LD=".
For details on the spelling of instructions, see "List of Instructions" ( page 1-44).

■ Annotation of operands
Targets to be referenced in execution of instructions and storage destinations for data resulting
from having executed an instruction are specified in the operand section of the instruction.
Different roles are assigned to operands depending on the order in which they are arranges, and
their annotation varies according to their differing roles.

Main Role of Operand Name Annotation in This Manual


Specification of target to be refer- Source S (in case of multiple, S1 S2 ...)
enced before execution
Specification of execution result Destination D (in case of multiple, D1 D2 ...)
store destination
Specification of numeric value for Constant n (in case of multiple, n1 n2 ...)
execution

For details on handling of numerical values, see "How Data Is Handled" ( page 1-20).

[Example] The 16-bit data move instruction "MOV" is annotated as follows. ( page 4-14)

MOV
S D MOV S D

This indicates that operands follow "reference target" and "storage destination"
in order after the MOV instruction.

Note: The relationship between the operand programming order and the role of the operand
differs according to the instruction. For details, check the respective page for the instruction
in question.

1-3
1-1 Configuration of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

About Programming of Instructions


When writing programs, script instructions using alphabet text strings as indicated in "Instruction
List" ( page 1-44). In this manual, operands are expressed as S , D and n for
convenience of explanation. However, in actual fact, program operands on devices.

Instruction Device Device Device

1 [Example] To store 16-bit data #00100 (decimal 100) to data memory DM00000 when input relay
00000 turns ON
Configuration of Instructions

Search for 16-bit move instruction "MOV" from the "Instruction List", and check the
page that gives the required explanation. Open the manual ( page 4-14) that
explains the MOV instruction, and refer to the format of the instruction and the devices
that can be used for the operand. The following kind of explanation will be given there.

Ladder Input method


Execution condition MOV
S D M O V S D

Execution condition MOV


S D @ M O V S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — * * — — — —
D — — — — * * —
S : Specifies the source data to be moved or the leading device to which that data is currently stored.

D : Specifies the device (move destination) to which the data is to be stored.


* When device T and C is specified, the current value becomes the move source (or move destination).

You should be able to see that to store 16-bit data #00100 to DM00000, #00100 should
be specified to S and DM00000 should be specified to D . For this reason, script
the program as follows:

00000 MOV
#00100 DM00000

The explanation also says that S can be specified by "the source data to move or
the device that stores this data." So, you can also script the program as follows:

00000 MOV
TM000 DM00000

In this case, the value currently stored to temporary data memory TM000 is move to
data memory DM00000.

1-4
1-1 Configuration of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Differences in Annotation According to Instruction Execution Type
There are two types of instructions, "every scan execution type" and "differential execution type
(pulse execution type)." With the "every scan execution type," the instruction is executed at every
scan for the duration that the execution condition is satisfied (ON). With the "differential execution
type," the execution is executed only once at the up edge when the execution condition turns ON
or at the down edge when the execution condition turns OFF.

Instructions prefixed with @ are executed as differential execution type instructions.


* There are some instructions that are not differential execution type instructions or are only
1
differential execution type instructions.

Configuration of Instructions
About Every Scan Execution Type and Differential Execution Type
■ Every scan execution type
These instructions are executed at each scan for the duration that the execution condition is
satisfied (ON).

Scan
ON
Execution Execution condition 1 scan
condition OFF
Instruction
Instruction Unprocessed Execution Unprocessed Execution Unprocessed

■ Differential execution type


These instructions are executed for one scan only at the up edge or down edge of the execution
condition.

Scan
ON
Execution 1 scan
Execution condition
condition OFF
Instruction
Instruction Unprocessed Unprocessed Unprocessed
Executed only once Executed only once

■ Conditions for detection of execution condition up edge/down edge


Differential execution type instructions compare the previous value of the execution condition
with its current value, and detects a change in state from OFF to ON as a up edge. A change in
state from ON to OFF is detected as a down edge.

ON ON ON ON OFF OFF OFF ON ON ON OFF OFF OFF ON ON ON ON

(A) (B) (A) (B)


1 scan

A down edge is detected at (A) as the previous value is ON and the current value is OFF.
A up edge is detected at (B) as the previous value is OFF and the current value is ON.

1-5
1-1 Configuration of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

■ Precautions when using differential execution type instructions


(1) When a differential execution type instruction is processed between the SBN and RET
instructions (sub-routine program)
The previous value of the differential detection device (execution condition for the differential
execution type instruction) is in the state when the sub-routine program was previously executed.
Care is required when a differential execution type instruction is executed twice or more in a
single scan or when a differential execution type instruction is not executed in a scan in which
execution of the nth sub-routine program is followed by execution of the n+1th sub-routine
program.
1
Configuration of Instructions

00000 00
CALL

END

SBN
00
Differential detection device
00001 DM00000 DM00001
LDA STA

RET

ENDH

When the nth and n+1th differential execution type instruction are not executed continu-
ously

Main routine scan

Previous This time

Sub-routine nth n+1th

ON
00000
OFF

Pattern A
ON
00001 OFF ON
OFF

Pattern B
ON
00001 ON ON
OFF

In pattern A, the up edge is detected as the current value (state of input n+1th input 00001) has
changed to ON (OFF to ON) with the previous value (state of nth input 00001) ON. For this
reason, @LDA and @STA are executed.
In pattern B, the up edge is not detected as the current value (state of n+1th input 00001) also
has not changed from ON (ON to ON) with the previous value (state of nth input 00001) ON. For
this reason, @LDA and @STA are not executed.
The above kind of difference sometimes occurs even if the state of the n+1th differential detection
device is the same.

1-6
1-1 Configuration of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
When a differential execution type instruction is executed twice or more in a single scan

Main routine scan

This time

n-1th Sub-routine nth n+1th

ON
00000
OFF 1

Configuration of Instructions
ON
00001 OFF ON ON
OFF

When the states of the n-1th, nth and n+1th differential detection devices (execution conditions of
differential execution type instruction) are as follows:
n-1th: OFF
nth: ON
n+1th: ON
At the nth instruction, the up edge is detected as the current value (state of nth input 00001) has
changed to ON (OFF to ON) with the previous value (state of n-1th input 00001) OFF. For this
reason, @LDA and @STA are executed.

At the n+1th instruction, the up edge is not detected as the current value (state of n+1th input 00001)
also has not changed from ON (ON to ON) with the previous value (state of nth input 00001) ON.
For this reason, @LDA and @STA are not executed.

1-7
1-1 Configuration of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

(2) When a differential execution type instruction is used between the STP and STE
instruction
The previous value of the differential detection device (execution condition of the differential
execution type instruction) is the state when the program between the previous STP and STE
instructions is executed. If the number of times that the program between the STP and STE
instructions is taken to be n, then the previous value of the n+1th instruction becomes the nth
state.
Care is required when the program between the STP and STE instructions is not executed
continuously between the nth and n+1th instructions.
1
Configuration of Instructions

STP
00000
Derivative detection device
00001 DM00000 DM00001
LDA STA

STE

Main routine scan

Previous This time

n-1th Program between nth n+1th


STP and STE
ON
00000
OFF

Pattern A
ON
00001 OFF ON
OFF

Pattern B
ON
00001 ON ON
OFF

In pattern A, the up edge is detected as the current value (state of input n+1th input 00001) has
changed to ON (OFF to ON) with the previous value (state of nth input 00001) ON. For this
reason, @LDA and @STA are executed.

In pattern B, the up edge is not detected as the current value (state of n+1th input 00001) also
has not changed from ON (ON to ON) with the previous value (state of nth input 00001) ON. For
this reason, @LDA and @STA are not executed.

The above kind of difference sometimes occurs even if the state of the n+1th differential detection
device is the same.

1-8
1-1 Configuration of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
(3) When a differential execution type instruction is used between the STG and JMP/ENDS
instructions
The previous value of the differential detection device (execution condition of differential
execution type instruction) becomes the state of the next scan after the program in the previous
stage has ended. (The program between the STG and JMP/ENDS instructions is executed at
execution condition OFF at the next scan after the stage has ended.) If the number of times that
the program in the stage is executed (including the one scan after the stage ends) is taken to be
n, then the previous stage of the n+1th instruction becomes the nth state.
Care is required when the program in the stage is not executed continuously between the nth
and n+1th instructions. 1

Configuration of Instructions
Derivative detection device
01100 00000 01000 00500 #00030 T000
STG T000 JMP
01000

Main routine scan

Previous This time

n-1th Program in stage nth n+1th

ON
01100
OFF

Pattern A
ON
00000 OFF ON
OFF

Pattern B
ON
00000 ON ON
OFF

In pattern A, the up edge is detected as the current value (state of input n+1th input 00000) has
changed to ON (OFF to ON) with the previous value (state of nth input 00000) ON. For this
reason, input 01000 is set.

In pattern B, the up edge is not detected as the current value (state of n+1th input 00000) also
has not changed from ON (ON to ON) with the previous value (state of nth input 00000) ON. For
this reason, input 01000 remains OFF.

The above kind of difference sometimes occurs even if the state of the n+1th differential detection
device is the same.

About Suffixes
A "suffix" is attached to the end of instruction words. There are five types of suffixes.

.U .D .S .L .F

* The instruction word that supports suffixes is entered for .


* .U is omitted and not displayed in the Ladder Support Software KV-BUILDER.
All instructions not appended with a suffix are assumed to have .U omitted.
"About Suffixes" page 1-28

1-9
1-2 Configuration of Devices
OF INSTRUCTIONS
BRIEF EXPLANATION

1-2 Configuration of Devices


A "device" is an element such as the relays or timers/counters on the PLC that are used in programs.
Devices are programmed following instructions, and are used to assign data to be used by
instructions or store the result of instruction execution.

Device List

1 Device Name
Bit devices
Range Quantity Main Functions
Configuration of Devices

Input relays 00000 to 00009*1 Total of 9530 Devices for capturing ON/OFF information
01000 to 59915*2 inputs, outputs from external devices
Output relays 00500 to 00503 and internal Devices for sending ON/OFF information to
01000 to 59915*2 auxiliary relays external devices
Internal auxiliary 00504 to 00915 Devices that can be used only internally by
relays 01000 to 59915*2 the CPU
Control relays CR0000 to CR3915 640 Devices for controlling PLC function and learn-
ing states
Timers TMR (TMH, TMS, UDT) 000 Total of 512 1 ms, 10 ms, 100 ms subtraction timers
to TMR (TMH, TMS, UDT) timers and and 10 ms up-down timers
511 counters
Counters C (UDC)000 to C (UDC)511 Add counters/up-down counters
High-speed counter CTC0 to CTC3 4 High-speed counter comparators
comparators
Word devices
Data memories DM00000 to DM19999 20000 Devices that can store numerical value data
DM00000 to DM39999*3 40000*3 internally on the PLC. These devices pro-
cess in 16-bit units.
Temporary data TM000 to TM511 512 These memories have the same functions as
memories data memories, and store data during indi-
rect specifications and arithmetic operations.
Control memories CM0000 to CM3999 4000 Devices for controlling PLC function and learn-
ing states
High-speed counters CTH0 to CTH1 2 Addition counters, phase difference counters
Internal registers 1 Devices for storing data and temporary stor-
age

*1 Devices 00010 to 00415 are reserved by the system, and cannot be used.
*2 Devices 01000 to 59915 can be set freely on Unit Editor to input relays, output relays and internal auxiliary relays.
*3 When extended memory is mounted

Duplicate use of timer and counter numbers is not allowed.


Each of the devices cannot be used outside of the above ranges.
Constants Range Main Functions
# #00000 to #65535 (16-bit unsigned) Used for specifying decimal constants and
#-32678 to #32767 (16-bit signed) floating point real numbers
#0000000000 to #4294967295 (32-bit unsigned)
#-2147483648 to #2147483647 (32-bit signed)
Floating Point Real Numbers Range
$ $0000 to $FFFF (16 bits) Used for specifying hexadecimal constants
$00000000 to $FFFFFFFF (32 bits)

1-10
1-2 Configuration of Devices

OF INSTRUCTIONS
BRIEF EXPLANATION
About Bit Devices
Input relays
• Input relays are devices for capturing ON/OFF information or data on the PLC from an external
device. External devices include buttons and switches (e.g. selector switches, limit switches,
photoelectric switches).
• Device Nos. are configured as follows:

[Example] 1

Configuration of Devices
Channel No. (000 to 599) Contact No. (00 to 15)

12515
Device No. (00000 to 00009, 01000 to 59915)

Device Nos. can be programmed in the ranges 00000 to 000009 and 01000 to 59915
as described above.

• 1-bit is assigned to each input terminal for input relays. Either a NO or NC contact can be specified.
• Input relays having the same No. can be written any number of times in a single program. The
number of times that the same No. can be programmed is not limited.
• Input relay Nos. cannot be used in duplicate with output relays and internal relays.

Output relays
• Output relays are devices for sending ON/OFF instruction or results of arithmetic operation from
the PLC to an external device. External devices include solenoids, electromagnetic switches and
indicators (signal lamps, digital displays).
• Device Nos. are configured as follows:

[Example]

Channel No. (005 to 599) Contact No. (00 to 15)

12515
Device No. (00500 to 00503, 01000 to 59915)

Device Nos. can be programmed in the ranges 00500 to 00503 and 01000 to 59915
as described above.

• 1-bit is assigned to each output terminal for output relays. Either a NO or NC contact can be
specified.
• Output relays having the same No. can be written any number of times in a single program. The
number of times that the same No. can be programmed is not limited. Take care to prevent double
coils from being programmed.
• Output relay Nos. cannot be used in duplicate with input relays and internal auxiliary relays.

1-11
1-2 Configuration of Devices
OF INSTRUCTIONS
BRIEF EXPLANATION

Internal auxiliary relays


• Internal auxiliary relays are can be used only internally on the PLC. (Use output relays for
outputting outside of the PLC.)
• Device Nos. are configured as follows:

[Example]
Channel No. (005 to 599) Contact No. (00 to 15)
1
12515
Configuration of Devices

Device No. (00500 to 00503, 01000 to 59915)

Device Nos. can be programmed in the range 01000 to 59915 as described above.

• Internal auxiliary relays can be used within the range 01000 to 59915.
• Internal auxiliary relays having the same No. can be written any number of times in a single
program. The number of times that the same No. can be programmed is not limited.
• Set power interruption hold by the MEMSW instruction. ( page 3-8)
• Internal auxiliary relay Nos. cannot be used in duplicate with input relays and output relays.

[Tip]
About annotation of devices for relay units
The KV-700 allows devices for relay units to be annotated as relays based upon the unit No. in
addition to regular channel annotation of relays. When programming ladders, relay annotation
can be handled in the same way as regular channel annotation.
Unit No. Unit relay No.

005- 00010
Channel No. Contact No.

Unit No.: Unit Nos. are assigned in the order that units are connected starting from the
CPU in the manner 000, 001, 002, 003, 004 and so forth.
Unit relay No.: The number of relays occupied from 00000 are assigned as relay Nos.

[Example]

Unit No. 000 001 002 003 004


KV-U7 KV-700 KV-B16XA KV-C32XA KV-B16TA KV-C32TA

CPU 16 Imput 32 Imput 16 Output 32 Output

Unit 000 to 009 (Input)


000 to 015 000 to 115 00000 to 00115 00000 to 00115
Relay No. 00500 to 00503 (Output)

5th KV-B16XA .......................... 001-00004


17th KV-C32TA ........................ 004-00100
3rd input of KV-700 .................. 000-00002
1st output of KV-700 ................ 000-00500

1-12
1-2 Configuration of Devices

OF INSTRUCTIONS
BRIEF EXPLANATION
CR Control relays
Control relays can be used in the range CR0000 to CR3915. Control relays are special internal
auxiliary relays whose method of use is pre-determined. These are used for controlling PLC
functions, or for learning PLC states. CRs reserved for the system cannot be used.
For details, see "Control Relay/Memory List" ( page A-19).

T Timers
Timers are devices that turn ON when the value (current value) of subtraction type timers whose
operation was started by the TMR/TMH/TMS instructions matches "0" (time up), or when the value
1

Configuration of Devices
of addition/subtraction type timers whose operation was started by the UDT instruction matches the
setting value or "0". There are four types of timers: 1 ms timers, 10 ms timers, 100 ms timers, or up-
down counter timers.

■ How to program timer operation


Program timer operation by specifying the timer No. and setting value (time until time up) of the
timer to be used to the timer instruction operand.
[Example]

Device No. Setting value (0 to 4294967295)


(000 to 511)

TMR 511 #1000


Differences by timer type
Types of Timers Timer No. Assignments Setting Value (n) Time until ON
TMR (100 ms subtraction timer) n x 100ms
TMH (10 ms subtraction timer) 0 to 511 0 to 4294967295 n x 10ms
TMS (1 ms subtraction timer) n x 1ms
UDT (10 ms up-down timer) n x 10ms

For details on how to change timer current values/setting values and how to read
current values, refer to the TMR, TMH, TMS, or UDT instructions.
"TMR instruction sample program" page 2-54

■ About timer error


The following shows the timer errors:
TMR: within ±(100 ms +1 scan time)
TMH: within ±(10 ms +1 scan time)
TMS: within ±(1 ms +1 scan time)
UDT: within ±(10 ms +1 scan time)

■ Precautions when using timer instructions (TMR, TMH, TMS, UDT, ONDL, OFDL, SHOT,
FLIK)
When a timer instruction is used between the SBN and RET instructions (in a sub-routine) and
between the STP to STE instructions, program a condition (a condition where execution of the
SBN to RET instructions or the STP to STPE instructions is not stopped during measurement
of the time) where execution of the timer instruction is not stopped.
If execution stops during time measurement, and execution is restarted, the timer may not turn
ON even if the setting value is exceeded.

1-13
1-2 Configuration of Devices
OF INSTRUCTIONS
BRIEF EXPLANATION

C Counters
Counters (C) are devices that turn ON when the value (current value) of addition type counters
whose operation is started by the counter instruction becomes (counted up) the same value as the
setting value.

■ How to program counter operation


Program counter operation by specifying the counter No., setting value and count input relay of
the counter to be used to the timer instruction operand.
1 [Example]
Configuration of Devices

Device No. Setting value Count input relay


(000 to 599) (0 to 4294967295)

C 511 #01000 30000


* Two 32-bit high-speed counters are also incorporated on the CPU Unit.
See the KV-700 User's Manual.
For details on how to change counter current values/setting values and how to read current
values, refer to the C instruction. "C instruction sample program" page 2-58

■ About the maximum count speed of counters


Counting is performed only when the count input ON and OFF times are each longer than the
scan time. The following shows the equation for calculating the maximum count speed. When
a faster count speed is required, use the high-speed counter or interrupt function.

duty ratio (%) 1


Maximum count speed = x (unit: times/sec)
100 scan time (sec.)

* The ratio between the time that the signal is ON and the time that it is OFF is called the "duty
ratio."

T1 T2
T1
When T1≤T2, the duty ratio becomes x 100 (unit: %).
T1 + T2
T2
When T1>T2, the duty ratio becomes x 100 (unit: %).
T1 + T2

CTC High-speed counter comparators


High-speed counter comparators are devices that set the setting value of high-speed counters and
that turn ON when the current value of the high-speed counter matches the setting value. The setting
value can be set within the range 0 to 4294967295.
Interrupt programs can also be executed when a CTC turns ON.

1-14
1-2 Configuration of Devices

OF INSTRUCTIONS
BRIEF EXPLANATION
About Word Devices
DM Data memories
Data memories are devices for saving data to be referenced when an instruction performs an
arithmetic operation or for storing the result of an arithmetic operation.
Devices Nos. start with DM and are followed with a No. (decimal).
[Example]

Device name Device No.


1
DM06143

Configuration of Devices
Data memory Nos. can be programmed in the range DM00000 to DM199999 (or DM00000 to
DM39999 when extended memory is mounted*) as described above.
* When extended memory is mounted

• The bit width of a single device is 16 bits, and is 0 to 65535 when devices are handled as unsigned
binary data.
When devices are handled as signed binary data, the values in the range -32768 to 32767 (both
expressed in Hex $0 to $FFFF) can be handled.

DM00001

bit bit bit bit


16 8 7 0

16 bit

• Two devices can also be used and handled as 32-bit data. In the case of 32-bit data, the lower
16 bits are stored to the data memory of the specified device No., and the upper 16 bits are stored
to the data memory of following device No. When devices are handled as unsigned binary data,
values can be handled in the range 0 to 4294967295, and when devices are handled as signed
binary data, values can be handled in the range -2147483648 to 2147483647 (both expressed in
Hex $0 to $FFFFFFFF).

DM00001 DM00000

bit bit bit bit bit bit bit bit


31 24 23 16 15 8 7 0

Upper 16 bits Lower 16 bits

32 bit

When the operand of the instruction for handling 32-bit data is specified by a data memory, specify
only the device No. to which the lower 16 bits are stored.
"About Handling 32-bit Data" page 1-24

• Data stored to data memory does not change until new data is next stored to that data memory.
Data is held in the event of a power interruption.
• Temporary data memory (TM) can be used as a substitute for a data memory. Temporary data
memory can be used in the same way as data memories when there are not enough data
memories.
Note, however, that temporary data memories has specific functions, so be sure to thoroughly
read the explanation for the device before you use temporary data memories.

1-15
1-2 Configuration of Devices
OF INSTRUCTIONS
BRIEF EXPLANATION

[Tip]
About annotation of devices for data memory units
The KV-700 allows devices for data memory units to be annotated based upon the unit No. in
addition to regular annotation. When programming ladders, data memory annotation can be
handled in the same way as regular annotation.

Unit No. Device No.

1 DM005- 00010
Unit No.: Unit Nos. are assigned in the order that units are connected starting from the CPU
Configuration of Devices

in the manner 000, 001, 002, 003, 004 and so forth.


Device No.: The number of data memories occupied from 00000 are assigned.

[Example]

Unit No. 000 001 002


KV-U7 KV-700 KV-AD40 KV-DA40

CPU 22 words 18 words

Unit 00000 to 00021 00000 to 00017


Device No.

5th KV-AD40 ............................ DM001-00004


53rd KV-AD40 (unit No.3) ........ DM003-00052

CM Control memories
Control memories are assigned to CM0000 to CM3999.
Control memories are special internal registers whose method of use is pre-determined. These are
used for controlling PLC functions, or for learning PLC states. CMs reserved for the system cannot
be used.
For details, see "Control Relay/Memory List" ( page A-25).

TM Temporary data memories


Temporary data memories can be used in the same way as data memories.
Besides data memory functions, temporary data memories are used for arithmetic operations and
for indirect specification.
Values are not saved to temporary data memories when the power is turned OFF.
TM0000 to TM0003 are used for arithmetic operation instructions. When these memories are used
in combination with indirect specification and for user use, the value that is executed last is stored
on the program.
TM No. Application
TM000 Arithmetic operation (DIV, MUL, ROOT instructions), indirection specification/
TM001 user use
TM002 Arithmetic operation (DIV instruction), indirection specification/user use
TM003
TM004 to TM511 Indirect specification/user use

"DIV Instruction" page 4-40


"MUL Instruction" page 4-36
"About Indirect Specification" page 1-42

1-16
1-2 Configuration of Devices

OF INSTRUCTIONS
BRIEF EXPLANATION
CTH High-speed counters
High-speed counters are 32-bit counters for capturing short signals that cannot be captured by
regular counter instructions.
The internal clock can also be counted in addition to external inputs.
There are two response frequencies, single-phase 40 kHz and 2-phase 30 kHz, both having a duty
ratio of 50%.
For details, see "Outline of High-speed Counters" ( page 5-69).
KV-700 User's Manual
1
About Internal Registers

Configuration of Devices
Internal registers are devices for storing the result of arithmetic operations by applied instructions,
arithmetic operation instructions and extended instructions, and for temporarily storing data during
arithmetic operation.
Internal registers are made up of 32 bits, by upper 16 bits and lower 16 bits, as shown as follows.

bit bit bit bit bit bit bit bit


31 24 23 16 15 8 7 0

Upper 16 bits Lower 16 bits

16-bit internal register

32-bit internal register

Sometimes only the lower 16 bits are used, while sometimes all of the upper and lower 32 bits are
used. This depends on the instruction word.
"About Suffixes" page 1-28
The internal register of the lower 16 bits is called the "16-bit internal register." The internal register
of 32 bits made by combining the upper and lower 16 bits is called the "32-bit internal register."
The lower 16 bits of the 32-bit internal register becomes a 16-bit internal register.

Data stored to internal registers does not change until new data is next stored.
Values are not saved when the power is turned OFF.
Instructions that handle 16-bit data use only 16-bit internal registers. Instructions that handle 32-bit
data use the 32-bit internal register.

Internal registers and arithmetic operation instructions


Internal register and
Instruction of operation
Data memory Constant Timer/counter current value Relay ON/OFF
DM
Temporary data memory 00000 to 59915
TM #$ TMR, TMH, TMS
Control memory UDT, C, UDC CR0000 to CR3915
CM

LDA instruction

Internal register

LDA instruction

Data memory Timer/counter setting value Relay ON/OFF


DM
Temporary data memory 00500 to 59915
TM TMR, TMH, TMS
Control memory UDT, C, UDC CR0000 to CR3915
CM

1-17
1-2 Configuration of Devices
OF INSTRUCTIONS
BRIEF EXPLANATION

About Constants
# Decimal constant
Decimal constants are devices that indicate in decimal numerical values that are expressed by two
bit widths, 16 bits and 32 bits.
Decimal constants are annotated by a # prefix followed by the numerical value in decimal.

[Example]
1
Symbol indicating
Configuration of Devices

Hex annotation Numerical value

#06143
The following numerical values can be handled as decimal constants:
16-bit unsigned values: 0 to 65535
32-bit unsigned values: 0 to 4294967295
16-bit signed values: -32768 to 32767
32-bit signed values: -2147483648 to 2147483647

$ Hexadecimal constant
Hexadecimal constants are devices that indicate in hexadecimal numerical values that are
expressed by two bit widths, 16 bits and 32 bits.

Hexadecimal constants are annotated by a # prefix followed by the numerical value in hexadecimal.

[Example]

Symbol indicating
Hex annotation Numerical value

$1AF 7
The following numerical values can be handled as hexadecimal constants:
16 bits: $0000 to $FFFF
32 bits: $00000000 to $FFFFFFFF

1-18
1-2 Configuration of Devices

OF INSTRUCTIONS
BRIEF EXPLANATION
■ Changes in numerical values when maximum and minimum values are exceeded
Numerical values change as follows when the result of arithmetic operation exceeds the
maximum/minimum value range in which 16/32-bit signed/unsigned data can be handled.

In the case of 16-bit binary data


Change in value when 65535 is exceeded. Change in value when maximum/minimum
value is exceeded.

Unsigned binary
(Decimal annotation)
HEX
(Hex annotation)
Signed binary
(Decimal annotation)
HEX
(Hex annotation)
1

Configuration of Devices
3 0003 3 0003
2 0002 2 0002
Overflow 1 Overflow 0001 1 0001
0 0000 0 0000
65535 FFFF -1 FFFF
65534 FFFE -2 FFFE
Underflow Underflow FFFD -3 FFFD
65533
65532 FFFC -4 FFFC

...
...
...

32771 ...
8003 -32765 8003
32770 8002 -32766 8002
Overflow Overflow
32770 8001 -32767 8001
32768 8000 -32768 8000
32767 7FFF 32767 7FFF
32766 7FFE Underflow 32766 Underflow 7FFE
32765 7FFD 32765 7FFD
32764 7FFC 32764 7FFC
32763 7FFB 32763 7FFB

In the case of 32-bit binary data


Change in value when 4294967295 is exceeded. Change in value when maximum/minimum
value is exceeded.

Unsigned binary HEX Signed binary HEX


(Decimal annotation) (Hex annotation) (Decimal annotation) (Hex annotation)
3 00000003 3 00000003
2 00000002 2 00000002
Overflow Overflow
1 00000001 1 00000001
0 00000000 0 00000000
4294967295 FFFFFFFF -1 FFFFFFFF
4294967294 FFFFFFFE -2 FFFFFFFE
Underflow 4294967293 Underflow FFFFFFFD -3 FFFFFFFD
4294967292 FFFFFFFC -4 FFFFFFFC
...

...
...

...

2147483651 80000003 -2147483645 80000003


2147483650 80000002 Overflow -2147483646 Overflow 80000002
2147483649 80000001 -2147483647 80000001
2147483648 80000000 -2147483648 80000000
2147483647 7FFFFFFF 2147483647 7FFFFFFF
2147483646 7FFFFFFE 2147483646 7FFFFFFE
7FFFFFFD Underflow 2147483645 Underflow 7FFFFFFD
2147483645
2147483644 7FFFFFFC 2147483644 7FFFFFFC
2147483643 7FFFFFFB 2147483643 7FFFFFFB

Numerical values exceeding the maximum value that can be handled is called an "overflow,"
while numerical values falling below the minimum value that can be handled is called an
"underflow."

1-19
1-3 How Data Is Handled
OF INSTRUCTIONS
BRIEF EXPLANATION

1-3 How Data Is Handled


Four types of numerical values can be handled in programs: decimal (unsigned binary/signed
binary), hexadecimal, binary, and binary coded decimal.

About Numerical Values and Text


The following shows how these four numerical value types (decimal (unsigned binary/signed binary),
hexadecimal, binary, and binary coded decimal) are expressed.
1 Note that binary coded decimal numbers differ from decimal and hexadecimal in that decimal digits are
How Data Is Handled

expressed by binary digits.

■ 16 bits

Decimal Binary Coded


Unsigned Signed Hex Binary Decimal Binary
Binary Binary (BCD)
0 0 0 0000 0000 0000 0000 0000 0000 0000 0000 0000
1 1 1 0000 0000 0000 0001 0001 0000 0000 0000 0001
2 2 2 0000 0000 0000 0010 0002 0000 0000 0000 0010
3 3 3 0000 0000 0000 0011 0003 0000 0000 0000 0011
4 4 4 0000 0000 0000 0100 0004 0000 0000 0000 0100
5 5 5 0000 0000 0000 0101 0005 0000 0000 0000 0101
6 6 6 0000 0000 0000 0110 0006 0000 0000 0000 0110
7 7 7 0000 0000 0000 0111 0007 0000 0000 0000 0111
8 8 8 0000 0000 0000 1000 0008 0000 0000 0000 1000
9 9 9 0000 0000 0000 1001 0009 0000 0000 0000 1001
10 10 A 0000 0000 0000 1010 0010 0000 0000 0001 0000
11 11 B 0000 0000 0000 1011 0011 0000 0000 0001 0001
12 12 C 0000 0000 0000 1100 0012 0000 0000 0001 0010
13 13 D 0000 0000 0000 1101 0013 0000 0000 0001 0011
14 14 E 0000 0000 0000 1110 0014 0000 0000 0001 0100
15 15 F 0000 0000 0000 1111 0015 0000 0000 0001 0101
16 16 10 0000 0000 0001 0000 0016 0000 0000 0001 0110
: : : : : : : : : : : :
99 99 63 0000 0000 0011 1111 0099 0000 0000 1001 1001
100 100 64 0000 0000 0100 0000 0100 0000 0001 0000 0000
: : : : : : : : : : : :
32767 32767 7FFF 0111 1111 1111 1111 0999 0000 1001 1001 1001
32768 -32768 8000 1000 0000 0000 0000 1000 0001 0000 0000 0000
: : : : : : : : : : : :
65534 -2 FFFE 1111 1111 1111 1110 9998 1001 1001 1001 1000
65535 -1 FFFF 1111 1111 1111 1111 9999 1001 1001 1001 1001

1-20
1-3 How Data Is Handled

OF INSTRUCTIONS
BRIEF EXPLANATION
■ 32 bits

Decimal
Hex Binary
Unsigned Binary Signed Binary
0 0 0 0000 0000 0000 0000 0000 0000 0000 0000
1 1 1 0000 0000 0000 0000 0000 0000 0000 0001
2 2 2 0000 0000 0000 0000 0000 0000 0000 0010
3 3 3 0000 0000 0000 0000 0000 0000 0000 0011
4 4 4 0000 0000 0000 0000 0000 0000 0000 0100
5
6
5
6
5
6
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0101
0110
1

How Data Is Handled


7 7 7 0000 0000 0000 0000 0000 0000 0000 0111
8 8 8 0000 0000 0000 0000 0000 0000 0000 1000
9 9 9 0000 0000 0000 0000 0000 0000 0000 1001
10 10 A 0000 0000 0000 0000 0000 0000 0000 1010
11 11 B 0000 0000 0000 0000 0000 0000 0000 1011
12 12 C 0000 0000 0000 0000 0000 0000 0000 1100
13 13 D 0000 0000 0000 0000 0000 0000 0000 1101
14 14 E 0000 0000 0000 0000 0000 0000 0000 1110
15 15 F 0000 0000 0000 0000 0000 0000 0000 1111
16 16 10 0000 0000 0000 0000 0000 0000 0001 0000
: : : : : : : : : : :
99 99 63 0000 0000 0000 0000 0000 0000 0011 1111
100 100 64 0000 0000 0000 0000 0000 0000 0100 0000
: : : : : : : : : : :
2147483647 2147483647 7FFFFFFF 0111 1111 1111 1111 1111 1111 1111 1111
2147483648 –2147483648 80000000 1000 0000 0000 0000 0000 0000 0000 0000
: : : : : : : : : : :
4294967294 –2 FFFFFFFE 1111 1111 1111 1111 1111 1111 1111 1110
4294967295 –1 FFFFFFFF 1111 1111 1111 1111 1111 1111 1111 1111

Binary Coded Decimal (BCD) Binary


00000000 0000 0000 0000 0000 0000 0000 0000 0000
00000001 0000 0000 0000 0000 0000 0000 0000 0001
00000002 0000 0000 0000 0000 0000 0000 0000 0010
00000003 0000 0000 0000 0000 0000 0000 0000 0011
00000004 0000 0000 0000 0000 0000 0000 0000 0100
00000005 0000 0000 0000 0000 0000 0000 0000 0101
00000006 0000 0000 0000 0000 0000 0000 0000 0110
00000007 0000 0000 0000 0000 0000 0000 0000 0111
00000008 0000 0000 0000 0000 0000 0000 0000 1000
00000009 0000 0000 0000 0000 0000 0000 0000 1001
00000010 0000 0000 0000 0000 0000 0000 0001 0000
00000011 0000 0000 0000 0000 0000 0000 0001 0001
00000012 0000 0000 0000 0000 0000 0000 0001 0010
00000013 0000 0000 0000 0000 0000 0000 0001 0011
00000014 0000 0000 0000 0000 0000 0000 0001 0100
00000015 0000 0000 0000 0000 0000 0000 0001 0101
00000016 0000 0000 0000 0000 0000 0000 0001 0110
: : : : : : : : :
00000099 0000 0000 0000 0000 0000 0000 1001 1001
00000100 0000 0000 0000 0000 0000 0001 0000 0000
: : : : : : : : :
00000999 0000 0000 0000 0000 0000 1001 1001 1001
00001000 1000 0000 0000 0000 0001 0000 0000 0000
: : : : : : : : :
99999998 1001 1001 1001 1001 1001 1001 1001 1000
99999999 1001 1001 1001 1001 1001 1001 1001 1001

1-21
1-3 How Data Is Handled
OF INSTRUCTIONS
BRIEF EXPLANATION

BIN Binary
Binary numbers are expressed by 0 and 1 only. When each binary digit exceeds 1, it is carried out
to the next digit.

MSB
bit bit bit bit
15 8 7 0

1 2
15
2
14
2
13
2
12
2
11
2
10
2
9
2
8
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
Bit weighting
=

=
How Data Is Handled

32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1 Decimal value

Decimal (unsigned binary)


Decimal numbers (unsigned binary) are value obtained by converting binary to decimal.
Binary numbers are expressed in the range 0 to 65535 in the case of 16 bits and in the range 0 to
4294967295 in the case of 32 bits.

Decimal (signed binary)


Decimal numbers (signed binary) are value obtained by converting binary to decimal. The plus/
minus sign is judged by the MSB.
Binary numbers are expressed in the range -32768 to +32767 in the case of 16 bits and in the range
-2147483648 to +2147483647 in the case of 32 bits.

HEX (Hexadecimal)
Hexadecimal numbers are expressed using binary four bits as one digit. As the values that can be
expressed by a single digit are 0 to 15, ABCDEF are used for values that are greater than 9. When
a digit exceeds F, it is carried out to the next digit.
The range of values that can be stored to each register is $0000 to $FFFF.

BDC (Binary Coded Decimal)


Just hexadecimal numbers, binary coded numbers are expressed using binary four bits as one digit.
and numbers are carried out to the next digit when the value exceeds 9 just like decimal numbers.
Though BCD numbers are expressed in the same way a hexadecimal, A to F are not used.
The range 0000 to 9999 can be used for 16-bit values, and the range 00000000 to 99999999 can
be used for 32-bit numbers.
bit bit bit bit
[Example] 15 8 7 0

0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1

When data is stored as shown above, ordinarily, it is stored as the value #0987 (#2439
in decimal). However, with BCD numbers, this is expressed as "0987" in decimal
annotation.

0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1
1,000's value 100's value 10's value 1's value

0 9 8 7

BCD numbers are a handy method of number representation when handling external data (e.g. from
a digital switch). Note, however, that BCD numbers are handled as binary numbers when the PLC
performs arithmetic operations. When values are read from an external device, convert them to
binary numbers by the TBIN instruction, and when outputting binary numbers to an external device
(e.g. digital display), convert them to BCD by the BCD instruction.

1-22
1-3 How Data Is Handled

OF INSTRUCTIONS
BRIEF EXPLANATION
Floating point real numbers
With floating point instructions, values (n) in the following range can be handled:
–3.4E38 ≤ n ≤ –1.4E–45
n=0
1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7)

To be more precise, the precision of floating point real numbers is 32-bit single-precision, and the
number of effective digits is as follows: 1

How Data Is Handled


• Mantissa: 24 bits
• Indicator: 8 bits (2-126 to 2127)

When the result of arithmetic operations exceeds the above bit widths, an error will occur in the
result.
The size of floating point real numbers can be compared by 32-bit binary data compare instructions
(=.D <>.D >.D >=.D <.D <=.D =.L<>.L >.L >=.L <.L <=.L). Note, however, that when minus numbers
are compared with minus numbers, the size relationship is inverted.

When comparing with 16/32-bit binary data, set the same data format for the data to be compared
by the FLOAT or INTG instruction.

About Internal Annotation of Floating Point Real Numbers


With floating point real number data, values are annotated (internal annotation) by a special
bit configuration. So, try to avoid parsing the internal annotation to directly manipulate bits.

The floating point real number value is a numerical value annotated as follows:

-3
-1.234x2
Sign Mantissa section Exponent section

Sign Exponent section Mantissa section

bit bit
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Sign (1 bit) Indicator (8 bits)


0 = plus 00000000($00)= Unused
00000001($01)= -126
1 = minus 00000010($02)= -125
00000011($03)= -124
:
Mantissa (23 bits)
01111110($7E)= -1
0 to 8388607 01111111($7F)= 0
10000000($80)= 1
10000001($81)= 2

11111100($FC)= 125
11111101($FD)= 126
11111110($FE)= 127
11111111($FF)= Unused

1-23
1-3 How Data Is Handled
OF INSTRUCTIONS
BRIEF EXPLANATION

ASCII code (American national Standard Code for Information Interchange)


All text is handled as ASCII code.
ASCII codes are assigned to each individual letter. For example, "A" is $41 is ASCII code and "9"
is $39 in ASCII code.
For details on the correspondence between ASCII codes and letters, see "Appendix ASCII Code
Table" (page A-18).

1 About Handling 32-bit Data


How to program when handling 32-bit data
How Data Is Handled

When handling 32-bit data, use the .D or .L suffixes after the instruction.
When specifying a word device as the operand, specify the device to which the lower 16 bits are
stored.

[Example] Use the MOV.D instruction to store the value #200000 to data memories DM00100 and
DM00101.

MOV.D
#200000 DM00100

Unsigned 32-bit data can be handled as a value in the range 0 to 4294967295, and signed 32-bit
data can be handled as a value in the range -2147483648 to 2147483647.
"About Suffixes" page 1-28
"About Handling Bit Devices in Word Units" page 1-25

1-24
1-3 How Data Is Handled

OF INSTRUCTIONS
BRIEF EXPLANATION
About Handling Bit Devices in Word Units
Normally (that is, by a sequence instruction), bit devices are processed as 1-bit devices.

00006 30500 LD 00006 Such an instruction as this, the processing target is


one bit of input relay 00006 and one bit of output relay 30500.
OUT 30500

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0

Input relay
5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1

How Data Is Handled


Processing target

Output relay
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0

Bit devices can be processed in 16-bit or 32-bit groups by arithmetic operation instructions.

When a bit device is specified to the operand of an instruction that processes in word units, the bit
device is handled in word units starting from the specified bit device.

[Example]
MOV
30000 DM00000

30015 30000

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

bit DM0000 bit


15 0

1 1 1 1 0 0 0 011 1 1 1 0 0 0 0

MOV.D
30000 DM00000

30115 30100 30015 30000

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

bit DM0001 bit bit DM0000 bit


15 0 15 0

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

1-25
1-3 How Data Is Handled
OF INSTRUCTIONS
BRIEF EXPLANATION

When the bit device specified to the operand is not the start of the channel, the bit device is handled
as a word unit straddling the next channel.

MOV
30003 30505

30102 301ch 300ch 30003

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
1
30604 30505
How Data Is Handled

306ch 305ch

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

Note: When the operand is set on a bit device by the STA instruction, and channels are
straddled, data is not moved to the channel that the bit device straddles.

00000 00503
LDA STA

00015 00000

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

16-bit internal register


00602 00600 00503

? ? ? 1 0 0 0 0 1 1 1 1 0 0 0 0

00601 00515

* 00600 to 00602 is not moved. The value before execution of the instruction is held in
00600 to 00602.
"STA Instruction" page 4-8

1-26
1-3 How Data Is Handled

OF INSTRUCTIONS
BRIEF EXPLANATION
This page left intentionally blank.

How Data Is Handled

1-27
1-4 About Suffixes
OF INSTRUCTIONS
BRIEF EXPLANATION

1-4 About Suffixes


With instructions appended with the symbol ".U .S .D .L .F" called a "suffix," the type of data that can
be handled varies according to the difference in the suffix. The following data types can be handled:
"16-bit unsigned binary data," "16-bit signed binary data," "32-bit unsigned binary data," "32-bit
signed binary data," and "floating point real numbers."

What Is a "Suffix?"
1 A "suffix" is attached to the end of instruction words. There are five types of suffixes as follows.
About Suffixes

.U .S .D .L .F
* The instruction word that supports suffixes is entered for .

[Example] ADD(.U) MOV.(U)


ADD.S MOV.S
ADD.D MOV.D
ADD.L MOV.L
ADD.F MOV.F

Data memory and internal register values are handled as follows according to the suffix.

.U Values are handled as 16-bit unsigned binary data. (0 to 65535)


.S Values are handled as 16-bit signed binary data. (–32768 to 32767)
.D Values are handled as 32-bit unsigned binary data. (0 to 4294967295)
.L Values are handled as 32-bit signed binary data. (–2147483648 to 2147483647)
.F Values are handled as floating point real number data. –3.4E38 ≤ n ≤ –1.4E–45
n=0
1.4E38 ≤ n ≤ 3.4E38
(eff. number of digits: approx. 7)

Indication of .U is omitted on Ladder Software KV BUILDER. Also, instruction without a suffix are
handled as 16-bit unsigned binary data.
Instructions with suffixes execute binary data in decimal annotation values corresponding to the
suffix.
Accordingly, the result of instruction execution may differ depending on differences in the suffix even
if the binary data is the same.

Differences between .U and .S


When the suffix is " .U", binary data is handled as 16-bit unsigned data.
When the suffix is " .S", binary data is handled as 16-bit signed data.
For details on constants, see "1-3 How Data Is Handled" ( page 1-20).

Accordingly, the relationship between binary data and decimal annotation corresponding to the
suffix is as follows.
BIN Binary 1111111111111111
.U Unsigned decimal 65535
.S Signed decimal –1

1-28
1-4 About Suffixes

OF INSTRUCTIONS
BRIEF EXPLANATION
[Example] To compare 16-bit binary data (1111111111111111) currently stored in DM00000 with
constant #00100

When the suffix is .U, the value of DM00000 becomes 65535.

DM00000
> .U LD.U> DM00000 #00100
#00100

Accordingly, DM00000 is greater than #00100, and the contact turns ON.
(65535) 1

About Suffixes
When the suffix is .S, the value of DM00000 becomes -1.

DM00000
> .S LD.S> DM00000 #00100
#00100

Accordingly, DM00000 is less than #00100, and the contact turns OFF.
(-1)

Differences between .D and .L


When the suffix is " .D", binary data is handled as 32-bit unsigned data.
When the suffix is " .L", binary data is handled as 32-bit signed data.
"1-3 How Data Is Handled" page 1-20
"About Handling 32-bit Data" page 1-24

Accordingly, the relationship between binary data and decimal annotation corresponding to the
suffix is as follows.
BIN Binary 11111111111111111111111111111111
.D Unsigned decimal 4294967295
.L Signed decimal –1

[Example] To compare 16-bit binary data (11111111111111111111111111111111) currently


stored in DM00000 and DM00001 with constant #00100

When the suffix is .D, the value of DM00000 and DM00001 becomes 4294967295.

DM00000
> .D LD.D> DM00000 #00100
#00100

Accordingly, DM00001 (upper) and DM00000 (lower) is greater than #00100, and the
contact turns ON. (4294967295)
When the suffix is .L, the value of DM00000 and DM00001 becomes -1.

DM00000
> .L LD.L> DM00000 #00100
#00100

Accordingly, DM00001 (upper) and DM00000 (lower) is smaller than #00100, and the
contact turns OFF. (-1)

1-29
1-4 About Suffixes
OF INSTRUCTIONS
BRIEF EXPLANATION

[Tip]
In the xcase of instructions that move data, the execution result is the same even if either of the
.U and .S (.D and .L) suffixes is used for the instruction.
LDA, STA, MOV etc.
The value of binary expressed in decimal has not bearing on the suffix before or after execution
of these instructions.
Only the length of the data (16 bits or 32 bits) has any bearing on the suffix.

1
[Example] In this example, the MOV instruction is used to move DM00000 to DM00010.
About Suffixes

MOV.U
DM00000 DM00010
MOV.S
DM00000 DM00010

DM00000 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

DM00010 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

In this example, the LDA and STA instructions are used to move DM00000/DM00001
to DM00010/DM00011.

DM00000 DM00010
LDA.D STA.D
DM00000 DM00010
LDA.L STA.L

DM00000 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

32-bit internal register

DM00010 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

Additional Explanation
With the .F suffix, binary data is handled as floating point real numbers. Data becomes
32-bit data. Accordingly, with the MOV, LDA and STA instructions, the result will be the
same as when .D or .L is used even if .F is used as the suffix.

MOV.F
DM00000 DM00010

* In the Ladder Support Software KV BUILDER (when a Monitor or Simulator is used), binary data
is expressed in decimal corresponding to the suffix. Accordingly, a different value may be
displayed even if the result of instruction execution is the same.

1-30
1-4 About Suffixes

OF INSTRUCTIONS
BRIEF EXPLANATION
About suffix .F
With the .F suffix, binary data is handled as floating point real number data. Data is 32-bit data.
With floating point real number data, values are annotated (internal annotation) by a special
bit configuration. So, try to avoid parsing the internal annotation to directly manipulate bits.

The floating point real number value is a numerical value annotated as follows:

-1.234x2 -3
1

About Suffixes
Sign Mantissa section Exponent section

Sign Exponent section Mantissa section

bit bit
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Sign (1 bit) Indicator (8 bits)


0 = plus 00000000($00)= unused
1 = minus 00000001($01)= -126
00000010($02)= -125
Mantissa (32 bits) 00000011($03)= -124
0 to 8388607 :
01111110($7E)= -1
01111111($7F)= 0
10000000($80)= 1
10000001($81)= 2
11111100($FC)= 125
11111101($FD)= 126
11111110($FE)= 127
11111111($FF)= unused

About data ranges


The data range that can be handled varies according to the suffix type.

.U (16-bit signed binary data) ..................................... 0 to 65535


.S (16-bit signed binary data) ................................. –32768 to 32767
.D (32-bit unsigned binary data) .................. –0000000000 to 4294967295
.L (32-bit signed binary data) ....................... –2147483648 to 2147483647
.F (floating point real number data) ......................................
–3.4E38 ≤ n ≤ –1.4E–45
n=0
1.4E38 ≤ n ≤ 3.4E38

1-31
1-4 About Suffixes
OF INSTRUCTIONS
BRIEF EXPLANATION

[Tip]
Numerical values are converted on KV BUILDER according to the suffix.

Input Display

#65535
L D A ( . U ) # 6 5 5 3 5 LDA

–1
L D A . S # 6 5 5 3 5 LDA.S
1 –1
About Suffixes

L D A . S # – 1 LDA.S

#65535
L D A ( . U ) # – 1 LDA

#4294967295
L D A . D # 4 2 9 4 9 6 7 2 9 5 LDA.D

–1
L D A . L # 4 2 9 4 9 6 7 2 9 5 LDA.L

–1
L D A . L # – 1 LDA.L

#4294967295
L D A . D # – 1 LDA.D

1-32
1-4 About Suffixes

OF INSTRUCTIONS
BRIEF EXPLANATION
This page left intentionally blank.

About Suffixes

1-33
1-5 Configuration of Programs
OF INSTRUCTIONS
BRIEF EXPLANATION

1-5 Configuration of Programs


On the KV-700, the entire program from step 0 to the ENDH instruction is called a "sequence
program," and the main routine program, sub-routine program, and interrupt program are scripted
in that sequence program.

About Sequence Programs


The entire program from the start of the program (step 0) up to the ENDH instruction is called the
1 "sequence program."
Configuration of Programs

Step 0

Sequence program

ENDH

■ Main routine program


The entire program from the start of the program up to the END instruction is called the "main
routine program."
If a sub-routine program or interrupt program (explained later) is not scripted in the main routine
program, the ENDH instruction that indicates the end of the sequence program is written
immediately after the END instruction.

Step 0

Main routine program


Sequence program

END

ENDH

The main routine program is executed at each scan. Be sure to program the main routine program
in a sequence program.
If the main routine program is not written in the sequence program, sub-routine programs or
interrupt programs also cannot written.

1-34
1-5 Configuration of Programs

OF INSTRUCTIONS
BRIEF EXPLANATION
■ Sub-routine program
The sub-routine program is executed by the CALL instruction from within the main routine
program. Sub-routine programs are used to execute the same processing at multiple locations
within the main routine program. Sub-routine programs can also hold programs to be executed
only when preset conditions are satisfied. In this case, write such programs in the sub-routine
program and execute the sub-routine program whenever it is necessary.
"CALL Instruction/SBN Instruction" page 3-34

Program sub-routine programs in steps between the END and ENDH instructions. 1

Configuration of Programs
Step 0

Main routine program

END
Sequence program
SBN00

RET
SBN01 Sub-routine program
RET
ENDH

Sub-routine programs can also be programmed with interrupt programs (explained later) if they
are programmed between the END and ENDH instructions.

Step 0

Main routine program

END
Sequence program
SBN00 RET Sub-routine program
INT000 RETI Interrupt routine program

SBN01 RET Sub-routine program


INT001 RETI Interrupt routine program

ENDH

Specify the SBN instruction after the END instruction for the start of the sub-routine program. At
the final step of the sub-routine program, program the RET (return to step following called CALL
instruction) instruction.

Though up to 99 programs can be programmed in a single sequence program, sub-routine


programs having the same No. cannot be programmed. Note, however, the same sub-routine
program can be called from multiple steps in the main routine program by the CALL instruction.

Note: To be precise, the sub-routine program is executed when the CALL instruction execution
condition turns ON. Sub-routine programs can also be called (nested) from within sub-
routine programs. Note, however, that sub-routine programs can be programmed only
down to a nesting level of four.
"CALL Instruction/SBN Instruction" page 3-34

1-35
1-5 Configuration of Programs
OF INSTRUCTIONS
BRIEF EXPLANATION

■ Interrupt program
The interrupt program is executed when an interrupt cause set by the INT instruction is
generated.
"INT Instruction" page 5-56

Note: To execute an interrupt program, set execution of the interrupt program to "enabled" by the
EI instruction in the main routine program. The default setting when the program is started
up is "disabled."
1
Configuration of Programs

Program interrupt programs in steps between the END and ENDH instructions.

Step 0

Main routine program

END
Sequence program
INT000

RETI
INT001 Interrupt program
RETI
ENDH

Interrupt programs can also be programmed with sub-routine programs (explained earlier) if they
are programmed between the END and ENDH instructions.

Step 0

Main routine program

END
Sequence program
SBN00 RET Sub-routine program
INT000 RETI Interrupt program

SBN01 RET Sub-routine program


INT001 RETI Interrupt program

ENDH

Program interrupt programs by specifying the INT instruction after the END instruction.
At the final step of the interrupt program, program the RETI (return to step before interrupt)
instruction.
Though up to eight interrupt programs can be programmed in a single sequence program,
multiple interrupt programs that use the same interrupt cause cannot be programmed.

1-36
1-5 Configuration of Programs

OF INSTRUCTIONS
BRIEF EXPLANATION
■ Precautions relating to execution of interrupt programs
• To execute an interrupt program, set execution of the interrupt program to "enabled" by the EI
instruction in the main routine program. The default setting when the program is started up is
"disabled." When the interrupt program is executing, the interrupt program enters an interrupt
"disabled" state. To set interrupt to "enabled" during execution of the interrupt program,
program the EI instruction into the interrupt program.

• Interrupt programs for interrupt causes that occur before the EI instruction is executed are
executed after interrupt is enabled by the EI instruction. Interrupt causes that are generated
before execution of the EI instruction are stored to memory. 1

Configuration of Programs
• When two or more interrupt causes are stored to memory, program execution starts with the
program for the interrupt cause having the highest priority.

High Interrupt processing priority Low

INT00000>INT00001>INT00002>INT00003>INT CTC2>INT CTC3>INT CTC0>INT CTC1

• When an interrupt cause is generated, execution of instructions in the main routine program
is discontinued even during instruction execution.

• When the PLC is operating in the constant scan mode, the corresponding interrupt program
is executed even if an interrupt cause is generated during the wait time in END processing.
"About the interrupt function" page 5-57

1-37
1-6 Extended Ladder
OF INSTRUCTIONS
BRIEF EXPLANATION

1-6 Extended Ladder


This section describes the extended ladder language exclusive to Keyence.

Features of the Extended Ladder Language


"Extended ladder" is a programming system that was especially developed for the purpose of
reducing the number of man-hours used in program design, testing, operation, and maintenance.

1 With conventional ladder languages, output instructions could be written only at the right side of the
ladder program. However, with extended ladder language, it can be written at all position except the
Extended Ladder

left edge, thus enabling programs such as the one shown below to be written.

Mixing of input/output circuits

(conventional ladder language) (extended ladder language)

Only input circuit Only output Only input Input/output Only output
can be written. circuit can circuit can be circuits can circuit can be
be written. incorporated. be mixed. incorporated.

Multiple instructions connected on a single rung

(conventional ladder language) (extended ladder language)

Instructions that can be written on a single


rung of the ladder extend from left to right. Many instructions can be connected.

Branches from output coils

(conventional ladder language) (extended ladder language)

Branches can be input only from input contacts. Branches can also be input from output coils.

3 rungs in ladder diagram

Number of rungs in ladder program can be


seen in a single rung.

MOV
Note: Box type instructions ( ) cannot be programmed in extended ladders.

1-38
1-6 Extended Ladder

OF INSTRUCTIONS
BRIEF EXPLANATION
Advantages of the Extended Ladder Language
Fewer ladder rungs
Input and output instructions can be mixed and programmed next to each other, which reduces the
number of rungs in the ladder program. The content of the ladder program to be executed can also
be understood at a glance.

[Example] The content of DM0000 turns the following outputs ON as follows:


Output 00500 is turned ON when the content is #01000. 1
Output 00501 is turned ON when the content is #02000.

Extended Ladder
Output 00502 is turned ON when the content is #03000.

(conventional ladder language) (extended ladder language)

CR2002 DM00000 CR2002 DM00000 #01000 CR2010 00500


LDA LDA CMP
#01000 #02000 CR2002 00501
CMP CMP
CR2010 00500 #03000 CR2002 00502
CMP
CR2002 #02000
CMP
CR20010 00501
In conventional ladder languages, it was difficult to tell at a
glance what the program executed. With extended ladder
language, you can tell at a glance.
CR202 #03000
CMP
CR2012 00502

Clear processing order


Ladder symbols can be arranged in processing order, which makes it easier to understand the flow
of the program. This also makes program maintenance much easier.

[Example] When the Start switch is turned ON, the indicator lights for three seconds, the buzzer
sounds for two seconds, and motor operation is started.

00000 01100 01100 01000 When the start switch (00000) turns ON,
DIFU SET the indicator (00500) lights, and timer
01000 00500 #00030 T000 01001 T000 starts to operate.
STG T000 JMP
01001 00501 #00020 T001 01002 When timer T000 turns ON three sec-
STG T001 JMP onds later, the indicator goes out, the
01002 00502 00000 buzzer (00501) sounds, and timer T001
STG ENDS
starts to operate.
When timer T001 turns ON two seconds
later, sounding of the buzzer stops, and
motor (00502) operation starts.
When the start switch (00000) turns
OFF, motor operation stops and all de-
vices are reset.

1-39
1-6 Extended Ladder
OF INSTRUCTIONS
BRIEF EXPLANATION

[Example]

(conventional ladder language) (extended ladder language)

00000 01000 00000 01000 01000 01001


DIFU DIFU SET
01000 T000 #00010 01001 00500 #00030 T000 01002
T000 STG T000 JMP
01001 01001 01002 00501 #00030 T001 01003
STG T001 JMP
T002 01003 00500 00501 #00030 T002 01001

1 T000 T001 #00020


STG T002 JMP

T001
Extended Ladder

01002 01002 As shown above, the program can be made to execute


in the desired order, and even beginners new to relay
T001 T002 #00030 sequences can understand the content of processing if
T002 an extended ladder is used.
01003 01003 Double coils can also be used by combining the STG
instruction in the program.
T001 00500

01003

01002 00501

01003

1-40
1-6 Extended Ladder

OF INSTRUCTIONS
BRIEF EXPLANATION
[Example] Output 00500 is turned ON only when inputs 00000, 00001 and 00002 are input in that
order.

(conventional ladder language)

00001 01002
DIFU 01002 turns ON at the up edge of input 00001.
00002 01003
DIFU 01003 turns ON at the up edge of input 00002.
01002 00000 01000
01000 turns ON if input 00000 is in an ON state.
01000
1
01003 01000 01001

Extended Ladder
01001 turns ON if input 10000 is in an ON state.
01001

01001 00500
Output 00500 turns ON when 01001 turns ON.

(extended ladder language)

00000 00001 01000 00002 01001 00500

01000 01001

Input 0000 ON Input 0001 ON Input 0002 ON Output 0500 ON

As shown above, extended ladder language can be written on a single rung. This
makes programs easier to view and understand than conventional ladder languages.

1-41
1-7 Indirect Specification
OF INSTRUCTIONS
BRIEF EXPLANATION

1-7 Indirect Specification


Temporary data memory (TM) is used for indirectly specify data memory device Nos. and relay Nos.
on the ladder not in a fixed manner but in a variable manner.

About Indirect Specification


Indirect specification method
1 Indirect specification can be performed by programming #TMnnn to the instruction operand and
varying the value to be stored in TMnnn.
Indirect Specification

The following table shows the relationship between #TMnnn and the value currently stored to
TMnnn.

Relationship between #TMnnn and the value currently stored to TMnnn


Value Stored to TMnnn Content of Indirect Specification
0 DM00000
1 DM00001
2 DM00002
: : Indirectly specified DMs.
9997 DM09997
9998 DM09998
9999 DM09999
10000 00000
10001 00001
10002 00002
: : Indirectly specified relays.
17913 07913
17914 07914
17915 07915

The range of temporary data memories that can be used is TM000 to TM511. Note, however, that
attention should be paid to prevent duplicate use of these temporary data memories as they are also
used for arithmetic operations.

Note: Data memories DM10000 to DM39999 and relays 08000 to 59915 cannot be indirectly
specified.

Device ranges not available for indirect specification


Indirect specification is not possible when the value of the temporary data memory (TM) is greater
than 17915.
If indirect specification is performed with the value of the TM greater than 17915, control relay
CR2012 (the operation flag) will turn ON during instruction execution. At this time, the instruction will
not be executed.

1-42
1-7 Indirect Specification

OF INSTRUCTIONS
BRIEF EXPLANATION
Instructions that allow indirect specification in operands
= < > <= >- <> LDA STA
MOV FMOV ADD SUB MUL DIV CMP ZCMP
ANDA ORA EORA DASC RDASC SMOV SADD SCMP
DISS UNIS LEN RCOM XCH

[Example 1]When the value currently stored to TM004 is "20", #TM004=DM00020.


#TM004 DM00000 DM00020 DM00000
1
LDA STA = LDA STA

Indirect Specification
When the above ladder is executed, the value of DM00020 is stored to DM00000.

[Example 2]When the value currently stored to TM010 is "11000", #TM010=01000.


07000 #TM010 07000 01000
LDA STA = LDA STA

When the above ladder is executed, the values of 07000 to 07015 are stored to 01000
to 01015.

■ Example of data accumulation


In the case of 16-bit data
The value of DM00100 is stored in order from DM00000 at the up edge of input 00000.

CR2008 #00000 TM004


LDA STA 00000 : Timing input

DM00100 : Storage source data


00000 01000 01000 DM00100 #TM004 TM004
DIFU LDA STA INC #TM004 : Storage destination data

DM00100 Data DM00000 Data 1

DM00001 Data 2
DM00002 Data 3

DM00003 Data 4

DM00003 Data 5

In the case of 32-bit data


The values of DM00100 and DM00101 are stored in order from DM00000 and DM00001 at the
up edge of input 00000.

CR2008 #00000 TM004


LDA STA 00000 : Timing input

DM00100 : Storage source data


00000 01000 01000 DM00100 #TM004 TM004 #00002 TM004
DIFU LDA.D STA.D LDA ADD STA #TM004 : Storage destination data

DM00101 Data DM00100 DM00001 Data 1 DM00000

DM00003 Data 2 DM00002

DM00005 Data 3 DM00004

DM00007 Data 4 DM00006

DM00009 Data 5 DM00008

Stored data can be batch-reset by the ZRES instruction.


"ZRES instruction" page 5-24

1-43
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

1-8 List of Instructions


This section presents a list of instructions together with a brief description of its processing details.
For details, refer to the page that describes the respective instruction.
The following execution symbols are used in the list of instructions: for execution at every scan,
for execution for one scan only at a up edge, and for execution for one scan only at a down
edge.

1 Basic Instructions
List of Instructions

Specification
Object size
Execution
Condition

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Contact instructions
S Treats a device as an NO contact, and connects
LD it to the left bus line. 4 10 – 2-4

S Treats a device as an NC contact, and connects


LDB it to the left bus line. 4 10 – 2-4

S Treats a device as an NO contact, and connects


AND it serially to a circuit. 4 6 – 2-6

S Treats a device as an NC contact, and connects


ANB it serially to a circuit. 4 6 – 2-6

Treats a device as an NO contact, and connects


OR S
it in parallel to a circuit. 4 6 – 2-8

Treats a device as an NC contact, and connects


ORB S it in parallel to a circuit. 4 6 – 2-8
Contacts
S Connects a device to the left bus line as an NO
LDP contact that turns ON for one scan at its up 6 12 – 2-10
edge.

S Connects a device to the left bus line as an NO


LDF contact that turns ON for one scan at its down 6 12 – 2-10
edge.

S Connects a device serially to a circuit as an NO


ANP contact that turns ON for one scan at its up 6 10 – 2-10
edge.

S Connects a device serially to a circuit as an NO


ANF contact that turns ON for one scan at its down 6 10 – 2-10
edge.
Connects a device in parallel to a circuit as an
ORP S NO contact that turns ON for one scan at its up 6 10 – 2-10
edge.
Connects a device in parallel to a circuit as an
ORF S NO contact that turns ON for one scan at its 6 10 – 2-10
down edge.

1-44
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Category

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Mnemonic Symbol Description of Instruction
Page

Bit contact instructions


S Connects a device to the left bus line as a contact that relays the
BLD B ON/OFF states of specified bits on the device. 6 12 – 2-14
n

S Connects a device to the left bus line as a contact that inverts and
BLDB B relays the ON/OFF states of specified bits on the device. 6 12 – 2-14
n

S Connects a device serially to a circuit as a contact that relays the


ON/OFF states of specified bits on the device.
1
BAND B 6 10 – 2-14
Bit contacts

List of Instructions
n

S Connects a device serially to a circuit as a contact that inverts and


BANDB B relays the ON/OFF states of specified bits on the device. 6 10 – 2-14
n

Connects a device in parallel to a circuit as a contact that relays the


S ON/OFF states of specified bits on the device. 2-14
BOR 6 10 –
B
n
Connects a device in parallel to a circuit as a contact that inverts and
S relays the ON/OFF states of specified bits on the device. 2-14
BORB 6 10 –
B
n
Compare contact instructions
Turns ON when condition S1 = S2 is established.
.U/ .S Turns OFF when condition S1 ≠ S2 is established. 7
S1
= = 18 – 2-20
S2 Turns ON when condition [ S1 +1• S1 ]=[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ]≠[ S2 +1• S2 ] is established.

Turns ON when condition S1 < S2 is established.


.U/ .S 7
S1 Turns OFF when condition S1 > S2 is established.
< < 18 – 2-20
S2 Turns ON when condition [ S1 +1• S1 ]<[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ]≥[ S2 +1• S2 ] is established.

Turns ON when condition S1 > S2 is established.


.U/ .S 7
S1 Turns OFF when condition S1 ≤ S2 is established.
Compare contacts

> > 18 – 2-20


S2 Turns ON when condition [ S1 +1• S1 ]>[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ]≤[ S2 +1• S2 ] is established.
Turns ON when condition S1 ≠ S2 is established.
.U/ .S 7
S1 Turns OFF when condition S1 = S2 is established.
<> <> 18 – 2-20
S2 Turns ON when condition [ S1 +1• S1 ]≠[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ]=[ S2 +1• S2 ] is established.
Turns ON when condition S1 ≤ S2 is established.
.U/ .S 7
S1 Turns OFF when condition S1 > S2 is established.
<= <= 18 – 2-20
S2 Turns ON when condition [ S1 +1• S1 ]≤[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ] >[ S2 +1• S2 ] is established.
Turns ON when condition S1 ≥ S2 is established.
.U/ .S 7
S1 Turns OFF when condition S1 < S2 is established.
>= >= 18 – 2-20
S2 Turns ON when condition [ S1 +1• S1 ]≥[ S2 +1• S2 ] is established.
.D/.L 9
Turns OFF when condition [ S1 +1• S1 ]<[ S2 +1• S2 ] is established.

1-45
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Output instructions
D Outputs the previous ON/OFF state.
OUT 4 12 – 2-24

D Inverts and outputs the previous ON/OFF state.


OUB 4 12 – 2-24

1 D Turns the device ON and holds it in this state.


SET SET 4 12 – 2-26
List of Instructions

D Turns the device OFF.


RES RES 4 12 – 2-26

KEEP
Sets and resets the target relay according to SET and RES
SET inputs.
KEEP D 4 8 – 2-28
RES

D Scans the target relay once (up differential) at the up edge


DIFU DIFU of the previous state. 4 12 – 2-30
Output

D Scans the target relay once (down differential) at the down


DIFD DIFD edge of the previous state. 4 12 – 2-30

n The target relay performs ON delay operation.


ONDL ONDL 7 12 – 2-32
D

n The target relay performs OFF delay operation.


OFDL OFDL 7 12 – 2-32
D

n The target relay performs one-shot operation.


SHOT SHOT 7 26 – 2-34
D

FLIK The target relay performs operation of the flicker circuit.


FLIK n1 n2 D 10 26 – 2-36

D The target relay performs operation of the alternate circuit.


ALT ALT 4 12 – 2-38

1-46
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Bit output instructions


D Outputs the previous state to the specified bit of the reference
BOUT B word device. 6 10 – 2-44
n

D Inverts and outputs the previous state to the specified bit of


BOUB B the reference word device. 6 10 – 2-44
n
Bit
output D Turns the specified bit of the reference word device ON and 1
BSET BSET holds this state. 6 10 – 2-46

List of Instructions
n

D Turns the specified bit of the reference word device OFF.


BRES BRES 6 10 – 2-46
n

Timer/counter instructions
S Operation unit 100 ms 32-bit subtraction type ON delay timer
TMR T n 4 6 – 2-48

S Operation unit 10 ms 32-bit subtraction type ON delay timer


Timers TMH T
H n 4 6 – 2-50

S Operation unit 1 ms 32-bit subtraction type ON delay timer


TMS T
S n 4 6 – 2-52

S1 32-bit addition counter


Counter C C n 7 10 – 2-56
S2
Sets the mode, and measures the pulse intervaland DM
ITVL
.U average values. 7
PLS
Interval D1
timer ITVL PAUSE 10 – 2-60
D2
.S RES 8

Increments the current value of the counter specified by S


by 1 at the up edge of up input.
UDC n Decrements the current value of the counter specified by S
UP
by 1 at the up edge of downinput.
Up-down S
UDC DW
Counter UDC n turns ON at 1-digit 4 6 – 2-64
counter
incrementing/decrementing of the current value.
RES The current value is reset to 0 when reset input turns ON.

Operation unit 10 ms up/down timer.


The current value of the timer specified by n is
UDT D incremented by 1 every 10 ms when up input isON.
UP
Up-down The current value of the timer specified by n is
n
UDT decremented by 1 every 10 ms when up input isON. 4 6 – 2-66
timer DW
The current value is held when up and down inputs both
RES turn ON or OFF.

1-47
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Connection/end instructions
END Indicates the end of the regular program (main routine
END program). – 1 14 – 2-70

End
ENDH Indicates the end of the entire program.
ENDH – 1 0 – 2-70

1 a b c
Indicates a series connection following an output instruction.
CON – 1 0 – 2-72
List of Instructions

CON CON
MPS Stores the input state and arithmetic operation flag to memory. – 1 4 – 2-74

MRD Reads contents stored to memory by MPS. – 1 4 – 2-74

MPP Reads contents stored to memory by MPS, and clears memory. – 1 4 – 2-74
Connect Connects the contact block in series.

ANL – 1 4 – 2-76

A block B block
ANL
Connects the contact block in parallel.

A block
ORL – 1 4 – 2-76

B block
ORL

1-48
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Applied Instructions

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Shift instruction

SFT The ON/OFF state of data inputs is loaded at the up edge of


D clock input.
D1 That state is shifted from D1 to the relay specified by D2 in
Shift SFT CLK 7 14 – 3-4
sync with the clock pulse.

RES
D2 When reset input is ON, all relays from D1 to D2 turn OFF.
The state is not shifted to relays D2 +1 onwards.
1

List of Instructions
Memory switch instruction
MEMSW n Sets a memory switch.
Memory MEMSW S – 6 0 – 3-8
switch

Step instructions
STP Executes the entire program up to the STE instruction when
STP S the relay indicated by the operand is ON. 4 10 – 3-14
Step
STE This instruction is used in a pair with the STP instruction,
STE and indicates the end of the programto be executed by step – 1 0 – 3-14
operation.
Stage processing instructions
S Executes the instruction in the STG block.
STG STG 4 16 – 3-20

S Turns the relay of the currently executing stage OFF, and


JMP JMP jumps to the specified stage. 4 8 – 3-20

Ends the relay of the currently executing stage.


ENDS ENDS 1 4 – 3-20

Stage
processing S Sets D with S ON when the execution condition is ON.
W-ON ON 7 10 – 3-24
D

S Sets D with S OFF when the execution condition is ON.


W-OFF OFF 7 10 – 3-24
D

S Sets D at the up edge of S when the execution condition


W-UE is ON. 7 16 – 3-26
D

S Sets D at the down edge of S when the execution


W-DE condition is ON. 7 16 – 3-26
D

1-49
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Flow instructions
MC Sets the master control relay.
MC 1 2 – 3-30
Master
control MCR Ends the MC instruction.
MCR – 1 2 – 3-30

1 n Executes the specified No. sub-routine program.


CALL CALL 3 8 – 3-34
List of Instructions

SBN Indicates the start of the sub-routine program.


Sub- –
SBN n 3 4 – 3-34
routine

RET Ends the sub-routine program.


RET – 1 4 – 3-34

FOR Repeatedly executes the instruction sequence between the


FOR n FOR and NEXT instructions for the specified number of times 4 22 – 3-38
in a single scan.
NEXT Indicates the end of the repeat range.
Repetition
NEXT – 1 4 – 3-38

BREAK Forcibly ends repeated execution between the FOR and


BREAK NEXT instructions. 1 14 – 3-38

1-50
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Arithmetic Operation Instructions

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

* Note: Arithmetic operation instructions preceded with @ are differential execution type instructions.
S Executes the instruction only once at the up edge of the
@ *** execution condition.
D

Data move instructions


.U Writes 16-bit data. 7
1
S S → D 10

List of Instructions
.S 8
DW DW – 4-4
.D D Writes 32-bit data.
[ S • S +1]→[ D • D +1] 10 12
.L
.U Writes 16-bit data to the 16-bit internal register. 4
S S → 16-bit internal register 8
.S 5
LDA LDA STA 4-6
.D Writes 32-bit data to the 32-bit internal register.
[ S • S +1]→ 32-bit internal register 7 8
.L
.U Writes the content of the 16-bit internal register. 4
D 16-bit internal register → D 8
.S 5
STA LDA STA 4-8
.D Writes the content of the 32-bit internal register. 5
32-bit internal register →[ D • D +1] 8
.L 5
n Writes digital trimmer values to the 32-bit internal register.
TMIN TWIN STA Digital trimmer → 32-bit internal register 3 6 – 4-12

.U Moves 16-bit data. 5


S → D 8
.S MOV 10
MOV S D 4-14
.D Moves 32-bit data.
[ S • S +1]→[ D • D +1] 10 14
.L
Moves 16-bit data in blocks.
S Move D
BMOV S +1 Move D +1
BMOV S D n
n S +2 Move D +2 10 14 – 4-18

S + D –2 Move D + n –2
S + D –1 Move D + n –1

Batch moves the same 16-bit data to a specified device.


.U D 10 16 –
D +1
D +2
S n
D + n –3
.S D + n –2 11 16
D + n –1
FMOV
FMOV S D n 4-20
Batch moves the same 32-bit data to a specified device.
.D [ D • D +1] 13 16
[ D • D +1]+1
[ D • D +1]+2
[ S • S +1] n

[ D • D +1]+ n –3
.L [ D • D +1]+ n –2 13 16
[ D • D +1]+ n –1

1-51
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Arithmetic/comparison instructions (continued)


Adds 16-bit data.
.U 4 8
16-bit 16-bit
internal register + S = internal register
.S S 16 bits 16 bits 16 bits 5 8
(1 word)
ADD LDA ADD STA 4-28
Adds 32-bit data.
.D 7 8

1
Upper Lower Upper Lower
32-bit
internal register + S +1 S = 32-bit
internal register
.L 32 bits 32 bits 32 bits 7 8
(2 words)
List of Instructions

Subtracts 16-bit data.


.U 4 8
16-bit 16-bit
internal register – S = internal register
16 bits 16 bits 16 bits
.S S
(1 word) 5 8
SUB LDA SUB STA 4-32
Subtracts 32-bit data.
.D 7 8
Upper Lower Upper Lower
32-bit 32-bit
internal register – S +1 S = internal register
.L 32 bits 32 bits 32 bits 7 8
(2 words)

Multiplies 16-bit data.


32-bit internal register
.U 4 8
16-bit
internal register × S = Upper Lower
16-bit
16 bits 16 bits TM000 internal register
(1 word)
32 bits
.S * The upper 16 bits are stored to both the upper 16 bits of the 32-bit internal register
(2 words)
5 8
S and to the TM000.
MUL LDA MUL STA 4-36
Multiplies 32-bit data.
.D 7 8
Upper Lower Upper 32 bits Lower 32 bits

×
32-bit 32-bit
internal register S +1 S = TM001 TM000 internal register
32 bits 32 bits 64 bits
.L (2 words) 7 8

Divides 16-bit data. 32-bit internal register


Upper Lower
.U 4 8
TM000 16-bit
internal register ÷ S = Upper Lower
16-bit
32 bits 16 bits TM000 internal register
(2 words) (1 word)
32 bits
(2 words)
.S Remainder: TM001
16 bits
(1 word)
5 8
DIV S * The upper 16 bits of the quotient are stored to both the upper 16 bits of the 32-bit
internal register and to the TM000.
.D LDA DIV STA 4-40
Divides 32-bit data.
7 8
32-bit
TM001 TM000 internal register ÷ S +1 S
.L 64 bits 32 bits
(2 words)
32-bit
= TM001 TM000 internal register Remainder: TM003 TM002
64 bits 32 bits
(2 words)
7 8

.U Increments D by 1 and stores the result to D . 4 8


.S D 5 8
INC INC – 4-44
.D Increments [ D • D +1] by 1 and stores the result to 5 8
.L [ D • D +1]. 5 8
.U Decrements D by 1 and stores the result to D . 4 8
.S D 5 8
DEC DEC – 4-48
.D Decrements [ D • D +1] by 1 and stores the result to 5 8
.L [ D • D +1]. 5 8

1-52
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Arithmetic/comparison instructions (continued)

.U Calculates the square root of 16-bit data.


1 4
Upper Lower

.S
T000 Internal register = 16-bit internal register
32 bits 16 bits
2 4
ROOT LDA ROOT STA — 4-52
.D Calculates the square root of 32-bit data.
2 4

.L
Upper 32 bits Lower 32 bits

TM001 TM000 32-bit internal register


64 bits
=
Upper Lower

32-bit internal register


32 bits 2 4
1

List of Instructions
Compares 16-bit data.
.U Comparison Result Arithmetic Flag State 4 8
Value in 16-bit internal register is smaller than CR2009→ ON
specified range. 16-bit internal register< S 2009
Value in 16-bit internal register is within CR2010→ ON
specified range.16-bit internal register= S 2010
.S Value in 16-bit internal register is greater than CR2011→ ON 5 8
specified range. 16-bit internal register> S 2011
S Flag
CMP LDA CMP 4-54
Compares 32-bit data.
.D Comparison Result Arithmetic Flag State 7 8
Value in 32-bit internal register is smaller than CR2009→ ON
specified range.32-bit internal register<[ S • S +1] 2009
Value in 32-bit internal register is within CR2010→ ON
specified range.32-bit internal register=[ S • S +1] 2010
.L Value in 32-bit internal register is greater than CR2011→ ON 7 8
specified range.32-bit internal register>[ S • S +1] 2011

Compares 16-bit data.


.U Comparison Result (when S1 < S2 ) Arithmetic Flag State 7 14
Value in 16-bit internal register is smaller than
CR2009→ ON
specified range.16-bit internal register< S1 < S2
Value in 16-bit internal register is within
CR2010→ ON
specified range. S1 ≤16-bit internal register≤ S2
.S Value in 16-bit internal register is greater than 8 14
CR2011→ ON
specified range. S1 < S2 <16-bit internal register
S1 Flag
ZCMP LDA ZCMP 4-58
S2 Compares 32-bit data.
.D Comparison Result (when S1 • S1 +1]<[ S2 • S2 +1]) Arithmetic Flag State 12 14
Value in 32-bit internal register is smaller than specified range.
CR2009→ ON
32-bit internal register<[ S1 • S1 +1]<[ S2 • S2 +1]
Value in 32-bit internal register is within specified range.
CR2010→ ON
[ S1 • S1 +1]<32-bit internal register≤[ S2 • S2 +1]
.L Value in 32-bit internal register is greater than specified range. 12 14
CR2011→ ON
[ S1 • S1 +1]<[ S2 • S2 +1]<32-bit internal register

Logical arithmetic instructions


Calculates the logical AND of the 16-bit data.
.U S 16-bit internal register S
U 4 8
ANDA LDA ANDA STA 4-64
Calculates the logical AND of the 32-bit data.
.D 32-bit internal register [ S • S +1]
U
7 8

Calculates the logical OR of the 16-bit data.


.U S 16-bit internal register U S 4 8
ORA LDA ORA STA 4-66
Calculates the logical OR of the 32-bit data.
.D 32-bit internal register U [ S • S +1] 7 8

Calculates the exclusive logical OR of the 16-bit data.


.U S 16-bit internal register S
A 4 8
EORA LDA EORA STA 4-68
Calculates the exclusive logical OR of the 32-bit data.
.D 32-bit internal register [ S • S +1]
A 7 8

1-53
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Logical arithmetic instructions


Inverts the state of each bit of the 16-bit internal register.
.U 1 4
COM LDA COM STA – 4-70
Inverts the state of each bit of the 32-bit internal register
.D 2 4

Inverts the sign of the data in 16-bit internal register.


.U 1 4
1 NEG LDA NEG STA
Inverts the sign of the data in 32-bit internal register.
– 4-72
.D 2 4
List of Instructions

Data shift instructions


Shifts the data in the 16-bit internal register to the right by the
number of specified bits.
bit bit ( n –1) bit
15 0
16-bit
internal register 1110100000011001

.U 3 6
16-bit
internal register 0000011101000000 1100 1
Upper n bit Delete

"0" is stored. 1
n CR2009
(Carry)
SRA LDA SRA STA – 4-76
Shifts the data in the 32-bit internal register to the right by the
number of specified bits.
bit bit ( n –1) bit
31 32-bit internal register 0

11101000000 110011110 10000001100 1


.D 32-bit internal register 4 6
00000111010 000001100 11110100000 0 1100 1
Upper n bit Delete

1
"0" is stored.
CR2009
(Carry)

Shifts the data in the 16-bit internal register to the left by the
number of specified bits. bit (16— n )
bit bit
15 0
16-bit
internal register 1110100000011001

.U 3 6
16-bit
internal register 1110 100000011001 00000
Delete Upper n bit

1 "0" is stored.
n CR2009
(Carry)
SLA LDA SLA STA – 4-78
Shifts the data in the 32-bit internal register to the left by the
number of specified bits.
bit bit (32–  )
n bit
31 32-bit internal register 0

11101000000 110011110 10000001100 1


.D 32-bit internal register 4 6
1110 100000011001 111010000 00110010000 0
Delete Upper n bit

1
"0" is stored.
CR2009
(Carry)

1-54
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Data shift instructions (continued)


Rotates the data in the 16-bit internal register to the right by
the number of specified bits.
bit bit
CR2009 15 0
16-bit
0 1111000000001111 internal register
Flag state varies according
to result of previous arith- (Rotated once)
metic operation.
.U 3 6
CR2009

1
(Carry)
0111100000000111
1
Rotated n times (Above processing is repeated n times.)

List of Instructions
bit bit
CR2009 15 0
16-bit
n 0 1111011110000000 internal register
RRA LDA RRA STA – 4-80
Rotates the data in the 32-bit internal register to the right by
the number of specified bits.
bit bit bit bit
CR2009 31 16 15 32-bit internal register 0

0 11110000000011110000000000001111
Flag state varies according
to result of previous arith- (Rotated once)
metic operation.
.D CR2009 4 6
1 01111000000001111000000000000111
(Carry)
Rotated n times (Above processing is repeated n times.)
bit bit
CR2009 31 32-bit internal register 0

0 11110111100000000111100000000000
(Carry)

Rotates the data in the 16-bit internal register to the left by


the number of specified bits.
bit bit
15 0 CR2009
16-bit
1111000000001111 0 internal register
Flag state varies according
(Rotated once) to result of previous arith-
metic operation.
.U CR2009 3 6
1110000000011110 1
(Carry)
Rotated n times (Above processing is repeated n times.)
bit bit
15 0 CR2009
16-bit
n 0000000111101111 0 internal register
(Carry)
RLA LDA RLA STA – 4-82
Rotates the data in the 32-bit internal register to the left by
the number of specified bits.
bit bit bit bit
31 16 15 32-bit internal register 0 CR2009

11110000000011110000000000001111 0
Flag state varies according
(Rotated once) to result of previous arith-
metic operation.
.D CR2009 4 6
11100000000111100000000000011110 1
(Carry)
Rotated n times (Above processing is repeated n times.)
bit bit
31 32-bit internal register 0 CR2009

00000001111000000000000111101111 0
(Carry)

1-55
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Shifts 16-bit data to the right.


Before execution After execution

S 1000 0
S +1 2000 0
"0" is stored.
0
0
n1
items S + n2 1000
.U ( S +1) + n2 2000 10 12

1
8000
S + n1 –1 9000

n2
items 8000
List of Instructions

( S +1 ( n1 –1) + n2 9000

WSR
WSR S n1 n2 – 4-84
Shifts 32-bit data to the right.
Before execution After execution

S +1 100000 S 0
S +3 200000 S +2 0
"0" is stored.
0
0
n1
( S +1) +2 n1 100000 S +2 n2
items
.D ( S +3) +2 n2 200000 ( S +2) +2 n2 11 12
800000
S +2 ( n1 –1) +1 900000 S +2 ( n1 –1)

n2
items 800000
( S +2 ( n1 –1) +1) +2 n2 900000 ( S +2 ( n1 –1) +2 n2

Shifts 16-bit data to the left.


Before execution After execution

S – n2 1000
( S +1) – n2 2000
n2
items

S 1000
.U S +1 2000 10 12
8000
( S + n1 –1) – n2 9000
n1
items 0
0
"0" is stored.
8000 0
S + n1 –1 9000 0

WSL
WSL S n1 n2 – 4-86
Shifts 32-bit data to the left.
Before execution After execution

( S +1) –2 n1 100000 S –2 n2
( S +3) –2 n2 200000 ( S +2) –2 n2
n2
items

S +1 100000 S
.D S +3 200000 S +2 11 12
800000
( S +2 ( n1 –1) +1) –2 n2 900000 ( S +2 ( n1 –1) –2 n2
n1 0
items
0
"0" is stored.
800000 0
S +2 ( n1 –1) +1 900000 S +2 ( n1 –1) 0

1-56
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Data conversion instruction


Converts the content of 16-bit internal register to BCD.
.U 1 4
TBCD LDA TBCD STA – 4-90
Converts the content of 32-bit internal register to BCD.
.D 2 4

Converts the content of 16-bit internal register to binary.


.U 1 4
TBIN LDA TBIN STA
Converts the content of 32-bit internal register to binary.
– 4-92 1
.D 2 4

List of Instructions
Decodes on digit in 16-bit internal register to 16 bits.
n (#1)th digit
#3 #2 #1 #0
16-bit
internal register 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1
n
MPX LDA MPX STA 3 6 – 4-94
7 n
Bit 7 of 16-bit internal
F E D C B A 9 8 7 6 5 4 3 2 1 0 register is turned ON ("1" is
16-bit
internal register 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 stored) as (#1)th digit is
"0111" (decimal 7).

Encodes to the value at the MSB position in the 16-bit internal


register. Ignore
F E D C B A 9 8 7 6 5 4 3 2 1 0
16-bit
internal register 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0

DMX LDA DMX STA 1 4 – 4-94


16-bit
internal register 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
"7" (hex 0111) is stored to the 16-bit internal register as the
uppermost bit of ON ("1") bits is bit 7.

Decodes binary data in 16-bit internal register to gray code.


.U 1 4
GRY LDA GRY STA – 4-96
Decodes binary data in 32-bit internal register to gray code.
.D 2 4

Decodes gray code in 16-bit internal register to binary data.


.U 1 4
RGRY LDA RGRY STA – 4-98
Decodes gray code in 32-bit internal register to binary data.
.D 2 4

Disperses 16-bit data to nibble (4-bit) units, and stores the


nibbles to four word devices.
bit bit bit bit
15 8 7 0
DISN 1 2 3 4 : S bit bit bit bit
DISN S D 15 8 7 0
7 12 – 4-100
0 0 0 4 : D
0 0 0 3 : D +1
0 0 0 2 : D +2
0 0 0 1 : D +3

"0" is stored to the upper 12 bits.

Unites the lower 4 bits of four word devices to single 16-bit


data. bit
15
bit
4
bit
0
S : 1
UNIN
S +1 : 2
S D
UNIN S +2 : 3 7 12 – 4-102
S +3 : 4

bit bit bit bit


15 8 7 0
D : 4 3 2 1

1-57
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Data conversion instructions (continued)


Disperses 16-bit data to byte (8-bit) units, and stores the
bytes to two word devices.
bit bit bit bit
DISB 15 8 7 0

DISB S D S : 1 2 3 4 bit bit bit bit 7 12 – 4-104


15 8 7 0
D : 0 0 3 4
D +1 : 0 0 1 2

1
"0" is stored to the upper bytes (8 bytes).

Unites the lower 1 byte (8 bits) of two word devices to single


16-bit data.
List of Instructions

bit bit bit bit


UNIB 15 8 7 0
UNIB S D S : 3 4 7 12 – 4-106
S +1 : 1 2
bit bit bit bit
15 8 7 0
D : 1 2 3 4

Swaps the upper and lower data of the 16-bit internal register.
bit bit bit bit
15 8 7 0
Before
execution 1 2 3 4 ←16-bit internal register: $1234
.U 1 4

After
execution 3 4 1 2 ←16-bit internal register: $3412
SWAP LDA SWAP STA – 4-108
Swaps the upper and lower data of the 32-bit internal register.
↓32-bit internal register: $12345678
bit bit bit bit bit bit bit bit
31 2423 16 15 8 7 0
Before
1 2 3 4 5 6 7 8
.D execution 2 4

After
execution 5 6 7 8 1 2 3 4
↑32-bit internal register: $56781234
Exchanges 16-bit data.
Before execution After execution
bit bit bit bit
15 S1 0 15 S1 0

.U 1 2 3 4 A B C D 7 14
bit bit bit bit
15 S2 0 15 S2 0

XCH A B C D 1 2 3 4
XCH S D 4-110
Exchanges 32-bit data.
Before execution After execution
bit bit bit bit
31 S1 +1 S1 0 31 S1 +1 S1 0

.D 0 1 2 3 4 5 6 7 8 9 A B C D E F 8 14
bit bit bit bit
31 S2 +1 S2 0 31 S2 +1 S2 0

8 9 A B C D E F 0 1 2 3 4 5 6 7

Floating point instructions


Converts the binary data currently stored in 16-bit internal
.U register to floating point type real number. 1 4
Before execution After execution
bit bit bit bit
15 16-bit internal register 0 31 32-bit internal register 0
16-bit unsigned
.S binary data Floating point type real number 2 4
16 bits 32 bits
Conversion FLOAT LDA FLOAT STA.F – 4-114
Converts the binary data currently stored in 32-bit internal
.D register to floating point type real number. 2 4
bit Before execution bit bit After execution bit
31 32-bit internal register 0 31 32-bit internal register 0

32-bit unsigned binary data Floating point type real number


.L 2 4
32 bits 32 bits

1-58
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Floating point instructions (continued)


Converts the floating point type real number currently stored
.U in 16-bit internal register to binary data. 1 4
Before execution After execution
bit bit bit bit
31 32-bit internal register 0 15 16-bit internal register 0
16-bit unsigned
.S Floating point type real number binary data 2 4
32 bits 16 bits
Conversion INTG LDA INTG STA – 4-116
.D
Converts the floating point type real number currently stored
in 32-bit internal register to binary data. 2 4 1
bit Before execution bit bit After execution bit

List of Instructions
31 32-bit internal register 0 31 32-bit internal register 0

Floating point type real number 32-bit unsigned binary data


.L 2 4
32 bits 32 bits

Writes floating point type real number values.


S D +1 D
DW.F DW.F 10 12 – 4-120
S :+1.234567 Floating point type real number
D
32 bits
(2 words)

Writes floating point type real number values to 32-bit internal


register.
S
LDA.F LDA.F STA.F S +1 S 32-bit internal register 7 8 4-122
+1.234 +1.234
32 bits 32 bits
(2 wods)

Writes floating point type real number values in 32-bit internal


register.
D
STA.F LDA.F STA.F 32-bit internal register D +1 D 5 8 4-124
Move +1.234 +1.234
32 bits 32 bits
(2 words)

Moves floating point type real number values.


MOV.F S +1 S D +1 D
MOV.F S D 10 14 4-126
Floating point type real number Floating point type real number
32 bits 32 bits
(2 words) (2 words)

Moves floating point type real number values.


Move destination
D +1 D

Move destination
DM00201: +1.234 :DM00200
FMOV.F
FMOV.F S D n S +1 S DM00203: +1.234 :DM00202 10 14 4-128
DM00101: +1.234 :DM00100 DM00205: +1.234 :DM00204
DM00207: +1.234 :DM00206
DM00209: +1.234 :DM00208

Disperses a floating point type real number to a mantissa


Mantissas/ and exponent. Mantissa section:
Exponent D1 +1 D1
S +1 S Signed 32-bit binary data
DISF
DISF S D1 D2
Separation 32 bits 10 16 – 4-130
Floating point type real number (2 words)

Floating 32 bits
Exponent section:
[Example of separation] D2
point
conversion –1.234 x 10–3 Signed 16-bit
binary data
32 bits
Mantissa Exponent (1 word)

1-59
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Floating point instructions (continued)


Units the mantissa and exponent to form a floating point type
real number.
Mantissas/ Mantissa section:
Exponent S1 +1 S1
UNIF Signed 32-bit binary data D +1 D
UNIF S1 S2 D 32 bits Coupling
10 16 – 4-132
(2 words) Floating point type real number
Exponent section:
Floating 32 bits
S2

1 point Floating point type integer

conversion
Signed 32-bit
binary data
[Coupling –1.234 x 10–3
example]
16 bits
Mantissa Exponent
(1 word)
List of Instructions

Adds a floating point type real number.


32-bit internal register S1 +1 S1
S Floating point type real number + Floating point type real number
ADD.F LDA.F ADD.F STA.F 2 words (32 bits) 32 bits 7 8 4-134
32-bit internal register

Floating point type real number


2 words (32 bits)

Subtracts a floating point type real number.


32-bit internal register S +1 S
S Floating point type real number Floating point type real number
SUB.F LDA.F SUB.F STA.F 32 bits 32 bits (2 words) 7 8 4-136
32-bit internal register

Floating point type real number


Arithmetic 32 bits

operations Multiplies a floating point type real number.


32-bit internal register S +1 S
S Floating point type real number x Floating point type real number
MUL.F LDA.F MUL.F STA.F 32 bits 32 bits (2 words) 7 8 4-138
32-bit internal register

Floating point type real number


32 bits

Divides a floating point type real number.


32-bit internal register S +1 S
S Floating point type real number ÷ Floating point type real number
DIV.F LDA.F DIV.F STA.F 32 bits 32 bits (2 words) 7 8 4-140
32-bit internal register

Floating point type real number


32 bits

Calculates the square root of a floating point type real number


S value.
Square ROOT.F LDA.F ROOT.F STA.F 32-bit internal register 32-bit internal register
2 4 – 4-142
root Floating point type real number Floating point type real number
2 words (32 bits) 2 words (32 bits)

Compares a floating point type real number value.


Comparison Result Arithmetic Flag State
S Flag Value in internal register is smaller than specified range.
CR2009→ ON
LDA.F CMP.F Internal register<[ S • S +1]
CMP.F 7 8 4-144
Value in internal register is within specified range.
CR2010→ ON
Internal register=[ S • S +1]
Value in internal register is greater than specified range.
CR2011→ ON
Internal register>[ S • S +1]

Comparison
Compares ranges of floating point type real number values.
Comparison Result (when S1 • S1 +1]<[ S2 • S2 +1]) Arithmetic Flag State
S1 Flag Value in 32-bit internal register is smaller thanspecified range.
CR2009→ ON
Internal register<[ S1 • S1 +1]<[ S2 • S2 +1]
ZCMP.F LDA.F ZCMP.F 12 14 4-146
Value in internal register is within specified range.
S2 S1 • S1 +1]≤ Internal register <[ S2 • S2 +1]
CR2010→ ON

Value in internal register is greater than specified range.


CR2011→ ON
[ S1 • S1 +1]<[ S2 • S2 +1]< Internal register

1-60
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Floating point instructions (continued)


Calculates the exponent function that takes a floating point
type real number as its quotient.
EXP LDA.F EXP STA.F 32-bit internal register 32-bit internal register 1 4 – 4-148

Quotient/
e ( Floating point type real number
32 bits
) Floating point type real number
32 bits

logarithm Calculates the natural logarithm of a floating point type real


number.
LOG LDA.F LOG STA.F
Log (
32-bit internal register

Floating point type real number )


32-bit internal register

Floating point type real number


1 4 – 4-150
1
32 bits 32 bits

List of Instructions
Converts the angle in degrees (°) of the floating point type
real number current stored to 32-bit internal register to radians.
RAD LDA.F RAD STA.F 1 4 – 4-152
32-bit internal register 32-bit internal register
Angle
( Floating point type real number )° ( Floating point type real number ) RAD
32 bits 32 bits

Radian Converts the angle in radians of the floating point type real
number current stored to 32-bit internalregister to degrees (°).
conversion
DEG LDA.F DEG STA.F 32-bit internal registerv 32-bit internal register 1 4 – 4-154
( Floating point type real number ) rad. ( Floating point type real number )°
32 bits 32 bits

Calculates the sine (sin) value from the angle in radians of


the floating point type real number currently stored to 32-bit
internal register. 1 4 –
SIN LDA.F SIN STA.F
32-bit internal register 32-bit internal register
4-156
SIN ( Floating point type real number ) Floating point type real number
32 bits 32 bits

Calculates the cosine (cos) value from the angle in radians


of the floating point type real number currently stored to 32-bit
Trigonometric internal register. 1 4 –
COS LDA.F COS STA.F 32-bit internal register 32-bit internal register
4-158
functions
COS ( Floating point type real number
32 bits
) Floating point type real number
32 bits

Calculates the tangent (tan) value from the angle in radians


of the floating point type real number currently stored to 32-bit
TAN LDA.F TAN STA.F internal register. 1 4 – 4-160
32-bit internal register 32-bit internal register

TAN ( Floating point type real number ) Floating point type real number
32 bits 32 bits

Calculates the inverse sine (sin-1) value of the floating point


type real number currently stored to 32-bit internal register.
ASIN LDA.F ASIN STA.F 32-bit internal register 32-bit internal register 1 4 – 4-162
SIN-1 ( Floating point type real number
32 bits
) Floating point type real number
32 bits

Calculates the inverse cosine (cos-1) value of the floating point


Inverse type real number currently stored to 32-bit internal register.
trigonometric ACOS LDA.F ACOS STA.F 32-bit internal register 32-bit internal register 1 4 – 4-164
functions COS-1 ( Floating point type real number
32 bits
) Floating point type real number
32 bits

Calculates the inverse tangent (tan ) value of the floating point -1

type real number currently stored to 32-bit internal register.


ATAN LDA.F ATAN STA.F 32-bit internal register 32-bit internal register 1 4 – 4-166
TAN-1 ( Floating point type real number
32 bits
) Floating point type real number
32 bits

1-61
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Text processing instructions


Converts the lower order byte two digits in 16-bit internal
register to 2-digit ASCII text code.
3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Before 1 0 1 0 0 1 0 1 :16-bit internal register


execution
0 0 A 5
ASC LDA ASC STA 1 4 – 4-170

1 After
2
3
2
2
2
1
2
0
2
3
2
2

0 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 :16-bit internal register


2
1
2
0
2
3
2
2
2
1
2
0
2
3
2
2
2
1
2
0

execution
List of Instructions

4 1 3 5

Reverse converts the 2-digit ASCII text code in 16-bit internal


register to two numerical value digits.
3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Before 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1 :16-bit internal register


execution
3 6 4 3
RASC LDA RASC STA 1 4 – 4-172

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

After 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 :16-bit internal register


execution
0 0 6 C

Converts 16-bit unsigned binary data to a decimal ASCII text


string.
bit bit bit bit bit bit
15 S 0 15 0 15 0
.U 16-bit unsigned binary data D 10,000's 1,000's
7 14
Decimal 16 bits
D +1: 100's 10's
00H is automatically
N stored at the end.
D +2: 1's U (00H)
L

ASCII
string Converts 16-bit signed binary data to a decimal ASCII text
conversion string. bit
15
bit
0
bit
15 S
bit
0
D Sign 10,000's
.S 16-bit signed binary data D +1: 1,000's 100's
8 14
16 bits
D +2: 10's 1's No change before
00H is automatically and after instruction
N
stored at the end. D +3: U (00H)
L
execution

Converts 32-bit unsigned binary data to a decimal ASCII text


bit bit
string. 15 0

DASC bit bit bit bit D 1,000,000,000's 100,000,000's


S +1 S
DASC S D
31 16 15 0
* 4-178
32-bit unsigned binary data D +1: 10,000,000's 1,000,000's
32 bits
.D D +2: 100,000's 10,000's
8 14
D +3: 1,000's 100's

D +4: 10s 1's


No change
N
U (00H)
before and
D +5: L after instruction
00H is automatically
stored at the end. execution

Converts 32-bit signed binary data to a decimal ASCII text


bit bit
string. 15 0

bit bit bit bit D


31 S +1 16 15 S 0
Sign 1,000,000,000's

32-bit signed binary data D +1: 100,000,000's 10,000,000's


32 bits
D +2: 1,000,000's 100,000's
.L 8 14
D +3: 10,000's 1,000's

D +4: 100's 10s


N
1's U (00H)
D +5: L

00H is automatically stored


at the end.

* To specify relays at the same time, specify the start (1000, 1100 and so forth) of the channel.

1-62
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Text processing instructions (continued)


Converts a decimal ASCII text string to 16-bit unsigned binary
data.
bit bit bit bit
15 S 0 15 D 0

.U S 10,000's 1,000's 16-bit unsigned binary data 7 14


16 bits
S +1: 100's 10's
N
S +2: 1's U (00H)
L NUL (00H) is required at end of text string.

Converts a decimal ASCII text string to 16-bit signed binary


1
data.

List of Instructions
bit bit bit bit
15 S 0 15 D 0

S Sign 10,000's 16-bit signed binary data


.S 16 bits
8 14
S +1: 1,000's 100's

S +2: 10's 1's


N
S +3: U (00H)
L NUL (00H) is required at end of text string.

Decimal
RDASC Converts a decimal ASCII text string to 32-bit unsigned binary
RDASC S D data. bit bit bit bit bit bit
* 4-178
S
15 D +1 0 31 16 15 D 0
ASCII S 1,000,000,000's 100,000,000's 32-bit unsigned binary data
string 32 bits
S +1: 10,000,000's 1,000,000's
conversion .D 8 14
S +2: 100,000's 10,000's

S +3: 1,000's 100's

S +4: 10s 1's


N
U (00H)
S +5: L NUL (00H) is required at end of text string.

Converts a decimal ASCII text string to 32-bit signed binary


data. 15
bit
S bit
0
bit
31
bit bit
D +1 16 15 D
bit
0

S Sign 1,000,000,000's 32-bit signed binary data


32 bits
S +1: 100,000,000's 10,000,000's
.L 8 14
S +2: 1,000,000's 100,000's

S +3: 10,000's 1,000's

S +4: 100's 10s


N
1's U (00H)
D +5: L NUL (00H) is required at end of text string.

Moves text strings to a specified device.

S : A(41H) B(42H)
SMOV S +1: C(43H) D(44H)
Move SMOV S D N 7 14 * 4-182
S +2: E(45H) U
L (00H) D : A(41H) B(42H)
G(47H) H(48H) D +1: C(43H) D(44H)
N
I(49H) J(4AH) D +2: E(45H) U (00H)
L

16 bits 16 bits

Unites the text strings of a specified device.

S1 A(41H) B(42H)
N
S1 +1 C(43H) U (00H)
L D A(41H) B(42H)
SADD D +1 C(43H) D(44H)
Unite SADD S1 S1 D 10 20 * 4-184
D +2 E(45H) F(46H)
S2 D(44H) E(45H) G(47H)
N
U (00H)
D +3 L
S2 +1 F(46H) G(47H)
N
S2 +2 U (00H)
L

* To specify relays at the same time, specify the start (1000, 1100 and so forth) of the channel.

1-63
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Text processing instructions (continued)


Compares text strings.
Compare
Compare
S1 A(41H) B(42H) S2 A(41H) B(42H)
S1 +1 C(43H) D(44H) S2 +1 C(43H) D(44H)
S1 +2 E(45H) F(46H) S2 +2 E(45H) F(46H)
S1 +3 G(47H) H(48H) S2 +3 G(47H) H(48H)
S1 +4 I(49H) J(4AH) S2 +4 I(49H) J(4AH)

1 SCMP
S1 +5
S1 +6
K(4BH)
M(4DH) N
U
L
L(4CH)
(00H)
S2 +5
S2 +6
K(4BH)
N(4EH) N
L(4CH)
U
L (00H)
Compare is continued until
end code (NUL (00H)) is
found.
Compare SCMP S1 S2 7 14 * 4-186
List of Instructions

When the text string resulting from comparison up to NUL (00H) is the
same, the arithmetic operation flag CR2010 turns ON.
Comparison Result Arithmetic Flag State
When (all characters in S1 )=(all characters in S2 ) CR2010→ ON
When the number of characters n is different, the arithmetic operation
flag changes as follows.
Comparison Result Arithmetic Flag State
When (ASCII code of nth characters in S1 )<(ASCII code of nth characters in S2 ) CR2009→ON
When (ASCII code of nth characters in S1 )>(ASCII code of nth characters in S2 ) CR2011→ON

Disperses byte unit text strings to word unit text strings.


D 0 a(61H)
S a(61H) b(62H) D +1 0 b(62H)
DISS
DISS S D S +1 c(63H) d(64H) D +2 0 c(63H) 7 16 * 4-188
S +2 e(65H) UL(00H)
N
D +3 0 d(64H)
D +4 0 e(65H)

"0" is automatically stored to the upper byte.


Disperse/
Unite Unites word unit text strings to byte unit text strings.
S a(61H)
S +1 b(62H) D a(61H) b(62H)
UNIS S +2 c(63H) D +1 c(63H) d(64H)
UNIS S D n 10 16 * 4-190
n
items S + n –3 x(78H) D +( n /2)–1 x(78H) y(79H)
N
S + n –2 y(79H) D +( n /2)–1 z(7AH) U
L (00H)
S + n –1 z(7AH) D +( n /2)–1

Counts the number of characters in a text string.


S a(61H) b(62H) D 26
16 bits
S +1 c(63H) d(64H) (1 word)
Detect text LEN S +2 e(65H) f(66H)
string LEN S D 7 14 * 4-192
length w(77H) x(78H)
y(79H) z(7AH)
N
U
L (00H)

Reads device comments


Comment of device specified by S
1st 2nd
D character character
3rd 4th
RCOM D +1 character character
Read Max. 32 1-byte characters 7 12 * 4-194
RCOM S D D +2 5th 6th
comment character character
Single-byte characters are stored
as ASCII code (1 byte) and two-
byte characters are stored as shift 31st 32nd
JIS code (2 bytes). D +15 character character
D +16 N
U
L (00H)

* To specify relays at the same time, specify the start (1000, 1100 and so forth) of the channel.

1-64
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Extended Instructions

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Text processing instructions (continued)


HKEY Enters hexadecimal key data.
Hex key S1
HKEY 7 12 – 5-4
entry S2

Counts the number of bits currently ON in 16-bit internal


.U register. 1 4 1
BCNT LDA BCNT STA – 5-6
Counts the number of bits currently ON in 32-bit internal

List of Instructions
.D register. 2 4

Counts the number of same data as a 16-bit internal register


in a specified range.
bit bit 16-bit internal register
15 0 bit15 bit0
Compare The number of data items to which
S 1234 1234 the same value as that of the 16-bit
Compare
S +1 2345 internal register is stored is
counted. The result is stored to the
.U 3456
Compare
16-bit internal register.
7 10
S +2
n items
Compare
( n words) 1234
Data S
16-bit internal register
Compare
count S 4567 bit15 bit0
Compare Result
S + n –1 5678 2
S
DCNT LDA DCNT STA – 5-8
n Counts the number of same data as a 32-bit internal register
in a specified range.
bit bit bit bit bit 32-bit bit
31 16 15 0 31 internal register 0
Compare
S +1 12345678 S 12345678
Compare
S +3 23456789 S +2 The number of data items to
Compare which the same value as that of
.D S +5 34567890 S +4 the 32-bit internal register is 8 10
n items stored is counted. The result is
Compare
stored to the 32-bit internal
(2 n words) S +2( n –3)+1 12345678 S +2( n –3) register.
Compare
S +2( n –2)+1 45678901 S +2( n –2)
Compare
32-bit
S +2( n –1)+1 56789012 S +2( n –1) bit
internal register
bit
31 0
Result
2

Searches the number of same data as 16-bit internal register


from a specified range.
bit bit 16-bit internal register
15 0 bit15 bit0
Compare The No. of the devices to which the
S 1234 3456 same value as that of the 16-bit
Compare
S +1 2345 internal register is stored is
searched. The result is stored to the
.U 3456
Compare
16-bit internal register.
7 12
S +2
n items

( n words) Compare
S + n –3 1234
Compare 16-bit internal register
S + n –2 3456 bit15 bit0
CR2010 Compare Result
S + n –1 5678 S +2
S
Search SER LDA SER STA – 5-10
n Searches the number of same data as 32-bit internal register
from a specified range.
bit bit bit bit bit 32-bit bit
31 16 15 0 31 internal register 0
Compare
S +1 12345678 S 23456789
Compare
S +3 23456789 S +2 The No. of the devices to which
Compare the same value as that of the 32-
.D S +5 34567890 S +4 8 12
bit internal register is stored is
n items searched. The result is stored to
Compare the 32-bit internal register.
(2 n words) S +2( n –3)+1 45678901 S +2( n –3)
Compare
S +2( n –2 )+1 23456789 S +2( n –2)
Compare bit 32-bit bit
S +2( n –1)+1 56789012 S +2( n –1) 31 internal register 0
Result
S +2

1-65
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Data processing instructions


Searches for the maximum value in a specified range.
bit bit
15 0
S 1234
S +1 2345
16-bit internal register
.U S +2 3456 bit15 bit0 7 10
n items
Largest value 9876
9876
is stored.
S + n —3
( n words)
S + n —2 8765

1
S + n —1 7654

Searches for the maximum value in a specified range.


List of Instructions

8 10
.S

S
MAX MAX STA – 5-12
n Searches for the maximum value in a specified range.
bit bit bit bit
31 16 15 0
S +1 12345678 S
S +3
32-bit internal register
23456789 S +2 Largest value bit bit
.D S +5 34567890 S +4 is stored. 31 0 8 10
n items 98765432
S +2( n –3)+1 98765432 S +2( n –3)
(2 n words)
S +2( n –2)+1 87654321 S +2( n –2)
S +2( n –1)+1 76543210 S +2( n –1)

Searches for the maximum value in a specified range.

.L 8 10

Search
Searches for the minimum value in a specified range.
bit bit
15 0
S 1234
S +1 2345 16-bit internal register
.U S +2 3456 bit15 bit0 7 10
n items
Smallest value 1234
7654
is stored.
S + n –3
( n words)
S + n –2 8765
S + n –1 9876

Searches for the minimum value in a specified range.

.S 8 10

S
MIN MIN STA – 5-16
n Searches for the minimum value in a specified range.
bit bit bit bit
31 16 15 0
S +1 12345678 S
32-bit internal register
S +3 23456789 S +2 Smallest value bit bit
.D S +5 34567890 S +4 is stored. 31 0 8 10
n items 12345678
+2( n –3)+1 76543210 S +2( n –3)
(2 n words) S
S +2( n –2)+1 87654321 S +2( n –2)
S +2( n –1)+1 98765432 S +2( n –1)

Searches for the minimum value in a specified range.

.L 8 10

1-66
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Data processing instructions (continued)


Calculates the average value of a specified range.
bit bit
15 0
S 16
S +1 256
.U S +2 4096 Average value is stored to 7 10
n items 16-bit internal register.
S + n –3 16383
( n words) 16-bit internal register
S + n –2 32767 bit15 bit0
Average

1
S + n –1 65535 Average value

Calculates the average value of a specified range.

List of Instructions
.S 8 10

S
Average
AVG AVG STA – 5-20
value n Calculates the average value of a specified range.
bit bit bit bit
31 16 15 0
S +1 12345678 S
S +3 23456789 S +2
.D 34567890
Average value is stored to 8 10
S +5 S +4
n items 32-bit internal register.
S +2( n –3)+1 78901234 S +2( n –3)
(2 n words) bit 32-bit bit
S +2( n –2)+1 89012345 S +2( n –2) 31 internal register 0
Average
S +2( n –1)+1 90123456 S +2( n –1) Average value

Calculates the average value of a specified range.

.L 8 10

S1 Batch-resets a specified range.


Batch
ZRES ZRES 7 12 – 5-24
reset S2

.U FIFOW Writes data to the FIFO table. 7 12


FIFOW S D – 5-26
FIFO .D 8 12
processing .U Reads data from the FIFO table. 7 12
FIFOR
FIFOR S D – 5-28
.D 8 12
Extends values in 16-bit internal register to 32-bit data.
.U 1 4
32-bit internal register
16-bit
internal register Upper Lower

.S EXT(.U/.S) 16-bit 2
TM000 internal register 4
Extension EXT LDA EXT STA.D – 5-32
Extends values in 32-bit internal register to 64-bit data.
.D 2 4
Upper Lower
32-bit 32-bit
internal register TM001 TM000 internal register
EXT(.D/.L)
.L 2 4

1-67
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Clock processing instructions


Writes the time data to the calendar timer.
bit bit
15 0

S Year 0 to 99 The bottom two digits of the calendar year are


displayed for the year.
S +1 : Month 1 to 12
S
S +2 : Day 1 to 31
WTIME WTIME 4 8 – 5-38
S +3 : Hour 0 to 23 All data is described in 16-bit binary data format.

1 S +4 :
S +5 :
Minute

Second
0 to 59

0 to 59 Day of week is expressed as 0: (Sunday),


List of Instructions

Clock S +6 : Day of week 0 to 6 1: (Monday), 2: (Tuesday), 3: (Wednesday),


4: (Thursday), 5: (Friday), and 6: (Saturday).
processing
SEC
Converts date/time format data to second format data.
SEC S D 7 12 – 5-40

RSEC
Converts second format data to date/time format data.
RSEC S D 7 12 – 5-42

Adjusts the calendar timer by ±30 seconds.


AJST AJST 1 4 – 5-44

Alarm instruction
Resets the alarm relay and alarm history.
Alarm ARES ARES 1 4 – 5-48

High-speed processing instructions


HSP Reduces the time constant of the input relay to speed up input
Input time D response. –
constant HSP 4 6 5-52

Disables execution of the interrupt program.


DI DI 1 4 – 5-54

Enables execution of the interrupt program.


EI EI 1 4 – 5-54
Interrupts
INT Executes the interrupt program from the INT to the RETI
INT S instructions. 4 0 – 5-56

RETI Indicates the end of the interrupt program.


RETI 1 4 – 5-56

CTH n Performs high-speed counter operation.


CTH S 6 6 – 5-68
High-speed
counter S Compares the setting value with the current value of the high-
CTC CTC n speed counter in the hardware, and sets the high-speed 3 0 – 5-68
counter when values are equaled.

1-68
1-8 List of Instructions

OF INSTRUCTIONS
BRIEF EXPLANATION
Object size

Specification
Condition
Execution

Byte Size

Indirect
See
Category Mnemonic Symbol Description of Instruction
Page

Positioning instructions
S Starts trapezoidal control of the X-axis.
PLSX PLSX 3 6 – 5-90
Trapezoidal
control Starts trapezoidal control of the Y-axis.
S
PLSY PLSY 3 6 – 5-90

JOGX
CW
Performs jog operation of the X-axis. 1
JOGX CCW 1 4 – 5-92

List of Instructions
High
Jog
operation JOGY Performs jog operation of the Y-axis.
CW
JOGY CCW 1 4 – 5-92
High

Starts zero return of the X-axis.


ORGX ORGX 1 4 – 5-94
Zero
return Starts zero return of the Y-axis.
ORGY ORGY 1 4 – 5-94

Loads the current position of the X-axis.


TCHX TCHX 1 4 – 5-98
Teaching
Loads the current position of the Y-axis.
TCHY TCHY 1 4 – 5-98

1-69
1-8 List of Instructions
OF INSTRUCTIONS
BRIEF EXPLANATION

This page left intentionally blank.

1
List of Instructions

1-70
2-1 Contact Instructions

BASIC INSTRUCTIONS
2

Contact Instructions
BASIC INSTRUCTIONS
This chapter explains the most basic instructions in writing a se-
quence program.
These instructions enable mechanical control on a level with general
relay sequence circuits.
You can make a complete program merely by using these instruc-
tions.

2-1 Contact Instructions ...........................................................2-2

2-2 Bit Contact Instructions ...................................................2-12

2-3 Comparison Contact Instructions ................................... 2-16

2-4 Output Instructions .......................................................... 2-22

2-5 Bit Output Instructions ..................................................... 2-40

2-6 Timer/Counter Instructions ..............................................2-46

2-7 Connect/End Instructions ................................................2-68

2-1
2-1 Contact Instructions

2-1 Contact Instructions


BASIC INSTRUCTIONS

Contact instructions are for connecting contacts (switches) to circuits.


The ON/OFF states of contacts are output to devices using output instructions, and are used as
execution conditions for basic instructions, applied instructions, arithmetic calculation instructions,
and extended instructions.

Contact Instruction List


There are 12 contact instructions as follows.

2 Instruction Mnemonic Brief Description of Operation Page


Load LD Treats a device as a NO contact, and connects it to 2-4
Contact Instructions

the left bus line.*


Load bar LDB Treats a device as an NC contact, and connects it to
the left bus line.*
AND AND Treats a device as a NO contact, and connects it 2-6
serially to a circuit.
AND bar ANB Treats a device as an NC contact, and connects it
serially to a circuit.
OR OR Treats a device as a NO contact, and connects it in 2-8
parallel to a circuit.
OR bar ORB Treats a device as an NC contact, and connects it in
parallel to a circuit.
Load pulse LDP Connects a device to the left bus line as a NO contact 2-10
that turns ON for one scan at its up edge.
Load pulse fall LDF Connects a device to the left bus line as a NO contact
that turns ON for one scan at its down edge.
AND pulse ANP Connects a device serially to a circuit as a NO contact
that turns ON for one scan at its up edge.
AND pulse fall ANF Connects a device serially to a circuit as a NO contact
that turns ON for one scan at its down edge.
OR pulse ORP Connects a device in parallel to a circuit as a NO
contact that turns ON for one scan at its up edge.
OR pulse fall ORF Connects a device in parallel to a circuit as a NO
contact that turns ON for one scan at its down edge.

* The LD and LDB instructions relate the ON/OFF state of specified devices to instructions from LD
and LDB onwards at each scan. These instructions are used for connecting contacts to the bus
lines (programmed at position (1)).

(1) (2)
00001 00002 00500 (1) LD 00001
(2) AND 00002
OUT 00500
00003 00004 00501
LDB 00003
(3) AND 00004
00005 (3) OR 00005
OUT 00501

Left bus line Right bus line

2-2
2-1 Contact Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Contact Instructions

2-3
Treats a device as a NO contact, and connects it to the left
LD
2-1 Contact Instructions Load
bus line.

LDB Load bar Treats a device as a NC contact, and connects it to the left
bus line.
BASIC INSTRUCTIONS

Ladder program Input method


S
L D S
A S
X S
S
L D B S
B S

2 L
L
D I
D N O T
S
S
A N I S
Contact Instructions

A N D N O T S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —

S : Specifies the device to be connected to the left bus line.

Explanation of Operation
LD Connects the device specified by S to the bus line as a NO contact.
The ON/OFF state of the device specified by S is related to instructions from LD
onwards.
LDB Connects the device specified by S to the bus line as an NC contact.
The inverted ON/OFF state of the device specified by S is related to instructions
from LDB onwards.

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

2-4
2-1 Contact Instructions

Sample Program

BASIC INSTRUCTIONS
LD
When input relay 00000 is ON, output relay 00500 turns ON. When input relay 00000 is OFF, output
relay 00500 turns OFF.

00000 00500

LDB
When input relay 00000 is ON, output relay 00500 turns OFF. When input relay 00000 is OFF, output 2
relay 00500 turns ON.

Contact Instructions
00000 00500

LD

LDB

AND

ANB

OR

ORB

LDP

LDF

ANP

ANF

ORP

ORF

2-5
2-1 Contact Instructions Treats a device as a NO contact, and connects it serially to
AND AND
a circuit.

ANB AND bar Treats a device as an NC contact, and connects it serially to


a circuit.
BASIC INSTRUCTIONS

Ladder program Input method


S
A N D S
A S
X S
S
A N B S
B S

2 L
L
D I
D N O T
S
S
A N I S
Contact Instructions

A N D N O T S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —

S : Specifies the device to be connected to the circuit.

Explanation of Operation
AND Connects the device specified by S serially to the circuit as a NO contact.
AND Connects the device specified by S serially to the circuit as an NC contact.

• In the ladder diagram, the device is shown in a serially connected state.

00000 00001 00500 LD 00000


AND 00001
OUT 00500

In this case, when input 00000 is ON, and (AND)00001 are ON, output 00500 turns ON.

• The number of contacts that can be serially connected in the program is not limited.

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

2-6
2-1 Contact Instructions

Sample Program

BASIC INSTRUCTIONS
AND
When input relays 00000 and 00001 both are ON, output relay 00500 turns ON. When either (or both)
of input relays 00000 or 00001 is OFF, output relay 00500 turns OFF.

00000 00001 00500

ANB
When input relay 00000 is ON, and input relay 00001 is OFF, output relay 00500 turns ON.
Otherwise, output relay 00500 turns OFF.
2

Contact Instructions
00000 00001 00500

LD

LDB

AND

ANB

OR

ORB

LDP

LDF

ANP

ANF

ORP

ORF

2-7
2-1 Contact Instructions Treats a device as a NO contact, and connects it in parallel
OR OR
to a circuit.

ORB OR bar Treats a device as an NC contact, and connects it in parallel


to a circuit.
BASIC INSTRUCTIONS

Ladder program Input method

S O R S

S O R B S
O R I S

2 O R N O T S

Available Bit Devices Word Devices Operation Flag


Contact Instructions

Constant Indirect
Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —

S : Specifies the device to be connected to the circuit.

Explanation of Operation
OR Connects the device specified by S in parallel to the circuit as a NO contact.
ORB Connects the device specified by S in parallel to the circuit as an NC contact.

The number of contacts that can be connected in parallel in the program is not limited.

Note: Parallel connections that include a non-contact instruction are not allowed.

Non-contact instructions

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

2-8
2-1 Contact Instructions

Sample Program

BASIC INSTRUCTIONS
OR
When either (or both) of input relays 00000 and 00001 is ON, output relay 00500 turns ON. When
both input relays 00000 or 00001 are OFF, output relay 00500 turns OFF.

00000 00500

00001

2
ORB

Contact Instructions
When input relay 00000 is ON, or input relay 00001 is OFF, output relay 00500 turns ON. When input
relay 00000 is OFF and 00001 is ON, output relay 00500 turns OFF.

00000 00500

00001

LD

LDB

AND

ANB

OR

ORB

LDP

LDF

ANP

ANF

ORP

ORF

2-9
2-1 Contact Instructions
LDP Load pulse
Connects a device that turns ON for one scan at its up
ANP AND pulse
edge.
ORP OR pulse
BASIC INSTRUCTIONS

LDF Load pulse fall


Connects a device that turns ON for one scan at its down
ANF AND pulse fall
edge.
ORF OR pulse fall

Ladder program Input method


S
L D S S

2
S
Contact Instructions

A N S S

Program P or F at .

S1
At , ↑ is entered in the case of P and O R S
↓ is entered in the case of F.

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —

S : Specifies the device whose up edge or down edge is detected.

Explanation of Operation
LDP ANP ORP
This device turns ON only for one scan when the up edge of the bit device speci-
fied by S is detected.

Instruction Operation
LDP Connects the device to the left bus line as a NO contact. This contact turns ON only
for one scan when the up edge of the bit device specified by S is detected.
ANP Connects the device serially as a NO contact. This contact turns ON only for one scan
when the up edge of the bit device specified by S is detected.
ORP Connects the device in parallel to a circuit as a NO contact. This contact turns ON only
for one scan when the up edge of the bit device specified by S is detected.

LDF ANF ORF


This device turns ON only for one scan when the down edge of the bit device specified
by S is detected.

Instruction Operation
LDF Connects the device to the left bus line as a NO contact. This contact turns ON only
for one scan when the down edge of the bit device specified by S is detected.
ANF Connects the device serially as a NO contact. This contact turns ON only for one scan
when the down edge of the bit device specified by S is detected.
ORF Connects the device in parallel to a circuit as a NO contact. This contact turns ON only
for one scan when the down edge of the bit device specified by S is detected.

2-10
2-1 Contact Instructions

Note: • This instruction cannot be used in interrupt programs.


• Care is required when programming this instruction between the STP and STE

BASIC INSTRUCTIONS
instructions, and between the STG to JMP/ENDS instructions and in a sub-routine
program.
"Precautions when using differential execution type instructions" page 1-6
• Parallel connections that include a non-contact instruction are not allowed.

Non-contact instructions
2

Contact Instructions
Operation flag
The operation flag does not change state.

Execution Timing
LDP, ANP, ORP This instruction is executed for one scan at the up edge of S .
LDP, ANP, ORP This instruction is executed for one scan at the down edge of S .
LD

LDB
Scan
AND
ON
ANB
S
OFF OR

LDP instruction ORB


ANP instruction Execution Execution
LDP
ORP instruction
LDF
LDF instruction
ANF instruction Execution Execution ANP
ORF instruction
ANF

ORP

ORF

Sample Program
When the up edge of input relay 00000 is detected, #00100 is moved to data memory DM00000.
When the down edge is detected, #00200 is moved to data memory DM00001.

00000 MOV
#00100 DM00000
00000 MOV
#00200 DM00001

2-11
2-2 Bit Contact Instructions

2-2 Bit Contact Instructions


BASIC INSTRUCTIONS

Bit contact instructions are for connecting bit contacts to a circuit. Bits of word devices are specified,
and handled as contacts.
The ON/OFF states of contacts are output to devices using output instructions, and are used as
execution conditions for basic instructions, applied instructions, arithmetic calculation instructions,
and extended instructions.

Bit Contact Instruction List


There are six bit contact instructions as follows.
2
Instruction Mnemonic Brief Description of Operation Page
Bit Contact Instructions

Bit load BLD Connects a device to the left bus line as a contact that 2-14
relays the ON/OFF states of specified bits on the device.
Bit load bar BLDB Connects a device to the left bus line as a contact that
inverts and relays the ON/OFF states of specified bits on
the device.
Bit AND BAND Connects a device serially to a circuit as a contact that
relays the ON/OFF states of specified bits on the device.
Bit AND bar BANB Connects a device serially to a circuit as a contact that
inverts and relays the ON/OFF states of specified bits on
the device.
Bit OR BOR Connects a device in parallel to a circuit as a contact that
relays the ON/OFF states of specified bits on the device.
Bit OR bar BORB Connects a device in parallel to a circuit as a contact that
inverts and relays the ON/OFF states of specified bits on
the device.

■ About word device bit specification


Word devices that can be used in bit contact instructions are DM (data memory), TM (temporary
data memory) and CM (control memory).
These word devices are configured in 16 bits.

bit bit
15 0

1-word device

With bit contact instructions, the bits of word devices are specified and handled as contacts.

[Example] To turn output relay 00500 ON/OFF by the state of bit 6 of DM00000.

DM00000 00500
B
#06

bit bit bit


15 6 0

DM00000

2-12
2-2 Bit Contact Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Bit Contact Instructions

2-13
2-2 Bit Contact Instructions
BLD B Bit load
The device functions as a contact for relating the ON/OFF
BAND B Bit AND
state of specified bits of a word device.
BOR B
Bit OR
BASIC INSTRUCTIONS

BLDB B Bit load bar


The device functions as a contact for relating the inverted
BANDB B Bit AND bar
ON/OFF state of specified bits of a word device.
BORB B
Bit OR bar

Ladder program Input method


S B B L D S n
( B A S n )

2 n B
(
B L D B S
)
n
B B S n
Bit Contact Instructions

S
B B A N D S n
( B A S n )
n
B B A N D B S n
( B B S n )

B B O R S n
S
At , B is entered in the case of B and B B O R B S n
n B is entered in the case of B B.

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the word device whose bit state is to be read.


n : Specifies the position of the bit of the word device specified by S . Specify within the
range 0 to 15.

Explanation of Operation
BLD BAND BOR
The instruction itself becomes a NO contact. This contact relates the ON/OFF state of
the n th bit of the word device specified by S to subsequent instructions.
BLDB BANDB BORB
The instruction itself becomes an NC contact. This contact inverts and relates the ON/
OFF state of the n th bit of the word device specified by S to subsequent
instructions.
bit S bit
15 0

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

15th bit 0 bit


n bit 1st bit

ON
n th bit of S
OFF

ON
BLD instruction
OFF

ON
BLDB instruction
OFF

2-14
2-2 Bit Contact Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
The instruction is executed at every scan.

Sample Program
When the 0th bit of data memory DM00000 and the 1st bit of data memory DM00001 both are ON,
output relay 00500 turns ON. When either of the 0th bit of DM00000 or the 1st bit of DM00001 is OFF,
output relay 00500 turns OFF.
2

Bit Contact Instructions


DM00000 DM00001 00500
B B
#00 #01

When either of the 3rd bit of data memory DM00000 and the 5th bit of data memory DM00001 is ON,
output relay 00500 turns ON. When the 3rd bit of DM00000 and the 5th bit of DM00001 both are OFF,
output relay 00500 turns OFF.

DM00000 00500
B
#03
BLD
DM00001
BLDB
B
#05 BAND

BANB

BOR

BORB

2-15
2-3 Comparison Contact Instructions

2-3 Comparison Contact Instructions


BASIC INSTRUCTIONS

Comparison contact instructions compare the size of two items of data. The result of comparison
operation causes that instruction itself to turn ON/OFF as a contact.
The ON/OFF states of contacts are output to devices using output instructions, and are used as
execution conditions for basic instructions, applied instructions, arithmetic calculation instructions,
and extended instructions.

Comparison Contact Instruction List


There are 72 comparison contact instructions as follows.
2
Instruction Mnemonic Brief Description of Operation Page
Comparison Contact Instructions

16-bit = LD= Turns ON when condition S1 = S2 is established. 2-20


unsigned AND= Turns OFF when condition S1 ≠ S2 is established.
binary
OR=
comparison
< LD< Turns ON when condition S1 < S2 is established.
AND< Turns OFF when condition S1 ≥ S2 is established.
OR<
> LD> Turns ON when condition S1 > S2 is established.
AND> Turns OFF when condition S1 ≤ S2 is established.
OR>
<= LD<= Turns ON when condition S1 ≤ S2 is established.
AND<= Turns OFF when condition S1 > S2 is established.
OR<=
>= LD>= Turns ON when condition S1 ≥ S2 is established.
AND>= Turns OFF when condition S1 < S2 is established.
OR>=
<> LD<> Turns ON when condition S1 ≠ S2 is established.
AND<> Turns OFF when condition S1 = S2 is established.
OR<>
32-bit =.D LD=.D Turns ON when condition [ S1 +1 • S1 ] = [ S2 +1 • S2 ] is established. 2-20
unsigned AND=.D Turns OFF when condition [ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ] is established.
binary OR=.D
comparison
<.D LD<.D Turns ON when condition [ S1 +1 • S1 ] < [ S2 +1 • S2 ] is established.
AND<.D Turns OFF when condition [ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ] is established.
OR<.D
>.D LD>.D Turns ON when condition [ S1 +1 • S1 ] > [ S2 +1 • S2 ] is established.
AND>.D Turns OFF when condition [ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ] is established.
OR>.D
<=.D LD<=.D Turns ON when condition [ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ] is established.
AND<=.D Turns OFF when condition [ S1 +1 • S1 ] > [ S2 +1 • S2 ] is established.
OR<=.D
>=.D LD>=.D Turns ON when condition [ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ] is established.
AND>=.D Turns OFF when condition [ S1 +1 • S1 ] < [ S2 +1 • S2 ] is established.
OR>=.D
<>.D LD<>.D Turns ON when condition [ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ] is established.
AND<>.D Turns OFF when condition [ S1 +1 • S1 ] = [ S2 +1 • S2 ] is established.
OR<>.D

2-16
2-3 Comparison Contact Instructions

Instruction Mnemonic Brief Description of Operation Page


16-bit =.S LD=.S Turns ON when condition S1 = S2 is established. 2-20

BASIC INSTRUCTIONS
signed AND=.S Turns OFF when condition S1 ≠ S2 is established.
binary
OR=.S
comparison
<.S LD<.S Turns ON when condition S1 < S2 is established.
AND<.S Turns OFF when condition S1 ≥ S2 is established.
OR<.S
>.S LD>.S Turns ON when condition S1 > S2 is established.
AND>.S Turns OFF when condition S1 ≤ S2 is established.
OR>.S
<=.S LD<=.S Turns ON when condition S1 ≤ S2 is established.
AND<=.S Turns OFF when condition S1 > S2 is established. 2
OR<=.S

Comparison Contact Instructions


>=.S LD>=.S Turns ON when condition S1 ≥ S2 is established.
AND>=.S Turns OFF when condition S1 < S2 is established.
OR>=.S
<>.S LD<>.S Turns ON when condition S1 ≠ S2 is established.
AND<>.S Turns OFF when condition S1 = S2 is established.
OR<>.S
32-bit =.L LD=.L Turns ON when condition [ S1 +1 • S1 ] = [ S2 +1 • S2 ] is established. 2-20
signed AND=.L Turns OFF when condition [ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ] is established.
binary
OR=.L
comparison
<.L LD<.L Turns ON when condition [ S1 +1 • S1 ] < [ S2 +1 • S2 ] is established.
AND<.L Turns OFF when condition [ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ] is established.
OR<.L
>.L LD>.L Turns ON when condition [ S1 +1 • S1 ] > [ S2 +1 • S2 ] is established.
AND>.L Turns OFF when condition [ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ] is established.
OR>.L
<=.L LD<=.L Turns ON when condition [ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ] is established.
AND<=.L Turns OFF when condition [ S1 +1 • S1 ] > [ S2 +1 • S2 ] is established.
OR<=.L
>=.L LD>=.L Turns ON when condition [ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ] is established.
AND>=.L Turns OFF when condition [ S1 +1 • S1 ] < [ S2 +1 • S2 ] is established.
OR>=.L
<>.L LD<>.L Turns ON when condition [ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ] is established.
AND<>.L Turns OFF when condition [ S1 +1 • S1 ] = [ S2 +1 • S2 ] is established.
OR<>.L

■ Precautions relating to comparison contact instructions


With comparison contact instructions, binary data is handled in decimal annotation in accor-
dance with the instruction suffix. For this reason, the execution result of these instructions
sometimes differs according to the type of suffix even if the binary data is the same.
Pay attention to the selection of suffixes.
"About suffixes" page 1-28

2-17
2-3 Comparison Contact Instructions

[Example 1]To compare DM00000 with constant #00100


This example assumes that binary data "1111111111111111" is stored to DM00000.
BASIC INSTRUCTIONS

When the suffix is ".U" (.U: Binary data is handled as 16-bit unsigned data.)

DM00000
(.U) LD(.U) DM00000 #00100
#00100

DM0000 is greater than #00100, and the contact turns ON.


2 (65535)
Comparison Contact Instructions

When the suffix is ".S" (.S: Binary data is handled as 1-bit signed data.)

DM00000
S LD.S DM00000 #00100
#00100

DM00000 is smaller than #00100, and the contact turns OFF.


(-1)

"About suffixes" page 1-28

2-18
2-3 Comparison Contact Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Comparison Contact Instructions

2-19
2-3 Comparison Contact Instructions
= <= (U)
Contact type The result of having performed comparison calcu-
.D
< >= .S
comparison
calculation
lation on the binary data causes the instruction itself
to turn ON/OFF as a contact.
.L
BASIC INSTRUCTIONS

> <>
Ladder program Input method
S1 L D S1 S2
*
* ( * S1 S2 )
S2

S1
A N D * S1 S2
*
( S1 S2 )
S2 *
2
At * , program = < > <> <= or >=.
Comparison Contact Instructions

S1
* O R * S1 S2
S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — — — —
S2 — — — — — — — — — — —

S1 , S2 : Specifies the data to be compared or the device to which that data is stored.

Explanation of Operation: (.U) .S (16-bit binary data comparison instructions)


= < > <= >= <>
Unsigned 16-bit binary data specified by S1 and S2 is compared for the
arithmetic calculation. The result of the comparison calculation causes the instruction
itself to turn ON/OFF as a contact.
=.S <.S >.S <=.S >=.S <>.S
Signed 16-bit binary data specified by S1 and S2 is compared for the arithmetic
calculation. The result of the comparison calculation causes the instruction itself to turn
ON/OFF as a contact.

Instruction Operation ON Operation OFF


LD= AND= OR=
S1 = S2 S1 ≠ S2
LD=.S AND=.S OR=.S
LD< AND< OR<
S1 < S2 S1 ≥ S2
LD<.S AND<.S OR<.S
LD> AND> OR>
S1 > S2 S1 ≤ S2
LD>.S AND>.S OR>.S
LD<= AND<= OR<=
S1 ≤ S2 S1 > S2
LD<=.S AND<=.S OR<=.S
LD>= AND>= OR>=
S1 ≥ S2 S1 < S2
LD>=.S AND>=.S OR>=.S
LD<> AND<> OR<>
S1 ≠ S2 S1 = S2
LD<>.S AND<>.S OR<>.S

Operation flag
CR2009 ..... No change in state
CR2010 ..... No change in state
CR2011 ..... No change in state
CR2012 ..... ON when indirect specification range is inappropriate. Otherwise, OFF

2-20
2-3 Comparison Contact Instructions

Explanation of Operation: .D .L (32-bit binary data comparison instructions)

BASIC INSTRUCTIONS
=.D <.D >.D <=.D >=.D <>.D
Unsigned 32-bit binary data specified by S1 and S2 is compared for the
arithmetic calculation. The result of the comparison calculation causes the instruction
itself to turn ON/OFF as a contact.
=.L <.L >.L <=.L >=.L <>.L
Signed 32-bit binary data specified by S1 and S2 is compared for the arithmetic
calculation. The result of the comparison calculation causes the instruction itself to turn
ON/OFF as a contact.

Instruction Operation ON Operation OFF 2


LD=.D AND=.D OR=.D
[ S1 +1 • S1 ] = [ S2 +1 • S2 ] [ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ]

Comparison Contact Instructions


LD=.L AND=.L OR=.L
LD<.D AND<.D OR<.D
[ S1 +1 • S1 ] < [ S2 +1 • S2 ] [ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ]
LD<.L AND<.L OR<.L
LD>.D AND>.D OR>.D
[ S1 +1 • S1 ] > [ S2 +1 • S2 ] [ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ]
LD>.L AND>.L OR>.L
LD<=.D AND<=.D OR<=.D
[ S1 +1 • S1 ] ≤ [ S2 +1 • S2 ] [ S1 +1 • S1 ] > [ S2 +1 • S2 ]
LD<=.L AND<=.L OR<=.L
LD>=.D AND>=.D OR>=.D
[ S1 +1 • S1 ] ≥ [ S2 +1 • S2 ] [ S1 +1 • S1 ] < [ S2 +1 • S2 ]
LD>=.L AND>=.L OR>=.L
LD<>.D AND<>.D OR<>.D
[ S1 +1 • S1 ] ≠ [ S2 +1 • S2 ] [ S1 +1 • S1 ] = [ S2 +1 • S2 ]
LD<>.L AND<>.L OR<>.L =

<

>

Operation flag <=

>=
See "Operation flag" on previous page.
<>

Execution Timing
All contact type comparison calculation instructions are executed at every scan.

Sample Program
Constant #00100 is compared with the current value of counter C000, and output relays 00500 and
00501 are turned ON/OFF by the comparison result.

00000 #09999 When the current value of counter C000 is com-


C000 pared with constant #01000
00001
CR2002 C000 DM00000 At (1), output relay 00500 turns ON when the
LDA STA
current value of C000 is smaller than the con-
DM00000 00500
stant #01000.
< (1)
#01000 At (2), output relay 00502 turns ON when the
DM00000 00501 current value of C000 is equal to the constant
= (2) #01000.
#01000
DM00000 00502 At (3), output relay 00502 turns ON when the
> (3) current value of C000 is greater than the con-
#01000
stant #01000.
DM00000 DM00000 00503
>= <= (4) At (4), output relay 00503 turns ON when the
#01000 #02000
current value of C000 is the same value or
greater than the constant #01000 or the same
value or smaller than the constant #02000.

2-21
2-4 Output Instructions

2-4 Output Instructions


BASIC INSTRUCTIONS

Output instructions are for turning specified bit devices ON/OFF according to the ON/OFF state
before that instruction.

Output Instruction List


There are 12 output instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Out OUT Outputs the previous ON/OFF state. 2-24
2 Out bar OUB Inverts and outputs the previous ON/OFF state.
Output Instructions

Set SET Turns the device ON and holds it in this state. 2-26

Reset RES Turns the device OFF.

Keep KEEP Sets and resets the target relay according to SET and 2-28
RES inputs.
Diff up DIFU Scans the target relay once (up differential) at the up 2-30
edge of the previous state.
Diff down DIFD Scans the target relay once (down differential) at the
down edge of the previous state.
ON delay ONDL The target relay performs ON delay operation. 2-32

OFF delay OFDL The target relay performs OFF delay operation.

One shot SHOT The target relay performs one-shot operation. 2-34

Flicker FLIK The target relay performs operation of the flicker 2-36
circuit.
Alternate ALT The target relay performs operation of the alternate 2-38
circuit.

2-22
2-4 Output Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Output Instructions

2-23
2-4 Output Instructions
OUT Out
Outputs to a device.
OUB Out bar
BASIC INSTRUCTIONS

Ladder Input method


Execution condition D
O U T D O D
Y D
D
O U B D ( O B D )

Available Bit Devices Word Devices Constant Indirect Operation Flag


2 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM CR
2009
CR
2010
CR
2011
CR
2012

D — — — — — — — — — — — — — — — — —
Output Instructions

D : Specifies the device to turn ON.

Explanation of Operation
OUT Outputs the ON/OFF state before that instruction to the device specified by D .
OUB Outputs the inverted ON/OFF state before that instruction to the device specified by
D .

The OUT and OUB instructions are coil drive instructions for output relays and internal auxiliary
relays, and are not used for input relays, timers, and counters.

Note: Double Coils


When multiple OUT and OUB instructions are used on the same output relay as follows,
the instruction programmed later is given priority on the program.
When input relay 00001 is OFF, output relay 00500 does not turn ON even if input
relay 00000 turns ON.
00000 00500 00000 00500
SET

00001 00500 00001 00500

Operation flag
The operation flag does not change state.

2-24
2-4 Output Instructions

Execution Timing

BASIC INSTRUCTIONS
OUT Outputs the ON/OFF state before the OUT instruction at every scan.
OUB Outputs the ON/OFF state before the OUB instruction at every scan.

Scan
ON

Execution condition
OFF

ON

Bit device specified by the OUT


OFF
instruction
ON 2
Bit device specified by the OUB
OFF

Output Instructions
instruction

Sample Program
When input relay 00000 is ON, output relay 00500 turns ON. When input relay 00000 is OFF, output
relay 00500 turns OFF.
When input relay 00001 is OFF, output relay 00501 turns ON. When input relay 00001 is ON, output
relay 00501 turns OFF.

00000 00500
OUT

OUB
00001 00501 SET

RES

KEEP

DIFU

DIFD

ONDL

OFDL

SHOT

FLIK

ALT

2-25
2-4 Output Instructions
SET SET Set Turns the device ON and holds it in this state.

RES RES Reset Turns the device OFF.


BASIC INSTRUCTIONS

Ladder program Input method


Execution condition D
S E T D
SET
( S D )
Execution condition D R E S D
RES R D
R S T D

Available Bit Devices Word Devices Constant Indirect Operation Flag


2 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM CR
2009
CR
2010
CR
2011
CR
2012

SET D — — — — — — — — — — — — — — —
Output Instructions

RES D — — — — — — — — —

D : Specifies the device to turn ON/OFF.

Explanation of Operation
SET When the execution condition is ON, the device specified by D turns ON. Once this
device is turned ON, the device is held in an ON state even if the execution condition
turns OFF. (Turn ON devices OFF by the RES instruction.) When the execution
condition is OFF, no processing is executed.
* The current value of timers (TMR, TMH, TMS) and up-down counters (UDC) become
"0".
The current value of counters (C) and up-down timers (UDT) becomes the same
value as the setting value.

00001 00501 ON
SET 00001
OFF
ON
00002 00501 00002
RES OFF
ON

00501
OFF

RES When the execution condition turns ON, the device specified by D turns OFF.
* The current value of timers (TMR, TMH, TMS) becomes the same value as the
setting value.
The current value of counters (C), up-down counters (UDC), up-down timers (UDT),
and high-speed counters (CTH) becomes "0".

Note: The SET or RES instruction programmed later in the program is given priority which of the
instructions is programmed first.

■ About differences between the SET and RES instructions and the KEEP instructions
Basically, the SET and RES instructions and the KEEP instruction execute the same operation.
• As the SET and RES instructions can be used independently, the order of these two
instructions can swapped in the program. There is also the advantage that a program can be
inserted between the SET and RES instructions.
• Fewer program steps are used with the KEEP instruction, so the number of programmed steps
can be reduced when the KEEP instruction is used many times in a program.
"KEEP instruction" page 2-28

2-26
2-4 Output Instructions

• In the following example, when inputs 00000 and 00001 both are ON, output 00500 turns OFF
in the case of the KEEP instruction. With the SET and RES instructions, the SET instruction

BASIC INSTRUCTIONS
programmed later is enabled, and output 00500 turns ON.

00000 00500
RES

00001 00500
SET

00000 KEEP
SET
00500
2
00001

Output Instructions
RES

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Scan
ON OUT
Execution condition OUB
OFF

SET
SET/RES instruction Execution Execution
RES

KEEP
Sample Program DIFU

■ Example of bit device set reset DIFD

ONDL
Output relay 00500 turns ON when one of the following conditions is satisfied:
OFDL
• Input relay 00000 turns ON. SHOT

• Both of input relays 00001 and 00002 turns ON. FLIK

ALT
• Input relay 00003 turns ON.
Also, output relay 00501 turns OFF when one of the following conditions is satisfied:
• Input relay 00004 turns ON.
• Input relay 00005 turns ON.
• Input relay 00006 turns ON.

00000 00500
SET

00001 00002

00003

00004 00501
RES

00005

00006

2-27
2-4 Output Instructions
KEEP Turns ON the relay specified by SET condition ON
SET
KEEP RES
Keep and is held in this state. Turns OFF the relay specified
by RES condition ON.
BASIC INSTRUCTIONS

Ladder program Input method


SET condition KEEP
SET K E E P D
D
RES condition
RES

Available Bit Devices Word Devices Constant Indirect Operation Flag


2 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM CR
2009
CR
2010
CR
2011
CR
2012

D — — — — — — — — — — — — — — — — —
Output Instructions

D : Specifies the device to be set or reset.

Explanation of Operation
D is turned ON when the SET condition is ON and the RES condition is OFF.
D is turned OFF when the SET condition is OFF and the RES condition is ON.
D is turned OFF when the SET and RES conditions both are ON. (The RES condition is given
priority.)
The state of D is held when the SET and RES conditions both are OFF.

Note: In the following program example, a double coil is formed, so the OUT 00500 pro-
grammed later is given priority.

00000 KEEP
SET
00500
00001
RES

00002 00500

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Scan
ON

Execution condition
OFF

KEEP instruction Execution Execution

2-28
2-4 Output Instructions

Sample Program

BASIC INSTRUCTIONS
When input relay 00000 is ON and input relay 00001 is OFF, output relay 00500 is turned ON and
is held in this state.
When input relay 00001 is ON, output relay 00500 is turned OFF. When input relays 00000 and
00001 are OFF, the state of output relay 00500 is held.

00000 KEEP
SET
00500
00001
RES
2

Output Instructions
Internal auxiliary relay hold function
The power interruption hold (latch) for the internal auxiliary relays can be set by the memory switch
instruction (MEMSW).
"MEMSW instruction" page 3-6
A relay that has been set once can be held at power OFF also by combining this internal auxiliary
relay with the KEEP instruction (e.g. SET instruction or RES instruction).

MEMSW1
$0001
OUT
00001 KEEP
OUB
SET
SET
01000
RES
00002
RES KEEP

DIFU

01000 00500 DIFD

ONDL

OFDL

SHOT

FLIK

ALT

2-29
2-4 Output Instructions Turns a device ON for one scan only at the up edge of
DIFU DIFU Diff up the execution condition.
Turns a device ON for one scan only at the down edge
DIFD DIFD Diff down
of the execution condition.
BASIC INSTRUCTIONS

Ladder program Input method

Execution condition D D I F U D
DIFU P L S D
U D
Execution condition D D I F D D
DIFD P L F D
D D

2 Available
Devices I O
Bit Devices
Internal
T C CTC CR DM TM T
Word Devices Constant Indirect

C CTH CTC CM #/$ #TM


Operation Flag
CR CR CR CR
auxiliary 2009 2010 2011 2012
Output Instructions

D — — — — — — — — — — — — — — — — — — —

D : Specifies the device to turn ON.

Explanation of Operation
DIFU The device specified by D is turned ON for one scan only at the up edge of the
execution condition.
Duplicate use of the operand with other DIFU instructions is not allowed.

DIFD The device specified by D is turned ON for one scan only at the down edge of the
execution condition.
Duplicate use of the operand with other DIFD instructions is not allowed.

Precautions when using the DIFD instruction in an extended ladder.


When the DIFD instruction is programmed as in
00000 01000 01000 00500
(a) DIFD (a), input 01000 turns ON in scans in which input
00000 is OFF. For this reason, output 00500 does
not turn ON in the ladder as it is without 00000 and
00000 01000 01000 turning ON simultaneously.
DIFD
(b)
01000 00500 If the DIFD instruction is programmed as in (b) or
(c), output 00500 can be turned ON in scans in
which input 00000 is OFF.
00000 01000 01000 00500
(c) DIFU
Even if the DIFU instruction is programmed as in
00000 01000 01000 00500
(d), input 01000 turns ON and output 00500 turns
(d) DIFU ON at the same time that input 00000 turns ON.

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,
and between the STG and JMP/ENDS instructions and in a sub-routine program.
"Precautions when using differential execution type instructions" page 1-6

2-30
2-4 Output Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
DIFU The specified operand is turned ON for one scan only at the up edge of the execution
condition.
DIFD The specified operand is turned ON for one scan only at the down edge of the execution
condition.

Scan
ON
2

Output Instructions
Execution condition
OFF

DIFU instruction Execution Execution

DIFD instruction Execution Execution

Sample Program
Example of edge synchronization
OUT
When input relay 00001 is OFF at the up edge of input relay (timing input) 00000, output relay 00500
OUB
is turned ON, and is held at this state until input relay 00002 turns ON.
SET

RES

00000 01000 KEEP


DIFU DIFU

DIFD
01000 00001 01001 ONDL

OFDL

SHOT
01001 00002 00500
FLIK

ALT
00500

2-31
2-4 Output Instructions
ONDL ONDL ON delay The specified relay operates as an ON delay timer.

OFDL OFDL OFF delay The specified relay operates as an OFF delay timer.
BASIC INSTRUCTIONS

Ladder program Input method


Execution condition n
ONDL O N D L n D
D
Execution condition n
OFDL O F D L n D
D

Available Bit Devices Word Devices Constant Indirect Operation Flag


2 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM
CR
2009
CR
2010
CR
2011
CR
2012

n — — — — — — — — — — — — — — — — — —
Output Instructions

D — — — — — — — — — — — — —

n : Specifies the ON delay/OFF delay setting value (0 to 65535) or the device to which the
setting value is stored. Specify the delay in 10 ms units. The delay cannot be specified in
Hex ($).
D : Specifies the device on which ON delay and OFF delay operation is to be performed.

Explanation of Operation
ONDL The device specified by D is operated as an ON delay timer.
(1) D is turned ON after n x 10 ms when the execution condition is ON.
(2) When the execution condition turns OFF, the device specified by D simulta-
neously turns OFF.
(3) If the execution condition turns OFF before n x 10 ms, D does not turn ON.

(1) (2) (3)

ON

Execution condition
OFF
ON

D
OFF

n X10 ms n X 10 ms

OFDL The device specified by D is operated as an OFF delay timer.


(1) D turns ON simultaneously when the execution condition turns ON.
(2) D is turned OFF after n x 10 ms after the execution condition turns OFF.
(3) If the execution condition turns ON before n x 10 ms, D does not turn OFF.

(1) (2) (3)

ON

Execution condition
OFF

ON
D
OFF

n X10 ms n X10 ms

The error of the ONDL and OFDL timers is "within ±(10 ms +1 scan time)."

2-32
2-4 Output Instructions

Note: • The ON delay operates for one scan only even if the setting value of the ONDL instruction
is set to "0".

BASIC INSTRUCTIONS
• The OFF delay operates for one scan only even if the setting value of the OFDL
instruction is set to "0".
• Care must be paid to operation when writing in the RUN mode. For details, see CPU
User's Manual, "Cautions during Writing in the RUN Mode."

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,
and between the STG and JMP/ENDS instructions and in a sub-routine program.
2

Output Instructions
"Precautions when using timer instructions" page 1-13

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

OUT
Sample Program OUB

SET
(1) When input relay 00000 turns ON for three seconds or more, output relay 00500 turns ON. When
RES
input relay 00000 turns OFF, output relay 00500 also turns OFF.
KEEP
(2) When input relay 00001 turns ON, output relay 00501 turns ON. Output relay 00501 turns OFF
DIFU
when the value set at data memory DM00000 has elapsed after input relay 00001 turns OFF.
DIFD

ONDL
00000 #00300
OFDL
ONDL (1)
00500 SHOT

00001 DM00000 FLIK

OFDL (2) ALT


00501

2-33
2-4 Output Instructions
SHOT SHOT One shot The specified relay operates as a one-shot timer.

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition n
S H O T n D
SHOT
D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

n : Specifies the setting value (0 to 65535) of the one-shot timer or the device to which the
2 setting value is stored. Specify the delay in 10 ms units. The delay cannot be specified in
Hex ($).
Output Instructions

D : Specifies the device on which one-shot timer operation is to be performed.

Explanation of Operation
SHOT The device specified by D turns ON at the up edge of the execution condition, and
turns OFF n x 10 ms later.
Execution condition up edges are ignored for the duration that the device specified by
D is ON.

ON

Execution condition
OFF

ON

D
OFF

n X 10 ms n X 10 ms n X 10 ms

* The error of the SHOT timer is "within ±(10 ms + 1 scan time)."

Note: • The one-shot timer operates for one scan only even if the setting value of the SHOT
instruction is set to "0".
• Care must be paid to operation when writing in the RUN mode. For details, see CPU
User's Manual, "Cautions during Writing in the RUN Mode."

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,
and between the STG and JMP/ENDS instructions and in a sub-routine program.
"Precautions when using timer instructions" page 1-13

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

2-34
2-4 Output Instructions

Sample Program

BASIC INSTRUCTIONS
(1) Output relay 00500 turns ON for 0.2 seconds at the up edge of input relay 00000. Output relay
00500 stays ON for 0.2 seconds after the up edge of input relay 00000 even if input relay 00000
turns OFF.
(2) When input relay 00001 turns ON, output relay 00501 turns ON. Output relay 00501 turns OFF
when the value set at data memory DM00000 has elapsed after input relay 00001 turns OFF.

00000 #00020
SHOT (1)
00500
00001 DM00000
SHOT
00501
(2) 2

Output Instructions
OUT

OUB

SET

RES

KEEP

DIFU

DIFD

ONDL

OFDL

SHOT

FLIK

ALT

2-35
FLIK
2-4 Output Instructions
FLIK Flicker The specified relay is used as the flicker circuit.

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition FLIK


n1 n2 D F L I K n1 n2 D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n1 — — — — — — — — — — — — — — — — — —
n2 — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

2 n1 : Specifies the setting value (0 to 65535) at which D turns ON or the device to which the
setting value is stored. Specify the delay in 10 ms units. The delay cannot be specified in
Output Instructions

Hex ($).
n2 : Specifies the setting value (0 to 65535) at which D turns OFF or the device to which the
setting value is stored. Specify the delay in 10 ms units. The delay cannot be specified in
Hex ($).
D : Specifies the device on which flicker circuit operation is to be performed.

Explanation of Operation
FLIK (1) The relay specified by D is repeatedly turned ON/OFF for the duration that the
execution condition is ON. The specified relay is executed from the ON state.
The time that the device is ON is n1 x 10 ms, and the time that the device is OFF
is n2 x 10 ms.
(2) D turns OFF when the execution condition turns OFF even with D in an ON
state.

(1) (2)
ON
Execution condition
OFF
ON

D
OFF

n1 X 10 ms n2 X 10 ms n1 X 10 ms n2 X 10 ms n1 X 10 ms

* The error of the FLIK instruction is "within (±10 ms + 1 scan time)."

Note: • The flicker circuit turns ON or OFF for one scan only even if the setting value of the FLIK
instruction is set to "0".
• Care must be paid to operation when writing in the RUN mode. For details, see CPU
User's Manual, "Cautions during Writing in the RUN Mode."

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,
and between the STG and JMP/ENDS instructions and in a sub-routine program.
"Precautions when using timer instructions" page 1-13

Operation flag
The operation flag does not change state.

2-36
2-4 Output Instructions

Execution Timing

BASIC INSTRUCTIONS
The instruction is executed at every scan.

Sample Program
When input relay 00000 is ON, output relay 00500 repeatedly turns ON for one second and turns
OFF for two seconds.

00000 FLIK
#00100 #00200 00500

Output Instructions
OUT

OUB

SET

RES

KEEP

DIFU

DIFD

ONDL

OFDL

SHOT

FLIK

ALT

2-37
2-4 Output Instructions
ALT ALT Alternate Inverts the state of the relay.

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition D
ALT A L T D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D — — — — — — — — — — — — — — — — —

D : Specifies the device whose state is to be inverted.

2 Explanation of Operation
The ON/OFF state of the device specified by D is inverted at the up edge of the execution condition.
Output Instructions

ON
Execution condition
OFF
ON

D
OFF

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,
and between the STG and JMP/ENDS instructions and in a sub-routine program.
"Precautions when using differential execution type instructions" page 1-6

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at the up edge of the execution condition.

Sample Program
The ON/OFF state of output relay 00500 is inverted at the up edge of input relay 00000.

00000 00500
ALT

2-38
2-4 Output Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Output Instructions
OUT

OUB

SET

RES

KEEP

DIFU

DIFD

ONDL

OFDL

SHOT

FLIK

ALT

2-39
2-5 Bit Output Instructions

2-5 Bit Output Instructions


BASIC INSTRUCTIONS

Bit output instructions specify the bits of word devices and handle them as output relays. These
instructions are for turning ON/OFF the bits of word devices by the ON/OFF state before the bit
output instruction.

Bit Output Instruction List


There are four bit output instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


2 Bit out BOUT Outputs the previous state to the specified bit of the
reference word device.
2-44
Bit Output Instructions

Bit out bar BOUB Inverts and outputs the previous state to the specified bit
of the reference word device.
Bit set BSET Turns the specified bit of the reference word device ON 2-46
and holds this state.
Bit reset BRES Turns the specified bit of the reference word device
OFF.

■ About word device bit specification


Word devices that can be used in bit output instructions are DM (data memory), TM (temporary
data memory) and CM (control memory).
These word devices are configured in 16 bits.

bit bit
15 0

1-word device

With bit output instructions, the bits of word devices are specified and handled as contacts.

[Example] When input relay 00000 is ON, data memory DM00000 bit 6 is turned ON. When input
relay 00000 is OFF, bit 6 is turned OFF.

00000 DM00000
B
#06

bit bit bit


15 6 0
DM00000

2-40
2-5 Bit Output Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Bit Output Instructions

2-41
2-5 Bit Output Instructions
BOUT B Bit out
Reflects the state of the input in the specified bit of the
word device.
BOUB B Bit out bar
BASIC INSTRUCTIONS

Ladder program Input method


Execution condition D
B B O U T D n
n ( B O D n )
D
B B O U B D n
n ( B O B D n )

Available Bit Devices Word Devices Constant Indirect Operation Flag


2 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM CR
2009
CR
2010
CR
2011
CR
2012

D — — — — — — — — — — — — — — — — —
Bit Output Instructions

n — — — — — — — — — — — — — — —

D : Specifies the device whose input state is to be reflected.


n : Specifies which bit (nth bit) of D is to be reflected. Specify within the range 0 to 15.

Explanation of Operation
BOUT Outputs the input state (before this instruction) to the n th bit of the device specified
by D .
BOUB Inverts and outputs the input state (before this instruction) to the n th bit of the
device specified by D .

bit bit
15 D 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

15th bit n th bit 0th bit


1st bit

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Sample Program
When input relay 00000 is ON, data memory DM00000 bit 5 is turned ON. When input relay 00000
is OFF, data memory DM00000 bit 0 is turned ON.

00000 DM00000
B
#05
DM00000
B
#00

2-42
2-5 Bit Output Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Bit Output Instructions


BOUT

BOUB

BSET

BRES

2-43
2-5 Bit Output Instructions
BSET BSET Bit set Turns the specified bit of the word device ON and holds
this state.
BRES BRES Bit reset Turns the specified bit of the word device OFF.
BASIC INSTRUCTIONS

Ladder program Input method


Execution condition D
BSET B S E T D n
n ( B S D n )

Execution condition D
BRES B R E S D n
n ( B R D n )

2 Available
Devices I O
Bit Devices
Internal
auxiliary T C CTC CR DM TM T
Word Devices
C CTH CTC CM #/$ #TM
Constant Indirect Operation Flag
CR CR CR CR
2009 2010 2011 2012
Bit Output Instructions

D — — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

D : Specifies the device including the bit to be set or reset.


n : Specifies the bit No. to be set/reset. Specify within the range 0 to 15.

Explanation of Operation
BSET When the execution condition is ON, the n th bit of the device specified by D
is turned ON and held in this state.

bit bit
15 D 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0

15th bit n th bit ON 0th bit

BRES When the execution condition is ON, the n th bit of the device specified by D
is turned OFF.

bit bit
15 D 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

15th bit n th bit OFF 0th bit

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

2-44
2-5 Bit Output Instructions

Sample Program

BASIC INSTRUCTIONS
When input relay 00000 is ON, data memory DM00000 bit 5 is set.
When input relay 00001 is ON, data memory DM00000 bit 5 is reset.

00000 DM00000
BSET
#05
00001 DM00000
BRES
#05

Bit Output Instructions


BOUT

BOUB

BSET

BRES

2-45
2-6 Timer/Counter Instructions

2-6 Timer/Counter Instructions


BASIC INSTRUCTIONS

Timer/counter instructions are for executing timer and counter operations. They are also used for
contact operands for output to devices in combination with an output instruction or as execution
conditions for basic instructions, applied instructions, arithmetic calculation instructions, and
extended instructions.

Timer/Counter Instruction List


There are seven timer/counter instructions as follows.

2 Instruction
Timer TMR
Mnemonic Brief Description of Operation
Operation unit 100 ms, 32-bit subtraction type ON delay
Page
2-48
timer
Timer/Counter Instructions

High-speed timer TMH Operation unit 10 ms, 32-bit subtraction type ON delay 2-50
timer
High-speed 1 ms TMS Operation unit 1 ms, 32-bit subtraction type ON delay 2-52
timer timer
Counter C 32-bit addition counter 2-56

Interval timer ITVL Sets the mode, and measures the pulse interval and 2-60
DM average values.
Up-down counter UDC 32-bit up-down counter 2-64

Up-down timer UDT Operation unit 10 ms, 32-bit up-down timer 2-66

2-46
2-6 Timer/Counter Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Timer/Counter Instructions

2-47
2-6 Timer/CounterTMR
Instructions Operation unit 100 ms, 32-bit subtraction type
TMR Timer
ON delay timer

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition S
T n T M R n S
T n S
T I M n S
T n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

2 n
S
— — — — — — — — — — — — — —
— — — — — — — — — — — — — —


— — — —
Timer/Counter Instructions

n : Specifies the device No. (0 to 511) of the timer.


S : Specifies the setting value of the timer. Set within the range 0 to 4294967295. The timer
setting value cannot be specified in $(Hex).

Explanation of Operation
When the execution condition is ON, the timer specified by n is started up. The value (setting
value) specified by S becomes the current value when the timer is started up. The current value
is decremented (-1) every 100 ms.
When the current value reaches "#00000", timer T n turns ON.
When the execution condition turns OFF, timer T n turns OFF, and the current value is reset.

Scan
ON
Execution condition
OFF
Value specified by S

Current value

#00000

Timer T n ON

* The device No. n of the timer cannot be used in duplicate with TMR, TMH, TMS, C, UDC, or
UDT instructions.
* The error of the TMR instruction is "within ±(100 ms 1 scan time)."

[Tip]
When the setting value is 0, and the execution condition is ON for two scans or more, timer T n
turns ON.
"Precautions when using timer instructions" page 1-13
"Example of changing timer setting values" page 2-54
"Example of changing timer current values" page 2-54
"Example of reading timer current values" page 2-55

2-48
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed at each scan for the duration that the execution conditions are ON.

Sample Program
When the input relay 00000 turns ON, timer T000 turns ON for three seconds, and output relay 00500
turns ON. 2

Timer/Counter Instructions
00000 #00030
T000

T000 00500

TMR

TMH

TMS

ITVL

UDC

UDT

2-49
2-6 Timer/CounterTMH
Instructions Operation unit 10 ms, 32-bit subtraction type ON delay
TMH High-speed timer timer

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition S
T
H n T M H n S
T H n S
T I M H n S
T n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

2 n
S
— — — — — — — — — — — — — —
— — — — — — — — — — — — — —


— — — —
Timer/Counter Instructions

n : Specifies the device No. (0 to 511) of the high-speed timer.


S : Specifies the setting value of the high-speed timer. Set within the range 0 to 4294967295.
The timer setting value cannot be specified in $(Hex).

Explanation of Operation
When the execution condition is ON, the timer specified by n is started up. The value (setting
value) specified by S becomes the current value when the timer is started up. The current value
is decremented (-1) every 10 ms.
T
When the current value reaches "#00000", the contact specified by timer H n turns ON.
T
When the execution condition turns OFF, the contact specified by timer H n turns OFF, and the
current value is reset.

Scan
ON
Execution condition
OFF
Value specified by s

Current value

#00000

Timer T
H n ON

* The device No. n of the high-speed timer cannot be used in duplicate with the TMR, TMH,
TMS, C, UDC, or UDT instructions.
* The error of the TMH instruction is "within ±(10 ms +1 scan time)."

[Tip]

When the setting value is 0, and the execution condition is ON for two scans or more, timer HT n
turns ON.
"Precautions when using timer instructions" page 1-13
"Example of changing timer setting values" page 2-54
"Example of changing timer current values" page 2-54
"Example of reading timer current values" page 2-55

2-50
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Sample Program
When input relay 00000 turns ON, timer HT 000 turns ON 0.5 seconds later, and output relay 00500
turns ON. 2

Timer/Counter Instructions
00000 #00050
T
H 000

T000 00500

TMR

TMH

TMS

ITVL

UDC

UDT

2-51
2-6 Timer/CounterTMS
Instructions Operation unit 1 ms, 32-bit subtraction type
TMS High-speed 1 ms timer
ON delay timer

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition S
T n
S n T M S S
( T S n S )

T n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — — —
2 S — — — — — — — — — — — — — — —
Timer/Counter Instructions

n : Specifies the device No. (0 to 511) of the high-speed 1 ms timer.


S : Specifies the setting value of the high-speed 1 ms timer. Set within the range 0 to
4294967295. The timer setting value cannot be specified in $(Hex).

Explanation of Operation
When the execution condition is ON, the timer specified by n is started up. The value (setting
value) specified by S becomes the current value when the timer is started up. The current value
is decremented (-1) every 1 ms.
T
When the current value reaches "#00000", timer S n turns ON.
T
When the execution condition turns OFF, timer S n turns OFF, and the current value is reset.

Scan
ON
Execution condition
OFF

Value specified by s

Current value

#00000

Timer T
S n ON

* The device No. n of the high-speed 1 ms timer cannot be used in duplicate with the TMR, TMH,
TMS, C, UDC, or UDT instructions.
* The error of the TMS instruction is "within ±(1 ms +1 scan time)."

[Tip]
When the setting value is 0, and the execution condition is ON for two scans or more, timer ST n
turns ON.
"Precautions when using timer instructions" page 1-13
"Example of changing timer setting values" page 2-54
"Example of changing timer current values" page 2-54
"Example of reading timer current values" page 2-55

2-52
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Sample Program
When input relay 00000 turns ON, timer ST 000 turns ON 7ms later, and output relay 00500 turns ON.
2
00000 #00007

Timer/Counter Instructions
T
S 000

T000 00500

TMR

TMH

TMS

ITVL

UDC

UDT

2-53
2-6 Timer/Counter Instructions

When reading or changing timer setting values or current values on a ladder, use the LDA, STA
and MOV instructions. When a timer is taken as an operand, LDA handles the current value, STA
BASIC INSTRUCTIONS

the setting value, and MOV the current value.

■ Example of changing timer setting values


(1) To change the setting value within the range 0 to 65535
When input relay 00000 is ON, the setting value of timer T000 is set to #00100.
When input relay 00000 is OFF, the setting value of timer T000 is changed to the value
currently stored to data memory DM00000.

2 00000 #00100
LDA
T000
STA
Timer/Counter Instructions

00000 DM00000 T000


LDA STA

• Even if values are changed by a suffix .U instruction, the value is automatically extended to 32
bits, and is stored to the setting value of the timer.

(2) To change the setting value within the range 0 to 4294967295


When input relay 00000 is ON, the setting value of timer T000 is set to #100000.
When input relay 00000 is OFF, the setting value of timer T000 is changed to the value
currently stored to data memories DM00000 and DM00001.

00000 #100000 T000


LDA.D STA.D

00000 DM00000 T000


LDA.D STA.D

Note: Operation as a result of executing the STA instruction:


When the current value ≤ setting value, the current value does not change.
When the current value > setting value, the current value is changed to the same
value as the setting value.

■ Example of changing timer current values


(1) When the current value changes within the range 0 to 65535
When input relay 00000 is ON, the current value of timer T000 is set to #00100.
When input relay 00000 is OFF, the current value of timer T000 is changed to the value
currently stored to data memory DM00000.

00000 MOV
#00100 T000

00000 MOV
DM00000 T000

• Even if values are changed by a suffix .U instruction, the value is automatically extended to 32
bits, and is stored to the current value of the timer.

2-54
2-6 Timer/Counter Instructions

(2) To change the current value within the range 0 to 4294967295


When input relay 00000 is ON, the current value of timer T000 is set to #100000.

BASIC INSTRUCTIONS
When input relay 00000 is OFF, the current value of timer T000 is changed to the value
currently stored to data memories DM00000 and DM00001.

00000 MOV.D
#100000 T000

00000 MOV.D
DM00000 T000

Timer/Counter Instructions
Note: Operation as a result of executing the MOV instruction:
When the current value ≤ setting value, the current value is changed to the written
value.
When the current value > setting value, the current value is changed to the same
value as the setting value.

■ Example of reading timer current values


(1) When the current value changes within the range 0 to 65535
When input relay 00000 is ON, the current value of timer T000 is stored to data memory
DM00000.
TMR
When input relay 00001 is ON, the current value of timer T001 is stored to data memory
TMH
DM00001.
TMS

C
00000 T000 DM00000
ITVL
LDA STA
UDC

00001 MOV UDT

T001 DM00001

(2) When the current value changes within the range 0 to 4294967295
When input relay 00000 is ON, the current value of timer T000 is stored to data memories
DM00000 and DM00001.
When input relay 00001 is ON, the current value of timer T000 is stored to data memories
DM00010 and DM00011.

00000 T000 DM00000


LDA.D STA.D

00001 MOV.D
T000 DM00010

"LDA Instruction" page 4-6


"STA Instruction" page 4-8
"MOV Instruction" page 4-14
"About suffixes" page 1-28

2-55
2-6 Timer/Counter CInstructions
C Counter 32-bit addition counter

Ladder program Input method


BASIC INSTRUCTIONS

Execution condition S1
C n C n S1 S2
S2 ( C N T n S1 S2 )

C n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

2 n
S1
— — — — — — — — — — — — — —
— — — — — — — — — — — — — —


— — — —

S2
Timer/Counter Instructions

n : Specifies the device No. (0 to 511) of the counter.


S1 : Specifies the setting value of the counter. Set within the range 0 to 4294967295. The counter
setting value cannot be specified in $(Hex).
S2 : Specifies the device to be used for count input.

Explanation of Operation
When the execution condition is ON, "1" is added (incremented by one) to the current value of the
counter specified by n at the up edge of the count input specified by S2 . When the current
value becomes the same as the setting value specified by S1 , counter C n turns ON. When
the execution condition is OFF, counter C n turns OFF, and the current value is reset to 0. The
execution condition is used as reset input.
ON
00000 ← Reset input #00012
Count input S2
C000 OFF
00001 ON
Execution condition
C000 OFF

S1
S1
11
8 9 10
7
6
4 5
2 3
Current value 1

ON
C n

* The response speed of the counter instruction is reliant on the scan time.
"About maximum count speed of counters" page 1-14
* n cannot be used in duplicate with the TMR, TMH, TMS, C, UDC, or UDT instructions.

[Tip]
• When "0" is set to the setting value, the counter stays ON at all times when the execution
condition is ON.
• The current value of counter C is held in the PROG mode or when the power is turned OFF.
(for five years or more at 25°C The current value can be cleared when the power is turned OFF
by setting the memory switch instruction (MEMSW).
"MEMSW instruction" page 3-6

2-56
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

Sample Program
When input relay 00001 is counted ten times, output relay 00500 turns ON.
When input relay 00000 turns ON, counter C000 is reset. 2

Timer/Counter Instructions
00000 #00010
C000
00001

C000 00500

TMR

TMH

TMS

ITVL

UDC

UDT

2-57
2-6 Timer/Counter Instructions

When reading or changing counter setting values or current values on a ladder, use the LDA, STA
and MOV instructions. When a counter is taken as an operand, LDA handles the current value,
BASIC INSTRUCTIONS

STA the setting value, and MOV the current value.

■ Example of changing counter setting values


(1) To change the setting value within the range 0 to 65535
When input relay 00000 is ON, the setting value of counter C000 is set to #00100.
When input relay 00000 is OFF, the setting value of counter C000 is changed to the value
currently stored to data memory DM00000.

2 00000 #00100
LDA
C000
STA
Timer/Counter Instructions

00000 DM00000 C000


LDA STA

• Even if values are changed by a suffix .U instruction, the value is automatically extended to 32
bits, and is stored to the setting value of the counter.

(2) To change the setting value within the range 0 to 4294967295


When input relay 00000 is ON, the setting value of counter C000 is set to #100000.
When input relay 00000 is OFF, the setting value of counter C000 is changed to the value
currently stored to data memories DM00000 and DM00001.

00000 #100000 C000


LDA.D STA.D

00000 DM00000 C000


LDA.D STA.D

Note: Operation as a result of executing the STA instruction:


When the current value ≤ setting value, the current value does not change.
When the current value > setting value, the current value is changed to the same
value as the setting value.

■ Example of changing counter current values


(1) To change the current value within the range 0 to 65535
When input relay 00000 is ON, the current value of counter C000 is set to #00100.
When input relay 00000 is OFF, the current value of counter C000 is changed to the value
currently stored to data memory DM00000.

00000 MOV
#00100 C000

00000 MOV
DM00000 C000

• Even if values are changed by a suffix .U instruction, the value is automatically extended to 32
bits, and is stored to the current value of the counter.

2-58
2-6 Timer/Counter Instructions

(2) To change the current value within the range 0 to 4294967295


When input relay 00000 is ON, the current value of counter C000 is set to #100000.

BASIC INSTRUCTIONS
When input relay 00000 is OFF, the current value of counter C000 is changed to the value
currently stored to data memories DM00000 and DM00001.

00000 MOV.D
#100000 C000

00000 MOV.D
DM00000 C000

Timer/Counter Instructions
Note: Operation as a result of executing the MOV instruction:
When the current value ≤ setting value, the current value is changed to the written
value.
When the current value > setting value, the current value is changed to the same
value as the setting value.

■ Example of reading counter current values


(1) When the current value changes within the range 0 to 65535
When input relay 00000 is ON, the current value of counter C000 is stored to data memory
DM00000.
TMR
When input relay 00001 is ON, the current value of counter C001 is stored to data memory
TMH
DM00001.
TMS

C
00000 C000 DM00000
ITVL
LDA STA
UDC

00001 MOV UDT


C001 DM00001

(2) When the current value changes within the range 0 to 4294967295
When input relay 00000 is ON, the current value of counter C000 is stored to data memories
DM00000 and DM00001.
When input relay 00001 is ON, the current value of counter C001 is stored to data memories
DM00010 and DM00011.

00000 C000 DM00000


LDA.D STA.D

00001 MOV.D
C001 DM00010

"LDA Instruction" page 4-6


"STA Instruction" page 4-8
"MOV Instruction" page 4-14
"About suffixes" page 1-28

2-59
ITVL(.U)
2-6 Timer/Counter Instructions ITVL Measures the pulse interval, pulse
ITVL
PLS
PAUSE Interval timer length and value of data memories in
RES
the preset mode.
ITVL .S
BASIC INSTRUCTIONS

Ladder program Input method


Pulse input ITVL
PLS I T V L D1 D2
Suspend count input D1
PAUSE
Reset input D2
RES

Available Bit Devices Word Devices Operation Flag


2
Constant Indirect
Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D1 — — — — — — — — — — — — — — — — — — —
Timer/Counter Instructions

D2 — — — — — — — — — — — — — — —

D1 : Specifies the start device of the data table.

D2 : Specifies the start device of the flag relay.

Explanation of Operation
About the two ITVL instruction functions
(1) Pulse measurement mode ..... In this mode, the pulse cycle or pulse width of PLS (pulse input)
is measured.
Specify pulse cycle measurement, pulse width measurement, and measurement unit by the data
table mode setting (in minimum increments of 10 ms).
The maximum measurement pulse width and maximum measurement pulse cycle are as
follows:
ITVL.U ....... 65535 sec
ITVL.S ....... 32767 sec
Pulses of width exceeding the above value cannot be measured. If the pulse width exceeds the
above value, an overflow occurs, and the lower 16 bits of the measured value are stored.
(2) DM measurement mode ........ In this mode, the maximum/minimum values and average
values* of captured measured values are calculated.
Specify the data to capture by the data table mode setting.
* For details on calculated values, read "Data table assignments" for the ITVL and ITVL.S
instructions.

About various input functions


PLS (pulse input) ...................... Measurement input
In pulse measurement mode: Input becomes pulse input for measuring cycle and pulse
width.
In DM measurement mode: Measured values are captured only for the scans in
which PLS (pulse input) is ON.
Use CR2002 to PLS (pulse input) to capture at each
scan.
PAUSE (measurement stop input) ..... Measurement is paused when PAUSE turns ON.
RES (reset input) ................................ When RES turns ON, the content of the data table is
initialized.
Each of the measured values, average values, measurement count, and total vales are reset to
"0".
The maximum measured value becomes 0 for .U instructions, and -32768 for .S instructions.
The minimum measured value becomes 65535 for .U instructions, and 32767 for .S
instructions.

2-60
2-6 Timer/Counter Instructions

ITVL(.U) Pulse measurement and DM measurement are processed by 16-bit unsigned binary
data.

BASIC INSTRUCTIONS
Setting values, measured values, and average values are handled as 16-bit unsigned
data (0 to 65535).
Integrated values are handled as 32-bit unsigned data.
ITVL.S Pulse measurement and DM measurement are processed by 16-bit signed binary
data.
Setting values, measured values, and average values are handled as 16-bit signed
data (-32768 to 32767).
Integrated values are handled as 32-bit signed data.

Data table assignments


2
16 continuous data memories (DM) starting from the device No. specified by D1 is called a "data

Timer/Counter Instructions
table" and is configured as follows. Store values for setting operation of the ITVL instruction to the
first four data memories in this data table.

D1 Mode setting →Sets mode No. 0 to 39999.

D1 +1 MAX setting value →Sets the maximum value of the measurement range.
Set to initial settings.
D1 +2 MIN setting value →Sets the minimum value of the measurement range.
D1 +3 Average count →Sets the count for calculating the average value.
D1 +4 Measurement value →The measured value of each measurement is stored.
D1 +5 MAX setting value →The maximum value of the measured values is stored.
D1 +6 MIN setting value →The minimum value of the measured values is stored. TMR
D1 +7 Average value →The average value of the count specified at average count is stored. TMH

D1 +8 Number of counts →The measured count is stored. TMS

D1 +9 Integrated value C
→The total value lower 16 bits of the measured value are stored.
(lower) ITVL

D1 +10 Integrated value UDC


(upper) →The total value upper 16 bits of the measured value are stored.
UDT

D1 +11
Work memory for
.....

→Work memory for calculating the above values.


system
D1 +15 (Do not use this work memory.)

• Set the mode setting by the STA(.U), DW(.U) or MOV(.U) instruction.


[Example] When D1 sets mode No. 10000 at DM00000

CR2008 #10000 DM0000


LDA STA

• The average value is not calculated when the average count is set to "0". The total value is
calculated, however an overflow will occur when the 32-bit range is exceeded.
• When the average count is reached, the measurement count and total value become "0".

Mode setting
Pulse measurement mode

Pulse Cycle Measurement Pulse Cycle Measurement

Mode No. Measurement Unit Mode No. Measurement Unit


0 10 ms 1 10 ms
2 100 ms 3 100 ms
4 1 sec 5 1 sec

2-61
2-6 Timer/Counter Instructions

DM measurement mode

Mode No. DM No. Description


BASIC INSTRUCTIONS

0 to 5 None Cannot be used.


6 DM00006 The content of DM0006 is measured to calculate the average value.
7 DM00007 The content of DM0007 is measured to calculate the average value.
: : :
39998 DM39998 The content of DM39998 is measured to calculate the average value.
39999 DM39999 The content of DM39999 is measured to calculate the average value.
40000 onwards None Cannot be used.

* Mode Nos. 20000 to 39999 can be set only when extended memory is mounted on the KV-700.
2 * When an unavailable mode has been set, the content of the data table is initialized.
Timer/Counter Instructions

Flag relay assignments


Four relays starting from the device No. specified by D2 is called a "flag relay" and is configured
as follows.

D2 MAX error →The device turns ON for one scan only when the measured value exceeds the MAX setting value.
D2 +1 MIN error →The device turns ON for one scan only when the measured value exceeds the MIN setting value.
D2 +2 End single count →The device turns ON for one scan only at the end of each measurement.
D2 +3 End average count →The device turns ON for one scan only when the count measurement specified at average count ends.

Operation flag
The operation flag does not change state.

Sample Program
■ Example of pulse interval measurement

CR2008 #00000 DM00000


LDA STA Sets the mode setting to "0". (Sets to measurement unit 10 ms.)
CR2008 #00051 DM00001
LDA STA Sets the measurement range maximum value to 510 ms.
CR2008 #00049 DM00002
LDA STA Sets the measurement range minimum value to 490 ms.
CR2008 #00010 DM00003
LDA STA Sets the average count to ten times.
00000 ITVL
PLS Measures the pulse interval of input relay 00000.
DM00000
00001
PAUSE Stops measurement when input relay 00001 is ON.
01000
00002
RES Resets when input relay 00002 is ON.
01000 #00030
SHOT 01000 turns ON for one scan only when the measurement value
00500 exceeds the maximum value of 510 ms.
01001

01001 turns ON for one scan only when the measurement value
falls below the minimum value of 490 ms.

At MAX error and MIN error, output relay 00500 is output for one-shot of 300 ms.

2-62
2-6 Timer/Counter Instructions

Time chart

BASIC INSTRUCTIONS
ON

Input relay 00000


OFF

500 ms 400 ms 600 ms


ON

Input relay 01000 ON


OFF

1 scan
ON

Input relay 01001 ON


OFF
1 scan
ON

Output relay 00500 ON ON


OFF

300 ms 300 ms
2

Timer/Counter Instructions
■ Example of A/D data measurement
Output 00500 turns ON when the analog input value (1 to 5V range) stored to data memory
DM01600 exceeds +3V. When the analog input value falls below +2V, output 00501 is turned
ON. The average value is stored to DM00100.

CR2008 #01600 DM00000


LDA STA Counts the content of DM01600.

CR2008 #02000 DM00001


LDA STA Sets the maximum value of the measurement range to 3V (2000).
CR2008 #01000 DM00002 TMR
LDA STA Sets the minimum value of the measurement range to 2V (2000).
TMH
CR2008 #00100 DM00003
TMS
LDA STA Sets the average count to 100 times.
C
CR2002 ITVL
PLS ITVL
DM00000
00001 Stops the measurement when input relay 00001 is ON. UDC
PAUSE UDT
01000
00002 Resets the measurement when input relay 00002 is ON.
RES

01000 00500
Turns output relay 00500 ON when the measured value exceeds maximum 3V (2000).
01001 00501
Turns output relay 00501 ON when the measured value falls below minimum 2V (1000).
01003 DM00007 DM00100
LDA STA Stores the average value to DM00100 every 100 measurements.

2-63
UDC
UP
2-6 Timer/Counter Instructions
UDC DW
RES
Up/down counter 32-bit increment/decrement counter

Ladder program Input method


BASIC INSTRUCTIONS

Up input UDC n
UP
U D C n S
Down input S
DW ( C N T R n S )

Reset input
RES
C n

2 Available Bit Devices


Internal
Word Devices Constant Indirect Operation Flag
CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
Timer/Counter Instructions

n — — — — — — — — — — — — — — — — — — —
S — — — — — — — — — — — — — — —

n : Specifies the device No. (0 to 511) of the counter.


S : Specifies the setting value of the counter.
Set within the range 0 to 4294967295. The setting value cannot be specified in $(Hex).

Explanation of Operation
"1" is added (incremented) to the current value of the counter at the up edge of the up input.
"1" is deducted (decremented) from the current value of the counter at the up edge of the down input.
Counter UDC n turns ON when the current value digits are incremented or decremented.
The current value is reset to "0" when the reset input is ON.

00001 UDC 000


UP

00002 #00009
DW

00003
RES

C000

ON

00001 (Up input)


OFF
ON

00002 (Down input)


OFF

ON
00003 (Reset input)
OFF

Setting value
9 9 8 9 8
7 8 7 6 7 6 7 8 7 6
5 6 5 4
3 4 2 3 3 2
Current value
0 1 2 0 1 0 1 0
Contacts C000 O At digit At digit At digit
O O
N rounding up N rounding down N rounding down

* n cannot be used in duplicate with the TMR, TMH, TMS, C, UDC, or UDT instructions.

[Tip]
The current value of up-down counter (UDC) is held in the PROG mode or when the power is
turned OFF. (for five years or more at 25°C The current value can be cleared when the power
is turned OFF by setting the memory switch instruction (MEMSW).
"MEMSW instruction" page 3-6

2-64
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed at the up edge of the execution condition.

Sample Program
The number of in-warehouse units is counted by input relay 00000.
The number of out-warehouse units is counted by input relay 00001. 2
When the truck is full (10 units), C000 turns ON to turn output relay 00500 ON.

Timer/Counter Instructions
The count is reset by input relay 00002.

Car park
00000 UDC 000 0000 0001
UP

00001 #00009
DW Entrance Exit
00002
RES

C000 00500
TMR

TMH

TMS

ITVL

UDC

UDT

2-65
UDT
UP
2-6 Timer/Counter Instructions Operation unit 10 ms, 32-bit integration/subtraction
UDT DW
RES
Up/down timer
timer

Ladder program Input method


BASIC INSTRUCTIONS

Up input UDT n
UP
S U D T n S
Down input
DW
Reset input
RES
T n

2 Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O T C CTC CR DM TM T C CTH CTC CM #/$ #TM
Timer/Counter Instructions

auxiliary 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — — —
S — — — — — — — — — — — — — — —

n : Specifies the device No. (0 to 511) of the timer.


S : Specifies the setting value of the timer. Set within the range 0 to 4294967295 in 10 ms units.

Explanation of Operation
When the up input is ON, "1" is added (incremented) every 10 ms to the current value of the timer
specified by S .
When the down input is ON, "1" is subtracted (decremented) every 10 ms to the current value of the
timer specified by S .
When the up and down inputs both are ON or OFF, the current value is held.
(1) T n turns ON when the current value is the same as the setting value with the up input ON.
(2) T n turns OFF when the up input is OFF.
(3) T n turns ON when the current value become "0" with the down input ON.
(4) T n turns OFF when the down input is OFF.
(5) The current value is reset to "0" at the up edge of the reset input.

(1) (2) (3) (4) (5)


ON

Up input
OFF
ON

Down input
OFF
ON
Reset input
OFF

Setting value
Current value
0

Timer UDT n ON ON ON ON

* D cannot be used in duplicate with the TMR, TMH, TMS, C, UDC, or UDT instructions.
* The error of the UDT instruction is "within ±(10 ms +1 scan time)."

[Tip]
The current value of UDT is held when operation is stopped or when the power is turned OFF.
(for five years or more at 25°C)

2-66
2-6 Timer/Counter Instructions

Operation flag
The operation flag does not change state.

BASIC INSTRUCTIONS
Execution Timing
This instruction is executed when the up input, down input or reset input is ON.

Sample Program
The time that output relay 00500 turned ON is measured. When input relay 00000 is ON, the
measured value is reset. The measured value is stored to data memories DM00000 and DM00001.
Up to 42949672950 ms (approx. 12000 hours can be measured in 10 ms units.
2

Timer/Counter Instructions
00500 UDT000
UP
CR2003 #4294967295
DW
00000
RES

CR2002 T000 DM00000


LDA.D STA.D

TMR

TMH

TMS

ITVL

UDC

UDT

2-67
2-7 Connect/End Instructions

2-7 Connect/End Instructions


BASIC INSTRUCTIONS

Connect instructions include ANL and ORL instructions, and MPS, MRD and MPP instructions. The
ANL and ORL instructions connect two contact blocks (combinations of contacts) in series or in
parallel. The MPS, MRD and MPP instructions are for memorizing or reading ON/OFF states. There
are two end instructions, END for specifying the end of the main routine program, and the ENDH
for specifying the final step of the sequence program.

Connect/End Instruction List


There are eight connect/end instructions as follows.
2 The ANL, ORL, MPS, MRD, and MPP instructions are programmed not as symbols on ladder
diagrams but as "connection lines" for contact blocks.
Connect/End Instructions

Instruction Mnemonic Brief Description of Operation Page


End END Indicates the end of a regular program (main routine 2-70
program).
End high ENDH Indicates the end of the entire program.

Connect CON Indicates a series connection following an output 2-72


instruction.
Push MPS Memorizes the previous ON/OFF state up to this 2-74
instruction.
Read MRD Reads contents stored to memory by MPS.

Pop MPP Reads contents stored to memory by MPS, and


clears memory.
AND load ANL Connects the contact block in series. 2-76

OR load ORL Connects the contact block in parallel.

■ About contact blocks and program blocks


A combination of any contact instructions that are connected is called a "contact block."

Contact block

When contact blocks are connected to the bus lines on the left and right to unit the bus lines, the
contact blocks are called a "program block."

Program block

2-68
2-7 Connect/End Instructions

■ About stacks
In ladder diagrams, branch points are expressed using lines.

BASIC INSTRUCTIONS
LD 00000
00000 00500
MPS
00001 00501 OUT 00500
MRD
00002 00502
AND 00001
OUT 00501
MPP
AND 00002
2

Connect/End Instructions
OUT 00502

• When the MPS instruction is executed, the ON/OFF state up to the MPS instruction and the
operation flag state are memorized to an area called a "stack." When multiple MPS instructions
are executed, the ON/OFF state at that moment in time and the operation flag state are
memorized to the stack in the order that the MPS instructions are executed. The ON/OFF state
and operation flag state last memorized by the MPS instruction are memorized to the top of the
stack.
• When the MRD instruction is executed, the ON/OFF state and the operation flag state currently
memorized at the top of the stack are read.
As the ON/OFF state and operation flag state currently memorized to the stack are held as they
are, the same ON/OFF state and operation flag state are read even if the stack is read two or
more times by the MRD instruction.
• When the MPP instruction is executed, the ON/OFF state and the operation flag state currently
memorized at the top of the stack are read.
However, the ON/OFF state and the operation flag state that were memorized at the top of the
stack are deleted, and the ON/OFF state and the operation flag state that were memorized by
execution of the previous MPS instruction rise up to the top of the stack.

■ Differences between the END and ENDH instructions


Sequence programs are named as follows according to their function.

Main routine program

END End of main routine program

SBN

Sub-routine program
Sequence program
RET End of sub-routine program
Write the sub-routine program and
INT interrupt program here as required.

Interrupt program

RETI End of interrupt program

ENDH End of sequence program

The END instruction indicates the final step of the main routine program.
• The sub-routine program and interrupt program are scripted after the END instruction of the
main routine program.
The ENDH instruction indicates the final step of the sequence program.
• Programs can be scripted following the ENDH instruction though they are not executed.

2-69
END
2-7 Connect/End Instructions
END End Indicates the end of the main routine program.

ENDH
ENDH End high Indicates the end of the entire program.
BASIC INSTRUCTIONS

Ladder program Input method

E N D
E
END
F E N D

2 ENDH
E N D H
( H )
Connect/End Instructions

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
END When the END instruction is executed, the PLC ends the main routine program,
executes END processing, and executes the main routine program again from step 0.
To indicate the end of the program, use the ENDH instruction.
ENDH This indicates the end of the sequence program (that there is no program from here
onwards).
When a sub-routine program or an interrupt program is not to be written in the ladder
program, write the END instruction followed immediately by the ENDH instruction.

Main routine
program

END

ENDH

Operation flag
The operation flag does not change state.

2-70
2-7 Connect/End Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Connect/End Instructions
END

ENDH

CON

MPS

MRD

MPP

ANL

ORL

2-71
2-7 Connect/End Instructions Indicates a series connection following an output
CON Connect
instruction.

Ladder Input method


BASIC INSTRUCTIONS

a b c d
↑ ↑ ↑
CON CON CON

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

2 Explanation of Operation
Connect/End Instructions

This instruction is used when writing programs in an extended ladder or when connecting
instructions following an output instruction.
* When the ladder program has been made in Ladder Support Software KV BUILDER, instructions
are automatically converted into mnemonics and incorporated into the program merely by
scripting the instruction after the output instruction.
* Programming this instruction does not influence the scan time.

For details on extended ladders, read "1-6 Extended Ladders" ( page 1-38).

Operation flag
The operation flag does not change state.

2-72
2-7 Connect/End Instructions

This page left intentionally blank.

BASIC INSTRUCTIONS
2

Connect/End Instructions
END

ENDH

CON

MPS

MRD

MPP

ANL

ORL

2-73
2-7 Connect/End Instructions Push
MPS Stores the input state and operation flag to memory.

MRD Read Reads contents stored to memory by MPS.


BASIC INSTRUCTIONS

MPP Pop Reads contents stored to memory by MPS, and clears


memory.
Ladder program


MPS

2 MRD

Connect/End Instructions


MPP

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
MPS Stores the ON/OFF state and operation flag state up to that instruction to memory, and
executes the instruction from the next step. If two or more of these instructions are
executed in a single block, the ON/OFF states at that moment in time are stored to memory
in the order that the instruction was executed. (Up to eight ON/OFF states can be stored
to memory.)
MRD Reads the ON/OFF state and operation flag state stored in memory by the MPS
instruction, and executes the instruction from the next step by that content. The ON/OFF
state and operation flag state currently stored in memory are held.
The MRD instructions can be used continuously. (In this case, the same content is read.)

00000 00500 LD 00000


MPS ............................ Record ON/OFF state at (1).
(1) OUT 00500
00001 00501 MRD ............................ Read ON/OFF state at (1).
AND 00001
OUT 00501
00002 00502 MRD ............................ Read ON/OFF state at (1).
AND 00002
OUT 00502
00003 00503 ............................ Read ON/OFF state at (1).
MRD
AND 00003
OUT 00503
00004 00504 ............................ Read ON/OFF state at (1).
MRD
AND 00004
OUT 00504
00005 00505 ............................ Read ON/OFF state at (1), clear MPS.
MPP
AND 00005
OUT 00505

MPP Reads the ON/OFF state and operation flag state stored to memory by the MPS
instruction, and executes the instruction from the next step by that content. When two or
more MPS instructions have been executed (two or more ON/OFF states and operation
flag states have been stored to memory), reading is performed in order from the last ON/
OFF state and operation flag state stored to memory. ON/OFF state and operation flag
state read by the MPP instruction are cleared from memory.

2-74
2-7 Connect/End Instructions

00000 00001 00002 00003 00004 00005 00006 00007 00008 00500 LD 00000
MPS . . . . Store ON/OFF state at (1).

BASIC INSTRUCTIONS
(1) (2) (3) (4) (5) (6) (7) (8) 00009 00501 AND 00001
MPS . . . . Store ON/OFF state at (2).

...
00010 00502
AND 00006
MPS . . . . Store ON/OFF state at (7).
00011 00503
AND 00007
MPS . . . . Store ON/OFF state at (8).
00012 00504 AND 00008
OUT 00500
00013 00505
MPP . . . . Read ON/OFF state at (8).
AND 00009
00014 00506
OUT 00501
. . . . Read ON/OFF state at (7).
2
MPP
00015 00507

Connect/End Instructions
AND 00010
OUT 00502
00100 00508

...
MPP . . . . Read ON/OFF state at (2).
AND 00015
OUT 00507
MPP . . . . Read ON/OFF state at (1).
AND 00100
OUT 00508

Note: Program the MPS and MPP instructions as a pair.


END
If these instructions are not programmed as a pair (number of programmed instructions ENDH
differ), a conversion error occurs when the program is edited on Ladder Support Software CON
KV BUILDER, and the program cannot be executed.
MPS

MRD

MPP
Operation flag
ANL
The operation flag does not change state. ORL

2-75
2-7 Connect/End Instructions AND load
ANL Connects the contact block in series.

ORL OR load Connects the contact block in parallel.


BASIC INSTRUCTIONS

Ladder program

A block B block
ANL
2 ORL
C block
Connect/End Instructions

D block

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
ANL Connects two contact blocks in series.
Block A and block B are connected in series as shown in the ladder diagram above.
This connection is indicated not by a symbol in the ladder diagram but by connection
lines.
ORL Connects two contact blocks in parallel.
Block C and block D are connected in parallel as shown in the ladder diagram above.
This connection is indicated not by a symbol in the ladder diagram but by connection
lines.

Operation flag
The operation flag does not change state.

2-76
2-7 Connect/End Instructions

Sample Program

BASIC INSTRUCTIONS
Output relays turns ON when the following two conditions (1) and (2) are both satisfied:
(1) Either (or both of) input relay 00000 or 00001 turn ON.
(2) Either (or both of) input relay 00002 or 00003 turn ON.

00000 00002 00501


LD 0000
OR 0001
00001 00003 LD 0002
OR 0003
ANL
OUT 0501
2

Connect/End Instructions
The operation of the above program is the same as that of the following program.

00000 00002 00501


LD 0000
OR 0001
00001 00003 LD 0002
OR 0003
ANL
OUT 0501
END

ENDH

CON

MPS

MRD

MPP

ANL

ORL

2-77
2-7 Connect/End Instructions

This page left intentionally blank.


BASIC INSTRUCTIONS

2
Connect/End Instructions

2-78
3-1 Shift Instruction

APPLIED INSTRUCTIONS
APPLIED INSTRUCTIONS 3

Shift Instruction
These instructions are for work progress, program control, and
extended ladders.
These instructions allow you to structurally script basic ladders.

3-1 Shift Instruction .................................................................. 3-2

3-2 Memory Switch Instruction ................................................3-6

3-3 Step Instructions .............................................................. 3-12


SFT
3-4 Stage Processing Instructions ........................................3-18

3-5 Flow Instructions .............................................................. 3-28

3-1
3-1 Shift Instruction

3-1 Shift Instruction


Shift Instruction List
APPLIED INSTRUCTIONS

There is one shift instruction as follows.

Instruction Mnemonic Brief Description of Operation Page


Shift SFT Operates the shift register. 3-6

3
Shift Instruction

3-2
3-1 Shift Instruction

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Shift Instruction
SFT

3-3
SFT
3-1 Shift InstructionDCLK
SFT RES
Shift Operates the shift register.

Ladder program Input method


Data input SFT
D
APPLIED INSTRUCTIONS

S F T D1 D2
Clock input D1
CLK
Reset input D2
RES

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D1 — — — — — — — — — — — — — — — — — —
D2 — — — — — — — — — — — — — —

3 D1 : Specifies the start relay device.

D2 : Specifies the end relay device.


Shift Instruction

Explanation of Operation
The ON/OFF state of the data input is captured at the up edge of the clock input.
That state is shifted from D1 to the relay specified by D2 at the clock timing.
When the reset input is ON, all relays at D2 from D1 turn OFF.
The state is not shifted to relays at D2 +1 onwards.

ON

Data input
OFF
ON

Clock input
OFF

ON
Reset input
OFF

ON

D1
OFF

ON
D1 +1
OFF

ON
D1 +2
OFF
ON
D1 +3
OFF

ON
D2 -1
OFF
ON
D2
OFF

Note: Duplicate use of No.1 operands and No.2 operands between two or more SFT instructions
is not possible.

3-4
3-1 Shift Instruction

Operation flag
The operation flag does not change state.

APPLIED INSTRUCTIONS
Execution Timing
This instruction is executed at the up edge of clock input.

Sample Program
■ Batch reset of internal auxiliary relays
When input relay 00000 turns ON, all internal auxiliary relays from 01000 to 01915 turn OFF.
This instruction can be used as a substitute for the RES instruction to reset multiple relays in a
single operation. It can also be used as a substitute for the ZRES instruction.
3
"ZRES Instruction" page 5-24

Shift Instruction
CR2003 SFT
D
CR2003 01000
CLK
00000 01915
RES

■ Repeat shift circuit


This circuit repeatedly turns outputs ON successively every second. Internal auxiliary relay
01000 is set by CR2008 (ON for one scan only at start of operation), and the outputs of output SFT
relays 00500 to 00504 are shifted every second by timer T001. Internal auxiliary relay 01000 is
set by internal auxiliary relay 01005 turning ON to repeat processing.

CR2008 01000
SET
T001 #00010
T001
CR2003 SFT
D
T001 01000
CLK
CR2003 01005
RES
01000 00500

01001 00501

01002 00502

01003 00503

01004 00504

01005 01000
SET

3-5
3-2 Memory Switch Instruction

3-2 Memory Switch Instruction


This instruction sets internal auxiliary relays, data memory power interruption hold function, and
other settings.
APPLIED INSTRUCTIONS

Memory Switch List


There is one memory switch instruction as follows.

Instruction Mnemonic Brief Description of Operation Page


Memory switch MEMSW Operates the memory switch. 3-8

3
Memory Switch Instruction

3-6
3-2 Memory Switch Instruction

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Memory Switch Instruction


MEMSW

3-7
MEMSW
3-2 Memory Switch Instruction
MEMSW Memory switch Operates the memory switch.

Ladder program Input method


MEMSW n
n
APPLIED INSTRUCTIONS

M E M S W S
S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — — —
S — — — — — — — — — — — — — — —

n : Specifies the memory switch No. (0 or 1). Input of "#" and "$" is not allowed.
S : Sets the memory switch ($0000 to $FFFF). Setting in # (decimal) is not allowed.

3
Explanation of Operation
Memory Switch Instruction

MEMSW0
The memory switch has two switches, 0 and 1.
Each switch comprises 16 bits, and switch functions are set by turning these bits ON/OFF.
The content of the memory switches is set when the program is moved.
If the program does not contain the MEMSW instruction, "$0000" is set on the switch.

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 MEMSW0
$0103
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SW1
SW2
SW3
SW4

No. Switch Functions ON OFF


0 Cancel error at power ON ON OFF
Write protection of main routine
1 program ON OFF
SW1
Hold QL output relay when main
2 unit is stopped ON OFF
(in Program mode)
3 Counter, CTH and CTC values Clear Hold

0 Set digital trimmer upper limit Enabled Disabled


value
SW2 1 Reserved for system – –
2 Reserved for system – –
3 Reserved for system – –
DM00000 to DM09999 at power
0 ON Clear Hold
1 DM00000 to DM19999 at power Clear Hold
SW3 ON
DM00000 to DM29999 at power
2 ON Clear Hold

3 DM00000 to DM39999 at power


ON Clear Hold
0 Reserved for system – –
SW4 1 Reserved for system – –
2 Reserved for system – –
3 Reserved for system – –

3-8
3-2 Memory Switch Instruction

MEMSW1

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 MEMSW0
$0216

APPLIED INSTRUCTIONS
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SW1
SW2
SW3
SW4

No. Switch Functions ON OFF


0 Hold relays 01000 to 04915 ON OFF
SW1 1 Hold relays 05000 to 09915 ON OFF
2 Hold relays 10000 to 14915 ON OFF
3 Hold relays 15000 to 19915 ON OFF
0 Hold relays 20000 to 24915 ON OFF
SW2 1 Hold relays 25000 to 29915 ON OFF
2 Hold relays 30000 to 34915 ON OFF 3
3 Hold relays 35000 to 39915 ON OFF

Memory Switch Instruction


0 Hold relays 40000 to 44915 ON OFF
SW3 1 Hold relays 45000 to 49915 ON OFF
2 Hold relays 50000 to 54915 ON OFF
3 Hold relays 55000 to 59915 ON OFF
0 Reserved for system – –
SW4 1 Reserved for system – –
2 Reserved for system – –
3 Reserved for system – –

MEMSW
Note: Set holding of relays set by MEMSW1 only to internal auxiliary relays.
Do not set this function to I/O Units and special units (units other than I/O Units). When
this function is set to I/O relays, the relays do not hold the content of devices. When this
function is set to relays assigned to special units, the program may not function normally.
In the case of programs that detect the up edge of relays at the first scan after operation
is started, the up edge may not be able to be detected and the unit may not operate if that
relay is held.

3-9
3-2 Memory Switch Instruction

Example of memory switch setting


Specify the memory switch in Hex for each switch No.

(Switch No.)
APPLIED INSTRUCTIONS

MEMSW1 SW4 SW3 SW2 SW1

$0269 3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
SW1 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 (Example)
SW2
SW3 0 2 6 9 (Hex)
SW4
(8) (4) (2) (1)
23 2 2 21 2 0 Hex
0 0 0 0 0
0 0 0 1 1 Power interruption hold set to
relays 45000 to 49915
0 0 1 0 2
0 0 1 1 3
3 0 1 0 0 4
Power interruption hold set to
Memory Switch Instruction

0 1 0 1 5
relays 25000 to 29915, 35000 to 34915
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8 Power interruption hold set to
relays 1000 to 4915, 15000 to 19915
1 0 0 1 9
1 0 1 0 A
1 0 1 1 B
1 1 0 0 C
1 1 0 1 D
1 1 1 0 E
1 1 1 1 F

[Tip]
If an attempt is made to move a program to the KV-700 that has been set as write-protected on
KV BUILDER, the message "Write-protected. Force operation?" will be displayed. Select "Yes"
to forcibly execute the move.

3-10
3-2 Memory Switch Instruction

Operation flag
The operation flag does not change state.

APPLIED INSTRUCTIONS
Execution Timing
This instruction is set when the power is turned ON and when the ladder program is moved to the
KV-700 (including writing in the RUN mode).

Sample Program
• Setting of error cancellation when the unit is turned ON

MEMSW0
$0001 3

Memory Switch Instruction


• Setting of program write protection

MEMSW0
$0002

• Setting to clear DM00000 to DM09999 when the unit is turned ON

MEMSW0
$0100

MEMSW

• Setting to hold relays 01000 to 04915

MEMSW1
$0001

• Setting to enable the digital trimmer upper limit value

MEMSW0
$0010

3-11
3-3 Step Instructions

3-3 Step Instructions


Instructions in the program are processed successively in step No. order. If step instructions are
used, you can skip program sections programmed with the STP and STE instructions.
APPLIED INSTRUCTIONS

Step Instruction List


There are two step instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Step STP Executes the program up to the STE instruction when 3-14
the relay indicated by the operand is ON.
Step end STE This instruction is used in a pair with the STP instruction,
and indicates the end of the program to be executed by
3 step operation.
Step Instructions

3-12
3-3 Step Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Step Instructions
STP

STE

3-13
STP
3-3 Step Instructions
STP Step Executes the program up to the STE instruction when
the relay indicated by the operand is ON.
STE
STE Step end This instruction is used in a pair with the STP instruction,
and indicates the end of the program to be executed by
step operation.
APPLIED INSTRUCTIONS

Ladder program Input method

STP
S S T P S

Program A

STE
S T E

3 Program B
Step Instructions

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —

S : Specifies the device to be used as the execution condition in the program between the STP
and STE instructions.

Explanation of Operation
When the device specified by S is ON, the instructions (program A) between the STP and STE
instructions are executed.
When the device specified by S is OFF, the program between the STP and STE instructions is
not executed, and execution jumps to the instruction sequence (program B) after the STE
instruction.

[Example] When input 00000 is ON, output 00500 turns ON/OFF interlocked to ON/OFF of input
00001. When input 00000 is OFF, output 00500 does not turn ON even if input 00001
is ON.
When input 00000 turns OFF with input 00001 and output 00500 both ON, output
00500 stays ON even if input 00001 turns OFF.

00000 01000

STP
01000

00001 00500
This program is not executed
when 01000 is OFF.

STE

3-14
3-3 Step Instructions

[Tip]
• The instruction sequence between the STP and STE instructions that have not been executed do
not affect the scan time.

APPLIED INSTRUCTIONS
• Care is required when programming differential execution type instructions or timer instructions
between the STP and STE instructions.
"Precautions when using differential execution type instructions" page 1-6
"Precautions when using timer instructions" page 1-13

About nesting structures


• The STP and STE can be programmed
down to a nesting level of eight. STP
01000
In the program shown on the right, (1) (2)
(3) are not executed when input 01000 is
3
OFF, and execution starts from (4). (1)

Step Instructions
When inputs 01000 and 01001 both are STP
ON, the program is executed in order (1) (2) 01001
(3) (4).
When input 01000 is ON and input 01001 is Nesting Nesting (2)
level: 1 level: 2
OFF, the program is executed in order (1)
(3) (4), and execution of (2) is skipped. STE

(3)

STP
STE
STE

(4)

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

3-15
3-3 Step Instructions

Sample Program
When input relay 00000 turns ON, output relay 00500 automatically turns ON for two seconds, and
then output relay 00501 turns ON for three seconds.
APPLIED INSTRUCTIONS

00000 01000 01000 01001


DIFU SET

STP
01001

T000 01001
RES

T000 00500

3 01001 #00020
Step Instructions

T000

T000 01002
SET

STE

STP
01002

T001 01002
RES

T001 00501

01002 #00030
T001

STE

END

ENDH

3-16
3-3 Step Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Step Instructions
STP

STE

3-17
3-4 Stage Processing Instructions

3-4 Stage Processing Instructions


Stage processing instructions execute the program at each stage.
APPLIED INSTRUCTIONS

When a stage ends, program execution jumps to the next stage by the JMP instruction. A stage ends
by the ENDS instruction.

Stage Processing Instruction List


There are seven stage processing instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Stage STG Executes the instruction in the STG block. 3-20

Jump JMP Turns the relay of the currently executing stage OFF,
3 and jumps to the specified stage.
End stage ENDS Turns the relay of the currently executing stage OFF.
Stage Processing Instructions

Wait ON W-ON Sets the device of the No.2 operand with the device 3-24
of the No.1 operand ON.
Wait OFF W-OFF Sets the device of the No.2 operand with the device
of the No.1 operand OFF.
Wait up edge W-UE Sets the device of the No.2 operand at the up edge of 3-26
the device of the No.1 operand.
Wait down edge W-DE Sets the device of the No.2 operand at the down edge
of the device of the No.1 operand.

About the STG instruction


■ What is a "stage instruction?"
"Stage instructions" are suited to successive processing (sequential processing) in keeping with
specific processes.
The entire program is divided up into smaller processes, and the program is executed one
process at a time.

Flow chart
Power ON

Ladder program
No
Start switch 1000
Start switch ↑ SET
ON?
Yes
01000 01001
Process (1) STG JMP → Process (1)

01001 01002
Process (2) STG JMP → Process (2)

01002 01003
Process (3) STG JMP → Process (3)

01003
Process (4) STG ENDS → Process (4)

When the STG, JMP and ENDS instructions are used, you can write a program for each individual
process.

3-18
3-4 Stage Processing Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Stage Processing Instructions

3-19
3-4 Stage Processing Instructions
STG STG Stage Executes the instruction in the STG block.

Turns the relay of the currently executing stage OFF, and


JMP JMP Jump
jumps to the specified stage.

ENDS ENDS End stage Turns the relay of the currently executing stage OFF.
APPLIED INSTRUCTIONS

Ladder program Input method


Execution condition S
SET

S S ' S T G S
STG JMP
J M P S
S ' E N D S
STG ENDS

3 Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Stage Processing Instructions

Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — — — —

S : Specifies the device to be used as the stage No.

Explanation of Operation
STG When the device specified by S is ON, that STG instruction is executed.
• Be sure to start the STG instruction from the bus line.
• Duplicate programming of STG instruction operands is not allowed. (Duplicate pro-
gramming of the JMP instruction is allowed. "JMP instruction operands" page 3-23)
• Use a differential type contact as the execution condition of the first programmed
STG instruction. If the execution condition continues to stay ON without a differential
type contact used, the JMP instruction will be executed, and the STG instruction will
be executed again even if the stage ends. For this reason, the stage will no longer
end.
• Use stage instructions in combination with the JMP instruction or END instruction.
JMP When the previous state is ON, the currently executing stage ends, and program
execution jumps to the S ' stage.
• Use this instruction in combination with the STG instruction.
ENDS When the previous state is ON, the currently executing stage ends.
• Use this instruction in combination with the STG instruction.

[Memo]
(1) Program execution jumps to STG01001 by
CR2008 01000
SET jump condition 00000 turning ON.
01000 00000 01001 (2) Program execution jumps to STG01002 by
(1) STG JMP input 00500 turning ON and jump condition
01001 00500 00001 01002 00001 turning ON.
(2) STG JMP
(3) Program execution jumps to STG01001 by
01002 00501 00002 01001
(3) STG JMP
input 00501 turning ON and jump condition
00002 turning ON.
Program execution jumps to 01003 by jump
00003 01003 condition 00003 turning ON.
JMP
(4) Program execution ends by input 00502 turn-
01003 00502 00004 ing ON and jump condition 00004 turning ON.
(4) STG ENDS

3-20
3-4 Stage Processing Instructions

[Tip]
• The instruction sequence between the STP and STE instructions or the STG and ENDS
instructions that have not been executed do not affect the scan time.

APPLIED INSTRUCTIONS
• Care is required when programming differential execution type instructions or timer instruc-
tions between the STG and JMP/ENDS instructions.
"Precautions when using differential execution type instructions" page 1-6
"Precautions when using timer instructions" page 1-13

• Stage instructions cannot be programmed in sub-routines.

• The table below summarizes the states of instructions between the STG to JMP/ENDS instruc-
tions when operand S of the STG instruction turns OFF.
3
Instruction State

Stage Processing Instructions


OUT instruction relay OFF
OUB instruction relay ON
TMR instruction Reset
TMH instruction
TMS instruction
C (counter) instruction
ONDL instruction
OFDL instruction
SHOT instruction
SET instruction State held
RES instruction STG

Other instructions The instruction is not executed. JMP

ENDS

W-ON

W-OFF
[Tip]
W-UE
To turn all stage instructions such as emergency stop OFF, use the ZRES or SFT instruction. W-DE

Reset input 01000 Stage start relay


ZRES
01004 Stage end relay

CR2003 SFT
D
1000 Stage start relay
CR2003
CLK
Reset input 1004 Stage end relay
RES

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the stage relay is ON.

3-21
3-4 Stage Processing Instructions

■ Precautions regarding stage instructions


Interlock
When a stage migrates, both the previous and next stages simultaneously turn ON for one scan
APPLIED INSTRUCTIONS

only.
Provide an interlock circuit for outputs (e.g. motor forward or reverse rotation) that might cause
a hazard when both of these stages simultaneously turn ON.

01000 00501 00500 00001 01001


STG JMP

01001 00500 00501 00002 01002


STG JMP

3 Interlock
Stage Processing Instructions

Double coils
Double coils can be used in stage instructions.

01000 00500 00001 01100 01001


STG JMP
01100
01001 00501 00002 01101 01002
STG JMP
01101
01002 00500 00003 01102 01003
STG JMP
01102

* When STG01000 and STG01002 simultaneously turn ON, output 00500 of STG01002
programmed later is given priority.

Note: When stages programmed with double coils simultaneously turn ON, the coil of the stage
programmed later is given priority.

Output hold
To hold output even if STG is OFF, use the SET instruction.

01000 00500 00000 01001


STG SET JMP

01001 00501 00001 01002


STG SET JMP

When there is no JMP instruction


The STG instruction does not turn OFF even if input 00001 turns ON when the STG instruction
is ON. Be sure to use the JMP instruction.

01000 00500 00001 00501


STG

3-22
3-4 Stage Processing Instructions

STG instruction execution conditions


Let's consider what happens when the STG instruction execution conditions (input relay 00000)
are held in an ON state.

APPLIED INSTRUCTIONS
In the following ladder, input 01000 is set at all times on the first rung even if input 00001 turns
ON and the JMP instruction is executed. For this reason, input 01000 does not turn OFF.
Accordingly, output relay 00500 does not turn OFF.

00000 (Execution condition) 01000


SET

01000 00500 00001 01001


STG JMP

Use a differential type execution condition for the STG instruction. 3

Stage Processing Instructions


00000 (Execution condition) 01000
SET

01000 00500 00001 01001


STG JMP

JMP instruction operands


Duplicate use of STG instruction operands is not allowed, though duplicate use of JMP
instruction operands is allowed.

STG
01000 00500 00001 01001
STG JMP JMP

ENDS

01002 W-ON
JMP W-OFF

W-UE
01000 00501 00002 01002
W-DE
STG JMP

Sample Program
Output relay 00500 turns ON by the start switch of input relay 00000.
Then, when input 00001 turns ON as a conditional branch, output 00501 turns ON for one second.
When input 00002 turns ON, output 00502 turns ON for two seconds. When each of these
processes ends, program execution returns to the conditional branch, and execution is repeated.

00000 01100 01100 01000


DIFU SET

01000 00500 00001 01001


STG JMP

00002 01002
JMP

01001 00501 #00010 T000 01000


STG T000 JMP

01002 00502 #00020 T001 01000


STG T001 JMP

3-23
3-4 Stage Processing Instructions Sets the device of the No.2 operand with the device
W-ON ON Wait ON
of the No.1 operand ON.
Sets the device of the No.2 operand with the device
W-OFF OFF Wait OFF
of the No.1 operand OFF.
APPLIED INSTRUCTIONS

Ladder program Input method


Execution condition S
ON W - O N S D
D ( W O N S D )

Execution condition W - O F F S D
S
( W O F F S D )
OFF
D

Available Bit Devices Word Devices Constant Indirect Operation Flag

3
Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —
Stage Processing Instructions

D — — — — — — — — — — — — — —

S : Specifies the device whose ON/OFF state is to be detected.


D : Specifies the device to be set by the ON/OFF state of S .

Explanation of Operation
W-ON (1) When the execution condition is ON, the device specified by D is set if the device
specified by S is in an ON state.
(2) D stays ON until the execution condition turns OFF even if S is OFF.
(3) When the execution condition turns OFF, the device specified by D turns OFF.
• Duplicate use of the No.2 operand D is not allowed.

(1) (2) (3) (1)' (3)'


ON
Execution condition S Execution
OFF
ON condition ON
D S
OFF
ON

D
OFF

W-OFF (1) When the execution condition is ON, the device specified by D is set if the device
specified by S is in an OFF state.
(2) D stays ON until the execution condition turns OFF even if S is ON.
(3) When the execution condition turns OFF, the device specified by D turns OFF.
• Duplicate use of the No.2 operand D is not allowed.

(1) (2) (3) (1)' (3)'


ON
Execution condition S Execution
OFF
OFF condition ON
D S
OFF
ON

D
OFF

3-24
3-4 Stage Processing Instructions

Operation flag
The operation flag does not change state.

APPLIED INSTRUCTIONS
Execution Timing
This instruction is executed at each scan for the duration that the execution conditions are ON.

Sample Program
When input relay 00000 turns ON during execution of stage 01000, output relay 00500 turns ON.
When output relay 00500 turns ON for three seconds, program execution jumps to stage 01001.
Input 01100 does not turn OFF even if input 00000 turns OFF before three seconds have elapsed.

01000 00000 01100 00500 #00030 T000 01001 3


STG ON T000 JMP

Stage Processing Instructions


01100

STG

JMP

ENDS

W-ON

W-OFF

W-UE

W-DE

3-25
3-4 Stage Processing Instructions Sets the device of the No.2 operand at the up edge
W-UE Wait up edge
of the device of the No.1 operand.
Sets the device of the No.2 operand at the down
W-DE Wait down edge
edge of the device of the No.1 operand.
APPLIED INSTRUCTIONS

Ladder program Input method


Execution condition S
W - U E S D
D W U E S D
W U S D

Execution condition S W - D E S D
W D E S D
D W D S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


3 Devices I O
Internal
auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM CR
2009
CR
2010
CR
2011
CR
2012

S — — — — — — — — — — — — —
Stage Processing Instructions

D — — — — — — — — — — — — — —

S : Specifies the device whose up edge/down edge is detected.


D : Specifies the device to be set by the up edge/down edge of S .

Explanation of Operation
W-UE (1) When the execution condition is ON, the device specified by D is set when the
device specified by S up.
(2) D stays ON until the execution condition turns OFF even if S is OFF.
(3) When the execution condition turns OFF, the device specified by D turns OFF.
• Duplicate use of the No.2 operand D is not allowed.
(4) When the execution condition is ON, D does not turn ON unless the up edge
is detected even if S is ON.

(1) (2) (3) (4)


ON
Execution condition S Execution
OFF
condition ON
D S
OFF
ON

D
OFF

W-DE (1) When the execution condition is ON, the device specified by D is set when the
device specified by S down.
(2) D stays ON until the execution condition turns OFF even if S is ON.
(3) When the execution condition turns OFF, the device specified by D turns OFF.
• Duplicate use of the No.2 operand D is not allowed.
(4) When the execution condition is ON, D does not turn ON unless the down edge
is detected even if S is ON.

(1) (2) (3) (4)


ON
Execution condition S Execution
condition OFF
ON
D S
OFF
ON
D
OFF

3-26
3-4 Stage Processing Instructions

[Tip]
• This instruction cannot be used in interrupt programs.
• Care is required when programming this instruction between the STP and STE instructions,

APPLIED INSTRUCTIONS
and between the STG and JMP/ENDS instructions and in a sub-routine program.
"Precautions when using differential execution type instructions" page 1-6

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.
3

Stage Processing Instructions


Sample Program
When the input relay is ON, and when the order in which input relays 00001 to 00003 turn ON is
00001→00002→00003, output relay 00500 turns ON.

00000 00001

01000

01000 00002

01001

01001 00003
STG
01002
JMP
01002 00500
ENDS

W-ON

W-OFF

W-UE

W-DE

3-27
3-5 Flow Instructions

3-5 Flow Instructions


Flow Instruction List
APPLIED INSTRUCTIONS

There are eight flow instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Master control MC Sets the master control relay. 3-30

Master control MCR Indicates the end of the master control range.
reset
Sub-routine call CALL Executes the specified No. sub-routine program. 3-34

Sub-routine entry SBN Indicates the start of the sub-routine program.

3 Sub-routine return RET Ends the sub-routine program, and returns to the sub-
routine call program.
Flow Instructions

Repeat range FOR Repeatedly executes the instruction sequence 3-28


start between the FOR and NEXT instructions for the
specified number of times in a single scan.
Repeat range end NEXT Indicates the end of the repeat range.

Break BREAK Forcibly ends repeated execution between the FOR and
NEXT instructions.

■ Thinking behind master control


"Master control" is a method of providing contacts on the left bus line of the circuit and switching
program blocks to be executed by turning these contacts ON/OFF. The following diagram shows
the concept behind this circuit.

Display by ladder software Concept schematic

00000 MC MC

00000
00001
00001 00500

This part turns OFF when input


00002
00002 00501 relay 00000 is OFF.
MCR

00003 MCR

00004 00003 00502

3-28
3-5 Flow Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Flow Instructions

3-29
3-5 Flow Instructions
MC
MC Master control Indicates the end of the master control range.

MCR
MCR Master control reset Indicates the start of the master control range.
APPLIED INSTRUCTIONS

Ladder program Input method


Execution condition MC
M C
( I L )

M C R
( I L C )

MCR

3
Available Bit Devices Word Devices Constant Indirect Operation Flag
Flow Instructions

Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
• The MC instruction indicates the start of the master control range.
• The MCR instruction indicates the end of the master control range.
• When the MC instruction execution condition is ON, the program between the MC and MCR
instructions is executed in the same way as the regular program (outside the MC to MCR
instructions).
• When the MC instruction execution condition is OFF, the instructions between the MC to MCR
instructions are executed with the execution condition OFF. As an exception, only the OUB
instruction turns OFF.
Operation of the instructions between the MC to MCR instructions is as follows.
Instruction State
OUT instruction OFF
OUB instruction
TMR instruction Reset
TMH instruction
TMS instruction
ONDL instruction
OFDL instruction
SHOT instruction
FLIK instruction
HKEY instruction
C (counter) instruction State held
SFT instruction
KEEP instruction
SET instruction
RES instruction
High-speed counters
Instructions other than TMIN The instruction is not executed.

3-30
3-5 Flow Instructions

• Output relay 00500 between the MC and MCR instructions and output relay 00500 outside of the
MC to MCR instructions becomes a double coil as follows. For this reason, the output relay
programmed later is given priority.

APPLIED INSTRUCTIONS
00003 00500

00001 MC

00002 00500
←This rung is given priority.
MCR

• Use the MC and MCR instructions in the following


combinations. STP
(1) Program a combination of the MC to MCR XXXX

instructions before the STP to STE instruc- STE 3


tions.

Flow Instructions
MC
"STP, STE instructions" page 3-12
MCR

STP
(2) Combine the MC to MCR instructions between XXXX

the STP to STE instructions. MC

MCR

STE

MC
MC MCR
(3) Combine the STP to STE instructions between CALL
STP
the MC to MCR instructions. XXXX SBN
STE RET

FOR
MCR
NEXT

BREAK

MC
• These instructions cannot be used in the following
MC
applications.
Nesting of MC to MCR instructions MCR

MCR

STP
XXXX
Combination with the STP to STE instructions
MC

STE

MCR

• The MC instruction execution conditions can be 00000 00001 00002 MC


programmed as follows.
00003 00500

MCR

3-31
3-5 Flow Instructions

[Tip]
The scan time is not shortened even if the input relay for the MC instruction is OFF.
"STP instruction" page 3-12
APPLIED INSTRUCTIONS

"SBN instruction" page 3-24

Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

3
Sample Program
Flow Instructions

When input relay 00000 and internal auxiliary relay 01000 are both ON, output relay 00500 turns
ON/OFF by input relay 00001 ON/OFF. (When input relay 00001 turns ON, output relay 00500 turns
ON, and when input relay 00001 turns OFF, output relay 00500 also turns OFF.)
When either (or both) of input relays 00001 and 01000 turn OFF, output relay 00500 stays OFF (does
not turn ON) regardless of the state of input relay 00001.

00000 01000 MC

00001 00500

MCR

3-32
3-5 Flow Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Flow Instructions
MC

MCR

CALL

SBN

RET

FOR

NEXT

BREAK

3-33
3-5 Flow Instructions
CALL CALL Sub-routine call Executes the specified sub-routine program.

SBN
SBN Sub-routine entry Indicates the start of the sub-routine program.

RET
RET Sub-routine return Ends the sub-routine program.
APPLIED INSTRUCTIONS

Ladder program Input method


Execution condition n
CALL C A L L n
END

SBN
n S B N n

3 RET
R E T

ENDH
Flow Instructions

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — — —

n : Specifies the sub-routine No.


The sub-routine No. can be specified within the range 0 to 99 (symbol "#" can be omitted).
The sub-routine No. cannot be specified in $(Hex).

Explanation of Operation
CALL Executes the sub-routine program specified by n .
SBN Indicates the start of the sub-routine program. Specify the sub-routine No. by n .
Duplicate entry of sub-routine Nos. for the SBN instruction is not allowed. (Duplicate
entry of sub-routine Nos. by the CALL instruction is allowed.)
Program these instructions between the END and ENDH instructions.
RET Indicates the end of the sub-routine program.

[Tip]
• When a sub-routine is executed, the scan time increases by the sub-routine execution time.
• The following instructions are not allowed in sub-routines:
INT, RETI, CTH, STG, JMP, ENDS
• Caution is required when using differential execution type instructions and timer instructions
in sub-routine programs.
"Precautions when using differential execution type instructions" page 1-6
"Precautions when using timer instructions" page 1-13

3-34
3-5 Flow Instructions

[Memo]
The sub-routine program is executed if CALL00 is
Program A
executed during execution of the main routine pro-

Main routine
00
gram. CALL

APPLIED INSTRUCTIONS
Program B
When execution of the sub-routine program ends,
END
program execution returns to program B following
the CALL00 instruction, and the main routine pro-
SBN
gram is executed until the END instruction is pro- 00

Sub-routine
grammed. Sub-routine
program
RET

SBN
01

3
To not execute the CALL instruction (input 00000 = OFF)

Flow Instructions
Program A
00000 00
CALL

Program B

To execute the CALL instruction (input 00000 = ON)

MC
SBN
MCR
Program A
A
CALL
00000 00
Sub-routine SBN
CALL program
RET RET

Program B
B FOR

NEXT

BREAK

00001 00
CALL
■ About sub-routine nesting structures
• Sub-routine instructions can be pro- Program A
grammed down to a nesting level of four. END
• To call a different sub-routine from inside a
sub-routine, the sub-routine to be called SBN
must already be defined (programmed in 01
the above rung). Sub-routine
program A
RET

SBN Call
00

Sub-routine
program B
00000 01
CALL
RET

ENDH

3-35
3-5 Flow Instructions

■ About calling of sub-routines from an interrupt program


• Call sub-routine programs from an interrupt 00001 00500
program.
APPLIED INSTRUCTIONS

• To call a sub-routine program from inside


an interrupt program, the sub-routine to be Program
called must already be defined (programmed END
in the above rung).
SBN
01

Sub-routine
program
RET

INT Call
00000
3 Interrupt
program
Flow Instructions

00002 01
CALL
RETI

ENDH

Operation flag
The operation flag does not change state.

Execution Timing
This instruction is executed at each scan for the duration that the execution condition is ON.

3-36
3-5 Flow Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Flow Instructions
MC

MCR

CALL

SBN

RET

FOR

NEXT

BREAK

3-37
3-5 Flow Instructions FOR Repeatedly executes the instruction sequence
FOR Repeat range start between the FOR and NEXT instructions for
the specified number of times in a single scan.
NEXT
NEXT Repeat range end Indicates the end of the repeat range.
BREAK
Forcibly ends repeated execution between the
BREAK Break
APPLIED INSTRUCTIONS

FOR and NEXT instructions.

Ladder program Input method


FOR
n F O R n

Program to repeat
Execution condition BREAK
B R E A K
NEXT
3 N E X T
Flow Instructions

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — —

n : Specifies the number of times that the program inside the FOR to NEXT instructions is
repeated.
*Can be specified within the range 0 to 65535.

Explanation of Operation
FOR • The program between the FOR to NEXT instructions is executed repeatedly within
a single scan for the number of times specified by n .
• The FOR instruction is executed unconditionally. To disable execution of the FOR
instruction, use the FOR instruction in combination with the STP and SBN instruc-
tions.
NEXT • Execution of this instruction is started from the instruction in the step following the
NEXT instruction after the program is executed for the specified number of times.
BREAK • This instruction is used for forcibly ending repeated execution between the FOR and
NEXT instructions when the execution condition is ON.
• Be sure to program the BREAK instruction between the FOR and NEXT instructions.
• Up to eight BREAK instructions can be used between a single FOR to NEXT
instruction program section. If the FOR to NEXT instructions are nested, up to eight
BREAK instructions can be used in the entire nested structure.

3-38
3-5 Flow Instructions

• The FOR instruction can be programmed down to a nesting level of eight.


If the nesting level exceeds nine, the "FOR-NEXT error" occurs, and the program cannot be
executed.

APPLIED INSTRUCTIONS
FOR
#5

(1)
FOR
#4

(2)
FOR
#3

Nest 3

Nest 2

Nest 1
(3) In this example,
the nesting level 3
NEXT is three.

Flow Instructions
NEXT

NEXT

(4)

• The program section in "Nest 1" is executed five times, and program execution jumps to
program (4).
For this reason, program (1) is executed five times.
MC
• While "Nest 1" is executed once, program (2) in "Nest 2" is executed four times.
MCR
This means that program (2) is executed a total of (5 x 4=) 20 times. CALL

• While "Nest 2" is executed once, program (3) in "Nest 3" is executed three times. SBN

RET
This means that program (3) is executed a total of (5 x 4 x 3=) 60 times.
FOR

NEXT

BREAK
Operation flag
The operation flag does not change state.

Execution Timing
The instruction is executed at every scan.

3-39
3-5 Flow Instructions

Sample Program
16-bit unsigned binary data currently stored to data memories DM00000 to DM00099 is added, and
the calculation result is stored to DM00100. Data is added in order from DM00000, and when the
APPLIED INSTRUCTIONS

result exceeds 1000, the calculation is stopped. At which data block the calculation was stopped is
stored to DM00101.

CR2002 #00000 TM010 #00000 DM00100 #00000 DM00101


LDA STA LDA STA LDA STA

FOR
#00100

CR2002 #TM010 DM00100 DM00100 TM010 DM00101


LDA ADD STA INC INC

3 DM00100
>=
BREAK

#01000
Flow Instructions

NEXT

"About indirect specification" page 1-42

3-40
3-5 Flow Instructions

This page left intentionally blank.

APPLIED INSTRUCTIONS
3

Flow Instructions
MC

MCR

CALL

SBN

RET

FOR

NEXT

BREAK

3-41
3-5 Flow Instructions

This page left intentionally blank.


APPLIED INSTRUCTIONS

3
Flow Instructions

3-42
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


ARITHMETIC OPERATION INSTRUCTIONS
These instructions are for executing comparisons, arithmetical calcu-
lations, logical calculations, data move, and text processing. 4
These instructions allow you to simply script complex arithmetic

Data Move Instructions


calculation circuits.

4-1 Data Move Instructions ...................................................... 4-2

4-2 Arithmetic/Comparison Instructions .............................. 4-24

4-3 Logical Arithmetic Operation Instructions ..................... 4-62

4-4 Data Shift Instructions ..................................................... 4-74

4-5 Data Conversion Instructions ..........................................4-88

4-6 Floating Point Instructions ............................................4-112

4-7 Text Processing Instructions ........................................4-168

4-1
4-1 Data Move Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-1 Data Move Instructions


Data move instructions store data to internal registers or other devices.

Data Move Instruction List


There are seven data move instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Write data DW(.U) Directly writes constants to data memory. 4-4
memory DW.S
DW.D
DW.L
Load A LDA(.U) Stores data to internal registers. 4-6
LDA.S
LDA.D
LDA.L
4 Store A STA(.U)
STA.S
Stores the data of internal registers to specified
devices.
4-8

STA.D
Data Move Instructions

STA.L
Trimmer setting TMIN Stores numerical values set by the digital trimmer in 4-12
value input the access window to internal registers.
Move MOV(.U) Stores 16/32-bit data to a specified device. 4-14
MOV.S
MOV.D
MOV.L
Block move BMOV Moves 16/32-bit data in blocks to a specified device. 4-18
Fill move FMOV(.U) Batch moves the same 16/32-bit data to a specified 4-20
FMOV.S device.
FMOV.D
FMOV.L

■ About data blocks


A group of data stored to continuous devices is called a "data block."
For example, a data block of ten words starting from data register DM01000 is described as
follows.

Device No. Stored content

DM01000: #00800
DM01001: #00200
DM01002: #00700
DM01003: #01000
DM01004: #00500
DM01005: #00600
DM01006: #00300
DM01007: #00100
DM01008: #00900
DM01009: #00400

4-2
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


■ About data move instruction execution conditions
The values of data stored to devices by data move instructions are held until new data is moved.
Values do not affect ON/OFF of execution conditions such as the OUT instruction.
For example, when the execution condition turns ON by "MOV #01000 DM00000", the constant
#01000 is stored to data memory DM00000. However, the content of DM00000 is held as it is
at #01000 even if the execution condition turns OFF after the constant is stored.

[Example] Let's assume that input relay 00000 is OFF when the program is started up.

00000 MOV
#010000 DM00000 The content of DM00000 is #00000.
OFF

00000 MOV
#010000 DM00000 The content of DM00000 becomes #01000.
ON

00000 MOV
4

Data Move Instructions


#010000 DM00000 The content of DM00000 stays #01000.
OFF

4-3
DW(.U)
4-1 Data MoveDW.D
Instructions
DW
DW DW.S
DW.L
ARITHMETIC OPERATION INSTRUCTIONS

Write data memory Directly writes constants to data memory.


@DW(.U)
@DW.D
@DW @DW.S
DW

@DW.L DW.F page 4-120

Ladder program Input method


Execution condition S
DW D W S D
D

Execution condition S
DW @ D W S D
D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — — —
4
S : Specifies the constant to store to data memory or control memory.
Data Move Instructions

D : Specifies the device to store the constant to.


The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation: DW(.U) DW.S (write 16-bit binary data)


When the execution condition is ON, the 16-bit binary data specified by S is stored to the data
memory (DM) or control memory (CM) specified by D .
DW(.U) The 16-bit unsigned binary data specified by S is stored to the data memory (DM)
or control memory (CM) specified by D .

S D
1234 1234
16 bits
(1 word)

DW.S The 16-bit signed binary data specified by S is stored to the data memory (DM)
or control memory (CM) specified by D .

S D
–1234 –1234
16 bits
(1 word)

Operation flag
The operation flag does not change state.

4-4
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation: DW.D DW.L (write 32-bit binary data)
When the execution condition is ON, the 32-bit binary data specified by S is stored to the data
memory (DM) or control memory (CM) specified by D / D +1.

DW.D The 32-bit unsigned binary data specified by S is stored to the data memory (DM)
or control memory (CM) specified by D / D +1.

S D +1 D
12345678 12345678
32 bits
(2 words)

DW.L The 32-bit signed binary data specified by S is stored to the data memory (DM)
or control memory (CM) specified by D / D +1.

S D +1 D
4
–12345678 –12345678

Data Move Instructions


32 bits
(2 words)

Operation flag
The operation flag does not change state.

Execution Timing
DW(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
DW
@DW(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution LDA
condition. STA

TMIN

Scan MOV

BMOV
ON

Execution condition FMOV


OFF

DW(.U/.D/.S/.L) Execution Execution

@DW(.U/.D/.S/.L) 1 scan execution

Sample Program
When input relay 00000 is ON, #00100 is stored to data memory DM00000.

00000 #00100
DW
DM00000

4-5
LDA(.U)
4-1 Data Move LDA.D
Instructions LDA
LDA LDA.S
LDA.L
ARITHMETIC OPERATION INSTRUCTIONS

Load A Stores data to internal registers.


@LDA(.U)
@LDA.D
@LDA @LDA.S
LDA

@LDA.L LDA.F page 4-122

Ladder program Input method


Execution condition S
LDA STA L D A S

Execution condition S
LDA STA @ L D A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — * * — — —

4 S : Specifies the data to write to internal registers or the device to which that data is currently
stored.
Data Move Instructions

* When T and C are specified for the device, the current value is read.
* When a bit device is specified, data is handled as continuous 16/32 bits. When a part other
than the start of a channel (e.g. 00002, 00106, 01012) is specified, 16/32 bits are handled
spanning the next channel.
"MOV Instruction" page 4-14
"About Bit Devices" page 1-11

Explanation of Operation: LDA(.U) LDA.S (write 16-bit binary data)


When the execution condition is ON, the 16-bit binary data specified by S is stored to the 16-
bit internal register.
"About Internal Registers" page 1-17

LDA(.U) The 16-bit unsigned binary data specified by S is stored to the 16-bit internal
register.

S 16-bit internal register


1234 1234
16 bits 16 bits
(1 word) (1 word)

LDA.S The 16-bit signed binary data specified by S is stored to the 16-bit internal register.

S 16-bit internal register


–1234 –1234
16 bits 16 bits
(1 word) (1 word)

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when the value read from the device specified to the operand is 0.
Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-6
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation: LDA.D LDA.L (write 32-bit binary data)
When the execution condition is ON, the 32-bit binary data specified by S is stored to the 32-
bit internal register.
"About Internal Registers" page 1-17

LDA.D The 32-bit unsigned binary data specified by S is stored to the 32-bit internal
register.

S +1 S 32-bit internal register


12345678 12345678
32 bits 32 bits
(2 words) (2 words)

LDA.L The 32-bit signed binary data specified by S is stored to the 32-bit internal register.

S +1 S 32-bit internal register


–12345678 –12345678 4
32 bits 32 bits

Data Move Instructions


(2 words) (2 words)

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when the value read from the device specified to the operand is 0.
Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON. DW

"About Indirect Specification" page 1-42 LDA

STA

TMIN

Execution Timing MOV

BMOV
LDA(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
FMOV
condition is ON.
@LDA(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

LDA(.U/.D/.S/.L) Execution Execution

@LDA(.U/.D/.S/.L) 1 scan execution

Sample Program
See the sample program for the STA instruction.
"Sample Programs" page 4-10

4-7
STA(.U)
4-1 Data Move STA.D
Instructions STA
STA STA.S
STA.L Stores the data of internal registers to
ARITHMETIC OPERATION INSTRUCTIONS

Store A
@STA(.U) specified devices.
@STA.D
@STA @STA.S
STA

@STA.L STA.F page 4-124

Ladder program Input method


Execution condition D
LDA STA S T A D

Execution condition D
LDA STA @ S T A D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D — — — — * * — — —
4 D : Specifies the No. of the device to store the internal register data to.
Data Move Instructions

* When T and C are specified for the device, the setting value is stored.
* When a bit device is specified, data is handled as continuous 16 bits. When a part other
than the start of a channel (e.g. 00002, 00106, 01012) is specified, data is not stored to
bits spanning the next channel.
"MOV Instruction" page 4-14
"About Bit Devices" page 1-11

Explanation of Operation: STA(.U) STA.S (move 16-bit binary data)


When the execution condition is ON, the 16-bit binary data currently stored to 16-bit internal register
is stored to the device specified by D .
"About Internal Registers" page 1-17
STA(.U) The 16-bit unsigned binary data currently stored to 16-bit internal register is stored to
the device specified by D .

16-bit internal register D


1234 1234
16 bits 16 bits
(1 word) (1 word)

STA.S The 16-bit signed binary data currently stored to 16-bit internal register is stored to the
device specified by D .

16-bit internal register D


–1234 –1234
16 bits 16 bits
(1 word) (1 word)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-8
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation: STA.D STA.L (move 32-bit binary data)
When the execution condition is ON, the 32-bit binary data currently stored to 32-bit internal register
is stored to the device specified by D / D +1.
"About Internal Registers" page 1-1
STA.D The 32-bit unsigned binary data currently stored to 32-bit internal register is stored to
the device specified by D / D +1.

32-bit internal register D +1 D


12345678 12345678
32 bits 32 bits
(2 words) (2 words)

STA.L The 32-bit signed binary data currently stored to 32-bit internal register is stored to the
device specified by D / D +1.

32-bit internal register D +1 D


4
–12345678 –12345678

Data Move Instructions


32 bits 32 bits
(2 words) (2 words)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON. DW

"About Indirect Specification" page 1-42 LDA

STA

TMIN

Execution Timing MOV

BMOV
STA(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
FMOV
condition is ON.
@STA(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

STA(.U/.D/.S/.L) Execution Execution

@STA(.U/.D/.S/.L) 1 scan execution

4-9
4-1 Data Move Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Sample Programs
Changing the timer setting values
To change the setting value within the range 0 to 65535
When input relay 00000 is ON, the setting value of timer T000 is set to #00100.
When input relay 00000 is OFF, the setting value of timer T000 is changed to the value currently
stored to data memory DM00000.

00000 #00100 T000


LDA STA

00000 DM00000 T000


LDA STA

4 Use the MOV instruction to change the current value of timers/counters.


Data Move Instructions

"MOV Instruction" page 4-14

Note: About the current value when the setting value has been changed
• Operation as a result of executing the STA instruction:
When the current value > setting value, the current value is changed to the same
value as the setting value.

Moving a counter current value to a data memory


When input relay 00000 is ON, the current value of counter C000 is stored to data memory DM00000.
When input relay 00001 is ON, the current value of counter C000 is stored to data memory DM00100.

00000 C000 DM00000


LDA STA

00001 MOV
C000 DM00100

4-10
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Example of specifying a bit device in the operand
The states of input relays 00000 to 00015 are stored to data memory DM00000.

00015 00000
CR2002 00000 DM00000 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Input relay
LDA STA
LDA

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 16-bit internal register

STA

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000

The states of data memory DM00000 are output to output relays 00500 to 00515.

CR2002 DM00000 00500 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000


LDA STA
LDA 4
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 16-bit internal register

Data Move Instructions


00515
STA 00500

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Output rerey

[Tip]
When the bit device specified by the LDA operand spans channels, the states of the 16 bits
spanning across channels are stored to internal register.

1ch 0ch
00102 00003
DW
CR2002 00003 DM00000 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Input relay
LDA STA LDA
LDA STA

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 16-bit internal register TMIN

MOV
STA
BMOV
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000
FMOV

[Tip]
When the bit device specified by the STA operand spans channels, the data is not stored to bits
spanning across channels.

CR2002 DM00000 00503 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000


LDA STA
LDA

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 16-bit internal register

6ch 5ch
00602
STA 00503

? ? ? 0 1 0 1 0 1 0 1 0 1 0 1 0 Output relay

Data is not stored to 00600 to 00602.


The state of 00600 to 00602 does not change
before or after execution of the instruction.

4-11
TMIN
4-1 Data Move Instructions
TMIN
Trimmer setting Inputs numerical values set by the digital trimmer
value input in the access window to internal registers.
ARITHMETIC OPERATION INSTRUCTIONS

@TMIN TMIN

Ladder program Input method


Execution condition D
TMIN STA.D T M I N D

Execution condition D
TMIN STA.D @ T M I N D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — — —

n : Specifies digital trimmer Nos. 0 to 7. (The "#" symbol can be omitted.)

4 The No. cannot be specified in $(Hex).


Data Move Instructions

Explanation of Operation
When the execution condition is ON, the value of the digital trimmer is stored to 32-bit internal
register. For details on the function and how to operate the digital trimmers in the access window,
read the KV-700 User's Manual "Chapter 2 Access Window."

. Timer/counter setting value


. Relay channel No.
TMIN 32-bit internal register STA.D . Data memory
. Temporary data memory

Digital trimmer of
Numerical value data
access window Input Move Move destination
of 0 to 4294967295
0 to 4294967295

"About Internal Registers" page 1-17

[Tip]
Each of the upper limit values of the digital trimmers can be set.
To enable preset upper limit values, you must set using the MEMSW instruction.
"MEMSW Instruction" page 3-8

Trimmer upper limit storage destination


Upper Limit Value Storage Destination
Trimmer No.
Upper Lower
0 CM1701 CM1700
1 CM1703 CM1702
2 CM1705 CM1704
3 CM1707 CM1706
4 CM1709 CM1708
5 CM1711 CM1710
6 CM1713 CM1712
7 CM1715 CM1714

4-12
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when the value captured from the digital trimmer is "0". Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

Execution Timing
TMIN This instruction is executed at each scan for the duration that the execution
condition is ON.
@TMIN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan

Execution condition
ON
4
OFF

Data Move Instructions


TMIN Execution Execution

@TMIN 1 scan execution

Sample Program

Digital value of trimmer 0 is entered to 32-bit internal register.


The value of 32-bit internal register is moved to timer T000.
DW
CR2002 0 T000
TMIN STA.D LDA

STA
00000 #65535 T000 00500 TMIN
T000
MOV

Output 00500 turns ON when the current value of T000 becomes "#00000". BMOV

T000 functions as an ON delay timer when 00000 is ON. FMOV


The setting value of T000 (#65535) is invalid.

4-13
MOV(.U)
4-1 Data Move Instructions MOV
MOV.D
MOV MOV.S
MOV.L
ARITHMETIC OPERATION INSTRUCTIONS

Move Stores 16/32-bit data to a specified device.


@MOV(.U)
MOV
@MOV.D
@MOV @MOV.S
@MOV.L MOV.F page 4-126

Ladder program Input method


Execution condition MOV
S D M O V S D

Execution condition MOV


S D @ M O V S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — * * — — — —
4 D — — — — * * —

S : Specifies the source data to be moved or the leading device to which the data is currently
Data Move Instructions

stored.
D : Specifies the device (move destination) to store the data to.
* When devices T and C are specified, the current value becomes the move source (or move
destination).
* When a bit device is specified, data is handled as continuous 16 bits. When a part other
than the start of a channel (e.g. 00002, 00106, 01012) is specified, 16 bits are handled
spanning the next channel.

Explanation of Operation: MOV(.U) MOV.S (move 16-bit binary data)


When the execution condition is ON, the 16-bit binary data currently stored to the device specified
by S is stored to the device specified by D .

MOV(.U) The 16-bit unsigned binary data currently stored to the device specified by S is
stored to the device specified by D .
MOV.S The 16-bit signed binary data currently stored to the device specified by S is stored
to the device specified by D .

MOV
[Example] When the constant is specified by S #12345 DM00100

State of data memory before State of data memory after


instruction executio instruction execution

DM00098: 0 S : 12345 DM00098: 0

DM00099: 0 DM00099: 0

DM00100: 0 Move D : DM00100: 12345

DM00101: 0 DM00101: 0

DM00102: 0 DM00102: 0
16 bits
(1 word)

4-14
4-1 Data Move Instructions

MOV

ARITHMETIC OPERATION INSTRUCTIONS


[Example] When the device No. is specified by S
DM00099 DM00101
State of data memory before State of data memory after
instruction execution instruction execution

DM00098: 0 DM00098: 0

DM00099: 12345 : S DM00099: 12345

DM00100: 0 DM00100: 0

DM00101: 0 Move D : DM00101: 12345

DM00102: 0 DM00102: 0
16 bits
(1 word)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
4

Data Move Instructions


ate. Otherwise, OFF
"About Indirect Specification" page 1-42

Explanation of Operation: MOV.D MOV.L (move 32-bit binary data)


When the execution condition is ON, the 32-bit binary data currently stored to the device specified
by S / S +1 is stored to the device specified by D / D +1.

MOV.D The 32-bit unsigned binary data currently stored to the device specified by S / S
+1 is stored to the device specified by D / D +1.
DW
MOV.L The 32-bit signed binary data currently stored to the device specified by S / S
+1 is stored to the device specified by D / D +1. LDA

STA

TMIN
MOV.D
[Example] When the constant is specified by S #12345678 DM00014
MOV

BMOV

FMOV
State of data memory before instruction execution State of data memory after instruction execution
Upper Lower Upper Lower

DM00011: 0 :DM00010 S DM00011: 0 :DM00010


DM00013: 0 :DM00012 : #12345678 DM00013: 0 :DM00012
DM00015: 0 :DM00014 Move DM00015: 12345678 :DM00014 : [ D . D +1]
DM00017: 0 :DM00016 DM00017: 0 :DM00016
DM00019: 0 :DM00018 DM00019: 0 :DM00018
32 bits (1 word)

MOV.D
[Example] When the device No. is specified by S DM00012 DM00016

State of data memory before instruction execution State of data memory after instruction execution
Upper Lower Upper Lower

DM00011: 0 :DM00010 DM00011: 0 :DM00010


DM00013: 12345678 :DM00012 : [ S . S +1] DM00013: 12345678 :DM00012
DM00015: 0 :DM00014 DM00015: 0 :DM00014
.
DM00017: 0 :DM00016 Move DM00017: 12345678 :DM00016 : [ D D +1]

DM00019: 0 :DM00018 DM00019: 0 :DM00018


32 bits (1 word)

4-15
4-1 Data Move Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
"About Indirect Specification" page 1-42

Execution Timing
MOV(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@MOV(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

4 Scan
Data Move Instructions

ON

Execution condition
OFF

MOV(.U/.D/.S/.L) Execution Execution

@MOV(.U/.D/.S/.L) 1 scan execution

Sample Program
When input relay 00000 is ON, the content of data memory DM00000 is moved to DM00100.

00000 MOV
DM00000 DM00100

Changing the counter current value


To change the setting value within the range 0 to 65535
When input relay 00000 has turned ON, the current value of counter C000 is set to #00100.
When input relay 00000 has turned OFF, the current value of counter C000 is changed to the value
currently stored to data memory DM00000.

00000 MOV
#100 C000
00000 MOV
DM00000 C000

• Even if values are changed by a suffix .U instruction, the value is automatically extended to 32 bits,
and is stored to the current value of the counter.

Note: Operation as a result of executing the MOV instruction:


When the current value > setting value, the current value is changed to the same value as
the setting value.

4-16
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Example of specifying a bit device in the operand
The states of input auxiliary relays 01000 to 01015 are stored to data memory DM00000.

01015 01000
CR2002 MOV 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Internal auxiliary relays
01000 DM00000
MOV

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000

[Tip]
When the bit device specified by the No.1 operand spans channels, the states of the 16 bits
spanning across channels are stored to DM00000.

1ch 0ch
00102 00003
CR2002 MOV 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Input relay
00003 DM00000
MOV

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000
4

Data Move Instructions


[Tip]
When the bit device specified by the No.2 operand spans channels, the data is stored to the 16
bits spanning across channels.

CR2002 MOV 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 DM00000


DM00000 01005
11ch 10ch MOV
01104 01005

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Internal auxiliary relays

DW

LDA

STA

TMIN

MOV

BMOV

FMOV

4-17
BMOV
BMOV
4-1 Data Move Instructions
Moves 16/32-bit data in blocks to a speci-
Block move
fied device.
ARITHMETIC OPERATION INSTRUCTIONS

BMOV
@BMOV
Ladder program Input method
Execution condition BMOV
S D n B M O V S D n

Execution condition BMOV


S D n @ B M O V S D n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — —
D — — — — — — — — — —
n — — — — — — — — — — — — — — —

4 S : Specifies the start device of the move source data block.


D : Specifies the start device of the move destination data block.
Data Move Instructions

n : Specifies the number of data items to move.


* Specify the leading channel No. (00000, 00100, 00200 and so forth) as the bit device.
A number midway in the channel (00001, 00102, 00203, and so forth) cannot be specified.

Explanation of Operation: BMOV


When the execution condition is ON, the content of n words starting from the device specified
by S is moved in a block to n words starting from the device specified by D .

S Move D
S +1 Move D +1

S +2 Move D +2
...

...

...

S + n -2 Move D + n -2

S + n -1 Move D + n -1

[Example]

When S :DM00100, BMOV


D :TM104. DM00100 TM104 #00005
n : #00005

Move source Move destination

DM00100: 1 1 :TM104
DM00101: 3 3 :TM105
DM00102: 7 7 :TM106
DM00103: 15 15 :TM107
DM00104: 31 31 :TM108
16 bits 16 bits
(1 word) (1 word)

• Data blocks at the move source and move destination will not be moved if they are partially
duplicated.

4-18
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
The operation flag does not change state.

Execution Timing
BMOV(.U) This instruction is executed at each scan for the duration that the execution
condition is ON.
@BMOV(.U) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

BMOV(.U) Execution Execution

@BMOV(.U) 1 scan execution


4

Data Move Instructions


Sample Program
When input relay 00000 is ON, the data block of data memories DM00000 to DM00009 is moved
as a block to DM00100 to DM00109.

00000 BMOV
DM00000 DM00100 #00010

DW

LDA

STA

TMIN

MOV

BMOV

FMOV

4-19
FMOV(.U)
4-1 Data Move Instructions FMOV
FMOV.D
FMOV FMOV.S
FMOV.L Batch moves the same 16/32-bit
ARITHMETIC OPERATION INSTRUCTIONS

Fill move
@FMOV(.U) data to a specified device.
FMOV
@FMOV.D
@FMOV @FMOV.S
@FMOV.L

Ladder program Input method


Execution condition FMOV
S D n F M O V S D n

Execution condition @FMOV


S D n @ F M O V S D n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — * * — — —
D — — — — — — — — — —
4 n — — — — — — — — — — — — — — —
Data Move Instructions

S : Specifies the move source data or the device to which the data is currently stored.
D : Specifies the leading device of the move destination data block.
n : Specifies the number of data items to move.
* When devices T and C are specified, each of their current values becomes the specified
target.
* Specify the leading channel No. (0000, 0100, 0200 and so forth) as the bit device to be
specified by D . A number midway in the channel (0001, 0102, 0203, and so forth)
cannot be specified.

Explanation of Operation: FMOV(.U) FMOV.S (batch move 16-bit binary data)


When the execution condition is ON, the 16-bit binary data currently stored to the device specified
by S is moved to n words starting from the device specified by D .

FMOV(.U) The 16-bit unsigned binary data currently stored to the device specified by S is
moved to n words starting from the device specified by D .
FMOV.S The 16-bit signed binary data currently stored to the device specified by S is moved
to n words starting from the device specified by D .

D
D +1

D +2
...

S
D + n -3

D + n -2

D + n -1

4-20
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Example] S :DM00100, FMOV
D :TM104. DM00100 TM104 #00005
n :In case of #00005

Move destination
123 :TM104
Move source 123 :TM105

DM00100: 123 123 :TM106


16 bits
(1 word) 123 :TM107
123 :TM108
16 bits
(1 word)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state 4
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-

Data Move Instructions


ate. Otherwise, OFF
"About Indirect Specification" page 1-42

Explanation of Operation: FMOV.D FMOV.L (move 32-bit binary data block)


When the execution condition is ON, the 32-bit binary data currently stored to the device specified
by S / S +1 is stored to n x 2 words starting from the device specified by D / D +1.

FMOV.D The 32-bit unsigned binary data currently stored to the device specified by S / S
+1 is stored to n x 2 words starting from the device specified by D / D +1.
DW

FMOV.L The 32-bit signed binary data currently stored to the device specified by S / S LDA
+1 is stored to n x 2 words starting from the device specified by D / D +1. STA

TMIN

[ D . D +1] MOV

BMOV
[ D +2 . D +3]
FMOV
[ D +4 . D +5]
.
...

[ S S +1]

[ D +2(n–3) . D +2(n–3)+1]

[ D +2(n–2) . D +2(n–2)+1]

[ D +2(n–1) . D +2(n–1)+1]

4-21
4-1 Data Move Instructions
ARITHMETIC OPERATION INSTRUCTIONS

[Example]
S :DM00100, FMOV.D
D :TM104. DM00100 TM104 #00005
n :In case of #00005
Move destination
Upper Lower

TM105: 12345678 :TM104


Move source
Upper Lower TM107: 12345678 :TM106
DM00101: 12345678 TM109: 12345678 :TM108
32 bits (1 word)
TM111: 12345678 :TM110
TM113: 12345678 :TM112
32 bits (1 word)

Operation flag
CR2009 .......... No change in state
4 CR2010 .......... No change in state
Data Move Instructions

CR2011 .......... No change in state


CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
"About Indirect Specification" page 1-42

Execution Timing
FMOV(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@FMOV(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

FMOV(.U/.D/.S/.L) Execution Execution

@FMOV(.U/.D/.S/.L) 1 scan execution

Sample Program
When input relay 00000 is ON, "0" is stored to all data memories DM00000 to DM00099.

00000 FMOV
#00000 DM00000 #00100

4-22
4-1 Data Move Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Data Move Instructions


DW

LDA

STA

TMIN

MOV

BMOV

FMOV

4-23
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-2 Arithmetic/Comparison Instructions


This instructions are for performing arithmetic calculations (addition, subtraction, multiplication,
division) on two data items and comparing their size. The data that can be handled in these
instructions varies according to the suffix: 16/32-bit unsigned binary and 16/32-bit signed binary.

Arithmetic/Comparison Instruction List


There are nine arithmetic/comparison instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Add ADD(.U) Adds 16-bit unsigned binary data. 4-28
ADD.S Adds 16-bit signed binary data.
ADD.D Adds 32-bit unsigned binary data.
ADD.L Adds 32-bit signed binary data.
Subtract SUB(.U) Subtracts 16-bit unsigned binary data. 4-32
SUB.S Subtracts 16-bit signed binary data.
4 SUB.D Subtracts 32-bit unsigned binary data.
SUB.L Subtracts 32-bit signed binary data.
Arithmetic/Comparison Instructions

Multiply MUL(.U) Multiplies 16-bit unsigned binary data. 4-36


MUL.S Multiplies 16-bit signed binary data.
MUL.D Multiplies 32-bit unsigned binary data.
MUL.L Multiplies 32-bit signed binary data.
Divide DIV(.U) Divides 16-bit unsigned binary data. 4-40
DIV.S Divides 16-bit signed binary data.
DIV.D Divides 32-bit unsigned binary data.
DIV.L Divides 32-bit signed binary data.
Increment memory INC(.U) Increments 16-bit unsigned binary data by 1. 4-44
INC.S Increments 16-bit signed binary data by 1.
INC.D Increments 32-bit unsigned binary data by 1.
INC.L Increments 32-bit signed binary data by 1.
Decrement DEC(.U) Decrements 16-bit unsigned binary data by 1. 4-48
memory DEC.S Decrements 16-bit signed binary data by 1.
DEC.D Decrements 32-bit unsigned binary data by 1.
DEC.L Decrements 32-bit signed binary data by 1.
Square root ROOT(.U) Calculates the square root of 16-bit unsigned binary data. 4-52
ROOT.S Calculates the square root of 16-bit signed binary data.
ROOT.D Calculates the square root of 32-bit unsigned binary data.
ROOT.L Calculates the square root of 32-bit signed binary data.
Compare CMP(.U) Compares a range of 16-bit unsigned binary data. 4-54
CMP.S Compares a range of 16-bit signed binary data.
CMP.D Compares a range of 32-bit unsigned binary data.
CMP.L Compares a range of 32-bit signed binary data.
Zone compare ZCMP(.U) Compares a range of 16-bit unsigned binary data. 4-58
ZCMP.S Compares a range of 16-bit signed binary data.
ZCMP.D Compares a range of 32-bit unsigned binary data.
ZCMP.L Compares a range of 32-bit signed binary data.

4-24
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


■ Cautions relating to arithmetic calculation instructions
An overflow or underflow occurs when the result of arithmetic calculations exceeds the range of
numerical values that can be handled on 16/32-bit unsigned/signed data.

In the case of 16-bit binary data

Unsigned binary Signed binary HEX


(Decimal annotation) (Decimal annotation) (Hex annotation)
Suffix .U Suffix .S
3 3 0003
2 2 0002
1 1 0001
0 0 0000
65535 -1
FFFF
65534 -2 FFFE
-3
Overflow

Underflow

Overflow

Underflow
65533 FFFD
-4
Overflow

Underflow
65532 FFFC

...
...

...
32771 -32765 8003
32770 -32766
8002
32769 -32767
8001
32768 -32768
8000
32767 32767 7FFF
32766
32765
32764
32766
32765
7FFE
7FFD
4
32764 7FFC
32763

Arithmetic/Comparison Instructions
32763 7FFB

In the case of 32-bit binary data

Unsigned binary Signed binary HEX


(Decimal annotation) (Decimal annotation) (Hex annotation)
Suffix .D Suffix .L
3 3 00000003
2 2 00000002
1 1 00000001
0 0 00000000
4294967295 -1 FFFFFFFF
4294967294 -2 FFFFFFFE
Overflow
Underflow
Overflow
Underflow

4294967293 -3 FFFFFFFD
4294967292 -4 FFFFFFFC
Overflow
Underflow
...

...
...

2147483651 -2147483645 80000003


2147483650 -2147483646 80000002
2147483649 -2147483647 80000001
2147483648 -2147483648 80000000
2147483647 2147483647 7FFFFFFF
2147483646 2147483646 7FFFFFFE
2147483645 2147483645 7FFFFFFD
2147483644 2147483644 7FFFFFFC
2147483643 2147463643 7FFFFFFB

4-25
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

The following five types of data formats can be handled in arithmetic calculation operations.
The data format is judged by the suffix appended to the instruction.

Suffix Arithmetic Operation Data Format


.U 0 to 65535
.D 0 to 4294967295
.S –32768 to 32767
.L –2147483648 to 2147483647
.F Floating point real numbers*

* For details on floating point real numbers, see "Floating point real numbers" ( page 1-23).
An overflow or underflow occurs of the result of addition (ADD instruction) or subtraction (SUB
instruction) exceeds the data format range.

● In case of .U (0 to 65535)
ADD.U 2
4 1

Overflow
When the operation result exceeds 65535
0
[Example] 65535 + 4 = 5
Arithmetic/Comparison Instructions

65535
65534
and the operation flag CR3009 turns ON.
65533

SUB.U 2
1

Underflow
When the operation result falls below 0
0
[Example] 4 – 5 = 65535 65535
65534
and the operation flag CR2009 turns ON.
65533

● In case of .S (–32768 to +32767)


ADD.S –32766
When the operation result exceeds +32767, the operation result –32767
becomes a minus number. –32768 Overflow
+32767
[Example] +32767 + 3 = –32766 +32766
and the operation flag CR2009 turns ON. +32765

SUB.S
–32766
When the operation result falls below –32767, the operation
Underflow

–32767
result becomes a plus number. –32768
+32767
[Example] –32766 – 3 = +32767
+32766
and the operation flag CR2009 turns ON. +32765

4-26
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


● In case of .D (0 to 44294967295)
ADD.D 2
1
When the operation result exceeds 4294967295

Overflow
0
[Example] 4294967295 + 5 = 4 4294967295

and the operation flag CR2009 turns ON. 4294967294


4294967293

SUB.D 2
1

Underflow
When the operation result falls below 0
0
[Example] 4 – 5 = 4294967295 4294967295
and the operation flag CR2009 turns ON. 4294967294
4294967293

● In case of .L (–2147483648 to +2147483647)


ADD.L –2147483646
–2147483647 4

Overflow
When the operation result exceeds +2147483647, the opera-
–2147483648
tion result becomes a minus number.

Arithmetic/Comparison Instructions
+2147483647
[Example] +2147483647 + 3 = –2147483646 +2147483646
+2147483657
and the operation flag CR2009 turns ON.

SUB.L –2147483646

Underflow
When the operation result falls below –2147483648, the opera- –2147483647

tion result becomes a plus number. –2147483648


+2147483647
[Example] –2147483646 – 3 = +2147483647 +2147483646

and the operation flag CR2009 turns ON. +2147483657

4-27
ADD(.U)
4-2 Arithmetic/Comparison
ADD.D Instructions
ADD ADD.S
ADD.L
ADD
Adds the value specified by the operand to the
ARITHMETIC OPERATION INSTRUCTIONS

Add value of the internal register, and stores the


@ADD(.U)
@ADD.D result again to the internal register.
@ADD @ADD.S ADD
@ADD.L ADD.F page 4-134

Ladder program Input method


Execution condition S
LDA ADD STA A D D S ( + S )

Execution condition S
LDA ADD STA @ A D D S ( @ + S )

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the addition data or the device to which the data is currently stored.
4 The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: ADD(.U) ADD.S (add 16-bit binary data)


When the execution condition is ON, the 16-bit binary data specified by S and the data of the
16-bit internal register are added, and the result is stored to the 16-bit internal register.
"About Internal Registers" page 1-17
16-bit internal
register + S = 16-bit internal
register
16 bits 16 bits 16 bits
(1 word)

[Tip]
The ADD and @ADD instructions perform addition in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

ADD.(.U) 16-bit unsigned binary data and unsigned data in the 16-bit internal register are added,
and the result is stored to the 16-bit internal register.
16-bit internal register S 16-bit internal register

1234 + 4321 = 5555


16 bits 16 bits 16 bits
(1 word)

An overflow occurs if the operation result is greater than 65535.


"Cautions relating to arithmetic calculation instructions" page 4-25

ADD.S 16-bit signed binary data and signed data in the 16-bit internal register are added, and
the result is stored to the 16-bit internal register.
16-bit internal register S 16-bit internal register

1234 + –4321 = –3087


16 bits 16 bits 16 bits
(1 word)

An overflow occurs if the operation result is greater than 32767.


An underflow occurs if the operation result falls below –32768.
"Cautions relating to arithmetic calculation instructions" page 4-25

4-28
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 16-bit range. Otherwise,
OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 4-42

Explanation of Operation: ADD.D ADD.L (add 32-bit binary data)


When the execution condition is ON, the 32-bit binary data specified by S / S +1 and the data
of the 32-bit internal register are added, and the result is stored to the 32-bit internal register.
"About Internal Registers" page 1-17

Upper Lower Upper Lower


4
32-bit internal register + S +1 S = 32-bit internal register

Arithmetic/Comparison Instructions
32 bits 32 bits 32 bits
(2 words)

[Tip]
The ADD and @ADD instructions perform addition in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

ADD.D 32-bit unsigned binary data and unsigned data in the 32-bit internal register are
added, and the result is stored to the 32-bit internal register.
32-bit internal register S +1 S 32-bit internal register ADD

12345678 + 87654321 = 99999999 SUB

32 bits 32 bits 32 bits MUL


(2 words)
DIV
An overflow occurs if the operation result is greater than 4294967295. INC
"Cautions relating to arithmetic calculation instructions" page 4-25 DEC

ROOT
ADD.L 32-bit signed binary data and signed data in the 32-bit internal register are added, and CMP
the result is stored to the 32-bit internal register.
ZCMP

32-bit internal register S +1 S 32-bit internal register

12345678 + –87654321 = –75308643


32 bits 32 bits 32 bits
(2 words)

An overflow occurs if the operation result is greater than 2147483647.


An underflow occurs if the operation result falls below –2147483648.
"Cautions relating to arithmetic calculation instructions" page 4-25

Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 32-bit range.
Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-29
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
ADD(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@ADD(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ADD(.U/.D/.S/.L) Execution Execution

@ADD(.U/.D/.S/.L) 1 scan execution

Sample Program
4 Each time that input relay 00000 turns ON, constant 100 is added to data memory DM00000, and
the result is stored to DM00100.
Arithmetic/Comparison Instructions

00000 DM00000 #00100 DM00100


LDA ADD STA

Each time that input relay 00001 turns ON, constant –100 is added to data memory DM00100, and
the result is stored to DM00110.

00001 DM00100 –100 DM00110


LDA.S ADD.S STA.S

Each time that input relay 00002 turns ON, constant 100000 is added to data memory DM00200,
and the result is stored to DM00210.

00002 DM00200 #100000 DM00210


LDA.D ADD.D STA.D

Each time that input relay 00003 turns ON, constant –100000 is added to data memory DM00300,
and the result is stored to DM00310.

00003 DM00300 –100000 DM00310


LDA.L ADD.L STA.L

4-30
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-31
SUB(.U)
4-2 Arithmetic/Comparison
SUB.D Instructions
SUB SUB.S
SUB.L
SUB
Subtracts the value specified by the operand
ARITHMETIC OPERATION INSTRUCTIONS

Subtract from the value of the internal register, and stores


@SUB(.U)
@SUB.D the result again to the internal register.
@SUB @SUB.S
SUB

@SUB.L SUB.F page 4-136

Ladder program Input method


Execution condition S
LDA SUB STA S U B S

Execution condition S
LDA SUB STA @ S U B S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — *
* SUB(.U) only
4 S : Specifies the subtraction data or the device to which the data is currently stored.
Arithmetic/Comparison Instructions

The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation: SUB(.U) SUB.S (subtract 16-bit binary data)


When the execution condition is ON, the 16-bit binary data specified by S is subtracted from the
data of the 16-bit internal register, and the result is stored to the 16-bit internal register.
"About Internal Registers" page 1-17

16-bit internal
register S = 16-bit internal
register
16 bits 16 bits 16 bits
(1 word)

[Tip]
The SUB and @SUB instructions perform subtraction in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

SUB.(.U) Unsigned data in the 16-bit internal register is subtracted from 16-bit unsigned binary
data, and the result is stored to the 16-bit internal register.
16-bit internal register S 16-bit internal register

5555 4321 = 1234


16 bits 16 bits 16 bits
(1 word)

An underflow occurs if the operation result falls below 0.


"Cautions relating to arithmetic calculation instructions" page 4-25

SUB.S Signed data in the 16-bit internal register is subtracted from 16-bit signed binary data,
and the result is stored to the 16-bit internal register.
16-bit internal register S 16-bit internal register

5555 –4321 = 9876


16 bits 16 bits 16 bits
(1 word)

An overflow occurs if the operation result is greater than 32767.


An underflow occurs if the operation result falls below –32768.
"Cautions relating to arithmetic calculation instructions" page 4-25

4-32
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 16-bit range. Otherwise,
OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state (SUB(.U) only: ON when the result is plus. Otherwise, OFF)
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Explanation of Operation: SUB.D SUB.L (subtract 32-bit binary data)


When the execution condition is ON, the 32-bit binary data specified by S / S +1 is subtracted
from the data of the 32-bit internal register, and the result is stored to the 32-bit internal register.
"About Internal Registers" page 1-17

Upper Lower Upper Lower


4
32-bit internal register S +1 S = 32-bit internal register

Arithmetic/Comparison Instructions
32 bits 32 bits 32 bits
(2 words)

[Tip]
The SUB and @SUB instructions perform subtraction in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

SUB.D Unsigned data in the 32-bit internal register is subtracted from 32-bit unsigned binary
data, and the result is stored to the 32-bit internal register.
32-bit internal register S +1 S 32-bit internal register ADD

99999999 12345678 = 87654321 SUB

32 bits 32 bits 32 bits MUL


(2 words)
DIV
An overflow occurs if the operation result is greater than 4294967295. INC
An underflow occurs if the operation result falls below 0.
DEC
"Cautions relating to arithmetic calculation instructions" page 4-25
ROOT

CMP

SUB.L Signed data in the 32-bit internal register is subtracted from 32-bit signed binary data, ZCMP

and the result is stored to the 32-bit internal register.


32-bit internal register S +1 S 32-bit internal register

87654321 –12345678 = 99999999


32 bits 32 bits 32 bits
(2 words)

An overflow occurs if the operation result is greater than 2147483647.


An underflow occurs if the operation result falls below –2147483648.
"Cautions relating to arithmetic calculation instructions" page 4-25

4-33
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 32-bit range. Otherwise,
OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
SUB(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@SUB(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.
4
Scan
Arithmetic/Comparison Instructions

ON

Execution condition
OFF

SUB(.U/.D/.S/.L) Execution Execution

@SUB(.U/.D/.S/.L) 1 scan execution

Sample Program
Each time that input relay 00000 turns ON, 100 is subtracted from data memory DM00000, and the
result is stored to DM00100.

00000 DM00000 #00100 DM00010


LDA SUB STA

Each time that input relay 00001 turns ON, constant –100 is subtracted from data memory
DM00100, and the result is stored to DM00110.

00001 DM00100 –100 DM00110


LDA.S SUB.S STA.S

Each time that input relay 00002 turns ON, constant 100000 is subtracted to data memory DM00200,
and the result is stored to DM00210.

00002 DM00200 #100000 DM00210


LDA.D SUB.D STA.D

Each time that input relay 00003 turns ON, constant –100000 is subtracted from data memory
DM00300, and the result is stored to DM00310.

00003 DM00300 –100000 DM00310


LDA.L SUB.L STA.L

4-34
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-35
MUL(.U)
4-2 Arithmetic/Comparison
MUL.D Instructions
MUL
MUL MUL.S
MUL.L
Multiplies the value specified by the operand with
ARITHMETIC OPERATION INSTRUCTIONS

Multiply the value of the internal register, and stores the


@MUL(.U)
@MUL.D result again to the internal register.
@MUL @MUL.S
MUL

@MUL.L MUL.F page 4-138

Ladder program Input method


Execution condition S
LDA MUL STA M U L S ( * S )

Execution condition S
LDA MUL STA @ M U L S ( @ * S )

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the multiplication data or the device to which the data is currently stored.
4 The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: MUL(.U) MUL.S (multiply 16-bit binary data)


When the execution condition is ON, the 16-bit binary data specified by S and the data of the
16-bit internal register are multiplied, and the result is stored to the 16-bit internal register. The result
is calculated as 32-bit data.
"About Internal Registers" page 1-17

32-bit internal register


* The upper 16 bits are stored to both the
16-bit internal
S = Upper Lower
+

register
16-bit internal
upper 16 bits of the 32-bit internal register
16 bits 16 bits TM000 register and to TM000.
(1 word)
32 bits
[Tip] (2 words)

The MUL and @MUL instructions perform multiplication in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

MUL(.U) Unsigned data in the 16-bit internal register is multiplied with 16-bit unsigned binary
data, and the result is stored to the 32-bit internal register.
32-bit internal register

16-bit internal register S 56088


123 456 = TM000 16-bit internal register
+

16 bits 16 bits 56088


(1 word)
32 bits
(2 words)

MUL.S Signed data in the 16-bit internal register is multiplied with 16-bit signed binary data,
and the result is stored to the 32-bit internal register.
32-bit internal register

16-bit internal register S –15129


–123 123 = TM000 16-bit internal register
+

16 bits 16 bits –15129


(1 word)
32 bits
(2 words)

4-36
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 16-bit range.
Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Explanation of Operation: MUL.D MUL.L (multiply 32-bit binary data)


When the execution condition is ON, the 32-bit binary data specified by S / S +1 and the data
of the 32-bit internal register are multiplied, and the result is stored to the 32-bit internal register and
temporary data memories TM000 and TM0001. The result is calculated as 64-bit data.
"About Internal Registers" page 1-17

Upper Lower Upper 32 bits Lower 32 bits


4
=

Arithmetic/Comparison Instructions
32-bit internal register S +1 S TM001 TM000 32-bit internal register
+

32 bits 32 bits 64 bits


(2 words)

[Tip]
The MUL and @MUL instructions perform multiplication in binary. When values stored to internal
register are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

MUL.D 32-bit unsigned binary data and unsigned data in the 32-bit internal register are
multiplied, and the result is stored to the 32-bit internal register and TM000 and TM001.
ADD

SUB

32-bit internal register S +1 S TM001 TM000 32-bit internal register MUL

1234 5678 = 7006652 DIV


+

32 bits 32 bits 64 bits INC


(2 words)
DEC

MUL.L 32-bit signed binary data and signed data in the 32-bit internal register are multiplied, ROOT

and the result is stored to the 32-bit internal register and TM000 and TM001. CMP

ZCMP
32-bit internal register S +1 S TM001 TM000 32-bit internal register

–1234 5678 = –7006652


+

32 bits 32 bits 64 bits


(2 words)

Operation flag
CR2009 .......... ON when the result exceeds (overflows/underflows) the 32-bit range.
Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-37
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
MUL(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@MUL(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

MUL(.U/.D/.S/.L) Execution Execution

@MUL(.U/.D/.S/.L) 1 scan execution

4 Sample Program
MUL.U
Arithmetic/Comparison Instructions

When input relay 00000 is ON, the 16-bit unsigned binary data currently stored to DM00001 is
multiplied with the 16-bit unsigned binary data currently stored to data memory DM00000, and the
result is stored to DM00010. When input relay 00000 is OFF, constant 100 is multiplied with
DM00000.
The result is stored to DM0010. The result is stored to DM00010/DM00011 when it exceeds the 16-
bit range.

When the operation result is 0 to 65535

00000 DM00000 DM00001 DM00010


LDA MUL STA
00000 DM0000 #00100 DM00010
LDA MUL STA

When the operation result is 0 to 4294967295

00000 DM00000 DM00001 DM00010


LDA MUL STA.D
00000 DM00000 #00100 DM00010
LDA MUL STA.D

or

00000 DM00000 DM00001 DM00010


LDA MUL STA
TM000 DM00011
LDA STA
00000 DM00000 #00100 DM00010
LDA MUL STA
TM000 DM00011
LDA STA

4-38
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


MUL.S
When input relay 00000 is ON, the 16-bit signed binary data currently stored to DM00001 is
multiplied with the 16-bit signed binary data currently stored to data memory DM00000, and the
result is stored to DM00010. When input relay 00000 is OFF, constant –100 is multiplied with
DM00000. The result is stored to DM00010.
The result is stored to DM00010/DM00011 when it exceeds the 16-bit range.

When the operation result is –32768 to 32767

00000 DM00000 DM00001 DM00010


LDA.S MUL.S STA.S
00000 DM00000 –100 DM00010
LDA.S MUL.S STA.S

When the operation result is –2147483648 to 2147483647 4

Arithmetic/Comparison Instructions
00000 DM00000 DM00001 DM00010
LDA.S MUL.S STA.L
00000 DM00000 –100 DM00010
LDA.S MUL.S STA.L

or

00000 DM00000 DM00001 DM00010


LDA.S MUL.S STA.S
TM000 DM00011
LDA.S STA.S
00000 DM00000 –100 DM00010
ADD
LDA.S MUL.S STA.S
SUB
TM000 DM00011
LDA.S STA.S MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-39
DIV(.U)
4-2 Arithmetic/Comparison
DIV.D Instructions
DIV
DIV DIV.S
DIV.L
Divides the value of the internal register with the
ARITHMETIC OPERATION INSTRUCTIONS

Divide value specified by the operand, and stores the


@DIV(.U)
@DIV.D result again to the internal register.
@DIV @DIV.S
DIV

@DIV.L DIV.F page 4-140

Ladder program Input method


Execution condition S
LDA DIV STA D I V S

Execution condition S
LDA DIV STA @ D I V S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

4 S : Specifies the division data or the device to which the data is currently stored.
The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: DIV(.U) DIV(.S) (division of 16-bit binary data)


When the execution condition is ON, the 32-bit binary data stored to TM000 and to the 16-bit internal
register is divided by the 16-bit binary data specified by S . The result is stored to the 32-bit
internal register, and the remainder is stored to TM0001.
"About Internal Registers" page 1-17
Upper Lower
32-bit internal register

TM000
16-bit internal
register ÷ S = Upper Lower
16-bit internal
Remainder: TM001
32 bits 16 bits TM000 register 16 bits
(2 words) (1 word) (1 word)
32 bits
(2 words)

* The upper 16 bits of the quotient are stored to both the upper
16 bits of the 32-bit internal register and to TM000.
[Tip]
The DIV and @DIV instructions perform division in binary. When values stored to internal register
are BCD, convert these values to binary by the TBIN instruction.
"TBIN Instruction" page 4-92

DIV(.U) The 32-bit unsigned binary data of the internal register and TM000 is divided by the 16-
bit unsigned binary data. The result is stored to the 32-bit internal register, and the
remainder is stored to TM0001.
32-bit internal register

TM000 16-bit internal register S 123 TM001

12345 ÷ 100 = TM000 16-bit internal register Remainder: 45


32 bits 16 bits 123 16 bits
(2 words) (1 word) (1 word)
32 bits
(2 words)

DIV.S The 32-bit signed binary data of the internal register and TM000 is divided by the 16-
bit signed binary data. The result is stored to the 32-bit internal register, and the
remainder is stored to TM0001.
32-bit internal register

TM000 16-bit internal register S –123 TM001

–12345 ÷ 100 = TM000 16-bit internal register Remainder: –45


32 bits 16 bits –123 16 bits
(2 words) (1 word) (1 word)
32 bits
(2 words)

4-40
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when quotient overflows. Otherwise, OFF
* The quotient overflows only when the suffix is .S and –32768 is divided by "-1".
CR2012 .......... ON when the quotient is "0" as a result of arithmetic calculation. Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the multiplier (value of device specified by the operand) is "0" or the
indirect specification range specified to the operand is inappropriate.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Explanation of Operation: DIV.D DIV.L (divide 32-bit binary data)


When the execution condition is ON, the 64-bit binary data stored to TM000 and TM001, and to the
32-bit internal register is divided by the 32-bit binary data specified by S . The result is stored to
the 32-bit internal register and to TM000 and TM001, and the remainder is stored to TM0002 and
TM003.
"About Internal Registers" page 1-17 4
÷ =

Arithmetic/Comparison Instructions
TM001 TM000 32-bit internal register S +1 S TM001 TM000 32-bit internal register

64 bits 32bits 64 bits


(2 words)

Remainder: TM003 TM002


32bits
(2 words)

DIV.D The 64-bit unsigned binary data stored to TM000 and TM001, and to the 32-bit internal
register is divided by the 32-bit unsigned binary data. The result is stored to the 32-
bit internal register and to TM000 and TM001, and the remainder is stored to TM0002
and TM003.
TM001 TM000 32-bit internal register TM001 TM000 32-bit internal register

12345678 ÷ 100 = 123456


64 bits 32bits 64 bits ADD
(2 words) TM003 TM002
Remainder: SUB
78
32bits MUL
(2 words)
DIV

DIV.L The 64-bit signed binary data stored to TM000 and TM001, and to the 32-bit internal INC
register is divided by the 32-bit signed binary data. The result is stored to the 32-bit DEC
internal register and to TM000 and TM001, and the remainder is stored to TM0002 and ROOT
TM003. CMP

TM001 TM000 32-bit internal register TM001 TM000 32-bit internal register ZCMP
–12345678 ÷ 100 = –123456
64 bits 32bits 64 bits
(2 words) TM003 TM002
Remainder: –78
32bits
(2 words)

Operation flag
CR2009 .......... ON when quotient overflows. Otherwise, OFF
* The quotient overflows only when the suffix is .L and –2147483648 is divided
by "-1".
CR2010 .......... ON when the quotient is "0" as a result of arithmetic calculation. Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the multiplier (value of device specified by the operand) is "0" or the
indirect specification range specified to the operand is inappropriate.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-41
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
DIV(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@DIV(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DIV(.U/.D/.S/.L) Execution Execution

@DIV(.U/.D/.S/.L) 1 scan execution

4 Sample Program
When input relay 00000 is ON, #10000 is divided by the 16-bit unsigned binary data currently stored
Arithmetic/Comparison Instructions

to data memory DM00000 is divided. The result is stored to DM00010, and the remainder is stored
to DM00020.
00000 #10000 DM00000 DM00010
LDA EXT DIV STA
TM001 DM00020
LDA STA

"EXT Instruction" page 5-32

When input relay 00001 is ON, the 32-bit signed binary data currently stored to data memories
DM00100/DM00101 is divided by the 16-bit signed binary data currently stored to data memory
DM00000. The result is stored to DM00010/DM00011, and the remainder is stored to DM00020.

00001 DM00101 TM000


LDA.S STA.S
DM00100 DM00000 DM00010
LDA.S DIV.S STA.L
TM001 DM00020
LDA.S STA.S

■ Precautions when using DIV(.U) and DIV.S


The DIV(.U) and DIV.S instructions execute the calculation "32-bit data ÷ 16-bit data". When
the calculation "16-bit data ÷ 16-bit data" is performed, temporary data memory TM000 to which
the upper 16-bit data of the 32-bit data must be set to "0".
Upper Lower

16-bit internal
TM000 register ÷ S
32 bits 16 bits
(2 words) (1 word)

[Example] 16-bit binary data currently stored to data memory DM00000 is divided by 16-bit
binary data currently stored to DM00001. The quotient is stored to DM00020.
CR2002 DM00000 DM00001 DM00020
LDA EXT DIV STA

"EXT Instruction" page 5-32

4-42
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


■ Precautions when using DIV(.D) and DIV.L
The DIV(.D) and DIV.L instructions execute the calculation "64-bit data ÷ 32-bit data".
When the calculation "32-bit data ÷ 32-bit data" is performed, temporary data memories TM000/
TM001 to which the upper 32-bit data of the 64-bit data must be set to "0".

TM001 TM000 32-bit internal register ÷ S +1 S


64 bits 32 bits
(2 words)

[Example] 32-bit binary data currently stored to data memories DM00000/DM00001 is divided
by 32-bit binary data currently stored to DM00010/DM00011. The result is stored
to DM00021.

CR2002 DM00000 DM00010 DM00020


LDA.D EXT.D DIV.D STA.D

"EXT Instruction" page 5-32


4
■ When performing multiplication and division operations continuously

Arithmetic/Comparison Instructions
Though the MUL(.U) and MUL.S instructions perform multiplication by 16-bit data, the result is
calculated by 32-bit data. The DIV.U and DIV.S instructions divide 32-bit data by 16-bit data.
For this reason, when performing multiplication and division operations continuously, operations
are execution successfully even if the product exceeds the 16-bit range during calculations.

[Example] The 16-bit unsigned binary data currently stored to data memory DM00000 that
changes from 0 to 4000 is scaled to 0 to 10000, and stored to DM00001.

CR2002 DM0000 #10000 #04000 DM0001


LDA MUL DIV STA ADD

SUB

MUL
When the value of DM00000 is #00010
DIV

INC
10 x 10000 ÷ 4000 = 25
DEC
On overflow occurs as the data is handled as 16-bit data. ROOT
On the PLC, however, the data is handled as 32-bit data. CMP

ZCMP
Likewise, though the MUL(.D) and MUL.L instructions perform multiplication by 32-bit data, the
result is calculated by 64-bit data. The DIV.D and DIV.L instructions divide 64-bit data by 32-bit
data.
For this reason, when performing multiplication and division operations continuously, operations
are execution successfully even if the product exceeds the 32-bit range during calculations.

4-43
INC(.U)
4-2 Arithmetic/Comparison
INC.D Instructions
INC
INC INC.S
INC.L Increments the device specified by the
ARITHMETIC OPERATION INSTRUCTIONS

Increment memory
@INC(.U) operand by one.
@INC.D
@INC @INC.S
INC

@INC.L

Ladder program Input method


Execution condition D
INC I N C D

Execution condition D
INC @ I N C D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D — — — — — — — — — — — — — — —

4 D : Specifies the device increment.


The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: INC(.U) INC.S (increment 16-bit binary data)


INC(.U) When the execution condition is ON, "1" is added to the unsigned data of the device
specified by D , and the result is stored to the device specified by D .
When the content of the device before the operation is #65535, the result of the
operation becomes #0, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25
INC.S When the execution condition is ON, "1" is added to the signed data of the device
specified by D , and the result is stored to the device specified by D .
When the content of the device before the operation is #32767, the result of the
operation becomes #–32768, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25

[Tip]
When the INC and INC.S instructions are executed at every scan, "1" is added at each scan for
the duration that the execution condition is ON. If the INC and INC.S instructions are executed
not at each scan but at the up edge of the execution condition, use the differential type execution
instruction (@INC and @INC.S) as follows.

DM00000
INC
DM00000
INC
01000 01000 DM00000
DIFU INC

"LDP Instruction ( )" page 2-10


"DIFU Instruction" page 2-30

4-44
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the result exceeds (overflows) the 16-bit range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

Explanation of Operation: INC.D INC.L (increment 32-bit binary data)


INC.D When the execution condition is ON, "1" is added to the unsigned data of the device
specified by D / D + 1, and the result is stored to the device specified by D /
D +1.

When the content of the device before the operation is #4294967295, the result of the
operation becomes #0, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-2
INC.L When the execution condition is ON, "1" is added to the signed data of the device
specified by D / D + 1, and the result is stored to the device specified by D /
4

Arithmetic/Comparison Instructions
D +1.
When the content of the device before the operation is #2147483647, the result of the
operation becomes #–2147483648, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-2

[Tip]
When the INC.D and INC.L instructions are executed at every scan, "1" is added at each scan
for the duration that the execution condition is ON. If the INC.D and INC.L instructions are
executed not at each scan but at the up edge of the execution condition, use the differential type
execution instruction (@INC.D and @INC.L) as follows.
ADD

SUB
DM00000
INC.D MUL

DIV
DM00000
INC.D INC

01000 01000 DM00000 DEC


DIFU INC.D ROOT

CMP
"LDP Instruction ( )" page 2-10 ZCMP

"DIFU Instruction" page 2-30

Operation flag
CR2009 .......... ON when the result exceeds (overflows) the 32-bit range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

4-45
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
INC(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@INC(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

INC(.U/.D/.S/.L) Execution Execution

@INC(.U/.D/.S/.L) 1 scan execution

4 Sample Program
The total of input relays 00000 to 00003 is counted, and the result is stored to data memory
Arithmetic/Comparison Instructions

DM00000.

00000 DM00000
INC

00001 DM00000
INC

00002 DM00000
INC

00003 DM00000
INC

4-46
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-47
DEC(.U)
4-2 Arithmetic/Comparison
DEC.D Instructions
DEC
DEC DEC.S
DEC.L Decrements the device specified by
ARITHMETIC OPERATION INSTRUCTIONS

Decrement memory
@DEC(.U) the operand by one.
@DEC.D DEC
@DEC @DEC.S
@DEC.L

Ladder program Input method


Execution condition D
DEC D E C D

Execution condition D
DEC @ D E C D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D — — — — — — — — — — — — — — —

D : Specifies the device to turn decrement.


4 The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: DEC(.U) DEC.S (decrement 16-bit binary data)


DEC(.U) When the execution condition is ON, "1" is subtracted from the unsigned data of the
device specified by D , and the result is stored to the device specified by D .
When the content of the device before the operation is #0, the result of the operation
becomes #65535, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25

DEC.S When the execution condition is ON, "1" is subtracted the signed data of the device
specified by D , and the result is stored to the device specified by D .
When the content of the device before the operation is #–32768, the result of the
operation becomes #32767, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25

[Tip]
When the DEC and DEC.S instructions are executed at every scan, "1" is added at each scan
for the duration that the execution condition is ON. If the DEC and DEC.S instructions are
executed not at each scan but at the up edge of the execution condition, use the differential type
execution instruction (@DEC and @DEC.S) as follows.

DM00000
DEC
DM00000
DEC
01000 01000 DM00000
DIFU DEC

"LDP Instruction ( )" page 2-10


"DIFU Instruction" page 2-30

4-48
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the result exceeds (underflows) the 16-bit range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

Explanation of Operation: DEC.D DEC.L (decrement 32-bit binary data)


DEC.D When the execution condition is ON, "1" is subtracted from the unsigned data of the
device specified by D / D +1, and the result is stored to the device specified by
D / D +1.

When the content of the device before the operation is #0, the result of the operation
becomes #4294967295, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25
4
DEC.L When the execution condition is ON, "1" is subtracted from the signed data of the

Arithmetic/Comparison Instructions
device specified by D / D +1, and the result is stored to the device specified by
D / D +1.
When the content of the device before the operation is #–2147483648, the result of the
operation becomes #2147483647, and an overflow occurs.
"Cautions relating to arithmetic calculation instructions" page 4-25

[Tip]
When the DEC.D and DEC.L instructions are executed at every scan, "1" is added at each scan
for the duration that the execution condition is ON. If the DEC.D and DEC.L instructions are
executed not at each scan but at the up edge of the execution condition, use the differential type ADD
execution instruction (@DEC.D and @DEC.L) as follows. SUB

MUL
DM00000 DIV
DEC.D
INC
DM00000
DEC
DEC.D
ROOT
01000 01000 DM00000
DIFU DEC.D CMP

ZCMP

"LDP Instruction ( )" page 2-10


"DIFU Instruction" page 2-30

Operation flag
CR2009 .......... ON when the result exceeds (underflows) the 32-bit range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

4-49
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
DEC(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@DEC(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DEC(.U/.D/.S/.L) Execution Execution

@DEC(.U/.D/.S/.L) 1 scan execution

4 Sample Program
The value of data memory DM00000 is decremented by "1" at each respective up edge of input
Arithmetic/Comparison Instructions

relays 00000, 00001 and 00002.

00000 DM00000
DEC

00001 DM00000
DEC

00002 DM00000
DEC

4-50
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-51
ROOT(.U)
4-2 Arithmetic/Comparison
ROOT.D Instructions
ROOT
ROOT ROOT.S
ROOT.L
Calculates the square root of the
ARITHMETIC OPERATION INSTRUCTIONS

Square root content of an internal registers, and


@ROOT(.U)
@ROOT.D stores the result to the internal register
@ROOT @ROOT.S
ROOT

@ROOT.L

Ladder program Input method


Execution condition
LDA ROOT STA R O O T

Execution condition
LDA ROOT STA @ R O O T

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — *
* CR2012 changes state
The data range that can be handled varies according to the suffix type.
4 "About Suffixes" page 1-28
only with the ROOT.S
and ROOT.L instruc-
tions.
Arithmetic/Comparison Instructions

Explanation of Operation: ROOT(.U) ROOT.S (square root of 32-bit data)


ROOT(.U) When the execution condition is ON, the square root of the 32-bit unsigned binary data
currently stored to temporary data memory TM000 and the 16-bit internal register is
calculated, and is stored again to the 16-bit internal register.
Decimal points in the calculation result are discarded.
"About Internal Registers" page 1-17
ROOT.S When the execution condition is ON, the square root of the 32-bit signed binary data
currently stored to temporary data memory TM000 and the 16-bit internal register is
calculated, and is stored again to the 16-bit internal register.
Decimal points in the calculation result are discarded.
"About Internal Registers" page 1-17

Upper Lower

T000 Internal register = 16-bit internal register


32 bits 16 bits

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... Only when the value to be calculated is a minus value only when the ROOT.S
instruction is executed. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

4-52
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation: ROOT.D ROOT.L (square root of 32-bit data)
ROOT.D When the execution condition is ON, the square root of the 64-bit unsigned binary data
currently stored to temporary data memories TM000 and TM001, and the 32-bit
internal register is calculated, and is stored again to the 32-bit internal register.
Decimal points in the calculation result are discarded.
"About Internal Registers" page 1-17

ROOT.L When the execution condition is ON, the square root of the 64-bit signed binary data
currently stored to temporary data memories TM000 and TM001, and the 32-bit
internal register is calculated, and is stored again to the 32-bit internal register.
Decimal points in the calculation result are discarded.
"About Internal Registers" page 1-17

Upper 32 bits Lower 32 bits Upper Lower

TM001 TM000 32-bit internal register = 32-bit internal register


4
64 bits 32 bits

Arithmetic/Comparison Instructions
Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... Only when the value to be calculated is a minus value only when the ROOT.L
instruction is executed. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

Execution Timing ADD

SUB
ROOT(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
MUL
condition is ON.
DIV
@ROOT(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution INC
condition. DEC

ROOT

CMP
Scan ZCMP

ON

Execution condition
OFF

ROOT(.U/.D/.S/.L) Execution Execution

@ROOT(.U/.D/.S/.L) 1 scan execution

Sample Program
When input relay 00000 is ON, the square root of 16-bit unsigned binary data currently stored to data
memory DM00000 is calculated, and the average value is stored to DM00010.

00000 DM00000 DM00010


LDA EXT ROOT STA

"EXT Instruction" page 5-32

4-53
CMP(.U)
4-2 Arithmetic/Comparison
CMP.D Instructions
CMP
CMP CMP.S
CMP.L Compares the value currently stored to the
ARITHMETIC OPERATION INSTRUCTIONS

Compare
@CMP(.U) internal register with the specified binary data,
@CMP.D
@CMP @CMP.S
CMP

@CMP.L

Input method Input method


Execution condition S Operation flag
LDA CMP C M P S

Execution condition S Operation flag


LDA CMP @ C M P S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — —

4 S : Specifies the device to compare with the internal data.


The data range that can be handled varies according to the suffix type.
Arithmetic/Comparison Instructions

"About Suffixes" page 1-28

Explanation of Operation: CMP(.U) CMP.S


CMP(.U) The sizes of the 16-bit unsigned binary data currently stored to the 16-bit internal
register and the 16-bit unsigned binary data currently stored to the device specified by
S are compared. The operation flag changes as follows according to the compari-
son results.

CMP.S The sizes of the 16-bit signed binary data currently stored to the 16-bit internal register
and the 16-bit signed binary data currently stored to the device specified by S are
compared. The operation flag changes as follows according to the comparison results.

Compare Result State of Operation Flag


Value of 16-bit internal register is smaller than S CR2009→ON
16-bit internal register < S
Value of 16-bit internal register is equal to S CR2010→ON
16-bit internal register = S
Value of 16-bit internal register is greater than S CR2011→ON
16-bit internal register > S

Operation flag
CR2009 .......... ON when the value to be compared (value of 16-bit internal register) is smaller than
the value currently stored to the specification operand ( S ). Otherwise, OFF
CR2010 .......... ON when the value to be compared (value of 16-bit internal register) is equal to the
value currently stored to the specification operand ( S ). Otherwise, OFF
CR2011 .......... ON when the value to be compared (value of 16-bit internal register) is greater than
the value currently stored to the specification operand ( S ). Otherwise, OFF
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
"About Indirect Specification" page 1-42

4-54
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation: CMP.D CMP.L
CMP.D The sizes of the 32-bit unsigned binary data currently stored to the 32-bit internal
register and the 32-bit unsigned binary data currently stored to the device specified
by S / S +1 are compared. The operation flag changes as follows according to
the comparison results.

CMP.L The sizes of the 32-bit signed binary data currently stored to the 32-bit internal
register and the 32-bit signed binary data currently stored to the device specified by
S / S +1 are compared. The state of the operation flag changes as follows
according to the comparison results.

Compare Result State of Operation Flag


Value of 32-bit internal register is smaller than S / S +1 CR2009→ON
32-bit internal register < S / S +1
Value of 32-bit internal register is equal to S / S +1 CR2010→ON
32-bit internal register = S / S +1
Value of 32-bit internal register is greater than S /
32-bit internal register > S / S +1
S +1 CR2011→ON 4

Arithmetic/Comparison Instructions
Operation flag
CR2009 ............ ON when the value to be compared (value of 32-bit internal register) is smaller than the
value currently stored to the specification operand ( S / S +1). Otherwise, OFF
CR2010 ............ ON when the value to be compared (value of 32-bit internal register) is equal to the
value currently stored to the specification operand ( S / S +1). Otherwise, OFF
CR2011 ............ ON when the value to be compared (value of 32-bit internal register) is greater than the
value currently stored to the specification operand ( S / S +1). Otherwise, OFF
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ADD
ate. Otherwise, OFF
SUB
The instruction is not executed when CR2012 has turned ON.
MUL
"About Indirect Specification" page 1-42
DIV

INC

Execution Timing DEC

ROOT
CMP(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution CMP
condition is ON.
ZCMP

@CMP(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

CMP(.U/.D/.S/.L) Execution Execution

@CMP(.U/.D/.S/.L) 1 scan execution

4-55
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Sample Program
#01000 is compared with the value currently stored to data memory DM00000.
Output relay 00500 turns ON when the value is smaller than #01000.
Output relay 00501 turns ON when the value equals #01000.
Output relay 00502 turns ON when the value is greater than #01000.

CR2002 DM00000 #01000 CR2009 00500


LDA CMP DM00000<1000

CR2010 00501
DM00000=1000

CR2011 00502
DM00000>1000

4 [Tip]
a b
Arithmetic/Comparison Instructions

Assuming LDA CMP that the internal register is a and the operand is b,
then,
CR2009
a<b
CR2011
a≤b
CR2010
a=b
CR2009
a≥b
CR2011
a>b

4-56
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-57
ZCMP(.U)
4-2 Arithmetic/Comparison
ZCMP.D Instructions
ZCMP
ZCMP ZCMP.S Compares the value currently stored to
ZCMP.L
ARITHMETIC OPERATION INSTRUCTIONS

Zone compare the internal register with a specified


@ZCMP(.U)
@ZCMP.D range.
@ZCMP @ZCMP.S
ZCMP

@ZCMP.L

Ladder program Input method


Execution condition S1 Operation flag
LDA ZCMP Z C M P S1 S2
S2

Execution condition S1 Operation flag


LDA ZCMP @ Z C M P S1 S2
S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — —
S2 — — — — — — — — — — —

4 S1 , S2 : Specifies the range to compare with the internal data.

* The maximum value and minimum value are automatically judged whichever of
Arithmetic/Comparison Instructions

S1 or S2 they are specified to.

The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation: ZCMP(.U) ZCMP.S


ZCMP(.U) When the execution condition is ON, the sizes of the range specified by S1 and
S2 , and the 16-bit unsigned binary data currently stored to the internal register are
compared. The state of the operation flag changes as follows according to the
comparison results.

ZCMP.S When the execution condition is ON, the sizes of the range specified by S1 and
S2 , and the 16-bit signed binary data currently stored to the internal register are
compared. The state of the operation flag changes as follows according to the
comparison results.

Compare Result (when S1 < S2 ) State of Operation Flag


Value of internal register is smaller than specified range CR2009→ON
16-bit internal register < S1 < S2
Value of internal register is within specified range CR2010→ON
S1 ≤ 16-bit internal register ≤ S2

Value of internal register is greater than specified range CR2011→ON


S1 < S2 < 16-bit internal register

* When S2 is smaller than S2 , swap each of the settings for S1 and S2 in


the above table.

4-58
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when the value to be compared (value of internal register) is smaller than the
specified range (range specified by operand). Otherwise, OFF
CR2010 .......... ON when the value to be compared (value of internal register) is within the specified
range (range specified by operand). Otherwise, OFF
CR2009 .......... ON when the value to be compared (value of internal register) is greater than the
specified range (range specified by operand). Otherwise, OFF
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Explanation of Operation: ZCMP.D ZCMP.L


ZCMP.D When the execution condition is ON, the size of the range specified by S1 / S1 +1
and S2 / S2 +1 and the 32-bit unsigned binary data currently stored to 32-bit
internal register are compared. 4

Arithmetic/Comparison Instructions
The state of the operation flag changes as follows according to the comparison results.

ZCMP.L When the execution condition is ON, the size of the range specified by S1 / S1 +1
and S2 / S2 +1 and the 32-bit signed binary data currently stored to 32-bit internal
register are compared.
The state of the operation flag changes as follows according to the comparison results.

Compare Result (when S1 / S1 +1 < S2 / S2 +1) State of Operation Flag


Value of internal register is smaller than specified range CR2009→ON
32-bit internal register < S1 / S1 +1 < S2 / S2 +1
Value of internal register is within specified range CR2010→ON ADD
S1 / S1 +1 ≤ 32-bit internal register ≤ S2 / S2 +1 SUB
Value of internal register is greater than specified range CR2011→ON MUL
S1 / S1 +1 < S2 / S2 +1 < 32-bit internal register
DIV

* When S2 / S2 +1 < S1 / S1 +1, swap each of the settings for S1 / S1 +1 INC

and S2 / S2 +1 in the above table. DEC

ROOT

CMP
Operation flag ZCMP

CR2009 .......... ON when the value to be compared (value of internal register) is smaller than the
specified range (range specified by operand). Otherwise, OFF
CR2010 .......... ON when the value to be compared (value of internal register) is within the specified
range (range specified by operand). Otherwise, OFF
CR2011 .......... ON when the value to be compared (value of internal register) is greater than the
specified range (range specified by operand). Otherwise, OFF
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-59
4-2 Arithmetic/Comparison Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
ZCMP(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@ZCMP(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ZCMP(.U/.D/.S/.L) Execution Execution

@ZCMP(.U/.D/.S/.L) 1 scan execution

4
Sample Program
Arithmetic/Comparison Instructions

When the value currently stored to data memory DM00000 is greater than #02000, output relays
00500 turns ON.
When the value currently stored to DM00000 is #01000 to #02000, output relay 00501 turns ON.
When the value currently stored to DM00000 is less than #01000, output relay 00502 turns ON.

CR2002 DM00000 #01000 CR2011 00500


LDA ZCMP 1000<2000<DM00000
#02000
CR2010 00501
1000≤DM00000≤2000

CR2009 00502
DM00000<1000<2000

4-60
4-2 Arithmetic/Comparison Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Arithmetic/Comparison Instructions
ADD

SUB

MUL

DIV

INC

DEC

ROOT

CMP

ZCMP

4-61
4-3 Logical Arithmetic Operation Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-3 Logical Arithmetic Operation Instructions


These instructions performed logical arithmetic operations on 16-bit and 32-bit binary data.

Logical Arithmetic Operation Instruction List


There are five logical arithmetic operation instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


AND A ANDA(.U) Calculates the logical AND of 16-bit binary data. 4-64
ANDA.D Calculates the logical AND of 32-bit binary data.
OR A ORA(.U) Calculates the logical OR of 16-bit binary data. 4-66
ORA.D Calculates the logical OR of 32-bit binary data.
Exclusive OR A EORA(.U) Calculates the exclusive AND of 16-bit binary data. 4-68
EORA.D Calculates the exclusive AND of 32-bit binary data.
Complement COM(.U) Inverts the bits of 16-bit binary data. 4-70
4 COM.D Inverts the bits of 32-bit binary data.
Negative NEG(.U) Inverts the sign of 16-bit binary data (2's complement). 4-72
Logical Arithmetic Operation Instructions

NEG.D Inverts the sign of 32-bit binary data (2's complement).

4-62
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Logical Arithmetic Operation Instructions

4-63
ANDA(.U)
4-3 Logical Arithmetic Operation Instructions
ANDA ANDA.D
ANDA
Calculates the logical AND of values in
AND A internal registers and values specified by
ARITHMETIC OPERATION INSTRUCTIONS

@ANDA(.U)
@ANDA @ANDA.D
ANDA operands.

Ladder program Input method


Execution condition S
LDA ANDA STA A N D A S

Execution condition S
LDA ANDA STA @ A N D A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — —

S : Specifies the data to be logically ANDed or the device to which the data is currently stored.
"About Suffixes" page 1-28
4
Logical Arithmetic Operation Instructions

Explanation of Operation: ANDA(.U) ANDA.D (logical AND of 16/32-bit binary data)


When the execution condition is ON, the logical AND of the binary data Logical AND truth table

specified by S and the content of the internal register is calculated, and Internal register 0 0 1 1
the result is stored to the internal register. S 0 1 0 1
Internal register (Result) 0 0 0 1
The result of this operation is "1" only when both the internal register and
bits in the binary data specified by S are "1".
"About Internal Registers" page 1-17

ANDA(.U) The logical AND of the 16-bit binary data specified by S and the content of the 16-
bit internal register is calculated, and the result is stored to the 16-bit internal register.

[Example] DM00000 $00FF DM00000


LDA ANDA STA

bit bit
15 0
DM00000
16-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit AND bit
15 0
$00FF
S 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ANDA
bit bit
15 0
DM00000
16-bit internal register 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 STA

ANDA.D The logical AND of the 32-bit binary data specified by S / S +1 and the content
of the 32-bit internal register is calculated, and the result is stored to the 32-bit internal
register.

[Example] DM00000 $00FF00FF DM00000


LDA.D ANDA.D STA.D

bit bit bit bit


31 16 15 0
DM00000
32-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA.D
bit AND bit
31 0
$00FF00FF
S / S +1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ANDA.D
bit Upper 16 bits Lower 16 bits bit
31 0
DM00000
32-bit internal register 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 STA.D

4-64
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
ANDA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@ANDA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Logical Arithmetic Operation Instructions


ON

Execution condition
OFF

ANDA(.U/.D) Execution Execution

@ANDA(.U/.D) 1 scan execution

Sample Program
The values of the 2-digit BCD digital switch (input relays 00000 to 00007) are stored to data memory
DM00000. ANDA

ORA
CR2002 00000 $00FF DM00000 EORA
LDA ANDA STA
COM

NEG

4-65
ORA(.U)
4-3 Logical Arithmetic Operation Instructions
ORA ORA.D ORA
Calculates the logical OR of values in internal
OR A
registers and values specified by operands.
ARITHMETIC OPERATION INSTRUCTIONS

@ORA(.U)
@ORA @ORA.D ORA

Ladder program Input method


Execution condition S
LDA ORA STA O R A S

Execution condition S
LDA ORA STA @ O R A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — —

S : Specifies the data to be logically ORed or the device to which the data is currently stored.
"About Suffixes" page 1-28
4
Logical Arithmetic Operation Instructions

Explanation of Operation: ORA(.U) ORA.D (logical OR of 16/32-bit binary data)


Logical OR truth table
When the execution condition is ON, the logical OR of the binary data
specified by S and the content of the internal register is calculated, and Internal register 0 0 1 1
the result is stored to the internal register. S 0 1 0 1
Internal register (Result) 0 1 1 1
The result of this operation is "1" only when either the internal register and
bits in the binary data specified by S are "1".
"About Internal Registers" page 1-17

ORA(.U) The logical OR of the 16-bit binary data specified by S and the content of the 16-
bit internal register is calculated, and the result is stored to the 16-bit internal register.

[Example] DM00000 $00FF DM00000


LDA ORA STA

bit bit
15 0
DM00000
16-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit OR bit
15 0
$00FF
S 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ORA
bit bit
15 0
DM00000
16-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 STA

ORA.D The logical OR of the 32-bit binary data specified by S / S +1 and the content
of the 32-bit internal register is calculated, and the result is stored to the 32-bit internal
register.

[Example] DM00000 $00FF00FF DM00000


LDA.D ORA.D STA.D

bit bit bit bit


31 16 15 0
DM00000
32-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA.D
bit OR bit
31 0
$00FF00FF
S / S +1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ORA.D
bit Upper 16 bits Lower 16 bits bit
31 0
DM00000
32-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 STA.D

4-66
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
ORA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@ORA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Logical Arithmetic Operation Instructions


ON

Execution condition
OFF

ORA(.U/.D) Execution Execution

@ORA(.U/.D) 1 scan execution

Sample Program
The current value of counter C000 is output at a 2-digit BCD to output relays 00500 to 00507.
ANDA
Note, however, that changing of the states of output relays 00508 to 00515 must be prevented.
ORA

00000 #00099 EORA

C000 Counter C000 is set. COM


00001
NEG
CR2002 00500 $FF00 DM00000
LDA ANDA STA Output relays 00508 to 00515 are set to
DM00000.

CR2002 C000 $00FF DM00000 00500 The current value of C000 is converted to
LDA TBCD ANDA ORA STA BCD, and the lower two digits of BCD are left
behind in the 16-bit internal register.
The 16-bit internal register and DM00000 is
ORed and the result is output to output
relays 00500 to 00515.

"TBCD Instruction" page 4-90

4-67
EORA(.U)
4-3 Logical Arithmetic Operation Instructions
EORA EORA.D
EORA
Calculates the logical exclusive OR of
Exclusive OR values in internal registers and values
ARITHMETIC OPERATION INSTRUCTIONS

@EORA(.U)
@EORA @EORA.D
EORA specified by operands.

Ladder program Input method


Execution condition S
LDA EORA STA E O R A S
( X O R A S , X O R S )
Execution condition S
LDA EORA STA @ E O R A S
( @ X O R A S ,@ X O R S )

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — —

S : Specifies the data to be exclusively ORed or the device to which the data is currently stored.
"About Suffixes" page 1-28
4
Logical Arithmetic Operation Instructions

Explanation of Operation: EORA(.U) EORA.D (exclusive OR of 16/32-bit binary data)


When the execution condition is ON, the exclusive OR of the binary data Logical XOR truth table

specified by S and the content of the internal register is calculated, and Internal register 0 0 1 1
the result is stored to the internal register. S 0 1 0 1
Internal register (Result) 0 1 1 0
The result of this operation is "1" only when the internal register and bits
in the binary data specified by S are different.
"About Internal Registers" page 1-17

EORA(.U) The exclusive OR of the 16-bit binary data specified by S and the content of the
16-bit internal register is calculated, and the result is stored to the 16-bit internal
register.

[Example] DM00000 $00FF DM00000


LDA EORA STA

bit bit
15 0
DM00000
16-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit EOR bit
15 0
$00FF
S 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 EORA
bit bit
15 0
DM00000
16-bit internal register 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 STA

EORA.D The exclusive OR of the 32-bit binary data specified by S / S +1 and the content
of the 32-bit internal register is calculated, and the result is stored to the 32-bit internal
register.

[Example] DM00000 $00FF00FF DM00000


LDA.D EORA.D STA.D

bit bit bit bit


31 16 15 0
DM00000
32-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA.D
bit OR bit
31 0
$00FF00FF
S / S +1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 EORA.D
bit Upper 16 bits Lower 16 bits bit
31 0
DM00000
32-bit internal register 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 STA.D

4-68
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
EORA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@EORA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Logical Arithmetic Operation Instructions


ON

Execution condition
OFF

EORA(.U/.D) Execution Execution

@EORA(.U/.D) 1 scan execution

Sample Program
When the setting value currently stored to data memory DM00000 matches the ON/OFF state of
input relays 30000 to 30007, output relay 00500 is turned ON. ANDA

ORA
CR2008 $00AA DM00000 EORA
LDA STA
COM

CR2002 30000 $00FF DM00000 CR2010 00500 NEG


LDA ANDA EORA

bit bit
15 0

$BBBB 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 Input relay 30000 to 30015


bit ANDA bit
15 0

$00FF 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Operand
bit bit
15 0

$00BB 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 16-bit internal register


bit EORA bit
15 0

$00AA 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 Data memory DM00000


bit bit
15 0

$0011 0 0 0 0 0 0 0 0 1 1 1 0 1 1 1 0 16-bit internal register CR2010 is OFF.

CR2010 turns ON when


the value is 00000.

Match when CR2010 is ON


Match judgment of value of DM00000 and input relays 30000 to 30007
Mismatch when CR2010 is OFF

4-69
COM(.U)
4-3 Logical Arithmetic Operation Instructions
COM COM.D COM

Complement Inverts each of the bits in internal registers.


ARITHMETIC OPERATION INSTRUCTIONS

@COM(.U)
@COM @COM.D COM

Ladder program Input method


Execution condition
LDA COM STA C O M

Execution condition
LDA COM STA @ C O M

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4
Explanation of Operation
Logical Arithmetic Operation Instructions

COM When the execution condition is ON, each of the bits in 16-bit internal registers is
inverted (0→1, 1→0).
"About Internal Registers" page 1-17
[Example] bit
15
bit
0

16-bit internal register 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0


bit bit
15 0

16-bit internal register 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1

COM.D When the execution condition is ON, each of the bits in internal registers is inverted
(0→1, 1→0).
"About Internal Registers" page 1-17
[Example] bit
31
bit bit
16 15
bit
0

32-bit internal register 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0


bit bit
31 0

32-bit internal register 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

[Tip]
When the COM instruction is executed at every scan, the bits are inverted at each scan for the
duration that the execution condition is ON. If the COM instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@COM) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA COM STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA COM STA

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

4-70
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
COM(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@COM(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

COM(.U/.D) Execution Execution

@COM(.U/.D) 1 scan execution

Sample Program 4
The states of input relays 00000 to 00003 are inverted and output to output relays 00500 to 00503.

Logical Arithmetic Operation Instructions


00000 $000F 00500
LDA ANDA COM STA

"ANDA Instruction" page 4-64

ANDA

ORA

EORA

COM

NEG

4-71
NEG(.U)
4-3 Logical Arithmetic Operation Instructions
NEG NEG.D
NEG

Negative Inverts the sign (2's complement).


ARITHMETIC OPERATION INSTRUCTIONS

@NEG(.U)
@NEG @NEG.D
NEG

Ladder program Input method


Execution condition
LDA NEG STA N E G

Execution condition
LDA NEG STA @ N E G

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28
4
Logical Arithmetic Operation Instructions

Explanation of Operation
When the execution condition is ON, the plus/minus sign of the data currently stored to internal
registers is inverted (2's complement is calculated), and the result is stored to internal registers.
"About Internal Registers" page 1-17

NEG(.U) When the execution condition is ON, the plus/minus sign of the 16-bit data currently
stored to 16-bit internal registers is inverted (2's complement is calculated).

[Example]
bit bit
15 0

16-bit internal register 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 1 Before exec


#12345
bit bit
15 0

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 1

bit bit
15 0

16-bit internal register 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 After execu


#–12345

NEG.U When the execution condition is ON, the plus/minus sign of the 32-bit data currently
stored to 32-bit internal registers is inverted (2's complement is calculated).
[Example]
bit bit bit bit
31 16 15 0

32-bit internal register 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0 Before execution


#12345678
bit bit bit bit
31 16 15 0

10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0

bit bit
31 0

32-bit internal register 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0 0 1 0 After execution


#–12345678

4-72
4-3 Logical Arithmetic Operation Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
When the NEG instruction is executed at every scan, the bits are inverted at each scan for the
duration that the execution condition is ON. If the NEG instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@NEG) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA NEG STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA NEG STA

Operation flag
The operation flag does not change state.

4
Execution Timing

Logical Arithmetic Operation Instructions


NEG(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@NEG(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

NEG(.U/.D) Execution Execution


ANDA

ORA
@NEG(.U/.D) 1 scan execution
EORA

COM

Sample Program NEG

When input relay 00000 is ON, the difference between the 16-bit signed binary data currently stored
to data memories DM00000 and DM00001 is calculated, and the absolute value is stored to
DM00002.

00000 DM00000 DM00001 DM00002


LDA.S SUB.S STA.S

DM00000 DM00002 DM00002


< .S LDA.S NEG STA.S
DM00001

4-73
4-4 Data Shift Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-4 Data Shift Instructions


These instructions are for shifting data in bit units or word units.

Data Shift Instruction List


There are six data shift instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Shift right A SRA(.U) Shifts the content of 16-bit internal registers to the right 4-76
by n bits.
SRA.D Shifts the content of 32-bit internal registers to the right
by n bits.
Shift left A SLA(.U) Shifts the content of 16-bit internal registers to the left by 4-78
n bits.
SLA.D Shifts the content of 32-bit internal registers to the left by
n bits.
4 Rotate right A RRA(.U) Rotates the content of 16-bit internal registers to the 4-80
right by n bits.
Data Shift Instructions

RRA.D Rotates the content of 32-bit internal registers to the


right by n bits.
Rotate left A RLA(.U) Rotates the content of 16-bit internal registers to the left 4-82
by n bits.
RLA.D Rotates the content of 32-bit internal registers to the left
by n bits.
Word shift right WSR(.U) Shifts 16-bit data to the right. 4-84

WSR.D Shifts 32-bit data to the right.

Word shift left WSL(.U) Shifts 16-bit data to the left. 4-86

WSL.D Shifts 32-bit data to the left.

4-74
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Data Shift Instructions

4-75
SRA(.U)
4-4 Data Shift Instructions
SRA SRA.D
SRA
This instruction shifts the bit content of internal
Shift right A registers to the right by the specified number
ARITHMETIC OPERATION INSTRUCTIONS

@SRA(.U)
@SRA @SRA.D
SRA of bits.

Ladder program Input method


Execution condition n
LDA SRA STA S R A S

Execution condition n
LDA SRA STA @ S R A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — —

n : Specifies the number of bits to shift to the right. With the SRA.U instruction, the number of
bits can be specified within the range 1 to 16, and with the SRA.D instruction, the number
of bits can be specified within the range 1 to 32.
4 "About Suffixes" page 1-28
Data Shift Instructions

Explanation of Operation: SRA(.U) SRA.D


SRA(.U) When the execution condition is ON, the state of the 16-bit internal register is shifted
to the right by specified n bits.
"0" is stored to the upper n bits, the state of bit( n -1) is stored to CR2009, and
the result is stored to the 16-bit internal register.
"About Internal Registers" page 1-17

bit ( n –1)
bit bit
15 0
16-bit internal
register 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1

16-bit internal 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1
register
Upper n bit Delete

Store "0". 1
CR2009
(Carry)

SRA.D When the execution condition is ON, the state of the 32-bit internal register is shifted
to the right by specified n bits.
"0" is stored to the upper n bits, the state of bit( n –1) is stored to CR2009, and
the result is stored to the 32-bit internal register.
"About Internal Registers" page 1-17
bit ( n –1)
bit bit
31 0
32-bit internal
register 1 1 1 0 10 0 0 0 0 0 1 1 0 0 1 1 11 0 10 0 0 0 0 0 1 1 0 0 1

32-bit internal
register 0 0 0 0 01 1 1 0 1 0 0 0 0 0 0 1 10 0 11 1 1 0 1 0 0 0 0 0 0 1 10 0 1

Upper n bit Delete

Store "0". 1
CR2009
(Carry)

4-76
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
When the SRA instruction is executed at every scan, the bits are shifted at each scan for the
duration that the execution condition is ON. If the SRA instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@SRA) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA SRA STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA SRA STA

Operation flag
CR2009 .......... ON when a carry is stored after the operation. Otherwise, OFF
CR2010 .......... ON when the operation result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state 4

Data Shift Instructions


Execution Timing
SRA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@SRA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

SRA(.U/.D) SRA
Execution Execution
SLA

@SRA(.U/.D) 1 scan execution RRA

RLA

WSR
Sample Program WSL

The BCD data (two digit's worth) from the digital switch entered to input relays 30008 to 30015 is
stored to data memory DM00000.
30000 #08 DM00000
LDA SRA STA

Digital switch

2 4
30015 30000
0 0 1 0 0 1 0 0 30000 to 30015

LDA

0 0 1 0 0 1 0 0 Internal register

SRA

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 Internal register

STA

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 DM00000

4-77
SLA(.U)
4-4 Data Shift Instructions
SLA SLA.D
SLA
This instruction shifts the bit content of internal
Shift left A registers to the left by the specified number of
ARITHMETIC OPERATION INSTRUCTIONS

@SLA(.U)
@SLA @SLA.D
SLA bits.

Ladder program Input method


Execution condition n
LDA SLA STA S L A S

Execution condition n
LDA SLA STA @ S L A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — —

n : Specifies the number of bits to shift to the left. With the SLA.U instruction, the number of bits
can be specified within the range 1 to 16, and with the SLA.D instruction, the number of bits
can be specified within the range 1 to 32.
4
"About Suffixes" page 1-28
Data Shift Instructions

Explanation of Operation: SLA(.U) SLA.D


SLA(.U) When the execution condition is ON, the state of the 16-bit internal register is shifted
to the left by specified n bits.
"0" is stored to the lower n bits, the state of bit(16- n ) is stored to CR2009, and
the result is stored to the 16-bit internal register.
"About Internal Registers" page 1-17

bit (16 – n )
bit bit
15 0
16-bit internal
1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 register

16-bit internal
1 11 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 register
Delete Lower n bit

1
Store "0".
CR2009
(Carry)

SLA.D When the execution condition is ON, the state of the 32-bit internal register is shifted
to the left by specified n bits.
"0" is stored to the lower n bits, the state of bit(32- n ) is stored to CR2009, and
the result is stored to the 32-bit internal register.
"About Internal Registers" page 1-17

bit (32 – n )
bit bit
31 0
32-bit internal
1 1 1 0 10 0 0 0 0 0 1 1 0 0 1 1 11 0 10 0 0 0 0 0 1 1 0 0 1 register

32-bit internal
1 11 0 10 0 0 0 00 1 1 0 0 1 1 1 1 0 1 0 00 0 00 1 1 0 0 1 0 0 0 0 0 register
Delete Lower n bit

1 Store "0".
CR2009
(Carry)

4-78
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
When the SLA instruction is executed at every scan, the bits are shifted at each scan for the
duration that the execution condition is ON. If the SLA instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@SLA) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA SLA STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA SLA STA

Operation flag
CR2009 .......... ON when a carry is stored after the operation. Otherwise, OFF
CR2010 .......... ON when the operation result is 0 (zero). Otherwise, OFF
4
CR2011 .......... No change in state

Data Shift Instructions


CR2012 .......... No change in state

Execution Timing
SLA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@SLA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
SRA
ON
SLA
Execution condition
OFF RRA

RLA
SLA(.U/.D) Execution Execution
WSR

WSL
@SLA(.U/.D) 1 scan execution

Sample Program
The 2-digit BCD data currently stored to each of data memories DM00000 and DM00001 are stored
to DM00000 as 4-digit BCD data with the DM00001 as the upper two digits.

CR2002 DM00001 #00008 DM00000 DM00010


LDA SLA ORA STA

DM00000
34 DM00010
DM00001 1234
12

4-79
RRA(.U)
4-4 Data Shift Instructions
RRA RRA.D
RRA
This instruction rotates the bit content of
Rotate right A internal registers to the right by the speci-
ARITHMETIC OPERATION INSTRUCTIONS

@RRA(.U)
@RRA @RRA.D
RRA fied number of times.

Ladder program Input method


Execution condition n
LDA RRA STA R R A n

Execution condition n
LDA RRA STA @ R R A n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — —

n : RRA(.U) specifies the number of times that the bit content is to be rotated to the right within
the range 1 to 16.

4 RRA.D specifies the number of times that the bit content is to be rotated to the right within
the range 1 to 32.
Data Shift Instructions

"About Suffixes" page 1-28

Explanation of Operation: RRA(.U) RRA.D


RRA(.U) When the execution condition is ON, the bit content of 16-bit internal registers is rotated
to the right for the number of times specified by n . The state of the carry flag
(CR2009) is entered to the MSB.
(The following operation is repeated n number of times.)

bit bit
CR2009 15 0

0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 16-bit internal register


The flag state varies
according to the previous (Rotate once)
operation result.

CR2009

1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1
(Carry)
Rotate n times (The above processing is repeated n times.)
bit bit
CR2009 15 0

0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 16-bit internal register


(Carry)

RRA.D When the execution condition is ON, the bit content of 32-bit internal registers is rotated
to the right for the number of times specified by n . The state of the carry flag
(CR2009) is entered to the MSB.
(The following operation is repeated n number of times.)
bit bit bit bit
CR2009 31 16 15 0

0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 32-bit internal register


The flag state varies
according to the previous (Rotate once)
operation result.

CR2009

1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
(Carry)

Rotate n times (The above processing is repeated n times.)


bit bit
CR2009 31 0

0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 32-bit internal register


(Carry)

4-80
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
When the PRA instruction is executed at every scan, the bits are rotated at each scan for the
duration that the execution condition is ON. If the PRA instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@PRA) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA RRA STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA RRA STA

Operation flag
CR2009 .......... ON when a carry is stored after the operation. Otherwise, OFF
CR2010 .......... ON when the operation result is 0 (zero). Otherwise, OFF
4
CR2011 .......... No change in state

Data Shift Instructions


CR2012 .......... No change in state

Execution Timing
RRA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@RRA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
SRA
ON
SLA
Execution condition
OFF RRA

RLA
RRA(.U/.D) Execution Execution
WSR

WSL
@RRA(.U/.D) 1 scan execution

Sample Program
Of the error sensors connected to input relays 30000 to 30015, the number of sensors that are
currently outputting an error is stored to data memory DM00000.

CR2002 #00000 30000


DW LDA Input relays 30000 to 30015 are stored to
DM00000 16-bit internal register.

FOR The FOR to NEXT instructions are executed


#00016 16 times.
The content of the 16-bit internal registers is
CR2002 #01 CR2009 DM00000
shifted to the right (including carrier flag
RRA INC
CR2009), and the content of data memory
DM00000 is incremented by one when
NEXT CR2009 is ON.

4-81
RLA(.U)
4-4 Data Shift Instructions
RLA RLA.D
RLA
This instruction rotates the bit content of
Rotate left A internal registers to the left by the specified
ARITHMETIC OPERATION INSTRUCTIONS

@RLA(.U)
@RLA @RLA.D
RLA number of times.

Ladder program Input method


Execution condition S
LDA RLA STA R L A S

Execution condition S
LDA RLA STA @ R L A S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

n — — — — — — — — — — — — — — — — —

n : RLA(.U) specifies the number of times that the bit content is to be rotated to the left within
the range 1 to 16.
4 RLA.D specifies the number of times that the bit content is to be rotated to the left within the
range 1 to 32.
Data Shift Instructions

"About Suffixes" page 1-28

Explanation of Operation: RLA(.U) RLA.D


RLA(.U) When the execution condition is ON, the bit content of 16-bit internal registers is rotated
to the left for the number of times specified by n . The state of the carry flag
(CR2009) is entered to the LSB.
bit bit
15 0 CR2009

1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 16-bit internal register


The flag state
varies according
(Rotate once) to the previous
operation result.

CR2009

1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1
(Carry)

Rotate n times (The above processing is repeated n times.)


bit bit
15 0 CR2009

0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 0 16-bit internal register


(Carry)

RLA.D When the execution condition is ON, the bit content of 32-bit internal registers is rotated
to the left for the number of times specified by n . The state of the carry flag
(CR2009) is entered to the LSB.
bit bit bit bit
31 16 15 0 CR2009

1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 32-bit internal register


The flag state
varies according
(Rotate once) to the previous
operation result.

CR2009

1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1
(Carry)

Rotate n times (The above processing is repeated n times.)


bit bit
31 0 CR2009

0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 0 32-bit internal register


(Carry)

4-82
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
When the RLA instruction is executed at every scan, the bits are rotated at each scan for the
duration that the execution condition is ON. If the RLA instruction is executed not at each scan
but at the up edge of the execution condition, use the differential type execution instruction
(@RLA) as follows.

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA RLA STA

DM ✽ ✽ ✽ ✽ DM ✽ ✽ ✽ ✽
LDA RLA STA

Operation flag
CR2009 .......... ON when a carry is stored after the operation. Otherwise, OFF
CR2010 .......... ON when the operation result is 0 (zero). Otherwise, OFF
4
CR2011 .......... No change in state

Data Shift Instructions


CR2012 .......... No change in state

Execution Timing
RLA(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@RLA(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
SRA
ON
SLA
Execution condition
OFF RRA

RLA
RLA(.U/.D) Execution Execution
WSR

WSL
@RLA(.U/.D) 1 scan execution

Sample Program
Of the error sensors connected to input relays 30000 to 30015, the number of sensors that are
currently outputting an error is stored to data memory DM00000.

CR2002 #00000 30000


DW LDA Input relays 30000 to 30015 are stored to
DM00000 16-bit internal register.

FOR
The FOR to NEXT instructions are executed
#00016
16 times.

#01 CR2009 DM00000 The content of the 16-bit internal registers is


CR2002
RLA INC shifted to the right (including carrier flag
CR2009), and the content of data memory
DM00000 is incremented by one when
NEXT CR2009 is ON.

4-83
WSR(.U)
4-4 Data Shift Instructions WSR
WSR WSR.D Shifts the word device to
Word shift right the right (towards the larger
ARITHMETIC OPERATION INSTRUCTIONS

WSR
@WSR(.U)
@WSR @WSR.D
number device No.).

Ladder program Input method


Execution condition WSR
S n1 n2 W S R S n1 n2

Execution condition WSR


S n1 n2 @ W S R S n1 n2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n1 — — — — — — — — — — — — — — —
n2 — — — — — — — — — — — — — — —

S : Specifies the leading device to be shifted.


4 n1 : Specifies the number of devices to be shifted.
Data Shift Instructions

n2 : Specifies the number of data blocks to be shifted.

"About Suffixes" page 1-28

Explanation of Operation: WSR(.U) WSR.D


WSR(.U) When the execution condition is ON, n1 number of 16-bit data items starting from
the device specified by S are shifted to the right (towards the larger device No.) by
n2 number of items. "0" is stored to n2 data starting from S .

Before execution After execution

S 1000 0
S +1 2000 0
Store "0".
0
n1 items 0
...

S + n2 1000
( S +1)+ n2 2000
8000
S + n1 –1 9000
...

n2 items
8000
( S + n1 –1)+ n2 9000

WSR.D When the execution condition is ON, n1 number of 32-bit data items starting from
the device specified by S / S +1 are shifted to the right (towards the larger device
No.) by n2 number of items. "0" is stored to n2 data starting from S .

Before execution After execution

S +1 100000 S 0
S +3 200000 S +2 0
Store "0".
0
n1 items 0
...

( S +1)+2 n2 100000 S +2 n2
( S +3)+2 n2 200000 ( S +2)+2 n2
800000
S +2( n1 –1)+1 900000 S +2( n1 –1)
...

n2 items
800000
( S +2( n1 –1)+1)+2 n2 900000 ( S +2( n1 –1)+2 n2

4-84
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
The operation flag does not change state.

Execution Timing
WSR(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@WSR(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

WSR(.U/.D) Execution Execution

@WSR(.U/.D) 1 scan execution


4

Data Shift Instructions


Sample Program
Each time that input relay 00000 turns ON, the content of data memories DM00000 to DM00099 is
shifted one word to the right (towards the larger device No.).

00000 WSR
DM00000 #00100 #00001

SRA

SLA

RRA

RLA

WSR

WSL

4-85
WSL(.U)
4-4 Data Shift Instructions WSL
WSL WSL.D Shifts the word device to
Word shift left the left (towards the smaller
ARITHMETIC OPERATION INSTRUCTIONS

@WSL(.U) WSL
@WSL @WSL.D
number device No.).

Ladder program Input method


Execution condition WSL
S n1 n2 W S L S n1 n2

Execution condition WSL


S n1 n2 @ W S L S n1 n2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n1 — — — — — — — — — — — — — — —
n2 — — — — — — — — — — — — — — —

S : Specifies the leading device to be shifted.


4 n1 : Specifies the number of devices to be shifted.
Data Shift Instructions

n2 : Specifies the number of data blocks to be shifted.

"About Suffixes" page 1-28

Explanation of Operation: WSL(.U) WSL.D


WSL(.U) When the execution condition is ON, n1 number of 16-bit data items starting from
the device specified by S are shifted to the left (towards the smaller device No.) by
n2 number of items. "0" is stored to n2 data starting from S + n1 – n2 .

Before execution After execution

S – n2 1000
n2 items ( S +1) – n2 2000
...

S 1000
S +1 2000
8000
( S + n1 –1) – n2 9000
...

n1 items
0
0
Store "0".
8000 0
S + n1 –1 9000 0

WSL.D When the execution condition is ON, n1 number of 32-bit data items starting from
the device specified by S / S +1 are shifted to the left (towards the smaller device
No.) by n2 number of items. "0" is stored to n2 data starting from S + n1 –
n2 .
Before execution After execution

( S +1) –2 n2 100000 S –2 n2
( S +3) –2 n2 ( S +2) –2 n2
200000
n2 items
...

S +1 100000 S
S +3 200000 S +2
800000
( S +2( n1 –1) +1) –2 n2 900000 ( S –2( n1 –1) –2 n2
...

n1 items
0
0
Store "0".
800000 0
S +2( n1 –1)+1 900000 S +2( n1 –1) 0

4-86
4-4 Data Shift Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
The operation flag does not change state.

Execution Timing
WSL(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@WSL(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

WSL(.U/.D) Execution Execution

@WSL(.U/.D) 1 scan execution


4

Data Shift Instructions


Sample Program
Each time that input relay 00000 turns ON, the content of data memories DM01000 to DM01099 is
shifted one word to the left (towards the smaller device No.).

00000 WSL
DM01000 #00100 #00001

SRA

SLA

RRA

RLA

WSR

WSL

4-87
4-5 Data Conversion Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-5 Data Conversion Instructions


These instructions convert data into code, and disperse and unite data units.

Data Conversion Instruction List


There are 12 data conversion instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Transfer BCD TBCD Converts 16-bit binary data to 4-digit BCD data. 4-90
TBCD.D Converts 32-bit binary data to 8-digit BCD data.
Transfer BIN TBIN Converts 4-digit BCD data to 16-bit binary data. 4-92
TBIN.D Converts 8-digit BCD data to 32-bit binary data.
Multiplex MPX Decodes 4-bit data to 16-bit binary data. 4-94
Demultiplex DMX Encodes 16-bit binary data to 4-bit data.
Gray code GRY(.U) Converts 16-bit binary data to 16-bit gray code. 4-96
4 conversion GRY.D Converts 32-bit binary data to 32-bit gray code.
Gray code reverse RGRY(.U) Converts 16-bit gray code to 16-bit binary data. 4-98
Data Conversion Instructions

conversion RGRY.D Converts 32-bit gray code to 32-bit binary data.


Disperse nibble DISN Disperses word units into nibble (4-bit) units. 4-100
Unite nibble UNIN Unites nibble (4-bit) units into word units. 4-102
Disperse byte DISB Disperses word units into byte units. 4-104
Unite byte UNIB Units byte units into word units. 4-106
Swap SWAP(.U) Swaps the upper and lower bytes. 4-108
SWAP.D Swaps the upper and lower words.
Exchange XCH(.U) Exchanges word units. 4-110
XCH.D Exchanges double-word units.

4-88
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Data Conversion Instructions

4-89
TBCD(.U)
4-5 Data Conversion Instructions
TBCD TBCD.D TBCD Converts the binary data currently
Transfer BCD stored to internal registers to BCD
ARITHMETIC OPERATION INSTRUCTIONS

@TBCD(.U)
@TBCD @TBCD.D TBCD
data.

Ladder program Input method


Execution condition
LDA TBCD STA T B C D

Execution condition
LDA TBCD STA @ T B C D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4 Explanation of Operation
Data Conversion Instructions

TBCD(.U) When the execution condition is ON, the 16-bit binary data currently stored to 16-bit
internal register is converted to 4-digit BCD data, and the result is stored to 16-bit
internal register.
When the operation result exceeds the 4-digit BCD data range 0 to 9999, operation flag
CR2012 turns ON. At this time, the value of the 16-bit internal register does not change
before or after execution of the instruction.
"About Internal Registers" page 1-17
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0

1234

BCD
Conversion
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0

1 2 3 4

TBCD.D When the execution condition is ON, the 32-bit binary data currently stored to 32-bit
internal register is converted to 8-digit BCD data, and the result is stored to 32-bit
internal register.
When the operation result exceeds the 8-digit BCD data range 0 to 99999999,
operation flag CR2012 turns ON. At this time, the value of the 32-bit internal register
does not change before or after execution of the instruction.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0

12345678

BCD
Conversion
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0

1 2 3 4 5 6 7 8

4-90
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... On when the BCD data currently stored to internal register is outside of the
range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

Execution Timing
TBCD(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@TBCD(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Data Conversion Instructions


ON

Execution condition
OFF

TBCD(.U/.D) Execution Execution

@TBCD(.U/.D) 1 scan execution

Sample Program
When input relay 00000 is ON, the value of data memory DM00000 is converted to BCD, and is
output to output relays 30500 to 30515.
TBCD
00000 DM00000 30500
LDA TBCD STA TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-91
TBIN(.U)
4-5 Data Conversion InstructionsTBIN
TBIN TBIN.D
Converts the BCD data currently stored
Transfer BIN
to internal registers to binary data.
ARITHMETIC OPERATION INSTRUCTIONS

@TBIN(.U)
@TBIN @TBIN.D
TBIN

Ladder program Input method


Execution condition
LDA TBIN STA T B I N

Execution condition
LDA TBIN STA @ T B I N

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4
Explanation of Operation
Data Conversion Instructions

TBIN(.U) When the execution condition is ON, the 4-digit BCD data currently stored to 16-bit
internal register is converted to 16-bit binary data, and the result is stored to 16-bit
internal register.
When the 4-digit BCD data is outside of the range (0 to 9999), operation flag CR2012
turns ON. At this time, the value of the 16-bit internal register does not change before
or after execution of the instruction.
"About Internal Registers" page 1-17
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0

1 2 3 4

BIN
Conversion
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0

1234

TBIN.D When the execution condition is ON, the 8-digit BCD data currently stored to 32-bit
internal register is converted to 32-bit binary data, and the result is stored to 32-bit
internal register.
When the 8-digit BCD data is outside of the range (0 to 99999999), operation flag
CR2012 turns ON. At this time, the value of the 32-bit internal register does not change
before or after execution of the instruction.
"About Internal Registers" page 1-17
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0

1 2 3 4 5 6 7 8

BIN
Conversion
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Internal register 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 1 0

12345678

4-92
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... On when the BCD data currently stored to internal register is outside of the
range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

Execution Timing
TBIN(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@TBIN(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Data Conversion Instructions


ON

Execution condition
OFF

TBIN(.U/.D) Execution Execution

@TBIN(.U/.D) 1 scan execution

Sample Program
When input relay 30100 is ON, the 4-digit BCD data captured by input relays 30000 to 30015 is
converted to binary data, and the result is stored to data memory DM00000.
TBCD
30100 30000 DM00000
LDA TBIN STA TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-93
4-5 Data Conversion Instructions
MPX MPX
Multiplex Decodes the number of 1-digit units (four bits) in
(4→16 decode) internal register to 16-bit binary data.
@MPX
ARITHMETIC OPERATION INSTRUCTIONS

MPX

DMX DMX
Demultiplex Encodes the bit position of the MSB whose 16-bit
(16→4 encode) binary data in the internal register is "1" to a 4-digit
@DMX DMX numerical value.

Ladder program Input method


Execution condition n
LDA MPX STA M P X n
Execution condition n
LDA MPX STA @ M P X n
Execution condition
LDA DMX STA D M X
Execution condition
LDA DMX STA @ D M X

4 Available
Devices I O
Bit Devices
Internal
auxiliary T C CTC CR DM TM T
Word Devices Constant Indirect

C CTH CTC CM #/$ #TM


Operation Flag
CR CR CR CR
2009 2010 2011 2012
Data Conversion Instructions

n — — — — — — — — — — — — — — — — — — *
* With the MPX instruc-
n : Specifies the number of digits to be multiplexed. tion, CR2012 does not
change state.

Explanation of Operation
MPX When the execution condition is ON, the n th digit of the 16-bit internal register is
binarized. The bit indicated by that numerical value is turned ON (stored).
"About Internal Registers" page 1-17

[Example] When the data currently stored to 16-bit internal register is $71 and n is #1

n (#1)th digit

#3 #2 #1 #0
16-bit
internal register 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1

As n (#1)th digit is "0111" (7 in decimal),


7
bit 7 of the 16-bit internal register turns ON
("1" is stored).
F E D C B A 9 8 7 6 5 1 3 2 1 0
16-bit
internal register 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0

DMX When the execution condition is ON, the position of the MSB of the bits that are ON ("1")
is stored to 16-bit internal register as binary data.
"About Internal Registers" page 1-17

[Example] When the data currently stored to 16-bit internal register is 138 (10001010 in binary)

Ignore
F E D C B A 9 8 7 6 5 4 3 2 1 0
16-bit
internal register 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0

As the uppermost of the ON ("1") bits is bit 7, "7"


(0111 in binary) is stored the the16-bit internal
16-bit
internal register 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 register.

4-94
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value of the data (internal register) to be operated on is 0. Other-
wise, OFF. When CR2012 is ON, "0" is stored to the internal register.
* With the MPX instruction, CR2012 does not change state.

Execution Timing
MPX DMX This instruction is executed at each scan for the duration that the execution
condition is ON.
@MPX @DMX This instruction is executed for one scan only at the up edge of the execution
condition.

Scan 4

Data Conversion Instructions


ON

Execution condition
OFF

MPX DMX Execution Execution

@MPX @DMX 1 scan execution

Sample Program
MPX When binary digital switch one digit is connected to input relay (30004 to 30007), and
lamps 0 to 15 are connected to each of output relays (30500 to 301515) TBCD

The worker lights the lamp matched to the setting of the digital switch by BIN TBIN

MPX

CR2002 30000 #1 30500 DMX


LDA MPX STA GRY

RGRY

DISN
When the digital switch is set to "8", output relay (30508) turns ON, and lamp "8" lights.
UNIN

DISB

DMX When sensors 0 to 15 are each connected to input relays (30000 to 30015), and binary UNIB
display one digit is connected to output relays (30500 to 30503) SWAP

Which sensor is ON is indicated by the binary display. XCH

* Note, however, that this sample program assumes that multiple sensors do not turn
ON at the same time.

CR2002 30000 30500


LDA DMX STA

When sensor "8" is ON, the binary display indicates "8".

4-95
GRY(.U)
4-5 Data Conversion Instructions
GRY GRY.D GRY
Gray code Converts the values currently stored to
conversion internal registers to gray code.
ARITHMETIC OPERATION INSTRUCTIONS

@GRY(.U)
@GRY @GRY.D
GRY

Ladder program Input method


Execution condition
LDA GRY STA G R Y

Execution condition
LDA GRY STA @ G R Y

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4 Explanation of Operation
Data Conversion Instructions

GRY(.U) When the execution condition is ON, the 16-bit binary data currently stored to 16-bit
internal register is converted to gray code.
"About Internal Registers" page 1-17

GRY.D When the execution condition is ON, the 32-bit binary data currently stored to 32-bit
internal register is converted to gray code.
"About Internal Registers" page 1-17

Gray code table


bit
Decimal
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
:
31 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
32 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
:
255 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
256 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
:
65535 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Operation flag
The operation flag does not change state.

4-96
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
GRY(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@GRY(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

GRY(.U/.D) Execution Execution

@GRY(.U/.D) 1 scan execution

Sample Program
The 16-bit unsigned binary data currently stored to data memory DM00000 is converted to gray 4
code. The result is stored to DM00010.

Data Conversion Instructions


CR2002 DM00000 DM00010
LDA GRY STA

TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-97
RGRY(.U)
4-5 Data Conversion Instructions
RGRY RGRY.D RGRY
Gray code reverse
Converts the gray code currently
stored to internal registers to
conversion
ARITHMETIC OPERATION INSTRUCTIONS

@RGRY(.U) binary data.


@RGRY @RGRY.D
RGRY

Ladder program Input method


Execution condition
LDA RGRY STA R G R Y

Execution condition
LDA RGRY STA @ R G R Y

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4
Explanation of Operation
Data Conversion Instructions

RGRY(.U) When the execution condition is ON, the gray code currently stored to 16-bit internal
register is converted to 16-bit binary data.
"About Internal Registers" page 1-17
"Gray code table" page 4-96

RGRY.D When the execution condition is ON, the gray code currently stored to 32-bit internal
register is converted to 32-bit binary data.
"About Internal Registers" page 1-17
"Gray code table" page 4-96

Operation flag
The operation flag does not change state.

Execution Timing
RGRY(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@RGRY(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

RGRY(.U/.D) Execution Execution

@RGRY(.U/.D) 1 scan execution

4-98
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
The 8-bit gray code captured by input relays 00000 to 00007 is converted to 16-bit unsigned binary
data, and the result is stored to DM00000.

CR2002 00000 $00FF DM00000


LDA ANDA RGRY STA

Data Conversion Instructions


TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-99
DISN
4-5 Data Conversion Instructions
DISN Disperses data into nibble units (4-bit units),
Disperse nibble and stores each of these to four word
ARITHMETIC OPERATION INSTRUCTIONS

DISN
@DISN devices.

Ladder program Input method


Execution condition DISN
S D D I S N S D

Execution condition DISN


S D @ D I S N S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the device to which the data to disperse is currently stored.

4 D : Specifies the leading device to which the dispersed data is to be stored.


Data Conversion Instructions

Explanation of Operation
DISN When the execution condition is ON, the content of the device specified by S is
dispersed to digits (4 bits), and is stored to four word devices starting from the device
specified by D . "0" is stored to the upper 12 bits.
bit bit bit bit
15 8 7 0

1 2 3 4 : S
bit bit bit bit
15 8 7 0

0 0 0 4 : D
0 0 0 3 : D +1
0 0 0 2 : D +2
0 0 0 1 : D +3

"0" is stored to upper 12 bits.

Operation flag
The operation flag does not change state.

Execution Timing
DISN This instruction is executed at each scan for the duration that the execution
condition is ON.
@DISN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DISN Execution Execution

@DISN 1 scan execution

4-100
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input 00000 is ON, the 4-digit BCD data currently stored to data memory DM00000 is
dispersed by each digit into word units. The result is stored to four words starting from DM00000.

00000 DISN
DM00000 DM00010

Data Conversion Instructions


TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-101
UNIN
4-5 Data Conversion Instructions
UNIN Unites the lower four bits of the four word
Unite nibble
devices to 16-bit data.
ARITHMETIC OPERATION INSTRUCTIONS

UNIN
@UNIN
Ladder program Input method
Execution condition UNIN
S D U N I N S D

Execution condition UNIN


S D @ U N I N S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the leading device to which the data to unite is currently stored.

4 D : Specifies the device to store the united data to.


Data Conversion Instructions

Explanation of Operation
UNIN When the execution condition is ON, the lower four bits of the four word devices starting
from the device specified by S are united into 16-bit binary data, and is stored to
the device specified by D .
bit bit bit
15 4 0

S : 1

S +1 : 2

S +2 : 3

S +3 : 4

bit bit bit bit


15 8 7 0

D : 4 3 2 1

Operation flag
The operation flag does not change state.

Execution Timing
UNIN This instruction is executed at each scan for the duration that the execution
condition is ON.
@UNIN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

UNIN Execution Execution

@UNIN 1 scan execution

4-102
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the BCD data currently stored to the lower four bits of data memories
DM00000 to DM00003 are united. The result is stored to DM00010.

00000 UNIN
DM00000 DM00010

Data Conversion Instructions


TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-103
DISB
4-5 Data Conversion Instructions
DISB Disperses data into byte units (8-bit units),
Disperse byte and stores each of these to two word
ARITHMETIC OPERATION INSTRUCTIONS

DISB
@DISB devices.

Ladder program Input method


Execution condition DISB
S D D I S B S D

Execution condition DISB


S D @ D I S B S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the device to which the data to disperse is currently stored.

4 D : Specifies the leading device to which the dispersed data is to be stored.


Data Conversion Instructions

Explanation of Operation
DISB When the execution condition is ON, the 16-bit data currently stored to the device
specified by S is dispersed to an upper byte (8 bits) and a lower byte (8 bits), and
is stored to two word devices starting from the device specified by D . "0" is stored
to the upper 8 bits.
bit bit bit bit
15 8 7 0

S : 1 2 3 4

bit bit bit bit


15 8 7 0

D : 0 0 3 4

D +1 : 0 0 1 2

"0" is stored to
upper byte (8 bits).

Operation flag
The operation flag does not change state.

Execution Timing
DISB This instruction is executed at each scan for the duration that the execution
condition is ON.
@DISB This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DISB Execution Execution

@DISB 1 scan execution

4-104
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
The data captured from input relays 30000 to 30015 is dispersed to byte units, and is stored to data
memories DM00010 and DM00011.

CR2002 30000 DM00000


LDA STA
DISB
DM00000 DM00010

Data Conversion Instructions


TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-105
4-5 Data Conversion UNIB
Instructions
UNIB Unites the lower eight bits of the two word
Unite byte
devices to 16-bit data.
ARITHMETIC OPERATION INSTRUCTIONS

UNIB
@UNIB
Ladder program Input method
Execution condition UNIB
S D U N I B S D

Execution condition UNIB


S D @ U N I B S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the leading device to which the data to unite is currently stored.

4 D : Specifies the device to store the united data to.


Data Conversion Instructions

Explanation of Operation
UNIB When the execution condition is ON, the lower four bytes (8 bits) of the device starting
from the device specified by S are united into 16-bit binary data, and is stored to
the device specified by D .

bit bit bit bit


15 8 7 0

S : 3 4

S +1 : 1 2

bit bit bit bit


15 8 7 0

D : 1 2 3 4

Operation flag
The operation flag does not change state.

Execution Timing
UNIB This instruction is executed at each scan for the duration that the execution
condition is ON.
@UNIB This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

UNIB Execution Execution

@UNIB 1 scan execution

4-106
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
The 4-digit BCD captured by input relays 30000 to 30007 (lower 2 digits) and 30100 to 30107 (upper
2 digits) are united, and is stored to data memory DM00010.

CR2002 30000 DM00000


LDA STA

30100 DM00001
LDA STA

UNIB
DM00000 DM00010

Data Conversion Instructions


TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-107
SWAP(.U)
4-5 Data Conversion Instructions
SWAP SWAP.D SWAP
Swaps the upper and lower data of the
Swap
internal register.
ARITHMETIC OPERATION INSTRUCTIONS

@SWAP(.U)
@SWAP @SWAP.D
SWAP

Ladder program Input method


Execution condition
LDA SWAP STA S W A P

Execution condition
LDA SWAP STA @ S W A P

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

"About Suffixes" page 1-28

4 Explanation of Operation
Data Conversion Instructions

SWAP(.U) When the execution condition is ON, the values of the upper byte (upper 8 bits) and
lower byte (lower 8 bits) of the 16-bit data currently stored to 16-bit internal register are
swapped, and stored to 16-bit internal register.
"About Internal Registers" page 1-17

[Example] When $1234 is stored to 16-bit internal register

bit bit bit bit


15 8 7 0

Before execution 1 2 3 4 16-bit internal register : $1234

After execution 3 4 1 2 16-bit internal register : $3412

SWAP.D When the execution condition is ON, the values of the upper word (upper 16 bits) and
lower word (lower 16 bits) of the 32-bit data currently stored to 32-bit internal register
are swapped, and stored to 32-bit internal register.
"About Internal Registers" page 1-17

[Example] When $12345678 is stored to 32-bit internal register

bit bit bit bit bit bit bit bit


31 24 23 16 15 8 7 0

Before execution 1 2 3 4 5 6 7 8 32-bit internal register : $12345678

After execution 5 6 7 8 1 2 3 4 32-bit internal register : $56781234

4-108
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
The operation flag does not change state.

Execution Timing
SWAP(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@SWAP(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

SWAP(.U/.D) Execution Execution

@SWAP(.U/.D) 1 scan execution


4

Data Conversion Instructions


Sample Program
When input relay 00000 is ON, the upper and lower bytes of data memory DM00000 are stored to
DM00010.

00000 DM00000 DM00010


LDA SWAP STA

TBCD

TBIN

MPX

DMX

GRY

RGRY

DISN

UNIN

DISB

UNIB

SWAP

XCH

4-109
InstructionsXCH
XCH(.U)
4-5 Data Conversion
XCH XCH.D
Exchange Swaps the content of two devices.
XCH
ARITHMETIC OPERATION INSTRUCTIONS

@XCH(.U)
@XCH @XCH.D

Ladder program Input method


Execution condition XCH
S1 S2 X C H S1 S2

Execution condition @XCH


S1 S2 @ X C H S1 S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — — — —
S2 — — — — — — — — — — — —

S1 , S2 : Specifies the device to which the data to swap is currently stored.


4 "About Suffixes" page 1-28
Data Conversion Instructions

Explanation of Operation
XCH(.U) When the execution condition is ON, the 16-bit data currently stored to the devices
specified by S1 and S2 is swapped.

[Example] When $1234 is stored to S1 and $ABCD is stored to S2

Before execution After execution


bit bit bit bit
15 S1 0 15 S1 0

1 2 3 4 A B C D

bit bit bit bit


15 S2 0 15 S2 0

A B C D 1 2 3 4

XCH.D When the execution condition is ON, the 32-bit data currently stored to the devices
specified by S1 / S1 +1 and S2 / S2 +1 is swapped.

[Example] When $01234567 is stored to S1 / S1 +1 and $89ABCDEF is stored


to S2 / S2 +1

Before execution After execution


bit bit bit bit
31 S1 +1 S1 0 31 S1 +1 S1 0

0 1 2 3 4 5 6 7 8 9 A B C D E F

bit bit bit bit


31 S2 +1 S2 0 31 S2 +1 S2 0

8 9 A B C D E F 0 1 2 3 4 5 6 7

4-110
4-5 Data Conversion Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate. Otherwise, OFF
"About Indirect Specification" page 1-42

Execution Timing
XCH(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.
@XCH(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON
4
Execution condition

Data Conversion Instructions


OFF

XCH(.U/.D) Execution Execution

@XCH(.U/.D) 1 scan execution

Sample Program
When input relay 00000 is ON, 16-bit unsigned binary data currently stored to data memories
DM00000 to DM00009 is exchanged in order starting from DM00000. When the exchange is
completed, the program sequence between the FOR to NEXT instructions ends.
TBCD
FOR
#00009 TBIN

MPX

00000 #00000 TM010 #00001 TM011 01000 DMX


LDA STA LDA STA RES GRY

RGRY
FOR
DISN
#00009
UNIN

#TM010 XCH DISB


> #TM010 #TM011 UNIB
#TM011
SWAP
01000 XCH
SET
CR2002 TM010 TM011
INC INC

NEXT

01000 BREAK

NEXT

"FOR/NEXT Instructions" page 3-38


"About Indirect Specification" page 1-42

4-111
4-6 Floating Point Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-6 Floating Point Instructions


Floating point instructions are for processing actual numbers as 32-bit floating point data.
These instructions allow you to perform real number ↔ integer conversion, arithmetic calculations
(addition/subtraction/multiplication/division), angle ↔ radian conversion, trigonometric functions,
inverse trigonometric functions, square root, and exponent/logarithmic functions.

Floating Point Instruction List


There are 25 floating point instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Floating point FLOAT(.U) Converts 16-bit unsigned binary data to a floating point real number value. 4-114
conversion FLOAT.S Converts 16-bit signed binary data to a floating point real number value.
FLOAT.D Converts 32-bit unsigned binary data to a floating point real number value.
FLOAT.L Converts 32-bit signed binary data to a floating point real number value.
4 Integer conversion INTG(.U) Converts a floating point real number value to 16-bit unsigned binary data. 4-116
INTG.S Converts a floating point real number value to 16-bit signed binary data.
Floating Point Instructions

INTG.D Converts a floating point real number value to 32-bit unsigned binary data.
INTG.L Converts a floating point real number value to 32-bit signed binary data.
Write data memory DW.F Stores floating point real number values to data memory. 4-120
Load A LDA.F Stores floating point real number values to 32-bit internal register. 4-122
Store A STA.F Stores floating point real number values currently stored to 32-bit internal 4-124
register to specified devices.
Move MOV.F Stores floating point real number values to specified devices. 4-126
Fill move FMOV.F Batch moves floating point real number values to specified devices. 4-128
Disperse F DISF Disperses floating point real number values into a mantissa and exponent. 4-130
Unite F UNIF Units the mantissa and exponent into a floating point real number value. 4-132
Add ADD.F Adds floating point real number values. 4-134
Subtract SUB.F Subtracts floating point real number values. 4-136
Multiply MUL.F Multiplies floating point real number values. 4-138
Divide DIV.F Divides floating point real number values. 4-140
Root ROOT.F Calculates the square root of floating point real number values. 4-142
Compare CMP.F Compares floating point real number values. 4-144
Zone compare ZCMP.F Compares a range of floating point real number values. 4-146
Exponent arithmetic EXP Calculates the exponent of floating point real number values. 4-148
operation
Logarithmic arithmetic LOG Calculates the natural logarithm of floating point real number values. 4-150
operation
Radian RAD Converts the unit of angles from degrees (°) to radians. 4-152
Degree DEG Converts the unit of angles from radians to degrees (°). 4-154
Sine SIN Calculates the sine value from an angle (radians). 4-156
Cosine COS Calculates the cosine value from an angle (radians). 4-158
Tangent TAN Calculates the tangent from an angle (radians). 4-160
Arc sine ASIN Calculates the angle (radians) from the sine value. 4-162
Arc cosine ACOS Calculates the angle (radians) from the cosine value. 4-164
Arc tangent ATAN Calculates the angle (radians) from the tangent value. 4-166

4-112
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


With floating point instructions, values in the following range can be handled:
–3.4E38 ≤ n ≤ –1.4E–45
n=0
1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7)
To be more precise, the precision of floating point real numbers is 32-bit single-precision, and the
effective bit width is as follows:
• Mantissa: 24 bits
• Indicator: 8 bits (2-126 to 2127)

When comparing with 16/32-bit binary data, set the same data format for the data to be compared
by the FLOAT or INTG instruction.

About Internal Expression of Floating Point Real Numbers


Internal expression of floating point real numbers confirms to IEEE standard format. 4
The floating point real number value is a numerical value annotated as follows:

Floating Point Instructions


– 1 . 2 3 4 x 2 –3
Sign Exponent section
Mantissa section

Sign Exponent section Mantissa section


bit bit
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Sign (1 bit) Indicator (8 bits)


0 = plus 0 0 0 0 0 0 0 0 ($00) = unused
1 = minus 0 0 0 0 0 0 0 1 ($01) = –126
0 0 0 0 0 0 1 0 ($02) = –125
Mantissa (23 bits) 0 0 0 0 0 0 1 1 ($03) = –124
0 to 8388607 :
0 1 1 1 1 1 1 0 ($7E) = –1
0 1 1 1 1 1 1 1 ($7F) = 0
1 0 0 0 0 0 0 0 ($80) = 1
1 0 0 0 0 0 0 1 ($81) = 2
:
1 1 1 1 1 1 0 0 ($FC) = 125
1 1 1 1 1 1 0 1 ($FD) = 126
1 1 1 1 1 1 1 0 ($FE) = 127
1 1 1 1 1 1 1 1 ($FF) = unused

Note: When the result of arithmetic operations on floating point real numbers exceeds the
effective numbers of the mantissa in the internal expression, the result is rounded
according to the following rules:
1.The result is rounded to the nearest of the two floating point real numbers that
approximate the result.
2.When the result is in the middle of the two approximating floating point real numbers, the
result is rounded in the direction where the final digit of the mantissa becomes 0.

4-113
FLOAT(.U)
4-6 Floating Point Instructions
FLOAT.D
FLOAT FLOAT.S FLOAT
FLOAT.L Floating point Converts the data of internal regis-
ARITHMETIC OPERATION INSTRUCTIONS

@FLOAT(.U) conversion ters to floating point real numbers.


@FLOAT.D
@FLOAT @FLOAT.S FLOAT
@FLOAT.L

Ladder program Input method


Execution condition
LDA FLOAT STA.F F L O A T

Execution condition
LDA FLOAT STA.F @ F L O A T

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

4 The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28
Floating Point Instructions

Explanation of Operation
FLOAT(.U) When the execution condition is ON, the 16-bit unsigned binary data currently stored
to 16-bit internal register is converted to a floating point real number, and the result is
stored to 32-bit internal register.
"About Internal Registers" page 1-17

Before execution After execution


bit bit bit bit
15 16-bit internal register 0 31 32-bit internal register 0

16-bit unsigned binary data Floating point real number

16 bits 32 bits

FLOAT.D When the execution condition is ON, the 32-bit unsigned binary data currently stored
to 32-bit internal register is converted to a floating point real number, and the result is
stored to 32-bit internal register.
"About Internal Registers" page 1-17

Before execution After execution


bit 32-bit internal register bit bit 32-bit internal register bit
31 0 31 0

32-bit unsigned binary data Floating point real number

32 bits 32 bits

Note: As floating point real numbers are processed a single precision of 32 bits, the effective
number of digits becomes 24 bits.
When the integer value exceeds the range –16777216 to 16777215 (24-bit binary data),
an error will occur during conversion. The conversion result becomes the value obtained
by discarding 0 and inserting 1 at the 25th bit from the start of the integer values, and
discarding from the 26th bit onwards.

Operation flag
The operation flag does not change state.

4-114
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation
FLOAT.S When the execution condition is ON, the 16-bit signed binary data currently stored to
16-bit internal register is converted to a floating point real number, and the result is
stored to 16-bit internal register.
"About Internal Registers" page 1-17

Before execution After execution


bit bit bit bit
15 16-bit internal register 0 31 32-bit internal register 0

16-bit signed binary data Floating point real number

16 bits 32 bits

FLOAT.L When the execution condition is ON, the 32-bit signed binary data currently stored to
32-bit internal register is converted to a floating point real number, and the result is
stored to 32-bit internal register.
"About Internal Registers" page 1-17

Before execution After execution


4
bit 32-bit internal register bit bit 32-bit internal register bit

Floating Point Instructions


31 0 31 0

32-bit signed binary data Floating point real number

32 bits 32 bits

Operation flag
The operation flag does not change state.

Execution Timing
FLOAT(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution FLOAT
condition is ON.
INTG
@FLOAT(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution DW.F
condition. LDA.F

STA.F

Scan MOV.F

FMOV.F
ON

Execution condition DISF


OFF
UNIF

FLOAT(.U/.D/.S/.L) Execution Execution ADD.F

SUB.F

@FLOAT(.U/.D/.S/.L) 1 scan execution MUL.F

DIV.F

ROOT.F

CMP.F
Sample Program ZCMP.F

EXP
The 16-bit unsigned binary data currently stored to data memory DM00000 is converted to a floating
LOG
point real number, and the result is stored to DM00010/DM00011.
RAD

CR2002 DM00000 DM00010 DEG


LDA FLOAT STA.F SIN

COS

TAN

ASIN

ACOS

ATAN

4-115
INTG(.U)
4-6 Floating Point Instructions
INTG.D
INTG INTG.S
INTG

INTG.L Integer conver- Converts floating point type data of


ARITHMETIC OPERATION INSTRUCTIONS

@INTG(.U) sion internal registers to binary data.


@INTG.D
@INTG @INTG.S INTG

@INTG.L

Ladder program Input method


Execution condition
LDA.F INTG STA I N T G

Execution condition
LDA.F INTG STA @ I N T G

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

The data range that can be handled varies according to the suffix type.
4 "About Suffixes" page 1-28
Floating Point Instructions

Explanation of Operation
INTG(.U) When the execution condition is ON, the floating point real number currently stored to
32-bit internal register is converted to 16-bit unsigned binary data.
The operation result is stored to 16-bit internal register. An error with the stored value
occurs as the digits past the decimal point of the floating point real number before
conversion are discarded.
"About Internal Registers" page 1-17

Before execution After execution


bit 32-bit internal register bit bit 16-bit internal register bit
31 0 31 0
Floating point real number 16-bit unsigned binary data

32 bits 16 bits

INTG.D When the execution condition is ON, the floating point real number currently stored to
internal register is converted to 32-bit unsigned binary data.
The operation result is stored to 16-bit internal register. An error with the stored value
occurs as the digits past the decimal point of the floating point real number before
conversion are discarded.
"About Internal Registers" page 1-17

Before execution After execution


bit 32-bit internal register bit bit 32-bit internal register bit
31 0 31 0

Floating point real number 32-bit unsigned binary data

32 bits 32 bits

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to be converted is outside the floating point real number
range or when the converted data is outside the 16/32-bit unsigned binary
range. Otherwise OFF
The instruction is not executed when CR2012 has turned ON.

4-116
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Explanation of Operation
INTG.S When the execution condition is ON, the floating point real number currently stored to
16-bit internal register is converted to 16-bit signed binary data.
The operation result is stored to 16-bit internal register. An error with the stored value
occurs as the digits past the decimal point of the floating point real number before
conversion are discarded.
"About Internal Registers" page 1-17

Before execution After execution


32-bit internal register 16-bit internal register
bit bit bit bit
31 0 31 0

Floating point real number 16-bit signed binary data

32 bits 16 bits

INTG.L When the execution condition is ON, the floating point real number currently stored to
32-bit internal register is converted to 32-bit signed binary data.
4
The operation result is stored to 32-bit internal register. An error with the stored value

Floating Point Instructions


occurs as the digits past the decimal point of the floating point real number before
conversion are discarded.
"About Internal Registers" page 1-17

Before execution After execution


32-bit internal register 32-bit internal register
bit bit bit bit
31 0 31 0

Floating point real number 32-bit signed binary data

32 bits 32 bits

Operation flag
CR2009 .......... No change in state FLOAT

CR2010 .......... No change in state INTG

DW.F
CR2011 .......... No change in state
LDA.F
CR2012 .......... ON when the data to be converted is outside the floating point real number STA.F
range or when the converted data is outside the 16/32-bit signed binary range. MOV.F
Otherwise OFF
FMOV.F
The instruction is not executed when CR2012 has turned ON.
DISF

UNIF

ADD.F
Execution Timing
SUB.F

INTG(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution MUL.F
condition is ON. DIV.F

@INTG(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution ROOT.F

condition. CMP.F

ZCMP.F

EXP
Scan LOG

ON RAD

Execution condition DEG


OFF
SIN
INTG(.U/.D/.S/.L) Execution Execution COS

TAN
@INTG(.U/.D/.S/.L) 1 scan execution ASIN

ACOS

ATAN

4-117
4-6 Floating Point Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Sample Programs
The floating point real number currently stored to data memories DM00000/DM00001 is converted
to 16-bit unsigned binary data, and the result is stored to DM00010.

CR2002 DM00000 DM00010


LDA.F INTG STA

The floating point real number currently stored to data memories DM00000/DM00001 is converted
to 16-bit signed binary data, and the result is stored to DM00010.

CR2002 DM00000 DM00010


LDA.F INTG.S STA.S

4 The floating point real number currently stored to data memories DM00000/DM00001 is converted
to 32-bit unsigned binary data, and the result is stored to DM00010/DM00011.
Floating Point Instructions

CR2002 DM00000 DM00010


LDA.F INTG.D STA.D

The floating point real number currently stored to data memories DM00000/DM00001 is converted
to 32-bit signed binary data, and the result is stored to DM00010/DM00011.

CR2002 DM00000 DM00010


LDA.F INTG.L STA.L

4-118
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-119
4-6 Floating Point Instructions
DW.F DW.F
Write data memory Stores floating point real numbers to
(floating point real number) data memory.
ARITHMETIC OPERATION INSTRUCTIONS

@DW.F DW.F

Ladder program Input method


Execution condition S
DW.F D W . F S D
D
Execution condition S
DW.F @ D W . F S D
D
Available Bit Devices Word Devices Constant Indirect Operation Flag
Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — — —

S : Specifies the floating point real number to write to data memory or control memory.

4 The floating point real number range is –3.4E38 to 1.4E–45, 1.4E–45 to 3.4E38 and 0.
D : Specifies the destination device to write the floating point real number specified by S to.
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the floating point real number specified by S is stored to
the data memory (DM) or control memory (CM) specified by D / D +1.

D +1 D
S : +1.234567 Floating point real number
32 bits
(2 words)

Operation flag
The operation flag does not change state.

Execution Timing
DW.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@DW.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DW.F Execution Execution

@DW.F 1 scan execution

4-120
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, floating point real number 1.23456 is stored to data memory
DM00000/DM00001, –1.23456 to DM00002/DM00003, 1.23456E10 to DM00004/DM00005, and
–1.23456E–10 to DM00006/DM00007.

00000 +1.23456 –1.23456


DW.F DW.F
DM00000 DM00002

+1.23456E10 –1.23456E–10
DW.F DW.F
DM00004 DM00006

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-121
4-6 Floating Point Instructions
LDA.F LDA.F
Load A Stores floating point real numbers to
(floating point real number) 32-bit internal register.
ARITHMETIC OPERATION INSTRUCTIONS

@LDA.F LDA.F

Ladder program Input method


Execution condition S
LDA.F STA.F L D A . F S

Execution condition S
LDA.F STA.F @ L D A . F S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — —

S : Specifies the floating point real number data to write to 32-bit internal registers or the device
to which that data is currently stored.
4
Explanation of Operation
Floating Point Instructions

When the execution condition is ON, the floating point real number currently stored to the device
specified by S is stored to the 32-bit internal register.
"About Internal Registers" page 1-17

[Example] When the constant is specified by S

32-bit internal register

S : +1.234 +1.234
32 bits

[Example] When the device No. is specified by S

S +1 S 32-bit internal register

+1.234 +1.234
32 bits
32 bits
(2 words)

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when the value read from the device specified to the operand is 0.
Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-122
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
LDA.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@LDA.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

LDA.F Execution Execution

@LDA.F 1 scan execution

Sample Program 4
See the sample program for the STA.F instruction.

Floating Point Instructions


"Sample Program" page 4-125

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-123
4-6 Floating Point Instructions
STA.F STA.F
Store A Stores the floating point real number of
(floating point real number) 32-bit internal register to a specified
ARITHMETIC OPERATION INSTRUCTIONS

@STA.F STA.F device.

Ladder program Input method


Execution condition D
LDA.F STA.F S T A . F D

Execution condition D
LDA.F STA.F @ S T A . F D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

D — — — — — — — — — — — —

D : Specifies the device to store the data of the 32-bit internal register to.

4 Explanation of Operation
Floating Point Instructions

When the execution condition is ON, the floating point real number currently stored to the internal
device is stored to the device specified by D / D +1.
"About Internal Registers" page 1-17

32-bit internal register D +1 D


+1.234 +1.234
32 bits
32 bits
(2 words)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
STA.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@STA.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

STA.F Execution Execution

@STA.F 1 scan execution

4-124
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the "constant + 1.234" is stored to data memories DM00010/
DM00011.
When input relay 00000 is OFF, the floating point real number currently stored to data memories
DM00000/DM00001 is stored to DM00010/DM00011.

00000 +1.234 DM00010


LDA.F
LDA STA.F

00000 DM00000 DM00010


LDA.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-125
MOV.F
4-6 Floating Point Instructions
MOV.F Move Stores floating point real
(floating point real number) numbers to a specified device.
ARITHMETIC OPERATION INSTRUCTIONS

MOV.F
@MOV.F
Ladder program Input method
Execution condition MOV.F
S D M O V . F S D

Execution condition MOV.F


S D @ M O V . F S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — —
D — — — — — — — — —

S : Specifies the source data to be moved or the device to which the data is currently stored.
4 D : Specifies the device (move destination) to store the data to.
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the floating point real number specified by S is stored to
the device specified by D .
MOV.F
[Example] When the constant is specified by S +1.234 DM00014

State of data memory before instruction execution State of data memory after instruction execution
DM00011: 0 :DM00010 S : 1.234 DM00011: 0 :DM00010

DM00013: 0 :DM00012 DM00013: 0 :DM00012

DM00015: 0 :DM00014 Move DM00015: +1.234 :DM00014: D

DM00017: 0 :DM00016 DM00017: 0 :DM00016

DM00019: 0 :DM00018 DM00019: 0 :DM00018

32 bits (2words)

MOV.F
[Example] When the device No. is specified by S DM00012 DM00016

State of data memory before instruction execution State of data memory after instruction execution
DM00011: 0 :DM00010 DM00011: 0 :DM00010

DM00013: -1.234 :DM00012: S DM00013: -1.234 :DM00012

DM00015: 0 :DM00014 DM00015: 0 :DM00014

DM00017: 0 :DM00016 Move DM00017: -1.234 :DM00016 : D

DM00019: 0 :DM00018 DM00019: 0 :DM00018

32 bits (2words)

4-126
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
MOV.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@MOV.F This instruction is executed for one scan only at the up edge of the execution
condition.
4
Scan

Floating Point Instructions


ON

Execution condition
OFF

MOV.F Execution Execution

@MOV.F 1 scan execution

Sample Program
When input relay 00000 is ON, "floating point real number + 1.234" is stored to data memories
DM00010/DM00011. When input relay 00000 is OFF, the floating point real number currently stored
FLOAT
to DM00000/DM00001 is stored to DM00010/DM00011.
INTG

DW.F
00000 MOV.F
+1.234 DM00010 LDA.F

00000 MOV.F STA.F

DM00000 DM00010 MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-127
4-6 Floating Point Instructions
FMOV.F FMOV.F
Fill move (floating
Batch moves floating point
real numbers to a specified
point real number)
ARITHMETIC OPERATION INSTRUCTIONS

device.
@FMOV.F FMOV.F

Ladder program Input method


Execution condition FMOV.F
S D n F M O V . F S D n

Execution condition @FMOV.F


S S
D D
n @ F M O V . F S D n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — —
D — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the move source data or the device to which the data is currently stored.
4 The floating point real number range is –3.4E38 to 1.4E–45, 1.4E–45 to 3.4E38 and 0.
Floating Point Instructions

D : Specifies the leading device of the move destination data block.


n : Specifies the number of data items to detect.

Explanation of Operation
When the execution condition is ON, the floating point real number currently stored to the device
specified by S is moved to n x 2 words leading from the device specified by D .

[Example] In the case of S : DM00100, D : DM00200, n : #00005

Move destination
D +1 D
DM00201: +1.234 :DM00200
Move source
S +1 S DM00203: +1.234 :DM00202

DM00101: +1.234 :DM00100 DM00205: +1.234 :DM00204

DM00207: +1.234 :DM00206

DM00209: +1.234 :DM00208

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the indirect specification range specified to the operand is inappropri-
ate. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-128
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
FMOV.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@FMOV.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

FMOV.F Execution Execution

@FMOV.F 1 scan execution

Sample Program 4
When input relay 00000 is ON, floating point real number #1.234 is stored to data memories

Floating Point Instructions


DM00100 to DM00119. When input relay 00000 is OFF, the floating point real number currently
stored to data memories DM00000/DM00001 is stored to DM00100 to DM00119.

00000 FMOV.F
+1.234 DM00100 #00010

00000 FMOV.F
DM00000 S
DM00100 D
#00010

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-129
DISF
4-6 Floating Point Instructions Disperse F (disperse Disperses a floating point real
DISF mantissa/exponent of number into a mantissa and
floating point real exponent, and stores each of
ARITHMETIC OPERATION INSTRUCTIONS

DISF
@DISF number) these to a specified device.

Ladder program Input method


Execution condition DISF
S D1 D2 D I S F S D1 D2

Execution condition DISF


S D1 D2 @ D I S F S D1 D2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — —
D1 — — — — — — — — — — — — —
D2 — — — — — — — — — — — — —

S : Specifies the device to which the data to disperse is currently stored.


4 D1 : Specifies the device to store the mantissa to.
Floating Point Instructions

D2 : Specifies the device to store the exponent to.

Explanation of Operation
When the execution condition is ON, the mantissa of the floating point real number currently stored
to the device specified by S / S +1 is stored to the device specified by D1 / D1 +1, and the
exponent is stored to the device specified by D2 . Seven digits are calculated for the mantissa
section.

D1 +1 D1
Mantissa section: 32-bit signed binary data

S +1 S 32 bits
(2 words)
Floating point real number Disperse

32 bits D2
Exponent section: 16-bit signed binary data

32 bits
Example of dispersion of –1.234 x 10–3 (1word)

Mantissa Exponent

Mantissa section –1234000 (32-bit signed binary data)


–1.234 x 10–3 Disperse
(Floating point real number) Exponent section –9 (16-bit signed binary data)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to disperse is outside the floating point real number range.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-130
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
DISF This instruction is executed at each scan for the duration that the execution
condition is ON.
@DISF This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DISF Execution Execution

@DISF 1 scan execution

Sample Program 4
When input relay 00000 is ON, the floating point real number currently stored to data memories

Floating Point Instructions


DM00000/DM00001 is dispersed, and the mantissa is stored to DM00010/DM00011, and the
exponent is stored to DM00012.

00000 DISF
DM00000 DM00010 DM00012

DM00011 DM00010
Mantissa –5678900
section:
DM00001 DM00000 32 bits
(1 word)
–5.6789E10 Disperse
FLOAT
DM00012
Exponent INTG
+4
section: DW.F
32 bits
(1 word) LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-131
UNIF
4-6 Floating Point Instructions Unite F (unite mantissa Unites the specified mantissa
UNIF and exponent to and exponent, and stores the
UNIF floating point real united floating point real
ARITHMETIC OPERATION INSTRUCTIONS

@UNIF number) number to a specified device.

Ladder program Input method


Execution condition UNIF
S1 S2 D D I S F S1 S2 D

Execution condition UNIF


S1 S2 D @ D I S F S1 S2 D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — — — — —
S2 — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S1 : Specifies the leading device to which the mantissa is currently stored.


4 S2 : Specifies the device to which the exponent is currently stored.
Floating Point Instructions

D : Specifies the device to store the floating point real number made by uniting S1 and S2 .

Explanation of Operation
When the execution condition is ON, the floating point real number is stored to the device specified
by D / D +1. The floating point real number takes the 32-bit signed binary data currently stored
to the device specified by S1 / S1 +1 as its mantissa, and the 16-bit signed binary data currently
stored to the device specified by S2 as its exponent.

S1 +1 S1
Mantissa section: 32-bit signed binary data
32 bits D +1 D
(2 words)
Unite Floating point real number

S2 32 bits

Exponent section: 16-bit signed binary data

16 bits
(1word)

Example of unit
Mantissa section: –1234 (32-bit signed binary data)
Unite –1.234 x 10–3
Exponent section: –6 (16-bit signed binary data) (Floating point real number)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the result exceeds the floating point real number range. Otherwise, OFF

4-132
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
UNIF This instruction is executed at each scan for the duration that the execution
condition is ON.
@UNIF This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

UNIF Execution Execution

@UNIF 1 scan execution

Sample Program 4
When input relay 00000 is ON, the floating point real number is stored to DM00010/DM00011. The

Floating Point Instructions


floating point real number takes the 32-bit signed binary data currently stored to data memories
DM00000/DM00001 as its mantissa, and the 16-bit signed binary data currently stored to DM00002
as its exponent.

00000 UNIF
DM00000 DM00002 DM00010

DM00001 DM00000
Mantissa section: +987654
32 bits
(2 words) DM00011 DM00010 FLOAT

+9.87654E10 INTG

DW.F
DM00002
LDA.F
Exponent section: +5
STA.F
16 bits
(1word) MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-133
4-6 Floating Point Instructions Adds the floating point real number specified
ADD.F ADD.F
Add (floating point by the operand to the floating point real num-
real number) ber of the 32-bit internal register, and stores
ARITHMETIC OPERATION INSTRUCTIONS

@ADD.F ADD.F
the result again to the 32-bit internal register.

Ladder program Input method


Execution condition S
LDA.F ADD.F STA.F A D D . F D

Execution condition S
LDA.F ADD.F STA.F @ A D D . F D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the addition data or the device No. to which the data is currently stored.
* When word devices (DM, TM, CM) are used as the operand, use two words.
4
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the floating point real number specified by S / S +1 and
the floating point real number of the 32-bit internal register are added, and the result is stored to the
32-bit internal register.

32-bit internal register S1 +1 S1 32-bit internal register


Floating point real number Floating point real number Floating point real number

32 bits 32 bits 32 bits


(2 words)

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)
Operation flag
CR2009 .......... ON when the result is outside the floating point real number range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or the addition data is
outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
ADD.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@ADD.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ADD.F Execution Execution

@ADD.F 1 scan execution

4-134
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the floating point real numbers currently stored to each of data
memories DM00000/DM00001 and DM00002/DM00003 are added, and the result is stored to
DM00010/DM00011.

00000 DM00000 DM00002 DM00010


LDA.F ADD.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-135
4-6 Floating Point Instructions Subtracts the floating point real number speci-
SUB.F SUB.F
Subtract (floating fied by the operand from the floating point real
point real number) number of the 32-bit internal register, and stores
ARITHMETIC OPERATION INSTRUCTIONS

@SUB.F SUB.F
the result again to the 32-bit internal register.

Ladder program Input method


Execution condition S
LDA.F SUB.F STA.F S U B . F S

Execution condition S
LDA.F SUB.F STA.F @ S U B . F S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the subtraction data or the device to which the data is currently stored.
* When word devices (DM, TM, CM) are used as the operand, use two words.
4
Explanation of Operation
Floating Point Instructions

When the execution condition is ON, the floating point real number specified by S / S +1 is
subtracted from the floating point real number of the 32-bit internal register, and the result is stored
to the 32-bit internal register.

32-bit internal register S +1 S 32-bit internal register


Floating point real number Floating point real number Floating point real number

32 bits 32 bits 32 bits


(2 words)

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits) bits)

Operation flag
CR2009 .......... ON when the result is outside the floating point real number range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or the subtraction data is
outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
SUB.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@SUB.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

SUB.F Execution Execution

@SUB.F 1 scan execution

4-136
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the floating point real number currently stored to data memories
DM00000/DM00001 is subtracted from "floating point real number +1.234". The result is stored to
DM00010/DM00011.

00000 +1.234 DM00000 DM00010


LDA.F SUB.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-137
4-6 Floating Point Instructions Multiplies the floating point real number speci-
MUL.F MUL.F
Multiply (floating fied by the operand with the floating point real
point real number) number of the 32-bit internal register, and stores
ARITHMETIC OPERATION INSTRUCTIONS

@MUL.F MUL.F
the result again to the 32-bit internal register.

Ladder program Input method


Execution condition S
LDA.F MUL.F STA.F M U L . F S

Execution condition S
LDA.F MUL.F STA.F @ M U L . F S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the multiplication data or the device to which the data is currently stored.
* When word devices (DM, TM, CM) are used as the operand, use two words.
4
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the floating point real number specified by S / S +1 and
the floating point real number of the 32-bit internal register are multiplied, and the result is stored
to the 32-bit internal register.

32-bit internal register S +1 S 32-bit internal register


Floating point real number Floating point real number Floating point real number

32 bits 32 bits 32 bits


(2 words)

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... ON when the result is outside the floating point real number range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or the multiplication data
is outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
MUL.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@MUL.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

MUL.F Execution Execution

@MUL.F 1 scan execution

4-138
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the floating point real number currently stored to data memories
DM00000/DM00001 is multiplied with the "floating point real number +1.234". The result is stored
to DM00010/DM00011.

00000 +1.234 DM00000 DM00010


LDA.F MUL.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-139
4-6 Floating Point Instructions Divides the floating point real number of the 32-
DIV.F DIV.F
Divide (floating bit internal register by the floating point real
point real number) number specified by the operand, and stores the
ARITHMETIC OPERATION INSTRUCTIONS

@DIV.F DIV.F
result again to the 32-bit internal register.

Ladder program Input method


Execution condition S
LDA.F DIV.F STA.F D I V . F S

Execution condition S
LDA.F DIV.F STA.F @ D I V . F S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — —

S : Specifies the division data or the device to which the data is currently stored.
* When word devices (DM, TM, CM) are used as the operand, use two words.
4
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the floating point real number of the 32-bit internal register is
divided by the floating point real number specified by S / S +1, and the result is stored to the
32-bit internal register.
32-bit internal register S +1 S 32-bit internal register
Floating point real number Floating point real number Floating point real number

32 bits 32 bits 32 bits


(2 words)

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... ON when the result is outside the floating point real number range. Otherwise, OFF
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... ON when the divider is 0 or when indirect specification range is inappropriate or
the division data is outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
DIV.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@DIV.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DIV.F Execution Execution

@DIV.F 1 scan execution

4-140
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the floating point real number #1.234 is divided by the floating point
real number currently stored to data memories DM00000/DM00001. The result is stored to
DM00010/DM00011.

00000 +1.234 DM00000 DM00010


LDA.F DIV.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-141
4-6 Floating Point Instructions Calculates the square root of the floating
ROOT.F ROOT.F
Root (floating point point real number currently stored to 32-bit
real number) internal register, and stores the result to the
ARITHMETIC OPERATION INSTRUCTIONS

@ROOT.F ROOT.F
32-bit internal register.

Ladder program Input method


Execution condition
LDA.F ROOT.F STA.F R O O T . F

Execution condition
LDA.F ROOT.F STA.F @ R O O T . F

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the square root of the floating point real number currently stored
Floating Point Instructions

to 32-bit internal register is calculated. The operation result is stored to the 32-bit internal register
as a floating point real number.

32-bit internal register 32-bit internal register


Floating point real number Floating point real number
32 bits 32 bits

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is a minus value or is outside
the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

Execution Timing
ROOT.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@ROOT.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ROOT.F Execution Execution

@ROOT.F 1 scan execution

4-142
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the square root of the floating point real number currently stored to
data memories DM00000/DM00001 is calculated, and the result is stored to DM00010/DM00011.

00000 DM00000 DM00010


LDA.F ROOT.F STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-143
4-6 Floating Point Instructions
CMP.F CMP.F
Compare (floating
Compares the floating point real number cur-
rently stored to 32-bit internal register with a
point real number)
ARITHMETIC OPERATION INSTRUCTIONS

specified floating point real number.


@CMP.F CMP.F

Ladder program Input method


Execution condition S
LDA.F CMP.F STA.F C M P . F S

Execution condition S
LDA.F CMP.F STA.F @ C M P . F S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — —

S : Specifies the device to compare with the internal register.


* When word devices (DM, TM, CM, #TM) are used as the operand, use two words.
4
Floating Point Instructions

Explanation of Operation
When the execution condition is ON, the size of the value specified by S / S +1 is compared
with the floating point real number currently stored to the 32-bit internal register. The state of the
operation flag changes as follows according to the comparison results.

Compare Result State of Operation Flag


Value of internal register is smaller than specified value CR2009→ON
Internal register < S / S +1
Value of internal register equals the specified value CR2010→ON
Internal register = S / S +1
Value of internal register is greater than specified value CR2011→ON
Internal register > S / S +1

The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... ON when the value to be compared (value of internal register) is smaller than
S / S +1. Otherwise, OFF

CR2010 .......... ON when the value to be compared (value of internal register) is equal to
S / S +1. Otherwise, OFF

CR2011 .......... ON when the value to be compared (value of internal register) is greater than
S / S +1. Otherwise, OFF

CR2012 .......... ON when indirect specification range specified to the operand is inappropriate
or the data to be compared is outside the floating point real number range.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-144
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


[Tip]
a b
Assuming LDA CMP that the internal register is a and the operand is b,
then,
CR2009
a<b
CR2011
a≤b
CR2010
a=b
CR2009
a≥b
CR2011
a>b

Execution Timing
CMP.F This instruction is executed at each scan for the duration that the execution
condition is ON.
4

Floating Point Instructions


@CMP.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

CMP.F Execution Execution

@CMP.F 1 scan execution

FLOAT

INTG

DW.F
Sample Program
LDA.F
When input relay 00000 is ON, the floating point real number currently stored to data memories STA.F
DM00000/DM00001 is compared with floating point real number #1.234. MOV.F

Output relay 00500 turns ON when the value is smaller than +1.234. FMOV.F

DISF
Output relay 00501 turns ON when the value equals +1.234.
UNIF
Output relay 00502 turns ON when the value is greater than +1.234. ADD.F

SUB.F

00000 #1.234 DM00000 CR2009 00500 MUL.F

LDA.F CMP.F DIV.F

ROOT.F
CR2010 00501 CMP.F

ZCMP.F

EXP
CR2011 00502
LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-145
4-6 Floating Point Instructions
ZCMP.F ZCMP.F Compares the floating point real number cur-
Zone compare rently stored to 32-bit internal register with a
ARITHMETIC OPERATION INSTRUCTIONS

specified range.
@ZCMP.F ZCMP.F

Ladder program Input method


Execution condition S1 Operation flag
LDA.F ZCMP.F Z C M P . F S2
S2
Execution condition S1 Operation flag
LDA.F ZCMP.F @ Z C M P . F S2
S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — —
S2 — — — — — — — — — — —

S1 , S2 : Specifies the range to compare with the internal register.


4 * The maximum value and minimum value are automatically judged whichever of
S1 or S2 they are specified to.
Floating Point Instructions

* When word devices (DM, TM, CM, #TM) are used as the operand, use two words.

Explanation of Operation
When the execution condition is ON, the size of the range specified by S1 / S1 +1 and S2 /
S2 +1 and the floating point real number currently stored to 32-bit internal register are compared.

The state of the operation flag changes as follows according to the comparison results.

Compare Result (when S1 / S1 +1 < S2 / S2 +1) State of Operation Flag


Value of internal register is smaller than specified range CR2009→ON
32-bit internal register < S1 / S1 +1 < S2 / S2 +1
Value of internal register is within specified range CR2010→ON
S1 / S1 +1 =< 32-bit internal register =< S2 / S2 +1
Value of internal register is greater than specified range CR2011→ON
S1 / S1 +1 < S2 / S2 +1 < 32-bit internal register

* When S2 / S2 +1 < S1 / S1 +1, swap each of the settings for S1 / S1 +1 and


S2 / S2 +1 in the above table.

Operation flag
CR2009 .......... ON when the value to be compared (value of internal register) is smaller than the
specified range (range specified by operand). Otherwise, OFF
CR2010 .......... ON when the value to be compared (value of internal register) is within the specified
range (range specified by operand). Otherwise, OFF
CR2011 .......... ON when the value to be compared (value of internal register) is greater than the
specified range (range specified by operand). Otherwise, OFF
CR2012 .......... ON when indirect specification range is inappropriate or the addition data is
outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-146
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
ZCMP.F This instruction is executed at each scan for the duration that the execution
condition is ON.
@ZCMP.F This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ZCMP.F Execution Execution

@ZCMP.F 1 scan execution

Sample Program 4
When the floating point real number currently stored to data memories DM00000/DM00001 is

Floating Point Instructions


greater than 5.678, output relay 00500 turns ON.
When the floating point real number currently stored to data memories DM00000/DM00001 is
between 1.234 and 5.678, output relay 00501 turns ON.
When the floating point real number currently stored to data memories DM00000/DM00001 is less
than 1.234, output relay 00502 turns ON.

CR2002 DM00000 +1.234 CR2011 00500


LDA.F ZCMP 1.234<5.678<[DM00000/DM00001]
+5.678
CR2010 00501
1.234≤[DM00000/DM00001]≤5.678 FLOAT

INTG

CR2009 00502 DW.F


[DM00000/DM00001]<1.234<5.678 LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-147
4-6 Floating Point Instructions
EXP EXP
Exponent arith-
Calculates the exponent function taking the floating
point real number currently stored to 32-bit internal
metic operation
ARITHMETIC OPERATION INSTRUCTIONS

register as the exponent.


@EXP EXP

Ladder program Input method


Execution condition
LDA.F EXP STA.F E X P

Execution condition
LDA.F EXP STA.F @ E X P

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the exponent function value is calculated taking the floating
Floating Point Instructions

point real number currently stored to 32-bit internal register as the exponent. The operation result
is stored to the 32-bit internal register as a floating point real number. The calculation is performed
taking e=2.7128.
"About Internal Registers" page 1-17
32-bit internal register 32-bit internal register

e ( Floating point real number


32 bits
) Floating point real number
32 bits

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)
Operation flag
CR2009 .......... ON when the operation result is outside the floating point real number range.
Otherwise, OFF
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to perform the operation on is outside the floating point real
number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

Execution Timing
EXP This instruction is executed at each scan for the duration that the execution
condition is ON.
@EXP This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

EXP Execution Execution

@EXP 1 scan execution

4-148
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, ex is calculated taking the floating point real number currently stored
to data memories DM00000/DM00001 as the exponent, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F EXP STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-149
4-6 Floating Point Instructions
LOG LOG
Logarithmic arith- Calculates the logarithm of the floating point real
metic operation number currently stored to 32-bit internal register.
ARITHMETIC OPERATION INSTRUCTIONS

@LOG LOG

Ladder program Input method


Execution condition
LDA.F LOG STA.F L O G

Execution condition
LDA.F LOG STA.F @ L O G

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the logarithm of the floating point real number currently stored
Floating Point Instructions

to 32-bit internal register is calculated. The operation result is stored to the 32-bit internal register
as a floating point real number.
The calculation is performed taking e=2.7128
"About Internal Registers" page 1-17
32-bit internal register 32-bit internal register

Log ( Floating point type real number ) Floating point type real number
32 bits 32 bits

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is "0", a minus value or is
outside the floating point real number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
LOG This instruction is executed at each scan for the duration that the execution
condition is ON.
@LOG This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

LOG Execution Execution

@LOG 1 scan execution

4-150
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the logarithm of the floating point real number currently stored to data
memories DM00000/DM00001 is calculated, and the result is stored to DM00010/DM00011.

00000 DM00000 DM00010


LDA.F LOG STA.F

Floating Point Instructions


FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-151
4-6 Floating Point Instructions
RAD RAD
Converts the angle (degrees) of the floating point real
Radian
number currently stored to 32-bit internal register to radians.
ARITHMETIC OPERATION INSTRUCTIONS

@RAD RAD

Ladder program Input method


Execution condition
LDA.F RAD STA.F R A D

Execution condition
LDA.F RAD STA.F @ R A D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the angle (degrees) of the floating point real number currently
Floating Point Instructions

stored to 32-bit internal register is converted to radians.


The operation result is stored to 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

( Floating point real number ) ( Floating point real number ) rad


32 bits 32 bits

π .. 0.01745(rad.)
1° = =
180
180 .. 57.23°
1(rad.) = =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

4-152
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
RAD This instruction is executed at each scan for the duration that the execution
condition is ON.
@RAD This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

RAD Execution Execution

@RAD 1 scan execution

Sample Program 4
When input relay 00000 is ON, the angle (degrees) of the floating point real number currently stored

Floating Point Instructions


to data memories DM00000/DM00001 is converted to radians, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F RAD STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-153
4-6 Floating Point Instructions
DEG DEG
Converts the angle (radians) unit of the floating point real
Degree
number currently stored to 32-bit internal register to degrees.
ARITHMETIC OPERATION INSTRUCTIONS

@DEG DEG

Ladder program Input method


Execution condition
LDA.F DEG STA.F D E G

Execution condition
LDA.F DEG STA.F @ D E G

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
4
When the execution condition is ON, the angle (radians) of the floating point real number currently
Floating Point Instructions

stored to 32-bit internal register is converted to degrees. The operation result is stored to the 32-bit
internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

( Floating point real number ) rad. ( Floating point real number )


32 bits 32 bits

π .. 0.01745(rad.)
1° = =
180
180 .=. 57.23°
1(rad.) =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

4-154
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
DEG This instruction is executed at each scan for the duration that the execution
condition is ON.
@DEG This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DEG Execution Execution

@DEG 1 scan execution

Sample Program 4
When input relay 00000 is ON, the angle (radians) of the floating point real number currently stored

Floating Point Instructions


to data memories DM00000/DM00001 is converted to degrees, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F DEG STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-155
4-6 Floating Point SIN
Instructions
SIN Calculates the sine (sin) value of the angle (radians) of the float-
Sine
ing point real number currently stored to 32-bit internal register.
ARITHMETIC OPERATION INSTRUCTIONS

@SIN SIN

Ladder program Input method


Execution condition
LDA.F SIN STA.F S I N

Execution condition
LDA.F SIN STA.F @ S I N

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the sine (sin) value of the angle (radians) of the floating point
Floating Point Instructions

real number currently stored to 32-bit internal register is calculated. The operation result is stored
to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

SIN ( Floating point real number ) Floating point real number


32 bits 32 bits
π .. 0.01745(rad.)
1° = =
180
180 .. 57.23°
1(rad.) = =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

4-156
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
SIN This instruction is executed at each scan for the duration that the execution
condition is ON.
@SIN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

SIN Execution Execution

@SIN 1 scan execution

Sample Program 4
When input relay 00000 is ON, the sine (sin) value of the angle of the floating point real number

Floating Point Instructions


currently stored to data memories DM00000/DM00001 is calculated, and the result is stored to
DM00010/DM00011.

00000 DM00000 DM00010


LDA.F SIN STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-157
4-6 Floating Point Instructions
COS COS Calculates the cosine (cos) value of the angle (radians) of
Cosine the floating point real number currently stored to 32-bit
ARITHMETIC OPERATION INSTRUCTIONS

internal register.
@COS COS

Ladder program Input method


Execution condition
LDA.F COS STA.F C O S

Execution condition
LDA.F COS STA.F @ C O S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
4
When the execution condition is ON, the cosine (cos) value of the angle (radians) of the floating point
Floating Point Instructions

real number currently stored to 32-bit internal register is calculated. The operation result is stored
to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

COS ( Floating point real number ) Floating point real number


32 bits 32 bits
π .. 0.01745(rad.)
1° = =
180
180 .=. 57.23°
1(rad.) =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.

4-158
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
COS This instruction is executed at each scan for the duration that the execution
condition is ON.
@COS This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

COS Execution Execution

@COS 1 scan execution

Sample Program 4
When input relay 00000 is ON, the cosine (cos) value of the angle of the floating point real number

Floating Point Instructions


currently stored to data memories DM00000/DM00001 is calculated, and the result is stored to
DM00010/DM00011.

00000 DM00000 DM00010


LDA.F COS STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-159
4-6 Floating Point Instructions
TAN TAN Calculates the tangent (tan) value of the angle (radians) of
Tangent the floating point real number currently stored to 32-bit
ARITHMETIC OPERATION INSTRUCTIONS

internal register.
@TAN TAN

Ladder program Input method


Execution condition
LDA.F TAN STA.F T A N

Execution condition
LDA.F TAN STA.F @ T A N

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the tangent (tan) value of the angle (radians) of the floating point
Floating Point Instructions

real number currently stored to 32-bit internal register is calculated. The operation result is stored
to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

TAN ( Floating point real number ) Floating point real number


32 bits 32 bits

π π 3π
Logically, tan ( ) = +∞, tan ( 3π )= –∞. However, as tan ( ), tan ( ) becomes
2 2 2 2
π 3π
a rounded figure in the calculation, both tan ( ) and tan ( ) does not exceed the values
2 2

that can be handled.


π .. 0.01745(rad.)
1° = =
180
180 .. 57.23°
1 (rad.) = =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF

4-160
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
TAN This instruction is executed at each scan for the duration that the execution
condition is ON.
@TAN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

TAN Execution Execution

@TAN 1 scan execution

Sample Program 4
When input relay 00000 is ON, the tangent (tan) value of the angle of the floating point real number

Floating Point Instructions


currently stored to data memories DM00000/DM00001 is calculated, and the result is stored to
DM00010/DM00011.

00000 DM00000 DM00010


LDA.F TAN STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-161
4-6 Floating Point Instructions
ASIN ASIN Calculates the angle (radians) from the sine (sin) value
Arc sine expressed as a floating point real number currently stored
ARITHMETIC OPERATION INSTRUCTIONS

to 32-bit internal register.


@ASIN ASIN

Ladder program Input method


Execution condition
LDA.F ASIN STA.F A S I N

Execution condition
LDA.F ASIN STA.F @ A S I N

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
4
When the execution condition is ON, the angle (radians) is calculated from the sine (sin) value
Floating Point Instructions

expressed as a floating point real number currently stored to 32-bit internal register. The operation
result is stored to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register

SIN -1 ( Floating point real number ) Floating point real number


32 bits 32 bits

π .. 0.01745(rad.)
1° = =
180
180 .. 57.23°
1(rad.) = =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on exceeds the range –1.0 to 1.0.
Otherwise, OFF

4-162
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
ASIN This instruction is executed at each scan for the duration that the execution
condition is ON.
@ASIN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ASIN Execution Execution

@ASIN 1 scan execution

Sample Program 4
When input relay 00000 is ON, the inverse sine (sin–1) of the floating point real number currently

Floating Point Instructions


stored to data memories DM00000/DM00001 is calculated, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F ASIN STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-163
4-6 Floating Point Instructions
ACOS ACOS Calculates the angle (radians) from the cosine (cos)
Arc cosine value expressed as a floating point real number cur-
ARITHMETIC OPERATION INSTRUCTIONS

rently stored to 32-bit internal register.


@ACOS ACOS

Ladder program Input method


Execution condition
LDA.F ACOS STA.F A C O S

Execution condition
LDA.F ACOS STA.F @ A C O S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
4
When the execution condition is ON, the angle (radians) is calculated from the cosine (cos) value
Floating Point Instructions

expressed as a floating point real number currently stored to 32-bit internal register. The operation
result is stored to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register


-1 ( )
COS Floating point real number Floating point real number
32 bits 32 bits

π .. 0.01745(rad.)
1° = =
180
180 .=. 57.23°
1(rad.) =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on exceeds the range –1.0 to 1.0.
Otherwise, OFF

4-164
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
ACOS This instruction is executed at each scan for the duration that the execution
condition is ON.
@ACOS This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ACOS Execution Execution

@ACOS 1 scan execution

Sample Program 4
When input relay 00000 is ON, the inverse cosine (cos-1) of the floating point real number currently

Floating Point Instructions


stored to data memories DM00000/DM00001 is calculated, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F ACOS STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-165
4-6 Floating Point Instructions
ATAN ATAN Calculates the angle (radians) from the tangent (tan)
Arc tangent value expressed as a floating point real number cur-
ARITHMETIC OPERATION INSTRUCTIONS

rently stored to 32-bit internal register.


@ATAN ATAN

Ladder program Input method


Execution condition
LDA.F ATAN STA.F A T A N

Execution condition
LDA.F ATAN STA.F @ A T A N

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
When the execution condition is ON, the angle (radians) is calculated from the tangent (tan) value
Floating Point Instructions

expressed as a floating point real number currently stored to 32-bit internal register. The operation
result is stored to the 32-bit internal register as a floating point real number.
"About Internal Registers" page 1-17

32-bit internal register 32-bit internal register


-1
TAN ( Floating point real number ) Floating point real number
32 bits 32 bits

π .. 0.01745(rad.)
1° = =
180
180 .=. 57.23°
1(rad.) =
π

[Tip]
The value (n) that can be handled in floating point real numbers is as follows:
–3.4E38 ≤ n ≤ –1.4E–45, n=0, 1.4E–45 ≤ n ≤ 3.4E38 (eff. number of digits: approx. 7, 24 bits)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the value to perform the operation on is outside the floating point real
number range. Otherwise, OFF

4-166
4-6 Floating Point Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
ATAN This instruction is executed at each scan for the duration that the execution
condition is ON.
@ATAN This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ATAN Execution Execution

@ATAN 1 scan execution

Sample Program 4
When input relay 00000 is ON, the inverse tangent (tan–1) of the floating point real number currently

Floating Point Instructions


stored to data memories DM00000/DM00001 is calculated, and the result is stored to DM00010/
DM00011.

00000 DM00000 DM00010


LDA.F ATAN STA.F

FLOAT

INTG

DW.F

LDA.F

STA.F

MOV.F

FMOV.F

DISF

UNIF

ADD.F

SUB.F

MUL.F

DIV.F

ROOT.F

CMP.F

ZCMP.F

EXP

LOG

RAD

DEG

SIN

COS

TAN

ASIN

ACOS

ATAN

4-167
4-7 Text Processing Instructions
ARITHMETIC OPERATION INSTRUCTIONS

4-7 Text Processing Instructions


Text processing instructions are for handling ASCII code data.

Text Processing Instruction List


There are 11 text processing instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


Hex ASCII code ASC Converts 16-bit binary data to a Hex ASCII code 4-170
conversion string.
Hex ASCII code RASC Converts a Hex ASCII code string to 16-bit binary 4-172
reverse data.
conversion
Decimal ASCII DASC Converts 16-bit unsigned binary data to a decimal 4-174
code conversion ASCII code string.
DASC.S Converts 16-bit signed binary data to a decimal ASCII
4 code string.
DASC.D Converts 32-bit unsigned binary data to a decimal
Text Processing Instructions

ASCII code string.


DASC.L Converts 32-bit signed binary data to a decimal ASCII
code string.
Decimal ASCII RDASC Converts a decimal ASCII code string to 16-bit 4-178
code reverse unsigned binary data.
conversion RDASC.S Converts a decimal ASCII code string to 16-bit signed
binary data.
RDASC.D Converts a decimal ASCII code string to 32-bit
unsigned binary data.
RDASC.L Converts a decimal ASCII code string to 32-bit signed
binary data.
Move text string SMOV Moves text strings to a specified device. 4-182
Add text string SADD Units two text strings. 4-184
Compare text SCMP Judges whether or not two text strings are the same. 4-186
string
Disperse text DISS Disperses multiple 16-bit binary data into 1-byte data. 4-188
string
Unite text string UNIS Units multiple 1-byte data into 16-bit binary data. 4-190
Detect text string LEN Counts the number of characters in text strings stored 4-192
length to a device.
Read comment RCOM Reads the comment appended to devices to a word 4-194
device.

4-168
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


This page left intentionally blank.

Text Processing Instructions

4-169
4-7 Text Processing Instructions
ASC ASC(.U) ASC
Hex ASCII code Converts binary data in internal
conversion registers to Hex ASCII code string.
ARITHMETIC OPERATION INSTRUCTIONS

@ASC @ASC(.U) ASC

Ladder program Input method


Execution condition
LDA ASC STA A S C

Execution condition
LDA ASC STA @ A S C

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

4 Explanation of Operation
ASC(.U) When the execution condition is ON, the binary data of the lower eight bits currently
Text Processing Instructions

stored to 16-bit internal register are converted to ASCII character code annotated in
Hex, and the result is stored to 16-bit internal register.
"About Internal Registers" page 1-17

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Before conversion 1 0 1 0 0 1 0 1 : 16-bit internal register

0 0 A 5

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

0 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 : 16-bit internal register


After conversion
4 1 3 5

Operation flag
The operation flag does not change state.

Execution Timing
ASC(.U) This instruction is executed at each scan for the duration that the execution
condition is ON.
@ASC(.U) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

ASC(.U) Execution Execution

@ASC(.U) 1 scan execution

4-170
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
The data currently stored to the lower eight bits of data memory DM00000 is converted to Hex ASCII
character code. The result is stored to DM00010.

00000 DM00000 DM00010


LDA ASC STA

DM00000 DM00010
Conversion
0 0 F 7 4 6 3 7

Text Processing Instructions


ASC

RASC

DASC

RDASC

SMOV

SADD

SCMP

DISS

UNITS

LEN

RCOM

4-171
4-7 Text Processing Instructions
RASC RASC(.U) RASC
Hex ASCII code Converts Hex ASCII code string in
reverse conversion internal registers to binary data.
ARITHMETIC OPERATION INSTRUCTIONS

@RASC @RASC(.U) RASC

Ladder program Input method


Execution condition
LDA RASC STA R A S C

Execution condition
LDA RASC STA @ R A S C

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — —

Explanation of Operation
4
RASC(.U) When the execution condition turns ON, the Hex ASCII character code currently stored
Text Processing Instructions

to the internal register is converted to binary data and is stored to the lower eight bites
of the 16-bit internal register as binary data. "0" is stored to the upper eight bits.
"About Internal Registers" page 1-17

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

Before conversion 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1 : 16-bit internal register

3 6 4 3

3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 : 16-bit internal register


After conversion
0 0 6 C

The Hex ASCII character codes are converted when both the upper eight bits and lower
eight bits of the internal register before conversion are $30 to $39 or $41 to $46, and
the upper eight bits are $00, and the lower eight bits are $30 to $39 or $41 to $46. When
either of the upper eight bits or lower eight bits is not in this range, the Hex ASCII
character codes are not converted. At this time, special auxiliary relay CR2012 turns
ON.

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when there are ASCII character codes that cannot be handled. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"ASCII Code Table" page A-18

4-172
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
RASC(.U) This instruction is executed at each scan for the duration that the execution
condition is ON.
@RASC(.U/.D) This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

RASC(.U) Execution Execution

@RASC(.U) 1 scan execution

Sample Program 4
The Hex ASCII character code currently stored to data memory DM00000 is converted to binary

Text Processing Instructions


data. The result is stored to DM00010.

00000 DM00000 DM00010


LDA RASC STA

DM00010 DM00010
4 6 3 7 0 0 F 7
Conversion

0 0 3 7 0 0 0 7

ASC

RASC

DASC

RDASC

SMOV

SADD

SCMP

DISS

UNITS

LEN

RCOM

4-173
DASC(.U)
4-7 Text Processing Instructions
DASC.D DASC

DASC DASC.S
DASC.L Decimal ASCII Converts numerical values to a
ARITHMETIC OPERATION INSTRUCTIONS

@DASC(.U) code conversion decimal ASCII code string.


@DASC.D DASC

@DASC @DASC.S
@DASC.L

Ladder program Input method


Execution condition DASC
S D D A S C S D

Execution condition DASC


S D @ D A S C S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *

4 * When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

S : Specifies the numerical value to convert to decimal ASCII text string or the device in which
Text Processing Instructions

this is currently stored.


D : Specifies the leading device to which the ASCII character code after conversion is to be
stored.
Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28
Explanation of Operation: DASC(.U) DASC.D (16/32-bit unsigned binary → decimal ASCII
code conversion)
DASC(.U) When the execution condition is ON, the 16-bit unsigned binary data specified by
S is converted to decimal ASCII character code text string, and is stored as follows
starting from the device specified by D . End code NUL(00H) is stored at the end
of the text string.
bit bit bit bit
15 S 0 15 0

16-bit unsigned binary data D 10,000's 1,000's

16 bits D +1: 100's 10's 00H is


automatically
D +2: –
N
U (00H)
stored at the
L
end.

DASC.D When the execution condition is ON, the 32-bit unsigned binary data specified by
S is converted to decimal ASCII character code text string, and is stored as follows
starting from the device specified by D . End code NUL(00H) is stored at the end
of the text string.

bit bit bit bit bit bit


31 S +1 16 15 S 0 15 0

32-bit unsigned binary data D 1,000,000,000's 100,000,000's

32 bits D +1: 10,000,000's 1,000,000's

D +2: 100,000's 10,000's

D +3: 1,000's 100's

D +4: + –
N
D +5: U
L
(00H)

00H is automatically No change before or after


stored at the end. execution of instruction.

4-174
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or a relay other than the
leading channel is specified. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"ASCII Code Table" page A-18
"About Indirect Specification" page 1-42

Explanation of Operation: DASC.S DASC.L (16/32-bit signed binary → decimal ASCII code
conversion)
DASC.S When the execution condition is ON, the 16-bit signed binary data specified by S
is converted to decimal ASCII character code text string, and is stored as follows 4
starting from the device specified by n . End code NUL(00H) is stored at the end

Text Processing Instructions


of the text string.

bit bit bit bit


15 S 0 15 0

16-bit signed binary data D Sign 10,000's

16 bits D +1: 1,000 100

D +2: + –
N
D +3: U
L
(00H)

00H is automatically No change before or after


stored at the end. execution of instruction.

ASC
DASC.L When the execution condition is ON, the 32-bit signed binary data specified by S
RASC
is converted to decimal ASCII character code text string, and is stored as follows
DASC
starting from the device specified by n . End code NUL(00H) is stored at the end
RDASC
of the text string.
SMOV

SADD
bit bit bit bit bit bit
31 S +1 16 15 S 0 15 0 SCMP

32-bit signed binary data D Sign 1,000,000,000's DISS

UNITS
32 bits D +1: 100,000,000,'s 10,000,000's
LEN
D +2: 1000,000's 100,000's
RCOM
D +3: 10,000's 1,000's

D +4: 100's 10's

N
D +5: – U
L
(00H)

00H is automatically
stored at the end.

4-175
4-7 Text Processing Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or the value after conversion
exceeds the range of devices. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"ASCII Code Table" page A-18
"About Indirect Specification" page 1-42

Execution Timing
DASC(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@DASC(.U/.D/.S/.L) This instruction is executed for one scan only at the up edge of the execution
4 condition.
Text Processing Instructions

Scan
ON

Execution condition
OFF

DASC(.U/.D/.S/.L) Execution Execution

@DASC(.U/.D/.S/.L) 1 scan execution

About zero suppress


"Zero suppress" is a function for omitting "0" (zeros) not required in the upper digits.

[Example] The 16-bit unsigned binary data currently stored to data memory DM00000 is
converted to ASCII text string, and the result is stored to DM00010.

00000 DASC
DM00000 DM00010

bit bit bit bit


15 DM00000 0 15 0
Zero suppress OFF
00123 DM00010: 0(30H) 0(30H)
CR2814: OFF
16 bits DM00011: 1(31H) 2(32H)
N
DM00012: 3(33H) U
L
(00H)

Zero suppress ON
DM00010: 1(31H) 2(32H)
CR2814: ON
N
DM00011: 3(33H) U
L
(00H)

DM00012:

No change before or after


execution of instruction.

4-176
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


About omission of signs
The "+" symbol can be omitted when signed data is converted to ASCII text strings.

[Example] The 16-bit signed binary data currently stored to data memory DM00000 is converted
to ASCII text string, and the result is stored to DM00010.

CR2002 DASC.S
DM00000 DM00010

bit bit bit bit


15 DM00000 0 15 0
Omission OFF
12345 DM00010: +(2BH) 1(31H)
CR2815: OFF
16 bits DM00011: 2(32H) 3(33H)
DM00012: 4(34H) 5(35H)
DM00013: N
U
L
(00H)
4

Text Processing Instructions


Omission ON
DM00010: 1(31H) 2(32H)
CR2815: ON
DM00011: 3(33H) 4(33H)
N
DM00012: 5(33H) U
L
(00H)

DM00013:

No change before or after


execution of instruction.

ASC

Sample Program RASC

DASC
The 16-bit unsigned binary data currently stored to data memory DM00000 is converted to decimal
RDASC
ASCII code, and the result is stored to DM00100 to DM00105.
SMOV

SADD
CR2002 DASC
DM00000 DM00010 SCMP

DISS

UNITS

LEN

RCOM

4-177
RDASC(.U)
4-7 Text Processing Instructions
RDASC.D RDASC
RDASC RDASC.S
Converts decimal
RDASC.L Decimal ASCII code
ARITHMETIC OPERATION INSTRUCTIONS

@RDASC(.U) reverse conversion ASCII code strings to


@RDASC.D RDASC numerical values.
@RDASC @RDASC.S
@RDASC.L

Ladder program Input method


Execution condition RDASC
S D R D A S C S D

Execution condition RDASC


S D @ R D A S C S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *
4 * When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

S : Specifies the decimal ASCII text string to convert to numerical value or the device in which
Text Processing Instructions

this is currently stored.


D : Specifies the device to store the converted data to.
Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation: RDASC RDASC.D (ASCII text string → 16/32-bit unsigned binary
data conversion)
RDASC(.U) When the execution condition is ON, the decimal ASCII text string (end code NUL(00H)
is required at the end of the text string) starting from the device specified by S is
converted to 16-bit unsigned binary data, and is stored to the device specified by D .

bit bit bit bit


15 S 0 15 D 0

S 10,000's 1,000's 16-bit unsigned binary data

S +1: 100's 10's


N
S +2: – U
L
(00H)
NUL (00H) is required at end of text string.

RDASC.D When the execution condition is ON, the decimal ASCII text string (end code NUL(00H)
is required at the end of the text string) starting from the device specified by S is
converted to 32-bit unsigned binary data, and is stored to the device specified by
D / D +1.

bit bit bit bit bit bit


15 S 0 31 D +1 16 15 D 0

S 1,000,000,000's 100,000,000's 32-bit unsigned binary data

S +1: 10,000,000's 1,000,000's

S +2: 100,000's 10,000's

S +3: 1,000's 100's

S +4: + –
N
S +5: U
L
(00H) NUL (00H) is required at end of text string.

4-178
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or the text string contains inappropriate characters, or
when the value after conversion exceeds the 16/32-bit unsigned binary data range.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"ASCII Code Table" page A-18
"About Indirect Specification" page 1-42

Explanation of Operation: RDASC.S RDASC.L (ASCII text string → 16/32-bit unsigned binary
data conversion) 4
RDASC.S When the execution condition is ON, the decimal ASCII text string (NUL(00H) is

Text Processing Instructions


required at the end of the text string) starting from the device specified by S is
converted to 16-bit signed binary data, and is stored to the device specified by D .
bit bit bit bit
15 S 0 15 D 0

S Sign 10,000's 16-bit signed binary data

S +1: 1,000's 100's

S +2: + –
N
S +3: U
L
(00H) NUL (00H) is required at end of text string.

RDASC.L When the execution condition is ON, the decimal ASCII text string (NUL(00H) is
required at the end of the text string) starting from the device specified by S is ASC
converted to 32-bit signed binary data, and is stored to the device specified by D / RASC
D +1.
DASC

RDASC
bit bit bit bit bit bit
15 0 31 D +1 16 15 D 0 SMOV
S Sign 1,000,000,000's 32-bit signed binary data SADD

S +1: 100,000,000's 10,000,000's SCMP

S +2: 1,000,000's 100,000's DISS

UNITS
S +3: 10,000's 1,000's
LEN
S +4: 100's 10's
RCOM
N
S +5: – U (00H)
L NUL (00H) is required at end of text string.

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or the text string contains inappropriate characters, or
when the value after conversion exceeds the 16/32-bit signed binary data range.
Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"ASCII Code Table" page A-18
"About Indirect Specification" page 1-42

4-179
4-7 Text Processing Instructions
ARITHMETIC OPERATION INSTRUCTIONS

Execution Timing
RDASC(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
condition is ON.
@RDASC(.U/.D/.S/.L)This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

RDASC(.U/.D/.S/.L) Execution Execution

@RDASC(.U/.D/.S/.L) 1 scan execution

4 Example of conversion of zero-suppressed data


"Zero suppress" is a function for omitting "0" (zeros) not required in the upper digits.
Text Processing Instructions

Data that is already zero-suppressed is converted correctly.


[Example] The ASCII text string currently stored starting from data memory DM00000 is
converted to 16-bit unsigned binary data. The result is stored to DM00010.

CR2002 RDASC
DM00000 DM00010
bit bit
15 0

DM00010: 1(31H) 2(32H) bit


DM00100
bit
15 0

DM00011: 3(33H) 0(30H) 1230


N
DM00012: U
L
(00H)

Example of conversion of sign-omitted data


ASCII text string without sign data is handled as data with +(2BH) omitted.
[Example] The ASCII text string currently stored starting from data memory DM00000 is
converted to 16-bit signed binary data. The result is stored to DM00100.

CR2002 RDASC.S
DM00000 DM00100
bit bit
15 0

DM00000: 1(31H) 2(32H) bit


DM00010
bit
15 0

DM00001: 3(33H) 4(34H) +12345


N
DM00002: 5(35H) U
L
(00H)

4-180
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Sample Program
When input relay 00000 is ON, the ASCII text string currently stored to data memory DM00000 is
converted to 32-bit unsigned binary data, and the result is stored to DM00010/DM00011.

00000 RDASC.D
DM00000 DM00010
bit bit
15 0

DM00000: 1(31H) 2(32H)


DM00011 DM00010
DM00001: 3(33H) 4(34H) 1234567890

DM00002: 5(35H) 6(36H)

DM00003: 7(37H) 8(38H)

DM00004: 9(39H) 0(30H)


N
DM00005: U
L
(00H)

4
When input relay 00000 is ON, the ASCII text string currently stored to data memory DM00000 is

Text Processing Instructions


converted to 32-bit signed binary data, and the result is stored to DM00010/DM00011.

00000 RDASC.L
DM00000 DM00010
bit bit
15 0

DM00000: – (20H) 1(31H)


DM00011 DM00010
DM00001: 2(32H) 3(33H) –1234567890

DM00002: 4(34H) 5(35H)

DM00003: 6(36H) 7(37H)


ASC
DM00004: 8(38H) 9(39H) RASC
N
DM00005: 0(30H) U
L
(00H) DASC

RDASC

SMOV

SADD

SCMP

DISS

UNITS

LEN

RCOM

4-181
SMOV
4-7 Text Processing Instructions
SMOV
Move text string Stores text strings to a specified device.
ARITHMETIC OPERATION INSTRUCTIONS

SMOV
@SMOV
Ladder program Input method
Execution condition SMOV
S D S M O V S D

Execution condition SMOV


S D @ S M O V S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

4 S : Specifies the leading device to which the source text string data to be moved is currently
stored.
Text Processing Instructions

D : Specifies the leading device (move destination) to store the data to.
Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the text string data (end code NUL(00H) is required at the end
of the text string) currently stored starting from the device specified by S is stored starting from
the device specified by D . End code NUL(00H) is stored at the end of the text string. Up to 256
1-byte characters can be handled as the text string.

S D
Text string data Move Text string data

[Example]
State of device before instruction execution State of device after instruction execution
...

S : A(41H) B(42H)

S +1 : C(43H) D(44H)
...

N
S +2 : E(45H) U
L
(00H) D : A(41H) B(42H)
...

: G(47H) H(48H) D +1 : C(43H) D(44H)


N
I(49H) J(4AH) D +2 : E(45H) U
L
(00H)
...

16 bits 16 bits

4-182
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or there is no end code (NUL(00H)) or when a text
string that includes an end code exceeds 256 characters. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
SMOV This instruction is executed at each scan for the duration that the execution
condition is ON.
@SMOV This instruction is executed for one scan only at the up edge of the execution
condition.
4

Text Processing Instructions


Scan
ON

Execution condition
OFF

SMOV Execution Execution

@SMOV 1 scan execution

Sample Program ASC

RASC
The ASCII text string currently stored starting from data memory DM00000 is stored to DM00100 DASC
onwards. RDASC

SMOV
CR2002 SMOV
SADD
DM00000 DM00100
SCMP

DISS

UNITS

LEN

RCOM
DM00000: A(41H) B(42H) DM00100: A(41H) B(42H)

DM00001: C(43H) D(44H) DM00101: C(43H) D(44H)

DM00002: 0(30H) 1(31H) DM00102: 0(30H) 1(31H)

DM00003: 2(32H) 3(33H) DM00103: 2(32H) 3(33H)


N N
DM00004: U
L
(00H) DM00104: U
L
(00H)

DM00005: DM00105:
...

...

4-183
SADD
4-7 Text Processing Instructions
SADD Unites the text string of the
Add text string
specified device.
ARITHMETIC OPERATION INSTRUCTIONS

SADD
@SADD
Ladder program Input method
Execution condition SADD
S1 S2 D S A D D S1 S2 D

Execution condition SADD


S1 S2 D @ S A D D S1 S2 D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — * — — —
S2 — — — — — — — — — — — — *
D — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).
4 S1 : Specifies the leading device to which the text string to unite is currently stored.
Text Processing Instructions

S2 : Specifies the leading device to which the text string to unite is currently stored.

D : Specifies the leading device to which the united text string is to be stored.
Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the text string currently stored starting from the device specified
by S1 is united with the text string currently stored starting from the device specified by S2 .
The result of the union is stored starting from the device specified by D , and the end code
NUL(00H) is stored at the end of the text string.
The end code NUL(00H) is required at the end of the text strings specified by S1 and S2 . Up
to 256 1-byte characters can be handled as the text string.

S1 A(41H) B(42H)
N
S1 +1 C(43H) U (00H)
L D A(41H) B(42H)

D +1 C(43H) D(44H)

D +2 E(45H) F(46H)
N
S2 D(44H) E(45H) D +3 G(47H) U
L
(00H)

S2 +1 F(46H) G(47H)
N
S2 +2 U
L
(00H)

Note: • Prevent the text string that starts S1 and S2 from being duplicated on D . If the
same text strings are specified, CR2012 will turn ON, and the instruction will not be
executed.
• Prevent the text string after it is united from exceeding 256 characters.

4-184
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or there is no end code (NUL(00H)) or when a text
string that includes an end code exceeds 256 characters or the text string that starts
S1 and S2 is duplicated on D . Otherwise, OFF

The instruction is not executed when CR2012 has turned ON.


"About Indirect Specification" page 1-42

Execution Timing
SADD This instruction is executed at each scan for the duration that the execution
condition is ON.
4
@SADD This instruction is executed for one scan only at the up edge of the execution

Text Processing Instructions


condition.

Scan
ON

Execution condition
OFF

SADD Execution Execution

@SADD 1 scan execution

ASC

Sample Program RASC

DASC
The ASCII text string currently stored starting from data memory DM00000 is united with the ASCII RDASC
text string currently stored starting from DM00100, and the result is stored to DM00200 onwards. SMOV

SADD
CR2002 SADD
SCMP
DM00000 DM00100 DM00200
DISS

UNITS

LEN

DM00000: A(41H) B(42H) RCOM

DM00001: C(43H) D(44H) DM00200: A(41H) B(42H)


N
DM00002: U
L
(00H) DM00201: C(43H) D(44H)

+ DM00202: 0(30H) 1(31H)

DM00100: 0(30H) 1(31H) DM00203: 2(32H) 3(33H)


N
DM00101: 2(32H) 3(33H) DM00204: 4(34H) U (00H)
L
N
DM00102: 4(34H) U
L
(00H)

4-185
SCMP
4-7 Text Processing Instructions
SCMP
Compare text string Compares text strings.
ARITHMETIC OPERATION INSTRUCTIONS

SCMP
@SCMP
Ladder program Input method
Execution condition SCPM
S1 S2 S C M P S1 S2

Execution condition SCMP


S1 S2 @ S C M P S1 S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — *
S2 — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

4 S1 : Specifies the leading device to which the ASCII text string to compare is currently stored.

S2 : Specifies the leading device to which the ASCII text string to compare is currently stored.
Text Processing Instructions

Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation: SCMP


When the execution condition is ON, the ASCII text string currently stored starting from the device
specified by S1 is compared with the ASCII text string currently stored starting from the device
specified by S2 . Comparison as to whether each single ASCII code character starting from the
top of the device is the same or not is performed. The end code NUL(00H) is required at the end of
the text strings specified by S1 and S2 . Up to 256 1-byte characters can be handled as the text
string.

Compare
Compare

S1 A(41H) B(42H) S2 A(41H) B(42H)

S1 +1 C(43H) D(44H) S2 +1 C(43H) D(44H)

S1 +2 E(45H) F(46H) S2 +2 E(45H) F(46H)

S1 +3 G(47H) H(48H) S2 +3 G(47H) H(48H)

S1 +4 I(49H) J(4AH) S2 +4 I(49H) J(4AH)

S1 +5 K(4BH) L(4CH) S2 +5 K(4BH) L(4CH)


Comparison is continued until
N N
S1 +6 M(4DH) U
L
(00H) S2 +6 N(4EH) U
L
(00H) end code (NUL(00H)) is found.
...

...

When the text strings are found to be the same as a result of comparing up to end code NUL(00H),
operation flag CR2010 turns ON.
Compare Result State of Operation Flag
When (all characters of S1 ) = (all characters of S2 ) CR2010→ON

When nth character is different, the operation flag changes as follows.


Compare Result State of Operation Flag
When (ASCII code of nth character of S1 ) < (ASCII code of nth character of S2 ) CR2009→ON
When (ASCII code of nth character of S1 ) > (ASCII code of nth character of S2 ) CR2011→ON

4-186
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... ON when nth character is different, and the ASCII code of the nth character of S1
is smaller than the ASCII code of the nth character of S2 . Otherwise, OFF
CR2010 .......... ON when all of the text string of S1 is the same as the text string of S2 .
Otherwise, OFF
CR2011 .......... ON when the ASCII code of the nth character of S1 is greater than the ASCII code
of the nth character of S2 . Otherwise, OFF
CR2012 .......... ON when indirect specification range is inappropriate or a text string including
the end code exceeds 256 characters. Otherwise, OFF
"About Indirect Specification" page 1-42
The instruction is not executed when CR2012 has turned ON.

Execution Timing
SCMP This instruction is executed at each scan for the duration that the execution
condition is ON. 4
@SCMP This instruction is executed for one scan only at the up edge of the execution

Text Processing Instructions


condition.

Scan
ON

Execution condition
OFF

SCMP Execution Execution

@SCMP 1 scan execution

ASC

RASC
Sample Program DASC

RDASC
The ASCII text string currently stored starting from data memory DM00000 is compared in order
from the start of the ASCII text string currently stored starting from DM00100. SMOV

SADD
When all characters match as a result of the comparison, output relay 00500 turns ON. When even
SCMP
one character does not match, output relay 00501 turns ON.
DISS

UNITS

CR2002 SCMP LEN


DM00000 DM00100 RCOM

CR2002 CR2010 00500

CR2009 00501

CR2011

4-187
DISS
4-7 Text Processing Instructions
DISS Disperses text strings in byte units into
Disperse text string
text strings in word units.
ARITHMETIC OPERATION INSTRUCTIONS

DISS
@DISS
Ladder program Input method
Execution condition DISS
S D D I S S S S2 D

Execution condition DISS


S D @ D I S S S S2 D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

4 S : Specifies the leading device to which the text string to disperse is currently stored.
D : Specifies the leading device to which the dispersed text string is to be stored.
Text Processing Instructions

Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the text string of byte units currently stored starting from the
device specified by S is dispersed, and is stored in word units starting from the device specified
by D . The end code NUL(00H) is required at the end of the text strings specified by S . Up
to 256 1-byte characters can be handled as the text string.

D 0 a(61H)
S a(61H) b(62H) D +1 0 b(62H)
S +1 c(63H) d(64H) D +2 0 c(63H)
N
S +2 e(63H) U
L
(00H) D +3 0 d(64H)

D +4 0 e(65H)

"0" is automatically stored to


the upper byte.

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or the text string to be dispersed including the end code
exceeds 256 characters, or the storage destination device for the text string that is
united exceeds the device range. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-188
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
DISS This instruction is executed at each scan for the duration that the execution
condition is ON.
@DISS This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

DISS Execution Execution

@DISS 1 scan execution

Sample Program 4
The ASCII text string in byte units currently stored starting from data memory DM00000 is dispersed

Text Processing Instructions


to word units, and is stored to DM00100 onwards.

CR2002 DISS
DM00000 DM00100

ASC

RASC

DASC

RDASC

SMOV

SADD

SCMP

DISS

UNITS

LEN

RCOM

4-189
UNIS
4-7 Text Processing Instructions
UNIS Unites text strings in word units into
Unite text string
text strings in byte units.
ARITHMETIC OPERATION INSTRUCTIONS

UNIS
@UNIS
Ladder program Input method
Execution condition UNIS
S D n U N I S S D n

Execution condition UNIS


S D n @ U N I S S D n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *
n — — — — — — — — — — — — — — —

4 * When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

: Specifies the leading device to which the text string to unite is currently stored.
S
Text Processing Instructions

D : Specifies the leading device to which the united text string is to be stored.
n : Specifies the number of characters to unit within the range 1 to 255.
Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is not expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the text string in word units currently stored starting from the
device specified by S is stored in byte units to the device specified by D . The number of
characters to unit is specified by n .

S a(61H)
S +1 b(62H) D a(61H) b(62H)

S +2 c(63H) D +1 c(63H) d(64H)


n items : :

S + n -3 x(78H) D +( n /2)-1 x(78H) y(79H)


N
S + n -2 y(79H) D +( n /2)-1 z(7AH) U
L
(00H)

S + n -1 z(7AH) D +( n /2)-1

* When n /2 cannot be divided, calculate with


the digit rounded up.

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or a relay other than the
leading channel is specified. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-190
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
UNIS This instruction is executed at each scan for the duration that the execution
condition is ON.
@UNIS This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

UNIS Execution Execution

@UNIS 1 scan execution

Sample Program 4
The ASCII text string currently stored in word units to data memories DM00000 to DM00099 is united

Text Processing Instructions


to word units, and is stored to DM00100 onwards.

CR2002 UNIS
DM00000 DM00100 #00100

ASC

RASC

DASC

RDASC

SMOV

SADD

SCMP

DISS

UNITS

LEN

RCOM

4-191
LEN
4-7 Text Processing Instructions
LEN Counts the number of characters in
Detect text string length
text strings.
ARITHMETIC OPERATION INSTRUCTIONS

LEN
@LEN
Ladder program Input method
Execution condition LEN
S D L E N S D

Execution condition LEN


S D @ L E N S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — * — — —
D — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

4 S : Specifies the leading device to which the text string whose number of characters to count
is currently stored.
Text Processing Instructions

D : Specifies the device to store the counted number of characters to.


Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the number of characters in the text string data (end code
NUL(00H) is required at the end of the text string) currently stored starting from the device specified
by S is counted. The number of characters is stored in binary data to the device specified by
D . Up to 256 1-byte characters can be handled as the text string.

S a(61H) b(62H) D 26
16 bits
S +1 c(63H) d(64H) (1 word)
S +2 e(65H) f(66H)
:

w(77H) x(78H)
y(79H) z(7AH)
N
U (00H)
L

Note: 2-byte characters (shift JIS, etc.) are counted as two characters.

4-192
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate, or a relay other than the
leading channel is specified, or there is no end code (NUL(00H)) or when a text
string that includes an end code exceeds 256 characters. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

Execution Timing
LEN This instruction is executed at each scan for the duration that the execution
condition is ON.
@LEN This instruction is executed for one scan only at the up edge of the execution 4
condition.

Text Processing Instructions


Scan
ON

Execution condition
OFF

LEN Execution Execution

@LEN 1 scan execution

Sample Program ASC

RASC
The length (number of characters) of the ASCII text string currently stored starting from data memory DASC
DM00000 is counted, and is stored to DM00100. RDASC

SMOV
CR2002 LEN
SADD
DM00000 DM00100
SCMP

DISS

UNITS

DM00000: A(41H) B(42H) LEN

RCOM
DM00001: C(43H) D(44H)

DM00002: E(45H) F(46H)


DM00100
11
DM00003: 0(30H) 1(31H)

DM00004: 2(32H) 3(33H)


N
DM00005: 4(34H) U
L
(00H)

4-193
RCOM
4-7 Text Processing Instructions
RCOM Reads the comment of a speci-
Read comment
fied device.
ARITHMETIC OPERATION INSTRUCTIONS

RCOM
@RCOM
Ladder program Input method
Execution condition RCOM
S D R C O M S D

Execution condition RCOM


S D @ R C O M S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — —
D — — — — — — — — — — — — *
* When indirectly specifying a relay, specify the leading channel (1000, 1100 and so forth).

4 S : Specifies the device whose comment is to be read.


D : Specifies the leading device to which the read comment is to be stored.
Text Processing Instructions

Range of DMs, TMs and CMs that can be used for operands:
DM00000 to DM19872 (when memory is not expanded) TM000 to TM384
DM00000 to DM39872 (when memory is expanded) CM0000 to CM3872

Explanation of Operation
When the execution condition is ON, the comment of the device specified by S is read, and is
stored starting from the device specified by D . End code NUL(00H) is stored at the end of the
text string.
Up to 32 1-byte characters can be handled as the text string.

Comment of device specified by S .


... D 1st character 2nd character

D +1 3rd character 4th character

Max. 32 character in 1-byte character D +2 5th character 6th character

1-byte characters are stored in ASCII code (1 byte),


...

and 2-byte characters are stored in shift JIS code (2 bytes).

D +15 31st character 32nd character


N
D +16 U
L
(00H)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when indirect specification range is inappropriate or a relay other than the
leading channel is specified. Otherwise, OFF
The instruction is not executed when CR2012 has turned ON.
"About Indirect Specification" page 1-42

4-194
4-7 Text Processing Instructions

ARITHMETIC OPERATION INSTRUCTIONS


Execution Timing
RCOM This instruction is executed at each scan for the duration that the execution
condition is ON.
@RCOM This instruction is executed for one scan only at the up edge of the execution
condition.

Scan
ON

Execution condition
OFF

RCOM Execution Execution

@RCOM 1 scan execution

Sample Program 4
The device comment "STARTING" of input relay 00000 is stored to DM00100, and the device

Text Processing Instructions


comment "Quantity" of data memory DM00200 is stored.

CR2002 RCOM
DM00000 DM00100

RCOM
00000 DM00200

DM00100: S (53H) T (54H) DM00200: Q (51H) u (75H)


ASC
DM00101: A (41H) R (52H) DM00201: a (61H) n (6EH)
RASC
DM00102: T (54H) I (49H) DM00202: t (74H) i (69H)
DASC

DM00103: N (4EH) G (47H) DM00203: t (74H) y (79H) RDASC

DM00104: NUL DM00204: NUL SMOV


(00H) (00H)
SADD

SCMP

DISS

UNITS

LEN

RCOM

4-195
4-7 Text Processing Instructions
ARITHMETIC OPERATION INSTRUCTIONS

This page left intentionally blank.

4
Text Processing Instructions

4-196
5-1 Data Processing Instructions

EXTENDED INSTRUCTIONS
EXTENDED INSTRUCTIONS
These instructions are for data processing, clock processing, high-
speed processing, and positioning processing.

Data Processing Instructions


5-1 Data Processing Instructions ............................................5-2

5-2 Clock Processing Instructions ........................................5-36

5-3 Alarm Instruction .............................................................. 5-46

5-4 High-speed Processing Instructions .............................. 5-50

5-5 Positioning Instructions ...................................................5-88

5-1
5-1 Data Processing Instructions

5-1 Data Processing Instructions


Data processing instructions are for searching within specified ranges, calculating the maximum
and minimum values, and average values, and for executing FIFO processing.

Data Processing Instruction List


There are 11 data processing instructions as follows.
EXTENDED INSTRUCTIONS

Instruction Mnemonic Brief Description of Operation Page


Hex key input HKEY Inputs Hex key data. 5-4

Bit count BCNT Counts the number of bits currently ON in internal 5-6
registers.
Data count DCNT Counts the number of data items that are the same as 5-8
internal registers in a specified range.
Search SER Searches the number of data items that are the same 5-10
as internal registers in a specified range.
Search max. MAX Searches the maximum value in a specified range. 5-12
value
5 Search min. value MIN Searches the minimum value in a specified range. 5-16
Data Processing Instructions

Average AVG Calculates the average value in a specified range. 5-20

Zone reset ZRES Batch-resets a specified range. 5-24

Write FIFO FIFOW Writes data to FIFO table. 5-26

Read FIFO FIFOR Reads data from FIFO table. 5-28

Extend data EXT Extends the signs of data in internal registers. 5-32

5-2
5-1 Data Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Data Processing Instructions

5-3
HKEY
5-1 Data Processing Instructions Stores Hex key data to the read control relays by
HKEY Hex key input
time division.

Ladder program Input method


Execution condition HKEY
S1 H K E Y S1 S2
S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S1 — — — — — — — — — — — — — — — — — —
EXTENDED INSTRUCTIONS

S2 — — — — — — — — — — — — — —

S1 : Specifies the leading device of the input relays to perform reading on.

S2 : Specifies the leading device of the output relays to perform timing output of reading on.

Explanation of Operation
• Four input relay and output relays each are used starting from the No. specified by S1 and S2 .
• When the execution condition is ON, the information of the four bits specified by S1 are captured
while being divided into four times, and is stored to control relays CR3600 to CR3615. Eight scans
5 (approx. 80 ms when the scan time is 10 ms or less) are required until input processing ends.
• Only one HKEY instruction can be used in a program.
Data Processing Instructions

• Execution of the instruction is canceled. CR3600 to CR3615 are reset when the scan time exceeds
200 ms.

(1) When simultaneous pressing


COM 00000 00001 00002 00003 of multiple keys is not allowed
24 VDC KV-700
COM 00500 00501 00502 00503

0 1 2 3

4 5 6 7 (2) When simultaneous pressing


of multiple keys is allowed (diode is inserted)
8 9 A B

C D E F

The HKEY instruction turns special auxiliary relays (CR3600 to CR3615) corresponding to the input
keys ON.
Relay No. CR3600 CR3601 CR3602 CR3603 CR3604 CR3605 CR3606 CR3607 CR3608 CR3609 CR3610 CR3611 CR3612 CR3613 CR3614 CR3615
Corresponding key 0 1 2 3 4 5 6 7 8 9 A B C D E F

Multiple key enable/disable, and end of key reading timing change according to the state of the
special auxiliary relays.

Relay No. CR3514 (read-write) CR3515 (read-only)


Description Entry of multiple keys is disabled when ON. ON when reading of keys ends.

[Tip]
• With the HKEY instruction, use the transistor output type unit to turn outputs ON/OFF at every
scan.
• Set so that the input time constant is less than the scan time.

Note: When the relay assigned to the KL Series is specified as the operand, set so that the "scan
time of KV-700 is greater than the KL communication cycle time." The CPU scan time can
be set as a fixed scan time.

5-4
5-1 Data Processing Instructions

Operation flag
The operation flag does not change.

Execution Timing
HKEY This instruction is executed at each scan for the duration that the execution condition
is ON.

EXTENDED INSTRUCTIONS
Scan
ON
Execution
condition OFF

HKEY Execution Execution

Sample Program
Changing the setting value of internal counters by BCD digital switch
When input relay 00004 is ON, and control relay CR3515 turns ON, the setting value of counter C000 5
changes to the value set by the digital switch (connected to input relays 00000 to 00003).

Data Processing Instructions


The setting value range is #00000 to #09999.

00004 HKEY
00000
00500
CR3515 CR3600 C000
LDA TBIN STA

END

ENDH

HKEY

BCNT

Connect the KV-700 to the digital switch as follows. (Be sure to insert a diode.) DCNT

SER

MAX

MIN

AVG
0 1 2 3
10 10 10 10
ZRES
BCD digital
FIFOW
switch
FIFOR

Diode EXT

1 2 4 8
+ COM 00000 00001 00002 00003

24 VDC KV-700
– COM 00500 00501 00502 00503

5-5
BCNT(.U)
5-1 Data Processing Instructions Counts the number of bits currently ON in
BCNT BCNT.D
BCNT Bit count
internal registers.

Ladder program Input method


Execution condition
LDA BCNT STA B C N T

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

— — — — — — — — — — — — — — — — — — —

The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation
BCNT(.U) When the execution condition is ON, the bits in 16-bit internal registers that are
currently ON are detected, and the number of ON bits is stored to 16-bit internal register
as 16-bit binary data.
"About Internal Registers" page 1-17
5
Data Processing Instructions

[Example] When #10313 (10100001001001 in binary) is currently stored to 16-bit internal register

bit bit
15 0
16-bit internal
0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 1
register

(1) (2) (3) (4) (5)

"5" is stored as there are


five ON bits.

16-bit internal
#00005
register

BCNT.D When the execution condition is ON, the bits in 32-bit internal registers that are
currently ON are detected, and the number of ON bits is stored to 32-bit internal register
as 32-bit binary data.
"About internal registers" page 1-17

[Example] When 675877264 (101000010010010001000110010000 in binary) is currently stored


to 32-bit internal register

bit bit bit bit


31 16 15 0
32-bit internal
0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 0 0
register

(1) (2) (3) (4) (5) (6) (7) (8) (9)

"9" is stored as there are


five ON bits.

32-bit internal
#00009
register

5-6
5-1 Data Processing Instructions

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

EXTENDED INSTRUCTIONS
Execution Timing
BCNT(.U/.D) This instruction is executed at each scan for the duration that the execution
condition is ON.

Scan
ON
Execution
condition OFF

BCNT(.U/.D) Execution Execution

Sample Program 5
The number of relays in internal relays 01000 to 01015 that are ON is counted, and the result is

Data Processing Instructions


stored to data memory DM00000.

CR2002 01000 DM00000


LDA BCNT STA

HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-7
5-1 Data Processing Instructions
DCNT(.U) Detects devices of the same value as the
DCNT DCNT.D
DCNT Data count internal register in the specified range, and
counts the number of devices.

Ladder program Input method


Execution condition S
LDA DCNT STA D C N T S n
n

Available Bit Devices Word Devices Constant Indirect Operation Flag


EXTENDED INSTRUCTIONS

Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the leading device of the range to detect.


n : Specifies the number of data items to detect.

Explanation of Operation
DCNT(.U) When the execution condition is ON, n number of data items starting from S
is compared with each respective 16-bit internal register. The number of data items
5 having the same value as the value in 16-bit internal registers is stored to the 16-bit
internal register. The number of data items is stored in 16-bit unsigned binary data.
Data Processing Instructions

"About Internal Registers" page 1-17


bit bit 16-bit internal register
15 0 bit15 bit0

S 1234 Compare 1234

S +1 2345 Compare The same value as the value of


the 16-bit internal register is
S +2 3456 Compare stored.
The number of data items is
n items counted. The result is stored in
( n word) S 1234 Compare the 16-bit internal register.
16-bit internal register
S 4567 Compare
bit15 bit0

S + n –1 5678 Compare Result 2

DCNT.D When the execution condition is ON, n number of data items starting from S
is compared with each respective 32-bit internal register. The number of data items
having the same value as the value in 32-bit internal registers is stored to the 32-bit
internal register. The number of data items is stored in 32-bit unsigned binary data.

bit bit bit bit bit 32-bit internal register bit


31 16 15 0 31 0

S +1 12345678 S Compare 12345678

S +3 23456789 S +2 Compare
The same value as the value of
S +5 34567890 S +4 Compare the 32-bit internal register is
n items stored.
The number of data items is
(2 n words) S +2 ( n –3) +1 12345678 S +2 ( n –3) Compare counted. The result is stored in
the 32-bit internal register.
S +2 ( n –2) +1 45678901 S +2 ( n –2) Compare

S +2 ( n –1) +1 56789012 S +2 ( n –1) Compare


bit 32-bit internal register bit
31 0

Result 2

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when result is 0 (zero). Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

5-8
5-1 Data Processing Instructions

Execution Timing
DCNT(.U/.D) This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

EXTENDED INSTRUCTIONS
DCNT(.U/.D) Execution Execution

Sample Programs
(1) 16-bit unsigned binary data count
When input relay 00000 is ON, the 16-bit unsigned binary data currently stored to data memory
DM00000 is compared with the 16-bit unsigned binary data currently stored to DM00100 to
DM00199. The number of devices to which the same value is stored is stored to DM00010.

00000 DM00000 DM00100 DM00010


LDA DCNT STA
#00100
5

Data Processing Instructions


(2) 16-bit signed binary data count
When input relay 00000 is ON, the 16-bit signed binary data currently stored to data memory
DM00000 is compared with the 16-bit signed binary data currently stored to DM00100 to
DM00199. The number of devices to which the same value is stored is stored to DM00010.

00000 DM00000 DM00100 DM00010


LDA.S DCNT STA.S
#00100

(3) 32-bit unsigned binary data count


HKEY

When input relay 00000 is ON, the 32-bit unsigned binary data currently stored to data memories BCNT
DM00000/DM00001 is compared with the 32-bit unsigned binary data currently stored to DCNT
DM00100 to DM00299. The number of devices to which the same value is stored is stored to SER
DM00010/DM00011. MAX

MIN
00000 DM00000 DM00100 DM00010
AVG
LDA.D DCNT.D STA.D
#00100 ZRES

FIFOW

FIFOR

(4) 32-bit signed binary data count EXT

When input relay 00000 is ON, the 32-bit signed binary data currently stored to data memories
DM00000/DM00001 is compared with the 32-bit signed binary data currently stored to DM00100
to DM00299. The number of devices to which the same value is stored is stored to DM00010/
DM00011.

00000 DM00000 DM00100 DM00010


LDA.L DCNT.D STA.L
#00100

5-9
5-1 Data Processing Instructions
SER(.U) Detects devices of the same value as the
SER SER.D
SER Search internal register in the specified range, and
detects their device Nos.

Ladder program Input method


Execution condition S CR2010
LDA SER STA S E R S n
n

Available Bit Devices Word Devices Constant Indirect Operation Flag


EXTENDED INSTRUCTIONS

Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the leading device of the range to detect.


n : Specifies the number of data items to detect. The range of constants that can be handled
varies according to the suffix.
"About Suffixes" page 1-28

Explanation of Operation
5 SER(.U) When the execution condition is ON, n number of data items starting from S
is compared with each respective 16-bit internal register. The device Nos. currently
Data Processing Instructions

stored with the same value as the value in 16-bit internal registers is stored to the 16-
bit internal register. The device Nos. are stored in 16-bit unsigned binary data.
bit bit 16-bit internal register
15 0 bit15 bit0

S 1234 Compare 3456

S +1 2345 Compare
The No. of the device to which the
same value as the 16-bit internal
S +2 3456 Compare
register is stored.
n items The result is stored in the 16-bit
internal register.
( n word)
S + n –3 1234 Compare

S + n –2 3456 Compare 16-bit internal register


bit15 bit0
S + n –1 5678 Compare
Result S +2

SER.D When the execution condition is ON, n number of data items starting from S
is compared with each respective 32-bit internal register. The device Nos. of the lower
16 bits currently stored with the same value as the value in 32-bit internal registers is
stored to the 32-bit internal register. When two or more are detected, the smallest
device No. is stored. The device Nos. are stored in 32-bit unsigned binary data.

bit bit bit bit bit 32-bit internal register bit


31 16 15 0 31 0

S +1 12345678 S Compare 23456789

S +3 23456789 S +2 Compare
The No. of the device to which
S +5 34567890 S +4 Compare the same value as the 32-bit
n items internal register is stored.
The result is stored in the 32-bit
(2 n words) S +2 ( n –3) +1 45678901 S +2 ( n –3) Compare internal register.

S +2 ( n –2) +1 23456789 S +2 ( n –2) Compare

S +2 ( n –1) +1 56789012 S +2 ( n –1) Compare


bit 32-bit internal register bit
31 0

Result S +2

Note: • Only the device No. is stored as the result. There is no difference in DM, TM and CM
device types.
• When there are no matching devices, nothing is written to internal registers. Accordingly,
the value that was last stored by LDA remains in the internal register.

5-10
5-1 Data Processing Instructions

Operation flag
CR2009 .......... No change in state
CR2010 .......... ON when the search target is found in the specified range. Otherwise, OFF
CR2011 .......... No change in state
CR2012 .......... No change in state

EXTENDED INSTRUCTIONS
Execution Timing
SER(.U/.D) This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

SER(U/.D) Execution Execution

Sample Programs 5
(1) 16-bit unsigned binary data search

Data Processing Instructions


When input relay 00000 is ON, the 16-bit unsigned binary data currently stored to data memory
DM00000 is compared with the 16-bit unsigned binary data currently stored to DM00100 to
DM00199. The device No. to which the same value is stored is stored to DM00010.

00000 DM00000 DM00100 CR2010 DM00010


LDA SER STA
#00100

(2) 16-bit signed binary data search


When input relay 00000 is ON, the 16-bit signed binary data currently stored to data memory
DM00000 is compared with the 16-bit signed binary data currently stored to DM00100 to
DM00199. The device No. to which the same value is stored is stored to DM00010. HKEY

BCNT
00000 DM00000 DM00100 CR2010 DM00010 DCNT
LDA.S SER STA.S
#00100 SER

MAX
(3) 32-bit unsigned binary data search MIN

When input relay 00000 is ON, the 32-bit unsigned binary data currently stored to data memories AVG

DM00000/DM00001 is compared with the 32-bit unsigned binary data currently stored to ZRES
DM00100 to DM00299. The device Nos. to which the same value is stored are stored to FIFOW
DM00010/DM00011. FIFOR

EXT
00000 DM00000 DM00100 CR2010 DM00010
LDA.D SER.D STA.D
#00100

(4) 32-bit signed binary data search


When input relay 00000 is ON, the 32-bit signed binary data currently stored to data memories
DM00000/DM00001 is compared with the 32-bit signed binary data currently stored to DM00100
to DM00299. The device Nos. to which the same value is stored are stored to DM00010/
DM00011.

00000 DM00000 DM00100 CR2010 DM00010


LDA.L SER.D STA.L
#00100

5-11
MAX(.U)
5-1 Data Processing Instructions
MAX.D Calculates the maximum value of binary
MAX MAX.S
MAX Search max. value data currently stored in a specified range,
and stores this to internal registers.
MAX.L

Ladder program Input method


Execution condition S
MAX STA M A X S n
n
EXTENDED INSTRUCTIONS

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the leading device of the range to search.


n : Specifies the number of data items to search.
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

5
Explanation of Operation: MAX(.U) MAX.D (maximum value of 16/32-bit unsigned binary data)
Data Processing Instructions

MAX(.U) When the execution condition is ON, each of n items of data starting from S is
compared. Currently stored values are compared as 16-bit unsigned binary data. As
a result of comparison, the maximum value is stored to 16-bit internal register.
bit bit
15 0

S 1234 The maximum


value in this
S +1 2345
range is
16-bit internal register
S +2 3456 stored. bit15 bit0

n items 9876
( n word)
S + n –3 9876

S + n –2 8765

S + n –1 7654

MAX.D When the execution condition is ON, each of n items of data starting from S is
compared. Currently stored values are compared as 32-bit unsigned binary data. As
a result of comparison, the maximum value is stored to 32-bit internal register.
bit bit bit bit
31 16 15 0

S +1 12345678 S The maximum


value in this
S +3 23456789 S +2 range is
S +5 34567890 S +4 stored. bit 32-bit internal register bit
31 0
n items 98765432
(2 n words) S +2 ( n –3) +1 98765432 S +2 ( n –3)
S +2 ( n –2) +1 87654321 S +2 ( n –2)
S +2 ( n –1) +1 76543210 S +2 ( n –1)

Operation flag
The operation flag does not change.

5-12
5-1 Data Processing Instructions

Explanation of Operation: MAX.S MAX.L (maximum value of 16/32-bit signed binary data)
MAX.S When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 16-bit signed binary data. As
a result of comparison, the maximum value is stored to 16-bit internal register.
bit bit
15 0

S 1234 The maximum


value in this
S +1 2345

EXTENDED INSTRUCTIONS
range is
16-bit internal register
S +2 3456 stored. bit15 bit0

n items 3456
( n word)
S + n –3 9876

S + n –2 8765

S + n –1 7654

MAX.L When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 32-bit signed binary data. As
a result of comparison, the maximum value is stored to 32-bit internal register.

bit
31
bit bit
16 15
bit
0
5
S +1 12345678 S The maximum

Data Processing Instructions


value in this
S +3 23456789 S +2 range is
S +5 34567890 S +4 stored. bit 32-bit internal register bit
31 0
n items 34567890
(2 n words) S +2 ( n –3) +1 98765432 S +2 ( n –3)
S +2 ( n –2) +1 87654321 S +2 ( n –2)
S +2 ( n –1) +1 76543210 S +2 ( n –1)

Operation flag
The operation flag does not change. HKEY

BCNT

DCNT
Execution Timing SER

MAX(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution MAX

condition is ON. MIN

AVG

Scan ZRES

FIFOW
ON
Execution
FIFOR
condition OFF
EXT

MAX(.U/.D/.S/.L) Execution Execution

5-13
5-1 Data Processing Instructions

Sample Programs
(1) 16-bit unsigned binary data max. value search
When input relay 00000 is ON, the 16-bit unsigned binary data currently stored to data memories
DM00000 to DM00099 is compared. The maximum value is stored to DM01000.

00000 DM00000 DM01000


MAX STA
#00100
EXTENDED INSTRUCTIONS

(2) 16-bit signed binary data max. value search


When input relay 00000 is ON, the 16-bit signed binary data currently stored to data memories
DM00000 to DM00099 is compared. The maximum value is stored to DM01000.

00000 DM00000 DM01000


MAX.S STA.S
#00100

5 (3) 32-bit unsigned binary data max. value search


When input relay 00000 is ON, the 32-bit unsigned binary data currently stored to data memories
Data Processing Instructions

DM00000/DM00001 to DM00198/DM00199 are compared. The maximum value is stored to


DM01000/DM01001.

00000 DM00000 DM01000


MAX.D STA.D
#00100

(4) 32-bit signed binary data max. value search


When input relay 00000 is ON, the 32-bit signed binary data currently stored to data memories
DM00000/DM00001 to DM00198/DM00199 are compared. The maximum value is stored to
DM01000/DM01001.

00000 DM00000 DM01000


MAX.L STA.L
#00100

5-14
5-1 Data Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Data Processing Instructions


HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-15
MIN(.U)
5-1 Data Processing Instructions
MIN.D Calculates the minimum value of binary data
MIN MIN.S
MIN Search min. value currently stored in a specified range, and
stores this to internal registers.
MIN.L

Ladder program Input method


Execution condition S
MIN STA M I N S n
n
EXTENDED INSTRUCTIONS

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the leading device of the range to search.


n : Specifies the number of data items to search.
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

5
Explanation of Operation: MIN(.U) MIN.D (minimum value of 16/32-bit unsigned binary data)
Data Processing Instructions

MIN(.U) When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 16-bit unsigned binary data. As
a result of comparison, the minimum value is stored to 16-bit internal register.
bit bit
15 0

S 1234
The minimum
S +1 2345 value in this
range is 16-bit internal register
S +2 3456 stored. bit15 bit0

n items 1234
( n word)
S + n –3 7654

S + n –2 8765

S + n –1 9876

MIN.D When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 32-bit unsigned binary data. As
a result of comparison, the minimum value is stored to 32-bit internal register.

bit bit bit bit


31 16 15 0

S +1 12345678 S
The minimum
S +3 23456789 S +2 value in this
range is bit bit
S +5 34567890 S +4 stored. 31
32-bit internal register
0
n items 12345678
(2 n words) S +2 ( n –3) +1 76543210 S +2 ( n –3)
S +2 ( n –2) +1 87654321 S +2 ( n –2)
S +2 ( n –1) +1 98765432 S +2 ( n –1)

Operation flag
The operation flag does not change.

5-16
5-1 Data Processing Instructions

Explanation of Operation: MIN.S MIN.L (minimum value of 16/32-bit signed binary data)
MIN.S When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 16-bit signed binary data. As
a result of comparison, the minimum value is stored to 16-bit internal register.

bit bit
15 0

S 1234
The minimum
value in this

EXTENDED INSTRUCTIONS
S +1 2345
range is 16-bit internal register
S +2 3456 stored. bit15 bit0

n items –3456
( n word)
S + n –3 –3456

S + n –2 –2345

S + n –1 –1234

MIN.L When the execution condition is ON, each of n items of data starting from S
is compared. Currently stored values are compared as 32-bit signed binary data. As
a result of comparison, the minimum value is stored to 32-bit internal register.

bit
31
bit bit
16 15
bit
0
5
S +1 12345678 S

Data Processing Instructions


The minimum
S +3 23456789 S +2 value in this
range is bit bit
S +5 34567890 S +4 32-bit internal register
stored. 31 0
n items –34567890
(2 n words) S +2 ( n –3) +1 –34567890 S +2 ( n –3)
S +2 ( n –2) +1 –23456789 S +2 ( n –2)
S +2 ( n –1) +1 –12345678 S +2 ( n –1)

Operation flag
The operation flag does not change. HKEY

BCNT

DCNT
Execution Timing SER

MIN(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution MAX

condition is ON. MIN

AVG

Scan ZRES

FIFOW
ON
Execution
FIFOR
condition OFF
EXT

MIN(.U/.D/.S/.L) Execution Execution

5-17
5-1 Data Processing Instructions

Sample Programs
(1) 16-bit unsigned binary data min. value search
When input relay 00000 is ON, the 16-bit unsigned binary data currently stored to data memories
DM00000 to DM00099 is compared. The minimum value is stored to DM01000.

00000 DM00000 DM01000


MIN STA
#00100
EXTENDED INSTRUCTIONS

(2) 16-bit signed binary data min. value search


When input relay 00000 is ON, the 16-bit signed binary data currently stored to data memories
DM00000 to DM00099 is compared. The minimum value is stored to DM01000.

00000 DM00000 DM01000


MIN.S STA.S
#00100

5 (3) 32-bit unsigned binary data min. value search


When input relay 00000 is ON, the 32-bit unsigned binary data currently stored to data memories
Data Processing Instructions

DM00000/DM00001 to DM00198/DM00199 are compared. The minimum value is stored to


DM01000/DM01001.

00000 DM00000 DM01000


MIN.D STA.D
#00100

(4) 32-bit signed binary data min. value search


When input relay 00000 is ON, the 32-bit signed binary data currently stored to data memories
DM00000/DM00001 to DM00198/DM00199 are compared. The minimum value is stored to
DM01000/DM01001.

00000 DM00000 DM01000


MIN.L STA.L
#00100

5-18
5-1 Data Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Data Processing Instructions


HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-19
AVG(.U)
5-1 Data Processing Instructions
AVG.D Calculates the average value of binary data
AVG AVG.S
AVG Average currently stored in a specified range, and
stores this to internal registers.
AVG.L

Ladder program Input method


Execution condition S
AVG STA A V G S n
n
EXTENDED INSTRUCTIONS

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —
n — — — — — — — — — — — — — — —

S : Specifies the leading device of the range to calculate the average value.
n : Specifies the number of data items whose average value is to be calculated.
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

5
Explanation of Operation: AVG(.U) AVG.D (average value of 16/32-bit unsigned binary data)
Data Processing Instructions

AVG(.U) When the execution condition is ON, the average value of n number of 16-bit
unsigned binary data items starting from S is calculated and stored to 16-bit internal
register.

bit bit
15 0

S 16

S +1 256

S +2 4096
n items The Average value is stored in the
16-bit internal register.
S + n –3 16383
16-bit internal register
S + n –2 32767 bit15 bit0

S + n –1 65535 Average Average value

AVG(.D) When the execution condition is ON, the average value of n number of 32-bit
unsigned binary data items starting from S is calculated and stored to 32-bit internal
register.

bit bit bit bit


31 16 15 0

S +1 12345678 S
S +3 23456789 S +2
S +5 34567890 S +4
n items The Average value is stored in the
(2 n words) S +2 ( n –3) +1 32-bit internal register.
78901234 S +2 ( n –3)
S +2 ( n –2) +1 89012345 S +2 ( n –2) bit
31
32-bit internal register bit
0

S +2 ( n –1) +1 90123456 S +2 ( n –1) Average Average value

Operation flag
The operation flag does not change.

5-20
5-1 Data Processing Instructions

Explanation of Operation: AVG.S AVG.L (average value of 16/3-bit signed binary data)
AVG.S When the execution condition is ON, the average value of n number of 16-bit
signed binary data items starting from S is calculated and stored to 16-bit internal
register.

bit bit
15 0

S –32700

EXTENDED INSTRUCTIONS
S +1 –16350

S +2 –8175
n items The Average value is stored in the
( n word) 16-bit internal register.
S + n –3 8175
16-bit internal register
S + n –2 16350 bit15 bit0

S + n –1 32700 Average Average value

AVG.L When the execution condition is ON, the average value of n number of 32-bit
signed binary data items starting from S is calculated and stored to 32-bit internal
register.

5
bit bit bit bit

Data Processing Instructions


31 16 15 0

S +1 –90123456 S
S +3 –89012345 S +2
S +5 –78901234 S +4
n items The Average value is stored in the
(2 n words) S +2 ( n –3) +1 32-bit internal register.
78901234 S +2 ( n –3)
S +2 ( n –2) +1 89012345 S +2 ( n –2) bit
31
32-bit internal register bit
0

S +2 ( n –1) +1 90123456 S +2 ( n –1) Average Average value

Operation flag
The operation flag does not change. HKEY

BCNT

DCNT

Execution Timing SER

MAX
AVG(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution
MIN
condition is ON.
AVG

ZRES
Scan
FIFOW
ON
Execution FIFOR
condition OFF EXT

AVG(.U/.D/.S/.L) Execution Execution

5-21
5-1 Data Processing Instructions

Sample Programs
(1) 16-bit unsigned binary data average value calculation
When input relay 00000 is ON, the average value of 16-bit unsigned binary data currently stored
to data memories DM00000 to DM00099 is calculated, and the average value is stored to
DM01000.

00000 DM00000 DM01000


AVG STA
EXTENDED INSTRUCTIONS

#00100

(2) 16-bit signed binary data average value calculation


When input relay 00000 is ON, the average value of 16-bit signed binary data currently stored
to data memories DM00000 to DM00099 is calculated, and the average value is stored to
DM01000.

00000 DM00000 DM01000


AVG.S STA.S
#00100

5
(3) 32-bit unsigned binary data average value calculation
Data Processing Instructions

When input relay 00000 is ON, the average value of 32-bit unsigned binary data currently stored
to data memories DM00000/DM00001 to DM00198/DM00199 is calculated, and the result is
stored to DM01000/DM01001.

00000 DM00000 DM01000


AVG.D STA.D
#00100

(4) 32-bit signed binary data average value calculation


When input relay 00000 is ON, the average value of 32-bit signed binary data currently stored
to data memories DM00000/DM00001 to DM00198/DM00199 is calculated, and the result is
stored to DM01000/DM01001.

00000 DM00000 DM01000


AVG.L STA.L
#00100

5-22
5-1 Data Processing Instructions

Example of instruction application


Let's assume that the average data of travel distance data (expressed as 32-bit unsigned binary
data) is calculated, and is stored to data memories DM01000/DM01001, and that the travel distance
data is currently stored to DM00000/DM00001. The latest ten data items are stored to DM00100/
DM00101 to DM00118/DM00119.
At the up edge of input relay 00000, the travel distance data is stored to data memories, and the latest
ten data items are updated. The correct value will not be calculated unless the average value is
measured for ten times or more from the start of measurement.

EXTENDED INSTRUCTIONS
"WSR Instruction" page 4-84

CR2008 DM00000
ZRES
DM00119
00000 WSR.D
DM00100 #00010 #00001

MOV.D
DM00000 DM00100

DM00100
AVG.D
DM01000
STA.D
5
#00010

Data Processing Instructions


HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-23
5-1 Data Processing Instructions Resets all values currently stored in the specified
ZRES ZRES Zone reset
range.

Ladder program Input method


Execution condition S1
ZRES Z R E S S1 S2
S2

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S1 — — — — — — — — — — — — — — —
S2 — — — — — — — — — — —

S1 : Specifies the leading device of the range to reset.

S2 : Specifies the final device of the range to reset.

Explanation of Operation
When the execution condition is ON, devices in the range specified by S1 to S2 are reset.

5 When word devices are selected


Data Processing Instructions

bit bit bit bit


15 0 15 0

S1 2048 Reset 0

S1 +1 4096 Reset 0

S1 +2 8192 Reset 0
: :

S2 –2 16384 Reset 0

S2 –1 32767 Reset 0

S2 65535 Reset 0

When bit devices are selected

When S1 : 01005 and S2 : 01011

01002: ON ON :01002
01003: ON ON :01003
01004: ON ON :01004

S1 01005: ON OFF :01005


01006: ON OFF :01006
01007: ON OFF :01007
01008: ON Reset OFF :01008
01009: ON OFF :01009
01010: ON OFF :01010
S2 01011: ON OFF :01011
01012: ON ON :01012
01013: ON ON :01013

Operation flag
The operation flag does not change.

5-24
5-1 Data Processing Instructions

Execution Timing
ZRES This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

EXTENDED INSTRUCTIONS
ZRES Execution Execution

Sample Program
When input relay 00000 is ON, data memories DM00000 to DM00099 are reset.
When 00000 is OFF, internal auxiliary relays 01000 to 01115 are reset.

00000 DM00000
ZRES
DM00099
00000 01000
ZRES
01115
5

Data Processing Instructions


HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-25
FIFOW(.U)
5-1 Data Processing Instructions FIFOW
FIFOW FIFOW.D
Write FIFO Writes data to the FIFO table.

Ladder program Input method


Execution condition FIFOW
S D F I F O W S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — — — —

S : Specifies the device currently stored with the data to write to the data block.
D : Specifies the leading device of the data table.
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation
5 About data tables and data block
The FIFOW and FIFOR instructions execute FIFO (First In First Out) processes using a group of
Data Processing Instructions

devices called a "data table." The figure below shows the structure of a data table.

bit bit
15 0

D n Number of data items: The number of data items written to the data block

max Max. number of


D +1
The maximum number of data items that can be stored to
stored data items:
Data table

D +2 A the data block (specified by user)

D +3 B Data block: The data for FIFO processing is stored.


A becomes the initially stored data, and C becomes
: the finally stored data.
D +n+1 C

As the initial settings, reset (store "0") the number of data items (n) to be stored to D . Also, set
the maximum number of stored data items to D +1.
As the leading device D of the data table, specify the same device as leading device S of
the data table for the corresponding FIFOR instruction.

FIFOW(.U) When the execution condition is ON, the 16-bit data specified at S is stored to the
end of the data block.
• The storage destination of the data becomes D + (n + 2).
• n is incremented (by 1) after storage.

bit bit bit bit


15 0 15 0

n D n+1 D
max : D +1 max : D +1
A : D +2 A : D +2
n items B : D +3 n+1 items B : D +3

bit S bit D : D D : D
15 0 + (n+1) + (n+1)
E Spare : D + (n+2) E : D + (n+2)
Spare : D + (n+3) Spare : D + (n+3)

5-26
5-1 Data Processing Instructions

FIFOW.D When the execution condition is ON, the 32-bit binary data specified by S / S +1
is stored to the end of the data block that starts with D +2.
• The storage destination of the data becomes D + n.

bit bit
31 0

D +1 : n D
D +3 : max : D +2

D +5 : A : D +4

EXTENDED INSTRUCTIONS
n items D +7 : B : D +6
:
bit
S +1 S bit
D + (2n+3) : D : D + (2n+2)
31 0

E D + (2n+5) : Spare : D + (2n+4)

D + (2n+7) : Spare : D + (2n+6)

• n is incremented (by 1) after storage.

bit bit
31 0

D +1 : n+1 D
D +3 : max : D +2 5
D +5 : A : D +4

Data Processing Instructions


D +7 : B : D +6

n+1 items :

D + (2n+3) : D : D + (2n+2)

D + (2n+5) : E : D + (2n+4)

D + (2n+7) : Spare : D + (2n+6)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
HKEY
CR2011 .......... No change in state
BCNT
CR2012 .......... ON when the maximum number of stored data items is 0, when the stored data DCNT
exceeds the maximum number of stored data items, or at a maximum number SER
of stored data items that will cause the data table to exceed the range of de- MAX
vices. Otherwise OFF.
MIN
The instruction is not executed when CR2012 has turned ON.
AVG

ZRES

FIFOW
Execution Timing
FIFOR

FIFOW(.U/.D) This instruction is executed at each scan for the duration that the execution EXT
condition is ON.

Scan
ON
Execution
condition OFF

FIFOW(.U/.D) Execution Execution

Sample Program
See the sample program for the FIFOR instruction.
"Sample Program" page 5-30

5-27
FIFOR(.U)
5-1 Data Processing Instructions FIFOR
FIFOR FIFOR.D
Read FIFO Reads data from the FIFO data table.

Ladder program Input method


Execution condition FIFOR
S D F I F O R S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S — — — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the leading device of the data table.


D : Specifies the device for storing the data that is read from the data block.
The data range that can be handled varies according to the suffix type.
"About Suffixes" page 1-28

Explanation of Operation
5 About data tables and data block
The FIFOW and FIFOR instructions execute FIFO (First In First Out) processes using a group of
Data Processing Instructions

devices called a "data table." The figure below shows the structure of a data table.
bit bit
15 0

S n Number of data items: The number of data items written to the data block

max Max. number of


S +1
The maximum number of data items that can be stored to
stored data items:
Data table

S +2 A the data block (specified by user)

S +3 B Data block: The data for FIFO processing is stored.


A becomes the initially stored data, and C becomes
: the finally stored data.
S +n+1 C

As the leading device S of the data table, specify the same device as leading device D of
the data table for the corresponding FIFOW instruction.

FIFOR(.U) (1) When the execution condition is (2) After the data is stored, the content of
ON, the 16-bit data currently the data block is pushed forward by
stored to S +2 is stored to the one data item.
device specified by D .
n is decremented (by 1) after storage.
bit bit bit bit
15 0 15 0

S n S n-1
bit bit bit bit
S +1 max 15 D 0 S +1 max 15 D 0

S +2 A S +2 B A

S +3 B S +3 C
:

S +n D S +n E

S +n+1 E S +n+1 Spare (0) Store "0".

5-28
5-1 Data Processing Instructions

FIFOR.D (1) When the execution condition is ON, the 32-bit data currently stored to S +4/
S +5 is stored to the device specified by D / D +1.

bit bit
31 0

S +1 : n : S

: S +2 bit bit
S +3 max 31 D +1 D 0

S +5 : A : S +4

S +7 : B : S +6

EXTENDED INSTRUCTIONS
S + (2n+1) : D : S + (2n)

S + (2n+3) : E : S + (2n+2)

(2) After the data is stored, the content of the data block is pushed forward by one data
item.
n is decremented (by 1) after storage.

bit bit
31 0

S +1 : n-1 : S

S +3
S +5 :
max

B
: S +2

: S +4
bit
31 D +1
A
D bit
0
5

Data Processing Instructions


S +7 : C : S +6

S + (2n+1) : E : S + (2n)

S + (2n+3) : Spare (0) : S + (2n+2)

Store "0".

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
HKEY
CR2011 .......... No change in state BCNT

CR2012 .......... ON when there is not data in the data table, when the maximum number of DCNT
stored data items exceeds the range of devices, or when the number of data SER
items is greater than the maximum number of stored data items. MAX
Otherwise OFF. MIN
The instruction is not executed when CR2012 has turned ON. AVG

ZRES

FIFOW
Execution Timing FIFOR

FIFOR(.U/.D) This instruction is executed at each scan for the duration that the execution EXT

condition is ON.

Scan
ON
Execution
condition OFF

FIFOR (.U/.D) Execution Execution

5-29
5-1 Data Processing Instructions

Sample Program

Inspection Process Discharge Process

Sensor that Sensor that Discharge output


detects defect detects discharge 00500
00001 00002
Input relay 00000: Timing input
Input relay 00001: Defect judgment input
EXTENDED INSTRUCTIONS

ON Non-defective article
OFF Defective article
Input relay 00002: Discharge confirmation input
Output relay 00002: Discharge output
Timing sensor
00000 Defective
product box

When input relay 00000 (timing input) has turned ON, #0000 is written to the data table is the item
is judged as non-defective, and #1111 is written to the data table is the item is judged as defective.
When input relay 00002 (discharge confirmation input) has turned ON, output relay turns ON for one
second if the item is judged as non-defective, and the item is discharged.
5 If 11 or more workpieces are fed in from the inspection point to the discharge point, an error is output
from 00501.
Data Processing Instructions

CR2008 #00000 #00010


DW DW
DM00100 DM00101
00000 00001 $0000 DM00000 FIFOW
LDA STA DM00000 DM00100

00001 $1111 DM00000 FIFOW


LDA STA DM00000 DM00100

00000 CR2012 00501


SET

00002 FIFOR
DM00100 DM00001

DM00001 #00100
= SHOT
$1111 00500

bit bit
15 0

DM00100:
Data content bit bit
DM00101: 10 15 0
Non-defective article: $0000: Non-defective
Data
$0000 DM00102: FIFOR DM00001 article
table
Defective article: $1111: Defective
DM00103: article
$1111
:
One-shot output
bit bit DM00105:
15 0 of 00501
DM00000 FIFOW DM00106:

5-30
5-1 Data Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Data Processing Instructions


HKEY

BCNT

DCNT

SER

MAX

MIN

AVG

ZRES

FIFOW

FIFOR

EXT

5-31
EXT(.U)
5-1 Data Processing Instructions
EXT.D
EXT EXT.S
EXT Extend data Extends the data in internal registers.

EXT.L

Ladder program Input method


Execution condition
LDA EXT STA.D E X T
EXTENDED INSTRUCTIONS

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

– — — — — — — — — — — — — — — — — — — — —

Explanation of Operation: EXT(.U) EXT.S


Extends the values of 16-bit internal registers to 32 bits. This instruction is used for addition,
subtraction, multiplication and division arithmetic operation calculations.
"ADD Instruction" page 4-28

5 "SUB Instruction" page 4-32


"MUL Instruction" page 4-36
Data Processing Instructions

"DIV Instruction" page 4-40


"ROOT Instruction" page 4-52

32-bit internal register


16-bit internal
Upper Lower
register
16-bit internal
EXT (.U/.S) TM000 register

EXT(.U) Extends 16-bit unsigned binary data currently stored to 16-bit internal registers to 32
bits.
Stores $0000 to temporary data memory TM000 and to the upper 16 bits of the 32-bit
internal register.

1234
1234 TM000 16-bit internal register

16-bit 1234
(1 word)
32-bit
(2 words)

EXT.S Extends 16-bit signed binary data currently stored to 16-bit internal registers to 32 bits.
Stores $0000 if the data is plus or $FFFF if the data is minus to temporary data memory
TM000 and to the upper 16 bits of the 32-bit internal register.

–1234
–1234 TM000 16-bit internal register

16-bit –1234
(1 word)
32-bit
(2 words)

Operation flag
The operation flag does not change.

5-32
5-1 Data Processing Instructions

Explanation of Operation: EXT.D EXT.L


Extends the values of 32-bit internal registers to 64 bits. This instruction is used for addition,
subtraction, multiplication and division arithmetic operation calculations.
"MUL Instruction" page 4-36
"DIV Instruction" page 4-40
"ROOT Instruction" page 4-52

EXTENDED INSTRUCTIONS
Upper Lower

32-bit internal register TM001 TM000 32-bit internal register

EXT (.D/.L)

EXT.D Extends 32-bit unsigned binary data currently stored to 32-bit internal register to 64
bits. Stores $00000000 to temporary data memories TM000/TM001.

TM001 TM000 32-bit internal register

12345678 12345678
32-bit 64-bit
(2 words) (4 words)

EXT.L Extends 32-bit signed binary data currently stored to 32-bit internal register to 64 bits.
5
Stores $00000000 if the data is plus or $FFFFFFFF if the data is minus to temporary

Data Processing Instructions


data memories TM000/TM001.

TM001 TM000 32-bit internal register

–12345678 –12345678
32-bit 64-bit
(2 words) (4 words)

Operation flag
The operation flag does not change.

HKEY

Execution Timing BCNT

DCNT
EXT(.U/.D/.S/.L) This instruction is executed at each scan for the duration that the execution SER
condition is ON. MAX

MIN
Scan AVG

ON ZRES
Execution
condition OFF
FIFOW

FIFOR
EXT(.U/.S) Execution Execution EXT

5-33
5-1 Data Processing Instructions

Sample Programs
The 16-bit unsigned binary data currently stored to data memory DM00000 is extended to 32 bits,
and 32-bit unsigned binary data currently stored to DM00010/DM00011 is added. The result is
stored to DM00020/DM00021.

CR2002 DM00000 DM00010 DM00020


LDA EXT ADD.D STA.D
EXTENDED INSTRUCTIONS

The 16-bit signed binary data currently stored to data memory DM00000 is extended to 32 bits, and
32-bit signed binary data currently stored to DM00010/DM00011 is added. The result is stored to
DM00020/DM00021.

CR2002 DM00000 DM00010 DM00020


LDA.S EXT.S ADD.L STA.L

5 The 32-bit unsigned binary data currently stored to data memory DM00000/DM00001 is extended
to 64 bits, and is divided by 32-bit unsigned binary data currently stored to DM00010/DM00011. The
Data Processing Instructions

quotient is stored to DM00020/DM00021, and the remainder is stored to DM00022/DM00023.

CR2002 DM00000 DM00010 DM00020


LDA.D EXT.D DIV.D STA.D

TM002 DM00022
LDA.D STA.D

5-34
5-1 Data Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Data Processing Instructions

5-35
5-2 Clock Processing Instructions

5-2 Clock Processing Instructions


Clock processing instructions are for writing the time of the calendar timer built into the PLC, and
for converting time (seconds) to hours:minutes:seconds and vice versa.

Clock Processing Instruction List


There are four clock processing instructions as follows.
EXTENDED INSTRUCTIONS

Instruction Mnemonic Brief Description of Operation Page


Write time WTIME Writes the time data to the calendar timer. 5-38

Date/time → Sec- SEC Converts date/time format data to second format 5-40
onds conversion data.
Seconds → Date/ RSEC Converts second format data to date/time format 5-42
time conversion data.
Adjust AJST Adjusts the calendar timer by ±30 seconds. 5-44

5
Clock Processing Instructions

5-36
5-2 Clock Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Clock Processing Instructions

5-37
5-2 Clock ProcessingWTIME
Instructions Write time
WTIME Writes the time data to the calendar timer.

Ladder program Input method


Execution condition S
WTIME W T I M E S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S — — — — — — — — — — — — — — — —

S : Specifies the leading device to which the time data is currently stored.

Explanation of Operation
When the execution condition is ON, the time data starting from the device specified by S is
written to the calendar timer. If the time data is inappropriate, CR2012 turns ON and the data is not
written to the calendar timer.
The calendar timer's time data is stored to control memories CM0700 to CM0706.
The following shows the format of the time data.
5 bit bit
15 0
Clock Processing Instructions

S Year 0 to 99 Indicates the lower two digits of the Western calendar year.

S +1 : Month 1 to 12

S +2 : Day 1 to 31

S +3 : Hour 0 to 23 All data is described in 16-bit binary data format.

S +4 : Minute 0 to 59

S +5 : Second 0 to 59

S +6 : Day of week 0 to 6 Day of week is expressed as 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday,


4: Thursday, 5: Friday, 6: Saturday

[Tip]
The time data can be specified using either unsigned data or signed data.

Note: The time data cannot be written directly to control memories CM0700 to CM0706.
If time data is written directly, the time will be overwritten by the system, and written values
will be invalidated.

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to be written is inappropriate as time data. Otherwise OFF.
The instruction is not executed when CR2012 has turned ON.

5-38
5-2 Clock Processing Instructions

Execution Timing
WTIME This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

EXTENDED INSTRUCTIONS
WTIME Execution Execution

Sample Program
At the up edge of input relay 00000, the time data currently stored to data memories DM00000 to
DM00006 is written to the calendar timer.
(The time data of DM00000 to DM00006 is written from the access window or touch panel.)

00000 DM00000
WTIME 5

Clock Processing Instructions


WTIME

SEC

RSEC

AJST

5-39
SEC
5-2 Clock Processing Instructions Date/time → Converts date/time format data to second
SEC Seconds conversion format data.

Ladder program Input method


Execution condition SEC
S D S E C S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the leading device to which the time data is currently stored.
D : Specifies the leading device to which the data after conversion to second format data is to
be stored.

Explanation of Operation
When the execution condition is ON, the six words of date/time data starting from the device
specified by S is converted to seconds referenced to "year 2000, January 1st, 0:0:0", and is
5 written to D / D +1 as two words (32-bit unsigned binary data).
Clock Processing Instructions

bit bit bit bit bit bit


15 0 31 D +1 16 15 D 0

S Year 0 to 99 Seconds conversion Second

S +1 : Month 1 to 12 2 words (32-bit)

S +2 : Day 1 to 31 32-bit unsigned binary data


S +3 : Hour 0 to 23

S +4 : Minute 0 to 59

S +5 : Second 0 to 59

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to be written is inappropriate as date/time data. Otherwise OFF.
The instruction is not executed when CR2012 has turned ON.

Execution Timing
SEC This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

SEC Execution Execution

5-40
5-2 Clock Processing Instructions

Sample Program
See the sample program for the RSEC instruction.
"Sample Program" page 5-43

EXTENDED INSTRUCTIONS
5

Clock Processing Instructions


WTIME

SEC

RSEC

AJST

5-41
RSEC
5-2 Clock Processing Instructions Seconds → Converts second format data to date/time
RSEC Date/time conversion format data.

Ladder program Input method


Execution condition RSEC
S D R S E C S D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

S — — — — — — — — — — — — — — — —
D — — — — — — — — — — — — —

S : Specifies the leading device to which the second data is currently stored.
D : Specifies the leading device to which the data after conversion to date/time format data is
to be stored.

Explanation of Operation
When the execution condition is ON, the second data (32-bit unsigned binary data) currently stored
to the device specified by S is converted to date/time data referenced to "year 2000, January
5 1st, 0:0:0". The result is stored to D onwards.
Clock Processing Instructions

bit bit bit bit bit bit


31 S +1 16 15 S 0 15 0

Second Seconds conversion Year : D (0 to 99)


2 words (32-bit) Month : D +1 (1 to 12)
Day : D +2 (1 to 31)
Hour : D +3 (0 to 23)
Minute : D +4 (0 to 59)
Second : D +5 (0 to 59)

Operation flag
CR2009 .......... No change in state
CR2010 .......... No change in state
CR2011 .......... No change in state
CR2012 .......... ON when the data to be written is inappropriate as date/time data. Otherwise OFF.
The instruction is not executed when CR2012 has turned ON.

Execution Timing
RSEC This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

RSEC Execution Execution

5-42
5-2 Clock Processing Instructions

Sample Program
Output the expiry date from the date of production. Let's assume that the expiry date is 30 days
(2592000 seconds) from the production date.
The result is stored to DM00100 onwards.

CR2002 SEC
CM00700 DM00000

EXTENDED INSTRUCTIONS
DM00000 #2592000 DM00010
LDA ADD.D STA.D

RSEC
DM00010 D00100

bit bit
15 0

CM00700: 00 Year 00 DM00100: 01 Year 01


CM00701: 12 December DM00101: 01 January
5
CM00702: 20 20th DM00102: 19 19th

Clock Processing Instructions


CM00703: 10 10 o'clock After 30 days DM00103: 10 10 o'clock

CM00704: 10 10 mins DM00104: 10 10 mins

CM00705: 10 10 seconds DM00105: 10 10 seconds

WTIME

SEC

RSEC

AJST

5-43
5-2 Clock ProcessingAJST
Instructions Adjust
AJST Adjusts the calendar timer by ±30 seconds.

Ladder program Input method


Execution condition
AJST A J S T

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

– — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
Sets the "seconds" setting to "0" when the "seconds" setting of the current time of the KV-700's built-
in calendar timer is 0 to 29. When the "seconds" setting is 3 to 59 seconds, the "minutes" setting is
rounded up and the "seconds" setting is set to "0". The time data of the calendar timer is currently
stored to control memories CM00700 to CM00706.

Operation flag
5 The operation flag does not change.
Clock Processing Instructions

Execution Timing
AJST This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

AJST Execution Execution

Sample Program
The calendar timer is adjusted by ±30 seconds at the up edge of input relay 00000.

00000
AJST

Before execution After execution


12:59:15 12:59:00
12:59:30 13:00:00

5-44
5-2 Clock Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Clock Processing Instructions


WTIME

SEC

RSEC

AJST

5-45
5-3 Alarm Instruction

5-3 Alarm Instruction


The state of the alarm relay can be monitored in real time or the alarm history can be confirmed in
the access window.

Alarm Instruction List


There is one alarm instruction as follows.
EXTENDED INSTRUCTIONS

Instruction Mnemonic Brief Description of Operation Page


Alarm relay reset ARES Resets currently operating alarm relays and the alarm 5-48
history.

5
Alarm Instruction

5-46
5-3 Alarm Instruction

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Alarm Instruction

5-47
5-3 Alarm Instruction ARES Resets currently operating alarm relays and the
ARES Alarm relay reset
alarm history.

Ladder program Input method


Execution condition
ARES A R E S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

– — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
Resets currently operating alarm relays and the alarm history.

Operation flag
The operation flag does not change.

5 Execution Timing
Alarm Instruction

ARES This instruction is executed at each scan for the duration that the execution condition
is ON.

5-48
5-3 Alarm Instruction

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Alarm Instruction
ARES

5-49
5-4 High-speed Processing Instructions

5-4 High-speed Processing Instructions

High-speed Processing Instruction List


There are seven high-speed processing instructions as follows.

Instruction Mnemonic Brief Description of Operation Page


EXTENDED INSTRUCTIONS

High-speed HSP Reduces the time constant of the input relay to speed up 5-52
input response.
Disable interrupt DI Disables execution of the interrupt program. 5-54

Enable interrupt EI Enables execution of the interrupt program.

Interrupt INT Executes the interrupt program from the INT to the 5-56
RETI instructions.
Return interrupt RETI Indicates the end of the interrupt program.

High-speed CTH Executes operation of the response frequency 40 kHz 5-68


counter (single-phase) and 30 kHz (2-phase) 32-bit (0 to
5 High-speed CTC 4294967295) addition/subtraction counters.
counter
High-speed Processing Instructions

comparator

5-50
5-4 High-speed Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

High-speed Processing Instructions

5-51
HSP
5-4 High-speed Processing InstructionsHigh-speed Reduces the time constant of the input
HSP relay to speed up input response.

Ladder program Input method


Execution condition HSP
D H S P D

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
EXTENDED INSTRUCTIONS

D — — — — — — — — — — — — — — — — — — —

D : Specifies the device No. of the relay for reducing the input time constant.
Available relays are 00000 to 00009.

Explanation of Operation
When the execution condition is ON, the input time constant of the device specified by D is set
to 10 µs.
Be sure to set this instruction when using the INT and CTH instructions.

5
Note: When an input time constant setting using control relay CR2305 and an input time constant
High-speed Processing Instructions

using the HSP instruction are programmed together, the HSP instruction is given priority.

• For details on how to change the input time constant of the CPU Unit, refer to KV-700 User's
Manual "Input Time Constant Selection Function."
• For details on how to change the input time constant of the Expansion Input Unit, refer to KV-700
User's Manual "Input Time Constant Selection Function."

Operation flag
The operation flag does not change.

Execution Timing
HSP This instruction is executed at each scan for the duration that the execution condition
is ON.

Scan
ON
Execution
condition OFF

HSP Execution Execution

5-52
5-4 High-speed Processing Instructions

Sample Program
Set the input time constant of input relay 00000 to 10 µs.

CR2002 HSP
00000

EXTENDED INSTRUCTIONS
5

High-speed Processing Instructions


HSP

DI

EI

INT

RETI

CTH

CTC

5-53
5-4 High-speed Processing Instructions
DI EI Disable interrupt Disables execution of the interrupt program.

EI DI Enable interrupt Enables execution of the interrupt program.

Ladder program Input method


Execution condition
EI E I

Execution condition
EXTENDED INSTRUCTIONS

DI D I

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
DI When the execution condition is ON, execution of the interrupt program is disabled.

5 This instruction is used to temporarily disable interrupt.


High-speed Processing Instructions

EI When the execution condition is ON, execution of the interrupt program is enabled.
The interrupt program disabled by the DI instruction is enabled (disable canceled).

• Once the EI instruction is executed, interrupts up to execution of the DI instruction are enabled.
• Interrupts are disabled at all times when operation is started.
• Up to eight interrupts can be stored if they occur during execution of the DI instruction (interrupts
are disabled).
When the EI instruction is executed, interrupts stored to memory are executed. Note, however,
that even if interrupts caused by the CTC instruction are stored to memory, the interrupts are
deleted from memory if CTC is reset during that time.
• To execute another interrupt program while an interrupt program is being executed, execute the
EI instruction in the interrupt program. The sequence program accepts nesting of interrupt
programs down to a nesting level of four.
"About the Interrupt Function" page 5-57

Operation flag
The operation flag does not change.

Execution Timing
EI, DI This instruction is executed at the up edge of the execution condition.

Scan
ON
Execution
condition OFF

EI, DI Execution Execution

5-54
5-4 High-speed Processing Instructions

Sample Program
When input relay 00000 is ON, execution of the interrupt program is disabled.
When input relay 00000 is OFF, execution of the interrupt program is enabled.

00000
DI

EXTENDED INSTRUCTIONS
00000
EI

High-speed Processing Instructions


HSP

DI

EI

INT

RETI

CTH

CTC

5-55
INT The interrupt program is executed up to RETI at the
5-4 High-speed Processing Instructions
INT Interrupt
up edge or down edge of the operand.
RET
RETI Return interrupt Indicates the end of the interrupt program.

Ladder program Input method


Execution condition INT
S I N T S
( I S )

Interrupt program
EXTENDED INSTRUCTIONS

RETI
R E T I
( I R E T )

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — —

S : Specifies the device to be used as the execution condition.

Explanation of Operation
5
INT Specifies the start of the interrupt routine.
High-speed Processing Instructions

RETI Specifies the end of the interrupt routine.

Operation flag
The operation flag does not change.

Execution Timing
INT, RETI These instructions are executed once when an interrupt cause is generated.

Scan

Generation of interrupt cause! Generation of interrupt cause!


Interrupt cause

INT, RETI Execution Execution

Sample Program

CR2008
EI
END

INT
00000
CR2002 00500
SET
RETI

ENDH

5-56
5-4 High-speed Processing Instructions

About the Interrupt Function


■ Interrupt function
The interrupt function is used to load short signals, to increase input response or to measure time
to high precision. When an interrupt cause (external input or high-speed counter comparator) is
generated, the interrupt program is executed immediately regardless of scan processing.
"Scan processing" is the process "input processing → program execution → output
processing." The PLC execute the main routine program by repeating this processing.

EXTENDED INSTRUCTIONS
Scan processing is discontinued while the interrupt program is executed. When the interrupt
program ends, the scan processing is resumed from where it was discontinued.
KV-700 User's Manual "About Scan Time"

Generation of interrupt cause

Output Input Output Input


process- process- Main routine program process- process-
ing ing ing ing

5
Input

High-speed Processing Instructions


process- Interrupt program
ing

Direct input Direct output


00000 to 00009 00500 to 00503

The interrupt program is executed once when an interrupt is generated.


The interrupt program is processed in order "input processing → program processing."

Interrupt program input processing: The relays (00000 to 00009) to which direct input is HSP
enabled and high-speed counters CTH are refreshed DI
(information is updated). With other devices, the EI
information of input processing at the scan that the INT
interrupt was input is held. RETI

Interrupt program output processing: The relays (00500 to 00503) to which direct input is CTH
enabled are output at all times during program execu- CTC
tion. Other output relays wait for output processing at
the scan that the interrupt was input before they are
output after the interrupt program ends.
"About direct input" page 5-60
"About direct output" page 5-61

[Tip]
When execution of the interrupt program starts, the values of internal registers, input relays
00000 to 00009, operation flags TM000 to TM003 are stored on the system. When execution of
the interrupt program ends, the memorized values are overwritten. The values of these devices
do not affect the main routine even if they are changed during execution of the interrupt program.
New values after a change are valid only during execution of the interrupt program.
The main routine is affected if the values of other devices are changed during execution of the
interrupt program.

5-57
5-4 High-speed Processing Instructions

■ Interrupt program execution conditions


The interrupt program is defined between the INT and RETI instructions.
The interrupt program is executed when an interrupt cause is generated and the INT instruction
is executed.
The interrupt cause is specified by the operand of the INT instruction.
When the interrupt cause is an input relay, the input time constant must be set to a small value
to increase the response speed.
EXTENDED INSTRUCTIONS

Disabling of interrupts is defined by the DI instruction, while enabling of interrupts is defined by


the EI instruction. Interrupts are disabled at start of operation.

EI

Main routine program

END

5 INT
00000
Interrupt program
High-speed Processing Instructions

RETI
KV-700 User's Manual "Input Time Con-
stant Selection Function"
ENDH
"INT Instruction" page 5-56
"EI, DI Instruction" page 5-54

Types of Interrupt Causes


There are two types of interrupt causes, external inputs and high-speed counter comparators.

With interrupts caused by external inputs, the INT instruction is executed at the up edge or down
edge of input relays (00000 to 00003). Up edge/down edge is set in control relays.

With interrupts caused by high-speed counter comparators, the INT instruction is executed
when the setting value of high-speed counter comparators matches the current value of high-speed
counters CTH.

Interrupts caused by external inputs


INT Interrupt Control Operation Conditions
Instruction Cause Input Relay Both up/down
Relay Up edge Down edge edges
INT0 00000 CR2700 OFF ON OFF ON
CR2701 OFF OFF ON ON
INT1 00001 CR2702 OFF ON OFF ON
CR2703 OFF OFF ON ON
INT2 00002 CR2704 OFF ON OFF ON
CR2705 OFF OFF ON ON
INT3 00003 CR2706 OFF ON OFF ON
CR2707 OFF OFF ON ON

5-58
5-4 High-speed Processing Instructions

Interrupts caused high-speed counter comparators

INT Instruction Interrupt Cause High- Operation Conditions


speed Counter Comparator
INT CTC0 CTC0 When setting value of high-speed counter compara-
tor CTC0 matches the current value
INT CTC1 CTC1 When setting value of high-speed counter compara-
tor CTC1 matches the current value
INT CTC2 CTC2 When setting value of high-speed counter compara-

EXTENDED INSTRUCTIONS
tor CTC2 matches the current value
INT CTC3 CTC3 When setting value of high-speed counter compara-
tor CTC3 matches the current value

■ Precautions when multiple interrupt causes are generated


Interrupt programs are executed in the order that interrupt causes are generated.
When a new interrupt cause is generated during execution of an interrupt program, that interrupt
cause is stored to memory. Note, however, that causes the same as the currently executing
interrupt program are not stored to memory.
When execution of the currently executing interrupt program ends, the interrupt program for the
cause that is stored to memory is executed.
5

High-speed Processing Instructions


When multiple interrupt causes are stored to memory, the interrupt programs are executed in the
following order. Note that this order is not the order in which they were stored to memory.

INT00000 > INT00001 > INT00002 > INT00003 > INT CTC2 > INT CTC3 > INT CTC0 > INT CTC1

When the EI instruction is programmed in an interrupt program, interrupts can be nested (an
interrupt within an interrupt). Note, however, that interrupts having the same interrupt cause
cannot be nested.
HSP

DI

EI

INT

RETI

CTH

CTC

5-59
5-4 High-speed Processing Instructions

Direct Input/Output
■ About direct input
"Direct input/output" is a function for loading the state of input relays (00000 to 00009) during
interrupt program execution. Input relays other than these adopt a state acquired by input
processing of that scan also during execution of the interrupt program.
The state acquired by direct input is valid only during execution of the interrupt program, and is
invalid by the main routine program. In the main routine program, the state of input processing
EXTENDED INSTRUCTIONS

at that scan is valid.

[Example]

Generation of interrupt cause

ON

00000
OFF
ON

00001
OFF
ON

5 30000
OFF

00001: OFF 00001: ON


High-speed Processing Instructions

30000: OFF 30000: ON

Output Input Output Input


process- process- Main routine program process- process-
ing ing ing ing

Input
process- Interrupt program
ing

00001: ON
30000: OFF

00001 00001 00001 00001

OFF ON OFF ON

30000 30000 30000 30000

OFF OFF OFF ON

When the above interrupt program is executed,


(1) Input processing of the main routine program → 00001: OFF, 30000: OFF
(2) Input processing of the interrupt program → 00001: ON, 30000: OFF

As input relay 00001 is direct input, the state during execution of the interrupt program is loaded.
Input relay 30000 is handled as the state of input processing of the main routine program even
in the interrupt program.
Direct input is valid only in the interrupt program.
In the main routine program, input relay 00001 is in an OFF state regardless of whether the relay
is before or after execution of the interrupt program.
Input relay 00001 is in an ON state only during the interrupt program.

5-60
5-4 High-speed Processing Instructions

■ About direct output


"Direct output" is a function for outputting the state of output relays 00500 to 00503 during
execution of the interrupt program. With the interrupt program, there is no output processing.
When the program is executed, the states of output relays 00500 to 00503 are output
immediately without waiting for output processing. Output relays other than direct output are
output by output processing of the main routine program after execution of the interrupt program
ends.
Program direct output by the SET instruction. When direct output is programmed by the OUT or

EXTENDED INSTRUCTIONS
STA instruction, output relays are output by output processing of the main routine program.

[Example]
00501: Output
30500: Output

Output Input Output Input


process- process- Main routine program process- process-
ing ing ing ing

Input
process- (1) (2) (3) (4)
ing

00500: Output 00502: Output


5

High-speed Processing Instructions


CR2002 00500
(1) SET

CR2002 00501
(2)

CR2002 00502
(3) SET

CR2002 30500
(4) SET

When the above interrupt program is executed,


HSP
• At rung (1), output relay 00500 is immediately output as it is a direct output relay.
DI
• At rung (2), output relay 00501 is a direct output relay. However, as it is programmed by the
EI
OUT instruction, it is output by output processing of the main routine program.
INT
• At rung (3), output relay 00502 is immediately output as it is a direct output relay. RETI

• At rung (4), output 30500 turns ON by internal processing. However, as it is not a direct output CTH

relay, it is output by output processing of the main routine program. CTC

5-61
5-4 High-speed Processing Instructions

Input Capture Function


Input capture is a function for acquiring the current value of high-speed counters to data memory
when an interrupt cause is generated.
Input capture functions when the interrupt cause is an external input. This function needs not to be
set for use.
Acquired values are stored to control memories CM1610 to CM1617.
EXTENDED INSTRUCTIONS

Interrupt Cause High-speed Counter for Storage Destination


External Input Capturing Current Value Upper Lower
INT 00000 CTH0 CM1611 CM1610
INT 00001 CTH0 CM1613 CM1612
INT 00002 CTH1 CM1615 CM1614
INT 00003 CTH1 CM1617 CM1616

About differences between the input capture function and the current value of high-speed
counters during interrupt programs

5
• The input capture function captures the value at the moment that the interrupt cause is generated
High-speed Processing Instructions

(not reliant on scan time).


• The value of high-speed counters that capture by the LDA or MOV instruction during the interrupt
program is the value that is acquired by input processing of the interrupt program.
A difference occurs in the values that are captured in the following instance.

Generation of interrupt cause


(External input) EI instruction execution
Time difference

Scan Interrupt prohibited Interrupt enabled

Current value of
high-speed counter CTH0 ...... 10 11 12 ............. 99 100 101 ............................ 999 1000 1001
Input capture function Interrupt program
Input CTH0
process- LDA STA
ing

(1) (2)
100 1000

(1) As the input capture function captures the value at the moment that the interrupt cause is
generated (not reliant on scan time), the current value of high-speed counter CTH0 becomes
#00100.
(2) As the value acquired by the interrupt program is the value acquired by input processing of the
interrupt program, the current value of high-speed counter CTH0 to be acquired becomes
#01000.
As shown above, when an error in the time occurs from when an interrupt cause is generated up to
execution of the interrupt program, an error occurs in the current value of the high-speed counter
to be acquired.

5-62
5-4 High-speed Processing Instructions

Sample Program
■ Example of application of an interrupt using a signal converter
A minute pulse is converted to a pulse of fixed width and output using interrupt processing.
• The minute pulse that is input by input relay 00000 is converted to a pulse having an ON width
of one second from output relay 00500.
• Output relay 00500 turns ON for one second from the up edge of input relay 00000.

EXTENDED INSTRUCTIONS
Scan
ON

Input relay 00000


OFF

ON

Output relay 00500 ON ON ON


OFF
1 sec. 1 sec. 1 sec.

CR2008
EI The interrupt is enabled at power ON.

CR2002 HSP
The input time constant of input relay 00000
5
00000
is set to 10 µs.

High-speed Processing Instructions


00500 #00010 T000 00500
Output relay 00500 turns ON for one second
T000 RES
only.

END

INT When input relay 00000 turns ON, output


00000 00500 turns ON.

CR2002 00500
SET
HSP
RETI DI

EI

INT
ENDH
RETI

CTH

CTC

5-63
5-4 High-speed Processing Instructions

■ Example of application of an interrupt using a high-speed counter


Output relay 00500 ON/OFF is controlled by input relay ON/
OFF and the input value of the high-speed counter.
• When the high-speed counter input value from input relay
00004 becomes #10000, output relay 00500 turns ON.
• When input relay 00000 turns ON, output relay 00500
turns OFF.
EXTENDED INSTRUCTIONS

Scan
ON

Input relay 00004


OFF

ON

Input relay 00000


OFF

ON

Output relay 00500 ON


5 OFF
High-speed Processing Instructions

CR2008 CR2103 CTH0 At power ON, interrupt is enabled, automatic


EI SET RES reset of high-speed counter CTH0 is set,
and reset is applied.
CR2002 HSP
The input time constant of input relay 00004
00004
is set to 10 µs.

CR2002 CTH0
00004 The high-speed counter of input relay 00004
is set to CTH0, and the setting value is set to
#10000 #10000.
CTC0

00000 00500
When input relay 00000 turns ON, output
RES
00500 turns OFF.

END

INT
CTC0 When the value of high-speed counter com-
parator CTC0 becomes #10000, the inter-
rupt program is executed, and output relay
CR2002 00500
SET 00500 turns ON.

RETI

ENDH

5-64
5-4 High-speed Processing Instructions

■ Example of application of high-speed pulse ON width measurement


The width of the pulse entering an input relay is measured.

ON

Input relay 00000


OFF
Pulse width

EXTENDED INSTRUCTIONS
• Control relay CR2100 is used to measure the pulse width in 1 µs units.
• The input capture value (CM1610/CM1611) when input relay 00000 is ON, is stored to data
memory DM00010/DM00011.
The value of DM00010/DM00011 is subtracted from the input capture value when 00000 is
OFF.
This value becomes the pulse width.
• The measured value is stored to data memory DM00000/DM00001 in 1 µs units.

CR2008
EI
The interrupt is enabled at power ON.
5

High-speed Processing Instructions


CR2002 HSP The input time constant of input relay 00000
00000 is set to 10 µs.

CR2002 CTH0
CR2100 The 1 µs internal clock is counted by high-
speed counter CTH0.
END

INT
00000 The interrupt is executed at input relay 00000.
First, the interrupt is executed at the up edge
CR2701 CM1610 DM00010 KEEP of input relay 00000, and the current value
LDA.D STA.D SET (CM1610/CM1611) at that time is stored to HSP
DM00010/DM00011, and the interrupt po- DI
CR2701
larity is changed to down edge by turning
CR2701 CM1610 DM00010 DM00000 EI
CR2701 ON.
LDA.D SUB.D STA.D RES
INT
Next, the interrupt is executed by the down
RETI
edge of input relay 00000, and the pulse
RETI width of input relay 00000 is calculated by CTH
subtracting DM00010/DM00011 at the up CTC
edge from the current value (CM1610/
ENDH CM1611) at that time. The result is stored to
DM00000/DM00001.
Finally, CR2701 is turned OFF to change
the interrupt polarity to up edge.

5-65
5-4 High-speed Processing Instructions

■ Example of application of passage time measurement between two points

The passage time between two input relays is


measured. Sensor 1

Sensor 1 ON
Sensor 2
Input relay 00002
OFF
EXTENDED INSTRUCTIONS

Sensor 2 ON

Input relay 00003


OFF
Elapsed time (µs)

• The passage time from input relay 00002 up to input relay 00003 is measured.
• The measured value is stored to data memory DM00000/DM00001 in 1 µs units.
CR2008 CR2704 CR2705 CR2706 CR2707
EI RES RES RES RES At power ON, interrupt is enabled, and the
interrupt polarity of input relays 00002 and
CR2002 HSP 00003 is set to up edge.
00002
5 The input time constant of input relay
00002 is set to 10 µs.
HSP
High-speed Processing Instructions

00003
The input time constant of input relay 00003
is set to 10 µs.
CR2002 CTH1
CR2200 The 1 µs internal clock is counted by high-
speed counter CTH1.
END

INT
00002
When INT00002 is executed, the current
RETI value of CTH1 is automatically stored (by
input capture) to CM1614/CM1615.

INT
00003
When INT00003 is executed, the current
value of CTH1 is automatically stored (by
CR2002 CM1616 CM1614 DM00000 input capture) to CM1616/CM1617.
LDA.D SUB.D STA.D
The passage time between the two points is
calculated by subtracting the input capture
RETI value of INT00002 from the input capture
value of INT00003.
The result is stored to DM00000/DM00001.
ENDH

5-66
5-4 High-speed Processing Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

High-speed Processing Instructions


HSP

DI

EI

INT

RETI

CTH

CTC

5-67
CTH
5-4 High-speed Processing Instructions Executes operation of response
CTH 32-bit high-speed counter
frequency 50 kHz 32-bit (0 to
4294967295) addition/subtraction
CTC CTC High-speed counter comparator counters.

Ladder program Input method


CR2002 HSP
S
Execution condition CTH n C T H n S
S
EXTENDED INSTRUCTIONS

S
CTC n C T C n S

CTC n

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

CTH n — — — — — — — — — — — — — — — — — — —
S — — — — — — — — — — — — —
CTC n — — — — — — — — — — — — — — —
5 S — — — — — — — — — — — — — — —
High-speed Processing Instructions

CTH n : Specifies the counter No. as 0 or 1.


S : Specifies count input.
CTC n : Specifies the comparator No. as 0 to 3.
S : Specifies the setting value of the high-speed counter within the range 0 to 4294967295.

Explanation of Operation
CTH When the execution condition is ON, the device specified by S is counted.
When the execution condition is OFF, the count value is cleared.
When an external input (00004, 00005) is counted, the input time constant must be
reduced.
KV-700 User's Manual "About the Input Time Constant"
"HSP Instruction" page 5-52
CTC Turns ON when the setting value specified by S matches the current value of the
high-speed counter.

With the high-speed counter function, set the count method or reset method in control relays CR and
data memory DM. Read the description for the respective setting item.
"Outline of High-speed Counters" page 5-69
"High-speed Counter Specifications" page 5-72
"Setting Count Input" page 5-75
"Reset Method" page 5-78
"Comparator Match Output" page 5-81
"Preset Function" page 5-80
"Ring Counter Function" page 5-82
"High-speed counter application example" page 5-84

5-68
5-4 High-speed Processing Instructions

Execution Timing
CTH This instruction is executed at each scan for the duration that the execution condition
is ON.
CTC This instruction is executed at each scan during high-speed counter operation.

Scan

EXTENDED INSTRUCTIONS
ON
Execution
condition OFF

CTH Execution Execution

CTC

Outline of High-speed Counters


High-speed counters, high-speed counter comparators
High-speed counters are counters (response frequency (40 kHz/single-phase, 30 kHz/2-phase (at
24 V))) for measuring high-speed signals that cannot be measured by counter instructions C and 5
UDC. High-speed counter comparators are devices for specifying the setting values of high-speed

High-speed Processing Instructions


counters, and turn ON when the setting value matches the current value. As high-speed counters
are processed in the hardware, they can operate at high speed independent of the scan.

■ Configuration of high-speed counters, high-speed comparators


The KV-700 series is provided with two high-speed counters, and high-speed comparators and
exclusive internal clocks for each of these high-speed counters.

High-speed counter block diagram

Preset input 00008


HSP
32-bit high-speed CTH0 input capture *1
Count input function DI
counter 0
A phase 00004 External input CM1610, CM1611 (INT00000)
CTH0 EI
(B phase 00006) 00004 CM1612, CM1613 (INT00001)
(00006) INT
Internal clock RETI
CR2100 (1.0 µs) Control circuit 2
00500 *
CR2101 (10.0 µs) CH0 setting value CTH
CR2102 (100.0 µs) High-speed counter (direct clock pulse)
Direct clock pulse input comparator Interrupt function CTC
00501 (internally wired) CTC0 INT CTC0
CTC1 INT CTC1

32-bit high-speed CTH1 input capture *1


Count input function
counter 1
Direct clock pulse input CM1614, CM1615 (INT00002)
CTH1
00500 (internally wired) CM1616, CM1617 (INT00003)

Internal clock 2
CR2200 (1.0 µs) 00501 *
CR2201 (10.0 µs) Control circuit
(direct clock pulse)
CR2202 (100.0 µs) CTH1 setting value
High-speed counter
A phase 00005 External input comparator Interrupt function
00005 CTC2
(B phase 00007) INT CTC2
(00007) CTC3 INT CTC3

Preset input 00009

*1 "Input Capture Function" page 5-62


*2 KV-700 User's Manual "Direct Clock Pulse Output"

5-69
5-4 High-speed Processing Instructions

List of control devices for CTH0


Relay No. Description ON OFF
CR2100 CTH0 dedicated internal clock (1.0 µs) — —
CR2101 CTH0 dedicated internal clock (10.0 µs) — —
CR2102 CTH0 dedicated internal clock (100.0 µs) — —
CR2103 When CTC0 is ON, CTH0 auto clear Execute. Do not execute.
CR2104 When CTC0 is ON, direct output (00500) Disable output. Enable output.
EXTENDED INSTRUCTIONS

CR2105 When CTC0 is ON, direct output (00500) OFF Execute. Do not execute.
CR2106 When CTC0 is ON, direct output (00500) ON Execute. Do not execute.
CR2107 When CTC0 is ON, direct output (00500) ON/OFF reversal Execute. Do not execute.
CR2108 When CTC1 is ON, direct output (00500) Disable output. Enable output.
CR2109 When CTC1 is ON, direct output (00500) OFF Execute. Do not execute.
CR2110 When CTC1 is ON, direct output (00500) ON Execute. Do not execute.
CR2111 When CTC1 is ON, direct output (00500) ON/OFF reversal Execute. Do not execute.
CR2112 When CTC1 is ON, CTH0 auto clear Execute. Do not execute.

Single-phase, Single-phase, 1X 2X 4X 2 pulses


W/out direction W/ direction

5 CR2113
CR2114
CTH0 count input method
selection
OFF
OFF
ON
OFF
OFF
ON
ON
ON
OFF
OFF OFF
ON
High-speed Processing Instructions

CR2115 OFF OFF OFF OFF ON ON

Unused Up edge Down edge Level


CR2400 External signal preset OFF ON OFF ON
CR2401 OFF OFF ON ON

At ON At OFF
CR2402 Ring counter use by CTH0 Execute. Do not execute.

Device No. Description


CM1600 CTH0 ring counter upper limit value (lower)
CM1601 CTH0 ring counter upper limit value (upper)
CM1604 CTH0 preset input value (lower)
CM1605 CTH0 preset input value (upper)

[Tip]
The initial state of CR2104 and CR2108 is ON. Otherwise, these devices are OFF.

Note: To turn a control relay ON, use the SET instruction. To turn a control relay OFF, use the RES
instruction.

5-70
5-4 High-speed Processing Instructions

List of control devices for CTH1


Relay No. Description ON OFF
CR2200 CTH1 dedicated internal clock (1.0 µs) — —
CR2201 CTH1 dedicated internal clock (10.0 µs) — —
CR2202 CTH1 dedicated internal clock (100.0 µs) — —
CR2203 When CTC2 is ON, CTH1 auto clear Execute. Do not execute.
CR2204 When CTC2 is ON, direct output (00501) Disable output. Enable output.

EXTENDED INSTRUCTIONS
CR2205 When CTC2 is ON, direct output (00501) OFF Execute. Do not execute.
CR2206 When CTC2 is ON, direct output (00501) ON Execute. Do not execute.
CR2207 When CTC2 is ON, direct output (00501) ON/OFF reversal Execute. Do not execute.
CR2208 When CTC3 is ON, direct output (00500) Disable output. Enable output.
CR2209 When CTC3 is ON, direct output (00500) OFF Execute. Do not execute.
CR2210 When CTC3 is ON, direct output (00500) ON Execute. Do not execute.
CR2211 When CTC3 is ON, direct output (00500) ON/OFF reversal Execute. Do not execute.
CR2212 When CTC3 is ON, CTH1 auto clear Execute. Do not execute.

Single-phase, Single-phase, 1X 2X 4X 2 pulses


W/out direction W/ direction
CR2213
CR2214
CTH1 count input method
selection
OFF
OFF
ON
OFF
OFF
ON
ON
ON
OFF
OFF
ON
OFF
5

High-speed Processing Instructions


CR2215 OFF OFF OFF OFF ON ON

Unused Up edge Down edge Level


CR2404 External signal preset OFF ON OFF ON
CR2405 OFF OFF ON ON

At ON At OFF
CR2404 Ring counter use by CTH1 Execute. Do not execute.

Device No. Description


CM1602 CTH1 ring counter upper limit value (lower)
CM1603 CTH1 ring counter upper limit value (upper)
HSP
CM1606 CTH1 preset input value (lower)
DI
CM1607 CTH1 preset input value (upper) EI

INT

RETI
[Tip] CTH

The initial state of CR2204 and CR2208 is ON. Otherwise, these devices are OFF. CTC

Note: To turn a control relay ON, use the SET instruction. To turn a control relay OFF, use the RES
instruction.

5-71
5-4 High-speed Processing Instructions

High-speed Counter Specifications


■ Specifications
Setting value range: 32 bits (0 to 4294967295)
Response frequency: 40 kHz/single-phase (at 24 V), 30 kHz/2-phase (at 24 V)
Pulse input system: 2-phase (phase difference) input possible
Number of channels: 2
EXTENDED INSTRUCTIONS

■ Count input types


High-speed counters have the following three count inputs. The input to count is specified as the
operand.
(1) External input

A phase B phase
CTH0 00004 00006
CTH1 00005 00007

Short externally input signals are counted. Single-phase, phase difference and 2-pulse can be
5 input.
The count method is set by control relays.
High-speed Processing Instructions

"Setting Count Input" page 5-75


[Example]
CTH0
Count of external input 00004 00004

(2) Internal clock input

1.0 µs 10.0 µs 100.0 µs


CTH0 CR2100 CR2101 CR2102
CTH1 CR2200 CR2201 CR2202

The internal clock is counted. As the time can be measured from the count value, this input can
be used as a high-precision timer.
[Example]
CTH0
Count of internal clock (1.0 µs) by CTH0 CR2100

(3) Direct clock pulse input


Direct Clock Pulse
CTH0 00501
CTH1 00500

Pulses output by the direct clock pulse function can be counted without being wired externally.
See CPU Hardware Manual "Direct Clock Pulse Output."
[Example]
CTH0
Count of direct clock pulse from 00501 00501

5-72
5-4 High-speed Processing Instructions

■ Current value (CTH)


The current values of the high-speed counters are stored in CTH0 and CTH1, respectively.
When the value has increased beyond 4294967295, the counter overflows, and when the value
has fallen below 0, the counter underflows. Counter values are held even if a power interruption
occurs. To clear current values set MEMSW.
"MEMSW Instruction" page 3-6

EXTENDED INSTRUCTIONS
■ Setting value (CTC)
The setting values of high-speed counters are set in high-speed counter comparators CTC0 to
CTC3.
Setting values can be set within the range 0 to 4294967295. A CTC turns ON when the setting
value matches the current value.
Set CTC OFF by the RES instruction. Setting values are automatically reset when an interrupt
is applied by CTC.

Setting Value
CTH0 CTC0

CTH1
CTC1
CTC2
5

High-speed Processing Instructions


CTC3

[Example] CTH0
00004
Setting of CTC0 and CTC1
#00100
CTC 0

#100000
CTC 1

Note: CTCs do not turn ON when the current value is rewritten with the same value as the CTC
HSP
by the current value being changed.
DI
CTCs turn ON only when the current value has equaled CTC after a count up or count
EI
down.
INT

RETI

CTH
■ Reading/changing current values, rewriting setting values
CTC
(1) Reading current values
The current value is read by the LDA or MOV instruction.
"LDA Instruction" page 4-6
"MOV Instruction" page 4-14

When the current value is 0 to 65535 CTH0 DM00000


LDA STA
[Example]
To store the current value of CTH0 to data MOV
memory DM00000 CTH0 DM00000

When the current value is 0 to 4294967295 CTH0 DM00000


LDA.D STA.D
[Example]
To store the current value of CTH0 to data MOV.D
memory DM00000/DM00001 CTH0 DM00000

5-73
5-4 High-speed Processing Instructions

(2) Changing the current value (CTH)


The current value is changed by the MOV instruction.
"MOV Instruction" page 4-14

When changing to 0 to 65535


[Example] MOV
EXTENDED INSTRUCTIONS

#00100 CTH0
To change the current value of CTH0 to 100

When changing to 0 to 4294967295


[Example] MOV.D
#100000 CTH0
To change the current value of CTH0 to 100000

Note: Current values are overwritten as 32-bit data even if they are changed by the MOV.U
instruction.
When the current value has been changed to a value greater than the CTC to which an
5 automatic reset is specified, the current value is changed to "value of CTC - 1".
The current value cannot be changed to a value greater than the CTC to which an automatic
High-speed Processing Instructions

reset is specified.

(3) Changing the setting value (CTC)


The setting value is changed by the STA or MOV instruction.
"STA Instruction" page 4-8
"MOV Instruction" page 4-14

When changing to 0 to 65535


[Example] #00100 CTC0
LDA STA
To change the current value of CTC0 to 100
MOV
#00100 CTC0

When changing to 0 to 4294967295


[Example] #100000 CTC0
LDA.D STA.D
To change the value of CTC0 to 100000
MOV.D
#100000 CTC0

Note: Setting values are overwritten as 32-bit data even if they are changed by the MOV.U
instruction.

5-74
5-4 High-speed Processing Instructions

Setting Count Input


■ External input setting
The following count methods are available for counting external inputs.

CTH0 count input method


Single-phase Phase Difference 2 pulses

EXTENDED INSTRUCTIONS
W/out W/ 1X 2X 4X
direction direction
CR2113 OFF ON OFF ON OFF ON
CR2114 OFF OFF ON ON OFF OFF
CR2115 OFF OFF OFF OFF ON ON

CTH1 count input method


Single-phase Phase Difference 2 pulses
W/out W/ 1X 2X 4X
direction direction
CR2213 OFF ON OFF ON OFF ON
CR2214 OFF OFF ON ON OFF OFF 5
CR2215 OFF OFF OFF OFF ON ON

High-speed Processing Instructions


Note: Do not set to combinations other than those described in the above tables.

(1) Single-phase
Set this when counting single-phase pulses.

W/out direction The up edge of the A phase is counted.


The B phase can be used as regular input. HSP

DI

EI
W/ direction The count is incremented at the up edge of the A phase when the B phase is
INT
OFF.
RETI
The count is decremented at the up edge of the A phase when the B phase is CTH
ON.
CTC

W/out direction W/ direction


ON ON
(A phase) 00004 (A phase) 00004
OFF OFF
ON ON
(B phase) 00006 (B phase) 00006
OFF OFF

(counter value) CTH0 (counter value) CTH0


0 1 2 3 2 1 0 0 1 2 3 4 5 6

5-75
5-4 High-speed Processing Instructions

(2) Phase difference


Set this when counting the phase difference.

1X The count is incremented at the up edge of the A phase when the B phase is OFF.
The count is decremented at the down edge of the A phase when the B phase is OFF.

ON
(A phase)
EXTENDED INSTRUCTIONS

0004
OFF
ON
(B phase)
0006 OFF

(counter value)
CTH0
0 1 2 3 4 3 2 1 0

2X The count is incremented at the up edge of the A phase when the B phase is OFF.
The count is decremented at the down edge of the A phase when the B phase is OFF.
The count is decremented at the up edge of the A phase when the B phase is ON.
The count is incremented at the down edge of the A phase when the B phase is ON.
5
ON
(A phase)
High-speed Processing Instructions

0004 OFF
ON
(B phase)
0006 OFF

(counter value)
CTH0
0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0

4X The count is incremented at the up edge of the A phase when the B phase is OFF.
The count is decremented at the down edge of the A phase when the B phase is OFF.
The count is decremented at the up edge of the A phase when the B phase is ON.
The count is incremented at the down edge of the A phase when the B phase is ON.
The count is decremented at the up edge of the B phase when the A phase is OFF.
The count is incremented at the down edge of the B phase when the A phase is OFF.
The count is incremented at the up edge of the B phase when the A phase is ON.
The count is decremented at the down edge of the B phase when the A phase is ON.

ON
(A phase)
0004 OFF
ON
(B phase)
0006 OFF

(counter value)
CTH0

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

5-76
5-4 High-speed Processing Instructions

(3) 2-pulse
The pulse that is input in 2-pulse method is counted.

The pulse is incremented at the up edge of the A phase, and decremented at the up edge of the
B phase.

ON
(A phase)

EXTENDED INSTRUCTIONS
0004 OFF
ON
(B phase)
0006 OFF

(counter value)
CTH0
0 1 2 3 4 3 2 1 0

■ Internal clock input setting


When counting the internal clock, specify the following control relays to the operand.
1.0 µs 10.0 µs 100.0 µs
CTH0 CR2100 CR2101 CR2102 5
CTH1 CR2200 CR2201 CR2202

High-speed Processing Instructions


The A and B phases can be used as regular input.

■ Direct clock pulse input


When counting the direct clock pulse, specify the following relays to the operand.

Direct Clock Pulse


CTH0 00501
CTH1 00500

The A and B phases can be used as regular input. HSP

DI

EI

INT

RETI

CTH

CTC

5-77
5-4 High-speed Processing Instructions

Reset Method
Clearing the current value of a high-speed counter is called a "reset."
There are four reset methods:
Reset by RES instruction
Reset by execution condition OFF
Automatic reset by a count up
EXTENDED INSTRUCTIONS

Reset by external input

■ Reset by RES instruction


The counter is reset by "RES CTH." The counter is reset at the moment that the RES instruction
is executed.

Scan

5 CTH current value


High-speed Processing Instructions

"RES CTH" execution

[Example] Reset by RES instruction

CTH0
RES

■ Reset by execution condition OFF


The counter is reset by turning the CTH instruction execution condition OFF.

Scan

Execution condition

CTH current value

CTH instruction execution

[Example] Reset by execution condition OFF

Execution condition CTH0


00004
The current value is reset
when execution condition turns OFF.

5-78
5-4 High-speed Processing Instructions

■ Automatic reset by a count up


The counter is automatically reset when the current value reaches the setting value.
This automatic reset is set in control relays.
High-speed High-speed Relay No. Operation
Counter Counter
Comparator
CTH0 CTC0 CR2103 If control relays CR2103 and CR2112 are turned ON in
advance, the current value of CTH0 is cleared when the

EXTENDED INSTRUCTIONS
CTC1 CR2112 preset value of CTH0 becomes the same as the setting
values of CTC0 and CTC1.
CTH1 CTC2 CR2203 If control relays CR2203 and CR2212 are turned ON in
advance, the current value of CTH1 is cleared when the
CTC3 CR2212 preset value of CTH1 becomes the same as the setting
values of CTC2 and CTC3.

Scan

CTH

CTH=CTC
5

High-speed Processing Instructions


* The counter is reset when CTH=CTC.

Note: When the current value has been changed to a value greater than CTC to which an
automatic reset is specified, the current value is changed to "value CTC - 1".
The current value cannot be changed to a value greater than the CTC to which an
automatic reset is specified.

■ Reset by external input


The preset function is used to reset the current value. HSP

DI
Set the preset value to "0" to execute the preset.
EI
"Preset Function" page 5-80 INT

RETI
Scan CTH

CTC

External reset input

CTH

* The current value is reset when the external reset input turns ON.

[Tip]
With resets by "execution condition OFF" or the "RES instruction," a delay of one scan maximum
until the reset is performed occurs. With resets by "automatic reset by a count up" or "external
input," the reset is performed without the scan time being influenced.

5-79
5-4 High-speed Processing Instructions

Preset Function
The preset function changes the current value of the high-speed counter to the preset value. The
current value is changed by external input.
Preset Input Preset Value Storage Destination
Upper Lower
CTH0 00008 CM1605 CM1604
CTH1 00009 CM1607 CM1606
EXTENDED INSTRUCTIONS

Set the preset execution condition in control relays.


High-speed Counter CR2400 CR2401 Operation
CTH0 OFF OFF External reset disabled
ON OFF Reset at up edge of input 00008
OFF ON Reset at down edge of input 00008
ON ON Reset for duration that input 00008 is ON

High-speed Counter CR2404 CR2405 Operation


5 CTH1 OFF OFF External reset disabled
ON OFF Reset at up edge of input 00009
High-speed Processing Instructions

OFF ON Reset at down edge of input 00009


ON ON Reset for duration that input 00009 is ON

When the preset value is set to "0" and the preset is executed, the preset can be used as a reset
for the high-speed counters.

[Example] To reset at the up edge of 00008 (high-speed counter reset), the setting for presetting
CTH0 to "0"

CR2008 CR2400 CR2401 #00000 CM1604


SET RES LDA.D STA.D

5-80
5-4 High-speed Processing Instructions

Comparator Match Output


This function turns output relays ON when the value (setting value) of the comparator matches the
current value. Set this function in control relays.

CTH0 setting
Relay No. Description ON OFF

EXTENDED INSTRUCTIONS
CR2104 When CTC0 is ON, direct output (00500) Disable output. Enable output.
CR2106 When CTC0 is ON, direct output (00500) ON Execute. Do not execute.
CR2108 When CTC1 is ON, direct output (00500) Disable output. Enable output.
CR2110 When CTC1 is ON, direct output (00500) ON Execute. Do not execute.

CTH1 setting
Relay No. Description ON OFF
CR2204 When CTC2 is ON, direct output (00501) Disable output. Enable output.
CR2206 When CTC2 is ON, direct output (00501) ON Execute. Do not execute.
CR2208 When CTC3 is ON, direct output (00501) Disable output. Enable output.
CR2210 When CTC3 is ON, direct output (00501) ON Execute. Do not execute. 5

High-speed Processing Instructions


Set this function to "direct output enabled" and "output ON" when CTC is ON.
This function is output without being influenced by the scan time.
To set this function to OFF, write a program for setting this function to OFF.

[Example] Setting for direct output of output relay 00500 when CTC0 turns ON
When high-speed counter CTH0 matches the value (100) set by high-speed counter
comparator, the output relay is directly output.
When input relay 00000 turns ON, output relay 00500 is turned OFF. HSP

DI
CR2002 CR2103 CTH0
0001 EI SET RES EI
Always ON CTH0 when CTC0 is ON INT
CR2002 Auto-clear
HSP
0002 00004 RETI
Always
ON CTH
CTH0
0003 00004 CTC

#100
0004 CTC 0

00000 00500
0005 RES

END
0006

INT
0007 CTC0

CR2002 00500
0008 SET
Always ON
RETI
0009

ENDH
0010

0011

5-81
5-4 High-speed Processing Instructions

Ring Counter Function


A "ring counter" is a function for setting the upper limit of a high-speed counter to any desired value.
A ring counter operates when the operation enable relay (CR) is ON.
Regular high-speed counters overflow when the count up exceeds 4294967295, and the count
returns to 0. When these counters count down from 0, they overflow, and the count becomes
4294967295.
However, when a ring counter is set, the value when the counter underflows becomes the preset
EXTENDED INSTRUCTIONS

upper limit value. When the counter overflows from the upper limit value, the count returns to 0.

Regular Ring counter

Overflow Overflow

4294967295 0 Upper limit value 0

Underflow Underflow
4294967294 1 Upper limit value -1 1

5 2 2
High-speed Processing Instructions

4 3 4 3

Ring counters are set in control relays and control memory.

Upper Limit Value


High-speed Counter Enable Operation Relay
Upper Lower
CTH0 CR2402 CM1601 CM1600
CTH1 CR2406 CM1603 CM1602

[Example] Ring counter setting for upper limit value 100000 for CTH0

CR2008 #100000 CM1600


LDA.D STA.D

CR2402
SET

Note: When the current value of the high-speed counter has been changed to a value greater
than the upper limit value of the ring counter, the current value is changed to the upper limit
value. The current value does not change when the upper limit value is changed to a value
smaller than the current value.

5-82
5-4 High-speed Processing Instructions

Extended Functions
High-speed counters have the following three extended functions in addition to regular high-speed
counting. These functions use the high-speed counter.
Note that extended functions cannot be used in combination with regular high-speed counting.

(1) Specified frequency pulse output function

EXTENDED INSTRUCTIONS
This function sets any frequency and outputs this as a pulse.
This function enables motor speed control.

(2) Frequency counter function


This function measures the frequency of rotating bodies, for example.

(3) Cam switch function


This function performs cam control on a PLC.

5
For details on extended functions, refer to the KV-700 User's Manual.

High-speed Processing Instructions


HSP

DI

EI

INT

RETI

CTH

CTC

5-83
5-4 High-speed Processing Instructions

High-speed counter application example


■ Comparison of encoder values
An encoder is connected to phase difference inputs 00004/00006 and 00005/00007 to count the
inputs.
These inputs are counted at 1X resolution. When the value of CTH0 is #60000, the value of CTH1
is compared.
If the value of CTH1 is greater, output relay 00500 turns ON. When input relay 00000 turns ON,
EXTENDED INSTRUCTIONS

CTH0 and CTH1 are reset.

CR2008 CR2113 CR2114 CR2115


Initial setting
EI RES SET RES
CR2113 OFF
CR2213 CR2214 CR2215 CR2114 ON CTH0, 1X setting
RES SET RES CR2115 OFF
CR2213 OFF
CR2008 CTH0 CTH1 CR2214 ON CTH1, 1X setting
RES RES CR2215 OFF

00000

5 CR2002 HSP The input time constant of input relays 00004,


00004 00005, 00006 and 00007 is set to 10 µs.
High-speed Processing Instructions

HSP
00005

HSP
00006

HSP
00007

CR2002 CTH0
00004 Input of phase difference of 00004 and 00006

#60000
CTC0 The setting value of counter comparator CTC0 is
taken as #60000.
CTH1
Input of phase difference of 00005 and 00007
00005

END

INT
CTC0

CR2002 CTH1 #60000 CR2011 00500


The current value of high-speed counter CTH1 is
LDA.D CMP.D SET
compared with #60000. If it is greater, output relay
00500 is turned ON. If it is smaller, output relay
CR2011 00500 00500 is turned OFF.
RES

CR2002 CTH0 CTH1


RES RES

RETI

ENDH

5-84
5-4 High-speed Processing Instructions

■ Multi-stage setting of high-speed counters


Set the high-speed counter comparator of input relay 00005 as follows.
#01000 → DM00000/DM00001
#02000 → DM00010/DM00011
#03000 → DM00020/DM00021
When each of the values or above is reached, the result is as follows:

EXTENDED INSTRUCTIONS
CTH1 ≥ #01000 → 00500 turns ON.
CTH1 ≥ #02000 → 00501 turns ON.
CTH1 ≥ #03000 → 00502 turns ON.

CR2008 #01000 DM00000 #02000 DM00010 #03000 DM00020


LDA.D STA.D LDA.D STA.D LDA.D STA.D
CTH1
RES

CR2002 HSP
00005

00001 CTH1 5
00005

High-speed Processing Instructions


CR2002 CTH1 DM00000 CR2009 00500
LDA.D CMP.D

DM00010 CR2009 00501


CMP.D

DM00020 CR2009 00502


CMP.D

■ Clearing the current value of high-speed counters


HSP
The pulse of input 00005 is counted. When the setting value #60000 is reached, the current value
DI
of high-speed counter CTH1 is cleared, and output 00502 is turned ON for three seconds.
EI

INT

RETI
CR2008 CR2203 CTH1
SET RES CTH

CTC
CR2002 HSP
00005

CR2002 CTH1
00005

#60000
CTC2

CTC2 00502 #00030 T001 CTC2


T001 RES

5-85
5-4 High-speed Processing Instructions

■ Phase difference input


• The phase difference of inputs 00004 and 00006 is input, and is counted by high-speed counter
CTH0.
• The phase is counted at resolution 1X.
• The count data is stored to DM00000/DM00001.
• When the high-speed counter reaches #60000, the current value of the high-speed counter is
cleared, output 00500 is set, and high-speed counter capture is canceled.
EXTENDED INSTRUCTIONS

• Output reset is taken as 00008.

CR2008 CR2103 CR2113 CR2114 CR2115


EI SET RES SET RES

CR2400 CR2401 CTH0 #00000


SET RES RES DW.D
CM1604
CR2002 HSP
00004

HSP
00006
5 HSP
00008
High-speed Processing Instructions

00500 CTH0
00004

#60000
CTC0

CR2002 CTH0 DM00000


LDA.D STA.D

END

INT
CTH0

CR2002 00500
SET

RETI

ENDH

Initial setting
Control relays
• When CR2103 is turned ON, the current value of CTH0 is cleared when CTC0 is ON.
• The high-speed counter resolution is 1X if CR2113 is OFF, CR2114 is ON, and CR2115 is OFF.
• When CR2400 is turned ON and CR2401 is turned OFF, external reset is enabled (preset
function) ↓
Reset at up edge of input 00008

5-86
5-4 High-speed Processing Instructions

■ Capturing the count of the VP (optical scale sensor)


The phase difference input of a VP is captured at 2X resolution. Let's assume that values 0 to
9999 are input.
Captured data is output as BCD.
Phase difference input 00004, 00006
BCD outputs 30000 to 30015 (4 digits)

EXTENDED INSTRUCTIONS
CR2008 CR2113 CR2114 CR2115 CTH0 CR2400 CR2401
SET SET RES RES SET RES

CR2002 HSP
00004

HSP
00006

HSP
00008

CR2002 CTH0
00004
5
CR2002 CTH0 #00002 30000
STA

High-speed Processing Instructions


LDA EXT DIV TBCD

END

ENDH

Initial setting
Special auxiliary relays
HSP
• The high-speed counter resolution is 2X if CR2113 is ON, CR2114 is ON, and CR2115 is OFF.
DI
• When CR2400 is turned ON and CR2401 is turned OFF, external reset is enabled (preset
EI
function) ↓
INT
Reset at up edge of input 00008
RETI

CTH

CTC

5-87
5-5 Positioning Instructions

5-5 Positioning Instructions

Positioning Instruction List


There are eight positioning instruction as follows.

Instruction Mnemonic Brief Description of Operation Page


EXTENDED INSTRUCTIONS

Trapezoidal PLSX Starts trapezoidal control of the X-axis. 5-90


control X-axis
Trapezoidal PLSY Starts trapezoidal control of the Y-axis. 5-90
control Y-axis
Jog operation JOGX Performs jog operation of the X-axis. 5-92
X-axis
Jog operation JOGY Performs jog operation of the Y-axis. 5-92
Y-axis
Zero return X-axis ORGX Starts zero-return of the X-axis. 5-94

Zero return Y-axis ORGY Starts zero-return of the Y-axis. 5-94

5 Teach X-axis TCHX Loads the current position of the X-axis. 5-98
Positioning Instructions

Teach Y-axis TCHY Loads the current position of the Y-axis. 5-98

Positioning instructions operate according to parameters preset on KV BUILDER.

Parameter setup flow

(1) Initial parameter setup Set these parameters on KV BUILDER.

(2) Programming of ladder program Create a program using positioning parameters.

When the program is executed, positioning control is


(3) Execution of ladder program started according to the parameters set at (1).

The content of parameters can be changed by directly


No Change parameter
settings during ladder program rewriting the content of control memory on the ladder
execution? program without having to use KV BUILDER.

Yes

Change parameters

For details on the settings of these parameters, refer to the KV-700 Series User's Manual "Motor
Control." Also, for details on KV BUILDER operations, refer to the KV BUILDER User's Manual
"Editing Point Parameters."

5-88
5-5 Positioning Instructions

■ Related parameter list


The following presents a list of only positioning related parameters. For details on parameter
settings, refer to KV-700 Series User's Manual "Motor Control."

Point parameters
Common to Both X-/Y-axes Remarks
Target value/travel No.0 CM2060/CM2061

EXTENDED INSTRUCTIONS
No.1 CM2070/CM2071
:
No.31 CM2370/CM2371
Startup speed No.0 CM2062
No.1 CM2072
:
No.31 CM2372
Acceleration/deceleration time No.0 CM2063
No.1 CM2073
:
No.31 CM2373
Run speed No.0 CM2064/CM2065
No.1 CM2074/CM2075
:
No.31 CM2374/CM2375 5
Operation mode No.0 CM2066

Positioning Instructions
No.1 CM2076
:
No.31 CM2376

System parameters
X-axis Y-axis Remarks
Assignment of 00000 to 00003 CM2000 CM2030
Output format CM2000 CM2030
Current position comparators 0.1 CM2000 CM2030 The values must be set when a com-
parator is used.
Input sensor enable CM2001 CM2031
Input sensor polarities CM2001 CM2031
Current position comparator 0 CM2002 CM2032 Set when using a comparator as a
Current position comparator 1 CM2004 CM2034 substitute for a limit sensor.
Zero return startup speed CM2006 CM2036
Zero return acceleration/decelera- CM2007 CM2037
tion time
Zero return run speed CM2008 CM2038
Jog startup speed CM2010 CM2040
Jog acceleration/deceleration time CM2011 CM2041
Jog run speed CM2012 CM2042
Error/warning code CM2024 CM2054

Control relays
X-axis Y-axis Remarks
Limit switch CW input CR3000 CR3100 1=ON, 0=OFF
Limit switch CCW input CR3001 CR3101 1=ON, 0=OFF
Origin sensor input CR3002 CR3102 1=ON, 0=OFF
Pulse output in progress CR3009 CR3109 1=Pulse output in progress
Error CR3007 CR3107 1=Error state (cleared when "0" is stored)
Warning CR3008 CR3108 1=Warning state (cleared when "0" is stored)
Zero return locus/ CR3013 CR3113 1=Zero return in progress
zero return in progress

5-89
5-5 Positioning Instructions
PLSX PLSX Trapezoidal control X-axis Starts trapezoidal control of the X-axis.

PLSY PLSY Trapezoidal control Y-axis Starts trapezoidal control of the Y-axis.

Ladder program Input method


Execution condition S
PLSX P L S X S

Execution condition S
EXTENDED INSTRUCTIONS

PLSY P L S Y S

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

S — — — — — — — — — — — — — — — — — — —

S : Specifies the point parameter No. (0 to 31).


Set the parameters (acceleration/deceleration time, run speed, etc. using the parameter
setup functions on KV BUILDER.

5 Explanation of Operation
Positioning Instructions

When the execution condition turns ON, the pulse is output according to the point parameter setting
specified by S .

Frequency (Hz)
Target value/travel amount (number of output pulses)

Run speed

Start speed
(stop speed)

Time (ms)

Acceleration Deceleration
time time

During point travel, flags CR3009 (X-axis) and CR3109 (Y-axis) turn ON during pulse output, and
turn OFF when pulse output ends. The point parameter Nos. during operation are stored to CM2025
(X-axis) and CM2055 (Y-axis).

To perform an emergency stop, set CR3009 (X-axis) and CR3109 (Y-axis) OFF. When an
emergency stop has been performed, the emergency stop error is generated, error code 30 is stored
to CM2024 (X-axis) and CM2054 (Y-axis), and the pulse output in progress flags turns OFF. Also,
CR3007 (X-axis) and CR3107 (Y-axis) turn ON.

5-90
5-5 Positioning Instructions

Note: The following describes the precautions to follow in the position mode.
• New operations cannot be started during pulse output. The PLSX and PLSY instructions
are ignored if an attempt is made to execute them during pulse output. (The PLSX and
PLSY instructions are not executed even if current pulse output ends.)
• Instructions cannot be accepted and are ignored during generation of an error.
• When pulse output was stopped by an emergency stop, the current position information
is not assured. Also, the duty of the last pulse by which pulse output stopped is not

EXTENDED INSTRUCTIONS
assured.
• The pulse output in progress flags CR3009 (X-axis) and CR3109 (Y-axis) turn ON/OFF
at each scan (The pulse output in progress flags during ON for one scan even if there
were every few output pulses and pulse output ended within one scan.) Perform a pulse
output operation handshake using the pulse output in progress flags.
• When the parameter is such that the number of output pulses is "0", the pulse output in
progress flag does not turn ON, and warnings are not output.

Operation flag
The operation flag does not change.
5

Positioning Instructions
Execution Timing
PLSX, PLSY This instruction is executed at each scan for the duration that the execution
condition is ON.

Scan
ON
Execution
condition OFF

PLSX, PLSY Execution condition Execution

PLSX

Sample Program PLSY

JOGX
At the up edge that input relay 00000 turns ON, the pulse is output according to the setting of point
JOGY
parameter No.00.
ORGX

ORGY
00000 00
PLSX TCHX

TCHY

5-91
JOGX
5-5 Positioning Instructions
JOGX CW
CCW
High
Jog operation X-axis Performs jog operation of the X-axis.
JOGY
JOGY CW
CCW
High
Jog operation Y-axis Performs jog operation of the Y-axis.

Ladder program Input method


CW signal JOGX
CW J O G X

CCW signal
EXTENDED INSTRUCTIONS

CCW

High signal
High

CW signal JOGX
CW J O G Y

CCW signal
CCW

High signal
High

5 Available Bit Devices


Internal
Word Devices Constant Indirect Operation Flag
CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012
Positioning Instructions

— — — — — — — — — — — — — — — — — — — — —

Set jog operation, acceleration/deceleration time, run speed and other details using the parameter
setup function on KV BUILDER.

Explanation of Operation
When the CW and CCW signals are ON, pulse output is started at the start speed.

Frequency (Hz)
CW/CCW signal High signal High signal CW/CCW signal
ON! ON! OFF! OFF!

Run speed

Start speed
(Stop speed)

Time (ms)

When the CW (or CCW) signal is ON and the High signal is ON, the start speed accelerated to the
run speed.
When the High signals turns OFF, the run speed decelerates to the start speed. If the CW (or CCW)
turns OFF even when the High signal is ON, the run speed decelerates to the start speed and stops.
During operation, the pulse output in progress flags CR3009 (X-axis) and CR3109 (Y-axis) turn ON,
and turn OFF when pulse output ends.
Travel inside the limit sensor range is possible even if the limit error occurs.
To make an emergency stop, turn CR3009 (X-axis) and CR3109 (Y-axis) OFF.
Operation stops immediately when an emergency stop has been made. Also, the emergency stop
error occurs, CR3007 (X-axis) and CR3107 (Y-axis) turn ON, error code 30 is stored to CM2024 (X-
axis) and CM2054 (Y-axis), and the pulse output in progress flags turn OFF.

5-92
5-5 Positioning Instructions

Note: • New jog operations cannot be started during pulse output. (The JOGX and JOGY
instructions are ignored if an attempt is made to execute them during pulse output.)
• The pulse output in progress flags CR3009 (X-axis) and CR3109 (Y-axis) turn ON/OFF
at each scan (The pulse output in progress flags during ON for one scan even if there
were every few output pulses and pulse output ended within one scan.) Perform a pulse
output operation handshake using the pulse output in progress flags.
• Instructions cannot be accepted and are ignored during generation of an error.

EXTENDED INSTRUCTIONS
• When pulse output was stopped by an emergency stop, the current position information
is not assured. Also, the duty of the last pulse by which pulse output stopped is not
assured.

Operation flag
The operation flag does not change.

Execution Timing
JOGX, JOGY These instructions are executed at each scan for the duration that the execution
condition is ON. 5

Positioning Instructions
Scan
ON
Execution
condition OFF

JOGX, JOGY Execution condition Execution

Sample Program

00000 JOGX PLSX


CW PLSY

00001 JOGX
CCW
JOGY
00002 ORGX
High
ORGY

TCHX

TCHY

5-93
ORGX
5-5 Positioning Instructions
ORGX Zero return X-axis Starts zero-return of the X-axis.

ORGY ORGY Zero return Y-axis Starts zero-return of the Y-axis.

Ladder program Input method


Execution condition
ORGX O R G X

Execution condition
EXTENDED INSTRUCTIONS

ORGY O R G Y

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Set zero return operation, using the parameter setup function on KV BUILDER.

Explanation of Operation
When the execution condition is ON, a zero return is started.
5 During a zero return, the zero return in progress flags CR3004 (X-axis) and CR3104 (Y-axis), and
pulse output in progress flags CR3009 (X-axis) and CR3109 (Y-axis).
Positioning Instructions

The pulse of the pulse output in progress flag (operation during a zero return is clockwise) is
disrupted, however, the zero return in progress flag stays ON.
To cancel a zero return (perform an emergency stop), set pulse output in progress flags CR3009
(X-axis) and CR3109 (Y-axis) OFF. When an emergency stop has been performed, the emergency
stop error is generated, error code 30 is stored to CM2024 (X-axis) and CM2054 (Y-axis), and the
pulse output in progress flag turns OFF. Also, CR3007 (X-axis) and CR3107 (Y-axis) turn ON.
When zero return ends (or, stops due to an error), the zero return in progress flags and pulse output
in progress flags turn OFF and the current values return to zero.

Note: • New operations cannot be started during a zero return.


The next operation instruction can be accepted after zero return has completed or an
emergency stop input is input, zero return stops, and the error is cleared.
• During startup, make sure that the emergency stop or limit sensor (CW, CCW) inputs are
not entered.
• If a limit switch input in the direction opposite to that of the executing zero return is input
after a zero return is started, a limit sensor error occurs and zero return stops.
• The current position information when pulse output has stopped due to an emergency
stop is not assured.
Also, the duty of the last pulse at which pulse output stopped is not assured.
• When both (not simultaneously, one after the other) of the CW and CCW limit sensor
inputs have turned ON in a single zero return operation, a limit sensor error occurs and
zero return stops.
• When there is input from a limit sensor during a zero return, operation is immediately
stopped, the tool then moves in the opposite direction at startup speed, and then
accelerates from startup speed.
• After a zero return is started, there is a blank interval of at least one scan. (Note that after
an immediate stop caused by a limit sensor, with some parameters operation may
become out of sync as operation likewise starts after at least one scan.)
• After a limit sensor input has been confirmed and zero return has been stopped, the limit
sensor in the advance direction is only checked.
• At the end of a zero return, operation stops immediately after input from the home sensor,
and zero return is completed. As the speed at the end of zero return is controlled by the
value set as the zero return startup speed, the deviation with the stop speed may increase
due to the deviation with the response of the sensor input if the zero return startup speed
is set to a large value.
• No operations are performed while an error is generated.

5-94
5-5 Positioning Instructions

■ Zero return locus


The locus of tool movement during a zero return varies as follows according to the position of
the tool when zero return is started. If an error is cleared when whichever of the limit switches
is ON, a zero return is performed in this state.

[Zero return direction] CW [Zero return direction] CCW


Start point Forward: CW from origin Start point Forward: CW from origin
CW
speed

EXTENDED INSTRUCTIONS
Origin Start point
CCW Origin Start point CW CCW CW

Home return start speed [Home return


CCW start speed]
speed [Home return speed]
Origin sensor [Home return acceleration speed]
Origin sensor

[Zero return direction] CW [Zero return direction] CCW


Start point Reverse: CCW from origin Start point Reverse: CCW from origin

5
Start point Origin

Positioning Instructions
CCW Origin CW CCW CW
Start point

Origin sensor Origin sensor

[Zero return direction] CW [Zero return direction] CCW


Start point Reverse: CCW from origin Start point Reverse: CCW from origin

Start point Origin


CCW Origin CW PLSX
CCW CW
Start point
PLSY

JOGX

JOGY
Wide origin sensor Wide origin sensor
ORGX

ORGY

TCHX
[Zero return direction] CW [Zero return direction] CCW
Start point Within home sensor Start point Within home sensor TCHY
detection range detection range

Start point Origin


CCW Origin CW CCW Start point CW

Origin sensor Origin sensor

5-95
5-5 Positioning Instructions

Operation flag
The operation flag does not change.

Execution Timing
ORGX, ORGY These instructions are executed at each scan for the duration that the execution
condition is ON.
EXTENDED INSTRUCTIONS

Scan
ON
Execution
condition OFF

ORGX, ORGY Execution condition Execution

Sample Program

5 00000
ORGX
Positioning Instructions

00000
↑ ORGY

5-96
5-5 Positioning Instructions

This page left intentionally blank.

EXTENDED INSTRUCTIONS
5

Positioning Instructions
PLSX

PLSY

JOGX

JOGY

ORGX

ORGY

TCHX

TCHY

5-97
TCHX
5-5 Positioning Instructions
TCHX Teach X-axis Loads the current position of the X-axis.

TCHY TCHY Teach Y-axis Loads the current position of the Y-axis.

Ladder program Input method


Execution condition
TCHX T C H X

Execution condition
EXTENDED INSTRUCTIONS

TCHY T C H Y

Available Bit Devices Word Devices Constant Indirect Operation Flag


Internal CR CR CR CR
Devices I O auxiliary T C CTC CR DM TM T C CTH CTC CM #/$ #TM 2009 2010 2011 2012

— — — — — — — — — — — — — — — — — — — — —

Explanation of Operation
The current value is stored to the target value/travel of the specified point parameter No. at the up
edge of the execution condition.
5 (1) The point parameter No. for storing the current value (as the target value/travel) is stored to
CM2025 (X-axis) and CM2055 (Y-axis) within the range 0 to 31.
Positioning Instructions

• The point No. is ignored if it outside of the range 0 to 31.


(2) The position that is moved to using the JOG instruction becomes the current value.
• Whether movement to the current position is expressed by an absolute value or a relative value
conforms to the operation mode setting.
(3) The current value is stored to the target value/travel of the point parameter No. specified at (1)
when the TCHX and TCHY instruction execution conditions turn ON.

[Example] TCHX instruction


To store the current value of the X-axis as the target value of point No.0
Store "0" to CM2025.
Execute the TCHX instruction.
The content of CM2020 and CM2021 (current value of X-axis) is moved to CM2060 and
CM2061 (target value/travel of point No.0).

TCHY instruction
To store the current value of the Y-axis as the target value of point No.10
Store "10" to CM2055.
Execute the TCHY instruction.
The content of CM2050 and CM2051 (current value of Y-axis) is moved to CM2160 and
CM2161 (target value/travel of point No.10).

5-98
5-5 Positioning Instructions

Note: The following describes the precautions to follow in the position mode.
• Point parameter Nos. stored to CM2025 outside the 0 to 31 range are ignored. An error
or a warning is not generated in this case.
• Point parameter Nos. are common to the X- and Y-axes. Point parameter Nos. are
ignored if they outside the 0 to 31 range. An error or a warning is not generated in this
case.
The following describes the precautions to follow in the speed control mode.

EXTENDED INSTRUCTIONS
• Values can be stored even in the speed control mode.
• No operations are performed while an error is generated.

Operation flag
The operation flag does not change.

Execution Timing
TCHX, TCHY Level operation of the execution conditions
5
Scan

Positioning Instructions
ON
Execution
condition
OFF

TCHX, TCHY Execution condition Execution condition

Sample Program
00000
TCHX
PLSX

PLSY

JOGX

JOGY

ORGX

ORGY

TCHX

TCHY

5-99
5-5 Positioning Instructions

This page left intentionally blank.


EXTENDED INSTRUCTIONS

5
Positioning Instructions

5-100
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

This chapter presents error code tables, instruction execution times,


differences between the KZ-300/350 and the Visual KV Series, text

APPENDICES
code lists (ASCII/JIS), special device lists, and an instruction index.

1 About Storage of Arithmetic Operations


(Internal Registers/Temporary memory) ............................................................. A-2

About Storage of Arithmetic Operations (Internal Registers/Temporary memory)


2 Error No. Tables ................................................................. A-8

3 Operation Processing Times List ................................... A-11

4 Differences Between KV-300 & Visual KV Series ......... A-16

5 Text Code Table ............................................................... A-18

6 Special Device List .......................................................... A-19

7 Index ................................................................................. A-31

8 Instruction Index .............................................................. A-33

A-1
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

1 About Storage of Arithmetic Operations


(Internal Registers/Temporary memory)
This appendix describes how data is stored to internal registers or temporary data memory (TM)
depending on the arithmetic instruction (ADD, SUB, MIL, DIV) and square root (ROOT instruction).

List of Internal Register/Temporary Data Memory Storage States


Stored State See
Instruction Page
Before Operation After Operation

ADD.U 16-bit 16-bit


internal register + S = internal register
ADD.S
4-28
ADD.D 32-bit internal register + S+1 S = 32-bit internal register
APPENDICES

ADD.L Upper Lower Upper Lower Upper Lower

SUB.U 16-bit 16-bit


internal register – S = internal register
SUB.S
4-32
SUB.D 32-bit internal register – S+1 S = 32-bit internal register
SUB.L Upper Lower Upper Lower Upper Lower

32-bit internal register


About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

* The upper 16 bits are


MUL.U 16-bit Upper Lower stored to both the upper
internal register x S =
16-bit part of the internal
MUL.S TM000 internal register register and the TM000.
Upper Lower 4-36

MUL.D 32-bit internal register x S+1 S = TM001 TM000 32-bit internal register
MUL.L Upper Lower Upper Lower Upper Lower

32-bit internal register


16-bit Upper Lower
DIV.U TM000 internal register S = Remainder TM001
16-bit
Upper Lower TM000 internal register
DIV.S
Upper Lower
* The upper 16 bits are stored to both the
upper part of the internal register and the 4-40

TM001 TM000 32-bit internal register


DIV.D Upper Lower
TM001 TM000 32-bit internal register S+1 S =
DIV.L Upper Lower Upper Lower Remainder TM003 TM002
Upper Lower

ROOT.U 16-bit 16-bit


TM000 internal register = internal register
ROOT.S Upper Lower

4-52

ROOT.D
TM001 TM000 32-bit internal register = 32-bit internal register
ROOT.L Upper Lower Upper Lower

A-2
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

Example of arithmetic operations


■ Addition (ADD)
(1) Unsigned 16-bit binary data + unsigned 16-bit binary data = unsigned 16-bit binary data
DM00000 + DM00001 = DM00010

CR2002 DM00000 DM00001 DM00010


LDA ADD STA

(2) Signed 16-bit binary data + signed 16-bit binary data = signed 16-bit binary data
DM00000 + DM00001 = DM00010

CR2002 DM00000 DM00001 DM00010


LDA.S ADD.S STA.S

APPENDICES
(3) Unsigned 16-bit binary data + unsigned 32-bit binary data = unsigned 32-bit binary data
DM00000 + [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA EXT ADD.D STA.D

About Storage of Arithmetic Operations (Internal Registers/Temporary memory)


(4) Signed 16-bit binary data + signed 32-bit binary data = signed 32-bit binary data
DM00000 + [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA.S EXT.S ADD.L STA.L

(5) Unsigned 32-bit binary data + unsigned 32-bit binary data = unsigned 32-bit binary data
[DM00000/DM00001] + [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA.D ADD.D STA.D

(6) Signed 32-bit binary data + signed 32-bit binary data = signed 32-bit binary data
[DM00000/DM00001] + [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA.L ADD.L STA.L

A-3
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

■ Subtraction (SUB)
(1) Unsigned 16-bit binary data – unsigned 16-bit binary data = unsigned 16-bit binary data
DM00000 – DM00001 = DM00010

CR2002 DM00000 DM00001 DM00010


LDA SUB STA

(2) Signed 16-bit binary data – signed 16-bit binary data = signed 16-bit binary data
DM00000 – DM00001 = DM00010

CR2002 DM00000 DM00001 DM00010


LDA.S SUB.S STA.S
APPENDICES

(3) Unsigned 32-bit binary data – unsigned 16-bit binary data = unsigned 32-bit binary data
[DM00000/DM00001] – DM00002 = [DM00010/DM00011]

CR2002 DM00002 DM00002


LDA EXT STA.D

DM00000 DM00002 DM00010


About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

LDA.D SUB.D STA.D

(4) Signed 32-bit binary data – signed 16-bit binary data = signed 32-bit binary data
[DM00000/DM00001] – DM00002 = [DM00010/DM00011]

CR2002 DM00002 DM00002


LDA.S EXT.S STA.L

DM00000 DM00002 DM00010


LDA.L SUB.L STA.L

(5) Unsigned 32-bit binary data – unsigned 32-bit binary data = unsigned 32-bit binary data
[DM00000/DM00001] – [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA.D SUB.D STA.D

(6) Signed 32-bit binary data – signed 32-bit binary data = signed 32-bit binary data
[DM00000/DM00001] – [DM00002/DM00003] = [DM00010/DM00011]

CR2002 DM00000 DM00002 DM00010


LDA.L SUB.L STA.L

A-4
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

■ Multiplication (MUL)
(1) Unsigned 16-bit binary data x unsigned 16-bit binary data = unsigned 32-bit binary data
DM00000 x DM00001 = [DM00010/DM00011]

CR2002 DM00000 DM00001 DM00010


LDA MUL STA.D

(2) Signed 16-bit binary data x signed 16-bit binary data = signed 32-bit binary data
DM00000 x DM00001 = [DM00010/DM00011]

CR2002 DM00000 DM00001 DM00010


LDA.S MUL.S STA.L

APPENDICES
(3) Unsigned 16-bit binary data x unsigned 32-bit binary data = unsigned 64-bit binary data
DM00000 x [DM00002/DM00003] = [DM00010/DM00011/DM00012/DM00013]

CR2002 DM00000 DM00002 DM00010


LDA EXT MUL.D STA.D

TM000 DM00012

About Storage of Arithmetic Operations (Internal Registers/Temporary memory)


LDA.D STA.D

(4) Unsigned 16-bit binary data x unsigned 32-bit binary data = unsigned 64-bit binary data
DM00000 x [DM00002/DM00003] = [DM00010/DM00011/DM00012/DM00013]

CR2002 DM00000 DM00002 DM00010


LDA.S EXT.S MUL.L STA.L

TM000 DM00012
LDA.L STA.L

(5) Unsigned 32-bit binary data x unsigned 32-bit binary data = unsigned 64-bit binary data
[DM00000/DM00001] x [DM00002/DM00003] = [DM00010/DM00011/DM00012/DM00013]

CR2002 DM00000 DM00002 DM00010


LDA.D MUL.D STA.D

TM000 DM00012
LDA.D STA.D

(6) Signed 32-bit binary data x signed 32-bit binary data = signed 64-bit binary data
[DM00000/DM00001] x [DM00002/DM00003] = [DM00010/DM00011/DM00012/DM00013]

CR2002 DM00000 DM00002 DM00010


LDA.L MUL.L STA.L

TM000 DM00012
LDA.L STA.L

A-5
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

■ Division (DIV)
(1) Unsigned 16-bit binary data ÷ unsigned 16-bit binary data = unsigned 16-bit binary data
Remainder: Unsigned 16-bit binary data
DM00000 ÷ DM00001 = DM00010 to DM00020

CR2002 DM00000 DM00001 DM00010


LDA EXT DIV STA

TM001 DM00020
LDA STA

(2) Signed 16-bit binary data ÷ signed 16-bit binary data = signed 16-bit binary data
Remainder: Signed 16-bit binary data
DM00000 ÷ DM00001 = DM00010 to DM00020

CR2002 DM00000 DM00001 DM00010


LDA.S EXT.S DIV.S STA.S
APPENDICES

TM001 DM00020
LDA.S STA.S

(3) Unsigned 32-bit binary data ÷ unsigned 16-bit binary data = unsigned 32-bit binary data
Remainder: Unsigned 16-bit binary data
[DM00000/DM00001] ÷ DM00002 = [DM00010/DM00011] to DM00020

CR2002 DM00001 TM000 DM00000 DM00002 DM00010


LDA STA LDA DIV STA.D
About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

TM001 DM00020
LDA STA

(4) Signed 32-bit binary data ÷ signed 16-bit binary data = signed 32-bit binary data
Remainder: Signed 16-bit binary data
[DM00000/DM00001] ÷ DM00002 = [DM00010/DM00011] to DM00020

CR2002 DM00001 TM000 DM00000 DM00002 DM00010


LDA.S STA.S LDA.S DIV.S STA.L

TM001 DM00020
LDA.S STA.S

(5) Unsigned 32-bit binary data ÷ unsigned 32-bit binary data = unsigned 32-bit binary data
Remainder: Unsigned 32-bit binary data
[DM00000/DM00001] ÷ [DM00002/DM00003] = [DM00010/DM00011] to [DM00012/
DM00013]

CR2002 DM00000 DM00002 DM00010


LDA.D EXT.D DIV.D STA.D

TM002 DM00020
LDA.D STA.D

(6) Unsigned 32-bit binary data ÷ unsigned 32-bit binary data = unsigned 32-bit binary data
Remainder: Unsigned 32-bit binary data
[DM00000/DM00001] ÷ [DM00002/DM00003] = [DM00010/DM00011] to [DM00012/
DM00013]

CR2002 DM00000 DM00002 DM00010


LDA.L EXT.L DIV.L STA.L

TM002 DM00020
LDA.L STA.L

A-6
1 About Storage of Arithmetic Operations (Internal Registers/Temporary memory)

(7) Unsigned 32-bit binary data x unsigned 32-bit binary data ÷ unsigned 32-bit binary data
= unsigned 64-bit binary data
Remainder: Unsigned 32-bit binary data
[DM00000/DM00001] x [DM00002/DM00003] ÷ [DM00004/DM00005] = [DM00010/DM00011/
DM00012/DM00013] to [DM00020/DM00021]

CR2002 DM00000 DM00002 DM00004 DM00010


LDA.D MUL.D DIV.D STA.D

TM000 DM00012 TM002 DM00020


LDA.D STA.D LDA.D STA.D

(8) Signed 32-bit binary data x signed 32-bit binary data ÷ signed 32-bit binary data
= signed 64-bit binary data
Remainder: Signed 32-bit binary data
[DM00000/DM00001] x [DM00002/DM00003] ÷ [DM00004/DM00005]
= [DM00010/DM00011/DM00012/DM00013] to [DM00020/DM00021]

APPENDICES
CR2002 DM00000 DM00002 DM00004 DM00010
LDA.L MUL.L DIV.L STA.L

TM000 DM00012 TM002 DM00020


LDA.L STA.L LDA.L STA.L

■ Square root (ROOT)

About Storage of Arithmetic Operations (Internal Registers/Temporary memory)


(1) Square root of unsigned 16-bit binary data
DM00000 = DM00010

CR2002 DM00000 DM00010


LDA EXT ROOT STA

(2) Square root of signed 16-bit binary data


DM00000 = DM00010

CR2002 DM00000 DM00010


LDA.S EXT.S ROOT.S STA.S

(3) Square root of unsigned 32-bit binary data


[DM00000/DM00001] = [DM00010/DM00011]

CR2002 DM00000 DM00010


LDA.D EXT.D ROOT.D STA.D

(4) Square root of signed 32-bit binary data


[DM00000/DM00001] = [DM00010/DM00011]

CR2002 DM00000 DM00010


LDA.L EXT.L ROOT.L STA.L

A-7
2 Error No. Tables

2 Error No. Tables


The following describes error messages and remedies to take when an error message is displayed.

No. Messages Cause Remedy


10 CALL Nest Sub-routine exceeds the nesting This error occurs during ladder execu-
level of 4. tion. Review the ladder paying attention
11 FOR Nest FOR to NEXT instructions exceed to how sub-routines are used and how the
the nesting level of 8. INT instruction is used.
12 INT Nest Five or more interrupts occurred This error occurs during ladder execu-
simultaneously. tion. Review the ladder paying attention
to how the INT instruction is used.
13 MPS Nest MPS to MPP instructions exceed This error occurs during ladder execu-
the nesting level of 8. tion. Review the ladder paying attention
to how sub-routines are used and how the
INT instruction is used.
14 BREAK The number of BREAK instructions This error occurs during conversion.
APPENDICES

between FOR and NEXT exceeds Limit the number of BREAK instructions
eight. between FOR and NEXT to within eight.
(In a nested structure, the number
of nested instructions exceeds
eight.)
15 Convert System error occurred. Clear the error, and turn the unit ON
16 Opecode again.
17 Operand If this error occurs frequently, contact
your agent.
Error No. Tables

18 Operand Range
19 Object Size The ladder object size has ex- Ether add on expanded memory, or re-
ceeded the maximum size. duce the size of the ladder program.
20 Code Size The ladder code size has exceeded
the maximum size.
30 Cycletime Over Scan time is 300 ms or faster. Review the program.
Make sure that there are not too many
repeated FOR to NEXT instructions.
Make sure that the interrupt program is
not being executed at a fast rate.
40 No Ladder The program is not registered. Register the ladder program before oper-
ating the main unit.
50 Unit Kobetu Expansion and Special Unit settings Use the Ladder Support software or
Chksum are corrupted. Memory Card to register unit setup infor-
51 Unit Conf Info Unit setup information is not set. mation.

A-8
2 Error No. Tables

No. Messages Cause Remedy


52 No Unit Connection Expansion or Special Units are not Turn the KV OFF, then connect the Ex-
connected even though they are set pansion or Special Unit set in Unit Editor.
as connected in the unit setup
information.
53 S-Unit BSI Timeout A probable cause is that noise has Remove any sources of noise.
caused bus communications to If this error occurs frequently, contact
stop. your agent.
54 Unit Number The actual number of connected units Turn the KV OFF, then connect the Ex-
differs from the number of Expansion pansion or Special Unit set in Unit Editor.
and Special Units set in Unit Editor.
55 Unit Type The type of actual units differs from
the number of Expansion and Special
Units set in Unit Editor.
56 Extend Bus Com A probable cause is that noise has Remove any sources of noise.
Error caused bus communications to stop. If this error occurs frequently, contact
your agent.

APPENDICES
57 No End Unit The End Unit is not connected. Turn the KV OFF, and connect the End
Unit.
80 FROM Broken Flash ROM error Contact your agent.
81 SRAM Broken Hardware malfunction
82 Extend Memory Expanded memory was removed or Execute an all clear, and transfer the
Change inserted. ladder program again.
83 Low Battery The backup battery voltage has Replace the backup battery.
dropped.

Error No. Tables


84 SRAM Backup The content (DM, CM, DR, RLY, TM, Replace the backup battery, and execute
C current values) of RAM is corrupted an all clear. This erases the ladder pro-
as the voltage of the backup battery gram, so transfer the ladder program
has dropped. again.
85 RTC Low Voltage A probable cause is that the clock Replace the backup battery, check the
value is corrupted as the voltage of clock value, and set the clock again as
the backup battery has dropped. required.
86 NMI Only System error occurred. Clear the error, and turn the unit ON
again.
If this error occurs frequently, contact
your agent.
87 Memory Card Error A probable cause is that the Memory Write protect (memory switch)
Card is damaged, data is incorrect, or ↓
magnetism or noise has caused the
Remove the memory switch.
Memory Card to stop functioning.
File content is in error.

Store programs and data files matched to
the environment.

A-9
2 Error No. Tables

No. Messages Cause Remedy


120 Watch Dog Timer System error occurred. Clear the error, and turn the unit ON
121 Stack Overflow again.
122 System If this error occurs frequently, contact
your agent.
123 Device Range
124 Resource
125 Error Buffer Overflow More than 16 system internal errors
have occurred.
126 Error Buffer Invalid System error occurred.
127 Code Size Automatic load failed. Write protect (memory switch)
A probable cause is that noise has ↓
caused the unit to stop operating. Remove the memory switch.
File content is in error.

Store programs and data files matched to
APPENDICES

the environment.
255 No Error Message System error occurred. Clear the error, and turn the unit ON
again.
If this error occurs frequently, contact
your agent.
Error No. Tables

A-10
3 Operation Processing Times List

3 Operation Processing Times List


This appendix presents a list of processing times for each of the instructions and object sizes after
compilation.

Basic Instructions
● Contact instructions ● Output instructions
Instruction Byte Object Processing time (µs) Instruction Byte Object Processing time (µs)
size size MIN MAX size size MIN MAX
LD 4 10 0.1 0.4 OUT 4 12 0.5 0.8
LDB OUB 4 12 0.5 0.8
AND 4 6 0.4 0.4 SET 4 12 0.9 4.1
ANB
RES 4 12 0.9 3.5
OR 4 6 0.4 0.4
KEEP 4 8 2.6 2.6
ORB
DIFU 4 12 2.8 2.8
LDP 4 14 3 3

APPENDICES
LDF DIFD 4 12 2.8 2.8
ANP 4 12 3 3 ONDL 7 12 6 6
ANF OFDL 7 12 6.3 6.3
ORP 4 12 3 3 SHOT 7 26 5.7 5.7
ORF
FLIK 10 26 7.8 7.8
ALT 4 12 3.7 3.7
● Bit contact instructions
Instruction Byte Object Processing time (µs) ● Bit output instructions

Operation Processing Times List


size size MIN MAX
Instruction Byte Object Processing time (µs)
BLD 6 12 2 2.3 size size MIN MAX
BLDB
BOUT 6 10 2.3 2.5
BAND 6 10 2 2.3
BANB BOUB 6 10 2.3 2.5

BOR 6 10 2 2.3 BSET 6 10 2.1 2.3


BORB BRES 6 10 2.1 2.3

● Comparison contact instructions ● Timer/counter instructions


Instruction Byte Object Processing time (µs) Instruction Byte Object Processing time (µs)
size size MIN MAX size size MIN MAX
=(.U) 7 18 5.8 16.7 TMR 4 6 5.7 5.7
<(.U) TMH 4 6 5.7 5.7
>(.U)
TMS 4 6 5.7 5.7
< >(.U)
<=(.U) C 7 10 6.9 6.9
>=(.U) ITVL(.U) 7 10 11.4 35.9
=.D 9 18 6.1 20.8 ITVL.S 8 10 11.4 36.7
<.D
UDC 4 6 4.3 7.3
>.D
< >.D UDT 4 6 3.6 7.2
<=.D
>=.D
=.S 7 18 7.6 18.5 ● Connect/end instructions
<.S Instruction Byte Object Processing time (µs)
>.S size size MIN MAX
< >.S
NOP 1 0 0 0
<=.S
>=.S END 1 22 0 0
=.L 9 18 8.3 23.0 ENDH 1 0 0 0
<.L CON 1 0 0 0
>.L MPS 1 4 2.8 2.8
< >.L
<=.L MRD 1 4 1.0 1.0
>=.L MPP 1 4 2.7 2.7
ANL 1 4 0.2 0.2
ORL 1 4 0.2 0.2

A-11
3 Operation Processing Times List

Applied Instructions Arithmetic Operation Instructions


● Shift instructions ● Differential execution type instructions
Instruction Byte Object Processing time (µs) Instruction Byte Object Processing time (µs)
size size MIN MAX size size MIN MAX
SFT 7 14 12.4 870.0*1 @onwards +1 +12 +4.2 +4.2

* 1 When 500 to 59915 is set to the operand Differential execution type arithmetic operation in-
structions are provided. The result of execution be-
comes the value obtained by adding the above fig-
● Memory switch instructions
ures to the each scan execution type instructions.
Instruction Byte Object Processing time (µs)
size size MIN MAX
● Data move instructions
MEMSW 6 0 0 0
Instruction Byte Object Processing time (µs)
size size MIN MAX
● Step instructions DW(.U) 7 10 1.7 1.7
Processing time (µs) DW.S 8 10 1.7 1.7
APPENDICES

Instruction Byte Object


size size MIN MAX DW.D 10 12 2.1 2.1
STP 4 10 0.7 0.7 DW.L 10 12 2.1 2.1
STE 1 0 0 0 LDA(.U) 4 8 1.6 7.5
LDA.S 5 8 1.6 7.5
LDA.D 7 8 1.7 10.6
● Stage processing instructions LDA.L 7 8 1.7 10.6
Instruction Byte Object Processing time (µs) STA(.U) 4 8 1.5 9.2
size size MIN MAX
STA.S 5 8 1.5 9.2
Operation Processing Times List

STG 4 16 2.7 2.7


STA.D 5 8 1.7 10.2
JMP 4 8 2.7 2.7
STA.L 5 8 1.7 10.2
ENDS 1 4 1.9 1.9
TMAX 3 6 2.0 2.0
W-ON 7 10 2.4 2.5
MOV(.U) 4 8 5.1 19.9
W-OFF 7 10 2.4 2.5
MOV.S 5 8 5.1 19.9
W-UE 7 16 5.2 5.4
MOV.D 10 14 5.2 21.8
W-DE 7 16 5.2 5.4
MOV.L 10 14 5.2 21.8
BMOV 10 14 12.9 8960.0*1
● Flow instructions FMOV(.U) 10 16 6.5 12330.0*2

Processing time (µs) FMOV.S 11 16 6.5 12330.0*2


Instruction Byte Object
size size MIN MAX FMOV.D 13 16 6.7 9300.0*3
MC 1 2 0.1 0.1 FMOV.L 13 16 6.7 9300.0*3
MCR 1 2 0.1 0.1 *1 When 39999 words are transferred
CALL 3 8 2.9 2.9 *2 When 40000 words are transferred
SBN 3 4 0.2 0.2 *3 When 20000 double-words are transferred
RET 1 4 2.9 2.9
FOR 4 22 5.1 6.4
NEXT 1 4 0 0
BREAK 1 14 1.3 1.3

A-12
3 Operation Processing Times List

Arithmetic Operation Instructions


(continued)
● Arithmetic/comparison instructions ● Data shift instructions
Instruction Byte Object Processing time (µs) Instruction Byte Object Processing time (µs)
size size MIN MAX size size MIN MAX
ADD(.U) 4 8 2.5 8.4 SRA(.U) 3 6 2.2 5.2
ADD.S 5 8 2.6 8.5 SRA.D 4 6 2.2 8.5
ADD.D 7 8 2.7 11.4 SLA(.U) 3 6 2.2 5.2
ADD.L 7 8 2.7 11.4 SLA.D 4 6 2.2 8.5
SUB(.U) 4 8 2.8 8.8 RRA(.U) 3 6 2.4 5.5
SUB.S 5 8 2.5 8.5 RRA.D 4 6 2.5 8.8
SUB.D 7 8 2.6 11.4 RLA(.U) 3 6 2.5 5.5
SUB.L 7 8 2.7 11.4 RLA.D 4 6 2.5 8.8
MUL(.U) 4 8 3.5 9.4 WSR(.U) 10 12 17.9 22570.0*1
MUL.S 5 8 4.2 11.0 WSR.D 11 12 18.8 22570.0*2

APPENDICES
MUL.D 7 8 4.3 14.5 WSL(.U) 10 12 17.9 20500.0*1
MUL.L 7 8 6.2 16.8 WSL.D 11 12 18.5 20500.0*2
DIV(.U) 4 8 5.5 11.7
*1 When 39999 words are shifted
DIV.S 5 8 16.1 22.1 *2 When 19999 double-words are shifted
DIV.D 7 8 9.8 51.3
DIV.L 7 8 10.8 55.6
● Data transfer instructions
INC(.U) 4 8 3.4 3.4
Instruction Byte Object Processing time (µs)
INC.S 5 8 3.6 3.6
size size MIN MAX

Operation Processing Times List


INC.D 5 8 3.9 3.9
TBCD(.U) 1 4 1.6 1.6
INC.L 5 8 4.1 4.1
TBCD.D 2 4 1.6 1.6
DEC(.U) 4 8 3.5 3.5
TBIN(.U) 1 4 2.3 2.3
DEC.S 5 8 3.6 3.6
TBIN.D 2 4 2.3 2.3
DEC.D 5 8 4.0 4.0
MPX 3 6 2.4 2.4
DEC.L 5 8 4.1 4.1
DMX 1 4 1.5 1.5
ROOT(.U) 1 4 18.8 18.8
GRY(.U) 1 4 1.1 1.1
ROOT.S 2 4 19.4 19.4
GRY.D 2 4 1.1 1.1
ROOT.D 2 4 41.8 41.8
RGRY(.U) 1 4 3.2 3.2
ROOT.L 2 4 42.3 42.3
RGRY.D 2 4 5.9 5.9
CMP(.U) 4 8 2.9 8.8
DISN 7 12 4.3 4.3
CMP.S 5 8 3.0 8.9
UNIN 7 12 4.1 4.1
CMP.D 7 8 3.0 11.7
DISB 7 12 2.4 2.4
CMP.L 7 8 3.4 12.1
UNIB 7 12 2.3 2.3
ZCMP(.U) 7 14 5.4 16.5
SWAP(.U) 1 4 1.1 1.1
ZCMP.S 8 14 6.7 18.3
SWAP.D 2 4 1.1 1.1
ZCMP.D 12 14 7.8 23.4
XCH(.U) 7 14 4.4 12.3
ZCMP.L 12 14 7.8 23.4
XCH.D 8 14 5.0 13.0

● Logical arithmetic operation instructions


Instruction Byte Object Processing time (µs)
size size MIN MAX
ANDA(.U) 4 8 2.2 8.0
ANDA.D 7 8 2.4 11.0
ORA(.U) 4 8 2.2 8.0
ORA.D 7 8 2.4 11.1
EORA(.U) 4 8 2.2 8.0
EORA.D 7 8 2.4 11.0
COM(.U) 1 4 1.4 1.4
COM.D 2 4 1.4 1.4
NEG(.U) 1 4 0.9 0.9
NEG.D 2 4 0.9 0.9

A-13
3 Operation Processing Times List

Arithmetic Operation Instructions Extended Instructions


(continued) ● Data processing instructions
● Floating point instructions Instruction Byte Object Processing time (µs)
size size MIN MAX
Instruction Byte Object Processing time (µs)
size size MIN MAX HKEY 7 12 11.0 42.0
FLOAT(.U) 1 4 3.0 3.0 BCNT(.U) 1 4 5.7 5.7
FLOAT.S 2 4 3.6 3.6 BCNT.D 2 4 9.8 9.8
FLOAT.D 2 4 5.0 5.0 DCNT(.U) 7 10 3.8 22570.0*1
FLOA0.L 2 4 5.4 5.4 DCNT.D 8 10 4.1 14370.0*2
INTG(.U) 1 4 11.5 11.5 SER(.U) 7 12 4.0 24617.0*1
INTG.S 2 4 11.7 11.7 SER.D 8 12 4.4 15404.0*2
INTG.D 2 4 11.5 11.5 MIN(.U) 7 10 5.0 22550.0*1
INTG.L 2 4 11.7 11.7
MIN.D 8 10 6.9 29810.0*2
DW.F 10 12 2.1 2.1
MIN.S 8 10 5.0 22550.0*1
LDA.F 7 8 1.7 10.6
MIN.L 8 10 6.9 29810.0*2
STA.F 5 8 1.7 1.7
APPENDICES

MOV.F 10 14 5.2 5.2 MAX(.U) 7 10 5.0 22550.0*1


FMOV.F 13 16 6.7 9300*1 MAX.D 8 10 6.9 29810.0*2
DISF 10 16 810 810 MAX.S 8 10 5.0 22550.0*1
UNIF 10 16 4.5 4.5 MAX.L 8 10 6.9 29810.0*2
ADD.F 7 8 8.7 18.3 AVG(.U) 7 10 9.1 20490.0*1
SUB.F 7 8 8.9 19.3 AVG.D 8 10 6.1 15640.0*2
MUL.F 7 8 8.3 20.7 AVG.S 8 10 10.6 20500.0*1
DIV.F 7 8 37.4 42.3
AVG.L 8 10 7.4 25020.0*2
ROOT.F 2 4 54.9 54.9
12340.0*1,*2
Operation Processing Times List

ZRES 7 12 10.1
CMP.F 7 8 11.2 19.8
FIFOW(.U) 7 12 7.0 7.0
ZCMP.F 12 14 18.9 34.3
FIFOW.D 8 12 11.3 11.3
EXP 1 4 360 360
LOG 1 4 370 370 FIFOR(.U) 7 12 9.5 20500.0*3
RAD 1 4 42.7 42.7 FIFOR.D 8 12 16.0 20500.0*4
DEG 1 4 44.3 44.3 EXT(.U) 1 4 1.5 1.5
SIN 1 4 210 210 EXT.S 2 4 1.5 1.5
COS 1 4 190 190 EXT.D 2 4 1.7 1.7
TAN 1 4 290 290 EXT.L 2 4 1.8 1.8
ASIN 1 4 440 440
ACOS 1 4 460 460
*1 When 40000 words are calculated
ATAN 1 4 230 230
*2 When 20000 double-words are calculated
*3 When the data of 39998 words is stored
*1 When 20000 double-words are calculated *4 When the data of 19998 double-words is stored
● Text processing instructions
Instruction Byte Object Processing time (µs) ● Clock processing instructions
size size MIN MAX Processing time (µs)
Instruction Byte Object
ASC 1 4 2.4 2.4 size size MIN MAX
RASC 1 4 2.4 2.4 WTIME 4 8 39.7 39.7
DASC(.U) 7 14 30.2 35.4 SEC 7 12 21.8 21.8
DASC.D 8 14 61.8 67.0
RSEC 7 12 34.1 34.1
DASC.S 8 14 30.7 36.2
AJST 1 4 32.7 32.7
DASC.L 8 14 62.7 67.9
RDASC(.U) 7 14 32.3 37.2
RDASC.D 8 14 60.9 65.8
RDASC.S 8 14 35.0 40.0
RDASC.L 8 14 62.1 67.1
SMOV 7 14 12.9 480*1
SADD 10 20 28.1 490.0*1
SCMP 7 14 15.8 850.0*1
DISS 7 16 14.4 390.0*1
UNIS 10 16 10.0 160.0*1
LEN 7 14 9.7 180.0*1
RCOM 7 12 63.0 63.0*1
*1 When 255 characters are calculated

A-14
3 Operation Processing Times List

Arithmetic Operation Instructions


(continued)
● Alarm instructions
Instruction Byte Object Processing time (µs)
size size MIN MAX
ARES 1 4 68.4 68.4

● High-speed processing instructions


Instruction Byte Object Processing time (µs)
size size MIN MAX
HSP 4 6 2.6 2.6
DI 1 4 2.4 2.4
EI 1 4 3.0 3.0
INT 4 0 30.0 60.0

APPENDICES
RETI 1 4 45.0 75.0
CTH 6 6 3.0 15.0
CTC 3 0 0 0

● Positioning instructions
Instruction Byte Object Processing time (µs)
size size MIN MAX
PLSX 3 6 6.0 6.0

Operation Processing Times List


PLSY 3 6 6.0 6.0
JOGX 1 4 37.0 37.0
JOGY 1 4 37.0 37.0
ORGX 1 4 79.0 79.0
ORGY 1 4 79.0 79.0
TCHX 1 4 10.0 10.0
TCHY 1 4 10.0 10.0

A-15
4 Differences Between KV-300 & Visual KV Series

4 Differences Between KV-300 & Visual KV Series

Differences in Instructions
■ Changes in data size
Instruction Details of Change
TMR The setting value was changed from 16 bits to 32 bits.
TMH
TMS
C
UDC
CTC
TMIN The digital trimmer value was changed from 16 bits to 32 bits.
APPENDICES

■ Changes in number of operands


Instruction Details of Change
MEMSW The type was changed to a 2-operand type by addition of a memory switch No.
Example: MEMSW 0 $FFFF

■ Changes in target operands


Differences Between KV-300 & Visual KV Series

Instruction Details of Change


SFT Output relay was added to available devices.
W-ON Output relay was added to available devices (No.2 operand).
W-OFF
W-UE
W-DE
MEMSW The No.1 operand was changed from the setting value to the memory switch No. (0,1).
TMIN Trimmer Nos. 1 and 0 were changed to 0 to 7.

■ Changes in differential execution type instructions


Instruction Details of Change
DW Differential type execution was supported.

■ Changes in operation content


Instruction Details of Change
MUL The upper 16 bits of the product are stored to upper 16 bits of the 32-bit internal register
at the same time as TM000.
DIV The upper 16 bits of the product are stored to upper 16 bits of the 32-bit internal register
at the same time as TM000.
ITVL See "Changes in ITVL Instruction" ( page A-17).
MEMSW The content of switch functions was changed.

A-16
4 Differences Between KV-300 & Visual KV Series

Changes in ITVL Instruction


■ Changes from old ITVL instruction
Operation of mode Nos. 00006 to 399999 have been changed. (See "Mode setting of new
instructions" below.)
The storage location of upper and lower total values has been changed.
Suffixes are supported.

■ Mode setting of new instructions


Mode No. DM No. Description
0000 to 0005 Same as pulse measurement mode of old ITVL instruction
(completely compatible)
0006 DM00006 The content of DM00006 is measured to calculate the average
value.

APPENDICES
0007 DM00007 The content of DM00007 is measured to calculate the average
value.
: : :
39998 DM39998 The content of DM39998 is measured to calculate the average
value.
39999 DM39999 The content of DM39999 is measured to calculate the average
value.
40000 onwards Communications is not possible.

Differences Between KV-300 & Visual KV Series


■ Changes in DM measurement mode
There were two DM measurement modes for the old ITVL instruction, a mode for handling values
at every scan (mode No. 0006 to 1999), and a mode for handling values of scans where the PLS
input is ON (mode Nos.10000 to 11999). With the new ITVL instruction, only the latter mode
(mode for handling values of scans where the PLS input is ON ) is supported.

■ About support of suffixes


Two suffixes are supported, ITVL.U and ITVL.S.
ITVL.U Setting values, measurement values, average values are all handled as 16-bit
unsigned data (0 to 65535). Total values are calculated as 32-bit unsigned data.
ITVL.S Setting values, measurement values, average values are all handled as 16-bit signed
data (-32768 to 32767). Total values are calculated as 32-bit unsigned data.

A-17
4 Differences
5 Text Code Table
Between KV-300 & Visual KV Series

5 Text Code Table

ASCII Code Table


APPENDICES
Differences
Text Code Table
Between KV-300 & Visual KV Series

A-18
6 Special Device List

6 Special Device List

Control Relay CR
With control relays (CR0000 to CR3915), you can check the operation state of the CPU Unit, set input time constants,
set high-speed counters, and make other settings.
Control relay reserved for the system cannot be used.
★ Reference pages are the page Nos. of pages in the KV-700 User's Manual. ★

Attribute
Device No. R: Read only Function
Blank: R/W
CR0000 Reserved for system
:
CR0715

APPENDICES
CR0800 Reserved for system
:
CR0915
CR1000 Reserved for system
:
CR1715
CR1800 Reserved for system
CR1801 Reserved for system

Special Device List


CR1802 Reserved for system
CR1803 Reserved for system
CR1804 Reserved for system
CR1805 Reserved for system
:
CR1813
CR1814 Cam switch function, absolute/incremental ON: Absolute
OFF: Incremental

CR1815 Cam switch function, cam switch function stopped when turn ON
and OFF during operation
CR1900 Reserved for system
:
CR2001
CR2002 R ON at all times
CR2003 R OFF at all times
CR2004 R 10 ms clock pulse (at 50% duty)
CR2005 R 100 ms clock pulse (at 50% duty)
CR2006 R 1s clock pulse (at 50% duty)
CR2007 R OFF only for 1 scan at start of operation
CR2008 R ON only for 1 scan at start of operation
CR2009 ON when result of arithmetic operation is minus or overflows
CR2010 R ON when result of arithmetic operation is zero
CR2011 R ON when result of arithmetic operation is plus
CR2012 R ON at arithmetic operation execution error
CR2013 Reserved for system
:
CR2015

A-19
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CR2100 R CTH0 dedicated internal clock (1 µs)
CR2101 R CTH0 dedicated internal clock (10 µs)
CR2102 R CTH0 dedicated internal clock (100 µs)
ON: Execute.
CR2103 Automatically clear CTH0. OFF: Do not execute.
Operation when highspeed ON: Disable output.
CR2104 counter comparator CTC0 Disable/enable direct output to 00500. OFF: Enable output.
ON: Execute.
CR2105 is ON Turn OFF direct output to 00500. OFF: Do not execute.
ON: Execute.
CR2106 Turn ON direct output to 00500. OFF: Do not execute.

CR2107 Invert ON/OFF of output to 00500 each time that high-speed counter ON: Execute.
OFF: D o n o t e x e c u t e .
comparator CTC0 turns ON.
ON: Disable output.
CR2108 Operation when highspeed Disable/enable direct output to 00500. OFF: Enable output.
ON: Execute.
CR2109 counter comparator CTC1 Turn OFF direct output to 00500. OFF: Do not execute.

CR2110 is ON Turn ON direct output to 00500.


ON:
OFF:
Execute.
Do not execute.
APPENDICES

CR2111 Invert ON/OFF of output to 00500 each time that high-speed counter ON: Execute.
OFF: D o n o t e x e c u t e .
comparator CTC1 turns ON.
ON: Execute.
CR2112 Automatically clear CTH0 when high-speed counter comparator CTC1 is ON. OFF: Do not execute.

CR2113 Single-phase 1X 2X 4X 2 pulses


High-speed counter CTH0
W/out direction W/ direction
count input mode selec-
CR2114 CR2113 OFF ON OFF ON OFF ON
tion.
CR2114 OFF OFF ON ON OFF OFF
CR2115 CR2115 OFF OFF OFF OFF ON ON
CR2200 R CTH1 dedicated internal clock (1 µs)
Special Device List

CR2201 R CTH1 dedicated internal clock (10 µs)


CR2202 R CTH1 dedicated internal clock (100 µs)
ON: Execute.
CR2203 Operation when highspeed Automatically clear CTH1. OFF: Do not execute.
ON: Disable output.
CR2204 counter comparator CTC2 Disable/enable direct output to 00501. OFF: Enable output.

CR2205 is ON Turn OFF direct output to 00501.


ON:
OFF:
Execute.
Do not execute.
ON: Execute.
CR2206 Turn ON direct output to 00501. OFF: Do not execute.

CR2207 Invert ON/OFF of output to 00501 each time that high-speed counter ON: Execute.
OFF: D o n o t e x e c u t e .
comparator CTC2 turns ON.
ON: Disable output.
CR2208 Operation when highspeed Disable/enable direct output to 00501. OFF: Enable output.
ON: Execute.
CR2209 counter comparator CTC3 Turn OFF direct output to 00501. OFF: Do not execute.
is ON ON: Execute.
CR2210 Turn ON direct output to 00501. OFF: Do not execute.

CR2211 Invert ON/OFF of output to 00501 each time that high-speed counter ON: Execute.
OFF: D o n o t e x e c u t e .
comparator CTC3 turns ON.
ON: Execute.
CR2212 Automatically clear CTH1 when high-speed counter comparator CTC3 is ON. OFF: Do not execute.

Single-phase 1X 2X 4X 2 pulses
CR2213 High-speed counter CTH1
W/out direction W/ direction
count input mode selec-
CR2214 CR2213 OFF ON OFF ON OFF ON
tion.
CR2214 OFF OFF ON ON OFF OFF
CR2215 CR2215 OFF OFF OFF OFF ON ON
ON: Execute.
CR2300 Disable external outputs OFF: Do not execute.
ON: Execute.
CR2301 Disable external input refreshing OFF: Do not execute.

CR2302 Reserved for system


ON: Enabled
CR2303 Fixed scan time operation OFF: Disabled

CR2304 R ON for 1 scan only at fixed scan time setting value exceeded
CR2305 Set input time constant of all CPU Unit inputs. ON: Set.
OFF: Do not set. (10 ms)
(Determine referring to CM1620 when ON.)
CR2306 R ON at backup battery error
CR2307 Reserved for system
:
CR2315

A-20
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
Unused Up edge Down edge Level
CR2400 CTH0 external signal preset
CR2400 OFF ON OFF ON
CR2401 CR2401 OFF OFF ON ON
ON: Use.
CR2402 CTH0 ring counter OFF: Do not use.

CR2403 Reserved for system


Unused Up edge Down edge Level
CR2404 CTH1 external signal preset
CR2400 OFF ON OFF ON
CR2405 CR2405 OFF OFF ON ON
ON: Use.
CR2406 CTH1 ring counter OFF: Do not use.

CR2407 Reserved for system


:
CR2413
ON: Execute.
CR2414 Specified frequency pulse output OFF: Do not execute.

APPENDICES
CR2415 Specified frequency pulse output, error
ON: Execute.
CR2500 Frequency counter, start of operation OFF: Do not execute.

CR2501 Frequency counter, Single-phase, Single-phase, 2-phase 1X 2 pulses


input source setting w/out direction w/ direction
CR2502 CR2501 OFF ON OFF ON
CR2502 OFF OFF ON ON
ON: rpm
CR2503 Frequency counter, Hz/rpm switching OFF: Hz
ON: Use.
CR2504 Frequency counter, user function for updating rpm by single rotation OFF: Do not use.

CR2505 Reserved for system

Special Device List


:
CR2507
ON: Execute.
CR2508 Cam switch, start of operation OFF: Do not execute.

CR2509 Cam switch, output response impossible warning (generated when output does not track during cam
switch operation)
CR2510 R Cam switch, error
CR2511 Reserved for system
:
CR2615
CR2700 INT0 interrupt polarity Up edge Down edge Both edges
CR2700 OFF ON OFF ON
CR2701 CR2701 OFF OFF ON ON

CR2702 INT1 interrupt polarity Up edge Down edge Both edges


CR2702 OFF ON OFF ON
CR2703 CR2703 OFF OFF ON ON

Up edge Down edge Both edges


CR2704 INT2 interrupt polarity
CR2704 OFF ON OFF ON
CR2705 CR2705 OFF OFF ON ON

CR2706 INT3 interrupt polarity Up edge Down edge Both edges


CR2706 OFF ON OFF ON
CR2707 CR2707 OFF OFF ON ON

CR2708 Reserved for system


:
CR2715
CR2800 Serial communications, send break signal (sent while relay is ON)
CR2801 R Serial communications, ON for 1 scan only at reception of text data
CR2802 R Serial communications, text data download error

A-21
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CR2803 R Serial communications, ON for 1 scan only at text data receive error
CR2804 Serial communications, start sending text data (ON while data is being sent)
ON: Perform.
CR2805 Serial communications, receive text data in word units OFF: Do not perform.
ON: Perform.
CR2806 Serial communications, send text data in word units OFF: Do not perform.

CR2807 Reserved for system


:
CR2813
ON: Execute.
CR2814 Suppress zero during execution of DASC instruction (all suffixes) OFF: Do not execute.
ON: Execute.
CR2815 Omit + sign during execution of DASC.S, DASC.L and DASC.F. OFF: Do not execute.
ON: Execute.
CR2900 Access window, display user message 1 OFF: Do not execute.
ON: Execute.
CR2901 Access window, display user message 2 OFF: Do not execute.

CR2902 Reserved for system


:
APPENDICES

CR2915
CR3000 X-axis, limit switch CW input
CR3001 X-axis, limit switch CCW input
CR3002 X-axis, origin sensor input
CR3003 X-axis, stop sensor input
CR3004 R X-axis, zero return in operation
CR3005 X-axis, zero return completed
CR3006 Reserved for system
Special Device List

CR3007 X-axis, error/clear error


CR3008 X-axis, warning/clear warning
CR3009 X-axis, ON during pulse output/emergency stop
CR3010 X-axis, start driver operation
CR3011 X-axis, change current value request (level detection)
CR3012 X-axis, change operation speed request (level detection)
CR3013 Reserved for system
:
CR3015
CR3100 Y-axis, limit switch CW input
CR3101 Y-axis, limit switch CCW input
CR3102 Y-axis, origin sensor input
CR3103 Y-axis, stop sensor input
CR3104 R Y-axis, zero return in operation
CR3105 Y-axis, zero return completed
CR3106 Reserved for system
CR3107 Y-axis, error/clear error
CR3108 Y-axis, warning/clear warning
CR3109 Y-axis, ON during pulse output/emergency stop
CR3110 Y-axis, start driver operation
CR3111 Y-axis, change current value request (level detection)
CR3112 Y-axis, change operation speed request (level detection)
CR3113 Reserved for system
:
CR3115

A-22
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CR3200 Logging function, trigger setting
CR3201
CR3202 Logging function, time stamp ON
CR3203 Logging function, start
CR3204 Logging function, write during operation
CR3205 Logging function, CPU buffer overflow
CR3206 Logging function, registered device error
CR3207 Logging function, write error
CR3208 Logging function, MMC data overflow
CR3209 Logging function, MMC insufficient free space
CR3210 Logging function, logging execution in progress
CR3211 Reserved for system

APPENDICES
:
CR3215
CR3300 Alarm relay Alarm 0
: :
CR3415 Alarm 31
CR3500 R Turn ON if one of alarm relays CR3300 to CR3415 is ON.
ON: Leave history.
CR3501 Leave history when alarm relay state changes to OFF from ON. OFF: Do not leave history.

CR3502 Reserved for system


:

Special Device List


CR3513
CR3514 HKEY instruction, multiple keys disabled
CR3515 R HKEY instruction, end of scan
CR3600 R HKEY instruction information storage area
:
CR3615
CR3700 Operation panel KV-D30, F1 (customized switch 1)
CR3701 Operation panel KV-D30, F2 (customized switch 2)
CR3702 Operation panel KV-D30, F3 (customized switch 3)
CR3703 Operation panel KV-D30, F4 (customized switch 4)
CR3704 Operation panel KV-D30, LED1 (customized lamp 1)
CR3705 Operation panel KV-D30, LED2 (customized lamp 2)
CR3706 Operation panel KV-D30, LED3 (customized lamp 3)
CR3707 Operation panel KV-D30, LED4 (customized lamp 4)
CR3708 Operation panel KV-D30, green backlight (lights when ON)
CR3709 Operation panel KV-D30, red backlight (lights when ON)
ON: Japanese
CR3710 Operation panel KV-D30, system message display OFF: English
ON: Sound.
CR3711 Operation panel KV-D30, sound buzzer OFF: Turn off.
ON: Positive display
CR3712 Operation panel KV-D30, screen display setting OFF: Negative display
ON: Enabled
CR3713 Operation panel KV-D30, enable alarm interrupt OFF: Disabled

CR3714 Operation panel KV-D30, page switching


(Switch to page of CM0401 value is forcibly turned OFF by up edge.)
ON: Disabled
CR3715 Operation panel KV-D30, page switching by "▲" "▼" keys disabled OFF: Enabled

CR3800 Operation panel KV-D30, output 0 ON when panel is ON


CR3801 Operation panel KV-D30, output 1 ON when panel is ON
CR3802 Reserved for system
:
CR3915

A-23
6 Special Device List

Control Memory CM
With control memory (CM0000 to CM3999), you can set various special CPU Unit functions.
Control memory reserved for the system cannot be used.

Attribute
Device No. R: Read only Function
Blank: R/W
CM0000 1st line display device setting
CM0001 1st line display device setting
CM0002 2nd line display device setting
CM0003 2nd line display device setting
CM0004 Operation panel KV-D30 3rd line display device setting
page 0
CM0005 3rd line display device setting
CM0006 4th line display device setting
CM0007 4th line display device setting
APPENDICES

CM0008 Reserved for system


CM0009
CM0010 Page 1, display device setting
: Operation panel KV-D30 :
CM0189 Page 18, display device setting
CM0190 1st line display device setting
CM0191 1st line display device setting
CM0192 2nd line display device setting
Special Device List

CM0193 2nd line display device setting


CM0194 Operation panel KV-D30 3rd line display device setting
page 19
CM0195 3rd line display device setting
CM0196 4th line display device setting
CM0197 4th line display device setting
CM0198 Reserved for system
CM0199
CM0200 1st line display attribute setting
CM0201 1st line display attribute setting
CM0202 2nd line display attribute setting
CM0203 2nd line display attribute setting
CM0204 Operation panel KV-D30 3rd line display attribute setting
page 0
CM0205 3rd line display attribute setting
CM0206 4th line display attribute setting
CM0207 4th line display attribute setting
CM0208 Template 1 setting
CM0209 Template 2 setting

A-24
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM0210 Page 1, display attribute setting
: Operation panel KV-D30 :
CM0389 Page 18, display attribute setting
CM0390 1st line display attribute setting
CM0391 1st line display attribute setting
CM0392 2nd line display attribute setting
CM0393 2nd line display attribute setting
Operation panel KV-D30
CM0394 3rd line display attribute setting
page 19
CM0395 3rd line display attribute setting
CM0396 4th line display attribute setting
CM0397 4th line display attribute setting
CM0398 Template 1 setting
CM0399 Template 2 setting

APPENDICES
CM0400 Operation panel KV-D30, move enable/disable setting
CM0401 Operation panel KV-D30, page switching setting
CM0402 Operation panel KV-D30, current display page
CM0403 Reserved for system
:
CM0409
CM0410 Operation panel KV-D30, used by CM direct accessing
:

Special Device List


CM0415
CM0416 Reserved for system
:
CM0699
CM0700 R Read from calendar (year)
CM0701 R Read from calendar (month)
CM0702 R Read from calendar (day)
CM0703 R Read from calendar (hour)
CM0704 R Read from calendar (minute)
CM0705 R Read from calendar (second)
CM0706 R Read from calendar (day of week)
CM0707 Reserved for system
:
CM0719
CM0720 R Scan time measurement value (Average value of each tens scans is entered to this memory.) (in 0.1
ms units)
CM0721 Fixed scan time operation setting value (in 1 ms units)
CM0722 R Scan time (in 1 ms units) when the setting value is exceeded during fixed scan time operation is
entered to this memory.
CM0723 Reserved for system
:
CM0999
CM1000 Number of received text data
CM1001 R Received text data 1
: :
CM1099 Received text data 99

A-25
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM1100 Number of sent text data
CM1101 R Received sent data 1
: :
CM1199 Received sent data 99
CM1200 Reserved for system
:
CM1399
CM1400 Cam switch function, set leading output relay No.
CM1401 Cam switch function, comparator value in multi-stage compare mode
CM1402 Cam switch function, number of pulses in cycle of device input to CTH0
CM1403 Cam switch function, absolute type input address
CM1404 R Cam switch function, current angle
CM1405 R Cam switch function, error No.
APPENDICES

CM1406 Reserved for system


:
CM1409
CM1410 Cam switch function, angle setting value for turning output relay ON/OFF
CM1411
CM1412 Cam switch function, : angle setting value for turning output +1 relay ON/OFF
: :
CM1471 angle setting value for turning output +30 relay ON/OFF
CM1472 Cam switch function, angle setting value for turning output +31 relay ON/OFF
Special Device List

CM1473
CM1474 Reserved for system
:
CM1479
CM1480 R Frequency counter function, frequency measurement results (Hz/rpm)
CM1481 R
CM1482 Frequency counter function, measurement cycle (ms)
CM1483 Frequency counter function, average number of measurements
CM1484 Reserved for system
:
CM1489
CM1490 Specified frequency pulse output function, set frequency (Hz)
CM1491
CM1492 Reserved for system
:
CM1499
CM1500 R Reserved for system
:
CM1531
CM1532 R Reserved for system
:
CM1563

A-26
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM1564 R Reserved for system
CM1565 Reserved for system
:
CM1569
CM1570 Reserved for system
:
CM1577
CM1578 Reserved for system
:
CM1599
CM1600 CTH0 ring counter upper limit value
CM1601
CM1602 CTH1 ring counter upper limit value

APPENDICES
CM1603
CM1604 CTH0 preset input
CM1605
CM1606 CTH1 preset input
CM1607
CM1608 Reserved for system
CM1609
CM1610 R Input capture at INT0 generation

Special Device List


CM1611 R
CM1612 R Input capture at INT1 generation
CM1613 R
CM1614 R Input capture at INT2 generation
CM1615 R
CM1616 R Input capture at INT3 generation
CM1617 R
CM1618 Reserved for system
CM1619
CM1620 Input time constant setting
CM1621 Reserved for system
:
CM1699
CM1700 Digital trimmer 0 upper limit value
CM1701
CM1702 Digital trimmer 1 upper limit value
CM1703
CM1704 Digital trimmer 2 upper limit value
CM1705
CM1706 Digital trimmer 3 upper limit value
CM1707
CM1708 Digital trimmer 4 upper limit value
CM1709
CM1710 Digital trimmer 5 upper limit value
CM1711

A-27
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM1712 Digital trimmer 6 upper limit value
CM1713
CM1714 Digital trimmer 7 upper limit value
CM1715
CM1716 Reserved for system
:
CM1719
CM1720 Access window, user message 1
CM1721 Access window, user message 2 (max. 32 characters)
:
CM1737
CM1738 Access window, operation disabled setting
CM1739 Reserved for system
APPENDICES

:
CM1999
CM2000 X-axis, I/O setting
CM2001 X-axis, sensor enable
CM2002 X-axis, current value comparator 0
CM2003
CM2004 X-axis, current value comparator 1
CM2005
Special Device List

CM2006 X-axis, zero return: startup frequency


CM2007 X-axis, zero return: acceleration/deceleration time
CM2008 X-axis, zero return: operation frequency
CM2009
CM2010 X-axis, jog operation: startup frequency
CM2011 X-axis, jog operation: acceleration/deceleration time
CM2012 X-axis, jog operation: operation frequency
CM2013
CM2014 X-axis, change current value setting value
CM2015
CM2016 X-axis, change operation speed setting value in speed control mode
CM2017
CM2018 Reserved for system
CM2019 X-axis, M code
CM2020 R X-axis, output pulse current value
CM2021 R
CM2022 R X-axis, output frequency current value
CM2023 R
CM2024 X-axis, error code
CM2025 X-axis, operation point No.
CM2026 Reserved for system
:
CM2029

A-28
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM2030 Y-axis, I/O setting
CM2031 Y-axis, sensor enable
CM2032 Y-axis, current value comparator 0
CM2033
CM2034 Y-axis, current value comparator 1
CM2035
CM2036 Y-axis, zero return: startup frequency
CM2037 Y-axis, zero return: acceleration/deceleration time
CM2038 Y-axis, zero return: operation frequency
CM2039
CM2040 Y-axis, jog operation: startup frequency
CM2041 Y-axis, jog operation: acceleration/deceleration time

APPENDICES
CM2042 Y-axis, jog operation: operation frequency
CM2043
CM2044 Y-axis, change current value setting value
CM2045
CM2046 Y-axis, change operation speed setting value in speed control mode
CM2047
CM2048 Reserved for system
CM2049 Y-axis, M code

Special Device List


CM2050 R Y-axis, output pulse current value
CM2051 R
CM2052 R Y-axis, output frequency current value
CM2053 R
CM2054 Y-axis, error code
CM2055 Y-axis, operation point No.
CM2056 Reserved for system
:
CM2059
CM2060 Target value/travel
CM2061 Startup frequency
CM2062 Acceleration/deceleration time
CM2063 Operation frequency
CPU positioning function
CM2064
Point parameter 0
CM2065 Operation mode
CM2066 Number of specified stop sensor pulses
CM2067 Reserved for system
CM2068
CM2069
CM2070 CPU positioning function Point parameter 1
: :
CM2369 Point parameter 30

A-29
6 Special Device List

Attribute
Device No. R: Read only Function
Blank: R/W
CM2370 Target value/travel
CM2371 Startup frequency
CM2372 Acceleration/deceleration time
CM2373 Operation frequency
CPU positioning function
CM2374
Point parameter 31
CM2375 Operation mode
CM2376 Number of specified stop sensor pulses
CM2377 Reserved for system
CM2378
CM2379
CM2380 Reserved for system
:
CM2599
APPENDICES

CM2600 Logging function, device type 0


CM2601
CM2602 Logging function, device type 1
: :
CM2661 device type 30
CM2662 Logging function, device type 31
CM2663
CM2664 Logging function, trigger selection details 0
Special Device List

: :
CM2670 trigger selection details 6
CM2671 Logging function, number of registered devices
CM2672 Logging function, Memory Card storage capacity
CM2673 Reserved for system
:
CM3999

A-30
7 Index

7 Index [D]
data blocks ............................................................ 4-2
Data memories .......................................... 1-10, 1-15
[Numbers/Symbols] Decimal ............................................................... 1-22
.D ............................................................ 1-28, 4-27 Differential execution type ..................................... 1-5
.F ...................................................................... 1-28 direct input ........................................................... 5-60
.L ............................................................ 1-28, 4-27 direct output ........................................................ 5-61
.S ............................................................ 1-28, 4-26
.U ............................................................ 1-28, 4-26 [E]
$ .......................................................................... 1-18 Every scan execution type .................................... 1-5
# .......................................................................... 1-18 EXTENDED INSTRUCTIONS ............................... 5-1
16-bit internal register ......................................... 1-17 Extended instructions ............................................ 1-2
32-bit Data ........................................................... 1-24 Extended Ladder ................................................. 1-38
32-bit internal register ......................................... 1-17

APPENDICES
[F]
[A]
Floating point real numbers ................................. 1-23
About annotation of devices for data memory units ...
............................................................................ 1-16
[H]
About annotation of devices for relay units ......... 1-12
HEX ..................................................................... 1-22
APPLIED INSTRUCTIONS ................................... 3-1
High-speed counter comparators .... 1-10, 1-14, 5-69
Applied instructions ............................................... 1-2

Index
Comparator Match Output ............................. 5-81
Arithmetic instructions ........................................... 1-2
High-speed counters (CTH) ............ 1-10, 1-17, 5-69
ARITHMETIC OPERATION INSTRUCTIONS ...... 4-1
Changing the current value (CTH) ................. 5-74
ASCII ................................................................... 1-24
Changing the setting value (CTC) .................. 5-74
ASCII code .......................................................... 1-24
Extended Functions ....................................... 5-83
ASCII Code Table .............................................. A-18
Preset Function .............................................. 5-80
Reading current values .................................. 5-73
[B]
Reset Method ................................................. 5-78
BASIC INSTRUCTIONS ....................................... 2-1
Setting Count Input ........................................ 5-75
Basic instructions .................................................. 1-2
BDC..................................................................... 1-22
[I]
BDC (Binary Coded Decimal) ............................. 1-22
Indirect Specification ........................................... 1-42
BIN ...................................................................... 1-22
Input Capture Function ........................................ 5-62
Binary .................................................................. 1-22
Input relays................................................ 1-10, 1-11
Bit Devices ................................................ 1-10, 1-11
Internal Annotation of Floating Point Real Numbers 1-23
Handling Bit Devices in Word Units ............... 1-25
Internal auxiliary relays ............................. 1-10, 1-12
Internal Registers ...................................... 1-10, 1-17
[C]
16-bit internal register .................................... 1-17
CM ...................................................................... A-24
32-bit internal register .................................... 1-17
contact blocks ..................................................... 2-68
Interrupt Function ................................................ 5-57
Control Memory ............................... 1-10, 1-16, A-24
Interrupt program ................................................ 1-36
Control Relay ................................... 1-10, 1-13, A-19
Interrupt program execution conditions .......... 5-58
Count input types ................................................ 5-72
Counters .................................................... 1-10, 1-14
[J]
About the maximum count speed of counters 1-14
Jog operation ...................................................... 5-92
changing counter current values .................... 2-58
changing counter setting values .................... 2-58
reading counter current values ...................... 2-59 [M]
CR ...................................................................... A-19 Main routine program .......................................... 1-34

A-31
7 Index

[O]
operands ............................................................... 1-3
Output relays ............................................. 1-10, 1-11

[P]
Point parameters ................................................. 5-89
Positioning Instructions ....................................... 5-88
program blocks .................................................... 2-68

[R]
Ring Counter Function ........................................ 5-82

[S]
APPENDICES

Sequence Programs ........................................... 1-34


signed binary ....................................................... 1-22
Special auxiliary relays ........................................ 5-87
stacks .................................................................. 2-69
Sub-routine program ........................................... 1-35
Suffixes ............................................................... 1-28
System parameters ............................................. 5-89
Index

[T]
Teach .................................................................. 5-98
Temporary data memories ........................ 1-10, 1-16
Timers ....................................................... 1-10, 1-13
About timer error ............................................ 1-13
changing timer current values ........................ 2-54
changing timer setting values ........................ 2-54
reading timer current values .......................... 2-55
Trapezoidal control .............................................. 5-88
Types of Interrupt Causes ................................... 5-58

[U]
unsigned binary ................................................... 1-22

[W]
Word Devices ............................................ 1-10, 1-15
word device bit specification .......................... 2-12

[X]
Example of changing counter setting values ....... 2-58

[Z]
zero-return ........................................................... 5-94

A-32
8 Instruction
7 Index

8 Instruction Index [D]


DASC ................................................................ 4-174
DASC(S)(D)(L) .................................................. 4-174
[A] DCNT .................................................................... 5-8
ACOS ................................................................ 4-164 DEC ..................................................................... 4-48
ADD..................................................................... 4-28 DEG .................................................................. 4-154
ADD.F ............................................................... 4-134 DI ......................................................................... 5-54
ADD.S ................................................................. 4-28 DIFD .................................................................... 2-30
AJST ................................................................... 5-44 DIFU .................................................................... 2-30
ALT ...................................................................... 2-38 DISB .................................................................. 4-104
ANB ....................................................................... 2-6 DISF .................................................................. 4-130
AND....................................................................... 2-6 DISN .................................................................. 4-100
ANDA .................................................................. 4-64 DISS .................................................................. 4-188
ANF ..................................................................... 2-10 DIV ...................................................................... 4-40

APPENDICES
ANL ..................................................................... 2-76 DIV.F ................................................................. 4-140
ANP ..................................................................... 2-10 DMX .................................................................... 4-94
ARES .................................................................. 5-48 DW ........................................................................ 4-4
ASC ................................................................... 4-170 DW.F ................................................................. 4-120
ASIN .................................................................. 4-162
ATAN ................................................................. 4-166 [E]
AVG..................................................................... 5-20 EI ......................................................................... 5-54

Instruction
Index
END ..................................................................... 2-70
[B] ENDH .................................................................. 2-70
BAND .................................................................. 2-14 ENDS .................................................................. 3-20

Index
BANDB ................................................................ 2-14 EORA .................................................................. 4-68
BCNT .................................................................... 5-6 EXP ................................................................... 4-148
BLD ..................................................................... 2-14 EXT ..................................................................... 5-32
BLDB ................................................................... 2-14
BMOV .................................................................. 4-18 [F]
BOR .................................................................... 2-14 FIFOR ................................................................. 5-28
BORB .................................................................. 2-14 FIFOW ................................................................. 5-26
BOUB .................................................................. 2-42 FLIK ..................................................................... 2-36
BOUT .................................................................. 2-42 FLOAT ............................................................... 4-114
BREAK ................................................................ 3-38 FMOV .................................................................. 4-20
BRES .................................................................. 2-44 FMOV.F ............................................................. 4-128
BSET ................................................................... 2-44 FOR ..................................................................... 3-38

[C] [G]
C .......................................................................... 2-56 GRY .................................................................... 4-96
CALL ................................................................... 3-34
CMP .................................................................... 4-54 [H]
CMP.S ................................................................. 4-54
HKEY .................................................................... 5-4
CMP.F ............................................................... 4-144
HSP ..................................................................... 5-52
COM .................................................................... 4-70
CON .................................................................... 2-72
[I]
COS .................................................................. 4-158
INC ...................................................................... 4-44
CTC ..................................................................... 5-68
INT ...................................................................... 5-56
CTH ..................................................................... 5-68

A-33
7 Index
8 Instruction Index

INTG .................................................................. 4-116 ORGX .................................................................. 5-94


ITVL..................................................................... 2-60 ORGY .................................................................. 5-94
ORL ..................................................................... 2-76
[J] ORP .................................................................... 2-10
JMP ..................................................................... 3-20 OUB .................................................................... 2-24
JOGX .................................................................. 5-92 OUT ..................................................................... 2-24
JOGY .................................................................. 5-92
[P]
[K] PLSX ................................................................... 5-90
KEEP................................................................... 2-28 PLSY ................................................................... 5-90

[L] [R]
LD.......................................................................... 2-4 RAD ................................................................... 4-152
LDA ....................................................................... 4-6 RASC ................................................................ 4-172
APPENDICES

LDA.F ................................................................ 4-122 RCOM ............................................................... 4-194


LDB ....................................................................... 2-4 RDASC .............................................................. 4-178
LDF ..................................................................... 2-10 RDASC(S)(D)(L) ............................................... 4-178
LDP ..................................................................... 2-10 RES ..................................................................... 2-26
LEN ................................................................... 4-192 RET ..................................................................... 3-34
LOG................................................................... 4-150 RETI .................................................................... 5-56
RGRY .................................................................. 4-98
Index
Instruction Index

[M] RLA ..................................................................... 4-82


ROOT .................................................................. 4-52
MAX .................................................................... 5-12
ROOT.F ............................................................. 4-142
MC ....................................................................... 3-30
RRA ..................................................................... 4-80
MCR .................................................................... 3-30
RSEC .................................................................. 5-42
MEMSW ................................................................ 3-8
MIN...................................................................... 5-16
MOV .................................................................... 4-14
[S]
MOV.F ............................................................... 4-126 SADD ................................................................ 4-184
MOV.S ................................................................. 4-14 SBN ..................................................................... 3-34
MPP .................................................................... 2-74 SCMP ................................................................ 4-186
MPS .................................................................... 2-74 SEC ..................................................................... 5-40
MPX .................................................................... 4-94 SER ..................................................................... 5-10
MRD .................................................................... 2-74 SET ..................................................................... 2-26
MUL..................................................................... 4-36 SFT ....................................................................... 3-4
MUL.F ............................................................... 4-138 SHOT .................................................................. 2-34
SIN .................................................................... 4-156
[N] SLA ..................................................................... 4-78
SMOV ................................................................ 4-182
NEG .................................................................... 4-72
SRA ..................................................................... 4-76
NEXT................................................................... 3-38
STA ....................................................................... 4-8
STA.F ................................................................ 4-124
[O]
STE ..................................................................... 3-14
OFDL................................................................... 2-32
STG ..................................................................... 3-20
ONDL .................................................................. 2-32
STP ..................................................................... 3-14
OR ......................................................................... 2-8
SUB ..................................................................... 4-32
ORA .................................................................... 4-66
SUB.F ................................................................ 4-136
ORB ...................................................................... 2-8
SWAP ................................................................ 4-108
ORF..................................................................... 2-10

A-34
8 Instruction7 Index

[T]
TAN ................................................................... 4-160
TBCD .................................................................. 4-90
TBIN .................................................................... 4-92
TCHX .................................................................. 5-98
TCHY .................................................................. 5-98
TMH .................................................................... 2-50
TMIN ................................................................... 4-12
TMR .................................................................... 2-48
TMS..................................................................... 2-52

[U]
UDC .................................................................... 2-64
UDT ..................................................................... 2-66

APPENDICES
UNIB .................................................................. 4-106
UNIF .................................................................. 4-132
UNIN ................................................................. 4-102
UNIS .................................................................. 4-190

[W]
W-DE ................................................................... 3-26

Instruction
Index
W-OFF ................................................................ 3-24
W-ON .................................................................. 3-24
W-UE ................................................................... 3-26

Index
WSL .................................................................... 4-86
WSR .................................................................... 4-84
WTIME ................................................................ 5-38

[X]
XCH................................................................... 4-110

[Z]
ZCMP .................................................................. 4-58
ZCMP.F ............................................................. 4-146
ZRES ................................................................... 5-24

A-35
Revision History
Printing Date Version Revision Details

July 2003 Ver 1.0


WARRANTIES AND DISCLAIMERS:
(1) KEYENCE warrants the Products to be free of defects in materials and workman-
ship for a period of one (1) year from the date of shipment. If any models or samples
were shown to Buyer, such models or samples were used merely to illustrate the
general type and quality of the Products and not to represent that the Products
would necessarily conform to said models or samples. Any Products found to be
defective must be shipped to KEYENCE with all shipping costs paid by Buyer or
offered to KEYENCE for inspection and examination. Upon examination by
KEYENCE, KEYENCE, at its sole option, will refund the purchase price of, or repair
or replace at no charge any Products found to be defective. This warranty does not
apply to any defects resulting from any action of Buyer, including but not limited to
improper installation, improper interfacing, improper repair, unauthorized modifica-
tion, misapplication and mishandling, such as exposure to excessive current, heat,
coldness, moisture, vibration or outdoors air. Components which wear are not
warranted.

(2) KEYENCE is pleased to offer suggestions on the use of its various Products. They
are only suggestions, and it is Buyer's responsibility to ascertain the fitness of the
Products for Buyer's intended use. KEYENCE will not be responsible for any
damages that may result from the use of the Products.

(3) The Products and any samples ("Products/Samples") supplied to Buyer are not to
be used internally in humans, for human transportation, as safety devices or fail-
safe systems, unless their written specifications state otherwise. Should any
Products/Samples be used in such a manner or misused in any way, KEYENCE
assumes no responsibility, and additionally Buyer will indemnify KEYENCE and
hold KEYENCE harmless from any liability or damage whatsoever arising out of any
misuse of the Products/Samples.

(4) OTHER THAN AS STATED HEREIN, THE PRODUCTS/SAMPLES ARE PRO-


VIDED WITH NO OTHER WARRANTIES WHATSOEVER. ALL EXPRESS, IM-
PLIED, AND STATUTORY WARRANTIES, INCLUDING, WITHOUT LIMITATION,
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EX-
PRESSLY DISCLAIMED. IN NO EVENT SHALL KEYENCE AND ITS AFFILI-
ATED ENTITIES BE LIABLE TO ANY PERSON OR ENTITY FOR ANY DIRECT,
INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSEQUENTIAL DAM-
AGES (INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RESULTING
FROM LOSS OF USE, BUSINESS INTERRUPTION, LOSS OF INFORMATION,
LOSS OR INACCURACY OF DATA, LOSS OF PROFITS, LOSS OF SAVINGS,
THE COST OF PROCUREMENT OF SUBSTITUTED GOODS, SERVICES OR
TECHNOLOGIES, OR FOR ANY MATTER ARISING OUT OF OR IN CONNEC-
TION WITH THE USE OR INABILITY TO USE THE PRODUCTS, EVEN IF
KEYENCE OR ONE OF ITS AFFILIATED ENTITIES WAS ADVISED OF A
POSSIBLE THIRD PARTY'S CLAIM FOR DAMAGES OR ANY OTHER CLAIM
AGAINST BUYER. In some jurisdictions, some of the foregoing warranty disclaim-
ers or damage limitations may not apply.

BUYER’S TRANSFER OBLIGATIONS:


If the Products/Samples purchased by Buyer are to be resold or delivered to a third
party, Buyer must provide such third party with a copy of this document, all specifica-
tions, manuals, catalogs, leaflets and written information provided to Buyer pertaining
to the Products/Samples.
Specifications are subject to change without notice.
AFFILIATED COMPANIES
KEYENCE CORPORATION OF AMERICA KEYENCE (THAILAND) CO., LTD.
Phone: 201-930-0100 Fax: 201-930-0099 Phone: 02-369-2777 Fax: 02-369-2775
KEYENCE CORPORATION KEYENCE DEUTSCHLAND GmbH KEYENCE TAIWAN CO., LTD.
1-3-14, Higashi-Nakajima, Phone: 06102-36 89-0 Fax: 06102-36 89-100 Phone: 02-2627-3100 Fax: 02-2798-8925
Higashi-Yodogawa-ku, KEYENCE (UK) LIMITED KEYENCE (HONG KONG) CO., LTD.
Osaka, 533-8555, Japan Phone: 01908-696900 Fax: 01908-696777 Phone: 3104-1010 Fax: 3104-1080
Phone: 81-6-6379-2211 KEYENCE FRANCE S.A. KEYENCE INTERNATIONAL TRADING
Fax: 81-6-6379-2131 Phone: 01 47 92 76 76 Fax: 01 47 92 76 77 (SHANGHAI) CO., LTD.
KEYENCE SINGAPORE PTE LTD. Phone: 021-68757500 Fax: 021-68757550
Phone: 6392-1011 Fax: 6392-5055 KEYENCE KOREA CORPORATION
KEYENCE (MALAYSIA) SDN BHD Phone: 02-563-1270 Fax: 02-563-1271
Phone: 03-2092-2211 Fax: 03-2092-2131
©KEYENCE CORPORATION, 2003 KV-700-IM 0073-1 Printed in Japan

Das könnte Ihnen auch gefallen