Vous êtes sur la page 1sur 676

96112E

Programable Controller
KV-5500/5000/3000/1000 Series
Preface
The manual describes functions required to compile KV- 5500 / 5000 / 3000 / 1000 script program and
setting method. Carefully read and fully understand the manual before compiling program.
During programming, about the command of CPU internal function and special command of expansion
unit, please see User's Manuals of every unit such as "KV-5500/5000/3000 series User's Manual", "KV-
5500/5000/3000/1000 series Instruction Reference Manual" and "KV STUDIO User's Manual", etc.
Store this Manual in a safe place so that you can retrieve it whenever necessary.
Please handover this manual to the end-users who are going to use the PLC series.

Ƶ KV-5500/5000/3000/1000 series related manuals


All the following PDF manuals can be found and opened in the help file of KV STUDIO. In addition, the
latest version of PDF manuals can be downloaded from the Keyence web site.

Type Description
This Manual describes the configuration/specification, CPU
KV-5500/5000/3000 series
internal function, ladder programming method of KV-5500/5000/
User's Manual
3000 series.
KV-5500/5000/3000/1000 series This Manual describes various instructions available in Ladder
Instruction Reference Manual program.
KV-5500/5000/3000/1000 series This Manual describes the script programming method and
Script Programming Manual available operators, control statements and functions, etc.
KV STUDIO User's Manual This Manual describes how to operate KV STUDIO.
KV-5500/5000/3000/1000 series This Manual describes the system macros available for the KV-
System Macro Manual 5500/5000/3000/1000 series PLC.
This Manual describes the basic functions and how to use the KV-
KV-1000 Introduction Manual
1000 briefly.
KV-1000 series This Manual describes the specifications, integrated functions and
User's Manual operating method of the KV-1000 PLC.
KV-1000 series This manual describes how to make ladder programs using the
Programming Manual KV-1000 PLC, and modules/macros and local devices.
Safety Precautions
Ƶ Symbols
This document contains notices which you should observe to ensure your own personal safety, as well
as to protect the product and connected equipment. These notices are highlighted in the manual by a
warning triangle and are marked as follows according to the level of danger:

Danger
Indicates that death or severe personal injury will result if proper precautions
are not taken.

Warning
Indicates that failure to follow these instructions may lead to personal injury
damage.

Caution
Indicates that damage to property can result if proper precautions are not taken.

Important
Indicates that an undesirable result or status can occur if the relevant notice is ignored.

Note
Indicates cautions for easily mistaken operations.

TIP Indicates useful information or information that aids understanding of text descriptions.

Indicates a reference item or page to be referred to in this manual and other manuals.

Ƶ General Precautions
• When using KV STUDIO, firstly confirm whether the function and performance of KV-5500/5000/3000/1000 are
normal before use.
• Verify that this device functions correctly before the start of work and when operating the device.
• Provide a safety circuit that bypasses PLC to enable failsafe operation of the entire system in the event that the PLC
fails.
• Output circuit or internal circuit malfunctions sometimes prevent control from being performed normally.Be sure to
provide a safety circuit in control systems where circuit malfunction may lead to fire or other serious accidents.
• Proceed with care when modifying the KV-5000/3000/1000 Series, or when using it in a manner that falls outside of
the ranges indicated in its specifications, since KEYENCE is unable to guarantee device functionality or performance
in such situations.
• Use this product in combination with other devices only after careful consideration, since the product may fail to
satisfy its functionality and performance capabilities as a result of the conditions and environment in which it is used.
• Do not use the product with the purpose of protecting human beings.

- KV-5500/5000/3000/1000 96112E
Series Script Programming Manual - 1
Ƶ Note
When using this device under the following conditions or operating environments, please consult with
your KEYENCE agents in addition to implementing safety measures such as product operation that
allows redundancy with respect to ratings and functions and use of failsafe provisions.
• Use of the product under conditions and environments not described in this manual;
• Use of the product in nuclear power control, railroad facilities, aviation facilities, vehicles, combustion
devices, medical equipment, entertainment machinery, safety equipment, etc.;
• Use of the product in applications that may have a significant impact on human life or property, or that
place a high priority on safety.

KV-5500/5000/3000 CPU Function Version

The CPU function version has been added to the KV-5500/5000/3000 Series shipped after September
10, 2009.
Check the serial label on the side for details on the CPU function version.

CPU function version

2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Differences in KV-5500/5000/3000 CPU function versions

Differences according to the CPU function version are listed below.

Ƶ Differences in CPU functions according to CPU function version


Following September Following June 14,
Time of shipment Following June 14, 2010
10, 2009 2007
CPU function version Ver.2.0 Ver.1.1 Ver.1.0
KV STUDIO compatible version Ver. 6.0 or higher Ver. 5.6 or higher Ver. 4.0 or higher
KV-5500 - -
Compatible CPU
KV-5000
unit
KV-3000
*1
Bluetooth communication h
Battery-less operation h h
Initial screen display
h h
(access window)
Read folder specification
h h
(auto-loading function)
CPU function
SDHC card (memory card) h h
Word device bit comment
h h
(KV STUDIO)
Performance monitor
h h
(KV STUDIO)
Differential monitor (KV STUDIO) h h
Double precision floating point
h h
type real number
Timer/counter instruction 1 instruction added (TMU) No additions -
PID control instruction 1 instruction added (PIDAT) No additions -
Data control instruction 3 instructions added (RAMP,TPOUT,LLFLT) No additions -
2 instructions added (BYLMOV,BYBMOV)
Move instruction No additions -
Specifications of 1 instruction expanded*2
Arithmetic/comparison
1 instruction added (POW) No additions -
instruction
Data shift instruction 2 instructions added (ASRA,ASLA) No additions -
4 instructions added
Data conversion instruction (ABS,BSWAP,CPMSET,CPMGET) No additions -
Instruction
Specifications of 2 instructions expanded*3
language/script
5 instructions added
Floating point instruction No additions -
(LOG10,DFLOAT,DINTG,FTODF,DFTOF)
Simple operation instruction Specifications of 2 instructions expanded*4 No additions -
5 instructions added
Text string processing instruction (SPLIT,STRIM,SFINDN,CPSASC,RCPSASC)*5 No additions -
Specifications of 1 instruction expanded*6
Data processing instruction 2 instructions added (SORT,SORTN) No additions -
7 instructions added
Memory card instruction (MPRINT,MREADL,MCOPY,MMOV,MREN, No additions -
MFREEK,MSTAT)
Sensor setting instruction 3 instructions added (SPRD,SPWR,SSVC) No additions -
Refresh instruction 2 instructions added (RFSCI,RFSCO) No additions -

*1 KV-3000 Ver.1.1 does not support Bluetooth communication.


*2 Constants can be specified for the PMOV operand S.
*3 Devices can be specified for the DECO/ENCO operand n.
*4 A signed integer can be specified for the shift instruction (CAL>>, CAL<<). (Arithmetic shift)
*5 Only scrip function is added for SPLIT.
*6 RCOM supports word device bit comment.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3


Ƶ Differences in Ethernet functions according to CPU function version
Time of shipment Following June 14, 2010 Following September 10, 2009 Following June 14, 2007
KV-5500 Ver.2.0 - -
KV-5000 Ver.2.0 Ver.1.1 Ver.1.0
Compatible unit
Ethernet/IP unit KV-EP21V - -
Ethernet unit KV-LE21V KV-LE21V KV-LE20V
Simple PLC link h
FTP client h
BOOTP client h
Ethernet function Communication without unit
h h
setting
APPE command support
h h
(FTP server function)

ƽ Restrictions for using extended input/output unit (KV-B8XTD, KV-C16XTD, KV-


C32XTD)
The following restrictions apply when connecting an extended input/output unit to the CPU function
version 1.0 CPU unit. (These restrictions do not apply to the CPU function version 1.1 or higher CPU
unit.)
• During the I/O test, 32DO is displayed on the KV-C16XTD and 64DO on the KV-C32XTD.
• During the I/O test, the details displayed for the KV-B8XTD differ according to the unit setting
information stored in the CPU unit.
When the unit information stored in the CPU unit is the same as the actual unit configuration.
32DO is displayed.
When the unit information stored in the CPU unit differs from the actual unit configuration.
16DO is displayed.
• If the unit information stored in the CPU unit differs from the actual unit configuration, the I/O test
operation will differ according to the type of unit to the right of the KV-B8XTD.
When the right unit is a special unit, or when there is no unit to the right.
The KV-B8XTD output relay is not controlled.
When the right unit is an output unit.
When the right unit's output relay turns ON, the KV-B8XTD outut relay also turns ON.
When the right unit is an input unit.
When the right unit's input relay turns ON, the KV-B8XTD output relay also turns ON.
• The input refresh prohibit setting is invalid for the KV-B8XTD, KV-C16XTD and KV-C32XTD.
If output prohibit is set, the input refresh will also be prohibited.
• If the input relay forced set assigned to the KV-B8XTD, KV-C16XTD, KV-C32XTD is canceled, the
input status will be applied after the target input relay has turned OFF for one scan.

4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


How This Manual Is Organized
Describes features of KV scripts such as script application

Chapter 1 OVERVIEW example (program example) and KV script type, operators


and control statements, functions, etc.

1
Chapter 2 PROGRAMMING
SCRIPT
Describes script making steps as well as error message and
warning message during conversion. 2
3
Chapter 3 DATA PROCESSING
Describes script processing device, constant range (type) and
programming method, index modification and indirect specifying,
4
etc.
5
6
Chapter 4 SCRIPT SYNTAX Describes how to use assignment statement and operators
AND PRECAUTIONS used in scripts as well as syntax of control statement, etc.
7
8
Chapter 5 BASIC FUNCTIONS
Describes contact functions, bit functions, bit output
functions, output functions, and timer/counter functions, etc. A

Chapter 6 APPLICATION
FUNCTIONS
Describes program flow control functions, macro functions,
Index register functions, and indirectly specifying functions,
etc.

ARITHMETIC Describes data more functions, arithmetic operation functions, logical

Chapter 7 OPERATION
FUNCTIONS
operation functions, data shift functions, data conversion functions, floating
real number functions, and text string processing functions, etc.

Describes data processing functions, table processing functions, clock

Chapter 8 EXTENDED
FUNCTIONS
processing functions, high speed processing functions, record
functions, memory card functions, and access window functions, etc.

Presents character code table, a list of control relay/control


APPENDICES
memories, index, etc.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5


Contents
Preface
Safety Precautions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1
How This Manual Is Organized ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5
Contents •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6

Chapter 1 OVERVIEW
1-1 KV Scripts ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-2
Features of KV Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-2
How to Use KV Scripts•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-3
1-2 KV Script Type ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-8
Box Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-8
Area Script •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••1-9
1-3 KV Script Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-10
About Assignment Statement••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-10
About Operator •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-11
About Control Statement •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-12
About Suffix •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-14
About Script Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1-17

Chapter 2 PROGRAMMING SCRIPT


2-1 Programming Script•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••2-2
Programming Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••2-2
2-2 Box Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••2-4
Features of Box Script •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••2-4
Making Box Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••2-6
Precautions When Using Box Script •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-13
2-3 Area Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-16
Features of Area Script •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-16
Making Area Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-18
2-4 Label Programming and Label Array ••••••••••••••••••••••••••••••••••••••••••••••• 2-25
Label Programming •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-25
Label Array ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-35
2-5 Precautions on Script Programming ••••••••••••••••••••••••••••••••••••••••••••••• 2-40
About Parallel Connection of Box Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-40
Precautions When Using Script Programming Operation Formula ••••••••••••••••••••••••••• 2-40
2-6 Script Conversion Output Message••••••••••••••••••••••••••••••••••••••••••••••••• 2-41
Warning Message •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-41
Error Message••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-42
2-7 Macro•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-47
Macro Call•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-47
Programming Macro by Using Script•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-48
2-8 Script Debug Function•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-49
Monitor Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-49
2-9 Input Auxiliary Function and Other Info ••••••••••••••••••••••••••••••••••••••••••• 2-51
About Input Auxiliary Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-51

6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


About Comments Function•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-56
Write Easy-reading Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-57
Inline Mnemonics ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-59
Precautions on Edit Screen and Customization •••••••••••••••••••••••••••••••••••••••••••••••••• 2-60
About Script Work Memory (Work Devices) ••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-61
XYM Marking •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-64

Chapter 3 DATA PROCESSING


3-1 Device and Constants ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••3-2
Device List •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••3-2
Bit Device•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••3-8
Word Device ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-17
Processing Bit Device in Word Unit ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-27
Processing Word Device as Bit Device••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-28
Direct I/O Relay ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-29
Constant •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-30
3-2 Index Modification and Indirect Specifying ••••••••••••••••••••••••••••••••••••••• 3-33
Index Modification •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-33
Indirect Specifying •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-35
Combination of Index Modification and Indirect Specifying ••••••••••••••••••••••••••••••••••••• 3-39
3-3 Data Type (suffix) •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-40
Suffix •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-40
About Type Declaration (TYPE)•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-47
About Operation Type•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-48
PRAGMA Directive ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-50

Chapter 4 SCRIPT SYNTAX AND Precautions


4-1 Assignment Statement •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••4-2
How to Use An Assignment Statement ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••4-2
4-2 Operator ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••4-6
Operator List •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••4-6
4-3 Control Statement•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-10
Control Statement List ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-10
IF to Statement (Conditional Branch (1)) ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-12
IF to ELSE Statement (Conditional Branch (2)) ••••••••••••••••••••••••••••••••••••••••••••••••••• 4-14
IF to ELSEIF Statement (Conditional Branch (3)) •••••••••••••••••••••••••••••••••••••••••••••••• 4-16
SELECT CASE to Statement (Multi-branch control)•••••••••••••••••••••••••••••••••••••••••••• 4-18
MC to MCR Statement (Master control) •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-22
FOR to NEXT Statement ( specified loop control times) ••••••••••••••••••••••••••••••••••••••• 4-24
WHILE Statement (pre-judge loop control) •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-27
DO to UNTIL Statement (Post Identification Loop Control) •••••••••••••••••••••••••••••••••••• 4-29
BREAK Processing ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-31
Precautions on Using Control Statement••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-32
4-4 Precutions on Script Programming ••••••••••••••••••••••••••••••••••••••••••••••••• 4-38
Status of Hold Control Bit Device •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-38

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7


Precautions About Use of Timer Device/ Counter Device ••••••••••••••••••••••••••••••••••••• 4-40

Chapter 5 BASIC FUNCTIONS


Contact Function••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••5-2
LDP Up edge differential of specified device •••••••••••••••••••••••••••••••••••••••5-2
LDF Down edge differential of specified device ••••••••••••••••••••••••••••••••••••5-4
LDPB Up edge differential bar of specified device•••••••••••••••••••••••••••••••••••5-6
LDFB Down edge differential bar of specified device •••••••••••••••••••••••••••••••5-7
Bit Contact Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••5-8
BLD Specified bit information of word device •••••••••••••••••••••••••••••••••••••••5-8
BLDB Specified bit information bar of word device •••••••••••••••••••••••••••••••• 5-10
Output Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-12
SET Output ON of specified device••••••••••••••••••••••••••••••••••••••••••••••••• 5-12
RES Output OFF of specified device ••••••••••••••••••••••••••••••••••••••••••••••• 5-13
Bit output Function••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-14
BOUT Specified bit output of word device ••••••••••••••••••••••••••••••••••••••••••• 5-14
BOUB Specified bit inverted output of word device •••••••••••••••••••••••••••••••• 5-16
BSET Specified bit output ON of word device •••••••••••••••••••••••••••••••••••••• 5-18
BRES Specified bit output OFF of word device •••••••••••••••••••••••••••••••••••• 5-20
Timer/counter Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-22
TMR 100 ms 32-bit down timer •••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-22
TMH 10ms 32-bit down timer ••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-24
TMS 1 ms 32-bit down timer•••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-26
TMU 10μs 32-bit down timer•••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-28
CNT 32 bit up counter ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-30
Direct I/O Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-32
RFSX Input refresh •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-32
RFSY Output refresh •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-33

Chapter 6 APPLICATION FUNCTION


Flow Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••6-2
CALL Start specified sub-routine •••••••••••••••••••••••••••••••••••••••••••••••••••••••6-2
ECALL Module sub-routine instruction ••••••••••••••••••••••••••••••••••••••••••••••••••6-4
Macro Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••6-6
MCALL Start sub-routine type macro ••••••••••••••••••••••••••••••••••••••••••••••••••••6-6
MSTRT Start self-hold type macros•••••••••••••••••••••••••••••••••••••••••••••••••••••••6-7
MEND End self-hold type macros •••••••••••••••••••••••••••••••••••••••••••••••••••••••6-8
Module Functions••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-10
MDSTRT Module execution start•••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-10
MDSTOP Module execution stop •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-11
Index Register Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-12
ZPUSH Batch purge of index register •••••••••••••••••••••••••••••••••••••••••••••••••• 6-12
ZPOP Batch restore of index registers ••••••••••••••••••••••••••••••••••••••••••••••• 6-16
Indirect Specification Functions•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-18
ADRSET Stored address of indirect specification device •••••••••••••••••••••••••••• 6-18

8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ADRINC Add 1 to stored address •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-20
ADRDEC Decrement stored address by 1••••••••••••••••••••••••••••••••••••••••••••••• 6-22
ADRADD Add stored address•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-24
ADRSUB Subtract stored address •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-26
File register Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-28
FRSET Switch file register mode ••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-28
FRSTM Batch-store file register ••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-30
FRLDM Batch-read file register •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-32
Buffer memory Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-34
UREAD Read buffer•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-34
UWRIT Write buffer•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-35
UFILL Insert same value in data string of buffer•••••••••••••••••••••••••••••••••••• 6-38

Chapter 7 ARITHMETIC OPERATION FUNCTIONS


Data Move Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-2
BMOV Batch data move of word block •••••••••••••••••••••••••••••••••••••••••••••••••7-2
FMOV Substitute same value in data string •••••••••••••••••••••••••••••••••••••••••••7-4
PMOV Move continuous bit information to a specified position ••••••••••••••••••••7-8
BYBMOV Move continuous byte string information to specified position (H ė L) •••• 7-12
BYLMOV Move continuous byte string information to specified position (L ė H) •••• 7-14
Arithmetic Operation Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-16
INC Increment specified device by 1 •••••••••••••••••••••••••••••••••••••••••••••• 7-16
DEC Decrement specified device by 1 ••••••••••••••••••••••••••••••••••••••••••••• 7-18
ROOT Square root•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-20
SQRT Square root•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-22
Logic Operation Functions••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-24
ANDA Logical AND operation •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-24
ORA Logical OR operation•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-26
EORA Exclusive OR operation••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-28
ENRA Exclusive NOR ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-30
COM Bit inversion ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-32
NEG Invert sign ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-34
ABS Absolute value •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-38
Data Shift Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-40
SRA Shift right (bit unit) ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-40
SLA Shift left (bit unit) ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-42
ASRA Arithmetic right shift A (bit unit)•••••••••••••••••••••••••••••••••••••••••••••••• 7-46
ASLA Arithmetic left shift (bit unit) •••••••••••••••••••••••••••••••••••••••••••••••••••• 7-48
RRA Right rotate (bit unit, with carry) ••••••••••••••••••••••••••••••••••••••••••••••• 7-50
RLA Left rotate (bit unit, with carry)••••••••••••••••••••••••••••••••••••••••••••••••• 7-52
RRNCA Right rotate (bit unit, without carry) ••••••••••••••••••••••••••••••••••••••••••• 7-54
RLNCA Left rotate (bit unit, without carry)••••••••••••••••••••••••••••••••••••••••••••• 7-56
WSR Shift word device right •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-58
WSL Shift word device left •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-60
BSR Shift bit device right•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-62
BSL Shift bit device left ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-64

- KV-5500/5000/3000/1000 Series Script Programming Manual - 9


Data Control Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-66
LIMIT Upper/lower limit value control •••••••••••••••••••••••••••••••••••••••••••••••• 7-66
BANDC Dead band control ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-68
ZONE Zone control••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-70
APR Linear approximation •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-72
RAMP Ramp signal••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-76
TPOUT Time proportional output•••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-78
LLFLT Lead-lag filter ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-80
Data Conversion Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-82
TBCD Convert BIN data to BCD data •••••••••••••••••••••••••••••••••••••••••••••••• 7-82
TBIN Convert BCD data to BIN data •••••••••••••••••••••••••••••••••••••••••••••••• 7-84
MPX 4-bit data decode •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-86
DMX 4-bit data encode •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-88
GRY Convert BIN data to gray code •••••••••••••••••••••••••••••••••••••••••••••••• 7-90
RGRY Convert gray code to BIN data •••••••••••••••••••••••••••••••••••••••••••••••• 7-92
DISN Disperse nibble ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-94
UNIN Unite nibble ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-96
DISB Disperse byte ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-98
UNIB Unite byte•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-100
SWAP High lower byte conversion •••••••••••••••••••••••••••••••••••••••••••••••••••7-102
BSWAP Block swap •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-104
DECO Decode 8 bits of specified device••••••••••••••••••••••••••••••••••••••••••••7-106
ENCO Encode 8 bits of specified device ••••••••••••••••••••••••••••••••••••••••••••7-108
TOU Convert data type to .U ••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-110
TOS Convert data type to .S ••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-110
TOD Convert data type to .D ••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-110
TOL Convert data type to .L•••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-110
CPMSET CIP message creation •••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-114
CPMGET CIP message retrieval •••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-116
Floating Point Functions•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-118
FLOAT Convert BIN data to single precision floating point type real number data•••• 7-118
TOF Convert BIN data to single precision floating point type real number data•••• 7-120
DFLOAT Convert BIN data to double precision floating point type real number data •• 7-122
TODF Convert BIN data to double precision floating point type real number data •• 7-124
INTG Convert single/double precision floating point type real number data to BIN data•••••••7-126
INT Convert single precision floating point type real number data to BIN data•••• 7-128
DISF Disperse mantissa/exponent of single precision floating point type real number ••••••••7-130
UNIF Unite mantissa and exponent to single precision floating point type real number •••••••7-132
EXP Exponent function operation ••••••••••••••••••••••••••••••••••••••••••••••••••7-134
LOG Natural logarithm operation •••••••••••••••••••••••••••••••••••••••••••••••••••7-136
LOG10 Constant logarithm operation •••••••••••••••••••••••••••••••••••••••••••••••••7-138
RAD Convert degree (e) to radian unit •••••••••••••••••••••••••••••••••••••••••••7-140
DEG Convert radian to degree (e) unit •••••••••••••••••••••••••••••••••••••••••••7-142
SIN Angle (radian) to sine value•••••••••••••••••••••••••••••••••••••••••••••••••••7-144
COS Angle (radian) to cosine value••••••••••••••••••••••••••••••••••••••••••••••••7-146
TAN Angle (radian) to tangent value ••••••••••••••••••••••••••••••••••••••••••••••7-148
ASIN Sine value to angle (radians) •••••••••••••••••••••••••••••••••••••••••••••••••7-150

10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ACOS Cosine value to angle (radians) ••••••••••••••••••••••••••••••••••••••••••••••7-152
ATAN Tangent value to angle (radian) ••••••••••••••••••••••••••••••••••••••••••••••7-154
Text Processing Functions••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 7-156
ASC Convert BIN data to HEX ASCII code•••••••••••••••••••••••••••••••••••••••7-156
RASC Convert HEX ASCII code to BIN data•••••••••••••••••••••••••••••••••••••••7-158
DASC Convert BIN data to DEC ASCII text string ••••••••••••••••••••••••••••••••7-160
STR Convert numerical value data to ASCII code ••••••••••••••••••••••••••••••7-164
RDASC Convert DEC ASCII text string to BIN data ••••••••••••••••••••••••••••••••7-166
HASC Convert BIN data to HEX ASCII text string ••••••••••••••••••••••••••••••••7-168
RHASC Convert HEX ASCII text string to BIN data ••••••••••••••••••••••••••••••••7-172
FASC Convert single precision floating point type real number to text string ••• 7-174
RFASC Text string to single precision floating point type real number conversion •••• 7-178
VAL Text string to single precision floating point type real number conversion •••• 7-182
LEN Detect text string length •••••••••••••••••••••••••••••••••••••••••••••••••••••••7-184
SRGHT Cut text string on right••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-188
RIGHT Cut text string on right••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-190
SLEFT Cut text string on left •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-192
LEFT Cut text string on left •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-194
SMID Cut text string ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-196
MID Cut text string ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-198
SRPLC Replace text string section ••••••••••••••••••••••••••••••••••••••••••••••••••••7-200
REPLACE Replace text string section ••••••••••••••••••••••••••••••••••••••••••••••••••••7-203
SINS Insert text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-204
INSERT Insert text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-207
SDEL Delete text string section ••••••••••••••••••••••••••••••••••••••••••••••••••••••7-208
DELETE Delete text string section ••••••••••••••••••••••••••••••••••••••••••••••••••••••7-212
TRIM Trim 1-byte space and tab at ends of text string ••••••••••••••••••••••••••7-216
LTRIM Trim 1-byte space and tab at left end of text string•••••••••••••••••••••••7-218
RTRIM Trim 1-byte space and tab at right end of text string •••••••••••••••••••••7-220
STRIM Trim 1-byte space and tab from specified text string position ••••••••••7-222
SPLIT Split text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-224
SFIND Search text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-228
SFINDN Search text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-232
INSTR Search text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-236
FIND Search text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-240
DISS Disperse text string •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-244
UNIS Unite text string••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••7-246
CHR Convert HEX ASCII text code to text string ••••••••••••••••••••••••••••••••7-248
CPSASC CIP text string conversion •••••••••••••••••••••••••••••••••••••••••••••••••••••7-250
RCPSASC CIP text string type data reverse conversion ••••••••••••••••••••••••••••••7-252

Chapter 8 EXTENDED FUNCTIONS


Data Processing Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••8-2
SEG Decode 4-bit data to 7-segment ••••••••••••••••••••••••••••••••••••••••••••••••8-2
BCNT ON bit count of specified device ••••••••••••••••••••••••••••••••••••••••••••••••8-6
DCNT Count detected data in specified block ••••••••••••••••••••••••••••••••••••••••8-8
- KV-5500/5000/3000/1000 Series Script Programming Manual - 11
SER Detect data in specified block ••••••••••••••••••••••••••••••••••••••••••••••••• 8-10
DSER Detect MAX value in a specified block••••••••••••••••••••••••••••••••••••••• 8-12
MAX Detect maximum value in a specified block••••••••••••••••••••••••••••••••• 8-14
MIN Detect minimum value in a specified block ••••••••••••••••••••••••••••••••• 8-16
AVG Average value of specified block•••••••••••••••••••••••••••••••••••••••••••••• 8-18
WSUM Total value of specified block •••••••••••••••••••••••••••••••••••••••••••••••••• 8-20
BSUM Total value (in byte units) of specified block •••••••••••••••••••••••••••••••• 8-24
CRC Calculate CRC value in specified block ••••••••••••••••••••••••••••••••••••• 8-26
ZRES Reset specified block•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-30
BCMP Compare data between specified blocks •••••••••••••••••••••••••••••••••••• 8-32
BCMPI Compare data of value with block •••••••••••••••••••••••••••••••••••••••••••• 8-34
RND Generate random number•••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-36
SORT Binary data sort••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-38
SORTN Binary data partition sort•••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-40
Table Processing Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-42
FIFOW Write to FIFO table •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-42
FIFOR Read from FIFO table ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-46
LIFOW Write to LIFO table••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-50
LIFOR Read from LIFO table ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-54
FWRIT Overwrite data table specified position •••••••••••••••••••••••••••••••••••••• 8-58
FINS Insert to data table specified position •••••••••••••••••••••••••••••••••••••••• 8-60
FDEL Delete data table specified position •••••••••••••••••••••••••••••••••••••••••• 8-62
Time Processing Functions•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-64
WTIME Write time data to calendar timer ••••••••••••••••••••••••••••••••••••••••••••• 8-64
SEC Convert date/time format data to second format data •••••••••••••••••••• 8-66
RSEC Convert second format data to date/time format data •••••••••••••••••••• 8-68
AJST Calendar timer adjustment ••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-70
High-speed Processing Functions ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-72
DI Disable interrupt•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-72
EI Enable interrupt •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-72
RFSCTH High-speed Counter refresh ••••••••••••••••••••••••••••••••••••••••••••••••••• 8-73
DIC Set interrupt disabled range ••••••••••••••••••••••••••••••••••••••••••••••••••• 8-74
PID Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-76
PIDAT PID control with automatic tuning••••••••••••••••••••••••••••••••••••••••••••• 8-76
Log Function ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-78
LOGE Enable logging of specified ID••••••••••••••••••••••••••••••••••••••••••••••••• 8-78
LOGD Disable logging of specified ID •••••••••••••••••••••••••••••••••••••••••••••••• 8-78
TRGD Acquire Logging data•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-79
Memory Card Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-80
MWRIT Write to Memory Card••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-80
MREAD Read from Memory Card ••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-82
MFREE Get memory card free space in byte unit•••••••••••••••••••••••••••••••••••• 8-84
MFREEK Get memory card space in kilobyte unit ••••••••••••••••••••••••••••••••••••• 8-86
MMKDIR Make Memory Card directory•••••••••••••••••••••••••••••••••••••••••••••••••• 8-88
MRMDIR Delete Memory Card directory •••••••••••••••••••••••••••••••••••••••••••••••• 8-92
MDEL Delete Memory Card file•••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-94
MPRINT Write text in memory card file•••••••••••••••••••••••••••••••••••••••••••••••••• 8-96

12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MREADL Read one line from file in memory card ••••••••••••••••••••••••••••••••••••• 8-98
MCOPY Copy file in memory card ••••••••••••••••••••••••••••••••••••••••••••••••••••••8-100
MMOV Move file in memory card••••••••••••••••••••••••••••••••••••••••••••••••••••••8-102
MREN Rename memory card file •••••••••••••••••••••••••••••••••••••••••••••••••••••8-104
MSTAT Get status of file in memory card ••••••••••••••••••••••••••••••••••••••••••••8-106
Access Window Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-108
AWNUM Display access window numerical value •••••••••••••••••••••••••••••••••••8-108
AWMSG Display access window message••••••••••••••••••••••••••••••••••••••••••••8-110
FREE RUN Counter Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-112
RFSFRC FREE RUN counter refresh •••••••••••••••••••••••••••••••••••••••••••••••••••8-112
Sensor Setting Function •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-114
SPRD Read sensor parameter••••••••••••••••••••••••••••••••••••••••••••••••••••••••8-114
SPWR Sensor parameter write ••••••••••••••••••••••••••••••••••••••••••••••••••••••••8-116
SSVC Sensor service execution••••••••••••••••••••••••••••••••••••••••••••••••••••••8-118
Cyclic Communication Refresh Function •••••••••••••••••••••••••••••••••••••••••••••••• 8-120
RFSCI Refresh cyclic communication input•••••••••••••••••••••••••••••••••••••••••8-120
RFSCO Refresh cyclic communication output •••••••••••••••••••••••••••••••••••••••8-122

Chapter APPENDICES
1 List of Control Relays/Control Memories••••••••••••••••••••••••••••••••••••••••••••••• A-2
Control Relays•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• A-2
Control memory •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• A-8
2 ASCII Code Table•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••A-15
3 List of Unusable Characters ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••A-16
4 List of Unusable Functions••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••A-18
5 Index•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••A-19
6 Functions Index ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••A-23

- KV-5500/5000/3000/1000 Series Script Programming Manual - 13


14 - KV-5500/5000/3000/1000 Series Script Programming Manual -
1

OVERVIEW
OVERVIEW

1-1 KV Scripts •••••••••••••••••••••••••••••••••••••••••••••••••••• 1-2


1-2 KV Script Type••••••••••••••••••••••••••••••••••••••••••••••• 1-8
1-3 KV Script Function •••••••••••••••••••••••••••••••••••••••• 1-10

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-1


1-1 KV Scripts
KV script is a program language developed for operation processing and text string processing that
OVERVIEW

failed using former Ladder language. Since KV script can be programed in Ladder language, Ladder
program needs not to be interrupted during application.

1 Features of KV Script
KV Scripts

Ladder program is applicable to feedback control programming of driver control and sensor, etc.
For complicated value operation processing and text string processing program, the programming
becomes complicated, and the debug and maintenance also difficult.
KV script is a programming language developed to remedy main problems of these ladder programs.
Using script to supersede complicated part that cannot be described by ladder program, allows to
prepare program effectively.

Ladder program

Multi-rung programming in ladder program


can result in different understanding of
setps.
Simple calculations (such as +, -, x, \)
must use specified instructions. Comments
by circuit block is difficult to understand.

Can coexist with Ladder. Each script


can be added with comments.

KV script

Thanks to programming control


statement, program steps are
Even if not awaring of internal
easy-to-understand.
register, arithmetic operation can be
discribled as mathematic formula.

TIP Script program is executed after ladder conversion.


Script program operation confirmation etc may be monitored by converted ladder programs.

1-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-1 KV Scripts

OVERVIEW
How to Use KV Scripts

We will use the following example to describe how to realize operation processing and text string
processing that failed using Ladder program.
1
Ƶ Programming operation processing with KV Scripts

KV Scripts
Exclusive Ladder program method is required to program operation processing with Ladder programs.
When operation formula contains multiple operators and brackets, it be disassembled one by one,
programed according to precedence order of the operation, otherwise correct result will be not
obtained.

ƽ When using operators


Trapezoid A and B in different heights are shown below.
Please write a script program, summate the area of trapezoid A and B, and store the result to DM50.

3cm

Top
3cm
Height 4cm Trapeze A
Top
Height 2cm Trapeze B
Bottom Bottom

5cm 5cm

Programming Script '------<The comments are as follows >---------------------------------------------


Calculate trapezoid area according to (upper bottom + lower bottom) x height 12.
' DM01 = 3 : Stores value of upper bottom.
' DM02 = 5 : Stores value of lower bottom.
' DM03 = 4 : Stores height value of trapezoid A.
' DM04 = 2 : Stores height value of trapezoid B.
' Calculate summation of trapezoid A and B.
' ------< The above is comments >---------------------------------------------
DM50 = ((DM01 + DM02) * DM03 / 2) +((DM01 + DM02) * DM04 / 2)

As mentioned above, the trapezoid area formula can be programmed using a rung of script program.
Same processing can be programmed using ladder as follows.

Ladder Programming
CR2002 DM1 DM2 DM3 #2 DM1000
LDA ADD MUL DIV STA
Normal ON Top Bottom Height of Area of
trapeze A trapeze A

DM1 DM2 DM4 #2 DM1000 DM50


LDA ADD MUL DIV ADD STA
Top Bottom Height of Area of Sum of area
trapeze B trapeze A for trapeze
A and B

"Firstly save the area of trapezoid A to TM (DM1000), calculate area of trapezoid B, and plus the area
of trapezoid A" shall be described in ladder program.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-3


1-1 KV Scripts

ƽ When using operation functions


OVERVIEW

To add sin value and cos value of an angle.


The operation result (addition result) is stored in DM10.F.

1 Programming Script '------<The comments are as follows >---------------------------------------------


' DM02.F : Stores angle value to be SINed.
' DM06.F : Stores angle value to be COSed.
KV Scripts

'------< The above is comments >---------------------------------------------


DM10.F = SIN(DM02.F) + COS(DM06.F) Add sin value and cos value.

Programming via script functions such as SIN function and COS function is more simple than same
processing via ladder.
Ladder programming example as follows.

Ladder Programming

CR2002 DM2 DM2000


LDA.F SIN STA.F
Always ON Temporary
DM6
memory device
DM2000 DM10
LDA.F COS ADD.F STA.F

During ladder programming, the operation results of SIN function and COS function need to be
temporarily stored in TM before addtion operation.

TIP Operation function is a function for operation processing such as arithmetic/compare


processing and logical operation, etc.
It includes ANDA function and ORA function for bit device operation, BMOV function, FMOV
function for data movement, and SIN and COS floating point function, etc.

1-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-1 KV Scripts

Ƶ Programming text string processing with KV Script

OVERVIEW
KV script simple and convenient programming even if character processing (text string processing).

ƽ When using string operator


From DM 100, plus CR (0DH) and LF (0AH) into text string " KEYENCE" and then store.
1

KV Scripts
Data save status
K(4BH) E(45H) : DM100

Y(59H) E(45H) : DM101

N(4EH) C(43H) : DM102

E(45H) CR(0DH) : DM103

LF(0AH) NUL(00H) : DM104

Ladder Programming
CR2002 SMOV
"KEYENCE" DM100
Always ON
MOV
$D0A DM2000

MOV
$0 DM2001

SADD
DM100 DM2000 DM100

Programming Script
CR2002
DM100.T = "KEYENCE" + CHR($0D) + CHR($0A)
Always ON

Because control codes cannot be directly processed by using SADD instruction in Ladder program, so,
shall be stored in the device and then connected to the required text string. Thanks to special function,
KV script can simply connect text strings and control codes.

TIP gThe text string is truly the "string" of "character". The text string is bracketed using double
quote(" ").
For detail, see "Fixed text string (text string type constant)", Page 3-32
gSuffix .T added to DM100 indicates that the device for storing text string with KV script.
For detail, see "3-3 Data Type (suffix)", Page 3-40

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-5


1-1 KV Scripts

ƽ When using text string processing function


OVERVIEW

Search "@" from "Keyence@KV-5000", extract the programed " KV-5000" and save to DM50.T. The
program is described in script form as follows.

1 Programming Script ' ------<The comments are as follows >---------------------------------------------


' DM40.T : Stores string "Keyence@KV-5000".
KV Scripts

' DM10 : Stores "@" position (SFIND search result).


' DM20 : Stores DM40.T string length (LEN return value).
' DM30 : Stores string length of "KV-5000".
' ------< The above is comments >---------------------------------------------
DM40.T = "Keyence@KV-5000"

DM10 = SFIND(DM40.T, "@", 0) ' Search "@" from DM40.T, store the position to DM10.

DM20 = LEN(DM40.T) ' Obtain string length of DM40.T.

DM30 = DM20 - DM10 - 1 ' Obtain string length of "KV-5000".

DM50.T = SRGHT(DM40.T, DM30) ' Obtain "KV-5000".

When processing such a complicated processing as text string, script function allows simple
programming as the sample program above mentioned.
Besides, above sample program can be also programmed according to following method.

Programming Script DM40.T = "Keyence@KV-5000"


DM50.T = SRGHT(DM40.T, LEN(DM40.T) - SFIND(DM40.T, "@", 0) - 1)

TIP Text string processing function is a function to perform text string operations such as edition and
conversion of text string and string data processing such as search, etc., including LEN function
for testing string length, SMID and SLEFT functions for extracting text string, etc.

For text string function, see "Chapter 7 ARITHMETIC OPERATION FUNCTIONS", Page 7-1.

1-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-1 KV Scripts

Ƶ Programming control statements with KV Scripts

OVERVIEW
KV script, can enable functions such as conditional branch and reprocessing, etc. simply via control
statements.

ƽ For multi-branch control 1


The control "To store corresponding version information according to the word device value", can be

KV Scripts
programmed with SELECT statement as follows.

Programming Script ' ------<The comments are as follows >---------------------------------------------


' According to version No. stored in DM01,
' store corresponding version information to DM02.
' ------< The above is comments >---------------------------------------------
SELECT CASE DM01 ' Identify according to version No.
CASE 5000 ' When version No. is 5000.
DM02.T = "KV-5000"
CASE 3000 ' When version No. is 3000.
DM02.T = "KV-3000"
CASE 1000 ' When version No. is 1000.
DM02.T = "KV-1000"
CASE ELSE ' Whenno corresponding version No.
DM02.T = "Other Version"
END SELECT

About details of SELECT statement, please see "SELECT CASE to statement (multiple branch
control)", Page 4-18

The above script is programmed with ladder program as follows.

Ladder Programming Store version information corresponding version No. saved in DM01 to DM02.

DM1 SMOV
= "KV-5000" DM2
#5000
DM1 SMOV
= "KV-3000" DM2
#3000
DM1 SMOV
= "KV-1000" DM2
#1000
DM1 DM1 DM1 SMOV
<> <> <> "Other Version" DM2
#5000 #3000 #1000

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-7


1-2 KV Script Type
Two KV script types are available, each with different programming style.
OVERVIEW

Box Script

1 Box Script is a script programming execution conditions using ladder.


6 cells from the 5th to the 10th cell on a rung in edit screen is used for programming area. During
KV Script Type

programming, character code and the number of characters used will be limited and Box Script shall be
written within this limited range.
"2 Programming Script", Page 2-2

Programming Script 'Example script


IF DM000 > 100 THEN 'When DM000>100 is true
DM000 = DM000 - 5 'Subtract "5 " from DM000
When ELSE 'If false (DM000 <= 100)
DM000 = DM000 + 3 'DM000 is added with "3".
END IF

Programming

Box script programming

The contents behind a single quote are Line feed must be


comments. ensured at the end of
Chinese characters are allowed in contents.
comments.

Note
When execution condition is false, the program inside Box Script will be not
executed but jumped (please pay attentionn to partial functions such as differential
command, etc.)

1-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-2 KV Script Type

OVERVIEW
Area Script

Area Script is a script that can be executed during scanning even if the execution condition is not
established.
The programming area on edit screen occupies whole 1 rung. 1

KV Script Type
Programming Script 'Example script
IF DM000 > 100 THEN ' When DM000>100 is true
DM000 = DM000 - 5 ' Subtract "5" from DM000
When ELSE ' If false ( DM000 <= 100)
DM000 = DM000 + 3 ' DM0000 is added with "3".
END IF

Programming
Area script programming

Programming
among ladder
circuits.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-9


1-3 KV Script Function
KV script can enable programming program a series of ladder control in a format similar to BASIC
OVERVIEW

language.

About Assignment Statement


1
Via KV script, you can program using assignment statement, and store the value and operation result to
KV Script Function

the device.

Ƶ Assignment statement
DM1000 = DM1001 + 10

Right result (value) is stored into the device programed on the left of "=".

ƽ Numerical value assignment


To store constant 1000 to DM1000.

Programming Script DM1000 = 1000


Ladder Programming
CR2002 MOV
#1000 DM1000
Always ON

ƽ Text string assignment


To store text string "KEYENCE" into DM1000 (NUL (00H) indicating the end of text string will be
automatically added).

Programming Script DM1000.T = "KEYENCE"


Ladder Programming

CR2002 SMOV
"KEYENCE" DM1000
Always ON
Storage device

ƽ Bit assignment
To map the status of bit device R3001 to R3000.

Programming Script R3000 = R3001


Ladder Programming
R3001 R3000

Bit assignment Assignment result

For assignment statement, see "4-1 Assignment Statement", Page 4-2.

1-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-3 KV Script Function

OVERVIEW
About Operator

For KV script, arithmetic operation and logical operation, etc. need not to be converted to special
instructions such as Ladder program, operators can be directly programed, which enabling more visible
programming. 1

KV Script Function
ƽ Operation example
To multiply DM100 value by 10, add DM101 result and then multiply by 2. Assign (store) operation result to
DM1000.

Programming Script DM1000.L = 2 * (DM100 * 10 + DM101)


Ladder Programming
CR2002 DM100 +10 @VM0 DM101 @VM0 +2 DM1000
LDA EXT MUL.L STA.L LDA EXT ADD.L MUL.L STA.L
Always ON

ƽ List of operators
Symbols Processing content Program example
^ Calculate the power DM500 = DM100 ^2
* Calculate product of 2 value (multiplication) DM502 = DM100 * 3
Arithmetic / Calculate quotient of 2 values (division) DM504=DM100/4
operator MOD Divide 2 values, return remainder DM506=DM100 MOD 5
+ Calculate summation of 2 values (addition ) DM508 = DM100 + 6
- Calculate difference of 2 values (subtraction) DM510 = DM100 -7
< Less than MR500=DM100<10
<= Less than or equal to (below) MR501=DM100 <= 20
Comparison > Larger than MR502=DM100 >30
>= Larger than or equal to (above) MR503=DM100 >= 40
operator
Equal to (equivalent)
= MR504=DM100 = 50
* identical to "˙" of assignment
<> Unequal to (unequivalent) MR505 = DM100 <> 60
Text string
+, & Connect 2 text strings DM600.T="KEY"+"ENCE"
operator
NOT Calculate logical NOT of value MR600=NOT R000
Calculate logical AND of 2 values (bit
AND MR601=R000 AND R001
device relation, word device relation)
Logic operator Calculate logical OR of 2 values (bit device
OR MR602=R000 OR R001
relation, word device relation)
Calculate XOR of 2 values (bit device
XOR MR603=R000 XOR R001
relation, word device relation)
For operators, see "4-2 Operator", Page 4-6.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-11


1-3 KV Script Function
OVERVIEW

About Control Statement

KV script allows to program various control statements. facilitating to simply change (control) program flow.
Two kinds of control statements are available, including conditional branch statement and loop control
1 statement.
KV Script Function

Ƶ Conditional transfer control statements

To select the processing to be implemented according to the condition.

ƽ Type of conditional transfer statement


control
Basic format Description
statement
IF <Conditional formula> THEN According to the result of <conditional
<processing statement> formula>, determine whether executed or
END IF not
IF <Conditional formula> THEN
<processing statement 1> According to the result of <conditional
ELSE formula>, 2 branch control statements are
<processing statement 2> executed separately
END IF

IF statement IF <Conditional formula 1> THEN


<processing statement 1>
ELSE IF <Conditional expression 2> THEN
<processing statement 2> According to the result of multiple
conditional expression (<conditional
g
formula 1>, <conditional expression 2 >...
g
<conditional expression n>), multi-branch
g
ELSE control statements are executed separately
<processing statement n>
END IF

SELECT CASE < word device>


CASE <comparision value 1>
<Processing statement 1 >
CASE <comparision value 2>
<processing statement 2 > According to value of <word device>,
SELECT
g select and execute multi-branch control
statement
g statement correspondingly.
g
CASE ELSE
<processing statement n>
END SELECT

MC <MC execution condition > THEN


MC statement <processing statement> Master control statement
MCR

* Indicates inserting 1-byte space.


* Indicates that line feed must be made at the mark.

1-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-3 KV Script Function

Ƶ Loop control statement

OVERVIEW
To process according to specified conditional loop.

ƽ Type of loop control statement


Control
Basic format Description
1
statement

KV Script Function
FOR <word device>=<default>
TO <final value> STEP <increment > Loop processing is performed
FOR statement <processing statement>
until <word device>= <final value>
NEXT

WHILE <Conditional formula> When conditional formula is


WHILE <processing statement> TRUE, loop processing is
statement END IF performed for uncertain times
DO When conditional formula is
DO statement <processing statement> FALSE, loop processing is
UNTIL <Conditional formula> performed for uncertain times
Used in interrupt loop control
<Loop conditional statement start> statement, unrelated to condition
BREAK
BREAK (only used in FOR statement,
statement
<Loop conditional statement end> WHILE statement and DO
statement)
* indicates inserting 1-byte space.
* Indicates that line feed must be made at the mark.

For control statement, please see "4-3 Control Statement", Page 4-10.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-13


1-3 KV Script Function
OVERVIEW

About Suffix

In Ladder language, the suffix attached with an instruction can indicate the operation type of the
instruction; meanwhile, in KV script, the suffix attached with a device or constant can indicatethe
1 operation type of a function or the meaning of value stored in the device.
For data type (suffix), see "3-3 Data Type (suffix)", Page 3-40.
KV Script Function

ƽ Suffix type
Suffix Type Programmable range
.U unsigned 16-bit data 0 to 65535
.S signed16-bit data -32768 to +32767
.D unsigned 32-bit data 0 to 4294967295
.L signed 32-bit data -2147483648 to +2147483647
-3.4E+38dNd-1.4E-45
N=0
.F Single precision floating point type
1.4E-45dNd3.4E+38
(Significant bits: 7 bits)
-1.79E+308dNd-2.23E-308
N=0
.DF* Double precision floating point type
2.23E-308dNd1.79E+308
(Number of effective digits: approx. 16 digits)
.B Bit type (Boolean value) 1(ON, TRUE), 0(OFF, FALSE)
.T Text string type Text string
* • The ".DF" suffix can be used only with the KV STUDIO Ver. 6.00 and higher versions.
* • The ".DF" suffix can be specified only with a CPU function version 2.0 or higher CPU module.
"KV-5500/5000/3000 CPU Function Version", Page 2

ƽ Operator
Programming Script DM1000.D = 123456
DM1100.F = 123.456
BMOV(R1000, DM1200.D, DM2000, 50)

Ladder Programming
CR2002 MOV.D
#123456 DM1000
Always ON

CR2002 MOV.F
+123.456 DM1100
Always ON

R1000 BMOV.D
DM1200 DM2000 #50

1-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-3 KV Script Function

ƽ Omitting suffix

OVERVIEW
For programming of the device whose suffix omitted, the processing type depends on the device type.
Device type Type processed when suffix is omitted (default type)
R(DR),B,MR,LR,T,C,CTC,CR,URO .B (bit type)
DM,W,EM,ZF,FM,TM,CM,V0,P0,UM0,UV0
indirect specifying (㪁㩷) device
.U ( unsigned 16-bit data) 1
KV-5500/5000/3000 :.L ( signed 32-bit data)

KV Script Function
Z*
KV-1000 :.S (signed 16-bit data)
CTH .D ( unsigned 32-bit data)

* The default type varies with the CPU units used.

ƽ Label suffix
For programming when suffix of global label/local label is omitted, the processing type depends on the
"data format" selected when registering a lable.
Label data type Type processed when suffix is omitted (default type)
bit (BOOL) .B
1-word unsigned integer (UINT) .U
2-word unsigned integer (UDINT) .D
1-word signed integer (INT) .S
2-word signed integer (DINT) .L
Single precision floating
.F
point type real number (REAL)
Double precision floating
.DF*1
point type real number (LREAL)
Text string (STRING) (.T)*2
Timer .B
Counter .B
Array Data format based on array size

*1 • The ".DF" suffix can be used only with the KV STUDIO Ver. 6.00 and higher versions.
• The ".DF" suffix can be specified only with a CPU function version 2.0 or higher CPU module.
"KV-5500/5000/3000 CPU Function Version", Page 2
*2 For the label whose data type is "text string", suffix cannot be attached (Generally, suffix is omitted when
using).

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-15


1-3 KV Script Function

ƽ Device type declaration


OVERVIEW

By declaring the type of device at the start of script program, default type of every device can be
specified.
Declaration
Format Description
1 statement
DM1000 will be still processed as .D (32-bit
TYPE DM1000.D
KV Script Function

unsigned number). even if suffix omitted


TYPE EM1000 to EM2000 will be still processed
TYPE EM1000 - EM2000.F
as..F( 32-bit single precision floating point
(TYPE EM1000.F - EM2000)
type) even if suffix omitted.

For type declaration, see "3-3 Data Type (suffix)", Page 3-40.

Note
• Type declaration is valid only for the script programmed using TYPE.
• During type declaration for local label and array, the type larger than data format selected
during label registration and text string type shall be declared.
Example When "1-word unsigned integer" is selected in Data Format, if 32 bit type
declaration (TYPE [label name].D, etc.) is made, error will occur.
• When the type of global label is declared with TYPE, the suffix after type declaration will
become valid.

TIP When the device after type declaration is used via indirect specifying, it will be processed as
.U by default.

1-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1-3 KV Script Function

OVERVIEW
About Script Function

KV-5500/5000/3000/1000 ladder instructions can be used via KV script for script function.
To discriminate from ladder instructions, the instruction used via KV script are called "script function".
1
Ƶ Function

KV Script Function
Ladder language compiles program by connecting instructions via symbol lines, but KV script uses
assignment statement, operators, control statement and script function to compile program.
Script functions basically cover all ladder instructions. Because that operators and assignment
statement can be used, the function corresponding to operation type instructions (ADD, MUL, etc.) and
data move instruction ( MOV , DW , etc.) can not be used.
MR1000 MR1002

MR1001

CR2002 DM2000 DM1000


LDA.F SIN STA.F
Normal ON R02002
DM1000.F = SIN(DM2000)
BMOV(R1000,DM100,DM2000,4)
Normal ON
R1000 BMOV
DM100 DM2000 #4

Most of script functions shall be programmed according to function name identical to ladder instruction.
The action is identical to ladder instruction.

TIP Since script needs not to operate internal registers, LDA and STA instruction are not used.
Some functions are unavailable in ladder instruction but can be added via KV script.

ƽ Script function type


Script functions can be divided into the following types.
Type Description
Function group for operation of word device and bit device, Including ANDA and
Operation processing
ORA logical operation, BMOV and FMOV for data movement, and SIN and COS
function
floating-point operation etc.
String processing Function group for text string processing, including LEN for testing string length,
function SMID/SLEFT for extracting text string, etc.
Data processing Function group for data processing, including MAX, MIN, and BCNT for calculating
function the number of ON bits in specified word device.
Function group for processing other than operation, text string, data processing,
Other Function including TMR, ADRST for indirect specifying, MWRIT and MREAD functions for
memory card control , etc.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 1-17


1-3 KV Script Function

Ƶ About operation flag (CR2009 to CR2012)


OVERVIEW

Every script shall be converted to ladder. During function execution, the status of operation flag will be also
changed correspondingly. The status of operation flag will vary before and after execution of script program.
Besides, ladder generated via script conversion can be programed according to different function
combinations, so, if operation flag varies with the change of script program, it cannot be used.
1
Ƶ When looking up notes on indirect specifying and index modification
KV Script Function

When using indirect specifying and index modification, do not specify the device that actually does not
exist in the lookup destination address.
For the device nonexistent actually via indirect specifying or index modification in argument of every
function, function operates as follows.

ƽ Every function operation table when invalid address is specified


Function operation Function name
"0 " is stored in return value UNIF,RDASC,RHASC,RFASC,VAL,LEN,SFIND,INSTR,FIND,S
EG,MAX,MIN,AVG,WSUM,BSUM,BCMP,BCMPI,SEC
NUL (00H) is save in return value DASC,STR,HASC,FASC,SRGHT,RIGHT,SLEFT,LEFT,SMID,MI
D,SRPLC,REPLACE,SINS,INSERT,SDEL,DELETE
Value of 1st argument stored in return ROOT,ANDA,ORA,EORA,ENRA,COM,NEG,SRA,SLA,RRA,RL
value *1 A,RRNCA,RLNCA,TBCD,TBIN,MPX,DMX,GRY,RGRY,SWAP,D
ECO,ENCO,TO,USDLF,FLOAT,INTG,INT,EXP,LOG,RAD,DEG,S
IN,COS,TAN,ASIN,ACOS,ATAN,ASC,RASC,DASC,CHR,BCNT,
DCNT,SER,CRC,WTIME,AWNUM,AWMSG,WTIME,SQRT,ABS,
RND
The function is not executed LDP, LDF, BLD, BLDB, SET, RES, BOUT, BOUB, BSET, BRES,
MCALL, MSTRT, ZPUSH, ZPOP, ADRSET, ADRINC, ADRDEC,
ADRADD, ADRSUB, BMOV, FMOV, PMOV, INC, DEC, WSR,
WSL, BSR, BSL, DISF, DISS, UNIS, ZRES, FIFOW, FIFOR,
LIFOW, LIFOR, FWRIT, FINS, FDEL, RSEC, DIC, LOGE,
LOGD, MWRIT, MREAD, MFREE, MMKDIR, LDPD, LDFB,
RFSX, RFSY, ECALL, MDSTRT, MDSTOP, FRSET, FRSTM,
FRLDM, UREAD, UWRIT, UFILL, LIMIT, BANDC, ZONE, APR,
DISN, DISB, UNIN, UNIB, DSER, RFSCTH, TRGD, MRMDIR,
MDEL, RFSFRC
*1 But, if invalid indirect lookup is performed in the 1st argument, the correctness of return value cannot be
guaranteed.

1-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


PROGRAMMING SCRIPT
2
PROGRAMMING SCRIPT

2-1 Programming Script •••••••••••••••••••••••••••••••••••••••• 2-2


2-2 Box Script••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-4
2-3 Area Script ••••••••••••••••••••••••••••••••••••••••••••••••• 2-16
2-4 Label Programming and Label Array•••••••••••••••••• 2-25
2-5 Precautions on Script Programming •••••••••••••••••• 2-40
2-6 Script Conversion Output Message ••••••••••••••••••• 2-41
2-7 Macro•••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-47
2-8 Script Debug Function ••••••••••••••••••••••••••••••••••• 2-49
2-9 Input Auxiliary Function and Other Info ••••••••••••••• 2-51

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-1


2-1 Programming Script
PROGRAMMING SCRIPT

The chapter describes how to operate Box Script/Aea Script as well as menus and edit screen.

Programming Script

KV script can be programed directly in text format in ladder edit image.


In addition, it also supports the Windows functions such as Cut/Paste, Copy, Undo/Redo, etc.

2
How to Program Script
Programming Script

Box script/area script can be programmed by combining ladder program in ladder edit window.
KV script can be programed after checking script programming area in ladder edit window.

(1) Call the script from the menu


Select "Script (S)" -> "Insert area script (A)" or "Insert box script (B)".

(2) Call script from right-click menu


When the cursor locates on ladder edit window, select "Edit script (X)" from right-click menu, and then
select "Insert area script (A)" or "Insert box script (B)".

(3) Call script from icon


Click the icon on the toolbar.
• Area script:
• Box script:

(4) Call script using shoutcut key


• Area script: key + key
• Box script: key + key





2-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-1 Programming Script

PROGRAMMING SCRIPT
How to Input Scripts

2 Script input methods are available. But function will not vary with different input methods. So, please
select as you like.

Ƶ Direct input (default)


Like ladder instruction programming scripts can be directly programmed on Ladder Editor. 2

Programming Script
1 From the menu, select "Script (S)" -> "Change edit method (N)" -> "Direct input (D)".

Other procedure From "Tool (T)" -> "Option (O)", select "Direct input" in "Input format" of "Script setting" tab.

Ƶ Window input
To input scripts in text edit window displayed during script programming.

1 From the menu, select "Script (S)" -> "Change edit method(N)" -> "Window(W)".

Other procedure From "Tool (T)" -> "Option (O)", select "Window(Window entry)" in "Entry method" of
"Script" tab.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-3


2-2 Box Script
PROGRAMMING SCRIPT

This section describes precautions on how to make/edit and use box scripts.

Features of Box Script

Box Script is a script that can specify the time and sequence to executing KV script programs using
ladder with ladder execution conditions.

2 Box Script is executed only when execution condition specified by ladder is true, programming can be
adaptable with operation formula.
Box Script

When using box scripts in the following cases

Box scripts are suitable for making programs excluding several lines of operation formula and
complicated control statements.
Besides, for execution condition programmed via Ladder, the program in box script can only program
execution processing statement, so, control statement is not required, it can be used simply.
Box Script

Ladder Programming

2-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
ƽ Example for programming using box scripts
[Scaling]
The value within the range of 0 to 4000 stored in DM0.F ([DM1/DM0]) is scaled to the range of 50 to
1999 and stored to DM2.F ([DM3/M2]). The operation is performed via single precision floating point
type.
DM2

gDM0=0 -> DM2=50 1999


2
gDM0=50 -> DM2=74

Box Script
gDM0=100 -> DM2=98
gDM0=500 -> DM2=293
gDM0=1000 -> DM2=537
gDM0=2000 -> DM2=1024
gDM0=4000 -> DM2=1999

50

0 DM0
0 4000

Use Box Script to program above operation.

Box Script

Ladder Programming

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-5


2-2 Box Script
PROGRAMMING SCRIPT

Making Box Script

The flow from making to debugging box script is described as follows.

Operation Flow

2 The operation flows for making and editing box scripts are described as follows.
Box Script

Programming execute condition


࡮From icon……
(contact) using ladder
࡮From key operation…… key +key

࡮From menu……

New a box script ǂǂǂ"Script (S)" ->


Correct program
ǂǂǂ"Insert box script (B)"
࡮From right-click menu

ǂǂǂ"Edit script (X)" ->


Program and edit scripts
ǂǂǂ"Insert dialog script (B)"

Convert scripts

When conversion fails

Verify error by
poped window
When conversion successful

Verify program operation

Use Monitor
or Simulator function

When defective operation occurs

2-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
New a box script

The making steps of box scripts are described as follows.

1 To program execution condition in Ladder Editor, click the cell in which box script to be edited is located.

2
Box script is made at this section.
Select the cell.

Box Script
TIP Box script occupies 6 cell (cell 5 to 10). Execution condition can be programmed within cell 1 to cell 4.
Regardless of the position of the selected cell, the box script shall be make in the cell 5 to
cell 10.

2 From the menu, select "Script (S)" -> "Insert box script (B)".

Other procedure g key + key


gFrom right-click menu, select "Edit script (X)" -> "Insert box script (B)".

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-7


2-2 Box Script
PROGRAMMING SCRIPT

3 Program the inserted box script.


After programming, press key + key, or press key, click the ladder edit window other than
box script being edited, complete programming.

2
Box Script

Status for editing


Please use + or to
complete programming.

Status after edit completed

TIP Execution condition can be also programed after making box scripts.

Insert dialog script and then


program

Then program
execute conditions

2-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
4 After programming, convert box script.

Other procedure From right-click menu, select "Edit script (X)" -> "Convert all scripts (C)"

Box Script
ƽ When conversion successful

indicates conversion completed

The popping up window displays "warning" message sometimes.


"Warning Message", Page 2-41

ƽ When conversion fails


"Script conversion error" appears.
In addition, the popping up window displays error message.
"When conversion error occurs", Page 2-44

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-9


2-2 Box Script
PROGRAMMING SCRIPT

5 Verify program by using ladder after successful script conversion.


Click " " displayed on the left side of the box script rung to display the converted ladder. (if script
conversion fails, " " will be not displayed

Other proceduregSelect the extended box script, select "Edit script (X)" -> "Display/hide converted ladder
(V)"from right-click menu.
g key+ key
2
Please click ladder
Box Script

extend button

Status after conversion completed

Click to extend Click and the extended


ladder diagram ladder is hidden

Click and the extended


ladder diagram is hidden
and return to

Status after extend ladder

TIP If editing script after script conversion, the converted ladder will be not displayed. (
disappears)
To display ladder, script shall be converted again.

6 The extended ladder can be partially hidden (folded).


Click beside the extended ladder.

Other procedure Select the comment part ( ) of the folded ladder rung. select "Display/hide converted ladder
(V)" from right-click menu.

2-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
Reedit Box Script

The re-editing steps of box script are described as follows.

Ƶ Reedit box script

1 To reedit the box script programmed, double-click the Box Script to be edited.
2
Other procedure After selecting the box script to be edited, click the following keys:

Box Script
g key
g key
g key

Please double
click in this box

Uneditable status

Editable status

Ƶ Delete box script

1 Select the box script to be deleted.

2 Press key in keyboard.

Box script is deleted

Ladder after deleting box


scripts

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-11


2-2 Box Script
PROGRAMMING SCRIPT

Ƶ Copy box script

1 Select the box script to be copied, select "Edit (E)" -> "Copy (C)" from the menu.

2
Box Script

Other procedure g key+ key


gFrom the right-click menu, select "Copy (C)"

2 Select the cell (rung) to paste box script copied according to step 1.
From the menu, select "Edit (E)" -> "Paste (P)".

Other procedure g key+ key


gFrom the right-click menu, select "Paste(P)"

2-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
TIP The whole rung including box script can be also copied.

Please select whole


rung you want to copy,
and then select
"Edit (E)" -> "Copy (C)"
from the menu

Select rung
2

Box Script
㸠ܼԧࠍࠦࡇ࡯
㸠ܼԧ
Copy ࠍࠦࡇ࡯
the whole rung

Select whole rung to be


copied, select "Edit (E)"
-> "Copy (C)" from
menu and you can copy
to this rung

Select rung or cell

Precautions When Using Box Script

When the execution condition of box script is OFF, the script program will be not executed. For this the
following points shall be noted.

ƽ When using differential execution type functions


The previous status of differential detection device (execution condition of differential execution type
functions) is the status when executing the previous box script (subroutine).
Care must be taken when differential execution type functions are executed for 2 times within 1
scanning, or after Box Script is executed for the nth times, the [n+1]th box script is not executed in
continuous scanning.

For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "Precautions when using
differential execution Type Instructions".

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-13


2-2 Box Script
PROGRAMMING SCRIPT

ƽ When using timer function


When timer function is used by Box Script, TMR instruction will be programmed between NCJ to
LABEL of the extended ladder program. From this, the timer contacts fail to be correct ON/ OFF
sometimes. Besides, TMR function whose execution condition omitted shall be also noted.
For example, when programming the following programs:

2 Box script
Box Script

Ladder Programming

Observe the extend ladder program, if the reset condition of timer instruction is CR2002 (mormal ON),
the timer cannot be reset after executing.
To solve this problem, DIFU instruction can be connected with AND as execution condition.

2-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-2 Box Script

PROGRAMMING SCRIPT
As execution condition, connect AND to DIFU instruction
Box script

Ladder Programming
2

Box Script
When execution condition (MR2000) of Box Script is TRUE, R1100 will be ON only in 1 scanning via
DIFU instruction. In this case, RES function programmed on the 1st rung of Box Script enables the
timer to reset, unrelated to the previous status of the ladder. After execution of Box Script, the timer is
cleared and timer function (contact) acts correctly.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-15


2-3 Area Script
PROGRAMMING SCRIPT

This section describes precautions on how to make/edit and use of Area Script.

Features of Area Script

Area script is programmed on a whole rung.

2
Area script is used in the following cases
Area Script

Area script is every-scan execution type, suitable to the program including conditional branch
and loop control.
Area script allows to simplify programming of complicated conditional branch and multiple
branches.

Area script

* the description on the rigt side of single quote (') shall be processed as comment.

Ladder Programming

If conditional branch is complex, or program is lengthened via ladder programming, area script can
enable improving programming efficiency.

2-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-3 Area Script

PROGRAMMING SCRIPT
ƽ Example for programming with area scripts
To identify the category of disk passing a certain point on belt conveyer, store corresponding color
name.
When the disk does not pass the point, the bit device MR001 is OFF. When the disk passes it, it is ON.
When MR001 is ON, identify the category of disc stored in DM10, and store the color of disc
corresponding to DM50.T.
Using area script to program the part from disk category identifying to storaging.
2
When the disk reaches the check point, disk color can be detected via color sensor.

Area Script
• Red "1" is stored in DM10
• Yellow "2" is stored in DM10
• Orange "3" is stored in DM10
• Gold "4" is stored in DM10

Color sensor

Script

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-17


2-3 Area Script
PROGRAMMING SCRIPT

Making Area Script

The flow from making to debugging of Area Script is described as follows.

Area script is used in the following cases

2 The operation flow for making/editing box script is described as follows.


Area Script

࡮From icon……
࡮From key operation… key+ key
New a area script ࡮From menu……
ǂ"Script (s)" -> "Insert area script (A)"
Modify program
࡮Right click menu
"Script edit (X)" ->"Insert area script (A)"
Program and edit scripts

Verify error content Convert script

When conversion fail

When conversion successful

Verify program operation

Use Monitor
or Simulator function

When defective operation occurs

2-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-3 Area Script

PROGRAMMING SCRIPT
New a area script

The creation steps of Area Script are described as follows.

1 Click the cell (rung) in which area script will be located.

Area Script
Select cell

Make area script in this part

TIP Area script occupies 1 whole rung (10 cells).

2 From the menu, select "Script (S)" -> "Insert area script (A)".

*Area script can be inserted from the menu, tool bar and keyboard.

Other procedure gPress key+ key.


gFrom right-click menu, select "Edit script (X)" -> Insert area script (A)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-19


2-3 Area Script
PROGRAMMING SCRIPT

3 Program the inserted area script.


After programming, press key + key, or press key, click the Ladder Edit window other than Area
Script being edited to complete programming.

2 Please use + or
complete programming .
key to Status for editing
Area Script

Status after edit completed

4 Area script shall be converted after programming completed.

ƽ When conversion successful

indicates onversion completed

The popping up window displays "Warning" message sometimes.


"Warning Message", Page 2-41

2-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-3 Area Script

PROGRAMMING SCRIPT
ƽ When conversion fails
"Script conversion error" will be displayed.
In addition, the popping up window displays error message.
"When conversion error occurs", Page 2-44

5 After successful script conversion, is displayed on the left side of area script. Click to
extend ladder under area script. 2
(if script conversion fails, will be not displayed)

Area Script
Other proceduregSelect the expanded area script, select "Edit script (X)" -> "Display/hide converted ladder
(V)" from right-click menu.
g key+ key

Please click ladder


extend button

Status after conversion completed


Click to
extend ladder Click and the extended
ladder is hiden

will appear after


extending

Status after extending ladder

TIP If editing script after script conversion, the converted ladder will be not displayed. ( disappears)
To display ladder, script shall be converted again.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-21


2-3 Area Script
PROGRAMMING SCRIPT

6 The outspread Ladder can be partially hidden (folded).


Click .beside the extended ladder.

2
Area Script

Reedit area script

The re-editing steps of Area Script are described as follows.

Ƶ Reedit area script

1 Double-click the area script to be edited to reedit the area script programmed.

Other procedure Select the Area Script that you want to edit, press the following keys.
g key
g key

Please double
click in this box

Uneditable

Editable

2-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-3 Area Script

PROGRAMMING SCRIPT
Ƶ Delete area script

1 Select the area script to be deleted.

Area Script
Selected

2 Press key in keyboard.

Delete area
script

Deleted

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-23


2-3 Area Script
PROGRAMMING SCRIPT

Ƶ Copy area script

1 Select the area script to be copied, select "Edit (E)" -> "Copy (C)" from the menu.

2 Selected
Area Script

Other procedure g key+ key


gFrom the right-click menu, select "Copy (C)"

2 Select the cell (rung) of area script copied according to step 1.


From the menu, select "Edit (E)" -> "Paste (P)".

Status of copy complete

Other procedureg key+ key


gFrom the right-click menu, select "Paste(P)"

2-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
This section describes label program method and precautions, and label array application method, etc.

Important
Local label and label array can be used only when CPU unit is KV-5500/5000/3000. When
CPU unit is KV-1000, local label and label array cannot be used.

Label Programming 2

Label Programming and Label Array


Pre-setting the label for the device used in the program can allow label programming.

Label can be divided into two types: global label and local label.

Note
Local label can be used only when CPU unit is KV-5500/5000/3000.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-25


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

Ƶ Global label
Global label refers to the common label in whole project.
1 global device must be assigned with 1 global label.

ƽ Programming flow using global label

2 Pre-register the following items


Register global lable ・Label name
Label Programming and Label Array

through label edit window


・Data format*1
・Device/Constants
Program and edit scripts ・(Lable comments)*1*2
using global lables registered

1 Can’t specify when KV-1000 CPU is used


2 Lable comments can be converted even if not
registered.

Convert script

When
conversion fails

End

ƽ Register global label


The global label registration steps are described as follows.

1 From the menu, select "View (V)" -> "Label edit window (L)". Label edit window appears.

Other procedure Double click "Label" in workspace.

Click “Global” lable when using


KV-5500/5000/3000 CPU.

2-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
2 Register global label to be used.
For label editor window, see KV STUDIO User's Manual.

When selecting CPU KV-5500/5000/3000

Label Programming and Label Array


Item Description
Label name Set within half-width 32 character, full-width 16 character. *1
Specify label type. Click input box, select label type from the drop down menu
Data format
displayed.
Specify the device or constant to which global label is assigned.
Device/constant The range of device and constant that can be specified varies with Data Format.
"About label type", Page 2-32
Label comment Specify comment in global label.

*1 The character and character string that cannot be specified also available, such as reserved word
of KV STUDIO, etc.
"Precautions when using label", Page 2-32

When selecting CPU KV-1000

Item Description
Label name Set within half-width 16 character, full-width 8 character. *1
Device Specify the device to which global label is assigned. *2
Device Comment Display the device comment assigned. Cannot be edited.

*1 The character and character string that cannot be specified also available, such as reserved word
of KV STUDIO, etc.
"Precautions when using label", Page 2-32
*2 The device that cannot be specified also available.
KV STUDIO User's Manual

Note
Label can be set for global device, other than local device.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-27


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

3 Use global label registered to meke script program.

Character color of label registered in script edition will be changed.


2
Convert script after programming completed.
Label Programming and Label Array

ƽ Example for programming using global label

2-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
Ƶ Local label
Local label refers to label that can be used when CPU is KV-5500/5000/3000, only valid in every
module, and every module shall be set.
For the device (VB, VM) whose local label using system area (working memory) of KV-5500/5000/3000,
local label can be also set even if service condition of the device is not known.

Note
When CPU is KV-1000, local label cannot be used. 2

Label Programming and Label Array


TIP Working memory has 50000 words in VM, 16384 points (1024ch) in VB, which assignment
can be managed by using KV STUDIO.
"About Script Work Memory (Work Devices)", Page 2-61

ƽ Programming flow using local label

Program and edit


scripts using lables

Register programmed
lables* as local lables

Convert script

When
conversion fails

End

* Before script programing, local label can be also registered in advance.

ƽ Register local label


The registration steps of local label are describled as follows.

1 Program script with labels.

Character color is not changed due to label not registered.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-29


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

2 Under script editing mode, select the label range registered as local label, select "local label
register (L)" from right-click menu.

Select range

2
Label Programming and Label Array

Right click menu

3 Set data format in label edit window.

Item Description
Label name Automatically stored after label range selection. *1
Default to "1-word unsigned integer".
Data format Data format can be changed by clicking drop-down menu.
"About label type", Page 2-32
During constant assignment of local label, constant can be specified. Constant is not
Constant
assigned if blank.
Label comment Specify comment to be added to local label.

*1 The character and character string that cannot be specified also available, such as reserved word
of KV STUDIO, etc.
"Precautions when using label", Page 2-32

TIP All labels of the module being edited can be registered in batch as local label.
"Batch register of local label", Page 2-31

2-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
4 Convert after all local labels are registered.

Label Programming and Label Array


ƽ Batch register of local label
Via editing module, register all labels unregistered to local label in batch.

Data Format of every local label changes to "1-word unsigned integer", which, can be separately
changed.

Note
During batch registration, all labels in module are registered. So, the error flag is also
registered as label, the error occuring in script conversion may appear in normal
conversion.
Example DN1000 = 10 ...... Before batch registration: during script conversion, error occurs.
.... After batch registration: error will not occur during script conversion.
After batch registration, it is recommended to check content registered via label edit
window.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-31


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

Ƶ Precautions when using label


ƽ About label type
When CPU is KV-5500/5000/3000, data format (type) can be specified in label.

2
Label Programming and Label Array

Data format can be selected as follows.

Item Processing data range


Bit BOOL 0(OFF,FALSE),1(ON,TRUE)
1-word Unsigned integer UINT 0 to 65535
2-word Unsigned integer UDINT 0 to 4294967295
1-word Signed integer INT -32768 to +32767
2-word Signed integer DINT -2147483648 to +2147483647
Single precision -3.4E+38d Nd1.4E-45
floating point type real REAL N=0
number 1.4E-45dNd3.4E+38
Double precision -1.79E+308d Nd-2.23E-308
floating point type real LREAL N=0
number*1 2.23E-308d Nd1.79E+308
Text string STRING Less than 32 characters (half-width character)

Timer*2 --- 0˄OFF,FALSE˅,1˄ON,TRUE˅


* the label added with suffix ".D" will be processed as current value.

Counter*2 --- 0˄OFF,FALSE˅,1˄ON,TRUE˅


* the label added with suffix ".D", will be processed as current value.
Specify via "Array size" dialog box
Array ---
"Label Array", Page 2-35

*1 • The ".DF" suffix can be used only with the KV STUDIO Ver. 6.00 and higher versions.
• The ".DF" suffix can be specified only with a CPU function version 2.0 or higher CPU module.
"KV-5500/5000/3000 CPU Function Version", Page 2
*2 If a .D suffix is added to the label, it will be handled as the current value.

2-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
ƽ About label suffix
During label registration, type of data (Data Format) is set via label edit window, so, programming can
be also performed even if suffix not added. But, the programming with additional suffix can be also
performed as same as other device.

TIP Type declaration can be also conducted based on TYPE. The relations among "Data
Format", "Type declaration" based on TYPE, and "Direct specifying" of suffix via label edit
window are as follows.
2

Label Programming and Label Array


Data format < Type declaration < Direct specifying

Low          PRI High

When registering labels, the suffix which can be specified based on data type (data format) in label edit
window is limited as follows.

Global label Local label


Item O O
.B .U .S .D .L .F .DF .T mit .B .U .S .D .L .F .DF .T mit
ted ted
Bit ƻ h h h h h h h .B ƻ h h h h h h h .B
1-word Unsigned integer ƻ ƻ ƻ ƻ ƻ ƻ ƻ ƻ .U ƻ ƻ ƻ h h h h h .U
2-word Unsigned integer ƻ ƻ ƻ ƻ ƻ ƻ ƻ ƻ .D ƻ ƻ ƻ ƻ ƻ ƻ ƻ h .D
1-word Signed integer ƻ ƻ ƻ ƻ ƻ ƻ ƻ ƻ .S ƻ ƻ ƻ h h h h h .S
2-word Signed integer ƻ ƻ ƻ ƻ ƻ ƻ ƻ ƻ .L ƻ ƻ ƻ ƻ ƻ ƻ ƻ h .L
Single precision
floating point type real h ƻ ƻ ƻ ƻ ƻ ƻ h .F h ƻ ƻ ƻ ƻ ƻ ƻ h .F
number
Double precision
floating point type real h ƻ ƻ ƻ ƻ ƻ ƻ h .DF h ƻ ƻ ƻ ƻ ƻ ƻ h .DF
number
Text string h h h h h h h ƻ .T h h h h h h h ƻ .T
Timer ƻ ƻ ƻ ƻ ƻ h h h .B ƻ ƻ ƻ ƻ ƻ h h h .B
Counter ƻ ƻ ƻ ƻ ƻ h h h .B ƻ ƻ ƻ ƻ ƻ h h h .B

ƻ: Suffix can be specified (but, in case of suffix specified different from Data Format, prompt is given
during conversion)
h: Suffix cannot be specified.

TIP When programming the suffix that cannot be specified, error will appear during script
conversion.

ƽ About the bit of global label


When bit is specified in Data Format of global label, different types of assignment device will use
different suffixes.

Device to be assigned Suffix that can be specified


R,B,MR,LR .U/.S/.D/.L./.F/.DF/.T*/.B
Bit specifying of word device
.B
(DM1000.12, etc.)
* When specifying ".T", please specify the leading device of channel to assign the bit device.
- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-33
2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

ƽ Other precautions
• Same label name can be set for global label and local label. It operates in form of local label.
• Text string such as reserved words can not be used in label name.
"List of Unusable Characters", Page A-16
• When CPU unit is KV-5500/5000/3000, label is full-width character/half-width character sensitive but
is not case-sensitive.
2 • Index modification cannot be conducted for local label.
"Index Modification", Page 3-33
Label Programming and Label Array

• Index modification and indirect specifying cannot be conducted for label array.
"Label Array", Page 2-35
• When constant is assigned in label, index modification and indirect specifying cannot be performed.
• Label and word device bit cannot be specified.
"Processing Word Device as Bit Device", Page 3-28

2-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
Label Array

When registering label, label array can be used by specifying "Array" in Data Format via label edit window.

Note
When CPU is KV-1000, label array cannot be used (global label array, local label array).

2
ƽ Array

Label Programming and Label Array


Array refers to continuous aggregation of same data type.
KV script represents the array in form of "label + [label end code]", Multi-dimensional array can be
realized by takeing comma as end code for separating label.
Maximal 8-dimensional label array can be specified.

Denotation Label array is expressed as follows.

End code

LABEL [10, 10,࡮࡮࡮࡮, 10]


࡮࡮࡮࡮
Label name 1D 2D 8D

TIP For label end code of label array, except integer (DEC, HEX), integer type (.U /.S /.D /.L)
device, macro argument (P0 to P9, V0 to V9) and the function with formula and return value
can be also programmed.
Example: LABEL[1, 2, DM0]
LABEL[1, DM2 㪁㩷3, Z01]

Note
• Index modification cannot be conducted for label array.
• The indirect specifying device cannot be specified in label array.
• When programming device and formula in label end code of label array, the value to be
stored shall not exceed the range of label end code.

Scope Multi-dimensional array : maximal 8 dimension


Label end code range : 1 to 131071

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-35


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

Example
The following describes a data storage diagram when the array size of label is registered as "10,10" in label
edit window.
LABEL[0,0]
LABEL[0,1]
LABEL[0,2]
LABEL[0,9]
0 1 2 3 4 5 6 7 8 9
2 LABEL[1,0]
0 1 2 3 4 5 Ă Ă Ă 9
LABEL[1,9]

1 10 11 12 19
Label Programming and Label Array

LABEL[2,0]
2 20 Ă
LABEL[3,0]
3 30 Ă

4 Ă

5
6
7
LABEL[9,9]
8
LABEL[9,0]
9 90 Ă Ă Ă 97 98 99 100

When Data Format of label array is selected as "1-word unsigned integer" or "1-word signed integer", in above
label array, 10x10 = 100 words shall be guaranteed as label array area.

Ƶ Global label array


When registering global label array, "Array" in data format shall be specified.

1 From the menu, select "View (V)" -> "Label edit window (L)". Label edit window appears.

Other procedure gDouble-click "Label" in workspace.


gClick the tool bar in the Script Edit window.

Click “Global ” lable.

2-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
2 Register global label array name and set data format to "array".

Label Programming and Label Array


Select "array", the "array size" dialog box will pop up.

3 Set the format and size of array data.

Item Description
Specify label type. Click input box, select label type from the drop down menu
Data format
displayed.
• Specify array size. Via comma separation, maximal 8 dimensional array can be
specified.
Array size
• Please specify the array size within 1 to 131071. *1
• When major data of array is uncertain, can be replace with "?". *2

*1 Do not exceed the range of global device to be assigned.


*2 When it is converted under the status of "?" reserved, the error will occur.

TIP Please select data format from the following options.

Item Processing data range


Bit 0(OFF, FALSE), 1(ON,TRUE)
1-word Unsigned integer 0 to 65535
2-word Unsigned integer 0 to 4294967295
1-word Signed integer -32768 to +32767
2-word Signed integer -2147483648 to +2147483647
-3.4E+38dNd1.4E-45
Single precision
N=0
floating point type
1.4E-45dNd3.4E+38
-1.79E+308dNd-2.23E-308
Double precision
N=0
floating point type
2.23E-308dNd1.79E+308

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-37


2-4 Label Programming and Label Array
PROGRAMMING SCRIPT

4 Specify global device to be assigned.

Note
Global label array occupies global device whose size has been specified in array.

Ƶ Local label array


2 The label pre-registration method of local label array and global label array is identical to registration
method after script programming.
Label Programming and Label Array

The method of registering local label array after script programming is introduced below.

1 Using local label array to program the script.

Character color is not changed due to label not registered.

2 Under script editing mode, select the label range as local label register, select "Local Label
Register (L)" from right-click menu.

Select range of lable name only.


End code not selected.

Right-click menu

2-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-4 Label Programming and Label Array

PROGRAMMING SCRIPT
3 Set local label array in label edit window.

Label Programming and Label Array


Select "array", the "array size" dialog box will pop up.

4 Set the format and size of array data.

Item Description
Specify type of local label array. Click input box, select label type from the drop down
Data format
menu displayed.
• Specify array size. Via comma separation, maximal 8 dimensional array can be
Array size specified.
• When major data of array is uncertain, can be replace with "?".

* Do not exceed the range of global device to be assigned.


"Application area of work memories", Page 2-61

TIP Please select data format from the following option.

Item Processing data range


Bit 0(OFF, FALSE), 1(ON,TRUE)
1-word Unsigned integer 0 to 65535
2-word Unsigned integer 0 to 4294967295
1-word Signed integer -32768 to +32767
2-word Signed integer -2147483648 to +2147483647
-3.4E+38dNd1.4E-45
Single precision
N=0
floating point type
1.4E-45dNd3.4E+38
-1.79E+308dNd-2.23E-308
Double precision
N=0
floating point type
2.23E-308dNd1.79E+308

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-39


2-5 Precautions on Script Programming
PROGRAMMING SCRIPT

About Parallel Connection of Box Script

"OR" (logical OR) connection cannot be made R1000


between Box Script and ladder instruction. TMR (MR1000 AND R2000 = OFF, T100, 300)
Execution
Error will occur during conversion of right program. conditon MR1100

2
Precautions on Script Programming

ƽ Ladder program equivalent to OR connection


Logic OR connection shall be made via other R1000
devices (MR3000 as shown on the right side).
Execution conditon
MR3000
TMR (MR1000 AND R2000 = OFF, T100, 300)
Execution conditon
MR3000 MR1100

Execution conditon

Precautions When Using Script Programming Operation Formula

In the script, all operation formulas are handled as .L (signed 32-bit), .F (single precision floating point
type) or .DF (double precision floating point type).

• When all types (U,.D,.S) other than .F and .L and .DF are specified by arithmetic element (device or
constant) in operation formula, it will be still processed as .L. Operation result shall be also calculated
according to .L .
• If .F is used by arithmetic element (device and constant) in operation formula, all operations before .F will
be conducted as .L, all operations and operation result after this will be processed as .F (single precision
floating point type).
• If .DF is used by arithmetic element (device and constant) in operation formula, all operations before .DF
will be conducted as .L or .F, all operations and operation result after this will be processed as .DF (double
precision floating point type).

Note
• Operation formula shall be processed within the range of .L (signed 32-bit ) (-
2147483648 to +2147483647). Care shall be taken during calculation exceeds the .L
range.
• The operation formula expands all arithmetic elements to .L operation, and operational
precision will be impaired sometimes when .D (unsigned 32-bit ) contained in the
operation formula.
"Type conversion leads to data loss", Page 2-41
• When imparing precision, "Warning" display can be set.
"Setting method of warning level", Page 2-41

2-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-6 Script Conversion Output Message

PROGRAMMING SCRIPT
Script program is converted to ladder program, then transferred to CPU unit.
This section describes warning message and error message displayed during script conversion to
ladder program.

Warning Message

The message displayed when expected operation result cannot be obtained after execution of Ladder
program converted from script program. The warning reason shall be removed as possible.
2

Script Conversion Output Message


It will occur when the result type of assignment statement on the right side is different from the left type,
or the operation formula includes .D.

Ƶ Type conversion leads to data loss


The required data may be not obtained if data loss in the following script.

Programming script DM1000.U = EM2000.S * 10000

• For example, when EM2000 value is "-1", as DM1000 type is suffix 16-bit , correct calculation result
cannot be stored. In addition, when EM2000 value is "10", operation result will exceed suffix 16-bit
range (0 to 65535), so, the expected correct operation result cannot be applied.

After conversion of above script, output window displays following messages (when setting script
warning level to "high").

[Warning 1130]: "=": (signed 32-bit integer type -> suffix 16-bit integer type) ata may be lost due to
assignment.

In this case, by changing suffix of the left device from .U to .L (i.e. left type and right type are
conformable), warning message will be no longer displayed.
"2-5 Precautions on Script Programming", Page 2-40

Script warning level setting

The "Warning" level is displayed in output window when changing script conversion.

Ƶ About warning level


Two levels available: "Error" and "Warning".

ƽ Setting method of warning level

1 From the menu, select "Script (S)" -> "Set script warning level (W)".

Other procedure Select "Tool(T)"->"Option(O)" from the menu, and then select "High", "Medium" or "None" in
"Warning level" of "Script" tab.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-41


2-6 Script Conversion Output Message
PROGRAMMING SCRIPT

2 "Script warning level setting" dialog box appears. You can select the warning level.

2
Script Conversion Output Message

Item Note
All warning information can be displayed including errors and warnings.
Example 1) when the precision of operation formula is impaired
High gDM1000.U = DM2000.L (Assign .L type data to .U type device)
Example 2) Assign data other than signed 16-bit data to index
gDM1000.U:DM2000.L = 10 (Index modification via .L device)
Only error is displayed (for example, when processing out-of-range constants).
Example) When the operation both two constants exceeds the range of constants.
Medium
g DM1000.D= 90000 * 50000
(Assign a value out of constants range (4500000000))
None No alarm will be displayed.
Not output warning After the checkbox is selected, the warning that occurs when specifying a suffix
when different suffix different from the data type defined when registering global label is not output.
specified forglobal Example) When specifying global label toĀ1-word signed integer: UINTāand suffix .L
label data type is specified via script

Error Message

Error will occur when part of scrip programs can not be converted ladder program and error causes will
be displayed in output window.
Errors must be removed. Otherwise, programs cannot be transferred into CPU unit even if conversion
successes. You can correct scripts according to error messages displayed in the window that pops up.

Ƶ Error message when script conversion


Maybe due to the following reasons.

ƽ Typing error
• Function name error.
Example) correct -> BLD ( DM1000, 10 ) error -> BLF ( DM1000, 10 )
• Device name error.
Example) correct -> DM1000.D error -> DN1000.D
• 2-byte character (Only comments and character constants can use 2-byte characters)
Example)correct -> DM1000.D error -> DM1000.D
• 0(zero) and O (letter) are confused.
etc.

2-42 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-6 Script Conversion Output Message

PROGRAMMING SCRIPT
ƽ Syntax error
• The control statement format is wrong.
Example) correct -> IF R1000 THEN error -> IF R1000 THEN
DM1000 += 1 DM1000 += 1
END IF END
• BREAK is programmed outside the loop control statement.
• DO is not paired with UNTIL. 2
• Other general syntax error.

Script Conversion Output Message


ƽ Function argument error
• Argument error.
Example) correct -> FIND (DM1000.T, DM1200.T) error -> FIND(DM1000.T, DM1200.T, 8 )
• The macro that is executing calling instruction is not programmed.
etc.

ƽ Specify invalid type


• String constants is assigned to the device for processing numerical values and bits.
Example) correct -> DM1000.T = "ABCD"error -> DM1000 = "ABCD"
• Word devices and bit device must be specified with arguments specified by text string.
• Numerical constants is assigned to bit device.
• Other invalid type is specified.
• The size of the type specified in local label is larger than the data format when registering.
• A .DF type was specified when using KV-1000.

ƽ Others
• Nonexistent device is specificed.
• There are more than 1024 (half-width) characters in a script rung.
• Array label end code is specified in the label that has not been registered to array.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-43


2-6 Script Conversion Output Message
PROGRAMMING SCRIPT

When conversion error occurs

Script conversion error will occur and a dialog box will appear in case of typing error of function name,
invalid type (suffix) specified, wrong use of control statements, incorrect script programming.

2
Script Conversion Output Message

When a conversion error occurs, the error position and contents will be displayed in the window that
pops up.

Ƶ Error display in output window


The following error contents will be displayed when script conversion error occurs: :

Module name Message


Row No. Error signal Error (alarm) description

In case of "Error" : Script program cannot be converted to ladder program.


Programs cannot be transferred to PLC under this status.
In case of "Warning" : Script program can be converted to ladder program. Program can be
transferred to PLC and executed by Simulator.But the expected operation
result cannot be obtained after executing programs.

2-44 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-6 Script Conversion Output Message

PROGRAMMING SCRIPT
Ƶ How to use output window
Error (warning) contents will be displayed in output window when conversion error occurs.
Double-click the highlighted rung and the cursor moves to the error rung in Ladder Edit window.
To correct error according to error contents.

1 To convert the edited scripts.


Select "Script(S)" -> "Convert selected script(S)" from the menu.
2
Other procedure key+ key

Script Conversion Output Message


Select "Edit script(X)" -> "Convert selected script(S)" from the right-click menu.

When a conversion error occurs, the following dialog box will appear and
error information will be displayed in the window that pops up.

Click "OK" key

2 Double-click the error contents (1) displayed in the window.


The cursor moves to the rung (2) with programming error and script is turned to editable status.

(2)

(1)

3 To correct error programming.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-45


2-6 Script Conversion Output Message
PROGRAMMING SCRIPT

4 After correcting, only the corrected scripts are converted.


From the menu, select "Script (S)" -> "Convert selected script(S)".

Other procedure key+ key


From the right-click menu, select "Edit script(X)" -> "Convert selected script(S)"

No error displayed in output window indicates that script correction is completed.


2
TIP gIn the case of many errors and warnings, other errors will be still displayed when selecting
Script Conversion Output Message

"Convert all scripts(C)" even if one error is corrected.


Many warnings Only an error is corrected Many warnings

"Convert all scripts(C)"

In this case, select ĀConvert selected script(S)ā from the menu.


Many warnings Only an error is corrected

"Convert selected script(S)"

Since only the corrected scripts are converted, the correction verification will be simpler.
gBy using converted ladder show/hide (Ctrl+G), a converted ladder can be displayed and
confirmed or a developed ladder can be closed even while editing the script.

2-46 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-7 Macro

PROGRAMMING SCRIPT
Ladder program section in project that is used for many times repeatedly, registered with any
designated name, is called "macro".
Registered macro can be called from script program, and the macro can be also made using script.

Macro Call

2
Ƶ Calling subroutine macro

Macro
The macro that is registered as subroutine type can call MCALL function.
"MCALL function", Page 6-6

ƽ How to use
Programming Script MCALL(MR1000,"Macro A", DM1000, #50, MR2000)

Ladder Programming

MR1000 MCALL Macro A


DM1000 #50 MR2000
Execution
condition

Ƶ Calling self-hold type macro


The macro that is registered as self-hold type can call MSTRT function. In this case, the called macro
must have MEND instructions (functions).
"MSTRT function", Page 6-7
"MEND function", Page 6-8

ƽ How to use
Programming script MSTRT(MR1000, "MacroA", DM1000, #50, MR2000)

Ladder Programming

MR1000 MSTRT Macro A


DM1000 #50 MR2000
Execution
condition

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-47


2-7 Macro
PROGRAMMING SCRIPT

Programming Macro by Using Script

Newly make macro can be used with scripts by programming with ladder or scripts with script.

1 For the menu, select "Modules/macro (M)" -> "New macro (M)".

Other procedure gClick the icon.


2 gFrom right-click menu, select "Edit macro (M)" -> "New macro (N)"

2 Specify macro name and macro type.


Macro

Specify macro name with 12


characters (half-width) or less.

Select macro type.

Note
If macro name contains "+" / "-", "The bit under macro execution status" cannot be
programmed in script (The script identifies "+ /-" to operators).
For details of "The bit under macro execution status", see "KV-5500/5000/3000 series
User's Manual".

TIP g Some characters cannot be used in macro name.


g Macro type can also be changed after making a macro.
g When assigning local device manually, the checkbox shall be OFF.

3 Set macro argument.


Set the argument used by the macro to be registered from "Macro argument settings" dialog box.

4 Program the new macro.


To add the new macro in Workspace. Macro can be programmed by ladder, scripts or the combination
of adder and scripst.

TIP For detailed information on unit device contained in script program and the setting of macro
argument device, please see "KV-5500/5000/3000 Programming Manual", Page 3-9.

Note
The script has no functions equivalent to END instruction and ENDH instruction and shall
use ladder programming END and ENDH instructions.

2-48 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-8 Script Debug Function

PROGRAMMING SCRIPT
Monitor Function

Monitor function allows to debug script program under online state or during starting simulator.

Ƶ Register monitor
The current value of every device programmed in script can be monitored. 2

Script Debug Function


1 When KV STUDIO is in Monitor status or Simulator status, click the script to be monitored,
select "Registration monitor window" from the right-click menu.

By registering all device programmed in script to


“Register Monitor” window, current value and bit
status can be monitored, as well as setting value,
comments and time chart.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-49


2-8 Script Debug Function
PROGRAMMING SCRIPT

Ƶ Watch window
From monitor window, current value and bit status of all devices in script can be monitored by only
selecting script, without the steps such as device registration, etc. But the current value can be only
displayed.

1 When KV STUDIO is in Monitor or Simulator status, click the script to be monitored, select
2 "Watch window " from the right-click menu.
Script Debug Function

Other procedure

If programming other scripts, the device displayed in Monitor Window will be automatically switched.

Ƶ Monitoring with tool tip


When KV STUDIO is in the Monitor or Simulator status, if the mouse cursor is moved to the device to
be monitored, the current value and device comment will appear at the tool tip.

2-50 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
About Input Auxiliary Function

KV STUDIO provides various convenient functions and input auxiliary functions for Script Programming.

Script Function List


2
If function name is unknown, optional function can be called as follows after inputting function in

Input Auxiliary Function and Other Info


midway.

ƽ Call function list


From the menu, select "Script (S)" -> "Script function list (F)".

Select the function to be used and press key or double click, insert the selected function to the
cursor position in Script Editor, and the script function format prompt is displayed.

Other procedure g key+ key


g From the right-click menu, select "Script function list (F)"

TIP gOptional script function can be also called when any content not input. In this case, all
optional functions are displayed in alphabetic sequence.
g In this case, all optional functions are displayed in alphabetic sequence.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-51


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

Script Function Format Hints

When inputting function, "Script function format hints" can simply inform messages such as argument
and return value, etc.

Script function format hints

2
Input Auxiliary Function and Other Info

After inputting "Function name", the "Script function format hints" will be automatically displayed.

Return Function Number of arguments


value name (in this case, 2)

Function Execution Number of argument


name conditon* (in this case, 3)
* Arguments in [ ] can be omitted.

ƽ Call script function format hints


Place mouse cursor "I" to the right side of "(", and select "Script (S)" -> "Script function hints (H)".

Other procedure key+ key+ key

TIP "Script function format hints (H)" can be also called during script programming.

Note
When calling script function format hints, the cursor must be placed to the right side of "(" or
start position of function. When the cursor is at other positions, the script function format
hints cannot be called.

2-52 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
Reserved word

The word (reserved word) such as control statement and function, etc. registered to KV script will be
blue during programming. If character color is not changed, it indicates an input error.

TIP The character color of reserved word can be changed via the "option setting" dialog box of
KV STUDIO.
2

Input Auxiliary Function and Other Info


The color of reserved words such as
IFONTHENEND IF are all blue.

No change for its color even if "END" is input.


But its color becomes blue after inputting "END IF".

HELP Function

For details of function format and how to use, please see "Script function help".

Ƶ Start script function help

1 From the menu, select "Help (H)" -> "Script Function Help (L)".
"Script function help" directory appears.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-53


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

2 Select the function that you want to inquire.


To display detailed function descriptions.

2
Input Auxiliary Function and Other Info

Ƶ Display help of the specified function on Script Edit Screen

1 Move the cursor to the function that you want to inquire.

The cursor position as follows, shall be before and after or in middle of function, or a part of function is
within the selected range.

2-54 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
2 Click button.

Input Auxiliary Function and Other Info


Other procedure To select function, press key.

Display the help screen of the selected function.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-55


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

About Comments Function

KV script can program the content from single quote( ' ) (or "REM ") to line feed (carriage return entry)
at any position of script program as comment. Comment programming can improve efficiency of debug
and program modification. It is recommended that comment shall be programed together with script.

2 ƽ Comment writing method


Whole rung comment can be made on right side of statement (operation formula).
Input Auxiliary Function and Other Info

Whole rung comment faciliates to


understand program.
Comment rung also
needs line feed.

Note, contents at the right of quote are


allcomment. In this case, the contents
with underline are all comments.
Ladder extension

Comment can be reflected


after conversion.

TIP g Even increase of comment line will not influence program size and scanning time.
g The number of characters entered on a single rung is up to 1024 characters (half-
width)including scripts and comments.

2-56 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
Write Easy-reading Script

When programming scripts, understandable programming method enables improving debug efficiency.
Similar to ladder program, script programs finished shall be easy-to-understand in modification,
maintenance and reuse. So, the written script shall be understandale and clear.
So, it can be effectively used without programmer.

ƽ Sample Program 2

Input Auxiliary Function and Other Info


Abstruse program

IF CR2008 OR LDP(R5200) THEN


EM2200=0
EM2201=10
Z01=0
END IF
IF EM2200>=10 THEN
FIFOR(EM2200,DM1002:Z01)
Z01+=1
END IF
IF LDP(R1700) THEN
FIFOW(DM1000,EM2200)
DM3033=AVG(EM2202,EM2200)
END IF

Intelligible program
Calculate 10 average values of data.
IF CR2008 or LDP (r5200) THEN ' R5200 = FIFO table initialization trigger
EM2200 = 0 ' number of data stored in current FIFO table
EM2201 = 10 ' maximal number of FIFO table
Z01 = 0 ' index initialization
END IF

IF EM2200 > = 10 THEN ' when FIFO table is full


FIFOR (EM2200, dm1002:z01 ) ' delete the earliest data from table
Z01 + = 1 ' address of storing device
END IF

IF LDP(R1700) THEN ' R1700 check end trigger


FIFOW (DM1000, EM2200) ' the latest data (DM1000 ) is writen into FIFO table
DM3033 = AVG ( EM2202, EM2200) ' DM3033 =average value of the latest data (10)
END IF

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-57


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

Tips for programming


• Use Indent.
• Add Space before and after operators.
• Add line feed (blank line).
• Add line comment and sentence end comment.

2 TIP gAutomatic indent function is available.


Select "Tool (T)" -> "Option (O)" from the menu, set automatic indentation of "Script" tab to
Input Auxiliary Function and Other Info

ON.
g If the line of script is long, a new line can be started by adding an underbar (_) to the end.

2-58 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
Inline Mnemonics

Mnemonics is a language to enable operation of the created program on CPU unit.


The program made with KV script and expansion ladder, will be converted to mnemonics when
transferring to CPU unit.
For detail of operation diagram, see "KV-5500/5000/3000 series User's Manual".
2
With inline mnemonics, mnemonics can be programmed directly in script program, i.e. mnemonics

Input Auxiliary Function and Other Info


language can be mixed with script language.
Plus "!! " attached at the start of mnemonics is used to discriminate from script.

Programming script
IF R1000 = ON THEN
DM1000 = DM1000 + 3
BSET(MR1015 = OFF, DM2000, 10)
ELSE
!!LD R01000 Inline mnemonics

!!OR R04000
!!ANB MR1000
!!OUT R04000
END IF

Ladder Programming

Inline mnemonics ladder

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-59


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

Precautions on Edit Screen and Customization

Ƶ Precautions when programming script


• Script program cannot use 2-byte (Chinese characters) code (but, comment part and text string
constant, global label/local label can use Chinese characters).

2 • The number of characters input on one rung is within 1024 characters (half-width), including scripts
and comments.
Input Auxiliary Function and Other Info

• Ladder of KV script extended cannot be directly edited.

Ƶ Customizing script window


From the menu, select "Tool (T)" -> "Option (O)" -> "Script setting" to customize edit window.
For details, see KV STUDIO User's Manual.

2-60 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
About Script Work Memory (Work Devices)

When converting the script program to Ladder, work memories can be used for CPU unit KV-5500/
5000/3000, work memory and work devices for CPU unit KV-1000.

Work memory (work device)


2
Work memory (work device) refers to the device for temporarily storing partial operation result such as

Input Auxiliary Function and Other Info


complicated operation formula.
In script program, during script conversion, KV STUDIO can allocate work devices from the pre-
determined area automatically, so, reuse of devices doesn't occur during use.

Programming script DM1000.L = DM2000 * (DM3000 - 50)


Ladder Programming

Work memory*

* When CPU unit is KV-1000, work devices such as EM64536 can be used.
Operation description The result obtained by carrying out [DM3000-50] operation is stored in work memory
(@VM0) temporally, and then multiplied with DM2000, the final result is stored in left
DM1000.L.

Ƶ Application area of work memories


When CPU is KV-5500/5000/3000, the script uses work memories.

Work memories used for scripts can be checked via "workspace setting" dialog box.
"KV STUDIO User's Manual"

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-61


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

Ƶ Application area of work devices


When CPU unit is KV-1000, the script uses work devices.
Work devices take the pre-determined area as "bit workspace", "word workspace" and "text string
workspace". According to program content, quantity of work devices will be inadequate sometimes.

ƽ When work devices are insufficient


2 When work devices are insufficient, the following message will be displayed in output window during
conversion of ladder program.
Input Auxiliary Function and Other Info

In the status, the program cannot be transfered to PLC, so the area of work devices shall be enlarged
as follows.

1 From the menu, select "Convert (A)" -> "SET entire assignments of local devices (A)", and "CPU
system setting" dialog box will appear.

Other procedureg Double click "CPU system setting" in workspace.


gDouble click error message in popping up window
g Click button.

TIP Only display the items of "KV-1000" corresponding to the model (CPU unit).

2-62 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2-9 Input Auxiliary Function and Other Info

PROGRAMMING SCRIPT
2 Enlarge workspace.
According to error message of output window, change assignment of every workspace.

Bit workspace

Word workspace 2

Input Auxiliary Function and Other Info


String workspace

TIP Three types of work devices in workspace: "bit work device" for temporarily storing bit status,
"word working device" for temporarily storing operation result, and "text string work devices"
for temporarily storing text string.

Note
Work devices for text string can be reused for many times in a project, so, care shall be
taken when programming script using text string via interrupt program.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 2-63


2-9 Input Auxiliary Function and Other Info
PROGRAMMING SCRIPT

XYM Marking

Script program can be made via XYM marking.

Ƶ Script program via XYM mark.

2 1 From the menu, select "Tool (T)" -> "Option (O)".


"Option settings" dialog box appears.
Input Auxiliary Function and Other Info

2 Click the "Display modes setting" label.

Select “Display by XYM(X)” checkbox


and click “OK”.

3 Program with XYM marking.

TIP After selecting "Display by XYM (X)", programming can be enabled with normal Device No.
(mixable).

If the XYM marking is canceled after editing the script with XYM marking, an error will occur when the
script using X or Y is converted again. For M and L, the device number changes from a decimal to a CH
marking such as R, so note that the device number in the converted results will change.
Example) M100 = ON
The results of converting this script to a M100 ladder are:
g When using XYM marking, the script is converted to MR604.
g When not using XYM marking, the script is converted to MR100.

2-64 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3

DATA PROCESSING
DATA PROCESSING

3-1 Device and Constants•••••••••••••••••••••••••••••••••••••• 3-2


3-2 Index Modification and Indirect Specifying ••••••••••• 3-33
3-3 Data Type (suffix) ••••••••••••••••••••••••••••••••••••••••• 3-40

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-1


3-1 Device and Constants
Device refers to element (variable) used in internal relay and data memory, etc. of CPU unit, enabling to
supply data used for operation and functions and store function execution results.
DATA PROCESSING

The device varies with the models (CPU units).

Device List

Ƶ KV-5500/5000/3000 bit device


When Index Indirect
3 Device name Range *1 Number of
Main Functions
operation starts
Local
device
modifica specifying (*)*9
points (Power ON, tion
(@)*1
(:Z/:#) Lookup Store
Device and Constants

PROG -> RUN)


To acquire
R000 to R015 ON/ OFF info
Input relay - 嗟 嗟 嗟 h
(R1000 to R99915*3) from peripheral
Input/output/
equipment
Internal
To output ON/
auxiliary
R500 to R507 OFF info to
Output relay relay total Clear/hold*4 嗟 嗟 嗟 h
(R1000 to R99915*3) peripheral
15936 points
equipment
Internal R508 to R915*2 Used in CPU and
Clear/hold*4 嗟 嗟 嗟 h
auxiliary relay R1000 to R99915*3 expansion unit
Link relay B00 to B3FFF*10 16384 Clear/hold*4 h 嗟 嗟 h
Internal 16000 Only usable
MR000 to MR99915 Clear 嗟 嗟 嗟 h
auxiliary relay inside CPU
Latch relay LR000 to LR99915 16000 Hold 嗟 嗟 嗟 h
Contact device
for 10μs, 1ms,
10ms, 100ms
Timer (contact) T0 to T3999 4000 Clear 嗟 嗟 嗟 h
down counter,
10ms up/down
counter
Contact device
Counter(contact) C0 to C3999 4000 for up counter, Clear/hold*8 嗟 嗟 嗟 h
up/down counter
High-speed
Used for contact
counter
CTC0 to CTC3 4 of high-speed Clear/hold*8 h h h h
comparator
counter
(contact)
Used to control
PLC function,
Control relay CR000 to CR3915 640 Hold h h h h
acquire
equipment status

TIP Some input, output and internal auxiliary relays can be used for interrupt and high speed
counter.
“KV-5500/5000/3000 series User's Manual, "3-6 Device and Constants””

3-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Ƶ KV-5500/5000/3000 word device


When operation Index Indirect

DATA PROCESSING
Local
Number of starts modific specifying (*)*9
Device name Range*1 Main Functions device
points (Power ON, ation
(@)*1
PROG->RUN) (:Z/:#) Lookup Store
Data Memory DM0 to DM65534 65535 Clear/hold*4 嗟 嗟 嗟 嗟
Extended data
EM0 to EM65534 65535 Clear/hold*4 嗟 嗟 嗟 嗟
memory
Used for
Consecutive numbering:
131072 numerical data h 嗟 嗟 嗟
ZF0 to ZF131071
(16-bit)
File register
Bank memory:
FM0 to FM32767
(32768x4bank)
Hold
嗟 *12 嗟 嗟 嗟
3
W0 to W3FFF*10 Clear/hold*4

Device and Constants


Link register 16384 h 嗟 嗟 嗟
Used for storing
Temporary numerical data,
TM0 to TM511 512 Clear 嗟 嗟 嗟 嗟
memory simple indirect
specifying (16 bit)
Current/setting value
Timer (Current for 10μs, 1ms, Current value :
value/setting T0 to T3999 4000 10ms, 100ms down clear*6 嗟 嗟 嗟 h
value) counter, 10ms up/ Setting: hold
down counter (32-bit)
Current/setting
Counter
value of up
(Current value/ C0 to C3999 4000 Clear/hold*8 嗟 嗟 嗟 h
counter/reversible
setting value)
counters (32 bit)
High-speed High-speed
counter CTH0 to CTH1 2 counter current Clear/hold*8 h h h h
(current value) value (32 bit)
High-speed
high-speed
counter
CTC0 to CTC3 4 counter setting Clear/hold*4 h h h h
comparator
value (32 bit)
(setting value)
Used in index
Index register Z1 to Z12*7 12 Clear h h h h
modification (32 bit) *11
Used to control PLC
function, acquire
Control memory CM0 to CM5999 6000 Hold h h h h
equipment status (16
bit)
*1 Used as local device, so, the applicable range of global device is limited by the number of of local devices reserved.
"KV-5500/5000/3000 series User's Manual, "3-10 Local Device""
*2 R100 to R415, R508 to R915 are reserved for the system and cann't be used.
*3 R1000 to R99915 can be set to expansion I/O relays via Unit Editor.
*4 Power OFF hold functiion in CPU system setting enables set clear/hold.
*5 "List of Control Relays/Control Memories", Page A-2
*6 Up/down timer (UDT) keeps current value.
*7 Z11/Z12 are reserved by system and cannot be used.
*8 Power OFF hold functiion in CPU system setting enables set clear/hold. (only for contact, current value)
*9 "Store" is the device that may be described as "*(device) ". "Lookup" is the device that can perform indirect specifying.
"Indirect Specifying", Page 3-35
*10 Device No. is specified in HEX number.
*11 The range of value that can be processed by index register is "-131072 to +131071".
*12 The local device cannot be used for bank switching.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-3


3-1 Device and Constants

Ƶ KV-1000 bit device


When Index Indirect
DATA PROCESSING

Local
Number of operation starts modific specifying (*)*10
Device name Range*1 Main Functions device
points (Power ON, ation
(@)*1 Lookup Store
PROG->RUN) (:Z/:#)
Used to acquire
ON/ OFF
R000 to R015
Input relay message from q 嗟 嗟 嗟 h
(R1000 to R59915*3)
Input/output/ peripheral
Internal equipment
3 auxiliary Used to output
R500 to R507 relay total ON/ OFF info to
Output relay clear*4 嗟 嗟 嗟 h
(R1000 to R59915*3)
Device and Constants

9536 points peripheral


equipment
R508 to R915*2 Used in CPU and
Internal clear*4 嗟 嗟 嗟 h
R1000 to R59915*3 expansion unit
auxiliary relay
MR000 to MR99915*4 16000 clear 嗟 嗟 嗟 h
Internal Only usable
auxiliary relay LR000 to LR99915 16000 inside CPU hold 嗟 嗟 嗟 h
(latch relay)
Contact device
for 1ms, 10ms,
Timer (contact) T0 to T3999 100ms down Clear 嗟 嗟 嗟 h
Timer/
counter/10ms
Counter
up/down counter
contact
Contact device for
Counter total 4000
C0 to C3999 up counter,up/ hold*9 嗟 嗟 嗟 h
(contact)
down counter
High-speed
Used for contact
counter
CTC0 to CTC3 4 of high-speed hold*9 h h h h
comparator
counter
(contact)
Used to control
* PLC function or
Control relay 6 CR000 to CR3915 640 - h h h h
acquire
equipment status

TIP Some input, output and internal auxiliary relays can be assigned for interrupt and high speed
counter.
KV-1000 User's Manual, Chapter 4 “Interrupt"
KV-1000 User's Manual, Chapter 5 “High-speed Counter"

3-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Ƶ KV-1000 word device


When Index Indirect

DATA PROCESSING
Local
Number of operation starts modific specifying (*)*10
Device name Range*1 Main Functions device
points (Power ON, ation
(@)*1 Lookup Sore
PROG->RUN) (:Z/:#)
Data Memory DM0 to DM65534 65535 Device for storing Hold *4 嗟 嗟 嗟 嗟
*
Extended EM0 to EM65534 5 65535 numerical data Hold *4 嗟 嗟 嗟 嗟
data memory FM0 to FM32766*5 32767 (16-bit) Hold *4 嗟 嗟 嗟 嗟
Device for storing
numerical data,
Temporary
TM0 to TM511 512 points
simple indirect
Clear
3
嗟 嗟 嗟 嗟
data memory specifying and

Device and Constants


arithmetic operation
(16 bit)
current/setting
value for 1ms, Current value :
Timer (Current
10ms, 100ms clear*7
value/setting T0 to T3999 嗟 嗟 嗟 h
Timer/ down counter, Setting value :
value)
Counter 10ms up/down hold
contact counter (32-bit)
Counter total 4000 Up counter, up/down
(Current value/ C0 to C3999 hold*9 嗟 嗟 嗟 h
counter (32 bit)
setting value)
High-speed current value (32-
counter CTH0 to CTH1 2 bit) of high-speed hold*9 h h h h
(current value) counter
High-speed
Setting value (32-
counter
CTC0 to CTC3 4 bit) for high-speed Hold h h h h
comparator
counter
(setting value)
Index Used in index
Z1 to Z12*8 12 Clear h h h h
register modification (16-bit)
Used to control
Control PLC function,
CM0 to CM11998 11999 - h h h h
memory*6 acquire equipment
status (16-bit)
*1 Global device range is limited to the number reserved for local device.
"KV-1000 Programming Manual", "4-2, Range and Setting of Local Devices"
*2 R100 to R415 are reserved for system and cannot be used.
*3 R1000 to R59915 can be set to expansion I/O relays via Unit Editor.
*4 MEMSW instruction allows to set clear/holding.
*5 According to assignment setting of work devices used in script, some areas are reserved for system.
*6 "List of Control Relays/Control Memories", Page A-2
*7 Up/down timer (UDT) to keep current value.
*8 Z11/Z12 are reserved for system and cannot be used.
*9 MEMSW instruction allows to set hold/clear. (only for contact, current value)
*10 "Store" is the device that may be described as " *(device)". "Lookup" is the device that can perform
indirect specifying.
"Indirect Specifying", Page 3-35

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-5


3-1 Device and Constants

ƽ Device specifying mode


Symbols Main Function Program example
DATA PROCESSING

@ Local device specifying @DM0, @MR1200


: Index modification DM0: Z1, DM0: 3
* Indirect specifying *DM0

ƽ Device specifying

3 With KV script, data type and range that can be processed by the device, can be represented by adding
suffixto the device.
Device and Constants

Type Suffix Data range/type Program example


Unsigned
.U 0 to 65535 Example) DM1000.U*1, MR1000.U
16-bit
Signed 16- bit .S -32768 to +32767 Example) DM1000.S, MR1000.S
Unsigned
.D 0 to 4294967295 Example) DM1000.D, MR1000.D
32-bit
Signed 32- bit .L -2147483648 to +2147483647 Example) DM1000.L, MR1000.L
Single
precision -3.4E+38dNd1.4E-45
floating .F N=0 Example) DM1000.F, MR1000.F
point type 1.4E-45dNd3.4E+38
(32-bit)
Double
precision -1.79E+308dNd-2.23E-308
floating .DF N=0 Example) DM1000.DF, MR1000.DF
point type 2.23E-308dNd1.79E+308
(64-bit)
Text string
.T string with up to 1999 characters Example) DM1000.T, MR1000.T
type data
ON (1, TRUE)
Bit type data .B Example) MR1000.B*1, DM1000.B
OFF (0, FALSE)

*1 During programming, the suffixof the data can be also omitted.


For suffix, see "3-3 Data Type (suffix)", Page 3-40.

3-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Ƶ Constant
Constant Scope Main Functions

DATA PROCESSING
Used to specify DEC constant. ("#"
(#)0 to (#)65535(Unsigned 16-bit) can be omitted. )
(#)-32768 to (#)+32767 (Signed 16-bit) TIP Displayed as "K" when
DEC (#)
(#)0 to (#)4294967295 (Unsigned 32-bit) using the XYM display
(#)-2147483648 to (#)+2147483647 (Signed 32-bit) mode. (K can be
omitted.)
(#)-3.4E38dNd(#)-1.4E-45
Single precision Used to specify single precision
floating point type
N=(#)0
floating point type constant. ("#"
3
(#)+1.4E-45dNd(#)+3.4E38
real number can be omitted.)

Device and Constants


(Significant digits : 7 bits)
(#)-1.79E+308dNd(#)-2.23E-308
Double precision Used to specify double precision
ǂ N=(#)0
floating point type floating point type constant. ("#"
(#)+2.23E-308dNd(#)+1.79E+308
real number can be omitted.)
(Number of effective digits: approx. 16 digits)
Used to specify HEX constants.
$0 to $FFFF (16 bits) TIP Displayed as "H" when
HEX ( $)
$0 to $FFFFFFFF (32 bits) using the XYM display
mode.
Fixed text string
Example) "Model ABC","Month/08:30:15" Used to fixed text string
("")

ƽ Device specifying
With KV script, the constant range can be determined by adding suffixto the DEC constant.
Type Suffix Data range Program example
Constant
Unsigned 16-bit 0 to 65535 910U, 505U
U
Constant
Signed 16-bit -32768 to +32767 23S, -600S
S
Constant
Unsigned 32-bit 0 to 4294967295 1234567D, 5D
D
Constant
Signed 32-bit -2147483648 to +2147483647 123L, -89335963L
L
32-bit single -3.4E+38dNd-1.4E-45
Constant 100F, -3.4E38F,
precision floating N=0
F 0.12F
point type +1.4E-45dNd+3.4E+38
64-bit double -1.79E+308dNd-2.23E-308
Constant 100DF, -1.7E123DF,
precision floating N=0
DF 0.0256DF
point type +2.23E-308dNd+1.79E+308

ƽ Device specifying
The type of HEX constant processed by KV script depends on the number of digits. (for HEX constant,
suffix cannot be programed).
4 digits or less gg
gunsigned 16-bit (.U)
5 digits or more gggunsigned 32-bit (.D)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-7


3-1 Device and Constants

Bit Device
DATA PROCESSING

Ƶ status bit
In KV-5500/5000/3000/1000, the status of the bit device is described in the following representation
method.
Bit status Denotation Program example
ON (TRUE) ON, 1, TRUE MR1000=ON, MR1001=1, MR1002=TRUE
OFF (FALSE) OFF, 0, FALSE MR2000=OFF, MR2001=0, MR2002=FALSE
3
TIP These 2 status called "Boolean value".
Device and Constants

I/O relay R

Overview Input relay is the device that acquires ON/OFF information from peripheral equipment into
PLC.
Output relay is the device that sends ON/OFF instruction or arithmetic operation result from
PLC to PLC peripheral equipment.

Denotation Device No. composition as follows.


Example) Channel No. (000 to 999*1) Contact No. (00 to 15)

R00012
Device name Device No. (00000 to 99915*2 )

*1 When CPU unit is KV-1000, the range is "000 to 599"


*2 When CPU unit is KV-1000, the range is "000 to 59915"

TIP gZero-suppression input possible when programming.


Example) R12
g Suffix can be added when programming
Example) R12.B
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
g Processed as word device.
Example) R2000.U (16 bits occupied from R2000)
gWhen CPU unit is KV-5500/5000/3000, if adding "D" to the device name, it will operate as
direct I/O relay.
Example) DR500 (R500 operates as direct output relay)
"Direct I/O Relay", Page 3-29

Scope gR000 to R015 (special for input)


gR500 to R507 (special for output )
gR1000 to R99915 * (can be assigned as the expansion input unit)
* When CPU unit is KV-1000, the range is “R1000 to R59915"

3-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Application Input Relay


gUsed peripheral equipment connected, including button and switch (for example Selector

DATA PROCESSING
Switch, limit switch, photoelectric switch, digital switch), etc.
gInput relay can be used as high speed inputs such as interrupt, high speed counter,
positioning function etc. (R000 to R015)
Output Relay
gUsed the peripheral equipment connected, including solenoid valve, electromagnetic
switch, display (signal indicator, numerical indicator), etc.
gOutput relay can be used as high speed output of high speed counter and positioning
function, etc. (only for R500 to R503) 3

Device and Constants


Note Input Relay
g Assign 1 bit to every input for input relay.
g Assign 1 bit to every output for output relay.
g NO or NC contact can be specified.
g In the same project, the input relay with same Device No. can be programed for many
times.
g R100 to R415 are reserved for system and can be used.
g R508 to R915 are reserved for system and can be used.

Default Default setting of output relay: shutoff and cleared when powering ON and when PPROG
-> RUN.
g When CPU unit is KV-5500/5000/3000, power off hold function in CPU system setting
allows to set up holding status.
g When CPU unit is KV-1000, MEMSW instruction allows to set up holding status.

TIP g About representation method of relay (R) unit device


In KV STUDIO , except general representation method, the relay can also be represented
according to Unit No.. If representing with devices usd for unit, you can select "View (V)" ->
"Display devices for unit (Y)" from the menu.

Unit No. Unit relay No.


Input allows zero
suppression when
R05_00010 programming.
(Example) R5_10
Channel No. Contact No.

Unit No. : Starting from CPU, according to the unit connection sequence, assign
00, 01, 02, 03, 04 , and the like.
Unit relay No. : Number of relay points occupied from 00000 are assigned to relay
No.

Unit No. 00 01 02 03 04 05
KV-B16XA KV-C32XA KV-B16TA KV-C32TA KV-H20
KV-U7 CPU
10CH
unit 16-input 32-input 16-input 32-input occupied
Unit R0000 to R00015 (input)
relay No. R00500 to R00507 (output) 00000 to 00015 00000 to 00115 00000 to 00015 00000 to 00115 00000 to 00915

* KV-3000/1000 (CPU unit) hardware element cannot be used to represent the unit device.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-9


3-1 Device and Constants

Link relay B
DATA PROCESSING

Overview When CPU unit is KV-5500/5000/3000, it can be used.


It is used as link relay when connecting via FL-net, etc. Different from other relays, device
No. is specified in HEX.

Denotation Device No. composition as follows.


Example) Channel No. (000 to 3FF) Contact No. (0 to F)

3 B1EE7
Device name Device No. (0000 to 3FFF)
Device and Constants

TIP : Input allows zero suppression when programming.


Example) B7A
: Suffix can be added when programming
Example) B7A. B
: When suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
: Processed as word device.
Example) B80.U (16 bits occupied starting from B80,)

Note
• Please use HEX number (0 to F) to specify.
• Local device (@) cannot be used.

Range B0000 to B3FFF

Application It is used as link relay when connecting via FL-net, etc.

Note : These relays cannot be assigned as the unit device of expansion unit.
: In the same project, the link relay with same Device No. can be programmed for many
times.

Default Default setting of link relay: shutoff and cleared when powering ON and when PPROG ->
RUN. Power off hold in CPU system setting allows to set up holding status.

3-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Internal auxiliary relay R/B/MR/LR

DATA PROCESSING
ƵR
Overview R unassigned to actual I/O relay and expansion unit relay is used as internal auxiliary relay.

Denotation Device No. composition as follows.


Example)
Channel No. (000 to 999*1) Contact No. (00 to 15)

R00012
Device name Device No. (00000 to 99915*2 )
3

Device and Constants


*1 When CPU unit is KV-1000, the range is "000 to 599"
*2 When CPU unit is KV-1000, the range is "000 to 59915"

TIP gInput allows zero suppression when programming.


Example) R12
gSuffix can be added when programming.
Example) R12.B
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
gProcessed as word device.
Example) R2000.U (16 bits occupied starting from R2000)

Rage g R1000 to R99915 * (can be assigned as the expansion input unit No.)
* When CPU unit is KV-1000, the range is “R1000 to R59915".
ƵB
Overview When CPU unit is KV-5500/5000/3000, it can be used.
When FL-net is not connected, B that is not assigned to link relay can be used as internal
auxiliary relay.

Denotation Device No. composition as follows.


Example) Channel No. (000 to 3FF) Contact No. (0 to F)

B1EE7
Device name Device No. (0000 to 3FFF)

TIP g Input allows zero suppression when programming.


Example) B7A
g Suffix can be added when programming.
Example) B7A.B
g When suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
g Processed as word device.
Example) B80.U ( 16 bits occupied starting from B80)

Note
• Please use HEX (0 to F) to specify.
• Local device (@) cannot be used.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-11


3-1 Device and Constants

Range B0000 to B3FFF


DATA PROCESSING

Note gThese relays cannot be assigned as the unit device of expansion unit.
gIn the same project, the link relay with same Device No. can be programmed for many
times.

Default Under default status, when powering ON and output is off when powering ON or when
PPROG -> RUN. Power off hold function in CPU system setting allows to set up holding
status.
3 Ƶ MR
Device and Constants

Overview The device that can be used only inside CPU.

Denotation Device No. composition as follows.


Example) Channel No. (000 to 999) Contact No. (00 to 15)

MR02809
Device name Device No. (00000 to 99915)

TIP gInput allows zero suppression when programming.


Example) MR2809
gSuffix can be added when programming
Example) MR2809.B
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
gProcessed as word device.
Example) MR2000.U (16 bits occupied starting from R2000)

Scope MR00000 to MR99915

Note
Under default status, MR 50000 to MR99915 will be assigned to local device and cannot be used.
(The reserved area can be changed using "whole local assignment setting" set in CPU
system setting)

Note gThese relays cannot be assigned as the unit device of expansion unit.
gIn the same project, the MR with same Device No. can be programmed for many times.
Default When powering ON, or PROG->RUN, status will be cleared, output will be OFF.

3-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Ƶ LR (Latch relay)
Overview This device could only be used in CPU to hold status.

DATA PROCESSING
Denotation Device No. composition as follows.
Example) Channel No. (000 to 999) Contact No. (00 to 15)

LR02308
Device name Device No. (00000 to 99915)

TIP gInput allows zero suppression when programming.


Example) LR2308 3
gSuffix can be added when programming

Device and Constants


Example) LR2308.B
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.
gProcessed as word device.
Example) LR2400.U (16 bits occupied starting from R2000)

Range LR00000 to LR99915

Note gThese relays cannot be assigned as the unit device of expansion unit.
gIn one project, the latch relay with same Device No. can be programmed for many times.
Default Hold the status before the last power OFF.

Timer (contact) T

Overview Timer including contact (1 bit) and current value (32 bit). Timer is a device for turning contact
ON, when current value of down timer is equal to "0".

Denotation Device No. composition as follows.


Example) Device No. (0000 to 3999)

T0501.B
Device name Suffix

TIP gInput allows zero suppression when programming.


Example) T501.B
gSuffix can be added when programming When used as timer contact, plus suffix.B must be
attached; when processing current value of timer, suffix.D must be attached.
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is
available.

Range T0000.B to T3999.B

Note 4 timer functions available: 10μs timer, 1ms timer, 10ms timer, 100ms timer.

Default When powering ON, or PROG->RUN , status will be cleared, output will be OFF.
Current value is identical to setting value when powering ON or PR O G->RUN.
Setting value is held.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-13


3-1 Device and Constants

Ƶ How to program the timer when timer function is operated via scripts
Specifying via execution condition of timer for timer function argument (timer reset relay), timer No. and
DATA PROCESSING

setting value (time before timeup), enables programming the timer's operation.
Example)
Timer device (T0000 to T3999) Setting vale (0 to 4294967295, device No.)

TMR (R1000,T501,1000
Timer function name Timer execution conditon
(100ms down timer)

3 [Operation difference of every timer]


Timer type (function) Device No. Setting value Time before ON
Device and Constants

100ms Down Counter (TMR) n x100ms


10ms Down Counter (TMH) n x10ms
T0 to T3999 0 to 4294967295
1ms Down Counter (TMS) n x 1ms
10μs Down Counter (TMU) n x 10μs

TIP The device (unsigned 32-bit data) and formula can be specified in setting value.
“Timer function"(Page 5-22)

Ƶ Timer error
Timer error as follows:
TMR (100ms Timer) : withinf (100ms + 1 scanning time)
TMH (10ms Timer) : withinf (10ms + 1 scanning time)
TMS (1ms Timer) : within f (1ms + 1 scanning time)
TMU (10μs Timer) : within f (10μs + 1 scanning time)

Ƶ Precautions when using a timer function


When using timer function in IF statement or Box Script, if IF statement or Box Script is not executed
during timer function execution, the current value of timer will be not updated.
If time measurement is continued, and every instruction executed, the elapsed time will be reflected in
current value of timer . If reaching setting time, timer contact will be ON rapidly after execution again.
Programming Svript IF MR1000 = ON THEN
TMR (MR2000 = ON, T100, 200)
END IF
Execute condition is OFF, Do not reset even if execution
so timer function is reset conditon is OFF

Execution Processing statement of


ON
conditon of IF statement not scanned
IF statement OFF
(MR1000)
Execution ON
conditon of
Timer contact ON by timing of
timer function OFF
IF statement restart
(MR2000)
ON
Status of
timer contact
OFF
(T100)

Current
value
Since TMR function is not
scanned, the current value is
stored with “8” and not updated

Setting
value
20 20 18 16 14 20 20 18 16 14 12 10 8 ˄6˅ ˄4˅ ˄2˅ ˄0˅ 0
(When timeup) IF statement starts again

3-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Ƶ How to process setting/current value of the timer


The method of reading via script or changing setting value/current value of timer in ladder as follows.

DATA PROCESSING
How to Read How to Change
Timer device=changed value (constant,
Storage DM = timer device
Current value device)
Example) DM1000.D=T100.D
Example) T100.D˙DM2000.D
Device Setting value storage device=changed
Setting Storage DM= setting value storage device
specifying value (constant, device)
value
Constant Setting values can't be read. Setting values can't be changed.

Note
3
When correcting, if current value exceeds setting value, the current value is corrected to the

Device and Constants


value identical to the setting value.

Counter (contact) C

Overview Counter including contact (1 bit) and current value (32 bit).
Counter is a device in which contact is ON when current value is the same as setting value
(counting is finished).

Denotation Device No. composition as follows.


(Example)
Device No. (0000 to 3999)

C0551.B
Device name Suffix

TIP gInput allows zero suppression when programming.


Example) C551.B
gSuffix can be added when programming. When used as timer contact, suffix.B must be
attached; when processing current value of timer, suffix.D can be attached.
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is available.

Range C0000.B to C3999.B

Ƶ How to program the counter when counter function is operated via scripts
Specifying via execution condition (counter reset) of the counter for counter function argument, counter No.,
setting value and cout input relay enables programming the counter's operation.

Counter device No. Setting value

%06
4%/4
Counter function counter execution conditon Count input relay

When count input relay OFF->ON (differential type), the current value of counter function will be
incremented by "1"; when the current value reaches setting value, counter contact is ON.

TIP The device (unsigned 32-bit data) and formula can be specified via setting value.
“Counter function"(Page 5-30)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-15


3-1 Device and Constants

Ƶ How to process setting/current value of the counter


The method of reading via script or changing setting value/current value of counter in ladder as follows.
DATA PROCESSING

How to Read How to Change


Storage DM = timer device Timer device=changed value (constant, device)
Current value
Example) DM1000.D=C200.D Example} C200.D=DM2000.D
Device Setting value storage device=changed
Setting Storage DM= setting value storage device
specifying value (constant, device)
value
Constant Setting values can't be read. Setting values can't be changed.

3 Note
When correcting, if current value exceeds setting value, the current value is corrected to the
value identical to the setting value.
Device and Constants

High-speed counter comparator (contact) CTC

Overview High-speed counter comparer including contact (1 bit) and setting value.
High speed counter comparator is a device that turns ON when current value of high speed
counter is the same as setting value.

Note
When CTC is used as interrupt element, CTC (contact) is not ON.

Range CTC0 to CTC3

TIP gSuffix can be added when programming. When processed as contact, suffix.B must be
attached; when processing setting value, suffix.D must be attached.
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is available.

Note Interrupt program can be also executed with CTC as interrupt condition.

Default Under default status, the value is held.


g When CPU unit is KV-5500/5000/3000, poer off hold function in CPU system setting to
set clear status (non-hold).
gWhen CPU unit is KV-1000, can use MEMSW instruction allows to set clear status (non-hold).

KV-5500/5000/3000 series PLC User's Manual, "2-8 High-speed Counter"

Control relay (contact) CR

Overview Control relay is an internal auxiliary relay to control PLC function and acquire PLC status.

Range CR0000 to CR3915

TIP gSuffix can be added when programming


Example) CR2002.B
gWhen suffix is omitted, the type will be processed as .B (bit type), unless type declaration is available.

Note "List of Control Relays/Control Memories", Page A-2

3-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Word Device

DATA PROCESSING
Data memory/Extended data memory DM/EM/FM

Overview Data memory and extended data memory are used to store lookup data or 16-bit/point
operation result during function operation.
When CPU unit is KV-5500/5000/3000, FM is used as File Register.
"File register ZF/FM", Page 3-19

Denotation
3
Device No. composition as follows.

Device and Constants


Example) Device name Device No.

DM06143
TIP gInput allows zero suppression when programming.
Example) DM6143
gSuffix can be added when programming
Example) DM1000.S (signed 16 bit), DM2000.D (Unsigned 32 bit)
gWhen suffix is omitted, the type will be processed as .U (signed 16-bit), unless type
declaration is available.
gProcessed as the bit device.
Example) DM1100.B ....... the lowest bit of DM1100
gWhen CPU unit is KV-5500/5000/3000,it can be processed as the bit device whose bit
position is specified.
example) DM1200.12 ..... the 13th bit of Device of DM1200

Range gDM00000 to DM65534


gEM00000 to EM65534
gFM00000 to FM32766*
When CPU unit is KV-5500/5000/3000, the range is FM00000 to FM32767.
"File register ZF/FM", Page 3-19

Note gOnly Data Memory (DM) can be assigned as the unit device of expansion unit.

ƽWhen processing 16-bit data


gThe bit width of the device is 16 bit per point. when processing unsigned DEC number, 0 to
65535 can be processed; when processing signed DEC number, -32768 to + 32767 can be
processed; when processing HEX number, $0 to $FFFF can be processed.
gWhen processing16-bit data, suffix .U (can be omitted) or .S shall be added on Device No.
DM1
bit bit bit bit
15 8 7 0

16 bits

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-17


3-1 Device and Constants

ƽWhen processing 32-bit data


g2 devices can be used to process 32-bit data. For 32-bit data, low 16 bits will be stored in
DATA PROCESSING

Data Memory of the specified Device No., and high 16 bit will be stored in Data Memory of
the next Device No.. When processing unsigned DEC number, 0 to 4294967295 can be
processed; when processing signed DEC number, -2147483648 to + 2147483647 can
be processed; when processing HEX number, $0 to $FFFFFFFF can be processed.
gWhen processing 32-bit data, suffix .D or .L shall be added on Device No..
DM1 DM0

3
bit bit bit bit bit bit bit bit
31 24 23 16 15 8 7 0
Device and Constants

High 16 bits Low 16 bits

32 bits

Default Under default status, the value is held.


gWhen CPU unit is KV-5500/5000/3000, power off hold function in CPU system setting
to set clear status (non-holding).
gWhen CPU unit is KV-1000, MEMSW instruction allows to set clear status (non-hold).

TIP gAbout the presentation of unit device for Data Memory (DM)
In KV STUDIO , except general representation, it can also be represented according to Unit No.
When unit device representation mode is used, select "View V" -> "Display devices for unit
(Y)" from the menu.

Unit No. Device No. Input allows zero


suppression when
programming.
DM05_0010.S (example) DM5_10
Suffix

Unit No. : Starting from CPU, according to the unit connection sequence, assign
00, 01, 02, 03, 04...., and the like.
Unit DM No. : Assign the occupied Data Memory from 0000.
Suffix : When programming, Data Memory and expansion Data Memory may
have suffix. When suffix is omitted, these memorizers are processed
as unsigned 16-bit (.U ).
Example)

Unit No. 00 01 02 03 04 05

KV-U7 KV-5000 KV-AD40 KV-DA40 KV-H20 KV-H20 KV-H20


CPU 22 words 18 words 252 words 252 words 252 words

Unit DM No.
0000to0019 0000to 0021 0000to 0017 0000 to 0251 0000to 0251 0000to 0251

The 5 th of KV-AD40 .................... DM01_0004


The 53rd of KV-H20 (Unit No. 03) .................... DM03_0052
The 1st of KV-H20 (Unit No. 05) .................... DM05_0000

3-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

File register ZF/FM

DATA PROCESSING
Overview When CPU unit is KV-5500/5000/3000, it can be used.
File Register is divided into ZF processing all areas with consecutive number method and FM
dividing the area into 4 Banks and processing in Bank switching mode.
KV-5500/5000/3000 series PLC User's Manual, "3-11 File register"

Note
When CPU unit is KV-1000, only FM (FM00000 to FM32766) can be processed.
"Data memory/Extended data memory DM/EM/FM", Page 3-17
3

Device and Constants


Denotation Device No. composition as follows.
Example)
Device name Device No.

ZF0372

TIP gInput allows zero suppression when programming.


Example) ZF372
gSuffix can be added when programming
Example) ZF1000.S (signed 16-bit), FM12300.D (Unsigned 32-bit)
gWhen suffix is omitted, the type will be processed as .U (signed 16-bit), unless type
declaration is available.
gProcessed as the bit device.
Example) FM1100.B ........the lowest bit of FM1100
gWhen CPU unit is KV-5500/5000/3000, can be processed as the bit device whose bit
position is specified.
example) ZF1200.12.......the 13th bit of ZF1200

Note
• Local device for ZF (@ZFxxx) cannot be used.
• Local device for FM (@FM0 to @FM32767) cannot be bank switched.
• Local device for FM (@FM0 to @FM32767) uses work memories.

Range gZF000000 to ZF131071


gFM00000 to FM32767*
*When CPU unit is KV-1000/3000, the range is FM00000 to FM32766.
"Data memory/Extended data memory DM/EM/FM", Page 3-17

Note gThese relays cannot be assigned as the unit device of expansion unit.
gDevice types and range are different between consecutive number method and Bank
switching mode.

ƽZF: when file register is processed with consecutive number method


Process whole area of File Register as 1 device.
When CPU unit is KV-1000 , it cannot be used.
File register area

<( <(

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-19


3-1 Device and Constants

ƽFM: when File Register is processed in Bank switching mode


File Register area will be separated into 4 blocks, processing is performed by switching banks.
DATA PROCESSING

When CPU unit is KV-1000, only FM0 to FM32766 of Bank1 can be used.
File register area

ZF0 ....... ZF32767,ZF32768 ....... ZF65535,ZF65536 ....... ZF98303,ZF98304 ....... ZF131071

Storage unit 1 Storage unit 2 Storage unit 3 Storage unit 4

FM00000 ... ... FM32767 FM00000 ... ... FM32767 FM00000 ... ... FM32767 FM00000 ... ... FM32767

1 device can be used as 4 different devices via switching Bank.


But, it can be reused with ZF device, so, care must be taken during data processing.
3 For Bank switching method, please see "KV-5500/5000/3000 series User's Manual,"3-
11 File Register".
Device and Constants

ƽWhen processing 16-bit data


gThe bit width of the device is 16 bit per point, when processing unsigned DEC number, 0 to
65535 can be processed; when processing signed DEC number, -32768 to + 32767 can be
processed; when processing HEX number, $0 to $FFFF can be processed.
gWhen processing 16-bit data, suffix .U (can be omitted) or .S shall be added on Device No.
ZF2510
bit bit bit bit
15 8 7 0

16 bits

ƽ When processing 32-bit data


g2 devices can be used to process 32-bit data. For 32-bit data, low 16bits will be stored in
Data Memory of the specified Device No., and high 16 bits will be stored in Data Memory of
the next Device No.. When processing unsigned DEC number, 0 to 4294967295 can be
processed; when processing signed DEC number, -2147483648 to + 2147483647 can be
processed; when processing HEX number, $0 to $FFFFFFFF can be processed.
gWhen processing 32-bit data, suffix .D or .L shall be added on Device No..
ZF2511 ZF2510
bit bit bit bit bit bit bit bit
31 24 23 16 15 8 7 0

High 16 bits Low 16 bits

32 bits

Default Under default status, the value is held.


gWhen CPU unit is KV-5500/5000/3000, power off hold function in CPU system setting
to set clear status (non-hold).
gWhen CPU unit is KV-1000, MEMSW instruction allows to set clear status (non-hold).

3-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Link register W

DATA PROCESSING
Overview When CPU unit is KV-5500/5000/3000, it can be used.
It is used as link register when connecting via FL-net, etc. Different from other word devices,
Device No. is specified using HEX system.

Denotation Device No. composition as follows.


Example)
Device name Device No. (0 to 3FFF)

W3A6F
3

Device and Constants


TIP gInput allows zero suppression when programming.
Example) W7A
gSuffix can be added when programming
Example) W7A.S (signed 16 bit), W3E76.D (Unsigned 32-bit)
gWhen suffix is omitted, the type will be processed as .U (unsigned 16-bit), unless type
declaration is available.
gProcessed as the bit device. bit position can be also specified.
Example) the 13th bit of W1200.12W1200

Note
• Please use HEX (0 to F) to specify.
• Local device (@) cannot be used.

Range W0000 to W3FFF

Application It is used as link relay when connecting via FL-net, etc.

Note These relays cannot be assigned as the unit device of expansion unit.

ƽ When processing 16-bit data


gThe bit width of the device is 16-bit per point, when processing unsigned DEC number, 0 to
65535 can be processed; when processing signed DEC number, -32768 to + 32767 can be
processed; when processing HEX number, $0 to $FFFF can be processed.
gWhen processing 16-bit data, suffix .U(can be omitted) or .S shall be added on Device No.
W123E
bit bit bit bit
15 8 7 0

16 bits

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-21


3-1 Device and Constants

ƽ When processing 32-bit data


g2 devices can be used to process 32-bit data. For 32-bit data, low 16 bits will be stored in
DATA PROCESSING

Data Memory of the specified Device No., and high 16 bits will be stored in Data Memory of
the next Device No.. When processing unsigned DEC number, 0 to 4294967295 can be
processed; when processing signed DEC number, -2147483648 to + 2147483647 can be
processed; when processing HEX number, $0 to $FFFFFFFF can be processed.
gWhen processing of 32-bit data, suffix .D or .L shall be added on Device No..
W2BE1 W2BE0

3
bit bit bit bit bit bit bit bit
31 24 23 16 15 8 7 0
Device and Constants

High 16 bits Low 16 bits

32 bits

Default Under default status, the value is held.


Hold mode setting can be performed utilizing “Power off hold function" in CPU system
setting.

3-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Temporary data memory TM

DATA PROCESSING
Overview Temporary data memory is a 16-bit word device that can conduct same processing with Data
Memory. Some device areas are also used to temporarily store arithmetic operation data or
arithmetic operation result data.

Denotation Device No. composition as follows.


Example) Device name Device No.

TM010 3
TIP gTM000 to TM003 are used in operation instructions such as DIV, MUL in ladder, TM000 and

Device and Constants


TM001 used for processing 32-bit above data. It is recommended that these temporary data
memories are not used for other purposes.
gInput allows zero suppression when programming.
Example) TM10
gSuffix can be added when programming
Example) TM10.D (Unsigned 32-bit)
gWhen suffix is omitted, if without type declaration, process as .U (Unsigned 16-bit).

Range TM000 to TM511


TM No. Application
TM000 to TM001 64-bit data
TM002/TM003 Used to store the remainder after dividing
TM004 to TM511 Common*

* Simple indirect specifying cannot be used for script.

Default When powering ON or PROG -> RUN, temporary data memoryis cleared.

Timer (current value) T

Overview By adding suffix .D to timer device, timer device can process current value.

Range T0000.D to T3999.D

TIP When timer device processes current value, suffix.D cannot be omitted. When suffix is omitted,
if without type declaration, it is processed as .B (timer contact).

Note Current value of timer device can be changed within 0 to 4294967295.

Note
When current value changes, if current value exceeds setting value, current value will be
changed to the value identical to setting value.

"Timer (contact) T", Page 3-13

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-23


3-1 Device and Constants

Counter (current value) C


DATA PROCESSING

Overview By adding suffix.D to counter device, counter device can process current value.

Range C0000.D to C3999.D

TIP When Counter device processes current value, suffix.D cannot be omitted. When suffix is
omitted, if without type declaration, it is processed as .B (counter contact).

3 Note Current value of counter device can be changed within 0 to 4294967295.


Device and Constants

Note
When current value changes, if current value exceeds setting value, current value will be
changed to the value identical to setting value.

"Counter (contact) C", Page 3-15

High-speed counter (current value) CTH

Overview High speed counter is 32-bit counter used to collect short interval signal that cannot be
collected by counter instruction.

Range CTH0 to CTH1

TIP gSuffix can be added when programming


Example) CTH0.D
gWhen suffix is omitted, if without type declaration, process as .B (Unsigned 32-bit).

Note gA value within 0 to 4294967295 can be processed.


gIn addition to external input counting, internal clock can also be counted.
gMaximal response frequency is duty ratio 50%, 1-phase, 100KHz, phase difference 50KHz.

Default Under default status, output is off when powering ON and when status is cleared during
PPROG -> RUN.
gWhen CPU unit is KV-5500/5000/3000, power off hold function in CPU system setting
allows to set hold mode.
gWhen CPU unit is KV-1000, MEMSW instruction allows to set hold mode.

KV-5500/5000/3000 series PLC User's Manual, "2-8 High-speed Counter"

3-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

High-speed counter comparator (setting value) CTC

DATA PROCESSING
Overview By adding suffix.D to CTC, setting value of high-speed counter (32-bit) can be processed.

Range CTC0 to CTC3

TIP When high-speed counter comparer device processes setting value, suffix .D cannot be
omitted. When suffix is omitted, if without type declaration, it is processed as .B (contact).

Note gThe range should be 0 to 4294967295.


g2 setting values ( CTC ) can be set for every high-speed counter (CTH) .
3
CTC0,CTC1g
ggCTH0

Device and Constants


CTC2,CTC3g
ggCTH1

Default The value is held.

KV-5500/5000/3000 series PLC User's Manual, "2-8 High-speed Counter"

Index register Z

Overview 32-bit word device that is used to specify No. attached to destination device during index
modification. Just like data memory, it may store data and operation result.

Range Z1 to Z12

TIP gSuffix can be added when programming


Example) Z01.L (signed 32-bit)
Z02.D (unsigned 32-bit)
gFor programming when suffix omitted, if without type declaration, when the model is KV-
5500/5000/3000, it is processed as .L (signed 32-bit); when the model is KV-1000, it is
processed as .S (signed 16-bit).

Note
• Z11/Z12 are reserved for system and cannot be used.
• .F, .DF, .T, .B cannot be specified in suffix.
• The bit of word device cannot be specified.
• Local device is not available. ZPUSH and ZPOP function should be used.
"ZPUSH function", Page 12
"ZPOP function", Page 16

Default When powering ON, or PROG-RUN , index register is cleared.

"Index Modification", Page 3-33

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-25


3-1 Device and Constants

Control memory CM
DATA PROCESSING

Overview Control memory is a specific word device to control PLC function and acquire PLC status.

Range KV-5500/5000/3000 : CM0000 to CM5999


KV-1000 : CM00000 to CM11998

TIP gSuffix can be added when programming


3 Example) CM1720.U
gWhen suffix is omitted, if without type declaration, it is processed as .U (Unsigned 16-bit).
Device and Constants

Note "List of Control Relays/Control Memories", Page A-2

3-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

Processing Bit Device in Word Unit

DATA PROCESSING
If the bit device without suffix.B is specified according to functions and assignment statements of word
device used, it will be processed in word unit starting from the specified bit device.
Example)
DM0000.U = R3000.U
R30015 R30000

1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
3

Device and Constants


bit DM00000 bit
15 0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

DM0000.D = R3000.D
R30115 R30100R30015 R30000

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 DM00001 bit bit DM00000 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

If the bit device with suffix is not at the leading of a channel, straddle the next channel and process in
word unit.

R30505.U = R30003.U
R30102 R30003
301ch 300ch

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

R30604 R30505
306ch 305ch

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

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-27


3-1 Device and Constants

Processing Word Device as Bit Device


DATA PROCESSING

In general, word device is processed as the device of 16-bit/32-bit, but it can be processed as bit device
after adding suffixof bit type.

Note
High-speed counter (CTH) and index register (Z) cannot be processed as the bit device.

3 ƽ When processing as the bit device at the lowerest bit


When adding suffix .B to word device, or specifying word device in arguments and assignment
Device and Constants

statements of contact output function used for processing bit devices etc., it will be processed as bit
device at the lowerest bit of word device.
When DM1000 value is #46563 ($B5E3)
DM1000˙#46563($B5E3)

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

Lowest bit
1: Contact ON
0: Contact OFF

The lowest bit of DM1000 is 1, so, DM1000.B shall be processed as per "ON".

ƽ When processing as the bit device at any bit.


When CPU unit is KV-5500/5000/3000, it can be used.
When bit position of ".0 to .15" is specified in word device, it is processed as bit device at specified bit
position of word device.

Denotation Example)

&/
Random word device Bit position (.0 to .15)

TIP gSame bits are processed by DM123.B and DM123.0.


gDevice comment displays comment set against word device.

Note
• When CPU unit is KV-1000, it cannot be used.
• Please use DEC (0 to 15) to specify the bit position.
• Local device (@) cannot be used.
• The devices whose bit can be specified are only limited to DM, W, EM, FM, ZF, TM and CM.
• For label, bit position cannot be specified. (during global label registration, the word
device whose bit has been specified can be specified)
• For macro argument device, bit cannot be processed based on the position of the bit specified.
• Macro function argument cannot be set for the device whose bit position specified.
• Indirect specifying and index modification cannot be performed for the device whose bit
position specified.

3-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

When DM123 value is #59 ($3B)


bit bit bit bit bit bit bit bit bit bit bit bit bit bit bit bit

DATA PROCESSING
               

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

When DM123 is treated as bit device at the specified bit position, bit status as follows.
Device Bit status
DM123.0 ON
DM123.1 ON
DM123.2 OFF 3
DM123.3 ON

Device and Constants


DM123.4 ON
DM123.5 ON
DM123.6
to OFF
DM123.15

Direct I/O Relay

When CPU unit is KV-5500/5000/3000, you can add "D" to the front end of device No. of I/O relay (R),
and it works as direct I/O relay.

Denotation Example)
Direct I/O relay

DR001
I/O relay

Note
• When CPU unit is KV-1000, direct I/O relay cannot be used.
• No suffix other than .B could be added.

Range DR000 to DR015


DR500 to DR507
Expansion I/O relay

For direct I/O relays, see "KV-5500/5000/3000 series User's Manual."

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-29


3-1 Device and Constants

Constant
DATA PROCESSING

Constant and its range will vary with function used and suffixof device.

(#) DEC constant

Overview DEC constant is expressed by 16-bit and 32-bit DEC.

3 Denotation DEC value is experessed as it is. (signed representation also acceptable)


Example) Value
Device and Constants

06143
TIP gInput allows zero suppression when programming.
gDEC constant can also be attached prefix "#" when programming. For signed DEC
constant, only "+" can be omitted.

Range gUnsigned 16-bit: 0 to 65535


gUnsigned 32-bit: 0 to 4294967295
gSigned 16-bit: -32768 to +32767
gSigned 32-bit: -2147483648 to +2147483647

TIP Adding suffix via constant and programming, can expand the range of constant. (suffix is not
added to constant in programming generally)
300U : 16-bit, unsigned (0 to 65535)
500S : 16-bit, signed (-32768 to +32767)
3000D : 32-bit, unsigned (0 to 4294967295)
5000L : 32-bit, signed (-2147483648 to +2147483647)
123F : Single precision floating point type (-3.4E+38dNd1.4E-45
N=0
1.4E-45dNd3.4E+38)
(Number of effective digits: 7 bits)
1.2345678DF : Double precision floating point type (-1.79E+308dNd-2.23E-308
N=0
2.23E-308dNd1.79E+308)
(Number of effective digits: approx. 16 digits)

Note
For constant suffix, "." (point) is not added when programming.

3-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-1 Device and Constants

$ HEX constant

DATA PROCESSING
Overview HEX constant is expressed by 16-bit and 32-bit HEX number.

Denotation HEX constant takes "$" as prefix, attached with HEX value.
Example) HEX symbol Value

$1AF7
TIP Input allows zero suppression when programming.
3
Range g16 bit : $0 to $FFFF

Device and Constants


g32 bit : $0 to $FFFFFFFF

TIP Due to HEX number without suffix, 16-bit/32-bit will be identified via the number of digits after "$".
$00FF(4 digits or less) ĂĂ16-bit
$0000 00FF (5 digits or more) ĂĂ32-bit

Note
• When programming, if HEX constant has no prefix "$" and contains A to F , error will
occur; if it does not contain A to F, it will be considered as DEC number.
• When programming, sign (+/-) cannot be attached to HEX constant.

Single precision floating point type constant

Overview When programming, single precision floating point type real number can act as floating real
number.

Denotation gDEC constant is expressed by [sign + DEC number].


Example) Value

1234.56
g8-bit above is represented in exponential form.
gDEC constant is represented by suffix.
Example) Value single precision floating point type

1234F
TIP For floating typeconstant, suffix can be omitted.
Example) 1234.0
Indicates single precision floating point type
TIP DEC constant can also contain prefix "#" when programming. For signed DEC constant, only "+" can be omitted.

Range -3.4E+38dNd-1.4E-45
N=0
+1.4E-45dNd+3.4E+38 (Number of effective digits: 7 digits)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-31


3-1 Device and Constants

Double precision floating point type constant


DATA PROCESSING

Overview When programming, double precision floating point type real number can act as floating real
number.

Denotation gDEC constant is expressed by [sign + DEC number].


Example) Value

12345.6786

3 g17-bit above is represented in exponential form.


gDEC constant is represented by suffix.
Device and Constants

Example) Value double precision floating point type

1234F
TIP DEC constant can also contain prefix "#" when programming. For signed DEC constant, only "+" can be omitted.

Range -1.79E+308dNd-2.23E-308
N=0
+2.23E-308dNd+1.79E+308 (Number of effective digits: approx. 16 digits)

Fixed text string (text string type constant)

Overview During programming, any text string can be bracketed using double quote (").

Denotation ("") indicates text string.


Example) String

“Operation result”
TIP gWhen processing (") as characters, please input (" ").
gWhen adding ( ") to other characters, use" + " and characters.

DM1000.T = " " + "Operation result" + " " “Operation result” is stored in DM1000.T.

Note
(" ") will be processed as label.

Range Up to 1999 characters can be processed by KV-5500/5000/3000/1000.

3-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-2 Index Modification and Indirect Specifying

Index Modification

DATA PROCESSING
"Index modification" refers to the method for specifying numbered device by adding the value and
constant of index register (Z) to corresponding device.
The range of the value that can be summarized is signed 32-bit value (-2147483648 to +2147483647).
The types of device for index modification include: R (DR), B, MR, LR, T, C, DM, W, EM, ZF, FM and TM.
Index modification can be used together with indirect specifying (㪁) or local device (@).

Note
• CTH, CTC, CR, CM, Z, label (label array and bit specifying device of word device cannot
3

Index Modification and Indirect Specifying


perform index modification.
• When specify the device out of range that is capable of index modification according to argument,
control relay CR2012 is ON and this function is not executed. But operation continues.

Ƶ Modify via index register


Index modification is Used to change device no. in KV-1000 operation.
Programming method to modify device through index register is as follows:
ǂǂǂǂǂ(Device No.) : Z(01 to 10)
.
Example) DM1000:Z01 Specify DM0990 when value in Z01 is –10

R0000:Z05 Specify R0100 when value in Z05 is +16.

Note
Z11/Z12 are reserved for system and cannot be used.

Example
The current value stored in DM1000 will be saved as triggering signal at the rising edge of R0001.
Index register will be initialized during start of operation; the data is stored in memories
starting from DM0000 at the rising edge of R0001( OFF -> ON change).

Programming Script
IF LDP(CR2008) THEN
Set index register Z01 to 0 when
Z01=0 starting operation.
END IF
Write value of DM1000 to destination
IF LDP(R0001) THEN device to be index-modified at rising
DM0000:Z01 = DM1000 edge of R0001.
INC(Z01) Increment (+1) index register Z01
END IF

Current value Storedz to

DM1000 1234 DM0000 2152


DM0001 2348

DM0099 1234

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-33


3-2 Index Modification and Indirect Specifying

Note
Since the device (value) to be index-modified is processed as signed 32-bit data, the index
DATA PROCESSING

register whose type is not declared will be automatically performed as ".L (signed 32-bit)".

TIP If 10 or more index registers (Z) are required in a project, index register function (ZPUSH/ZPOP)
can be used for batch cleaning or restoring index register of every module or macro. Besides, due
to automatic cleaning or restoring when interrupt program is started and stopped, ZPUSH/ZPOP
function needs not to be used.
"ZPUSH function", Page 6-12
3 "ZPOP function", Page 6-16
KV-5000/3000 series PLC User's Manual, "3-5 Break".
Index Modification and Indirect Specifying

Ƶ Modify via index constant


When constant is used for index modification, program as follows:
(Device No.): (#) (DEC constant)
. ("#" can be omitted.)
Example)

DM1000:10 DM1000+10 words -> DM1010

R0000:16 R0000+16 bits (1 channel) -> R0100.

TIP If it is used when making ladder using unit device, the device No. assigned can be clearly
identified. Besides, when making macro as argument device, it is valid when UR/UM is
used.
Example)
UR0:2
UM1:32

Ƶ Modify via the device and expression


Script allows to perform index modification for the device other than index register.
In this case, index register (Z11/Z12) automatically reserved for system during ladder conversion is
used .
Programming Script
DM1000 : (DM10 + 2) = 100
Ladder
CR2002 DM10 +2 Z11 MOV
LDA EXT ADD.L STA.S #100 DM01000:Z11

* during index modification via expression, must add bracket () to the expression.

Ƶ Modify the device with suffix


The suffix of the device for index modification can be programmed as follows:
DM1000.D:Z01.S
DM1100.F:(DM10+10)

3-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-2 Index Modification and Indirect Specifying

Ƶ Invalid index modification


Index modification cannot be performed in the following cases:

DATA PROCESSING
• (DM1000˖Z01): Z02 To modify the device after index modification
• (DM1000+3): Z02. To modify operation result
• DM1000: Z01+5 "( )" is not included index modification expression
• Z01: Z02 To modify the device that the index modification cannot be performed

Indirect Specifying
3
Ƶ What is indirect specifying (*)

Index Modification and Indirect Specifying


Indirect specifying (*) refers to indirect specifying by programming the device storage device indicated
value (address) instead of direct device specifying.

ƽ Indirect specifying principle


Every device is managed by internal memory in CPU unit, each with separate address.

• Indirect specifying (*) operates the address via special function, changing the device to be searched.
• Index modification is represented via [base address device + relative offset (index constant)], and
indirect specifying represented via ["*" + specifying destination address storage device].
• Indirect specifying can be used with index modification (: Z /: (#) decimal constant) and local device (@).
2 words must be used for address storage due to address managed as 32-bit.

Note
• If the device outside range of applicability is addressed via indirect specifying, the action
of function cannot be guaranteed.
• If the device outside range of applicability is addressed according to the condition
operation formula, the operation result cannot be guaranteed.

ƽ Indirect specifying programming


If indirect specifying is programmed with "*(device)", the device value or the device matching the
address stored in the device will be searched.

Example)
<When the address of DM1 is set to FM100 and programmed as "*FM100">

Device Value
FM100࡮FM101 DM0 25
Indicates value FM100 specify 1234
DM1 1234
of DM1’s address or DM1.
DM2 0
DM3 96

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-35


3-2 Index Modification and Indirect Specifying

Note
• Devices that can be programmed or for storing address as "*(device)" include DM/W/EM/
DATA PROCESSING

FM/ZF/TM.
• The devices that can be Indirect specifying are R (DR)/B/MR/LR/T/C/DM/W/EM/ZF/FM/
TM and label (label array).
• Bit position specifying device of word device cannot be Indirect specifying.

TIP g If indirect specifying device is a timer (T) or counter (C), contact, current value and setting
value will depend on the function argument used and additional suffix.
3 g Use programming format of local device " *@( device) ".
g Indirect specifying device is processed as .U (unsigned 16 bit).
Index Modification and Indirect Specifying

g Type declaration can be also conducted for indirect specifying.

ƽ Application method of indirect specifying


Indirectly specify according to the following steps.

1 Write the address of device to be searched with ADRSET function.


Example)
ADRSET(R1000,DM0,FM100) Store address of DM0 to FM100/FM101
when execution conditon (R1000) is ON.

Note
Address storage devices include: DM, W, EM, ZF, FM, TM.

"ADRSET function", Page 6-18

2 For every argument (device) of indirect specifying function, Prefix "*" can be added to the
device for storing current address.
Example)
EM1000.U = AVG( FM100.U,10) Store average vaue of 10-word data starting from
FM100 (DM0) to EM1000.U.

Note
Before adding prefix "*" to address storage device, ADRSET function must be used to store
the address of device to be indirectly addressed.

3 If changing the device to be searched, indirect specifying function (ADRINC/ADRDEC/ADRADD


/ADRSUB) can be used to change the address stored currently.
Example)
Set EM300’s address to FM100.
ADRSET(EM300,FM100)
ADRINC(R1001,FM100) Increment (+1) DM0 address stored in FM100/
FM101 when execution conditon (R1001) is ON
FM100 = DM1000

Store value of DM1000 in FM100 (EM300).

Note
When changing the address to be searched, do not use common operators (+, -,*, /, etc.).
Otherwise, Ladder fails to operate correctly.

3-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-2 Index Modification and Indirect Specifying

ƽ Type of indirect specifying device


For indirect specifying device (*[device]), similar to other device, data range that can be processed

DATA PROCESSING
varies with suffix.

• The device type can be represented by adding suffixto indirect specifying device.
Programming Script *DM1000.F = 123.567 ' *DM1000 indirect specifying device is processed as .F
' (single precision floating point type).

• If using type declaration (TYPE) to specify the type of indirect specifying device, the suffixcan be
omitted when programming.
3

Index Modification and Indirect Specifying


Programming Script
TYPE *DM1000.F ' Type declaration: DM1000 is processed as .F.
*DM1000 = 123.567 ' Even if the suffix is omitted, the device of DM1000
' indirect specifying is also processed as .F.

• When programming, if the suffixof indirect specifying device without type declaration is omitted, the
device will be processed as .U.
Programming Script *DM1000 = 65535 ' * DM1000 indirect specifying device without type
' declaration is processed as .U (unsigned 16 bit).

In this case, even if the device type of indirect specifying is not.U, if suffixof indirect specifying device
is omitted, can be also processed as.U.
Programming Script ADESET (MR2000, ' MR2000 address is stored in DM1000.D( DM1000.D).
DM1000.D) ' MR2000 is bit device but suffix is omitted,
*DM1000 = 123 ' DM1000 ( = MR2000 ) is processed as. U ( word
' device).

• If the type of indirect specifying device has been declared, the type of address storage device is declared as
.D (unsigned 32-bit).
Programming Script TYPE *DM1000.F ' *DM1000DM1000 is declared as .F,
' and DM1000 as .D.
TYPE *DM2000.S ' *DM2000 acts as . S declaration,
' or DM 2 000 as .D declaration.
ADESET (EM5000, DM1000) ' DM1000 is processed as .D .
*DM1000 = 123.567 ' *DM1000 (= EM5000 ) is processed as .F .
ADESET (FM6000, DM2000) ' DM2000 is processed as .D .
*DM2000 = -555 ' * DM 2000 ( = FM6000 ) is processed as. S .

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-37


3-2 Index Modification and Indirect Specifying

ƽ Example for indirect specifying


During initial scanning, DM0 address will be stored to FM100/FM101.
DATA PROCESSING

DM1000 current value is stored from DM0 in turn and triggered at rising edge of R0001.

ADRSET(LDP(CR2008),DM0,FM100) Write address of DM0 to [FM100/FM101]


when starting operation.
IF LDP(R1) THEN
FM100 = DM1000 Write value of DM1000 to index-specified
destination device at the rising edge
ADRINC(FM100) of R0001.
END IF
3 Increment (+1) address stored in
[FM100FM101].
Index Modification and Indirect Specifying

Current value Save to

DM1000 1234 DM0000 2152


DM0001 2348

DM0099 1234

3-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-2 Index Modification and Indirect Specifying

Combination of Index Modification and Indirect Specifying

DATA PROCESSING
Ƶ How To Program
During index modification for indirect specifying device, you can program according to following method.
Example)

(DM1000.U):Z01 Index-modify DM1000 by Z01.

(DM1000.U:Z01) Indirect-specify DM1000 by Z01.

3
When programming with "( )" is omitted, the meaning is as follows:

Index Modification and Indirect Specifying


Example)

DM1000.U:Z01 Index-modify DM1000 by Z01.

ƽ Example for combination of index modification and indirect specifying


Taking rising edge of R1 as trigger signal, store current value of DM1000.
If R2 is ON at rising edge of R0, the data will be stored in turn from DM0; if it is OFF, the data will be
stored in turn from EM0.
IF LDP(R0000) THEN
Z01 = 0 (1)
ADRSET(R2,DM0,FM100) (2)
ADRSET(R2 = OFF,EM0,FM100) (3)
END IF
IF LDP(R1) THEN
FM100:Z01 = DM1000 (4)
Z01 += 1 (5)
END IF
[When starting measurement]
(1) Write 0 in Index register Z01. (Index register initialization)
(2) If R2 is ON, write address of FM100/FM101 to DM0.
(3) If R2 is OFF, write address of FM100/FM101 to EM0.

[When trigger occurs]


(4) Write FM100/FM101 value into device obtained via index modification Z01 (Z01 added), address
device is stored in DM1000.
Example) when R2 is OFF,
*FM100->EM0 *FM100:Z01->EM23
Z01= 23
(5) Z01 increment "+ 1".

Ƶ Simple indirect specifying


KV script cannot use simple indirect specifying (#TM. When using simple indirect specifying, ladder
program must be used.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-39


3-3 Data Type (suffix)
For KV script, device type and constant type can be represented by adding suffix to the device.
For the device with the "Suffix".U.S.D.L.F.DF.B.T", the type of processing data varies with different
DATA PROCESSING

suffixes.

Suffix

A suffix refers to a symbol attached to the end of the device, and can be divided into seven kinds as
follows.

3 .U .S .D .L .F .DF .B .T
* The device with corresponding suffix is input in .
Data Type (suffix)

According to suffix, every device can process Data Memory value, etc. as follows:
Suffix .U is processed as unsigned 16-bit data. (0 to 65535+˅
Suffix .S is processed as signed 16-bit data. (-32768 to 32767˅
Suffix .D is processed as unsigned 32-bit data. (0 to 4294967295+˅
Suffix .L is processed as signed 32-bit data. (-2147483648 to 2147483647˅
Suffix .F is processed as single precision floating point type real number data.
-3.4E+38dNd-1.4E - 45
-3.4E38 < N=0
1.4E - 45dNd3.4E+38
(Number of effective digits: 7 digits)

Suffix .DF is processed as double precision floating point type real number data.
-1.79E+308dNd-2.23E-308
-3.4E38 < N=0
2.23E-308dNd1.79E+308
(Number of effective digits: approx. 16 digits)

Suffix .B is processed as bit data. (ON: TRUE, OFF: FALSE)


Suffix .T is processed as text string data.

TIP The suffix specified by ladder program can be only added at the end of an instruction, not
device (for script, suffix is only added at the end of the device, not function).

Example
DM1000 (.U)
DM1000.S
DM1000.D
DM1000.L
DM1000.F
DM1000.DF
DM1000.B
DM1000.T

3-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

ƽ Suffix omitted
For programming of the device whose suffix omitted, the processing type depends on the device type.

DATA PROCESSING
Device type Type processed when suffix is omitted (default)
R(DR),B,MR,LR,T,C,CTC,CR,UR0 .B (bit type)
DM,W,EM,ZF,FM,TM,CM,V0,P0,UM0,UV0
.U (unsigned 16-bit data type)
indirect addressing (㪁㩷) device
KV-5500/5000/3000 : .L (signed 32-bit data type)
Z*
KV-1000 : .S (signed 16-bit data type)
CTH .D (unsigned 32-bit data type)

* Default type varies with different CPU units. 3

Data Type (suffix)


Programming Script DM1000 = 2000 ' When omitted, data is processed as unsigned 16-bit (.U).
DM1100.D = 75535 ' DM1100 is processed as unsigned 32-bit (.D).
IF DM1000 = 3000 THEN '
DM3000.L = DM1100 + 1000 ' Right side is operated as signed 32-bit.
END IF '
'
DM1000.L = -21474800 ' DM1000 is processed as signed 32-bit (.L)
IF DM1000 > 0 THEN '
DM3000.D = DM1000.S * -1 ' Right side is developed to .L operation, converted to .D
END IF ' and then replaced. *

The signed 32 bit data (.L) will be replaced with unsigned 32-bit data (.D). If "Set script warning level" is
set too higher, the warning will be sent during script conversion.

TIP The type of device can also be declared in advance via "TYPE" programming.
Type declaration is valid only in type statement script.
For details, see "About Type Declaration (TYPE)", Page 3-47

Ƶ About .U and .S
Suffix .U processes BIN data as unsigned 16-bit data.
Suffix .S processes BIN data as signed 16-bit data.
Correspondingly, the decimal representation relation between BIN data and corresponding suffix, is
shown below.
Device (DM1000) Constant type 1111111111111111
DM1000.U Unsigned DEC system 65535
DM1000.S Signed DEC system -1

• When 16-bit BIN data (1111111111111111) stored in DM1000 is compared with decimal constant 100,
if suffix is .U, the value of DM1000 is compiled to 65535.
Programming Script IF DM1000.U > 100 THEN
INC (DM2000)
END IF
Correspondingly, if DM1000 > 100 is TRUE, add "1" to DM2000

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-41


3-3 Data Type (suffix)

• If suffix is .S, DM1000 value is compiled to "-1".


Programming Script IF DM1000.S > 100 THEN
DATA PROCESSING

DEC (DM2000)
END IF
Correspondingly, subtraction is not conducted for DM2000 due to DM1000 < 100, DM2000.
For control statements, see "4-3 Control Statement", Page 4-10.

Ƶ About .D and .L
3 Suffix .D processes BIN data as unsigned 32-bit data.
Suffix .L processes BIN data as signed 32-bit data.
Data Type (suffix)

Correspondingly, the decimal representation relation between BIN data and corresponding suffix is
shown below.
Device (DM1000) Constant type 11111111111111111111111111111111
DM1000.D Unsigned decimal system 4294967295
DM1000.L Signed decimal system -1

• When comparing 32 bit BIN data (11111111111111111111111111111111) stored in DM1000/DM1001 with


decimal constant 100, if suffix is .D, the value of [DM1000/DM1001] is compiled as 4294967295.
Programming Script IF DM1000.D > 100 THEN
DM2000 = DM2000 + 1
END IF
Correspondingly, DM1001 (high bit)/DM1000 (low bit) (4294967295) > 100. Contact is ON, DM2000
plus "1".

• If the suffix is .L, the value of [DM1000/DM1001] is processed as "-1".


Programming Script IF DM1000.L > 100 THEN
DM2000 = DM2000 - 1
END IF
Correspondingly, DM1001 (high bit)/DM1000 (low bit) (-1) < 100. Contact is OFF, DM2000 minus "1".

Note
During processing of 32-bit data (.D,.L,.F), device No. of even number must be used.

3-42 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

Ƶ About .F
.F suffix will process BIN data as single precision floating point type real number. The data is 32-bit

DATA PROCESSING
type.
Single precision floating point type real number data is indicated with specific bit (internal
representation).
So, direct bit operation and analysis on internal representation must be avoided.
Single precision floating point type real number value is a value represented according to the following
method.

ˉ1.234×2ˉ
3

Data Type (suffix)


Sign Mantissa Exponent

Sign Exponent Mantissa


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) Exponent (8-bit)


0=plus 00000000($00)=not used
1=minus 00000001($01)=-126
00000010($02)=-125
Mantissa section (23 bit) 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)=Not used

Note
Suffix .D., L. and.F shall be added to the device when 32-bit data is processed by word
devices suhc as DM/W/EM/FM/TM, etc.
In this case, the device uses 2 words with continuous No..
The device to be specified is that the suffix is added to low 16bits.
Example) DM1000.D->[DM1001/DM1000] .

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-43


3-3 Data Type (suffix)

Ƶ About .DF
.DF suffix will process BIN data as double precision floating point type real number. The data is 32-bit
DATA PROCESSING

type.
Double precision floating point type real number data is indicated with specific bit (internal
representation).
So, direct bit operation and analysis on internal representation must be avoided.
Double precision floating point type real number value is a value represented according to the following
method.

3 ˉ1.2345678×2ˉ
Data Type (suffix)

Sign Mantissa Exponent

Sign Exponent Mantissa


bit bit
63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 … … 3 2 1 0

Sign (1 bit) Exponent (12-bit)


0=plus 000000000000($000)=not used
1=minus 000000000001($001)=-2046
000000000010($002)=-2045
Mantissa section (51 bit) 000000000011($003)=-2044
0 to 2251799813685248
011111111110($000)=-1
011111111111($7FF)=0
100000000000($800)=1
100000000001($801)=2

000000000000($000)=2045
000000000000($000)=2046
000000000000($000)=2047
111111111111($FFF)=Not used

Note
Suffix .DF shall be added to the device when double precision floating point type real
number is processed by word devices suhc as DM/W/EM/FM/TM, etc.
In this case, the device uses 4 words with continuous No.. Use an even number device
when handling .DF.
The device to be specified is that the suffix is added to low 16bits.
Example) DM1000.DFė[DM1003•DM1002•DM1001•DM1000] .

3-44 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

Ƶ About .B
.B suffix processes BIN data as bit data.

DATA PROCESSING
Example) Set the bit device MR1000 to ON (1, TRUE).
Programming Script SET (MR1000.B)

TIP If the word device is bit processed (suffix .B), and the lowest significant digit is the bit target.
As mentioned in above example, DM10.B is specified in the argument of SET function, the
least significant bit of DM10 changes to "1". TRUE/FALSE judgement of word device is
identified as follows.
3

Data Type (suffix)


Exmaple) IF DM10.B = ON THEN
Processing statement
END IF

Example) Set the bit device MR1000 to OFF (0, FALSE).


Programming Script RES (MR1000.B)

Ƶ About .T
Suffix .T processes BIN data as text-string data.

Example) Continuous devices from DM100 stores "KEYENCE" text string.


Programming Script DM100.T = "KEYENCE" + CHR ($0D) + CHR ($0A)

For above example, data storage status as follows.

bit bit
15 0
Data storage status . %+ ( + '0
< + ( + '0
1 (+ & + '0
( + &5 '+ '0
/) $+ 18/ + '0

TIP NUL will be automatically stored into text string (00H).

Note
Up to 1999 characters can be processed KV-5500/5000/3000/1000.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-45


3-3 Data Type (suffix)

Ƶ Value change when exceeding max./min. value


When arithmetic operation result exceeds maximum value or minimum value, according to data type,
data change is shown below respectively.
DATA PROCESSING

● For 16-bit data


Value change when □.U larger than 65535 Value change when □.U larger/less than max./min. value

Unsigned DEC HEX Signed DEC HEX


3 0003 3 0003
2 0002 2 0002
1 0001 1 0001

3 0
65535
65534
0000
FFFF
FFFE -2
0
-1
0000
FFFF
FFFE
65533 FFFD -3 FFFD
Data Type (suffix)

65532 FFFC -4 FFFC


… … … …
32771 8003 -32765 8003
32770 8002 -32766 8002
32769 8001 -32767 8001
32768 8000 -32768 8000
32767 7FFF 32767 7FFF
32766 7FFE 32766 7FFE
32765 7FFD 32765 7FFD
32764 7FFC 32764 7FFC

● For 32-bit data


Value change when □.D larger than 4294967295 Value change when □.L larger/less than max./min. value

Unsigned DEC HEX Signed DEC HEX


3 00000003 3 00000003
2 00000002 2 00000002
1 00000001 1 00000001
0 00000000 0 00000000
4294967295 FFFFFFFF -1 FFFFFFFF
4294967294 FFFFFFFE -2 FFFFFFFE
4294967293 FFFFFFFD -3 FFFFFFFD
4294967292 FFFFFFFC -4 FFFFFFFC
… … … …
2147483651 80000003 -2147483645 80000003
2147483650 80000002 -2147483646 80000002
2147483649 80000001 -2147483647 80000001
2147483648 80000000 -2147483648 80000000
2147483647 7FFFFFFF 2147483647 7FFFFFFF
2147483646 7FFFFFFE 2147483646 7FFFFFFE
2147483645 7FFFFFFD 2147483645 7FFFFFFD
2147483644 7FFFFFFC 2147483644 7FFFFFFC
2147483643 7FFFFFFB 2147483643 7FFFFFFB

TIP gFor single precision floating point type data


Overflow : when absolute value is larger than 3.4x1038, it becomes "Ğ (infinity)".
Underflow : when absolute value is less than 1.4x10-45, it becomes "0".

1.4×10-45 3.4×1038
0 (1.4E-45) (3.4E38)

Display “0” Display “----” (∞infinity)

gFor double precision floating point type data


Overflow : when absolute value is larger than 1.79x10308, it becomes "Ğ (infinity)".
Underflow : when absolute value is less than 2.23x10-308, it becomes "0".

2.23×10-308 1.79×10308
0 (2.23E-308) (1.79E308)

Display “0” Display “----” (∞infinity)

3-46 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

About Type Declaration (TYPE)

DATA PROCESSING
In KV script, the device whose suffix programming omitted will be processed as the pre-determined
type (varies with different device). After type declaration, the type of device whose suffix programing
omitted can be changed.
Type declaration is only valid in box script (or area script) of stated type.

• When programming via [device type + suffix (Example: DM.F)], the type of device shall be processed
as the device with declared suffix. 3
Programming Script TYPE DM1000.D ' DM1000 will be processed as.D in the script

Data Type (suffix)


' Emnnnn will be processed as .F in the script
TYPE EM.F ' Even if suffix is omitted, DM1000 can be still
' processed as.D
DM1000 = 10000 * DM2000.D ' All EM devices are processed as .F
EM3000 = 123.456 / DM1200.F '
• Device type of specialized range can be also declared.
Programming Script TYPE DM1200 - DM1600.F ' DM1200 to DM1600 processed as .F
TYPE DM2000.L - DM2100 ' Programming method in another specified range
TYPE DM2200.D - DM2300.D ' Programming method in another specified range
DM1200 = 12.5 * DM1100 ' Although DM1200 suffix is omitted, shall be also
DM1210 = SIN(DM1300) ' processed as .F
' Argument and return value are processed as .F
• Even if the device with type declaration, other suffix will still be addressed firstly.
Programming Script TYPE EM.F ' Afterwards, all EM are .F in this script
EM1000.S = DM1100 * -10 ' But, after other suffix is specified, the specified
EM3000.D = 1234 * DM1200 ' suffix will be precedential
EM3000 = EM3000 + 10000 ' After suffix omitted, the device is processed as
' TYPE statement type.

Note
• Type declaration can be programmed at the start of every script.
• All type declarations are invalid except the script with type declaration.
Correspondingly, type shall be declared again in other scripts, or corresponding suffix
shall be specified.
• Note: when using of global label, type declaration shall be precedential based on data
format defined when registering a label.
Example) TYPE DM.D
When programming above script, data format of all global labels of assignment
DM is .D.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-47


3-3 Data Type (suffix)

About Operation Type


DATA PROCESSING

For value operation via KV script, operators (+,-,*, /) are used in programming instead of special
instructions used like ladder language.

Ƶ Data range processed by operation formula


Each item of the operation formula is handled as .L (signed 32-bit), .F (single precision floating point
type) or .DF (double precision floating point type). Thus, all devices of the formula are automatically
3 sign extended to .L, .F or .DF.
Data Type (suffix)

ƽ When operation formula does not contain floating point data (.F, .DF, constant
value)

Example) DM3000.L = (DM1000.U + 30) *DM2000.U

The device in the operation formula is sign extended to .L once, so the above operation formula is
calculated as DM3000.L = (TOL(DM1000.U)+30) * TOL(DM2000.U).

Example) DM3100.L = (DM1100.D + 30) * DM2100.U

In which, .D (unsigned-32 bit) data existgs, symbol is expanded to .L, data precision will be
impaired sometimes, this shall be noted.
Above operation formula is calculated as follows:
DM3100.L = (DM1100.L + 30) * DM2100.L
When "Script warning level setting" is "high", the following warning is displayed in output window.
Warning : data may lose in "+" operation. (unsigned 32-bit-> signed 32-bit)

ƽ When operation formula contains floating point data (.F, .DF, constant value)

Example) DM3000.F = (DM1000.S + 30) * DM2000.F + DM2500.U

If the operation formula has no .DF (double precision floating point type) but has an .F (single
precision floating point type), .F is calculated as .L until it is used as an arithmetic element. Once .F
becomes an arithmetic element, it is operated as .F.
In the above operation formula, data other than .L and .F is sign extended to .L or .F once, so the
above operation formula is calculated as
DM3000.F = (TOL(DM1000.S) + 30) * DM2000.F + TOF(DM2500.U).

Example) DM3000.DF = (DM1000.S + 30) * DM2000.F + DM2500.U + DM2600.DF -


DM2700.U
If the operation formula has a .DF (double precision floating point type), .DF is calculated as .L or
.F until .DF is used as an arithmetic element. Once D.F becomes an arithmetic element, it is
operated as .DF.
In the above operation formula, data other than .L, .F and .DF is sign extended to .L, .F or .DF
once, so the above operation formula is calculated as
DM3000.DF = TOF(TOL(DM1000.S) + 30) * DM2000.F + TOF(DM2500.U) + DM2600.DF -
TODF(DM2700.U).

3-48 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

ƽ When the device for storing result is not . L

Example) DM3200.S = (DM1200.U + 30) * DM2200.U

DATA PROCESSING
As the result of woking equation excluding floating point data is .L, if the type other than .L is
specified as the device type storing result, data precision may be impaired, which shall be noted.
Above operation formula is calculated as follows:
DM3200.S =TOS ((DM1200.U + 30) * DM2200.U)
When "Script warning level setting" is "high", the following warning is displayed in output window.
Warning : data may lose due to assignment "=". (signed 32-bit -> signed 16-bit)
Even if the device storing the results is .F, if the right-hand side contains .DF, the 3
precision will drop.

Data Type (suffix)


Note
The warning on precision impairement of operation formula is not displayed in output
window by default.
To display warning message, script warning level must be set to "high".
"2-6 Script Conversion Output Message", Page 2-41

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-49


3-3 Data Type (suffix)

PRAGMA Directive
DATA PROCESSING

If the operation formula contains a single precision floating point type data (.F, constant), the operation
is executed after converting the type to a single precision floating point type (.F). However, by using a
PRAGMA directive, compilation can be instructed to convert the type to a double precision floating
point type (.DF).
By operating with double precision, a drop in precision, including in the interim operation results, can be
prevented.
3
Ƶ Explanation of PRAGMA Directive Usage and Operation
Data Type (suffix)

The PRAGMA directive is written in pairs, such as #PRAGMA DOUBLE ON and #PRAGMA DOUBLE
OFF in the same manner as the control syntax for IF statements and FOR statements. The interval
starting with #PRAGMA DOUBLE ON and ending with #PRAGMA DOUBLE OFF is the effective range
of the double precision operation.

ƽ Operation formula
Programming Script

DM1000.F = 123.45
DM1004.S = -1998

DM2000.DF = DM1000.F 3.141592 ‘ ...(1)

DM2004.DF = DM1004.S / 25 ‘ ...(2)

#PRAGMA DOUBLE ON
DM2010.DF = DM1000.F 3.141592 ‘ ...(3) Effective interval of PRAGMA
DM2014.DF = DM1004.S / 25 ‘ ...(4) DOUBLE

#PRAGMA DOUBLE OFF

Operation discription

The right-hand sides (1), (2) and (3), (4) are the exactly same operation formula, but (3), (4) specify to
convert the floating point type operation to a double precision floating point type with a PRAGMA
directive. (1), (2) are operated with a single precision floating point type and (3), (4) are operated with a
double precision floating point type.
(1) The operation formula contains only a single precision floating point type (.F, constant) so it is
operated using the single precision floating point type. The operation results are converted to the
left-hand side type (double precision floating point type (.DF), and stored in DM2000 to DM2003 (4
words).
(2) The operation formula contains only an integer type (.S, constant), so the integer type value is
converted into a signed 32-bit integer (.L) and then operated. The operation results are converted
into double precision floating point type (.DF), and stored in DM2004 to DM2007 (4 words).
(3) The operation formula contains only a single precision floating point type (.F), but PRAGMA
DOUBLE Is valid so each is converted into a double precision floating point type (.DF) and operated.
The operation results are stored in DM2010 to DM2013 (4 words).

3-50 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3-3 Data Type (suffix)

(4) PRAGMA DOUBLE is valid but the operation formula does not contain floating point type data so,
the operation is executed with the same rules as (2). The operation results are converted into double

DATA PROCESSING
precision floating point type (.DF) and stored in DM2014 to DM2017 (4 words).

Data Type (suffix)


The operation results differ for (1) (DM2000) and (3) (DM2010).

Note
• The size of the double precision floating point type (.DF) is 4 words (64 bits).
• When operating integers, they are first converted into signed 32-bit integers (.L)
regardless of the validity of the PRAGMA directive. To operate the integers as floating
point types, for example with case (4) above, part of the target device must be extended
into a float point type such as:
DM2014.DF=TODF(DM1004.S)/25.
The same effect can be attained by noting the constant as a decimal as shown below.
DM2014.DF=DM1004.S/25.0
• The operation precision increases by operating as a double precision type, but the
execution speed is slower than the single precision type. Using the PRAGMA directive
only where operation precision is required is the key point.

Note
The PRAGMA directive cannot be written to cross other control statements (where control
blocks cross).
"Precautions on use of nesting", Page 4-32
[When FOR statement (repeated control statement) and PRAGMA directive intersect]

FOR <Word device (1) value> TO <end value> 'control statement (1)
   Process statement (1)
   FOR <word device (2) value> TO <end value> 'control statement (2)
      Process statement (2)
      #PRAGMA DOUBLE ON 'PRAGMA directive
       Operation Formula
   NEXT
      #PRAGMA DOUBLE OFF
NEXT

Crossing of control blocks

- KV-5500/5000/3000/1000 Series Script Programming Manual - 3-51


3-3 Data Type (suffix)

ƽ Operation of functions
Programming Script
DATA PROCESSING

DM1000.DF = SIN(DM100.F) ‘ ...(1)

#PRAGMA DOUBLE ON
Effective interval of PRAGMA
DM1010.DF = SIN(DM100.F) ‘ ...(2)
DOUBLE
3 #PRAGMA DOUBLE OFF
Data Type (suffix)

Operation discription

The right-hand sides of (1) and (2) are the exact same operation formula, but (2) specifies to convert
the floating point type operation to a double precision floating point type with a PRAGMA directive.
When a PRAGMA directive is issued, even when a single precision floating point type (.F) is specified
for the function's argument, if the function specifications support double precision operation, the type
will be converted to a double precision floating point type and executed.
(1) The argument is a single precision floating point type (.F) so it is operated using the single precision
(SIN.F). The operation results are converted to the left-hand side type (double precision floating
point type (.DF)) and stored in DM1000 to DM1003 (4 words).
(2) The argument's single precision floating point type (.F) is converted to a double precision floating
point type (.DF) and operated with double precision (SIN.DF). The operation results are stored in
DM1010 to DM1013 (4 words).
The script for (2) is written in the following manner without the PRAGMA directive.

Programming Script DM1010.DF = SIN(TODF(DM100.F))

Note
Even if there is a function in the PRAGMA directive, the following functions will not be
extended to double precision floating point type data.
• TOU function (converted to .U (unsigned 16-bit integer))
• TOS function (converted to .S (signed 16-bit integer))
• TOD function (converted to .D (unsigned 32-bit integer))
• TOL function (converted to .L (signed 32-bit integer))
• TOF function (converted to .F (single precision floating point type data))

3-52 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4

SCRIPT SYNTAX AND Precautions


SCRIPT SYNTAX AND
Precautions

4-1 Assignment Statement ••••••••••••••••••••••••••••••••••••• 4-2


4-2 Operator •••••••••••••••••••••••••••••••••••••••••••••••••••••• 4-6
4-3 Control Statement••••••••••••••••••••••••••••••••••••••••• 4-10
4-4 Precutions on Script Programming •••••••••••••••••••• 4-38

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-1


4-1 Assignment Statement
Assignment statement is the statement whereby the result or value on the right side of equal sign (=) is
assigned to the left side of equal sign.
SCRIPT SYNTAX AND Precautions

How to Use An Assignment Statement

Programmable contents ( device and formula) on the right side of assignment statement include values,
character strings and bits, separately via the constant, formula or function (with returned value).

ƽ Numerical value assignment statement


Assign right numerical constant or value calculation result to the left.
4
Programming Script DM1000.U = 123 'Assignment of numerical constant
Assignment Statement

DM1100.L = DM2000.U + 123 'Assignation of numerical operation result


DM1200.U = DCNT(DM2100, EM1000, 20) 'Assignment of function processing result

ƽ String assignment statement


Assign right character string constant or character string calculation result to the left.

Programming Script DM100.T = "ABCD" 'Assignment of character string constant


DM100.T = "current" + DM300.T + "use" 'Assignation of character string connection result

ƽ Bit assignment statement


• Assign right bit constant or bit calculation (conditional formula evaluation) result to the left.

Programming Script R1000 = ON 'Assignment of bit constant (Boolean value)


R1000 = R1100 OR (R1200 AND R1300) 'Assignment of bit operation result
R1000 = DM100.S > 100 'Assignment of conditional formula evaluation
R1000 = R2000 = R3000 'Assignment of comparative result

• 1 If multiple equal signs(=) are used on one line, the initial ( the most left) equal sign(=) is processed
as "=" of assignment, the later equal signs(=) are processed as comparative sign(=).
in this case, the left side of equal sign(=) assigned is processed as the left, and the right side
processed as the right side.
(Example) R1000 = R2000 = R3000 = R4000 ė R1000=(R2000 = (R3000 = R4000))
Ė Ė Ė
Assign Compare Compare
Left sideĕ:ėRight side
• Except ON, OFF, bit status can be also represened with 1, 0 and TRUE, FALSE.
Programming Script R1000 = 1
Operation description R1000 Set R1000 to ON .
Ladder diagram Conversion
CR2002 R1000

4-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-1 Assignment Statement

• The bit device can only be assigned to Boolean value.


R1000 = TRUE . . . . . . R1000 = ON

SCRIPT SYNTAX AND Precautions


R1000 = FALSE. . . . . . R1000 = OFF
• The bit device can not be assigned to constants other than 1, 0 and assigned to result of value
formula.

h: R1000 = DM1000 + DM2000 . . . . ."+" Not used


• The bit device can be assigned to logical operation result and comparison operation result (results are
Boolean value).

ƻ: R1000 = R2000 AND R2100 . . . . . . Logical operators allowed


R1000 = DM1000 >= 500 . . . . . . . . . Equal sign, inequality sign allowed
(calculation result is only formula of Boolean
value)
4
ƽ Operation assignment statement

Assignment Statement
Operation assignment statement is a assignment statement programed with right device omitted in four
arithmetic operation for left assignment statement device.
There are 4 operation assign statements as follows.
+=, -=, 㪁=, /=
Left side right side operation assignment statement
DM1000.U = DM1000.U + 1 -> DM1000.U += 1

Besides, when using operation assignment statement, right operation is based on type operation on the
left side.

Programming Script DM1000.U += 3 'DM1000.U = DM1000.U + 3(Right side as .U operation) *


DM1100.S -= 3 'DM1100.S = DM1100.S - 3(Right side operates as. S)*
DM1200.D*= 3 'DM1200.D = DM1200.D * 3(Right side operates as. D) *
DM1300.L /= 3 'DM1300.L = DM1300.L / 3(Right side operates as.L )*
DM2000.F += DM1500-3 'DM2000.F = DM2000.F + TOF (DM1500 - 3)
DM2100.D += SRA (EM1000, 8) * 2 'DM2100.D = DM2100.D + TOD (SRA (EM1000, 8) * 2)

* formula operates as .L in general, but assignment statement shall be operated according to


type operation on the left side.

The following script operation results are same (.L range), but LD converted is different.
Programming Script DM1000.U = 10
DM1000.U = DM1000.U + 10 'Programming method A: operation result is 20
DM1000.U += 10 'Programming method B: operation result is 20

Character string can be only added.


Programming Script DM3000.T += "ABC" 'And DM3000.T = DM3000.T + "ABC" Meaning same

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-3


4-1 Assignment Statement

Ƶ Precautions on using assignment statement


ƽ When the type on right side is different from that on left side
SCRIPT SYNTAX AND Precautions

• Assignment statement is FALSE when the types on right side and left side are different (type
conversion cannot be performed).

Programming Script DM1000.T = DM2000.U 'Error


Operation description Assign right DM2000.U (constant: unsigned 16 bit) to DM1000.T (character string type)
(conversion error)

• Even if the types are different, different types .U,.S,.D,.L,.F can also be converted (precision drops
4 sometimes).
Assignment Statement

Programming Script DM1100.U = DM2100.D 'Script alarm grade "high" alarm


Operation description Assign right DM2100.D (unsigned 32 bit) to DM1100.U (unsigned 16 bit). In such a case,
low 16 bit is only assigned to DM2100.D.

Script alarm grade setting "Setting method of warning level", Page 2-41

ƽ When it can not be assigned to left side


• In following script, the left "3" is value, and is not the device storing result and value. So it is incorrect
as assignment statement.

Programming Script 3 = DM1000.U 'Error (can not be assigned to constant)


Operation description Assign right DM1000.U (unsigned 16 bit) to 3 (constant). (conversion error)

• During formula and function programming on the left side, incorrect as assignment statement, error
appears.

Programming Script DM1100.U + 30 = DM1000.U 'Error (can not be assigned to formula)


Operation description Assign right DM1000.U (unsigned 16 bit) to left formula . (conversion error). changes error.

4-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-1 Assignment Statement

MEMO

SCRIPT SYNTAX AND Precautions


4

Assignment Statement

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-5


4-2 Operator
Operators is a data processing symbol, including addition (+), multiplication (*), etc. used in working
equation.
SCRIPT SYNTAX AND Precautions

Operator List

Ƶ Operator type
The operators include the following 4 kinds: "arithmetic operator", "comparison operator", "character
string connection operators", and "logical operator", etc.

Note
4 Operators shall be programed with single byte character.
Operator

ƽ Arithmetic operator
Arithmetic operator can return arithmetic operation result of 2 values.
Symbol Processing content Program example
^*1 Calculate the power DM500 = DM100 ^ 2
* Calculate product of 2 values (multiplication) DM502 = DM100 * 3
/ Calculate quotient of 2 values (division) DM504 = DM100 / 4
MOD*2 Divide 2 values, return remainder DM506 = DM100 MOD 5
+ Calculate summation of 2 values (addition ) DM508 = DM100 + 6
- Calculate difference of 2 values (subtraction) DM510 = DM100 - 7

*1 With the CPU function version 2.0 or higher CPU unit, exponentiation can be used for the .F and .DF
suffixes.
*2 A half-width space is required before and after symbol.

ƽ String Connection Operator


Return connection result of 2 character strings.
Symbols Processing content Program example
&, +*3 Connect 2 character strings DM600.T = "KEY" + "ENCE"

*3 "+" automatically identifies arithmetic operation and character string connection according to
programming contents.

ƽ Comparison operator
Return the evaluation result of size relation of 2 values in Boolean value (ON or OFF).
Symbols Processing content Program example
< Less than MR500 = DM100 < 10
<= Less than or equal to (as follows) MR501 = DM100 <= 20
> Larger than MR502 = DM100 > 30
>= Greater than or equal to (above) MR503 = DM100 >= 40
= Equal to (equivalent) MR504 = DM100 = 50
<> Unequal to (unequivalent) MR505 = DM100 <> 60

4-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-2 Operator

ƽ Logic operator
In case bit relation operation for result of logical operation of 2 values and word relation operation

SCRIPT SYNTAX AND Precautions


Boolean value (ON or OFF), a word value is returned.
Symbol Processing content Program example
NOT*4 Calculat logical NOT of value MR600 = NOT R000
Calculate logical AND of 2 device (bit device
AND*4 MR601 = R000 AND R001
relation, word device relation)
Calculate logical OR of 2 devices (bit device
OR*4 MR602 = R000 OR R001
relation, word device relation)
Calculate exclusive logical OR of 2 devices (bit
XOR*4 MR603 = R000 XOR R001
device relation, word device relation)
*4 1-byte space is required before and after symbol.

Note
4
• To operate device (operate element), please specify the relation of the bit device relation

Operator
or the word device. Do not perform logical operation of bit device and word device, etc.
• When the types and sizes of operation device (operate element) are different, operate
with larger type.
Example) DM1000.U and DM2000.D.... operate with 32 bit type

Operator priority

When multiple operators are used in 1 formula, each operation section of the formula is evaluated (
calculated) according to the specified sequence. This sequence is called operator priority.

Ƶ About order of priority


When different operators are used in a formula, evaluating is perfromed according to the sequence of
arithmetic operator, comparison operator, and logical operator; besides, for arithmetic operator and
logical operator, evaluating is performed according to the high to low sequence.

Order of prionity high Power ^


Minus sign -
Multiplication and division 㪁, /
Arithmetic operator
Remainder operation MOD
Addition and subtraction +, -
String Concatenation +
Equal to, unequal to, =, <>,
Comparison operator Less than, more than, <, >,
Below, above <=, >=
Logic Not NOT
Logic AND AND
Logic operator
Logic OR OR
Order of prionity low Exclusive OR XOR

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-7


4-2 Operator

ƽ The priority between multiplication, division, addition, and subtraction


When multiplication and division (or addistion and subtraction) exist in programming of 1 formula
SCRIPT SYNTAX AND Precautions

calculate according to the sequence (from left to right) of operators. Multiplydivide is precedential in
case of multiplydivide and plus-minus method in programming.

Example) When DM1000 + DM2000 *30 - DM3000/10


Operating sequence 1 : DM2000 * 30 . . . . . . . . . . .result (1)
Operating sequence 2 : DM3000/10 . . . . . . . . . . . . .result (2)
Operating sequence 3 : DM1000 + result (1) . . . . . .result (3)
Operation sequence 4 : result (3) - result (2) . . . . . . .final operation result

4 ƽ Comparison operator priority


The priority of all comparison operators is same. So, when multiple comparison operators are specified
Operator

in 1 formula, evaluating is performed according to the sequence( from left to right) of operators.

Example) When R000 = DM2 > 100 = R1 = FALSE assignment statement


R000 = ( ( (DM2 > 100) = R001) = FALSE) Operation.
Compare sequence 1 : DM2 > 100 . . . . . . . . . . . . . . . . result(1)
Comparison sequence 2 :result (1) = R001 . . . . . . . . . . result (2)
Compare sequence 3 : result (2) = FALSE . . . . . . . . . compare result
Operation 1: compare result (ON during TRUE; OFF during FALSE) assig to R000

ƽ Logic operator priority


Device actual application example as follows.

Example) When R1000 = R000 OR R001 AND DM0 = 100 assignment statement
R1000 = (R000 OR (R001 AND (DM0 = 100) ) ) Operation.
Operation sequence 1 : DM0 = 100 comparison (ON or OFF) . . . . . .compare result (1)
Operation sequence 2 : Compare result (1) and R001 logical AND . . . .result (2)
Operation sequence 3 : Result (2) and R000 logical OR . . . . . . . . . . .result (3)
Operation sequence 4 : Assign result (3) to R1000

ƽ Change priority
(if using parentheses () ), operation in "( )" is implemented before outer operation, so, priority can be
changed, the part with woking equation is firstly evaluated. The priority of operators is kept in "( )" .

Example) When DM5000 = DM3000 * (DM3001 + (DM3002 + DM3003 * 5) / 10)


Operating sequence 1 : DM3003 * 5 . . . . . . . . . . . . .result (1)
Operating sequence 2 : DM3002 +result (1) . . . . . .result (2)
Operating sequence 3 : Result (2) / 10 . . . . . . . . . . .result (3)
Operating sequence 4 : DM3001 + result (3) . . . . .result (4)
Operating sequence 5 : DM3000 * result (4) . . . . . .Operating result
Operation sequence 6 : Assign operation result to DM5000

TIP Complicated programming operation and immethodical operation, is unrelated to the priority of
operators, use "()" to clarify the programming operaton step, improve maintenance (reading).

4-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-2 Operator

Differences between assignments statements and compare operators

SCRIPT SYNTAX AND Precautions


Although the symbols (=) used by assignment statement and comparison operator are same, its meanings
(application methods) are different.

• (statement) including statement of (=).......... assignment as assignment is TRUE


Meaning : assign the result (value) on the right to the left

Example) 1 SELECT CASE DM2000 'SELECT control statement


2 CASE 1
3 DM1000 = 100 'Separately used as processing statement
4 CASE 2 4
5 DM3000 = DM1000 + 5 'Separately used as processing statement

Operator
6 END SELECT

• As comparison operator (=) .......in statement including comparison operator, the statement is FALSE
(process as a part of control statements such as conditional branch
statements)
Meaning: compare right side and left side, identify ON (TRUE) or
OFF (FALSE)

Example) 7 IF DM1000 = 100 THEN 'A part of control statement (IF statement)
8 BMOV(DM10,DM20,4) 'Processing statement
9 END IF

* although same "DM1000 = 100 " is programed on the 3 rd line of assignment statement example and on the
7th line of comparison operator example, its meanings are different.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-9


4-3 Control Statement
Control statement is used to change the flowing direction of program, and, where applicable, enable
processing flow branching or looping, change execution selection and the number of execution.
SCRIPT SYNTAX AND Precautions

Control Statement List

Control statements include 2 types: "conditional branch statement" and "loop control statement".

Ƶ Conditional branch statement


Conditional branch statements enable processing flow branching according to the specified condition.
Control
4 statement
Content of control

(1) Execute branch control statement according to conditional formula


Control Statement

• If conditional formula A is TRUE,


IF Conditional formula A THEN
processing statement B will be executed. If
Processing statement B
conditional formula A is FALSE, any
END IF
processing will not be performed.

(2) Dual branch control statement shall be separately processed according to conditional
formula

IF Conditional formula A THEN


• If conditional formula A is TRUE,
Processing statement B
processing statement B will be executed. If
IF statement ELSE
conditional formula A is FALSE, processing
Processing statement C
statement C will be executed.
END IF

(3) Execute multiple branch control statements according to multiple conditional formula

IF Conditional formula A THEN


• If conditional formula A is TRUE, processing
Processing statement B
statement B will be executed. conditional
ELSE IF conditional formula 2THEN
formula A is FALSE, conditional formula C is
Processing statement D
TRUE, processing statement D is executed.
ggg

• If conditional formula A. C are FALSE, any


processing will be not performed.
ENDǂIF

According to conditional value, select corresponding processing, execute multiple branch


control statement

SELECT CASE compare source


CASE Conditional value A • If compare source and conditional value A
Processing statement B are same, processing statement B will be
SELECT
CASE Conditional value C performed. If compare source and
statement
Processing statement D conditional value C are same, processing
statement D will be performed.
g
gg

• If compare source is not conditional value


CASE ELSE A, C, etc., processing statement E will be
Processing statement E performed.
END SELECT

master control statement

• If conditional formula A is TRUE,


MC statement MC Conditional formula A THEN processing statement B will be executed. If
Processing statement B conditional formula A is FALSE, processing
MCR statement B will be executed under OFF
condition.

4-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Ƶ Loop control statement


Loop control statement is processed according to the specified conditional loop.

SCRIPT SYNTAX AND Precautions


Control
Content of control
statement
The statement is a loop control statement for loop process before the conditional formula of
the number specified is TRUE

FOR statement FOR initial value TO final value STEP


• From initial value to final value, and also an
incremental value
incremental value , loop execution of
Processing statement A
processing statement.
NEXT

The variable number of loop control statement in loop process during conditional formula is
TRUE 4
WHILE

Control Statement
statement WHILE conditional formula
• Loop execution of processing statement
Processing statement
during conditional formula is TRUE.
END WHILE

The variable number of loop control statement in loop process before conditional formula is
TRUE
DO statement DO
• Loop execution of processing statement
Processing statement
during conditional formula is FALSE.
UNTIL conditional formula

In loop control statement, unrelated to loop condition, exit from loop control

<loop processing statement>


ggg

BREAK
• After BREAK execution, loop control
statement
BREAK including BREAK is ended irrespective
ggg

condition.

<loop processing statement>

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-11


4-3 Control Statement

IF to Statement (Conditional Branch (1))


SCRIPT SYNTAX AND Precautions

IF statement is the most simple conditional branch statement to identify processing or not according to
conditional formula.
IF to THEN to ELSE to END IF
Basic format Format description
IF <Conditional formula> THEN If conditional formula is TRUE, processing statement
<Processing statement 1> Processing statement 1 will be executed.
END IF IF statement end

4 * Indicates inserting 1-byte space.


ǂ Indicates that line feed must be made at the mark.
Control Statement

Format example Explanation


IF R1000 = ON THEN 'If R1000 is ON,
DM1000 = DM1000 + 1 'Constant 1 added to DM1000.
END IF

Tip

• If the result of conditional formula is bit (return Boolean value) formula, it can be used in any formula.
• Processing statement is a series of programming processing between THEN to END IF, and can be
programmed among multiple lines if required.
• IF statement can be nested, multiple-branch processing can then be conducted by programming IF
statement in processing statement and selecting AND condition.

TIP Up to 200 layers are available for the IF statement nesting (program IF statement in IF
statement).
"About control statements nesting", Page 4-32.

4-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) Identify "TRUE" or "FALSE" via
(1)
When condition is FALSE
conditional formula.
(When conditional
Conditional equation is FALSE) (2) If conditional formula to "TRUE",
equation (3)
(TRUE or FALSE)
FALSE processing statement follwing THEN will
(2) be executed, and END IF executed.
When condition is TRUE TRUE (3) if conditional formula is "FALSE", jump to
(When conditional
equation is TRUE) END IF , any operation is not executed,
processing after jump to END IF.
THEN processing ELSE processing
statement 1 statement 2
4

Control Statement
IF statement end

Programming example

Programming Script IF (10 <= DM1000) AND (DM1000 <= 50) THEN 'if DM 1000 is more than 10 or
less than 50

FM1000.T = "within the range" 'specifies that the character string


'is saved to FM 1000.T

END IF 'IF statement end

Operation description If DM1000 value is more than 10 and less than 50, character string "within range" is stored
into FM1000.T.
If the value is out of the range, any operation will be not executed.

TIP The part from (single quote) (or "REM") to the end of line( before line feed input) is processed
as comment. So there is no any influence on actual operation.
For details of comment writing, see "About Comments Function", Page 2-56

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-13


4-3 Control Statement

IF to ELSE Statement (Conditional Branch (2))


SCRIPT SYNTAX AND Precautions

The statement refers to a simple conditional branch statements dividing 1 conditional formula into 2
processing methods.
IF to THEN to ELSE to END IF
Basic format Format description
IF <Conditional formula> THEN If conditional formula is TRUE,
<Processing statement 1> processing statement 1 will be executed.
ELSE If conditional formula is FALSE,
<Processing statement 2> processing statement 2 will be executed
4 END IF IF statement end
Control Statement

* Indicates inserting 1-byte space.


ǂ Indicates that line feed must be made at the mark.

Format example Description


IF R1000 = ON THEN 'If R1000 is ON,
DM2000 = 50 'then constant 50 is stored in DM2000.
ELSE 'If R1000 is OFF,
DM2000 = 10 'then constant 10 is stored in DM2000.
END IF

Tip

• If the result of conditional formula is bit (return Boolean value) formula, it can be used in any formula.
• Processing statement is a series of programming processing between THEN to END IF, capable of
programming among lines if required.
• IF statement can be nested, so multiple-branch processing can be conducted by programming IF
statement in processing statement and selecting AND condition.

TIP IF statement nesting (program IF statement in IF statement), maximal upto 200 layers.
"About control statements nesting", Page 4-32.

4-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) Identify "TRUE" or "FALSE" via conditional
(1)
When condition is FALSE
formula.
(When conditional
Conditional equation is FALSE) (2) If conditional formula is "TRUE", processing
equation (3)
(TRUE or FALSE)
FALSE statement 1 below THEN will be executed,
(2) and jump to END IF( middle formula will
When condition is TRUE TRUE be not executed).
(When conditional
equation is TRUE) (3) If conditional formula is "FALSE", the

ELSE processing
program between THEN to ELSE will be
THEN processing
statement 1 statement 2 not executed, but processing statement
2 below ELSE will be executed. 4

Control Statement
IF statement end

Programming example

Programming Script IF R1000 THEN 'If R1000 is ON (the abbreviated form


'for R1000= ON)
DM1000.F = COS (DM1100) 'COS function will be processed.
ELSE 'if R1000 is not ON (OFF),
IF R0002 THEN 'nested IF statement: if R0002 is ON,
DM1000.F = SIN (DM1100) 'SIN function will be processed.
ELSE 'if R0002 is OFF,
BMOV (DM5000,DM5500,10) 'BMOV function will be processed
END IF 'nested IF statement ends
END IF 'IF statement end

Operation description If contact R1000 is ON, COS (DM1100) result will be stored in DM1000.F.
If contact R1000 is not ON (OFF), and contact R0002 is ON, return value of SIN (DM1100)
will be stored in DM1000.F.
If R1000 is not ON (OFF), and R0002 is also not ON (OFF), BMOV function will be used to
transfer 10 word data of DM5000 to DM5500.

"SIN", Page 7-106


"COS", Page 7-108
"BMOV", Page 7-2

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-15


4-3 Control Statement

IF to ELSE IF Statement (Conditional Branch (3))


SCRIPT SYNTAX AND Precautions

If the initial conditional formula is not met, it will be identified again according to the next conditional
formula. The conditional branch statement may have multiple conditions.
IF to THEN to ELSE IF to END IF
Basic format Format description
IF <Conditional formula 1> THEN If conditional formula 1 is TRUE
<Processing statement 1> processing statement 1 will be performed.
ELSE IF <Conditional formula 2> THEN If conditional formula 1 is FALSE, conditional formula 2 is TRUE,
<Processing statement 2> processing statement 2 will be performed.
4 ELSE IF <Conditional formula 3> THEN If conditional formula 1.2 is FALSE, conditional formula 3 is TRUE, *2
ggg

ggg

ggg
Control Statement

ELSE*1 If all conditional formula are FALSE,


< Processing statement n >*1 processing statement n will be executed.
END IF IF statement ends here.

* Indicates inserting 1-byte space.


ǂ Indicates that line feed must be made at the mark.
* 1 "[]" can be omitted.
* 2 You can set any counter maximal value. There is no upper limit.

Format example Explanation


IF R1000 THEN 'If R1000 is ON (the abbreviated form for R1000 = ON)
DM1000 = 1000 '1000 is saved into DM1000.
ELSE IF R1001 THEN 'If R1000 is not ON, R1001 is ON,
DM1000 = 1001 '1001 is saved into DM1000.
ELSE IF R1002 THEN 'If R1000, R1001 are not ON, R1002 is ON,
DM1000 = 1002 '1002 is saved into DM1000.
ELSE IF R1003 THEN 'If R1000, R1001, R1002 are not ON, R1003 is ON,
DM1000 = 1003 '1003 is saved into DM1000.
ELSE IF R1004 THEN 'If R1000, R1001, R1002, R1003 are not ON, R1004 is ON,
DM1000 = 1004 '1004 is saved into DM1000.
ELSE 'If R1000, R1001, R1002, R1003, R1004 are not ON,
DM1000 = 1005 '1005 is saved into DM1000.
END IF

Tip

• If the result of conditional formula is bit ( return Boolean value) formula, it can be used in any formula.
• Processing statement is a series of programming processing between control statements, capable of
programming among lines if required.
• ELSE IF statement is differnt from IF statement, multiple lines are programmable, but it is not a nesting structure.

4-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) When condition is FALSE
(When conditional
Conditional equation 1 is FALSE)
equation 1
(TRUE or FALSE)
(3)
FALSE
(2) When condition is FALSE
TRUE (When conditional
Conditional equation 2 is FALSE)
When condition is TRUE equation 2
(When conditional
(5)
(TRUE or FALSE)
equation 1 is TRUE) FALSE
(4) When condition is FALSE
(When conditional
TRUE Conditional equation 3 is FALSE)
THEN processing
statement 1
When condition is TRUE
(When conditional
equation 3
(TRUE or FALSE)

(6)
(7)
FALSE 4
equation 2 is TRUE)

Control Statement
TRUE When condition is TRUE
THEN processing (When conditional
equation 3 is TRUE)
statement 2


THEN processing
statement 3
IF statement end

(1) Identify "TRUE" or "FALSE" via conditional formula 1.


(2) If conditional formula is "TRUE", processing statement 1 below THEN will be executed, and jump to
END IF( middle formula will be not executed).
(3) If conditional formula is "FALSE", "TRUE" or "FALSE" will be identified with conditional formula 2.
(4) If conditional formula 2 is "TRUE", processing statement 2 will be executed, and jump to END IF
(middle formula is not executed).
(5) If conditional formula 2 is "FALSE", "TRUE" or "FALSE" will be identified with conditional formula 3.
(6) If conditional formula 3 is "TRUE", processing statement will be executed, and jump to END IF
(middle formula is not executed).
(7) If conditional formula 3 is "FALSE", "TRUE" or "FALSE" will be identified with conditional formula,
and the like.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-17


4-3 Control Statement

SELECT CASE to Statement (Multi-branch control)


SCRIPT SYNTAX AND Precautions

The conditional branch statements can be processed according to the value stored in reference word
device.
SELECT CASE to
Basic format Format description
SELECT CASE Word device According to the value of word device, conditional branch
CASE Constant 1*ˏ If constant 1 and word device value are same,
Processing statement 1 processing statement 1 will be performed.
CASE Constant 2 If constant 2 and word device value are same,
4 Processing statement 2 processing statement 2 will be performed.
CASE Constant 3 If constant 3 and word device value are same, *2
Control Statement

gg

gg

gg
g

g
CASE ELSE*1 If constant and word device value are not same, the
Processing statement n*1
processing statement will be performed.
END SELECT
SELECT statement ends heve.

* Indicates inserting 1-byte space.


ǂ Indicates that line feed must be made at the mark.
* 1 Can be omitted.
* 2 Up to 200 CASE constants ( ELSE ) can be programed.
* 3 A character string, device which handles a character string, or a bit type device cannot be specified for
constant 1.

Format example Explanation


SELCT CASE DM1000 'With DM1000 store value as basis
CASE 1 'If DM1000 = 1,
DM2000 = 1000 '1000 is saved into DM2000.
CASE 2 TO 10 'If DM1000 = 2 to 10,
DM2000 = 2000 '2000 is saved into DM2000.
CASE 11,15,60 'If DM1000 = 11 or 15 or 60,
DM2000 = 3000 '3000 is saved into DM2000.
CASE IS > 100* 'if DM1000 exceeds 100,
DM2000 = 4000 '4000 is saved into DM2000.
CASE ELSE 'If DM1000 value is the value other than above,
DM2000 = 5000 '5000 is saved into DM2000.
END SELECT

* The conditional formula using comparison operator can be writen into the constant part. In this case, " IS"
is used for comparison.
(example) IS >= 100 ( more than 100), IS < > 30 ( values other than 30)

4-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) The declaration acts as the identification
Comparison source
(word device) reference value of conditional value.
(1) (2) Compare conditional value 1 and compare
source, if "conditional value 1 = compare
When comarison source
CASE equals conditional value 1 source" is TRUE, processing statement 1 will
conditional (2) Processing be executed. After executing processing
value 1 statement 1
statement 1, jump to END SELECT.
(3)
When comarison
(3) If "conditional value 1 = compare source"
source ≠ conditional is FALSE, transfer to compare the next
value 1 When comarison source
equals conditional value 2
conditional value. 4
CASE (4) Compare conditional value 2 and compare
Processing

Control Statement
conditional (4)
value 2
statement 2 source, if "conditional value 2 = compare
(5) source" is TRUE, processing statement 2 will
When comarison
source ≠ conditional be executed. Execute processing statement
value 2
When comarison source 2, then, jump to END SELECT.
CASE equals conditional value 3 (5) If "conditional value 2 = compare source"
conditional (6) Processing
is FALSE, transfer to compare the next
value 3 statement 3
(7) conditional value.
When comarison (6) Compare conditional value 3 and compare
source ≠ conditional
source, if "conditional value 3 = compare
value 3
source" is TRUE, processing statement 3 will
CASE ELSE processing be executed. Execute processing statement
statement 4
3, then, jump to END SELECT.
(7) If "conditional value 3 = compare source" is
SELECT statement end
FALSE, perform processing statement 4.

Tip

• The selected constant may be single constant, or multiple specifying and range specifying constants.
Example) CASE 1 . . . . . . . . . . . . .Single specifying (only 1)
CASE 3,9,12,50 . . . . . . . . . . .Multiple specifying (3, 9, 12 or 50)
CASE 8 TO 20 . . . . . . . . . . . .Range specifying ( above 8, below 20)
CASE IS>=100 . . . . . . . . . . . .Use comparison operator specifying range( above 100)
• CASE ELSE <Processing statement >script can be omitted.
But CASE ELSE of " all CASE conditions are FALSE " can help solving the accident.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-19


4-3 Control Statement

Reference script example


SCRIPT SYNTAX AND Precautions

• Count the number of workpieces dropped out from belt conveyer. When workpiece falls into the
case, "1" is added to Good Counter( DM1000).
After reaching 100 good articles, the case is changed. When reaching 200, the bell rings, and the
case is changed. When 300, the alarm sounds, operation is shut off, and the Good Counter is reset.

[reference script example]

IF LDP(R000) = ON THEN 'If workpiece drop sensor ( R000) is ON,


DM1000 += 1 'Good counter (DM1000) plus _1
4 END IF
SELECT CASE DM1000 'Compare source is DM1000
Control Statement

CASE 100 'If DM1000 value reaches 100,


"change box"
CASE 200 'If DM1000 value reaches 200,
"bell ringing"
"change box"
CASE 300 'If DM1000 value reaches 300,
"alarm ringing"
"shutdown"
DM1000 = 0 'Reset DM1000 value.
CASE ELSE 'If DM1000 value is the value other than 100, 200, 300,
"display in operation"
"warning blue lamp lit"
END SELECT 'SELECT CASE statement ends

Sensor for defective judgment

Defective
dischargeing
LED column

Sensor for
workpieces fall NG

OK OK OK
100pcs 100pcs 100pcs

4-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Note
If the selected constants are multiple, the processing statement written on the upper line is

SCRIPT SYNTAX AND Precautions


firstly executed; the processing statement written later will be not executed.

Programming Script SELECT CASE DM1000 'Set selection reference to DM1000.


CASE 1 'If DM1000 value is "1",
Processing statement 1
CASE 3 TO 20 'If DM1000 value is above 3, below 20,
Processing statement 2
CASE IS >= 15 'If DM1000 value is more than 15
Processing statement 3
CASE ELSE 'If DM1000 value is the value other than above, 4
Processing statement 4

Control Statement
END SELECT

* if the value stored in DM1000 (compare source) is 17, the 2nd CASE and the 3rd CASE,
will be matched. In this case, the 2nd CASE is given the priority for selection, and
processing statement 2 will be executed. After processing statement is exeucted, END
SELECT is jumped to, and processing statement 3 is not executed.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-21


4-3 Control Statement

MC to MCR Statement (Master control)


SCRIPT SYNTAX AND Precautions

The script is used to program Master Control.


For action of Master Control, see "KV-5500/5000/3000/1000 Instruction Reference Manual".

MC to THEN to MCR
Basic format Format description
MC < MC Execution condition > THEN If MC execution condition is TRUE, master control
processing will be conducted.
<Processing statement 1> Execute processing statement.

4 MCR If MC execution condition is FALSE, processing


statement will be executed in OFF status. 1
Control Statement

* About the status of every function, see the following table.


ǂ This is a line feed symbol.
*1 For function status, see the following table:

Format example Explanation


MC R1000 THEN 'If R1000 is ON, Master Control processing will be conducted.
R0500 = ON 'Execute after setting R0500 to ON
MCR 'If R1000 is OFF, set R0500 to OFF before execution.

If MC execution condition is OFF, the function between MC to MCR will be executed in OFF status.
For details please refer to "KV-5500/5000/3000/1000 command reference manual", MC, MCR command.

Tip

• If conditional formula result is the bit type (return Boolean value), MC execution condition can be used in any
format.
• Processing statement is a series of programming processing between MC to MCR, which can be
used in programming multiple lines if required.

4-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) (1) Identify "TRUE" or "FALSE" via MC execution
condition, determine MC to MCR processing
MC execution FALSE method.
conditon (3) (2) If execution condition is "TRUE", processing
(TRUE or FALSE)
statement below THEN will be executed.
(2)
TRUE
(3) If conditional formula is "FALSE", will be
When execution conditon When execution conditon executed after processing statement
is TRUE (when execution is FALSE (when execution below THEN is set to OFF.
conditon is TRUE) conditon is FALSE)

Setup processing
4
Execute THEN
statement as OFF

Control Statement
processing statement
then execute

MC to MCR statement end

Note
Up to 16 layers are available for MC to MCR statement composition nesting (program MC to
MCR statement in MC to MCR statement).
"About control statements nesting", Page 4-32.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-23


4-3 Control Statement

FOR to NEXT Statement ( specified loop control times)


SCRIPT SYNTAX AND Precautions

According to loop condition, the control statement processing the number of statement executed is
determined.
FOR to NEXT
Basic format
1 FOR <Word device>=<Initial value > TO <Final value >[ STEP <incremental value >]*1
2 <Processing statement>
3 NEXT

4 Format description
1 gDetermine initialization and termination value of word device limiting the number of loop controls.
Determine how many word device values willbe added to every processing via STEP (the line is
Control Statement

2 not added)
3 gThe processing statement will be executed before word device exceeds final value.
gPlus incremental value to word device.

*1 Programming in [ ] can be omitted. If omitted, will be executed as STEP 1.


About the status of every function, see the following table.
This is a line feed symbol.

Format example Explanation


FOR DM1000 = 0 TO 100 STEP 5 DM1000 value loop s from 0 to more than 100.
DM2000 = DM2000 + 5 Plus 5 to DM2000 and store to DM2000
Add incremental value 5 to current value of DM1000, return
NEXT FOR to

Tip

Multiple elements are programed on the 1st line of format example. It shall be described separately.

Row 1: (14&/6156'2
(4) (1) (2) (3)

(1) The specified word device can use any content. The initial value needs to be stored first. The initial
value is only processed in the first time of executing FOR to NEXT statement.
(2) Specify the final value. FOR to NEXT identifies whether the value of word device exceeds final
value, and branches the "execute processing statement (the final value is not exceeded)" and
"terminating loop control (the final value is exceeded)" .
(3) Incremental value can be omitted. "STEP 1" will be processed when omitted. The incremental
processing of the word device specified is not executed in the first time. The execution sequence is
before NEXT statement( the 3rd line of format example).
(4) Identify whether the value of word device specified meets the conditions.

TIP According to constant symbol of STEP program, automatically identify "final value" and "word
device final value".
Example) FOR DM1100 = 100 TO 0 STEP - 5
Subtract 5 from 100, the value stored in DM1100 before 0.

4-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Processing flow

SCRIPT SYNTAX AND Precautions


(1) (1) Assign the initial value to word device.
(2) Set final value indicating the end of loop
Evaluate default value
to FOR word device process. Besides, set the incredent
(initialization process) value added on the value of word device.
(2) (3) Identify whether the value of word device
Setup final and addtion is less than final value.
value (increment value)
(4) If (3) condition is "TRUE", processing
of word device
statement will be executed.
(3) (5) If " FALSE", loop process statement will
be terminated. 4
FALSE Value of word
(6) Plus incremental value to the value of

Control Statement
device final
(5) value (TRUE or FALSE) word device, and return (3).

TRUE
(4)

Execute processing statement

(6)
NEXT
Add increment
to word device

Next

Note
If programming single precision floating point type real number on added value( incremental
value), suffix .F shall be added on the specified word device.

Example) when setting the value to "0.5"


FOR DM2000.F = 0 TO 100 STEP 0.5 ' DM2000 must be .F
gg
g

TIP FOR to NEXT NEXT statement will execute following processing.


• Specify word device +=incremental value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-25


4-3 Control Statement

Precautions on Using FOR to NEXT statement


SCRIPT SYNTAX AND Precautions

ƽ The range that can be specified with STEP


In programming of FOR to NEXT statement, the incremental value specified by STEP is as follows.

The range that can be specified by STEP : -32767 to 32767 (-32768 cannot be specified)

If the range value is specified, error will occur during script conversion.

ƽ When specifying single precision floating point type constant with STEP
4 The constant with decimal point can be specified with incremental value specified by STEP, but, shall
be noted.
Control Statement

The constant with decimal point is automatically converted to single precision floating point type real
number. In this case, some error will occur, error will also occur in loop index sometimes.

Programming example

ƽ When FOR to NEXT statements are imperatively ended


Before meeting condition set by FOR to NEXT statement, when loop control statement is imperatively
ended with other conditions, BREAK statement will be used.

Programming Script FOR DM1000 = 0 TO 1000 STEP 10 'Before DM1000 value exceeds 1000
'loop
DM2000 += 9 'DM2000 value plus 9 every time
IF DM2000 > 100 THEN 'DM2000 value exceeds 100
BREAK 'Terminate the loop control
END IF 'IF statement end
NEXT 'Add incremental value, return FOR to

For details, see "BREAK Processing", Page 4-31.

Note
A script should be programmed in the loop control statement to end loop process.
If the loop processing is not stopped, this then becomes "infinite loop" (permanent loop
processing) and scanning timeout occurs during program execution (infinite loop is not
detected as error during conversion).
"loop control statement and processing time", Page 4-35.

Up to 100 layers are available for nesting of FOR to NEXT statement.


"About control statements nesting", Page 4-32.

4-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

WHILE Statement (pre-judge loop control)

SCRIPT SYNTAX AND Precautions


When loop condition is "TRUE", execute control statement of loop process.
WHILE TO END WHILE
Basic format Format description
WHILE < conditional formula> If conditional formula is TRUE, *1

<processing statement>
executes processing statement.
END WHILE Return to the line start (WHILE).

* Insert a half-width space.


ǂ This is a line feed symbol.
*1 If conditional formula is FALSE, loop process will be terminated.
4

Control Statement
Format example Explanation
WHILE DM1000 < 100 If DM1000 value is less than 100, * 2
DM1000 += 5 'Plus 5 to DM1000.
END WHILE Return to the line start (WHILE)

*2 If DM1000 value is above 100, the processing statement will be not executed, will be executed from the
next line of END WHILE.

Hint

• If the result of conditional formula is bit (return Boolean value) formula, it can be used in any formula.
• Processing statement is a series of programming processing between WHILE to END WHILE,
capable of programming among lines if required.

TIP In loop control statement of WHILE statement/DO to UNTIL statement, maximal 199 layers
are programmable for nesting of combination composition.
Combination and nesting via master control and IF statement can be also conducted.
"About control statements nesting", Page 4-32.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-27


4-3 Control Statement

Processing flow
SCRIPT SYNTAX AND Precautions

(1) Identify " TRUE " or "FALSE" with WHILE


(1)
execution condition, determine processing

OFF
method of WHILE to END WHILE.
WHILE execution
(3) conditon (TRUE or FALSE) (2) If execution condition is "TRUE",
processing statement will be executed,
(2)
and return (1)
TRUE
(WHILE statement start).
When execution conditon When execution conditon
is false (when execution is true (when execution (3) If conditional formula is "FALSE"
conditon is FALSE) conditon is TRUE) END WHILE statement will enter the next
4 step.
Execute processing
Control Statement

statement

END WHILE

WHILE statement end

Next

Programming example

ƽ When WHILE statement is imperatively terminated


In WHILE to END WHILE statement, before meeting loop termination condition, to imperatively
terminate loop control statement with other conditions, use BREAK statement.
Programming Script From loop control statement, exit via BREAK statement
WHILE R1000 = OFF 'During R1000 is OFF (condition is on
'TRUE)), loop
IF (DM2000 MOD 8) = 0 THEN 'If DM2000 becomes a multiple of 8, then
ZRES(DM1000, DM1100) 'DM1000 to DM1100 is reset
ELSE IF DM2000 > 100 THEN 'If DM2000 value exceeds 100
BREAK 'Terminate the loop control
END IF 'IF statement end
DM2000 += 1 'Plus 1 to DM2000
END WHILE 'Return WHILE to

For details, see "BREAK Processing", Page 4-31.

Note
A script should be programmed in the loop control statement to end loop control.
If the loop processing is not stopped, this then becomes "infinite loop" (permanent loop
processing) and scanning timeout occurs during program execution (infinite loop is not
detected as error during conversion).
For details, see "loop control statement and processing time", Page 4-35.

4-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

DO to UNTIL Statement (Post Identification Loop Control)

SCRIPT SYNTAX AND Precautions


When loop condition is "FALSE", execute control statement of loop process.
DO to UNTIL
Basic format Format description
DO Perform loop control
Perform Processing statement
<Processing statement>
If conditional formula is FALSE, return to statement
UNTIL < conditional formula>
start (DO).*1

* Insert a half-width space.


ǂ This is a line feed symbol.
4
*1 If the conditional formula is FALSE, loop control is then ended.

Control Statement
Format example Explanation
DO 'process at the start of next step.
DM1000 += 5 'Plus 5 to DM1000.
UNTIL DM1000 >= 100 If DM1000 value is not above 100, return to sentence leading (DO). *2

*2 If DM1000 value is above 100, processing statement will be not executed, the execution will start from
the next line of UNTIL.

Hint

• If the result of conditional formula is bit (return Boolean value) formula, it can be used in any formula.
• Processing statement is a series of programming processing between DO to UNTIL, capable of
programming among lines if required.
• As the action (loop process) control statement identical to DO to UNTIL statement, can use WHILE
statement.
• DO to UNTIL statement is firstly processed, then conditional formula identified. loop identification
condition FALSE .
For details, see "WHILE Statement (pre-judge loop control)", Page 4-27.

Note
In loop control statement of WHILE statement/DO to UNTIL statement, maximal 199 layers
are programmable for nesting of combination composition.
Combination and nesting via master control and IF statement can be also conducted.
For details, see "About control statements nesting", Page 4-32.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-29


4-3 Control Statement

Processing flow
SCRIPT SYNTAX AND Precautions

(1) Execute processing statement.


(1) (2) Identify "TRUE" or "FALSE" via DO
Execute processing execution condition, determine DO to
statement UNTIL processing method.
(2) (3) If conditional formula is "FALSE", return
to (1) (DO to UNTIL statement leading).
TRUE DO execution
(4)conditon (TRUE or FALSE) (4) If conditional formula is "TRUE", will
enter next step.
(3)
4 FALSE

When execution conditon When execution conditon


Control Statement

is TRUE (when execution is FALSE (when execution


conditon is TRUE) conditon is FALSE)

DO to UNTIL statement end

Next

About difference between WHILE statement between DO statement

The control statements that imply the same actions as those implied by DO ~ UNTIL statement can use
WHILE statement.
The difference as follows
WHILE statement DO statement
1. Identification of conditional formula 1. Execute loop process statement
(TRUE or FALSE) 2. Identification of conditional formula
Sequence different
2. Execute loop process statement (TRUE or FALSE)
3. Return to sentence leading 3. Return to sentence leading
Identification of conditional perform repeatedly when condition is perform repeatedly when condition is
formula different "TRUE" "FALSE"

For details, see "WHILE Statement (pre-judge loop control)", Page 4-27.

WHILE statement .............primary loop control statement (primary processing statement will be not
executed according to conditions)
DO statement ...................post identification loop control statement (1 processing statement must be
performed)

Note
A script should be programmed in the loop control statement to end loop control.
If the loop processing is not stopped, this then becomes "infinite loop" (permanent loop
processing) and scanning timeout occurs during program execution (infinite loop is not
detected as error during conversion).
"loop control statement and processing time", Page 4-35

4-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

BREAK Processing

SCRIPT SYNTAX AND Precautions


It is used in force termination of loop control (exit from loop).
BREAK
Basic format Format description
<loop control statement start> Program in loop process *1
BREAK Force termination of the loop process
<loop control statement end>
loop control statement end

* Indicates that line feed must be made at the mark.


*1 BREAK must be programmed in loop process statement. 4
Format example Explanation

Control Statement
FOR DM1000 = 0 TO 50 STEP 2 'DM1000 from 0 to 50, loop.
DM2000 += 5 'Plus 5 to DM2000.
IF DM2000 > 70 THEN 'If DM2000 value exceeds 70,
BREAK 'Imperatively terminate loop control (FOR TO NEXT statement).
END IF 'IF statement end.
NEXT 'Plus 5 to DM1000, return to sentence leading of FOR statement.
*Except FOR TO NEXT, loop process statement can be also used in WHILE statement, DO TO UNTIL statement.

Note
BREAK must be written inside loop process statement.
If it is written outside the loop process, conversion error will occur.

Programming example

When BREAK statement is programmed in the nested loop control statement, the loop control
statement with BREAK programming is only terminated.

Programming Script FOR DM1000 = 1 TO 100 STEP 3 'FORstatement (1)


FOR DM2000 = 1 TO 100 STEP 3 'FORstatement (2)
FOR DM3000 = 1 TO 100 STEP 3 'FORstatement (3)
DM4000 = DM1000 + DM2000 + DM3000 'Processing statement
IF DM4000 > 100 THEN 'BREAK Execution condition
BREAK
END IF
NEXT 'When Break excute,
'FOR statement (3) End.
NEXT
NEXT

Operation description FOR statement (3)


contains control statement of BREAK statement, so, only FOR statement (3)
is terminated during execution of BREAK .
"Precautions on Using Control Statement", Page 4-32.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-31


4-3 Control Statement

Precautions on Using Control Statement


SCRIPT SYNTAX AND Precautions

About control statements nesting

Control statement can be processed in conditional branch processing and loop process, so that other
conditional branch and loop process can be performed.

Ƶ Control statements nesting


Nesting means that a case is embedded into another case, other loop control statement is programmed
4 in a loop control statement, thus forming a multi-layer control block. In the following example, FOR
statement (2) is nested in FOR statement (1), and then 3 layers of FOR statement (3) are nested in it.
Control Statement

"nest programing example"

FOR <value of word device (1)> TO <end value> FOR statement (1) ǂǂ
Processing statement
ǂǂǂǂFOR <value of word device (2)> TO <end value> FOR statement (2)

1 layer
2 layer
ǂǂǂǂǂProcessing statement

3 layer
ǂǂǂǂǂ FOR <value of word device (3)> TO <end value> FOR statement (3)
ǂǂǂǂǂǂProcessing statement
ǂǂǂǂǂ NEXT
ǂǂǂNEXT
NEXT

ƽ Precautions on use of nesting


All conditional branch statements and loop control statements can be nested, but with the following limit.
• FOR statement is limited on separate layer, maximal 100 layers can be nested.
• WHILE statement, DO statement are limited on separate layer, maximal 199 layers can be nested.
• Conditional branch statements (IF statement, SELECT statement) with separate layer limit, maximal
200 layers can be nested.
• Master control with separate layer limit, maximal 16 layers can be nested.
• Nest is required in control block*(layer), control block cross programming is not allowed.
* The script from start to end of IF to END IF or FOR to NEXT control statements, etc. is called control block.

Note
In case of multi-nesting, the program will be difficult to be understood. Besides, scanning
time will be also increased, so multi-nesting shall be avoided as possible.

4-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Note
Programming cannot be made under the following loop control statement or conditional

SCRIPT SYNTAX AND Precautions


branch or loop control statement and conditional branch statement cross.

[[FOR statement (loop control statement) and WHILE statement (loop control statement)
cross]

FOR <value of word device (1)> TO <end value> 'Control statement (1)
ǂǂProcessing statement (1)
ǂǂFOR <value of word device (2)> TO <end value> 'Control statement (2)
ǂǂǂǂǂProcessing statement (2)
ǂǂǂǂǂWHILE <condition equation > 'Control statement (3) 4
ǂǂǂ Processing statement (3)

Control Statement
ǂǂNEXT
ǂǂǂǂǂEND WHILE
NEXT

Control Block Cross

[[FOR statement (loop control statement) and IF statement (conditional branch statements)
cross]

FOR <value of word device (1)> TO <end value> 'Control statement (1)
ǂǂǂProcessing statement (1)
ǂǂǂFOR <value of word device (2)> TO <end value> 'Control statement (2)
ǂǂǂǂǂǂProcessing statement (2)
ǂǂǂǂǂǂIF <conditional equation> THEN 'Conditional branch statement
ǂǂǂǂǂǂǂProcessing statement (3)
ǂǂǂNEXT
ǂǂǂǂǂǂEND IF
NEXT

Control Block Cross

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-33


4-3 Control Statement

Ƶ Actual nesting actions


Establish the following processing programs.
SCRIPT SYNTAX AND Precautions

Example
The 3-layer nesting using loop control statement (FOR statement, WHILE statement, do
statement) is produced to calculate the number of actual processings.
Programming Script DM1000 = 0 'Clear the counter for the number of processing.
FOR DM2000 = 1 TO 10 'DM2000 loop s from 1 to 10
'--- FOR loop :10 times
DM3000 = 0 'WHILE loop counter is reset
WHILE DM3000 < 10 'Loop when DM3000 is less than 10

4 '--- WHILE loop :10 times


DM3000 += 1 'WHILE loop counter plus 1
Control Statement

DM4000 = 0 'DO loop counter is reset


DO
'--- DOloop : 10 times
'The most deep nesting
DM4000 += 1 'DO loop counter plus 1
DM1000 += 1 'Plus 1 to the counter for the number of
'processing
UNTIL DM4000 >= 10 'Until DM4000 exceeds 10
'Loop
END WHILE
NEXT
Operation description DM2000 performs 10 FOR loops. Among which, DM 3000 performs 10 WHILE
loops, DM 4000 performs 10 DO loops, and (the bottom layer) counts the number
of processings (DM0 1000).

When executing the program, 10 FOR loop s * 10 WHILE loop s * 10 DO loops take place,
execute 1000 tmes of the most deep nesting processing.

4-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

loop control statement and processing time

SCRIPT SYNTAX AND Precautions


With the loop control statement (FOR to NEXT, WHILE, DO), loop process programming can be easily
performed by KV script. Loop processing, however, should be perfromed within the allowed scanning
time range.

Ƶ About processing time


Here the scanning time means the scanning time for a program which includes multiple loops.
Example) sum 1+2+3+ĂĂ200,000.

Programming Script DM1000.D = 0


4

Control Statement
DM1002.D = 0
WHILE DM1000.D < 200000 '(1) to (2) processing shall be repeated
'for 200,000 times.
DM1000.D += 1 '(1)
DM1002.D = DM1002.D + DM1000.D '(2)

END WHILE

"WHILE Statement (pre-judge loop control)", Page 4-27.

Processing time of above Sample Program as follows.

1 loop time -> approx 1.65μs


200,000 loop time -> approx 1.65μs x 200,000=about 330,000μs (330ms)
* above processing time is only a reference example. Actual processing varies with the number of
expansion unit connected and

In this case, there is no problem for 1 loop processing whereas for 200,000 tmes of loop processing,
the total processing time is within allowed scanning time (over 300ms for KV-5500/5000/3000/1000).

If the program is used in KV script, easy programming can be enabled by using smaller programs to
program a complicated procedure and loop process. However, attention should be paid to the scanning
time.

TIP When Ladder exceeds allowed scanning time (KV-5500/5000/3000/1000 reaches 300ms),
scanning time overflow may occur (error No.30)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-35


4-3 Control Statement

When the processing time of loop control statement is long (complicated operation processing and
macro processing), scanning timeout will still occur, even if the number of loops is small.
SCRIPT SYNTAX AND Precautions

To avoid scanning timeout, changes should be made to the program in order to execute several
scanning ( or scanning every time) processes.

Example) sum 1+2+3+ĂĂ 200,000


(avoid scanning timeout in programming)

Programming Script IF R1004 = OFF THEN


SET(R1004) 'Operation in progress
DM1000.D = 0 'DM1000.D initialization
4 DM1002.D = 0 'DM1002.D initialization
END IF
Control Statement

IF R1004 AND DM1000.D < 200,000 THEN


DM1000.D += 1 'Counter
DM1002.D = DM1002.D + DM1000.D 'Sum 1 to 200,000
END IF
Operation description If R1004 is OFF, 0 is then stored in DM1000.D and DM1002.D (initialize) to set up R1004.
If R1004 is ON and DM1000.D is less than 200,000, 1 is then added to the current value of
DM1000.D, and the value from 1 to 200,000 is added in turn, and stored to DM1002.D
(operation is executed in each time scanning).

"IF to Statement (Conditional Branch (1))", Page 4-12.

4-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-3 Control Statement

Ƶ About infinite loop


The situation whereby that loop process cannot ended is called infinite loop.

SCRIPT SYNTAX AND Precautions


[inexecutable programming]
There is no programming for ending repeat
WHILE MR1000 = OFF control statement in progress statement.
NO end since no programming to
DM1001 += 1
MR1000 become ON.
DM1000 = DM1000 + DM1001
END WHILE

Add force end condition Infinite loop


4

Control Statement
Programming Script WHILE MR1000 = OFF If MR1000 is ON, loop process will be ended
DM1001 += 1
DM1000 = DM1000 + DM1001
IF DM1000 > 1000 THEN
BREAK Add end condition of repeate control statement.
Execute BREAK after DM1000 changed to
END IF 1000 above, end repeate control.
END WHILE

"BREAK Processing", Page 4-31.

TIP You can program the BREAK statement for force termination of a loop control.
Alternatively, you can program MR1000 = ON to terminate the program. From the
perspective of "improved program readability, it is recommended that the BREAK statement
used in terminating a loop control.

Ƶ About timer actions in a loop control statement


Timer cannot be used in force termination of loop control statement.
Timer, counter contact in loop control will not be changed, the following script becomes infinite loop.

[inexecutable Script Programming]


TMH(T001,1) '10ms timer
WHILE MR1000 = OFF 'If MR1000 is ON, loop process will be ended
DM1001 += 1
DM1000 = DM1000 + DM1001
IF T001.B THEN 'BREAK is executed after the timer contact
'T001 is opened.
BREAK Execute no processing statement because
END IF of without change to contact of timer.

END WHILE
"TMR function", Page 5-22

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-37


4-4 Precutions on Script Programming

Status of Hold Control Bit Device


SCRIPT SYNTAX AND Precautions

In KV script, the program changing the status of the previous bit device can be conducted (assign ON /
OFF).

Example) set MR1000 (the bit device) to ON status (assign ON).

[Box Script]

4 Programming Script
CR2008
MR1000 = ON
Precutions on Script Programming

ON 1 scan at operation start

Ladder development
CR2008 NCJ
#1000
ON 1 scan at operation start

CR2002 MR1000

Always ON

LABEL
#1000

[Area Script]

Programming Script

MR1000 = ON
ˇ

Ladder development
CR2002 MR1000

Always ON Operation destination device

The MR1000=ON programed with KV script is converted to the OUT command taking normal ON
(CR2002) as execution condition. So the script should be executed. After this, MR1000 is ON.

TIP When clearing the value of bit device and word device, RES function can be reset, or select
[Debug (D)] ė [All Clear Device (L)] from the menu.

4-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-4 Precutions on Script Programming

Ƶ Excution timing
Scan

SCRIPT SYNTAX AND Precautions


Script execute ON

OFF
ON
OUT command
Bit device for holding output
OFF

Ƶ How to use
Since "MR1000 = ON" is ON, then it should be turned to OFF by executing "MR1000 = OFF" or RES
(MR1000).
4
Example) when R2000 (execute condition) is ON, MR1000 is turned to ON. When R2000 is not ON

Precutions on Script Programming


(OFF), MR1000 is turned to OFF.

Programming Script

+(4106*'0
/410
㧗 '.5'
/41((
'0&+(

LD
R2000 NCJ
#2000

CR2002 MR1000

Always ON

CR2002 CJ
#2001
Always ON

LABEL
#2000

CR2003 MR1000

Always ON

LABEL
#2001

To use script to control the bit device, instead of use assignment statement, the SET/RES
function should be used.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-39


4-4 Precutions on Script Programming

Precautions About Use of Timer Device/ Counter Device


SCRIPT SYNTAX AND Precautions

Timer device / counter device processes current valueand contact status as the same device number.
When the contact status is .B (bit type), processing is the same as other bit device processing ( suffix .B
can be omitted).
When the current value as .D (32 bit unsigned), processing is the same as other word devices. The
suffix .D, however, must be specified.
"Timer (Contact) T", Page 3-13
"Counter (Contact) C", Page 3-15

ƽ Timer/ Counter current value reading


4
Precutions on Script Programming

Programming Script DM1000.D = T0.D 'Store the current value of timer T0 to DM1000.D.
DM1002.D = C5.D 'Store the current value of counter C5 to DM1002.D.
T0.D = DM1100.D 'Replace the current value of timer T0 with the value stored in
'DM1100.D.
C5.D = DM1102.D 'Replace the current value of counter C5 with the value stored in
'DM1102.D.

LD

CR2002 MOV.D
T0000 DM01000
Always ON
Store device

CR2002 MOV.D
C0005 DM01002
Always ON
Store device

CR2002 MOV.D
DM01100 T0000
Always ON

CR2002 MOV.D
DM01102 C0005
Always ON

Note
• Current value of timer/counter is processed as 32 bit.
• When processing timer/counter as current value, shall specify suffix .D suffix, or describe
the type.
• When support model (using CPU unit) is KV-1000, timer device and counter device can
use same Device No..
Example) when T100( timer) has been used, C100 cannot be used (counter)

4-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-4 Precutions on Script Programming

ƽ Timer/ Counter contact

SCRIPT SYNTAX AND Precautions


Programming Script SET(T100.B, MR1000) 'When timer contact T 100 is ON, change
'MR1000 to ON (hold).
SET(C200.B = OFF, MR1001) 'When counter contact C 200 is OFF, MR1001
'changes to ON (hold).

LD
T100 MR1000
SET

Operation destination device

C200 MR1001 4
SET

Precutions on Script Programming


The default type of timer device/counter device is bit type.

Ƶ Presautions about the use of timer function


An execution condition is included in timer function which is also used as the reset instruction of
counter. The execution conditon of timer function can be omitted in programming. In this case,
however, resetting cannot be perfomed, meaning that it cannot behave like an ordinary function.

Programming Script TMR(T100,500) 'Programming with execution condition omitted


Ladder development CR2002 #500
T100
Always ON

Operation description Timer device T100 enables T100 contact ON 5 seconds after programmed start.
Only when RES (T100), or PLC power OFF or "RUN Ÿ PROG" conversion is converted, the
contact can be cleared.)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-41


4-4 Precutions on Script Programming

Ƶ Precautions about use of timer function in Box Script and IF statement


Box Script and IF statement are converted to NCJ command to LABEL.
SCRIPT SYNTAX AND Precautions

When execution condition of Box Script and IF statement is FALSE, jumping is performed between NCJ
to LABEL. So care must be taken during use of timer function.

ƽ Use timer function in IF statement of area script


The following points must be noted during use of area script, timer function in IF statement.
Programming Script IF MR2000 = ON THEN 'Program in IF statement
TMR (MR1000 = ON, T101, 500)
END IF
4 LD Notice
MR2000 NCJ
If condition execution of statement is FALSE,
Precutions on Script Programming

#2000

MR1000 #500 statement processed via N CJ command is


T101 jumped.In this case, keep the status of every

LABEL
contact(the status before N CJ jump), when
#2000 execution condition of timer function is ON,
timer is not reset.
The timer continues action before reset, processing statement jumps with N CJ command,
so, even if timeout, timer contact changes to ON in PLC, will not output. In such status,
when execution condition of IF statement is TRUE, processing statement is executed, so,
any action without timer function, timer contact ON, output.
Operation description
(1) (3)
No scan processing
ON
Execution conditon statement of IF statement
for IF statement
(MR 2000) OFF (2)
Perform conditon ON
for timer function
(MR1000) OFF
(5)
ON
Status for
timer contact (T101)
OFF

Timer current value 500

(4)
timeup

0
Restart IF statement

(1) When execution condition of IF statement (MR2000) is ON, and when execution condition of timer(
MR1000) is ON, timer T101 acts. timer contact T101 changes to ON 5 seconds after action starts.
(2) When execution condition of IF statement( MR2000) changes to ON, and execution
condition of timer( MR1000) changes to OFF, the timer is reset.
(3) Timer action is unrelated to execution condition of timer before timeout, when execution
condition of IF statement changes to OFF, processing statement( timer function) of IF
statement is not scaned. In this case,, timer function seems in pause mode, but actually
in continual action( due to no reset input).
(4) But after timeout, processing statement will be not scaned. So in stead of output, timer
contact will be in standby status.
(5) During scan when execution condition of next IF statement is TRUE, timer contact
changes to ON without timer action.
4-42 - KV-5500/5000/3000/1000 Series Script Programming Manual -
4-4 Precutions on Script Programming

Precautions When execution condition of IF statement is OFF, resetting timer function contained in
processing statement can avoid this problem.

SCRIPT SYNTAX AND Precautions


The change for programming script are as follows.*1
Programming Script IF MR2000 = ON THEN
TMR (MR1000 = ON, T101, 500) 'Programming in IF statement

ELSE
'Reset timer device.
RES (T101)
END IF
Ladder development MR2000 NCJ
#2000

MR1000 #500
T101
4

Precutions on Script Programming


CR2002 CJ
#2001
Always ON
LABEL
#2000

CR2002 T101
RES
Always ON
LABEL
#2001

Operation description When execution condition (MR2000) of IF statement is ON, and when execution condition of
timer (MR1000) is ON, timer T101 acts.
Timer contact T101 changes to ON 5 seconds after action starts.

When execution condition (MR2000) of IF statement changes to OFF, reset timer device
(T101).

*1 When programming area script including timer function between CJ-LABEL command, or
programming in sub-program, timer function may fail to normal working, this fails to be avoided
using above method.
For details, please see "KV-5500/5000/3000 series instruction reference Manual".

ƽ Specify timer function using Box Script


When using Box Script, care must be taken as same as timer function used in IF statement.

Programming Script MR2000


TMR(MR1000=ON,T101,500)
' Programming in Box Script

Ladder development
MR2000 NCJ
#1001

MR1000 #500
T101

LABEL
#1001

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-43


4-4 Precutions on Script Programming

Operation description (1) (3) (5)


Execution conditon No scan processing
ON
for dialog script statement of dialog script
(MR 2000)
SCRIPT SYNTAX AND Precautions

OFF
(2)
ON
Perform conditon for
timer function (MR1000)
OFF

ON
Status for timer
contact (T101)
OFF

Timer current value OFF

(4)
(timeup)

4 ?
Restart IF statement
Precutions on Script Programming

(1) When execution condition of Box Script (MR2000) is ON, and when execution condition
of timer( MR1000) is ON, timer T101 acts. timer contact T101 changes to ON 5
seconds after action starts.
(2) When execution condition of Box Script (MR2000) changes to ON, and execution
condition of timer (MR1000) changes to OFF, and the timer is reset.
(3) Timer action is unrelated to execution condition of timer before timeout, when execution
condition of Box Script changes to OFF, processing statement( timer function) of Box
Script is not scaned. In this case, the timer function contines to work, although it seems
that it is paused ( cause no reset input).
(4) But after setup timeout, processing statement will be not scaned, so, timer contact will
be not output, and in standby status.
(5) During scan when execution condition of next Box Script is TRUE, timer contact
changes to ON without timer action.

Precautions When execution condition of Box Script is OFF, resetting timer function contained in Box
Script can avoid this problem.
Script programming change as follows. *1

Programming Script MR2000


TMR(MR1000=ON,T101,500)
Execution conditon
MR2000 T101
RES
Execution conditon

Operation description Reset timer device via contact B of execution condition of Box Script.

*1 When programming area script including timer function between CJ- LABEL, or programming in
sub-routine, timer function may not work, and the above measures also do not work.
For details, see KV-5500/5000/3000 series Instruction Reference Manual.

4-44 - KV-5500/5000/3000/1000 Series Script Programming Manual -


4-4 Precutions on Script Programming

ƽ MC to MCR When using timer / counter function

SCRIPT SYNTAX AND Precautions


Programming Script MC MR1000 THEN 'start timer/counter when MR1000 is ON
TMR(T1, 10)
CNT(C3, 100, R1000)
MCR

Ladder development

Timer/Counter stop (clear) when execution conditon is false

MR1000 MC

Execution conditon 4
CR2002 #10

Precutions on Script Programming


T1
Always ON
CR2002 #100
C3
Always ON R1000

MCR

If condition is FALSE (MR1000 is OFF) OFF , the timer / counter is reset.


For details, see "MC to MCR Statement (Master control)", Page 4-22

- KV-5500/5000/3000/1000 Series Script Programming Manual - 4-45


4-4 Precutions on Script Programming

MEMO
SCRIPT SYNTAX AND Precautions

4
Precutions on Script Programming

4-46 - KV-5500/5000/3000/1000 Series Script Programming Manual -


5

BASIC FUNCTIONS
BASIC FUNCTIONS

Contact Function•••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-2


Bit Contact Function ••••••••••••••••••••••••••••••••••••••••••••••••• 5-8
Output Function••••••••••••••••••••••••••••••••••••••••••••••••••••• 5-12
Bit output Function ••••••••••••••••••••••••••••••••••••••••••••••••• 5-14
Timer/counter Function •••••••••••••••••••••••••••••••••••••••••••• 5-22
Direct I/O Function ••••••••••••••••••••••••••••••••••••••••••••••••• 5-32

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-1


Contact Function

LDP Up edge differential of specified device

Load pulse

Return value
*1
= LDP (Up edge detection device)
Argument/Return Recognized Type Const
Explanation *3*4 Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Up edge
Specifies the device No. whose up edge
detection - - - - - - .B - - ƻ ƻ
*2 is to be detected.
device
R
BASIC FUNCTIONS

Return value Specifies the device No. to be activated. - - - - - - .B - - ƻ -


*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 When a word device has been specified to the up edge detection device, the state of the LSB is
detected.
*3 Direct I/O realys (DR) can be specified when KV-5500/5000/3000 is used.
*4 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.

5 Description of Operation
Contact Function

When the up edge (OFF ė ON) of S is detected, the device specified by R is turned ON for
one scan.
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-1 Contact Instructions".

ƽ Example of format
MR2000 = LDP (MR1000)
MR1000 MR2000

Device for up Return value
edge inspection

Note
Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", Page 2-13

5-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When using operation formulas


Programmed script MR2000 = LDP (DM1000 + DM1001 = 1000)
Description of Operation MR2000 is turned ON for one scan only when the total of DM1000 and DM1001 is 1000 or
more (the operation result is FALSE -> TRUE).

BASIC FUNCTIONS
Ladder conversion CR2002 DM1001 @VM0 DM1000 @VM0 +1000
LDA EXT STA.L LDA EXT ADD.L CMP.L
Always ON Device for up Device for
edge inspection up edge inspection
CR2010 @VB00

the operation
result is zero
@VB00 MR2000

ON device
5

Contact Function
ƽ When combining with other functions
Programmed script BMOV (LDP (R3000), DM1000, DM2000, 10)
Description of Operation The content of ten words starting from DM1000 is block-moved to ten words starting from
DM2000 only at the scan where the up edge (OFF-> ON) of R3000 is detected.
Ladder conversion
R3000 BMOV
↑ DM1000 DM2000 #10
Device for
up edge inspection Conversion Conversion
source device destination device

TIP Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"BMOV function", Page 7-2

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-3


LDF Down edge differential of specified device

Load pulse fall


*1
Return value = LDF (Down edge detection device)

Argument/Return Recognized Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B*3*4 .T #/$
S Down edge
Specifies the device No. whose down
detection
*2 - - - - - - .B - -- 嗟 嗟
edge is to be detected.
device
R
BASIC FUNCTIONS

Return value Specifies the device No. to be activated. - - - - - - .B - - 嗟 -


*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 When a word device has been specified to the down edge detection device, the state of the LSB is
detected.
*3 Direct I/O realys (DR) can be specified when KV-5500/5000/3000 is used.
*4 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.

5 Description of Operation
Contact Function

When the down edge (ONėOFF) of S is detected, the device specified by R is turned ON for
one scan.
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see "KV-5500/5000/3000/1000 Instruction Reference Manual", 2-1 Contact Instructions."

ƽ Example of format
MR2000 = LDF (MR1000)
MR1000 MR2000

Device for down Return value
edge inspection

Note
Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", Page 2-13

5-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When using operation formulas


Programmed script MR2000 = LDF (DM1000 + DM1001 = 1000)
Description of Operation MR2000 is turned ON for one scan only when the total of DM1000 and DM1001 is 1000 or
more (the operation result is TRUE ė FALSE).

BASIC FUNCTIONS
Ladder conversion CR2002 DM1001 @VM0 DM1000 @VM0 +1000
LDA EXT STA.L LDA EXT ADD.L CMP.L
Always ON Device for down Device for down
edge inspection edge inspection
CR2010 @VB00

the operation
result is zero
@VB00 MR2000

ON device
5

Contact Function
ƽ When combining with other functions
Programmed script BMOV (LDF (R3000), DM1000, DM2000, 10)
Description of Operation The content of ten words starting from DM1000 is block-moved to ten words starting from
DM2000 only at the scan where the down edge (ON ė OFF) of R3000 is detected.
Ladder conversion R3000 BMOV
↓ DM1000 DM2000 #10
Device for down
edge inspection Move Move
source device destination device

TIP Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"BMOV function", Page 7-2

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-5


LDPB Up edge differential bar of specified device

Load pulse bar

Return value
*1
= LDPB (Up edge detection device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B*3*4 .T #/$
S Up edge
Specifies the device No. whose up edge
detection - - - - - - .B - - 嗟 嗟
*2 is to be detected.
device
R
BASIC FUNCTIONS

Return value Specifies the device No. to be activated. - - - - - - .B - - 嗟 -


*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 When a word device has been specified to the up edge detection device, the status of the lowest bit is
detected.
*3 Setable between direct I/O realys (DR).
*4 Bit position devices can be specified as word device.

Note
5 The KV-1000 series does not support the LDPB function.
Contact Function

Description of Operation

When the up edge (OFF ė ON) of S is detected, the device specified by R is turned OFF for
one scan.
For operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-1 Contact Instructions."

ƽ Example of format
MR2000 = LDPB (MR1000)
/4 MR2000

Device for Return value
up edge inspection

Note
Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", Page 2-13

5-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


LDFB Down edge differential bar of specified device

Load pulse bar

Return value
*1
= LDFB (Down edge detection device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .B*3*4 .T #/$
S Down edge
Specifies the device No. whose down
detection - - - - - .B - - 嗟 嗟
*2 edge is to be detected.
device
R

BASIC FUNCTIONS
Return value Specifies the device No. to be activated. - - - - - .B - - 嗟 -
*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 When a word device has been specified to the down edge detection device, the state of the LSB is
detected.
*3 Direct I/O realys (DR) can be specified.
*4 Bit position devices can be specified as word device.

Note
The KV-1000 series does not support the LDFB function. 5

Contact Function
Description of Operation

When the down edge (ONėOFF) of S is detected, the device specified by R is turned OFF for
one scan.
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see "KV-5500/5000/3000/1000 Instruction Reference Manual", 2-1 Contact Instructions."

ƽ Example of format
MR2000 = LDFB (MR1000)
/4 MR2000

Device for down Return value
edge inspection

Note
Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", Page 2-13

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-7


Bit Contact Function

BLD Specified bit information of word device

Bit load

Return value
*1
= BLD (read device, bit position)
Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B*4*5 .T #/$
S Read Specifies the device whose bit state is to
*2 .U .U .D .D - - - - - 嗟 嗟
device be read.
n *3 Specifies the bit position where device
Bit position .U .U .U .U - - - - 嗟 嗟 嗟
ON/OFF is judged. (16-bit binary data)
BASIC FUNCTIONS

R Return value Specifies the device No. to be activated. - - - - - - .B - - 嗟 -


*1 The return value can be omitted. When omitted, the operation result is stored to a work device.
*2 When a bit device has been specified to S , the relay of the device No. to be calculated by the value
of the [device No. + n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the read device is .U, and 0 to 31 when
the suffix is .D.
5 *4 Direct I/O realys (DR) can be specified when KV-5500/5000/3000 is used.
*5 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.
Bit Contact Function

Description of Operation

The ON/OFF state of Bit n of S is transferred to R .


DKV 5 DKV
 

               

VJDKV DKV
P DKV UVDKV

10
PDKVQH5
1((

10
$.&HWPEVKQP
1((

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "Contact Instructions."

ƽ Example of format
R1000 = BLD (DM1000, 10)
DM1000 R1000
B
#10 Return value
Read device

Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds the suffix range (0 to 15 for .U suffix and 0 to 31
for .D suffix) of S :
When the suffix of S is .U: The values of lower 4 bits of n are used.
When the suffix of S is .D: The values of lower 5 bits of n are used.

5-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When specifying bit device


Programmed script R1000 = BLD (MR2009.U, 10)
Description of Operation R1000 is turned ON when bit 10 (MR2103) of MR2009.U is ON.
Ladder conversion
MR2009 R1000

BASIC FUNCTIONS
B
#10 ON device
Read device

ƽ When combining with other functions


Programmed script TMR (BLD (DM1000, 5), T001, 10)
Description of Operation Timer (T1) is started when bit 5 of DM1000 is ON.
Ladder conversion
DM1000 #10
5
B T1

Bit Contact Function


#5
Read device

TIP Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
TMR function", Page 5-22

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-9


BLDB Specified bit information bar of word device

Bit load bar

Return value
*1
= BLDB (read device, bit position)
Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B*4*5 .T #/$
S Read Specifies the device whose bit state is to
*2 .U .U .D .D - - - - - 嗟 嗟
device be read.
n *3 Specifies the bit position where device
Bit position .U .U .U .U - - - - 嗟 嗟 嗟
ON/OFF is judged. (16-bit binary data)
BASIC FUNCTIONS

R Return value Specifies the device No. to be activated. - - - - - - .B - - 嗟 -


*1 The return value can be omitted. When omitted, the operation result is stored to a work device.
*2 When a bit device has been specified to S , the relay of the device No. to be calculated by the value
of the [device No. + n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the read device is .U, and 0 to 31 when
the suffix is .D.
5 *4 Direct I/O realys (DR) can be specified when PCL KV-5500/5000/3000 is used.
*5 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.
Bit Contact Function

Description of Operation

The ON/OFF state of Bit n of S is invert-transferred to R .


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 bit of S
OFF

ON
BLDB function
OFF

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-2 Contact Instructions".

ƽ Example of format
R1000 = BLDB (DM1000, 10)
DM1000 R1000
B
#10 Return value
Read device

Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds the suffix range (0 to 15 for .U suffix and 0 to 31
for .D suffix) of S :
When the suffix of S is .U: The values of lower 4 bits of n are used.
When the suffix of S is .D: The values of lower 5 bits of n are used.

5-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When specifying a bit to a read device


Programmed script R1000 = BLDB (MR2009.U, 10)
Description of Operation R1000 is turned ON when bit 10 (MR2103) of MR2009.U is OFF.
Ladder conversion
MR2009

BASIC FUNCTIONS
R1000
B
#10 ON device
Read device

ƽ When combining with other functions


Programmed script TMR (BLDB (DM1000, 5), T1, 10)
Description of Operation Timer (T1) is started when bit 5 of DM1000 is OFF.
Ladder conversion
DM1000 #10
5
B T1

Bit Contact Function


#5
Read device

TIP Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
TMR function", Page 5-22

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-11


Output Function

SET Output ON of specified device

Set

SET ([execution condition,]*1 Destination device)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B*2*3 .T #/$
D Destination Specifies the device No. of the target
- - - - - - .B - - 嗟 -
device to be turned ON and held.
R Return value No - - - - - - - - - - -
BASIC FUNCTIONS

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Direct I/O realys (DR) can be specified when PCL KV-5500/5000/3000 is used.
*3 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.

Description of Operation
5 When the execution condition is TRUE, D is turned ON. Once the destination device is turned ON,
it is held in the ON state even if the execution condition becomes FALSE. (Devices in ON state are
Output Function

turned OFF by the SET function.)


"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-4 Output Instructions."
"RES function", Page 5-13

ƽ Example of format
SET (R3000, MR1000)
R3000 MR1000
SET
Execution conditon Destination device

Sample Program

ƽ When pecifying a word device to the destination device


Programmed script SET (MR1000, DM2000.B)
Description of Operation When MR1000 is ON, the LSB of DM2000 is turned ON and held in this state.
Ladder conversion
MR1000 DM2000
SET
Execution conditon Destination device

5-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


RES Output OFF of specified device

Reset

RES ([Execution condition,] *1 Destination device)


Argument/Return Applicable Suffix Const
Explanation Device Formul
Value .U .S .D .L .F .DF .B*2*3 .T #/$ a
D destination Specifies the device No. of the
- - - - - - .B - - 嗟 -
device destination device to turn OFF.
R Return value No - - - - - - - - - - -

BASIC FUNCTIONS
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Direct I/O realys (DR) can be specified when PCL KV-5500/5000/3000 is used.
*3 Devices for bit position of word device can be specified when KV-5500/5000/3000 is used.

Description of Operation

When the execution condition is TRUE, D is turned OFF. (Devices that were turned ON by the SET
5
function are turned OFF by the RES function.)

Output Function
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual "2-4 Output Instructions."
"SET function", Page 5-12

ƽ Example of format
RES (R3000, MR1000)
R3000 MR1000
RES
Execution conditon Destination device

Sample Program

ƽ When specifying a word device to the destination device


Programmed script RES (MR1001, DM2000.B)
Description of Operation When MR1001 is ON, the LSB of DM2000 is set to OFF.
Ladder conversion
MR1001 DM2000
RES
Execution conditon Destination device

ƽ When resetting a timer device


Programmed script RES (MR1002, T100)
Description of Operation When MR1002 is ON, the current value of T100 is changed to the same value as the setting value.
Ladder conversion
MR1002 T100
RES
Execution conditon Destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-13


Bit output Function

BOUT Specified bit output of word device

Bit output

BOUT ([Execution condition,]*1 Destination device, bit position)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Destination Specifies the destination device whose input
*2 .U .U .D .D - - - - - ƻ -
device state is to be output.
*3
n Bit position Specifies the bit position to output. .U .U .U .U - - - - ƻ ƻ ƻ
BASIC FUNCTIONS

R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is specified.)
*2 When a bit device has been specified by D , the relay of the device No. to be calculated by the value
of the [device No.+ n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the destination device is .U, and 0 to 31
when the suffix is .D.

5 Description of Operation
Bit output Function

When the execution condition is TRUE, Bit n of D is turned ON, and when the execution
condition is FALSE, it is turned OFF.
bit
15
D bit
0

when 16bit and suffix is .U 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0

when 32bit and suffix is .D 15th bit 1st bit 0 bit


n bit

bit
31
D +1 bit
16
bit
15
D bit
0

0 0 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

31th bit 16th bit 15th bit 1st bit 0 bit

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2--5 bit Output Instructions."

ƽ Example of format
• D : 16-bit (.U suffix) instruction
BOUT (MR1000, DM2000, 12)
MR1000 DM2000
B
Execution conditon #12
Target device

• D : 32-bit (.U suffix) instruction


BOUT (MR1000 = OFF, DM2100.D, 28)
MR1000 DM2100
B.D
Execution conditon #28
Target device

5-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds suffix range (0 to 15 for .U suffix and 0 to 31 for
.D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of R are used.
When the suffix of D is .D: The values of the lower 5 bits of n are used.

BASIC FUNCTIONS
Sample Program

ƽ When specifying a bit device to the destination device


Programmed script BOUT (DM1000 <= 100, MR2002.U, 14)
When DM1000 is 100 or less, bit 14 (MR2100) of MR2002.U is turned ON, and when
Description of Operation

DM1000 is greater than 100, bit 14 is turned OFF.


5
Ladder conversion

Bit output Function


DM1000 MR2002
<= B
#100 #14
Execution conditon Destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-15


BOUB Specified bit inverted output of word device

Bit out bar

BOUTB ([Execution condition,] *1 Destination device, bit position)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Destination Specifies the destination device whose input
*2 .U .U .D .D - - - - - ƻ -
device state is to be output inverted.
*3
n Bit position Specifies the bit position to output. .U .U .U .U - - - - ƻ ƻ ƻ
BASIC FUNCTIONS

R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is specified.)
*2 When a bit device has been specified by D , the relay of the device No. to be calculated by the value
of the [device No.+ n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the destination device is .U, and 0 to 31
when the suffix is .D.

5 Description of Operation
Bit output Function

When the execution condition is TRUE, Bit n of D is turned OFF, and when the execution
condition is FALSE, it is turned ON.
bit
15
D bit
0

when 16bit and suffix is .U 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

when 32bit and suffix is .D 15th bit 1st bit 0 bit


n bit

bit
31
D +1 bit
16
bit
15
D bit
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

31 bit 16 bit 15 bit 1st bit 0 bit

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-5 bit Output Instructions."

ƽ Example of format
• D : 16-bit (.U suffix) instruction
BOUB (MR1000, DM2000, 12)
MR1000 DM2000
B
Execution conditon #12
Destination device

• D : 32-bit (.U suffix) instruction


BOUB (MR1100 = OFF, DM2100.D, 28)
MR1100 DM2100
B.D
Execution conditon #28
Destination device

5-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds suffix range (0 to 15 for .U suffix and 0 to 31 for
.D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of R are used.
When the suffix of D is .D: The values of the lower 5 bits of n are used.

BASIC FUNCTIONS
Sample Program

ƽ When specifying a bit device to the destination device


Programmed script

Description of Operation
BOUB (DM1000 <= 100, MR2002.U, 14)
When DM1000 is 100 or less, bit 14 (MR2100) of MR2002.U is turned OFF, and when
5

Bit output Function


DM1000 is greater than 100, bit 14 is turned ON.
Ladder conversion
DM1000 MR2002
<= B
#100 #14
Execution conditon Destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-17


BSET Specified bit output ON of word device

Bit set

BSET ([Execution condition,]*1 Destination device, bit position)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Destination Specifies the device of the target to be
*2 .U .U .D .D - - - - - ƻ -
device turned ON and held.
n *3 Specifies the bit position to be turned ON
Bit position .U .U .U .U - - - - ƻ ƻ ƻ
BASIC FUNCTIONS

and held.
R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is specified.)
*2 When a bit device has been specified by D , the relay of the device No. to be calculated by the value
of the [device No.+ n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the destination device is .U, and 0 to 31
when the suffix is .D.
5
Description of Operation
Bit output Function

When the execution condition is TRUE, Bit n of D is turned ON. Once the destination device
is turned ON, it is held in the ON state even if the execution condition becomes FALSE. (Devices in ON
state are turned OFF by the BRES function.)
bit
15
D bit
0

when 16bit and suffix is .U 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0

when 32bit and suffix is .D 15th bit 1st bit 0 bit


n bit

bit
31
D +1 bit
16
bit
15
D bit
0

0 0 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

31th bit 16th bit 15th bit 1st bit 0 bit

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-5 bit Output Instructions."
"BRES function", Page 5-20

ƽ Example of format
• D : 16-bit (.U suffix) instruction
BSET (R1000, DM1000, 10)
R1000 DM1000
BSET
Execution conditon #10
Destination device

• D : 32-bit (.U suffix) instruction


BSET (R1100 = OFF, DM1100.D, 20)
R1100 DM1100
BSET.D
Execution conditon #20
Destination device

5-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds suffix range (0 to 15 for .U suffix and 0 to 31 for
.D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of R are used.
When the suffix of D is .D: The values of the lower 5 bits of n are used.

BASIC FUNCTIONS
Sample Program

ƽ When specifying a bit device to the destination device


Programmed script BSET (DM1000 = 100, MR2008.U, 10)
Description of Operation

Ladder conversion
When DM1000 is 100, bit 10 (MR2102) of MR2008.U is turned ON and is held in this state. 5
DM1000 MR2008

Bit output Function


= BSET
#100 #10
Execution conditon Destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-19


BRES Specified bit output OFF of word device

Bit reset

BRES ([Execution condition,]*1 Destination device, bit position)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Destination
*2 Specifies the destination device to turn OFF. .U .U .D .D - - - - - ƻ -
device
*3
n Bit position Specifies the bit position to turn OFF. .U .U .U .U - - - - ƻ ƻ ƻ
BASIC FUNCTIONS

R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is specified.)
*2 When a bit device has been specified by D , the relay of the device No. to be calculated by the value
of the [device No.+ n ] is specified. Operation is normal even when relays straddle channels.
*3 For the value of the bit position, specify 0 to 15 when the suffix of the destination device is .U, and 0 to 31
when the suffix is .D.

5 Description of Operation
Bit output Function

When the execution condition is TRUE, Bit n of D is turned OFF.


bit
15
D bit
0

when 16bit and suffix is .U 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

15th bit 1st bit 0 bit


when 32bit and suffix is .D
n bit

bit
31
D +1 bit
16
bit
15
D bit
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

31th bit 16th bit 15th bit 1st bit 0 bit

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-5 Output Instructions."
"BSET function", Page 5-18

ƽ Example of format
• D : 16-bit (.U suffix) instruction
BRES (MR1000, DM2000, 5)
MR1000 DM2000
BRES
Execution conditon #5
Destination device

• D : 32-bit (.U suffix) instruction


BRES (MR1100 = OFF, DM2100.D, 30)
MR1100 DM2100
BRES.D
Execution conditon #30
Destination device

5-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
When programming a device or operation formula in n , the operation result is as
follows. When the operation result exceeds suffix range (0 to 15 for .U suffix and 0 to 31 for
.D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of R are used.
When the suffix of D is .D: The values of the lower 5 bits of n are used.

BASIC FUNCTIONS
Sample Program

ƽ When specifying a bit device to the destination device


Programmed script BRES (DM1000 >= 100, MR2008.U, 10)
Description of Operation

Ladder conversion
When DM1000 is 100 or more, bit 10 (MR2102) of MR2008.U is turned OFF. 5
DM1000 MR2008

Bit output Function


>= BRES
#100 #10
Execution conditon Destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-21


Timer/counter Function

TMR 100 ms 32-bit down timer

Timer

TMR ([Timer execution condition,]*1 timer device, timer setting value)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Timer Specifies the device No. of the timer.(T0 to
- - - - - - - - - - -
device T3999)
S Timer Specifies the setting value of the timer in
*2 .D .D .D .D - - - - 嗟 嗟 嗟
BASIC FUNCTIONS

setting value 100 ms units.(0 to 4294967295)


R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution condition
is OFF, the TMR function is reset.)
When the execution condition is omitted, use the RES function separately to reset the timer.
*2 When a bit device has been specified to the timer setting value, continuous 32 bits are occupied,
and when a word device has been specified, continuous two words are occupied.

5 Description of Operation
Timer/counter Function

When the execution condition is TRUE, the timer specified by D is ON. S becomes the current value,
and is decremented by 1 every 100 ms. When the current value becomes "0", the specified timer device (contact)
turns ON. When the execution condition is FALSE, the specified timer is turned OFF and the current value is reset.
Scan
ON

Execution conditon
OFF
Value set in S

Current value

#00000

ON
Timerǂ T D

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "2-6 Timer/Counter Instructions."

ƽ Example of format
TMR (R3000, T125, 100)
R3000 #100
T125
Execution conditon

TIP The error of the TMR instruction is "within f (100 ms + 1 scan time)."

Note
• When using KV-5500/5000/3000, the device No. identical with other TMR, TMH, TMS,
TMU function (instruction), UDT instructions cannot be used.
• When using KV-1000, the device No. identical with other TMR, TMH, TMS, CNT function
(instruction), OUTC, UDC, and UDT instructions can be used.
• Operation formulas can also be specified to setting values. Attention is required in the following
instances as the range in which operation formulas can be handled is -2147483648 to +2147483647.
g Operation formulas can also be specified to setting values. When the result of the
operation formula is a minus value, the value obtained by adding 4294967295 to the
result of the operation formula is set as the setting value.
g Attention is required when using this function in box scripts and programming this function in sub-routines.
"Precautions About Use of Timer Device/ Counter Device", Page 4-40

5-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Reading and changing timer current values

Timer devices handle current values by specifying .D (unsigned 32-bit) as their suffix.

ƽ Reading the current value


Specify the timer device to the right side using an assignment statement, and specify the device to
store the current value of the read timer device to the left side.

BASIC FUNCTIONS
Programmed script DM1000.D = T125.D
Description of Operation The current value of T125.D is stored in DM1000.D.
Ladder conversion
CR2002 MOV.D
T125 DM1000
Always ON

ƽ Rewriting the current value


Specify the device stored with the value to rewrite to the right side using an assignment statement, and 5
specify the timer device to the left side.

Timer/counter Function
Programmed script T125.D = DM1100.D
Description of Operation The current value of T125.D is rewritten to the value currently stored in DM1100.D.
Ladder conversion
CR2002 MOV.D
DM1100 T125
Always ON

Note
• When the current value is greater than the setting value when the current value is
rewritten, the current value is changed to the same value as the setting value.
• As unsigned 32-bit data is used for the counter setting value and current value of the TMR
function, unsigned 32-bit (.D) must be used for the devices to store the current value and
setting value and the data to change.
• To change the timer setting value or to read the setting value, specify a device (unsigned
32- bit) to the setting value.
KV-5500/5000/3000/1000 Instruction Reference Manual, "2-6 Timer/Counter Instructions"

Reading timer contacts

Contacts are handled by specifying .B (bit type) as the suffix of the timer device.(.B can be omitted)
Programmed script MR1000 = T125.B
Description of Operation MR1000 is substituted with the contact state of T125.B.
Ladder conversion
T125 MR1000

Note
• Timer contacts cannot be substituted with other bit information.
• To forcibly reset a timer, reset the timer contact by the RES function.
• When the timer device suffix is omitted, the timer device is handled as a bit type.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-23


TMH 10ms 32-bit down timer

High-speed timer

TMH ([Timer execution condition,]*1 timer device, timer setting value)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Timer Specifies the device No. of the timer.(T0 to
- - - - - - - - - - -
device T3999)
S Timer Specifies the setting value of the timer in
*2 .D .D .D .D - - - - 嗟 嗟 嗟
BASIC FUNCTIONS

setting value 10ms units.(0 to 4294967295)


R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution condition
is OFF, the TMH function is reset.)
When the execution condition is omitted, use the RES function separately to reset the timer.
*2 When a bit device has been specified to the timer setting value, continuous 32 bits are occupied,
and when a word device has been specified, continuous two words are occupied.

5
Description of Operation
Timer/counter Function

When the execution condition is TRUE, the timer specified by n is ON. S becomes the current
value, and is decremented by 1 every 10 ms.When the current value becomes "0", the specified timer
device (contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF
and the current value is reset.

Scan
ON

Execution conditon
OFF
Value set in S

Current value

#00000

ON
Timer T
H D

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual", 2-6 Timer/Counter
Instructions."

ƽ Example of format
TMH (R3000, T150, 100)
R3000 #100
T150
H
Execution conditon

TIP The error of the TMR instruction is "within f (10 ms + 1 scan time)."

5-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
• When using KV-5500/5000/3000, the device No. identical with other TMR, TMH, TMS,
TMU function (instruction), UDT instructions cannot be used.
• When using KV-1000, the device No. identical with other TMR, TMH, TMS, CNT function
(instruction), OUTC, UDC, and UDT instructions can be used.
• Operation formulas can also be specified to setting values. Attention is required in the
following instances as the range in which operation formulas can be handled is -

BASIC FUNCTIONS
2147483648 to +2147483647:
g Operation formulas can also be specified to setting values. When the result of the
operation formula is a minus value, the value obtained by adding 4294967295 to the
result of the operation formula is set as the setting value.
g Attention is required when using this function in box scripts and programming this function
in sub-routines.
"Precautions About Use of Timer Device/ Counter Device", Page 4-40
5
"TMR function", Page 5-22.

Timer/counter Function
Sample Program

ƽ When using operation formulas for the setting value


Programmed script TMH (R1000, T150, DM1000 + 100)
Description of Operation High-speed timer T150 is activated for the duration that the execution condition R1000 is
TRUE. When the execution condition is FALSE, the timer is stopped and the current value is
reset.
Ladder conversion
CR2002 DM1000 +100 @VM0
LDA EXT ADD.L STA.L
Always ON

R1000 @VM0
T150
Execution conditon H

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-25


TMS 1 ms 32-bit down timer

High-speed 1ms timer

TMS ([Timer execution condition,]*1 timer device, timer setting value)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Timer Specifies the device No. of the timer.(T0 to
- - - - - - - - - - -
device T3999)
S Timer Specifies the setting value of the timer in
*2 .D .D .D .D - - - - 嗟 嗟 嗟
BASIC FUNCTIONS

setting value 1ms units. (0 to 4294967295)


R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution condition
is OFF, the TMS function is reset.)
When the execution condition is omitted, use the RES function separately to reset the timer.
*2 When a bit device has been specified to the timer setting value, continuous 32 bits are occupied,
and when a word device has been specified, continuous two words are occupied.

5
Description of Operation
Timer/counter Function

When the execution condition is TRUE, the timer specified by D is ON. S becomes the current
value, and is decremented by 1 every 1ms. When the current value becomes "0", the specified timer
device (contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF
and the current value is reset.

Scan
ON

Execution conditon
OFF
Value set in S

Current value

#00000

ON
Timer T
S D

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual", 2-6 Timer/Counter
Instructions."

ƽ Example of format
TMS (R3000, T175, 100)
R3000 #100
T175
S
Execution conditon

TIP The error of the TMS instruction is "within f (1 ms + 1 scan time)."

5-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
• When using KV-5500/5000/3000, the device No. identical with other TMR, TMH, TMS,
TMU function (instruction), UDT instructions cannot be used.
• When using KV-1000, the device No. identical with other TMR, TMH, TMS, CNT function
(instruction), OUTC, UDC, and UDT instructions can be used.
• Operation formulas can also be specified to setting values. Attention is required in the
following instances as the range in which operation formulas can be handled is -

BASIC FUNCTIONS
2147483648 to +2147483647:
g Operation formulas can also be specified to setting values. When the result of the
operation formula is a minus value, the value obtained by adding 4294967295 to the
result of the operation formula is set as the setting value.
g Attention is required when using this function in box scripts and programming this function
in sub-routines.
"Precautions About Use of Timer Device/ Counter Device", Page 4-40
5
"TMR function", Page 5-22.

Timer/counter Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-27


TMU 10μs 32-bit down timer

High-speed 10μs timer

TMU ([Timer execution condition,]*1 timer device, timer setting value)


Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Timer Specifies the device No. of the timer.(T0 to
- - - - - - - - - - -
device T3999)
S Timer Specifies the setting value of the timer in
*2 .D .D .D .D - - - - 嗟 嗟 嗟
BASIC FUNCTIONS

setting value 10μs units. (0 to 4294967295)


R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution condition
is OFF, the TMU function is reset.)
When the execution condition is omitted, use the RES function separately to reset the timer.
*2 When a bit device has been specified to the timer setting value, continuous 32 bits are occupied,
and when a word device has been specified, continuous two words are occupied.

5 Note
The TMU function can be used with the CPU function version 2.0 and higher CPU unit.
Timer/counter Function

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution condition is TRUE, the timer specified by D is ON. S becomes the current
value, and is decremented by 1 every 10μs. When the current value becomes "0", the specified timer
device (contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF
and the current value is reset.

Scan
ON

Execution conditon
OFF
Value set in S

Current value

#00000

ON
Timer T
U D

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual", 2-6 Timer/Counter
Instructions."

ƽ Example of format
TMU (R3000, T200, 100)
R3000 #100
T200
U
Execution conditon

TIP The error of the TMU instruction is "within f (10μs + 1 scan time)."

5-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
• When using KV-5500/5000/3000, the device No. identical with other TMR, TMH, TMS,
TMU function (instruction), UDT instructions cannot be used.
• Operation formulas can also be specified to setting values. Attention is required in the
following instances as the range in which operation formulas can be handled is -
2147483648 to +2147483647:
g Operation formulas can also be specified to setting values. When the result of the

BASIC FUNCTIONS
operation formula is a minus value, the value obtained by adding 4294967295 to the
result of the operation formula is set as the setting value.
g Attention is required when using this function in box scripts and programming this function
in sub-routines.
"Precautions About Use of Timer Device/ Counter Device", Page 4-40

"TMR function", Page 5-22.


5

Timer/counter Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-29


CNT 32 bit up counter

Counter

CNT ([Counter execution condition,]*1 counter device, counter setting value, input device)
Argument/Return Applicable Suffix Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Counter Specifies the device No. of the counter. (C0
- - - - - - - - - - -
device to C3999)
n Counter Specifies the setting value of the counter. (0
*2 .D .D .D .D - - - - 嗟 嗟 嗟
BASIC FUNCTIONS

setting value to 4294967295)


S Specifies the device to be used for count
Input device - - - - - - .B - - 嗟 嗟
input.
R Return value No - - - - - - - - - - -
*1 "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution condition
is OFF, the CNT function is reset.)
When the execution condition is omitted, use the RES function separately to reset the timer.
*2 When a bit device has been specified to the timer setting value, continuous 32 bits are occupied,
5 and when a word device has been specified, continuous two words are occupied.
Timer/counter Function

Description of Operation

When the execution condition TRUE, the timer specified by n is ON. S becomes the current
value, and is decremented by 1 every 1 ms. When the current value becomes "0", the specified timer
device (contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF
and the current value is reset
ON
R00000 ←Reset input #12 Count input S
C0000 OFF

R00001 ON
Execution conditon
OFF
C000
n
S1
11
8 9 10
7
6
4 5
2 3
D :Current value 1

ON
D :counter output contact

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual "2-6 Timer/Counter Instructions."

ƽ Example of format
CNT (R3000, C120, 1000, MR1000)
R3000 #1000
C120
Execution conditon MR1000

Note
• The device No. identical with instruction of OUTC and UDC cannot be used.
• When using KV-1000, the device No. identical with other TMR, TMH, TMS, CNT function
(instruction), OUTC, UDC, and UDT instructions can be used.
• Operation formulas can also be specified to setting values. Attention is required in the following
instances as the range in which operation formulas can be handled is -2147483648 to +2147483647:
g Operation formulas can also be specified to setting values. When the result of the
operation formula is a minus value, the value obtained by adding 4247483648 to the
result of the operation formula is set as the setting value.

5-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Reading and changing timer current values

Counter devices handle current values by specifying .D (unsigned 32-bit) as their suffix.

ƽ Reading the current value


Specify the counter device to the right side using an assignment statement, and specify the device to
store the current value of the read counter device to the left side.

BASIC FUNCTIONS
Programmed script DM1000.D = C100.D
Description of Operation The current value of C100.D is stored to DM1000.D.
Ladder conversion
CR2002 MOV.D
C100 DM1000
Always ON

ƽ Rewriting the current value


Specify the device to store the current value of the read counter device to the right side using an 5
assignment statement, and specify the counter device to the left side.

Timer/counter Function
Programmed script C100.D = DM1100.D
Description of Operation The current value of C100.D is rewritten to the value currently stored to DM1100.D.
Ladder conversion
CR2002 MOV.D
DM1100 C100
Always ON

Note
• When the current value is greater than the setting value when the current value is
rewritten, the current value is changed to the same value as the setting value.
• As unsigned 32-bit data is used for the counter setting value and current value of the CNT
function, unsigned 32-bit (.D) must be used for the devices to store the current value and
setting value and the data to change.
• To change the counter setting value or to read the setting value, specify a device
(unsigned 32-bit) to the setting value.
KV-5500/5000/3000/1000 Instruction Reference Manual", 2-6 Timer/Counter Instructions"

Reading counter contacts

Contacts are handled by specifying .B (bit type) as the suffix of the counter device.(.B can be omitted)
Programmed script MR1000 = C100.B
Description of Operation MR1000 is substituted with the contact state of C100.B.
Ladder conversion
C100 MR1000

Note
• Counter contacts cannot be substituted with other bit information.
To forcibly reset a counter, reset the counter contact by the RES function.
• When the counter device suffix is omitted, the counter device is handled as a bit type.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-31


Direct I/O Function

RFSX Input refresh

Refresh X

RFSX ([Execution condition,] *1 Leading device for changing input, number of relays)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Leading device
Specifies leading No. of device for changing
for refresh - - - - - - .B - - ƻ -
input status
input
n
BASIC FUNCTIONS

Number of Specifies number of relays for changing


*2 .U .U .U .U - - - - ƻ ƻ ƻ
relays input status. (1 to 256)
R Return value No - - - - - - - - - - -
*1 " [ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 When device is specified, continuous 16 bits are processed.
When relays other than the leading relay (e.g. R002, R1012) of a channel are specified, 16 bitsare

5 processed straddling the next channel. The number of relays can be specified within the range of 1 to
256.
Direct I/O Function

Note
RFSX function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

In general, this functioin can be used for executing END instruction in ladder, or when changing batch-
changing input by anything in 1 scan period.
When the execution condition is TRUE, status of inputs of n bit devices starting from D will be
changed.
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see KV-5500/5000/3000/1000 command reference manual," 2-8 Direct I/O command".

ƽ Example of format
RFSX (MR1000, R3000, 128)
MR1000 RFSX
R3000 #128
Execution conditon Input Refresh leading device Number of relay

5-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


RFSY Output refresh

Refresh Y
RFSY ([Execution condition,]*1 Leading device for changing output, number of relays)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Leading device
Specifies leading No. of device for changing
for changing - - - - - - .B - - ƻ -
output status
output
n

BASIC FUNCTIONS
Number of Specifies number of relays for changing
*2 .U .U .U .U - - - - ƻ ƻ ƻ
relays output status. (1 to 256)
R Return value No - - - - - - - - - - -
*1 " [ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 When device is specified, continuous 16 bits are processed.
When relays other than the leading relay (e.g. R002, R1012) of a channel are specified, 16 bitsare
processed straddling the next channel. The number of relays can be specified within the range of 1 to
256.
5

Direct I/O Function


Note
RFSY function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

In general, this functioin can be used for executing END instruction in ladder, or when changing batch-
changing output by anything in 1 scan period.
When the execution condition is TRUE, status of inputs of n bit devices starting from D will be
changed.
"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, please see KV-5500/5000/3000/1000 command reference manual," 2-8 Direct I/O command".

ƽ Example of format
RFSY (MR1000, R3000, 128)
MR1000 RFSY
R3000 #128
Execution conditon
Output Refresh leading device Number of relay

- KV-5500/5000/3000/1000 Series Script Programming Manual - 5-33


MEMO
BASIC FUNCTIONS

5
Direct I/O Function

5-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


6

APPLICATION FUNCTION
APPLICATION FUNCTION

Flow Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-2


Macro Functions •••••••••••••••••••••••••••••••••••••••••••••••••••••• 6-6
Module Functions••••••••••••••••••••••••••••••••••••••••••••••••••• 6-10
Index Register Functions ••••••••••••••••••••••••••••••••••••••••• 6-12
Indirect Specification Functions•••••••••••••••••••••••••••••••••• 6-18
File register Functions ••••••••••••••••••••••••••••••••••••••••••••• 6-28
Buffer memory Functions ••••••••••••••••••••••••••••••••••••••••• 6-34

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-1


Flow Functions

CALL Start specified sub-routine

Call

CALL ([Execution condition,]*1 Sub-routine No.)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
n Sub-routine Specifies the sub-routine No. to start up.(0
- - - - - - - - *2 ƻ - ƻ
No. to 99)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
APPLICATION FUNCTION

times (at every scan)).


*2 Specify sub-routine No. within the range of 0 to 99.Sub-routine No. cannot be specified by $ (HEX).

Description of Operation

When the execution condition is TRUE, the sub-routine specified by n is ON.


For details, see KV-5500/5000/3000/1000 Instruction Reference Manual, "3-5 Flow Instruction."

6 ƽ Example of format
Flow Functions

CALL (R3000, 10)


R3000 #10
CALL
Execution conditon

TIP The CALL function can be programmed down to a nesting level of 16.

Note
• Only constants can be specified as the sub-routine No. Devices or formulas cannot be
used.
• Sub-routine No. constants cannot be specified by $ (HEX).
• The SBN and RET instructions are not available by script functions. Program them in the
ladder.

• When the CALL instruction is not excuted (R1000=OFF) .

Program A
BMOV(DM1000,EM2000,20)
CALL(R1000,10)
ZRES(DM1000,DM1200)

Program B

• When the CALL instruction is executed (R1000˙ON)

SBN
Program A
ࡊࡠࠣ࡜ࡓ A #10
BMOV(DM1000,EM2000,20)
CALL(R1000,10) Subroutine
ZRES(DM1000,DM1200)
RET
Program B
ࡊࡠࠣ࡜ࡓ B

6-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Hint

Ƶ About the sub-routine nesting structure


• Sub-routine functions can be programmed down to
BMOV(DM1000,EM2000,20)
a nesting level of 16. CALL(R1000,10)
ZRES(DM1000,DM1200)
• To call a different sub-routine from inside a Program A

APPLICATION FUNCTION
subroutine, the sub-routine to be called must END

already be defined (programmed in the above rung).


SBN
#20

Subroutine A
RET

Call
SBN
#10

Subroutine B
6
BMOV(DM1200,EM2100,20)
CALL(R1100,20)

Flow Functions
ZRES(DM1100,DM1300)
RET

ENDH

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-3


ECALL Module sub-routine instruction

Ecall

Ecall ([Execution condition,]*1 "Module name (string)")


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Module name
Specify module name with text string. - - - - - - - - *2 ƻ - -
(Text string)
n Sub-routine No. Specify the sub-routine No. to call. - - - - - - - - *3 ƻ ƻ -
R Return value None - - - - - - - - - - -
APPLICATION FUNCTION

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Enter the macro name set on KV STUDIO enclosed by " ".
Up to 12 1-byte alphanumerics, and six 2-byte alphanumerics can be specified.
*3 Specify sub-routine No. within the range of 0 to 99.Sub-routine No. cannot be specified by $ (HEX).

Note
ECALL function cannot be used for CPU unit other than KV-1000 series.

6
Description of Operation
Flow Functions

When the execution condition is TRUE, Sub-routine n specified by Module S is executed.


All types of module (every scan, initialization, standup, fixed period) can be specified except macro.

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, please see KV-5500/5000/3000/1000 Instruction Reference Manual, "3-5 Flow Instruction."

ƽ Example of format
ECALL(MR1000, "Module 1",1)
MR1000 ECALL
“module 1” #1
Execution conditon

Note
• Sub-routine No. constants cannot be specified by $ (HEX).
• The SBN and RET instructions are not available by script functions. Program them in the
ladder.

6-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Flow Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-5


Macro Functions

MCALL Start sub-routine type macro

Macro call

MCALL ([Execution condition,]*1 "Macro name (Text string) " [,Macro argument 1,
Macro argument 2, Macro argument 3ĂĂ, Macro argument 10])
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S1 Macro name
Specifies the macro name by a text string. - - - - - - - - *3 ƻ - -
(Text string)
S2 Specifies the macro argument.(The number
Macro
APPLICATION FUNCTION

*2 of arguments differs according to the - - - - - - - - ƻ ƻ ƻ


argument*4
macro).
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 The number and attribute of macro argument devices differ according to the argument setting made to
the macro to execute.
"KV-5500/5000/3000/1000 instruction reference manual", MCALL instruction
*3 Enter the macro name set on KV STUDIO enclosed by " ".

6 *4
Up to 12 1-byte alphanumerics, and six 2-byte alphanumerics can be specified.
When an ID No. is used, the format becomes "(macro name)_(ID No.)". For example) Batch send_2
Macro Functions

For details on ID No.s, please see KV-5500/5000/3000 Series Manual, "Chapter 3-9 Macro."

Description of Operation

When the execution condition is TRUE, the sub-routine type macro specified by S1 is executed.
The argument specified by S2 is handed over to the macro. With macros, arguments are handled as
device No (P0 onwards) or constants (V0 onwards) according to the argument settings.
"About operation flag (CR2009 to CR2012)", Page 1-18 .
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-6 Macro instruction.

ƽ Example of format
MCALL (R3000, "Marco 1", DM1000, 10)
R3000 MCALL Macro 1
DM1000 #10
Execution conditon
Argument 1 Argument 2

Note
• Text strings other than sub-routine type macros enclosed by " " cannot be programmed as
macro names.
• When the MCALL function is handled in box scripts or in IF statements, attention is
required as OFF processing sometimes is not executed.
"KV-5500/5000/3000 series User Manual "3-9 Macro""

6-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MSTRT Start self-hold type macros

Macro start

MSTRT ([Execution condition,]*1 "Macro name (Text string) " [,Macro argument 1,
Macro argument 2, Macro argument 3ĂĂ, Macro argument 10]*2)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S1 Macro name
Specifies the macro name by a text string. - - - - - - - - *4 ƻ - -
(Text string)
S2 Specifies the macro argument.(The number
Macro

APPLICATION FUNCTION
*3 of arguments differs according to the - - - - - - - - ƻ ƻ ƻ
argument*5
macro).
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 The number and attribute of macro argument devices differ according to the argument setting made
tothe macro to execute.
*3 The number and attribute of macro argument devices differ according to the argument setting made to
the macro to execute.

*4
"KV-5500/5000/3000/1000 instruction reference manual", "MSTRT instruction"
Enter the macro name set on KV STUDIO enclosed by " ".
6

Macro Functions
Up to 12 1-byte alphanumerics, and six 2-byte alphanumerics can be specified.
*5 When an ID No. is used, the format becomes "(macro name)_(ID No.)". For example) Batch send_2
For details on ID Nos., Please see KV-5500/5000/3000 Series User's Manual, "3-9 Macro."

Description of Operation

When the execution condition is TRUE, the self-hold type macro specified by S1 is executed.
The argument specified by S2 is handed over to the macro. With macros, arguments are handled as
device Nos. (P0 onwards) or constants (V0 onwards) according to the argument settings.
"About operation flag (CR2009 to CR2012)", Page 1-18 .
For details, please see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-6 Macro instruction.

ƽ Example of format

MSTRT (R3000,ĀMacro2ā, DM1000, 10)


R3000 MSTRT Macro 2
DM1000 #10
Execution conditon
Argument 1 Argument 2

Note
• Text strings other than self-hold type macros enclosed by " " cannot beprogrammed as
macro names.
• When the MSTRT function is handled in box scripts or in IF statements, attention is
required as OFF processing sometimes is not executed.
"KV-5500/5000/3000 series User Manual "3-9 Macro""

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-7


MEND End self-hold type macros

Macro end

MEND ([Execution condition]*1 )


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
APPLICATION FUNCTION

Description of Operation

When the execution condition is TRUE, OFF processing is performed at the next scan, and execution is
stopped for self-hold type macros programmed with the MEND function.
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-6 Macro instruction.

ƽ Example of format
6 MEND (R3000 = OFF)
Macro Functions

R3000 MEND

Execution conditon

TIP "MSTRT function", Page 6-7

Note
• The MEND function can be used only when the content of a self-hold type macro is
programmed by a script.
• At least one MEND function (instruction) must be programmed in self-hold type macros.

6-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Macro Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-9


Module Functions

MDSTRT Module execution start

Module start

MDSTRT ([Execution condition,]*1 "Module name (Text string)")


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S Module name
Specifies the module name by a text string. - - - - - - - - *2 ƻ - -
(Text string)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
APPLICATION FUNCTION

times (at every scan)).


*2 Enter the macro name set on KV STUDIO enclosed by " ".
Up to 12 1-byte alphanumerics, and six 2-byte alphanumerics can be specified.

Note
MDSTRT function can be used only by KV STUDIO ver.4 or later.

6 Description of Operation
Module Functions

When the execution condition is TRUE, Module S is executed.


The module in ON status operates from next scan period.
No operation is executed when the module is ON.
"About operation flag (CR2009 to CR2012)", Page 1-18 .
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-7 Module instruction.

ƽ Example of format
MDSTRT (MR1000, "Module 1")
MR1000 MDSTRT
Module 1
Execution conditon

Note
• As the default status at the start of the module execution, the differential execution type
instruction turns ON when the rising edge is detected, and turns OFF when the falling edge is
detected. The differential sign cannot be detected immediately in initial execution stage.
• When MDSTRT and MDSTOP function instruction are required to be executed for many times
for the same module in the same scan period, the final module instruction is executed.
• Execution of initialization module cannot be stopped or started.

6-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MDSTOP Module execution stop
Module

MDSTOP ([Execution condition,]*1 "Module name (Text string)")


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S Module name
Specifies the module name by a text string. - - - - - - - - *2 ƻ - -
(Text string)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all

APPLICATION FUNCTION
times (at every scan)).
*2 Enter the macro name set on KV STUDIO enclosed by " ".
Up to 12 1-byte alphanumerics, and six 2-byte alphanumerics can be specified.

Note
MDSTOP function can be used only by KV STUDIO ver.4 or later.

Description of Operation 6
When the execution condition is TRUE, Module S is executed.

Module Functions
The specified module is stopped after OFF processing in next scan period.
No operation is executed when the module is ON.
The instruction can stop its own module.

"About operation flag (CR2009 to CR2012)", Page 1-18 .


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-7 Module instruction.

ƽ Example of format
MDSTOP (MR1000, "Module 1")
MR1000 MDSTOP
Module 1
Execution conditon

Note
• If MDSTRT function (instruction) and MDSTOP function (instruction) are executed the same
module multiple times in the same scan, the module instruction executed last will be followed.
• Do not stop all modules. Under this circumstance, please restore by using any method. (Only
after the program is stopped.)
• Cut off the power supply of KV-5500/5000/3000/1000 PLC once, and power on
again.
• Toggle selector switch "RUN-PROG" of KV-5500/5000/3000/1000 PLC to "PROG"
mode.
• In KV STUDIO, turn RUN mode to OFF, then ON again.
• For off processing, only 1 scan period is ON for the process idential with the execution condition
of "MC instruction". For detailed, see "KV-5500/5000/3000/1000 Instruction Reference
Manual", MC instruction.
• Execution of initialization module cannot be stopped or started.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-11


Index Register Functions

ZPUSH Batch purge of index register

Zpush

ZPUSH ([Execution condition,]*1 Purge destination device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
D Purge
Specifies the leading device of the purge *3 *3 *4 *4
destination .S .S .L .L - - - - - ƻ -
*2 destination data block.
device
R Return value None - - - - - - - - - - -
APPLICATION FUNCTION

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 gT,C,CR,CTC,CTH,Z cannot be used.
*3 When the type of device for store destination is specified in .S:
gA minimum of 13 continuous words is occupied. When nesting functions, "number of register purges x
12 words + 1" words are occupied.
gWhen KV-5500/5000/3000 is used, only lower 16 bits are processed.
*4 When the type of device for store destination is specified in .L:
gContinuous 25 words are occupied. When nesting functions, "number of register purges x 24 words +
6 1" words are occupied.
gFor KV-1000, it is processed as .S.
Index Register Functions

Note
For Z (index register), when KV-5500/5000/3000 is used, it is processed as .L (signed 32-
bit); for KV-1000, it is processed as .S (signed 16-bit).

Operation description

When the execution condition is TRUE, the values of Z1 to Z10 index registers are stored in the data
block specified by D . After the function is executed, the value of [ D +0˹is incremented by 1.

Note
• Before the execution of initial ZPUSH function,[ D +0] is set to 0.This is not necessary
from the second "ZPUSH function" onwards.
• The "ZPUSH function" and "ZPOP function" are used as a pair.
• Do not write to the range of D occupied by the "ZPUSH function" in other functions and instructions.
• When the data block range exceeds the device range, the function is not executed.

"About operation flag (CR2009 to CR2012)", Page 1-18.

Ƶ When using KV-5500/5000/3000


• D : 32-bit purge destination device

bit bit bit bit


31 16 15 0

bit
31
bit bit
16 15
bit
0
Save times D +0

Z1 Z1 D +1 D +2

Z2 Z2 D +3 D +4

Z10 Z10 D +19 D +20


Reserved for system Reserved for system D +21 D +22
Reserved for system Reserved for system D +23 D +24

6-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


TIP "The "ZPUSH function" and ZPOP function" are programmed nested. When nesting these
functions, specify the same leading device.

bit bit bit bit


31 16 15 0
ZPUSH
DM0 3 DM0

Z1 DM1࡮DM2
ZPUSH
DM0

APPLICATION FUNCTION
ZPUSH Reserved for system DM23࡮DM24
DM0
Z1 DM25࡮DM26
ZPOP
DM0
Reserved for system DM47࡮DM48
ZPOP
DM0 Z1 DM49࡮DM50

ZPOP
DM0 Reserved for system DM71࡮DM72

• D : 16-bit purge destination device 6

Index Register Functions


bit bit
15 0

bit
31
bit bit
16 15
bit
0
Save times D +0

Z1 (High) Z1 (Low) Z1 (Low) D +1

Z2 (High) Z2 (Low) Z2 (Low) D +2


Z10 (High) Z10 (Low) Z10 (Low) D +10


Reserved for system Reserved for system
(High) (low) (low) D +11
Reserved for system Reserved for system
(High) (low) (low) D +12

Note
For KV-5500/5000/3000, Z (index register) is processed as .L (signed 32-bit). When 16-bit
type suffix (.S, .U) is specified in D , only 16 bits are stored in D , and higher 16 bits
are discarded.
The stored value cannot be restored even if the ZPOP function (instruction) is used.
When the values used in program exceed .S (-32768 to +32767), please do not specify .S in
D .

Ƶ When using KV-1000

bit bit
15 0

bit
15
bit
0
Save times D +0

Z1 Z1 D +1

Z2 Z2 D +2

Z10 Z10 D +10


Reserved for system Reserved for system D +11
Reserved for system Reserved for system D +12

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-13


ƽ Example of format
ZPUSH (MR3000, DM1000.L)
MR1000 ZPUSH.L
DM1000
Execution conditon
Return value

For details, see "KV-5500/5000/3000/1000", 3-8 Index register instruction.


APPLICATION FUNCTION

6
Index Register Functions

6-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Index Register Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-15


ZPOP Batch restore of index registers

ZPop

ZPOP ([Execution condition,]*1 Purge destination device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
D Purge
Specifies the leading device of the purge *3 *3 *4 *4
destination .S .S .L .L - - - - - ƻ -
*2 destination data block.
device
R Return value None - - - - - - - - - - -
APPLICATION FUNCTION

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 T,C,CR,CTC,CTH,Z cannot be used.
*3 When the type of device for store destination is specified in .S:
gA minimum of 13 continuous words is occupied. When nesting functions, "number of register purges x
12 words + 1" words are occupied.
gWhen KV-5500/5000/3000 is used, only lower 16 bits are processed.
*4 When the type of device for store destination is specified in .L:
6 gContinuous 25 words are occupied. When nesting functions, "number of register purges x 24 words +
1" words are occupied.
Index Register Functions

g For KV-1000, it is processed as .S.

Note
For Z (index register), when KV-5500/5000/3000 is used, it is processed as .L (signed 32-
bit); for KV-1000, it is processed as .S (signed 16-bit).

Description of Operation

When the execution condition is TRUE, the values of Z1 to Z10 index registers are stored in the data
block (index register stored in ZPUSH function) specified by D . After the function is executed, the
value of [ D +0˹is incremented by 1.

Note
• The "ZPUSH function" and "ZPOP function" are used as a pair.
• The function is not executed when either of the following conditions is TRUE:
g [ D +0] is "0".
g When the data block range exceeds the device range

"About operation flag (CR2009 to CR2012)", Page 1-18.

Ƶ When using KV-5500/5000/3000


• D : 32-bit purge destination device
bit bit bit bit
31 16 15 0

D +0 Saving times bit


31
bit bit
16 15
bit
0

D +1 D +2 Z1 Z1
D +3 D +4 Z2 Z2

D +19 D +20 Z10 Z10


D +21 D +22 Reserved for system Reserved for system

D +23 D +24 Reserved for system Reserved for system

6-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


• D : 16-bit purge destination device
bit bit
15 0

D +0 Saving times bit


30
bit bit
16 15
bit
0

D +1 Z1 Z1
D +2 Z2 Z2


Extend signal to L and then restore
D +10 Z10 Z10

APPLICATION FUNCTION
D +11 Reserved for system Reserved for system

D +12 Reserved for system Reserved for system

Note
For KV-5500/5000/3000, Z (index register) is processed as .L (signed 32-bit). When 16-bit
type suffix (.S, .U) is specified in D , only 16 bits are stored in D , and higher 16 bits
are discarded.
The stored value cannot be restored even if the ZPOP function (instruction) is used.
When the values used in program exceed .S (-32768 to +32767), please do not specify .S in
D
6
.

Index Register Functions


Ƶ When using KV-1000

bit bit
15 0

D +0 Save times bit


15
bit
0

D +1 Z1 Z1
D +2 Z2 Z2

D +10 Z10 Z10


Reserved Reserved
D +11 for system for system

Reserved Reserved
D +12 for system for system

ƽ Example of format
ZPUSH (MR3000, DM1000.L)
MR1000 ZPOP.L
DM1000
Execution conditon
Return value

For details, see "KV-5000/3000/1000", 3-8 Index register instruction.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-17


Indirect Specification Functions

ADRSET Stored address of indirect specification device

Set address

ADRSET ([Execution condition,]*1 indirect specification device, destination \


store address)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S Indirect *4
Specifies the device to be indirectly
specification .U .S .D .L .F .DF .B .T - ƻ -
specified.
device
D
APPLICATION FUNCTION

Destination Specifies the the device to be indirectly


store stored. - - .D .D - - - - - ƻ -
*2
device*3
R Return value None. - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Continuous two words are used.
*3 Only DM, W, EM, ZF, FM can be specified.
*4 gThe .DF suffix can be used only when the compatible model is a CPU function version 2.0 or higher

6 CPU unit.
gThe ".DF" suffix cannot be specified for device Z.
Indirect Specification Functions

Description of Operation

When the execution condition is TRUE, the address of S is stored in continuous two words starting
from D . After the addresses are stored, the result will be identical with that indirectly specified by
S when the function is programmed by indirect specification (* destination Store device).

D +1 D The "address" of S , rather than the values specified by


S , is stored in [ D g D +1].
S Address for S *
* All devices specified by S , other
addresses (two words) are assigned
internally on the CPU.

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-9 Indirect specified instruction.

ƽ Example of format
BSET (R3000, DM1000, 10)
R3000 ADRSET
DM1000 DM2000
Execution conditon
Indirect Store
designation device destination device

Note
• Two continuous words starting from the specified device No. are always occupied as the
address destination Store device.
• Before indirect specification (* destination Store device) is used, be sure to set the indirect
specification device to the destination Store device by the ADRSET function.
• Be sure to use the ADRSET, ADRINC, ADRDEC, ADRADD, and ADRSUB functions to
generate and manipulate addresses.

6-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When specifying a bit device to the indirect specification device


Programmed script ADRSET ( R3000, MR1000, DM2000.D )
Description of Operation When R3000 is ON, the address of bit device MR1000 is stored in DM2000.D.
(one point lookup)
Ladder conversion

APPLICATION FUNCTION
R3000 ADRSET
MR1000 DM2000
Execution conditon
Indirect Save
designation device destination device

ƽ When using an index register


Programmed script ADRSET ( DM1000:Z1, DM2000.D:Z1 )
Description of Operation The address of the DM (1000+Z1) is stored in DM (2000+Z1) .D at every scan (no execution
condition).
Ladder conversion
CR2002 ADRSET
DM1000:Z01 DM2000:Z01
6
Always ON

Indirect Specification Functions


Indirect Save
designation device destination device

Hint

When the address of a bit device is used for indirect specification, the address is processed as a word
device if the suffix is omitted. To process the address as a bit device, modify it by the .B suffix.

Programmed script ADRSET (R1000, DM1000.D)


MR2000 = LDP (*DM1000.B)
Description of Operation The address of R1000 is stored in DM1000.D.
*When the up edge of *DM1000.B(R1000) is detected, MR2000 is turned ON for one scan.

TIP "LDP function", Page 5-2

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-19


ADRINC Add 1 to stored address

Increment address

ADRINC ([Execution condition,]*1 Address Store device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
D Address Store Specifies the device to which the indirect
*2 - - .D .D - - - - - ƻ -
device*3 specification address is currently stored.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
APPLICATION FUNCTION

times (at every scan)).


*2 Continuous two words are used.
*3 Only DM, W, EM, ZF, FM can be specified.

Description of Operation

When the execution condition is TRUE, the indirect specification address currently stored in D

becomes the next address. When a word device address is currently stored, this indicates the address
6 of the next word device, or when a bit device address is currently stored, this indicates the address of
the next bit device.
Indirect Specification Functions

Adds 1 to the address currently stored in D .

D +1 D D +1 D
Address Address ˇ1

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-9 Indirect specified instruction.

ƽ Example of format
ADRINC (R3000, DM2000.D)

R3000 ADRINC
DM2000
Execution conditon
Address store Device

Note
• Two continuous words starting from the specified device No. are always occupied as the
address Store device.
• Before the ADRINC function is used, be sure to set the indirect specification address to
the address Store device by the ADRSET function.
• Be sure to use the ADRSET, ADRINC, ADRDEC, ADRADD, and ADRSUB functions to
generate and manipulate addresses.
• The function is not executed when either of the following conditions is TRUE:
g D is inappropriate
g The address is inappropriate after the increment.

6-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When using an index register


Programmed script ADRNIC (R3000, DM2000.D:Z1)
Description of Operation When the R3000 is ON, the indirect specification address currently stored in DM(2000+Z1).
D is the next address.*

APPLICATION FUNCTION
Ladder conversion

R3000 ADRINC
DM2000:Z01
Execution conditon
Address store Device

*Before execution, the address must be stored in DM2000.D by the ADRSET function (instruction).

Hint

When the currently stored address is a bit device, the ADRINC function indicates the next bit device.
When the address straddles channels at this time, the address becomes the address of the next
6
channel.

Indirect Specification Functions


Programmed script ADRINC (R3015, DM1000.D)
ADRINC (*DM1000.B = ON, DM1000.D)
SET( *DM1000.B)
Description of Operation The address of bit device R3015 is stored in DM1000.
㪁When DM1000.B(R3015) is ON, the address stored in 㪁DM1000 is incremented by 1, and
*DM1000.B(R3100) is set.

TIP "ADRSET function", Page 6-18


"SET function", Page 5-12

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-21


ADRDEC Decrement stored address by 1
Decrement address

ADRDEC ([Execution condition,] *1 Address Store device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
D Address Store Specifies the device to which the indirect
*2 - - .D .D - - - - - ƻ -
device*3 specification address is currently stored.
R Return None - - - - - - - - - - -
*1 "[ ]" can be omitted.(When the execution condition has been omitted, the instruction is executed at all
APPLICATION FUNCTION

times (at every scan)).


*2 Continuous two words are used.
*3 Only DM, W, EM, ZF, FM can be specified.

Description of Operation

When the execution condition is TRUE, the indirect specification address currently stored in D is
made into the previous address. When a word device address is currently stored, this indicates the
6 address of the previous word device, or when a bit device address is currently stored, this indicates the
address of the previous bit device.
Indirect Specification Functions

The address currently stored in D is subtracted by 1.

D +1 D D +1 D
Address Address ˉ1

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-9 Indirect specified instruction.

ƽ Example of format
ADRDEC (R3000, DM2000.D)

R3000 ADRDEC
DM2000
Execution conditon
Address store Device

Note
• Two continuous words starting from the specified device No. are always occupied as the
address store device.
• Before the ADRDEC function is used, be sure to set the indirect specification address to
the address Store device by the ADRSET function.
• Be sure to use the ADRSET, ADRINC, ADRDEC, ADRADD, and ADRSUB functions to
generate and manipulate addresses.
• The function is not executed when either of the following conditions is TRUE:
g D is inappropriate
g The address is inappropriate after the decrement.

6-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When using an index register


Programmed script ADRDEC (R3000, DM2000.D:Z1)
Description of Operation When the R3000 is ON, the indirect specification address currently stored in DM(2000+Z1).
Dis made into the previous address.*

APPLICATION FUNCTION
Ladder conversion

R3000 ADRDEC
DM2000:Z01
Execution conditon
Address store Device

*Before execution, the address must be stored in DM2000.D by the ADRSET function (instruction).

Hint

When the currently stored address is a bit device, the ADRDEC function indicates the previous bit
device. When the address straddles channels at this time, the address becomes the address of the
6
previous channel.

Indirect Specification Functions


Programmed script ADRSET (R3100, DM1000.D)
ADRDEC (*DM1000.B = ON, DM1000.D)
SET( *DM1000.B)
Description of Operation The address of bit device R3100 is stored in DM1000.D.
*When DM1000.B(R3100) is ON, the address stored in DM1000.D is incremented by 1, and
*DM1000.B(R3015) is set.

TIP "ADRSET function", Page 6-18


"SET function", Page 5-12

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-23


ADRADD Add stored address

Add address

ADRADD ([Execution condition,]*1 Address add value, address store device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S Address Specifies the address add data or the device
.S .S .L .L - - - - ƻ ƻ ƻ
add value to which the data is currently stored.
D Specifies the device to which the indirect
Address store
specification address is currently stored. - - .D .D - - - - - ƻ -
APPLICATION FUNCTION

*2
device
(Continuous two words are used.)
R Return value None. - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Only DM, W, EM, ZF, FM can be specified.

Description of Operation

6 When the execution condition is TRUE, the indirect specification address currently stored in
into the address by adding S . When the address of the word device is currently stored, this indicates
D is made
Indirect Specification Functions

only address of the word device of address add value is added, or when the address of the bit device is
currently stored, this indicates only bit address of the bit device is added.

S is subtracted from the address in D .

D +1 D S D +1 D
Address + Value of S Value of address + S

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-9 Indirect specified instruction.

ƽ Example of format
ADRADD (R3000, DM1000.S,DM2000.D)
R3000 ADRADD
DM1000 DM2000
Execution conditon
Address Address
addition value store Device

Note
• Two continuous words starting from the specified device No. are always occupied as the
address store device.
• Before the ADRADD function is used, be sure to set the indirect specification address to
the address store device by the ADRSET function.
• Be sure to use the ADRSET, ADRINC, ADRDEC, ADRADD, and ADRSUB functions to
generate and manipulate addresses.
• The function is not executed when either of the following conditions is TRUE:
g D is inappropriate
g The address is inappropriateafter the increment.

6-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

When a device address is used for indirect specification, the indirect specification device (㪁DM1000,
etc.) is processed as a 16-bit device. To handle the device as a 32-bit device, add the .D(.L) suffix.
The ADRADD function is handy when handling 32-bit data as it indicates the device No. obtained by
adding the value specified by the address add value.

APPLICATION FUNCTION
Programmed script ADRSET (DM2000, DM1000.D)
*DM1000.D += 1
ADRADD (2,DM1000.D)
*DM1000.D += 1
Description of Operation The address of DM2000 is stored to DM1000.D
"1" is added to the stored address as a 32-bit device.
"2" is added to the address stored to DM1000.D, and "1" is added to the next 32-bit address
(DM2002.D).
6
TIP "ADRSET function", Page 6-18

Indirect Specification Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-25


ADRSUB Subtract stored address

Subtract address

ADRSUB ([Execution condition,]*1 Address subtract value, address store device)


Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
S Address Specifies the address subtract data or the
.S .S .L .L - - - - ƻ ƻ ƻ
subtract value device to which the data is currently stored.
D Specifies the device to which the indirect
Address store
specification address is currently - - .D .D - - - - - ƻ -
APPLICATION FUNCTION

*2
device
stored.(Continuous two words are used.)
R Return value None. - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Only DM, W, EM, ZF, FM can be specified.

Description of Operation

6 When the execution condition is TRUE, the indirect specification address currently stored in
the address obtained by subtracting S . When the address of the word device is currently stored, this
D is made into
Indirect Specification Functions

indicates the address of the word device that is obtained by subtracting the address subtract value, or when the
address of the bit device is currently stored, this indicates the bit device obtained by subtracting the address
subtract value.

S is subtracted from the address in D .

D +1 D S D +1 D
Address ˉ Value of S Value of address ˉ S

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-9 Indirect specified instruction.

ƽ Example of format
ADRSUB (R3000, DM1000.S,DM2000.D)
R3000 ADRSUB
DM1000 DM2000
Execution conditon
Address Address
subtraction value store Device

Note
• Two continuous words starting from the specified device No. are always occupied as the
address store device.
• Before the ADRSUB function is used, be sure to set the indirect specification address to
the address store device by the ADRSET function.
• Be sure to use the ADRSET, ADRINC, ADRDEC, ADRADD, and ADRSUB functions to
generate and manipulate addresses.
• The function is not executed when either of the following conditions is TRUE:
g D is inappropriate
g The address is inappropriate after the decrement.

6-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

When a device address is stored for indirect specification, the indirect specification device (*DM1000,
etc.) is handled as a 16-bit device. To handle the device as a 32-bit device, add the .D(.L) suffix.
The ADRSUB function is handy when handling 32-bit data as it indicates the device No. obtained by
adding the value specified by the address add value.

APPLICATION FUNCTION
Programmed script ADRSET (DM2000, DM1000.D)
*DM1000.D += 1
ADRSUB (2,DM1000.D)
* DM1000.D += 1
Description of Operation The address of DM2000 is stored in DM1000.D
"1" is added to the store address as a 32-bit device.
"2" is subtracted from the address stored in DM1000.D, and "1" is added to the previous 32-
bit address (DM1998.D).
6
TIP "ADRSET function", Page 6-18

Indirect Specification Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-27


File register Functions

FRSET Switch file register mode

Switch mode
FRSET ([Execution condition,]*1 Bank No.)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n Specifies canlender bank No. after ƻ
Bank No. .U .U .U .U - - - - *2
ƻ ƻ
switching. (0 to 3)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
APPLICATION FUNCTION

times (at every scan)).


*2 Please specify file No. within the range of 0 to 3.

Note
FRSET function cannot be used for CPU unit other than KV-1000 series.

Description of Operation
6 When the execution condition is TRUE, switch the current file register No. to n .
File register Functions

For operation flag change, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-10 File register instruction.

ƽ Example of format
FRSET (MR1000, 2)
MR1000 FRSET
#2
Execution conditon

6-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

File register Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-29


FRSTM Batch-store file register

Batch-store file register


Return value*1 =FRSTM (Bank No., File No., result store device)
*4
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n Bank No. Specifies file No. to store data.(0 to 3) .U .U .U .U - - - - ƻ
*2
ƻ ƻ
Specifies the leading No. of bit device for
S File No. notifying the store result. .U .U .U .U - - - - *3 ƻ ƻ ƻ
(0 to 999)
APPLICATION FUNCTION

D Result store Specifies the bit device for notifying the


- - - - - - .B - - - ƻ -
device *5 store result.
R ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started, otherwise OFF.
*1 The return value can be omitted. When omitted, the operation result is stored in the internal registers.
*2 Please specify the number of data within the rang of 0 to 3.
*3 Please specify the number of data within the range of 0 to 999.
*4 T,C,CTC,CTH,Z cannot be specified.
*5 When a bit device has been specified to the store result Store device, continuous two bits are used as
6 the notification bit. When a word device has been specified, each of the LSBs of continuous two words is
used as the notification bit device.
File register Functions

Note
FRSTM function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

When the execution condition is TRUE, the data in n file register is batch-stored in memory card
in BIN bits as the file name specified by S .
The write complete notification and abnormality end warning is stored in D .
When the FRSTMfunction is started normally, R is ON, otherwise OFF.

TIP gThe file name stored in memory card is "\FR\FR (file NO. 3-digit) .FRB"
(Example) When 10 is specified by S , read "\FR\FR010.FRB"
gMeaning of notification bit of D
(Example) when MR2000 is specified,
notification bit is ON (1,TRUE) OFF (1,FALSE)
End
MR2000 Completed Not completed
notification
Error
MR2001 Normal end Abnormal end
notification

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-10 File register instruction.

6-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1000 = FRSTM (1, 10, MR2000)
CR3214 @VB01

Execute command of
memory card in progress

@VB00

APPLICATION FUNCTION
RES

CR3214 CJ
#2000
Execute command of
memory card in progress

FOR
#2

@VB00 FRSTM
#1 #10 MR2000
Bank No. File No. Save result
save device
6
@VB00 @VB00

File register Functions


SET

NEXT

LABEL
#2000

@VB01 MR1000

Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-31


FRLDM Batch-read file register

Batch- read file register


Return value*1 =FRLDM (Bank No., File No., result store device)
*4
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n Specifies the bank No. of file register to ƻ
Bank No. .U .U .U .U - - - - *2
ƻ ƻ
be batch-read. (0 to 3)
S Specify file No. of memory card to be ƻ
File No. .U .U .U .U - - - - *3
ƻ ƻ
read. (0 to 999)
APPLICATION FUNCTION

D Read result
Specifies the leading No. of device for
store - - - - - - .B - - - ƻ -
notifying read result
device*5
R ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started, otherwise OFF.
*1 The return value can be omitted. When omitted, the operation result is stored in the internal registers.
*2 Please specify the number of data within the range of 0 to 3.
*3 Please specify the number of data within the range of 0 to 999.
*4 T,C,CTC,CTH,Z cannot be specified.
6 *5 When a bit device has been specified to the read result store device, continuous two bits are used as the
notification bit. When a word device has been specified, each of the LSBs of continuous two words is
File register Functions

used as the notification bit device.

Note
FRLDM function cannot be used for CPU other than KV-1000 series.

Description of Operation

When the execution condition is TRUE, the data (\FR\FR(file No. 3-digit) specified by S can be
read from memory card, and stored in n file register.
The write complete notification and abnormality end warning is stored in D .
When the FRSTMfunction is started normally, R is ON, otherwise OFF.

TIP gThe file name read from memory card is "\FR\FR(File No. 3 digit).FRB"
(Example) When 10 is specified by S , read "\FR\FR010.FRB"
gMeaning of notification bit of D
(Example) when MR2000 is specified,
notification bit is ON (1, TRUE) OFF (1, FALSE)
End
MR2000 Completed Not completed
notification
Error
MR2001 Normal end Abnormal end
notification

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-10 File register instruction.

6-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1000 = FRSTM (1, 10, MR2000)
CR3214 @VB01

Execute command of
memory card in progress

@VB01

APPLICATION FUNCTION
RES

CR3214 CJ
#2000
Execute command of
memory card in progress

FOR
#2

@VB00 FRLDM
#1 #10 MR2000
Bank No. File No. Write result
store device
6
@VB00 @VB00

File register Functions


SET

NEXT

LABEL
#2000

@VB01 MR1000

Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-33


Buffer memory Functions

UREAD Read buffer

Read buffer
UREAD*1 ([Execution condition,]*1 Unit No., leading buffer address,
Leading read data store device, number of read data)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n1 Specifies expansion special unit/KV-5000
Unit No. *2 .U .U .U .U - - - - *2 ƻ ƻ ƻ
of buffer for data to be read. (0 to 63)
n2 Leading buffer Specify leading buffer device for data to
.U .U .U .U - - - - *3 ƻ ƻ ƻ
address *3
APPLICATION FUNCTION

be read(0 to 32767)
D Leading read data Specify leading device for read data to be
.U .S .D .L .F - - - - ƻ -
store device*5 stored.
n3 Number of read Specify number of data read from buffer.
.U .U .U .U - - - - ƻ ƻ ƻ
data*4 (1 to 32768)
R Return value None - - - - - - - - - ƻ -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Please specify the number of data within the range of 0 to 63."$(HEX)" is cannot be specified.
*3 Please specify the number of data within the range of 0 to 32767.
6 *4 Please specify the number of data within the range of 1 to 32768.
*5 CTC,CTH,Z cannot be specified.
Buffer memory Functions

Note
UREAD function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

When execution condition is TRUE, read buffer of n1 connected with CPU unit, adress of n2

and n3 data (16-bit word data), and stored them in D .

"About operation flag (CR2009 to CR2012)", Page 1-18.


For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-11 Buffer memory instruction.

ƽ Example of format
UREAD (MR1000, 3, DM1200, DM1000, DM1100)
MR1000 UREAD
#3 DM1200 DM1000 DM1100
Execution conditon
Unit No. Leading address Read data store Number of read data
for buffer memory object leading device

6-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


UWRIT Write buffer

Write buffer
UWRIT ([Execution condition,]*1 Unit No., leading buffer address
Leading write data device, number of write data)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n1 Specifies expansion special unit/KV-5000
Unit No. *2 .U .U .U .U - - - - *2 ƻ ƻ ƻ
of buffer for data to be written. (0 to 63)
n2 Leading buffer Specify leading buffer device or data to be
.U .U .U .U - - - - *3 ƻ ƻ ƻ
address *3

APPLICATION FUNCTION
read. (0 to 32767)
S Leading write data Specify leading buffer device for data to
.U .S .D .L .F - - ƻ ƻ *6 ƻ
device*5 be written.
n3 Number of write Read number of data within specified
.U .U .U .U - - - - ƻ ƻ ƻ
data *4 range. (1 to 32768)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).
*2 Please specify the number of data within the range of 0 to 63."$(HEX)" is cannot be specified.
*3 Please specify the number of data within the range of 0 to 32767.
*4 Please specify the number of data within the range of 1 to 32768.
6
*5 CTC,CTH,Z cannot be specified.

Buffer memory Functions


*6 The text string operation can only be specified. Operation other than text string operation (e.g.
DM0+DM2) cannot be programmed.

Note
UWRIT function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

When execution condition is TRUE, n3 data of device stored in the address of n2 starting from
S are written into the buffer of n1 connected with CPU unit.

• S : When transfer source device is 16-bit (.U/.S)


CPU device Buffer memory

S Write n2

S +1 Write n2 +1
S +2 Write n2 
Ă

S + n3 -2 Write n2 + n3 -2

S + n3 -1 Write n2 + n3 -1

• S : When transfer source device is 32-bit (.D/.L/.F)


CPU device Buffer memory
[ S S +1] Transfer [ n2 n2 +1]
[ S +2 S +3] Transfer [ n2 +2 n2 +3]
Ă

[ S +2(n-2) S +2(n-2)+1] Transfer [ n2 +2(n-2) n2 +2(n-2)+1]


[ S +2(n-1) S +2(n-1)+1] Transfer [ n2 +2(n-1) n2 +2(n-1)+1]

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-35


TIP g When the constant is specified in S , UWRIT function executes the operation identical
with UFILL function.
"UFILL function", Page 6-38

For operation flag change, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-11 Buffer memory instruction.

ƽ Example of format
APPLICATION FUNCTION

UWRIT(MR1000, 3, 1000, DM3000.U, 5)


MR1000 UWRIT
#3 #1000 DM3000 #5
Execution conditon
Unit No. Leading address Write data store Number of write data
for buffer memory object leading device

CPU device Buffer memory

6 DM3000:
DM3001:
1
3
1
3
:#1000
:#1001
DM3002: 7 7 :#1002
Buffer memory Functions

DM3003: 15 15 :#1003
DM3004: 31 31 :#1004
16 bits 16 bits
(1 word) (1 word)

6-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Buffer memory Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-37


UFILL Insert same value in data string of buffer

Buffer file
UFILL ([Execution condition,]*1 Unit No., Leading buffer address,
Leading write data store device, number of write data)
Argument/Return Recognized Type Const
Explanation Device Formula
value .U .S .D .L .F .DF .B .T #/$
n1 Specifies expansion special unit/KV-5000
Unit No. *2 .U .U .U .U - - - - *2 ƻ ƻ ƻ
of buffer for data to be written. (0 to 63)
n2 Leading buffer Specify leading device of buffer memory
.U .U .U .U - - - - *3 ƻ ƻ ƻ
address *3
APPLICATION FUNCTION

for data to be read. (0 to 32767)


S Leading write
Specifies the device for the data to be
data store .U .S .D .L .F - - - ƻ ƻ ƻ
written or stored.
device*5
n3 Number of write Read number of data within specified
.U .U .U .U - - - - ƻ ƻ ƻ
data*4 range. (1 to 32768)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan)).
*2 Please specify the number of data within 0 to 63."$(HEX)" is cannot be specified.
6 *3 Please specify the number of data within 0 to 32767.
*4 Please specify the number of data within 1 to 32768.
Buffer memory Functions

*5 CTC,CTH,Z cannot be specified.

Note
UFILL function cannot be used for CPU unit other than KV-1000 series.

Description of Operation

When execution condition is TRUE, data stored in the address of n2 in S are batch-written into
the buffer of n1 connected with CPU unit in three batches.

• S : When transfer source device is 16-bit (.U/.S)


CPU device Buffer memory

n2

n2 +1
n2 
Ă

n2 + n3 -3

n2 + n3 -2

n2 + n3 -1

6-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


• S : When transfer source device is 32-bit (.D/.L/.F)

CPU device Buffer memory

[ n2 n2 +1]

[ n2 +2 n2 +3]

[ n2 +4 n2 +5]

Ă
[ S S +1]

APPLICATION FUNCTION
[ n2 +2(n-3) n2 +2(n-3)+1]

[ n2 +2(n-2) n2 +2(n-2)+1]

[ n2 +2(n-1) n2 +2(n-1)+1]

For operation flag change, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details, see "KV-5500/5000/3000/1000 Instruction Reference Manual", 3-11 Buffer memory instruction.

ƽ Example of format
UWRIT(MR1000, 3, 1000, DM3000.U, 5) 6

Buffer memory Functions


MR1000 UFILL
#3 #1000 DM3000 #5
Execution conditon Leading address Write data store device Number of write data
Unit No.
for buffer memory

CPU device Buffer memory


123 :#1000
123 :#1001
DM3000: 123 123 :#1002
16 bits
(1 word) 123 :#1003
123 :#1004
16 bits
(1 word)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 6-39


MEMO
APPLICATION FUNCTION

6
Buffer memory Functions

6-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


7

ARITHMETIC OPERATION FUNCTIONS


ARITHMETIC
OPERATION FUNCTIONS

Data Move Function•••••••••••••••••••••••••••••••••••••••••••••••••• 7-2


Arithmetic Operation Functions •••••••••••••••••••••••••••••••••• 7-16
Logic Operation Functions•••••••••••••••••••••••••••••••••••••••• 7-24
Data Shift Functions ••••••••••••••••••••••••••••••••••••••••••••••• 7-40
Data Control Function ••••••••••••••••••••••••••••••••••••••••••••• 7-66
Data Conversion Functions••••••••••••••••••••••••••••••••••••••• 7-82
Floating Point Functions ••••••••••••••••••••••••••••••••••••••••• 7-118
Text Processing Functions•••••••••••••••••••••••••••••••••••••••7-156

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-1


Data Move Function

BMOV Batch data move of word block

Block move

BMOV ([execution condition,]*1 Move source device, move destination device,


number of move data)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Move source Specifies the leading device of the move
*2 .U .U .D .D .D - - - - ƻ -
device*4 source data block.
D Move
Specifies the leading device of the move Handled as same type
destination as S .
- - - - ƻ -
*3 destination data block.
device*4
ARITHMETIC OPERATION FUNCTIONS

n Number of Specifies the device currently storing the


.U .U .U .U - - - - ƻ ƻ ƻ
move data data to move, or the number of move data.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When device T or C is specified, the current value becomes the move source.
*3 When device T or C is specified, the current value becomes the move destination.
*4 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in16/32 bits
straddling the next channel.
7
Description of Operation
Data Move Function

When the execution condition is established (TRUE), n move data of word block starting from
S is block-moved to the work block starting from D . (When the move destination is 32-bit
data, the word block becomes the "specified number of move data x 2 words".)

g S : When move source device is 16 bits (.U/.S)

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

g S : When move source device is 32 bits (.D /.L /.F)

[ S ࡮ S +1] Move [ D ࡮ D +1]


[ S +2 ࡮ S +3] Move [ D +2 ࡮ D +3]
...
...

...

[ S +2(n-2)࡮ S +2(n-2)+1] Move [ D +2(n-2)࡮ D +2(n-2)+1]


[ S +2(n-1)࡮ S +2(n-1)+1] Move [ D +2(n-1)࡮ D +2(n-1)+1]

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-1 Data Move
Instructions".

7-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
BMOV (MR1000, DM1000.U, EM2000, 5)
MR1000 BMOV S :DM1000
DM1000 EM2000 #5 D :EM2000
Execution conditon n :When :#5
Move source Move destination
device device

Move source Move destination


DM1000: 1 1 :EM2000

ARITHMETIC OPERATION FUNCTIONS


DM1001: 3 3 :EM2001
DM1002: 7 7 :EM2002
DM1003: 15 15 :EM2003
DM1004: 31 31 :EM2004
16 bits 16 bits
(1 word) (1 word)

Note
When n = 0, the function is not executed.

Sample Program 7

Data Move Function


Programmed Script BMOV (MR1008.U, MR1100.U, 1)
Operation Description The content of one word (16 bits) starting from MR1008 is block-moved to one word (16 bits)
starting from MR1100.
Ladder Conversion
CR2002 BMOV
MR1008 MR1100 #1
Always ON
Move source Move destination
device device
bit bit bit bit
15 MR1100 0 15 MR1000 0

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

bit bit
15 MR1100 0
bit
15 MR1000 bit
0

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

Data blocks (bit) at the move source and move destination will be moved successfully even if
they partially straddle channels.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-3


FMOV Substitute same value in data string

Fill move

FMOV ([execution condition,] *1 Move source device, move destination device,


number of move data)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the move source device or the *3
Move source
*2 device to which the move source data is .U .U .D .D .D .DF - - - ƻ ƻ
device
currently stored.
D Move
Specifies the leading device of the move Handled as same type as
destination S . - - - ƻ -
destination data block.
ARITHMETIC OPERATION FUNCTIONS

*2
device
n Number of Specifies the device currently storing the
.U .U .U .U - - - - ƻ ƻ ƻ
move data data to move, or the number of move data.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When device T, C or CTH is specified, each of their current values becomes the specified destination.
When device CTC is specified, the setting value becomes the specified destination.
*3 The ".DF" suffix cannot be specified for device Z.

7 Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Data Move Function

• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution condition is established (TRUE), n 16-bit/32-bit data (unsigned/signed)


stored in S is block-moved to the word block starting from D . (When the move destination is
32-bit data, the word block becomes the "specified number of move data x 2 words".)

g S : When move source device is 16 bits (.U/.S)


D
D +1

D +2
S
...

D + n -3

D + n -2

D + n -1

7-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When move source device is 32 bits (.D /.L /.F)

[ D ࡮ D +1]

[ D +2 ࡮ D +3]

[ 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]

ARITHMETIC OPERATION FUNCTIONS


g S : When move source device is 64 bits (.DF)
[ D D +1 D +2 D +3]

[ D +4 D +5 D +6 D +7]

[ D +8 D +9 D +10 D +11]
S S +1 S +2 S +3]

[ D (n-3)
+4 D (n-3)
+4 +1 D (n-3)
+4 +2 D (n-3)
+4 +3]

[ D (n-2)
+4 D (n-2)
+4 +1 D (n-2)
+4 +2 D (n-2)
+4 +3]

[ D (n-1)
+4 D (n-1)
+4 +1 D (n-1)
+4 +2 D (n-1)
+4 +3]

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-1 Data Move 7
Instructions".

Data Move Function


ƽ Example of format
FMOV (MR1000, DM1000.U, EM2000, 5)
MR1000 FMOV S :DM1000
DM1000 EM2000 #5 D :EM2000
Execution conditon n When :#5
Move source Move destination
device device

Move destination
123 :EM2000
Move source 123 :EM2001

DM1000: 123 123 :EM2002


16 bits
(1 word) 123 :EM2003
123 :EM2004
16 bits
(1 word)

Note
When n = 0, the function is not executed.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-5


Sample Program

Programmed Script FMOV (MR1008.U, MR1100.U, 2)


Operation Description With the FMOV function, bit devices can be used for the move source device and move
destination device.
The content of one word (16 bits) starting from MR1008 is block-moved to two words (32
bits) starting from MR1100.
Ladder Conversion
CR2002 FMOV
ARITHMETIC OPERATION FUNCTIONS

MR1008 MR1100 #2
Always ON
Move source Move destination
device device
bit bit bit bit
15 MR1100 0 15 MR1000 0

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

bit bit
15 MR1200 0
bit
15 MR1100 bit
0

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

7 Data blocks (bit) at the move source and move destination will be moved successfully even if
they partially straddle channels.
Data Move Function

7-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Move Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-7


PMOV Move continuous bit information to a specified position

Partial move

PMOV ([execution condition,]*1 move source device, move source leading bit position,
move destination device, move destination leading bit position, number of move bits)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Move source Specifies the device to which the move
*2 .U .U .D .D - - - - *6 ƻ ƻ ƻ
device*3 source data is currently stored.
n1 Move source Specifies the device to which the leading bit
leading position of the move source is currently .U .U .U .U - - - - ƻ ƻ ƻ
*4
bit position*5 stored, or the leading bit position.
ARITHMETIC OPERATION FUNCTIONS

D Move destination Specifies the device of the move Handled as same


*2
type as S .
- - - - - ƻ -
device No.*3 destination.
n2 Move destination Specifies the device to which the leading bit
leading bit position of the move destination is currently .U .U .U .U - - - - ƻ ƻ ƻ
*4
position*5 stored, or the leading bit position.
n3 Number of Specifies the device currently storing the
.U .U .U .U - - - - ƻ ƻ ƻ
move bits data to move, or the number of move data.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)

7 *2 When a bit device has been specified, continuous 16 bits (.U suffix instructions)/32 bits (.D suffix
instructions) are occupied.
*3 S and D may be the same device.
Data Move Function

*4 When, for example, the suffix is .U, DM1000 has been specified to n1 ( n2 ), and the value is 20

(BIN: 0000 0000 0001 0100), "4" is used as the value of n1 ( n2 ) because the value of the lower 4
bits is "4" (0100).
*5 When the S is 16 bits (.U/.S), 0 to 15 is specified, and when it is 32 bits (.D/.L), 0 to 31 is specified.
*6 A constant can be specified for the move source device only when the following conditions are satisfied.
gKV STUDIO Ver. 6.00 or higher
gWhen compatible model is CPU function version 2.0 or higher CPU unit

Description of Operation

When the execution condition is established (TRUE), bits from n1 of the 16-bit/32-bit data stored in
S are block-moved by n3 bits to bits from n2 of D .

g S : When move source device is 16 bits (.U/.S)

n3
bit bit
15 0

S : Move source
device

n1

bit bit
15 0

D : Move destination
device

n2

7-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When move source device is 32 bits (.D /.L /.F)

n3
bit bit bit bit
31 16 15 0

[ S ࡮ S +1]

n1

bit bit bit bit


31 16 15 0

[ D ࡮ D +1]

ARITHMETIC OPERATION FUNCTIONS


n2

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-1 Data Move
Instructions".

The original values of bits that are not moved (not destinationed for the move) are held as
they are.

ƽ Example of format
7
PMOV (R1000, DM1000.U, 2, EM2000, 4, 10)

Data Move Function


R3000 PMOV
DM1000 #2 EM2000
Execution conditon
Move source Move destination
device device
#4 #10

Note
The function is not executed when either of the following conditions is established:
g When the suffix of S is .U, and n3 = 0 or 16 < n1 + n3 or 16< n2 + n3 .
g When the suffix of S is .D, and n3 = 0 or 32 < n1 + n3 or 32< n2 + n3 .

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-9


Sample Program

ƽ To move a bit device


Programmed Script PMOV (MR1008.U, 2, MR2004.U, 4, 10)
Operation Description The ten bits (MR1010 to MR1103) starting from the 2nd bit of MR1008.U are block-moved
(by bit) to the ten bits (MR2008 to MR2101) starting from the 4th bit of MR2004.U.
Ladder Conversion
CR2002 PMOV
MR1008 #2 MR2004
ARITHMETIC OPERATION FUNCTIONS

Always ON
Move source Move destination
device device
#4 #10

bit bit bit bit


15 MR1100 0 15 MR1000 0

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

Start from (MR1008.U, 2), 10 bits


Start from (MR1008.U, 4), 10 bits

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

7 bit
15 MR2100
bit
0
bit
15 MR2000
bit
0
Data Move Function

ƽ When this function is used in combination with other functions


Programmed Script PMOV (DM3000, EM3001, DM3100, EM3002, ANDA (EM3000, $7))
Operation Description Bits onwards from the bit position specified by EM3001 of the 16-bit data stored in DM3000
are moved at every scan (no execution condition) to bits onwards from the bit position
specified by EM3002 of DM3001 in blocks (bits) by the number of move bits specified by the
lower three bits (extracted) of EM3000.
Ladder Conversion
CR2002
EM3000 $7 @VM0
LDA ANDA STA
Always ON Number of
move bits PMOV
DM3000 EM3001 DM3100
Move source Move source Move destination
device leading position device
EM3002 @VM0

Move destination leading position

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

7-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Move Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-11


BYBMOV
Move continuous byte string information to specified
position (HėL)
Byte B move

BYBMOV ([execution condition,]*1 move source byte string leading device, move source
byte offset, move destination byte string storage destination leading device,
move source byte offset, number of move bytes)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Move source *3
Specifies the leading device storing the
byte string .U .S .D .L .F .DF .B .T - ƻ -
*2 move source byte string data.
leading device
Specifies the device storing the position from the
ARITHMETIC OPERATION FUNCTIONS

n1 Move source
move source byte string leading device, or .U .U .U .U - - - - ƻ ƻ ƻ
byte offset
specifies that position. (0 to 65535)
D Move destination *3
Specifies the leading device of the move
byte string .U .S .D .L .F .DF .B .T - ƻ -
*2 destination byte string.
leading device
n2 Specifies the device storing the position from the
Move destination
move destination byte string leading device, or .U .U .U .U - - - - ƻ ƻ ƻ
byte offset
specifies that positon. (0 to 65535)
n3 Specifies the device storing the number of
Number of
bytes to move, or specifies the size of the .U .U .U .U - - - - ƻ ƻ ƻ
move bytes
move data. (1 to 65535)
7 R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
Data Move Function

times (at every scan).)


*2 gFor the bit device, specify the leading device of the channel.
g S and D may be the same device.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The BYBMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the data from the n1 (move source byte
offset) byte to the n3 (move byte number of bytes) byte of the S move source byte string
leading device (counting from the high-order byte) is moved from n2 (move destination byte offset)
byte of the D
move destination byte string leading device (counting from the high-order byte) to the
[ n2 + n3 -1) byte. The original values are saved in the bytes where data is not moved.

7-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Move source data Move start position n1 Data to move
Position 0
bit bit
15 0

S A(41H) B(42H) S +1 C(43H) D(44H)


S +1 C(43H) D(44H) S +2 E(45H) 1(31H)
S +2 E(45H) 1(31H) S +3 2(32H) 3(33H)
Number of move bytes n3
S +3 2(32H) 3(33H) S +4 F(46H) G(47H)
S +4 F(46H) G(47H)
7(37H) S(53H)

ARITHMETIC OPERATION FUNCTIONS


T(54H) 8(38H)

When n1 =3, n2 =0 n3 =6, the move destination device is as follows.


Move destination data
bit bit
15 0

D D(44H) E(45H)
D +1 1(31H) 2(32H)
D +2 3(33H) F(46H)
D +3

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-1 Data Move
Instructions". 7

Data Move Function


ƽ Example of format
BYBMOV (MR1000, DM2000, 4, EM4000, 2, 8)
BYBMOV
MR1000
DM2000 #4 EM4000

Execution conditon Move source Move


Byte string destination
destination Byte string
destination
#2 #8

Note
When n3 = 0, the function is not executed.

Sample Program

Programmed Script BYBMOV (DM200, 4, DM400, 2, 8)


Operation Description The 4th byte to 8th byte (counting from the high-order byte) of the move source byte string
data starting with DM200 is moved to the 2nd to 9th bytes (counting from the high-order
byte) of the move destination byte string data starting with DM400.
Ladder Conversion BYBMOV
CR2002
DM200 #4 DM400

Always ON Move source Move


Byte string destination
destination Byte string
destination
#2 #8

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-13


BYLMOV
Move continuous byte string information to specified
position (LėH)
Byte L move

BYLMOV ([execution condition,]*1 move source byte string leading device, move source
byte offset, move destination byte string storage destination leading device,
move source byte offset, number of move bytes)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Move source *3
Specifies the leading device storing the
byte string .U .S .D .L .F .DF .B .T - ƻ -
*2 move source byte string data.
leading device
Specifies the device storing the position from the
ARITHMETIC OPERATION FUNCTIONS

n1 Move source
move source byte string leading device, or .U .U .U .U - - - - ƻ ƻ ƻ
byte offset
specifies that position. (0 to 65535)
D Move destination *3
Specifies the leading device of the move
byte string .U .S .D .L .F .DF .B .T - ƻ -
*2 destination byte string.
leading device
n2 Specifies the device storing the position from the
Move destination
move destination byte string leading device, or .U .U .U .U - - - - ƻ ƻ ƻ
byte offset
specifies that positon. (0 to 65535)
n3 Specifies the device storing the number of
Number of
bytes to move, or specifies the size of the .U .U .U .U - - - - ƻ ƻ ƻ
move bytes
move data. (1 to 65535)
7 R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
Data Move Function

times (at every scan).)


*2 gFor the bit device, specify the leading device of the channel.
g S and D may be the same device.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The BYLMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the data from the n1 (move source byte
offset) byte to the n3 (move byte number of bytes) byte of the S move source byte string
leading device (counting from the lower-order byte) is moved from n2 (move destination byte offset)
byte of the D
move destination byte string leading device (counting from the lower-order byte) to
the [ n2 + n3 -1) byte. The original values are saved in the bytes where data is not moved.

7-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Move source data Move start position n1 Data to move
bit bit
15 0

S A(41H) B(42H) Position 0 S +1 C(43H) D(44H)


S +1 C(43H) D(44H) S +2 E(45H) 1(31H)
S +2 E(45H) 1(31H) S +3 2(32H) 3(33H)
Number of move bytes n3
S +3 2(32H) 3(33H) S +4 F(46H) G(47H)
S +4 F(46H) G(47H)
7(37H) S(53H)

ARITHMETIC OPERATION FUNCTIONS


T(54H) 8(38H)

Move destination data When n1 =3, n2 =0 n3 =6, the move destination device is as follows.
bit bit
15 0

D 1(31H) C(43H)
D +1 3(33H) E(45H)
D +2 G(47H) 2(32H)
D +3

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-1 Data Move
Instructions".
7

Data Move Function


ƽ Example of format
BYLMOV (MR1000, DM1000, 4, EM3000, 2, 8)
BYLMOV
MR1000
DM1000 #4 EM3000

Execution conditon Move source Move


Byte string destination
destination Byte string
destination
#2 #8

Note
When n3 = 0, the function is not executed.

Sample Program

Programmed Script BYLMOV (DM100, 4, DM200, 2, 8)


Operation Description The 4th byte to 8th byte (counting from the lower-order byte) of the move source byte string
data starting with DM100 is moved to the 2nd to 9th bytes (counting from the lower-order
byte) of the move destination byte string data starting with DM200.
Ladder Conversion BYLMOV
CR2002
DM100 #4 DM200

Always ON Move source Move


Byte string destination
destination Byte string
destination
#2 #8

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-15


Arithmetic Operation Functions

INC Increment specified device by 1

Increment memory

INC ([execution condition,]*1 Increment destination device)


Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Increment
destination Specifies the device to increment by 1. .U .S .D .L - - - - - ƻ -
*2
device
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
ARITHMETIC OPERATION FUNCTIONS

times (at every scan).)


*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.

Description of Operation

The data of D is incremented by 1, and the result is stored in D .

7 g D : When increment destination device is unsigned 16-bit data (.U)


An overflow occurs if the operation result is greater than 65535.
Arithmetic Operation Functions

(When the count before the operation is 65535, the count becomes 0, and an overflow occurs.)
g D : When increment destination device is signed 16-bit data (.S)
An overflow occurs if the operation result is greater than +32767.
(When the count before the operation is +32767, the count becomes -32768, and an overflow occurs.)
g D : When increment destination device is unsigned 32-bit data (.D)
An overflow occurs if the operation result is greater than 4294967295.
(When the count before the operation is 4294967295, the count becomes 0, and an overflow occurs.)
g D : When increment destination device is signed 32-bit data (.L)
An overflow occurs if the operation result is greater than 2147483647.
(When the count before the operation is 2147483647, the count becomes -2147483648, and an
overflow occurs.)

Note
Arithmetic operation is performed normally even if an overflow occurs.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-2 Arithmetic/
Comparison Instructions".

ƽ Example of format
INC (LDP (MR2000), DM1000.U)
MR2000 DM1000
↑ INC
Execution conditon Increment destination device

7-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

There are two ways of incrementing the data of devices, by using operation formulas (DM1000 =
DM1000 + 1) and by using the INC function.
When using operation formulas, attention must be paid to reduce accuracy as the right side of the
instruction is operated on as an .L suffix regardless of the suffix. However, when the INC function, you
can program instructions without being aware of any drop in accuracy as the instruction is operated on
by the suffix specified to the device.

ARITHMETIC OPERATION FUNCTIONS


Programmed Script IF LDP (MR1000) THEN
DM1000 = DM1000 +1
INC (DM1100)
END IF

Operation Description The current values of DM1000 and DM1100 are incremented by 1 at the rising edge (OFF ė
ON) of MR1000.
Ladder Conversion
MR1000 NCJ

CR2002
#2000
7
DM1000 +1 DM1000

Arithmetic Operation Functions


LDA EXT ADD.L STA
Always ON
CR2002 DM1100
INC
Always ON
LABEL
#2000

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-17


DEC Decrement specified device by 1

Decrement memory

DEC ([execution condition,]*1 Decrement destination device)


Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Decrement
destination Specifies the device to decrement by 1. .U .S .D .L - - - - - ƻ -
*2
device
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
ARITHMETIC OPERATION FUNCTIONS

times (at every scan).)


*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.

Description of Operation

The data of D is decremented by 1, and the result is stored in D .

7 g D : When decrement destination device is unsigned 16-bit data (.U)


An underflow occurs if the operation result is smaller than 0.
Arithmetic Operation Functions

(When the count before the operation is 0, the count becomes 65535, and an underflow occurs.)
g D : When decrement destination device is signed 16-bit data (.S)
If operation result is less than -32768, underflow will occur.
(if it is -32768 before operation, it will be ˇ32767 after operation, underflow occurs).
g D : When decrement destination device is unsigned 32-bit data (.D)
An underflow occurs if the operation result is smaller than 0.
(When the count before the operation is 0, the count becomes 4294967295, and an underflow occurs.)
g D : When decrement destination device is signed 32-bit data (.L)
If operation result is less than -2147483648, underflow will occur.
(if it is -2147483648 before operation, it will be +2147483647 after operation, underflow occurs).

Note
Arithmetic operation is performed normally even if an underflow occurs.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-2 Arithmetic/
Comparison Instructions".

ƽ Example of format
DEC (DM1000.U)
CR2002 DM1000
DEC
Always ON Decrement destination device

7-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

There are two ways of decrementing the data of devices, by using operation formulas (DM1000 =
DM1000 -1) and by using the DEC function.
When using operation formulas, attention must be paid to reduce accuracy as the right side of the
instruction is operated on as an .L suffix regardless of the suffix. However, when the DEC function, you
can program instructions without being aware of any drop in accuracy as the instruction is operated on
by the suffix specified to the device.

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
IF LDP(MR1000) THEN
DM1000 = DM1000 - 1
DEC (DM1100)
END IF

Operation Description The current values of DM1000 and DM1100 are decremented by 1 at the rising edge (OFF ė
ON) of MR1000.
Ladder Conversion
MR1000 NCJ
↑ #2001
7
CR2002 DM1000 +1 DM1000

Arithmetic Operation Functions


LDA EXT SUB.L STA
Always ON
CR2002 DM1100
DEC
Always ON
LABEL
#2001

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-19


ROOT Square root

. Square root

Return value
*1
= ROOT (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation *3
Specifies the operation destination device or
destination .U .S .D .L .F .DF - - ƻ ƻ ƻ
the operation destination data.
device
Stores the value of the ROOT function *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
processing result.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.

7 "KV-5500/5000/3000 CPU Function Version", Page 2


Arithmetic Operation Functions

Description of Operation

The square root of the data stored in S is calculated, and the result is stored in R .

g S : When operation destination device is 16 bits (.U/.S)


High bit Low bit
TM000 S = R
32 bits 16 bits

g S : When operation destination device is 32 bits (.D/.L)

High 32 bits Low 32 bits High bit Low bit


TM001 TM000 S ˇ1࡮ S = R ˇ1࡮ R
64 bits 32 bits

g S : When operation destination device is a floating real number (.F)

S ˇ1 S R ˇ1 R
Float Float
32 bits 32 bits

g S : When operation destination device is double-precision floating point type real number
(.DF)

S +3 S +2 S +1 S R +3 R +2 R +1 R

Double precision floating point type real number Double precision floating point type real number
64 bits 64 bits

7-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


When integer is specified for operation destination data
gThe square root of 16-bit/32-bit BIN data targeted for conversion is calculated as 32-bit/64-
bit BIN data resulting from having extended each of these data, and each result is stored
again as 16-bit/32-bit BIN data.
gThe decimal point and below in the operation result are discarded.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-2 Arithmetic/
Comparison Instructions".

ARITHMETIC OPERATION FUNCTIONS


ƽ Example of format
DM2000.U = ROOT (DM1000.U)
CR2002 DM1000 DM2000
LDA EXT ROOT STA
Always ON Operation destination device Return value

Sample Program
7
ƽ When using operation formulas

Arithmetic Operation Functions


Programmed Script DM2000.L = ROOT(DM1000.S * EM1000.S)
Operation Description The square root of the product (multiplication) of the data stored in DM1000.S and
EM1000.S is calculated, and the result is stored in DM2000.L.
Ladder Conversion
CR2002 EM1000 @VM0 DM1000 @VM0 DM2000
LDA.S EXT.S STA.L LDA.S EXT.S MUL.L ROOT.L STA.L
Always Operation Operation Return value
ON destination device destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-21


SQRT Square root

Square root

Return value
*1
= SQRT (Operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation *3
Specifies the operation destination device or
destination .U .S .D .L .F .DF - - ƻ ƻ ƻ
the operation destination data.
device
Stores the value of the SQRT function *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
processing result.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The SQRT function can be used only with KV STUDIO Ver. 4.00 or higher.
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher

7 CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
Arithmetic Operation Functions

Description of Operation

This function is similar to "ROOT function" except function name is different.


"ROOT function", Page 7-20.

7-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Arithmetic Operation Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-23


Logic Operation Functions

ANDA Logical AND operation

AND A

Return value
*1
=ANDA (Operation destination device, operation data device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
*2 the operation destination data.
device
S2 Specifies the device to which the logical
Operation Handled as same
*2 AND data is currently stored, or the logical type as S1 .
- - - - ƻ ƻ ƻ
data device
AND data.
ARITHMETIC OPERATION FUNCTIONS

*4
R ANDAfunction type is identical to the 1st
Return value *3 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in16/32 bits
straddling the next channel.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

7 Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Logic Operation Functions

• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The logical AND operation of the data stored in the S1 operation destination device and binary data
stored in the S2 operation data device is executed.
ƽ Example of format
g S1 : When operation destination device is 16 bits (.U/.S)
DM2000.U = ANDA (DM1000.U, $00FF)
CR2002 DM1000 $FF DM2000
LDA ANDA STA
Always ON Operation destination device Return value
bit bit
15 0
DM1000
S1 :Operation destination device 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit
15
AND bit
0
$FF
S2 :Operation destination device 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ANDA
bit bit
15 0
DM2000
R :Return value 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 STA

7-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When operation destination device is 32 bits (.D/.L)
DM2100.D = ANDA (DM1100.D, $00FF00FF)
bit bit bit bit
31 16 15 0
DM1100
S1 ࡮ S1 ˇ1 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
31
AND bit
0
$FF00FF
S2 ࡮ S2 ˇ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
High 16 bits Low 16 bits
bit bit
31 0
DM2100
R ࡮ R ˇ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 0 0 0 STA.D

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Logical AND operation truth table


Operation destination device 0 0 1 1
Operation data device 0 1 0 1
Return value 0 0 0 1

Sample Program 7

Logic Operation Functions


ƽ To calculate the logical AND of the bit device
Programmed Script DM2000.D = ANDA (MR1100.D, DM1100.D)
Description of Operation The logical AND operation of the data stored in MR1000.D and the data stored in DM1100.D
is executed.
The result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM1100 DM2000
LDA.D ANDA.D STA.D
Always ON Operation destination device Operation data Return value

ƽ When this function is used in combination with other functions


Programmed Script FMOV (ANDA (DM1000, $FF), DM2000, 10)
Description of Operation The logical AND operation of the data stored in DM1000 and the operation data $FF (HEX)
is executed.
The operation result data is block-moved to ten words starting from DM2000 by the same data.
Ladder Conversion
CR2002 DM1000 $FF @VM0
LDA ANDA STA
Always ON Operation
destination device
FMOV
@VM0 DM2000 #10

Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"FMOV function", Page 7-4

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-25


ORA Logical OR operation

ORA

Return value
*1
= ORA (Operation destination device, operation data device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Operation destination Specifies the operation destination device or
*2 .U .U .D .D - - - - ƻ ƻ ƻ
device the operation destination data.
S2 Specifies the device to which the logical OR
Operation Handled as same
*2 data is currently stored, or the logical OR type as S1 .
- - - - ƻ ƻ ƻ
data device
data.
ORA function type is identical to the 1st *4
ARITHMETIC OPERATION FUNCTIONS

R Return value .U .S .D .L .F .DF - - - ƻ -


*3
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in16/32 bits
straddling the next channel.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
7 • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Logic Operation Functions

• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S1 and the BIN data stored in S2 are ORed.

ƽ Example of format
g S1 : When operation destination device is 16 bits (.U/.S)
DM2000.U = ORA (DM1000.U, $00FF)
CR2002 DM1000 $FF DM2000
LDA ORA STA
Always ON Operation data device Return value
bit bit
15 0
DM1000
S1 :Operation destination device 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit
15
OR bit
0
$FF
S2 :Operation destination device 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ORA
bit bit
15 0
DM2000
R :Return value 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 STA

7-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When operation destination device is 32 bits (.D/.L)
DM2100.D = ORA (DM1100.D, $00FF00FF)
bit bit bit bit
31 16 15 0
DM1100
S1 ࡮ S1 ˇ1 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
31
OR bit
0
$FF00FF
S2 ࡮ S2 ˇ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
High 16 bits Low 16 bits
bit bit
31 0
DM2100
R ࡮ R ˇ1 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

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Logical OR operation truth table


Operation destination device 0 0 1 1
Operation data device 0 1 0 1
Return value 0 1 1 1

Sample Program 7

Logic Operation Functions


ƽ To calculate the logical OR of the bit device
Programmed Script DM2000.D = ORA (MR1000.D, DM1100.D)
Description of Operation The data stored in MR1000.D and the data stored in DM1100.D are ORed.
The result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM1100 DM2000
LDA.D ORA.D STA.D
Always ON Operation destination device Operation data device Return value

ƽ When this function is used in combination with other functions


Programmed Script R5000.U = ORA (TBCD (DM1000), $1111)
Description of Operation The data stored in DM1000 is converted to 4-digit BCD data. The converted 4-digit BCD data
and $1111 (HEX) are ORed (converted to an odd number (+1) when each of the digits of the
4-digit BCD are an even number), and the operation result data is output to output relays
R5000 to R5015.
Ladder Conversion
CR2002 DM1000 $1111 R5000
LDA TBCD ORA STA
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBCD function", Page 7-82

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-27


EORA Exclusive OR operation

Exclusive ORAA

Return value
*1
= EORA (Operation destination device, operation data device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Operation Specifies the operation destination device or
*2 .U .U .D .D - - - - ƻ ƻ ƻ
destination device the operation destination data.
S2 Specifies the device to which the exclusive OR
Operation Handled as same
*2 data is currently stored, or the exclusive OR type as S1 .
- - - - ƻ ƻ ƻ
data device
data.
*4
EORAfunction type is identical to the 1st
ARITHMETIC OPERATION FUNCTIONS

R Return value *3 .U .S .D .L .F .DF - - - ƻ -


argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
R002, R1012) of the channel has been specified, the relay is handled in16/32 bits straddling the next channel.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher

7 versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Logic Operation Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The exclusive OR operation of the data stored in the S1 operation target device and the binary data
stored in the S2 operation data device is executed.

ƽ Example of format
g S1 : When operation destination device is 16 bits (.U/.S)
DM2000.U = EORA (DM1000.U, $00FF)
CR2002 DM1000 $FF DM2000
LDA EORA STA
Always ON Operation destination device Return value
bit bit
15 0
DM1000
S1 :Operation destination device 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit
15
XOR bit
0
$FF
S2 :Operation destination device 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 EORA
bit bit
15 0
DM2000
R :Return value 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 STA

7-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When operation destination device is 32 bits (.D/.L)
DM2100.D = EORA (DM1100.D, $00FF00FF)
bit bit bit bit
31 16 15 0
DM1100
S1 ・ S1 ˇ1 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
31
XOR bit
0
$FF00FF
S2 ・ S2 ˇ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
High 16 bits Low 16 bits
bit bit
31 0
DM2100
R ・ R ˇ1 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

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Exclusive OR operation truth table


Operation destination device 0 0 1 1
Operation data device 0 1 0 1
Return value 0 1 1 0

Sample Program 7

Logic Operation Functions


ƽ To calculate the exclusive OR of the bit device
Programmed Script DM2000.D = EORA (MR1000.D, DM1100.D)
Description of Operation The data stored in MR1000.D and the data stored in DM1100.D are exclusive ORed. The
result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM1100 DM2000
LDA.D EORA.D STA.D
Always ON Operation destination device Operation data device Return value

ƽ Example of use
The EORA function is used, for example, to invert the ON and OFF states of only the bits specified by
the operation data device on data specified by the operation destination device as the logic of only
arbitrary bits specified as 1 (ON) is inverted.

Programmed Script R5000.U = EORA (R5000.U, $00FF)


Description of Operation Output relays R5000 to R5015 invert and output the current output state (ON/OFF) of R5000
to R5007 at every scan. (R5008 to R5015 do not change state.)
Ladder Conversion
CR2002 R5000 $FF R5000
LDA EORA STA
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-29


ENRA Exclusive NOR

Exclusive NORAA

Return value
*1
= ENRA (Operation destination device, operation data device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Operation Specifies the operation destination device or
*2 .U .U .D .D - - - - ƻ ƻ ƻ
destination device the operation destination data.
S2 Specifies the device to which the exclusive NOR
Operation Handled as same
*2 data is currently stored, or the exclusive NOR type as S1 .
- - - - ƻ ƻ ƻ
data device
data.
*4
ENRA function type is identical to the 1st
ARITHMETIC OPERATION FUNCTIONS

R Return value *3 .U .S .D .L .F .DF - - - ƻ -


argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
R002, R1012) of the channel has been specified, the relay is handled in16/32 bits straddling the next channel.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher

7 versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Logic Operation Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The exclusive NOR operation of the data stored in the S1 operation target device and the binary
data stored in the S2 operation data device is executed. The results are stored in the R return
value.

ƽ Example of format
g S1 : When operation destination device is 16 bits (.U/.S)
DM2000.U = ENRA (DM1000.U, $00FF)
CR2002 DM1000 $FF DM2000
LDA ENRA STA
Always ON Operation destination device Return value
bit bit
15 0
DM1000
S1 :Operation destination device 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 LDA
bit
15
XNOR bit
0
$FF
S2 :Operation destination device 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ENRA
bit bit
15 0
DM2000
R :Return value 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 STA

7-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When operation destination device is 32 bits (.D/.L)
DM2100.D = ENRA (DM1100.D, $00FF00FF)
bit bit bit bit
31 16 15 0
DM1100
S1 ࡮ S1 ˇ1 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
31
XNOR bit
0
$FF00FF
S2 ࡮ S2 ˇ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 ENRA.D
High 16 bits Low 16 bis
bit bit
31 0
DM2100
R ࡮ R ˇ1 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 0 0 0 0 STA.D

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Exclusive NOR truth table


Operation destination device 0 0 1 1
Operation data device 0 1 0 1
Return value 1 0 0 1

Sample Program 7

Logic Operation Functions


ƽ When this function is used in combination with other functions
Programmed Script DM2000 = BCNT (ENRA (MR1000.U, MR1100.U))
Description of Operation The number of matching bits in the 16-bit BIN data currently stored in MR1000.U and
MR1100.U are calculated, and the result is stored in DM2000.
Ladder Conversion
CR2002 MR1000 MR1100 DM2000
LDA ENRA BCNT STA
Always ON Operation destination device Operation data device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"BCNT function", Page 8-6

ƽ Example of use
The ENRA function is used to understand bit changes between the previous value and the current
value as ON: ON or OFF:OFF matching bits can be extracted.

Programmed Script R1000.U = ENRA (R2000.U, MR2000.U)


Description of Operation Bits matching the previous input state currently stored in MR2000 are extracted at the
current input state (ON/OFF) of R2000 to R2015, and the corresponding bits of output relays
R1000 to R1015 are turned ON.
Ladder Conversion
CR2002 R2000 MR2000 R1000
LDA ENRA STA
Always ON Operation destination device Previous value Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-31


COM Bit inversion

Complement

Return value
*1
= COM (Operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
the operation destination data.
device
*3
R The type of COM function is identical to
Return value *2 .U .S .D .L .F .DF - - - ƻ -
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7
Logic Operation Functions

Description of Operation

Each of the bits of the BIN data stored in S is inverted.

g S : When operation destination device is 16 bits


bit bit
15 0
S :Operation
destination device 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0
bit bit
15 0

R :Return value 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1

g S : When operation destination device is 32 bits


bit bit bit bit
31 16 15 0

S ࡮ S ˇ 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

R ࡮ R ˇ 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

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Example of format
DM2000.U = COM (DM1000.U)
CR2002 DM1000 DM2000
LDA COM STA
Always ON Operation destination device Return value

7-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ Example of use
The COM function is used, for example, to invert the current ON and OFF bit states as it can invert the
logic of the BIN data specified by the operation destination device.

Programmed Script R5000.U = COM (R5000.U)


Description of Operation Output relays R5000 to R5015 invert (alternately turn ON/OFF) and output the current output

ARITHMETIC OPERATION FUNCTIONS


state at every scan.
Ladder Conversion
CR2002 R5000 R5000
LDA COM STA
Always ON Operation destination device Return value

The above script is the equivalent to


R5000.U = EORA (R5000.U, $FFFF).
"EORA function", Page 7-28

Logic Operation Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-33


NEG Invert sign

Negative

Return value
*1
= NEG (Operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation *3
Specifies the operation destination device or
destination .U .U .D .D .F .DF - - - ƻ -
the operation destination data.
device
*3
R TBCD function type is identical to the
Return value *2 .U .S .D .L .F .DF - - - ƻ -
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7
Logic Operation Functions

Description of Operation

The plus/minus sign of the BIN data stored in S is inverted (2's complement is calculated).

g S : When operation destination device is 16 bits


bit bit
15 0

S :Operation destination device 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 1 ←Before perform


#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

R :Return value 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 ←After perform


#-12345

g S : When operation destination device is 32 bits


bit bit bit bit
31 16 15 0

S ࡮ S ˇ1 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 perfor
#12345678
bit bit bit bit
31 16 15 0

1 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 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

R ࡮ R ˇ1 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 perform
#-12345678

7-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : Operation destination device is single precision floating point type real number
bit bit bit bit
31 16 15 0

S ・ S ˇ1 Single precision floating point type real number


bit bit
31 0

R ・ R ˇ1 -1×Single precision floating point type real number

g S : Operation destination device is double precision floating point type real number
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

ARITHMETIC OPERATION FUNCTIONS


S S ˇ1 S ˇ2 S ˇ3 Double precision floating point type real number

bit bit
63 0

R R ˇ1 R ˇ2 R ˇ3 -1×Double precision floating point type real number

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-3 Arithmetic
Operation Instructions".

ƽ Example of format
DM2000.S = NEG (DM1000.S)
CR2002 DM1000
LDA.S NEG.S
DM2000
STA.S
7
Always ON Operation data device Return value

Logic Operation Functions


Sample Program

ƽ To invert the sign of the bit device


Programmed Script DM2000.U = NEG (MR1000.U)
Description of Operation The plus/minus sign of the BIN data stored in MR1000 is inverted.
The result is stored in DM2000.
Ladder Conversion
CR2002 MR1000 DM2000
LDA NEG STA
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-35


HINT

The NEG function is used, for example, to invert the sign of a minus value to calculate the absolute
value as it can invert the plus/minus sign of BIN data specified by the operation destination device.

Programmed Script
IF DM1000.S < DM1100.S THEN
DM2000.S = NEG (TOS (DM1000.S - DM1100.S)) 'Sign of operation result inverted
ELSE
ARITHMETIC OPERATION FUNCTIONS

DM2000.S = TOS (DM1000.S - DM1100.S)


END IF

Description of Operation The absolute value of the operation result of DM1000.S-DM1100.S is stored in DM2000.

when DM1000.S < DM1100.S when DM1000.S > DM1100.S


DM1000.S 1000 DM1000.S 2000
- DM1100.S 2000 DM2000.S - DM1100.S 1000
-1000 NEG 1000 --- 1000

7 Note
When the NEG function is used on signed 16-bit data (.S), the range that can be handled is
Logic Operation Functions

-32768 to 32767. For this reason, the operation result becomes -32768 when -32768 has
been operated on by the NEG function. At this time, +32768 can be calculated by using the
TOL function to extend the data to signed 32-bit data (.L) and inverting its sign.
Also, as the device is handled as a formula by prefixing it with a minus operator (-) instead
of using the NEG function, the data is automatically extended to signed 32-bit data (.L), and
the sign of -32768 is inverted to find +32768.

7-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Logic Operation Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-37


ABS Absolute value

Absolute value

Return value
*1
= ABS (Operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation *3
Specifies the operation destination device or
destination .U .S .D .L .F .DF - - ƻ ƻ ƻ
the operation destination data.
device
*3
R The type of ABS function is identical to
Return value *2 .U .S .D .L .F .DF - - - ƻ -
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The ABS function can be used only with KV STUDIO Ver. 4.00 or higher.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7
Description of Operation
Logic Operation Functions

The absolute value of binary data saved in S operation destination device is saved to R return
value.

g S : When the operation destination device is unsigned 16/32 bits data (.U/.D)
S : The operation destination device is saved to R return value without processing.

g S : When the operation destination device is signed 16/32 bits data (.S/.L) or single/double
precision floating point type real number data (.F/.DF)
When S t0, the operation destination device is saved to R return value without processing.
When S <0, the operation destination device is saved to R return value after the sign is
reversed (two's complement operation).
bit bit
15 0

S :Operation destination device 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 ←Before perform


#-12345
bit bit
15 0

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

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

bit bit
15 0

R :Return value 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 1 ←After perform


#12345

7-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.S = ABS (DM1000.S)

CR2002 DM1000 +0
LDA.S CMP.S
Always ON Operation destination device
CR2009
NEG.S
Result of operation is minus

ARITHMETIC OPERATION FUNCTIONS


CR2002 DM2000
STA.S
Always ON Return value

Logic Operation Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-39


Data Shift Functions

SRA Shift right (bit unit)

Shift right A

Return value
*1
= SRA (Operation destination device, number of right shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
the operation destination data.
device
n Specifies the device to which the number of right
Number of right
shifts is currently stored or the number of right .U .U .U .U - - - - ƻ ƻ ƻ
shifts
shifts.
ARITHMETIC OPERATION FUNCTIONS

SRA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Shift Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is shifted to the right by n , and "0" is stored in upper bit.

g S : When operation destination device is 16 bits


bit ( n -1)
bit bit
15 0

S ˖Operation destination device 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1

R ˖Return value 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 10 0 1

High n bits Delete

Store 0 1
CR2009
(Carry)

g S : When operation destination device is 32 bits


bit ( n -1)
bit bit
31 0

S ࡮ S +1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1

R ࡮ R +1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1

High n bits Delete

Store 0
1
CR2009
(Carry)

7-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

ƽ Example of format
DM2000.U = SRA (DM1000.U, 5)
CR2002 DM1000 #5 DM2000
LDA SRA STA
Always ON Operation destination device Return value

ARITHMETIC OPERATION FUNCTIONS


Note
g When n is 0, the value of S is stored in R .
g When S is .U and n t17, and S is .D and n t33, the operation results
will be 0.

Sample Program

ƽ To shift a bit device right 7


Programmed Script DM2000.U = SRA (R1000.U, 10)

Data Shift Functions


Description of Operation The data currently stored in R1000.U is shifted to the right by 10 bits.
The result is stored in DM2000.U.
Ladder Conversion
CR2002 R1000 #10 DM2000
LDA SRA STA
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-41


SLA Shift left (bit unit)

Shift left A

Return value
*1
= SLA (operation destination device, number of left shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
the operation destination data.
device
n Specifies the device to which the number of left
Number of left
shifts is currently stored or the number of left .U .U .U .U - - - - ƻ ƻ ƻ
shifts
shifts.
ARITHMETIC OPERATION FUNCTIONS

SLA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Shift Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is shifted to the left by n and "0" is stored in lower bit.

g S : When operation destination device is 16 bits


bit (16ˉ n )
bit bit
15 0

1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 S ˖Operation destination device

1 11 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 R ˖Return value

Delete Lowǂn bit

1
Store 0
CR2009
(Carry)

7-42 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits
bit (32ˉ n )
bit bit
31 0

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 S ・ S +1

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 R ・ R +1

Delete Low n bit

ARITHMETIC OPERATION FUNCTIONS


1 Store 0
CR2009
(Carry)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

ƽ Example of format
DM2000.U = SLA (DM1000.U, 5)
CR2002 DM1000 #5 DM2000

Always ON
LDA
Operation destination device
SLA STA
Return value
7

Data Shift Functions


Note
g When n is 0, the value of S is stored in R .
g When S is .U and n t17, and S is .D and n t33, the operation results
will be 0.

Sample Program

ƽ To shift a bit device left


Programmed Script DM2000.U = SLA (MR1000.U, 10)
Description of Operation The data currently stored in MR1000.U is shifted to the left by 10 bits.
The result is stored in DM2000.
Ladder Conversion
CR2002 MR1000 #10 DM2000
LDA SLA STA
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-43


HINT

The SLA function is used, for example, to disperse and unite data stored in word devices, etc. as it can
shift any number of bits to the left.

Programmed Script DM2000 = ANDA (DM1000, $F)


DM2000 = ORA (M1000, SLA (ANDA (DM1001, $F), 4))
DM2000 = ORA (DM1000, SLA (ANDA (DM1002, $F), 8))
ARITHMETIC OPERATION FUNCTIONS

DM2000 = ORA (DM1000, SLA (ANDA (DM1003), 12))


Description of Operation The BCD data stored DM1000, DM1001, DM1002, and DM1003 is united as 4-digit BCD one
digit at a time from the lower bit, and stored in DM2000.
DKV DKV DKV
  

&/㧦 

&/㧦 

&/㧦 

&/㧦 

7 &/㧦
DKV


 
DKV

DKV


 
DKV

Data Shift Functions

The above script functions in an equivalent way to data conversion instruction UNIN (nibble
unit).
"ANDA function", Page 7-24
"ORA function", Page 7-26
"UNIN function", Page 7-96
"KV-5500/5000/3000/1000 Instruction Reference Manual", "Data conversion Instruction"
"UNIN Instruction"

7-44 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Shift Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-45


ASRA Arithmetic right shift A (bit unit)

Arithmetic shift right A

Return value
*1
= ASRA (operation destination device, number of right shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .S .D .L - - - - ƻ ƻ ƻ
the operation destination data.
device
n Number of
Specifies the device storing the number of
arithmetic right .U .U .U .U - - - - ƻ ƻ ƻ
right shifts, or the number of right shifts.
shifts
ARITHMETIC OPERATION FUNCTIONS

ASRA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The ASRA function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
Data Shift Functions

Description of Operation

The data stored in S operation target device is right shifted by the number of bits specified with n
number of arithmetic right shifts. When S t0, "0" is stored in the bits shifted right from the high-order bit,
and "1" is stored when S <0.

g When S : operation target device is unsigned 16-bit data


bit
bit ( n -1) bit
15 0
S : 59417
S : Operation destination device 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1

ASRA function is executed when n=5

R : Return value 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 10 0 1
R : 1856
High n bits Delete

1
Store 0
CR2009
(Carry)

g When S : operation target device is signed 16-bit data


bit ( n -1)
bit bit
15 0
S : -1000
S : Operation destination device 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0

ASRA function is executed when n=4

R : Return value 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0
R : -63
High n bits Delete

1
Stores signed value
CR2009
0 or more: 0
When S value is
Less than 0: 1
(Carry)

7-46 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g When S : operation target device is unsigned 32-bit data
bit ( n -1)
bit bit
31 0

S ・ S +1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 3894011929

n=5

R ・ R +1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 10 0 1 121687872

High n bits Delete

ARITHMETIC OPERATION FUNCTIONS


1
Store 0
CR2009
(Carry)

g When S : operation target device is signed 32-bit data


bit ( n -1)
bit bit
31 0

S ・ S +1 1CR2009
1 0 0 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0(キャリー)
1 1 0 -1865478994

n=4

R ・ R +1 1 1 1 1 1 0 0 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0

Delete
-116592438
7
High n bits

Data Shift Functions


1
Stores signed value
0 or more: 0 CR2009
When S value is
Less than 0: 1 (Carry)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

ƽ Example of format
DM2000.U = ASRA (DM1000.U, 5)
CR2002 DM1000 #5 EM2000
LDA ASRA STA
Always ON Operation destination device Return value

Note
g When n is 0, the value of S is stored in R .
g When S is .U and n t17, and S is .D and n t33, the operation results
will be 0.

Sample Program

Programmed Script DM2000.U = ASRA (R1000.U, 10)


Description of Operation The data currently stored in R1000.U is shifted to the right by 10 bits.
The result is stored in DM2000.U.
Ladder Conversion
CR2002 R1000 #10 DM2000
LDA ASRA STA
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-47


ASLA Arithmetic left shift (bit unit)

Arithmetic shift left A

Return value
*1
= ASLA (operation destination device, number of left shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .S .D .L - - - - ƻ ƻ ƻ
the operation destination data.
device
n Number of
Specifies the device storing the number of
arithmetic left .U .U .U .U - - - - ƻ ƻ ƻ
left shifts, or the number of left shifts.
shifts
ARITHMETIC OPERATION FUNCTIONS

ASLA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The ASLA function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
Data Shift Functions

Description of Operation

The data stored in S operation target device is left shifted by the number of bits specified with n
number of arithmetic left shifts. "0" is stored in the bits shifted left from the low-order bit.

g S : When operation destination device is 16 bits


bit
bit (16- n ) bit
15 0

S : Operation destination device 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 S : 59417

ASLA function is executed when n=5


R : Return value 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0

Delete Low n bits R : 800

1
Store 0
CR2009
(Carry)

g S : When operation destination device is 32 bits


bit (32- n )
bit bit
31 0

S S +1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 3894011929

n=5
R R +1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0
54330144
Delete Low n bits

1
CR2009 Store 0
(Carry)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".
7-48 - KV-5500/5000/3000/1000 Series Script Programming Manual -
ƽ Example of format
DM2000.U = ASLA (MR1000.U, 5)
CR2002 DM1000 #5 EM2000
LDA ASLA STA
Always ON Operation destination device Return value

Note
g When n is 0, the value of S is stored in R .
g When S is .U and n t17, and S is .D and n t33, the operation results
will be 0.

ARITHMETIC OPERATION FUNCTIONS


Sample Program

Programmed Script DM2000.U = ASLA (R1000.U, 10)


Description of Operation The data currently stored in R1000.U is shifted to the left by 10 bits.
The result is stored in DM2000.U.
Ladder Conversion
CR2002 R1000 #10 DM2000

Always ON
LDA
Operation destination device
ASLA STA
Return value
7

Data Shift Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-49


RRA Right rotate (bit unit, with carry)

Rotate right A

Return value
*1
= RRA (operation destination device, number of right rotates)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
the operation destination data.
device
n Specifies the device to which the number of right
Number of right
rotates is currently stored or the number of right .U .U .U .U - - - - ƻ ƻ ƻ
rotates
rotates.
ARITHMETIC OPERATION FUNCTIONS

SRA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Shift Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is rotated to the right by n with carry flag (CR2009).

g S : When operation destination device is 16 bits


bit bit
CR2009 15 0

0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 S ˖Operation destination device


Status of marking
differs for different
previous calculate result.
(1-bit rotate)

CR2009

1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1
(Carry)
n times rotates

bit bit
CR2009 15 0

0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 R ˖Return value
(Carry)

7-50 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits
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 S ・ S +1
Status of marking
differs for different
previous calculate result.
(1-bit rotate)

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)

n times rotates

ARITHMETIC OPERATION FUNCTIONS


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 R ・ R +1
(Carry)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

ƽ Example of format
DM2000.U = RRA (DM1000.U, 10)
CR2002 DM1000 #10 DM2000
7
LDA RRA STA

Data Shift Functions


Always ON Operation destination device Return value

Note
When the data is rotated to the right, the LSB is stored in carry flag (CR2009).

Sample Program

ƽ To rotate a bit device right


Programmed Script DM2000.U = RRA (R1000.U, 10)
Description of Operation The data currently stored in R1000.U is rotated to the right by 10 bits.
The result is stored in DM2000.
Ladder Conversion
CR2002 R1000 #10 DM2000
LDA RRA STA
Always ON Operation destination device Return value

HINT

With the SRA function, the MSB becomes "0" at each shift. However, with the RRA function, the LSB is
shifted around to the MSB via the carry flag.

Programmed Script R5000.D = RRA (R5000.U, 1)


Description of Operation Output relays R5000 to R5115 output so that the current output state is repeatedly moving
while being rotated by one bit at a time to the right at each scan.
Ladder Conversion
CR2002 R5000 #1 R5000
LDA.D RRA.D STA.D
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-51


RLA Left rotate (bit unit, with carry)

Rotate left A

Return value
*1
= RLA (operation destination device, number of left rotates)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the operation destination device or
destination .U .U .D .D - - - - ƻ ƻ ƻ
the operation destination data.
device
n Specifies the device to which the number of left
number of left
rotates is currently stored or the number of left .U .U .U .U - - - - ƻ ƻ ƻ
rotates
rotates.
ARITHMETIC OPERATION FUNCTIONS

SRA function type is identical to the 1st *3


R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Shift Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is rotated to the left by n with carry flag (CR2009).

g S : When operation destination device is 16 bits


bit bit
15 0 CR2009

1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0
Status of marking
(1-bit rotate)
differs for different S ˖Operation destination device
previous calculate result.

CR2009

1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1
(Carry)

n times rotates

bit bit
15 0 CR2009

0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 1 0 R ˖Return value
(Carry)

7-52 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits
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 S ・ S +1
Status of marking
differs for different
(1-bit rotate) previous calculate 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)

ARITHMETIC OPERATION FUNCTIONS


n times rotates

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 R ・ R +1
(Carry)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

ƽ Example of format
DM2000.U = RLA (DM1000.U, 10)
CR2002 DM1000 #10 DM2000
7
LDA RLA STA

Data Shift Functions


Always ON Operation destination device Return value

Note
When the data is rotated to the left, the MSB is stored in carry flag (CR2009).

Sample Program

ƽ To rotate a bit device left


Programmed Script DM2000.U = RLA (R1000.U, 10)
Description of Operation The data currently stored in R1000.U is rotated to the left by 10 bits.
The result is stored in DM2000.
Ladder Conversion
CR2002 R1000 #10 DM2000
LDA RLA STA
Always ON Operation destination device Return value

HINT

With the SLA function, the LSB becomes "0" at each shift. However, with the RLA function, the MSB is
shifted around to the LSB via the carry flag.

Programmed Script R5000.D = RLA (R5000.D, 1)


Description of Operation Output relays R5000 to R5031 output so that the current output state is repeatedly moving
while being rotated by one bit at a time to the left at each scan.
Ladder Conversion
CR2002 R5000 #1 R5000
LDA.D RLA.D STA.D
Always ON Store device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-53


RRNCA Right rotate (bit unit, without carry)
Rotate right A without a carry

Return value
*1
= RRNCA(Operation destination device, number of right rotates)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the device to which the operation
.U .U .D .D - - - - ƻ ƻ ƻ
destination device destination data is currently stored.
n Specifies the number of right rotates or the device
Number of right
*2 to which the number of right rotates is currently .U .U .U .U - - - - ƻ ƻ ƻ
rotates
stored.
RRNCA function type is identical to the 1st *4
ARITHMETIC OPERATION FUNCTIONS

R Return value .U .S .D .L .F .DF - - - ƻ -


*3
argument.
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 When a device has been specified to n , operation is as follows when the value of n is 16 or more (when
the operation destination device has a .U suffix) or 32 or more (when the operation destination device has a .D suffix).
In the case of a .U suffix instruction, the remainder value obtained by dividing the value of n by 16
is taken as the number of bits to rotate.
In the case of a .D suffix instruction, the remainder value obtained by dividing the value of n by 32
is taken as the number of bits to rotate.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
7 automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.
Data Shift Functions

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is rotated to the right by n without a carry, and the result is stored in R .
g S : When operation destination device is 16 bits
bit bit
15 0

111100001111 0000 S :Operation destination device

(1-bit rotate)

011110000 1111 000

n times rotates

bit bit
15 0

1 000 011110000 111 R :Return value

CR2009(Carry) 1

7-54 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits
bit bit bit bit
31 16 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 S ・ S +1

(1-bit rotate)

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

n times rotates

bit bit
31 0

ARITHMETIC OPERATION FUNCTIONS


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 1 1 R ・ R +1

CR2009(Carry) 1
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

The state of the LSB as a result of having performed a rotate is entered to the carry flag (CR2009).

ƽ Example of format
DM2000.U = RRNCA (DM1000.U, 10) 7
CR2002 DM1000 #10 DM2000

Data Shift Functions


LDA RRNCA STA
Always ON Operation destination device Return value

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2100.D = TBIN (RRNCA (DM1100.D, 16))
Description of Operation The 8-digit BCD data currently stored in DM1100.D is rotated to the right without a carry by
16 bits, the upper and lower words (upper 4 digits and lower 4 digits of the 8-digit BCD) are
swapped, and the result is converted to 32-bit BIN data and stored in DM2000.D.
Ladder Conversion
CR2002 DM1100 #16 DM2100
LDA.D RRNCA.D TBIN.D STA.D
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBIN function", Page 7-84

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-55


RLNCA Left rotate (bit unit, without carry)

Rotate left A without a carry

Return value
*1
= RLNCA(operation destination device, number of left rotates)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the device to which the operation
.U .U .D .D - - - - ƻ ƻ ƻ
destination device destination data is currently stored.
n Specifies the number of right rotates or the device
number of left
*2 to which the number of right rotates is currently .U .U .U .U - - - - ƻ ƻ ƻ
rotates
stored.
RLNCA function type is identical to the 1st *4
ARITHMETIC OPERATION FUNCTIONS

R Return value .U .S .D .L .F .DF - - - ƻ -


*3
argument.
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 When a device has been specified to n , operation is as follows when the value of n is 16 or more (when the
operation destination device has a .U suffix) or 32 or more (when the operation destination device has a .D suffix).
In the case of a .U suffix instruction, the remainder value obtained by dividing the value of n by 16
is taken as the number of bits to rotate.
In the case of a .D suffix instruction, the remainder value obtained by dividing the value of n by 32
is taken as the number of bits to rotate.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
7 automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.
Data Shift Functions

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The data stored in S is rotated to the left by n without a carry, and the result is stored in R .
g S : When operation destination device is 16 bits
bit bit
15 0

111100001111 0000 S :Operation destination device

(1 bit cycle)

1110000 1111 000 01

Cycle times N

bit bit
15 0

00 011110000 1111 0 R :Return value

CR2009 (Carry) 0

7-56 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits
bit bit bit bit
31 16 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 S ・ S +1

(1-bit rotate)

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

n times rotates

bit bit
31 0

ARITHMETIC OPERATION FUNCTIONS


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 1 1 1 0 R ・ R +1

CR2009 (Carry) 0
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

The state of the MSB as a result of having performed a rotate is entered to the carry flag (CR2009).

ƽ Example of format
DM2000.U = RLNCA (DM1000.U, 10) 7
CR2002 DM1000 #10 DM2000

Data Shift Functions


LDA RLNCA STA
Always ON Operation destination device Return value

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2100.D = TBIN (RLNCA (DM1100.D, 16))
Description of Operation The 8-digit BCD data currently stored in DM1100.D is rotated to the left without a carry by 16
bits, the upper and lower words (upper 4 digits and lower 4 digits of the 8-digit BCD) are
swapped, and the result is converted to 32-bit BIN data and stored in DM2000.D.
Ladder Conversion
CR2002 DM1100 #16 DM2100
LDA.D RLNCA.D TBIN.D STA.D
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBIN function", Page 7-84

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-57


WSR Shift word device right

Shift word right

WSR ([execution condition,]*1 operation destination device, number of operation range data, number of shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Operation Specifies the operation destination device or
*2 .U .U .D .D .D - - - - ƻ -
destination device the operation destination data.
n1 Specifies the device to which the number of
Number of
data in the range to be shifted right is
operation .U .U .U .U - - - - ƻ ƻ ƻ
currently stored or the number of right shift
range data
range data.
ARITHMETIC OPERATION FUNCTIONS

n2 Number of Specifies the device to which the number of right


.U .U .U .U - - - - ƻ ƻ ƻ
shifts shifts is currently stored or the number of right shifts.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.

Description of Operation
7
When the execution condition is established (TRUE), n1 data (16-bit/32-bit) stored in devices
Data Shift Functions

starting from D is shifted to the right (towards the larger device No.) by n2 shifts.
"0" is stored in sections (devices) in the shift source range that do not straddle the shift destination range.

g D : When operation destination device is 16 bits


Before perform After perform

D 1000 0
D +1 2000 0
Store 0
0
0
n1
...

D + n2 1000
( D +1)+ n2 2000
8000
D + ˉ1
n1 9000
...

n2
8000
(D + ˉ1)+
n1 n2 9000

g D : When operation destination device is 32 bits


Before perform After perform

D +1 100000 D 0
D +3 200000 D +2 0
Store 0
0
0
n1
...

( D +1)+2 n2 100000 D +2 n2
( D +3)+2 n2 200000 ( +
D 2)+2 n2

800000
D +2( n1 ˉ1)+1 900000 D +2( n1 ˉ1)
...

n2
800000
D +2( n1 ˉ1)+1)+2 n2 900000 ( D +2( n1 ˉ1)+2 n2

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

7-58 - KV-5500/5000/3000/1000 Series Script Programming Manual -


When the operation destination device is 32-bit data, the number of operation range data and
number of shifts becomes"number of specified data x 2 words".

ƽ Example of format
WSR (R3000, DM1000.U, 32, 10)
R3000 WSR
DM1000 #32 #10
Execution conditon
Conversion destination device

ARITHMETIC OPERATION FUNCTIONS


Note
g When n1 = 0, the function is not executed.
g When n2 = 0, the operation result does not change with before the operation was executed.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script WSR (DM3000, EM3000, ANDA (EM3001, $F)) 7
Description of Operation The 16-bit data currently stored in range of words specified by EM3000 is shifted to the right

Data Shift Functions


by the number of words specified by the lower 4 bits (extracted) of EM3001starting from
DM3000 at every scan (no execution condition).
"0" is stored in sections (devices) in the shift source range that do not straddle the shift
destination range.
Ladder Conversion CR2002 EM3001 $F @VM0
LDA ANDA STA
Always ON Operation
destination device WSR
DM3000 EM3000 @VM0

Operation destination device Number of operation range

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-59


WSL Shift word device left

Shift word left

WSL ([execution condition,]*1 operation destination device, number of operation


range data, number of shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Operation Specifies the leading device of the range to
*2 .U .U .D .D .D - - - - ƻ -
destination device shift left.
n1 Specifies the device to which the number of
Number of
data in the range to be shifted left is
operation .U .U .U .U - - - - ƻ ƻ ƻ
currently stored or the number of left shift
range data
ARITHMETIC OPERATION FUNCTIONS

range data.
n2 Number of Specifies the device to which the number of left shifts
.U .U .U .U - - - - ƻ ƻ ƻ
shifts is currently stored or the number of left shifts.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.

Description of Operation
7
When the execution condition is established (TRUE), n1 data (16-bit/32-bit) stored in devices
Data Shift Functions

starting from D is shifted to the left (towards the smaller device No.) by n2 shifts.
"0" is stored in sections (devices) in the shift source range that do not straddle the shift destination range.

g D : When operation destination device is 16 bits


Before perform After perform

D - n2 1000
( D +1)- n2 2000
n2
...

D 1000
D +1 2000
8000
(D + n1ˉ1)- n2 9000
n1
...

0
0
Store 0
8000 0
D + n1ˉ1 9000 0

g D : When operation destination device is 32 bits


Before perform After perform

( D +1)-2 n2 100000 D -2 n2
( D +3)-2 n2 200000 ( D +2)-2 n2
n2
...

D +1 100000 D
D +3 200000 D +2
800000
D +2( n1 ˉ1)+1)-2 n2 900000 ( D +2( n1ˉ1)-2 n2
n1
...

0
0
Store 0
800000 0
D +2( n1ˉ1)+1 900000 D +2( n1 ˉ1) 0

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

7-60 - KV-5500/5000/3000/1000 Series Script Programming Manual -


When the operation destination device is 32-bit data, the number of operation range data and
number of shifts becomes"number of specified data x 2 words".

ƽ Example of format
WSL (R3000, DM1000.U, 32, 10)
R3000 WSL
DM1000 #32 #10
Execution conditon

ARITHMETIC OPERATION FUNCTIONS


Operation destination device

Note
g When n = 0, the function is not executed.
g When n2 = 0, the operation result does not change with before the operation was executed.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script WSL (DM3000, EM3000, ANDA (EM3001, $F))
7
Description of Operation In every scanning period (no execution condition), from DM3000, 16 bit data stored currently

Data Shift Functions


to the word range displayed via EM3000, will right shift the word displayed by EM3001 low 4
bit (abstracted).
"0" is stored in sections (devices) in the shift source range that do not straddle the shift
destination range.
Ladder Conversion CR2002 EM3001 $F @VM0
LDA ANDA STA
Always ON Operation
destination device WSL
DM3000 EM3000 @VM0

Operation destination device Number of operation range

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-61


BSR Shift bit device right

Bit shift right

BSR ([execution condition,]*1 operation destination device, number of operation


range devices, number of shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Operation
Specifies the leading device of the range to
destination - - - - - - .B - - ƻ -
*2 shift right.
device*3
n1 Number of Specifies the device to which the number of
operation devices in the range to be shifted right is currently .U .U .U .U - - - - ƻ ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

range devices stored or the number of right shift range devices.


n2 Number of Specifies the device to which the number of right
.U .U .U .U - - - - ƻ ƻ ƻ
shifts shifts is currently stored or the number of right shifts.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, the program will function normally even if the bit device straddles
channels.
When a bit device has been specified, the LSB of n1 number of word devices is destinationed for
shifting. Bits other than the lowermost bit do not change.
7 *3 T, C, CR, CTC, CTH, Z, CM can not be used.
Data Shift Functions

Description of Operation

When the execution condition is established (TRUE), the state of n1 devices starting from D is
shifted to the right (towards the larger device No.) by n2 shifts. When D is a word device, only
the LSB of each word device is targeted for shifting. (Bits other than the LSB do not change.)
"OFF" is stored in sections (LSB in the case of word devices) in the shift source range (device) that do
not straddle the shift destination range.

ƽ Example of format
BSR (R3000, MR1002, 3, 4)
R3000 BSR.D
MR1002 #3 #4
Execution conditon
Operation destination device

1000 1001 1002 1003 1004 1005 1006 1007 1008


MR1000̚Before perform 1 1 0 1 1 0 1 1 0

1000 1001 1002 1003 1004 1005 1006 1007 1008


MR1000̚After perform 1 1 0 0 0 0 0 1 1

Add 0

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

7-62 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g When n2 =0, the operation result does not change with before the operation was
executed.
g The function is not executed when either of the following conditions is established:
g When D + n1 + n2 > number of devices (when the actually number of existing
devices is exceeded)
g When n1 is 0

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script BSR (DM3000, EM3000, ANDA (EM3001, $F))
Description of Operation The state of the LSBs of the number of word devices specified by EM3000 starting from
DM3000 is shifted to the right by the count specified by the lower four bits (extracted) of
EM3001 at every scan (no execution condition).
"OFF" is stored in LSB of sections (devices) in the shift source range that do not straddle the
shift destination range. 7
Ladder Conversion CR2002 EM3001 $F @VM0

Data Shift Functions


LDA ANDA STA
Always ON Operation
destination device BSR.D
DM3000 EM3000 @VM0

Operation destination device Number of operation range

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-63


BSL Shift bit device left

Bit shift left

BSL ([execution condition,]*1 operation destination device, number of operation


range devices, number of shifts)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Operation
Specifies the leading device of the range to
destination - - - - - - .B - - ƻ -
*2 shift left.
device*3
n1 Specifies the device to which the number of
Number of
devices in the range to be shifted left is
operation .U .U .U .U - - - - ƻ ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

currently stored or the number of left shift


range devices
range devices.
n2 Number of Specifies the device to which the number of left shifts
.U .U .U .U - - - - ƻ ƻ ƻ
shifts is currently stored or the number of left shifts.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, the program will function normally even if the bit device straddles channels.
When a bit device has been specified, the LSB of n1 is targeted for shifting. Bits other than the
lowermost bit do not change.
7 *3 T, C, CR, CTC, CTH, Z, CM can not be used.
Data Shift Functions

Description of Operation

When the execution condition is established (TRUE), the state of n1 devices starting from D is
shifted to the left (towards the smaller device No.) by n2 shifts. When D is a word device, only
the LSB of each word device is targeted for shifting. (Bits other than the LSB do not change.)
"OFF" is stored in sections (LSB in the case of word devices) in the shift source range (device) that do
not straddle the shift destination range.
"0" is stored in sections (devices) in the shift source range that do not straddle the shift destination
range.

ƽ Example of format
BSL (R3000, MR1009, 2, 3)
R3000 BSL.D
MR1009 #2 #3
Execution conditon
Operation destination device

1005 1006 1007 1008 1009 1010 1011 1012


MR1005̚Before perform 1 0 1 1 0 1 1 0

1005 1006 1007 1008 1009 1010 1011 1012


MR1005̚After perform 1 0 1 0 0 0 1 0

Add 0

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-4 Data Shift
Instructions".

7-64 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g When n2 = 0, the operation result does not change with before the operation was
executed.
g The function is not executed when either of the following conditions is established:
g When D - n1 >0
g When n1 is 0

Sample Program

ARITHMETIC OPERATION FUNCTIONS


ƽ When this function is used in combination with other functions
Programmed Script BSL (DM3000.B, EM3000, ANDA (EM3001, $F))
Description of Operation The state of the LSBs of the number of word devices specified by EM3000 starting from
DM3000.B is shifted to the left by the count specified by the lower four bits (extracted) of
EM3001 at every scan (no execution condition).
"OFF" is stored in LSB of sections (devices) in the shift source range that do not straddle the
shift destination range.
Ladder Conversion CR2002 EM3001 $F @VM0
7
LDA ANDA STA

Data Shift Functions


Always ON Operation
destination device BSL.D
DM3000 EM3000 @VM0

Operation destination device Number of operation range

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-65


Data Control Function

LIMIT Upper/lower limit value control

Limit

Return value
*1
= LIMIT(Upper limit value, lower limit value, input value)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
*2
S1 Lower limit
Specify lower limit value or the device
(min. output .U .S .D .L - - - - ƻ ƻ ƻ
storing lower limit value.
threshold value)
S2 Upper limit
*2
value Specify upper limit value or the device Handled as same
type as S1 .
- - - - ƻ ƻ ƻ
(max. output storing upper limit value.
ARITHMETIC OPERATION FUNCTIONS

threshold value)
S3 *2 Specify the device storing upper/lower limit Handled as same
Input value type as S1 .
- - - - ƻ ƻ ƻ
control input value or input value.
*4
R LIMIT function type is identical to the
Return value *3 .U .S .D .L - .DF - - - ƻ -
1st argument.
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 gWhen a bit device has been specified, 16/32 continuous bits are handled. If relays other than channel
leading relay (R002, R1012 etc.) are specified, it jumps to the next channel for 16/32 bit processing.
gWhen specifying CTH, current value is processed. When using CTC, process setting value.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
7 automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.
Data Control Function

Note
• LIMIT function is special function of KV-5500/5000/3000. When using KV-1000, please
use system macro "LIMITS" and "LIMITL".
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

Upper/lower limit control is performed for S3 via S2 and S1 , the result is stored in R .

Output value Output value

Upper limit
Input value
Input value

Lower limit

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-66 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
g S1 : When lower limit value is 16 bits (.U /.S)

DM1000.U = LIMIT(DM2000.U, DM2100, DM2200)


CR2002 #0 LIMIT
LDA.0 DM2000 DM2100 DM2200 @VMO
Always ON
Lower limit Upper limit Input value

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM1000
LDA STA
Return value

Condition Value stored in R


S1 (Lower limit value)> S3 (Input value) S1 (Lower limit value)
S2 (Upper limit value)< S3 (Input value) S2 (Upper limit value)
S1 (Lower limit value)<= S3 (Input value)<= S2 (Upper S3 (Input value)
limit value)

S1
7
g : When lower limit value is 32 bits (.D /.L)

Data Control Function


DM1100.D = LIMIT(DM2010.D, DM2110, DM2210)
CR2002 #0 LIMIT.D
LDA.D DM2010 DM2110 DM2210 @VMO
Always ON
Lower limit Upper limit Input value

@VM0 DM1100
LDA.D STA.D
Return value

Condition Value stored in [ R +1]


[ S1 • S1 +1]>[ S3 • S3 +1] [ S1 • S1 +1]
(Lower limit value)
(Input value) (Lower limit value)
[ S2 • S2 +1]>[ S3 • S3 +1] [ S2 • S2 +1]
(Upper limit value) (Input value) (Upper limit value)
[ S1 • S1 +1]<=[ S3 • S3 +1]<=[ S2 • S2 +1] [ S3 • S3 +1]
(Lower limit value) (Input value) (Upper limit value) (Input value)

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-67


BANDC Dead band control
Dead band control
Return value
*1
= BANDC (Lower limit for dead band, upper limit for dead band, input value)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Dead band
(non-output Specify lower limit value or the device
.S .S .L .L - - - - ƻ ƻ ƻ
range) lower storing lower limit value.
*2
limit value
S2 Dead band
(non-output Specify upper limit value or the device Handled as same
ARITHMETIC OPERATION FUNCTIONS

type as S1 .
- - - - ƻ ƻ ƻ
range) upper storing upper limit value.
*2
limit value
S3 *2 Specify the dead angle control input value or Handled as same
Input value type as S1 .
- - - - ƻ ƻ ƻ
the device storing input value.
*4
R BANDC function type is identical to the 1st
Return value *3 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 gWhen a bit device has been specified, 16/32 continuous bits are handled. If relays other than channel
leading relay (R002, R1012 etc.) are specified, it jumps to the next channel for 16/32 bit processing.
gWhen specifying CTH, current value is processed. When using CTC, process setting value.
7 *3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
Data Control Function

*4 The ".DF" suffix cannot be specified for device Z.

Note
• BANDC function is special function of KV-5500/5000/3000. When using KV-1000, please
use system macro "BANDSS" and "BANDL".
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

Dead band control is performed for S3 via S2 and S1 , and the result is stored in R .
Output value Output value
Input value

Input value

Lower limit Upper limit

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-68 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
g S1 : When dead angle (no output area) lower limit value is 16 bits (.S)

DM1000.S = BANDC (DM2000.S, DM2100, DM2200)


CR2002 #0 BANDC.S
LDA.D DM2000 DM2100 DM2200 @VM2
Always ON
dead spots dead spots Input value
upper limit lower limit

ARITHMETIC OPERATION FUNCTIONS


@VM2 DM1000
LDA.S STA.S
Return value

Condition Value stored in R


S1 (Lower limit value)> S3 (Input value) S3 (Input value)- S1 (Lower
limit value)
S2 (Upper limit value)˘ S3 (Input value) S3 (Input value)- S2 (Upper
limit value)
S1 (Lower limit value)<= S3 (Input value)<= S2 (Upper 0
limit value) 7
* The value with 16 bits symbol within the BIN data range is stored in R .

Data Control Function


• R <=-32768 ė R =-32768
• R >=+32767ė R =+32767

g S1 : When dead angle (no output area) lower limit value is 32 bits (.L)

DM1100.L = BANDC(DM2010.L, DM2110, DM2210)


CR2002 #0 BANDC.L
LDA.D DM2010 DM2110 DM2210 @VM0
Always ON dead spots dead spots Input value
upper limit lower limit
@VM0 DM1100
LDA.L STA.L
Return value

Condition Value stored in [R +1]


[ S1 • S1 +1]>[ S3 • S3 +1] [ S1 • S1 +1]
(Lower limit value) (Input value) (Lower limit value)

[ S2 • S2 +1]>[ S3 • S3 +1] [ S2 • S2 +1]


(Upper limit value) (Upper limit value) (Upper limit value)

[ S1 • S1 +1]<=[ S3 • S3 +1]<=[ S2 • S2 +1] [ S3 • S3 +1]


(Lower limit value) (Input value) (Upper limit value) (Input value)

* The value with 32 bits symbol within the BIN data range is stored in [ R +1].
•[ R • R +1]<=-2147483648ė[ R • R +1]=-2147483648
•[ R • R +1]>=+2147483647ė[ R • R +1]=+2147483647

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-69


ZONE Zone control

ZONE
*1
Return value = ZONE (Negative bias, positive bias, input value)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 *2 Specify negative bias value added to input
Negative bias .S .S .L .L - - - - ƻ ƻ ƻ
value or the device storing negative bias value.
S2 *2 Specify positive bias value added to input Handled as same
Positive bias type as S1 .
- - - - ƻ ƻ ƻ
value or the device storing positive bias value.
S3 *2 Specify the zone control input value or the Handled as same
Input value type as S1 .
- - - - ƻ ƻ ƻ
device storing input value.
ARITHMETIC OPERATION FUNCTIONS

*4

R ZONE function type is identical to the 1st


Return value *3 .S .S .L .L - - - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 gWhen a bit device has been specified, 16/32 continuous bits are handled. If relays other than channel
leading relay (R002, R1012 etc.) are specified, it jumps to the next channel for 16/32 bit processing.
gWhen specifying CTH, current value is processed. When using CTC, process setting value.
*3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.
7 Note
• ZONE function is special function of KV-5500/5000/3000. When using KV-1000, please
Data Control Function

use system macro "BANDSS" " BANDL".


• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

Zone control is performed for S3 via S2 and S1 , and the result is stored in R .

Output value Output value

Plus deviation
Input value
Input value

Negative deviation

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-70 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
g S1 : When negative bias value is 16 bits (.S)

DM1000.S = ZONE(DM2000.S, DM2100, DM2200)


CR2002 #0 ZONE.S
LDA.D DM2000 DM2100 DM2200 @VMO
Always ON
Negative deviation Plus deviation Input value

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM1000
LDA.S STA.S
Return value

Condition Value stored in R


S3 (Input)<0 S3 (Input value)+ S1 (Negative bias)
S3 (Input)=0 0
S3 (Input)>0 S2 (Input value)+ S2 (Positive bias)
* The value with 16 bits symbol within the BIN data range is stored in R .
R <=-32768ė R =-32768

• R >=+32767ė R =+32767
7

Data Control Function


g S1 : When negative bias value is 32 bits (.L)

DM1100.L = ZONE(DM2010.L, DM2110, DM2210)


CR2002 #0 ZONE.L
LDA.D DM2010 DM2110 DM2210 @VMO
Always ON
Negative deviation Plus deviation Input value

@VM0 DM1100
LDA.L STA.L
Return value

Condition Value stored in [ R +1]


[ S1 • S1 +1]>[ S3 • S3 +1] [ S1 • S1 +1]
(Negative bias) (Input value) (Negative bias)
[ S2 • S2 +1]>[ S3 • S3 +1] [ S2 • S2 +1]
(Positive bias) (Input value) (Positive bias)
[ S1 • S1 +1]<=[ S3 • S3 +1]<=[ S2 • S2 +1] [ S3 • S3 +1]
(Negative bias) (Input value) (Positive bias) (Input value)
* The value with 32 bits symbol within the BIN data range is stored in [ R • R +1].
•[ R • R +1]<=-2147483648ė[ R • R +1]=-2147483648
•[ R • R +1]>=+2147483647ė[ R • R +1]=+2147483647

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-71


APR Linear approximation

Linear approximation
*1
Return value = APR (Input value, leading device of data table, number of data
records)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 *2 Specify polyline approximate input value or
Input value .U .S .D .L .F - - - ƻ ƻ ƻ
the device saving input value.
S2 Leading device Specify the leading device storing polyline Handled as same type
*3
as S1 .
- - - - ƻ -
of data table data table.
n Number of data Specify the device of the number of polyline
.U .U .U .U - - - -
ARITHMETIC OPERATION FUNCTIONS

records data records or the number of store records. ƻ ƻ ƻ


*5
R APR function type is identical to the 1st
Return value *4 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 gWhen a bit device has been specified, 16/32 continuous bits are handled. If relays other than channel
leading relay (R002, R1012 etc.) are specified, it jumps to the next channel for 16/32 bit processing.
gWhen specifying CTH, current value is processed. When using CTC, process setting value.
*3 When S1 type is .F, T, C cannot be specified.
*4 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
7 *5 The ".DF" suffix cannot be specified for device Z.
Data Control Function

Note
• APR function is special function of KV-5500/5000/3000. When using KV-1000, please use
system macro "APRS" "APRL" "APRF".
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

g S1 : When input value is 16 bits (.U /.S)


Linear approximation is performed for n data records of S1 starting from S2 .
S1 is searched according to the polyline data table range, and search result is used to perform 2-
point polyline proximation. The result is stored in R .
; Broken data form
㧔:  ; 㧕 㧔:  ; 㧕
Index X Y
S2 0 0 10
;2
Leading of table 1 8 13
2 14 20
3 20 20 n
㧔:  ; 㧕
㧔:  ; 㧕 㧔:  ; 㧕 4 23 6
5 26 6
: Number of records
:2 㧔:  ; 㧕 6 28 0
;  㧙; 
; 2  㧔: 2 㧙:  㧕 ; 
:  㧙:  Please remember store data of X in ascending order.

7-72 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Please set X value of polyline data table according to ascending sequence. ˄X0 < X1 _ < Xk _ <Xn˅
Polyline data table, please store in turn from the Device No. specified from (table head) according to the
sequence of (X0, Y0), (X1, Y1), (Xn-1, Yn-1), (Xn, Yn). S2 Stands for the state of devices in order from
the specified device No..

Index X Y
S2 0 S2 S2 +1

Leading of table 1 S2 +2 S2 +3

2 S2 +4 S2 +5

ARITHMETIC OPERATION FUNCTIONS


3 S2 +6 S2 +7

4 S2 +8 S2 +9

5 S2 +10 S2 +11
6 S2 +12 S2 +13

n Please store the number of polyline data table records to (the number of records). In addition,
n shall take the value more than 2.

S1 (input value)<X0, R Y0 is stored in R (return value).


S1 (input value)<X0, R Yn is stored in R (return value).
S1 (input value)<X0, R Yk is stored in R (return value).
7

Data Control Function


g S1 : Destination device is 32 bits (.D/.L)
Corresponds to [ S1 g S1 +1] polyline approxinate "input value" [ S2 g S2 +1] set front [ n ]
set to "polyline data table" of store record, and perform proximate calculation.
Polyline proximate calculation [ S1 g S1 +1] search (input value) is located in polyline data table
range, perform polyline proximate calculation at 2 points back and forth.
Calculation result is stored in [ R g R +1](return value).
;
Broken data form
㧔:  ; 㧕 㧔:  ; 㧕
Index X Y
;2 [ S2 ࡮ S2 +1 ] 0 0 10
Leading of table 1 8 13
2 14 20
㧔:  ; 㧕
㧔:  ; 㧕 㧔:  ; 㧕
3 20 20 [ n ]
4 23 6

: 5 26 6
:2 㧔:  ; 㧕 Number of records
6 28 0
;  㧙; 
; 2  㧔: 2 㧙:  㧕 ; 
:  㧙: 

Polyline data table, please store in turn from the Device No. specified from (table head) according to the
sequence of (X0, Y0), (X1, Y1), (Xn-1, Yn-1), (Xn, Yn)[ S2 g S2 +1]Stands for the state of devices in
order from the specified device No.
[ n ]Please store the number of polyline data table records to (the number of records).
In addition,[ n ] please take 2 above.

[ S1 g S1 +1](input value)<X0, Y0 is stored in [ S1 g S1 +1] (return value).


[ S1 g S1 +1](input value)<X0, Yn is stored in [ S1 g S1 +1] (return value).
[ S1 g S1 +1](input value)<X0, Yk(k=1 to n) is stored in [ R g R +1](return value).

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-73


g S1 : When input value is 32 bits (.F)
Corresponds to [ S1 g S1 +1] polyline approximate "input value" [ S2 g S2 +1] set front
[ n ]set to "polyline data table" of store record, and perform proximate calculation. (single precision
float decimal point)
Polyline proximate calculation [ S1 g S1 +1] search (input value) is located in polyline data table
range, perform polyline proximate calculation at 2 points back and forth.
Calculation result is stored in [ R g R +1] (return value).
; Broken data form
ARITHMETIC OPERATION FUNCTIONS

㧔:  ; 㧕 㧔:  ; 㧕
Index X Y

;2 [ S2 ࡮ S2 + 1 ] 0 0 5.2
Leading of table 1 3.3 6.8
2 5.7 13.9

㧔:  ; 㧕 3 7.9 13.9 [ n ]


㧔:  ; 㧕 㧔:  ; 㧕
4 9.9 2.1

:
5 12.2 2.1
:2 㧔:  ; 㧕 Number of records
6 15.5 0
;  㧙; 
; 2  㧔: 2 㧙:  㧕 ;
7

:  㧙: 

Polyline data table, please store in turn from the Device No. specified from (table head) according to the
Data Control Function

sequence of (X0, Y0), (X1, Y1), (Xn-1, Yn-1), (Xn, Yn)[ S2 g S2 +1] Stands for the state of devices in
order from the specified device No.
Please set X value of polyline data table according to ascending sequence. (X0 < X1 Ă < Xk Ă <Xn)

[ n ] Please store the number of polyline data table records to (the number of records).
In addition, [ n ] please take 2 above.

[ S1 g S1 +1](input value)<X0, Y0 is stored in [ R g R +1](return value).


[ S1
g S1
+1](input value)<Xn, Yn is stored in [ g R
+1](return value). R

[ S1 g S1 +1](input value)=X0, Yk(k=1 to n) is stored in [ R g R +1](return value).

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format

DM1000.S = APR(DM2000.S, DM2100, DM2200)


CR2002 #0 APR.S
LDA.D DM2000 DM2100 DM2200 @VMO
Always ON Number of
Input value Data table
leading device data recorels
@VM0 DM1000
LDA.S STA.S
Return value

7-74 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Control Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-75


RAMP Ramp signal

Ramp signal
*1
RAMP ([execution condition,] input value, change rate setting, time unit setting,
output value)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 *2 Specifies the input value, or the device
Input value .S .S .S .S - - - - ƻ ƻ ƻ
storing the input value. (-32768 to 32767)
S2 Specifies the change rate per time unit, or
Change rate
*2 the device storing the change rate. (0 to .U .U .U .U - - - - ƻ ƻ ƻ
setting
65535)
ARITHMETIC OPERATION FUNCTIONS

S3 Time unit
*2 Specifies the time unit. (0 to 2) .U .U .U .U - - - - ƻ ƻ ƻ
setting*3
D *2 Stores the results of the input value plus the
Output value .S .S .S .S - - - - - ƻ -
inclination amount at the set interval.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 gIf a bit device is specified, 16 continuous bits are processed. When a channel other than the leading channel
(R002, R1012, etc.) is specified, 16 bits are processed crossing to the next channel.
gWhen CTH is specified, the current value is processed. If CTC is used, the set value is processed.
7 gT, C, CTH, CTC and Z process the low-order 16 bits.
*3 Specify the time unit setting in the range of 0 to 2.
Data Control Function

Explanation of S3 time unit setting


Value Time unit
0 1 second unit
1 1 minute unit
2 1 hour unit

Note
• The RAMP function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the D (output value) is changed at the
specified inclination ( S2 (change rate setting/ S3 (time unit setting)) until it matches the S1

input value.
Value

S1
(Input value)

D
(Output value)
Time

Execution TRUE
conditions FALSE

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-76 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
RAMP (MR1000, DM1000.S, DM2000.U, 1, EM1000.S)
MR1000 RAMP
DM1000 DM2000 #1 EM1000

Execution conditon Input Change Output


value rate value

Note
The function is not executed when S3 t3.

ARITHMETIC OPERATION FUNCTIONS


Sample Program

Programmed Script RAMP (DM1500.S, DM2500.U, 2, EM1500.S)


Description of Operation The output value stored in EM1500.S is changed toward the input value at the specified
inclination (DM2000/time).
Ladder Conversion
CR2002 RAMP
DM200
DM1500 DM2500 #2 EM1500

Always ON Input
value
Change
rate
Output
value 7

Data Control Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-77


TPOUT Time proportional output

Time proportional output


*1
TPOUT ([execution condition,] ON time, cycle, output relay)

Argument/Return Supported Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 *2 Specifies the time to keep the output relay
ON time .U .U .U .U - - - - ƻ ƻ ƻ
ON with a ms unit. (0 to 65535)
S2 *2 Specifies the output relay ON/OFF cycle
Cycle .U .U .U .U - - - - ƻ ƻ ƻ
with a ms unit. (1 to 65535)
*3
D Output relay Specifies the device to turn ON/OFF. - - - - - - .B - - ƻ -
R
ARITHMETIC OPERATION FUNCTIONS

Return value None - - - - - - - - - - -


*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 gIf a bit device is specified, 16 continuous bits are processed. When a channel other than the leading channel
(R002, R1012, etc.) is specified, 16 bits are processed crossing to the next channel.
gWhen CTH is specified, the current value is processed. If CTC is used, the set value is processed.
gT, C, CTH, CTC and Z process the low-order 16 bits.
*3 gWhen a word device is specified, the LSB is the storage destination for the results. (The bits other than
the LSB do not change.)

7 gEven if a device other than the leading channel (R1002, R1005, etc.) is specified, the output will
function correctly crossing to the next channel.
gCTC, CTH, Z can not be used.
Data Control Function

Note
• The TPOUT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the D output relay turns ON for the S1

ON time (ms) at the S2 cycle (ms).


Execution ON
conditions OFF

S1 : 0.5 , S2 : 1.5 S1 : 0.7 , S2 : 1.2

When the execution conditions


turn OFF, the output relay also
turns OFF.

D ON
OFF
S1 ×1ms S1 ×1ms S1' ×1ms

S2 ×1ms S2 ×1ms S2' ×1ms

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-78 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
TPOUT (MR1000, DM1000, DM2000, MR3000)
MR1000 TPOUT
DM1000 DM2000 MR3000

Execution conditon ON time Control cycle Output relay

Note
• The function is not executed when one of the following conditions is established.
• When S2 < S1

ARITHMETIC OPERATION FUNCTIONS


• When S2 = 0
• An error within ±10μs+1 scan time occurs.
• When 0 is specified for S1 , the function does not turn ON for even one scan.
• If writing is attempted during RUN, the cycle ( S2 ) will be initialized, and the ON time
( S1 ) will be counted after the write during RUN ends.
• This function cannot be used in an interrupt program or initialization module.
• Caution is required when using in a subroutine program, between the STP to STE
instructions, between the STG to JMP/ENDS instructions or between the CJ (NCJ) to
LABEL instructions.
"KV-5500/5000/3000 Series User’s Manual "Cautions for using Timer Instruction"" 7
• Caution is required when using write during RUN.

Data Control Function


"KV-5500/5000/3000 Series User’s Manual "Writing during RUN""

Sample Program

Programmed Script TPOUT (DM1500, EM1000, MR2000)


Description of Operation The MR2000 ON(DM1500ms) and OFF (EM1000-DM1500ms) is switched at the EM1000ms
cycle at each scan (no execution conditions).
Ladder Conversion CR2002 TPOUT
DM1500 EM1000 MR2000

Always ON ON time Cycle Output


relay

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-79


LLFLT Lead-lag filter

Lead-lag filter
*1
LLFLT ([execution condition,] input value, parameter, output value)

Argument/Return Supported Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S *2 Specifies the filter input value, or the device
Input value*3 .S .S .S .S - - - - ƻ ƻ ƻ
storing that input value. (-32768 to 32767)
D1 *2 Specifies the leading device storing the
Parameter*4 .U .U .U .U - - - - - ƻ -
parameter.
D2 *2 Specifies the device storing the output
Output value .S .S .S .S - - - - - ƻ -
value. (-32768 to 32767)
ARITHMETIC OPERATION FUNCTIONS

R Return value None - - - - - - - - - - -


*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 If a bit device is specified, 16 continuous bits are processed. When a channel other than the leading channel
(R002, R1012, etc.) is specified, 16 bits are processed crossing to the next channel.
*3 gWhen CTH is specified, the current value is processed. If CTC is used, the set value is processed.
gT, C, CTH, CTC and Z process the low-order 16 bits.
*4 gIf a bit device is specified, 48 continuous bits are occupied.
gSpecify the channel's leading device for the bit device.
7 gWhen a word device is specified, 3 continuous words are occupied.
Data Control Function

Note
• The LLFLT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the lead-lag operation is executed for S

input value at each D1 sampling cycle, and stored in D2 output value. D2 is initialized with
the S value at the rising edge of the execution conditions.

Description of D1 parameter
Device Description
Specifies the cycle time for executing the instruction. (1 to
D1 Sampling cycle (TS) 60000ms)
Specify the smaller value than Lag/Lead time.
Specifies the time constant for the lag element. (0 to 65535ms)
D1 +1 Lag time (T1)
Lag is disabled if 0 is specified.
Specifies the time constant for the lead element. (0 to 65535ms)
D1 +2 Lead time (T2)
Lead is disabled if 0 is specified.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "LLFLT
command".
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.

7-80 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
LLFLT (MR1000, DM1000.S, EM1000, DM3000.S)
MR1000 LLFLT
DM1000 EM1000 DM3000

Execution conditon Input value Sampling Output


cycle value

Note
• If writing is attempted during RUN, the sampling cycle ( D1 +1) will be initialized, and
the output value ( D2 ) will be initialized with the input value ( S ).

ARITHMETIC OPERATION FUNCTIONS


• This function cannot be used in an interrupt program or initialization module.
• Caution is required when using in a subroutine program, between the STP to STE
instructions, between the STG to JMP/ENDS instructions or between the CJ (NCJ) to
LABEL instructions.
"KV-5500/5000/3000 Series User’s Manual "Cautions for using Timer Instruction""
• Caution is required when using write during RUN.
"KV-5500/5000/3000 Series User’s Manual "Writing during RUN""

Sample Program 7

Data Control Function


Programmed Script LLFLT (DM1500.S, EM2000, DM2000.S)
Description of Operation At each scan (no execution conditions), the lead-lag operation is executed on the value
stored in DM1500 using the DM1001 (lag element time constant) and EM1002 (lead element
time constant) at the EM1000 sampling cycle.
The operation results are stored in DM3000.
Ladder Conversion CR2002 LLFLT
DM1500 EM2000 DM2000

Always ON Input value Sampling Output


cycle value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-81


Data Conversion Functions

TBCD Convert BIN data to BCD data

TransferBCD

Return value
*1
=TBCD (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination device
.U .U .D .D - - - - ƻ ƻ ƻ
destination device or the conversion destination data.
TBCD function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7
Data Conversion Functions

Description of Operation

The 16-bit BIN data stored in S is converted to 4-digit BCD (16-bit) data or 32-bit BIN data is converted
to 4-digit BCD (32-bit) data, and is stored in R .

g S : When the conversion destination device is 16-bit


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

S ˖Conversion 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0
destination device
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

R ˖Return value 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0

1 2 3 4

g S : When the conversion destination device is 32-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
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

S ࡮ S +1 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

R ࡮ R +1 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

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-82 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.U = TBCD (DM1000.U)
CR2002 DM1000 DM2000
LDA TBCD STA
Always ON Conversion destination device Return value

Note S
When the range 0 to 9999 is exceeded when is 16 bits, or the range 0 to 99999999 is
exceeded when it is 32 bits, the value of S is stored in R .

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ To specify the bit device


Programmed Script DM2000.D = TBCD (MR1000.D)
Description of Operation The BIN data stored in MR1000.D is converted to 8-digit BCD (32-bit) data.
The conversion result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM2000

Always ON
LDA.D TBCD.D
Conversion destination device
STA.D
Return value
7

Data Conversion Functions


ƽ Example of use
The TBCD function is used, for example, to output the current values as they are as BCD as it can
convert BIN data specified by the conversion destination device to BCD data.

Programmed Script R1000.U = TBCD (TOU (DM1000 + 1000))


Description of Operation The value of the result obtained by adding 1000 to the content of DM1000 is converted to 4-
digit BCD, and is output to output relays R1000 to R1015.
Ladder Conversion
CR2002 DM1000 +1000 R1000
LDA EXT ADD.L TBCD STA
Always ON Conversion destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-83


TBIN Convert BCD data to BIN data

TransferBIN

Return value
*1
= TBIN (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination device
.U .U .D .D - - - - ƻ ƻ ƻ
destination device or the conversion destination data.
TBINfunction type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7
Data Conversion Functions

Description of Operation

The 4-digit (16-bit) data stored in S is converted to 16-bit BIN data or 8-digit BCD (32-bit) data is
converted to 32-bit BIN data, and is stored in R .

g S : When the conversion destination device is 16-bit


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

S ˖Conversion 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
destination device
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

R ˖Return value 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0

1234

g S : When the conversion destination device is 32-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
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

S ࡮ S +1 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

R ࡮ R +1 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

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-84 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.U = TBIN (DM1000.U)
CR2002 DM01000 DM02000
LDA TBIN STA
Always ON Conversion destination device Return value

Note S S R
When is not BCD data, the value of is stored in .

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ To specify the bit device


Programmed Script DM2000.D = TBIN (MR1000.D)
Description of Operation The 8-digit BCD (32 -bit) data stored in MR1000.D is converted to BIN data.
The conversion result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM2000

Always ON
LDA.D TBIN.D
Conversion destination device
STA.D
Return value 7

Data Conversion Functions


ƽ Example of use
The TBIN function is used, for example, to input the current BCD value as it is as BIN data as it can
convert BCD data specified by the conversion destination device to BIN data.

Programmed Script DM2000.U = TOU (TBIN (R2000.U) + 1000)


Description of Operation The states (values) of relays R2000 to R2015 to which 4-digit BCD data is currently being
output are input, converted to BIN data, 1000 is added to the result, and is stored in
DM2000.
Ladder Conversion
CR2002 R2000 +1000 DM2000
LDA TBIN EXT ADD.L STA
Always ON Conversion destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-85


MPX 4-bit data decode

Multiplex

Return value
*1
= MPX (conversion destination device, conversion digit position)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the conversion destination device
destination .U .U .D .D - - - - - ƻ ƻ
*3 or the conversion destination data.
device*4
n Conversion Specifies the conversion digit position.˄0 to
*2 - - - - - - - - ƻ - -
digit position 3˅
*6
ARITHMETIC OPERATION FUNCTIONS

*5
R Return value .U type MPX function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 The number of digits 0 to 3 (4 bits/1 digit) is specified to the conversion digit position by a constant.
(Devices cannot be specified.)
*3 When 32-bit data has been specified to the conversion destination device, the lower 16 bits (lower word)
becomes the conversion destination (effective conversion digits).
*4 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit device
has been specified for the conversion destination device, the function operates normally straddling the
next channel.
7 *5 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
Data Conversion Functions

*6 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The 4 bits (0 digit to 3 digits) from n of the 16-bit data stored in S are converted to numbers (0
to 15). The result of turning ON only the bit specified by the values after conversion to numbers is
stored in R .

Bit n (#1)

#3 #2 #1 #0

S ˖Conversion 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1
destination device

7 Bit n (#1) is “0111”


(7 in decimal), so setup ON
F E D C B A 9 8 7 6 5 1 3 2 1 0

R ˖Return value 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 (store 1) to bit 7 of R return value.

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-86 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000 = MPX (DM1000, 2)
CR2002 DM1000 #2 DM2000
LDA MPX STA
Always ON Conversion destination device Return value

Sample Program

ARITHMETIC OPERATION FUNCTIONS


ƽ To decode a bit device to 16-bit BIN data
Programmed Script DM2000 = MPX (MR1000.U, 3)
Description of Operation The value of the 3rd digit (four bits, bit 12 to bit 15) of the data stored in MR1000.U is
decoded, and result is stored in DM2000.
Ladder Conversion
CR2002 MR1000 #3 DM2000
LDA MPX STA
AlwaysON Conversion destination device Return value

ƽ When this function is used in combination with other functions


Programmed Script R2000.U = MPX (TBIN (DM1000), 1)
7

Data Conversion Functions


Description of Operation The 16-bit BIN data currently stored in DM1000 is converted to 4-digit BCD (16-bit) data, and
the value of the 10's digit (1st digit) of the conversion result is decoded to turn ON the
corresponding output relays (R2000 to R2015).
Ladder Conversion
CR2002 DM1000 #1 R2000
LDA TBIN MPX STA
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBIN function, Page 7-84

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-87


DMX 4-bit data encode

Demultiplex

Return value
*1
= DMX (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the conversion destination device
destination .U .U .U .U - - - - ƻ ƻ ƻ
*2 or the operation destination data.
device*3
*5
*4
R Return value .U type DMX function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 When 32-bit data has been specified to the conversion destination device, the lower 16 bits (lower word)
becomes the conversion destination (effective bits).
*3 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit device
has been specified for the conversion destination device, the function operates normally straddling the
next channel.
*4 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

7 Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Data Conversion Functions

• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The uppermost bit positions (0 to 15) in the ON bits of the 16-bit data stored in S is stored in R

as 16-bit (stored in lower four bits) data.


Ignore

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

S ˖Conversion 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0
destination device
Because the highest bit

is 7 in bits ON (become 1),


R ˖Return value 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
so store 7 (0111 in binary) to R return value.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-88 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000 = DMX (DM1000)
CR2002 DM1000 DM2000
LDA DMX STA
Always ON Operation destination device Return value

Note S R
When the value of is 0, 0 is stored in .

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ To encode a bit device to 4-bit numerical value data


Programmed Script DM2000 = DMX (MR1000.U)
Description of Operation The uppermost bit position in the ON bits of the data stored in MR1000.D is stored in DM2000.
Ladder Conversion
CR2002 MR1000 DM2000

Always ON
LDA
Operation destination device
DMX STA
Return value 7

Data Conversion Functions


ƽ When this function is used in combination with other functions
Programmed Script R2000.U = TBCD (DMX (MR1000.U))
Description of Operation The uppermost bit position (sensor No.) in the ON bits is converted to 4-digit BCD (16-bit)
data by the sensor input relay (MR1000 to MR1015), and the result is output to the BCD
output relays (R2000 to R2015).
Ladder Conversion
CR2002 MR1000 R2000
LDA DMX TBCD STA
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBCD function, Page 7-82

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-89


GRY Convert BIN data to gray code

Gray code conversion

Return value
*1
= GRY (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the conversion destination device
destination .U .U .D .D - - - - ƻ ƻ ƻ
or the operation destination data.
device
GRY function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
Data Conversion Functions

Description of Operation

The 16-bit or 32-bit BIN data stored in S is converted to gray code, and is stored in R .
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
DM2000.U = GRY (DM1000.U)
CR2002 DM1000 DM2000
LDA GRY STA
Always ON Conversion destination device Return value

Gray code table


bit
Decimal
16 15 14 13 12 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
1 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 1 1
3 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 1 1 0
to
31 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 1 1 0 0 0 0
to
255 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
256 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
to
65535 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7-90 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ To specify the bit device


Programmed Script DM2000.D = GRY (MR1000.D)
Description of Operation The BIN data stored in MR1000.D is converted to gray code.
The conversion result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM2000
LDA.D GRY.D STA.D

ARITHMETIC OPERATION FUNCTIONS


Always ON Conversion destination device Return value

ƽ Example of use
The GRY function is used, for example, to output the current value as it is as gray code as it can
convert BIN data specified by the conversion destination device to gray code.

Programmed Script R1000.U = GRY (TOU (DM1000 + 128))


Description of Operation The value of the result obtained by adding 128 to the content of DM1000 is converted to gray
code, and is output to output relays R1000 to R1015.
Ladder Conversion CR2002 DM1000
LDA EXT
+128
ADD.L GRY
R1000
STA
7
Always ON Conversion Return value

Data Conversion Functions


destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-91


RGRY Convert gray code to BIN data

Gray code reverse conversion

Return value
*1
= RGRY (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the conversion destination device
destination .U .U .D .D - - - - ƻ ƻ ƻ
*2 or the operation destination data.
device
RGRY function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
Data Conversion Functions

Description of Operation

The gray code stored in S is converted to 16-bit or 32-bit BIN data, and is stored in R .
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
DM2000.U = RGRY (DM1000.U)
CR2002 DM1000 DM2000
LDA RGRY STA
Always ON Conversion destination device Return value

Gray code table


bit
Decimal
16 15 14 13 12 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
1 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 1 1
3 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 1 1 0
to
31 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 1 1 0 0 0 0
to
255 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
256 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0
to
65535 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7-92 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ To specify the bit device


Programmed Script DM2000.D = RGRY (MR1000.D)
Description of Operation The gray code stored in MR1000.D is converted to BIN data.
The conversion result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM2000
LDA.D RGRY.D STA.D

ARITHMETIC OPERATION FUNCTIONS


Always ON Conversion destination device Return value

ƽ Example of use
The RGRY function is used, for example to input the current value of the gray code as it is as BIN data
as it can convert gray code specified by the conversion destination device to BIN data.

Programmed Script DM2000.U = TOU (RGRY (R2000.U) -128)


Description of Operation The states (values) of relays R2000 to R2015 to which gray code is currently being output
are input, converted to BIN data, 128 is subtracted from the result, and is stored in DM2000.
Ladder Conversion CR2002 R2000
LDA RGRY EXT
+128
SUB.L
DM2000
STA
7
Always ON Conversion Return value

Data Conversion Functions


destination device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-93


DISN Disperse nibble

Disperse N

DISN ([execution condition,]*1 Operation destination device, disperse data store


device, number of data to be dispersed)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specify the device storing disperse nibble
destination .U .U .D .D - - .B - - ƻ -
*2 data.
device*4
D Disperse data
Specify the leading device storing the Handled as same
store type as S .
- - - - - ƻ -
dispersed data.
ARITHMETIC OPERATION FUNCTIONS

*2
device*4
n Number of
Specify the number of half-byte data to be
disperse .U .U .U .U - - - - - ƻ -
*3 dispersed.
data
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, S 16/32 continuous bits are handled. D 64/128
continuous bits are handled. When a relay other than the leading relay (e.g. R002, R1012) of the
channel has been specified, the relay is handled straddling the next channel.
7 When a word device has been specified, S 1/2 continuous words are handled. D 4/8
continuous words are handled.
Data Conversion Functions

*3 Postfix of S data specified, .U or .B specifies 0 to 4; .D specifies 0 to 8.


*4 CTC, CTH, Z can not be specified.

Note
DISN function is special function of KV-5500 / 5000 / 3000. CPU other than KV-5000 / 3000
series cannot be used.
When using KV-1000, please use DISN command in Ladder.

Description of Operation

When the execution condition is established (TRUE),data in S is dispersed in n halfwidth


charaters (4-bit) data, the result is stored in D .
4 bit upper stored 0.

g S : For signed 16-bit data of operation destination device (.U)


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
n
0 0 0 2 ˖ D +2
0 0 0 1 ˖ D +3

Store 0 in high 12 bits.

7-94 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : For signed 32-bit data of operation destination device (.D)
bit bit bit bit bit bit bit bit
31 24 23 16 15 8 7 0

S +1 1 2 3 4 5 6 7 8 ˖ S
bit bit bit bit
15 8 7 0

0 0 0 8 ˖ D
0 0 0 7 ˖ D +1
0 0 0 6 ˖ D +2
0 0 0 5 ˖ D +3
n
0 0 0 4 ˖ D +4

ARITHMETIC OPERATION FUNCTIONS


0 0 0 3 ˖ D +5
0 0 0 2 ˖ D +6
0 0 0 1 ˖ D +7

Store 0 in high 12 bits.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format 7
DISN (R3000, DM1000.U, DM2000, DM2100.U)

Data Conversion Functions


R3000 DISN
DM1000 DM2000 DM2100
Execution conditon
Operation destination device Separate data saving device Number of separateting data

Note n
When is 0, the function is invalid.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-95


UNIN Unite nibble

UniteN

UNIN ([execution condition,]*1 Operation destination device, unite data store


device, number of data to be united )
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
destination Specify the device storing unite nibble data. .U .U .D .D - - .B - - ƻ -
*2
device*4
D Unite data store Specify the leading device storing unite Handled as same
*2
type as S .
- - - - - ƻ -
device*4 nibble data.
ARITHMETIC OPERATION FUNCTIONS

n Number of unite Specify the number of half-byte data to be


*3 .U .U .U .U - - - - - ƻ -
data united.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, S 64/128 continuous bits are handled. D 16/32
continuous bits are handled. When a relay other than the leading relay (e.g. R002, R1012) of the
channel has been specified, the relay is handled straddling the next channel.
When a word device has been specified, S 4/8 continuous words are handled. D 1/2 words are
handled.
7 *3 Postfix of S data specified, .U or .B specifies 0 to 4; .D specifies 0 to 8.
*4 CTC, CTH, Z can not be specified.
Data Conversion Functions

Note
UNIN function is special function of KV-5500/5000/3000. CPU other than KV-1000 series
cannot be used.
When using KV-1000, please use UNIN command in Ladder.

Description of Operation

When the execution condition is established (TRUE), lower 4 bits of data stored in devices starting from
S are united to n BIN data, the result is stored in D .

g S : For signed 16-bit data of operation destination device (.U)


DKV DKV DKV
  

5 㧦 

5  㧦 
P
5  㧦 

5  㧦 

DKV DKV DKV DKV


   

& 㧦    

7-96 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : For signed 32-bit data of operation destination device (.D)
DKV DKV DKV DKV DKV
    

5 㧦 

5  㧦 

5  㧦 

5  㧦 
P
5  㧦 

5  㧦 

ARITHMETIC OPERATION FUNCTIONS


5  㧦 

5  㧦 

DKV DKV DKV DKV DKV DKV DKV DKV


       

&  㧦         㧦 &

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format 7
UNIN (R3000, DM1000.U, DM2000, DM2100.U)

Data Conversion Functions


R3000 UNIN
DM1000 DM2000 DM2100
Execution conditon
Operation destination device Separate data saving device Number of separateting data

Note n
When is 0, the function is invalid.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-97


DISB Disperse byte

Disperse B

DISB ([execution condition,]*1 Operation destination device, disperse data store


device, number of data to be dispersed)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specify the device storing disperse byte
destination .U .U .D .D - - .B - - ƻ -
*2 data.
device*4
D Disperse data
Specify the leading device storing disperse Handled as same
storage type as S .
- - - - - ƻ -
byte data.
ARITHMETIC OPERATION FUNCTIONS

*2
device*4
n Number of Specify the number of byte data to be
*3 .U .U .U .U - - - - - ƻ -
disperse data dispersed.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, S 16/32 continuous bits are handled. D 32/64
continuous bits are handled. When a relay other than the leading relay (e.g. R002, R1012) of the
channel has been specified, the relay is handled straddling the next channel.
When a bit device has been specified, S 1/2 continuous words are handled. D 2/4 words are
7 handled.
*3 Postfix of S data specified, .U or .B specifies 0 to 2; .D specifies 0 to 4.
Data Conversion Functions

*4 CTC, CTH, Z can not be specified.

Note
DISB function is special function of KV-5500 / 5000 / 3000. CPU other than KV-1000 series
cannot be used.
When using KV-1000, please use DISB command in Ladder.

Description of Operation

When the execution condition is established (TRUE), data in S is dispersed in n half-width


characters (8-bit) data, the result is stored in D .
8 bit upper stored 0.

g S : For signed 16-bit data of operation destination device (.U)

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
n
D +1 ˖ 0 0 1 2

Store 0 in high 8 bits.

7-98 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : For signed 32-bit data of operation destination device (.D)

bit bit bit bit bit bit bit bit


15 8 7 0 15 8 7 0

S +1˖ 1 2 3 4 5 6 7 8 ˖ S
bit bit bit bit
15 8 7 0

D ˖ 0 0 7 8

D +1 ˖ 0 0 5 6
n
D +2 ˖ 0 0 3 4

ARITHMETIC OPERATION FUNCTIONS


D +3 ˖ 0 0 1 2

Store 0 in high 8 bits.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
DISB (R3000, DM1000.U, DM2000, DM2100.U)
R3000 DISB 7
DM1000 DM2000 DM2100

Data Conversion Functions


Execution conditon
Operation destination device Separate data saving device Number of separateting data

Note n
When is 0, the function is invalid.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-99


UNIB Unite byte

UniteB

UNIB ([execution condition,]*1 Operation destination device, unite data store


device, number of data to be united)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
destination Specify the device storing unite nibble data. .U .U .D .D - - .B - ƻ ƻ
*2
device*4
D Unite data
Specify the leading device storing unite Handled as same
storage type as S .
- - - - - ƻ -
nibble data.
ARITHMETIC OPERATION FUNCTIONS

*2
device*4
n Number of unite Specify the number of half-byte data to be
*3 .U .U .U .U - - - - - ƻ -
data united.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, S 32/64 continuous bits are handled. D 16/32
continuous bits are handled. When a relay other than the leading relay (e.g. R002, R1012) of the
channel has been specified, the relay is handled straddling the next channel.
When a word device has been specified, S 2/4 continuous words are handled. D 1/2 words are
7 handled.
*3 Postfix of S data specified, .U or .B specifies 0 to 2; .D specifies 0 to 4.
Data Conversion Functions

*4 CTC, CTH, Z can not be specified.

Note
UNIB function is special function of KV-5500/5000/3000. CPU other than KV-1000 series
cannot be used.
When using KV-1000, please use UNIB command in Ladder.

Description of Operation

When the execution condition is established (TRUE), lower 8 bits of data stored in devices starting from
S are united to n BIN data, the result is stored in D .

g S : For signed 16-bit data of operation destination device (.U)


DKV DKV DKV DKV
   

5 㧦  
P
5  㧦  

DKV DKV DKV DKV


   

& 㧦    

7-100 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : For signed 32-bit data of operation destination device (.D)
DKV DKV DKV DKV
   

5 㧦  

5  㧦  
P
5  㧦  

5  㧦  

ARITHMETIC OPERATION FUNCTIONS


DKV DKV DKV DKV DKV DKV DKV DKV
       

&  㧦         㧦 &

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
UNIB (R3000, DM1000.U, DM2000, DM2100.U)
R3000 UNIB
7
DM1000 DM2000 DM2100

Data Conversion Functions


Execution conditon
Operation destination device Merge data saving device Number of merging data

Note n
When is 0, the function is invalid.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-101


SWAP High lower byte conversion

Swap

Return value
*1
=SWAP (Exchange destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Swap
Specifies the exchange destination device
destination .U .U .D .D - - - - ƻ ƻ ƻ
or the exchange destination data.
device
SWAP function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
argument.
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the exchange result is stored in internal registers.
*2 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
Data Conversion Functions

Description of Operation

The value of high byte (high 8-bit) of 16 bit data and lower byte (low 8-bit) in S stores the result to
R .

g S : When the exchange destination device is 16-bit


bit bit bit bit
15 8 7 0

S 1 2 3 4 ←Switch destination device: $1234

R 3 4 1 2 ←Return value: $3412

g S : When the exchange destination device is 32-bit


bit bit bit bit bit bit bit bit
31 24 23 16 15 8 7 0

S ࡮ S +1 1 2 3 4 5 6 7 8 ←Switch destination device (32-bit): $12345678

R ࡮ R +1 5 6 7 8 1 2 3 4 ←Return value (32-bit): $56781234

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-102 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.U = SWAP (DM1000.U)
CR2002 DM1000 DM2000
LDA SWAP STA
Normal ON Swap destination device Return value

Sample Program

ARITHMETIC OPERATION FUNCTIONS


ƽ To specify the bit device
Programmed Script DM2000.D = SWAP (MR1000.D)
Description of Operation Convert the value of high word (MR1000 to MR1015) and low word (MR1100 to MR1115)
saved in 32 bit data in MR1000.D.
The exchange result is stored in DM2000.D.
Ladder Conversion
CR2002 MR1000 DM2000
LDA.D SWAP.D STA.D
Always ON Swap destination device Return value

ƽ When this function is used in combination with other functions 7


Programmed Script R2000.U = SWAP (TBCD (TOU (DM1000 + 100)))

Data Conversion Functions


Description of Operation Plus 100 into DM1000, convert the result value to 4 bit BCD, then convert high 2 bit and low
2 bit of BCD data and output to output relay R2000 to R2015.
Ladder Conversion
CR2002 DM1000 +100 R2000
LDA EXT ADD.L TBCD SWAP STA
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBCD function, Page 7-82

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-103


BSWAP Block swap

Block swap

BSWAP ([execution condition,]*1 swap destination device, number of target data


items)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Swap
destination Specifies the swap destination device. .U .U .U .U - - - - - ƻ -
device
n Number of
Specifies the number of devices to swap.
target data .U .U .U .U - - - - ƻ ƻ ƻ
(1 to 65535)
ARITHMETIC OPERATION FUNCTIONS

items
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)

Note
• The BSWAP function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7 Description of Operation
Data Conversion Functions

When the execution conditions are established (TRUE), the high-order bytes (high-order 8 bytes) and
low-order bytes (low-order 8 bytes) of the n number of target data items starting with the D

swap target device are swapped.


High-order Low-order High-order Low-order
8 bytes 8 bytes 8 bytes 8 bytes
D 12 34 34 12 D
D +1 56 78 78 56 D +1
D +2 9A BC BC 9A D +2
D +3 DE FG FG DE D +3

D + n -2 ST UV UV ST D + n -2
D + n -1 WX YZ YZ WX D + n -1

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
BSWAP (MR1000, DM2000, 4)
MR1000 BSWAP
DM2000 #4

Execution conditon Switch destination


device

Note n
The function is not executed when =0.

7-104 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

Programmed Script BSWAP (DM3000, 8)


Description of Operation The high-order bytes and low-order bytes of DM3000 to DM3007 are swapped.
Ladder Conversion CR2002 BSWAP
DM3000 #8

Always ON Switch destination


device

ARITHMETIC OPERATION FUNCTIONS


7

Data Conversion Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-105


DECO Decode 8 bits of specified device

8-bit decode

DECO ([execution condition,]*1 Conversion destination device, store destination


device, conversion destination range)
Supported Type Const
Argument/Return Value Explanation Device Formula
.U .S .D .L .F .DF .B .T #/$
S Conversion destination Specifies the leading device of the range
.U .U .U .U - - - - - ƻ ƻ
device to convert.
D Store destination Specifies the device to store the decode
*2 - - - - - - .B - - ƻ -
device*3 result to.
n Number of conversion Specifies the number of ranges (number *4 *4 *4 *4

.U .U .U .U - - - -
ARITHMETIC OPERATION FUNCTIONS

destination range of bits within range 1 to 8) to convert. ƻ *4 ƻ ƻ


R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a word device has been specified, the LSB of continuous 2n number of word devices becomes the
decode result store destination. (Bits other than the LSB do not change.)
*3 CTC, CTH, Z can not be specified.
*4 A device can be specified for the conversion target range only when the following conditions are
satisfied.

7 gWhen the KV STUDIO version is Ver. 6.00 or higher


gWhen the compatible model is a CPU function version 2.0 or higher CPU unit.
Data Conversion Functions

Description of Operation

When the execution condition is established (TRUE), the states of the number of devices (number of bits) specified by the
n starting from S is converted to a numerical value (0 to 255). For 2 bit devices starting from D , the device
n

with "leading No. + numerical value" is ON, and other devices are turned OFF.
When the S is a word device, n indicates the number of bits to convert to numerical values, and when the
n
store destination device is a word device, of the word devices of continuous 2 number of conversion destination
ranges starting from the specified device, the LSB of the "leading No. + (nth) value obtained after conversion to numerical
value" device is turned ON, and the LSB of all other devices turns OFF. (Bits other than the LSB do not change.)

S ˖Conversion destination device 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 n 4 bit

5 Because bit 4 is “0101”


(5 in decimal) so connect 16 (=24)
MR2005 ON starting from MR1000.
2007 2006 2005 2004 2003 2002 2001 2000 Others all OFF (store 0)
D ˖Save destination device 0 0 1 0 0 0 0 0
MR2000̚MR2007

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

7-106 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DECO (R3000, MR1000.U, MR2000, 4)
R3000 MR1000 MR2000
LDA DECO
Execution conditon Conversion destination device #4

Note n
The function is not executed when =0.

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DECO (ORA (DM3000, DM3001), MR3000, 5)
Description of Operation The lower five bits of the result of ORing the data currently stored in DM3000 and DM3001 is
decoded at every scan (no execution condition).
Of 25 continuous devices starting from MR3000, the "leading No. + (nth) value obtained after
conversion to numerical value" device is turned ON, and all other devices turn OFF. 7
Ladder Conversion

Data Conversion Functions


CR2002 DM3000 DM3001 MR3000
LDA ORA DECO
Always ON Conversion destination device #5

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ORA function, Page 7-26

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-107


ENCO Encode 8 bits of specified device

8-bit encode

Return value
*1
= ENCO (conversion destination device, number of conversion
destination ranges)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the leading device of the range to
destination - - - - - - .B - - ƻ -
*2 convert.
device*3
n Number of
*5 *5 *5 *5
conversion Specifies the number of ranges (number of
.U .U .U .U - - - - ƻ *5 ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

destination bits within range 1 to 256) to convert.


ranges
*6
*4
R Return value .U type ENCO function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a word device has been specified, the LSB of continuous n number of word devices is
targeted for encoding.
*3 CTC, CTH, Z can not be specified.
*4 When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.
7 *5 A device can be specified for the conversion target range only when the following conditions are
satisfied.
Data Conversion Functions

gWhen the KV STUDIO version is Ver. 6.00 or higher


gWhen the compatible model is a CPU function version 2.0 or higher CPU unit.
*6 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

States of n devices (number of bits) starting from S , the position (0 to 255) of the smallest ON
bit device are stored in R as 16-bit data.
When S is a word device, n indicates the number of words (devices), and the number of
devices specified by the number of conversion destination ranges, the position (0 to 255) of the
smallest word device whose LSB is ON is stored in R as 16-bit data.

Ignore

107 106 105 104 103 102 101 100


S ̚ S + n -1 1 0 1 0 1 0 0 0
MR1000̚MR1007 7 6 5 4 3 2 1 0

Store “3” to DM2000 becauce


MR1003 is the smallest device No.
in devices that is ON (become 1)

R Return value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1

7-108 - KV-5500/5000/3000/1000 Series Script Programming Manual -


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
DM2000.U = ENCO (MR1000, 8)
CR2002 MR1000 DM2000
ENCO STA
Always ON #8 Return value
Conversion destination device

ARITHMETIC OPERATION FUNCTIONS


Note n
The function is not executed when =0.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = TBCD (ENCO (MR3000, 32))
Description of Operation Of 32 bit devices (MR3000 to MR3115) starting from MR3000, the position (16-bit data) of 7
the smallest ON device is converted to 4-digit BCD data and stored in DM2000.

Data Conversion Functions


Ladder Conversion
CR2002 MR3000 DM2000
ENCO TBCD STA
Always ON #32 Return value
Conversion destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBCD function, Page 7-82

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-109


TOU Convert data type to .U

TOS Convert data type to .S

TOD Convert data type to .D

TOL Convert data type to .L

Uconversion

Return = TOU (conversion destination device)


Sconversion

Return = TOS (conversion destination device)


ARITHMETIC OPERATION FUNCTIONS

Dconversion

Return = TOD (conversion destination device)


Lconversion

Return = TOL (conversion destination device)


Supported Type Const
Argument/Return Value Explanation Device Formula
.U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the *2

destination conversion destination data is stored .U .S .D .L .F .DF - - ƻ ƻ ƻ


device or the conversion data.
TOU function: Has .U type.
*2
TOUS function: Has .S type.
7 R Return value
*1

TOD function: Has .D type.


TOL function: Has .L type.
.U .S .D .L .F .DF - - - ƻ -
Data Conversion Functions

*1 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*2 The ".DF" suffix cannot be specified for device Z.

Note
• The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
• The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

g TOU
The data stored in S is converted to unsigned 16-bit BIN data, and the result is stored in R .

gWhen 32-bit BIN data has been specified, the lower 16 bits are targeted for conversion.
gWhen single/double precision floating point type real number has been specified as the
conversion destination data, the lower 16 bits of the result after having converted to unsigned
32-bit BIN data is targeted for conversion.
gSet the suffix of the device for storing the return value to .U .

7-110 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g TOS
The data stored in S is converted to signed 16-bit BIN data, and the result is stored in R .

gWhen 32-bit BIN data has been specified, the lower 16 bits are targeted for conversion.
gWhen single/double precision floating point type real number has been specified as the
conversion destination data, the lower 16 bits of the result after having converted to signed 32-
bit BIN data is targeted for conversion.
gSet the suffix of the device for storing the return value to .S.

ARITHMETIC OPERATION FUNCTIONS


g TOD
The data stored in S conversion destination device is converted to unsigned 32-bit BIN data, and
the result is stored in R return value.

gWhen 16-bit BIN data has been specified to the conversion destination data, the 32-bit data
of the result of having extended the data is targeted for conversion.
gWhen single/double precision floating point type real number has been specified as the
conversion destination data, the result after having converted to unsigned 32-bit BIN data is
targeted for conversion.
gSet the suffix of the device for storing the return value to .D.
7

Data Conversion Functions


g TOL
The data stored in S is converted to signed 32-bit BIN data, and the result is stored in R .

gWhen 16-bit BIN data has been specified to the conversion destination data, the 32-bit data
of the result of having extended the data is targeted for conversion.
gWhen single/double precision floating point type real number has been specified as the
conversion destination data, the result after having converted to signed 32-bit BIN data is
targeted for conversion.
gSet the suffix of the device for storing the return value to .L.

ƽ Example of format
DM2000.L = TOL (DM1000.S)
CR2002 DM1000 DM2000
LDA.S EXT.S STA.L
Always ON Conversion destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-111


Sample Program

The operation formula programmed by the script is operated on as signed 32-bit data (.L).
When converting to a ladder from script, and the suffix of the device to substitute (store) the operation
result is other than ".L", the type conversion alarm is generated.
To avoid the type conversion warning, use each of the "TOU, TOS, TOD, TOL" functions to convert the
operation result to the same type as the device to substitute.
ARITHMETIC OPERATION FUNCTIONS

ƽ When the type of the device for substituting the operation result is unsigned 32-
bit data ".D"
Description of Operation The operation result (operated on by .L) of the right side of "=" is converted to unsigned 32-
bit data ".D", and substituted (stored) to DM1000.D on the left side.
Programmed Script DM1000.D = TOD ((DM2000 + 50) * DM2100 + 10)
Ladder Conversion CR2002 DM2000 +50 @VM0 DM2100 @VM0 +10 DM1000
LDA EXT ADD.L STA.L LDA EXT MUL.L ADD.L STA.D
Always ON Return value

7
Data Conversion Functions

7-112 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Conversion Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-113


CPMSET CIP message creation

CPMSET ([execution condition]*1 , input data storage destination, parameter,


output data storage destination)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Input data
storage Specifies the leading device of the
.U .S .D .L .F .DF .B .T - ƻ -
destination additional send data.
*2
device
Specifies the data type or size (byte unit) of
ARITHMETIC OPERATION FUNCTIONS

S2 Parameter the additional send data, or the device .U .U .U .U - - - - ƻ ƻ ƻ


*2
storing that information.
D Output data
storage Sets the leading device of the created send
.U .S .D .L .F .DF .B .T - ƻ -
destination data.
*2
device
R Return value None - - - - - - - - - - -

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When specifying a bit device, specify the leading device of the channel.
7 Note
• The CPMSET function can be used only with KV STUDIO Ver. 6.00 or higher.
Data Conversion Functions

• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the data stored in the S1 input data storage
destination device is added after the data size (byte unit) stored in the D output data storage
destination device. The data is saved with the type specified with the high-order 4 bits of the S2

parameter, and the data size (byte unit) specified with the low-order 12 bits.
When adding data for the first time, 0 is stored in the D output data storage destination device
before the function is executed.
The CPMSET function is a function for creating CIP data type text string data and numeric data.
Refer to "KV-EP21V User's Manual" for details on the CIP data types.
bit bit
15 0
S2
Data type Data size (byte unit)

High-order 4 bits Low-order 12 bits

High-order 4 bits Low-order 12 bits


0: Other than text string 1 to 4095 (001H to FFFH): Specifies data size
0 to 1999 (000H to 7CFH): Specifies number of characters to convert
into CIP text string type data. If 0 is specified, characters up to
1: Text string NUL(00H) are converted.
If the specified number of characters contains NUL(00H), 00H is added
to the data following NULL(00H).
2 or more: Reserved for system -

7-114 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Data storage start position Data storage start position: 0
specified with data size
Additional data
S1 +0
S1 +1
Created data
S1 +2
Data size (Byte unit)* D +0
S1 +3
D +1
D +2
The type* and size of data specified

ARITHMETIC OPERATION FUNCTIONS


D +3
with S2 is added to the data
storage start position. D +4
* If the data type is a text string, the D +5
data is converted into CIP text string D +6
type data and then added.
D +7

* When the function is executed, the


data size added to D1 +0 data
size is added.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".
7
ƽ Example of format

Data Conversion Functions


CPMSET (MR0,DM1000,$1003,EM2000)
MR000 CPMSET
DM1000 $1003 EM2000

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-115


CPMGET CIP message retrieval

CPMGET ([execution condition]*1 , input data storage destination, parameter,


input data offset, output data storage destination)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Input data
storage Specifies the number of the leading device
.U .S .D .L .F .DF .B .T - ƻ -
destination storing the receive data.
*2
device
Specifies the type or size (byte unit) of
ARITHMETIC OPERATION FUNCTIONS

S2 Parameter receive data to be retrieved, or the device .U .U .U .U - - - - ƻ ƻ ƻ


*2
storing that information.
D1 Specifies the byte offset from the leading
Receive data
*2 device specifying the receive data retrieval .U .S .D .L - - - - - ƻ -
byte offset
position, or the device storing that information.
D2 Output data
storage Specifies the leading device for storing the
.U .S .D .L .F .DF .B .T - ƻ -
designation retrieved data.
*2
device
R Return value None - - - - - - - - - - -

7 *1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When specifying a bit device, specify the leading device of the channel.
Data Conversion Functions

Note
• The CPMGET function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions are established (TRUE), the data following the offset position specified
with the D1 receive data offset of the receive data stored in the S1 input data storage
designation device is stored in the D2 output data storage destination device. The data is stored
with the data type specified with the high-order 4 bits of the S2 parameter and the data size (byte
unit) specified with the low-order 12 bits of the S2 parameter. The D1 receive data offset is
updated after the data is stored.
The CPMGET function is used to retrieve the text string data and numeric data of the received CIP data
type.
Refer to "KV-EP21V User's Manual" for details on the CIP data types.
bit bit
15 0
S2
Data type Data size (byte unit)

High-order 4 bits Low-order 12 bits

High-order 4 bits Low-order 12 bits


0: Other than text string 1 to 4095 (001H to FFFH): Specifies data size
0 to 1999 (000H to 7CFH): Specifies number of characters to convert
into CIP text string type data. If 0 is specified, characters up to
1: Text string NUL(00H) are converted.
If the specified number of characters contains NUL(00H), 00H is added
to the data following NULL(00H).
2 or more: Reserved for system -

7-116 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Data retrieval start position: 0 Data retrieval start position specified
with receive data offset

Receive data
S1 +0 Data size (Byte unit) Receive data offset* *
D1
S1 +1 Retrieved data
S1 +2 D2 +0
S1 +3 D2 +1
S1 +4 D2 +2

ARITHMETIC OPERATION FUNCTIONS


S1 +5

The type* and size of data specified with * When the function is executed,
S2 is retrieved from the data following the retrieved data size is added
the D1 data retrieval start position, and to the D1 receive data offset.
stored after D2 .
* If the data type is a text string, it is
converted into CIP text string data.

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-6 Data
Conversion Instructions".

ƽ Example of format
7

Data Conversion Functions


CPMGET (MR0, EM2000, $1003, DM1000, DM2000)
MR000 CPMGET
EM2000 $1003 DM1000 DM2000

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-117


Floating Point Functions

FLOAT
Convert BIN data to single precision floating point type real
number data

Single precision floating point conversion

Return value
*1
= FLOAT (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the conversion destination *3
Conversion
device or the conversion destination .U .S .D .L - .DF - - ƻ ƻ ƻ
destination device
data.
*3
*2
R Return value .F type FLOAT function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 When the type other than .F is specified by return value, type conversion will be automatically conducted
during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.

7 "KV-5500/5000/3000 CPU Function Version", Page 2


Floating Point Functions

Description of Operation

The binary data (16-bit/32-bit (unsigned/signed), double precision floating point type real type data)
stored in S conversion destination device is converted into single precision floating point type real
number data, and the results are stored in the R return value.

g S : When the type of conversion destination device is 16-bit


bit
15
S bit
0
bit
31
R +1 R bit
0

16-bit BIN data Single precision floating point type real number

16 bits 32 bits

g S : When the type of conversion destination device is 32 -bit


bit
31
S +1 S bit
0
bit
31
R +1 R bit
0

32-bit BIN data Single precision floating point type real number

32 bits 32 bits

g S : When the type of conversion destination device is double precision floating point type
real number
bit
63
S +3 S +2 S +1 S bit
0
bit
32
R +1 R bit
0

Double precision floating


Double precision floating point type real number point type real number

64 bits 32 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-118 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.F = FLOAT (DM1000.U)
CR2002 DM1000 DM2000
LDA FLOAT STA.F
Always ON Conversion destination device Return value

Note
When S integer value exceeds -16777216 to 16777215 (24-bit BIN system) range, the
25th bit onwards is rounded.

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ Example of use
Programmed Script DM2000.F = FLOAT (DM1000.U + 123)
Description of Operation The operation result of DM1000.U+123 is converted to single precision floating point type
real number data, and is stored in DM2000.F.
Ladder Conversion CR2002 DM1000
LDA EXT
+123
ADD.L FLOAT.L
DM2000
STA.F 7
Always ON Return value

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-119


TOF
Convert BIN data to single precision floating point type real
number data

Fconversion

Return = TOF (conversion destination device)

Argument/Return Supported Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the *2

destination conversion destination data is stored .U .S .D .L .F .DF - - ƻ ƻ ƻ


device or the conversion data.
*2
*1
R Return value .F type TOF function available .U .S .D .L .F .DF - - - ƻ -

*1 When the type other than .F is specified by return value, type conversion will be automatically conducted
ARITHMETIC OPERATION FUNCTIONS

during conversion.
*2 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7
Description of Operation
Floating Point Functions

The data stored in S is converted to single precision floating point type real number data, and the
result is stored in R .
"FLOAT function", Page 7-118

ƽ Example of format
DM2000.F = TOF (DM1000.D)
CR2002 DM1000 DM2000
LDA.D FLOAT.D STA.F
Always ON Conversion destination device Return value

gThe conversion destination data is converted into 32-bit single precision floating point type
real number with the FLOAT instruction corresponding to the data type (16-bit/32-bit
(unsigned/signed)).
gIf the conversion destination data is a double precision floating point type real number, it is
converted into 32-bit single precision floating point type real number by the DFTOF
instruction.
gThe .F suffix must be specified to the device for storing the return value.

7-120 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-121


DFLOAT
Convert BIN data to double precision floating point type real
number data

Double precision floating point conversion

Return value
*1
= DFLOAT (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the conversion destination
Conversion
device or the conversion destination .U .S .D .L .F - - - ƻ ƻ ƻ
destination device
data.
.DF type DFLOAT function *3
R Return value .U .S .D .L .F .DF - - - ƻ -
*2
available
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in 64-bit internal registers.
*2 When the type other than .DF is specified by return value, type conversion will be automatically
conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The DFLOAT function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7
Description of Operation
Floating Point Functions

The binary data (16-bit/32-bit (unsigned/signed), single precision floating point type real type data)
stored in S conversion destination device is converted into double precision floating point type real
number data, and the results are stored in the R return value.

g S : When the type of conversion destination device is 16-bit


S R +3 R +2 R +1 R
16-bit BIN data Double precision floating point type real number
16 bits 64 bits

g S : When the type of conversion destination device is 32 -bit


bit bit bit bit
31 S +1 S 0 63 R +3 R +2 R +1 R 0

32-bit BIN data Double precision floating point type real number
32 bits 64 bits

g S : When the type of conversion destination device is single precision floating point type
real number
bit bit bit bit
31 S +1 S 0 63 R +3 R +2 R +1 R 0

Single precision floating point type real number Double precision floating point type real number
32 bits 64 bits

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

ƽ Example of format
DM2000.DF = DFLOAT (DM1000.S)
CR2002 DM1000 DM2000
LDA.S DFLOAT.S STA.DF

Always ON Conversion destination device Return value

7-122 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

Programmed Script DM2500.DF = DFLOAT (DM1500.L + 1000)


Description of Operation The operation result of DM1500.L+1000 is converted to double precision floating point type
real number data, and is stored in DM2500.DF.
Ladder Conversion CR2002 DM1500 +1000 DM2500
LDA.L ADD.L DFLOAT.L STA.DF

Always ON Return value

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-123


TODF
Convert BIN data to double precision floating point type real
number data

DF conversion

Return = TODF (conversion destination device)

Argument/Return Supported Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the *2

destination conversion destination data is stored .U .S .D .L .F .DF - - ƻ ƻ ƻ


device or the conversion data.
*2
*1
R Return value .DF type TODF function available .U .S .D .L .F .DF - - - ƻ -

*1 When the type other than .DF is specified by return value, type conversion will be automatically
ARITHMETIC OPERATION FUNCTIONS

conducted during conversion.


*2 The ".DF" suffix cannot be specified for device Z.

Note
g The TODF function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7 Description of Operation

The data stored in S is converted to double precision floating point type real number data, and the
Floating Point Functions

result is stored in R .
"DFLOAT function", Page 7-122

ƽ Example of format
DM2000.DF = TODF (DM1000.S)
CR2002 DM1000 DM2000
LDA.S DFLOAT.S STA.DF

Always ON Conversion destination device Return value

gThe conversion destination data is converted into 64-bit double precision floating point type
real number with the DFLOAT instruction corresponding to the data type (16-bit/32-bit
(unsigned/signed), single precision floating point type real number).
gThe .DF suffix must be specified to the device for storing the return value.

7-124 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-125


INTG
Convert single/double precision floating point type real number
data to BIN data

Integer conversion

Return value
*1
= INTG (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination *4

destination device or the conversion destination - - - - .F .DF - - ƻ ƻ ƻ


*2
device data.
*4
*3
R Return value .L type INTG function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 C, T, CTC, CTH, Zcan not be used.


*3 When the type other than .L is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
g The range of the single precision floating point type real number is shown below.
Floating Point Functions

-3.4E+38< N< -1.4E-45


N=0
1.4E-45 < N< 3.4E+38
(effective number of digits: approx. 7 digits)
g The range of the double precision floating point type real number is shown below.
-1.79E+308 <N < -2.23E-308
N=0
2.23E-308 <N < 1.79E+308
(Number of effective digits: approx. 16 digits)

Description of Operation

The single/double precision floating point type real number data stored in S is converted to signed
32-bit BIN data, and the result is stored in R .

g S : When the type of conversion destination device is single precision floating point type
real number
bit bit
31 S +1 S 0 R +1 R
Single precision floating point type real number Signed 32-bit binary data
32 bits 32 bits

g S : When the type of conversion destination device is double precision floating point type
real number
bit bit
63 S +3 S +2 S +1 S 0 R +1 R
Double precision floating point type real number Signed 32-bit binary data
64 bits 32 bits

7-126 - KV-5500/5000/3000/1000 Series Script Programming Manual -


For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

ƽ Example of format
DM2100.L = INTG (DM1100.F)
CR2002 DM1100 DM2100
LDA.F INTG.L STA.L
Always ON Conversion destination device Return value

Note

ARITHMETIC OPERATION FUNCTIONS


g When S is outside the single precision floating point type real number range, or when
the converted data is outside the 16-/signed 32-bit BIN range, the bit pattern of is stored
in R .
g When S is outside the double precision floating point type real number range, or
when the converted data is outside the 16-/signed 32-bit BIN range, the lower 32-bit
pattern of is stored in R .

Sample Program
7
ƽ Example of use

Floating Point Functions


Programmed Script DM2000.L = INTG (DM1000.F + 1.25)
Description of Operation The operation result of the single precision floating point type real number of
DM1000.F+1.25 is converted to a signed 32-bit data integer, and the conversion result is
stored in DM2000.L.
Ladder Conversion CR2002 DM1000 +1.25 DM2000
LDA.F ADD.F INTG.L STA.L
Always ON Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-127


INT
Convert single precision floating point type real number data to
BIN data

Integer conversion

Return value
*1
= INT (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination *4

destination device or the conversion destination - - - - .F .DF - - ƻ ƻ ƻ


*2
device data.
*4
*3
R Return value .L type INT function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 C, T, CTC, CTH, Zcan not be used.


*3 When the type other than .L is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
7 "KV-5500/5000/3000 CPU Function Version", Page 2
g Refer to the "INTG function" for details on the range of the single precision floating
Floating Point Functions

point type real number and double precision floating point real number.

Description of Operation

This function is similar to "INTG function" except function name is different.

7-128 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-129


DISF
Disperse mantissa/exponent of single precision floating point
type real number
Disperse F

DISF ([execution condition,]*1 Operation destination device, mantissa store device,


exponent store device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device of the single
Operation
precision floating point type real *3 ƻ
destination - - - - .F - - - ƻ ƻ
*2 number whose mantissa and exponent
device*4
are to be dispersed.
D1 Mantissa store Specifies the device to store the
- - .L .L - - - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*2
device dispersed mantissa section to.
D2 Exponent store Specifies the device to store the
.S .S - - - - - - - ƻ -
device dispersed exponent section to.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 32 continuous bits are handled. When a relay other than the leading
relay (e.g. R002, R1012) of the channel has been specified, the relay is handled straddling the next channel.
*3 The constant setting is the range of floating real numbers.
*4 C, T, CTC, CTH, Zcan not be used.
7 Note
Refer to the "INTG function" for details on the range of the single precision floating point
Floating Point Functions

type real number.

Description of Operation

When the execution condition is established (TRUE), the mantissa section and exponent section of the
32-bit single precision floating point type real number of S are dispersed, the mantissa section is
stored as signed 32-bit BIN data to the specified D1 , and the exponent section is stored as signed
16-bit BIN data to the specified D2 .

D1 +1 D1
Sǂ+1 S Mantissa part: Signed 32-bit binary data

Single precision floating point type real number Spilit 32 bits (2 words)

32 bits (2 words)
D2
Exponent part: Signed 16-bit binary data
Separate example for ˉ1.234×10嘑嘓
16 bits (1 word)

Mantissa Exponent

Mantissa part ˉ1234000 (Signed 32-bit binary data)


ˉ1.234×10嘑嘓 Spilit

Exponent part ˉ9 (Signed 16-bit binary data)


(Single precision floating
point type real number)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-130 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DISF (R3000, DM1000.F, DM2000.L, DM2100.S)
R3000 DISF
DM1000 DM2000 DM2100
Execution conditon
Operation Mantissa Exponent
destination device saving device saving device

Note
g With the DISF function, an error sometimes occurs as single precision floating point type
real number (BIN) are being converted to a mantissa section (decimal) and an exponent

ARITHMETIC OPERATION FUNCTIONS


section (decimal).
g The function is not executed when the data to disperse is outside the single precision
floating point type real number range.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DISF (LOG (DM3000.F), EM3000.L, EM3100) 7
Description of Operation The mantissa section and exponent section of the value resulting from having converted the

Floating Point Functions


natural logarithm of the single precision floating point type real number currently stored in
DM3000.F is dispersed, the mantissa section is stored in EM3000.L, and the exponent
section is stored in EM3100.S at every scan (no execution condition).
Ladder Conversion
CR2002 DM3000 @VM0
LDA.F LOG STA.F
Always ON Operation
destination device
DISF
@VM0 EM3000 EM3100

Mantissa Exponent saving device


saving device
Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"LOG function", Page 7-136

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-131


UNIF
Unite mantissa and exponent to single precision floating point
type real number

UniteF
*1
Return value = UNIF(mantissa store device, exponent store device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Mantissa store Specifies the device to which the
*2 - - .L .L - - - - - ƻ ƻ
device mantissa section to unite is stored.
S2 Exponent store Specifies the device to which the
.S .S .S .S - - - - - ƻ ƻ
device exponent section to unite is stored.
*4
*3
R Return value .F type UNIF function available .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 32 continuous bits are handled. When a relay other than the leading relay
(e.g. R002, R1012) of the channel has been specified, the relay is handled straddling the next channel.
*3 When the type other than .F is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The signed 32-bit BIN data of S1 is taken as the mantissa, and the signed 16-bit BIN data of S2

are united, and the resulting 32-bit single precision floating point type real number value is stored in
R .
S1 +1 S1
Mantissa: Signed 32-bit binary data
R +1 R
32 bits (2 words)
Merge Single precision floating point type real number

S2 32 bits (2 words)

Exponent: Signed 16-bit binary data

16 bits (1 word)

Mantissa part ˉ1234 (Signed 32-bit binary data)


Example of merge Merge ˉ1.234ǂ×ǂ10ˉ3
Exponent part ˉ6 (Signed 16-bit binary data) (Single precision floating
point type real number)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-132 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.F = UNIF (DM1000.L, DM1100.S)
CR2002 MOV.F
+0 @VM0
Always ON
UNIF
DM1000 DM1100 @VM0

Mantissa saving device Exponent saving device


CR2002 MOV.F

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM2000
Always ON
Return value

Note
g With the UNIF function, an error sometimes occurs as a mantissa section (DEC) and an
exponent section (DEC) are being converted to single precision floating point type real
number (BIN).
g When the operation result is outside the single precision floating point type real number
range, "0" is stored in R .

Sample Program
7

Floating Point Functions


ƽ When this function is used in combination with other functions
Programmed Script DM2000.F = EXP (UNIF (EM3000.L, EM3100.S))
Description of Operation The mantissa section currently stored in EM3000 (.L) is united with the exponent section
currently stored in EM3100 (.S), the exponent function is calculated taking the resulting
single precision floating point type real number value as the exponent, and the result is
stored in DM2000.F.
Ladder Conversion CR2002 MOV.F
+0 @VM0
Always ON
UNIF
EM3000 EM3100 @VM0

Mantissa store device Exponent store device


CR2002 @VM0 DM2000
LDA.F EXP STA.F
Always ON Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"EXP function", Page 7-134

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-133


EXP Exponent function operation

Exponent arithmetic operation

Return value
*1
= EXP (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The EXP function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The exponent function value is obtained using the exponent of the single precision floating point type
real number stored in the [ S +1· S ] conversion destination device.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R

e Single precision floating point type real number


32 bits
Single precision floating point type real number
32 bits

g When S : conversion destination device suffix is .DF


The exponent function value is obtained using the exponent of the double precision floating point type
real number stored in the [ S +3· S +2· S +1· S ] conversion destination device.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit
63 S +3 S +2 S +1 S 0
bit
63 R +3 R +2 R +1 R bit
0

e Double precision floating point type real number


64 bits
Double precision floating point type real number
64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-134 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2100.F = EXP (DM1100.F)
CR2002 DM1100 DM2100
LDA.F EXP STA.F
Always ON Conversion destination device Return value

Note
When the value to operate on or the operation result is outside the single precision floating
point type real number range, the value of S is stored in R .

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ Example of use
Programmed Script DM2000.F = EXP (DM1000.D)
Description of Operation The 32-bit BIN data stored in DM1000.D is automatically made into single precision floating
point type real number, the value of the result is taken as the exponent, and ex is calculated
and stored in DM2000.F. (DM1000.D does not need to be converted by the FLOAT function,
7
etc.)

Floating Point Functions


Ladder Conversion
CR2002 DM1000 DM2000
LDA.D FLOAT.D EXP STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"FLOAT function", Page 7-118

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-135


LOG Natural logarithm operation

Natural logarithm operation

Return value
*1
= LOG (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The LOG function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The natural logarithm of the single precision floating point type real number stored in [ S +1· S ]
conversion destination device is obtained.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R
Single precision floating point type real number Single precision floating point type real number
Log 32 bits 32 bits

g When S : conversion destination device suffix is .DF


The natural logarithm of the double precision floating point type real number stored in
[ S +3· S +2· S +1· S ] conversion destination device is obtained.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit
63 S +3 S +2 S +1 S 0
bit
63 R +3 R +2 R +1 R bit
0

Double precision floating point type real number Double precision floating point type real number

Log 64 bits 64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-136 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2100.F = LOG (DM1100.F)
CR2002 DM1100 DM2100
LDA.F LOG STA.F
Always ON Operation destination device Return value

Note
When the value to be operated on is 0 or a minus value, or the operation result is outside
the single precision floating point type real number range, the value of S is stored in

ARITHMETIC OPERATION FUNCTIONS


R .

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.L = INTG (LOG (DM1000.F)
Description of Operation The value resulting from having calculated the natural logarithm of the single precision
floating point type real number stored in DM1000.F is converted to signed 32-bit BIN data
and stored in DM2000.L.
7

Floating Point Functions


Ladder Conversion
CR2002 DM1000 DM2000
LDA.F LOG INTG.L STA.L
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"INTG function", Page 7-126

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-137


LOG10 Constant logarithm operation

Log10

Return value
*1
= LOG10 (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The LOG10 function uses the .F type if the
*3
R argument is U/S/D/L/F, and the .DF type for
Return value .U .S .D .L .F .DF - - - ƻ -
DF. The argument device type is automatically
ARITHMETIC OPERATION FUNCTIONS

*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The LOG10 function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7 g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.
Floating Point Functions

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The constant logarithm of the single precision floating point type real number stored in [ S +1· S ]
conversion destination device is obtained.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R

Log10 Single precision floating point type real number


32 bits
Single precision floating point type real number
32 bits

g When S : conversion destination data suffix is .DF


The constant logarithm of the double precision floating point type real number stored in
[ S +3· S +2· S +1· S ] conversion destination device is obtained.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit
63 S +3 S +2 S +1 S 0
bit
63 R +3 R +2 R +1 R bit
0

Log10 Double precision floating point type real number


64 bits
Double precision floating point type real number
64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-138 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.DF = Log10 (DM1000.DF)
CR2002 DM1000 DM2000
LDA.DF LOG10.DF STA.DF

Always ON Operation destination device Return value

Sample Program

ARITHMETIC OPERATION FUNCTIONS


Programmed Script DM2500.L = INTG (LOG10 (DM1500.DF))
Description of Operation The value resulting from having calculated the natural logarithm of the double precision
floating point type real number stored in DM1500.DF is converted to signed 32-bit BIN data
and stored in DM2500.L.
Ladder Conversion CR2002 DM1500 DM2500
LDA.DF LOG10.DF DINTG.L STA.L

Always ON Return value

Floating Point Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-139


RAD Convert degree (e) to radian unit

Radian

Return value
*1
= RAD (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination *3

destination device or the conversion destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The RAD function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The LOG10 function can be used only with the KV STUDIO Ver. 6.00 or higher.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
7 CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
Floating Point Functions

g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The angle ( e unit) of the single precision floating point type real number stored in [ S +1· S ]
conversion destination device is converted into a radian angle.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R
Single precision floating point type real number
32 bits
Single precision floating point type real number
32 bits
rad
g When S : conversion destination device suffix is .DF
The angle (e unit) of the double precision floating point type real number stored in
[ S +3· S +2· S +1· S ] conversion destination device is converted into a radian angle.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

Double precision floating point type real number


64 bits
Double precision floating point type real number
64 bits
rad
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-140 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gAngle (e) and radian (rad) are calculated as follows:
± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = RAD (DM1100.F)
CR2002 DM1100 DM2100
LDA.F RAD STA.F

ARITHMETIC OPERATION FUNCTIONS


Always ON Conversion destination device Return value

Note
When the value to operate on is outside the single precision floating point type real number
range, the value of S is stored in R .

Sample Program

ƽ Example of use
7

Floating Point Functions


Programmed Script DM2000.F = RAD (DM1000.D)
Description of Operation The angle (e unit) of the 32-bit BIN data stored in DM1000.D is automatically converted to
single precision floating point type real number, and the result is converted to radian unit and
stored in DM2000.F.
(DM1000.D does not need to be converted by the FLOAT function, etc.)
Ladder Conversion
CR2002 DM1000 DM2000
LDA.D FLOAT.D RAD STA.F
Always ON Operation destination device Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-141


DEG Convert radian to degree (e) unit

Degree

Return value
*1
= DEG (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the conversion destination *3

destination device or the conversion destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The DEG function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The angle (radian unit) of the single precision floating point type real number stored in [ S +1· S ]
conversion destination device is converted into degree (e) unit.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.

S +1 S R +1 R

Single precision floating point type real number rad Single precision floating point type real number

32 bits 32 bits

g When S : conversion destination device suffix is .DF


The angle (radian unit) of the double precision floating point type real number stored in
[ S +3· S +2· S +1· S ] conversion destination device is converted into degree (e) unit.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

Double precision floating point type real number rad Double precision floating point type real number

64 bits 64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-142 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gAngle (e) and radian (rad) are calculated as follows:
± 180
1e= ̯ 0.01745(rad) 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = DEG (DM1100.F)
CR2002 DM1100 DM2100
LDA.F DEG STA.F
Always ON Conversion destination device Return value

ARITHMETIC OPERATION FUNCTIONS


Note
When the value to operate on is outside the single precision floating point type real number
range, the value of S is stored in R .

Sample Program

ƽ When this function is used in combination with other functions


7
Programmed Script DM2000.L = INTG (DEG (DM1000.F))

Floating Point Functions


Description of Operation Convert the angle (arc) of single precision floating point type real number stored in
DM1000.F to degree ( e), convert the result to 32 bit, signed BIN data, then store it in
DM2000.L.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F DEG INTG.L STA.L
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"INTG function", Page 7-126

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-143


SIN Angle (radian) to sine value

Sine

Return value
*1
= SIN (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The SIN function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g The range of the single precision floating point type real number which can be handled
with this function is as follows:
-1.6777216E+7 <N < -1.4E-45
N=0
1.4E-45 <N < 1.6777216E+7
(effective number of digits: approx. 7 digits)
g The range of the double precision floating point type real number which can be handled
with this function is as follows:
-9.007199254740992E+15 < N < -2.23E-308
  N=0
+2.23E-308 < N < +9.007199254740992E+15
(effective number of digits: approx. 16 digits)

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The sine (SIN) value of the single precision floating point type real number angle (radian unit) stored in
[ S +1· S ] conversion destination device is obtained.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R
Single precision floating point type real number Single precision floating point type real number
SIN 32 bits 32 bits

7-144 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g When S : conversion destination device suffix is .DF
The sine (SIN) value of the double precision floating point type real number angle (radian unit) stored in
[ S +3· S +2· S +1· S ] conversion destination device is obtained.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

SIN Double precision floating point type real number Double precision floating point type real number
64 bits 64 bits

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

gAngle (e) and radian (rad) are calculated as follows:


± 180
1e= ̯ 0.01745(rad), 1(rad) ˙ ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = SIN (DM1100.F) 7
CR2002 DM1100 DM2100

Floating Point Functions


LDA.F SIN STA.F
Always ON Operation destination device Return value

Note
When the value to be operated on is outside the single precision floating point type real
number range that can be handled by the SIN function, the value of S is stored in
R .

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.F = SIN (RAD (DM1000.F))
Description of Operation The angle (e unit) of the single precision floating point type real number stored in DM1000.F
is converted to radian unit, and the sine value is calculated and the result is stored in
DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F RAD SIN STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RAD function", Page 7-140

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-145


COS Angle (radian) to cosine value

Cosine

Return value
*1
= COS (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The COS function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g The range of the single precision floating point type real number which can be handled
with this function is as follows:
-1.6777216E+7 <N < -1.4E-45
N=0
1.4E-45 <N < 1.6777216E+7
(effective number of digits: approx. 7 digits)
g The range of the double precision floating point type real number which can be handled
with this function is as follows:
-9.007199254740992E+15 < N < -2.23E-308
  N=0
+2.23E-308 < N < +9.007199254740992E+15
(effective number of digits: approx. 16 digits)

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The cosine (COS) value of the single precision floating point type real number angle (radian unit) stored
in [ S +1· S ] conversion destination device is obtained.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R

COS Single precision floating point type real number Single precision floating point type real number
32 bits 32 bits

7-146 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g When S : conversion destination device suffix is .DF
The cosine (COS) value of the double precision floating point type real number angle (radian unit)
stored in [ S +3· S +2· S +1· S ] conversion destination device is obtained.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

Double precision floating point type real number


COS Double precision floating point type real number
64 bits 64 bits

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

gAngle (e) and radian (rad) are calculated as follows:


± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = COS (DM1100. F) 7
CR2002 DM1100 DM2100

Floating Point Functions


LDA.F COS STA.F
Always ON Operation destination device Return value

Note
When the value to be operated on is outside the single precision floating point type real
number range that can be handled by the COS function, the value of S is stored in
R .

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.F = COS (RAD (DM1000.F))
Description of Operation The angle (e unit) of the single precision floating point type real number stored in DM1000.F
is converted to radian unit, and the cosine value is calculated and the result is stored in
DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F RAD COS STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RAD function", Page 7-140

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-147


TAN Angle (radian) to tangent value

Tangent

Return value
*1
= TAN (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The TAN function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g The range of the single precision floating point type real number which can be handled
with this function is as follows:
-1.6777216E+7 <N < -1.4E-45
N=0
1.4E-45 <N < 1.6777216E+7
(effective number of digits: approx. 7 digits)
g The range of the double precision floating point type real number which can be handled
with this function is as follows:
-9.007199254740992E+15 < N < -2.23E-308
  N=0
+2.23E-308 < N < +9.007199254740992E+15
(effective number of digits: approx. 16 digits)

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The tangent (TAN) value of the single precision floating point type real number angle (radian unit)
stored in [ S +1· S ] conversion destination device is obtained.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R
Single precision floating point type real number Single precision floating point type real number
TAN 32 bits 32 bits

7-148 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g When S : conversion destination device suffix is .DF
The tangent (TAN) value of the double precision floating point type real number angle (radian unit)
stored in [ S +3· S +2· S +1· S ] conversion destination device is obtained.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.

bit bit bit bit


63 S +3 S +2 S +1 S 0 63 R +3 R +2 R +1 R 0

Double precision floating point type real number Double precision floating point type real number
TAN 64 bits 64 bits

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

gAngle (e) and radian (rad) are calculated as follows:


± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format 7
DM2100.F = TAN (DM1100.F)

Floating Point Functions


CR2002 DM1100 DM2100
LDA.F TAN STA.F
Always ON Operation destination device Return value

Note
When the value to be operated on is outside the single precision floating point type real
number range that can be handled by the TAN function, the value of S is stored in
R .

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.F = TAN (RAD (DM1000.F))
Description of Operation The angle (e units) of the single precision floating point type real number stored in
DM1000.F is converted to radian unit, and the tangent value is calculated and the result is
stored in DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F RAD TAN STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RAD function", Page 7-140

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-149


ASIN Sine value to angle (radians)

Arc sine

Return value
*1
= ASIN (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The ASIN function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The angle (radian unit) is calculated from the sine (SIN) value of the single precision floating point type
real number angle stored in [ S +1· S ] conversion destination device.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.

S +1 S R +1 R

ASIN Single precision floating point type real number Single precision floating point type real number
32 bits 32 bits

g When S : conversion destination device suffix is .DF


The angle (radian unit) is calculated from the sine (SIN) value of the double precision floating point type
real number stored in [ S +3· S +2· S +1· S ] conversion destination device.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63 S +3 S +2 S +1 S 0 63 R +3 R +2 R +1 R 0

ASIN Double precision floating point type real number Double precision floating point type real number

64 bits 64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-150 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gAngle (e) and radian (rad) are calculated as follows:
± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = ASIN (DM1100.F)
CR2002 DM1100 DM2100
LDA.F ASIN STA.F

ARITHMETIC OPERATION FUNCTIONS


Always ON Operation destination device Return value

Note
When the value to operate on is outside of the range -1.0 to 1.0, the value of S is
stored in R .

Sample Program

ƽ When this function is used in combination with other functions


7

Floating Point Functions


Programmed Script DM2000.F = DEG (ASIN (DM1000.F))
Description of Operation The angle (radian unit) is calculated from the sine value of the single precision floating point
type real number stored in DM1000.F, and the result is converted to degrees ( e unit) and
stored in DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F ASIN DEG STA.F
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"DEG function", Page 7-142

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-151


ACOS Cosine value to angle (radians)

Arc cosine

Return value
*1
= ACOS (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The ACOS function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The angle (radian unit) is calculated from the cosine (COS) value of the single precision floating point
type real number angle stored in [ S +1· S ] conversion destination device.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R

ACOS Single precision floating point type real number Single precision floating point type real number
32 bits 32 bits

g When S : conversion destination device suffix is .DF


The angle (radian unit) is calculated from the cosine (COS) value of the double precision floating point
type real number stored in [ S +3· S +2· S +1· S ] conversion destination device.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63 S +3 S +2 S +1 S 0 63 R +3 R +2 R +1 R 0

ACOS Double precision floating point type real number Double precision floating point type real number
64 bits 64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-152 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gAngle (e) and radian (rad) are calculated as follows:
± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = ACOS (DM1100.F)
CR2002 DM1100 DM2100
LDA.F ACOS STA.F

ARITHMETIC OPERATION FUNCTIONS


Always ON Operation destination device Return value

Note
When the value to operate on is outside of the range -1.0 to 1.0, the value of S is
stored in R .

Sample Program

ƽ When this function is used in combination with other functions


7
Programmed Script DM2000.F = DEG (ACOS (DM1000.F))

Floating Point Functions


Description of Operation The angle (radian unit) is calculated from the cosine value of the single precision floating
point type real number stored in DM1000.F, and the result is converted to degrees (e unit)
and stored in DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F ACOS DEG STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"DEG function", Page 7-142

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-153


ATAN Tangent value to angle (radian)

Arc tangent

Return value
*1
= ATAN (operation destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination *3

destination device or the operation destination .F .F .F .F .F .DF - - ƻ ƻ ƻ


device data.
The ATAN function uses the .F type if the
argument is U/S/D/L/F, and the .DF type for *3
R Return value DF. .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

The argument device type is automatically


*2
converted to the function type.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type differing from the return value type is specified, the type will be automatically converted during
the conversion.
*3 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", Page 2


g Refer to the "INTG function" for details on the range of the single precision floating
point type real number and double precision floating point real number.

Description of Operation

g When S : conversion destination device suffix is .U/.S/.D/.L/.F


The angle (radian unit) is calculated from the tangent (TAN) value of the single precision floating point
type real number angle stored in [ S +1· S ] conversion destination device.
The results become the 32-bit single precision floating point type real number, and are stored in the
[ R +1· R ] return value.
S +1 S R +1 R

ATAN Single precision floating point type real number Single precision floating point type real number

32 bits 32 bits

g When S : conversion destination device suffix is .DF


The angle (radian unit) is calculated from the tangent (TAN) value of the double precision floating point
type real number stored in [ S +3· S +2· S +1· S ] conversion destination device.
The results become the 64-bit double precision floating point type real number, and are stored in the
[ R +3· R +2· R +1· R ] return value.
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

ATAN Double precision floating point type real number Double precision floating point type real number
64 bits 64 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-7 Floating
Point Instructions".

7-154 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gAngle (e) and radian (rad) are calculated as follows:
± 180
1e= ̯ 0.01745(rad), 1(rad)= ̯ 57.23e
180 ±

ƽ Example of format
DM2100.F = ATAN (DM1100.F)
CR2002 DM1100 DM2100
LDA.F ATAN STA.F

ARITHMETIC OPERATION FUNCTIONS


Always ON Operation destination device Return value

Note
When the value to operate on is outside the single precision floating point type real number
range, the value of S is stored in R .

Sample Program

ƽ When this function is used in combination with other functions 7


Programmed Script DM2000.F = DEG (ATAN (DM1000.F))

Floating Point Functions


Description of Operation The angle (radian unit) is calculated from the tangent value of the single precision floating
point type real number stored in DM1000.F, and the result is converted to degrees (e units)
and stored in DM2000.F.
Ladder Conversion
CR2002 DM1000 DM2000
LDA.F ATAN DEG STA.F
Always ON Operation destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"DEG function", Page 7-142

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-155


Text Processing Functions

ASC Convert BIN data to HEX ASCII code

HEX ASCII code conversion

Return value
*1
= ASC (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the HEX
destination ASCII text code to be converted is stored, .U .U .U .U - - - - ƻ ƻ ƻ
*2
device or the conversion destination data.
*4
*3
R Return value .U type ASC function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit device
has been specified for the conversion destination device, the function operates normally straddling the
next channel.
*3 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
7 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Text Processing Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The value of the lower eight bits of the BIN data stored in S is converted to HEX annotation ASCII
text code, and the result is stored in R .

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 S
conversion
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

After 0 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 R
convertion
4 1 3 5

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.U = ASC (DM1000.U)
CR2002 DM1000 DM2000
LDA ASC STA
Always ON Conversion destination device Return value

7-156 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = ASC (SRA (DM1000.U, 8))
Description of Operation The BIN data currently stored in DM1000 is shifted to the right by 8 bits.
The values of the lower eight bits (upper eight bits before the shift) of the shift result are
converted to HEX annotation ASCII text code, and the result is stored in DM2000.
Ladder Conversion

ARITHMETIC OPERATION FUNCTIONS


CR2002 DM1000 #8 DM2000
LDA SRA ASC STA
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SRA function", Page 7-40

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-157


RASC Convert HEX ASCII code to BIN data

HEX ASCII code reverse conversion

Return value
*1
= RASC (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the
destination conversion destination BIN data is stored .U .U .U .U - - - - ƻ ƻ ƻ
*2
device*3 or the conversion destination data.
*5
*4
R Return value .U type RASC function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
ARITHMETIC OPERATION FUNCTIONS

*2 Though 32-bit data also can be used for the conversion destination data, only the lower 16 bits are
targeted for conversion.
*3 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit device
has been specified for the conversion destination device, the function operates normally straddling the
next channel.
*4 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

7 Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Text Processing Functions

g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The HEX annotation ASCII text code (two characters worth) of the 16 bits stored in S are
converted to BIN data, the 16-bit data (lower eight bits are the conversion value, and the upper eight
bits are "0") of the result is stored in R .
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 S
conversion
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

After 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 R
conversion
0 0 6 C

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on ASCII codes, see "ASCII Code Table", Page A-15.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-158 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g An ASCII code both of whose upper and lower bits are 0 to 9 (30H to 39H) or A to F (41H to 46H),
or an ASCII code whose upper bit is a NUL (00H) and whose lower bit is 0 to 9 (30H to 39H) or A to
F (41H to 46H) must currently be stored in S .
When either of the upper eight bits or lower eight bits is outside of this range, the function
is not executed.
g When there is an ASCII text code that cannot be handled, the value of S is stored in
R .

ARITHMETIC OPERATION FUNCTIONS


ƽ Example of format
DM2000.U = RASC (DM1000.U)
CR2002 DM1000 DM2000
LDA RASC STA
Always ON Conversion destination device Return value

Sample Program

ƽ When this function is used in combination with other functions


7

Text Processing Functions


Programmed Script DM2000.U = RASC (SWAP (DM1000))
Description of Operation The values of the upper byte (upper eight bits) and the lower byte (lower eight bits) of the
HEX annotation ASCII text code currently stored in DM1000 are swapped.
As a result of the swap, the bytes are converted to 16-bit BIN data, and the result is stored in
DM2000.
Ladder Conversion
CR2002 DM1000 DM2000
LDA SWAP RASC STA
Always ON Conversion destination device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SWAP function", Page 7-102

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-159


DASC Convert BIN data to DEC ASCII text string

Decimal ASCII code conversion

Return value
*1
= DASC (conversion destination device, conversion parameter)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Conversion Specifies the device to which the conversion
destination destination BIN data is stored or the .U .S .D .L - - - - *4
ƻ ƻ ƻ
*2
device conversion destination data.
S2 Conversion Specifies the device to which the conversion
*5 .U .U .U .U - - - - ƻ ƻ ƻ
parameter parameter is stored, or the parameter. (0 to 3)
*3
R Return value .T type DASC function available - - - - - - - .T - -
ARITHMETIC OPERATION FUNCTIONS

*6 ƻ
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002 or R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.
*3 For bit devices, specify the leading device of the channel.
*4 Constants cannot be specified by $.
*5 Specify the conversion parameter with the range 0 to 3.
S2 conversion parameter explanation

7 Value
0
Description
Zero suppress OFF, sign omission OFF
CR2814
0
CR2815
0
1 Zero suppress ON, sign omission OFF 1 0
Text Processing Functions

2 Zero suppress OFF, sign omission ON 0 1


3 Zero suppress ON, sign omission ON 1 1

Note
The function might not operate correctly when a value outside of the range is specified to the conversion parameter.

*6 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

The BIN data stored in S1 is converted to DEC ASCII code text string according to the S2 , and the result
is stored in R .

g S1 : When the conversion destination device is unsigned 16-bit data (.U)


bit
15
S bit
0
bit
15
bit
0

Unsigned 16-bit binary data R ten thousand thousand


Store 00H in
16 bits R +1 hundred ten
last bit
N automatically.
R +2 one U
L
(00H)

g S1 : When the conversion destination device is signed 16-bit data (.S)


bit
15
S bit
0
bit
15
bit
0

Signed 16-bit binary data R Symbols ten thousand

16 bit R +1 thousand hundred

R +2 ten one
N
R +3 U
L
(00H)

Store 00H in last No change before and


bit automatically. after command perform.

7-160 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When the conversion destination device is unsigned 32-bit data (.D)
bit
31
S +1 bit
16
bit
15
S bit
0
bit
15
bit
0

Unsigned 32-bit BIN data R billion a hundred million


32 bits R +1 ten million million

R +2 a hundred thousand ten thousand

R +3 thousand hundred

R +4 ten one
N
R +5 U (00H)

ARITHMETIC OPERATION FUNCTIONS


L

Store 00H in last No change before and


bit automatically. after command perform.

g S1 : When the conversion destination device is signed 32-bit data (.L)


bit
31
S +1 bit
16
bit
15
S bit
0
bit
15
bit
0

Signed 32-bit binary data R Symbols billion


32 bits R +1 a hundred million ten million

R +2 million a hundred thousand

R +3 ten thousand thousand

R +4 hundred
N
ten 7
R +5 one U
L
(00H)

Text Processing Functions


Store 00H in last
bit automatically.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.T = DASC (DM1000 , 3)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#00000 VM2

MOV.D
VM0 @VM2

CR2002 MOV
CR2814 @VM0
Always ON
ASCII Conversion zero suppression setting

#3 CR2814
LDA STA
ASCII Conversion zero suppression setting

CR2002 DASC
DM1000 *@VM2
Always ON
Conversion destination device
@VM0 CR2814
LDA STA
ASCII Conversion zero suppression setting
CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-161


Note
g When a constant is used for the conversion destination data, it cannot be specified in HEX ($).
g 2-byte characters (shift JIS code) cannot be specified to conversion destination data.
g Attention is required when changing or looking up CR2814/CR2815 by interrupt programs.
g When either of the following conditions is established, the end code (NUL (00H)) is stored
in R .
g When a device other than the leading device of the channel is specified when a bit
device is specified to R .
g When a timer/counter is specified to R by indirect specifying.
ARITHMETIC OPERATION FUNCTIONS

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.T = DASC (TBIN (DM1000.D), 0)
Description of Operation The 8-digit BCD data stored in DM1000.D is converted to BIN data.
The value resulting from conversion is converted to decimal ASCII code text string, and the

7 Ladder Conversion
result is stored in EM2000.T.

CR2002 DM1000 @VM0


Text Processing Functions

LDA.D TBIN.D STA.D


Always ON Conversion destination device
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM4

CR2002 MOV
CR2814 @VM2
Always ON ASCII conversion
zero suppression
#0 CR2814
LDA STA
ASCII conversion
zero suppression
CR2002 DASC.D
@VM0 *@VM4
Always ON
@VM2 CR2814
LDA STA
ASCII conversion
zero suppression
CR2002 SMOV
*@VM4 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBIN function", Page 7-84

7-162 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-163


STR Convert numerical value data to ASCII code

Decimal ASCII code conversion

Return value
*1
= STR (conversion destination device)
Supported Type Const
Argument/Return Value Explanation Device Formula
.U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the
destination conversion destination BIN data is stored .U .S .D .L .F - - - ƻ ƻ ƻ
*2
device*4 or the conversion destination data.
*3
R Return value*5 .T type STR function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
ARITHMETIC OPERATION FUNCTIONS

*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002 or R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.
*3 For bit devices, specify the leading device of the channel.
*4 Constants cannot be specified by $.
*5 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

7 DEC ASCII text string conversion or single precision floating point type text string conversion is
S
performed according to the argument type specified by .
Text Processing Functions

g When S is 16 bits: The same operation as the DASC function is performed.


bit
15
S bit
0
bit
15
bit
0

Unsigned 16-bit binary data R ϛ ग

+1 ⱒ क ᳿ሒ㞾ࡼ
16 bits R
ᄬ‫ټ‬00HDŽ
N
R +2 ϔ U
L
(00H)

bit
15
S bit
0
bit
15
bit
0

Signed 16-bit binary data R Symbols ten thousand

16 bits R +1 thousand hundred

R +2 ten one
N
R +3 U
L
(00H)

Store 00H in last No change before and


bit automatically. after command perform.

For details on operation "DASC function", Page 7-160.

g When S conversion destination device is 32 bits: The same operation as the DASC function is performed.
bit
31
S +1 bit
16
bit
15
S bit
0
bit
15
bit
0

Unsigned 32-bit BIN data R billion a hundred million


32 bits R +1 ten million million

R +2 a hundred thousand ten thousand

R +3 thousand hundred

R +4 ten one
N
R +5 U
L
(00H)

Store 00H in last No change before and


bit automatically. after command perform.

7-164 - KV-5500/5000/3000/1000 Series Script Programming Manual -


bit
31
S +1 bit
16
bit
15
S bit
0
bit
15
bit
0

Signed 32-bit binary data R Symbols billion


32 bits R +1 a hundred million ten million

R +2 million a hundred thousand

R +3 ten thousand thousand

R +4 hundred ten
N
R +5 one U
L
(00H)

Store 00H in last bit automatically.

ARITHMETIC OPERATION FUNCTIONS


For details on operation "DASC function", Page 7-160.

g When the S conversion destination device is single precision floating point type: The same
operation as the FASC function* is performed.
bit
15
“12.30000” bit
0

R 1(31H) 2(32H)
S +1 S
R +1 .(2EH) 3(33H)
+12.3
R +2 0(30H) 0(30H)
Single precision floating point type real number
R +3 0(30H) 0(30H)
N
R +5 U
L (00H)

Store 00H in last No change before and

7
bit automatically. after command perform.

* Conversion is performed with the conversion parameter=3 (CR2814=ON, CR2815=ON: zero suppress, symbol omitted).
For details on operation "FASC function", Page 7-174.

Text Processing Functions


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.

Note
g When either of the following conditions is established, the end code (NUL (00H)) is stored in R .
g When a device other than the leading device of the channel is specified when a bit
device is specified to R
g When a timer/counter is specified to R by indirect specifying

ƽ Example of format
DM2000.T = STR (DM1000)
CR2002 ADRSET
VM2 VM0
Always ON

MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 MOV
CR2800 @VM0
Always ON
Send break signal
CR2814
SET
ASCII Conversion
zero suppression setting
CR2815
SET
ASCII conversion
+ omit signal
DASC
DM1000 *@VM2

MOV
@VM0 CR2800

Send turnoff signal


CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-165


RDASC Convert DEC ASCII text string to BIN data

Decimal ASCII code reverse conversion

Return value
*1
= RDASC (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the
Conversion
decimal ASCII text string to be
destination - - - - - - - .T ƻ ƻ ƻ
*2 converted is stored, or the decimal
device*3
ASCII code text string.
*6
*4 *5
R Return value .L type RDASC function available .U .S .D .L .F .DF - - - ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 T, C, CR, CTC, CTH, Z can not be used.
*4 When a bit device has been specified, 32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002 or R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.
*5 When the type other than .L is specified by return value, type conversion will be automatically conducted
during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
7 versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
Text Processing Functions

CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The DEC ASCII text string currently stored starting from S is converted to signed 32-bit BIN data,
and the result is stored in R .
bit
15
bit
0
bit
31
R +1 bit
16
bit
15
R bit
0

S Symbols billion Signed 32-bit binary data

S +1 a hundred million ten million

S +2 million a hundred thousand

S +3 ten thousand thousand

S +4 hundred ten
N
S +5 one U (00H)
L NUL (00H) shall add to end of string.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.L = RDASC (DM1000.T)
CR2002 MOV.L
+0 @VM0
Always ON

RDASC.L
DM01000 @VM0

CR2002 MOV.L
@VM0 DM2000
Always ON
Return value

7-166 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g Specify a text string comprising $30 to $39 ("0" to "9") and $2B, $2D (" f ": only in the
case of signed conversion) to the decimal ASCII text string specified by the conversion
destination data.
g When an ASCII text string other than the above has been specified to S , the function
is not executed.
g When the ASCII text string specified by S does not contain a NUL (00H), the function
converts text strings up to 11 characters.
g When either of the following conditions is established, 0 is stored in R :

ARITHMETIC OPERATION FUNCTIONS


g When there is an invalid character in . S
g When the value after conversion is outside the signed 32-bit BIN data range
g When a device other than the leading device of the channel is specified when a bit
device is specified to S .
g When a timer/counter is specified to S by indirect specifying.

Sample Program

ƽ When this function is used in combination with other functions 7


Programmed Script DM2000.L = RDASC (SLEFT (DM1000.T, 7))

Text Processing Functions


Description of Operation The leading seven characters of the decimal ASCII text string currently stored starting from
DM1000.T are cut, and converted to signed 32-bit BIN data, and the result is stored in
DM2000.L.
Ladder Conversion
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SLEFT
DM1000 *@VM0 #7
Always ON
Conversion destination device
CR2002 MOV.L
+0 @VM2
Always ON

RDASC.L
*@VM0 @VM2

CR2002 MOV.L
@VM2 DM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SLEFT function", Page 7-192

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-167


HASC Convert BIN data to HEX ASCII text string

HEX ASCII code conversion

Return value
*1
= HASC (conversion destination device,number of conversion digits)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the
Conversion
conversion destination BIN data is
destination .U .U .D .D - - - - ƻ ƻ ƻ
*2 stored or the conversion destination
device
data. (unsigned BIN data)
n Number of Specifies the number of digits of the
conversion numerical value (HEX) to store the .U .U .U .U - - - - *3
ƻ ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

*5
digits conversion result to. (0 to 8)
*4
R Return value*6 .T type HASC function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When a bit device has been specified, 16/32 continuous bits are handled.
When a relay other than the leading relay (e.g. R002 or R1012) of the channel has been specified, the
relay is handled in16/32 bits straddling the next channel.
*3 Constants must be specified by $. Constants cannot be specified by a "#".
*4 The .T suffix must be specified to the device for storing the return value.
Also, to specify a bit device to a return value, the start of the channel must be specified.
7 *5 Specify the number of digits (lower digit) to store the conversion result within the range 0 to 8 to the
number of conversion digits.
Text Processing Functions

(When "0" is specified, zero suppress is ON, and the number of effective digits is stored.)
*6 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

The BIN data stored in S is converted to a HEX ASCII text string appended with the end code NUL
(00H), and the result is stored in R for the specified N . (when n =0, all of the data of
S is converted with zeros suppressed.)

g S : When the conversion destination device is unsigned 16-bit data (.U)


Digit n 4 3 2 1
S 0 1 2 C

n =1 n =2
N
HEX ASCII string R C(43H) U
L
(00H) R 2(32H) C(43H)
N
R +1 U
L
(00H)

n =3 n =4
R 1(31H) 2(32H) R 0(30H) 1(31H)
N
R +1 C(43H) U
L
(00H) R +1 2(32H) C(43H)
N
U (00H)
R +2 L

n =0
R 1(31H) 2(32H)
N
R +1 C(43H) U
L
(00H)

7-168 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When the conversion destination device is unsigned 32-bit data (.D)
Digit n 8 7 6 5 4 3 2 1

Unsigned 32-bit BIN data S +1・ S 0 0 1 2 C D E 0

n =1 n =2
N
HEX ASCII string R 0(30H) U
L
(00H) R E(45H) 0(30H)
N
R +1 U
L
(00H)

ARITHMETIC OPERATION FUNCTIONS


n =7 n =8
R 0(30H) 1(31H) R 0(30H) 0(30H)

R +1 2(32H) C(43H) R +1 1(31H) 2(32H)


R +2 D(44H) E(45H) R +2 C(43H) D(44H)
N
R +3 0(30H) U
L
(00H) R +3 E(45H) 0(30H)
N
n =0 R +4 U
L
(00H)

R 1(31H) 2(32H)

R +1 C(43H) D(44H)

R +2 E(45H) 0(30H)

R +3
N
U
L
(00H)
7

Text Processing Functions


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.T = HASC (DM1000, 3)
CR2002 ADRSET
VM2 VM0
Always ON

MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 HASC
DM1000 *@VM0 #3
Always ON
Conversion destination device
CR2002 SMOV
*@VM0 DM2000
Always ON
Store device

Note
g When a constant is used for the conversion destination data, it cannot be specified in decimal (#).
g When either of the following conditions is established, the end code (NUL (00H)) is stored in R .
g When a device other than the leading device of the channel is specified when a bit
device is specified to R .
g When a timer/counter is specified to R by indirect specifying.
g When 5 or more is specified to n in the case of .U suffix instructions and 9 or more
is specified in the case of .D suffix instructions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-169


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.T = HASC (SRA (DM1000.D, 8), 0)
Description of Operation The BIN data currently stored in DM1000.D is shifted to the right by 8 bits.
The value of the shift result (upper 24 bits before the shift) is converted to a HEX ASCII text
string, and is stored in EM2000.T for the effective number of digits with zero suppress ON.
Ladder Conversion
ARITHMETIC OPERATION FUNCTIONS

CR2002 DM1000 #8 @VM0


LDA.D SRA.D STA.D
Always ON Conversion destination device
CR2002 ADRSET
VM2 VM0
Always ON

MOV
#0 VM2

MOV.D
VM0 @VM2

7 CR2002 HASC.D
@VM0 *@VM2 #0
Text Processing Functions

Always ON

CR2002 SMOV
*@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SRA function", Page 7-40

7-170 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-171


RHASC Convert HEX ASCII text string to BIN data

HEX ASCII code reverse conversion

Return value
*1
= RHASC (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the HEX
Conversion
ASCII text string to be converted is
destination - - - - - - - .T ƻ ƻ -
*2 stored, or the HEX ASCII code text
device*3
string.
*6
*4 *5
R Return value .D type RHASC function available .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device.
*2 For bit devices, specify the leading device of the channel.
*3 T, C, CR, CTC, CTH, Z can not be used.
*4 When a bit device has been specified, 32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 32 bits
straddling the next channel.
*5 When the type other than .D is specified by return value, type conversion will be automatically conducted
during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
7 versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
Text Processing Functions

CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The DEC ASCII text string currently stored starting from S is converted to unsigned 32-bit BIN
data, and the result is stored in R .
HEX ASCII string Unsigned 32-bit BIN data
bit bit
15 0

S 1(31H) 2(32H)

S +1 A(41H) B(42H) R +1 R

S +2 C(43H) D(44H) 1 2 A B C D 1 4

S +3 1(31H) 4(34H)
N
S +4 U
L (00H)

bit bit
15 0

S 1(31H) 2(32H)
R +1 R
S +1 A(41H) B(42H)
0 1 2 A B C D 3
S +2 C(43H) D(44H)
N
S +3 3(33H) U
L (00H)

bit
15
bit
0
R +1 R
N
S 1(31H) U
L (00H) 0 0 0 0 0 0 0 1

bit
15
bit
0
R +1 R
N
S U
L (00H) 0 0 0 0 0 0 0 0

7-172 - KV-5500/5000/3000/1000 Series Script Programming Manual -


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.D = RHASC (DM1000.T)
CR2002 MOV.D
#0 @VM0
Always ON
RHASC.D

ARITHMETIC OPERATION FUNCTIONS


DM1000 @VM0

Conversion destination device


CR2002 MOV.D
@VM0 DM2000
Always ON
Return value

Note
g A value in the range $30 to $39 ("0" to "9") or $41 to $46 ("A" to "F") must be currently stored
in HEX ASCII text string specified by the S conversion destination data.
g Use uppercase A to F (41H to 46H) in HEX ASCII text strings. Lowercase characters are not supported.
g When either of the following conditions is established, 0 is stored in R :
g When there is an invalid character in S
g When the value after conversion is outside the unsigned 32-bit BIN data range 7
g When a device other than the leading device of the channel is specified when a bit

Text Processing Functions


device is specified to S
g When a timer/counter is specified to S by indirect specifying

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.D = RHASC (SLEFT (DM1000.T, 6))
Description of Operation The leading six characters of the HEX ASCII text string currently stored starting from
DM1000.T are cut, and converted to unsigned 32-bit BIN data, and the result is stored in
DM2000.D.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SLEFT
DM1000 *@VM0 #6
Always ON
CR2002 Conversion destination device
MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2

CR2002 MOV.D
@VM2 DM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SLEFT function", Page 7-192
- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-173
FASC
Convert single precision floating point type real number to text
string
Floating text string conversion

Return value
*1
= FASC (display format, total number of digits, number of digits past
decimal point, conversion destination device, conversion parameter)
Supported Type Const
Argument/Return Value Explanation Device Formula
.U .S .D .L .F .DF .B .T #/$
S1 Specifies the display specification
Display specification
format (decimal point format, exponent .U .U .U .U - - - - ƻ ƻ ƻ
format
format).
S2 Total number of digits Specifies the total number of digits. .U .U .U .U - - - - ƻ ƻ ƻ
S3 Number of decimal Specify the number of decimals. .U .U .U .U - - - - ƻ ƻ ƻ
ARITHMETIC OPERATION FUNCTIONS

Specifies the device to which the


S4 Conversion conversion destination single precision
destination floating point type real number is - - - - .F - - - ƻ ƻ ƻ
*2 *5
device*3 stored or the single precision floating
point type real number data.
S5 Conversion parameter Specifies zero suppress and sign omission. .U .U .U .U - - - - ƻ ƻ ƻ
*4
R Return value*5 .T type FASC function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When a bit device has been specified, 32 continuous bits are occupied. When a relay other than the leading relay
(e.g. R002 or R1012) of the channel has been specified, 32 bits are occupied straddling the next channel.

7 *3 Refer to the
number.
"INTG function" for details on the range of the single precision floating point type real
Text Processing Functions

*4 For bit devices, specify the leading device of the channel.


*5 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

The single precision floating point type real number data stored in S is converted to a text string
appended with the end code NUL (00H) according to S1 to S3 and the conversion parameter
stored in S5 , and the result is stored in R .
The conversion parameter device is specified as follows.
Display Specifies "0" when converting to a decimal point format text string, and "1" when
S1
specification format converting to an exponent format text string.
S2 Total number of digits Specify within the range 1 to 24 digit.
S3 Number of decimal Specify within the range 0 to 7 digit.

The content to specify in the conversion parameter is as follows.


S5 Value Description CR2814 CR2815
0 Zero suppress OFF, sign omission OFF 0 0
1 Zero suppress ON, sign omission OFF 1 0
2 Zero suppress OFF, sign omission ON 0 1
3 Zero suppress ON, sign omission ON 1 1

bit
15
“+012.30” bit
0

R +(31H) 0(30H)
S2 +1 S2
R +1 1(31H) 2(32H)
+12.3
R +2 . (2EH) 3(33H)
Single precision floating point type real number N
R +3 0(30H) U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-174 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = FASC (0, 10, 3, DM1200.F, DM1000)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM4

ARITHMETIC OPERATION FUNCTIONS


CR2002 MOV
#0 @VM0
Always ON
MOV
#10 @VM1

MOV
#3 @VM2

MOV
CR2814 @VM3
ASCII Conversion
DM1000
LDA
zero suppression setting CR2814
STA 7
Conversion parameter ASCII Conversion
zero suppression setting

Text Processing Functions


FASC
@VM0 DM1200 *@VM4

Conversion destination device


@VM3 CR2814
LDA STA
ASCII Conversion zero suppression setting
CR2002 SMOV
*@VM4 DM2000
Always ON
Return value

Note
g When a constant is used for the conversion destination data, it cannot be specified in HEX ($).
g Attention is required when changing or looking up CR2814/CR2815 by interrupt programs.
g When either of the following conditions is established, the end code NUL (00H) is stored in R :
g When the argument value is out of range
g When a single precision floating point type real number out of the range has been
specified
gWhen the number of digits of the text string to store has exceeded the total number of digits
g When a device other than the leading device of the channel is specified when a bit
device is specified to R
g When a timer/counter is specified to R by indirect specifying
g When the total number of digits and the number of digits past the decimal point do not
satisfy the following conditions
Decimal point format display Exponent format display
S3 =0 1 <= S2 <= 24 5 <= S2 <= 24
S3 +2 <= S2 S3 +6 <= S2
0< S3 <= 7
3 <= S2 <= 24 7 <= S2 <= 24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-175


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.T = FASC (0, 10, 3, SIN (DM1000.F), 3)
Description of Operation The sine (SIN) value of the angle of the single precision floating point type real number
stored in DM1000.F is calculated, and the result is converted to a decimal point format text
string that takes three of the total of ten digits as the number of digits past the decimal point.
(conversion with zero suppress and sign omission)
ARITHMETIC OPERATION FUNCTIONS

The converted text string is appended with the end code NUL (00H), and is stored in
EM2000.T. (The conversion destination device need not be converted to a single precision
floating point type by using the FLOAT function, etc.)
Ladder Conversion CR2002 DM1000 @VM0
LDA.F SIN STA.F
Always ON
CR2002 ADRSET
VM2 VM0
Always ON
MOV

7 #0 VM2

MOV.D
Text Processing Functions

VM0 @VM6

CR2002 MOV
#0 @VM2
Always ON
MOV
#10 @VM3

MOV
#3 @VM4

MOV
CR2814 @VM5
ASCII Conversion
#3 zero suppression setting CR2814
LDA STA
ASCII Conversion
zero suppression setting
FASC
@VM2 @VM0 *@VM6

@VM5 CR2814
LDA STA
ASCII Conversion
zero suppression setting
CR2002 SMOV
*@VM6 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SIN function", Page 7-144

7-176 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-177


RFASC
Text string to single precision floating point type real number
conversion

Single precision floating point text string reverse conversion

Return value
*1
= RFASC (conversion destination device)
Supported Type Const
Argument/Return Value Explanation Device Formula
.U .S .D .L .F .DF .B .T #/$
Specifies the device to which the
S Conversion conversion destination single
destination precision floating point text string is - - - - - - - .T ƻ ƻ ƻ
*2 *5
device*4 stored or the single precision
floating point text string.
*7
ARITHMETIC OPERATION FUNCTIONS

*3 *6
R Return value*5 .F type RFASC function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device.
*2 For bit devices, specify the leading device of the channel.
*3 When a bit device has been specified, 32 continuous bits are occupied. When a relay other than the leading relay
(e.g. R002 or R1012) of the channel has been specified, 32 bits are occupied straddling the next channel.
*4 A NUL (00H) is required at the end of the floating text string that it specified by the conversion destination device.
*5 T, C, CR, CTC, CTH, Z can not be used.
*6 When the type other than .F is specified by return value, type conversion will be automatically conducted during conversion.
*7 The ".DF" suffix cannot be specified for device Z.

7 Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
Text Processing Functions

versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The single precision floating point text string currently stored starting from S is converted to single precision
floating point type real number data, and the result is stored in R .
when single precision floating point text string “+012.30”
bit bit
15 0

S +(2BH) 0(30H)
R +1 R
S +1 1(31H) 2(32H)
+12.3
S +2 .(2EH) 3(33H)
N Single precision floating point type real number
S +3 U
L (00H)

when single precision floating point text string “+1.23E+01”


bit bit
15 0

S +(2BH) 1(31H)

S +1 .(2EH) 2(32H) R +1 R

S +2 3(33H) E(45H) +12.3

S +3 +(2BH) 0(30H) Single precision floating point type real number


N
S +4 1(31H) U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-178 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.F = RFASC (DM1000.T)
CR2002 MOV.F
+0 @VM0
Always ON
RFASC
DM1000 @VM0
Conversion destination device
CR2002 MOV.F

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM2000
Always ON
Return value

Note
g Only the values of $30 to $39 ("0" to "9"), $2B ("+"), $2C ("-"), $45 ("E"), and $2E (".") must be
currently stored in single precision floating point text string to be specified by the conversion
destination data.
g When either of the following conditions is established, 0 is stored in R :
g When the length of a text string is 0
g When the format of the text string is incorrect
g When the numerical value after conversion exceeds the single precision floating point 7
type real number range

Text Processing Functions


gWhen the number of digits of the text string to store has exceeded the total number of digits
g When a device other than the leading device of the channel is specified when a bit
device is specified to S .

ƽ Format of text string


+
ˉ
Symbols Value

Sign: +, - or no sign is allowed

Numerical value: 0 to 9, seven effective digits


.(2EH) position is not specified.

+ +

ˉ
Symbols Value Symbols Value

Sign: +, - or no sign is allowed

Numerical value: 0 to 9, seven effective digits


.(2EH) position is not specified.

Sign: Either of + or - is required.

Numerical value: 0 to 9, one or two effective digits

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-179


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.F = COS (RFASC (DM1000.T))
Description of Operation The single precision floating point text string of the angle (radian units) currently stored
starting from DM1000.T is converted to single precision floating point type real number data,
and the cosine (COS) value is calculated from the conversion result and stored in DM2000.F.
Ladder Conversion
CR2002
ARITHMETIC OPERATION FUNCTIONS

MOV.F
+0 @VM0
Always ON
RFASC
DM1000 @VM0

Conversion destination device


CR2002 @VM0 DM2000
LDA.F COS STA.F
Always ON Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
7 "COS function", Page 7-146
Text Processing Functions

7-180 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-181


VAL
Text string to single precision floating point type real number
conversion

Single precision floating point text string reverse conversion

Return value
*1
= VAL (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the
Conversion
conversion destination single precision
destination - - - - - - - .T ƻ ƻ ƻ
*2 *5 floating point text string is stored or the
device*3
single precision floating point text string.
*7
*4 *6
R Return value .FF type VAL function available .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 A NUL (00H) is required at the end of the single precision floating point text string that it specified by the conversion
destination device.
*4 When a bit device has been specified, 32 continuous bits are occupied. When a relay other than the leading relay
(e.g. R002 or R1012) of the channel has been specified, 32 bits are occupied straddling the next channel.
*5 T, C, CR, CTC, CTH, Z can not be used.
*6 When the type other than .F is specified by return value, type conversion will be automatically conducted
during conversion.
7 *7 The ".DF" suffix cannot be specified for device Z.

Note
Text Processing Functions

g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

This function differs from the "RFASC function" in name only, and operation, etc. are the same.
For details on operation, see "RFASC function", Page 7-178.

7-182 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-183


LEN Detect text string length

Detect text string length

Return value
*1
= LEN (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device to which the
S Destination text destination text string for calculating the
*3 - - - - - - - .T
*2
ƻ ƻ ƻ
string device*4 text string length is stored, or the
destination text string.
*6
*5
R Return value .U type LEN function available .U .S .D .L .F .DF - - - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 To specify a text string using constants, enclose with " ".
*3 For bit devices, specify the leading device of the channel.
*4 T, C, CR, CTC, CTH, Z can not be used.
*5 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
7 versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
Text Processing Functions

CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The number of characters of the text string currently stored starting from S is counted, and the result is stored
in R as 16-bit BIN data.

S a(61H) b(62H) R 26
S +1 c(63H) d(64H) 16 bits
(1 word)
S +2 e(65H) f(66H)
˖

w(77H) x(78H)
y(79H) z(7AH)
N
U (00H)
L

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-184 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000 = LEN (DM1000.T)
CR2002 MOV
#0 @VM0
Always ON
LEN
DM1000 @VM0

Destination string
CR2002 MOV

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM2000
Always ON
Return value

Note
g 2-byte characters (shift JIS code) are handled as two characters.
g End codes (NUL (00H)) are not counted.
g When either of the following conditions is established, 0 is stored in R :
g When there is no end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When a device other than the leading device of the channel is specified when a bit
device is specified to S by indirect specifying
g When a timer/counter is specified to S by indirect specifying
7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-185


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.T = SINS (DM1000.T, DM1100.T, LEN (DM1000.T) - 10)
Description of Operation The length (number of characters) of the text string currently stored starting from DM1000 is calculated, and
the text string currently stored starting from DM1100 is inserted ten characters in front (LEN (DM1000.T) -10).
The text string resulting from the insertion is appended with the end code NUL (00H) and is stored in DM2000.
bit bit
15 0
ARITHMETIC OPERATION FUNCTIONS

DM1000 A(41H) B(42H)

DM1001 C(43H) D(44H) bit


15
bit
0

DM1002 E(45H) F(46H) DM1100 G(47H) O(30H)

DM1003 G(47H) 1(31H) DM1101 G(47H) O(30H)

DM1004 2(32H) 3(33H) DM1102 T(54H) I(49H)

DM1005 4(34H) 5(35H) DM1103 M(40H) E(45H)

DM1006 6(36H) 7(37H)

DM1007 8(38H) 9(39H)


N

7 Ladder Conversion
DM1008

CR2002
0(30H) U
L (00H)

MOV
#0 @VM0
Text Processing Functions

Always ON
LEN
DM1000 @VM0

Destination string
CR2002 @VM0 +10 @VM2
LDA EXT SUB.L STA.L
Always ON
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM4

CR2002 SINS
DM1000 DM1100 *@VM4
Always ON
@VM2

CR2002 SMOV
*@VM4 DM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function it is combined with.
"SINS function", Page 7-204

7-186 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-187


SRGHT Cut text string on right

Cut text string on right

Return value
*1
= SRGHT (cut destination device, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Cut destination Specifies the device to which the text string to be
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*6 cut is stored, or the cut destination text string.
n Number of cut Specifies the number of characters
*5 .U .U .U .U - - - - *4 ƻ ƻ ƻ
characters (number of bytes) to cut. (0 to 1999)
*2
R Return value *6 .T type SRGHT function available - - - - - - - .T - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) to the number of cut
characters within the range 0 to 1999.
When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.

7 Description of Operation
Text Processing Functions

The text string currently stored starting from S is cut from the right end by n characters
(number of bytes), appended with the end code NUL (00H), and the result is stored in R .

bit bit
15 0

S A(41H) B(42H)

S +1 C(43H) D(44H)

S +2 E(45H) F(46H)

K(4BH) L(4CH) R K(4BH) L(4CH)

M(4DH) N(4EH) R +1 M(4DH) N(4EH)

S(53H) T(54H) S(53H) T(54H)


N N
U(55H) U
L (00H) U(55H) U
L (00H)

Not including NUL(00H) Save NUL (00H) in the


in the end of string. end of string after cutting.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-188 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = SRGHT (DM1000.T, 40)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SRGHT
DM1000 *@VM0 #40
Always ON
Cut destination device
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note
g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S does not contain the end code (NUL(00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When the text string to be stored in R onwards exceeds the device range
g When a device other than the leading device of the channel is specified when a bit 7
device is specified to S and R .

Text Processing Functions


g When a timer/counter is specified to S and R by indirect specifying

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.L = RDASC (SRGHT (DM1000.T, 8))
Description of Operation The final eight characters (lower eight digits) of the DEC ASCII text string currently stored starting from
DM1000 are cut, and converted to signed 32-bit BIN data, and the result is stored in EM2000.L.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SRGHT
DM1000 *@VM0 #8
Always ON
Cut destination device
CR2002 MOV.L
+0 @VM2
Always ON
RDASC.L
*@VM0 @VM2
CR2002 MOV.L
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RDASC function", Page 7-166

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-189


RIGHT Cut text string on right

Cut text string on right

Return value
*1
= RIGHT (cut destination device, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Cut destination Specifies the device to which the text string to be
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*6 cut is stored, or the cut destination text string.
n Number of cut Specifies the number of characters
*5 .U .U .U .U - - - - *4 ƻ ƻ ƻ
characters (number of bytes) to cut. (0~1999)
*2
R Return value *6 .T type RIGHT function available - - - - - - - .T - ƻ -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) to the number of cut
characters within the range 0 to 1999.
When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.

7 Description of Operation
Text Processing Functions

This function differs from the "SRGHT function" in name only, and operation, etc. are the same.
For details on operation, see "SRGHT function", Page 7-188.

7-190 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-191


SLEFT Cut text string on left

Cut text string on left

Return value
*1
= SLEFT (cut destination device, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Cut destination Specifies the device to which the text string to be
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*6 cut is stored, or the cut destination text string.
n Specifies the number of characters
Number of cut *4
ƻ
*5 (number of bytes) to cut. .U .U .U .U - - - - ƻ ƻ
characters
(0 to 1999)
*2
R Return value*6 .T type SLEFT function available - - - - - - - .T - -
ARITHMETIC OPERATION FUNCTIONS

ƻ
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) to the number of cut
characters within the range 0 to 1999.
When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.

7 Description of Operation
Text Processing Functions

The text string currently stored starting from S is cut from the left end (leading end) by n

characters (number of bytes), appended with the end code NUL (00H), and the result is stored in R .
bit bit
15 0

S A(41H) B(42H) R A(41H) B(42H)


S +1 C(43H) D(44H) R +1 C(43H) D(44H)
S +2 E(45H) F(46H) n
N
K(4BH) U
L (00H)

K(4BH) L(4CH)
NUL (00H) shall store to end of string.
M(4DH) N(4EH)

S(53H) T(54H)
N
U(55H) U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-192 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = SLEFT (DM1000.T, 40)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SLEFT
DM1000 *@VM0 #40
Always ON
Cut destination device
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note
g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When the text string to be stored in R onwards exceeds the device range
g When a device other than the leading device of the channel is specified when a bit
device is specified to S and R
7
g When a timer/counter is specified to S and R by indirect specifying

Text Processing Functions


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.D = RHASC (SLEFT (DM1000.T, 4))
Description of Operation The leading four characters (upper four digits) of the HEX ASCII text string currently stored starting
from DM1000.T are cut, and converted to unsigned 16-bit BIN data, and the result is stored in EM2000.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SLEFT
DM1000 *@VM0 #4
Always ON
Cut destination device
CR2002 MOV.D
+0 @VM2
Always ON
RHASC.D
*@VM0 @VM2
CR2002 MOV.D
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RHASC function", Page 7-172

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-193


LEFT Cut text string on left

Cut text string on left

Return value
*1
= LEFT(cut destination device, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Cut destination Specifies the device to which the text string to be
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*6 cut is stored, or the cut destination text string.
n Specifies the number of characters
Number of cut *4
ƻ
*5 (number of bytes) to cut. .U .U .U .U - - - - ƻ ƻ
characters
(0 to 1999)
*2
R Return value*6 .T type LEFT function available - - - - - - - .T - -
ARITHMETIC OPERATION FUNCTIONS

ƻ
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) to the number of cut
characters within the range 0 to 1999.
When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.

7 Description of Operation
Text Processing Functions

This function differs from the "SLEFT function" in name only, and operation, etc. are the same.
For details on operation "SLEFT function", Page 7-192.

7-194 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-195


SMID Cut text string

Cut text string

Return value
*1
= SMID(cut destination device, cut character position, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the text string to
Cut destination *3
ƻ
*2 be cut is stored, or the cut destination text - - - - - - - .T ƻ ƻ
device*6
string.
n1 Specifies the cut leading position (number of
Cut character *4 ƻ
*7 bytes). .U .U .U .U - - - - ƻ ƻ
position
(0 to 1999)
ARITHMETIC OPERATION FUNCTIONS

n2 Specifies the number of characters (number of bytes)


Number of cut *4
ƻ
*5 to cut. .U .U .U .U - - - - ƻ ƻ
characters
(0 to 1999)
*2
R Return value*6 .T type SMID function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the cut characters to the cut characters within
the range 0 to 1999.
7 When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.
Text Processing Functions

*7 The leading character of the text string specified by R is taken to be "0".

Description of Operation

The text string currently stored starting from S is cut from n1 (number of bytes) by n2

characters (number of bytes), appended with the end code NUL (00H), and the result is stored in
R .
Position ˌ

Cut start position n1


bit bit
15 0

S A(41H) B(42H) R C(43H) D(44H)

S +1 C(43H) D(44H) R +1 E(45H) F(46H)

S +2 E(45H) F(46H)
n2 number of
K(4BH) L(4CH)
character N
K(4BH) L(4CH) U
L (00H)

M(4DH) N(4EH) NUL (00H) shall store


to end of string.

S(53H) T(54H)
N
U(55H) U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-196 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = SMID (DM1000.T, 8, 16)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SMID
DM1000 *@VM0 #8
Always ON Cut destination device
#16

CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note
g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When S text string length < n1 . 7
g When the text string to be stored in R onwards exceeds the device range

Text Processing Functions


g When a device other than the leading device of the channel is specified when a bit
device is specified to S and R
g When a timer/counter is specified to S and R by indirect specifying

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.D = RHASC (SMID (DM1000.T, 2, 4))
Description of Operation The four characters (middle four digits) from the 2nd character of the HEX ASCII text string
currently stored starting from DM1000.T are cut, and converted to unsigned 16-bit BIN data,
and the result is stored in EM2000.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON MOV
#0 VM2

MOV.D
VM0 @VM0
CR2002 SMID
DM1000 *@VM0 #2
Always ON Cut destination device
#4
CR2002 MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2
CR2002 MOV.D
@VM2 EM2000
Always ON
Return value
Note that this function sometimes cannot be used depending on the argument of the function it is combined with.
"RHASC function", Page 7-172

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-197


MID Cut text string

Cut text string

Return value
*1
= MID (cut destination device, cut character position, number of cut characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Cut destination Specifies the device to which the text string to be
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*6 cut is stored, or the cut destination text string.
n1 Cut character Specifies the cut leading position (number of bytes).
*7 .U .U .U .U - - - - *4 ƻ ƻ ƻ
position (0 to 1999)
n2 Number of cut
*5 (0 to 1999) .U .U .U .U - - - - *4
ƻ ƻ ƻ
characters
ARITHMETIC OPERATION FUNCTIONS

*2
R Return value *6 .T type MID function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the cut characters to the cut characters within
the range 0 to 1999.
When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z can not be used.
7 *7 The leading character of the text string specified by S is taken to be "0".
Text Processing Functions

Description of Operation

This function differs from the "SMID function" in name only, and operation, etc. are the same.
For details on operation "SMID function", Page 7-196.

7-198 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-199


SRPLC Replace text string section

Replace text string section

Return value
*1
= SRPLC (replace destination device, replace text string device,
replace leading postion, number of replaced characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Replace Specifies the device to which the text string
destination to be replaced is stored, or the replace - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*6 destination text string.
S2 Replace text Specifies the device to which the text string to
*2 - - - - - - - .T *3
ƻ ƻ ƻ
string device*6 replace is stored, or the replace text string.
ARITHMETIC OPERATION FUNCTIONS

n1 Replace Specifies the replace leading position


*7 .U .U .U .U - - - - *4
ƻ ƻ ƻ
leading position (number of bytes).(0 to 1999)
n2 Number of replaced Specifies the number of characters (number
*5 .U .U .U .U - - - - *4 ƻ ƻ ƻ
characters of bytes) to replace. (0 to 1999)
R *2 Stores the value of the function processed
Return value*6 - - - - - - - .T - ƻ -
result.
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.

7 *5 Specify the number of characters (number of bytes) from the replace leading position to the number of
replace characters within the range 0 to 1999.
Text Processing Functions

*6 T, C, CR, CTC, CTH, Z can not be used.


*7 The leading character of the text string specified by S1 is taken to be "0".

Description of Operation

The text string of n2 characters (number of bytes) from n1 (number of bytes) of the text string currently stored starting from
S1 is replaced with the text string currently stored starting from the S2 , appended with the end code NUL (00H), and the result
is stored in R .
Position 0

Replace string of object Replace start position n1


bit bit
15 0

S1 A(41H) B(42H) R A(41H) B(42H)

S1 +1 C(43H) D(44H) R +1 C(43H) D(44H)

S1 +2 E(45H) F(46H) When number of character is 2, R +2 X(58H) Y(59H) E and F are


replaced with
G(47H) H(48H) R +3 Z(5AH) G(47H) X, Y, and Z.
I(49H) J(4AH) R +4 H(48H) I(49H)

n1 = 4ǃ n2 = 2,
S(53H) T(54H) when n2=2, string after T(54H) U(55H)
N replace are as follows. N
U(55H) U
L (00H)
U
L (00H)

NUL (00H) shall add to end of string. NUL (00H) shall store to end of string.

String shall replace

S2 X(58H) Y(59H)
N
S2 +1 Z(5AH) U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text Processing
Instructions".
7-200 - KV-5500/5000/3000/1000 Series Script Programming Manual -
ƽ Example of format
DM2000.T = SRPLC (DM1000.T, DM1200.T, 10, 20)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SRPLC
DM1000 DM1200 *@VM0
Always ON Replace destination device Replace string device
#10 #20
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note
g When either of the following conditions is established, the end code (NUL (00H)) is stored:
gWhen the text string specified by S1 and S2 does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When S text string length < n1 .
g When the length of the text string after the replace exceeds 2000 characters including
7
(NUL (00H))

Text Processing Functions


g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 , S2 , and R
g When a timer/counter is specified to S1 , S2 and R by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-201


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.L = RDASC (SRPLC (DM1000.T, EM1000.T, 0, 4))
Description of Operation The text string four characters long (number of bytes) from the start of the decimal ASCII text
string currently stored from the start of DM1000.T is replaced with the decimal ASCII text
string currently stored starting from EM1000.T.
The decimal ASCII text string resulting from the replace is converted to signed 32-bit BIN
ARITHMETIC OPERATION FUNCTIONS

data, and the result is stored in EM2000.L.


Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SRPLC
DM1000 EM1000 *@VM0
7 Always ON Replace
destination device
Replace
string device
#0 #4
Text Processing Functions

CR2002 MOV.L
+0 @VM2
Always ON
RDASC.L
*@VM0 @VM2

CR2002 MOV.L
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RDASC function", Page 7-166

HINT

Operation of the SRPLC function changes as follows according to the content specified to the argument:

Example 1)Operation is the same as the SINS function when "0" is specified to the number of replace characters.
The replace text string is inserted (no replace destination range) to the 4th character of the replace
destination text string.
Programmed Script DM2000.T = SRPLC (DM1000.T, DM1200.T, 4, 0)

Example2)Operation is the same as the SDEL function when an empty text string (NUL only) is specified to
the replace text string.
The four characters from the 2nd character of the replace destination text string are deleted (no replace text string).
Programmed Script DM2000.T = SRPLC (DM1000.T, "", 2, 4)

7-202 - KV-5500/5000/3000/1000 Series Script Programming Manual -


REPLACE Replace text string section

Replace text string section

Return value
*1
= REPLACE(replace destination device, replace text string device, replace
leading position, number of replaced characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Replace Specifies the device to which the text
destination string to be replaced is stored, or the - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*6 replace destination text string.
S2 Specifies the device to which the text
Replace text string *3 ƻ
*2 string to replace is stored, or the replace - - - - - - - .T ƻ ƻ
device

ARITHMETIC OPERATION FUNCTIONS


*6
text string.
n1 Number of
Specifies the number of characters *4
ƻ
replaced .U .U .U .U - - - - ƻ ƻ
*5 (number of bytes) to replace. (0 to 1999)
characters
n2 Replace Specifies the replace leading position (number
*7 .U .U .U .U - - - - *4
ƻ ƻ ƻ
leading position of bytes).(0 to 1999)
R *2 Stores the value of the function processed
Return value*6 - - - - - - - .T - ƻ -
result.
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
7
*5 Specify the number of characters (number of bytes) from the replace leading position to the number of

Text Processing Functions


replace characters within the range 0 to 1999.
*6 T, C, CR, CTC, CTH, Z can not be used.
*7 The leading character of the text string specified by S1 is taken to be "0".

Description of Operation

This function differs from the "SRPLC function" in name only, and operation, etc. are the same.
For details on operation "SRPLC function", Page 7-200.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-203


SINS Insert text string

Insert text string

Return value
*1
= SINS(insert destination device, insert text string device, insert leading position)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Specifies the device to which the text string to be
Insert destination *3
ƻ
*2 inserted is stored, or the insert destination text - - - - - - - .T ƻ ƻ
device *6
string.
S2 Insert text
Specifies the device to which the text string *3 ƻ
string - - - - - - - .T ƻ ƻ
*2 to insert is stored, or the insert text string.
device*6
ARITHMETIC OPERATION FUNCTIONS

̊ Insert leading Specifies the insert leading position (number *4 ƻ


*7 .U .U .U .U - - - - ƻ ƻ
position of bytes). (0 to 1999)
*4
R Return value *6 .T type SINS function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the insert leading position to the number of
insert characters within the range 0 to 1999.

7 *6
*7
T, C, CR, CTC, CTH, Z can not be used.
The leading character of the text string specified by S1 is taken to be "0".
Text Processing Functions

Description of Operation

The text string currently stored starting from S1 is inserted to n (number of bytes) of the text
string currently stored starting from S2 , appended with the end code NUL (00H), and the result is
stored in R .
Position ˌ

Insert string of object Insert start position n


bit bit
15 0

S1 A(41H) B(42H) R A(41H) B(42H)

S1 +1 C(43H) D(44H) R +1 C(43H) D(44H)

S1 +2 E(45H) F(46H) R +2 E(45H) F(46H)

S1 +3 K(4BH) L(4CH) R +3 G(47H) H(48H)

S1 +4 M(4DH) N(4EH) R +4 I (49H) J(4AH)


n when n=6, string after
R +5 K(4BH) L(4CH)
insert are as follows.
S(53H) T(54H) R +6 M(4DH) N(4EH)
N
U(55H) U
L (00H)

S(53H) T(54H)
NUL (00H) shall add to end of string.
N
U(55H) U
L (00H)

Character string shall insert NUL (00H) shall add to end of string.

S2 G(47H) H(48H)

S2 +1 I (49H) J(4AH)
N
S2 +1 U
L (00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-204 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = SINS (DM1000.T, DM1200.T, 10)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SINS
DM1000 DM1200 *@VM0
Always ON Insert Insert string device
destination device
#10

CR2002 SMOV
*@VM0 DM2000
Always ON
Storage device

Note g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S1 and S2 does not contain the end code (NUL
7

Text Processing Functions


(00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When S text string length < n .
g When the length of the text string after the insert exceeds 2000 characters including
(NUL (00H))
g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 , S2 , and R
g When a timer/counter is specified to S1 , S2 and R by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-205


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.D = RHASC (SINS (DM1000.T, EM1000.T, 2))
Description of Operation The HEX ASCII text string currently stored starting from EM1000.Tis inserted at the 2nd character
(number of bytes) from the start of the HEX ASCII text string currently stored in DM1000.T.
The HEX ASCII text string resulting from the insert is converted to unsigned 32-bit BIN data,
and the result is stored in EM2000.D.
ARITHMETIC OPERATION FUNCTIONS

Ladder Conversion CR2002 ADRSET


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SINS
DM1000 EM1000 *@VM0
Always ON Insert
7 destination device
Insert string device

#2
Text Processing Functions

CR2002 MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2

CR2002 MOV.D
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RDASC function", Page 7-166

7-206 - KV-5500/5000/3000/1000 Series Script Programming Manual -


INSERT Insert text string
Insert text string

Return value = INSERT (insert destination device, insert text string device, insert
*1

leading position)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Insert Specifies the device to which the text string
destination to be inserted is stored, or the insert - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*6 destination text string.
S2 Insert text
Specifies the device to which the text string *3 ƻ
string - - - - - - - .T ƻ ƻ
to insert is stored, or the insert text string.

ARITHMETIC OPERATION FUNCTIONS


*2
device*6
̊ Insert leading Specifies the insert leading position *4 ƻ
*7 .U .U .U .U - - - - ƻ ƻ
position (number of bytes). (0 to 1999)
*2
R Return value *6 .T type INSERT function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) to the number of cut
characters within the range 0 to 1999.
*6 T, C, CR, CTC, CTH, Z can not be used. 7
*7 The leading character of the text string specified by S1 is taken to be "0".

Text Processing Functions


Description of Operation

This function differs from the "SINS function" in name only, and operation, etc. are the same.
For details on operation "SINS function", Page 7-204.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-207


SDEL Delete text string section

Delete text string section

Return value
*1
= SDEL (deletedestination device, delete leading position, number
of delete characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Delete Specifies the device to which the text string
destination to be deleted is stored, or the delete - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*7 destination text string.
n1 Delete leading Specifies the delete leading position
*4 .U .U .U .U - - - - ƻ ƻ ƻ
position*5 (number of bytes). (0 to 1999)
ARITHMETIC OPERATION FUNCTIONS

n2 Number of
Specifies the number of characters (number
delete .U .U .U .U - - - - ƻ ƻ ƻ
*4 of bytes) to delete. (0 to 1999)
characters*6
*2
R Return value*7 .T type SDEL function available - - - - - - - .T ƻ ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) as the position to
delete to the delete leading position within the range 0 to 1999.
7 *6 Specify the number of characters (number of bytes) from the delete leading position to the number of
deleted characters within the range 0 to 1999.
Text Processing Functions

*7 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

The text string of n2 characters (number of bytes) is deleted from the n1 position (number of
bytes) of the text string currently stored starting from S , appended with the end code NUL (00H),
and the result is stored in R .
Position ˌ n1 =2ǃ n2 =2
Delete start position n2
bit bit
15 0

S A(41H) B(42H) R A(41H) B(42H)

S +1 C(43H) D(44H) n1 number of character R +1 E(45H) F(46H)

S +2 E(45H) F(46H) R +2

K(4BH) L(4CH)

K(4BH) L(4CH)

S(53H) T(54H)
N
S(53H) T(54H) U(55H) U
L (00H)

N
U(55H) U
L (00H) NUL (00H) shall store
to end of string.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-208 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = SDEL (DM1000.T, 10, 20)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SDEL
DM1000 *@VM0 #10
Always ON
Delete destination device

#20

CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S does not contain the end code (NUL (00H))
7
g When the text string including the end code (NUL (00H)) exceeds 2000 characters

Text Processing Functions


g When S text string length < n1 .
g When the text string to be stored in R onwards exceeds the device range
g When a device other than the leading device of the channel is specified when a bit
device is specified to S and R
g When a timer/counter is specified to S and R by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-209


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.D = RHASC (SDEL (DM1000.T, 2, 4))
Description of Operation A text string of four characters (number of bytes) is deleted from the 2nd character (number
of bytes) of the HEX ASCII text string currently stored starting from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2000.D.
ARITHMETIC OPERATION FUNCTIONS

Ladder Conversion CR2002 ADRSET


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SDEL
DM1000 *@VM0 #2
Always ON Delete
7 destination device
#4
Text Processing Functions

CR2002 MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2

CR2002 MOV.D
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RHASC function", Page 7-172

7-210 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-211


DELETE Delete text string section

Delete text string section

Return value
*1
= DELETE (delete destination device, delete leading position,
number of delete characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Delete Specifies the device to which the text string
destination to be deleted is stored, or the delete - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*7 destination text string.
n1 Number of
Specifies the number of characters (number
delete .U .U .U .U - - - - ƻ ƻ ƻ
of bytes) to delete. (0 to 1999)
ARITHMETIC OPERATION FUNCTIONS

*4
characters*6
n2 Delete leading Specifies the delete leading position
*4 .U .U .U .U - - - - ƻ ƻ ƻ
position*5 (number of bytes). (0 to 1999)
*2
R Return value *7 .T type DELETE function available - - - - - - - .T ƻ ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (leading end) as the position to
delete to the delete leading position within the range 0 to 1999.
7 *6 Specify the number of characters (number of bytes) from the delete leading position to the number of
deleted characters within the range 0 to 1999.
Text Processing Functions

*7 T, C, CTC, CTH, Z can not be used.

Description of Operation

The text string of n1 characters (number of bytes) is deleted from the n2 positon (number of
bytes) of the text string currently stored starting from S , appended with the end code NUL (00H),
and the result is stored in R .
Position ˌ n1 =2ǃ n2 =2
Delete start position n2
bit bit
15 0

S A(41H) B(42H) R A(41H) B(42H)

S +1 C(43H) D(44H) n1 number of character R +1 E(45H) F(46H)

S +2 E(45H) F(46H) R +2

K(4BH) L(4CH)

K(4BH) L(4CH)

S(53H) T(54H)
N
S(53H) T(54H) U(55H) U
L (00H)

N
U(55H) U
L (00H) NUL (00H) shall store
to end of string.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-212 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = DELETE (DM1000.T, 20, 10)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 SDEL
DM1000 *@VM0 #10
Always ON Delete
destination device
#20

CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Note g When either of the following conditions is established, the end code (NUL (00H)) is stored:
g When the text string specified by S does not contain the end code (NUL (00H))
7
g When the text string including the end code (NUL (00H)) exceeds 2000 characters

Text Processing Functions


g When S text string length < n2 .
g When the text string to be stored in R onwards exceeds the device range
g When a device other than the leading device of the channel is specified when a bit
device is specified to S and R
g When a timer/counter is specified to S and R by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-213


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2000.D = RHASC (DELETE (DM1000.T, 4, 2))
Description of Operation A text string of four characters (number of bytes) is deleted from the 2nd character (number
of bytes) of the HEX ASCII text string currently stored starting from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2000.D.
ARITHMETIC OPERATION FUNCTIONS

Ladder Conversion
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SDEL
DM1000 *@VM0 #2
Always ON
7 Delete
destination device
#4
Text Processing Functions

CR2002 MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2

CR2002 MOV.D
@VM2 EM2000
Always ON
Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RHASC function", Page 7-172

7-214 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-215


TRIM Trim 1-byte space and tab at ends of text string

Trim

Return value
*1
= TRIM (Target text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies device storing text string to be
Target text *3
ƻ
*2 trimmed, or specifies the trim target text - - - - - - - .T ƻ ƻ
string device
string.
*2
R Return value*4 Stores the trimmed text string. - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
ARITHMETIC OPERATION FUNCTIONS

*2 For bit devices, specify the leading device of the channel.


*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z can not be used.

Note
g The TRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation
7
Removes all 1-byte spaces (20H) and tabs (09H) at both ends (leading and end) of a text string stored
Text Processing Functions

starting from the device specified with S target text string device. An end code NUL(00H) is added,
and the results are stored in R return value.

S HT(09H) SP(20H) R K(4BH) e(65H)


S +1 SP(20H) K(4BH) R +1 y(79H) e(65H)
S +2 e(65H) y(79H) R +2 n(6EH) c(63H)
S +3 e(65H) n(6EH) R +3 e(65H) NUL(00H)
c(63H) e(65H)
SP(20H) SP(20H)
HT(09H) NUL(00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-216 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = TRIM (DM1000.T)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 MOV

ARITHMETIC OPERATION FUNCTIONS


#0 @VM0
Always ON @VM0
BSET
#0
@VM0
BSET
#1
CR2002 STRIM
DM1000 @VM0 *@VM2
Always ON Target text
CR2002 string device SMOV
*@VM2 DM2000
Always ON
Return value 7

Text Processing Functions


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script EM2500.D = RHASC (TRIM (DM1000.T))
Description of Operation The 1-byte spaces and tabs are removed from both ends (leading and end) of a hexadecimal
ASCII text string stored starting from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2500.D.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#0
@VM0
BSET
#1
CR2002 STRIM
DM1000 @VM0 *@VM2
Always ON Target text
string device
CR2002 MOV.D
#0 @VM4
Always ON
RHASC.D
*@VM2 @VM4

CR2002 MOV.D
@VM4 EM2500
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-217


LTRIM Trim 1-byte space and tab at left end of text string

Left trim

Return value
*1
= LTRIM (Target text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies device storing text string to be
Target text *3
ƻ
*2 trimmed, or specifies the trim target text - - - - - - - .T ƻ ƻ
string device
string.
*2
R Return value*4 Stores the trimmed text string. - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
ARITHMETIC OPERATION FUNCTIONS

*2 For bit devices, specify the leading device of the channel.


*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z can not be used.

Note
g The LTRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7 Description of Operation
Text Processing Functions

Removes all 1-byte spaces (20H) and tabs (09H) at the left end (leading) of a text string stored starting
from the device specified with S target text string device. An end code NUL(00H) is added, and the
results are stored in R return value.

S HT(09H) SP(20H) R K(4BH) e(65H)


S +1 SP(20H) K(4BH) R +1 y(79H) e(65H)
S +2 e(65H) y(79H) R +2 n(6EH) c(63H)
S +3 e(65H) n(6EH) R +3 e(65H) SP(20H)
c(63H) e(65H) R +4 SP(20H) HT(09H)
SP(20H) SP(20H) R +5 NUL(00H)
HT(09H) NUL(00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-218 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = LTRIM (DM1000.T)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

ARITHMETIC OPERATION FUNCTIONS


CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#0
CR2002 STRIM
DM1000 VM0 *@VM2
Always ON Target text
string device
CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

Sample Program 7

Text Processing Functions


ƽ When this function is used in combination with other functions
Programmed Script EM2500.D = RHASC (LTRIM (DM1000.T))
Description of Operation The 1-byte spaces and tabs are removed from the left end (leading) of a hexadecimal ASCII
text string stored from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2500.D.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#0
CR2002 STRIM
DM1000 @VM0 *@VM2
Always ON
Target text
string device MOV.D
CR2002
#0 @VM4
Always ON
RHASC.D
*@VM2 @VM4

CR2002 MOV.D
@VM4 EM2500
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-219


RTRIM Trim 1-byte space and tab at right end of text string

Right trim

Return value
*1
= RTRIM (Target text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies device storing text string to be
Target text *3
ƻ
*2 trimmed, or specifies the trim target text - - - - - - - .T ƻ ƻ
string device
string.
*2
R Return value*4 Stores the trimmed text string. - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
ARITHMETIC OPERATION FUNCTIONS

*2 For bit devices, specify the leading device of the channel.


*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z can not be used.

Note
g The RTRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7 Description of Operation
Text Processing Functions

Removes all 1-byte spaces (20H) and tabs (09H) at the right end (leading) of a text string stored
starting from the device specified with S target text string device. An end code NUL(00H) is added,
and the results are stored in R return value.

S HT(09H) SP(20H) R HT(09H) SP(20H)


S +1 SP(20H) K(4BH) R +1 SP(20H) K(4BH)
S +2 e(65H) y(79H) R +2 e(65H) y(79H)
S +3 e(65H) n(6EH) R +3 e(65H) n(65H)
c(63H) e(65H) R +4 c(63H) e(65H)
SP(20H) SP(20H) R +5 NUL(00H)
HT(09H) NUL(00H)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-220 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = RTRIM (DM1000.T)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

ARITHMETIC OPERATION FUNCTIONS


CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#1
CR2002 STRIM
DM1000 @VM0 *@VM2
Always ON Target text
string device
CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

Sample Program 7

Text Processing Functions


ƽ When this function is used in combination with other functions
Programmed Script EM2500.D = RHASC (RTRIM (DM1000.T))
Description of Operation The 1-byte spaces and tabs are removed from the right end (leading) of a hexadecimal
ASCII text string stored from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2500.D.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#1
CR2002 STRIM
DM1000 @VM0 *@VM2
Always ON
Target text
string device MOV.D
CR2002
#0 @VM4
Always ON
RHASC.D
*@VM2 @VM4

CR2002 MOV.D
@VM4 EM2500
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-221


STRIM Trim 1-byte space and tab from specified text string position

Specified position trim

Return value
*1
= STRIM (Target text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Specifies device storing text string to be
Target text *3
ƻ
*2 trimmed, or specifies the trim target text - - - - - - - .T ƻ ƻ
string device
string.
S2 Delete position
Specifies the position to be trimmed ƻ
specifying .U .U .U .U - - - - ƻ ƻ
(1 to 3).
parameter
ARITHMETIC OPERATION FUNCTIONS

*2
R Return value*4 Stores the trimmed text string. - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z can not be used.

Note
g The STRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
7
Text Processing Functions

Description of Operation

Removes all 1-byte spaces and tabs at the position specified with S2 delete position specifying
parameter from the text string stored startting from the device specified with S1 target text string
device. An end code NUL(00H) is added, and the results are stored in R return value.
The details specified with the delete position specifying parameter are given below.
S2 value Details
All 1-byte spaces and tabs at the left end of the text string are deleted.
1
(Same action as LTRIM function)
All 1-byte spaces and tabs at the right end of the text string are deleted.
2
(Same action as RTRIM function)
All 1-byte spaces and tabs at both ends of the text string are deleted.
3
(Same action as TRIM function)

Note
If a parameter other than the above is specified, S1 is stored in R without executing
the function.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-222 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = STRIM (DM1000.T, 3)
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 STRIM
DM1000 #3 *@VM0
Always ON Target text
string device
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Sample Program

ƽ When this function is used in combination with other functions 7


Programmed Script EM2500.D = RHASC (STRIM (DM1000.T, 3))

Text Processing Functions


Description of Operation The 1-byte spaces and tabs are removed from both ends (leading and end) of a hexadecimal
ASCII text string stored starting from DM1000.T.
The HEX ASCII text string resulting from the delete is converted to unsigned 16-bit BIN data,
and the result is stored in EM2500.D.
Ladder Conversion CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 STRIM
DM1000 #3 *@VM0
Always ON Target text
string device
CR2002 MOV.D
#0 @VM2
Always ON
RHASC.D
*@VM0 @VM2
CR2002 MOV.D
@VM2 EM2500
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-223


SPLIT Split text string

Split

Return value
*1
= SPLIT (split source text string, limit text string, split text string 1,
split text string 2, ..., split text string n)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Specifies the device storing the split source
Split source *3
ƻ
*2 text string, or specifies the split target text - - - - - - - .T ƻ ƻ
text string
string.
S2 Limit text Specifies the device storing the limit text
*2 - - - - - - - .T *3
ƻ ƻ ƻ
string string, or specifies the limit target text string.
ARITHMETIC OPERATION FUNCTIONS

D1 Split text string Specifies the device storing the split text
*2 - - - - - - - .T - ƻ -
1 string 1.
D2 Split text string Specifies the device storing the split text
*2 - - - - - - - .T - ƻ -
2 string 2.
 - - - - - - - .T - -

ƻ
Dn Split text string Specifies the device storing the split text
*2 - - - - - - - .T - ƻ -
n*4 string n.
R *2 Stores the number of divisions. The
Return value*5 *6 .U .S .D .L .F .DF - - - ƻ -
SPLIT function uses the .U type.
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
7 *3 To specify a text string using constants, enclose with " ".
*4 Specify the argument number n in the range of 1 to 10.
Text Processing Functions

*5 T, C, CTC, CTH, Z can not be used.


*6 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.

Note
g The SPLIT function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The S1 split source text string is split with the S2 limit text string, and the results are stored in the
D1 to Dn split text strings.
The number of text string divisions is stored in R return value.

When S1 : "18,1A,35,E0,C3,EB", S2 : "," (comma)

S 1(31H) 8(38H) D1 1(31H) 8(38H)


S +1 ,(2CH) 1(31H) D2 1(31H) A(41H)
S +2 A(41H) ,(2CH) D3 3(33H) 5(35H)
S +3 3(33H) 5(35H) D4 E(45H) 0(30H)
,(2CH) E(45H) D5 C(43H) 3(33H)
0(30H) ,(2CH) D6 E(45H) B(42H)
C(43H) 3(33H)
,(2CH) E(45H)
"6" is stored in R .
B(42H) NUL(00H)

7-224 - KV-5500/5000/3000/1000 Series Script Programming Manual -


gThis function is not executed when R number of divisions = 0.
gWhen 0< R number of divisions<n, only the end code (NUL) is stored for the excessive
argument.
gWhen R number of divisions = n, Dn may contain a limit character (divisions may
still be possible). If only judging whether splitting is possible, the number of limit characters
in Dn can be checked with the SFIND function.
If there is a possibility of splitting, the text string can be split by specifying Dn in S1

and executing the SPLIT function.

ARITHMETIC OPERATION FUNCTIONS


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.

ƽ Example of format
DM5000.U = SPLIT (DM2000.T, ",", EM3000.T, EM3100.T, EM3200.T)
Sample Program

Programmed Script DM2000.T = "Date, data, record"


DM5000.U = SPLIT (DM2000.T, ",", EM3000.T, EM3100.T, EM3200.T)
Description of Operation The text string "date, data, record" stored in DM2000.T is split by "," (comma) and stored in
EM3000.T, EM3100.T, and EM3200.T. 7
Ladder Conversion
SMOV

Text Processing Functions


CR2002
“Date... DM2000
Always ON
Text string device
before splitting
CR2002 ADRSET
VM2 VM0

Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

SMOV
“,” *@VM0

CR2002 LEN
DM2000 @VM2
Always ON Text string device
before splitting
LEN
*@VM0 @VM3

#0 #0 #0 #0
DW DW DW DW
@VM4 @VM5 @VM6 @VM7
CR2002 #0 #0 #0
DW DW DW
Always ON EM3000 EM3100 EM3200
Split text Split text Split text
string device 1 string device 2 string device 3
FOR
#3

CR2002 @VM7
INC
Always ON
@VM4 SMOV
BREAK
>= #3
@VM2
@VM7 MOV
>= #65535 @VM5
#3
CJ
#2000

CR2002 @VM4 @VM3 @VM2


LDA ADD CMP
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-225


CR2011 MOV
#65535 @VM5
Operation results
are positive
CR2002 SFIND
DM2000 *@VM0 @VM5
Operation results Text string device
are negative before splitting
CR2010
@VM4

Operation results
are zero
CR2012 MOV
#0 @VM7
Operation
ARITHMETIC OPERATION FUNCTIONS

execution error BREAK

LABEL
#2000

@VM5
= - @VM2 @VM4 @VM6
#65535
MOV
@VM5
= #0 @VM6
#0
@VM5
> - @VM5 @VM4 @VM6
#0
MOV
@VM6 @VM7 @VM6

7 >
#0
=
#1
>
#1999
#1999 @VM6

SMID
Text Processing Functions

DM2000 EM3000 @VM4


Text string device Split text
before splitting string device 1

@VM6

@VM7 @VM6 MOV


= > #1999 @VM6
#2 #1999
SMID
DM2000 EM3100 @VM4
Text string device Split text
before splitting string device 2

@VM6

@VM7 @VM6 MOV


= > #1999 @VM6
#3 #1999
SMID
DM2000 EM3200 @VM4
Text string device Split text
before splitting string device 3

@VM6

CR2012 MOV
#0 @VM7
Operation
execution error BREAK

@VM5 BREAK
=
#65535
CR2002
+ @VM5 @VM3 @VM4
Always ON
NEXT

CR2002 MOV
@VM7 DM5000
Always ON
Return value

7-226 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-227


SFIND Search text string

Search text string

Return value
*1
= SFIND(search destination device, search text string device, search
leading position)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Search Specifies the device to which the text string
destination to be searched is stored, or the search - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*6 destination text string.
S2 Search text
Specifies the device to which the text string *3 ƻ
string - - - - - - - .T ƻ ƻ
to search is stored, or the search text string.
ARITHMETIC OPERATION FUNCTIONS

*2
device*6
n Search leading Specifies the search leading position
*4 .U .U .U .U - - - - *4
ƻ ƻ ƻ
position*5 (number of bytes).(0 to 1999)
*8
*7
R Return value .U type SFIND function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the search leading position to the number of

7 *6
search characters within the range 0 to 1999.
T, C, CTC, CTH, Z can not be used.
*7 When the type other than .U is specified by return value, type conversion will be automatically conducted
Text Processing Functions

during conversion.
*8 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7-228 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Description of Operation

When the execution condition is established (TRUE), the search text string currently stored in S2 is
searched from the n position (number of bytes) of the search destination text string currently
stored starting from S1 .
The leading character position (number of bytes starting from S1 ) of the search text string that was
first found from n onwards as a result of the search is stored in R .
Position ˌ
Destination text string

ARITHMETIC OPERATION FUNCTIONS


Position n
to be searched
String shall search

S1 A(41H) B(42H) S2 C(43H) D(44H)


N
S1 +1 C(43H) D(44H) Ignore S2 +1 E(45H) U
L (00H)

S1 +2 E(45H) F(46H) NUL (00H) shall add to end of string.


S1 +3 G(47H) H(48H)

S1 +4 C(43H) D(44H)
When n =6, position for detected string CDE after 6 is 8.
S1 +5 E(45H) F(46H)

R 8

S(53H)
N
T(54H) Search range 7
U(55H) U
L (00H)

Text Processing Functions


NUL (00H) shall add to end of string.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.U = SFIND (DM1000.T, DM1200.T, 8)
CR2002 MOV
#0 @VM0
Always ON
SFIND
DM1000 DM1200 @VM0
Search destination device Search string device
#8

CR2002 MOV
@VM0 DM2000
Always ON
Search result

Note When either of the following conditions is established, 0 is stored in R :


gWhen the text string specified by S1 and S2 does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When (length of text string) < (length of n + S2 text string) (Length of text
strings do not include end code “NUL (00H)".)
g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 and S2
g When a timer/counter is specified to S1 and S2 by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-229


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = SFIND (DM1000.T, SMID (DM1200.T, 4, 6), 0)
Description of Operation The text string currently stored starting from DM1000.T is searched from the start of the search
destination text string currently stored starting from DM1200.T, and the text string resulting from
having cut six characters (number of bytes) from the 4th character (number of bytes) is searched.
The leading character position of the search text string that was first found from the start of
the search destination text string as a result of the search is stored in DM2000.U.
ARITHMETIC OPERATION FUNCTIONS

Ladder Conversion CR2002 ADRSET


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SMID
DM1200 *@VM0 #4
Always ON
#6
7 CR2002 MOV
#0 @VM2
Text Processing Functions

Always ON
SFIND
DM1000 *@VM0 @VM2

#0

CR2002 MOV
@VM2 DM2000
Always ON

Note that this function sometimes cannot be used depending on the argument of the function it is combined with.
"SMID function", Page 7-196

7-230 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-231


SFINDN Search text string

Search text string N

Return value
*1
= SFINDN (search destination device, search text string device,
number of search target bytes, search leading position)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Search Specifies the device to which the text string
destination to be searched is stored, or the search - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*4 destination text string.
S2 Search text
Specifies the device to which the text string *3 ƻ
string - - - - - - - .T ƻ ƻ
to search is stored, or the search text string.
ARITHMETIC OPERATION FUNCTIONS

*2
device*4
S3 Number of
Specifies the length (number of bytes) of the ƻ
search target .U .U .U .U - - - - ƻ ƻ
text string to be searched.
bytes
S4 Search leading Specifies the search leading position
.U .U .U .U - - - - ƻ ƻ ƻ
position (number of bytes).
*6
*5
R Return value .U type SFINDN function available .U .S .D .L .F .DF - .T - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
7 *4 T, C, CTC, CTH, Z can not be used.
*5 When the type other than .U is specified by return value, type conversion will be automatically conducted
Text Processing Functions

during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

Note
g The SFINDN function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7-232 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Description of Operation

When the execution conditions are established (TRUE), the text string stored starting from the device
specified with S2 search text string is searched from the S4 search start byte position of the text
string having the number of search target bytes. The search leads with the device specified in S1
search target device.
The start position (number of bytes) of the text string specified with S2 found first after the specified
position in the text string specified with the S3 number of search target bytes is stored in R
return value.

ARITHMETIC OPERATION FUNCTIONS


If the text string specified with S2 is not found, or if the text string length of S2 is 0, "$FFFF" is
stored in R .
Position : 0
Position : S3 +1
String shall search
S1 A(41H) B(42H) S2 K(4BH) e(65H)
Ignore
S1 +1 NUL(00H) K(4BH) S2 +1 y(79H) NUL(00H)
S1 +2 e(65H) y(79H)
NUL (00H) shall add to end of string.
S1 +3 a(61H) b(62H)
S1 +4 c(63H) 1(31H)
S1 +5 K(4BH) e(65H)
Search target text string
7
S1 +6 y(79H) NUL(00H) Search range

Text Processing Functions


S1 +7 d(64H) Z(60H)
S1 +8 2(32H) K(4BH) When S3 =18 and S4 =4, the position where the text
e(65H) y(79H) string "Key" is detected after position 4 is 10.

NUL(00H) 3(33H)
A(41H) b(62H) R 10
c(63H) N(4EH)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DM2000.U = SFINDN ( EM1000.T, EM3000.T, 50, 4)
CR2002 MOV
#50 @VM0
Always ON
MOV
#4 @VM1

CR2002 SFINDN
EM1000 EM3000 @VM0 @VM2
Always ON
Search destination Search string
device device
CR2002 MOV
@VM2 DM2000
Always ON
Search result

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-233


Sample Program

Programmed Script EM1000.T = "abcdefghijklmnabcdefghijklmn"


EM3000.T = "abc"
DM2000.U = SFINDN (EM1000.T, EM3000.T, 50, 4)
Description of Operation The EM3000.T text string (abc) is searched for from the 50 characters in the text string
stored in EM1000.T. The search starts from the fourth character of EM1000.T.
Ladder Conversion CR2002 SMOV
“abcdef... EM1000
ARITHMETIC OPERATION FUNCTIONS

Always ON Search destination


device
CR2002 SMOV
“abc” EM3000
Always ON
Split text
string device 1
CR2002 MOV
#50 @VM0
Always ON
MOV
#4 @VM1

CR2002 SFINDN

7 Always ON
EM1000 EM3000

Search destination Split text


@VM0 @VM2

device string device 1


Text Processing Functions

CR2002 MOV
@VM2 DM2000
Always ON Text string device
before splitting

7-234 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-235


INSTR Search text string

Search text string

Return value
*1
= INSTR (search leading position, search destination device, search
text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
n Search leading Specifies the search leading position
*5 .U .U .U .U - - - - *4
ƻ ƻ ƻ
position (number of bytes). (0 to 1999)
S1 Search Specifies the device to which the text string
destination to be searched is stored, or the search - - - - - - - .T *3 ƻ ƻ ƻ
*2
device*6 destination text string.
ARITHMETIC OPERATION FUNCTIONS

S2 Search text
Specifies the device to which the text string *3
ƻ
string - - - - - - - .T ƻ ƻ
*2 to search is stored, or the search text string.
device*6
*8
*7
R Return value .U type INSTR function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 "$" cannot be used.
*5 Specify the number of characters (number of bytes) from the search leading position to the number of

7 *6
search characters within the range 0 to 1999.
T, C, CTC, CTH, Z can not be used.
*7 When the type other than .U is specified by return value, type conversion will be automatically conducted
Text Processing Functions

during conversion.
*8 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

7-236 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Description of Operation

When the execution condition is established (TRUE), the search text string currently stored in S1 is
searched from the n position (number of bytes) of the search destination text string currently
stored starting from S2 .
The leading character position (number of bytes starting from S1 ) of the search text string that was
first found from n onwards as a result of the search is stored in R .
Position ˌ

ARITHMETIC OPERATION FUNCTIONS


Destination text string Position n
to be searched
Character string shall search

S1 A(41H) B(42H) S2 C(43H) D(44H)


N
S1 +1 C(43H) D(44H) Ignore S2 +1 E(45H) U
L (00H)

S1 +2 E(45H) F(46H) String must be ended with NUL(00H).


S1 +3 G(47H) H(48H)

S1 +4 C(43H) D(44H)
When n =6, position for detected string CDE after 6 is 8.
S1 +5 E(45H) F(46H)

R 8

S(53H) T(54H)
Search range
7
N
U(55H) U (00H)

Text Processing Functions


L

String must be ended with NUL(00H).

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text Processing
Instructions".

ƽ Example of format
DM2000.U = INSTR (8, DM1000.T, DM1200.T)
CR2002 MOV
#0 @VM0
Always ON
SFIND
DM1000 DM1200 @VM0
Search destination device Search string device
#8

CR2002 MOV
@VM0 DM2000
Always ON
Search result

Note When either of the following conditions is established, 0 is stored in R :


gWhen the text string specified by S1 and S2 does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When (length of text string) < (length of n + S2 text string) (Length of text
strings do not include end code “NUL (00H)".)
g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 and S2
g When a timer/counter is specified to S1 and S2 by indirect specifying

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-237


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = INSTR (0, DM1000.T, SMID (DM1200.T, 4, 6))
Description of Operation The text string currently stored starting from DM1000.T is searched from the start of the search
destination text string currently stored starting from DM1200.T, and the text string resulting from
having cut six characters (number of bytes) from the 4th character (number of bytes) is searched.
The leading character position of the search text string that was first found from the start of
the search destination text string as a result of the search is stored in DM2000.
ARITHMETIC OPERATION FUNCTIONS

Ladder Conversion CR2002 ADRSET


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SMID
DM1200 *@VM0 #4
Always ON
#6
7 CR2002 MOV
#0 @VM2
Text Processing Functions

Always ON
SFIND
DM1000 *@VM0 @VM2

#0

CR2002 MOV
@VM2 DM2000
Always ON

Note that this function sometimes cannot be used depending on the argument of the function it is combined with.
"SMID function", Page 7-196

7-238 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-239


FIND Search text string

Search text string

Return value
*1
= FIND(search destination device, search text string device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Specifies the device to which the text string to be
Search *3
ƻ
*2 searched is stored, or the search destination text - - - - - - - .T ƻ ƻ
destination device*4
string.
S2 Search text string Specifies the device to which the text string
*2 - - - - - - - .T *3
ƻ ƻ ƻ
device*4 to search is stored, or the search text string.
*6
ARITHMETIC OPERATION FUNCTIONS

*5
R Return value .U type FIND function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " " (up to 31 1-byte characters).
*4 T, C, CTC, CTH, Z can not be used.
*5 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
7 versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
Text Processing Functions

CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation
When the execution condition is established (TRUE), the search text string currently stored starting from S2 is
searched from the search destination text string currently stored starting from S1 .
The leading character position (number of bytes) from S1 of the search text string that was first found as a result of
the search is stored in R .
Position 0
Destination text string
to be searched
Text string to be searched

S1 A(41H) B(42H) S2 C(43H) D(44H)


N
S1 +1 C(43H) D(44H) S2 +1 E(45H) U
L (00H)

S1 +2 E(45H) F(46H) String must be ended with NUL(00H).


S1 +3 G(47H) H(48H)

S1 +4 C(43H) D(44H)

S1 +5 E(45H) F(46H)

R 8

S(53H) T(54H)
Search range
N
U(55H) U
L (00H)

String must be ended with NUL(00H).


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-240 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000 = FIND (DM1000.T, DM1200.T)
CR2002 MOV
#0 @VM0
Always ON
SFIND
DM1000 DM1200 @VM0
Search
destination device Search string device
#0

CR2002 MOV

ARITHMETIC OPERATION FUNCTIONS


@VM0 DM2000
Always ON
Search result

Note When either of the following conditions is established, 0 is stored in R :


gWhen the text string specified by and S1 S2
does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When (length of text string) < (length of S2 text string)
g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 and S2
g When a timer/counter is specified to S1 and S2 by indirect specifying
gWhen S2 string length is 0, or character string not found, 65535 is input to . R 7

Text Processing Functions


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = FIND (DM1000.T, SMID (DM1200.T, 4, 6))
Description of Operation The text string currently stored starting from DM1000.T is searched from the start of the search
destination text string currently stored starting from DM1200.T, and the text string resulting from having
cut six characters (number of bytes) from the 4th character (number of bytes) is searched.
The leading character position of the search text string that was first found from the start of
the search destination text string as a result of the search is stored in DM2000.U.
Ladder Conversion
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SMID
DM1200 *@VM0 #4
Always ON
#6

CR2002 MOV
#0 @VM2
Always ON
SFIND
DM1000 *@VM0 @VM2

#0

CR2002 MOV
@VM2 DM2000
Always ON

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-241


Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SMID function", Page 7-196
ARITHMETIC OPERATION FUNCTIONS

7
Text Processing Functions

7-242 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-243


DISS Disperse text string

Disperse text string

DISS([execution condition,]*1 disperse destination device, store destination device)


Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Disperse Specifies the device to which the text string
destination to be dispersed is stored, or the disperse - - - - - - - .T *3
ƻ ƻ ƻ
*2
device*4 destination text string.
D Store
Specifies the device to store the dispersed
destination .U .U .U .U - - - - - ƻ -
*2 text string (word unit) section to.
device*5
ARITHMETIC OPERATION FUNCTIONS

R Return value None - - - - - - - - - - -


*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 For bit devices, specify the leading device of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CR, CTC, CTH, Z can not be used.
*5 T, C, CTC, CTH, Z can not be used.

Description of Operation
7
When the execution condition is established (TRUE), the text string in byte units currently stored
Text Processing Functions

starting from S is dispersed into D and stored.

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)

Higher bytes filled with


0 automatically.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
DISS (R3000, DM1000.T, DM2000)
R3000 DISS
DM1000 DM2000
Execution conditon
Separate Store
destination device destination device

7-244 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note When either of the following conditions is established, 0 is stored in D :
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When a device other than the leading device of the channel is specified when a bit
device is specified to S and D
g When a timer/counter is specified to S and D by indirect specifying

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DISS (SMID (DM1000.T, EM1000, EM1001), DM2000)
Description of Operation The text string currently stored starting from DM1000.T is cut from the character position
(number of bytes) specified by EM1000 by the number of characters (number of bytes)
specified by EM1001 at every scan (no execution condition).
The text string in byte units resulting from the cut is dispersed to word units starting from
DM2000 and is stored.
Ladder Conversion
7
CR2002 ADRSET

Text Processing Functions


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SMID
DM1000 *@VM0 EM1000
Always ON Separate
Cut character
destination device
position
EM1001

Number of cutting characters


CR2002 DISS
*@VM0 DM2000
Always ON
Store destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"SMID function", Page 7-196

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-245


UNIS Unite text string

Unite text string

UNIS ([execution condition,]*1 unite destination device, store destination device, number of unite characters)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Unite Specifies the device to which the text string
destination (word units) to be united is stored, or the .U .U .U .U - - - - ƻ ƻ ƻ
*2
device*5 unite destination text string (word units).
D Store
Specifies the device to store the united text
destination - - - - - - - .T - ƻ -
*2 string to.
device*6
ARITHMETIC OPERATION FUNCTIONS

n Specifies the number of characters (number of


Number of unite *3
ƻ
*4 bytes or number of word units) to unite. (1 to .U .U .U .U - - - - ƻ ƻ
characters
1999)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 For bit devices, specify the leading device of the channel.
*3 "$" cannot be used.
*4 Specifies the number of unite characters within the range 1 to 1999.

7 *5
*6
T, C, CTC, CTH, Z can not be used.
T, C, CR, CTC, CTH, Z can not be used.
Text Processing Functions

Description of Operation

When the execution condition is established (TRUE), the text string in word units currently stored starting
from S is united into byte units for n characters (number of word units) , appended with the end
code NUL (00H) and stored starting from D .

S a(61H)
S +1 b(62H) D a(61H) b(62H)

S +2 c(63H) D +1 c(63H) d(64H)

n Ͼ ˖ ˖

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

* Round up the number if n /2 cannot be divisible

Omit high bit

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

ƽ Example of format
UNIS (R3000, DM1000, DM2000.T, 16)
R3000 UNIS
DM1000 DM2000 #16
Execution conditon
Merge destination device Store destination device

7-246 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note The function is not executed when either of the following conditions is established:
g When the value of n is "0" or "2000" or more
g When the text string including the end code (NUL (00H)) exceeds 2000 characters
g When a device other than the leading device of the channel is specified when a bit
device is specified to S and D
g When a timer/counter is specified to S and D by indirect specifying

ARITHMETIC OPERATION FUNCTIONS


Sample Program

ƽ To specify the bit device


Programmed Script UNIS (MR3000.U < 10, MR1000.U, MR2000.T, 10)
Description of Operation When MR3000.U is smaller than 10, the text string in word units currently stored starting
from MR1000.U is united to byte units for ten characters (number of word units), and
appended with the end code NUL (00H) and stored starting from MR2000.T.
Ladder Conversion
MR3000 UNIS
<
#10
MR1000 MR2000

Merge destination device Store destination device


#10
7
Execution conditon

Text Processing Functions


ƽ When this function is used in combination with other functions
Programmed Script UNIS (DM1000, DM2000.T, ANDA (EM1000, $FF))
Description of Operation The text string in word units currently stored starting from DM1000 is united to byte units for
the number of characters (number of word units) specified by the lower eight bits (extracted)
of EM1000, and is appended with the end code NUL (00H) and stored starting from
DM2000.T at every scan (no execution condition).
Ladder Conversion
CR2002 EM1000 $FF @VM0
LDA ANDA STA
Always ON Number of
merging character
UNIS
DM1000 DM2000 @VM0
Merge destination device Store destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-247


CHR Convert HEX ASCII text code to text string

Convert characters

Return value
*1
= CHR (conversion destination device)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the conversion
destination destination ASCII code is stored or the .U .U - - - - - - *2
ƻ ƻ ƻ
device ASCII code data. (16-bit data)
*3
R Return value .T type CHR function available - - - - - - - .T - ƻ -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
ARITHMETIC OPERATION FUNCTIONS

*2 The value of the constant is within the range 0 to 255. When a device is specified and the value of the
device is 0 to 255 or more, the value obtained by discarding the upper eight bits is used.
*3 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

The ASCII code data stored in S is converted to a half-width text string appended with the end
code NUL (00H), and the result is stored in R .

ƽ Example of format
7 DM1000.T = CHR ($0A)
Text Processing Functions

CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM2

CR2002 $A #8 @VM0 SMOV


LDA SLA STA @VM0 *@VM2
Always ON Conversion
destination device
CR2002 SMOV
*@VM2 DM1000
Always ON
Return value

7-248 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

Programmed Script DM2000.T = DM2000.T + CHR ($0D) + CHR ($0A)


Description of Operation The CR code (0DH) and LF code (0AH) are appended at the end of the text string DM2000.T.
Ladder Conversion
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

ARITHMETIC OPERATION FUNCTIONS


MOV.D
VM0 @VM2

CR2002 $A #8 @VM0 SMOV


LDA SLA STA @VM0 *@VM2
Always ON
CR2002 ADRADD.S
+1 VM0
Always ON
CR2002 MOV.D
VM0 @VM6
Always ON
CR2002 $D
LDA
#8
SLA
@VM4
STA
SMOV
@VM4 *@VM6
7
Always ON

Text Processing Functions


CR2002 ADRADD.S
+1 VM0
Always ON
CR2002 MOV.D
VM0 @VM8
Always ON
SMOV
DM2000 *@VM8

CR2002 SADD
*@VM8 *@VM6 *@VM8
Always ON
SADD
*@VM8 *@VM2 *@VM8

SMOV
*@VM8 DM2000

Specify ASCII code (half-width) to the conversion destination data.


"ASCII Code Table", Page A-15

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-249


CPSASC CIP text string conversion

Return value
*1
= CPSASC (target data storage destination)

Argument/Return Supported Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
target data Specifies the leading device number of the
storage device storing the CIP text string type data .U .S .D .L .F .DF .B .T - ƻ -
destination before conversion.
*2
device
R Return value .T type CPSASC function available - - - - - - - .T - - -
ARITHMETIC OPERATION FUNCTIONS

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit devices, specify the leading device of the channel.

Note
g The CPSASC function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation
7
The CIP text string type data stored starting from the device specified with S conversion target
Text Processing Functions

data storage designation device is converted into a text string, and the results are stored in R

return value.
The CPSASC function is used to convert the CIP text string type data, and process it as a text string.
Refer to the "KV-EP21V User's Manual" for details on the CIP data type.

When the CPSASC function is executed, the CIP text string type data is converted and stored in the
return value.
CIP text string type data (“ABCDE”) Converted text string data
bit bit bit bit
15 0 15 0
S +0 5(0005H) A(41H) B(42H) Return value
S +1 B(42H) A(41H) C(43H) D(44H)
S +2 D(44H) C(43H) E(45H) NULL(00H)
S +3 E(45H)
NULL(00H) is added to the end,
The CIP text string type data specifies and the high-order byte and
the data size with the leading word, low-order byte of the text string
and stores the text string in the order equivalent to the data size are
of low-order byte to high-order byte. interchanged and stored.

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-250 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.T = CPSASC (DM1000)

CR2002 ADRSET
VM2 VM0
Always ON

MOV
#0 VM2

ARITHMETIC OPERATION FUNCTIONS


MOV.D
VM0 @VM0

CR2002 CPSASC
DM1000 *@VM0
Always ON

CR2002 SMOV

Always ON
*@VM0 DM2000
7

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-251


RCPSASC CIP text string type data reverse conversion

Return value
*1
= RCPSASC (target data storage destination, converted data
storage destination)
Argument/Return Supported Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
target data
Specifies the number of the leading device *3
ƻ
storage - - - - - - - .T ƻ -
storing the text string to be converted.
destination
device
D Converted data
ARITHMETIC OPERATION FUNCTIONS

Specifies the number of the leading device


storage
storing the converted CIP text string type .U .S .D .L .F .DF .B .T - ƻ -
destination
data.
device
The number of characters (byte unit) stored
*2
R Return value in D is stored. The RCPSASC function .U .S .D .L .F .DF - - - - -
uses the .U function.
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*3 To specify a text string using constants, enclose with " ".
7 Note
g The RCPSASC function can be used only with KV STUDIO Ver. 6.00 or higher.
Text Processing Functions

g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The text string stored in the S conversion target data storage destination device is converted into
CIP text string type data, and the results are stored in the D converted data storage destination
device. After conversion, the number of characters (byte units) stored in D are stored in R

return value.
The RCPSASC function is used to convert the CIP text string type data, and process it as a text string.
Refer to the "KV-EP21V User's Manual" for details on the CIP data type.

When the RCPSASC function is executed, the CIP text string type data is converted and stored in the
return value.
Text string “ABCDE” CIP text string type data (“ABCDE”)
bit bit
15 0 5(0005H) D +0
S +0 A(41H) B(42H) B(42H) A(41H) D +1
S +1 C(43H) D(44H) D(44H) C(43H) D +2
S +1 E(45H) NULL(00H) E(45H) D +3

The data size (number of bytes) of the


text string to NULL(00H) is stored in
7(0007H) R
D +0, and the high-order bytes and
low-order bytes of the text string are
interchanged and stored in D +1 The data size (byte unit) stored
and after. in D is stored in R .

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "4-8 Text
Processing Instructions".

7-252 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM3000 = RCPSASC (DM1000.T, DM2000)

CR2002 MOV
#0 @VM0
Always ON

RCPSASC
DM1000 DM2000 @VM0

ARITHMETIC OPERATION FUNCTIONS


CR2002 MOV
@VM0 DM3000
Always ON

Text Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 7-253


MEMO
ARITHMETIC OPERATION FUNCTIONS

7
Text Processing Functions

7-254 - KV-5500/5000/3000/1000 Series Script Programming Manual -


8
EXTENDED FUNCTIONS

EXTENDED FUNCTIONS
Data Processing Functions ••••••••••••••••••••••••••••••••••••••••• 8-2
Table Processing Functions •••••••••••••••••••••••••••••••••••••• 8-42
Time Processing Functions••••••••••••••••••••••••••••••••••••••• 8-64
High-speed Processing Functions •••••••••••••••••••••••••••••• 8-72
PID Function••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-76
Log Function••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-78
Memory Card Functions••••••••••••••••••••••••••••••••••••••••••• 8-80
Access Window Function ••••••••••••••••••••••••••••••••••••••••8-108
FREE RUN Counter Function••••••••••••••••••••••••••••••••••• 8-112
Sensor Setting Function•••••••••••••••••••••••••••••••••••••••••• 8-114
Cyclic Communication Refresh Function •••••••••••••••••••••8-120

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-1


Data Processing Functions

SEG Decode 4-bit data to 7-segment

7-segment decode

Return value
*1
= SEG(decode destination device, destination digit position)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Decode Specifies the device to which the decode
destination destination data is stored or the decode .U .U .D .D - - - - ƻ ƻ ƻ
*2
device destination data.
Specifies the device to which the digit
n position to decode is stored, or the decode
Destination
*3 digit position. (0 to 3 for a .U suffix .U .U .U .U - - - - ƻ ƻ ƻ
digit position
instruction, and 0 to 7 for a .D suffix
instruction)
*5
*4
R Return value .U type SEG function available .U .S .D .L .F .DF - - - ƻ -
EXTENDED FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified to the S decode destination device, 16/32 continuous bits are
handled. When a relay other than the leading relay (e.g. R002 or R1012) of the channel has been specified, the
relay is handled in 16/32 bits straddling the next channel.
*3 When a device is specified to the n destination digit position, and the value stored in device
exceeds 0 to 3 or 0 to 7, operation is as follows.
When the decode destination device suffix is .U: The values of the lower two bits of the specified device are
used.
8 When the decode destination device suffix is .D: The values of the lower three bits of the specified device are
used.
Data Processing Functions

For example, when the suffix of the S decode destination device is .U, DM01000 is specified to
n , and that value is 23 (BIN: 0000 0000 0001 0111), "3" is used as the value of n as the value
of the lower two bits is "3".
*4 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The four bits (one digit) of n digits of the 16-bit/32-bit data stored in S are decoded to data (8 bits)
for 7-segment display, and the result is stored in R .
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.

8-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
g S : When decode destination device is 16 bits (.U/.S)
DM2000.U = SEG (DM1000.U, 2)
CR2002 #0 DM1000 DM2000
LDA SEG STA
Always ON #002 Return value
Decode destination device

in case of 1234
#3 #2 #1 #0

S :Decode destination device 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 DM1000.U

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

R :Return value 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 1 DM2000.U

Fill higher 8 bits with 0

g S : When decode destination device is 32 bits (.D/.L)


DM2100.U = SEG (DM1100.D, 3)
in case of 12345678
#7 #6 #5 #4 #3 #2 #1 #0 8
S 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 DM1100.D

Data Processing Functions


5

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

R 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 DM2100.U

Fill higher 8 bits with 0


For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data
Processing Instruction".

ƽ Data table for 7-segment display


Value 16-bit internal register Bit 0
of Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
$0 0 0 1 1 1 1 1 1
$1 0 0 0 0 0 1 1 0
Bit 5

Bit 1

$2 0 1 0 1 1 0 1 1
$3 0 1 0 0 1 1 1 1
$4 0 1 1 0 0 1 1 0
Bit 6
$5 0 1 1 0 1 1 0 1
$6 0 1 1 1 1 1 0 1
$7 0 0 1 0 0 1 1 1
Bit 4

Bit 2

$8 0 1 1 1 1 1 1 1
$9 0 1 1 0 1 1 1 1
$A 0 1 1 1 0 1 1 1
$B 0 1 1 1 1 1 0 0 Bit 3
$C 0 0 1 1 1 0 0 1
$D 0 1 0 1 1 1 1 0
$E 0 1 1 1 1 0 0 1
$F 0 1 1 1 0 0 0 1

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-3


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script R2000.U = SEG (TBCD (DM1000), 3)
Description of Operation The 16-bit BIN data currently stored in DM1000 is converted to 4-digit BCD (16-bit) data, and
the value of the 1000's digit (3rd digit) of the conversion result is decoded to data for 7-
segment display to turn ON the corresponding output relays (R2000 to R2015 (R2007)).
Ladder Conversion
CR2002 DM1000 @VM0 #0 @VM0 R2000
LDA TBCD STA LDA SEG STA
Always ON Decode destination #3 Return value
device
Note that this function sometimes cannot be used depending on the argument of the function
EXTENDED FUNCTIONS

it is combined with.
"TBCD function", Page 7-82

8
Data Processing Functions

8-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-5


BCNT ON bit count of specified device

Bit count

Return value
*1
= BCNT(operation destination)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation Specifies the operation destination device or
.U .U .D .D - - - - ƻ ƻ ƻ
destination the operation destination data.
*3
*2
R Return value .U type BCNT function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*3 The ".DF" suffix cannot be specified for device Z.
EXTENDED FUNCTIONS

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

8 Description of Operation
Data Processing Functions

The number of ON bits of the (16-bit/32-bit) BIN data stored in S are counted, and the result is
stored in return value.

g S : When operation destination is 16 bits (.U/.S)


bit bit
15 0

S 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 1

ķ ĸ Ĺ ĺ Ļ

Total bits of ON is 5 so save 5 to return value.

R ʿ00005

g S : When operation destination is 32 bits (.D/.L)


bit bit bit bit
31 16 15 0

S 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

ķ ĸ Ĺ ĺ Ļ ļ Ľľ Ŀ

Total bits of ON is 9 so save 9 to return value.

R ʿ00009

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

8-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.U = BCNT (DM1000.U)
CR2002 DM1000 DM2000
LDA BCNT STA
Always ON Operation destination device Return value

Sample Program

ƽ To count a bit device


Programmed Script DM2000.U = BCNT (MR1000.D)

EXTENDED FUNCTIONS
Description of Operation The ON bits of the 32-bit BIN data stored in MR1000.D are counted.
The result is stored in DM2000.U.
Ladder Conversion CR2002 MR1000 DM2000
LDA.D BCNT.D STA
Always ON Operation destination device Return value

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = BCNT (ORA (DM1000.D, DM1100.D))
Description of Operation The data stored in DM1000.D is ORed by the data stored in DM1100.D, and the number of 8
ON bits of the operation result is counted and stored in DM2000.U.

Data Processing Functions


Ladder Conversion CR2002 DM1000 DM1100 DM2000
LDA.D ORA.D BCNT.D STA
Always ON Operation destination device Operation data device Return value

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ORA function", Page 7-26

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-7


DCNT Count detected data in specified block

Data count

Return value = DCNT (detection destination, detection range leading device,


*1

number of detected data)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Detection Specifies the device to which the value to
*2 .U .U .D .D .D - - - ƻ ƻ ƻ
destination detect is stored, or the detection value.
S2 Detection
Specifies the leading device of the data Handled as same type
range leading as S1 .
- - - - ƻ -
*2 block to detect.
device
n Specifies the device currently storing the
Number of
number of data of the block to detect, or the .U .U .U .U - - - - ƻ ƻ ƻ
detected data
number of detected data.
*4
*3
R Return value .U type DCNT function available .U .S .D .L .F .DF - - - ƻ -
EXTENDED FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*3 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

8 Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
Data Processing Functions

versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

n block data starting from S2 are each compared with the data in S1 , and the number of
matching data is stored in R .

g S1 : When detection destination is 16 bits (.U/.S)

bit bit
S1 Detection destination
15 0 bit15 bit0

S2 1234 Compare 1234


Calculate and save the number of
S2 +1 2345 Compare device whose value equals that of
detection destination (16-bit).
S2 +2 3456 Compare
Save the result to return value
n (16-bit).

˄ nǂWord˅ S2 ˇ n ˉ3 1234 Compare

R Return value
S2 ˇ n ˉ2 4567 Compare
bit15 bit0

S2 ˇ n ˉ1 5678 Compare Result 2

8-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When detection destination is 32 bits (.D/.L)
bit bit bit bit bit S1 Detection destination bit
31 16 15 0 31 0

S2 +1 12345678 S2 Compare 12345678

S2 +3 23456789 S2 +2 Compare
Calculate and save the number of
S2 +5 34567890 S2 +4 Compare device whose value equals that of
detection destination (32-bit). Save


n


the result to return value (16-bit).
˄2 n Word˅ S2 +2˄ n -3˅+1 12345678 S2 +2˄ n -3˅ Compare

S2 +2˄ n -2˅+1 45678901 S2 +2˄ n -2˅ Compare


R Return value
S2 +2˄ n -1˅+1 56789012 S2 +2˄ n -1˅ Compare bit15 bit0

Result 2

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

EXTENDED FUNCTIONS
ƽ Example of format
DM2000.U = DCNT (DM1000.U, DM1200.U, 4)
CR2002 DM1000 DM1200 DM2000
LDA DCNT STA
Always ON Detection destination device #4 Return value
Detection range
leading device

Note
When the value of n is "0", the value of the S1 is stored in R .
8

Data Processing Functions


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = DCNT (COM (DM1000.D), MR1000.D, EM2000)
Description of Operation The 32-bit BIN data of number of detection data indicated by EM2000 starting from MR1000
(.D) are each compared with the value resulting from having inverted the bits of unsigned 32-
bit BIN data currently stored in DM1000.D, and the number of matching data is stored in
DM2000.U.
Ladder Conversion
CR2002 DM1000 MR1000 DM2000
LDA.D COM.D DCNT.D STA
Always ON Detection destination device EM2000 Return value
Detection range
leading device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"COM function", Page 7-32

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-9


SER Detect data in specified block

Search

Return value = SER (detection destination, detection range leading device,


*1

number of detected data)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Detection Specifies the device to which the value to
*2 .U .U .D .D .D - - - ƻ ƻ ƻ
destination detect is stored, or the detection value.
S2 Detection
Specifies the leading device of the data Handled as same type
range leading as S1 .
- - - - ƻ -
*2 block to detect.
device
n Specifies the device currently storing the
Number of
number of data of the block to detect, or the .U .U .U .U - - - - ƻ ƻ ƻ
detected data
number of detected data.
*4
*3
R Return value .U type SER function available .U .S .D .L .F .DF - - - ƻ -
EXTENDED FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*3 When the type other than .U is specified by return value, type conversion will be automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
8 g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Data Processing Functions

g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

n block data starting from S2 are each compared with the data in S1 , and the number of
matching data is stored in R .
When multiple matching data are detected, the smallest device No. is stored.

g S1 : When detection destination is 16 bits (.U/.S)

bit bit
S1 Detection destination
15 0 bit15 bit0

Detect and save the No. of device


S2 1234 Compare 3456 whose value equals that of
Compare detection destination (16-bit).
S2 +1 2345
Save the result to return value
3456 Compare (16-bit).
S2 +2
n ˖

˄ nǂWord) S2 ˇ n ˉ3 1234 Compare

R Return value
S2 ˇ n ˉ2 3456 Compare
bit15 bit0

S2 ˇ n ˉ1 5678 Compare Result S2 +2

8-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When detection destination is 32 bits (.D/.L)

bit
31
bit bit
16 15
bit
0
bit
31
S1 Detection destination bit
0

S2 +1 12345678 S2 Compare 23456789

23456789 Compare
S2 +3 S2 +2 Detect and save the No. of
device whose value equals that
S2 +5 34567890 S2 +4 Compare
of detection destination (32-bit).
n ˖ Save the result to return value


˄2 nǂWord˅ (32-bit).
S2 +2˄ n -3˅+1 45678901 S2 +2˄ n -3˅ Compare

S2 +2˄ n -2˅+1 23456789 S2 +2˄ n -2˅ Compare

S2 +2˄ n -1˅+1 56789012 S2 +2˄ n -1˅ Compare R Return value


bit15 bit0

Result S2 +2

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.

EXTENDED FUNCTIONS
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format
DM2000.U = SER (DM1000.U, DM1200.U, 40)
CR2002 DM1000 DM1200 DM2000
LDA SER STA
Always ON Detection destination device #40 Return value
Detection range
leading device 8
Note

Data Processing Functions


g When no matching devices are found, or value of n is "0", the value of S1 is stored
in R .
g When a bit device has been specified to the detection range leading device, the value
obtained by converting not to 16-bit units but to decimal units taking R (MR, LR) 0000 as its
reference point is stored in search result (return value).
(example) When the search result is MR82312: 823x16+12=13180 is stored.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.U = SER (NEG (DM1000.D), MR1000.D, EM2000.U)
Description of Operation The block of unsigned 32-bit BIN data of number of detection data indicated by EM2000
starting from MR1000.D are each compared with the values resulting from having inverted
the sign of unsigned 32-bit BIN data currently stored in DM2000.U.
Ladder Conversion
CR2002 DM1000 MR1000 DM2000
LDA.D NEG.D SER.D STA
Always ON Detection destination device EM2000 Return value
Detection range
leading device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"NEG function", Page 7-34

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-11


DSER Detect MAX value in a specified block

Search value

Return value
*1
= DSER(Detection data, detection range leading device, number of detection
device, number of detection store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 *2 Specify detection data or the device storing
Search data .U .U .D .D .D - - - ƻ ƻ ƻ
detection data.
S2 Detection
Specifies the leading device of the range to Handled as same type
range leading as S1 .
- - - - ƻ -
*2 detect.
device
n Number of
Specify the number of device to be detected
detection store .U .U .U .U - - - - ƻ ƻ ƻ
*2 or stored.
device
D Number of
Specify the device store detection result (the
EXTENDED FUNCTIONS

detection store .U .U .U .U - - - - - ƻ -
*2 number of detections).
device
Specify the device store detection position *4
R Return value (offset from the leading device of detection .U .S .D .L .F .DF - - - ƻ -
*3
range). .U type DSER function available
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
8 *3 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
Data Processing Functions

*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
g DSER function is special function of KV-5500/5000/3000. CPU other than KV1000 series
cannot be used.

Description of Operation

To search n devices starting from S2 by using S1 as keyword.


• The number of the device in conformity with S1 is stored in D .
• From the initial conformable device position S1 in relative position R .
• When conformable data not found, it is stored in D and R .

8-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When detection data is16 bits (.U)
bit bit S1
15 0 bit15 bit0
Position at first Count the number of device
S2 1234 Compare 3456
R whose value identical to the
S2 +1 2345 Compare
value of detection destination
3
S2 +2 3456 Compare device (16 bit). Detection
16 bits
n result (position) is stored into
… ˖
( n Word) return value (16 bit).
S2 + n - 3 1234 Compare Number of consistent
D
S2 + n - 2 3456 Compare
2
5678 Compare Result
S2 + n - 1
16 bits

g S1 : When operation destination device is 32 bits

EXTENDED FUNCTIONS
bit bit bit bit bit S1 +1 S1 bit
31 16 15 0 31 0
Position at first
S2 +1 12345678 S2 Compare 23456789
R
S2 +3 34567890 S2 +1 Compare
3
S2 +5 23456789 S2 +2 Compare
16 bits
n
˖

( 2× n Word)
S2 +( n - 3 ) +1 45678901 S2 +( n - 3) Compare Number of consistent
D
S2 +( n - 2 )+1 23456789 S2 +( n - 2) Compare
2
- 1 )+1 56789012 - 1) Compare Result
S2 +( n S2 +( n 16 bits

Count the number of device whose value


identical to the value of detection destination
8
device (32 bit). Detection result (position) is

Data Processing Functions


stored into return value (16 bit).

ƽ Example of format
DM2000.U = DSER (DM1000.U, EM0, DM1002, DM2002)
CR2002 DSER
DM1000 EM0 @VMO DM1002
Always ON
Search data Search range leading device Number of
search devices

MOV
@VM1 DM2002
Detect number of
store device

@VM0 DM2000
LDA STA
Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-13


MAX Detect maximum value in a specified block

Search max. value

Return value
*1
= MAX (search destination device, number of search range data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Detection
Specifies the leading device of the range to
destination .U .S .D .L - - - - - ƻ -
*2 detect.
device*3
n Number of Specifies the device currently storing the
search number of data in the range to search, or .U .U .U .U - - - - ƻ ƻ ƻ
*2
range data the number of search range data.
*5
R MAX function type is identical to the 1st
Return value *4 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
EXTENDED FUNCTIONS

*2 The range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*4 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
8 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Processing Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The maximum value is searched in the (16-bit/32-bit) BIN data stored in n words starting from
S . (When the search destination is 32-bit data, the search range becomes the "specified number of
data x 2 words".)
The maximum value as a result of the search is stored in R .

g S : When search destination device is unsigned 16-bit data (.U)


bit bit
15 0

S 1234

S +1 2345

3456 Save Max. value


S +2
R Return value
n

bit15 bit0

˄ nǂWord˅ S ˇ n ˉ3 9876 9876

S ˇ n ˉ2 8765

S ˇ n ˉ1 7654

g S : When search destination device is signed 16-bit data (.S)


bit bit
15 0

S 1234

S +1 2345

S +2 3456 Save Max. value


R Return value
n

bit15 bit0

˄ nǂWord˅ S ˇ n ˉ3 ˉ1234 3456

S ˇ n ˉ2 ˉ2345

S ˇ n ˉ1 ˉ3456

8-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When search destination device is unsigned 32-bit data (.D)
bit bit bit bit
31 16 15 0

S +1 12345678 S
S +3 23456789 S +2
34567890 Save Max. value
S +5 S +4
n bit
R Return value bit
31 0

˄2 nǂWord˅ S +2˄ n ˉ3˅+1 98765432 S +2˄ n ˉ3˅ 98765432

S +2˄ n ˉ2˅+1 87654321 S +2˄ n ˉ2˅


S +2˄ n ˉ1˅+1 76543210 S +2˄ n ˉ1˅

g S : When search destination device is signed 32-bit data (.L)


bit bit bit bit
31 16 15 0

S +1 12345678 S

EXTENDED FUNCTIONS
S +3 23456789 S +2

S +5 34567890 S +4 Save Max. value


n bit
31
R Return value bit
0

(2 n Word) S +2˄ n ˉ3˅+1 ˉ12345678 S +2˄ n ˉ3˅ 34567890

S +2˄ n ˉ2˅+1 ˉ23456789 S +2˄ n ˉ2˅


S +2˄ n ˉ1˅+1 ˉ34567990 S +2˄ n ˉ1˅

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format
8

Data Processing Functions


DM2000.U = MAX (DM1000.U, 32)
CR2002 #0 DM1000 DM2000
LDA.D MAX STA
Always ON #32 Return value
Search destination device

Note
When the value of n is 0, 0 is stored in R :

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000 = TBCD (MAX (DM1000.U, EM1100.U))
Description of Operation The maximum value is searched in the data stored in the range of EM1100 words starting
from DM1000. The maximum value in the search result is converted to 4-digit BCD data, and
stored in DM2000.
Ladder Conversion CR2002 #0 DM1000 DM2000
LDA.D MAX TBCD STA
Always ON EM1100 Return value
Search destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"TBCD function", Page 7-82

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-15


MIN Detect minimum value in a specified block

Detect minimum value

Return value
*1
= MIN (search destination device, number of search range data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Detection
Specifies the leading device of the range to
destination .U .S .D .L - - - - - ƻ -
*2 detect.
device*3
n Number of Specifies the device currently storing the
search number of data in the range to search, or .U .U .U .U - - - - ƻ ƻ ƻ
*2
range data the number of search range data.
*5
R MIN function type is identical to the 1st
Return value *4 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
EXTENDED FUNCTIONS

*2 The range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*4 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
8 g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
Data Processing Functions

"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The minimum value is searched in the (16-bit/32-bit) BIN data stored in n words starting from
S . (When the search destination is 32-bit data, the search range becomes the "specified number of
data x 2 words".)
The minimum value as a result of the search is stored in R .

g S : When search destination device is unsigned 16-bit data (.U)


bit bit
15 0

S 1234

S +1 2345
Save Min. value
S +2 3456
R Return value
n

bit15 bit0

˄ nǂWord˅ S ˇ n ˉ3 9876 1234

S ˇ n ˉ2 8765

S ˇ n ˉ1 7654

g S : When search destination device is signed 16-bit data (.S)


bit bit
15 0

S 1234

S +1 2345
Save Min. value
S +2 3456
R Return value
n

bit15 bit0

˄ nǂWord˅ S ˇ n ˉ3 ˉ1234 ˉ3456

S ˇ n ˉ2 ˉ2345

S ˇ n ˉ1 ˉ3456

8-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When search destination device is unsigned 32-bit data (.D)
bit bit bit bit
31 16 15 0

S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4 Save Min. value


n … bit
31
R Return value bit
0

˄2 nǂWord˅ S +2˄ n ˉ3˅+1 98765432 S +2˄ n ˉ3˅ 12345678

S +2˄ n ˉ2˅+1 87654321 S +2˄ n ˉ2˅


S +2˄ n ˉ1˅+1 76543210 S +2˄ n ˉ1˅

g S : When search destination device is signed 32-bit data (.L)


bit bit bit bit
31 16 15 0

S +1 12345678 S

EXTENDED FUNCTIONS
S +3 23456789 S +2

S +5 34567890 S +4 Save Min. value


Return valuebit

n bit
31
R 0

˄2 nǂWord˅ S +2˄ n ˉ3˅+1 ˉ12345678 S +2˄ n ˉ3˅ ˉ34567990

S +2˄ n ˉ2˅+1 ˉ23456789 S +2˄ n ˉ2˅


S +2˄ n ˉ1˅+1 ˉ34567990 S +2˄ n ˉ1˅

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".
8
ƽ Example of format

Data Processing Functions


DM2000.U = MIN (DM1000.U, 32)
CR2002 #0 DM1000 DM2000
LDA.D MIN STA
Always ON #32 Return value
Search destination device

Note
When the value of n is 0, 0 is stored in R :

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.S = NEG (MIN (DM1000.S, EM1100))
Description of Operation The minimum value is searched in the data stored in the range of EM1100 words starting
from DM1000. The sign of the MIN value in the search result is inverted, and stored in
DM2000.S.
Ladder Conversion CR2002 #0 DM1000 DM2000
LDA.D MIN.S NEG.S STA.S
Always ON EM1100 Return value
Search destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"NEG function", Page 7-34

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-17


AVG Average value of specified block

Average

Return value
*1
= AVG (operation destination device, number of operation range data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the leading device of the range to
destination .U .S .D .L - - - - - ƻ -
*2 average.
device*3
n Number of Specifies the number of data in the range to
operation average or the device to which that number .U .U .U .U - - - - ƻ ƻ ƻ
*2
range data is currently stored.
*5
R AVG function type is identical to the 1st
Return value *4 .U .S .D .L .F .DF - - - ƻ -
argument.
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
EXTENDED FUNCTIONS

*2 The range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*4 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
8 g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Data Processing Functions

g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The average value of all BIN data (16-bit/32-bit (unsigned/signed)) stored in n words is calculated
starting from S . (When the operation destination is 32-bit data, the operation range becomes the
"specified number of data x 2 words".)
The average value as a result of the search is stored in R .

g S : When operation destination device is unsigned 16-bit data (.U)


bit bit
15 0

S 16

S +1 256

S +2 4096

n
˄ n Words S ˇ n ˉ3 16383 Average is stored in R (return value).
R Return value
S ˇ n ˉ2 32767 bit15 bit0

S ˇ n ˉ1 65535 Average Average value

8-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is signed 16-bit data (.S)
bit bit
15 0

S -32700

S +1 -16350

S +2 -8175
n


˄ n Words˅ S ˇ n ˉ3 8175 Average is stored in R (return value).
R Return value
S ˇ n ˉ2 16350 bit15 bit0

S ˇ n ˉ1 32700 Average Average value

g S : When operation destination device is unsigned 32-bit data (.D)


bit bit bit bit
31 16 15 0

EXTENDED FUNCTIONS
S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4



n
˄2 n Words˅ S +2˄ n -3˅+1 78901234 S +2˄ n -3˅ Average is stored in R (return value).
R +1 R
S +2˄ n -2˅+1 89012345 S +2˄ n -2˅ bit
31
bit
0

S +2˄ n -1˅+1 90123456 S +2˄ n -1˅ Average Average value

g S : When operation destination device is signed 32-bit data (.L)


bit
31
bit bit
16 15
bit
0
8
S S

Data Processing Functions


+1 -90123456

S +3 -89012345 S +2

S +5 -78901234 S +4

n

˄2 n Words˅ S +2˄ n -3˅+1 78901234 S +2˄ n -3˅ Average is stored in R (return value).
R +1 R
S +2˄ n -2˅+1 89012345 S +2˄ n -2˅ bit
31
bit
0

S +2˄ n -1˅+1 90123456 S +2˄ n -1˅ Average Average value

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format
DM2000.U = AVG (DM1000.U, 32)
CR2002 #0 DM1000 DM2000
LDA.D AVG STA
Always ON #32 Return value
Operation destination device

Note
When the value of n is 0, 0 is stored in R :

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-19


WSUM Total value of specified block

Word sum

Return value
*1
= WSUM (operation destination device, number of operation range data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the leading device of the range to
destination .U .U .D .D - - - - - ƻ -
*2 total.
device*3
n Number of Specifies the device currently storing the
operation number of data in the range to total, or the .U .U .U .U - - - - ƻ ƻ ƻ
*2
range data total range data.
*5
*4
R Return value .L type WSUM function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
EXTENDED FUNCTIONS

*2 The range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*4 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
8 g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
Data Processing Functions

g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

All unsigned 16-bit BIN data stored in n words is totaled starting from S , and the resulting
signed 32-bit BIN data is stored in R .

g S : When operation destination device is 16 bits (.U/.S)


bit bit
15 0

S 16

S +1 256

S +2 4096

n Higher 16 bits are stored to higher 16


˄ nǂword˅ S ˇ n ˉ3 16383 bits of returned value R and TM000.

S ˇ n ˉ2 32767

S ˇ n ˉ1 65535 Total R Return value


32 bit

8-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When operation destination device is 32 bits (.D/.L)
bit bit bit bit
31 16 15 0

S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4




n
(2 nǂbit) S +2 ( n -3) +1 78901234 S +2( n -3)
S +2( n -2)+1 89012345 S +2( n -2)
S +2( n -1)+1 90123456 S +2( n -1) Total R Return value
32 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing

EXTENDED FUNCTIONS
Instruction".

ƽ Example of format
DM2000.L = WSUM (DM1000.U, 24)
CR2002 #0 DM1000 DM2000
LDA.D WSUM STA.L
Always ON #24 Store device
Operation destination device

When the operation result exceeds the range (-2147483648 to +2147483647) of signed 32-
bit data, the lower 32-bit data is stored in return value, and the upper 32-bit data is stored in
8

Data Processing Functions


TM001 and TM000.

Note
When the value of n is 0, 0 is stored in R :

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.F = FLOAT (WSUM (DM1000.U, EM1100.U))
Description of Operation The total value of all data stored in range of values currently stored in EM1100.U starting
from DM1000.U is calculated. The total value in the operation result is converted to single
precision floating point type real number data, and is stored in DM2000.F.
Ladder Conversion CR2002 #0 DM1000 DM2000
LDA.D WSUM FLOAT.L STA.F
Always ON EM1100 Return value
Operation destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"FLOAT function", Page 7-118

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-21


Hint

When the result of having performed an operation by the WSUM function exceeds the signed 32-bit range,
the lower 32-bit data is stored in return value, and the upper 32-bit data is stored in temporary data memories
TM0 and TM1.
The WSUM uses the upper 32-bit (TM0/TM1) data to handle data as 64-bit data.
Programmed Script EM2000.L = WSUM (DM1000, 1024)
EM2002.L = TM0000.L

All of unsigned 16-bit BIN data stored in range of 1024 words starting from DM1000 is totaled. The lower 32
bits of the total value are stored in EM2000.L, and then the upper 16 bits (TM0.L) are immediately stored in
EM2002.L to be handled as signed 64-bit BIN data from EM2000.L to EM2002.L.
EXTENDED FUNCTIONS

High bit Low bit

EM2003 EM2002 EM2001 EM2000


64 bits

The temporary data of TM0/TM1 is used also in other operation formulas. For this reason,
when data is to be handled as 64-bit data, the data must be stored in a separate device
immediately after the WSUM has been programmed.

8
Data Processing Functions

8-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-23


BSUM Total value (in byte units) of specified block

Byte sum

Return value
*1
= BSUM(operation destination device, number of operation range data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Operation
Specifies the leading device of the range to
destination .U .U .U .U - - - .U - ƻ -
*2 *4 calculate the total value.
device*3
n Number of
Specifies the number of data (in byte units)
operation .U .U .U .U - - - - ƻ ƻ ƻ
*2 to calculate the total value.
range data
*6
*5
R Return value .U type BSUM function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
EXTENDED FUNCTIONS

*2 The range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*4 T, C, CTC, CTH, Z cannot be used.
*5 When the type other than .D is specified by return value, type conversion will be automatically conducted
during conversion.
*6 The ".DF" suffix cannot be specified for device Z.

8 Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
Data Processing Functions

versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The total values of each of the lower and upper eight bits of the BIN data currently stored in the
specified range starting from the S are calculated, and are stored in R . When n is an odd
number, up to the upper eight bits of the last device are calculated. Calculation is performed in order
upper to lower bits, and when n is an odd number, the lower eight bits of the last word data are
ignored.
16 bits (1 word)

bit bit bit bit


15 8 7 0

S BDH 21H
BDH
S +1 B4H DDH 21H
S +2 B7H B0H B4H



S ˇ n ÷2ˉ3 4EH 43H 45H
4BH
59H 45H R +1 R
S ˇ n ÷2ˉ2 + 45H
R Return value
S ˇ n ÷2ˉ1 4BH 45H Total
32 bits

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

8-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.D = BSUM (DM1000, 24)
CR2002 #0 DM1000 DM2000
LDA.D BSUM STA.D
Always ON #24 Storage device
Operation destination device

When the operation result exceeds the signed 32-bit data range, the lower 32-bit data is
stored in return value, and the upper 32-bit data is stored in TM001 and TM000.

Note
When either of the following conditions is established, 0 is stored in R :
g When a timer/counter is specified to S

g When a device other than the leading device of the channel is specified when a bit device is specified

EXTENDED FUNCTIONS
to S

g When the value of n is "0"

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script DM2000.D = BSUM (DM1000.T, LEN (DM0000.T)) 8
Description of Operation The ASCII text string currently stored in DM1000.T is totaled in byte units, and the result is

Data Processing Functions


stored in [DM2000, DM2001].
Ladder Conversion CR2002 MOV
#0 @VM0
Always ON
LEN
DM0 @VM0
Number of operation range
CR2002 #0 DM1000 DM2000
LDA.D BSUM STA.D
Aways ON @VM0 Storage device
Operation destination device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"LEN function", Page 7-184

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-25


CRC Calculate CRC value in specified block

Return value
*1
= CRC (default, operation method, operation order, invert bit
operation order,data block leading device, number of data)

Argument/Return Recognized Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
*5
S1 Default .U .U .U .U - - - - ƻ ƻ ƻ
S2 Operation
*5 .U .U .U .U - - - - ƻ ƻ ƻ
method *2
Specifies the operation mode.
S3 Operation
*5 .U .U .U .U - - - - ƻ ƻ ƻ
order
*5
S4 Invert bit order .U .U .U .U - - - - ƻ ƻ ƻ
S5 Data block Specifies the leading device of the data
*3 .U .U .U .U - - - - - ƻ -
leading device*5 block to calculate.
n Number of
EXTENDED FUNCTIONS

*4 Specifies the number of data (1- 65535). .U .U .U .U - - - - ƻ ƻ ƻ


data
*7
*6
R Return value .U type CRC function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When the specified device or the value of the formula is other than "0" or "1", the value is handled as " 1 ".
*3 When specifying a bit device, specify the leading device of the channel.
*4 When S3 is "0", specify the number in 1-word (16-bit) units.
When S3 is "1 (other than "0")", specify the number of 1-byte (8-bit) units.

8 *5
*6
T, C, CTC, CTH, Z cannot be used.
When the type other than .U is specified by return value, type conversion will be automatically conducted
Data Processing Functions

during conversion.
*7 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The CRC value of n data starting from S5 is calculated in the operation mode specified by
S1 to S4 operation data bit order inversion, and is stored in R .

8-26 - KV-5500/5000/3000/1000 Series Script Programming Manual -


The operation mode is specified as follows.

CRC Operation Method


Item
When "1" is specified When "0" is specified
The value set to 16-bit internal register is The CRC default is fixed at
S1 CRC default
used as the CRC default. 0x0000.
CRC Operation
S2 CRC-ITU-T(CRC-CCITT) CRC-16(CRC-ANSI)
Method
Operation is performed in order upper 8 bits Operation is performed only on
-> lower 8 bits. the lower 8 bits.
n : Even n : Odd number (The upper 8 bits are ignored.)
Order of bit
15
bit bit
8 7
bit
0
bit
15
bit bit
8 7
bit
0
bit
15
bit bit
8 7
bit
0
S3
operation (1) (2) (1) (2) (1)

EXTENDED FUNCTIONS
(3) (4) (3) (4) (2)

(n) ˉ1 (n) (n) (n)

Operation data The bit alignment (order) of data to be


S4 bit order operated on is inverted in byte units, and the The bit position is not inverted.
inversion CRC value is calculated.

The following describes an example relating to S4 operation data bit order inversionin in byte units.
Operation Data
Bit Order Inversion
CRC-ITU-T ( S2 =1) CRC-16 ( S2 =0) 8
bit bit bit bit
Not inverted

Data Processing Functions


7 0 7 0

S4 : "0" Operating order Operating order


bit bit bit bit
Inverted 7 0 7 0

S4 :"1" (other than 0) Operating order Operating order

ƽ Example of format
EM2000.U = CRC (1, 0, 0, 0, DM1000.U, 256)
CR2002 #1
LDA
Always ON
#0 @VB00
<>
#0
#0 @VB01
<>
#0
CR2002 @VB02

Always ON
#0 @VB03
<>
#0
CR2002 CRC
@VB00 DM1000 #256
Always ON
CR2002 EM2000
STA
Always ON Return value

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-27


Note
When either of the following conditions is established, the value of S1 is stored in R :
g When a word device or timer/counter has been specified to S1

g When a device other than the leading device of the channel is specified when a timer/
counter or a bit device is specified to S2 by indirect specification
g When the value of n is "0"
EXTENDED FUNCTIONS

8
Data Processing Functions

8-28 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-29


ZRES Reset specified block

Zone reset

ZRES ([execution condition,]*1 leading device, final device)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
*2

D1 Specifies the leading device of the range to


Leading device .U .U .U .U .U .U .B .T - ƻ -
reset.
D2 Specifies the final device of the range to
Final device Handled as same type as D1 . - ƻ -
reset.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 The ".DF" suffix cannot be specified for device Z.
EXTENDED FUNCTIONS

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation
8 When the execution condition is established (TRUE), all of the values of D1 and D2 are reset.
Data Processing Functions

g To specify the word device


bit bit bit bit
15 0 15 0

D1 2048 Reset 0

D1 +1 4096 Reset 0

D1 +2 8192 Reset 0
˖ ˖

D2 -2 16384 Reset 0

D2 -1 32767 Reset 0

D2 65535 Reset 0

* The suffix is handled as .U even if .D .L .F .DF are specified as the suffix. For this reason, "0" is stored
for the specified one word as the final word.
g To specify the bit device
D1 : R01005ǃ D2 : R01011

R01002: ON ON :R01002
R01003: ON ON :R01003
R01004: ON ON :R01004

D1 R01005: ON OFF :R01005


R01006: ON OFF :R01006
R01007: ON OFF :R01007
R01008: ON Reset OFF :R01008
R01009: ON OFF :R01009
R01010: ON OFF :R01010
D2 R01011: ON OFF :R01011
R01012: ON ON :R01012
R01013: ON ON :R01013

8-30 - KV-5500/5000/3000/1000 Series Script Programming Manual -


When a word device has been specified, the word becomes "0" in word units, and when a bit
device has been specified, the bit becomes OFF in bit units.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format
ZRES (R3000, DM1000.U, DM1099.U)
R3000 DM1000
ZRES
DM1099
Execution conditon

EXTENDED FUNCTIONS
Reset device

Note
When the type of specified devices differ at D1 and D2 , the ZRES function is not
executed.

Sample Program

ƽ To specify the bit device 8


ZRES (R3000, MR1008, MR1207)

Data Processing Functions


Programmed Script

Description of Operation When R3000 turns ON, all of the 32 bits from M1008 to MR1207 are reset (are turned OFF).
Ladder Conversion R3000 MR1008
ZRES
MR1207
Execution conditon Reset device

ƽ When an index register is used


Programmed Script ZRES (DM2000: Z01, DM2000:Z02)
Description of Operation All of the words in the range DM2000:Z01 to DM2000: Z02 are reset (cleared to "0") at every
scan (no execution condition).
Ladder Conversion CR2002 DM2000:Z1
ZRES
Always ON DM2000:Z2
Reset device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-31


BCMP Compare data between specified blocks

Compare data between blocks

Return value
*1
= BCMP(compare source device, compare destination device,
operation store device, number of compare data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Compare
Specifies the leading device of the compare
source .U .U .D .D .D - - - - ƻ -
*2 source data block.
device
S2 Compare
Specifies the leading device of the compare Handled as same type
destination as S1 .
- - - - ƻ -
*2 destination data block.
device
D Result store Specifies the leading device to which the
*2 - - - - - - .B - - ƻ -
device*3 compare result is stored.
n Specifies the device currently storing the
Number of
EXTENDED FUNCTIONS

number of data of the block to compare, or .U .U .U .U - - - - ƻ ƻ ƻ


compare data
the number of compare data.
R Return value ON when all data matched. Otherwise, OFF - - - - - - .B - - ƻ -
*1 The return value can be omitted. When omitted, the bit information is stored in a work device/relay.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002, or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*3 When a bit device has been specified, the program will function normally even if the bit device straddles
channels.
8 When a word device has been specified to D , the LSB of n number of 16-bit word devices
becomes the store destination of the result. Bits other than the lowermost bit do not change.
Data Processing Functions

Description of Operation

When the execution condition is established (TRUE), n block data starting from S1 and n

block data starting from S2 are each compared.


When the compare result matches, ON is stored in bit devices for the number of compare data starting
from D . When the compare result does not match, OFF is stored.
When the D is a word device, storage of the compare result is handled in 16-bit word device units,
and only the LSB of each word device is targeted. (Bits other than the LSB do not change.)
If all data matches as a result of the compare, R are turned ON. Otherwise, the bit devices are
turned OFF.
g S1 : When the compare source device is 16 bits (.U/.S)
bit
15
bit
0
Compare bit
15
bit
0
Result
S1 1234 S2 1234 D ON

S1 +1 5678 S2 +1 5678 D +1 ON

S1 +2 0 S2 +2 1000 D +2 OFF
n

˄ n Words˅
S1 + n ˉ2 4567 S2 + n ˉ2 5678 D + n ˉ2 OFF
S1 + n ˉ1 7890 S2 + n ˉ1 7890 D + n ˉ1 ON

8-32 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S1 : When the compare source device is 32 bits (.D/.L)
bit
31
bit bit
16 15
bit
0
Compare bit
31
bit bit
16 15
bit
0
Result
S1 +1 12345678 S1 S2 +1 12345678 S2 D ON

S1 +3 56780123 S1 +2 S2 +3 56780123 S2 +2 D +1 ON

S1 +5 10002000 S1 +4 S2 +5 30004000 S2 +4 D +2 OFF


n


˄2 n Words˅
S1 +2˄ n ˉ2˅+1 45670123 S1 +2˄ n ˉ2˅ S2 +2˄ n ˉ2˅+1 56780123 S2 +2˄ n ˉ2˅ D + n ˉ2 OFF
S1 +2˄ n ˉ1˅+1 78903456 S1 +2˄ n ˉ1˅ S2 +2˄ n ˉ1˅+1 78903456 S2 +2˄ n ˉ1˅ D + n ˉ1 ON

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format

EXTENDED FUNCTIONS
R3000 = BCMP (DM1000.U, DM1200.U, MR2000, 40)
CR2002 BCMP
DM1000 DM1200 MR2000
Always ON
Compare source device Compare source device Result stroe device
#40

CR2010 R3000

the operation result is zero


8
Note

Data Processing Functions


When the value of n is 0, R turns ON.

Sample Program

ƽ When this function is used in combination with other functions


Programmed Script MR2000 = BCMP (DM1000.L, EM2000.L, MR3000, ANDA (EM3000, $3F))
Description of Operation Of signed 32-bit BIN data block starting from DM1000.L and signed 32-bit BIN data block
starting from EM2000 (.L), the data of the number of compare data (number of compare data
x 2 words) indicated by the lower six bits (extracted) of EM3000 are each compared.
The compare result is stored in 16-bit data starting from MR3000.
If all of the data is matching as a result of the compare, MR2000 is turned ON. Otherwise,
MR2000 is turned OFF.
Ladder Conversion CR2002 EM3000 $3F @VM0
LDA ANDA STA
Always ON Number of compare data
BCMP.L
DM1000 MR2000 MR3000
Compare source device Compare source device
@VM0
CR2010 MR2000

the operation result is zero

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"ANDA function", Page 7-24

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-33


BCMPI Compare data of value with block

Compare data between blocks

Return value
*1
= BCMPI (compare source device, compare value device,
result store device, number of compare data)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Compare
Specifies the leading device of the data
destination .U .U .D .D .D - - - - ƻ ƻ
*2 block to compare.
device
S2 Comparevalue Specifies the device to which the value to Handled as same
type as S1 .
- - - - - ƻ -
device compare is , or the compare value.
D Result store Specifies the leading device to which the
*3 - - - - - - .B - - ƻ -
device compare result is .
n Specifies the device currently storing the
Number of
number of data of the block to compare, or .U .U .U .U - - - - ƻ ƻ ƻ
compare data
EXTENDED FUNCTIONS

the number of compare data.


R Return value ON when all data matched. Otherwise, OFF - - - - - - .B - - ƻ -
*1 The return value can be omitted. When omitted, the operation result is to a work device.
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002, or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.
*3 When a bit device has been specified, the program will function normally even if the bit device straddles
channels.

8 When a word device has been specified to


becomes the store destination of the result. Bits other than the lowermost bit do not change.
D , the LSB of n number of 16-bit word devices
Data Processing Functions

Description of Operation

When the execution condition is established (TRUE), n block data starting from S1 and the
data in S2 are each compared.
When the compare result matches, ON is in n bit devices starting from D . When the compare
result does not match, OFF is .
When the D is a word device, storage of the compare result is handled in 16-bit word device units, and
only the LSB of each word device is targeted. (Bits other than the LSB do not change.)
If all data matches as a result of the compare, the bit devices specified by the R are turned ON.
Otherwise, the bit devices are turned OFF.
g S1 : When the compare source device is 16 bits (.U/.S)
bit
16
bit
0
Compare Result
S1 1234 D ON

S1 +1 5678 D +1 OFF
bit bit
16 0

S1 +2 0 D +2 OFF
n S2 1234

( n Word)
S1 + n ˉ2 1234 D + n ˉ2 ON
S1 + n ˉ1 7890 D + n ˉ1 OFF

g S1 : When the compare source device is 32 bits (.D/.L)


bit
31
bit bit
16 15
bit
0
Compare Result
S1 +1 12345678 S1 D ON

S1 +3 56780123 S1 +2 D +1 OFF
bit bit bit bit
31 16 15 0

S1 +5 10002000 S1 +4 D +2 OFF
n S2 +1 12345678 S2

˄2 nǂWord˅
S1 +2˄ n ˉ2˅+1 12345678 S1 +2˄ n ˉ2˅ D + n ˉ2 ON
S1 +2˄ n ˉ1˅+1 78903456 S1 +2˄ n ˉ1˅ D + n ˉ1 OFF

8-34 - KV-5500/5000/3000/1000 Series Script Programming Manual -


For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

ƽ Example of format
R3000 = BCMPI (DM1000.U, DM1200, MR2000, 40)
CR2002 BCMPI
DM1000 DM1200 MR2000
Always ON
Compare source device Compare source device Result store device
#40

CR2010 R3000

EXTENDED FUNCTIONS
the operation result is zero

Note
When the value of n is 0, R turns ON.

Sample Program

ƽ When this function is used in combination with other functions 8


Programmed Script MR2000 = BCMPI (DM1000.D, RRNCA(MR1000.D, 16), MR3000, 24)

Data Processing Functions


Description of Operation The unsigned 24*32-bit BIN data blocks starting from DM1000.D are each compared with
the value resulting from having rotated (upper/lower words swapped) the unsigned 32-bit
BIN data currently in MR1000.D 16 bits to the right without a carry.
The compare result is in 16-bit data starting from MR3000.
If all of the data is matching as a result of the compare, MR2000 is turned ON. Otherwise,
MR2000 is turned OFF.
Ladder Conversion
CR2002 MR1000 #16 @VM0
LDA.D RRNCA.D STA.D
Normal ON Compare source device
BCMPI.D
DM1000 @VM0 MR3000
Compare source device Result store device
#24

CR2010 MR2000

The operation result is zero

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RRNCA function", Page 7-54

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-35


RND Generate random number

Random

Return value*1 ˙ RND (type of random number)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Type of Specifies the operation destination device of
random generated random number or the operation .U .U .U .U - - - - - ƻ ƻ
*2
number destination data.
*4
*3
R Return value .U type RND function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored instored in working
memory.
*2 When (R1002, R1005, etc.) other than initial channel of the bit device is specified for category of random
number (conversion destination device), jump the following channel can also exert normal function.
EXTENDED FUNCTIONS

*3 When the type other than .U is specified by return value, type conversion will be automatically conducted
during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
CPU unit.
8 "KV-5500/5000/3000 CPU Function Version", Page 2
g RND function is special function of KV-5500/5000/3000. CPU other than KV-1000 series
Data Processing Functions

cannot be used.

Description of Operation

S generates the category of random number (operation destination device) to random number
R .
The random number occurring is analog random number of 1- 65535. When S = 0, R stores 1
in return value.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instruction".

Note
g Random number generation algorithm shall use "M series".
g Due to periodicity of value generated from RND function (for example, 2 generated after
1), so, when category of S random number is not changed, the value of random
number generated will be not changed.

8-36 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM1000.U = RND (DM1000.U)
CR2002 #0
LDA.D
Always ON
MOV
DM1000 @VM0
Type of
random number
RND
@VM0

@VM0 DM1000
LDA STA

EXTENDED FUNCTIONS
Return value

Data Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-37


SORT Binary data sort

Sort

SORT ([execution condition,]*1 sorting order, data table leading device,


number of data items to sort)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the sorting order. (0: ascending, 1:
Sorting order .U .U .U .U - - - - ƻ ƻ ƻ
descending)
D Data table Specifies the leading device of the byte
*2 .U .S .D .L - - - - - ƻ -
leading device sequence to search for.
n Number of data
*3 Specifies the number of data items to sort. .U .U .U .U - - - - ƻ ƻ ƻ
items to sort
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
EXTENDED FUNCTIONS

*2 When a bit device is specified, n channel is occupied if the D type is .U/.S, and 2x n

channels are occupied if the type is .D/.L.


When a word device is specified, n word is occupied if the D type is .U/.S, and 2x n words
are occupied if the type is .D/.L.
*3 When a bit device is specified, 16 continuous bits are occupied. When a word device is specified, one
word is occupied.

Note
g The SORT function can be used only with KV STUDIO Ver. 6.00 or higher.
8 g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
Data Processing Functions

Description of Operation

The n number of binary data items to sort in the data table specified with D data table leading
device is sorted with the sorting order specified in S sorting order.
g When D : data table leading device is 16 bits (.U/.S)
When S =0 (sort in ascending order)
Before SORT function is executed After SORT function is executed
bit bit bit bit
15 0 15 0

D 123 3 D
D +1 15 15 D +1
D +2 84 21 D +2
3 84
1398 123
653 653
D + n −1 21 1398 D + n −1

8-38 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g When D : data table leading device is 32 bits (.D/.L)
When S =1 (sort in descending order)
bit Before SORT function bit bit After SORT function bit
31 is executed 0 31 is executed 0

D ・ D +1 12345 6665321 D ・ D +1

D +2・ D +3 2165 619987 D +2・ D +3

D +4・ D +5 8004 78261 D +4・ D +5

31 12345
619987 8004
6665321 2165
D +2(n−1)
・ D +2(n−1)+1 78261 31 D +2(n−1)
・ D +2(n−1)+1

Note
The SORT function sorts all data when the function is executed. Therefore, if a large value
is specified in n , the scan time may increase.

EXTENDED FUNCTIONS
If the effect onto the scan time needs to be adjusted, divide the data to be sorted into
several scans using the SORTN function.
"SORTN function", Page 8-40

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instructions".

ƽ Example of format
8
SORT (MR1000, EM0, DM2000.D, 100)

Data Processing Functions


MR1000 SORT.D
EM0 DM2000 #100

Execution condition Sorting Data table


order leading device

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-39


SORTN Binary data partition sort

Partition sort

˙ SORTN (sort control flag, sort order, number of comparison


*1
Return value
times, data table leading device, number of data items to sort)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Sort control
Controls the sorting process. - - - - - - .B - - ƻ -
flag
S2 Specifies the sorting order. (0: ascending, 1:
Sorting order .U .U .U .U - - - - ƻ ƻ ƻ
descending)
S3 Number of
Specifies the number of comparisons to be
comparison .U .U .U .U - - - - ƻ ƻ ƻ
*3 made in one scan. (1 to 65535)
times
D Data table
Specifies the leading device of the byte
leading .U .S .D .L - - - - - ƻ -
sequence to search for.
EXTENDED FUNCTIONS

*2
device
n Number of data
*3 Specifies the number of data items to sort. .U .U .U .U - - - - ƻ ƻ ƻ
items to sort
R This device turns OFF during sorting, and
Return value - - - - - - .B - - ƻ -
turns ON when sorting is completed.
*1 The return value can be omitted. When omitted, the bit information is stored in a work device.
*2 When a bit device is specified, n channel is occupied if the D type is .U/.S, and 2x n

channels are occupied if the type is .D/.L.


When a word device is specified, n word is occupied if the D type is .U/.S, and 2x n words
8 are occupied if the type is .D/.L.
*3 When a bit device is specified, 16 continuous bits are occupied. When a word device is specified, one
Data Processing Functions

word is occupied.

Note
g The SORTN function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The n number of binary data items to sort in the data table specified with D data table leading
device is sorted with the sorting order specified in S2 sorting order.
The number of comparisons made per scan is specified with S3 number of comparison times.

8-40 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Example
When D : data table leading device is 16 bits (.U/.S)
When S2 =0, S3 =3, n =12
After SORTN function is executed
Before SORTN function
(sort in ascending order)
is executed
bit bit bit bit
15 0 15 0

D 123 1 D
D +1 15 3 D +1
D +2 84 15 D +2
D +3 3 71 D +3
D +4 1398 84 D +4
D +5 914 88 D +5
D +6 71 123 D +6

EXTENDED FUNCTIONS
D +7 1 512 D +7
D +8 6219 914 D +8 Three comparisons are made
per scan, and the data is sorted
D +9 7003 1398 D +9
over multiple scans.
D +10 512 6219 D +10 R =ON is written when sorting
is completed.
D +11 88 7003 D +11

The SORTN function execution timing is shown below.

Scan

ON
8
SORTN function

Data Processing Functions


execution conditions OFF

S1 : ON

Sort control flag OFF

SORTN function Execution Execution

ON
R :Return value
OFF
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-1 Data Processing
Instructions".

ƽ Example of format
MR2000 = SORTN (MR1000, EM10, EM20, DM1000.D, 100)

CR2002 MOV
EM10 @VM0
Always ON Sorting order
MOV
EM20 @VM1
Number of
comparison times
MR1000 SORTN.D
@VM0 DM1000 #100 @VB00
Execution condition
Data table
leading device

@VB00 MR2000

Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-41


Table Processing Functions

FIFOW Write to FIFO table

Write FIFO

FIFOW ([execution condition,]*1 data store device, data table leading device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the data to
Data store Handled as same type
*2 write to the FIFO data block is currently as D .
- - - - ƻ ƻ
device
stored.
D Data table Specifies the leading device of the FIFO
.U .U .D .D .D - - - - ƻ -
leading device data table.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
EXTENDED FUNCTIONS

leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.

Description of Operation

When the execution condition is established (TRUE), the data (16-bit/32-bit) stored in S is written to the
end of the data block specified by the D .

8 ƽ About data table and data block


Table Processing Functions

The FIFOW and FIFOR instructions FIFO (First In First Out) process using a group of devices called a "data
table". The figure below shows the structure of a data table.
bit bit
15 0

D n Number of data: data that write to data block.

D +1 max Max. number of storage number: Max number that data block can store (specifyd by user).
Data table

D +2 A

D +3 B Data block: save data processed by LIFO.


ǂǂData
A ǂ Data that finally saved.
saved at first; C
:

D +n+1 C

g Before executing this function, reset (store "0") the number of data (n) to be stored in D . Also, set
the maximum number of stored data items to D +1.
g As the leading device D of the data table, specify the same device as leading device of the data
table for the corresponding FIFOR function.

8-42 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When the data store device is 16 bits (.U/.S)
g The data store destination becomes D +(n+2).
g 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 B D +3 n+1 B D +3


bit
15
S bit
0
C D +(n+1) C D +(n+1)
D Blank D +(n+2) D D +(n+2)

EXTENDED FUNCTIONS
Blank D +(n+3) Blank D +(n+3)

g S : When the data store device is 32 bits (.D/.L/.F)


g The data store destination becomes D +(2n+4)g D +(2n+5).
g n is incremented by 1 after storage.
bit bit
31 0

D +1 n D
D +3 max D +2

D +5 A D +4 8
n D +7 B D +6

Table Processing Functions


:

bit
31
S +1 S bit
0
D +(2n+3) C D +(2n+2)
D D +(2n+5) Blank D +(2n+4)
D +(2n+7) Blank D +(2n+6)

bit bit
31 0

D +1 n+1 D
D +3 max D +2

D +5 A D +4

D +7 B D +6

n+1 :

D +(2n+3) C D +(2n+2)
D +(2n+5) D D +(2n+4)
D +(2n+7) Blank D +(2n+6)

For details on operation flag changes,"About operation flag (CR2009 to CR2012)", Page 1-18.
For details, KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table Processing Instructions".

ƽ Example of format
FIFOW (R3000, DM1000, DM2000.U)

R3000 FIFOW
DM1000 DM2000
Execution conditon
Data store device FIFO data table

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-43


Note
The function is not executed when either of the following conditions is established:
g When maximum number of stored data is "0"
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to
exceed the device range

Sample Program

ƽ When an index register is used


EXTENDED FUNCTIONS

Programmed Script FIFOW (R3000, DM1000, DM2000: Z1)


Description of Operation When R3000 turns ON, the 16-bit data currently stored in DM1000 is written to the end of the
data block starting from DM (2000+Z1).
Ladder Conversion

R3000 FIFOW
DM1000 DM2000:Z1
Execution conditon
Data store device FIFO data table

8 Hint
Table Processing Functions

The "number of currently stored data" of the data table specified by the data table leading device is
saved to the leading device. Also, the "maximum number of stored data" is set to the leading +1 device.
Before the FIFOW function is used, the number of currently stored data must be reset ("0" stored), and
the maximum number of stored data must be set. (default)

Programmed Script
IF LDP(R3000) THEN 'The entire data table is cleared when
DM1000 = 0 'R3000 turns ON.
DM1001 = 10 'The maximum number of stored data is set
END IF 'to 10 when R3000 turns ON.
FIFOW (LDP (R3100), DM2000, DM1000) 'Write to the data block is performed when
R3100 turns ON.

Description of Operation When the up edge of R3000 (change from OFF to ON state) has been detected, the data
table having ten data blocks is initialized from the 16-bit data table leading device DM1000.
(A data table comprises the number of stored data, maximum number of stored data, and
data block, and is a total of 12 words.)
When the up edge of R3100 (change from OFF to ON state) has been detected, the 16-bit
data currently stored in DM2000 is written to the end of the data block.

Note
In a 32-bit data table, the number of stored data, maximum number of stored data, and data
block are all handled as 32-bit data. For this reason, attention is required to the data table
structure (number of required words).

When the data table is a 32-bit data table, single precision floating point type real number data also can
be used as the write data.

8-44 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-45


FIFOR Read from FIFO table

Read FIFO

FIFOR ([execution condition,] *1 data table leading device, data store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D1 Data table Specifies the leading device of the FIFO
*2 .U .U .D .D .D - - - - ƻ -
leading device data table.
D2 Data store Specifies the leading device to store data Handled as same type
*2
as D1 .
- - - - ƻ -
device that is read from the FIFO data block.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits straddling the next channel.
EXTENDED FUNCTIONS

Description of Operation

When the execution condition is established (TRUE), the leading data currently stored in data block specified
by the D1 is read, and is stored in D2 .
After the data is stored, the content of the data block is pushed forward by one data, and the number of
stored data is decremented (-1).

8
ƽ About data table and data block
Table Processing Functions

The FIFOW and FIFOR instructions FIFO (First In First Out) process using a group of devices called a "data
table." The figure below shows the structure of a data table.
bit bit
15 0

D n Number of data: data that write to data block.

D +1 max Max. number of storage number: Max number that data block can store (specifyd by user).
Data table

D +2 A

D +3 B Data block: save data processed by FIFO.


ǂǂData
A ǂ Data that finally saved.
saved at first; C
:

D +n+1 C

g D1 : When the data table leading device is 16 bits (.U/.S)


(1)When the execution condition is ON, the (2)After the data is stored, the content of the data block
16-bit data currently stored in D1 +2 is is pushed forward by one data item at a time.
stored in the device specified by D2 . n is then decremented (by -1) after the data is pushed.
bit bit bit bit
15 0 15 0

D1 n D1 n-1

D1 +1 max bit
15
D2 bit
0
D1 +1 max bit
15
D2 bit
0

D1 +2 A D1 +2 B A

D1 +3 B D1 +3 C

D1 +4 C
: D1 +n E

D1 +n D D1 +n+1 Blank(0) Store 0

D1 +n+1 E

8-46 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g D1 : When the data table leading device is 32 bits (.D/.L/.F)
(1)When the execution condition is ON, the 32-bit data currently stored in [ D1 +4• D1 +5] is stored
in device specified by [ D2 • D2 +1].
bit bit
31 0

D1 +1 n D1
D1 +3 max D1 +2 bit
31
D2 +1 D2 bit
0

D1 +5 A D1 +4
D1 +7 B D1 +6
D1 +9 C D1 +8

D1 +(2n+1) D D1 +(2n)

EXTENDED FUNCTIONS
D1 +(2n+3) E D1 +(2n+2)

(2)After the data is stored, the content of the data block is pushed forward by one data item at a time.
n is then decremented (by 1) after the data is pushed.
bit bit
31 0

D1 +1 n-1 D1
D1 +3 max D1 +2 bit
31
D2 +1 D2 bit
0

D1 +5 B D1 +4 A

D1 +7 C D1 +6 8

Table Processing Functions


D1 +(2n+1) E D1 +(2n)
D1 +(2n+3) Blank(0) D1 +(2n+2)

Store 0
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

ƽ Example of format
FIFOR (R3000 = OFF, DM2000.U, DM1000)
R3000 FIFOR
DM2000 DM1000
Execution conditon
FIFO data table Result store device

Note
The function is not executed when either of the following conditions is established:
g When there is no data in the data table
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to
exceed the device range

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-47


Sample Program

ƽ When an index register is used


Programmed Script FIFOR (R3000, DM1000.D, DM2000.D:Z1)
Description of Operation When R3000 is turned ON, the start 32-bit data currently stored in data block starting from
DM1000.D is read and stored in DM (2000+Z1).D.
Ladder Conversion

R3000 FIFOR.D
DM1000 DM2000:Z1
Execution conditon
FIFO data table Result store device

Hint
EXTENDED FUNCTIONS

The data at the start of the data block is read as the data to be read by the FIFOR function.

Programmed Script
FIFOW (LDP (R3100), DM2000, DM1000) 'Write to the data block is performed when
R3100 turns ON.
FIFOR (LDP (R3101), DM1000, DM2100) 'Read from the data block is performed
when R3101 turns ON.

Description of Operation When the up edge of R3100 (change from OFF to ON state) has been detected, the data
8 stored in DM2000 is written to the data block starting from DM1000.
When the up edge of R3101 (change from OFF to ON state) has been detected, data is read
Table Processing Functions

from the table block and stored in DM2100.


bit bit bit bit bit bit
15 0 15 0 15 0

DM1000 n n+1 n-1

DM1001 max max max

DM1002 A A B A

DM1003 B B

DM1000+n C C D Save to DM2100

DM1000+n+1 D D DM2000 data

DM2000 data

Execute FIFOW function Execute FIFOR function

8-48 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-49


LIFOW Write to LIFO table

Write LIFO

LIFOW ([execution condition,]*1 data store device, data table leading device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the data to
Data store Handled as same type
*2 write to the LIFO data block is currently as D .
- - - - ƻ ƻ
device
stored.
D Data table Specifies the leading device of the LIFO
.U .U .D .D .D - - - - ƻ -
leading device data table.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits straddling the next channel.
EXTENDED FUNCTIONS

Description of Operation

When the execution condition is established (TRUE), the data (16-bit/32-bit) stored in S is written
to the end of the data block specified by the D .

ƽ About data table and data block


8 The FIFOW and FIFOR instructions LIFO (Last In First Out) process using a group of devices called a "data table".
The figure below shows the structure of a data table.
Table Processing Functions

bit bit
15 0

D n Number of data: data that write to data block.

D +1 max Max. number of storage number: Max number that data block can store (specifyd by user).
Data table

D +2 A

D +3 B Data block: save data processed by LIFO


ǂData
A saved at first; C Data that finally saved
:

D +n+1 C

g Before executing this function, reset (store "0") the number of data (n) to be stored in D . Also, set the
maximum number of stored data items to D +1.
g As the leading device D of the data table, specify the same device as leading device of the data table for
the corresponding LIFOR function.

g S : When the data store device is 16 bits (.U/.S)


g The data store destination becomes D +(n+2)
g 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 B D +3 n+1 B D +3

bit
15
S bit
0
C D +(n+1) C D +(n+1)
D Blank D +(n+2) D D +(n+2)
Blank D +(n+3) Blank D +(n+3)

8-50 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g S : When the data store device is 32 bits (.D/.L/.F)
g The data store destination becomes D +(2n+4)g D +(2n+5).
g n is incremented by 1 after storage.
bit bit
31 0

D +1 n D
D +3 max D +2

D +5 A D +4

n D +7 B D +6
:

bit
31
S +1 S bit
0
D +(2n+3) C D +(2n+2)
D D +(2n+5) Blank D +(2n+4)

EXTENDED FUNCTIONS
D +(2n+7) Blank D +(2n+6)

bit bit
31 0

D +1 n+1 D
D +3 max D +2

D +5 A D +4

D +7 B D +6

n+1 :

D +(2n+3) C D +(2n+2) 8
D +(2n+5) D D +(2n+4)

Table Processing Functions


D +(2n+7) Blank D +(2n+6)
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

ƽ Example of format
LIFOW (R3000, DM1000, DM2000.U)

R3000 LIFOW
DM1000 DM2000
Execution conditon
Result store device LIFO data table

Note
The function is not executed when either of the following conditions is established:
g When maximum number of stored data is "0"
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to
exceed the device range

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-51


Sample Program

ƽ When an index register is used


Programmed Script LIFOW (R3000, DM1000: Z1, DM2000)
Description of Operation When R3000 turns ON, the 16-bit data currently stored in DM (1000+Z1) is written to the end
of the data block starting from DM2000.
Ladder Conversion
R3000 LIFOW
DM1000:Z1 DM2000
Execution conditon
Write data LIFO data table
EXTENDED FUNCTIONS

Hint

The data table used by the LIFOW function is in the same structure as the data table used by the
FIFOW function, and the same data tables can be used.
* For details, refer to the FIFOW function.
Also, the store method of the LIFOW and FIFOW functions when writing to data blocks is also the same.
Programmed Script LIFOW (DM1000, DM2000)
Description of Operation The 16-bit data currently stored in DM1000 is written to the end of the data block starting
8 from DM2000 at every scan (no execution condition).
Table Processing Functions

bit bit bit bit


15 0 15 0

DM2000 n n+1

DM2001 max max

DM2002 A A

DM2003 B B
: :

DM2000+n+1 C C
Add data in DM1000
D D
DM1000 data

Add data to FIFOW function in the same way

The same operation as the following Programmed Script is performed:


FIFOW (DM1000, DM2000)
"FIFOW function, Page 8-42

8-52 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-53


LIFOR Read from LIFO table

Read LIFO

LIFOR ([execution condition,] *1 data table leading device, data store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D1 Data table Specifies the leading device of the LIFO
*2 .U .U .D .D .D - - - - ƻ -
leading device data table.
D2 Data store Specifies the leading device to store data Handled as same type
*2
as D1 .
- - - - ƻ -
device that is read from the LIFO data block.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits straddling the next channel.
EXTENDED FUNCTIONS

Description of Operation

When the execution condition is established (TRUE), the final data currently stored in data block
specified by the D1 is read, and is stored in D2 .
After the data is stored, the content of the data block is pushed forward by one data, and the number of
stored data is decremented (-1).

8 ("0" is stored in last data section that is read.)


Table Processing Functions

ƽ About data table and data block


The LIFOW and LIFOR instructions LIFO (Last In First Out) process using a group of devices called a "data
table". The figure below shows the structure of a data table.
bit bit
15 0

D n Number of data: data that write to data block.

D +1 max Max. number of storage number: Max number that data block can store (specifyd by user).
Data table

D +2 A

D +3 B Data block: save data processed by LIFO


ǂData
A saved at first; C Data that finally saved
:

D +n+1 C

g D1 : When the data table leading device is 16 bits (.U/.S)


(1)When the execution condition is ON, the 16- (2)n is then decremented (by -1) after the
bit data currently stored in D1 +n+1 is data is stored.
stored in the device specified by D2 .
bit bit bit bit
15 0 15 0

D1 n D1 n-1

D1 +1 max D1 +1 max

D1 +2 A D1 +2 A

D1 +3 B D1 +3 B

D1 +n C bit
15
D2 bit
0
D1 +n C bit
15
D2 bit
0

D1 +n+1 D D1 +n+1 Blank(0) D

Store 0

8-54 - KV-5500/5000/3000/1000 Series Script Programming Manual -


g D1 : When the data table leading device is 32 bits (.D/.L/.F)
(1)When the execution condition is ON, the 32-bit data currently stored in [ D1 +(2n+2)/ D1 +
(2n+3)] is stored in device specified by [ D2 / D2 +1].
bit bit
31 0

D1 +1 n D1
D1 +3 max D1 +2
D1 +5 A D1 +4
D1 +7 B D1 +6

D1 +(2n+1) C D1 +(2n) bit


31
D2 +1 D2 bit
0

D1 +(2n+3) D D1 +(2n+2)

EXTENDED FUNCTIONS
(2)n is then decremented (by 1) after the data is stored.
bit bit
31 0

D1 +1 n-1 D1
D1 +3 max D1 +2
D1 +5 A D1 +4
D1 +7 B D1 +6

D1 +(2n+1)
D1 +(2n+3)
C
Blank(0)
D1 +(2n)
D1 +˄2n+2˅
bit
31
D2 +1
D
D2 bit
0
8

Table Processing Functions


Store 0

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

ƽ Example of format
LIFOR (R3000 = OFF, DM2000.U, DM1000)

R3000 LIFOR
DM2000 DM1000
Execution conditon
LIFO data table Data store device

Note
The function is not executed when either of the following conditions is established:
g When there is no data in the data table
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to
exceed the device range

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-55


Sample Program

ƽ When an index register is used


Programmed Script LIFOR (R3000, DM1000.D, DM2000.D: Z1)
Description of Operation When R3000 is turned ON, the final 32-bit data currently stored in data block starting from
DM1000.D is read and stored in DM (2000+Z1).D.
Ladder Conversion

R3000 LIFOR.D
DM1000 DM2000:Z1
Excute
condition table LIFO data table Data stroe device
EXTENDED FUNCTIONS

Hint

The data at the end of the data block is read as the data to be read by the LIFOR function.

Programmed Script
LIFOW (LDP (R3100), DM2000, DM1000) 'Write to the data block is performed when
R3100 turns ON.
LIFOR (LDP (R3101), DM1000, DM2100) 'Read from the data block is performed
when R3101 turns ON.
8 Description of Operation When the up edge of R3100 (change from OFF to ON state) has been detected, the data
stored in DM2000 is written to the data block starting from DM1000.
Table Processing Functions

When the up edge of R3101 (change from OFF to ON state) has been detected, data is read
from the table block and stored in DM2100.
bit bit bit bit bit bit
15 0 15 0 15 0

DM1000 n n+1 n-1

DM1001 max max max

DM1002 A A A

DM1003 B B B
Stored in DM2100

DM1000+n C C C

DM1000+n+1 D D D

DM2000 data (Clear) DM2000 data

Execute LIFOW function Execute LIFOR function

8-56 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-57


FWRIT Overwrite data table specified position

Overwrite data table

FWRIT([execution condition,] *1 data store device, data table leading device, write block position)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the data to
Data store Handled as same type
*2 overwrite is currently stored, or the overwrite as D .
- - - - ƻ ƻ
device
data.
D Data table Specifies the leading device of the data
*2 .U .U .D .D .D - - - - ƻ -
leading device table.
n Specifies the device to which the position of the data
Write block
block to overwrite is currently stored, or the overwrite .U .U .U .U - - - - ƻ ƻ ƻ
position
position.
R Return value None - - - - - - - - - - -
EXTENDED FUNCTIONS

*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.

Description of Operation

8 When the execution condition is established (TRUE),


n D
the data (16-bit/32-bit) stored in S is
overwritten at of the data block specified by .
Table Processing Functions

g S : When the data store device is 16 bits (.U/.S)


bit
15
S bit
0
bit
15
bit
0
bit
15
bit
0

E Number of data n D n D
Max. number of storage data max D +1 max D +1
1st A D +2 A D +2
Data list

1st B D +3 B D +3

Data block (for saving data)


n st C E

Nst D D +N+1 D D +N+1

g S : When the data store device is 32 bits (.D/.L/.F)


bit
31
S +1 S bit
0

bit bit bit bit


31 0 31 0

Number of data D +1 n D D +1 n D
Max. number of storage data D +3 max D +2 D +3 max D +2
1st D +5 A D +4 D +5 A D +4
Data block (for saving data)

1st D +7 B D +7 B
Data list

D +6 D +6

n st D +(2n+3) C D +(2n+2) D +(2n+3) E D +(2n+2)


Nst D +(2N+3) D D +(2N+2) D +(2N+3) D D +(2N+2)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

8-58 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
FWRIT (R3000, DM1000.U, DM2000, 5)
R3000 FWRIT
DM1000 DM2000 #5
Execution conditon
Data store device Data table

Note
The function is not executed when either of the following conditions is established:
g When the value of n is 0 or greater than number of data (N)
g When maximum number of stored data (max) is "0"
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to exceed the device range

EXTENDED FUNCTIONS
Sample Program

ƽ When an index register is used


Programmed Script FWRIT (R3000, DM1000:Z1, DM2000:Z2, DM2100)
Description of Operation When R3000 turns ON, the 16-bit data currently stored in DM (1000+Z1) is overwritten on the block
position indicated by DM2100 of the data block starting from DM (2000+Z2).
Ladder Conversion R3000

Execution conditon
FWRIT
DM1000:Z1 DM2000:Z2 DM2100 8
Write data Data table Change block position

Table Processing Functions


Hint

The FWRIT function can be used in either of the data tables used by the FIFOW function/FIFOR
function or the LIFOW function/LIFOR function.
Programmed Script FIFOW (EM5000, DM2000) 'Makes a FIFO table.
LIFOW (EM5100, DM3000) 'Makes a LIFO table.
FWRIT (DM1000, DM2000, 2) 'Overwrites a FIFO table.
FWRIT (DM1000, DM3000, 2) 'Overwrites a LIFO table.
Description of Operation The 16-bit data currently stored in DM1000 is overwritten on each of the second data blocks
of the FIFO data blocks starting from DM2000 and LIFO data blocks starting from DM3000 at
every scan (no execution condition).
bit bit bit bit
15 0 15 0

DM2000 n n DM3000

DM2001 max max DM3001

DM2002 A A DM3002

DM2003 B DM1000 data B DM3003


Overwrite data in DM1000


DM2000+n C C DM3000+n
DM2000+n+1 D D DM3000+n+1

Execute FIFOW function Execute LIFOW function


or FIFOR function or LIFOR function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-59


FINS Insert to data table specified position

Insert in data table

FINS([execution condition,]*1 data store device, data table leading device, insert block position)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Specifies the device to which the data to
Data store Handled as same type
*2 overwrite is currently stored, or the overwrite as D .
- - - - ƻ ƻ
device
data.
D Data table Specifies the leading device of the data
*2 .U .U .D .D .D - - - - ƻ -
leading device table.
n Specifies the device to which the position of the data
Insert block
block to insert is currently stored, or the insert .U .U .U .U - - - - ƻ ƻ ƻ
position
position.
R Return value None - - - - - - - - - - -
EXTENDED FUNCTIONS

*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits
straddling the next channel.

Description of Operation

8 When the execution condition is established (TRUE), the data (16-bit/32-bit) stored in
n D
S is inserted
at of the data block specified by .
Table Processing Functions

g S : When the data store device is 16 bits (.U/.S)


bit
15
S bit
0
bit
15
bit
0
bit
15
bit
0

E Number of data n D n+1 D


Max. number of storage data max D +1 max D +1
1st A D +2 A D +2
Data table

2st B D +3 B D +3

Data block (for saving data)


n st C C

E

Nst D D +N+1

D D +(N+1)+1

g S : When the data store device is 32 bits (.D/.L/.F)


bit
31
S +1 S bit
0

bit bit bit bit


31 0 31 0

Number of data D +1 n D D +1 n+1 D


Max. number of storage data D +3 max D +2 D +3 max D +2
1st D +5 A D +4 D +5 A D +4
Data table
Data block (for saving data)

2st D +7 B D +6 D +7 B D +6

n st D +(2n+3) C D +(2n+2) D +(2n+3) C D +(2n+2)


D +(2n+5) E D +(2n+4)

Nst D +(2N+3) D D +(2N+2)


D +(2N+5) D D +(2N+4)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

8-60 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
FINS (R3000, DM1000.U, DM2000, 4)
R3000 FINS
DM1000 DM2000 #4
Execution conditon
Data store device Data table

Note
The function is not executed when either of the following conditions is established:
g When the value of n is 0 or greater than number of data (N)
g When maximum number of stored data (max) is "0"
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to exceed the device range

EXTENDED FUNCTIONS
Sample Program

ƽ When an index register is used


Programmed Script FINS (R3000, DM1000:Z1, DM2000:Z2, DM2100)
Description of Operation When R3000 turns ON, the 16-bit data currently stored in DM (1000+Z1) is inserted at the block
position indicated by DM2100 of the data block starting from DM (2000+Z2).
Ladder Conversion
R3000

Execution conditon
FINS
DM1000:Z1 DM2000:Z2 DM2100 8
Data saving device Data table Insert position

Table Processing Functions


Hint

The FINS function can be used in either of the data tables used by the FIFOW function/FIFOR function
or the LIFOW function/LIFOR function.
Programmed Script FIFOW (EM5000, DM2000) 'Makes a FIFO table.
LIFOW (EM5100, DM3000) 'Makes a LIFO table.
FINS (DM1000, DM2000, 2) 'Inserts in the FIFO table.
FINS (DM1000, DM3000, 2) 'Inserts in the LIFO table.
Description of Operation The 16-bit data currently stored in DM1000 is inserted at each of the 2nd data blocks of the
FIFO data blocks starting from DM2000 and the LIFO data blocks starting from DM3000 at
every scan (no execution condition).
bit bit bit bit
15 0 15 0

DM2000 n n DM3000

DM2001 max max DM3001

DM2002 A A DM3002
DM1000 data DM1000 data DM1000 data

DM2003 B Insert data in DM1000 B DM3003


DM2000+n C C DM3000+n

DM2000+n+1 D D DM3000+n+1

Execute FIFOW function or FIFOR function Execute LIFOW function or LIFOR function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-61


FDEL Delete data table specified position

Delete data table

FDEL([execution condition,]*1 data table leading device, delete block position)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Data table Specifies the leading device of the data
*2 .U .U .D .D .D - - - - ƻ -
leading device table.
n Specifies the device to which the position of the data
Delete block
block to delete is currently stored, or the delete .U .U .U .U - - - - ƻ ƻ ƻ
position
position.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When a bit device has been specified, 16/32 continuous bits are handled. When a relay other than the leading relay (e.g.
EXTENDED FUNCTIONS

R002 or R1012) of the channel has been specified, the relay is handled in 16/32 bits straddling the next channel.

Description of Operation

When the execution condition is established (TRUE), the data at n of the data block specified by the
D is deleted.
After the data is deleted, the content of the data block is pushed forward by one data, and the number
of stored data is decremented (-1).
8
Table Processing Functions

g D : When the data table leading device is 16 bits (.U/.S)


bit bit bit bit
15 0 15 0

Number of data N D Nˉ1 D


Max. number of storage data max D +1 max D +1
1st A D +2 A D +2
Data table

2st B D +3 B D +3

Data block
(for saving data) n st C D D +N

0 D +N+

Nst D D +N+1 Store 0.

g D : When the data table leading device is 32 bits (.D/.L/.F)


bit bit bit bit
31 0 31 0

Number of data D +1 N D D +1 Nˉ1 D


Max. number of storage data D +3 max D +2 D +3 max D +2
Data block (for saving data)

1st D +5 A D +4 D +5 A D +4
Data table

2st D +7 B D +6 D +7 B D +6

n st D +(2n+1) C D +(2n) D +(2N+1) D D +(2N)


D +(2N+3) 0 D +(2N+2
Nst D +(2N+3) D D +(2N+2) Store 0

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-2 Table
Processing Instruction".

ƽ Example of format
FDEL (R3000, DM2000.U, 3)
R3000 FDEL
DM2000 #3
Execution conditon
Data table
8-62 - KV-5500/5000/3000/1000 Series Script Programming Manual -
Note
The function is not executed when either of the following conditions is established:
g When the value of n is 0 or greater than number of data (N)
g When maximum number of stored data (max) is "0"
g When the number of data exceeds the maximum number of stored data
g When the maximum number of stored data is a number that causes the data table to
exceed the device range

Sample Program

ƽ When an index register is used

EXTENDED FUNCTIONS
Programmed Script FDEL (R3000, DM2000:Z1, DM2100)
Description of Operation When R3000 turns ON, the data at the block position indicated by DM2100 of the data block
starting from DM (2000+Z1) is deleted.
Ladder Conversion
R3000 FDEL
DM2000:Z1 DM2100
Execution conditon
Data table Delete
block position

8
Hint

Table Processing Functions


The FDEL function can be used in either of the data tables used by the FIFOW function/FIFOR function
or the LIFOW function/LIFOR function.
Programmed Script FIFOW (EM5000, DM2000) 'Makes a FIFO table.
LIFOW (EM5100, DM3000) 'Makes a LIFO table.
FDEL (DM2000, 2) 'Delete from FIFO table.
FDEL (DM3000, 2) 'Delete from LIFO table.
Description of Operation During every scanning (no execution condition), the data stored in the 2nd data block of DM 2
000 FIFO data block, and the 2nd data block of DM3000 LIFO data block will be deleted once.
bit bit bit bit
15 0 15 0

DM2000 n n+1 DM3000

DM2001 max max DM3001

DM2002 A A DM3002

B B

DM2003 C Delete 2nd data (data B) C DM3003


DM2000+n D D DM3000+n

DM2000+n+1 E E DM3000+n+1

Execute FIFOW function or FIFOR function Execute LIFOW function or LIFOR function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-63


Time Processing Functions

WTIME Write time data to calendar timer

Write time

WTIME([execution condition,] *1 Year, Month, Day, Hours, Minutes, Seconds,)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Year data (0 to 99) .U .U .U .U - - - - ƻ ƻ ƻ
S2 Month data (1 to 12) .U .U .U .U - - - - ƻ ƻ ƻ
S3 Day data (1 to 31) .U .U .U .U - - - - ƻ ƻ ƻ
S4 Time setting device Hour data (0 to 23) .U .U .U .U - - - - ƻ ƻ ƻ
S5 Minute data (0 to 59) .U .U .U .U - - - - ƻ ƻ ƻ
S6 Second data (0 to 59) .U .U .U .U - - - - ƻ ƻ ƻ
S7 Day of week data (0 to 6) .U .U .U .U - - - - ƻ ƻ ƻ
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
EXTENDED FUNCTIONS

times (at every scan).)

When word data has been specified to S1 to S7 , it is handled entirely as unsigned16-


bit data. (The specified suffix is ignored).

Description of Operation

8 When the execution condition is established (TRUE), the time data currently stored in
is written to the built-in calendar timer.
S1 to S7
Time Processing Functions

Time setting device bit


15
bit
0

S1 Year 0 to 99 Year indicates solar calendar 2000 ‘s last 2 digits.

S2 Month 1 to 12

S3 Day 1 to 31

S4 Hour 0 to 23 Data are all expressed as 16-bit binary format.

S5 Minute 0 to 59

S6 Second 0 to 59 Week designation are as follows.


0: (Sunday)ǃ1: (Monday)ǃ2: (Tuesday)ǃ
S7 Day of week 0 to 6 3: (Wednesday)ǃ4: (Thursday)ǃ5: (Friday)ǃ6: (Saturday)

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-3 Clock
Processing Instruction".

8-64 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
WTIME (R3000, 04, 06, 07, 22, 38, 43, 5)
R3000 MOV
#4 @VM0
Execution conditon
MOV
#6 @VM1

MOV
#7 @VM2

MOV
#22 @VM3

MOV

EXTENDED FUNCTIONS
#38 @VM4

MOV
#43 @VM5

MOV
#5 @VM6

@VMO
WTIME
Time setting device
8

Time Processing Functions


Note
g The time data cannot be written independently and directly to control memories.
g When the WTIME function is used, specify the time data in the correct format (year/
month/day/hours/minutes/seconds).
The day of the week is not checked for the year, month, day, hour, minutes, and seconds
settings.
g When the data to write is in the inappropriate format as the time data, the WTIME function
is not executed.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-65


SEC Convert date/time format data to second format data

Date/timeėseconds conversion

Return value
*1
= SEC (conversion source device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion
Specifies the leading device to which the
source .U .U .U .U .F - - - - ƻ -
*2 conversion source date/time is stored.
device*3
*5
*4
R Return value .D type SEC function available .U .S .D .L .F .DF - - - ƻ -

*1 The return value can be omitted. When omitted, the operation result is stored in a work device/a work memory.
*2 When a bit device has been specified, continuous 96 bits are handled as the date/time data and
continuous 32 bits are handled as the second data. A relay other than the leading relay (e.g. R002 or
R1012) of the channel can be specified.
EXTENDED FUNCTIONS

*3 T, C, CTC, CTH, Z cannot be used.


*4 When the type other than .D is specified by return value, type conversion will be automatically conducted
during conversion.
*5 The ".DF" suffix cannot be specified for device Z.

Note
g The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and higher
versions.
g The argument ".DF" can be specified only with the CPU function version 2.0 or higher
8 CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2
Time Processing Functions

Description of Operation

The six words (96 bits) of date/time data currently stored starting from S are converted to a total number
of seconds referenced to year 2000, January 1st, 0:0:0 (hours: minutes: seconds), and stored in R as
32-bit BIN data (unsigned).

Conversion source device bit


15
bit
0
bit
31
D +1 bit bit
16 15
D bit
0

S Year 0 to 99 Second conversion Second

S +1 month 1 to 12 2 words (32 bits)

S +2 day 1 to 31 Unsigned 32-bit BIN data


S +3 hour 0 to 23

S +4 minute 0 to 59

S +5 second 0 to 59

Year indicates solar calendar 2000 ‘s last 2 digits.

Date/time data is specified entirely as 16-bit BIN data, and can be used as both unsigned and signed.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-3 Clock Processing
Instruction".

8-66 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DM2000.D = SEC (DM1000.U)
CR2002 MOV.D
#0 @VM0
Normal ON
SEC
DM1000 @VM0
Conversion source device
MOV.D
@VM0 DM2000

store device

Note
When either of the following conditions is established, 0 is stored in R :

EXTENDED FUNCTIONS
g When the date/time data to convert is in an inappropriate format
g When a timer/counter is specified to S and R by indirect specification

Sample Program

ƽ When this function is used in combination with other functions


RSEC (TOL (SEC (CM0700)) + 864000, DM2000)
Programmed Script

Description of Operation The date/time ten days from the current date/time is calculated.
8
The current date/time (2000, January 1st, 0:0:0 (hours: minutes: seconds) data currently

Time Processing Functions


stored starting from CR0700 is converted to a total number of seconds from the reference
date/time.
The total number of seconds ten days after obtained by adding 864000 seconds (ten days)
to the total number of seconds of the conversion result is reverse-calculated to date/time
data, and stored in six words from DM2000.
Ladder Conversion
CR2002 MOV.D
#0 @VM0
Normal ON
SEC
CM700 @VM0
calendar timer (Year)
CR2002 @VM0 +864000 @VM2
LDA.L ADD.L STA.L
Normal ON
RSEC
@VM2 DM2000

Conversion data store device

Note that this function sometimes cannot be used depending on the argument of the function
it is combined with.
"RSEC function", Page 8-68"

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-67


RSEC Convert second format data to date/time format data

SecondsėDate/time conversion

RSEC([execution condition,]*1 conversion source device, conversion destination device)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Conversion Specifies the device to which the conversion
source source seconds (total number of seconds) is - - .D .D - - - - - ƻ ƻ
*2
device*3 currently stored.
D Conversiondata
Specifies the leading device to which the
destination .U .U .U .U - - - - - ƻ -
*2 converted date/time is to be stored.
device*3
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).˅
EXTENDED FUNCTIONS

*2 When a bit device has been specified, continuous 96 bits are handled as the date/time data and
continuous 32 bits are handled as the second data. A relay other than the leading relay (e.g. R002 or
R1012) of the channel can be specified.
*3 Timer devices and counter devices cannot be used.

Description of Operation

The total number of seconds (32-bit BIN data (unsigned)) referenced to "year 2000, January 1st, 0:0:0" and
8 specified by the S is converted to date/time data, and is stored in six words (96 bits) starting from the
device specified by the D .
Time Processing Functions

bit
31
S +1 bit bit
16 15
S bit
0
bit
15
bit
0

Second Second conversion year D (0 to 99)


2 words (32 bits) month (1 to 12)
D +1
day D +2 (1 to 31)

hour D +3 (0 to 23)

Minute D +4 (0 to 59)

Second D +5 (0 to 59)

The date/time data is stored entirely as 16-bit BIN data.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-3 Clock
Processing Instruction".

ƽ Example of format
RSEC (DM1000.D, DM2000)
CR2002 RSEC
DM1000 DM2000
Always ON
Conversion source device Store device

Note
The function is not executed when either of the following conditions is established:
g When the second data to convert is in an inappropriate format
g When a timer/counter is specified to S and D by indirect specification

8-68 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Sample Program

ƽ When this function is used in combination with other functions


Programmed Script RSEC (TOL (SEC (CM0700)) - 259200, DM2000)
Description of Operation The date/time three days from the current date/time is calculated.
The current date/time (2000, January 1st, 0:0:0 (hours: minutes: seconds) data currently
stored starting from CR0700 is converted to a total number of seconds from the reference
date/time.
The total number of seconds three days after obtained by subtracting 259200 seconds (three
days) to the total number of seconds of the conversion result is reverse-calculated to date/
time data, and stored in six words from DM2000.
Ladder Conversion
CR2002

EXTENDED FUNCTIONS
MOV.D
#0 @VM0
Always ON
SEC
CM700 @VM0
calendar timer (Year)
CR2002 @VM0 +259200 @VM2
LDA.L SUB.L STA.L
Always ON
RSEC
@VM2 DM2000
Conversion
data store device
Note that this function sometimes cannot be used depending on the argument of the function
8

Time Processing Functions


it is combined with.
"SEC function", Page 8-66"

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-69


AJST Calendar timer adjustment

Adjust

AJST([execution condition,]*1 ˅
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .B .DF .T #/$
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)

Description of Operation

When the execution condition is established (TRUE), the "seconds" of the current time according to the
built-in calendar timer is set to "0" when it is 0 to 29, or "minutes" is incremented by one digit and
"seconds" is set to "0" when "seconds is 30 to 59 to adjust the timer to the nearest minute unit ("0"
EXTENDED FUNCTIONS

seconds).
Before execution After execution
12 hours, 59 minutes, 15 seconds ė 12 hours, 59 minutes, 00 seconds
12 hours, 59 minutes, 30 seconds ė 13 hours, 00 minutes, 00 seconds
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-3 Clock
Processing Instruction".

8 ƽ Example of format
AJST (R3000)
Time Processing Functions

R3000
AJST
Execution conditon

When the execution condition is omitted, the script becomes as follows:

Programmed Script
AJST ( ) 'Execution condition omitted
Ladder Conversion
CR2002
AJST
Always ON

8-70 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Time Processing Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-71


High-speed Processing Functions

DI Disable interrupt

EI Enable interrupt

Disable interrupt

DI ([execution condition]*1 )
Enable interrupt

EI ([execution condition]*1 )
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)

Description of Operation
EXTENDED FUNCTIONS

The DI function disables execution of the interrupt program when the execution condition is established (TRUE).
The EI function enables execution of the interrupt program when the execution condition is established (TRUE).
Execution of interrupt programs temporarily disabled by the DIfunction are enabled (disable canceled)
by the EI function.
g Once the EI function is executed, interrupts up to execution of the DI function are enabled.
g Interrupts are disabled at all times when operation is started.
g Interrupts up to a nesting level of 16 can be stored if they occur during execution of the DI function
8 (interrupts are disabled).
When the EI function is executed, interrupts stored in memory are executed.
High-speed Processing Functions

g To execute another interrupt program while an interrupt program is being executed, execute the EI function in
the interrupt program. The sequence program accepts nesting of interrupt programs up to a nesting level of 16.
For details on interrupt processing, KV-5500/5000/3000/1000 Instruction Reference Manual, “INT/RETI
Instruction".
For details, KV-5500/5000/3000/1000 Instruction Reference Manual, "5-7 High-speed Processing Instruction".

ƽ Example of format
DI (R3000)
R3000
DI
Execution conditon

EI (R3000 = OFF)
R3000
EI
Execution conditon

Note
When the EI function is executed once in an interrupt disabled state at the start of operation,
interrupts are enabled until the DI function is executed.

When the interrupt program is executed, other interrupts are disabled until execution of that
interrupt program ends. To enable other interrupts, the EI function must be executed during
execution of the interrupt program. When the EI function is executed, the interrupt program
having the higher priority than the executed interrupt cause can be enabled (nested
interrupt). Note, however, that interrupts by the same interrupt cause cannot be programmed.

8-72 - KV-5500/5000/3000/1000 Series Script Programming Manual -


RFSCTH High-speed Counter refresh
High-speed Counter refresh

RFSCTH ([Execution condition,] *1High-speed counter No.)

Argument/Return Recognized Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S High-speed Specifies the high-speed counter No.. (0 or
.U .U .U .U - - - - *2 -
counter No. 1) ƻ ƻ
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 High-speed counter No., specifies 0 or 1.

Note
g RFSCTH function is special function of KV-5500/5000/3000. CPU other than KV-1000

EXTENDED FUNCTIONS
series cannot be used.

Description of Operation

When the execution condition is established (TRUE),change the current value of CTH specified by
S high-speed counter no. to the latest value.
At the same time, the CR (control relay) of CTH overflow and change method shall be also changed to
the latest status. 8
High-speed Control relay tobe refresh

High-speed Processing Functions


counter Overflow Change method
CTH0 CR2403 CR2412
CTH1 CR2407 CR2413

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-7 Text
Processing Instruction".

ƽ Example of format
RFSCTH(MR1000, 1)
MR1000 RFSCTH
#1
Execution conditon

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-73


DIC Set interrupt disabled range

Disable interrupt

DIC ([execution condition,]*1 interrupt state store device)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D Specifies the device to store the interrupt
Interrupt state
*2 disabled state before instruction execution - - - - - - .B - - ƻ -
store device
to.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 When the interrupt state store device is a word device, only the LSB is targeted for storing the interrupt
state. (Bits other than the LSB do not change.)
EXTENDED FUNCTIONS

Description of Operation

The DIC function disables execution of the interrupt program when the execution condition is
established (TRUE).
At the same time, D is set if the state before function execution is an interrupt enabled state, and
is reset if the state before function execution is an interrupt disabled state.

8 The interrupt state before execution of the interrupt program is disabled is stored in the
interrupt state store device. For this reason, use this function in combination with the EI
High-speed Processing Functions

function (enable interrupt) to nest interrupts.

Status for interrupt forbidden Status for allow interrupt

MR1000 D MR1000 D
DIC DIC
Execution conditon Execution conditon

Forbid constant Forbid constant

D D
EI EI

OFF ON
Status for interrupt forbidden Status for allow interrupt

Interrupt factor occur

Output Input Output Input


Interrupt forbidden range
process process process process

Input
Interrupt program
process

For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-7 Text
Processing Instruction".

8-74 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
DIC (R3000, R2000)
R3000 R2000
DIC
Execution conditon Interrupt status store

Sample Program

ƽ Example of use
Programmed Script DIC (R2000)

EXTENDED FUNCTIONS
FOR DM1000 = 0 TO 10
DM2000.L = DM2000 + DM1000
NEXT
EI (R2000)
Description of Operation Execution of the interrupt program in the specified range is disabled at every scan (no
execution condition). If the state before execution of the DIC function is the enabled state,
R2000 is set, and if it is interrupt disabled, R2000 is reset.
When R2000 is ON (state before execution of interrupt processing is an interrupt enabled
state), execution of the interrupt program by the EI function and below is enabled.
8

High-speed Processing Functions


Ladder Conversion
CR2002 R2000
DIC
Always ON Interrupt status storage

CR2002 MOV
#0 DM1000
Always ON
Conversion source device Distination device
LABEL
#2000

DM1000 CJ
> #2001
#10
CR2002 DM1000 @VM0 DM2000 @VM0 DM2000
Interrupt forbidden range LDA EXT STA.L LDA EXT ADD.L STA.L
Always ON
CR2002 DM1000
INC
Always ON
CR2009 CJ
#2000
Result of operation is minus
LABEL
#2001
R2000
EI
Interrupt status storage

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-75


PID Function

PIDAT PID control with automatic tuning

PID control with AT

PIDAT ([execution condition,] measured value, parameter, manipulated value)


*1

Argument/Return Recognized Type Const


Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Measured Specifies the value measured form the
.S .S .S .S - - - - - ƻ ƻ
value control target.
D1 *2 Specifies the leading device storing the
Parameter .U .U .U .U - - - - - ƻ -
parameter.
D2 Manipulated Specifies the device storing the PID
.S .S .S .S - - - - - ƻ -
value operation results.
R Return value None - - - - - - .B - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
EXTENDED FUNCTIONS

*2 The D1 parameter occupies 51 continuous words. Refer to the explanation of the PIDAT instruction
code for details on the parameter.

Note
g The PIDAT function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

8 Description of Operation
PID Function

The D2 manipulated value (PID operation results) are retrieved from the S measured value and
D1 parameter. At the first call, (when executing initialization), the execution conditions are turned
ON and the D1 parameter work area is cleared to zero before calling the PIDAT function.
When continuing operations, the execution conditions remain ON, and the PIDAT function is called out.
After the PIDAT function is called after the execution conditions have turned OFF and ON,
the initialization process will be executed.
Refer to "PIDAT instruction" of the "KV-5500/5000/3000/1000 Instruction Reference Manual" for details on the
operation flags and D1 parameter.

ƽ Example of format
PIDAT (DM1000, EM1000, DM2000)
CR2002 PIDAT
DM1000 EM1000 DM2000
Always ON Measured Parameter Manipulated
value leading device value

8-76 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

PID Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-77


Log Function

LOGE Enable logging of specified ID

LOGD Disable logging of specified ID

Enable logging

LOGE ([execution condition,]*1 logging ID)


Disable logging

LOGD ([execution condition,]*1 logging ID)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device that stores the logging
n Logging ID ID for enabling/disabling logging, or the .U .U .U .U - - - - *2
ƻ ƻ ƻ
logging ID. (0 to 9)
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
EXTENDED FUNCTIONS

*2 Cannot be specified by "$".

Description of Operation

The LOGE function enables execution of logging by the logging ID specified by the n when the
execution condition is established (TRUE). After the function is executed, the logging execution relay of
each logging ID is set.

8 The LOGD function disables execution of logging by the logging ID specified by the
execution condition is established (TRUE). After the function is executed, the logging execution relay of
n when the
Log Function

each logging ID is reset.


Logging ID Logging execution relay
0 CR0000
1 CR0100
2 CR0200
3 CR0300
4 CR0400
5 CR0500
6 CR0600
7 CR0700
8 CR0800
9 CR0900

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-12 Logging
Instruction".

ƽ Example of format
LOGE ( R3000, DM1000 )
R3000 DM1000
LOGE
Execution conditon Logging ID

Note
When a device is specified to n and 10 or more has been set, the function is not
executed.

8-78 - KV-5500/5000/3000/1000 Series Script Programming Manual -


TRGD Acquire Logging data

Acquire Logging data

TRGD (˷execution condition,˹*1 logging ID)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
n Logging ID Specifies the logging ID.˄0 to 10˅
*2
.U .U .U .U - - - - ƻ ƻ ƻ
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all
times (at every scan).)
*2 Please specify the logging ID as 0-10. Please specify the logging ID as 10
when instruction trigger is used on real-time curve monitor.

Note
TRGD function is special function of KV-5500/5000/3000. CPU other than KV-1000 series

EXTENDED FUNCTIONS
cannot be used.

Description of Operation

When the execution condition is established (TRUE), acquiring logging ID data is specified by the
n logging ID.
Under general condition, data is acquired by log, trace, real-time curve monitor via END processing
timing. Using TRGD command, can acquire data via any timing of Ladder.
8

Log Function
Note
• Only up to eight TRGD functions (instructions) can be used per ID in one project.
• To acquire data using TRGD function (instruction), it is necessary to set trigger category
to "instruction trigger " via log, trace, real-time curve monitor setting of KV STUDIO. If it is
not set to "instruction trigger", even if TRGD function (instruction) is executed, data
cannot be acquired.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-12 Logging
Instruction".

ƽ Example of format
TRGD (MR1000, 1)
MR1000 #1
TRGD
Execution conditon

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-79


Memory Card Functions

MWRIT Write to Memory Card

Write to Memory card

Return value
*1
= MWRIT (file name, save data store device,
number of save data store device, save format store device, save result store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device to which the file name for
saving the data is currently stored, or the save file
*7
S1 Save file name name. (A text string in the range 1 to 247 - - - - - - - .T *3
ƻ ƻ ƻ
characters (including end code NUL and folder
name) is specified.)
S2 Save data store Specifies the leading device to which the data
*4 .U .U .U .U - - - - - ƻ -
device*5 to save is currently stored.
n Number of save Specifies the device currently storing the
data store number of data in the range to save, or the .U .U .U .U - - - - - ƻ ƻ
EXTENDED FUNCTIONS

device number of save data.


D1 Specifies the leading device to store save
Save formatstore
*5 format-related parameters and the save state of .U .U .U .U - - - - - ƻ -
device*6
the data.
D2 Save result Specifies the bit device for notifying the save
*2 - - - - - - .B - - ƻ -
store device result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 When a bit device has been specified to the save result store device, continuous two bits are used as the notification bit.
8 When a word device has been specified, each of the LSBs of continuous two words is used as the notification bit device.
*3 To specify a text string using constants, enclose with " ".
Memory Card Functions

*4 When saving index register Z and digital trimmer values set in the access window, copy the data once to
a data memory DM, for example, and then set that data memory DM.
*5 For bit devices, specify the leading device of the channel.
*6 When a bit device has been specified to D1 , 96 continuous bits are occupied. When a word device
has been specified, six continuous words are occupied.
*7 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation

n data is stored in Memory Card starting from S2 by the file name (text string) specified by the
S1 .
Write processing is performed according to the write parameters specified by the D1 , and the write completion
notification and abnormal end alarm notification are stored in D2 .
When the MWRIT function is successfully started up, the R is turned ON. If startup failed, the
return value is turned OFF.
For details on parameters relating to the save format that is stored in D1 , KV-5500/5000/3000/1000
Instruction Reference Manual "MWRIT Instruction".

The following table shows the meanings of the notification bit of the D2 .
(Example) When MR2000 has been specified
Notification Bit ON (1, TRUE) OFF (0, FALSE)
MR2000 Completion notification Completed Not completed
MR2001 Error notification Normal end Abnormal end

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-80 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MWRIT ( DM5000.T, DM1000.U, DM1100.U, DM1200.U, MR2000 )
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MWRIT

EXTENDED FUNCTIONS
DM5000 DM1000 DM1100
Save file name Save data Number of

DM1200 MR2000 saving data

@VB00 @VB00
SET

NEXT

LABEL

@VB01
#2000
8
MR1100

Memory Card Functions


Note
The function is not executed when either of the following conditions is established:
g When the text string specified by S1 does not contain the end code (NUL (00H))
g When the text string specified by S1 exceeds 247 characters (including end code
“NUL (00H)")
g When a timer/counter is specified to S1 by indirect specification
g When a device other than the leading device of the channel is specified when a bit
device is specified to S1 , S2 and D1
g When a value outside of the range is specified to an argument
g When a value is specified for reservation of an argument

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-81


MREAD Read from Memory Card

Read from Memory Card

Return value
*1
= MREAD (read file name, read data store device,
number of read data, read format store device, read result store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device to which the file name for
reading the data is currently stored, or the read file
*4
S Readfile name*7 name. (A text string in the range 1 to 247 - - - - - - - .T *3
ƻ ƻ ƻ
characters (including end code NUL and folder
name) is specified.)
D1 Read data store Specifies the leading device to which the read
*4 .U .U .U .U - - - - - ƻ -
device data is to be stored.
n Specifies the device currently storing the
Number of read
*5 number of data in the range to read, or the .U .U .U .U - - - - ƻ ƻ ƻ
data
EXTENDED FUNCTIONS

number of read data.


D2 Specifies the leading device to store read
Read formatstore
*6 format-related parameters and the read state of .U .U .U .U - - - - - ƻ -
device
the data.
D3 Read result Specifies the bit device for notifying the read
*2 - - - - - - .B - - ƻ -
store device*4 result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 When a bit device has been specified to the read result store device, continuous two bits are used as the notification bit.
8 When a word device has been specified, each of the LSBs of continuous two words is used as the notification bit device.
*3 To specify a text string using constants, enclose with " " ".
Memory Card Functions

*4 For bit devices, specify the leading device of the channel.


*5 When reading ASCII text string data, specify the maximum number of characters (number of bytes) in the text string.
*6 When a bit device has been specified to D2 , 96 continuous bits are occupied. When a word device
has been specified, six continuous words are occupied.
*7 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation

The data of the file name (text string) specified by the S is read from the Memory Card and stored
in the range specified by n starting from D1 .
Read processing is performed according to the read parameters specified by the D2 , and the read completion
notification and abnormal end alarm notification are stored in D3 .
When the MREAD function is successfully started up, the R is turned ON. If startup failed, the
return value is turned OFF.
For details on parameters relating to the read format that is stored in D2 , KV-5500/5000/3000/1000
Instruction Reference Manual "READ Instruction".

The following table shows the meanings of the notification bit of the D3 .
(Example) When MR2000 has been specified
Notification Bit ON OFF
MR2000 Completion notification Completed Not completed
MR2001 Error notification Normal end Abnormal end
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-82 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MREAD ( DM5000.T, DM1000.U, DM1100.U, DM1200.U, MR2000 )
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MREAD

EXTENDED FUNCTIONS
DM5000 DM1000 DM1100
Read file name Read data Number of
saving data
DM1200 MR2000

@VB00 @VB00
SET

NEXT

LABEL

@VB01
#2000
8
MR1100

Memory Card Functions


Note
The function is not executed when either of the following conditions is established:
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string specified by S exceeds 247 characters (including end code
“NUL (00H)")
g When a timer/counter is specified to S by indirect specification
g When a device other than the leading device of the channel is specified when a bit
device is specified to S , D1 and D2
g When a value outside of the range is specified to an argument
g When a value is specified for reservation of an argument

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-83


MFREE Get memory card free space in byte unit

Get Memory Card free space

Return value
*1
= MFREE (free space store device, get result store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D1 Specifies the device to store the free space
Free space
*2 (byte units) got from the Memory Card to. - - .D .D - - - - - ƻ -
store device
(32-bit data device)
D2 Get result store Specifies the bit device for notifying the free
*3 - - - - - - .B - - ƻ -
device space get result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device/relay.
*2 When a bit device has been specified, 32 continuous bits from the start of the channel are handled.
EXTENDED FUNCTIONS

*3 When a bit device has been specified to the get result store device, continuous two bits are used as the
notification bit. When a word device has been specified, each of the LSBs of continuous two words is
used as the notification bit device.

Description of Operation

The free space (byte units)on the Memory Card is got and stored in the device specified by the D1

as 32-bit BIN data (two words), and the free space get completion notification and abnormal end alarm
8 notification are stored in D2 .
Memory Card Functions

D1 +1 D1
Free Space Available
32-bit BIN data
Memory card

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-84 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MFREE ( DM1000.D, R1000 )
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress
FOR
#2

@VB00 MFREE

EXTENDED FUNCTIONS
DM1000 R1000

Capacity store device Result store device

@VB00 @VB00
SET

NEXT

LABEL

@VB01
#2000
8
MR1100

Memory Card Functions


ƽ Notification bit device ( D2 completion notification, D2 +1: error notification)
Item Description
This device turns OFF when execution of the instruction starts, and turns
Completion
D2 ON when acquisition of free space on the Memory Card ends. The device
notification
turns ON whichever way execution ends, successfully or in error.
Error This device turns OFF when execution ends successfully, and turns ON
D2 +1
notification when execution ends in error.

Note
g The result of END processing after execution of the instruction is completed is written for
the completion notification and error notification.
g Several scans are sometimes required for getting free space.
g The get free space sometimes differs from the actual free space when file operations
were being performed via an FTP server function during acquisition processing or the
logging function was being used.
g The MFREE function is not executed while a Memory Card function is being executed
(CR3214 is ON).
g When a relay other than the leading relay of the channel has been specified to D1 , the
function is not executed.
g This instruction cannot be used in interrupt programs or in the initialization module.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-85


MFREEK Get memory card space in kilobyte unit

Get Memory Card free space

Return value
*1
= MFREEK (free space store device, get result store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D1 Specifies the device to store the free space
Free space
*2 (kilobyte unit) got from the Memory Card to. - - .D .D - - - - - ƻ -
store device
(32-bit data device)
D2 Get result store Specifies the bit device for notifying the free
*3 - - - - - - .B - - ƻ -
device space get result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 When a bit device has been specified, 32 continuous bits from the start of the channel are handled.
EXTENDED FUNCTIONS

*3 When a bit device has been specified to the get result store device, continuous two bits are used as the
notification bit. When a word device has been specified, each of the LSBs of continuous two words is
used as the notification bit device.

Note
g The MFREEK function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

8
Description of Operation
Memory Card Functions

The free space (kilobyte unit)on the Memory Card is got and stored in the device specified by the D1

as 32-bit BIN data (two words), and the free space get completion notification and abnormal end alarm
notification are stored in D2 .

D1 +1 D1
Free Space Available
32-bit BIN data
Memory card

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "MFREEK".

8-86 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MFREEK ( EM1000.D, MR2000 )
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress
FOR
#2

@VB00 MFREEK

EXTENDED FUNCTIONS
EM1000 MR2000

Memory card space Retrieved results


storage destination

@VB00 @VB00
SET

NEXT

LABEL

@VB01
#2000
8
MR1100

Memory Card Functions


ƽ Notification bit device ( D2 completion notification, D2 +1: error notification)
Item Description
This device turns OFF when execution of the instruction starts, and turns
Completion
D2 ON when acquisition of free space on the Memory Card ends. The device
notification
turns ON whichever way execution ends, successfully or in error.
Error This device turns OFF when execution ends successfully, and turns ON
D2 +1
notification when execution ends in error.

Note
g The result of END processing after execution of the instruction is completed is written for
the completion notification and error notification.
g Several scans are sometimes required for getting free space.
g The get free space sometimes differs from the actual free space when file operations
were being performed via an FTP server function during acquisition processing or the
logging function was being used.
g The MFREEK function is not executed while a Memory Card function is being executed
(CR3214 is ON).
g When a relay other than the leading relay of the channel has been specified to D1 , the
function is not executed.
g This instruction cannot be used in interrupt programs or in the initialization module.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-87


MMKDIR Make Memory Card directory

Make Memory Card directory

Return value
*1
= MMKDIR (created path name, make result store device))
Argument/Return Recognized Type Const
Explanation Device Formul
Value .U .S .D .L .F .DF .B .T #/$ a
Specifies the device to which the path name of
S the directory to make is currently stored, or the
Created path *2
ƻ
*3 created directory path name. (A text string in the - - - - - - - .T ƻ ƻ
name*5
range 1 to 247 characters (including end code
NUL) is specified.)
D Make result store Specifies the device for notifying the make
*4 - - - - - - .B - - ƻ -
device result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device/relay.
EXTENDED FUNCTIONS

*2 To specify a text string using constants, enclose with " ".


*3 For bit devices, specify the leading device of the channel.
*4 When a bit device has been specified, 2 continuous bits are occupied. When a word device has been
specified, each of the lowermost bits of two continuous words is used as the notification bit device. Bits
other than the lowermost bit do not change.
*5 T, C, CR, CTC, CTH, Z cannot be used.

8 Description of Operation
Memory Card Functions

A directory is made on the Memory Card using the path name (test string) specified by S .
The make result is stored in D .

Example
S "Directory A" "Directory A\Directory B"

Memory Memory Card Memory Memory Card


Example of
directory Directory A
Directory A
structure
Directory B

When a directory already exists, nothing Prepare a new directory (directory A) in


Note happens, processing ends successfully, and advance. It cannot be prepared together with
the completion notification relay turns ON. directory B.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-88 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MMKDIR ( DM1000.T, R1000 )
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MMKDIR

EXTENDED FUNCTIONS
DM1000 R1000

Path name Gernarate result

@VB00 @VB00
SET

NEXT

LABEL
#2000

@VB01 MR1100 8

Memory Card Functions


ƽ Notification bit device ( D : completion notification, D +1: error notification)
Item Description
Turns OFF when execution of the function starts, and turns ON when the
Completion
D directory has finished being made.
notification
Turns ON whichever way execution of the function ends, successfully or in error.
Error Turns OFF when execution of the function ends successfully, and turns ON
D +1
notification when execution ends in error.

Note
g Several scans are sometimes required for making the directory.
g The result of END processing after execution of the function is completed is written for the
notification bit device.
g The store destination when indirect specification or index modify is specified to a notification
bit device becomes the store destination at the up edge of the execution condition.
g The MMKDIR function is not executed while a Memory Card function is being executed
(CR3214 is ON).
g The function is not executed when either of the following conditions is established:
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string specified by S exceeds 247 characters (including end code
“NUL (00H)")
g When a timer/counter is specified to S by indirect specification
g When a device other than the leading device of the channel is specified when a bit
device is specified to S
g This instruction cannot be used in interrupt programs or in the initialization module.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-89


Hint

Several scans are sometimes required to write the directory for the MMKDIR function. When the value of the
created path name is changed during make directory processing, the directory make result is not assured.
For this reason, the special device CR3214 (Memory Card instruction executing) or the make result
(completion notification) of directory make processing must be used for the execution condition to
perform exclusive control.
Programmed Script IF MR1000 AND R5000 THEN
RES ( R5000 )
MR2000 = MMKDIR ( DM1000, R5000 )
END IF
IF MR2000 = OFF THEN
EXTENDED FUNCTIONS

SET ( R5000 )
END IF
Description of Operation When MR1000 (DIR make request) is ON, and R5000 is ON (previous DIR make request is
completed) is ON, the creation of the directory this time is executed.
R5000 is turned OFF (reset for judgment of completion of the DIR make request this time),
and the directory is made on the Memory Card using the path name (text string) stored in
DM1000.

8 The make result is stored in R5000 (notification of DIR make completion this time) and
R5001 (DIR make result notification this time).
Memory Card Functions

When startup of the MMKDIR function fails (MR2000=OFF), R5000 is turned ON to start up
the MMKDIR function again.

8-90 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Memory Card Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-91


MRMDIR Delete Memory Card directory

Delete Memory Card directory

Return value
*1
= MRMDIR (delete path name, delete result store device))
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device to which the path name of the
S directory to delete is currently stored, or the deleted
Delete path *2
ƻ
*3 directory path name. (A text string in the range 1 to - - - - - - - .T ƻ ƻ
name*5
247 characters (including end code NUL) is
specified.)
D Delete result Specifies the device for notifying the delete
*4 - - - - - - .B - - ƻ -
store device result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in working device.
EXTENDED FUNCTIONS

*2 To specify a text string using constants, enclose with " ".


*3 When a bit device has been specified, specify the leading device of the channel.
*4 When a bit device has been specified, 2 continuous bits are occupied. When a word device has been
specified, each of the lowermost bits of two continuous words is used as the notification bit device. Bits
other than the lowermost bit do not change.
*5 T, C, CR, CTC, CTH, Z cannot be used.

Note
8 MRMDIR function is special function of KV-5500/5000/3000. CPU other than KV-1000
series cannot be used.
Memory Card Functions

Description of Operation

Delete the directory whose path name (text string) specified by S from the Memory Card.
Delete result is stored in D .

g S does not exist in store device memory card,


D +1 will be ON, 3 stored in CM2390 (file or directory does not exist).

g When file and directory available in directory specified by S

Delete all file directory existent in directory, then delete the specified directory.

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-92 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MRMDIR (DM1000.T, MR2000)
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MRMDIR

EXTENDED FUNCTIONS
DM1000 MR2000

Delete file name s device Delete result store device

@VB00 @VB00
SET

NEXT

LABEL
#2000

@VB01 MR1100
8

Memory Card Functions


Return value

ƽ Notification bit store device ( D :completion notification, D +1: error notification)


Item Description
Turns OFF when execution of the function starts, and turns ON when the
Completion
D directory has finished being deleted.
notification
Turns ON whichever way execution of the function ends, successfully or in error.
Error Turns OFF when execution of the function ends successfully, and turns ON
D +1
notification when execution ends in error.

Note
g Several scans are sometimes required for deleting the directory.
g The result of END processing after execution of the function is completed is written for the
notification bit device.
g Storage destination during indirect specifying, index modification in notice bit device
changes to the storage destination for the rising edge of function operation.
g The MRMDIR function is not executed while a Memory Card function is being executed
(CR3214 is ON).
g The function is not executed when either of the following conditions is established:
g When the text string specified by S does not contain the end code (NUL (00H))
g When the text string specified by S exceeds 247 characters (including end code
“NUL (00H)")
g When a timer/counter is specified to S by indirect specification
g When a device other than the leading device of the channel is specified when a bit
device is specified to S
g This instruction cannot be used in interrupt programs or in the initialization module.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-93


MDEL Delete Memory Card file

Delete Memory Card file

Return value
*1
= MDEL (Delete path name store device, delete result store device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device to which the file name to
S delete is currently stored, or the deleted file
Delete file *2
ƻ
*3 name. (A text string in the range 1 to 247 - - - - - - - .T ƻ ƻ
name*5
characters (including end code NUL) is
specified.)
D Delete result Specifies the device for notifying the delete
*4 - - - - - - .B - - ƻ -
store device result.
R Turns ON when the function is successfully
Return value - - - - - - .B - - ƻ -
started up, and turns OFF when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in working relay.
EXTENDED FUNCTIONS

*2 To specify a text string using constants, enclose with " ".


*3 When a bit device has been specified, specify the leading device of the channel.
*4 When a bit device has been specified, 2 continuous bits are occupied. When a word device has been
specified, each of the lowermost bits of two continuous words is used as the notification bit device. Bits
other than the lowermost bit do not change.
*5 T, C, CR, CTC, CTH, Z cannot be used.

Note
8 MDEL function is special function of KV-5500/5000/3000. CPU other than KV-1000 series
cannot be used.
Memory Card Functions

Description of Operation

Delete the file whose file name (text string) specified by S from the Memory Card.
Delete result is stored in D .

g S does not exist in storage device memory card,


D +1 will be ON, 3 stored in CM2390 (file or directory does not exist).

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Memory
Card Instruction".

8-94 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MDEL (DM1000.T, MR2000)
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MDEL

EXTENDED FUNCTIONS
DM1000 MR2000

Delete file name store device Delete result store device

@VB00 @VB00
SET

NEXT

LABEL
#2000

@VB01 MR1100
8

Memory Card Functions


Return value

ƽ Notification bit store device ( D :completion notification, D +1:error notification)


Item Description
Completion During function operation, OFF; file deletion is complete, ON.
D
notification Turns ON whichever way execution of the function ends, successfully or in error.
Error Turns OFF when execution of the function ends successfully, and turns ON
D +1
notification when execution ends in error.

Note
g Several scans are sometimes required for deleting the directory.
g The result of END processing after execution of the function is completed is written for the
notification bit device.
g Storage destination during indirect specifying, index modification in notice bit device
changes to the storage destination for the rising edge of function operation.
g The MDEL function is not executed while a Memory Card function is being executed
(CR3214 is ON).
g The function is not executed when either of the following conditions is established:
g When the text string specified by S does not contain the end code (NUL (00H))
gWhen the text string specified by S exceeds 247 characters (including end code “NUL (00H)")
g When a timer/counter is specified to S by indirect specification.
g When a device other than the leading device of the channel is specified when a bit
device is specified to S .
g This instruction cannot be used in interrupt programs or in the initialization module.

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-95


MPRINT Write text in memory card file

Write text string to memory card

Return value
*1
= MPRINT (save file name, write text string, writing result storage
device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device storing the name of the file
in which the data is saved, or the save file
*2
S1 Save file name name. (Specify a text string in the range of 1 to .U .S .D .L .F .DF .B .T ƻ ƻ -
247 characters (including end code NUL and
folder name).)
S2 Specifies the leading device storing the text
Write text
*2 string to be written in, or specifies the text .U .S .D .L .F .DF .B .T ƻ ƻ -
string
string to be written.
D Writing result Specifies the bit device which notifies the
EXTENDED FUNCTIONS

storage device writing results.


R Turns ON if function starts successfully, and
Return value .U .S .D .L .F .DF - - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 If a bit device is specified for the writing result storage device, two continuous bits will be used as the
notification bits.
*3 To specify a text string using constants, enclose with " ".
*4 For bit devices, specify the leading device of the channel.
*5 T, C, CTC, CTH, Z cannot be used.
8 Note
g The MPRINT function can be used only with KV STUDIO Ver. 6.00 or higher.
Memory Card Functions

g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The text string specified with S2 write text string is written to the end of the file name (text string)
specified with S1 save file name. If the save file specified with S1 is not found, a new file will be
created.

The writing completion notice and abnormal end error notice are stored in D write results storage
device.
The R return value turns ON when the MPRINT function starts normally, and turns OFF if it fails.

The notification bit for the D write results storage device has the following meaning.
(Example) When MR2000 has been specified
Notification Bit ON (1, TRUE) OFF (0, FALSE)
MR2000 Completion notification Completed Not completed
MR2001 Error notification Normal end Abnormal end
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-9 Memory
Card Instructions".

8-96 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MPRINT (DM5000.T, DM1000.T, MR2000)
CR3214 @VB01

Execute command of
@VB00
memory card in progress
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MPRINT

EXTENDED FUNCTIONS
DM5000 DM1000 MR2000

Save file name Write text string Writing results


@VB00 @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100
8
Return value

Memory Card Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-97


MREADL Read one line from file in memory card

Read one line from memory card

Return value
*1
= MREADL (read file name, read text string storage destination
device, read parameter, read results storage device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device storing the name of the file
from which the data is to be read, or specifies
*6
S Read file name the name of the file to be read. (Specify a text - - - - - - - .T *4
ƻ ƻ ƻ
string in the range of 1 to 247 characters
(including end code NUL and folder name).)
D1 Read text string
storage Specifies the leading device for storing the
- - - - - - - .T - ƻ -
destination read text string.
*5
devicee
D2
EXTENDED FUNCTIONS

Read
*2 Specifies the parameter to read. .U .U .U .U - - - - - ƻ -
parameter
D3 Reading results
Specifies the bit device which notifies the
storage - - - - - - .B - - ƻ -
*3 reading results.
device
R Turns ON if function starts successfully, and
Return value - - - - - - .B - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device/relay.
*2 The read parameter occupies four continuous words.

8 *3
*4
The reading results storage device uses four continuous bits as the notification bits.
To specify a text string using constants, enclose with " ".
*5 For bit devices, specify the leading device of the channel.
Memory Card Functions

*6 T, C, CTC, CTH, Z cannot be used.

Note
g The MREADL function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

One line is read from the file name (text string) specified with S read file name, and is read to the
device specified with D1 read text string storage destination device. (The character codes which
express a line are 0DH (CR), 0AH (LF) and 0D0AH (CR+LF).)
The maximum byte size of the text string to read out is set with ( D2 +2] (number of upper limit bytes
to read). If the length of text data on one line in the file exceeds the length specified with [ D2 +2],
[ D3 +3] (no line return character notification) turns ON, the text data to [ D2 +2] bytes is read to
D1 , and the NUL character is stored to the end of D1 .

The reading completion notice and abnormal end alarm notice are stored in D3 read text string
storage destination device.
The R return value turns ON when the MREADL function starts normally, and turns OFF if it fails.
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on D2 and D3 parameters, see KV-5500/5000/3000/1000 Instruction Reference Manual,
"MREADL".

8-98 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MREADL (DM5000.T, DM1000.T, EM1000, MR2000)
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MREADL

EXTENDED FUNCTIONS
DM5000 DM1000 EM1000 MR2000

Read file Read text Read Reading results


@VB00 name string parameter @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100
8
Return value

Memory Card Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-99


MCOPY Copy file in memory card

Copy memory card file

Return value
*1
= MCOPY (copy source file name/folder name, copy destination file
name/folder name, copy format parameter, copy results storage device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device storing the copy source
S1 Copy source file file name/folder name, or specifies the file
name/folder name/folder name. (Specify a text string in the - - - - - - - .T *4
ƻ ƻ ƻ
*5
name*6 range of 1 to 247 characters (including end
code NUL and folder name).)
S2 Specifies the device storing the copy
Copy
destination file name/folder name, or specifies
destination file
the file name/folder name. (Specify a text string - - - - - - - .T *4 ƻ ƻ ƻ
name/folder
*5 in the range of 1 to 247 characters (including
name*6
end code NUL and folder name).)
EXTENDED FUNCTIONS

S3 Copy format
*2 Specifies the copy format parameter. .U .U .U .U - - - - ƻ ƻ ƻ
parameter
D Copy results
Specifies the bit device which notifies the copy
storage - - - - - - .B - - ƻ -
*3 results.
device
R Turns ON if function starts successfully, and
Return value - - - - - - .B - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 The copy format parameter occupies one word.
8 *3 The copy results storage device uses two continuous bits as the notification bits.
*4 To specify a text string using constants, enclose with " ".
Memory Card Functions

*5 For bit devices, specify the leading device of the channel.


*6 T, C, CTC, CTH, Z cannot be used.

Note
g The MCOPY function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The file name (text string) specified with S1 copy source file name/folder name is copied into the file
specified with S2 copy destination file name/folder name.
If a file or folder with the same name is found at the copy destination, whether to overwrite the data or
generate an error will be judged following the S3 copy format parameters.
When copy format parameter value is 0: If file with same name is found, data is overwritten.
When copy format parameter value is 1: If file with same name is found, error occurs without
overwriting the data.

The copy completion notice and abnormal end alarm notice are stored in D copy results storage
device.
The R return value turns ON when the MCOPY function starts normally, and turns OFF if it fails.

8-100 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Combinations of file and folder names which can be specified in S1 and S2

S2

File name Folder name


File name Normal operation Normal operation
S1
Folder name Error occurs Normal operation

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on S3 parameters and D copy results, see KV-5500/5000/3000/1000 Instruction
Reference Manual, "MCOPY".

ƽ Example of format
MR1100 = MCOPY (DM5000.T, DM1000.T, EM1000, MR2000)

EXTENDED FUNCTIONS
CR3214 @VB01

Execute command of
@VB00
memory card in progress
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MCOPY 8
DM5000 DM1000 EM1000 MR2000

Memory Card Functions


Copy source Copy destination Copy format Copy results
@VB00 file name file name parameter @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100

Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-101


MMOV Move file in memory card

Memory card file move

Return value = MMOV (move source file name/folder name, move destination file
*1

name/folder name, move format parameter, move results storage device)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device storing the move source
S1 Move source file file name/folder name, or specifies the file
name/folder name/folder name. (Specify a text string in the - - - - - - - .T *4
ƻ ƻ ƻ
*5
name*6 range of 1 to 247 characters (including end
code NUL and folder name).)
S2 Specifies the device storing the move
Move
destination file name/folder name, or specifies
destination file
the file name/folder name. (Specify a text string - - - - - - - .T *4 ƻ ƻ ƻ
name/folder
*5 in the range of 1 to 247 characters (including
name*6
end code NUL and folder name).)
EXTENDED FUNCTIONS

S3 Move format
*2 Specifies the move format parameter. .U .U .U .U - - - - ƻ ƻ ƻ
parameter
D Move results
Specifies the bit device which notifies the move
storage - - - - - - .B - - ƻ -
*3 results.
device
R Turns ON if function starts successfully, and
Return value - - - - - - .B - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 The move format parameter occupies one word.
8 *3 The move results storage device uses two continuous bits as the notification bits.
*4 To specify a text string using constants, enclose with " ".
Memory Card Functions

*5 For bit devices, specify the leading device of the channel.


*6 T, C, CTC, CTH, Z cannot be used.

Note
g The MMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The file name (text string) specified with S1 move source file name/folder name is moved to the file
specified with S2 move destination file name/folder name.
If a file or folder with the same name is found at the move destination, whether to overwrite the data or
generate an error will be judged following the S3 move format parameters.
When move format parameter value is 0: If file with same name is found, data is overwritten.
When move format parameter value is 1: If file with same name is found, error occurs without
overwriting the data.

The move completion notice and abnormal end alarm notice are stored in D move results storage
device.
The R return value turns ON when the MMOV function starts normally, and turns OFF if it fails.

8-102 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Combinations of file and folder names which can be specified in S1 and S2

S2

File name Folder name


File name Normal operation Normal operation
S1
Folder name Error occurs Normal operation

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on S3 parameters and D move results, see KV-5500/5000/3000/1000 Instruction
Reference Manual, "MMOV".

ƽ Example of format
MR1100 = MMOV (DM5000.T, DM1000.T, EM1000, MR2000)

EXTENDED FUNCTIONS
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MMOV 8
DM5000 DM1000 EM1000 MR2000

Memory Card Functions


Move source Move destination Move format Move results
@VB00 file name file name parameter @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100

Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-103


MREN Rename memory card file

Memory card file rename

Return value
*1
= MREN (file name/folder name to be renamed, new file name/folder
name, file name rename results storage device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specifies the device storing the file name/
S1 File name/folder folder name to be renamed, or specifies the file
name to be name/folder name with a full path. (Specify a - - - - - - - .T *3
ƻ ƻ ƻ
*4
renamed*5 text string in the range of 1 to 247 characters
(including end code NUL and folder name).)
Specifies the device storing the new file or
folder name, or specifies the file or folder
S2 New file name/ name. Only the new file name or folder name
*4 - - - - - - - .T *3
ƻ ƻ ƻ
folder name*5 is specified. (Specify a text string in the range
of 1 to 247 characters (including end code NUL
EXTENDED FUNCTIONS

and folder name).)


D File name
rename results Specifies the bit device which notifies the file
- - - - - - .B - - ƻ -
storage name rename results.
*2
device
R Turns ON if function starts successfully, and
Return value - - - - - - .B - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 The move results storage device uses two continuous bits as the notification bits.
8 *3 To specify a text string using constants, enclose with " ".
*4 For bit devices, specify the leading device of the channel.
Memory Card Functions

*5 T, C, CTC, CTH, Z cannot be used.

Note
g The MREN function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The file name or folder name (text string) specified with S1 file name/folder name to be renamed is
renamed with the file name or folder name specified with S2 new file name/folder name.
The rename completion notice and abnormal end alarm notice are stored in D file name rename
results storage device.
The R return value turns ON when the MREN function starts normally, and turns OFF if it fails.
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on actions, see KV-5500/5000/3000/1000 Instruction Reference Manual, "MREN".

8-104 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MREN (DM5000.T, DM1000.T, MR2000)
CR3214 @VB01

Execute command of
memory card in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MREN

EXTENDED FUNCTIONS
DM5000 DM1000 MR2000

File name New file Rename results


to rename name
@VB00 @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100 8

Memory Card Functions


Return value

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-105


MSTAT Get status of file in memory card

Get memory card file status

Return value
*1
= MSTAT (file name, file status storage destination device, retrieved
results storage device)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
Specify the device storing the name of the file
for which the status is to be retrieved, or
*5
S1 File name specify the file name. (Specify a text string in - - - - - - - .T *3
ƻ ƻ ƻ
the range of 1 to 247 characters (including end
code NUL and folder name).)
D1 File status
storage Specifies the device which stores the file
.U .U .U .U - - - - - ƻ -
destination status.
*4
device
D2
EXTENDED FUNCTIONS

Retrieved results
Specifies the bit device which notifies the
storage - - - - - - .B - - ƻ -
*2 retrieved results.
device
R Turns ON if function starts successfully, and
Return value - - - - - - .B - - ƻ -
turns OFF if the function fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
*2 The reading results storage device uses three continuous bits as the notification bits.
*3 To specify a text string using constants, enclose with " ".
*4 The file status storage destination device occupies ten continuous words.

8 *5 T, C, CTC, CTH, Z cannot be used.

Note
Memory Card Functions

g The MSTAT function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

The status of the file specified with S file name is stored in D1 file status storage destination
device.
The retrieval completion notification, abnormal end alarm notification and presence of file are stored in
D2 retrieved results storage device.
The R return value turns ON when the MSTAT function starts normally, and turns OFF if it fails.
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "MSTAT".

8-106 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
MR1100 = MSTAT (DM5000.T, EM1000, MR2000)
CR3214 @VB01

Execute command of
@VB00
memory card in progress
RES

CR3214 CJ
#2000
Execute command of
memory card in progress FOR
#2

@VB00 MSTAT

EXTENDED FUNCTIONS
DM5000 EM1000 MR2000

File name File status Retrieved results


@VB00 storage device storage device @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100
8
Return value

Memory Card Functions

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-107


Access Window Function

AWNUM Display access window numerical value

Display user message 1

AWNUM (display switching, AW write data)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Display Specifies display switching of the access
- - - - - - .B - - ƻ ƻ
switching window.
S2 Specifies user message 1 data or the device
AW write
*1 to which the numerical value to be displayed .U .U .U .U - - - - ƻ ƻ ƻ
data
as user message 1 is currently stored.
R Return value None - - - - - - - - - - -
*1 When a bit device has been specified, 16 continuous bits are occupied. When a relay other than the
leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16 bits
straddling the next channel.
EXTENDED FUNCTIONS

Description of Operation

When the S1 is ON, the value specified by the S2 is displayed on the access window as user
message 1.
When the S1 is OFF, display of user message 1 is canceled.

8 ƽ Example of format
AWNUM ( R3000, DM1000 )
Access Window Function

CR2002 MOV
DM1000 CM1720
Always ON
Usermessage 1
R3000 CR2900
SET
Usermessage 1 display

R3000 CR2900
RES
Usermessage 1 display
For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-14 Access
Window Instruction".

When user messages 1 and 2 are displayed simultaneously, user message 1 is given priority
and displayed.
For details on user message display, “KV-5500/5000/3000 Series User's Manual".

8-108 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g When display switching is ON, CR2900 is set, and when it is OFF, CR2900 is reset. In
addition, the value specified by S2 is copied to CM01720 at all times, and the result is
reflected immediately in the access window.
g If the value of S2 is changed when display switching is ON, the display content of user
message 1 is also changed.
g If the access window is operated even when display switching is ON, the message
display is canceled.
(CR2900 also is reset at this time.) If the AWNUM function is called again, CR2900 turns ON.
g When a project contains multiple AWNUM functions, the state of the access window
conforms to the last executed AWNUM function.
g This instruction cannot be used in interrupt programs or in the initialization module.

EXTENDED FUNCTIONS
8

Access Window Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-109


AWMSG Display access window message

Display user message2

AWMSG (display switching, AW write data)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S1 Display Specifies display switching of the access
- - - - - - .B - - ƻ ƻ
switching window.
S2 Specifies user message 2 data or the device
AW write
*1 to which the numerical value to be displayed - - - - - - - .T ƻ ƻ ƻ
data*2
as user message 2 is currently stored.
R Return value None - - - - - - - - - - -
*1 gThe maximum number of characters in a text string that can be displayed in the access window is 24.
gText string constants enclosed by double quotation marks can be specified.
gFor bit devices, specify the leading device of the channel.
EXTENDED FUNCTIONS

*2 T, C, CR, CTC, CTH, Z can not be used.

Description of Operation

When S1 is ON, the value specified by the S2 is displayed on the access window as user
message 2.
When S1 is OFF, display of user message2 is canceled.

8
ƽ Example of format
Access Window Function

AWMSG ( R3000, DM1000.T )


CR2002 SMOV
DM1000 CM1721
Always ON
Usermessage 2-1
R3000 CR2901
SET
Usermessage 2 display

R3000 CR2901
RES
Usermessage 2 display

For details on operation flag changes, see "About operation flag (CR2009 to CR2012)", Page 1-18.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-14 Access
Window Instruction".

When user messages 1 and 2 are displayed simultaneously, user message 1 is given priority
and displayed.
For details on user message display, “KV-5500/5000/3000 Series User's Manual".

8-110 - KV-5500/5000/3000/1000 Series Script Programming Manual -


Note
g Full-width characters cannot be displayed on the access window.
g When display switching is ON, CR2901 is set, and when it is OFF, CR2901 is reset. In
addition, The text string currently stored starting from the device specified by S2 is
copied to CM01721 to CM01737 at all times when the execution condition is ON, and the
result is reflected immediately in the access window.
g When display switching is ON, If the text string currently stored starting from the device
specified by S2 is changed, the display content of user message 2 is also changed.
g If the access window is operated even when display switching is ON, the message
display is canceled.
(CR2901 also is reset at this time.) If the AWMSG function is called again, CR2900 turns
ON.

EXTENDED FUNCTIONS
g When a project contains multiple AWMSG functions, the state of the access window
conforms to the last executed AWMSGfunction.
g Only text strings up to 24 characters (ASCII codes 20h to 7Eh, A1h to DFh) long from the
text string currently stored starting from the device specified by S2 can be displayed in
the access window. 2-byte characters such as Chinese characters cannot be displayed.
g This instruction cannot be used in interrupt programs or in the initialization module.
g The function is not executed when either of the following conditions is established:
g When a device other than the leading device of the channel is specified when a bit
device is specified to S2
8
g When a timer/counter is specified to S2 by indirect specification

Access Window Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-111


FREE RUN Counter Function

RFSFRC FREE RUN counter refresh


FREE RUN counter refresh

RFSFRC ([execution condition,]*1 )


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all times
(at every scan).

Note
RFSFRC function is special function of KV-5500/5000/3000. CPU other than KV-1000
series cannot be used.
EXTENDED FUNCTIONS

Description of Operation

When execution condition is true, refresh FREE RUN counter (CM708, CM709) to the latest value.

For details, KV-5500/5000/3000/1000 Instruction Reference Manual," 5-15 Program Control Flow Instruction".

ƽ Example of format
8 RFSFRC ( MR1000 )
FREE RUN Counter Function

MR1000 RFSFRC

Execution conditon

8-112 - KV-5500/5000/3000/1000 Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

FREE RUN Counter Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-113


Sensor Setting Function

SPRD Read sensor parameter

SPRD (execution condition, unit number, node address, slot number, parameter number,
completion code)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Execution Specifies the bit device used for execution
condition - - - - - - .B - - ƻ
condition.
n1 *1 Specifies the unit number (0 to 63, "0" for KV-
Unit number - - - - - - - - ƻ - ƻ
5500).
n2 *3 Specifies node address (1 to 256), or the device
Node address .U .U .U .U - - - - ƻ ƻ ƻ
storing that information.
n3 *3 Specifies the slot number, or the device storing
Slot number .U .U .U .U - - - - ƻ ƻ ƻ
that information.
n4 Parameter Specifies the parameter number, or the device
EXTENDED FUNCTIONS

*3 .U .U .U .U - - - - ƻ ƻ ƻ
number storing that information.
D Specifies the leading number of the device
Completion
*2 *5 storing the completion code or parameter read .U .U .U .U .F .DF .B .T - ƻ -
code*4
results.
R Return value None - - - - - - - - - -
*1 $ (hexadecimal specification) cannot be used.
*2 CTC, CTH, Z cannot be used.
*3 When a bit device has been specified, 16 continuous bits are occupied. When a relay other than the

8 leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16 bits
straddling the next channel.
*4 For bit devices, specify the leading device of the channel.
Sensor Setting Function

*5 The number of stored words (four words or more) differs according to the execution results.

Note
g The SPRD function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the S execution conditions turn ON, the parameters specified with n4 for the node
address n2 and slot number n3 sensor connected to the n1 unit are read out. When
finished, the completion bit is set in bit 0 of D , the execution failed bit in bit 1 of D , the
completion code in D +1, the detailed completion code in D +2, the number of array elements
(1 when not an array) in D +3, and the contents of the read parameter in D +4 and following.

8-114 - KV-5500/5000/3000/1000 Series Script Programming Manual -


D ~: Result storage destination device

Result storage destination device Details


This device turns OFF when execution of the instruction
starts, and turns ON when reading of the parameter is
Bit 0 Completion bit
finished. This device turns ON regardless of whether the
instruction ends normally or abnormally.
D If execution of the instruction fails, this device turns ON
simultaneously with the completion bit.
Bit 1 Execution failed bit
This device turns OFF when execution of the instruction
starts.
Bits 2 to 15 Reserved for system OFF (fixed value)
The completion code is stored when reading of the

EXTENDED FUNCTIONS
D +1 Completion code
parameters is completed. (Normally 0)
D
The detailed completion code is stored when reading of the
+2 Detailed completion code
parameters is completed.
The number of array elements in the read parameter is
D
stored.
+3 Number of array elements
1 is stored if the parameter is not an array, and 0 is stored if
the instruction ends abnormally.
D
The parameter value is stored. The number of data items
+4 to Read results
occupied differs according to the read parameter.
8
Note
The execution will fail if an "Ethernet/IP device reserved" sensor is specified.

Sensor Setting Function


If the sensor parameter read instruction is executed at the rising edge of the execution conditions, the
process will continue even if the input conditions are turned OFF at the next scan. The result storage
destination device completion bit and failed bit turn ON at completion, and turn OFF when execution
starts.
When the instruction is executed, the number of sensor setting instruction executions is incremented by
1, and is decremented when the execution finishes.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-12 Sensor
Setting Instruction".

ƽ Example of format
Programmed Script SPRD (MR0,1,1,1,805,DM0)
Operation Description When MR000 turns ON, the contents of parameter No. 805 for the node address 1, slot No.
1 sensor connected to the first connected unit are read out and stored in DM0 and following.
Ladder Conversion SPRD
MR000
#1 #1 #1

#805 DM0

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-115


SPWR Sensor parameter write

SPWR (execution condition, unit number, node address, slot number, parameter number,
completion code)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Execution Specifies the bit device used for execution
condition - - - - - - .B - - ƻ
condition.
n1 *1 Specifies the unit number (0 to 63, "0" for KV-
Unit number - - - - - - - - ƻ - ƻ
5500).
n2 *3 Specifies node address (1 to 256), or the device
Node address .U .U .U .U - - - - ƻ ƻ ƻ
storing that information.
n3 *3 Specifies the slot number, or the device storing
Slot number .U .U .U .U - - - - ƻ ƻ ƻ
that information.
n4 Parameter Specifies the parameter number, or the device
EXTENDED FUNCTIONS

*3 .U .U .U .U - - - - ƻ ƻ ƻ
number storing that information.
D Specifies the leading number of the device
Completion
*2 *5 storing the completion code or parameter read .U .U .U .U .F .DF .B .T - ƻ -
code*4
results.
R Return value None - - - - - - - - - -
*1 $ (hexadecimal specification) cannot be used.
*2 CTC, CTH, Z cannot be used.
*3 When a bit device has been specified, 16 continuous bits are occupied. When a relay other than the

8 leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16 bits
straddling the next channel.
*4 For bit devices, specify the leading device of the channel.
Sensor Setting Function

*5 The number of stored words (four words or more) differs according to the execution results.

Note
g The SPWR function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the S execution conditions turn ON, the setting value specified with D +4 and following
is written into the parameter specified with n4 of the node address n2 , slot No. n3 sensor
connected to the n1 unit. When writing is completed, the completion bit is set in bit 0 of D , the
execution failed bit in bit 1 of D , the completion code in D +1, and the detailed completion code
in D +2.

8-116 - KV-5500/5000/3000/1000 Series Script Programming Manual -


D ~: Result storage destination device

Result storage destination device Details


This device turns OFF when execution of the instruction
starts, and turns ON when writing of the parameter is
Bit 0 Completion bit
finished. This device turns ON regardless of whether the
instruction ends normally or abnormally.
D If execution of the instruction fails, this device turns ON
simultaneously with the completion bit.
Bit 1 Execution failed bit
This device turns OFF when execution of the instruction
starts.
Bits 2 to 15 Reserved for system OFF (fixed value)
The completion code is stored when writing of the

EXTENDED FUNCTIONS
D +1 Completion code
parameter is completed. (0 when normal)
D
The detailed completion code is stored when writing of the
+2 Detailed completion code
parameter is completed.
D +3 Reserved for system 0 (fixed value)
D
The setting value is stored. The number of data items
+4 to Setting value
occupied differs according to the write parameter.

Note
The execution will fail if an "Ethernet/IP device reserved" sensor (adaptor) is specified.
8
If the sensor parameter write instruction is executed at the rising edge of the execution conditions, the

Sensor Setting Function


process will continue even if the input conditions are turned OFF at the next scan. The result storage
destination device collection bit and failed bit turn ON at completion, and turn OFF when execution
starts.
When the instruction is executed, the number of sensor setting instruction executions is incremented by
1, and is decremented when the execution finishes.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-12 Sensor
Setting Instruction".

ƽ Example of format
Programmed Script SPWR (MR0,1,1,1,833,DM0)
Operation Description When MR000 turns ON, the setting value specified with DM4 and following is written to
parameter No. 833 (setting value) of the node address 1, slot No. 1 sensor connected to the
unit No. 1 KV-EP21V. The results are stored in DM0 and following.
Ladder Conversion SPWR
MR000
#1 #1 #1

#833 DM0

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-117


SSVC Sensor service execution

SSVC (execution condition, unit number, node address, slot number, parameter number,
completion code)
Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S Execution Specifies the bit device used for execution
condition - - - - - - .B - - ƻ
condition.
n1 *1 Specifies the unit number (0 to 63, "0" for KV-
Unit number - - - - - - - - ƻ - ƻ
5500).
n2 *3 Specifies node address (1 to 256), or the device
Node address .U .U .U .U - - - - ƻ ƻ ƻ
storing that information.
n3 *3 Specifies the slot number, or the device storing
Slot number .U .U .U .U - - - - ƻ ƻ ƻ
that information.
n4 Parameter Specifies the parameter number, or the device
EXTENDED FUNCTIONS

*3 .U .U .U .U - - - - ƻ ƻ ƻ
number storing that information.
D Specifies the leading number of the device
Completion
*2 *5 storing the completion code or parameter read .U .U .U .U .F .DF .B .T - ƻ -
code*4
results.
R Return value None - - - - - - - - - -
*1 $ (hexadecimal specification) cannot be used.
*2 CTC, CTH, Z cannot be used.
*3 When a bit device has been specified, 16 continuous bits are occupied. When a relay other than the

8 leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16 bits
straddling the next channel.
*4 For bit devices, specify the leading device of the channel.
Sensor Setting Function

*5 Up to six words are used depending on the specified service.

Note
g The SSVC function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions turn ON, the service specified with n4 of the node address n2 ,
slot No. n3 sensor connected to the n1 unit is executed. When execution is completed, the
completion bit is set in bit 0 of D , the execution failed bit in bit 1 of D , the completion code in
D +1, and the detailed completion code in D +2.

8-118 - KV-5500/5000/3000/1000 Series Script Programming Manual -


D ~: Result storage destination device

Result storage destination device Details


This device turns OFF when execution of the instruction starts,
and turns ON when execution of the service is finished. This
Bit 0 Completion bit
device turns ON regardless of whether the instruction ends
normally or abnormally.
D
If execution of the instruction fails, this device turns ON
Bit 1 Execution failed bit simultaneously with the completion bit.
This device turns OFF when execution of the instruction starts.
Bits 2 to 15 Reserved for system OFF (fixed value)
D
The completion code is stored when execution of the service
+1 Completion code
is completed. (0 when normal)

EXTENDED FUNCTIONS
D
The detailed completion code is stored when execution of the
+2 Detailed completion code
service is completed.
D +3 Reserved for system 0 (fixed value)
D +4 Specifies the send data (maximum two words) according to
D
Send data
+5 the service being executed.

Note
The execution will fail if an "Ethernet/IP device reserved" sensor is specified.

If the sensor service read instruction is executed at the rising edge of the execution conditions, the 8
process will continue even if the input conditions are turned OFF at the next scan. The result storage

Sensor Setting Function


destination device collection bit and failed bit turn ON at completion, and turn OFF when execution
starts.
When the instruction is executed, the number of sensor setting instruction executions is incremented by
1, and is decremented when the execution finishes.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-12 Sensor
Setting Instruction".

ƽ Example of format
Programmed Script SSVC (MR0,1,2,3,1,DM0)
Operation Description When MR000 turns ON, the service No. 1 service of the node address 2, slot No. 3 sensor
connected to the unit No. 1 KV-EP21V is executed. The results are stored in DM0 and
following.
Ladder Conversion SSVC
MR000
#1 #2 #3

#1 DM0

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-119


Cyclic Communication Refresh Function

RFSCI Refresh cyclic communication input

RFSCI ([execution condition,]*1 leading device number, number of data items)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
S *2 Specifies the leading device number for refreshing
Leading device .U .S .D .L .F - - - ƻ -
the cyclic communication input data.
n Number of data
Specifies the number of data items to refresh. .U .U .U .U - - - ƻ - -
items
R Return value None - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all times (at every scan).)
*2 For bit devices, specify the leading device of the channel.

Note
EXTENDED FUNCTIONS

g The RFSCI function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions turn ON, the cyclic communication input data from the data assigned to

8 the device specified with S to the number of data items specified with
leading device is 32-bit data, the number of refreshed words is number of data items x 2.)
n is refreshed. (If the
Cyclic Communication Refresh Function

g When S : leading device is 16 bits (.U/.S)


Example) When leading device is DM102 (.U) and number of data items is 3
CPU unit KV-EP21V
assignment device cyclic communication data
DM100 Leading word
DM101 Leading word+1
DM102 Leading word+2
DM103 Leading word+3
DM104 Leading word+4
Data in specified Leading word+5
DM105
range is refreshed.
g When S : leading device is 32 bits (.D/.L/.F)
Example) When leading device is DM102.D and number of data items is 3
CPU unit KV-EP21V
assignment device cyclic communication data
DM101 DM100 Leading word+1 Leading word
DM103 DM102 Leading word+3 Leading word+2
DM105 DM104 Leading word+5 Leading word+4
DM107 DM106 Leading word+7 Leading word+6
DM109 DM108 Leading word+9 Leading word+8
DM111 DM110 Leading word+11 Leading word+10

Data in specified
range is refreshed.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Cyclic
Communication Refresh Instruction".

8-120 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
Programmed Script RFSCI (MR0,DM100.U,10)
Operation Description When MR000 turns ON, 10 words of cyclic communication input data assigned after data
memory DM100 is refreshed.
Ladder Conversion
MR000 RFSCI
DM100 #10

EXTENDED FUNCTIONS
8

Cyclic Communication Refresh Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-121


RFSCO Refresh cyclic communication output

RFSCO ([execution condition]*1 , leading device number, number of data items)


Argument/Return Recognized Type Const
Explanation Device Formula
Value .U .S .D .L .F .DF .B .T #/$
D *2 Specifies the leading device for refreshing the
Leading device .U .S .D .L .F - - - ƻ -
cyclic communication output data.
n Number of data
Specifies the number of data items to refresh. .U .U .U .U - - - ƻ - -
items
R Return value None - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at all times (at every scan).)
*2 For bit devices, specify the leading device of the channel.

Note
EXTENDED FUNCTIONS

g The RFSCO function can be used only with KV STUDIO Ver. 6.00 or higher.
g This function can be used with the CPU function version 2.0 or higher CPU unit.
"KV-5500/5000/3000 CPU Function Version", Page 2

Description of Operation

When the execution conditions turn ON, the cyclic communication input data from the data assigned to

8 the device specified with D to the number of data items specified with
leading device is 32-bit data, the number of refreshed words is number of data items x 2.)
n is refreshed. (If the
Cyclic Communication Refresh Function

g When D : leading device is 16 bits (.U/.S)


Example) When leading device is DM102 (.U) and number of data items is 3
CPU unit KV-EP21V
assignment device cyclic communication data
DM100 Leading word
DM101 Leading word+1
DM102 Leading word+2
DM103 Leading word+3
DM104 Leading word+4
Data in specified Leading word+5
DM105
range is refreshed.
g When D : leading device is 32 bits (.D/.L/.F)
Example) When leading device is DM102.D and number of data items is 3
CPU unit KV-EP21V
assignment device cyclic communication data
DM101 DM100 Leading word+1 Leading word
DM103 DM102 Leading word+3 Leading word+2
DM105 DM104 Leading word+5 Leading word+4
DM107 DM106 Leading word+7 Leading word+6
DM109 DM108 Leading word+9 Leading word+8
DM111 DM110 Leading word+11 Leading word+10

Data in specified
range is refreshed.
For details on execution timing, see KV-5500/5000/3000/1000 Instruction Reference Manual, "5-13 Cyclic
Communication Refresh Instruction".

8-122 - KV-5500/5000/3000/1000 Series Script Programming Manual -


ƽ Example of format
Programmed Script RFSCO (MR0,DM100.U,10)
Operation Description When MR000 turns ON, 10 words of cyclic communication output data assigned after data
memory DM100 is refreshed.
Ladder Conversion RFSCO
MR000
DM100 #10

EXTENDED FUNCTIONS
8

Cyclic Communication Refresh Function

- KV-5500/5000/3000/1000 Series Script Programming Manual - 8-123


MEMO
EXTENDED FUNCTIONS

8
Cyclic Communication Refresh Function

8-124 - KV-5500/5000/3000/1000 Series Script Programming Manual -


APPENDICES

APPENDICES
1 List of Control Relays/Control Memories •••••••••••••••••A-2
2 ASCII Code Table••••••••••••••••••••••••••••••••••••••••••• A-15
3 List of Unusable Characters •••••••••••••••••••••••••••••• A-16
4 List of Unusable Functions •••••••••••••••••••••••••••••••• A-18
5 Index •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• B-19
6 Functions Index ••••••••••••••••••••••••••••••••••••••••••••• B-23

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-1


1 List of Control Relays/Control Memories

Control Relays

Control relays (CR0000 to CR3915) can be used to verifg state and setting of CPU unit, and monitor
various internal functions.
System reserved control relays cannot be used.
Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CR0000 Logging/tracing execution (ON: Enable)


CR0001 R Logging/tracing operation in progress
CR0002 R Logging/tracing file write complete
CR0003 R Logging buffer 50% not full alarm
CR0004 R Logging buffer overflow
CR0005 R RUN writing during loging
CR0006 to CR0007 - Logging/tracing Reserved for system
CR0008 R function (ID0) Logging/tracing error
CR0009 R Logging/tracing memory card full error
CR0010 R Logging/tracing device/trigger setting abnormal
APPENDICES

CR0011 R Tracing file storage trigger monitor


CR0012 R Tracing data capture complete
CR0013 R Write logging/tracing setting
CR0014 to CR0015 - Reserved for system
Logging/tracing
CR0100 to CR0915 (same as CR0000 to CR0015)
function (ID1 to ID9)
Real-time chart
CR1000 to CR1015 (same as CR0000 to CR0015)
List of Control Relays/Control Memories

monitoring(ID10)
CR1100 to CR2001 - Reserved for system
CR2002 R Normal ON
CR2003 R Normal OFF
CR2004 R 10ms clock pulse (duty cycle 50%)
CR2005 R 100ms clock pulse (duty cycle 50%)
CR2006 R 1ms clock pulse (duty cycle 50%)
CR2007 R 1 scan OFF at operation start
CR2008 R 1 scan ON at operation start
CR2009 ON when operation result is negative or overflow
CR2010 R ON when operation result is 0
CR2011 R ON when operation result is 0
CR2012 R ON when operation execution error occurs
CR2013 to CR2015 - Reserved for system
CR2100 R CTH0 specific internal clock (1μs)
CR2101 R CTH0 specific internal clock (10μs)
CR2102 R CTH0 specific internal clock (10μs)
CR2103 CTH0 automatic reset (ON: reset; OFF: not reset)
Disable comparator matching output to R500/R504 (ON:
CR2104
Operation when disable; OFF: not disable)
high-speed Set comparator matching output to R500/R504 to OFF (ON:
CR2105
counter output; OFF: not output)
comparator Set comparator matching output to R500/R504 to ON (ON:
CR2106
CTC0 is ON output; OFF: not output)
Invert ON/OFF state of comparator matching output to R500/
CR2107
R504 each time when ON (ON: invert; OFF: not invert)

A-2 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

Disable comparator matching output to R500/R504 (ON:


CR2108
disable; OFF: not disable)
Operation when Set comparator matching output to R500/R504 to OFF (ON:
CR2109
high-speed output; OFF: not output)
counter Set comparator matching output to R500/R504 to ON (ON:
CR2110
comparator output; OFF: not output)
CTC1 is ON Invert ON/OFF state of comparator matching output to R500/
CR2111
R504 each time when ON (ON: invert; OFF: not invert)
CR2112 CTH0 automatic reset (ON: reset; OFF: not reset)
1-phase
High-speed w/o w/ 1x 2x 4x 2-pulse
CR2113 to counter CTH0 direction direction
CR2113 OFF ON OFF ON OFF ON
CR2115 counting input CR2114 OFF OFF ON ON OFF OFF
CR2115 OFF OFF OFF OFF ON ON
mode selection

CR2200 R CTH1 specific internal clock (1μs)

APPENDICES
CR2201 R CTH1 specific internal clock (10μs)
CR2202 R CTH1 specific internal clock (100μs)
CR2203 CTH1 automatic reset (ON: reset; OFF: not reset)
Disable comparator matching output to R501/R505 (ON:
CR2204
Operation when disable; OFF: not disable)
high-speed Set comparator matching output to R501/R505 to OFF (ON:
CR2205
counter output; OFF: not output)

List of Control Relays/Control Memories


comparator Set comparator matching output to R501/R505 to ON (ON:
CR2206
CTC2 is ON output; OFF: not output)
Invert ON/OFF output to R501/R505 each time when ON (ON:
CR2207
output; OFF: not output)
Disable comparator matching output to R501/R505 (ON:
CR2208
disable; OFF: not disable)
Operation when Set comparator matching output to R501/R505 to OFF (ON:
CR2209
high-speed output; OFF: not output)
counter Set comparator matching output to R501/R505 to ON (ON:
CR2210
comparator output; OFF: not output)
CTC3 is ON Invert ON/OFF state of comparator matching output to R501/
CR2211
R505 each time when ON (ON: invert; OFF: not invert)
CR2212 CTH1 automatic reset (ON: reset; OFF: not set)
1-phase
High-speed w/o w/ 1x 2x 4x 2-pulse
CR2213 to counter CTH1 direction direction
CR2213 OFF ON OFF ON OFF ON
CR2215 counting input CR2214 OFF OFF ON ON OFF OFF
CR2215 OFF OFF OFF OFF ON ON
mode selection

CR2300 Disable external output (ON: disable; OFF: not disable)


CR2301 Disable external input change (ON: disable; OFF: not disable)
CR2302 Disable external output during interrupt (ON: disable; OFF: not disable)
CR2303 Fixed scan time operation (ON: enable; OFF: disable)
Only 1 scan is started when scan time setting (fixed scan time operation/END
CR2304 R
processing time setting) overflows
CR2305 Set input time constants of all inputs of CPU unit (ON: set -> CM1620; OFF: not set [10ms])

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-3


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CR2306 R ON when backup battery is abnormal


CR2307 Clear Min./Max. value of scan time
CR2308 END processing time setting (ON: enable; OFF: disable)
CR2309 to CR2312 - Reserved for system
VT sensor application screen forced changeover (Change: ON, disable
CR2313
change: OFF)
CR2314 - Reserved for system
In battery-less operation (during normal operation: OFF, during battery-less
CR2315 R
operation: ON)

Not used Up Down Level


CTH0 external
CR2400, CR2401 CR2400 OFF ON OFF ON
signal preset CR2401 OFF OFF ON ON

CR2402 Select CTH0 counter method (ON: ring; OFF: linear)


CR2403 Detect CTH0 overflow/underflow (ON: detected; OFF: not detected)

Not used Up Down Level


APPENDICES

CTH1 external
CR2404, CR2405 CR2404 OFF ON OFF ON
signal preset CR2405 OFF OFF ON ON

CR2406 Select CTH1 counter mode (ON: ring; OFF: linear)


CR2407 Detect CTH0 overflow/underflow (ON: detected: OFF: not detected)
CR2408 CTH 0 preset disable (ON: disable; OFF: not disable)
CR2409 CTH1 preset disable (ON: disable; OFF: not disable)
CR2410 CTH0 internal starting relay (ON: enable counting; OFF: disable counting)
List of Control Relays/Control Memories

CR2411 CTH1 internal starting relay (ON: enable counting; OFF: disable counting)
CR2412 R CTH0 counting direction (ON: up; OFF: down)
CR2413 R CTH1 counting direction (ON: up; OFF: down)
CR2414 R CTH0 specific internal clock (50ns)
CR2415 R CTH1 specific internal clock (50ns)
CR2500 Operation start (ON: start; OFF: not start)
Input Single-phase Single phase 2-phase
2-pluse
without direction with direction 1-multiple
CR2501, CR2502 source CR2501 OFF ON OFF ON
Frequency CR2502 OFF OFF ON ON
setting
counter (CTH0)
CR2503 Hz/rpm conversion (ON: rpm OFF: Hz)
Use the function of updating rotating speed per revolution
CR2504
(ON: use; OFF: not use)
CR2505 CTH0 comparator matching output relay switching (ON: R504; OFF: R500)
CR2506 Specified frequency pulse output (CTH0) (ON: output; OFF: not output)
CR2507 Specified frequency pulse output (CTH0) error
CR2508 Operation start (ON: start; OFF: not start)
Input Single-phase Single phase 2-phase
2-pulse
without direction with direction 1-multiple
CR2509, CR2510 source CR2509 OFF ON OFF ON
Frequency CR2510 OFF OFF ON ON
setting
counter (CTH1)
CR2511 Hz/rpm conversion (ON: rpm OFF: Hz)
Use the function of updating rotating speed per revolution
CR2512
(ON: use; OFF: not use)
CR2513 CTH1 comparator matching output relay switching˄ON: R505; OFF: R501˅
CR2514 Specified frequency pulse output (CTH1) (ON: output; OFF: not output)
CR2515 Specified frequency pulse output (CTH1) error

A-4 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

Both rising edge/


Rising edge Falling edge
falling edge
CR2600/CR2601 INT R000 interrupt polarity CR2600 OFF ON OFF ON
CR2601 OFF OFF ON ON

CR2602, CR2603 INT R001 interrupt polarity (same as CR2600/CR2601)


CR2604, CR2605 INT R002 interrupt polarity (same as CR2600/CR2601)
CR2606, CR2607 INT R003 interrupt polarity (same as CR2600/CR2601)
CR2608, CR2609 INT R004 interrupt polarity (same as CR2600/CR2601)
CR2610, CR2611 INT R005 interrupt polarity (same as CR2600/CR2601)
CR2612, CR2613 INT R006 interrupt polarity (same as CR2600/CR2601)
CR2614, CR2615 INT R007 interrupt polarity (same as CR2600/CR2601)
CR2700, CR2701 INT R008 interrupt polarity (same as CR2600/CR2601)
CR2702, CR2703 INT R009 interrupt polarity (same as CR2600/CR2601)
CR2704 to CR2715 - Reserved for system
CR2800 Send break signal (send when ON)
CR2801 R 1 scan ON when receiving text data

APPENDICES
CR2802 R Text data read error
Serial
CR2803 R 1 scan ON when text data receive error occurs
communication
CR2804 Start text data sending (ON during sending)
CR2805 Receive text data in word (ON: execute; OFF: not execute)
CR2806 Send text data in word (ON: execute; OFF: not execute)
CR2807 to CR2813 - Reserved for system
Zero suppression during execution of DASC instruction (full suffix) or FASC
CR2814
instruction (ON: execute; OFF: not execute)

List of Control Relays/Control Memories


"+" sign is omitted during execution of DASC.S, DASC.L and FASC instruction
CR2815
(ON: execute; OFF: not execute)
CR2900 User message display 1 (ON: display; OFF: not display)
Access window
CR2901 User message display 2 (ON: display; OFF: not display)
CR2902 to CR2915 - Reserved for system
CR3000 Limit switch CW direction input
CR3001 Limit switch CCW direction input
CR3002 Origin sensor input
CR3003 Stop sensor input
CR3004 R Origin return in progress
CR3005 R Origin return complete
CR3006 Positioning complete relay
CR3007 CPU positioning Error/error clear
CR3008 function X axis Alarm/alarm clear
CR3009 Pulse output in progress/emergency stop
CR3010 Drive operation start
CR3011 Current value change request (level detection)
CR3012 Operating speed change request (level detection)
CR3013 Comparator 2 matching relay
CR3014 -
Reserved for system
CR3015 -

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-5


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CR3100 Limit switch CW direction input


CR3101 Limit switch CCW direction input
CR3102 Origin sensor input
CR3103 Stop sensor input
CR3104 R Origin return in progress
CR3105 R Origin return complete
CR3106 Positioning complete relay
CR3107 CPU positioning Error/error clear
CR3108 function Y axis Alarm/alarm clear
CR3109 Pulse output in progress/emergency stop
CR3110 Drive operation start
CR3111 Current value change request (level detection)
CR3112 Operating speed change request (level detection)
CR3113 Comparator 2 matching relay
CR3114 -
Reserved for system
CR3115 -
APPENDICES

CR3200 to CR3209 - Reserved for system


CR3210 R Arbitary logging in progress
CR3211 R Memory card in use
CR3212 R Memory card identifying complete
CR3213 R With memory card
CR3214 R Memory card instruction execution in progress
CR3215 R Memory card write protection (ON: Write protection enable OFF: Write protection not enable)
List of Control Relays/Control Memories

CR3300 to CR3415 Alarm relay


CR3500 R Alarm relay in operation (it will be ON when any of CR3300 to CR3415 is ON)
CR3501 Log when alarm relay changes from ONėOFF (ON: retain; OFF: not retain)
CR3502 When OFFėON, alarm relay log is cleared
CR3503 to CR3513 - Reserved for system
CR3514 Multi-key disable
HKEY instruction
CR3515 R Scan complete
CR3600 to CR3615 R Info storage area of HKEY instruction

A-6 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CR3700 F1 customize switch 1


CR3701 F2 customize switch 2
CR3702 F3 customize switch 3
CR3703 F4 customize switch 4
CR3704 LED1 customize lamp 1
CR3705 LED2 customize lamp 2
CR3706 LED3 customize lamp 3
CR3707 LED4 customize lamp 4
CR3708 Green lamp (lit when ON)
CR3709 Operation panel Red lamp (lit when ON)
CR3710 KV-D30 System info display language (ON: Japanese; OFF: English)
CR3711 Buzzer ON
CR3712 Screen display setting (ON: normal display; OFF: highlight)
CR3713 Alarm interrupt enable (ON: enable; OFF: disable)
Screen switching (switch to the screen where CM0401 value
CR3714
is located, forced OFF)

APPENDICES
Disable screen switching throught "Ʒ" "ͩ" keys (ON:
CR3715
disable; OFF: enable)
CR3800 In ON state, external output 0 will also be in ON state
CR3801 In ON state, external output 1 will also be in ON state
CR3802 to CR3815 - Reserved for system
CR3900 Clear error log when OFFėON
CR3901 Clear alarm log when OFFėON

List of Control Relays/Control Memories


CR3902 R Maximum number of error logs
CR3903 R Maximum number of alarm logs
CR3904 R State of RUN/PRG toggle switch (ON: RUN side; OFF: PROG side)
CR3905 R Error occurring
CR3906 R Alarm occurring
CR3907 Clear power ON log when OFFėON
CR3908 Clear power OFF log when OFFėON
CR3909 Clear error that is occuring (Only SET/RES instruction)
CR3910 to CR3915 - Reserved for system

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-7


1 List of Control Relays/Control Memories

Control memory

Control memorys (CM0000 to CM5999) can be used to confirm operation state and setting of CPU unit,
and monitor various internal functions.
System reserved control memories cannot be used.
Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CM00000, CM00001 Set 1st line display device


CM0002, CM0003 Operation panel Set 2nd line display device
CM00004, CM00005 KV-D30 Set 3rd line display device
CM00006, CM00007 - screen 0 Set 4th line display device
CM0008, CM0009 Reserved for system
CM0010 to CM0199 Screen 1 to 19 (same as CM0000 to CM0009)
CM0200, CM0201 Set 1st line display attribute
CM0202, CM0203 Set 2nd line display attribute
Operation panel
CM0204, CM0205 Set 3rd line display attribute
KV-D30
CM0206, CM0207 Set 4th line display attribute
screen 0
CM0208 Set module 1
APPENDICES

CM0209 Set module 2


CM0210 to CM0399 Screen 1 to 19 (same as CM0200 to CM0209)
CM0400 Used for conversion enable/disable setting
CM0401 Used for screen switching setting
CM0402 Operation panel Current display screen
CM0403 to CM0409 KV-D30 Reserved for system
CM0410 to CM0415 Direct access function
CM0416 to CM0499 - Reserved for system
List of Control Relays/Control Memories

CM0500 to CM0699 - Reserved for system


CM0700 R (year)
CM0701 R (month)
CM0702 R (day)
Read from
CM0703 R (hour)
calendar timer
CM0704 R (Minute)
CM0705 R (second)
CM0706 R (week)
CM0707 - Reserved for system
CM0708, CM0709 R Free operation counter (32-bit, 1 ms)
CM0710 R Current bank No. of FM
CM0711 R "2" is stored for CPU function version 2.0, and "0" is stored in all other cases
CM0712 R Execution time of fixed period module (in 10μs)
CM0713 to CM0715 - Reserved for system
CM0716 Max. execution time of fixed period module (in 10μs)
CM0717 to CM0719 - Reserved for system
CM0720 R Scan time measurement value (in 10μs)
CM0721 Setting for operation at fixed scan time (in 10μs)
Scan time setting (Operation at fixed scan time/END processing time setting)
CM0722 R
Scan time measurement value (in 10μs)
CM0723 END processing time measurement value (in 10μs)
CM0724 to CM0725 - Reserved for system
CM0726 R Scan time min. value (in 10μs)
CM0727 R Scan time max. value (in 10μs)
CM0728 END processing time setting (in 10μs)
Scan time setting (operation at fixed scan time, END processing time setting)
CM0729
Scan time measurement value (in 10μs)
CM0730 to CM1479 - Reserved for system

A-8 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CM1480, CM1481 R Frequency measurement result (Hz or rpm)


Frequency counter
CM1482 Pulses per revolution
function (CTH0)
CM1483 Scan times
CM1484, CM1485 Specified frequency Set frequency (Hz)
CM1486 pulse output function Duty cycle (0 to 100%)
CM1487 to CM1489 - Reserved for system
CM1490, CM1491 R Frequency measurement result (Hz or rpm)
Frequency counter
CM1492 Number of pulses per rotation
function (CTH1)
CM1493 Scan times
CM1494, CM1495 Specified frequency Set frequency (Hz)
CM1496 pulse output function Duty cycle (0 to 100%)
CM1497 to CM1593 - Reserved for system
CM1594 CTH0 counting direction detection time constant
CM1595 CTH1 counting direction detection time constant
CM1596, CM1597 Lower limit of CTH0 ring counter
CM1598, CM1599 Lower limit of CTH1 ring counter
CM1600, CM1601 Upper limit value of CTH0 loop counter
CM1602, CM1603 Upper limit value of CTH1 loop counter

APPENDICES
CM1604, CM1605 CTH0 preset value
CM1606, CM1607 CTH1 preset value
CM1608 CTH0 start/reset/polarity setting
CM1609 CTH1 start/reset/polarity setting
CM1610, CM1611 R INT R000 Input capture (high level, low level)
CM1612, CM1613 R INT R001 Input capture (high level, low level)
CM1614, CM1615 R INT R002 Input capture (high level, low level)
CM1616, CM1617 R INT R003 Input capture (high level, low level)

List of Control Relays/Control Memories


CM1618, CM1619 - Reserved for system
CM1620 Input time constant setting
CM1621 to CM1649 Reserved for system
CM1650 R Number of executed sensor setting instructions
CM1651 to CM1659 Reserved for system
CM1660 to CM1669 R Residual capacity of logging/tracing ring buffer (ID0 to ID10)
CM1670 to CM1679 - Reserved for system
CM1680 to CM1689 R Logging/tracing file storage counter (ID0 to ID10)
CM1690 to CM1699 - Reserved for system
CM1700, CM1701 Digital trimmer 0 upper limit
CM1702, CM1703 Digital trimmer 1 upper limit
CM1704, CM1705 Digital trimmer 2 upper limit
CM1706, CM1707 Digital trimmer 3 upper limit
CM1708, CM1709 Digital trimmer 4 upper limit
CM1710, CM1711 Digital trimmer 5 upper limit
CM1712, CM1713 Digital trimmer 6 upper limit
CM1714, CM1715 Digital trimmer 7 upper limit
CM1716 to CM1719 Reserved for system
CM1720 User message 1
CM1721 to CM1737 User message 2 (max. 24 characters + end code (00 H) )
Acess window
CM1738 Operation disable setting
CM1739 - Reserved for system
CM1740 to CM1756 LD project name (max. 32 characters + end code (00 H) )
CM1757 to CM1763 Project name displayed in access window (max. 12 characters + end code (00 H) )
CM1764 to CM1774 Bluetooth device identification name (max. 20 characters + end code (00H))*1
CM1775 to CM1779 - Reserved for system
CM1780 AW initial screen setting Valid
CM1781 AW initial screen setting Device type
*1 Supported only by CPU unit compatible with Bluetooth communication.

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-9


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CM1782,CM1783 AW initial screen setting Screen ID


CM1784,CM1785 AW initial screen setting Device number
CM1786 AW initial screen setting Display format
CM1787 AW initial screen setting Device name notation
CM1788 AW initial screen setting Key lock state
CM1789 AW initial screen setting Display language
CM1790 Automatically loaded folder number at power ON (request)
CM1791 Automatically loaded folder number at power ON (complete)
CM1792 Automatically loaded folder number at PROGėRUN (request)
CM1793 Automatically loaded folder number at PROGėRUN (complete)
CM1794 to CM1799 Reserved for system
Year/month (DEC, lower 2 digits indicate "month", hundred
CM1800 digit and above indicate "year".

Error log Example: 706 ė June 2007


CM1801 Day
(latest)
CM1802 Hour (0 to 23)
CM1803 Minute
CM1804 error No.
APPENDICES

CM1805 to CM1899 Error Log (2 to 20 same as CM1800 to CM1804)


Year/month (DEC, low 2 digits indicate "month", hundred
CM1900 digit and above indicate "year".

Power ON log Example: 706 ė June 2007


CM1901 Day
(latest)
CM1902 Hour (0 to 23)
CM1903 Minute
CM1904 Second
List of Control Relays/Control Memories

CM1905 to CM1999 Power ON log (2 to 20 same as CM1900 to CM1904)


CM2000 I/O setting
CM2001 Sensor start
CM2002, CM2003 Comparator 0
CM2004, CM2005 Comparator 1
CM2006 Origin return: starting speed
CM2007 Origin return: acceleration/deceleration time
CM2008, CM2009 Origin return: operating speed
CM2010 JOG operation: starting speed
CM2011 JOG operation: acceleration/deceleration time
CPU
CM2012, CM2013 JOG operation: operating speed
Positioning function
CM2014, CM2015 Current value change setting
X axis
CM2016, CM2017 Operating speed change setting
CM2018 Origin return detailed setting
CM2019 Point No. during operation (M code)
CM2020, CM2021 R Current position
CM2022, CM2023 R Current speed
CM2024 error No.
CM2025 Specified point No.
CM2026, CM2027 fixed position coordinate setting
CM2028, CM2029 Comparator 2

A-10 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

CM2030 I/O setting


CM2031 Sensor start
CM2032, CM2033 Comparator 0
CM2034, CM2035 Comparator 1
CM2036 Origin return: starting speed
CM2037 Origin return: acceleration/deceleration time
CM2038, CM2039 Origin return: operating speed
CM2040 JOG operation: starting speed
CM2041 JOG operation: acceleration/deceleration time
CPU
CM2042, CM2043 JOG operation: operating speed
Positioning function
CM2044, CM2045 Current value change setting
Y axis
CM2046, CM2047 Operating speed change setting
CM2048 Origin return detailed setting
CM2049 Point No. during operation (M code)
CM2050, CM2051 R Current position
CM2052, CM2053 R Current speed
CM2054 error No.
CM2055 Specified point No.

APPENDICES
CM2056, CM2057 Fixed position coordinate setting
CM2058, CM2059 Comparator 2
CM2060, CM2061 Target value/movement
CM2062 Starting speed
CPU
CM2063 Acceleration/deceleration time
Positioning function
CM2064, CM2065 Operating speed
point
CM2066 Execution mode
Parameter 0
CM2067 Specified number of pulses for stop sensor

List of Control Relays/Control Memories


CM2068, CM2069 Reserved for system
CM2070 to CM2379 Point parameters 1 to 31 ( same as CM2060 to CM2069)
CM2380 to CM2389 - Reserved for system
CM2390 R error No. used for memory card instruction
CM2391 Power OFF during memory card access (When occuring: a value other than 0)
CM2392 Number of memory card retries (held even during power OFF)
CM2393 Number of memory card verify errors (held even during power OFF)
CM2394 Number of memory card timeouts (held even during power OFF)
Reset delay time during memory card error
CM2395
(ms unit, upper limit 10000[10 sec], reset disabled when 65535 is set)
CM2396 to CM2399 Reserved for system
Interrupt times (INT0 to INT3, CTC2, CTC3, CTC0, CTC1, positioning X axis,
CM2400 to CM2416
positioning Y axis, INT4 to INT9, fixed period module)
CM2417 to CM2999 - Reserved for system
CM3000 Text receiving times
CM3001 to CM3999 Text receiving data (1998 bytes)
CM4000 Text sending times
CM4001 to CM4999 Text sending data (1998 bytes)
Year/month (DEC, lower 2 digits indicate "month", hundred
CM5000 digit and above indicate "year".

Power OFF log Example: 706ė June 2007


CM5001 Day
(latest)
CM5002 Hour (0 to 23)
CM5003 minute
CM5004 Second
CM5005 to CM5099 Power OFF log (2 to 20 same as CM5000 to CM5004)

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-11


1 List of Control Relays/Control Memories

Attributes
Device No. ˮ: Read only. Function
Blank: R/W

Year/month (DEC, lower 2 digits indicates month, hundred


CM5100 digit above is year. ǂǂ
Example: 706 ė June 2007
CM5101 day
CM5102 hour
CM5103 minute
CM5104 Latest error second
CM5105 detailed info 1 * error No.
CM5106 Number of enabled data for expansion info
CM5107 Expansion info 1*
CM5108 Expansion info 2*
: :
: :
CM5126 Expansion info 20*
Year/month (DEC, lower 2 digits indicate "month", hundred
CM5150 digit and above indicate "year". ǂǂ
Example: 706 -> June 2007
APPENDICES

CM5151 day
CM5152 hour
CM5153 minute
CM5154 Latest alarm second
CM5155 detailed info 1 * error No.
CM5156 Enabled data for expansion info
CM5157 Expansion info 1*
List of Control Relays/Control Memories

CM5158 Expansion info 2*


: :
: :
CM5176 Expansion info 20*
CM5177 to CM5999 - Reserved for system
* Expansion info may change to the content on next page according to error No.

A-12 - KV-5500/5000/3000/1000 Series Script Programming Manual -


1 List of Control Relays/Control Memories

• No.128 (operation error)


Expansion info n Description
Expansion info 1 Detailed error content
0 (Not used)
1 Indirect specifying unreasonable
2 The indirectly specified destination is T/C
3 Indirect specifying unreasonable
4 Operand out of range
5 Floating real number overflow
6 Device specifying unreasonable
7 Argument of ROOT instruction is negative
8 No ON bit in ENCO instruction
9 Floating real number format abnormal
10 Trigonometric function instruction argument is unreasonable
11 Inconvertible data
12 Table specifying unreasonable
13 Time comparison instruction argument is unreasonable
14 Cam switch operand unreasonable
15 Frequency counter instruction argument is unreasonable
16 Divide by 0

APPENDICES
17 Logging ID incorrect
18 Direct Processing error
19 Unit cannot be processed directly
20 No jump destination sub-routine exists
21 Since writing is in progress during RUN mode, instruction cannot be executed
22 Expansion unit specific instruction destination error (unit No.)
23 Reserved for system
24 PIDAT operation setting out of range

List of Control Relays/Control Memories


25 PIDAT sampling cycle out of range
26 PIDAT proportional constant out of range
27 PIDAT integral constant out of range
28 PIDAT differential constant out of range
29 PIDAT proportional constant 2 degrees of freedom coefficient out of range
30 PIDAT integral constant 2 degrees of freedom coefficient out of range
31 PIDAT differential constant 2 degrees of freedom coefficient out of range
32 PIDAT operation amount upper/lower limit out of range
33 PIDAT operation amount fluctuation width limit value out of range
34 PIDAT measured value fluctuating width out of range
35 PIDAT AT status transition error
36 PIDAT operation control flag out of range
37 Operation cycle over
38 PIDAT AT adjustment parameter out of range
39 PIDAT AT hysteresis out of range
40 PIDAT AT timeout time out of range
41 PIDAT AT calculation control method setting out of range
42 PIDAT AT timeout
43 PIDAT AT proportional constant exceeded
44 PIDAT AT integral constant exceeded
45 PIDAT AT differential constant exceeded
46 Can't operate power root of negative number
47 ABS instruction argument is inappropriate
48 Operation overflow
Expansion info 2 00H fixed
Expansion info 3 Higher bit for the step No. of the curren error
Expansion info 4 Lower bit for the step No. of the current error
Expansion info 5 to 20 Module name stored in SJIS format. (The part other than module name is 00H)

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-13


1 List of Control Relays/Control Memories

• No.50,53,55,56,58,59 (unit ID related error)


Expansion info n Description
Expansion info 1 Unit No. (not stored when unit No. cannot be determined due to conditions of some errors)
Expansion info 2 to 20 00H fixed

• No.54 (number of units related error)


Expansion info n Description
Expansion info 1 The number of units in unit setting info
Expansion info 2 The number of units actually connected
Expansion info 3 to 20 00H fixed

• No.129 (Unit error)


Expansion info n Description
Expansion info 1 Unit No.
Expansion info 2 Unit error No.
Expansion info 3 to 20 00H fixed

• error No. other than above.


APPENDICES

Expansion info n Description


Expansion info 1 to 20 00H fixed
List of Control Relays/Control Memories

A-14 - KV-5500/5000/3000/1000 Series Script Programming Manual -


2 ASCII Code Table
List of ASCII codes is shown below.

High 4-bit

0 1 2 3 4 5 6 7 8 9 A B C D E F
N D S
0 U
L
L
E P 0 @ P ` p ー タ ミ
S D
1 O
H
C
1 ! 1 A Q a q 。 ア チ ム
S D
2 T
X
C
2 ” 2 B R b r 「 イ ツ メ
E D
3 T
X
C
3 # 3 C S c s 」 ウ テ モ
E D
4 O
T
C
4 $ 4 D T d t 、 エ ト ヤ
E N
5 N
Q
A
K % 5 E U e u 。 オ ナ ユ
A S
6 C
K
Y
N & 6 F V f v ヲ カ ニ ヨ
Low 4-bit

B E
7 E
L
T
B ’ 7 G W g w ァ キ ヌ ラ

APPENDICES
8 BS AN ( 8 H X h
C
x ィ ク ネ リ
9 HT EM ) 9 I Y i y ゥ ケ ノ ル
A LF UB
S
: J Z j z ェ コ ハ レ
B VT SC + ; K [ k {
E
ォ サ ヒ ロ
C FF → , < L ¥ l | ャ シ フ ワ

ASCII Code Table


D CR ← ー = M ] m } ュ ス ヘ ン
E SO ↑ . > N ^ n ~ ョ セ ホ ゛
D
F SI ↓ / ? O _ o E
L ッ ソ マ °

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-15


3 List of Unusable Characters
This section describes the characters that cannot be used in project names, module names, macro
names, labels and device comments.

ƽ The characters that cannot be used in destination names, module names and
macro names
! " # $ % &þ ( ) * , . / : ; < = > ?
Characters that cannot be used
@ [ \ ] ^ ÿ { | } ~ (Space)
Character that cannot be used at
+ - 0 1 2 3 4 5 6 7 8 9 _
leading position
Characters or character string that
_ _0 _1 _2 _3 _4 _5 _6 _7 _8 _9
cannot be used at end position
Unusable character string Global (case insensitive)

ƽ The character that cannot be used in mark


! " # $ % &þ ( ) * + , - . / : ; < = > ? @ [ \
Unusable character
] ^ _ ÿ{ǂ|ǂ}ǂ~ǂ (Space)
APPENDICES

The character cannot be used at


0 1 2 3 4 5 6 7 8 9
starting
Globall (case insensitive)
(Name identical to instruction)
(Device name)
g Letter 1 character + or + number
g Letter 1 character + number
List of Unusable Characters

g +( to )
g +( to )
g The following key words specified by KV script
g IF, THEN, ELSE, END, SELECT, CASE, IS, TO, MC, MCR, FOR,
NEXT, WHILE, DO, UNTIL, TYPE
g The following key words specified by IEC61131- 3
TRUE, FALSE
TIME, DATE,TIME_OF_DAY, TOD, DATE_AND_TIME, DT
Character strings that cannot be used BOOL, SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT,
REAL, LREAL, STRING, WSTRING, BYTE, WORD,
DWORD, LWORD
ANY, ANY_DERIVED, ANY_ELEMENTARY, ANY_MAGNITUDE,
ANY_NUM, ANY_REAL, ANY_INT, ANY_BIT, ANY_STRING,
ANY_DATE
ACTION, END_ACTION,
ARRAY, OF,
AT,
CASE, END_CASE,
CONFIGURATION, END_CONFIGURATION,
CONSTANT,
EN, ENO,
EXIT,

A-16 - KV-5500/5000/3000/1000 Series Script Programming Manual -


3 List of Unusable Characters

g F_EDGE,
FOR, TO, BY, DO, END_FOR,
FUNCTION, END_FUNCTION,
FUNCTION_BLOCK, END_FUNCTION_BLOCK,
IF, THEN, ELSIF, ELSE, END_IF,
INITIAL_STEP, END_STEP,
NOT, MOD, AND, XOR, OR,
PROGRAM, WITH, END_PROGRAM, R_EDGE,
READ_ONLY, READ_WRITE,
REPEAT, UNTIL, END_REPEAT,
RESOURCE, END_RESOURCE,
RETAIN, NON_RETAIN,
Unusable character string RETURN,
STEP,
STRUCT, END_STRUCT,
TASK,
TRANSITION, FROM, END_TRANSITION,

APPENDICES
TYPE, END_TYPE,
VAR,VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_TEMP,
VAR_EXTERNAL, VAR_ACCESS, VAR_CONFIG,VAR_GLOBAL,
END_VAR,
WHILE, DO, END_WHILE
g Others (IEC61131-3 specification)
g Consecutive 2 or above "_" should not appear label name.

List of Unusable Characters


For example, "a_b_c" is allowed, but "a__bc" is not allowed.

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-17


4 List of Unusable Functions
The functions which cannot be used in the initialization module, macro or interrupt program are
explained in this section.

ƽ Initialization module, interrupt program


Type of function Function
LDP/LDF Load pulse/load pulse fall
Contact functions
LDPB/LDFB Load pulse bar/load pulse fall bar
TMR/TMH/TMS/ Timer / high-speed timer / high-speed 1ms timer /
Timer counter
TMU high-speed 10μs timer
functions
C Counter
File register functions FRSTM/FRLDM File register batch save/ file register batch read
MWRIT/MREAD/ Write memory card / read memory card /
MFREE/MMKDIR get memory card open space / create memory card folder
MRMDIR/MDEL Delete memory card folder / delete memory card file
Memory card
MPRINT/MREADL/ Write memory card text / read one line of memory card /
functions
MCOPY/MMOV/ copy memory card file / move memory card file /
MREN/MFREEK/ rename memory card file / get memory card open space /
MSTAT get memory card status
APPENDICES

Access window
AWNUM/AWMSG User message 1 / user message 2
functions

ƽ Macros
Type of function Function
Macro functions MCALL/MSTRT Macro call / macro start
List of Unusable Functions

* The MEND (macro end) function is written in the self-holding type macro. It cannot be used in a module or sub-routine
type macro.

A-18 - KV-5500/5000/3000/1000 Series Script Programming Manual -


5 Index
(#) DEC constant •••••••••••••••••••••••••••••••• 3-30
A $ HEX constant •••••••••••••••••••••••••••••••••• 3-31
Double precision floating point type constant •••• 3-32
About assignment statement •••••••••••••••••••••1-10 Fixed text string (text string type constant) •••• 3-32
Bit assignment ••••••••••••••••••••••••••••••••••••1-10 Single precision floating point type constant •• 3-31
Numerical value assignment •••••••••••••••••••1-10 Control memory CM ••••••••••••••••••••••••• 3-26, A-8
Text string assignment ••••••••••••••••••••••••••1-10 Control relays CR •••••••••••••••••••••••••••• 3-16, A-2
About comments function •••••••••••••••••••••••••2-56 Control statement list •••••••••••••••••••••••••••••• 4-10
About control statement •••••••••••••••••••••••••••1-12 Copy area script •••••••••••••••••••••••••••••••••••• 2-24
Conditional transfer control statements ••••••1-12 Copy box script ••••••••••••••••••••••••••••••••••••• 2-12
Loop control statement ••••••••••••••••••••••••••1-13 Counter (contact) C •••••••••••••••••••••••••••••••• 3-15
About control statements nesting ••••••••••••••••4-32 Counter (current value) C ••••••••••••••••••••••••• 3-24
About infinite loop •••••••••••••••••••••••••••••••••••4-37 Customization ••••••••••••••••••••••••••••••••••••••• 2-60
About Input Auxiliary Function ••••••••••••••••••••2-51 Customizing script window •••••••••••••••••••• 2-60
About label suffix •••••••••••••••••••••••••••• 1-15, 2-33
About label type •••••••••••••••••••••••••••••••••••••2-32
About operation type •••••••••••••••••••••••••••••••3-48 D
About parallel connection of box script •••••••••2-40
About processing time •••••••••••••••••••••••••••••4-35 Data memory/Expansion data memory DM/EM/FM ••• 3-17
About script function ••••••••••••••••••••••••••••••••1-17 Data processing ••••••••••••••••••••••••••••••••••••••3-1
About suffix •••••••••••••••••••••••••••••••••••••••••••1-14 Data range processed by operation formula ••••• 3-48

APPENDICES
About the bit of global label •••••••••••••••••••••••2-33 Data type (suffix) ••••••••••••••••••••••••••••••••••• 3-40
About timer actions in a loop control statement •••••4-37 Delete area script ••••••••••••••••••••••••••••••••••• 2-23
Actual nesting actions ••••••••••••••••••••••••••••••4-34 Delete box script •••••••••••••••••••••••••••••••••••• 2-11
Application area of work devices •••••••••••••••••2-62 Device and constants ••••••••••••••••••••••••••••••••3-2
Application method of indirect specifying •••••••3-36 Device List •••••••••••••••••••••••••••••••••••••••••••••3-2
Area script •••••••••••••••••••••••••••••••••••••• 1-9, 2-16 Bit device •••••••••••••••••••••••••••••••••••••• 3-2, 3-4
Area script is used in the following cases ••••••2-16 Constant •••••••••••••••••••••••••••••••••••••••••••••3-7
Array •••••••••••••••••••••••••••••••••••••••••••••••••••2-35 DEC constant addressing ••••••••••••••••••••••••3-7

Index
ASCII Code list ••••••••••••••••••••••••••••••••••••• A-15 Device specifying ••••••••••••••••••••••••••••••••••3-6
Assignment setting of script work device •••••••2-61 Device specifying mode ••••••••••••••••••••••••••3-6
HEX constant addressing ••••••••••••••••••••••••3-7
Temporary data memory TM •••••••••••••••••• 3-23
B Word device •••••••••••••••••••••••••••••••••• 3-3, 3-5
Differences in CPU function version •••••••••••••••• 3
Batch register of local label •••••••••••••••••••••••2-31 Differences in CPU functions according to
Bit assignment •••••••••••••••••••••••••••••••••••••••1-10 CPU function version •••••••••••••••••••••••••••• 3
Bit assignment statement •••••••••••••••••••••••••• 4-2 Differences in Ethernet functions according to
Bit device •••••••••••••••••••••••••••••••••••3-2, 3-4, 3-8 CPU function version •••••••••••••••••••••••••••• 4
B ••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-11 Restrictions for using extended input/output unit •••• 4
LR (Latch relay) ••••••••••••••••••••••••••••••••••3-13 Direct input •••••••••••••••••••••••••••••••••••••••••••••2-3
MR ••••••••••••••••••••••••••••••••••••••••••••••••••3-12 DO to UNTIL •••••••••••••••••••••••••••••••••••••••• 4-29
R ••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-11 About difference between WHILE statement
Status of hold control bit device •••••••••••••••4-38 and DO statement •••••••••••••••••••••••••••• 4-30
Boolean value •••••••••••••••••••••••••••••••••••••••• 3-8 Double precision floating point type constant •••• 3-32
Box script •••••••••••••••••••••••••••••••••••••••• 1-8, 2-4
BREAK processing •••••••••••••••••••••••••••••••••4-31
E
C Error display in output window ••••••••••••••••••• 2-44
Error Message •••••••••••••••••••••••••••••••••••••• 2-42
Call function list •••••••••••••••••••••••••••••••••••••2-51 Error display in output window •••••••••••••••• 2-44
Change priority ••••••••••••••••••••••••••••••••••••••• 4-8 Error message when script conversion •••••• 2-42
Combination of index modification and indirect Function argument error ••••••••••••••••••••••• 2-43
specifying ••••••••••••••••••••••••••••••••••••••••••3-39 Specify invalid type •••••••••••••••••••••••••••••• 2-43
Comment writing method ••••••••••••••••••••••••••2-56 Syntax error ••••••••••••••••••••••••••••••••••••••• 2-43
Comparison operator priority •••••••••••••••••••••• 4-8 Typing error ••••••••••••••••••••••••••••••••••••••• 2-42
Conditional transfer control statements •••••••••1-12 When conversion error occurs •••••••••••••••• 2-44
Constant ••••••••••••••••••••••••••••••••••••••••••••••3-30
- KV-5500/5000/3000/1000 Series Script Programming Manual - A-19
5 Index

Error message when script conversion •••••••••2-42 IF ~ ELSE IF ••••••••••••••••••••••••••••••••••••••• 4-16


Example for indirect specifying •••••••••••••••••••3-38 Index modification •••••••••••••••••••••••••••••••••• 3-33
Modify the device with suffix ••••••••••••••••••• 3-34
Modify via index constant •••••••••••••••••••••• 3-34
F Modify via index register ••••••••••••••••••••••• 3-33
Modify via the device and expression ••••••• 3-34
Features of area script •••••••••••••••••••••••••••••2-16 Index modification and indirect specifying ••••• 3-33
Features of box script ••••••••••••••••••••••••••••••• 2-4 Index register Z ••••••••••••••••••••••••••••••••••••• 3-25
Features of KV script •••••••••••••••••••••••••••••••• 1-2 Indirect specifying (*) •••••••••••••••••••••••••••••• 3-35
File register ZF/FM •••••••••••••••••••••••••••••••••3-19 Indirect specifying principle ••••••••••••••••••••••• 3-35
Flow functions ••••••••••6-2, 6-4, 6-6, 6-7, 6-8, 6-11 Indirect specifying programming •••••••••••••••• 3-35
FOR to NEXT Statement (specified loop control Inline Mnemonics ••••••••••••••••••••••••••••••••••• 2-59
times) •••••••••••••••••••••••••••••••••••••••••••••••4-24 Input (How to input scripts) •••••••••••••••••••••••••2-3
Precautions on Using FOR to NEXT statement •••••4-26 Direct input ••••••••••••••••••••••••••••••••••••••••••2-3
When FOR to NEXT statements are imperatively Window input •••••••••••••••••••••••••••••••••••••••2-3
ended ••••••••••••••••••••••••••••••••••••••••••••4-26 Internal auxiliary relay R/B/MR/LR •••••••••••••• 3-11
Function •••••••••••••••••••••••••••••••••••••••••••••••1-17 Invalid index modification ••••••••••••••••••••••••• 3-35
About script function •••••••••••••••••••••••••••••1-17
Script function format hints •••••••••••••••••••••2-52
Script function list ••••••••••••••••••••••••••••••••2-51 L
Function argument error •••••••••••••••••••••••••••2-43
APPENDICES

Function Version ••••••••••••••••••••••••••••••••••••••••2 Label Array •••••••••••••••••••••••••••••••••••••••••• 2-35


Label Programming •••••••••••••••••••••••••••••••• 2-25
Link register W •••••••••••••••••••••••••••••••••••••• 3-21
G Link relay B •••••••••••••••••••••••••••••••••••••••••• 3-10
List of control relays/control memories •••••••••• A-2
Global label ••••••••••••••••••••••••••••••••••••••••••2-26 List of unusable characters ••••••••••••••••••••••• A-16
Global label array •••••••••••••••••••••••••••••••••••2-36 Local label ••••••••••••••••••••••••••••••••••••••••••• 2-29
Local label array •••••••••••••••••••••••••••••••••••• 2-38
Index

Loop control statement ••••••••••••••••••••• 1-13, 4-11


H loop control statement and processing time ••• 4-35
HELP Function ••••••••••••••••••••••••••••••••••••••2-53
High-speed counter (current value) CTH •••••••3-24 M
High-speed counter comparator (contact) CTC •••••3-16
High-speed counter comparator (setting value) Macro ••••••••••••••••••••••••••••••••••••••••••••••••• 2-47
CTC •••••••••••••••••••••••••••••••••••••••••••••••••3-25 Macro call •••••••••••••••••••••••••••••••••••••••••••• 2-47
How to input scripts •••••••••••••••••••••••••••••••••• 2-3 Calling self-hold type macro ••••••••••••••••••• 2-47
Direct input ••••••••••••••••••••••••••••••••••••••••• 2-3 Calling subroutine macro ••••••••••••••••••••••• 2-47
Window input •••••••••••••••••••••••••••••••••••••• 2-3 Making Area Script ••••••••••••••••••••••••••••••••• 2-18
How to process setting/current value of the counter •••3-16 Making Box Script ••••••••••••••••••••••••••••••••••••2-6
How to process setting/current value of the timer •••••3-15 MC to MCR •••••••••••••••••••••••••••••••••••••••••• 4-22
How to program script ••••••••••••••••••••••••••••••• 2-2 MC to MCR When using timer / counter function ••••• 4-45
How to Use An Assignment Statement •••••••••• 4-2 Monitor function ••••••••••••••••••••••••••••••••••••• 2-49
Numerical value assignment statement •••••• 4-2 Monitor window ••••••••••••••••••••••••••••••••••••• 2-50
Operation assignment statement •••••••••••••• 4-3
String assignment statement •••••••••••••••••••• 4-2
When it can not be assigned to left side •••••• 4-4 N
When the type on right side is different from
that on left side ••••••••••••••••••••••••••••••••• 4-4 New a area script ••••••••••••••••••••••••••••••••••• 2-19
How to Use KV Scripts •••••••••••••••••••••••••••••• 1-3 New a box script ••••••••••••••••••••••••••••••••••••••2-7
How to use output window ••••••••••••••••••••••••2-45

O
I
Omitting suffix ••••••••••••••••••••••••••••••••••••••• 1-15
I/O relay R ••••••••••••••••••••••••••••••••••••••••••••• 3-8 Operation assignment statement +=,-=,*=,/= •••4-3
IF ~ ••••••••••••••••••••••••••••••••••••••••••••••••••••4-12 Operation flag ••••••••••••••••••••••••••••••••••••••• 1-18
IF ~ ELSE ••••••••••••••••••••••••••••••••••••••••••••4-14 Operator •••••••••••••••••••••••••••••••••••••••••1-11, 4-6
A-20 - KV-5500/5000/3000/1000 Series Script Programming Manual -
5 Index

Operator list •••••••••••••••••••••••••••••••••••• 1-11, 4-6 Reserved word •••••••••••••••••••••••••••••••••••••• 2-53


Arithmetic operator ••••••••••••••••••••••••••••••• 4-6
Change priority •••••••••••••••••••••••••••••••••••• 4-8
Comparison operator ••••••••••••••••••••••••••••• 4-6 S
Comparison operator priority ••••••••••••••••••• 4-8
Differences between assignments statements Script ••••••••••••••••••••••••••••••••••••••••••••••••••••1-2
and compare operators ••••••••••••••••••••••• 4-9 Script conversion output message •••••••••••••• 2-41
Logic operator ••••••••••••••••••••••••••••••••••••• 4-7 Script function ••••••••••••••••••••••••••••••••••••••• 1-10
Logic operator priority •••••••••••••••••••••••••••• 4-8 Script function format hints ••••••••••••••••••••••• 2-52
String connection operator •••••••••••••••••••••• 4-6 Script function list ••••••••••••••••••••••••••••••••••• 2-51
The priority between multiplication, division, Script syntax and precautions ••••••••••••••••••••••4-1
addition, and subtraction •••••••••••••••••••••• 4-8 Script type •••••••••••••••••••••••••••••••••••••••••••••1-8
Operator priority •••••••••••••••••••••••••••••••••••••• 4-7 Script warning level setting ••••••••••••••••••••••• 2-41
Operator type ••••••••••••••••••••••••••••••••••••••••• 4-6 SELECT CASE •••••••••••••••••••••••••••••••••••• 4-18
Simple indirect specifying #TM •••••••••••••••••• 3-39
Single precision floating point type constant ••••• 3-31
P Specify timer function using box script ••••••••• 4-43
Precautions about use of counter device ••• 4-40
PRAGMA Directive •••••••••••••••••••••••••••••••••3-50 Timer/ Counter contact ••••••••••••••••••••••••• 4-41
Precautions about use of timer device ••••••••••4-40 Timer/ Counter current value reading •••••••• 4-40
Timer/ Counter contact ••••••••••••••••••••••••••4-41 Status bit •••••••••••••••••••••••••••••••••••••••••••••••3-8

APPENDICES
Timer/ Counter current value reading ••••••••4-40 String assignment •••••••••••••••••••••••••••••••••• 1-10
Precautions about use of timer function in String assignment statement •••••••••••••••••••••••4-2
Box Script and IF statement •••••••••••••••••••4-42 String connection operator ••••••••••••••••••••••••••4-6
Precautions on script programming ••••• 2-40, 4-38 Suffix •••••••••••••••••••••••••••••••••••••••••••••••••• 3-40
Precautions on using assignment statement ••• 4-4 About .B ••••••••••••••••••••••••••••••••••••••••••• 3-45
Precautions on using control statement ••••••••4-32 About .D and .L •••••••••••••••••••••••••••••••••• 3-42
About timer actions in a loop control statement •••••4-37 About .DF ••••••••••••••••••••••••••••••••••••••••• 3-44
loop control statement and processing time •••4-35 About .F ••••••••••••••••••••••••••••••••••••••••••• 3-43

Index
Precautions when programming script ••••••••••2-60 About .T ••••••••••••••••••••••••••••••••••••••••••• 3-45
Precautions when using box script ••••••••••••••2-13 About .U and .S •••••••••••••••••••••••••••••••••• 3-41
When using timer function ••••••••••••••••••••••2-14 Suffix type •••••••••••••••••••••••••••••••••••••••••••• 1-14
Precautions when using label ••••••••••••••••••••2-32
Presautions about the use of timer function ••• 3-14, 4-41
Precautions about use of timer function in Box T
Script and IF statement ••••••••••••••••••••••4-42
Processing bit device in word unit •••••••••••••••3-27 Text string type constant •••••••••••••••••••••••••• 3-32
Processing word device as bit device •••••••••••3-28 Fixed text string (text string type constant) •••• 3-32
Programming control statements with KV Scripts ••• 1-7 Timer (contact) T ••••••••••••••••••••••••••••••••••• 3-13
For multi-branch control ••••••••••••••••••••••••• 1-7 Timer (current value) T •••••••••••••••••••••••••••• 3-23
Programming example for device using suffix •••1-14 Timer error ••••••••••••••••••••••••••••••••••••••••••• 3-14
Programming flow using global label ••••••••••••2-26 Type conversion leads to data loss ••••••••••••• 2-41
Programming macro by using script •••••••••••••2-48 Type of indirect specifying device ••••••••••••••• 3-37
Programming operation processing with KV scripts •••• 1-3
Programming Script ••••••••••••••••••••••••••••••••• 2-1
Programming text string processing with KV Script ••••• 1-5
W
Warning message •••••••••••••••••••••••••••••••••• 2-41
R About warning leve •••••••••••••••••••••••••••••• 2-41
Script warning level setting •••••••••••••••••••• 2-41
Reedit area script •••••••••••••••••••••••••••••••••••2-22 Setting method of warning level •••••••••••••• 2-41
Reedit box script •••••••••••••••••••••••••••••••••••• 2-11 When looking up notes on indirect specifying
Register global label ••••••••••••••••••••••••••••••••2-26 and index modification •••••••••••••••••••••••••• 1-18
Register local label •••••••••••••••••••••••••••••••••2-29 Every function operation table when invalid
Register monitor •••••••••••••••••••••••••••••••••••••2-49 address is specified •••••••••••••••••••••••••• 1-18
Relay •••••••••••••••••••••••••••••••••••••••••••••••••• 3-11 When processing as the bit device at any bit •••• 3-28
I/O relay R •••••••••••••••••••••••••••••••••••••••••• 3-8 When processing as the bit device at the
Internal auxiliary relay R/B/MR/LR •••••••••••• 3-11 lowerest bit •••••••••••••••••••••••••••••••••••••••• 3-28

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-21


5 Index

When using box scripts in the following cases •••• 2-4


When using differential execution type functions •••2-13
When using operation functions •••••••••••••••••• 1-4
When using operators ••••••••••••••••••••••••••••••• 1-3
When using string operator •••••••••••••••••••••••• 1-5
When using text string processing function ••••• 1-6
When using timer function ••••••••••••••••••••••••2-14
When WHILE statement is imperatively
terminated •••••••••••••••••••••••••••••••••••••••••4-28
When work devices are insufficient ••••••••••••••2-62
The range that can be specified by STEP •••4-26
When specifying floating point constant with
STEP ••••••••••••••••••••••••••••••••••••••••••••4-26
WHILE~ •••••••••••••••••••••••••••••••••••••••••••••••4-27
Window input ••••••••••••••••••••••••••••••••••••••••• 2-3
Word device •••••••••••••••••••••••••••••• 3-3, 3-5, 3-17
Work device ••••••••••••••••••••••••••••••••••••••••••2-61
Write easy-reading script ••••••••••••••••••••••••••2-57

X
APPENDICES

XYM Marking ••••••••••••••••••••••••••••••••••••••••2-64


Index

A-22 - KV-5500/5000/3000/1000 Series Script Programming Manual -


6 Functions Index
DI ••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-72
A DIC ••••••••••••••••••••••••••••••••••••••••••••••••••• 8-74
DISB ••••••••••••••••••••••••••••••••••••••••••••••••• 7-98
ABS •••••••••••••••••••••••••••••••••••••••••••••••••••7-38 DISF ••••••••••••••••••••••••••••••••••••••••••••••••7-130
ACOS •••••••••••••••••••••••••••••••••••••••••••••• 7-152 DISN ••••••••••••••••••••••••••••••••••••••••••••••••• 7-94
ADRADD ••••••••••••••••••••••••••••••••••••••••••••6-24 DISS ••••••••••••••••••••••••••••••••••••••••••••••••7-244
ADRDEC ••••••••••••••••••••••••••••••••••••••••••••6-22 DMX•••••••••••••••••••••••••••••••••••••••••••••••••• 7-88
ADRINC •••••••••••••••••••••••••••••••••••••••••••••6-20 DSER •••••••••••••••••••••••••••••••••••••••••••••••• 8-12
ADRSET •••••••••••••••••••••••••••••••••••••••••••••6-18
ADRSUB•••••••••••••••••••••••••••••••••••••••••••••6-26
AJST •••••••••••••••••••••••••••••••••••••••••••••••••8-70 E
ANDA ••••••••••••••••••••••••••••••••••••••••••••••••7-24
APR•••••••••••••••••••••••••••••••••••••••••••••••••••7-72 ECALL •••••••••••••••••••••••••••••••••••••••••••••••••6-4
ASC••••••••••••••••••••••••••••••••••••••••••••••••• 7-156 EI ••••••••••••••••••••••••••••••••••••••••••••••••••••• 8-72
ASIN •••••••••••••••••••••••••••••••••••••••••••••••• 7-150 ENCO •••••••••••••••••••••••••••••••••••••••••••••••7-108
ASLA •••••••••••••••••••••••••••••••••••••••••••••••••7-48 ENRA •••••••••••••••••••••••••••••••••••••••••••••••• 7-30
ASRA •••••••••••••••••••••••••••••••••••••••••••••••••7-46 EORA •••••••••••••••••••••••••••••••••••••••••••••••• 7-28
ATAN ••••••••••••••••••••••••••••••••••••••••••••••• 7-154 EXP •••••••••••••••••••••••••••••••••••••••••••••••••7-134
AVG ••••••••••••••••••••••••••••••••••••••••••••••••••8-18
AWMSG ••••••••••••••••••••••••••••••••••••••••••• 8-110
AWNUM ••••••••••••••••••••••••••••••••••••••••••• 8-108 F
FASC •••••••••••••••••••••••••••••••••••••••••••••••7-174
B

APPENDICES
FDEL ••••••••••••••••••••••••••••••••••••••••••••••••• 8-62
FIFOR ••••••••••••••••••••••••••••••••••••••••••••••• 8-46
BANDC ••••••••••••••••••••••••••••••••••••••••••••••7-68 FIFOW ••••••••••••••••••••••••••••••••••••••••••••••• 8-42
BCMP ••••••••••••••••••••••••••••••••••••••••••••••••8-32 FIND ••••••••••••••••••••••••••••••••••••••••••••••••7-240
BCMPI •••••••••••••••••••••••••••••••••••••••••••••••8-34 FINS ••••••••••••••••••••••••••••••••••••••••••••••••• 8-60
BCNT •••••••••••••••••••••••••••••••••••••••••••••••••• 8-6 FLOAT •••••••••••••••••••••••••••••••••••••••••••••• 7-118
BLD •••••••••••••••••••••••••••••••••••••••••••••••••••• 5-8 FMOV ••••••••••••••••••••••••••••••••••••••••••••••••••7-4
BLDB •••••••••••••••••••••••••••••••••••••••••••••••••5-10 FRLDM •••••••••••••••••••••••••••••••••••••••••••••• 6-32
BMOV ••••••••••••••••••••••••••••••••••••••••••••••••• 7-2 FRSET••••••••••••••••••••••••••••••••••••••••••••••• 6-28
BOUB ••••••••••••••••••••••••••••••••••••••••••••••••5-16 FRSTM •••••••••••••••••••••••••••••••••••••••••••••• 6-30

Functions Index
BOUT ••••••••••••••••••••••••••••••••••••••••••••••••5-14 FWRIT ••••••••••••••••••••••••••••••••••••••••••••••• 8-58
BRES •••••••••••••••••••••••••••••••••••••••••••••••••5-20
BSET •••••••••••••••••••••••••••••••••••••••••••••••••5-18
BSL •••••••••••••••••••••••••••••••••••••••••••••••••••7-64 G
BSR•••••••••••••••••••••••••••••••••••••••••••••••••••7-62
BSUM ••••••••••••••••••••••••••••••••••••••••••••••••8-24 GRY •••••••••••••••••••••••••••••••••••••••••••••••••• 7-90
BSWAP •••••••••••••••••••••••••••••••••••••••••••• 7-104
BYBMOV ••••••••••••••••••••••••••••••••••••••••••••7-12
BYLMOV•••••••••••••••••••••••••••••••••••••••••••••7-14
H

C HASC •••••••••••••••••••••••••••••••••••••••••••••••7-168

CALL •••••••••••••••••••••••••••••••••••••••••••••••••• 6-2


CHR •••••••••••••••••••••••••••••••••••••••••••••••• 7-248
I
CNT•••••••••••••••••••••••••••••••••••••••••••••••••••5-30
COM ••••••••••••••••••••••••••••••••••••••••••••••••••7-32 INC ••••••••••••••••••••••••••••••••••••••••••••••••••• 7-16
COS •••••••••••••••••••••••••••••••••••••••••••••••• 7-146 INSERT ••••••••••••••••••••••••••••••••••••••••••••7-207
CPMGET •••••••••••••••••••••••••••••••••••••••••• 7-116 INSTR ••••••••••••••••••••••••••••••••••••••••••••••7-236
CPMSET••••••••••••••••••••••••••••••••••••••••••• 7-114 INT ••••••••••••••••••••••••••••••••••••••••••••••••••7-128
CPSASC ••••••••••••••••••••••••••••••••••••••••••• 7-250 INTG ••••••••••••••••••••••••••••••••••••••••••••••••7-126
CRC ••••••••••••••••••••••••••••••••••••••••••••••••••8-26

L
D
LDF•••••••••••••••••••••••••••••••••••••••••••••••••••••5-4
DASC •••••••••••••••••••••••••••••••••••••••••••••• 7-160 LDFB •••••••••••••••••••••••••••••••••••••••••••••••••••5-7
DCNT ••••••••••••••••••••••••••••••••••••••••••••••••• 8-8 LDP ••••••••••••••••••••••••••••••••••••••••••••••••••••5-2
DEC ••••••••••••••••••••••••••••••••••••••••••••••••••7-18 LDPB ••••••••••••••••••••••••••••••••••••••••••••••••••5-6
DECO •••••••••••••••••••••••••••••••••••••••••••••• 7-106 LEFT ••••••••••••••••••••••••••••••••••••••••••••••••7-194
DEG •••••••••••••••••••••••••••••••••••••••••••••••• 7-142 LEN •••••••••••••••••••••••••••••••••••••••••••••••••7-184
DELETE ••••••••••••••••••••••••••••••••••••••••••• 7-212 LIFOR ••••••••••••••••••••••••••••••••••••••••••••••• 8-54
DFLOAT ••••••••••••••••••••••••••••••••••••••••••• 7-122 LIFOW ••••••••••••••••••••••••••••••••••••••••••••••• 8-50
- KV-5500/5000/3000/1000 Series Script Programming Manual - A-23
6 Functions Index

LIMIT •••••••••••••••••••••••••••••••••••••••••••••••••7-66 RFSX •••••••••••••••••••••••••••••••••••••••••••••••• 5-32


LLFLT ••••••••••••••••••••••••••••••••••••••••••••••••7-80 RFSY •••••••••••••••••••••••••••••••••••••••••••••••• 5-33
LOG •••••••••••••••••••••••••••••••••••••••••••••••• 7-136 RGRY •••••••••••••••••••••••••••••••••••••••••••••••• 7-92
LOG10 ••••••••••••••••••••••••••••••••••••••••••••• 7-138 RHASC •••••••••••••••••••••••••••••••••••••••••••••7-172
LOGD ••••••••••••••••••••••••••••••••••••••••••••••••8-78 RIGHT ••••••••••••••••••••••••••••••••••••••••••••••7-190
LOGE ••••••••••••••••••••••••••••••••••••••••••••••••8-78 RLA •••••••••••••••••••••••••••••••••••••••••••••••••• 7-52
LTRIM •••••••••••••••••••••••••••••••••••••••••••••• 7-218 RLNCA •••••••••••••••••••••••••••••••••••••••••••••• 7-56
RND •••••••••••••••••••••••••••••••••••••••••••••••••• 8-36
ROOT •••••••••••••••••••••••••••••••••••••••••••••••• 7-20
M RRA •••••••••••••••••••••••••••••••••••••••••••••••••• 7-50
RRNCA •••••••••••••••••••••••••••••••••••••••••••••• 7-54
MAX ••••••••••••••••••••••••••••••••••••••••••••••••••8-14 RSEC •••••••••••••••••••••••••••••••••••••••••••••••• 8-68
MCALL •••••••••••••••••••••••••••••••••••••••••••••••• 6-6 RTRIM ••••••••••••••••••••••••••••••••••••••••••••••7-220
MCOPY •••••••••••••••••••••••••••••••••••••••••••• 8-100
MDEL ••••••••••••••••••••••••••••••••••••••••••••••••8-94
MDSTOP •••••••••••••••••••••••••••••••••••••••••••• 6-11 S
MDSTRT•••••••••••••••••••••••••••••••••••••••••••••6-10
MEND ••••••••••••••••••••••••••••••••••••••••••••••••• 6-8 SDEL •••••••••••••••••••••••••••••••••••••••••••••••7-208
MFREE ••••••••••••••••••••••••••••••••••••••••••••••8-84 SEC •••••••••••••••••••••••••••••••••••••••••••••••••• 8-66
MFREEK•••••••••••••••••••••••••••••••••••••••••••••8-86 SEG ••••••••••••••••••••••••••••••••••••••••••••••••••••8-2
MID ••••••••••••••••••••••••••••••••••••••••••••••••• 7-198 SER •••••••••••••••••••••••••••••••••••••••••••••••••• 8-10
MIN •••••••••••••••••••••••••••••••••••••••••••••••••••8-16 SET •••••••••••••••••••••••••••••••••••••••••••••••••• 5-12
MMKDIR •••••••••••••••••••••••••••••••••••••••••••••8-88 SFIND ••••••••••••••••••••••••••••••••••••••••••••••7-228
APPENDICES

MMOV•••••••••••••••••••••••••••••••••••••••••••••• 8-102 SFINDN ••••••••••••••••••••••••••••••••••••••••••••7-232


MPRINT •••••••••••••••••••••••••••••••••••••••••••••8-96 SIN ••••••••••••••••••••••••••••••••••••••••••••••••••7-144
MPX ••••••••••••••••••••••••••••••••••••••••••••••••••7-86 SINS ••••••••••••••••••••••••••••••••••••••••••••••••7-204
MREAD ••••••••••••••••••••••••••••••••••••••••••••••8-82 SLA••••••••••••••••••••••••••••••••••••••••••••••••••• 7-42
MREADL•••••••••••••••••••••••••••••••••••••••••••••8-98 SLEFT ••••••••••••••••••••••••••••••••••••••••••••••7-192
MREN •••••••••••••••••••••••••••••••••••••••••••••• 8-104 SMID ••••••••••••••••••••••••••••••••••••••••••••••••7-196
MRMDIR •••••••••••••••••••••••••••••••••••••••••••••8-92 SORT •••••••••••••••••••••••••••••••••••••••••••••••• 8-38
MSTAT ••••••••••••••••••••••••••••••••••••••••••••• 8-106 SORTN •••••••••••••••••••••••••••••••••••••••••••••• 8-40
MSTRT •••••••••••••••••••••••••••••••••••••••••••••••• 6-7 SPLIT •••••••••••••••••••••••••••••••••••••••••••••••7-224
MWRIT •••••••••••••••••••••••••••••••••••••••••••••••8-80 SPRD ••••••••••••••••••••••••••••••••••••••••••••••• 8-114
Functions Index

SPWR •••••••••••••••••••••••••••••••••••••••••••••• 8-116


SQRT •••••••••••••••••••••••••••••••••••••••••••••••• 7-22
N SRA •••••••••••••••••••••••••••••••••••••••••••••••••• 7-40
SRGHT •••••••••••••••••••••••••••••••••••••••••••••7-188
NEG ••••••••••••••••••••••••••••••••••••••••••••••••••7-34 SRPLC •••••••••••••••••••••••••••••••••••••••••••••7-200
SSVC ••••••••••••••••••••••••••••••••••••••••••••••• 8-118
STR •••••••••••••••••••••••••••••••••••••••••••••••••7-164
O STRIM ••••••••••••••••••••••••••••••••••••••••••••••7-222
SWAP ••••••••••••••••••••••••••••••••••••••••••••••7-102
ORA ••••••••••••••••••••••••••••••••••••••••••••••••••7-26
T
P TAN •••••••••••••••••••••••••••••••••••••••••••••••••7-148
TBCD •••••••••••••••••••••••••••••••••••••••••••••••• 7-82
PIDAT ••••••••••••••••••••••••••••••••••••••••••••••••8-76 TBIN ••••••••••••••••••••••••••••••••••••••••••••••••• 7-84
PMOV ••••••••••••••••••••••••••••••••••••••••••••••••• 7-8 TMH •••••••••••••••••••••••••••••••••••••••••••••••••• 5-24
TMR •••••••••••••••••••••••••••••••••••••••••••••••••• 5-22
TMS •••••••••••••••••••••••••••••••••••••••••••••••••• 5-26
R TMU •••••••••••••••••••••••••••••••••••••••••••••••••• 5-28
TOD ••••••••••••••••••••••••••••••••••••••••••••••••• 7-110
RAD •••••••••••••••••••••••••••••••••••••••••••••••• 7-140 TODF •••••••••••••••••••••••••••••••••••••••••••••••7-124
RAMP ••••••••••••••••••••••••••••••••••••••••••••••••7-76 TOF •••••••••••••••••••••••••••••••••••••••••••••••••7-120
RASC •••••••••••••••••••••••••••••••••••••••••••••• 7-158 TOL ••••••••••••••••••••••••••••••••••••••••••••••••• 7-110
RCPSASC ••••••••••••••••••••••••••••••••••••••••• 7-252 TOS ••••••••••••••••••••••••••••••••••••••••••••••••• 7-110
RDASC •••••••••••••••••••••••••••••••••••••••••••• 7-166 TOU ••••••••••••••••••••••••••••••••••••••••••••••••• 7-110
REPLACE ••••••••••••••••••••••••••••••••••••••••• 7-203 TPOUT •••••••••••••••••••••••••••••••••••••••••••••• 7-78
RES•••••••••••••••••••••••••••••••••••••••••••••••••••5-13 TRGD •••••••••••••••••••••••••••••••••••••••••••••••• 8-79
RFASC ••••••••••••••••••••••••••••••••••••••••••••• 7-178 TRIM ••••••••••••••••••••••••••••••••••••••••••••••••7-216
RFSCI •••••••••••••••••••••••••••••••••••••••••••••• 8-120
RFSCO •••••••••••••••••••••••••••••••••••••••••••• 8-122
RFSCTH •••••••••••••••••••••••••••••••••••••••••••••8-73
RFSFRC ••••••••••••••••••••••••••••••••••••••••••• 8-112
A-24 - KV-5500/5000/3000/1000 Series Script Programming Manual -
6 Functions Index

U
UFILL •••••••••••••••••••••••••••••••••••••••••••••••••6-38
UNIB •••••••••••••••••••••••••••••••••••••••••••••••• 7-100
UNIF •••••••••••••••••••••••••••••••••••••••••••••••• 7-132
UNIN •••••••••••••••••••••••••••••••••••••••••••••••••7-96
UNIS •••••••••••••••••••••••••••••••••••••••••••••••• 7-246
UREAD ••••••••••••••••••••••••••••••••••••••••••••••6-34
UWRIT •••••••••••••••••••••••••••••••••••••••••••••••6-35

V
VAL ••••••••••••••••••••••••••••••••••••••••••••••••• 7-182

W
WSL ••••••••••••••••••••••••••••••••••••••••••••••••••7-60
WSR ••••••••••••••••••••••••••••••••••••••••••••••••••7-58
WSUM •••••••••••••••••••••••••••••••••••••••••••••••8-20
WTIME •••••••••••••••••••••••••••••••••••••••••••••••8-64

APPENDICES
Z
ZONE ••••••••••••••••••••••••••••••••••••••••••••••••7-70
ZPOP •••••••••••••••••••••••••••••••••••••••••••••••••6-16
ZPUSH •••••••••••••••••••••••••••••••••••••••••••••••6-12
ZRES •••••••••••••••••••••••••••••••••••••••••••••••••8-30

Functions Index

- KV-5500/5000/3000/1000 Series Script Programming Manual - A-25


Revision History
Printing Date Version Details of Revision

Sep 2010 Initial version

- KV-5500/5000/3000/1000 Series Script Programming Manual -


WARRANTY

KEYENCE products are strictly factory-inspected. However, in the event of a failure, contact your nearest
KEYENCE office with details of the failure.

1. WARRANTY PERIOD
The warranty period shall be for one year from the date that the product has been delivered to the location
specified by the purchaser.

2. WARRANTY SCOPE
(1) If a failure attributable to KEYENCE occurs within the abovementioned warranty period, we will repair the
product, free of charge. However, the following cases shall be excluded from the warranty scope.
• Any failure resulting from improper conditions, improper environments, improper handling, or improper usage
other than described in the instruction manual, the user’s manual, or the specifications specifically arranged
between the purchaser and KEYENCE.
• Any failure resulting from factors other than a defect of our product, such as the purchaser’s equipment or the
design of the purchaser’s software.
• Any failure resulting from modifications or repairs carried out by any person other than KEYENCE staff.
• Any failure that can certainly be prevented when the expendable part(s) is maintained or replaced correctly
as described in the instruction manual, the user’s manual, etc.
• Any failure caused by a factor that cannot be foreseen at a scientific/technical level at the time when the
product has been shipped from KEYENCE.
• Any disaster such as fire, earthquake, and flood, or any other external factor, such as abnormal voltage, for
which we are not liable.
(2) The warranty scope is limited to the extent set forth in item (1), and KEYENCE assumes no liability for any
purchaser’s secondary damage (damage of equipment, loss of opportunities, loss of profits, etc.) or any other
damage resulting from a failure of our product.

3. PRODUCT APPLICABILITY
KEYENCE products are designed and manufactured as general-purpose products for general industries.
Therefore, our products are not intended for the applications below and are not applicable to them. If, however,
the purchaser consults with us in advance regarding the employment of our product, understands the
specifications, ratings, and performance of the product on their own responsibility, and takes necessary safety
measures, the product may be applied. In this case, the warranty scope shall be the same as above.
• Facilities where the product may greatly affect human life or property, such as nuclear power plants, aviation,
railroads, ships, motor vehicles, or medical equipment
• Public utilities such as electricity, gas, or water services
• Usage outdoors, under similar conditions or in similar environments

E 1040-1
Copyright (c) 2010 KEYENCE CORPORATION. All rights reserved. 084218E 1100-1 96112E Printed in Japan

Vous aimerez peut-être aussi