0% found this document useful (0 votes)
603 views

KVS Script Programming Manual

Uploaded by

doimkroi1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
603 views

KVS Script Programming Manual

Uploaded by

doimkroi1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 780

910GB

Chapter
OVERVIEW
1
Chapter PROGRAMMING
2 SCRIPT
Chapter DATA
Programable Controller 3 PROCESSING

KV-8000/7000/5000/3000/1000 Series
Chapter SCRIPT SYNTAX
4 AND PRECAUTIONS
KV Nano Series Chapter BASIC
5 FUNCTIONS

Script Programming Chapter

6
APPLICATION
FUNCTIONS

Manual
Chapter ARITHMETIC
7 OPERATION FUNCTIONS
Chapter EXTENDED
8 FUNCTIONS
Please read this Manual before use. · List of Control Relays/
Keep this Manual in a safe place for later reference. Control Memories
· Index

Applicable CPU Unit


•KV-8000
•KV-7500
•KV-7300
•KV-5500
Frequently Asked Questions •KV-5000
•KV-3000
•KV-1000
•KV Nano Series

www.keyence.com/controlfaq
Preface
The manual describes functions required to compile KV-8000/7500/7300/5000/3000/1000 and KV
Nano Series 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-8000 Series User's Manual", "KV-7000
Series User's Manual", "KV-5500/5000/3000 Series User's Manual", "KV Nano Series User's Manual"
"KV-8000/7000/5000/3000/1000 Series and KV Nano 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-8000/7000/5000/3000/1000 Series and KV Nano 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 how to connect, and maintain the KV-8000
KV-8000 Series User's Manual Series. It also describes the CPU built-in functions and how to
create ladder programs.
This manual describes how to connect, and maintain the KV-7000
KV-7000 Series User's Manual Series. It also describes the CPU built-in functions and how to
create ladder programs.
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.
This manual describes system configurations and specifications,
KV Nano Series Base Unit (terminal
built-in functions in the base unit, and how to create ladder
block type) User's Manual
programs for the terminal block type KV Nano Series.
This manual describes system configurations and specifications,
KV Nano Series Base Unit (connector
built-in functions in the CPU unit, and how to create ladder
type) User's Manual
programs for the connector type KV Nano Series.
KV-8000/7000/5000/3000/1000 Series
This Manual describes various instructions available in Ladder
and KV Nano Series Instruction
program.
Reference Manual
KV-8000/7000/5000/3000/1000 Series
This Manual describes the script programming method and
and KV Nano Series Script
available operators, control statements and functions, etc.
Programming Manual
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:

Failure to observe this item causes a risk that consequently results in death or
Danger
serious injury.

Warning Failure to observe the items mentioned may result in death or serious injury.

Caution Failure to observe the items mentioned may result in medium or minor injury.

Failure to observe this item may cause damage to the product itself as well to
NOTICE
other property.

Important Notes on operations that are always performed

Point Notes on operations that are often performed erroneously

Reference Here are listed items further enriching the understanding of the main text, and the
information useful to know.
Page or manual providing related information

 General Precautions

• Before using KV STUDIO, confirm whether the function and performance of KV-
8000/7500/7300/5500/5000/3000/1000 or KV Nano Series 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 fail safe operation of the
entire system in the event that the PLC fails.
Warning • 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.
• Do not use this product for the purpose to protect a human body or a part of
human body.
• This product is not intended for use as explosion-proof product. Do not use this
product in a hazardous location and/or potentially explosive atmosphere.

If you use the product in a manner that falls outside of the ranges indicated in its
Caution
specifications, protection provided by the product may be damaged.

• Proceed with care when modifying the device, 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.
NOTICE • 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.

910GB
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1
KV-8000 CPU Function Version
The functions of the KV-8000 Series differ depending on the CPU function version.
The CPU function version can be checked using "Tools" → "Check CPU Function Version" → "PLC" in
the KV STUDIO menu (* KV STUDIO Ver.10.0 or later is required).
The CPU function version can be updated using "Tools" → "Check CPU Function Version" → "PLC" →
"Update System Program" in the KV STUDIO menu. (* KV STUDIO Ver.10.0 or later is required.)

■Differences in CPU function depending on CPU function version


Release 2020/04 2019/04
CPU function version 2.0 1.0
KV STUDIO compatible version Ver.11.0 or later Ver.10.0 or later
Variable ○ ※1 ー
CPU Structure ○ ー
function ○(Compatible with EN/ENO,
Function block ○
instances)
2 function added(FBCALL,
Function/ Function block function Not added
FBSTRT)
Script 2 function added
(WSIZE,
Data size acquisition function ー
ACNT)
*1 Variables that can be used for communication with the VT5 series can be used in CPU function
version 2.0 or later instead of labels supported in CPU function version 1.0.

2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-7500/7300 CPU Function Version
The KV-7000 Series functions differ according to the CPU function version.
The CPU function version can be checked using "Tools"->"Functional version validation" ->"PLC" in the KV STUDIO
menu (* KV STUDIO Ver. 8 or later is required).
The CPU function version can be updated using "Tools"->"Functional version validation" -> "Update system program"
in the KV STUDIO menu (* KV STUDIO Ver. 8.1 or later is required).

■ Differences in CPU function according to CPU function version


Release date Dec 2018 July 2017 June 2016 December 2015 June 2015 March 2015
CPU function version 2.3 2.2 2.1 2.0 1.1 1.0
KV STUDIO compatible version 9.45 or later 9.2 or later 9.1 or later 9.0 or later 8.1 or later 8.0 or later
Compatible KV-7500 Yes Yes Yes Yes Yes
CPU unit KV-7300 Yes Yes Yes Yes Yes
KV-XLE02
Compatible Yes No
KV-XL402/XL202
expansion
KV-XH16ML/XH04ML Yes No
unit
KV-XH16EC Yes No
Project name Up to 64 characters Up to 32 characters
Program name Up to 64 characters Up to 24 characters
Program comment Up to 256 characters Up to 32 characters
OFF processing setting when
Yes No
program execution is stopped
Assignment for interrupt program
CPU Yes No
of work area for script text string
function
Inter-unit synchronization Yes No
Inter-unit synchronization
Yes No
read/write CPU device
KV socket communication Yes*1 No
Function block function Yes (compatible with unspecified unit argument types) Yes No
Application package Yes No No
Function block function 3 function added (FB,FEND,FUN) No additions
Unit program function 5 function added (UMALLOC,UPSTRT, UPSTOP,UFSUS,UFRSM) No additions
Function Floating point function 1 function added (ATAN2) No additions
script Data control function Specifications of 1 function expanded (APR)*2 No additions
Data processing function Specifications of 4 function expanded (MAX,MIN,AVG,WSUM)*3 No additions
Unit type judgment function Yes No

*1 KV socket communication can only be used with the KV-7500.


*2 Double precision floating point type real numbers can now be specified in linear approximation function (APR).
(Scaling)
*3 Single/double precision floating point type real numbers can now be specified in search max. value (MAX),
search min. value (MIN), average (AVG), and word sum (WSUM) function.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3


KV Nano Series CPU Function Version
The KV Nano Series functions differ according to the CPU function version.
The CPU function version can be checked using "Tools"->"Functional version validation"->"PLC" in the KV STUDIO
menu (* KV STUDIO Ver. 7 or later is required).
The CPU version can be updated using "Tools"->"Functional version validation" -> "Update system program" in the
KV STUDIO menu (* KV STUDIO Ver. 7.1 or later is required).

■ Differences in CPU function according to CPU function version


KV-N14*/N24*/N40*/N60*
CPU function version Release date Compatible functions
Ver. 1.0 October 17, 2012 Initial version
Ver. 2.0 May 15, 2013 Compatible with EtherNet/IP unit KV-NC1EP
KV-NC32T
CPU function version Release date Compatible functions
Ver. 2.0 May 15, 2013 Initial version

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

4 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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 ×
Battery-less operation × ×
Initial screen display
× ×
(access window)
Read folder specification
× ×
(auto-loading function)
CPU function
SDHC card (memory card) × ×
Word device bit comment
× ×
(KV STUDIO)
Performance monitor
× ×
(KV STUDIO)
Differential monitor (KV STUDIO) × ×
Double precision floating point
× ×
type real number
Timer/counter function 1 function added (TMU) No additions -
PID control function 1 function added (PIDAT) No additions -
Data control function 3 functions added (RAMP,TPOUT,LLFLT) No additions -
2 functions added (BYLMOV,BYBMOV)
Move function No additions -
Specifications of 1 function expanded*2
Arithmetic/comparison function 1 function added (POW) No additions -
Data shift function 2 functions added (ASRA,ASLA) No additions -
4 functions added
Data conversion function (ABS,BSWAP,CPMSET,CPMGET) No additions -
Specifications of 2 functions expanded*3
Function/script
5 functions added
Floating point function No additions -
(LOG10,DFLOAT,DINTG,FTODF,DFTOF)
*4
Simple operation function Specifications of 2 functions expanded No additions -
5 functions added
Text string processing function (SPLIT,STRIM,SFINDN,CPSASC,RCPSASC)*5 No additions -
Specifications of 1 function expanded*6
Data processing function 2 functions added (SORT,SORTN) No additions -
7 functions added
Memory card function (MPRINT,MREADL,MCOPY,MMOV,MREN, No additions -
MFREEK,MSTAT)
Sensor setting function 3 functions added (SPRD,SPWR,SSVC) No additions -
Refresh function 2 functions 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 function (CAL>>, CAL<<). (Arithmetic shift)
*5 Only scrip function is added for SPLIT.
*6 RCOM supports word device bit comment.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5


 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 ×
FTP client ×
BOOTP client ×
Ethernet function Communication without unit
× ×
setting
APPE command support
× ×
(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 output 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.

6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


How This Manual Is Organized

1
Describes features of KV scripts such as script application example
(program example) and KV script type, operators and control
Chapter OVERVIEW
statements, functions, etc.
1
2
Chapter 2 PROGRAMMING
SCRIPT
Describes script making steps as well as error message and warning
message during conversion. 3
4
Chapter 3 DATA PROCESSING
Describes script processing device, variable or constant range (type) and 5
programming method, index modification and indirect specifying, etc.

6
7
Chapter 4 SCRIPT SYNTAX
AND PRECAUTIONS
Describes how to use assignment statement and operators used in
scripts as well as syntax of control statement, etc.
8
A
Chapter 5 BASIC FUNCTIONS
Describes contact functions, bit functions, bit output functions, output
functions, and timer/counter functions, etc.

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

ARITHMETIC
7
Describes data more functions, arithmetic operation functions, logical

OPERATION operation functions, data shift functions, data conversion functions,


Chapter floating real number functions, and text string processing functions, etc.
FUNCTIONS

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

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


APPENDICES memories, index, etc.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7


Contents
Safety Precautions....................................................................................................1
How This Manual Is Organized ................................................................................7
Contents ....................................................................................................................8

Chapter 1 OVERVIEW
KV Scripts.....................................................................................................................1-2
Features of KV Script ..........................................................................................................1-2
How to Use KV Scripts ........................................................................................................1-3
KV Script Type..............................................................................................................1-8
Box Script ............................................................................................................................1-8
Area Script...........................................................................................................................1-9
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


PROGRAMMING SCRIPT.............................................................................................2-2
Programming Script.............................................................................................................2-2
Box Script .....................................................................................................................2-4
Features of Box Script .........................................................................................................2-4
Making Box Script................................................................................................................2-6
Precautions When Using Box Script..................................................................................2-13
Area Script..................................................................................................................2-16
Features of Area Script......................................................................................................2-16
Making Area Script ............................................................................................................2-18
Label Programming and Label Array .......................................................................2-25
Label Programming ...........................................................................................................2-25
Global and local variables .................................................................................................2-25
Variables and data formats at a glance .............................................................................2-26
Array ..................................................................................................................................2-27
Structure ............................................................................................................................2-29
Variable Setting .................................................................................................................2-32
Precautions for using variables..........................................................................................2-35
• Label Programming and Label Array .......................................................................2-37
Label Programming ...........................................................................................................2-37
Label Array ........................................................................................................................2-46
Precautions when programming script ...................................................................2-51
About Parallel Connection of Box Script............................................................................2-51
Precautions When Using Script Programming Operation Formula ...................................2-51

8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Script Conversion Output Message .........................................................................2-52
Warning Message..............................................................................................................2-52
Error Message ...................................................................................................................2-54
Function block............................................................................................................2-58
Calling Function Blocks .....................................................................................................2-58
Programing Function Blocks Using Script .........................................................................2-59
Macro ..........................................................................................................................2-60
Macro Call .........................................................................................................................2-60
Programming Macro by Using Script.................................................................................2-61
Script Debug Function...............................................................................................2-62
Monitor Function................................................................................................................2-62
Input Auxiliary Function and Other Info ..................................................................2-64
About Input Auxiliary Function...........................................................................................2-64
About Comments Function ................................................................................................2-69
Write Easy-reading Script..................................................................................................2-70
Inline Mnemonics...............................................................................................................2-72
Precautions on Edit Screen and Customization ................................................................2-73
About Script Work Memory (Work Devices) ......................................................................2-74
XYM Marking .....................................................................................................................2-77

Chapter 3 DATA PROCESSING


Devices .........................................................................................................................3-2
Device List (When using KV-8000) ......................................................................................3-2
Device list (When using KV-7000) .......................................................................................3-6
Device table (for KV-5500 / 5000/3000/1000)....................................................................3-10
Device table (for KV Nano) ................................................................................................3-17
Device notation method.....................................................................................................3-21
Bit Device ..........................................................................................................................3-24
Word device.......................................................................................................................3-35
Processing Bit Device in Word Unit ...................................................................................3-45
Processing Word Device as Bit Device .............................................................................3-46
Direct I/O Relay .................................................................................................................3-47
Variables............................................................................................................................3-49
Constant ............................................................................................................................3-51
Index Modification and Indirect Specifying .............................................................3-54
Index modification..............................................................................................................3-55
What is indirect specifying .................................................................................................3-57
Combination of index modification and indirect specifying ................................................3-61
Data Type (suffix).......................................................................................................3-62
Suffix..................................................................................................................................3-63
About Type Declaration (TYPE) ........................................................................................3-69
About Operation Type .......................................................................................................3-70
PRAGMA Directive ............................................................................................................3-72

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 9


Chapter 4 SCRIPT SYNTAX AND PRECAUTIONS
Assignment Statement...................................................................................................4-2
How to Use An Assignment Statement ...............................................................................4-2
Order of Prionity low ......................................................................................................4-6
Operator List........................................................................................................................4-6
Control statement.........................................................................................................4-10
Control Statement List .......................................................................................................4-10
IF ~ Statement (Conditional Branch (1))............................................................................4-12
IF ~ ELSE Statement (Conditional Branch (2)) .................................................................4-14
IF ~ ELSEIF Statement (Conditional Branch (3)) ..............................................................4-16
SELECT CASE ~ Statement (Multi-branch control) .........................................................4-18
MC ~ MCR Statement (Master control) .............................................................................4-22
FOR ~ NEXT Statement ( specified loop control times) ....................................................4-24
WHILE Statement (pre-judge loop control)........................................................................4-27
DO ~ UNTIL Statement (Post Identification Loop Control) ................................................4-29
BREAK Processing............................................................................................................4-31
Precautions on Using Control Statement ..........................................................................4-32
Precautions on Script Programming ............................................................................4-38
Status of Hold Control Bit Device ......................................................................................4-38
Precautions for using the timer / counter...........................................................................4-40

Chapter 5 BASIC FUNCTIONS


Contact function ..........................................................................................................5-2
LDP Rising edge differential of specified bit ...................................................5-2
LDF Falling edge differential of specified bit...................................................5-4
LDPB Rising edge differential bar of specified bit .............................................5-6
LDFB Falling edge differential bar of specified bit ............................................5-7
Bit contact function .....................................................................................................5-8
BLD Specified bit information of word data.....................................................5-8
BLDB Specified bit information bar of word data ............................................5-10
Output function ..........................................................................................................5-12
SET Output ON of specified bit.....................................................................5-12
RES Output OFF of specified bit...................................................................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 10 ms 32-bit down timer .......................................................................5-26
TMS 1 ms 32-bit down timer .........................................................................5-28
TMU 10μs 32-bit down timer .........................................................................5-30
CNT 32 bit up counter ...................................................................................5-32
Direct I/O functions....................................................................................................5-36
RFSX Input refresh..........................................................................................5-36
RFSY Output refresh.......................................................................................5-37

10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Chapter 6 APPLICATION FUNCTION
Flow Functions.............................................................................................................6-2
CALL Start specified sub-routine ......................................................................6-2
ECALL Module sub-routine instruction................................................................6-4
Macro function .............................................................................................................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
Function block function ............................................................................................6-10
FB Start function block ...............................................................................6-10
FBCALL Function block call ................................................................................6-11
FBSTRT Function block start...............................................................................6-13
FEND End function block ................................................................................6-15
FUN Start function.........................................................................................6-16
Module function .........................................................................................................6-18
MDSTRT Module execution start..........................................................................6-18
MDSTOP Module execution stop..........................................................................6-19
Index register function ..............................................................................................6-20
ZPUSH Batch purge of index register................................................................6-20
ZPOP Batch restore of index registers ............................................................6-24
Specifying functions indirectly.................................................................................6-26
ADRSET Address storage of indirectly specified target .......................................6-26
ADRINC Add 1 to stored address........................................................................6-28
ADRDEC Decrement stored address by 1............................................................6-30
ADRADD Add stored address...............................................................................6-32
ADRSUB Subtract stored address........................................................................6-34
File register function .................................................................................................6-36
FRSET Switch file register mode.......................................................................6-36
FRSTM Batch-store file register.........................................................................6-38
FRLDM Batch- read file register.........................................................................6-40
Unit program function ...............................................................................................6-42
UPSTRT Unit program start .................................................................................6-42
UPSTOP Unit program forced stop ......................................................................6-44
UFSUS Suspend flow ........................................................................................6-46
UFRSM Resume flow .........................................................................................6-48
UMALLOC Allocate buffer memory.........................................................................6-50
Buffer memory function ............................................................................................6-52
UREAD Read buffer ...........................................................................................6-52
UWRIT Write buffer ...........................................................................................6-54
UFILL Insert same value in data string of buffer..............................................6-56
Unit type judgment function .....................................................................................6-58
IS_ □□□ Unit type judgment................................................................................6-58
Array element number acquisition function............................................................6-60
ACNT Get the number of array elements ........................................................6-60
Word size get function ..............................................................................................6-62
WSIZE Get word size........................................................................................6-62

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 11


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-6
BYBMOV Move continuous byte string information to
specified position (H -> L).....................................................................7-10
BYLMOV Move continuous byte string information to
specified position (L -> H).....................................................................7-12
Arithmetic Operation Functions ...............................................................................7-14
INC Increament by 1 ....................................................................................7-14
DEC Decrement by 1 ....................................................................................7-16
ROOT Square root ...........................................................................................7-18
SQRT Square root ...........................................................................................7-20
Logic Operation Functions .......................................................................................7-22
ANDA Logical AND operation..........................................................................7-22
ORA Logical OR operation ............................................................................7-24
EORA Exclusive OR operation ........................................................................7-26
ENRA Exclusive NOR......................................................................................7-28
COM Bit inversion ..........................................................................................7-30
NEG Invert sign .............................................................................................7-32
ABS Absolute value ......................................................................................7-36
Data Shift Functions ..................................................................................................7-38
SRA Shift right (bit unit).................................................................................7-38
SLA Shift left (bit unit)...................................................................................7-40
ASRA Arithmetic right shift A (bit unit).............................................................7-42
ASLA Arithmetic left shift (bit unit) ..................................................................7-44
RRA Right rotate (bit unit, with carry)............................................................7-46
RLA Left rotate (bit unit, with carry) ..............................................................7-48
RRNCA Right rotate (bit unit, without carry).......................................................7-50
RLNCA Left rotate (bit unit, without carry) .........................................................7-52
WSR Shift word device right ..........................................................................7-54
WSL Shift word device left.............................................................................7-56
BSR Shift bit device right ..............................................................................7-58
BSL Shift bit device left.................................................................................7-60
Data Control Functions .............................................................................................7-62
LIMIT Upper/lower limit value control..............................................................7-62
BANDC Dead band control ................................................................................7-64
ZONE Zone control..........................................................................................7-66
APR Linear approximation (Scaling) .............................................................7-68
RAMP Ramp signal..........................................................................................7-74
TPOUT Time proportional output.......................................................................7-76
LLFLT Lead-lag filter ........................................................................................7-78

12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Conversion Functions ......................................................................................7-80
TBCD Convert BIN data to BCD data..............................................................7-80
TBIN Convert BCD data to BIN data..............................................................7-82
MPX 4-bit data decode ..................................................................................7-84
DMX 4-bit data encode ..................................................................................7-86
GRY Convert BIN data to gray code .............................................................7-88
RGRY Convert gray code to BIN data .............................................................7-90
DISN Disperse nibble .....................................................................................7-92
UNIN Unite nibble...........................................................................................7-94
DISB Disperse byte........................................................................................7-96
UNIB Unite byte..............................................................................................7-98
SWAP High lower byte conversion.................................................................7-100
BSWAP Block swap..........................................................................................7-102
DECO 8-bit decode ........................................................................................7-104
ENCO 8-bit encode ........................................................................................7-106
TOU Convert data type to .U.......................................................................7-108
TOS Convert data type to .S .......................................................................7-108
TOD Convert data type to .D.......................................................................7-108
TOL Convert data type to .L .......................................................................7-108
CPMSET CIP message creation ........................................................................7-110
CPMGET CIP message retrieval ........................................................................7-112
Floating Point Functions.........................................................................................7-114
FLOAT Convert BIN data to single precision floating point type real number data ....7-114
TOF Convert BIN data to single precision floating point type real number data ....7-116
DFLOAT Convert BIN data to double precision floating point type real number data ...7-118
TODF Convert BIN data to double precision floating point type real number data ...7-120
INTG Convert single/double precision floating point type real number data to BIN data...7-122
INT Convert single precision floating point type real number data to BIN data ....7-124
DISF Disperse mantissa/exponent of single precision floating point type real number... 7-126
UNIF Unite mantissa and exponent to single precision floating point type real number ..7-128
EXP Exponent function operation ...............................................................7-130
LOG Natural logarithm operation ................................................................7-132
LOG10 Constant logarithm operation..............................................................7-134
RAD Convert degree (°) to radian unit........................................................7-136
DEG Convert radian to degree (°) unit........................................................7-138
SIN Angle (radian) to sine value ................................................................7-140
COS Angle (radian) to cosine value ............................................................7-142
TAN Angle (radian) to tangent value...........................................................7-144
ASIN Sine value to angle (radians) ..............................................................7-146
ACOS Cosine value to angle (radians) ..........................................................7-148
ATAN Tangent value to angle (radian)..........................................................7-150
ATAN2 Coordinates to angle (radian) .............................................................7-152
Text Processing Functions .....................................................................................7-154
ASC Convert BIN data to HEX ASCII code.................................................7-154
RASC Convert HEX ASCII code to BIN data.................................................7-156
DASC Convert BIN data to DEC ASCII text string.........................................7-158
STR Convert numerical value data to ASCII code......................................7-162
RDASC Convert DEC ASCII text string to BIN data.........................................7-166
HASC Convert BIN data to HEX ASCII text string.........................................7-168

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 13


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-181
LEN Detect text string length ......................................................................7-182
SRGHT Cut text string on right.........................................................................7-184
RIGHT Cut text string on right.........................................................................7-186
SLEFT Cut text string on left...........................................................................7-188
LEFT Cut text string on left...........................................................................7-190
SMID Cut text string......................................................................................7-192
MID Cut text string......................................................................................7-194
SRPLC Replace text string section..................................................................7-196
REPLACE Replace text string section..................................................................7-199
SINS Insert text string ..................................................................................7-200
INSERT Insert text string ..................................................................................7-202
SDEL Delete text string section ....................................................................7-204
DELETE Delete text string section ....................................................................7-206
TRIM Trim 1-byte space and tab at ends of text string.................................7-208
LTRIM Trim 1-byte space and tab at left end of text string.............................7-210
RTRIM Trim 1-byte space and tab at right end of text string ..........................7-212
STRIM Trim 1-byte space and tab from specified text string position.............7-214
SPLIT Split text string ....................................................................................7-216
SFIND Search text string................................................................................7-218
SFINDN Search text string................................................................................7-220
INSTR Search text string................................................................................7-222
FIND Search text string................................................................................7-226
DISS Disperse text string .............................................................................7-228
UNIS Unite text string...................................................................................7-230
CHR Convert HEX ASCII code to characters..............................................7-232
CPSASC CIP text string conversion...................................................................7-234
RCPSASC CIP text string type data reverse conversion ......................................7-236

14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Chapter 8 EXTENDED FUNCTIONS
Data processing function............................................................................................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
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-18
AVG Average value of specified block ..........................................................8-22
WSUM Total value of specified block................................................................8-26
BSUM Total value (in byte units) of specified block .........................................8-30
CRC Calculate CRC value in specified block ................................................8-32
ZRES Reset specified block............................................................................8-34
BCMP Compare data between specified blocks ..............................................8-36
BCMPI Compare data of value with block.........................................................8-38
RND Generate random number ....................................................................8-40
SORT Binary data sort.....................................................................................8-42
SORTN Binary data partition sort.......................................................................8-44
Table processing function ........................................................................................8-48
FIFOW Write to FIFO table ...............................................................................8-48
FIFOR Read from FIFO table ...........................................................................8-52
LIFOW Write to LIFO table................................................................................8-56
LIFOR Read from LIFO table ...........................................................................8-60
FWRIT Overwrite data table specified position .................................................8-64
FINS Insert to data table specified position ...................................................8-66
FDEL Delete data table specified position ......................................................8-68
Clock processing function........................................................................................8-70
WTIME Write time data to calendar timer..........................................................8-70
SEC Convert date/time format data to second format data ..........................8-72
RSEC Convert second format data to date/time format data ..........................8-74
AJST Calendar timer adjustment....................................................................8-76
High-speed processing function ..............................................................................8-78
DI Disable interrupt....................................................................................8-78
EI Enable interrupt ....................................................................................8-78
RFSCTH High-speed Counter refresh .................................................................8-79
DIC Set interrupt disabled range..................................................................8-80
IEDGE Set interrupt condition...........................................................................8-82
PID Functions.............................................................................................................8-84
PIDAT PID control with automatic tuning .........................................................8-84
Log Functions ............................................................................................................8-86
LOGE Enable logging of specified ID ..............................................................8-86
LOGD Disable logging of specified ID .............................................................8-86
TRGD Acquire logging data .............................................................................8-87
TRGR Get device / variable data .....................................................................8-88

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 15


Storage Functions .....................................................................................................8-90
MWRIT Write to storage device (memory card/CPU memory) ..........................8-90
MREAD Read from storage device (memory card/CPU memory)......................8-92
MFREE Get storage device (memory card/CPU memory) free space in bytes....8-94
MFREEK Get storage device (memory card/CPU memory) free space in kilobytes ...8-96
MMKDIR Make storage device (memory card/CPU memory) directory...............8-98
MRMDIR Delete storage device (memory card/CPU memory) directory ...........8-102
MDEL Delete storage device (memory card/CPU memory) file ....................8-104
MPRINT Write text to a file in storage device (memory card/CPU memory).....8-106
MREADL Read one line from file in storage device (memory card/CPU memory) ...8-108
MCOPY Copy file in storage device (memory card/CPU memory)...................8-110
MMOV Move file in storage device (memory card/CPU memory) ..................8-112
MREN Rename file in storage device (memory card/CPU memory) .............8-114
MSTAT Get status of file in storage device (memory card/CPU memory).......8-116
Access Window Functions .....................................................................................8-118
AWNUM Display access window message 1 ....................................................8-118
AWMSG Display access window message 2 ....................................................8-120
AWSHOW User message display ........................................................................8-122
AWHIDE Hide user message.............................................................................8-123
FREE RUN Counter Functions................................................................................8-124
RFSFRC FREE RUN counter refresh ................................................................8-124
Sensor Setting Function .........................................................................................8-126
SPRD Read sensor parameter ......................................................................8-126
SPWR Sensor parameter write ......................................................................8-128
SSVC Sensor service execution....................................................................8-130
Cyclic Communication Refresh Function..............................................................8-132
RFSCI Refresh cyclic communication input ...................................................8-132
RFSCO Refresh cyclic communication output .................................................8-134

APPENDICES
CR/CM List................................................................................................................... A-2
Control Relays (CR) (For KV-8000) .................................................................................... A-2
Control Memory Entries CM (For KV-8000)........................................................................ A-5
Control Relays CR (For KV-7500/7300) ........................................................................... A-10
Control Memory Entries CM (For KV-7500/7300)............................................................. A-13
Control Relays CR (For KV-5500/5000/3000) .................................................................. A-18
Control Memory CM (For KV-5500/5000/3000)................................................................ A-24
Control Relays CR (For KV Nano series) ......................................................................... A-31
Control Memory Entries CM (For KV Nano series) .......................................................... A-41
ASCII Code Table ...................................................................................................... A-53
List of Characters That Cannot Be Used ................................................................ A-54
List of Unusable Functions ...................................................................................... A-58
Index........................................................................................................................... A-59
Functions Index ........................................................................................................ A-67

16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 17
Terminology
This manual uses the following terminology excluding some instances.
Term Explanation
An electronic device which can control freely the machines by altering
Programmable controller
programs, which is also called PLC (Programmable Logic Controller).
KV-8000/7500/7300/5500/5000/ Programmable Controller KV-5500/5000/3000/1000 Series unit made
3000/1000 by Keyence Corporation
KV-8000/7000/5000/3000/1000 The generic term for expansion units that can be connected to the KV-
Series 8000/7000/5000/3000/1000 CPU unit.
CPU unit KV-8000/7500/7300/5500/5000/3000/1000
Programmable Controller KV Nano Series unit made by Keyence
KV-N14/N24/N40/N60/NC32
Corporation
Generic term of expanded units connectable to Base units in "KV-N14/
KV Nano Series
N24/N40/N60/NC32"
Base unit KV-N14/N24/N40/N60/NC32
Expansion I/O units and expansion special units other than CPU units
KV-8000 Series expansion unit
that can be used with the KV-8000 Series.
KV-8000/7000 Series expansion Expansion I/O units and expansion special units other than CPU units
unit that can be used with the KV-8000/7000 Series.
KV-5000/3000/1000 Series Expansion I/O units and expansion special units other than CPU units
expansion unit that can be used with the KV-5500/5000/3000/1000 Series.
Expansion I/O units and expansion special units other than base units
KV Nano Series expansion unit
that can be used with the KV Nano Series.
KV STUDIO Supportive software for the programming of KV Series.
Ladder program Program made by using the KV STUDIO Ladder Support Software
Indicates KV-5000/3000 released after September 10, 2009, of which
<<KV-5000 Ver.1.1>> the CPU function version 1.1 is indicated as Ver. 1.1 on the serial label
<<KV-3000 Ver.1.1>> on the side. Used for distinction from KV-5000/3000 older than CPU
function version 1.1.

Symbols
Menus or buttons in descriptions in this manual are expressed using the following symbols.
Term Explanation
Values prefixed by "#" are expressed in decimal. Basically, all numerical values are
#
expressed in decimal even if they are not prefixed by "#".
$ Values prefixed by "$" are expressed in hexadecimal.
When 32-bit numerical values are handled, two devices are used. Programs are
"DM0·DM1" scripted using only device Nos. (in the example on the left, DM0) to which the lower 16
bits are stored. The example on the left indicates that 32-bit data is being handled.
This indicates "(device turns ON) at the rising edge of a signal."
This indicates "for the duration that the signal is ON."
This indicates "(device turns OFF) at the falling edge of a signal."

18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


OVERVIEW
1
OVERVIEW

KV Scripts ································································ 1-2


KV Script Type··························································· 1-8
KV Script Function·····················································1-10

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-1


KV Scripts
OVERVIEW

KV script is a program language developed for operation processing and text string processing that
failed using former Ladder language. Since KV script can be programed in Ladder language, Ladder
1 program needs not to be interrupted during application.
KV Scripts

Features of KV Script

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
steps.
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 aware of internal
easy-to-understand.
register, arithmetic operation can be
described as mathematic formula.

Reference Script program is executed after ladder conversion.


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

1-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Scripts

OVERVIEW
How to Use KV Scripts

We will use the following example to describe how to realize operation processing and text string
1

KV Scripts
processing that failed using Ladder program.

 Programming operation processing with 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-3


KV Scripts
OVERVIEW

 When using operation functions

1
To add sin value and cos value of an angle.
The operation result (addition result) is stored in DM10.F.
KV Scripts

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


' DM02.F : Stores angle value to be SINed.
' DM06.F : Stores angle value to be COSed.
'------< 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 addition operation.

Reference 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 data operation, BMOV function, FMOV
function for data movement, and SIN and COS floating point function, etc.

1-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Scripts

OVERVIEW
 Programming text string processing with KV Script
KV script simple and convenient programming even if character processing (text string processing).
1
 When using string operator

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

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.

Reference • The 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-53
• Suffix .T added to DM100 indicates that the device for storing text string with KV script.
For detail, see "Data Type (suffix)", Page 3-62

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-5


KV Scripts
OVERVIEW

 When using text string processing function

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

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


' DM40.T : Stores string "Keyence@KV-5000".
' 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)

Reference 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Scripts

OVERVIEW
 Programming control statements with KV Scripts
KV script, can enable functions such as conditional branch and reprocessing, etc. simply via control
statements. 1

KV Scripts
 For multi-branch control
The control "To store corresponding version information according to the word data value", can be
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 ' When no 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-7


KV Script Type
OVERVIEW

Two KV script types are available, each with different programming style.

1 Box Script
KV Script Type

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
programming, character code and the number of characters used will be limited and Box Script shall be
written within this limited range.
"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.

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

1-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Script Type

OVERVIEW
Area Script

Area Script is a script that can be executed during scanning even if the execution condition is not
1

KV Script Type
established.
The programming area on edit screen occupies whole 1 rung.

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-9


KV Script Function
OVERVIEW

KV script can enable programming program a Series of ladder control in a format similar to BASIC
language.
1
About Assignment Statement
KV Script Function

Via KV script, you can program using assignment statement, and store the value and operation result to
the devices, variables.

 Assignment statement
DM1000 = DM1001 + 10

Right result (value) is stored into 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 location

 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 "Assignment Statement", Page 4-2.

1-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Script Function

OVERVIEW
About Operator

For KV script, arithmetic operation and logical operation, etc. need not to be converted to special
1

KV Script Function
instructions such as Ladder program, operators can be directly programed, which enabling more visible
programming.

 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 data
AND MR601=R000 AND R001
Logic relation, word data relation)
Calculate logical OR of 2 values (bit data
operator OR MR602=R000 OR R001
relation, word data relation)
Calculate XOR of 2 values (bit data relation,
XOR MR603=R000 XOR R001
word data relation)
For operators, see "Order of Prionity low", Page 4-6.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-11


KV Script Function
OVERVIEW

About Control Statement


1 KV script allows to program various control statements. facilitating to simply change (control) program flow.
KV Script Function

Two kinds of control statements are available, including conditional branch statement and loop control
statement.

 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
· formula 1>, <conditional expression 2 >...
· <conditional expression n>), multi-branch
ELSE control statements are executed separately
<processing statement n>
END IF

SELECT CASE < word data>


CASE <comparison value 1>
<Processing statement 1 >
CASE <comparison value 2>
<processing statement 2 > According to value of <word data>, select
SELECT · and execute multi-branch control statement
statement · correspondingly.
·
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Script Function

OVERVIEW
 Loop control statement
To process according to specified conditional loop.
1
 Type of loop control statement

KV Script Function
Control
Basic format Description
statement
FOR <word data>=<default>
TO <final value> STEP <increment > Loop processing is performed
FOR statement <processing statement>
until <word data>= <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 "Control statement", Page 4-10.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-13


KV Script Function
OVERVIEW

About Suffix
1 In Ladder language, the suffix attached with an instruction can indicate the operation type of the
KV Script Function

instruction; meanwhile, in KV script, the suffix attached with a device or constant can indicatethe
operation type of a function or the meaning of value stored in the device.
For data type (suffix), see "Data Type (suffix)", Page 3-62.

Point When using variables, they operate as follows.


• When a suffix is added to variables・・・Operate according to the data type
specified by the suffix
• When no suffix is added to variables・・・Operate according to the data type set
in the variable edit window
"Variables", Page 3-49

 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+38≤N≤-1.4E-45
N=0
.F Single precision floating point type
1.4E-45≤N≤3.4E+38
(Number of effective digits: approx. 7 digits)
-1.79E+308≤N≤-2.23E-308
N=0
.DF* Double precision floating point type
2.23E-308≤N≤1.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 only be specified with KV-8000/7000 Series CPU units, KV-5500/5000/3000 Series
CPU units that have CPU function version 2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", Page 4

 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Script Function

OVERVIEW
 Omitting suffix
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)
1
R(DR),B,MR,LR,T,C,CTC*3,CR,UR .B (bit type)

KV Script Function
DM,W,EM*2,ZF*2,FM*2,TM,CM,V,P,UM,UV
.U ( unsigned 16-bit data)
indirect specifying (* ) device
KV-8000 :.L ( signed 32-bit data)
KV-7500/7300 :.L ( signed 32-bit data)
Z*1 KV-5500/5000/3000 :.L ( signed 32-bit data)
KV-1000 :.S (signed 16-bit data)
KV Nano Series :.L ( signed 32-bit data)
CTH*3 .D ( unsigned 32-bit data)

*1 The default type varies with the CPU units used.


*2 EM, FM, ZF cannot be used with the KV Nano Series.
*3 For KV-8000/7000 Series, CTC and CTH are not used.

● Variable suffix
When the suffixes of global variables or local variables are omitted, the type processed will be
determined according to the "data type" selected when registering the variables.
Variable data type Type when the suffix is omitted (default type)
BOOL Bit .B
INT 1-word signed integer .S
DINT 2-word signed integer .L
UINT 1-word unsigned integer .U
UDINT 2-word unsigned integer .D
Single-precision floating
REAL .F
point type
Double-precision floating
LREAL .DF
point type
STRING String (.T)*1
TIMER Timer .B
COUNTER Counter .B
ARRAY Default data type specified when registering variables
Default data type of each member set in the structure
Structure type
definition
Function block type Default data type of each argument set in the argument setting

*1 No suffix can be written for variables with the data type set to "STRING" (Always use them with
the suffix omitted).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-15


KV Script Function
OVERVIEW

 Label suffix
For programming when suffix of global label/local label is omitted, the processing type depends on the
1 "data format" selected when registering a label.
Label data type Type processed when suffix is omitted (default type)
KV Script Function

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
This varies depending on the data format in use when the
Array
array size is specified.

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

 Device type declaration


By declaring the type of device at the start of script program, default type of every device can be
specified.
Declaration
Format Description
statement
DM1000 will be still processed as .D (32-bit
TYPE DM1000.D
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 "Data Type (suffix)", Page 3-62.

Point • 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.

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

1-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV Script Function

OVERVIEW
About Script Function

KV-8000/7500/7300/5500/5000/3000/1000 or KV Nano Series ladder instructions can be used via KV


1

KV Script Function
script for script function.
To discriminate from ladder instructions, the instruction used via KV script are called "script function".

 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.

Reference 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 data and bit data, Including ANDA and ORA
Operation processing
logical operation, BMOV and FMOV for data movement, and SIN and COS floating-
function
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 data.
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 1-17


KV Script Function
OVERVIEW

 About operation flag (CR2009 to CR2012)

1 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
KV Script Function

combinations, so, if operation flag varies with the change of script program, it cannot be used.

 When looking up notes on indirect specifying and index modification


When using indirect specifying and index modification, be careful not to specify a device or work area
outside the specified range.
When a device or work area outside the specified range is accessed using indirect reference 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 LDP,LDF,BLD,BLDB,LDPB,LDFB,UNIF,RDASC,RHASC,RFAS
C,VAL,LEN,SFIND,INSTR,FIND,SEG,MAX,MIN,AVG,WSUM,BS
UM,BCMP,BCMPI,SEC
NUL (00H) is stored 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 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, 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, ACNT
*1 But, if invalid indirect lookup is performed in the 1st argument, the correctness of return value cannot be
guaranteed.

1-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
2
PROGRAMMING SCRIPT

PROGRAMMING SCRIPT•••••••••••••••••••••••••••••••••••••••••• 2-2


Box Script •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-4
Area Script ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-16
Label Programming and Label Array ••••••••••••••••••••••••••• 2-37
Precautions when programming script ••••••••••••••••••••••••• 2-51
Script Conversion Output Message ••••••••••••••••••••••••••••• 2-52
Macro ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 2-60
Script Debug Function ••••••••••••••••••••••••••••••••••••••••••••• 2-62
Input Auxiliary Function and Other Info •••••••••••••••••••••••• 2-64

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-1


PROGRAMMING SCRIPT

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

Programming Script

2 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.
Programming Script

How to Program 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 shortcut key


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

(1) (3)

(2)

2-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


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.

2
■ Direct input (default)

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

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-3


PROGRAMMING SCRIPT

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

Features of Box Script

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

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

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 development

2-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box 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. 2
DM2

Box Script
1999
• DM0=0 → DM2=50
• DM0=50 → DM2=74
• DM0=100 → DM2=98
• DM0=500 → DM2=293
• DM0=1000 → DM2=537
• DM0=2000 → DM2=1024
• DM0=4000 → DM2=1999

50

0 DM0
0 4000

Use Box Script to program above operation.

Box script

Ladder development

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-5


PROGRAMMING SCRIPT

Box Script

Making Box Script

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

2 Operation Flow
Box Script

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

Programming execute condition


(contact) using ladder • From icon……

• From key operation…… key +key

• From menu……
New a box script "Script (S)" 
Correct program
"Insert box script (B)"

• From right-click menu

Program and edit scripts "Edit script (X)" 

"Insert dialog script (B)"

Convert scripts

When conversion fails

Verify error by
popped window
When conversion successful

Verify program operation

Use Monitor
or Simulator function

When defective operation occurs

2-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box 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
Box script is made at this section.
Select the cell.

• Box script occupies 6 cell (cell 5 to 10). Execution condition can be programmed within
Reference
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 • key+ key


• From right-click menu, select "Edit script (X)" → "Insert box script (B)".。

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-7


PROGRAMMING SCRIPT

Box 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

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

Insert dialog script and then


program

Then program
execute conditions

2-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box 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-52

● When conversion fails


"Script conversion error" will be displayed.
In addition, the popping up window displays error message.
"When conversion error occurs", page 2-55

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-9


PROGRAMMING SCRIPT

Box 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 procedure • Select the extended box script, select "Edit script (X)" → "Display/hide converted ladder
2 (V)"from right-click menu.
• key+ key
Box Script

Please click ladder


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

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

6 The outspread 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box Script

Reedit Box Script

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

■ Reedit Box Script 2


1

Box Script
To reedit the box script programmed, double-click the Box Script to be edited.

Other procedure After selecting the box script to be edited, click the following keys:
• key
• key
• 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-11


PROGRAMMING SCRIPT

Box 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 • key+ key


• From 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 • key+ key


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

2-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box Script

Reference The whole rung including box script can be also copied.

Please select whole 2


rung you want to copy,

Box Script
and then select
"Edit (E)"  "Copy (C)"
from the menu

Select rung

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 state of the execution condition of the differential execution type function is the state when
the last box script (subroutine) was executed.
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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual, "Precautions when using differential execution Type Instructions."

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-13


PROGRAMMING SCRIPT

Box 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.
2 For example, when programming the following programs:
Box Script

Box script

Ladder development

Observe the extend ladder program, if the reset condition of timer instruction is CR2002 (normal 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Box Script

As execution condition, connect AND to DIFU instruction


Box script

Box Script
Ladder development

When execution condition (MR1000) of Box Script is TRUE, MR1100 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-15


PROGRAMMING SCRIPT

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

Features of Area Script

2 Area script is programmed on a whole rung.


Area Script

Area script is used in the following cases

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 right 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Area 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 2
corresponding to DM50.T.

Area Script
Using area script to program the part from disk category identifying to storaging.

When the disk reaches the check point, disk color can be detected via color sensor.
• 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-17


PROGRAMMING SCRIPT

Area Script

Making Area Script

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

2 Area script is used in the following cases


Area Script

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

• From icon……
• From key operation… key + key
New a area script
• From menu……
Modify program "Script (s)"  "Insert area script (A)"

• Right click menu

Program and edit scripts "Script edit (X)"  "Insert area script (A)"

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Area 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.


2

Area Script
Select cell

Make area script in this part

Reference 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 •Press key+ key.


• From right-click menu, select "Edit script (X)" → Insert area script (A)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-19


PROGRAMMING SCRIPT

Area 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
Area Script

Please use + or key to Status for editing


complete programming .

Status after edit completed

4 Area script shall be converted after programming completed.

● When conversion successful

indicates conversion completed

The popping up window displays "Warning" message sometimes.


"Warning Message", page 2-52

2-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Area 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-55
2
5 After successful script conversion, is displayed on the left side of area script. Click to

Area Script
extend ladder under area script.
(if script conversion fails, will be not displayed)

Other procedure Select the expanded area script, select "Edit script (X)" → "Display/hide converted ladder
(V)" from right-click menu.
• key+ key

Please click ladder


extend button

Status after conversion completed


Click to
extend ladder Click and the extended
ladder is hidden

will appear after


extending

Status after extending ladder

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

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-21


PROGRAMMING SCRIPT

Area 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.
• key
• key

Please double
click in this box

Uneditable

Editable

2-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Area 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-23


PROGRAMMING SCRIPT

Area Script

■ Copy area script

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

2
Area Script

Selected

Other procedure • key+ key


• From 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 procedure • key+ key


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

2-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


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

Point Variables can be used only with KV STUDIO Ver11.0 or later, and the compatible
model is only KV-8000 Ver.2.0 or later.

Label Programming and Label Array


Label Programming

Pre-setting the label for the device used in the program can allow label programming. KV STUDIO can
use variables for programming in addition to devices. Programming using variables has the following
advantages.
• Since the predefined names can be used for programming, the program readability is improved.
• The required size of the variable is automatically assigned to the work area of the CPU unit in
combination with the defined variable. Therefore, there is no need to care about the assignment.
• The device map is no longer created in advance, so that the debugging efficiency, etc. can be
improved, thus reducing the programming man-hours.
• Variables are automatically assigned even when a program is copied between different projects.
Unlike the devices, the device map need not be changed before copying, which makes the program
more reusable.
• Since the touch panel display of VT5 series also supports the variables of the KV-8000 series, there
is no need to change the device number, etc. on the touch panel display side when changing a device
number of PLC like the devices.

Global and local variables

There are 2 types of variables: global variables and local variables. Their features are as follows.

Details Global variables Local variables


The same entity is processed jointly These are variables that can be used only in
throughout the project. When the same global the program. Different entities are referenced
Entity
variable name is written in different programs, even if the same local variable name is written
the same entity is referenced. in different programs.
There are two types: manual assignment to The CPU unit automatically assigns the
Assignment devices and automatic assignment from the variables to the work memory. They cannot be
CPU unit to the work memory. assigned to a device.
The variables can be used for communication
areas with external equipment such as touch
Since no conflict occurs between different
panel display. Also, the expansion unit devices
Usage programs even if the same variable name is
such as operation enable can be programmed
used, they can be used as areas for operation.
using variables by assigning the expansion unit
devices in advance.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-25


PROGRAMMING SCRIPT

Label Programming and Label Array

Variables and data formats at a glance

When using variables, it is necessary to define the data format in advance. The CPU unit automatically

2 allocates the necessary data size to the work area *1 according to the defined data format.
The work area sizes and variable specifications that can be used with KV-8000 are as follows.
Label Programming and Label Array

Item Details
bit 64000 point
word 589824 words
Work area size
Timer 4000 point
Counter 4000 point
Definable number 100000 point*2
Variable specifications Maximum length of
128 character*3
variable name

*1 If it is defined as a global variable, it can also be manually assigned to a device of the CPU unit.
*2 Definable number means the variable name that can be registered in the variable edit window.
For example, if one array type variable 10000 elements is defined, it is counted as 1 point.
*3 The character code of the variable name is UTF-16.

The data types and data sizes of variables that can be used with KV-8000 are as follows.

Data type The amount of data


Type name Description (Byte unit)
BOOL bit 1
UINT 1 word unsigned integer 16
INT 1-word signed integer 16
UDINT 2 word unsigned integer 32
DINT 2-word signed integer 32
Single precision floating point
REAL 32
type
Double precision floating
LREAL 64
point type
(Number of characters *2+1) × 8 rounded up
STRING*1 Text string
to an integral multiple of 16
TIMER Timer -
COUNTER Counter -
ARRAY Array Data size in data format × array size
Structure - Based on definition*3
Function block Function block Based on definition*3

*1 The character code processed in STRING type follows the language set in the project language
settings. For details on project language settings, refer to "KV STUDIO User's Manual".
*2 The number of characters is the number of bytes up to NULL. For double-byte characters such as
Shift-JIS, the number of characters is calculated as 2 with 1 character.
*3 Structures and function blocks are data formats that use multiple data formats. Therefore, the
data size is determined according to the setting contents.

2-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

Array

Array is a data type that defines a collection of data of the same data type with 1 name. Each data that
constitutes an array is called an element. When using an array, the data type, number of elements and
number of dimensions should be set in addition to the variable name. An array with n dimensions is
2
called an n-dimensional array. An example of 1-dimensional array to 3-dimensional array is shown

Label Programming and Label Array


below.

• 1-dimensional array Variable name: Array_A Number of elements: 5

Array_A [0] [1] [2] [3] [4]

Number of elements 5

• 2-dimensional array Variable name: Array_C Number of elements: 6×5×4

Array_B [0,0] [0,1] [0,2] [0,3]

[1,0] [1,1] [1,2] [1,3]


Number of elements 5

[4,0] [4,1] [4,2] [4,3]

Number of elements 4

• 3-dimensional array Variable name: Array_C Number of elements: 6×5×4

Array_C

[5,4,3]

■Writing of array type variables


● Specification of element of array type variable
When an array element is specified and used in a program, the combination of the array name and the
subscript of [ ] is used. For an array with 2 or more dimensions, specify the element numbers
separated by "comma (,)". For example, when using the elements [5,0,3] of the 3-dimensional array
Array_C, write "Array_C[#5,#0,#3]" in the program as follows. (# can be omitted)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-27


PROGRAMMING SCRIPT

Label Programming and Label Array

● Specification of entire array type variable


All elements that constitute an array are called "the entire array". When an entire array is specified in a
script, only the variable name is written. For example, when specifying the entire array of a variable
2 called Array_A, write "Array_A".
Label Programming and Label Array

Array specifications

Item Details
Maximum number of elements
589823
per dimension
Maximum number of dimensions 8
Maximum data size that can be
589823 words
occupied per array
Data types that can be specified BOOL / UINT / INT / UDINT / DINT / REAL / LREAL / Structure
Subscripts that can be
Device / constant / variable / operation formula*2
specified*1
Data types that can be used for
UINT / INT / UDINT / DINT
subscript

*1 Specify 0 or a positive integer for the subscript. If any other number is specified, a conversion
error or operation error will occur.
*2 Only KV scripts can use operation formulas as subscripts. Operation formulas cannot be used as
subscripts in ladder programs.

Point • When an element specified exceeds the specifiable range, such as specifying
Array_A[10] (11th element) for an array called Array_A set with the number of
elements "10", the value in an unintended area may be referenced. Especially
when using variables or expressions as subscripts, the ACNT function or WSIZE
function should be executed before referencing the array to obtain the number of
elements in the array or the data size of the entire array, and avoid referencing
elements beyond the specifiable range.
"ACNT function", page 6-60
"WSIZE function", page 6-62
• If a device is specified as the subscript of an array, it is processed as a 16-bit
unsigned integer.
• Bit devices (R, MR, etc.), word device bits and BOOL type variables cannot be
specified for the subscript.

2-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

Structure

Structure is a data type that defines a collection of data of multiple data types with 1 name. Each data
that constitutes a structure is called a member. When using a structure, the names of the members that
constitute the structure and the data types of the members should be set in addition to defining its
2
name. The structure has the following advantages.

Label Programming and Label Array


• Registering the structure members and data types in advance makes it easier to create variables with
the same structure.
• All members can be monitored in batch by registering a structure variable when monitoring in the
registration monitor window, etc.

The following is an example of using the following information of a motor axis in a program.
Current coordinate (CurCoordinate)
Current speed (CurSpeed)
Axis control (Control)
Axis error (Error)
Axis error code (ErrorCode)

If multiple axes are used without a structure, variables with the same content except for the axis number
should be registered as shown below.
When using a structure, the data type should be set to the same structure only when using multiple
axes after defining the data structure of axis information as a structure in advance.

<When not using a structure> <When using a structure>


Variable name Data type Variable name Data type
Ax1_CurCoordinate DINT Ax1 AxisInfo
Ax1_CurSpeed DINT Ax2 AxisInfo
Ax1_Control BOOL
Reuse the pre-
Ax1_Error BOOL Definition of "AxisInfo" type data set structure
Ax1_ErrorCode UINT Member name Data type
Ax2_CurCoordinate DINT CurCoordinate DINT
Ax2_CurSpeed DINT CurSpeed DINT
Ax2_Control BOOL Control BOOL
Ax2_Error BOOL Error BOOL
Ax2_ErrorCode UINT ErrorCode UINT

Also, if no structure is used when monitoring in KV STUDIO, it is necessary to manually enter all
variables, but if a structure is used, the members in the structure can be monitored in batch simply by
entering a variable name.

<When not using a structure> <When using a structure>

When using a structure, the members can be


All variables to be monitored must be entered. monitored in batch simply by entering a variable
name.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-29


PROGRAMMING SCRIPT

Label Programming and Label Array

■Writing of structure type variables


This section describes how to write structure type variables when using them in a program.

●Specification of member of structure type variable

2 When using a member of a structure type variable in a program, write "Structure type variable name +
Period (.) + Member name". For example, "Ax1.CurSpeed" is written to reference a member called
Label Programming and Label Array

CurSpeed of an AxisInfo type variable called Ax1.

A structure can also be specified for the data type of a member of a structure type variable. In the
following example, a structure type variable called "ProductionDate" is nested in the structure type
variable Product_A of "ProductInfo".
Definition of "DateInfo" type
Definition of "ProductInfo" type data
data
Variable name Data type Member name Data type Member name Data type
Product_A ProductInfo Name STRING[20] Year UINT
SerialCode STRING[20] Month UINT
ProductionDate DateInfo Day UINT

When Day of Product_A is specified with a program, write "Product_A.ProductionDate.Day".

Point Structures can be nested up to 8 stages.

●Specification of entire structure type variable


All members that constitute a structure type variable are called "the entire structure". When an entire
structure is specified in a program, only the variable name is written. For example, when specifying the
entire structure of a structure type variable called Product_A, write "Product_A".

Point • When writing a value to the entire structure using the FMOV function, etc., the
value in an unintended area may be referenced if a value larger than the number
of data in the entire structure is specified as the number of move data. When
referencing the entire structure with the FMOV function, etc., the WSIZE function
should be executed before the function execution to obtain the data size of the
entire structure.
"WSIZE function", page 6-62

2-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

Structure specifications

Item Details
Maximum number of structures
defined
800
2
Maximum number of members per
500

Label Programming and Label Array


structure
Maximum number of stages for
8*1
nesting of structures
Data types that can be specified as BOOL / UINT / INT / UDINT / DINT / REAL / LREAL / STRING/ Array /
members Structure

*1 When stAAA.member is written, the number of nesting stages is 1. When stAAA.stBBB.member


is written, the number of nesting stages is 2.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-31


PROGRAMMING SCRIPT

Label Programming and Label Array

Variable Setting

This section describes the procedure from defining variables to using them in a ladder program.

2 ■How to set from the variable edit window


Label Programming and Label Array

Global and local variables can be set with this method.

1 Select "Display (V)" → "Variable Edit Window (L)" to open the "Edit Settings" window.
Other procedure Double-click "Variable" in the workspace

2 3 4 5 6 7 8

No. Item Details


Global / Local Switches between the global variable edit tab and local variable edit tab.
1
tab "Global and local variables", page 2-25
2 Variable name Enter the variable name (128 half-width characters / 128 full-width characters).
Select the data type of the variable from below.
3 Data type BOOL / UINT / INT / UDINT / DINT / REAL / LREAL / STRING /
TIMER / COUNTER / ARRAY / Structure / Function block
Assignment Set when manually assigning variables to devices of the CPU unit. Assignment is
4
Device not mandatory. This item does not exist in the local variable edit tab.
When the "Constant" item is checked:
Specifies the initial value of a variable. When the constant is checked, the value
is fixed and cannot be changed from the program.
When the "Constant" item is not checked:
5 Value
Sets the initial value of a variable. The value can be changed in the program.
When the assigned device is set, the initial value cannot be set in the variable
edit window. The initial value of the assigned device should be set in the device
initial value setting. For details, refer to the CPU Unit User's Manual.
Checked variables hold their values even when the power is turned off. The
maximum number of variables that can be held is 30000 including bits, words and
counters.
When the assigned device is set, the power off holding should be performed for the
6 Hold set device since it is not included in the above 30000 devices.
Variables without Retention checked will be initialized to the value set in "Value"
when switching from PROGRAM mode to RUN mode. It is initialized to 0 when not
set.
For details, refer to the CPU Unit User's Manual.
Checked variables are processed as constants. Variables set as constants are
7 Const included in the maximum of 100000 definitions, but they do not consume the work
area.
Sets the variable comment (32 half-width characters / 32 full-width characters).
8 Comment The set comment is displayed in the KV STUDIO ladder edit window. Comments 1
to 8 can be set for 1 variable.

2-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

■How to set unregistered variables imported in a script


With this method, only local variables can be set.

1 Write a script using variables.

2
2

Label Programming and Label Array


With the string to be registered as a local variable in the script selected, select "Register Local Variable
(L)" from the context menu.

3 The variable edit window will be displayed with the variable name imported. Set the data type.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-33


PROGRAMMING SCRIPT

Label Programming and Label Array

● Batch registration of local variables


This section describes how to import unregistered variables in a module in batch as local variables.
Click in the variable edit window when there are unregistered variables. All unregistered variables
existing in the target module are imported as local variables. Set the data type.
2
Label Programming and Label Array

Click the variable


import icon.

Unregistered
variables are
imported in batch,
and the display color
of registered
variables changes.

Point All variables in the module will be registered after performing batch registration.
Therefore, errors are also registered as variables, so that errors that originally
occur during conversion may be converted normally.
Example DN1000=10 ....Before batch registration: during script conversion, error
occurs.
....After batch registration: error will not occur during script
conversion.
It is recommended to confirm the registered contents in the variable edit window
after batch registration.

2-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

Precautions for using variables

This section describes restrictions and precautions when using variables.

● About variable suffix


2

Label Programming and Label Array


Variables can be written without adding a suffix when writing them in a script since the data type is set
in the variable edit window. However, they can also be added with a suffix like the devices. Type
declaration by TYPE is also possible. Their priority is as follows.

Data type < Type declaration < Suffix

low Order of prionity high

The suffix that can be specified is limited by the data type set when registering the variable.
Global variables (Automatic assignment) /
Global variables (Manual assignment)
Item local variables
.B .U .S .D .L .F .DF .T Omitted .B .U .S .D .L .F .DF .T Omitted
BOOL ○ × × × × × × × .B ○ × × × × × × × .B
UINT ○ ○ ○ ○ ○ ○ ○ ○ .U ○ ○ ○ × × × × × .U
UDINT ○ ○ ○ ○ ○ ○ ○ ○ .D ○ ○ ○ ○ ○ ○ × × .D
INT ○ ○ ○ ○ ○ ○ ○ ○ .S ○ ○ ○ × × × × × .S
DINT ○ ○ ○ ○ ○ ○ ○ ○ .L ○ ○ ○ ○ ○ ○ × × .L
REAL × ○ ○ ○ ○ ○ ○ × .F × ○ ○ ○ ○ ○ × × .F
LREAL × ○ ○ ○ ○ ○ ○ × .DF × ○ ○ ○ ○ ○ ○ × .DF
STRING × × × × × × × ○ .T × × × × × × × ○ .T
Timer ○ ○ ○ ○ ○ × × × .B ○ ○ ○ ○ ○ × × × .B
Counter ○ ○ ○ ○ ○ × × × .B ○ ○ ○ ○ ○ × × × .B

〇: Suffix can be specified. However, if a suffix different from the data type is specified, a warning will be
issued during conversion.
×: Suffix cannot be specified.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-35


PROGRAMMING SCRIPT

Label Programming and Label Array

● Variable range check


The range check will be performed when using KV-8000 to avoid the result of function execution
referencing an area that exceeds the variable range. The content of the range check differs depending
on the variable settings.
2 The following is an example of using a variable called Array_A with the number of elements set to 10.
Label Programming and Label Array

For global variables (automatic assignment) / local variables


When a constant exceeding the number of elements is specified, such as Array_A[20], an error will
occur during script conversion.
When other than a constant is specified for the number of elements, such as Array_A[idx], no error
occurs during script conversion. If the value of idx exceeds the range of 0~9 during program execution,
a calculation error will occur during instruction execution.

For global variables (manual assignment)


The following is an example in which the start of Array_A is assigned to DM0.
When a constant exceeding the number of elements is specified, such as Array_A[20], an error will
occur during script conversion.
When other than a constant is specified for the number of elements, such as Array_A[idx], a warning
will be issued during script conversion, but no error will occur. If the value of idx exceeds the range of 0
~ 9 during program execution, the target device will be processed, and no calculation error will occur.
For example, when idx=19, Array_A[idx] will be processed as DM19.

● Other precautions
• The global variable can be set to the same variable name as the local variable, but it operates as a
local variable when used.
• Variable names cannot use the strings such as reserved words.
"List of Characters That Cannot Be Used", page A-54
• Index modification cannot be performed for global variables and local variables automatically
assigned.
• Index modification and indirect specification cannot be performed for variables of array type and
structure type.
• When "Constant" is checked in the [Variable Edit] window, index modification and indirect
specification cannot be performed.

2-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


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

• Only labels can be used in projects where the model setting is other than KV-
Important
8000 (CPU function version 2.0 or later).
When the model setting is KV-8000 (CPU function version 2.0 or later), variables
can be used instead of labels.
2

Label Programming and Label Array


"Label Programming", page 2-25
• KV-1000 cannot use local labels and label arrays. Only global labels can be
used.

Label Programming

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.

• Only labels can be used in projects where the model setting is other than KV-
Point
8000 (CPU function version 2.0 or later).
When the model setting is KV-8000 (CPU function version 2.0 or later), variables
can be used instead of labels.
"When conversion error occurs", page 2-55
• Local label cannot be used when CPU unit is KV-1000.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-37


PROGRAMMING SCRIPT

Label Programming and Label Array

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

2 ● Programming flow using global label


Label Programming and Label Array

Pre-register the following items


Register global label ・Label name
through label edit window
・Data format*1
・Device/Constants
Program and edit scripts ・(Label comments)*1*2
using global labels registered

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


2 Label 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 the tool bar in the Script Edit window.

Click “Global” label when using


KV-8000/7500/7300/5500/5000/3000
or KV Nano series CPU.

2-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

2 Register global label to be used.


For label editor window, see KV STUDIO User's Manual.
When selecting CPU KV-8000/7500/7300/5500/5000/3000 or KV Nano Series

Label Programming and Label Array


Item Description
Set within 32 characters (or single-byte 32 characters, double-byte 16 characters for
Label name
KV-5500/5000/3000/1000 or KV Nano Series).* 1
Specify label type. Click input box, select label type from the drop down menu
Data type
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-44
Label comment Specify comment in global label.

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-44

When selecting CPU KV-1000

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

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-44
*2 There are also devices that cannot be specified.
"KV STUDIO User's Manual"

Point Labels can be set for global devices. But labels cannot be set for local devices.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-39


PROGRAMMING SCRIPT

Label Programming and Label Array

3 Use global label registered to make script program.

2
Label Programming and Label Array

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


Convert script after programming completed.

● Example for programming using global label

2-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

■ Local label
Local label refers to label that can be used when CPU is KV-8000/7500/7300/5500/5000/3000 or KV
Nano Series, 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-8000/7500/7300/
5500/5000/3000 or KV Nano Series, local label can be also set even if service condition of the device is 2
not known.

Label Programming and Label Array


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

The work memory is configured as follows.


Reference
KV-8000 VM: 589824 words VB: 64000 points (4000ch)
KV-7500/7300/5500/5000/3000 VM: 50000 words VB: 16384 points (2024ch)
KV Nano Series VM: 9500 words VB: 8192 points (512ch)
The assignment status is managed by KV STUDIO.
"About Script Work Memory (Work Devices)", page 2-74

● Programming flow using local label

Program and edit


scripts using labels

Register programmed
labels* as local labels

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 described as follows.

1 Program script with labels.

Character color is not changed due to label not registered.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-41


PROGRAMMING SCRIPT

Label Programming and Label Array

2 Under script editing mode, select the label range registered as local label, select "Register local
label (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 type Data format can be changed by clicking drop-down menu.
"About label type", page 2-44
During constant assignment of local label, constant can be specified. Constant is not
Const
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-44

All labels of the module being edited can be registered in batch as local label.
Reference
"Batch register of local label", page 2-43

2-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

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.

During batch registration, all labels in module are registered. So, the error flag is also
Point
registered as label, the error occurring in script conversion may appear in normal
conversion.
Exampl 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-43


PROGRAMMING SCRIPT

Label Programming and Label Array

■ Precautions when using label


● About label type
When CPU is KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, data format (type) can be

2 specified in label.
Label Programming and Label Array

Data format can be selected as follows.


Item Processing data range
bit BOOL O(OFF,FALSE),1(ON,TRUE)
1-word Unsigned integer UINT 0~65535
2-word Unsigned integer UDINT 0~4294967295
1 word signed integer INT -32768~+32767
2 word signed integer DINT -2147483648~+2147483647
-3.4E+38≦ N ≦-1.4E-45
Single precision N =0
floating point type REAL 1.4E-45≦ N ≦3.4E+38
Real number (For the KV Nano Series, an absolute value in a range of 1.4E-45 to
1.2E-38 cannot be used.)
Double precision -1.79E+308≦N≦-2.23E-308
floating point type LREAL N=0
Real number 2.23E-308≦N≦1.79E+308
Text string STRING No more than 32 characters (single-byte character)
Timer*2 --- 0(OFF,FALSE),1(ON,TRUE)
counter*2 --- 0(OFF,FALSE),1(ON,TRUE)
Specify via "Array size" dialog box
Array ---
"Label Array", page 2-46

*1 • The ".DF" suffix can be used only with the KV STUDIO Ver.6.00 and higher versions.
• The ".DF" suffix can only be specified with KV-8000/7000 Series CPU units, KV-5500/5000/3000 Series CPU
units that have CPU function version V2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
*2 If a .D suffix is added to the label, it will be handled as the current value.

● 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.
Type declaration can be also conducted based on TYPE. The relationship between
Reference
"Data format" set in the label editing window, "Type declaration" based on TYPE, and
"Direct designation" of suffix is as follows.

Data format < Type declaration < Direct specifying

Low PRI High


2-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
PROGRAMMING SCRIPT
Label Programming and Label Array

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
.B .U .S .D .L .F .DF .T Omitted .B .U .S .D .L .F .DF .T Omitted
bit ○ × × × × × × × .B ○ × × × × × × × .B 2
1-word Unsigned integer ○ ○ ○ ○ ○ ○ ○ ○ .U ○ ○ ○ × × × × × .U

Label Programming and Label Array


2-word Unsigned integer ○ ○ ○ ○ ○ ○ ○ ○ .D ○ ○ ○ ○ ○ ○ ○ × .D
1 word signed integer ○ ○ ○ ○ ○ ○ ○ ○ .S ○ ○ ○ × × × × × .S
2 word signed integer ○ ○ ○ ○ ○ ○ ○ ○ .L ○ ○ ○ ○ ○ ○ ○ × .L
Single precision
floating point × ○ ○ ○ ○ ○ ○ × .F × ○ ○ ○ ○ ○ ○ × .F
type real number
Double precision
floating point × ○ ○ ○ ○ ○ ○ × .DF × ○ ○ ○ ○ ○ ○ × .DF
type real number
Text string × × × × × × × ○ .T × × × × × × × ○ .T
Timer ○ ○ ○ ○ ○ × × × .B ○ ○ ○ ○ ○ × × × .B
Counter ○ ○ ○ ○ ○ × × × .B ○ ○ ○ ○ ○ × × × .B

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

Reference 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 (DM1000.12, etc.) .B
* When specifying ".T", please specify the leading device of channel to assign the bit device.

● 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 Characters That Cannot Be Used", page A-54
• When CPU unit is KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, label is double-byte
character/single-byte character sensitive but is not case-sensitive.
• Index modification cannot be conducted for local label.
"Index modification", page 3-55
• Index modification and indirect specifying cannot be conducted for label array.
"Label Array", page 2-46
• 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-46

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-45


PROGRAMMING SCRIPT

Label Programming and Label Array

Label Array

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

2 window.

When CPU is KV-1000, label array cannot be used (global label array, local label
Label Programming and Label Array

Point
array).

● 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 taking 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

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

• Index modification cannot be conducted for label array.


Point
• The indirect specifying device cannot be specified in label array.
• When programming devices and formulas in the end-of-label character of the label
array, the stored value should not exceed the range of the end-of-label character.

Range Multi-dimensional array: up to 8 dimensions


Label end code range : KV-5500/5000/3000 or KV Nano Series: 1 to 131071
KV-8000/7500/7300: 1 to 589823

2-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

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]
2
LABEL[0,9]

Label Programming and Label Array


0 1 2 3 4 5 6 7 8 9
LABEL[1,9]
0 1 2 3 4 5 … … … 9
LABEL[1,0]
1 10 11 12 19
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 • Double-click "Label" in workspace.


• Click the tool bar in the Script Edit window.

Click “Global ” label.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-47


PROGRAMMING SCRIPT

Label Programming and Label Array

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

2
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
Data type Specify label type. Click input box, select label type from the drop down menu 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.

Reference Please select data format from the following option.

Item Processing data range


bit 0(OFF,FALSE),1(ON,TRUE)
1-word Unsigned integer 0~65535
2-word Unsigned integer 0~4294967295
1 word signed integer -32768~+32767
2 word signed integer -2147483648~+2147483647
-3.4E+38≦ N ≦-1.4E-45
Single precision floating N =0
point type 1.4E-45≦ N≦ 3.4E+38
(For the KV Nano Series, an absolute value in a
range of 1.4E-45 to 1.2E-38 cannot be used.)

Double precision floating -1.79E+308≦ N ≦-2.23E-308


point type N =0
2.23E-308≦ N ≦1.79E+308
4 Specify global device to be assigned.

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

2-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Label Programming and Label Array

■ Local label array


The label pre-registration method of local label array and global label array is identical to registration
method after script programming.
The method of registering local label array after script programming is introduced below.
2
1 Using local label array to program the script.

Label Programming and Label Array


Character color is not changed due to label not registered.

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

Select range of label name only.


End code not selected.

Right-click menu

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-49


PROGRAMMING SCRIPT

Label Programming and Label Array

3 Set local label array in label edit window.

2
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 type
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-74

Reference Please select data format from the following option.

Item Processing data range


bit 0(OFF,FALSE),1(ON,TRUE)
1-word Unsigned integer 0~65535
2-word Unsigned integer 0~4294967295
1 word signed integer -32768~+32767
2 word signed integer -2147483648~+2147483647
-3.4E+38≦ N ≦1.4E-45
Single precision floating point N =0
type 1.4E-45≦ N ≦3.4E+38
(For the KV Nano Series, an absolute value in a
range of 1.4E-45 to 1.2E-38 cannot be used.)

Double precision floating -1.79E+308≦ N ≦-2.23E-308


point type N =0
2.23E-308≦ N ≦1.79E+308

2-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Precautions when programming script

About Parallel Connection of Box Script

"OR" (logical OR) connection cannot be made


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

Precautions when programming script


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

Execution condition

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).

• Operation formula shall be processed within the range of .L (signed 32-bit ) (-


Point
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-52
• When impairing precision, "Warning" display can be set.
"Setting method of warning level", page 2-53

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-51


PROGRAMMING SCRIPT

Script Conversion Output Message


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.

2 Warning Message
Script Conversion Output 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.
It will occur when the result type of assignment statement on the right side is different from the left type,
the operation formula includes .D, or when the function cannot be executed with the current model.

■ Type conversion leads to data loss


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

Programmin 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 1103]: "=": (signed 32-bit integer type → suffix 16-bit integer type) data may be lost dueto
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.
" Precautions when programming script", page 2-51

■ Functions that cannot be executed with the current model


For the models below, a warning occurs when a function is executed because the function cannot be
executed.

KV-N24□□
Functions that generate warnings KV-N14□□ KV-N40□□ KV-NC32T
KV-N60□□
WTIME/AJST Warning - -
MWRIT/MREAD/MFREE/MFREEK
/MMKDIR/MRMDIR/MDEL/MPRINT/ Warning Warning -
MREADL/MCOPY/MMOV/MREN/MSTAT
AWNUM/AWMSG - - Warning

When converted, the following message is displayed in the output window (when the script warning
level is set to "High").
[Warning 1008]: "MWRIT": Using a function that cannot be executed on the current model.
For the KV Nano Series, the number of internal positioning axes and the internal high speed counter
numbers differ according to the unit. If there is a function that specifies an axis number or counter
number that cannot be used, a warning occurs during conversion.
For the axis numbers and high speed counter numbers that can be used with the KV Nano Series, refer
to the "KV Nano Series User's Manual".
2-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
PROGRAMMING SCRIPT
Script Conversion Output Message

Script warning level setting

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

■ About warning level


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

Script Conversion Output Message


● 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.

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

Item Description
All warning information can be displayed including errors and warnings.
High Example) when the precision of operation formula is impaired
• DM1000.U = DM2000.L (Assign .L type data to .U type 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
• DM1000.D= 90000 * 50000
(Assign a value out of constants range (4500000000))
None No alarm will be displayed.
No warning outputs
when a suffix After the checkbox is selected, the warning that occurs when specifying a suffix
different from the different from the data type defined when registering global label is not output.
data type of global Example) When specifying global label to“1-word signed integer: UINT”and suffix .L
variable definition is specified via script
was specified.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-53


PROGRAMMING SCRIPT

Script Conversion Output Message

Error Message

Error will occur when part of scrip programs can not be converted ladder program and error causes will

2 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.
Script Conversion Output Message

■ Error message when script conversion


Maybe due to the following reasons.

● Typing error
• Function name error.
Example) correct →BLD ( DM1000, 10 ) error →BLF 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.
• 1-byte space and 2-byte space error.
Example) True →END IF (between half-width spaces) Wrong → END IF (between full-width spaces)
etc.

● 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 .
• Other general syntax error.

● Function argument error


• Argument error.
Example) correct →FIND ( DM1000.T, DM1200.T )error → FIND (DM1000.T,
• The macro that is executing calling instruction is not programmed.
etc.

● Specify invalid type


• You want to substitute a character string to a variable other than STRING type or a device without .T.
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.

2-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Script Conversion Output Message

● Others
• Nonexistent device is specified.
• There are more than 1024 (single-byte) characters in a script rung.
• Array label end code is specified in the label that has not been registered to array.
2
When conversion error occurs

Script Conversion Output Message


If you convert a script when the code in the script program is invalid due to a mistake such as mistyping
a function name, specifying an invalid type (suffix), or mistaking the usage of a control statement, a
script conversion error occurs and a dialog box is displayed.

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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-55


PROGRAMMING SCRIPT

Script Conversion Output Message

■ 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.
2 1 To convert the edited scripts.
Script Conversion Output Message

Select "Script(S)" → "Convert selected script(S)" from the menu.

Other procedure • key+ key


• 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.

2-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Script Conversion Output Message

4 After correcting, only the corrected scripts are converted.


Select "Script(S)" → "Convert selected script(S)" from the menu.

Other procedure • key+ key


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

Script Conversion Output Message


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

• In the case of many errors and warnings, other errors will be still displayed when
Reference
selecting "Convert all scripts(C)" even if one error is corrected.

Many warnings Fix only 1 Many warnings

"Convert all scripts(C)"

In this case, select“Convert selected script(S)”from the menu.


Many warnings Fix only 1

"Convert selected

Since only the corrected scripts are converted, the correction verification will be
simpler.
• By 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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-57


PROGRAMMING SCRIPT

Function block
Function blocks are ladder circuits used many times repeatedly in a project that are registered and
standardized under a name of your choosing.
The registered function blocks can be called from a script program, and scripts can be used within the
function blocks as well.

2
Calling Function Blocks
Function block

■ Calling Function Blocks


Function blocks can be called using FB / FBSTRT / FBCALL functions. To stop a function block, perform
the following steps:
• Stop the calling source program (FB/FBSTRT/FBCALL)
• Execute the FEND function (instruction) in the function block (FB/FBSTRT)
• Turn the execution condition of the function block OFF (FBCALL)
"FB function", page 6-10
"FBCALL function", page 6-11
"FBSTRT function", page 6-13
"FEND function", page 6-15
● How to use
Programming Script FB(MR1000,"FunctionBlock",DM0,#0,MR2000)
Programming Script FBSTRT(MR1000, "FunctionBlock", Instance, DM0, #0, MR2000)
Programming Script FBCALL(MR1000, "FunctionBlock", Instance, DM0, #0, MR2000)

After using the FBCALL/FBSTRT function, please upgrade the CPU function
Point
version of KV-8000 to the version after 2.0.

■ Calling functions
Functions can be called using the FUN instruction. The function stops when its execution condition is
turned OFF.

■ How to use
Programming Script FUN(MR1000,"Function",DM0,#0,MR2000)

When using KV-8000 with CPU function version 2.0 or later, the return value can be processed
Reference
after writing the FUN function in an expression.
The following is an example of storing the return value of Function1 in DM0.
Programm DM100 = FUN(MR1000, "Function1", DM0, DM1)

2-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Function block

Programing Function Blocks Using Script

Function blocks can be programmed with a mixture of ladder programs and scripts, or can be created
using scripts only.
For information on creating function blocks, see the "KV-8000 Series User's Manual", "KV-7000 Series 2
User's Manual", "4-8 Function Block".

Function block
Point END and ENDH instructions Point cannot be written in scripts.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-59


PROGRAMMING SCRIPT

Macro
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.

2 Macro Call
Macro

■ Calling subroutine 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,"MacroA",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

2-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Macro

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)". 2


Other procedure • Click the icon.

Macro
•From right-click menu, select "Edit macro (M)" → "New macro (N)"

2 Specify macro name and macro type.

Specify macro name with 12


characters (single-byte) or less.

Select macro type.

If macro name contains "+" / "-", "The bit under macro execution status" cannot be
Point
programmed in script (The script identifies "+ /-" to operators).
For details on "Bits in Macro Execution Status", refer to the user's manual of the CPU
unit used.

• Some characters cannot be used in macro name.


Reference
• Macro type can also be changed after making a macro.
• 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 setting" 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.

For detailed information on unit device contained in script program and the setting of
Reference
macro argument device, please see "Macro" in the User's Manual of the CPU unit used.

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

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-61


PROGRAMMING SCRIPT

Script Debug Function

Monitor Function

Monitor function allows to debug script program under online state or during starting simulator.
2
■ Register monitor
Script Debug Function

The current value of every device programmed in script can be monitored.

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


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

2-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Script Debug Function

■ Watch window
Through the monitor window, you can monitor the current values of all devices or variables in the script
by simply selecting the script.

1 When KV STUDIO is in Monitor or Simulator status, click the script to be monitored, select
2

Script Debug Function


"Watch window " from the right-click menu.

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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-63


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

About Input Auxiliary Function

KV STUDIO provides various convenient functions and input auxiliary functions for Script
2 Programming.
Input Auxiliary Function and Other Info

Script Function List

If function name is unknown, optional function can be called as follows after inputting function in
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 • key+ key


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

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

2-64 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

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 condition* (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 key+ key+ key

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

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

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-65


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

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.

2 The character color of reserved word can be changed via the "option setting" dialog box
Reference
Input Auxiliary Function and Other Info

of KV STUDIO.

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.

2-66 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

2 Select the function that you want to inquire.


To display detailed function descriptions.

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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-67


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

2 Click button.

2
Input Auxiliary Function and Other Info

Other procedure To select function, press key.

Display the help screen of the selected function.

2-68 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

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

Input Auxiliary Function and Other Info


● Comment writing method
Whole rung comment can be made on right side of statement (operation formula).

Whole rung comment facilitates 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.

• Even increase of comment line will not influence program size and scanning time.
Reference
• The number of characters entered on a single rung is up to 1024 characters (halfwidth)
including scripts and comments.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-69


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

Write Easy-reading Script

When programming scripts, understandable programming method enables improving debug efficiency.

2 Similar to ladder program, script programs finished shall be easy-to-understand in modification,


maintenance and reuse. So, the written script shall be understandable and clear.
So, it can be effectively used without programmer.
Input Auxiliary Function and Other Info

● Sample Program
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 written into FIFO table
DM3033 = AVG(EM2202, EM2200) 'DM3033 =average value of the latest data (10)
END IF

2-70 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

Tips for programming


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

Input Auxiliary Function and Other Info


• Automatic indent function is available.
Reference
Select "Tool (T)" → "Option (O)" from the menu, set automatic indentation of "Script"
tab to ON.
• If the line of script is long, a new line can be started by adding an underbar (_) to the
end.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-71


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

Inline Mnemonics

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

2 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 User's Manual of the CPU unit used.
Input Auxiliary Function and Other Info

With inline mnemonics, mnemonics can be programmed directly in script program, i.e. mnemonics
language can be mixed with script language.
Plus "!! " attached at the start of mnemonics is used to discriminate from script.

Programmin
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

Inline mnemonics ladder

2-72 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

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 2
constant, global label/local label can use Chinese characters).

Input Auxiliary Function and Other Info


• The number of characters input on one rung is within 1024 characters (single-byte), including scripts
and comments.
• 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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-73


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

About Script Work Memory (Work Devices)

When converting the script program to Ladder, work memories can be used for CPU unit KV-8000/

2 7500/7300/5500/5000/3000 or KV Nano Series, work memory and work devices for CPU unit KV-1000.

Work memory (work device)


Input Auxiliary Function and Other Info

Work memory (work device) refers to the device for temporarily storing partial operation result such as
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 diagram

Work memory*

*When CPU unit is KV-1000, work devices such as EM64536 can be used.
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-8000/7500/7300/5500/5000/3000 or KV Nano Series, the script uses work memories.
Work memories used for scripts can be checked via "Setup work area" dialog box.
"KV STUDIO User's Manual"

2-74 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

■ 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.
2
● When work devices are insufficient

Input Auxiliary Function and Other Info


When work devices are insufficient, the following message will be displayed in output window during
conversion of ladder program.

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

1 From the menu, select "Convert (A)" → "Entire assignment setting of local devices (A)", and
"CPU system setting" dialog box will appear.

Other procedure • Double click "CPU system setting" in workspace.


• Double click error message in popping up window
• Click button.

The setting for the reserved work devices for the script is only displayed in projects
Reference
where"KV-1000" is selected for the model (CPU unit).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-75


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

2 Edit the column for the reserved work devices for the script.
According to error message of output window, change assignment of every workspace.

2
Bit work
Input Auxiliary Function and Other Info

devices
Word work
devices

String work
devices

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

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

When using KV-8000 and KV-7500/7300 of the function version 2.2 or later, click [Working Area
Setting(W)] to assign the working area for interrupting the program.

2-76 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


PROGRAMMING SCRIPT
Input Auxiliary Function and Other Info

XYM Marking

Script program can be made via XYM marking.

■ Script program via XYM mark.


2

Input Auxiliary Function and Other Info


1 From the menu, select "Tool (T)" → "Option (O)".
"Option settings" dialog box appears.

2 Click the "Display modes setting" label.

Select “Display by XYM(X)” checkbox


and click “OK”.

3 Program with XYM marking.

After selecting "Display by XYM (X)", programming can be enabled with normal Device
Reference
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:
• When using XYM marking, the script is converted to MR604.
• When not using XYM marking, the script is converted to MR100.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 2-77


PROGRAMMING SCRIPT

Input Auxiliary Function and Other Info

MEMO

2
Input Auxiliary Function and Other Info

2-78 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


3

DATA PROCESSING
DATA PROCESSING

Devices.................................................................................. 3-2
Index Modification and Indirect Specifying .......................... 3-54
Data Type (suffix) ................................................................ 3-62

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-1


Devices
DATA PROCESSING

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.
The device varies with the models (CPU units).

Device List (When using KV-8000)

3 ■ KV-8000 bit device


When start Index Indirect Specifying
Devices

Local
Number of operation Modificat (*)*8
Device name Range*1 Main functions device
points (Power ON, ion Refere
(@)*1 Store
PRG →RUN) (:Z/:#) nce
Device used for
capturing ON/OFF
Input Relay*10
info from
peripherals.
Device used for
R000 ~ R199915*2 Total 32000 Clear/hold*3*12 〇 〇 〇 ×
Output relay*10 sending ON/OFF
info to peripherals
Internal
Used in CPU and
auxiliary
expansion unit
relay*10
Link relay B00 ~ B7FFF*10 32768 points Clear/hold*3 × 〇 〇 ×
Internal Devices that can be
MR000 to MR399915 64000 points Clear 〇 〇 〇 ×
auxiliary relay only used in CPU
Latch relay LR000 to LR99915 16000 points Hold 〇 〇 〇 ×
10ms, 1ms, 10ms,
100ms down
Timer (contact) T0 to T3999 4000 points counter, 10ms Clear 〇 〇 〇 ×
contact device of
up/down counter
Contact device for
Counter
C0 to C3999 4000 points up counter, up/ Clear/hold*7 〇 〇 〇 ×
(contact)
down counter
Devices used for
controlling PLC
Control relay CR000 to CR7915 1280 points function or capturing Hold × × × ×
the status from
peripherals.

3-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ KV-8000 series word device
When start Index Indirect Specifying
Local
Number of operation Modificat (*)*8
Device name Range*1 Main functions device
points (power supply ion Refer
(@)*1 Store
PRG →RUN) (:Z/:#) ence
Data 65535
DM0 to DM65534 Clear/hold*3 〇 〇 〇 〇
memory points
Expansion
data memory
EM0 to EM65534
65535
points Device for Clear/hold*3 〇 〇 〇 〇
3
storing

Devices
Dial mode 524288
numerical data ×
ZF0 to ZF524287 points
File register (16-bit) Clear/hold*3 〇 〇 〇
Current group (32768×16
〇 *11
FM0 to FM32767 bank)
Link register W0 ~ W7FFF*10 32768 points Clear/hold*3 × 〇 〇 〇
Device for storing
Temporary
TM0 to TM511 512 points numerical data (16- Clear 〇 〇 〇 〇
memory
bit)
10ms, 1ms,
current
10ms, 100ms
value:
Timer down counter,
4000 Clear*5
(current/ T0 to T3999 10ms current/ 〇 〇 〇 ×
points current
setting value) setting value of
value:
up/down
Hold
counter (32-bit)
Current/setting
Counter value of up
4000
(current/ C0 to C3999 counter and up/ Clear/hold*7 〇 〇 〇 ×
points
setting value) down counter
(32-bit)
Devices that can be
Index register Z1 ~ Z23*6 23 points used in index Clear × × × ×
modify (32-bit)
Devices used
for controlling
PLC function or
7600
Control memory CM0 to CM7599 capturing the Hold × × × ×
points
status from
peripherals (16-
bit).
*1 Since they are used for local device, their reserved number is limited by the usable range of global
devices. "Local device list", page 3-9
*2 R000 to R199915 can be specified as extended I/O relay with Unit Monitor.
*3 Clear/Hold settings can be made in the "Power Failure Holding" option.
*4 "KV-8000 Series User's Manual "CR/CM table""
*5 Up/down timers (UDT) hold the current value.
*6 Z11 and Z23 are reserved for the system, so you cannot use these devices.
*7 Hold/Clear setups can be made in the "Power Failure Holding" option. (only for contact, current value)
*8 "Store" is a device that can be described as "*(device)". "Lookup" is the device that can perform
indirect specifying.
"KV-8000 Series User's Manual" "Indirect specifying"
*9 Specify all device No. in HEX.
*10 "DR" represents direct processing.
"KV-8000 Series User's Manual "About direct processing"
*11 The local device cannot be used for bank switching.
*12 For the input relay, clear/hold cannot be set.
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-3
Devices
DATA PROCESSING

■ Macro operand device


The macro operand devices used only in macros are shown as follows.
Indirect Local Index
Sym
Attribute Range Description Specifying device modification
bols
(*) (@) (:)
Device P P0 to P9 Devices are used as argument. × × 〇
Device values or constants are used
3 Value

Leadi
V V0 to V9
as argument for processing.
Leading device (R) assigned to the
× × ×

UR UR0 to UR9 × × 〇
ng R expansion unit is processed as an argument.
Devices

Leadi Leading data memory (DM) assigned


UM0 to
Unit ng UM to the expansion unit is processed as × × 〇
UM9
DM an argument.
Unit number of the expansion unit is
No. UV UV0 to UV9 × × ×
processed as an argument.
■ Function block argument
The arguments used in the function block only are as shown below.

Indirect Local Index


Argument Argument name /
Description Specifying device modification
type device
(*) (@) (:)
Device values or constants are
IN Any label × × ×
used as argument for processing.
Written to the device that specified
OUT Any label × × ×
the operation results.
IN-OUT Any label Devices are used as argument. × × 〇
Leading Leading relay (R) assigned to the
UR UR0 to UR7 × × 〇
R unit is processed as an argument.
Unit Leading Leading data memory (DM) assigned to
UM UM0 to UM7 × × 〇
DM the unit is processed as an argument.
No. UV UV0 to UV7 Unit number is processed as an argument. × × ×

■ Const
Const Range Main functions
#0 to #65535 (unsigned 16-bit)
-32768 to +32767 (signed 16-bit) Used for specifying DEC constant.
DEC(#)
#0 to #4294967295 (unsigned 32-bit) *XYM Marking is represented by "K".
-2147483648 to +2147483647 (signed 32-bit)

Single precision -3.4E+38≦N≦-1.4E-45


N=0 Used for specifying single precision
floating point type
+1.4E-45≦N≦+3.4E+38 floating point type real number.
real number
(Significant digit : 7 digit)

Double precision -1.79E+308 ≦ N ≦ -2.23E-308


N=0
floating point type Used for specifying double precision
real number +2.23E-308 ≦ N ≦ +1.79E+308
(Significant digit : 16 digit)
floating point type HEX($) $0000 to $FFFF (16-bit) Used for specifying HEX constant.
real number. $00000000 to $FFFFFFFF (32-bit) * XYM Marking is represented by "H".
Fixed text string(" ") Example "Type ABC", "MON/08:30:15" Used to fixed text string

■ Internal register
Number of When start operation
Device name Range Main functions
points (Power ON, PROG -> RUN)
Device for temporary data storage
Internal register - 1 points Clear
(16-bit/32-bit/64-bit)

3-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Local device list

The number of local devices/global devices and their settings when a project is created are shown as
follows. Number of reserved devices can be changed through “CPU system setting” →“Assignment of
all local devices setting”on the “Workspace”.
Local device Global device
Device name*1 Reserved devices in the whole
number project*2
Counts/range
Total
3
32000 points (2000 CH) 32000 points

Devices
Relay(R) *3 None
R000 to R199915 (2000 CH)
32000 points (2000 CH) 64000 points
Internal auxiliary relay (MR)*3 32000 points (2000 CH)
MR000 to MR199915 (4000 CH)
8000 points (500 CH) 16000 points
Latch relay (LR)*3 8000 points (500 CH)
LR000 to LR49915 (1000 CH)
2500 points
Timer (T)*4 1500 points 4000 points
T0 to T2499
2500 points
Counter (C)*4 1500 points 4000 points
C0 to C2499
40535 points 65535
Data memory (DM) 25000 points
DM0 to DM40534 points
20535 points 65535
Expansion data memory (EM) 45000 points
EM0 to EM20534 points
512 points
Temporary data memory (TM) None 512 points
TM000 to TM511
*1 Link relays (B), link registers (W), file registers (ZF), control relays (CR), control memories (CM),
and index registers (Z) cannot be used as a local device.
When using @FMxxx, local devices in workspace will be occupied.
*2 When a project is created, the device area used for global devices can be guaranteed as a whole
(suppose 10 modules are used and 50 counts of macro calling.)
The number of reserved devices can be changed as required.
*3 Number can be set in“ch”unit.
*4 "@+ (device code)" can be used only when the device code is specified as an operand for timer/
counter instructions. (Example for inputting mnemonic : TMR @0 #100).

• If relays (R) and temporary data memories (TM) are used as a local device, the
Point number of relays and data memories must be specified.
• The following devices must be used as a global device:
- Devices assigned to expansion units
- The devices referenced by such peripherals as touch panel
- Common devices in the whole project
- Devices for inter-module data transmission
• Where possible, local devices should be coded from 0 and use consecutive numbers.
• Since R and DM are assigned to the expansion unit, as a global device, there must
be an area to be used. When using local devices, please use MR or EM first.
• If local devices or global devices are used outside the specified range, then a
conversion error will occur.
• For the KV-8000 Series, when an index device or indirect specification is used to
specify outside of the usable range of local devices or global devices, an
operation error will occur.
• When various instructions using the leading device as the operands and index
modification or indirect specifying are used, the range of the local devices and
global devices that can be used should not be exceeded.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-5


Devices
DATA PROCESSING

Device list (When using KV-7000)

■ Bit Device
When start Index Indirect
Local
*1 Number of operation Modific Specifying(*)*8
Device name Range Main functions device
3 points (Power ON,
PRG →RUN)
(@)*1
ation Refere
(:Z/:#) nce
Store

Device used for


Devices

capturing ON/OFF
Input Relay*10
info from
peripherals.
Device used for
R000 ~ R199915*2*13 Total 32000 Clear/hold*3*12 〇 〇 〇 ×
Output relay*10 sending ON/OFF
info to peripherals
Internal
Used in CPU and
auxiliary
expansion unit
relay*10
Link relay B00 ~ B7FFF*10 32768 points Clear/hold*3 × 〇 〇 ×
Internal Devices that can be
MR000 to MR399915 64000 points Clear 〇 〇 〇 ×
auxiliary relay only used in CPU
Latch relay LR000 to LR99915 16000 points Hold 〇 〇 〇 ×
10μs, 1ms, 10ms,
100ms down
Timer (contact) T0 to T3999 4000 points counter, 10ms Clear 〇 〇 〇 ×
contact device of
up/down counter
Contact device for
Counter
C0 to C3999 4000 points up counter, up/ Clear/hold*7 〇 〇 〇 ×
(contact)
down counter
Devices used for
controlling PLC
Control relay CR000 to CR7915 1280 points function or capturing Hold × × × ×
the status from
peripherals.

3-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ KV-7000 series word device
When start Indirect
Index
operation Local Specifying(*)*8
Device Number of Main Modific
Range*1 (power device
name points functions ation Refer
supply (@)*1 Store
(:Z/:#) ence
PRG →RUN)
Data 65535
memory
Expansion
DM0 to DM65534
points
65535
Clear/hold*3 〇 〇 〇 〇
3
EM0 to EM65534 Device for Clear/hold*3 〇 〇 〇 〇

Devices
data memory points
storing
Dial mode 524288
numerical data ×
ZF0 to ZF524287 points
File register (16-bit) Clear/hold*3 〇 〇 〇
Current group (32768×16
〇 *11
FM0 to FM32767 bank)
Link register W0 ~ W7FFF*10 32768 points Clear/hold*3 × 〇 〇 〇
Temporary Device for storing
TM0 to TM511 512 points Clear 〇 〇 〇 〇
memory numerical data (16-bit)
10ms, 1ms, 10ms,
current value:
Timer 100ms down counter,
4000 Clear*5
(current/ T0 to T3999 10ms current/setting 〇 〇 〇 ×
points current value:
setting value) value of up/down
Hold
counter (32-bit)
Counter Current/setting value
4000
(current/ C0 to C3999 of up counter and up/ Clear/hold*7 〇 〇 〇 ×
points
setting value) down counter (32-bit)
Devices that can be
Index register Z1 ~ Z12*6 12 points used in index Clear × × × ×
modify (32-bit)
Devices used for
controlling PLC
6000
Control memory CM0 to CM5999 function or capturing Hold × × × ×
points
the status from
peripherals (16-bit).
*1 Since they are used for local device, their reserved number is limited by the usable range of global
devices. "Local device list", page 3-9
*2 R000 to R199915 can be specified as extended I/O relay with Unit Monitor.
*3 Clear/Hold settings can be made in the "Power Failure Holding" option.
*4 "KV-8000 Series User's Manual "CR/CM table""
*5 Up/down timers (UDT) hold the current value.
*6 Z11 and Z12 are reserved for the system, so you cannot use these devices.
*7 Hold/Clear setups can be made in the "Power Failure Holding" option. (only for contact, current value)
*8 "Store" is a device that can be described as "*(device)". "Lookup" is the device that can perform
indirect specifying.
"KV-7000 Series User's Manual "Indirect specifying"
*9 Specify all device No. in HEX.
*10 "DR" represents direct processing.
"KV-7000 Series User's Manual "About direct processing"
*11 The local device cannot be used for bank switching.
*12 For the input relay, clear/hold cannot be set.
*13 For CPU function versions older than 2.2, the number of points for R is 16000 and the range is
R00000 to R99915.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-7


Devices
DATA PROCESSING

■ Macro operand device


The macro operand devices used only in macros are shown as follows.
Indirect Local Index
Sym
Attribute Range Description Specifyi device modification
bols
ng(*) (@) ( :)
Device P P0 to P9 Devices are used as argument. × × 〇
Device values or constants are used
3 Value

Leadi
V V0 to V9
as argument for processing.
Leading device (R) assigned to the
× × ×

UR UR0 to UR9 × × 〇
ng R expansion unit is processed as an argument.
Devices

Leading UM0 to Leading data memory (DM) assigned to the


Unit UM × × 〇
DM UM9 expansion unit is processed as an argument.
Unit number of the expansion unit is
No. UV UV0 to UV9 × × ×
processed as an argument .
■ Function block argument
The arguments used in the function block only are as shown below.

Indirect Local Index


Argument Argument name /
Description Specifyi device modification
type device
ng(*) (@) (:)
Device values or constants are
IN Any label × × ×
used as argument for processing.
Written to the device that specified
OUT Any label × × ×
the operation results.
IN-OUT Any label Devices are used as argument. × × 〇
Leadin Leading relay (R) assigned to the
UR UR0 to UR7 × × 〇
gR unit is processed as an argument.
Leading Leading data memory (DM) assigned to
Unit UM UM0 to UM7 × × 〇
DM the unit is processed as an argument.
Unit number is processed as an
No. UV UV0 to UV7 × × ×
argument.

■ Const
Const Range Main functions
#0 to #65535 (unsigned 16-bit)
-32768 to +32767 (signed 16-bit) Used for specifying DEC constant.
DEC(#)
#0 to #4294967295 (unsigned 32-bit) *XYM Marking is represented by "K".
-2147483648 to +2147483647 (signed 32-bit)

Single precision -3.4E+38≦N≦-1.4E-45


N=0 Used for specifying single precision
floating point type
+1.4E-45≦N≦+3.4E+38 floating point type real number.
real number
(Significant digit : 7 digit)

Double precision -1.79E+308 ≦ N ≦ -2.23E-308


N=0
floating point type Used for specifying double precision
real number +2.23E-308 ≦ N ≦ +1.79E+308
(Significant digit : 16 digit)
Used for specifying HEX constant.
floating point type HEX($) $0000 to $FFFF (16-bit)
* XYM Marking is represented by
real number. $00000000 to $FFFFFFFF (32-bit)
“H”.
Fixed text string
Example “Type ABC”、
“MON/08:30:15” Used to fixed text string
(“”)

■ Internal register
Number of When start operation
Device name Range Main functions
points (Power ON, PROG -> RUN)
Device for temporary data storage
Internal register - 1 points Clear
(16-bit/32-bit/64-bit)
3-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Devices

DATA PROCESSING
Local device list

The number of local devices/global devices and their settings when a project is created are shown as
follows. Number of reserved devices can be changed through “CPU system setting” →“Assignment of
all local devices setting”on the “Workspace”.
Local device Global device
Device name*1 Reserved devices in the whole
*2
Counts/range
Total 3
number project

Devices
32000 points (2000 CH) 32000 points
Relay(R) *3 None
R000 to R199915 (2000 CH)
32000 points (2000 CH) 64000 points
Internal auxiliary relay (MR)*3 32000 points (2000 CH)
MR000 to MR199915 (4000 CH)
8000 points (500 CH) 16000 points
Latch relay (LR)*3 8000 points (500 CH)
LR000 to LR49915 (1000 CH)
2500 points
Timer (T)*4 1500 points 4000 points
T0 to T2499
2500 points
Counter (C)*4 1500 points 4000 points
C0 to C2499
40535 points 65535
Data memory (DM) 25000 points
DM0 to DM40534 points
20535 points 65535
Expansion data memory (EM) 45000 points
EM0 to EM20534 points
512 points
Temporary data memory (TM) None 512 points
TM000 to TM511
*1 Link relays (B), link registers (W), file registers (ZF), control relays (CR), control memories (CM),
and index registers (Z) cannot be used as a local device.
When using @FMxxx, local devices in workspace will be occupied.
*2 When a project is created, the device area used for global devices can be guaranteed as a whole
(suppose 10 modules are used and 50 counts of macro calling.)
The number of reserved devices can be changed as required.
*3 Number can be set in“ch”unit.
*4 "@+ (device code)" can be used only when the device code is specified as an operand for timer/
counter instructions. (Example for inputting mnemonic : TMR @0 #100).

• If relays (R) and temporary data memories (TM) are used as a local device, the
Point number of relays and data memories must be specified.
• The following devices must be used as a global device:
- Devices assigned to expansion units
- The devices referenced by such peripherals as touch panel
- Common devices in the whole project
- Devices for inter-module data transmission
• Where possible, local devices should be coded from 0 and use consecutive numbers.
• Since R and DM are assigned to the expansion unit, as a global device, there must
be an area to be used. When using local devices, please use MR or EM first.
• If local devices or global devices are used outside the specified range, then a conversion
error will occur.
• For the KV-7000 Series, when an index device or indirect specification is used to specify
outside of the usable range of local devices or global devices, an operation error will occur.
• When various instructions using the leading device as the operands and index
modification or indirect specifying are used, the range of the local devices and global
devices that can be used should not be exceeded.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-9


Devices
DATA PROCESSING

Device table (for KV-5500 / 5000/3000/1000)

■ KV-5500/5000/3000 bit device


When start Index Indirect
operation Local Modific designation
Number of
3 Device name Range*1
points
Main functions (Power ON,
PROG →
device
*1
ation
(@) (:Z/: Refere
(*)*9

Store
RUN) #) nce
Devices

Device used
for capturing
R000 to R015
Input Relay ON/OFF info — 〇 〇 〇 ×
(R1000~R99915*3)
from
Input/ peripherals.
output/
Device used
Internal
for sending
R500 to R507 auxiliary
Output relay ON/OFF info Clear/hold*4 〇 〇 〇 ×
(R1000~R99915*3) relay total
from
15936
peripherals.
points
Used in CPU
Internal
R508~R915*2 and
auxiliary Clear/hold*4 〇 〇 〇 ×
R1000~R99915*3 expansion
relay
unit
16384
Link relay B00~B3FFF*10 Clear/hold*4 × 〇 〇 ×
points Devices that
Internal 16000 can be
MR000 to MR99915 Clear 〇 〇 〇 ×
auxiliary relay points only used in
16000 CPU
Latch relay LR000 to LR99915 Hold 〇 〇 〇 ×
points
10ms, 1ms,
10ms, 100ms
Timer 4000 down counter,
T0 to T3999 Clear 〇 〇 〇 ×
(contact) points 10ms contact
device of up/
down counter
Contact
device for up Clear /
Counter 4000
C0 to C3999 counter, up/ 〇 〇 〇 ×
(contact) points
down hold*8
counter
High-speed Used for
counter contact of Clear /
CTC0 to CTC3 4 points × × × ×
comparator high-speed hold*8
(contact) counter
Devices used
for controlling
PLC function
Control relay CR000 to CR3915 640 points or capturing Hold × × × ×
the status
from
peripherals.

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

3-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ KV-5500/5000/3000 word device
When start Index Indirect
Local *
Number of operation Modifica designation(*) 9
Device name Range*1 Main functions device
points (Power ON、 tion Refere
(@)*1 Store
PROG→RUN) (:Z/:#) nce
Data 65535
DM0 to DM65534 Clear/hold*4 〇 〇 〇 〇
memory points
Expansion
data memory
EM0 to EM65534
65535
points Devices that Clear/hold*4 〇 〇 〇 〇
3
can store
Dial mode 131072

Devices
numerical data × 〇 〇 〇
ZF0 to ZF131071 points
File register (16 bit) Hold
Memory: (32768x4B
FM0 to FM32767 ank) point 〇 *12 〇 〇 〇
Link register W0~W3FFF*10 16384 points Clear/hold*4 × 〇 〇 〇
Used for storing
Temporary numerical data,
TM0 to TM511 512 points Clear 〇 〇 〇 〇
memory simple indirect
specifying (16 bit)
10ms, 1ms, 10ms, Current value:
Timer 100ms down
(current/ 4000 counter, 10ms Clear*6
T0 to T3999 〇 〇 〇 ×
setting points current/setting Setting value:
value) value of up/down
counter (32-bit) Hold
Counter Up / down
(current/ 4000 counter current Clear /
C0 to C3999 〇 〇 〇 ×
setting points value / setting hold*8
value) (32-bit)
High-speed High-speed Clear /
counter CTH0 to CTH1 2 points counter current × × × ×
(current value) value (32 bit) hold*8
High-speed High-speed
counter
CTC0 to CTC3 4 points counter set Clear/hold*4 × × × ×
comparator
(setting value) value (32 bit)
Devices that can
Index
Z1~Z12*7 12 points be used in index Clear × × × ×
register
modify (32-bit)*11
Devices used for
controlling PLC
Control 6000 function or
CM0 to CM5999 Hold × × × ×
memory points capturing the status
from peripherals
(16-bit).
*1 Because this is used as a local device, the applicable range of global devices is limited by the number of
reserved local devices.
"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 cant be used.
*3 R1000 to R99915 can be set to expansion I/O relays via Unit Editor.
*4 Power OFF hold function in CPU system setting enables set clear/hold.
*5 "Control Memory Entries CM (For KV-8000)", page A-5
*6 Up/down timer (UDT) keeps current value.
*7 Z11 and Z12 are reserved for the system, so you cannot use these devices.
*8 Power OFF hold function 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.
"What is indirect specifying", page 3-57
*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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-11
Devices
DATA PROCESSING

■ KV-1000 bit device


Index Indirect
When start
Local Modifi designation(*)*10
Number of operation
Device name Range*1 Main functions softwar cation
points (Power Refere
e(@)*1 (:Z/: Gner
ONPROG-> RUN) nce
#)
Device for
3 R000 to R015
obtaining ON /
OFF
Input Relay*3 (R1000~R5991 - ○ ○ ○ ×
information
Devices

5*3) Input
from peripheral
Output,
devices
Internal
Device used for
R500 to R507 auxiliary
Output sending ON/
*3 (R1000~R5991 9536 relay Clear*4 ○ ○ ○ ×
relay OFF info to
5*3) points
peripherals
Used in CPU
R508~R915*2
Internal and expansion Clear*4 ○ ○ ○ ×
(R1000~R59915*3)
auxiliary unit
relay MR000~ 16000
Clear ○ ○ ○ ×
MR99915*4 points
Devices that
Internal
can be only
auxiliary LR000~ 16000
used in CPU Hold ○ ○ ○ ×
relay (Latch LR99915 points
relay)
10ms, 1ms,
Timer 10ms, 100ms
Timer Total down counter,
T0 to T3999 Clear ○ ○ ○ ×
(contact) counter 10ms contact
4000 points device of up/
down counter
Contact device
Counter for up counter,
C0 to C3999 256 points Maintain*9 ○ ○ ○ ×
(contact) up/down
counter
High-speed
Used for
counter
CTC0 to CTC3 4 points contact of high- Maintain*9 × × × ×
Comparator
speed counter
(contact)
CR000 to CR3915 Devices used
to control PLC
Control relay 640 points functions and - × × × ×
obtain device
status

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

3-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ KV-1000 series of word devices
Index Indirect
When start operation Local
Number Modifi Specifying(*)*10
Device name Range*1 Main functions (power supply ONPROG softwar
of points cation Refere
->RUN) e(@)*1 Gner
(:Z/:#) nce
Data DM0 to 65535
Maintain*4 ○ ○ ○ ○
memory DM65534 points
3
Device for
EM0~ 65535 storing
Maintain*4 ○ ○ ○ ○
EM65534*5 points numerical data
Link register
(16-bit)

Devices
FM0~ 32767
Maintain*4 ○ ○ ○ ○
FM32776*5 points
Device for
Temporary 512 storing
TM0 to TM511 Clear ○ ○ ○ ○
memory points numerical data
(16-bit)
10ms, 1ms,
10ms, 100ms
Timer Current value:
down counter,
(current/
T0 to T3999 Timer 10ms current/ Clear*7 ○ ○ ○ ×
setting
Total setting value of Setting value: Hold
value)
counter up/down
4000 counter (32-bit)
Counter points Up counter,
(current/ up/down
C0 to C3999 Maintain*9 ○ ○ ○ ×
setting counter (32
value) bit)
High-speed High-speed
counter *6 counter
CTH0 to CTH1 2 point Maintain*9 × × × ×
(current current value
value) (32 bit)
High-speed
counter High-speed
Comparator CTC0 to CTC3 4 point*6 counter set Hold × × × ×
(setting value (32 bit)
value)
Devices that
Index *8 12 can be used in
Z1~Z12 Clear × × × ×
register points index modify
(32-bit)
Device for
controlling
Control CM0~ 11999 PLC functions
- × × × ×
memory CM11998 points and obtaining
device status
(16 bits)
*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 " CR/CM List", page A-2
*7 Up/down timer (UDT) to keep current value.
*8 Z11 and Z12 are reserved for the system, so you cannot use these devices.
*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.
"What is indirect specifying", page 3-57

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-13


Devices
DATA PROCESSING

■ Macro argument device


The macro argument devices used only within the macro are as follows.

Indirect Local Index


Attribute Symbol Range Description Specifying device modification
(*) (@) ( :)
Devices are used as
Device P P0 to P9 × × ○
3 argument.
Devices are used as
argument. Device values
Value V V0 to V9 × × ×
Devices

or constants are used as


argument for processing.
Leading device assigned
Start
UR UR0 to UR9 to extended unit × × ○
R
processed as argument.
The leading device
Start assigned to extended unit
Unit DM UM UM0 to UM9 × × ○
is processed as an
argument.
Treat the unit number of
No. UV UV0 to UV9 the expansion unit as an × × ×
argument.

■ Const
Const Range Main functions
(#) 0 to (#) 65535 (unsigned 16-bit) Used to specify DEC constant. ("#"
(#) -32768 to +32767 (signed 16-bit) can be omitted.)
(#) 0 to (#) 4294967295 (unsigned 32-bit)
10 DEC(#)
Reference
When set to XYM
(#) -2147483648 to +2147483647 (signed 32-
bit) display mode, the
display will be "K".
(K can be omitted.)
(#) -3.4E+38 ≦ N ≦ (#) -1.4E-45
Single precision Used to specify single precision
N = (#) 0
floating point real floating point type constant.
numbers (#) +1.4E-45 ≦ N ≦ (#) +3.4E+38 ("#" can be omitted.)
(Significant digit : 7 digit)
(#) -1.79E+308 ≦ N ≦ (#) -2.23E-308
Double precision Used to specify double precision
N = (#) 0
floating point real floating point type constant.
numbers (#) +2.23E-308 ≦ N ≦ (#) +1.79E+308 ("#" can be omitted.)
(Significant digit : 16 digit)
Used to specify HEX constants.
floating point type real $0 to $FFFF (16-bit) Reference
When set to XYM
number ($). $0 to $FFFFFFFF (32-bit)
display mode, the
display is "H".
Fixed text string ("") Example "Type ABC", "MON/08:30:15" Used to fixed text string

■ Internal register
The status of the bit device is described in the following representation method.
When the operation
Number of
Device name Range Main functions starts (power ON,
points
PROG → RUN)
Device for temporary data
Internal register - 1 points Empty
storage (16-bit/32-bit/64-bit)

3-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Local device list (When KV-5500 / 5000/3000)

The number of local devices/global devices and their settings when a project is created are shown as
follows. Number of reserved devices can be changed through “CPU system setting” →“Assignment of
all local devices setting”on the “Workspace”.
Local device Global device
Device name*1 Reserved devices in the whole
number project*2
Counts/range
Total
3
16000 points (1000 CH) 16000 points

Devices
Relay(R) *3 None
R000 to R99915 (1000 CH)
8000 points (500 CH) 16000 points
Internal auxiliary relay (MR)*3 8000 points (500 CH)
MR000 to MR49915 (1000 CH)
8000 points (500 CH) 16000 points
Latch relay (LR)*3 8000 points (500 CH)
LR000 to LR49915 (1000 CH)
2500 points
Timer (T)*4 1500 points 4000 points
T0 to T2499
2500 points
Counter (C)*4 1500 points 4000 points
C0 to C2499
40535 points 65535
Data memory (DM) 25000 points
DM0 to DM40534 points
20535 points 65535
Expansion data memory (EM) 45000 points
EM0 to EM20534 points
512 points
Temporary data memory (TM) None 512 points
TM000 to TM511
*1 Link relay (B), link register (W), file register (ZF), high-speed counter (CTH), high-speed counter
comparator (CTC), control relay (CR), control storage (CM), index register (Z ) Cannot be used as
a local device.
When using @FMxxx, local devices in workspace will be occupied.
*2 When a project is created, the device area used for global devices can be guaranteed as a whole
(suppose 10 modules are used and 50 counts of macro calling.)
The number of reserved devices can be changed as required.
*3 Number can be set in "ch" unit.
*4 "@+ (device code)" can be used only when the device code is specified as an operand for timer/
counter instructions.
(Example for inputting mnemonic : TMR @0 #100).

• If relays (R) and temporary data memories (TM) are used as a local device, the
Point
number of relays and data memories must be specified.
• The following devices must be used as a global device:
- KV-5500/5000/3000 I/O unit
- The devices referenced by such peripherals as touch panel
- Common devices in the whole project
- Devices for inter-module data transmission
• Where possible, local devices should be coded from 0 and use consecutive numbers.
• Since R and DM are assigned to the expansion unit, as a global device, there must
be an area to be used. When using local devices, please use MR or EM first.
• If local devices or global devices are used outside the specified range, then a
conversion error will occur.
• When various instructions using the leading device as the operands and index
modification or indirect specifying are used, the range of the local devices and
global devices that can be used should not be exceeded.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-15


Devices
DATA PROCESSING

Local device list (At KV-1000)

The number of local devices/global devices and their settings when a project is created are shown as
follows. Number of reserved devices can be changed through “CPU system setting” →“Assignment of
all local devices setting”on the “Workspace”.
Local device Global device
name*1
3 Device Reserved devices in the whole
number project*2
Counts/range
Total

9600 points (600 CH) 9600 points


Devices

Relay(R) *3 None
R00000 to R59915 (600 CH)
7200 points (450 CH) 16000 points
Internal auxiliary relay (MR)*3 8000 points (500 CH)
MR000 to MR44915 (1000 CH)
8000 points (500 CH) 16000 points
Latch relay (LR)*3 8000 points (500 CH)
LR000 to LR49915 (1000 CH)
Timer (T)*5 1500 points Timer / counter total 1000
Timer /
points
counter total
Counter (C)*5 1500 points T0000 to T0999
4000 points
C0000 to C0999
40535 points
Data memory (DM) 25000 points 65535 points
DM0 to DM40534
19535 points 65535
Expansion data memory (EM) 45000 points
EM0 to EM19534 points*4
11767 points 32767
Expansion data memory (FM) 20000 points
FM00000 to FM11766 points*4
512 points
Temporary data memory (TM) None 512 points
TM000 to TM511
High-speed counters (CTH), high-speed counter comparator (CTC), control relays (CR), control
memories (CM), and index registers (Z) cannot be used as a device.
*2 When a project is created, the device area used for global devices can be guaranteed as a whole
(suppose 10 modules are used and 50 counts of macro calling.)
The number of reserved devices can be changed as required.
*3 Number can be set in“ch”unit.
*4 This number includes the workspace used for script devices.
*5 "@+ (device code)" can be used only when the device code is specified as an operand for timer/
counter instructions.
(Example for inputting mnemonic : TMR @0 #100).

• If relays (R) and temporary data memories (TM) are used as a local device, the
Point
number of relays and data memories must be specified.
• The following devices must be used as a global device:
- KV-1000 I/O unit
- The devices referenced by such peripherals as touch panel
- Common devices in the whole project
- Devices for inter-module data transmission
• Where possible, local devices should be coded from 0 and use consecutive numbers.
• Since R and DM are assigned to the expansion unit, as a global device, there must
be an area to be used. When using local devices, please use MR or EM first.
• If local devices or global devices are used outside the specified range, then a
conversion error will occur.
• When various instructions using the leading device as the operands and index
modification or indirect specifying are used, the range of the local devices and
global devices that can be used should not be exceeded.

3-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Device table (for KV Nano)

■ KV Nano Series bit device


Index Indirect
When start operation Local *2
*1 Number of Modifi designation(*)
Device name Range Main functions softwar
points
Power ON
PROG -
>RUN
cation Refere
e(@)*1 (:Z/:#)
nce
Gner 3
Device for

Devices
obtaining ON /
Input R000~R203*4
OFF information ○ ○ ○ ×
Relay*3 (R1000~R59915*5) Input
Output, from peripheral
Internal devices
auxiliary Device used for Clear Clear
*6
Output R500~R607 relay total sending ON/
○ ○ ○ ×
relay*3 (R1000~R59915*5) 9600 OFF info to
points peripherals
Internal Used in CPU and
R1000~R59915*3 ○ ○ ○ ×
auxiliary relay expansion unit
*8
Link relay B00~B1FFF 8192 points Clear Clear × ○ ○ ×
Devices that
Internal MR000 to 9600
can be only Clear Clear ○ ○ ○ ×
auxiliary relay MR59915 points
used in CPU
Latch relay LR000 to LR19915 3200 points Hold Hold ○ ○ ○ ×
10ms, 1ms, Of T0 to T9, Of T0 to T9,
10ms, 100ms only devices only devices
Timer down counter, used by the used by the
T0 to T511 512 points ○ ○ ○ ×
(contact) 10ms contact UDT UDT
device of up/ instruction are instruction are
down counter held held
Contact device
Counter
C0 to C255 256 points for up counter, Clear/hold*7 Hold ○ ○ ○ ×
(contact)
up/down counter
High-speed
Used for contact
counter
CTC0~CTC7*9 8 points*9 of high-speed Hold Hold × × × ×
Comparator
counter
(contact)
Devices used to
1440 control PLC
Control relay CR000 to CR8915 Hold Clear × × × ×
points functions and obtain
device status
*1 Because this is used as a local device, the applicable range of global devices is limited by the number of
reserved local devices. "KV Nano Series User's Manual, "List of Local Devices""
*2 "Store" is the device that may be described as "*(device) ". "Lookup" is the device that can perform indirect specifying.
KV Nano Series User's Manual, "Indirect Specifying"
*3 For direct processing, described with "DR".
*4 The range of devices that can be used varies according to the unit.
KV-N14 □□:R000 ~ R007、KV-N24 □□:R000 ~ R013
KV-N40 □□:R000 ~ R107、KV-N60 □□:R000 ~ R203
KV-NC32T: R000 to R015
*5 R1000 to R59915 can be set to expansion I/O relays via Unit Editor.
Relays not assigned to input and output relays less than R1000 are reserved for the system and cannot be used.
*6 The range of devices that can be used varies according to the unit.
KV-N14 □□:R500 ~ R505、KV-N24 □□:R500 ~ R509
KV-N40 □□:R500 ~ R515、KV-N60 □□:R500 ~ R607
KV-NC32T: R500 to R515
*7 The clear / hold setting can be set by the "power failure hold setting" set by the CPU system. (only for
contact, current value)
*8 Device No. is specified in HEX number.
*9 The range of devices that can be used varies according to the unit.
KV-N14 □□:CTC0 ~ CTC3 (4 point)、KV-N24 □□:CTC0 ~ CTC3 (4 point)
KV-N40 □□:CTC0 ~ CTC5 (6 point)、KV-N60 □□:CTC0 ~ CTC7 (8 point)
KV-NC32T:CTC0 ~ CTC5 (6 point)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-17


Devices
DATA PROCESSING

■ KV Nano series of word devices


Index Indirect
When start operation Local *9
Number Modifi Specifying(*)
Device name Range*1 Main functions softwar
of points PROG - cation
Power ON e(@)*1 (:Z/:#) Refere Gner
>RUN nce
Data DM0 to 32768 Device for Clear/
Clear/hold*3 ○ ○ ○ ○
memory DM32767 points storing hold*3
3 Link register W0~W3FFF*5
16384
points
numerical data
(16-bit) Clear/hold*3 Hold × ○ ○ ○
Devices

Device for storing


Temporary 512
TM0 to TM511 numerical data Clear Clear ○ ○ ○ ○
memory points
(16-bit)
10ms, 1ms, Of T0 to
10ms, 100ms Of T0 to T9, T9, only
Timer down counter, only devices devices
(current/ 512 10ms current/ used by the used by
T0 to T511 ○ ○ ○ ×
setting points setting value UDT the UDT
value) of up/down instruction instructi
counter (32- are held on are
bit) held
Counter Up counter, up/ Clear/
256
(current/ C0 to C255 down counter Clear/hold*4 ○ ○ ○ ×
setting value)
points
(32 bit) hold*4
High-speed High-speed
4
counter CTH0~CTH3*6 counter current Hold Hold × × × ×
points*6
(current value) value (32 bit)
High-speed
High-speed
counter 8
CTC0~CTC7*6 *6 counter set Hold Hold × × × ×
Comparator points
value (32 bit)
(setting value)
Devices that
Index 12 can be used in
Z1~Z12*7 Clear Hold × × × ×
register points index modify
(32-bit)
Device for
controlling
Control CM0 to 9000 PLC functions Mainta
Maintain*8 × ○ ○ ×
memory CM8999 points and obtaining in*8
device status
(16 bits)
*1 Because this is used as a local device, the applicable range of global devices is limited by the number of
reserved local devices.
"KV Nano Series User's Manual", "List of Local Devices"
*2 "Store" is the device that may be described as "*(device) ". "Lookup" is the device that can perform indirect specifying.
*3 "KV Nano Series User's Manual", "Indirect Specification"
*4 Power OFF hold function in CPU system setting enables set clear/hold. It can hold up to 3072 words
together with other devices that can set the power-down holding function.
*5 The hold / clear setting can be set in the "power-off hold setting" set in the CPU system. (only for contact, current value)
*6 Specify the device number by hexadecimal number.
*7 The range of devices that can be used varies according to the unit.
KV-N14 □□:CTH0 ~ CTH1 (2 points) CTC0 ~ CTC3 (4 points)、KV-N24 □□:CTH0 ~ CTH1 (2 points)
CTC0 ~ CTC3 (4 points)
KV-N40 □□:CTH0 ~ CTH2 (3 points) CTC0 ~ CTC5 (6 points)、KV-N60 □□:CTH0 ~ CTH3 (4 points)
CTC0 ~ CTC7 (8 points)
KV-NC32T :CTH0 ~ CTH2 (3 points) 、CTC0 ~ CTC5 (6 points)
*8 Z11 and Z12 are reserved for the system, so you cannot use these devices.
*9 Only for devices that need to be held. For details on the target devices, see "KV Nano Series User's
Manual", "List of CR and CM Devices" .

3-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ Macro argument devices
The macro argument devices used only within the macro are as follows.

Indirect Local Index


Attribute Symbol Range Description Specifying device modification
(*) (@) ( :)
Devices are used as
Device P P0 to P9 × × ○
argument.
Devices are used as 3
argument. Device values
Value V V0 ~V9 × × ×

Devices
or constants are used as
argument for processing.
Leading device assigned
Start
UR UR0 to UR9 to extended unit × × ○
R
processed as argument.
The leading device
Start assigned to extended unit
Unit DM UM UM0 to UM9 × × ○
is processed as an
argument.
Treat the unit number of
No. UV UV0 to UV9 the expansion unit as an × × ×
argument.

■ Const

Const Range Main functions


#0 to #65535 (Unsigned 16-bit) Used to specify DEC constant.
- 32768 to +32767 (Signed 16-bit) * Displayed as "K" when using the
DEC (#) #0 to #4294967295 (Unsigned 32-bit) XYM display mode.
-2147483648 ~ +2147483647 (Signed
32-bit)
Used to specify single precision
- 3.4E+38 ≦ N ≦- 1.2E - 38 floating point type constant.
Single precision floating point N=0 A denormal (-1.2E-38 ≦ N ≦ -
real numbers +1.2E - 38 ≦ N ≦ +3.4E+38 1.4E-45、 +1.4E-45 ≦ N ≦
(Significant digit : 7 digit) +1.2E-38) cannot be specified.
If the result is denormal, 0 is returned.
-1.79E+ 308 ≦ N ≦- 2.23E -308 Used to specify double precision
Double precision floating point N=0 floating point type constant.
real numbers +2.23E- 308 ≦ N ≦ +1.79E+308
(Significant digit : 16 digit)

$0000 to $FFFF (16 bits) Used to specify HEX constants.


HEX ($) * Displayed as "H" when using the
$00000000 to $FFFFFFFF (32 bits) XYM display mode.
Fixed text string ("") Example "Type ABC", "MON/08:30:15" Used to fixed text string

■ Internal register
The status of the bit device is described in the following representation method.
When the operation
Number of
Device name Range Main functions starts (power ON,
points
PROG → RUN)
Device for temporary data
Internal register - 1 points Empty
storage (16-bit/32-bit/64-bit)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-19


Devices
DATA PROCESSING

Local device list

The number of local devices/global devices and their settings when a project is created are shown as
follows. Number of reserved devices can be changed through “CPU system setting” →“Assignment of
all local devices setting”on the “Workspace”.
Local device Global device

3 Device name*1 Reserved devices in the whole


number project*2
Counts/range
Total
Devices

9600 points (600 CH) 9600 points


Relay(R) *3 None
R000 to R59915 (600 CH)
8000 points (500 CH) 9600 points
Internal auxiliary relay (MR)*3 1600 points (100 CH)
MR000 to MR49915 (600 CH)
3560 points (180 CH) 3200 points
Latch relay (LR)*3 320 points (20 CH)
LR000 to LR17915 (200 CH)
412 points
Timer (T)*4 100 points 512 points
T0 to T411
206 points
Counter (C)*4 50 points 256 points
C0 to C205
27768 points
Data memory (DM) 5000 points 32768 points
DM0 to DM27767
512 points
Temporary data memory (TM) None 512 points
TM000 to TM511
*1 Link relays (B), link registers (W), high-speed counters (CTH), high-speed counter comparators
(CTC), control relays (CR), control memory entries (CM), and index registers (Z) cannot be used
as local devices.
*2 When a project is created, the device area used for global devices can be guaranteed as a whole
(suppose 10 modules are used and 50 counts of macro calling.)
The number of reserved devices can be changed as required.
*3 Number can be set in“ch”unit.
*4 "@+ (device code)" can be used only when the device code is specified as an operand for timer/
counter instructions.
(Example for inputting mnemonic : TMR @0 #100).

• If relays (R) and temporary data memories (TM) are used as a local device, the
Point
number of relays and data memories must be specified.
• The following devices must be used as a global device:
- KV Nano Series I/O relays
- The devices referenced by such peripherals as touch panel
- Common devices in the whole project
- Devices for inter-module data transmission
• Where possible, local devices should be coded from 0 and use consecutive numbers.
• Since R and DM are assigned to the expansion unit, as a global device, there must
be an area to be used. When using local devices, please use MR or EM first.
• If local devices or global devices are used outside the specified range, then a
conversion error will occur.
• When various instructions using the leading device as the operands and index
modification or indirect specifying are used, the range of the local devices and
global devices that can be used should not be exceeded.

3-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Device notation method

● Writing index modification (modification according to index registers and


according to index constants)

3
• Modify via index register
Continuously enter :Z□ (□: numerical value 1 to 10) after device (R (DR) / MR / LR / B / T / C / DM /
EM / FM / ZF / W / TM / *DM / *EM / *FM / *ZF / *W / *TM).

Devices
Example
DM0:Z1 If the value of Z1 is 100, this means DM100.
R1000:Z1 If the value of Z1 is 100, this means R1604.

Point • Device Name KEYENCE


• The modification by index register towards CM is only possible for KV Nano series.

• Modify via index constant


After the device (R (DR)/MR/LR/B/T/C/DM/EM/FM/ZF/W/TM/*DM/*EM/*FM/*ZF/*W/*TM) Then enter:
#□(□:- 524287 ~ +524287).

Example
DM0:#1 This means DM1.
R1000:#1 This means R1001.

Point • Device Name KEYENCE


• The modification by index register towards CM is only possible for KV Nano series.

• Indexing by operation expression


Enter the operation expression after the device (R (DR)/MR/LR/B/T/C/DM/W/TM/CM/*DM/* W/*TM).

Example
DM0: (DM100 + 20) If the value of DM100 is 50, it means DM70
R1000: (DM0 * 4) If the value of DM0 is 2, it means R1008

Point • Indexing restriction by operation expression can only be used in KV script.


• The EM, FM can not be used in KV Nano series.
• Only in the KV Nano series, it is possible to add arithmetic expression limits to CM.

● Writing indirect specification (*)


Enter * in front of device (DM / EM / FM / ZF / W / TM). It is to be used together with indirect designation command.

Example
*DM0 *TM100

"What is indirect specifying", page 3-57

Point The EM, FM can not be used in KV Nano series.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-21


Devices
DATA PROCESSING

● Writing local devices


Enter @ in front of device (R/MR/LR/T/C/DM/EM/FM/TM).
These devices are only valid in modules and macros. You can also perform indirect specification and
index modification.

Example
@DM0 @R10000

3
Devices

Point The EM, FM can not be used in KV Nano series.

● XYM marking
The designation of device by XYM notation of the list below is possible for device (R(DR)/MR/LR/DM/
EM/FM).
KEYENCE
Device name XYM Marking Device Number during
Marking
X(DX) 0000 to 999F*1
Relay R(DR)
Y(DY) 0000 to 999F*1
Internal auxiliary relay MR M 00000 to 63999*1*2
Latch relay LR L 0000 to 999F*1
Data memory DM D 00000 to 65534*1
Expansion data memory EM E 00000 to 65534
File register FM F 00000 to 32767
*1 The scope of device number that can be used differs for KV Nano series.
X(DX):0000 to 599F
Y(DY):0000 to 599F
M:00000 to15999
‘ L:0000 to199F
D:00000 to32767
*2 The scope of device number that can be used differs for KV-5500/5000/3000 series.
M:00000 to15999
To display it in XYM notation, select “Tool” → “Option” from the KV STUDIO menu and put a check
on “Display in XYM”with “Configuration of Display Mode”.

Point The EM, FM can not be used in KV Nano series.

● Entry specifying bits of a word device


After the device (R (DR) / MR / LR / B / T / C / DM / EM / FM / ZF / W / TM / CM), continue to input. □ (
□: the value of 0 to 15).

Example
DM0.0 (Indicates the first DM0 bit)
EM10.4 (Indicates the fifth EM10.4)

"Processing Word Device as Bit Device", page 3-46

Point The EM, FM can not be used in KV Nano series.

3-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
● Suffix entry
Soft element (R (DR) / MR / LR / B / T / C / DM / EM / FM / ZF / W / TM / CM / * DM / * EM / * FM / * ZF
/ * W / * TM) Then continue to input. □ (□: U, S, D, L, F, DF, B, T).

Example
DM0.F (Values DM0 - DM1 are calculated as floating point data)
R1000.U (calculated as 16-bit data between R1000 - R1015)

"What is indirect specifying", page 3-57


3

Devices
Point • Suffix entries can be used only in KV scripts.
• The EM, FM can not be used in KV Nano series.

● Constant value type specification


With the KV script, by adding a suffix to the decimal, a range with constants can be set.
Type Suffix Data range Program example
Unsigned 16-bit Constant U 0 to 65535 910U, 505U
Signed 16-bit Constant S - 32768 to + 32767 23S, - 600S
Unsigned 32-bit Constant D 0 to 4294967295 1234567D, 5D
Signed 32-bit Constant L - 2147483648 to + 2147483647 123L, - 89335963L
- 3.4E + 38 ≦ N ≦- 1.4E - 45
N=0
Single precision
+ 1.4E - 45 ≦ N ≦+ 3.4E + 38
floating point type Constant F 100F, -3.4E38F,0.12F
(* For the KV Nano Series, an absolute
(32-bit)
value in a range of 1.4E - 45 to 1.2E - 38
cannot be used.)
Double precision - 1.79E + 308 ≦ N ≦- 2.23E - 308
100DF, - 1.7E123DF
floating point type Constant DF N=0
0.0256DF
(64-bit) + 2.23E - 308 ≦ N ≦+ 1.79E + 308
* The type of hexadecimal constant handled in KV script is determined by the number of digits. (suffixes
cannot be entered)
4 digits or less…16bit unsigned (.U)
5 digits or more…32bit unsigned (.D)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-23


Devices
DATA PROCESSING

Bit Device

■ Bit status
The status of the bit device is described in the following representation method.
Bit load Representation Program example
3 ON(TRUE)
OFF(FALSE)
ON, 1, TRUE
OFF, 0, FALSE
MR1000=ON, MR1001=1, MR1002=TRUE
MR2000=OFF, MR2001=0, MR2002=FALSE
Devices

Reference These 2 status called "Boolean value".

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 or KV Nano Series, the range is "000 to 599"
*2 When CPU unit is KV-1000, the range is "000 to 59915"

• Input allows zero suppression when programming.


Reference
Example) R12
• Suffix can be added when programming
Example) R12.B
• When suffix is omitted, the type will be processed as .B (bit type), unless type
declaration is available.
• Processed as word device.
Example) R2000.U (16 bits occupied from R2000)
• When CPU unit is KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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-47

Range • R000 to R015 * (special for input)


• R500 to R507 (special for output )
• R1000 to R199915 * (can be assigned as the expansion input unit)
* The relay numbers that can be used differ by model.

Assigned number of the


Special for input Special for output
expansion input unit
KV-8000 - - R1000 to R199915
KV-7500/7300 - - R1000 ~ R199915*1
KV-5500/5000/3000 R000 to R015 R500 to R507 R1000 to R99915
KV-1000 R000 to R015 R500 to R507 R1000 to R59915
KV-N14□□ R000 to R007 R500 to R505 R1000 to R59915
KV-N24□□ R000 to R013 R500 to R509 R1000 to R59915
KV-N40□□ R000 to R107 R500 to R515 R1000 to R59915
KV-N60□□ R000 to R203 R500 to R607 R1000 to R59915
KV-NC32T R000 to R015 R500 to R515 R1000 to R99915
*1 For CPU function versions older than 2.2, the range is R00000 to R99915.
3-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Devices

DATA PROCESSING
Usage Input Relay
• Used peripheral equipment connected, including button and switch (for example
Selector Switch, limit switch, photoelectric switch, digital switch), etc.
• Input relay can be used as high speed inputs such as interrupt, high speed counter,
positioning function etc.
(The input relays that can be used differ per unit.)
KV-5500/5000/3000/1000 R000 ~ R015
KV-N14 □□
KV-N24 □□
R000 ~ R007
R000 ~ R013
3
KV-N40 □□ /KV-N60 □□ R000 ~ R107

Devices
KV-NC32T R000 ~ R015

Output relay
• Used the peripheral equipment connected, including solenoid valve, electromagnetic
switch, display (signal indicator, numerical indicator), etc.
• Output relay can be used as high speed output of high speed counter and positioning
function, etc.
(The output relays that can be used differ per unit.)
KV-5500/5000/3000/1000 R500 ~ R503
KV-N14 □□ /KV-N24 □□ R500 ~ R503
KV-N40 □□ R500 ~ R505
KV-N60 □□ R500 ~ R507
KV-NC32T R500 ~ R505

Description • Assign 1 bit to every input for input relay.


• Assign 1 bit to every output for output relay.
• NO or NC contact can be specified.
• In the same project, the input relay with same Device No. can be programed for many
times.
• Of R000 to R915, relays that are not used by inputs or outputs are reserved for the
system and cannot be used.

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

• About representation method of relay (R) unit device


Reference
In KV STUDIO , except general representation method, the relay can also be
represented according to Unit No.. If representing with devices used 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 number :Starting from CPU, according to the unit connection sequence,
assign00, 01, 02, 03, 04...., and the like.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-25


Devices
DATA PROCESSING

Unit relay No. :Number of relay points occupied from 00000 are assigned to
relay No.

Unit No. 00※ 01 02 03 04 05

KV-U7 CPU KV-B16XA KV-C32XA KV-B16TA KV-C32TA KV-H20


unit 16-input 32-input 16-output 32-output 10CH

3 Unit R0000 to R00015 (input)


relay No. R00500 to R00507 (output)
occupied

00000∼00015 00000∼00115 00000∼00015 00000∼00115 00000∼00915


Devices

* Devices from R000 to R915 used by the CPU (base) unit cannot be used as unit devices.

Link relay B

Overview This device cannot be used when the compatible model (CPU unit or base unit to use) is
the KV-1000.
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.


Exampl Channel No. (000 to 7FF) Contact No. (0 to F)
e)
B1EE7
Device name Device No. (0000 to 7FFF)

• Input allows zero suppression when programming.


Reference
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,)

• Please use HEX number (0 to F) to specify.


Point
• Local device (@) cannot be used.

Range B0000~B7FFF*

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

Description • 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.

3-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Default Default setting of link relay: shutoff and cleared when powering ON and when PPROG→
RUN. Hold mode setting can be performed utilizing “Power off hold function" in CPU
system setting.

* The relay numbers that can be used differ by model.


KV-8000 B0000 to B7FFF
KV-7500/7300 B0000 to B7FFF
KV-5500/5000/3000
KV-1000
B0000 to B3FFF
--- 3
KV Nano Series B0000 to B1FFF

Devices
Internal auxiliary relay R/B/MR/LR

■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.


Exampl
Channel No. (000 to 999*1) Contact No. (00 to 15)
e)
R00012
Device name Device No. (00000 to 99915*2 )

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

• Input allows zero suppression when programming.


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

Range • R1000 to R199915* (can be assigned as the expansion input unit No.)
* The relay numbers that can be used differ by model.
KV-8000 :R000 to R199915
KV-7500/7300 :R000 to R199915*1
KV-5500/5000/3000 :R1000 to R99915
KV-1000 :R1000 to R59915
KV Nano Series :R1000 to R59915
*1 For CPU function versions older than 2.2, the range is R00000 to R99915.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-27


Devices
DATA PROCESSING

■B
Overview This device cannot be used when the compatible model (CPU unit to use) is the KV-1000.
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.


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

B1EE7
Devices

Device name Device No. (0000 to 7FFF)

• Input allows zero suppression when programming.


Reference
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 from B80)

•Please use HEX number (0 to F) to specify.


Point
•Local device (@) cannot be used.
Range B0000~B7FFF*

Description • 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 Under default status, output is off when powering ON and when status is cleared during
PPROG ← → RUN. Power off hold function in CPU system setting allows to set up
holding status.

* The relay numbers that can be used differ by model.


KV-8000 B0000 to B7FFF
KV-7500/7300 B0000 to B7FFF
KV-5500/5000/3000 B0000 to B3FFF
KV-1000 ---
KV Nano Series B0000 to B1FFF

3-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
■ MR
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)
3

Devices
• Input allows zero suppression when programming.
Reference
Example) MR2809
• Suffix can be added when programming
Example) MR2809.B
• When suffix is omitted, the type will be processed as .B (bit type), unless type
declaration is available.
• Processed as word device.
Example) MR2900.U (16 bits occupied from MR2900)

Range MR00000~MR399915*

By default, the range for the KV-8000/7000 Series is MR200000 to MR399915, and
Point
the range for the KV-5000/3000/1000 and
KV Nano Series is MR50000 to MR99915.* indicates it cannot be used because it
is already assigned to local device.
(The reserved area can be changed using "whole local assignment setting" set in
CPU system setting)

Description • These relays cannot be assigned as the unit device of expansion unit.
• In 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.

* The relay numbers that can be used differ by model.


KV-8000 :
MR00000 to MR399915 (MR200000 to MR399915 are local devices in the initial state)
KV-7500/7300:
MR00000 to MR399915 (MR200000 to MR399915 are local devices in the initial state)
KV-5500/5000/3000/1000:
MR00000 to MR99915 (MR50000 to MR99915 are local devices in the initial state)
KV Nano Series:
MR00000 to MR59915 (MR50000 to MR59915 are local devices in the initial state)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-29


Devices
DATA PROCESSING

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

Denotation Device No. composition as follows.


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

LR02308
3 Device name Device No. (00000 to 99915*)
Devices

• Input allows zero suppression when programming.


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

Range LR00000~LR99915*

Description • These relays cannot be assigned as the unit device of expansion unit.
• In one project, the latch relay with same Device No. can be programmed for many
times.

Default Hold the status before the last power OFF.

* The relay numbers that can be used differ by model.


KV-8000/7500/7300/5500/5000/3000/1000:LR00000 to LR99915
KV Nano Series: LR00000 to LR19915

3-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
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.

3
Example) Device No. (0000 to 3999*)

T0501.B

Devices
Device name Suffix

• Input allows zero suppression when programming.


Reference
Example) T501.B
• Suffix 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.
• When suffix is omitted, the type will be processed as .B (bit type), unless type
declaration is available.
Range T0000.B to T3999.B*

Description 4 timer functions available: 10ms 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.
* The relay numbers that can be used differ by model.
KV-8000/7500/7300/5500/5000/3000/1000:T0000.B to T3999.B
KV Nano Series: T000.B to T511.B

■ 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
setting value (time before time up), 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 condition
(100ms down timer)

[Operation difference of every timer]


Timer type (function) Device No. Setting value Time before ON
100ms Down Counter (TMR) n x100ms
10ms Down Counter (TMH) n x10ms
T0~T3999*1 0~4294967295
1ms Down Counter (TMS) n x 1ms
10μs down Timer (TMU)*2 n x 10μs

*1 The device numbers that can be used differ according to the model.
KV-8000/7500/7300/5500/5000/3000/1000 :T0000.B to T3999.B
KV Nano Series: T000.B to T511.B
*2 This function cannot be used with the KV-1000.

The device (unsigned 32-bit data) and formula can be specified in setting value.
Reference
"Timer / Counter function", page 5-22

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-31


Devices
DATA PROCESSING

■ Timer error
Timer error as follows:
TMR (100ms Timer ) : within± (100ms + 1 scanning time)
TMH (10ms Timer ) : within± (10ms + 1 scanning time)
TMS (1ms Timer ) : within ± (1ms + 1 scanning time)
TMU (10ms Timer ) : within ± (10ms+1 scanning time)
3 ■ 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
Devices

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.
Programmin 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 condition is OFF

Processing statement of
Execution ON
IF statement not scanned
condition of
IF statement
OFF
(MR1000)

Execution ON
condition of
timer function Timer contact ON by timing of
OFF IF statement restart
(MR2000)

Status of ON
timer contact
(T100)
OFF

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

■ 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.
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
Const The set value cannot be read. Setting values can't be changed.

When correcting, if current value exceeds setting value, the current value is
Point
corrected to the value identical to the setting value.

3-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
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*) 3

Devices
C0551.B
Device name Suffix

• Input allows zero suppression when programming.


Reference
Example) C551.B
• Suffix 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.
• When suffix is omitted, the type will be processed as .B (bit type), unless type
declaration is available.

Range C0000.B to C3999.B*


* Depending on the model, the Device No. that can be used varies.
KV-8000/7500/7300/5500/5000/3000/1000 : C0000.B to C3999.B
KV Nano Series: C000.B to C255.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 count input relay enables programming the counter's operation.

Counter device No. Setting value

CNT(R1000,C600,50,MR1
Counter function counter execution condition 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.

The device (unsigned 32-bit data) and formula can be specified via setting value.
Reference
"Timer / Counter function", page 5-22

■ 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.
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
Const The set value cannot be read. Setting values can't be changed.

When correcting, if current value exceeds setting value, the current value is
Point
corrected to the value identical to the setting value.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-33


Devices
DATA PROCESSING

High-speed counter comparator (contact) CTC

Overview High-speed counter compare 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.

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


3 Point

Range
Devices

CTC0 to CTC7*

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

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

Default Under default status, the value is held.


• When the compatible model (CPU unit or base unit to use) is the KV-5500/5000/3000 or
KV Nano, power off hold function in CPU system setting to set clear status (non-hold).
• When CPU unit is KV-1000, can use MEMSW instruction allows to set clear status
(non-hold).

* The device numbers that can be used differ by model.


KV-5500/5000/3000/1000 :CTC0 to CTC3
KV-N14 □□ /KV-N24 □□ :CTC0 to CTC3
KV-N40 □□ :CTC0 to CTC5
KV-N60 □□ :CTC0 to CTC7
KV-NC32T :CTC0 to CTC5

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


KV Nano Series User's Manual "4-4 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 CR7915

• Suffix can be added when programming


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

Description "CR/CM List", page A-2

* The device numbers that can be used differ by model.


KV-8000 :CR0000 to CR7915
KV-7500/7300 :CR0000 to CR7915
KV-5500/5000/3000/1000 :CR0000 to CR3915
KV Nano Series: CR0000 to CR8915
3-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Devices

DATA PROCESSING
Word device

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. 3
"File register ZF/FM", page 3-37

Devices
EM and FM cannot be used when the compatible model (base unit to use) is the
Point
KV Nano Series.

Denotation Device No. composition as follows.

Example) Device name Device No.

DM06143

• Input allows zero suppression when programming.


Reference
Example) DM6143
• Suffix can be added when programming
Example) DM1000.S (signed 16 bit), DM2000.D (Unsigned 32 bit)
• When suffix is omitted, the type will be processed as .U (signed 16-bit), unless type
declaration is available.
• Processed as the bit device.
Example) DM1100.Bthe lowest bit of DM1100
• When the compatible model (CPU unit or base unit to use) is the KV-8000/7500/7300/
5500/5000/3000 or KV Nano, it can be processed as the bit device whose bit position
is specified.
Example) DM1200.12the 13th bit of Device of DM1200

Range • DM00000 to DM65534


• EM00000 to EM65534*1
• FM00000 to FM32766*1*2
*1 When the compatible model (base unit to use) is the KV Nano, these devices cannot
be used.
*2 When CPU unit is KV-5500/5000/3000, the range is FM00000 to FM32767.
"File register ZF/FM", page 3-37

Description • Only Data Memory (DM) can be assigned as the unit device of expansion unit.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-35


Devices
DATA PROCESSING

●When processing 16-bit data


• The 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.
• When processing16-bit data, suffix .U (can be omitted) or .S shall be added on Device No.
DM1

3
bit bit bit bit
15 8 7 0
Devices

16 bits

●When processing 32-bit data


• 2 devices can be used to process 32-bit data. For 32-bit data, low 16 bits 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.
• When processing 32-bit data, suffix .D or .L shall be added on Device No..
DM1 DM0
bit bit bit bit bit bit bit bit
31 2423 1615 8 7 0

High 16 bits Low 16 bits

32 bits

Default Under default status, the value is held.


• When CPU unit is KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, power off
hold function in CPU system setting to set clear status (non-holding).
• When CPU unit is KV-1000, MEMSW instruction allows to set clear status (non-hold).

· About the presentation of unit device for Data Memory (DM)


Reference
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,
assign00, 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 ).

3-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Example)

Unit No. 00 01 02 03 04 05

KV-U7 KV-5000 KV-AD40 KV-DA40 KV-MC20V KV-MC20V KV-MC20V


CPU 22 words 18 words 402 words 402 words 402 words

3
Unit DM No.
0000∼0019 0000∼0021 0000∼0017 0000∼0401 0000∼0401 0000∼0401

Devices
The 5 th of KV-AD40 DM01_0004
The 53rd of KV-MC20V (Unit No. 03)................. DM03_0052
The 1st of KV-MC20V (Unit No. 05).................... DM05_0000

File register ZF/FM

Overview When CPU unit is KV-8000/7500/7300/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 multiple (16 or 4) Banks and processing in Bank switching
mode.
Refer to "File Register" in the User's Manual of the CPU unit used for details.

When CPU unit is KV-1000, only FM (FM00000 to FM32766) can be processed.


Point
"Data memory/Extended data memory DM/EM/FM", page 3-35
ZF/FM cannot be used when the compatible model (base unit to use) is the KVNano
Series.

Denotation Device No. composition as follows.


Example)
Device name Device No.

ZF0372

• Input allows zero suppression when programming.


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

• Local device for ZF (@ZFxxx) cannot be used.


Point
• Local device for FM (@FM0 to @FM32767) cannot be bank switched.
• Local device for FM (@FM0 to @FM32767) uses work memories.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-37


Devices
DATA PROCESSING

Range • ZF000000 to ZF524287*


• FM00000 to FM32767*
* The device numbers that can be used differ by model.
KV-8000 : ZF000000 to ZF524287, FM00000 to FM32767
KV-7500/7300 : ZF000000 to ZF524287, FM00000 to FM32767
KV-5500/5000/3000 : ZF000000 to ZF131071, FM00000 to FM32767
KV-1000 : FM00000 to FM32766
3 KV Nanoseries : Cannot be used
"Data memory/Extended data memory DM/EM/FM", page 3-35
Devices

Description • These relays cannot be assigned as the unit device of expansion unit.
• Device 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

ZF000000 ....... ....... ZF131071

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


File Register area will be separated into 16* blocks, processing is performed by switching
banks.
When the corresponding model (using CPU unit) is KV-1000, only Bank1 FM0 to FM32766
can be used.
File register area

ZF0 ....... ....... ZF65535,ZF65536


ZF32767,ZF32768 ....... 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 16* different devices via switching Bank.


But, it can be reused with ZF device, so, care must be taken during data processing.
For Bank switching method, please see "File Register" in the User's Manual of the CPU unit
used for details.
* The number of banks that can be divided depends on the type of device.
KV-8000 :16
KV-7500/7300 :16
KV-5500/5000/3000 :4

●When processing 16-bit data


• The 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.
• When processing16-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

3-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
● When processing 32-bit data
• 2 devices can be used to process 32-bit data. For 32-bit data, low 16 bits 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.
• When processing 32-bit data, suffix .D or .L shall be added on Device No..
3

Devices
ZF2511 ZF2510
bit bit bit bit bit bit bit bit
31 2423 1615 8 7 0

High 16 bits Low 16 bits

32 bits

Default Under default status, the value is held.


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

Link register W

Overview This device cannot be used when the compatible model (CPU unit to use) is the KV-
1000.
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.


Exampl Device name Device No. (0 to 3FFF)
e)
W3A6F

• Input allows zero suppression when programming.


Reference
Example) W7A
•Suffix can be added when programming.
Example) W7A.S (signed 16 bit), W3E76.D (Unsigned 32 bit)
• When suffix is omitted, the type will be processed as .U (unsigned 16-bit), unless type
declaration is available.
• Processed as the bit device. bit position can be also specified.
Example) the 13th bit of W1200.12W1200

• Please use HEX number (0 to F) to specify.


Point
• Local device (@) cannot be used.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-39


Devices
DATA PROCESSING

Range W0000 to W7FFF*


* The device number that can be used depends on the type of device.
KV-8000 : W0000 to W7FFF
KV-7500/7300 : W0000 to W7FFF
KV-5500/5000/3000 Series : W0000 to W3FFF
KV Nano Series : W0000 to W3FFF

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


Devices

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

●When processing 16-bit data


• The 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.
• When 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
●When processing 32-bit data
• 2 devices can be used to process 32-bit data. For 32-bit data, low 16 bits 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.
• When processing of 32-bit data, suffix .D or .L shall be added on Device No..
W2BE1 W2BE0
bit bit bit bit bit bit bit bit
31 2423 1615 8 7 0

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-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Temporary data memory TM

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. 3

Devices
TM010

• TM000 to TM003 are used in operation instructions such as DIV, MUL in ladder,
Reference
TM000 and TM001 used for processing 32-bit above data. It is recommended that
these temporary data memories are not used for other purposes.
• Input allows zero suppression when programming.
Example) TM10
• Suffix can be added when programming
Example) TM10.D (Unsigned 32-bit)
• When suffix is omitted, if without type declaration, it is processed 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*

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

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

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

"Timer (contact) T", page 3-31

* Depending on the model, the Device No. that can be used varies.
KV-8000/7500/7300/5500/5000/3000/1000:T0000.D to T3999.D
KV Nano Series: T000.D to T511.D

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-41


Devices
DATA PROCESSING

Counter (current value) C

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

Range C0000.D to C3999.D*

3 Reference
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).
Devices

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

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

* Depending on the model, the Device No. that can be used varies.
KV-8000/7500/7300/5500/5000/3000/1000 : C0000.D to C3999.D
KV Nano Series: C000.D to C255.D
"Counter (contact) C", page 3-33

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 CTH3*

• Suffix can be added when programming


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

Description • A value within 0 to 4294967295 can be processed.


• In addition to external input counting, internal clock can also be counted.
• Maximal response frequency is duty ratio 50%, 1-phase, 100KHz, phase
difference50KHz.

Default Under default status, output is off when powering ON and when status is cleared during
PPROG → RUN.
• When the compatible model (CPU unit or base unit to use) is the KV-5500/5000/3000
or KV Nano, power off hold function in CPU system setting allows to set hold mode.
• When CPU unit is KV-1000, MEMSW instruction allows to set hold mode.

* Depending on the model, the Device No. that can be used varies.
KV-5500/5000/3000/1000: CTH0 to CTH1
KV-N14**/KV-N24**: TH0 to CTH1
KV-N40**: TH0 to CTH2
KV-N60**: CTH0 to CTH3
KV-NC32T: CTH0 to CTH2
KV-5500/5000/3000 series PLC User's Manual, "2-8 High-speed Counter"
KV Nano series User's Manual, "4-4 High-speed Counter"
3-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Devices

DATA PROCESSING
High-speed counter comparator (setting value) CTC

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

Range CTC0 to CTC7*

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

Devices
• The range should be 0 to 4294967295.
• 2 setting values ( CTC ) can be set for every high-speed counter (CTH) .
• CTC0,CTC1 ........CTH0
• CTC2,CTC3 ........CTH1
• CTC4,CTC5 ........CTH2*
• CTC6,CTC7 ........CTH3*

Default The value is held.


* Depending on the model, the Device No. that can be used varies.
KV-5500/5000/3000/1000: CTC0 to CTC3
KV-N14**/KV-N24**: CTC0 to CTC3
KV-N40**: CTC0 to CTC5
KV-N60**: CTC0 to CTC7
KV-NC32T: CTC0 to CTC5
KV-5500/5000/3000 series PLC User's Manual, "2-8 High-speed Counter"
KV Nano series User's Manual, "4-4 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 KV-8000 after CPU function version V2.0: Z1 to Z23


Models other than the above: Z1 to Z12

• Suffix can be added when programming


Reference
Example) Z01.L (signed 32-bit)
Z02.D (unsigned 32-bit)
• For programming when suffix omitted, if without type declaration, when the model is
KV-8000/7500/7300/5500/5000/3000 or KV Nano series, it is processed as .L
(signed32-bit); when the model is KV-1000, it is processed as .S (signed 16-bit).

• Z11 are reserved for system and cannot be used.


Point
• .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 6-20
"ZPOP function", page 6-24
Default When powering ON, or PROG-RUN, index register is cleared.

"Index modification", page 3-55

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-43


Devices
DATA PROCESSING

Control memory CM

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

Range CM0000 to CM7599*

3 Reference
• Suffix can be added when programming.
Example) CM1720.U
• When suffix is omitted, if without type declaration, it is processed as .U (Unsigned 16-
Devices

bit).
* Depending on the model, the Device No. that can be used varies.
KV-8000 CM0000 to CM7599
KV-7500/7300/5500/5000/3000 CM0000 to CM5999
KV-1000 CM00000 to CM11998
KV Nano SeriesCM0000 to CM8999

Description "CR/CM List", page A-2

3-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Processing Bit Device in Word Unit

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
3

Devices
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0

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 R30100 R30015 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-45


Devices
DATA PROCESSING

Processing Word Device as Bit Device

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

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

● When processing as the bit device at the lowe rest bit


When adding suffix .B to word device, or specifying word device in arguments and assignment
statements of contact output function used for processing bit devices etc., it will be processed as bit
device at the lowe rest 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.


This device cannot be used when the compatible model (CPU unit or base unit to use) is the KV-1000.
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)

DM1234.12
Random word device Bit position (.0 to .15)

·Same bits are processed by DM123.B and DM123.0.


Reference
· Device comment displays comment set against word device.

3-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
• When CPU unit is KV-1000 , it cannot be used.
Point
• 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.
•The variables that can be specified by the execution bit are limited to the
variables whose data format is "INT, DINT, UINT, UDINT" and the elements of the
array type variables and structure type variables set to these data formats.
• For label, bit position cannot be specified. (during global label registration, the
3
word device whose bit has been specified can be specified)

Devices
• 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.
When DM123 value is #59 ($3B)
bit bit bit bit bit bit bit bit bit bit bit bit bit bit bit bit
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 0 0 0 0 0 0 0 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
DM123.3 ON
DM123.4 ON
DM123.5 ON
DM123.6
~ OFF
DM123.15

Direct I/O Relay

When the compatible model (CPU unit or base unit to use) is the KV-8000/7500/7300/5500/5000/3000 or
KV Nano, 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

• When the corresponding model (using a CPU unit) is KV-1000, direct I/O relays
Point
cannot be used.
• When the corresponding model (basic unit used) is the KV Nano series, the
direct input / output relay cannot be used for the expansion unit.
• No suffix other than .B could be added.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-47


Devices
DATA PROCESSING

Range I/O relay


KV-5500/5000/3000 DR000 to DR015/ DR500 to DR503/ Expansion I/O relay
KV-N14 □□ DR000 to DR007/ DR500 to DR505
KV-N24 □□ DR000 to DR013/ DR500 to DR509
KV-N40 □□ DR000 to DR107/ DR500 to DR515
KV-N60 □□ DR000 to DR203/ DR500 to DR607
KV-NC32T DR000 to DR015/ DR500 to DR515

3 For direct I/O relays, see


Manual".
"KV-5500/5000/3000 series User's Manual" or "KV Nano series User's
Devices

3-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Variables

The current values of all devices and variables in a script can be monitored simply by selecting the
script in the monitor window. KV STUDIO can use variables for programming in addition to devices.
Unlike devices, variables can be programmed with names defined by KV STUDIO, and the defined
variables are automatically assigned to the work area of the CPU unit. Therefore, it is not necessary to
create a device map, etc. to manage the device numbers assigned with functions. In addition, variables 3
are also applicable to the VT5 series and Soft-VT, so there is no need to change the device number on

Devices
the display unit side in combination with the device number on the PLC side.

Point • Variables are only available in KV STUDIO Ver11.0 and later. The corresponding
models are only KV-8000 with CPU function version 2.0 and later.
• Variables that can be read and written from the display unit are limited to VT STUDIO
Ver. 8.0 and later. The corresponding model is limited to the VT5 series and the PLC
model is KV-8000 (Ethernet).

For the setting method of variables, please refer to "Label Programming and Label Array", page 2-
25.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-49


Devices
DATA PROCESSING

Variables and data formats at a glance

When using variables, it is necessary to define the data format in advance. The CPU unit automatically
allocates the necessary data size to the work area*1 according to the defined data format.
The work area sizes and variable specifications that can be used with KV-8000 are as follows.
Item Details
3 bit
word
64000 points
589824 words
Work area size
Timer 4000 points
Devices

Counter 4000 points


Definable number 100000
Variable specifications Maximum length of
128 character
variable name
*1 You can manually assign devices to the CPU unit without using the work area. Please refer to
"KV-8000 Series User Manual" for details.

The data format and data size of the variables that can be used with KV-8000 are as follows.
Data type
Data size (bit units)
Type name Description
BOOL bit 1
UINT 1 word unsigned integer 16
INT 1-word signed integer 16
UDINT 2 word unsigned integer 32
DINT 2-word signed integer 32
Single precision floating
REAL 32
point type
Double precision floating
LREAL 64
point type
Round (number of characters * 2 + 1) × 8 to an
STRING Text string
integer multiple of 16
Timer Timer -
Counter Counter -
Array - Data format × array size
Structure - Based on definition*1
Function block Function block Based on definition*1
*1 Structures and function blocks are data formats that use multiple data formats. Therefore, the
data size is determined according to the setting contents. Please refer to "KV-8000 Series User
Manual" for details.

3-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Devices

DATA PROCESSING
Constant

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

Devices
Denotation DEC value is expressed as it is. (signed representation also acceptable)
Example) Value

06143

• Input allows zero suppression when programming.


Reference
• DEC constant can also be attached prefix "#" when programming. For signed DEC
constant, only "+" can be omitted.
• In XYM display mode,"K" can be added to indicate.

Range • Unsigned 16-bit: 0 to 65535


• Unsigned 32-bit: 0 to 4294967295
• Signed 16-bit: - 32768 to +32767
• Signed 32-bit: - 2147483648 to +2147483647

• Adding suffix via constant and programming, can expand the range of constant. (suffix
Reference
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+38≦ N ≦1.4E-45
N=0
1.4E-45≦ N ≦3.4E+38)
1.2345678DF (Number of effective digits: approx. 7 digits)
: Double precision floating point type
( -1.79E+308≦ N ≦-2.23E-308
N=0
2.23E-308≦ N ≦1.79E+308)
(Number of effective digits: approx. 16 digits)

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


Point
• For the KV Nano Series, an operation error occurs when using denormalized
single precision floating point types.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-51


Devices
DATA PROCESSING

$ HEX constant
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

3 $1AF7
Devices

• Input allows zero suppression when programming.


Reference
• In XYM display mode, "K" can be added to indicate.

Range • 16 bit : $0 to $FFFF


• 32 bit : $0 to $FFFFFFFF

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

• When programming, if HEX constant has no prefix "$" and contains A to F , error will occur;
Point
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 • DEC constant is expressed by [sign + DEC number].
Example) Value

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

1234F

Reference For floating type constant, suffix can be omitted.

Example)
1234.0
Indicates single precision floating point type

DEC constant can also contain prefix "#" when programming. For signed DEC
Reference
constant, only "+" can be omitted.

Range -3.4E+38≦N≦-1.4E-45
N=0
+1.4E-45≦N≦+3.4E+38 (Number of effective digits: approx. 7 digits)
(For the KV Nano Series, an absolute value in a range of 1.4E-45 to 1.2E-38 cannot be used.)
3-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Devices

DATA PROCESSING
Double precision floating point type constant

Overview When programming, double precision floating point type real number can act as floating
real number.
Denotation • DEC constant is expressed by [sign + DEC number].
Example)
3
Value

12345.6789

Devices
• 17-bit above is represented in exponential form.
• DEC constant is represented by suffix.
Example) Value double precision floating point type

1234DF

DEC constant can also contain prefix "#" when programming. For signed DEC constant,
Reference
only "+" can be omitted.

Range -1.79E+308≦N≦-2.23E-308
N=0
+2.23E-308≦N≦+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”

• When processing (") as characters, please input (" ").


Reference
•When adding (") to other characters, use "+" and characters.

DM1000.T = " " + "Operation result" + " " “Operation result” is stored in DM1000.T.

Point Text string will be processed as label if (“”) not inputted.

Range Up to 1999 characters can be processed.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-53


Index Modification and Indirect Specifying
DATA PROCESSING

Devices that can be used with index modification and indirect specifying are listed below.
KV-8000/7500/7300/
Device KV-1000 KV Nano
5500/5000/3000
Indirect Indirect Indirect
Symb Index Index Index
Type Name Specify Specify Specify
ols Modification Modification Modification
ing ing ing

3 bit R Relay * ○* ○*
○ ○ ○ ○
Device
CR Control relay - - - - - -
Index Modification and Indirect Specifying

T Timer (contact) ○ ○ *
○ ○ *
○ ○*
C Counter (contact) ○ ○* ○ ○* ○ ○*
MR Internal auxiliary
○ ○* ○ ○* ○ ○*
relay

LR Latch relay ○ ○* ○ ○* ○ ○*
B Link relay ○ ○* - - ○ ○*
Word DM Data memory ○ ○ ○ ○ ○ ○
Device
EM Expansion data
○ ○ ○ ○ - -
memory

FM File register
○ ○ ○ ○ - -
(Bank switching)

ZF File register
(Consecutive ○ ○ - - - -
numbering)

W Link register ○ ○ - - ○ ○
TM Temporary memory ○ ○ ○ ○ ○ ○
TS Timer (setting value) ○ ○ ○ ○ ○ ○
TC Timer (current value) ○ ○ ○ ○ ○ ○
CS Counter (setting
○ ○ ○ ○ ○ ○
value)

CC Counter (current
○ ○ ○ ○ ○ ○
value)

CM Control memory - - - - ○ ○*

* Indirect specifying is possible, but the address cannot be stored with the "*(device)" description.

Point • Index modification is not possible for CR, CTC, CTH, Z, labels (label arrays),
variable (variable array), and bit specifying devices of word devices.
• Indirect specifying is not possible for CR, CTC, CTH, Z, and bit specifying
devices of word devices.

3-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index Modification and Indirect Specifying

DATA PROCESSING
Index modification

"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 devices that can be used differ by unit. See "Devices that can be used with index modification and
indirect specifying" on page 第 3-54 页. 3
Index modification can be used together with indirect specifying (*) or local device (@).

Index Modification and Indirect Specifying


Point • Bits (label arrays) and word device bit designation devices cannot be index
modified.
• Index modification cannot be performed for variables. However, index modification
can be performed for variables manually assigned to global devices.
• 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 by 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.

Point Versions after Z11 are reserved by the system and cannot be used.

Exampl
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).

Scripting 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-55


Index Modification and Indirect Specifying
DATA PROCESSING

Point Since the device (value) to be index-modified is processed as signed 32-bit data,
the index register whose type is not declared will be automatically performed as".L
(signed 32-bit)".

Reference 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.
3 "ZPUSH function", page 6-20
"ZPOP function", page 6-24
Index Modification and Indirect Specifying

■Modify via index constant


When constant is used for index modification
(Device No.): (#) (DEC constant)
(“#”can be omitted.)
Example)
DM1000:10 DM1000+10 words -> DM1010

R0000:16 R0000+16 bits (1 channel) -> R0100.

Reference 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 .

Scripting 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)

■Invalid index modification


Index modification cannot be performed in the following cases:
• (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

3-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index Modification and Indirect Specifying

DATA PROCESSING
What is indirect specifying

■What is indirect specifying(*)


Indirect specifying (*) refers to indirect specifying by programming the device storage device indicated
value (address) instead of direct device specifying.

3
● Indirect specifying principle

Index Modification and Indirect Specifying


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.

Point • 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 DM1 1234 * FM100 specify 1234
of DM1’s address or DM1.
DM2 0
DM3 96

The devices that can be used differ by unit. For details, see“Devices that can be used with index
modification and indirect specifying.”

Point • Variables and labels can also be specified indirectly. However, the following
cannot be specified indirectly.
• Subscripts for array variables
• Elements of array variables
• Member of structure type variable
• Word data bit position specification cannot be performed indirectly.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-57


Index Modification and Indirect Specifying
DATA PROCESSING

Reference · 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.
· Use programming format of local device "*@( device) ".
· Indirect specifying device is processed as .U (unsigned 16 bit).
· Type declaration can be also conducted for indirect specifying.

3 ● Application method of indirect specifying


Indirectly specify according to the following steps.
Index Modification and Indirect Specifying

1 Write the address of device to be searched with ADRSET function.


Example)
ADRSET(R1000,DM0,FM100.D) Store address of DM0 to FM100/FM101
when execution condition (R1000) is ON.

Point The devices that can be used differ by unit. For details, see“Devices that can be
used with index modification and indirect specifying.”

"ADRSET function", page 6-26

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.

Point 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.D)
ADRINC(R1001,FM100.D) Increment (+1) DM0 address stored in FM100/
FM101 when execution condition (R1001) is ON
∗FM100 = DM1000

∗ Store value of DM1000 in FM100 (EM300).

Point When changing the address to be searched, do not use common operators(+, -,*, /,
etc.). Otherwise, Ladder fails to operate correctly.

3-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index Modification and Indirect Specifying

DATA PROCESSING
● Type of indirect specifying device
For indirect specifying device (*[device]), similar to other device, data range that can be processed
varies with suffix.
• The device type can be represented by adding suffix to indirect specifying device.
Scripting *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 suffix can be 3
omitted when programming.

Index Modification and Indirect Specifying


Scripting 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 suffix of indirect specifying device without type declaration is omitted, the
device will be processed as .U.
Scripting *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 suffix of indirect specifying device
is omitted, can be also processed as.U.
Scripting ADRSET (MR2000, DM1000.D) ’MR2000 address is stored in DM1000.D.
*DM1000 = 123 ’MR2000 is bit device but suffix is omitted, *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).
Scripting TYPE *DM1000.F ’*DM1000 is declared as .F, and DM1000 as .D.
TYPE *DM2000.S ’*DM2000 acts as .S declaration, or DM2000 as .D
’declaration.
ADRSET (EM5000, DM1000) ’DM1000 is processed as .D .
*DM1000 = 123.567 ’*DM1000(=EM5000) is processed as .F .
ADRSET (FM6000, DM2000) ’DM2000 is processed as .D .
*DM2000 = -555 ’*DM2000(=FM6000) is processed as.S .

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-59


Index Modification and Indirect Specifying
DATA PROCESSING

● Example for indirect specifying


During initial scanning, DM0 address will be stored to FM100/FM101.
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
3
Write value of DM1000 to index-specified
destination device at the rising edge
ADRINC(FM100) of R0001.
END IF
Index Modification and Indirect Specifying

Increment (+1) address stored in


[FM100/FM101].

Current value Save to

DM1000 1234 DM0000 2152


DM0001 2348

DM0099 1234

3-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index Modification and Indirect Specifying

DATA PROCESSING
Combination of index modification and indirect specifying

■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

Index Modification and Indirect Specifying


When programming with ( ) is omitted, the meaning is as follows:
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 ①
ADRSET(R2,DM0,FM100.D) ②
ADRSET(R2 = OFF,EM0,FM100.D) ③
END IF
IF LDP(R1) THEN
∗FM100:Z01 = DM1000 ④
Z01 += 1 ⑤
END IF
[When starting measurement]
① Write 0 in Index register Z01. (Index register initialization)
② If R2 is ON, write address of FM100/FM101 to DM0.
③ 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-61


Data Type (suffix)
DATA PROCESSING

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" or ".T", the type of processing data
varies with different suffixes.

Suffix

3 A suffix refers to a symbol attached to the end of the device, and can be divided into seven kinds as
follows.
Data Type (suffix)

.U .S .D .L .F .DF .B .T
* The device with corresponding suffix is input in .

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+38 ≦ N ≦−1.4E−45
N=0
1.4E−45 ≦ N ≦ 3.4E+38
(Number of effective digits: approx. 7 digits)
(For the KV Nano Series, an absolute value in a range of 1.4E-45
to 1.2E-38 cannot be used.)
Suffix .DF is processed as double precision floating point type real number data.

−1.79E+308 ≦ N ≦ −2.23E−308
N= 0
2.23E−308 ≦ N ≦ 1.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.

Reference 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).

例 DM1000 (.U)
DM1000.S
DM1000.D
DM1000.L
DM1000.F
DM1000.DF
DM1000.B
DM1000.T

Point When using variables and labels, you can also use the suffix like "AnalogData.L".
However, if the data size of the suffix processing is larger than the data format set
in the variable edit window / label edit window, a conversion error will occur.

3-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
● Suffix omitted
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)


R(DR),B,MR,LR,T,C,CTC,CR,UR .B (bit type)
DM,W,EM,ZF,FM,TM,CM,V0,P0,U .U (unsigned 16-bit data type)

3
M0,UV0 indirect addressing (*)
device
Z* KV-8000/7500/7300/5500/5000/3000 :.L (signed 32-bit data type)

Data Type (suffix)


KV-1000 :.S (signed 16-bit data type)
CTH .D (unsigned 32-bit data type)

* Default type varies with different CPU units.

Point When the suffix is omitted for a variable, it is processed according to the data
format set in the variable edit window.

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,

END IF converted
to .D 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.

Reference 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)".

■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 and bit data
DM1000.U Unsigned DEC 65535
DM1000.S Signed DEC -1

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-63


Data Type (suffix)
DATA PROCESSING

• 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

3 Correspondingly, if DM1000 > 100 is TRUE, add "1" to DM2000


Data Type (suffix)

• If suffix is .S, DM1000 value is compiled to "-1".

Programming Script IF DM1000.S > 100 THEN


DEC (DM2000)
END IF
Correspondingly, subtraction is not conducted for DM2000 due to DM1000 < 100, DM2000.
For control statements, see "Control statement".

■About .D and .L
Suffix .D processes BIN data as unsigned 32-bit data.
Suffix .L processes BIN data as signed 32-bit data.

Correspondingly, the decimal representation relation between BIN data and corresponding suffix is
shown below.

11111111111111111111111111111111 and
Device (DM1000) Constant type bit data
DM1000.D Unsigned DEC 4294967295
DM1000.L Signed DEC -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".

Point During processing of 32-bit data (.D,.L,.F), device No. of even number must be
used.

3-64 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
■About .F
.F suffix will process BIN data as single precision floating point type real number. The data is 32-bit
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 3
method.

Data Type (suffix)


−1.234×2−3
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 ($00)=not used
00000000
1=minus ($01)=-126
00000001
00000010($02)=-125
Mantissa section (23 bit) ($03)= -124
00000011
0∼8388607
($7E)= -1
01111110
($7F)=0
01111111
10000000($80)=1
10000001($81)=2

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

Point Suffix .D, .L and .F shall be added to the device when 32-bit data is processed by
word devices such 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) Use DM1000.D → "DM1001, DM1000".

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-65


Data Type (suffix)
DATA PROCESSING

■About .DF
.DF suffix will process BIN data as double precision floating point type real number. The data is 64-bit
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.
3 Double precision floating point type real number value is a value represented according to the following
method.
Data Type (suffix)

−1.2345678×2−102
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

Point Suffix .DF shall be added to the device when double precision floating point type
real number is processed by word devices such as DM/W/EM/FM/TM, etc.
In this case, the device uses 4 words with continuous No.. When using .DF, use
even-numbered devices.
The device to be specified is that the suffix is added to low 16bits.
Example) DM1000.DF → [DM1003•DM1002•DM1001•DM1000] .
.DF can be used with KV-8000/7000 CPU units, KV-5000/3000 Series CPU units that
have CPU function version 2.0 or higher and with KV Nano Series base units.

3-66 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
■About .B
.B suffix processes BIN data as bit data.

Example) Set the bit device MR1000 to ON (1, TRUE).

Programming Script SET(MR1000.B)

Reference 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
3
function, the least significant bit of DM10 changes to "1". The TRUE / FALSE judgment of

Data Type (suffix)


the word device is as follows.
Example) 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)


above example, data storage status as follows.
bit bit
15 0
Data storage 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

Reference NUL will be automatically stored into text string (00H).

Point Up to 1999 characters can be processed.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-67


Data Type (suffix)
DATA PROCESSING

■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.

● For 16-bit data


Value change when □.U larger than 65535 Value change when □.S larger/less than max./min. value

3 Unsigned DEC
2
3
HEX
0002
0003
Signed DEC
2
3
HEX
0002
0003

1 0001 1 0001
Data Type (suffix)

0 0000 0 0000
65535 FFFF -1 FFFF
65534 FFFE -2 FFFE
65533 FFFD -3 FFFD
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
32763 7FFB 32763 7FFB

● 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

Reference • For single precision floating point type data


Overflow : when absolute value is larger than 3.4×1038, it becomes "∞ (infinity)".
Underflow : when absolute value is less than 1.4×10-45*, it becomes "0".

1.4×10-45 ※ 3.4×1038
0 (1.4E-45) (3.4E38)

Display“0” Display“----”(∞infinity)
* For the KV Nano Series, 1.2x10-38 (1.2E-38).
• For double precision floating point type data
Overflow : when absolute value is larger than 1.79×10308, it becomes "∞ (infinity)".
Underflow : when absolute value is less than 2.23×10-308, it becomes "0".

2.23×10-308 1.79×10308
0 (2.23E−308) (1.79E308)

Display“0” Display“----”(∞infinity)

3-68 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
help_topic_start

About Type Declaration (TYPE)


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
3

Data Type (suffix)


as the device with declared suffix.

Programming Script TYPE DM1000.D DM1000 will be processed as .D in the script

TYPE EM.F Emnnnn will be processed as .F in the script

DM1000 = 10000 * DM2000.D Even if suffix is omitted, DM1000 can be still


processed as .D
EM3000 = 123.456 / DM1200.F All EM devices are processed as 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 processed as .F
DM1210 = SIN(DM1300) 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,

EM3000.D = 1234 * DM1200 the specified suffix will be precedential

EM3000 = EM3000 + 10000 After suffix omitted, the device is processed as


TYPE statement type.

Point • 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-69


Data Type (suffix)
DATA PROCESSING

help_topic_start

About Operation Type


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


3 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
Data Type (suffix)

sign extended to .L, .F or .DF.

● 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 exists, 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-70 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
● When the result storage location is other than .L

Example) DM3200.S = (DM1200.U + 30) * DM2200.U


The result of calculations that do not include floating-point data must be in .L format. Therefore,
when the format of the result storage location on the left is specified to be other than .L, data
accuracy may be reduced. This should be noted.
Above operation formula is calculated as follows:
DM3200.S =TOS ((DM1200.U + 30) * DM2200.U) 3
When "Script warning level setting" is "high", the following warning is displayed in output window.

Data Type (suffix)


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 precision will
drop.

Point The warning on precision impairment of operation formula is not displayed in


output window by default.
To display warning message, script warning level must be set to "high".
"Script Conversion Output Message", page 2-52

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-71


Data Type (suffix)
DATA PROCESSING

help_topic_start

PRAGMA Directive
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

3
prevented.

Point The PRAGMA directive instruction cannot be used with the KV-1000.
Data Type (suffix)

■ Explanation of PRAGMA Directive Usage and Operation


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 ‘ ...①

DM2004.DF = DM1004.S / 25 ‘ ...②

#PRAGMA DOUBLE ON
DM2010.DF = DM1000.F * 3.141592 ‘ ...③ Effective interval of PRAGMA
DM2014.DF = DM1004.S / 25 ‘ ...④ DOUBLE

#PRAGMA DOUBLE OFF

Operation description

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-72 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data Type (suffix)

DATA PROCESSING
(4) Although PRAGMA DOUBLE is valid, the floating decimal point type data is not included in the
calculation formula, so the calculation is performed according to the same rules as (2), and the
operation result is converted into a double precision floating decimal point type (.DF) and then stored
in DM2014 ~ DM2017 ( 4 words).

Data Type (suffix)


The operation results differ for (1) (DM2000) and (3) (DM2010).

Point • 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
Please expand some target devices to a floating decimal point type.
In addition, as shown below, the same effect is obtained even if the constant is
marked as a decimal.
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.

Point 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 3-73


Data Type (suffix)
DATA PROCESSING

● Operation of functions
Programming Script

DM1000.DF = SIN(DM100.F) ‘ ...①

3 #PRAGMA DOUBLE ON Effective interval of PRAGMA

DM1010.DF = SIN(DM100.F) ‘ ...② DOUBLE


Data Type (suffix)

#PRAGMA DOUBLE OFF

Operation description

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))

Point 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-74 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


4

SCRIPT SYNTAX AND


PRECAUTIONS
SCRIPT SYNTAX AND
PRECAUTIONS

Assignment Statement .......................................................... 4-2


Order of Prionity low.............................................................. 4-6
Control statement ................................................................ 4-10
Precautions on Script Programming.................................... 4-38

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-1


help_topic_start

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


Contents (devices and variable expressions) that can be written on the right side of an assignment
statement include values, strings and bits, etc. as shown below, and are written using constants,
expressions or functions (with return value).

4 ● Numerical value assignment statement


Assign right numerical constant or value calculation result to the left.
Assignment Statement

Programming Script
DM1000.U = 123 'Assignment of numerical constant

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

DM200.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

• 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 = R4


↑ ↑ ↑
Assign Compare Compa
Left side←:→Right side
• Except ON, OFF, bit status can be also represented with 1, 0 and TRUE, FALSE.

Programming Script
R1000 = 1
Operation description R1000 Set R1000 to ON.
Ladder diagram Conversion

4-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Assignment Statement

• Bit data can only be assigned to Boolean values.

SCRIPT SYNTAX AND


R1000 = TRUE . . . . . R1000 = ON
R1000 = FALSE . . . . . R1000 = OFF

PRECAUTIONS
• The bit device can not be assigned to constants other than 1, 0 and assigned to result of value
formula.

×: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 4
R1000 = DM1000 >= 500 . . . . . . . . Equal sign, inequality sign allowed (calculation

Assignment Statement
result is only formula of Boolean value)

● Operation 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 += _ 'DM2100.D = DM2100.D + TOD (SRA (EM1000, 8)*2)


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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-3


Assignment Statement

■Precautions on using assignment statement


SCRIPT SYNTAX AND

● When the type on right side is different from that on left side
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)
4 • Even if the types are different, different types .U,.S,.D,.L,.F can also be converted (precision drops
Assignment Statement

sometimes).

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.
"Setting method of warning level", page 2-53

● 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) (conversion
error). changes 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Assignment Statement

MEMO

SCRIPT SYNTAX AND


PRECAUTIONS
4

Assignment Statement

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-5


help_topic_start

Order of Prionity low


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.
4 Operators shall be programed with single byte character.
Point
Order of Prionity low

● Arithmetic operator
Arithmetic operator can return arithmetic operation result of 2 values.

Symbols 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 Exponentiation can be used for .F and .DF suffixes with KV-8000/7000 Series CPU units, with KV-
5000/3000 Series CPU units that have CPU function version 2.0 or higher and with KV Nano
Series base units.
*2 1-byte 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Order of Prionity low

● Logic operator

SCRIPT SYNTAX AND


In case bit relation operation for result of logical operation of 2 values and word relation operation
Boolean value (ON or OFF), a word value is returned.

PRECAUTIONS
Symbols 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)

OR*4
Calculate exclusive logical OR of 2 devices (bit
device relation, word device relation)
MR602 = R000 OR R001
4
Calculate exclusive logical OR of 2 devices (bit
XOR*4 MR603 = R000 XOR R001

Order of Prionity low


device relation, word device relation)

*4 1-byte space is required before and after symbol.

Point • To operate device (operate element), please specify the relation of the bit device
relation 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 performed 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.

Power ^
Order of prionity high
Minus sign −
Multiplication and division ∗, /
Arithmetic operator Remainder operation
MOD
Addition and subtraction +, −
String Concatenation +
Equal to, unequal to, =, <>,
Comparison Less than, more than, <, >,
operator Below, above <=, >=
Logic Not NOT
Logic AND AND
Logic operator
Logic OR OR
Order of prionity low Exclusive OR XOR

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-7


Order of Prionity low

● The priority between multiplication, division, addition, and subtraction


SCRIPT SYNTAX AND

When multiplication and division (or addition and subtraction) exist in programming of 1 formula
calculate according to the sequence (from left to right) of operators. Multiply divide is precedential in
PRECAUTIONS

case of multiply divide 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)

4
Operating sequence 4: result (3) - result (2) ..................final operation result

● Comparison operator priority


Order of Prionity low

The priority of all comparison operators is same. So, when multiple comparison operators are specified
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)


Compare 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)
Operating sequence 2: Compare result (1) and R001 logical AND ......result (2)
Operating sequence 3: Result (2) and R000 logical OR .....................result (3)
Operating 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 working 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
Operating sequence 6: Assign operation result to DM5000

Reference Complicated programming operation and immethodical operation, is unrelated to the


priority of operators, use "()" to clarify the programming operation step, improve
maintenance (reading).

4-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Order of Prionity low

Differences between assignments statements and compare operators

SCRIPT SYNTAX AND


Although the symbols (=) used by assignment statement and comparison operator are same, its
meanings (application methods) are different.

PRECAUTIONS
• (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
3
CASE 1
DM1000 = 100 Separately used as processing statement
4

Order of Prionity low


4 CASE 2
5 DM3000 = DM1000 + 5 Separately used as processing statement
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-9


help_topic_start

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


4 Conditional branch statements enable processing flow branching according to the specified condition.

Control statement Control statement


Control statement

(1) Execute branch control statement according to conditional formula

IF Conditional formula A THEN • If conditional formula A is TRUE,


processing statement B will be executed.
‫ޓޓޓ‬Processing statement B If 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


‫ޓޓޓ‬Processing statement B • If conditional formula A is TRUE,
processing statement B will be executed.
ELSE If conditional formula A is FALSE,
IF statement ‫ޓޓޓ‬Processing statement C processing 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 statement B processing statement B will be executed.
conditional formula A is FALSE, conditional
ELSE IF conditional formula 2THEN formula C is TRUE, processing statement
Processing statement D D is executed.
• 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
are same, processing statement B will be
Processing statement B
performed. If compare source and
CASE Conditional value C conditional value C are same, processing
SELECT statement D will be performed.
Processing statement D
statement
・・・・

• If compare source is not conditional value


A, C, etc., processing statement E will be
performed.
CASE ELSE
‫ޓޓޓ‬Processing statement E
END SELECT

master control statement

MC statement MC Conditional formula A THEN • If conditional formula A is TRUE,


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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

■Loop control statement

SCRIPT SYNTAX AND


Loop control statement is processed according to the specified conditional loop.

Control statement Control statement

PRECAUTIONS
The statement is a loop control statement for loop process before the conditional formula of the number specified is TRUE

FOR initial value


FOR
‫ޓޓޓ‬TO final value STEP incremental value • From initial value to final value, and also an
statement 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

WHILE conditional formula


4
WHILE
• Loop execution of processing statement

Control statement
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>


・・・

BREAK • After BREAK execution, loop control includ-


ing BREAK is ended irrespective condition.
statement BREAK
・・・

<loop processing statement>

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-11


Control statement

help_topic_start

IF ~ Statement (Conditional Branch (1))


SCRIPT SYNTAX AND

IF statement is the most simple conditional branch statement to identify processing or not according to
PRECAUTIONS

conditional formula.

IF ∼ THEN ∼ ELSE ∼ END IF


Basic format Format description
IF <Conditional formula> THEN If conditional formula is TRUE, processing statement

4
<Processing statement 1> Processing statement 1 will be executed.
END IF IF statement end

* Insert a single-byte space.


Control statement

This is a line feed symbol.

Example of format 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, 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.

Reference Nesting of IF statements (writing of IF statements in IF statements) can be up to 200 times


in the area script and up to 199 times in the box script.
"About control statements nesting", page 4-32

4-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


PRECAUTIONS
① (1) Identify "TRUE" or "FALSE" via
When condition is FALSE
(When conditional conditional formula.
Conditional equation is FALSE)
equation (2) If conditional formula to "TRUE",

(TRUE or FALSE)
FALSE processing statement following THEN will

be executed, and END IF executed.

4
When condition is TRUE TRUE
(When conditional
(3) if conditional formula is "FALSE", jump to
equation is TRUE)
END IF, any operation is not executed,
processing after jump to END IF.

Control statement
THEN processing ELSE processing
statement 1 statement 2

IF statement end

Programming example

Programming Script
IF (10 <= DM1000) AND (DM1000 <=_ 'if DM 1000 is more than 10

50) THEN or less than 50

FM1000.T ="within the range" 'specifies that the character string


is saved to FM 1000.T
END IF 'IF statement ends
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.

Reference 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.
"About Comments Function", page 2-69

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-13


Control statement

IF ~ ELSE Statement (Conditional Branch (2))


SCRIPT SYNTAX AND

The statement refers to a simple conditional branch statements dividing 1 conditional formula into 2
PRECAUTIONS

processing methods.

IF ∼ THEN ∼ ELSE ∼ END IF


Basic format Format description
IF <Conditional formula> THEN If conditional formula is TRUE,

4
<Processing statement 1> processing statement 1 will be executed.
ELSE If conditional formula is FALSE,
<Processing statement 2> processing statement 2 will be executed
Control statement

END IF IF statement end

* Insert a single-byte space.


This is a line feed symbol.

Example of format Explanation


IF R1000 = ON THEN 'If R1000 is ON,

DM2000 = 50 'The constant 50 is stored in the DM2000.

ELSE 'If R1000 is OFF,

DM2000 = 10 'The constant 10 is stored in the 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.

Reference IF statement nesting (program IF statement in IF statement), maximal upto 200 layers.
"About control statements nesting", page 4-32

4-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


PRECAUTIONS

(1) Identify "TRUE" or "FALSE" via
When condition is FALSE
(When conditional
conditional formula.
Conditional equation is FALSE) (2) If conditional formula is "TRUE",
equation ③
(TRUE or FALSE)
FALSE
processing statement 1 below THEN will
② be executed, and jump to END IF( middle
formula will be not executed).
4
When condition is TRUE TRUE
(When conditional
equation is TRUE) (3) If conditional formula is "FALSE", the
program between THEN ~ ELSE will be

Control statement
THEN processing ELSE processing
statement 1 statement 2
not executed, but processing statement 2
below ELSE will be executed.

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 ends


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 function", page 7-140
"COS function", page 7-142
"BMOV function", page 7-2

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-15


Control statement

IF ~ ELSE IF Statement (Conditional Branch (3))


SCRIPT SYNTAX AND

If the initial conditional formula is not met, it will be identified again according to the next conditional
PRECAUTIONS

formula. The conditional branch statement may have multiple conditions.

IF ∼ THEN ∼ ELSE IF ∼ END IF


Basic format Format description
IF <Conditional formula 1> THEN If conditional formula 1 is TRUE
<Processing statement 1>
4
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.
Control statement

ELSE IF <Conditional formula 2> THEN


If conditional formula 1.2 is FALSE, conditional formula 3 is TRUE,
※2


ELSE ※1 If all conditional formula are FALSE,
<Processing statement n> *1 processing statement n will be executed.
END IF IF statement ends here.

* Insert a single-byte space.


This is a line feed symbol.
*1 “[ ]”can be omitted.
*2 You can set any counter maximal value. There is no upper limit.

Example of format 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 different from IF statement, multiple lines are programmable, but it is not a
nesting structure.

4-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


PRECAUTIONS
① When condition is FALSE
(When conditional
Conditional equation 1 is FALSE)
equation 1 ③
(TRUE or FALSE) FALSE
② When condition is FALSE
TRUE (When conditional
Conditional equation 2 is FALSE)

4
When condition is TRUE equation 2 ⑤
(When conditional (TRUE or FALSE)
equation 1 is TRUE) FALSE
④ When condition is FALSE
(When conditional
TRUE

Control statement
Conditional equation 3 is FALSE)
THEN processing equation 3 ⑦
When condition is TRUE
statement 1 (TRUE or FALSE)
(When conditional FALSE
equation 2 is TRUE) ⑥
TRUE When condition is TRUE
(When conditional
THEN processing
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-17


Control statement

help_topic_start

SELECT CASE ~ Statement (Multi-branch control)


SCRIPT SYNTAX AND

The conditional branch statements can be processed according to the value stored in reference word
PRECAUTIONS

device.

SELECT CASE ∼
Basic format Format description
SELECT CASE Word device According to the value of word device, conditional branch

4
CASE Constant 1 *3 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,
Control statement

Processing statement 1 processing statement 2 will be performed.


CASE Constant 3 If constant 3 and word device value are same,
*2


CASE ELSE*1 If constant and word device value are not same,
Processing statement n *1
the processing statement will be performed.
END SELECT
SELECT statement ends here.

* Insert a single-byte space.


This is a line feed symbol.
*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.

Example of format Explanation


SELECT 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 written 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


(1) The declaration acts as the identification

PRECAUTIONS
Comparison source reference value of conditional value.
(word device) (2) Compare conditional value 1 and
(1)
compare source, if "conditional value 1 =
When comparison source compare source" is TRUE, processing
equals conditional value 1 statement 1 will be executed. After
CASE

4
conditional Processing executing processing statement 1, jump

value 1 statement 1 to ENDSELECT.
③ (3) If "conditional value 1 = compare source"

Control statement
When comparison is FALSE, transfer to compare the next
source ≠ conditional
value 1 conditional value.
When comparison source
equals conditional value 2 (4) Compare conditional value 2 and
CASE compare source, if "conditional value 2 =
conditional Processing
④ compare source" is TRUE, processing
value 2 statement 2
⑤ statement 2 will be executed. Execute
When comparison processing statement 2, then, jump to
source ≠ conditional END SELECT.
value 2
When comparison source (5) If "conditional value 2 = compare source"
equals conditional value 3
CASE is FALSE, transfer to compare the next
conditional Processing conditional value.

value 3 statement 3
(6) Compare conditional value 3 and

compare source, if "conditional value 3 =
When comparison
source ≠ conditional compare source" is TRUE, processing
value 3 statement 3 will be executed. Execute
processing statement 3, then, jump to
CASE ELSE processing
statement 4 END SELECT.
(7) If "conditional value 3 = compare source"
is FALSE, perform processing statement 4.
SELECT statement end

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-19


Control statement

Reference script example


SCRIPT SYNTAX AND

• Count the number of work pieces dropped out from belt conveyer. When work piece falls into the
case, "1" is added to Good Counter (DM1000).
PRECAUTIONS

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]

4
IF LDP(R000) = ON THEN 'If workpiece drop sensor ( R000) is ON,
DM1000 += 1 'Good counter (DM1000) plus _1
END IF
Control statement

SELECT CASE DM1000 'Compare source is DM1000


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
discharging
LED column

Sensor for
workpieces fall NG

OK OK OK
100pcs 100pcs 100pcs

4-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Point If the selected constants are multiple, the processing statement written on the

SCRIPT SYNTAX AND


upper line is firstly executed; the processing statement written later will be not
executed.

PRECAUTIONS
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,

4
Processing statement 2
CASE IS >= 15 'If DM1000 value is more than 15

Processing statement 3

Control statement
CASE ELSE 'If the value of DM1000 is something other
than the above,
Processing statement 4
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 executed,
END SELECT is jumped to, and processing statement 3 is not executed.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-21


Control statement

help_topic_start

MC ~ MCR Statement (Master control)


SCRIPT SYNTAX AND

The script is used to program Master Control.


PRECAUTIONS

For action of Master Control, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual".

MC ∼ THEN ∼ MCR
Basic format Format description
MC <MC Execution condition > THEN
4
If MC execution condition is TRUE,
master control processing will be conducted.
<Processing statement 1> Execute processing statement.
Control statement

MCR If MC execution condition is FALSE,


processing statement will be executed in OFF status.

* Insert a single-byte space.


This is a line feed symbol.

Example of format Explanation


MC R1000 THEN 'If R1000 is ON, Master Control processing will be conducted.

R500 = 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", MC, MCR command.

Tip
• If the result of the MC execution condition is a bit (return Boolean) expression, it can be used in any
expression.
• 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


PRECAUTIONS

(1) Identify "TRUE" or "FALSE" via MC
execution condition, determine MC to
MC execution FALSE
MCR processing method.
condition
③ (2) If execution condition is "TRUE", processing
(TRUE or FALSE)
statement below THEN will be executed.

4

(3) If conditional formula is "FALSE", will be
TRUE

When execution condition


executed after processing statement below
When execution condition
is TRUE (when execution is FALSE (when execution THEN is set to OFF.

Control statement
condition is TRUE) condition is FALSE)

Execute THEN Setup processing


processing statement statement as OFF
then execute

MC to MCR statement end

Point 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-23


Control statement

help_topic_start

FOR ~ NEXT Statement ( specified loop control times)


SCRIPT SYNTAX AND

According to loop condition, the control statement processing the number of statement executed is
PRECAUTIONS

determined.

FOR ∼ NEXT
Basic format

1 FOR <Word device>=<Initial value > TO <Final value >[ STEP <incremental value >] *1

4
2 <Processing statement>
3 NEXT
Control statement

Format description
1 ・ Determine 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 not added)
2 ・The processing statement will be executed before word device exceeds final value.
3 ・Plus incremental value to word device.

*1 Programming in [ ] can be omitted. If omitted, will be executed as STEP 1.


Insert a single-byte space.
This is a line feed symbol.

Example of format 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 ~

Tip
Multiple elements are programed on the 1st line of format example. It shall be described separately.

Row 1: FOR DM1000=0 TO 100 STEP 5


④ ① ② ③
(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 ~ NEXT statement.
(2) Specify the final value. FOR ~ 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.

Reference According to constant symbol of STEP program, automatically identify "final value" and
"word device final value".
例) FOR DM1100 = 100 TO 0 STEP - 5
Subtract 5 from 100, the value stored in DM1100 before 0.

4-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Processing flow

SCRIPT SYNTAX AND


PRECAUTIONS
(1) Assign the initial value to word device.
Evaluate default value (2) Set final value indicating the end of loop
to FOR word device process. Besides, set the increment
(initialization process)
value added on the value of word device.
② (3) Identify whether the value of word device
Setup final and addition is less than final value.
value (increment value)
of word device
(4) If (3) condition is "TRUE", processing 4
statement will be executed.

Control statement
③ (5) If " FALSE", loop process statement will
be terminated.
Value of word (6) Plus incremental value to the value of
FALSE
device final
word device, and return (3).
⑤ value (TRUE or FALSE)

TRUE

Execute processing statement


NEXT
Add increment
to word device

Next

Point 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

Reference FOR ~ NEXT NEXT statement will execute following processing.


• Specify word device +=incremental value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-25


Control statement

Precautions on Using FOR ~ NEXT statement


SCRIPT SYNTAX AND

● The range that can be specified with STEP


PRECAUTIONS

In programming of FOR ~ 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.

4 ● When specifying single precision floating point type constant with STEP
The constant with decimal point can be specified with incremental value specified by STEP, but, shall be
Control statement

noted.

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~NEXT statements are imperatively ended


Before meeting condition set by FOR ~ 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

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 ends

NEXT 'Add incremental value, return FOR ~

For details please refer to "BREAK Processing", page 4-31.

Point 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 time out occurs during program execution (infinite
loop is not detected as error during conversion).
"Loop control statement and processing time", page 4-35

Reference Up to 100 layers are available for nesting of FOR ~ NEXT statement.
"About control statements nesting", page 4-32

4-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

help_topic_start

WHILE Statement (pre-judge loop control)

SCRIPT SYNTAX AND


When loop condition is "TRUE", execute control statement of loop process.

PRECAUTIONS
WHILE ∼ 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).
4
* Insert a single-byte space.

Control statement
This is a line feed symbol.
*1 If the conditional formula is FALSE, loop control is then ended.

Example of format Explanation


WHILE DM1000 < 100 'If DM1000 value is less than 100, *2

DM1000 += 5 'Add 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.

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 WHILE ~ END WHILE,
capable of programming among lines if required.

Reference In loop control statement of WHILE statement/DO ~ 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-27


Control statement

Processing flow
SCRIPT SYNTAX AND
PRECAUTIONS

① (1) Identify " TRUE " or "FALSE" with WHILE


execution condition, determine processing
OFF
WHILE execution method of WHILE ~ END WHILE.
③ condition (TRUE or FALSE)
(2) If execution condition is "TRUE", process-
② ing statement will be executed, and return

4 When execution condition


TRUE
When execution condition
(1) (WHILE statement start).
(3) If conditional formula is "FALSE" END
is false (when execution is true (when execution
Control statement

condition is FALSE) condition is TRUE) WHILE statement will enter the next step.

Execute processing
statement

END WHILE

WHILE statement end

Next

Programming example

● When WHILE statement is imperatively terminated


In WHILE~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),
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 ends

DM2000 += 1 'Add 1 to DM2000.

END WHILE 'Return WHILE ~.

For details please refer to "BREAK Processing", page 4-31.

Point 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 time out occurs during program execution (infinite
loop is not detected as error during conversion).
"Loop control statement and processing time", page 4-35

4-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

help_topic_start

DO ~ UNTIL Statement (Post Identification Loop Control)

SCRIPT SYNTAX AND


When loop condition is "FALSE", execute control statement of loop process.

PRECAUTIONS
DO ∼ UNTIL
Basic format Format description
DO Perform loop control
<Processing statement> Perform Processing statement

4
UNTIL <conditional formula> If conditional formula is FALSE, return to statement
start (DO). *1

* Insert a single-byte space.

Control statement
This is a line feed symbol.
*1 If the conditional formula is FALSE, loop control is then ended.

Example of format Explanation


DO 'process at the start of next step.

DM1000 += 5 'Add 5 to DM1000.


'If DM1000 value is not above 100, return to sentence leading (DO).*
UNTIL DM1000 >= 100 2

*2 If DM1000 value is above 100, processing statement will be not executed, the execution will start
from the next line of UNTIL.

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 DO ~ UNTIL, capable of
programming among lines if required.
• The control statements that imply the same actions as those implied by DO ~ UNTIL statement can
use WHILE statement.
• DO ~ UNTIL statement is firstly processed, then conditional formula identified. loop identification
condition FALSE .
For details please refer to "WHILE Statement (pre-judge loop control)", page 4-27.

Point In loop control statement of WHILE statement/DO ~ 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-29


Control statement

Processing flow
SCRIPT SYNTAX AND
PRECAUTIONS


(1) Execute processing statement.
Execute processing
statement
(2) Identify "TRUE" or "FALSE" via DO execu-

tion condition, determine DO to UNTIL
processing method.
4 TRUE

DO execution
condition (TRUE or FALSE) (3) If conditional formula is "FALSE", return to
(1) (DO ~ UNTIL statement leading).
Control statement


FALSE
(4) If conditional formula is "TRUE", will enter
When execution condition When execution condition next step.
is TRUE (when execution is FALSE (when execution
condition is TRUE) condition is FALSE)

DO ~ 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


Sequence different 1. Identification of conditional formula 1. Execute loop process statement
(TRUE or FALSE) 2. Identification of conditional formula
2. Execute loop process statement (TRUE or FALSE)
3. Return to sentence leading 3. Return to sentence leading
Execute loop process perform repeatedly when condition perform repeatedly when condition
statement is"TRUE" is"FALSE"

For details please refer to "WHILE Statement (pre-judge loop control)", page 4-27.

WHILE ・・・・ primary loop control statement


statement (primary processing statement will be not executed according to conditions)
DO ・・・・ post identification loop control statement
statement (1 processing statement must be performed)

Point 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 time out 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

help_topic_start

BREAK Processing

SCRIPT SYNTAX AND


It is used in force termination of loop control (exit from loop).

PRECAUTIONS
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


4
* This is a line feed symbol.

Control statement
*1 BREAK must be programmed in loop process statement.

Example of format Explanation


FOR DM1000 = 0 TO 50 STEP 2 'DM1000 from 0 to 50, loop.

DM2000 += 5 'Add 5 to DM2000.

IF DM2000 > 70 THEN 'If DM2000 value exceeds 70,

BREAK 'Imperatively terminate loop control (FOR ~ NEXT statement).

END IF 'IF statement end.

NEXT 'Plus 5 to DM1000, return to sentence leading of FOR statement.

* Except FOR ~ NEXT, loop process statement can be also used in WHILE statement, DO ~ UNTIL statement.

Point 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 'FOR statement (1)

FOR DM2000 = 1 TO 100 STEP 3 'FOR statement (2)

FOR DM3000 = 1 TO 100 STEP 3 'FOR statement (3)

DM4000 = DM1000 + DM2000 + DM3000 'Processing statement


IF DM4000 > 100 THEN 'BREAK Execution condition

BREAK
END IF
NEXT 'When Break execute, 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-31


Control statement

Precautions on Using Control Statement


SCRIPT SYNTAX AND

About control statements nesting


PRECAUTIONS

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


4 Nesting means that a case is embedded into another case, other loop control statement is programmed
in a loop control statement, thus forming a multi-layer control block. In the following example, FOR
Control statement

statement (2) is nested in FOR statement (1), and then 3 layers of FOR statement (3) are nested in it.

"nest programing example"

FOR <value of word device (1)> TO <end value> ' FOR文①

Processing statement
FOR <value of word device (2)> TO <end value FOR文②

Processing statement

1 layer
2 layer
FOR <value of word device (3)> TO <end value> FOR文③

3 layer
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, maximal100layers can be nested.
• WHILE statement, DO statement are limited on separate layer, maximal199layers 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~END IF or FOR~NEXT control statements, etc. is called control
block.

Point 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Point Programming cannot be made under the following loop control statement or

SCRIPT SYNTAX AND


conditional branch or loop control statement and conditional branch statement
cross.

PRECAUTIONS
[[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>


Processing statement (2)
'Control statement (2)
4

Control statement
WHILE <condition equation > 'Control statement (3)

Processing statement (3)

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-33


Control statement

■Actual nesting actions


SCRIPT SYNTAX AND

Establish the following processing programs.


PRECAUTIONS

例 The 3-layer nesting using loop control statement (FOR statement, WHILE statement, do
statement) is produced to calculate the number of actual processing.
Programming Script
DM1000 = 0 ' Clear the counter for the number of
FOR DM2000 = 1 TO 10 'processing.
'DM2000 loop s from 1 to 10

4 '--- FOR loop :10 times


DM3000 = 0 'WHILE loop counter is reset
Control statement

'Loop when DM3000 is


WHILE DM3000 < 10 'less than 10
'--- WHILE loop :10 times
DM3000 += 1 'WHILE loop counter plus 1
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
UNTIL DM4000 >= 10 'processing
'Until DM4000 exceeds 10
END WHILE 'Loop
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 processing (DM0 1000).
When executing the program, 10 FOR loop s x 10 WHILE loop s x 10 DO loops take place,
execute 1000 times of the most deep nesting processing.

4-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

Loop control statement and processing time

SCRIPT SYNTAX AND


With the loop control statement (FOR ~ NEXT, WHILE, DO), loop process programming can be easily
performed by KV script. Loop processing, however, should be performed within the allowed scanning

PRECAUTIONS
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, 1 to 200,000.
Programming Script
DM1000.D = 0
4

Control statement
DM1002.D = 0
WHILE DM1000.D < 200000 '(1) to (2) processing shall be repeat

'for 200,000 times.


DM1000.D += 1 '①
DM1002.D = DM1002.D + DM1000.D ' ②
END WHILE
For details please refer to "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 the application environment.

In this case, there is no problem for 1 loop processing whereas for 200,000 times of loop processing,
the total processing time is within allowed scanning time (over 300ms for KV-8000/7500/7300/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.

Reference When Ladder exceeds allowed scanning time (KV-8000/7500/7300/5500/5000/3000/1000


or KV Nano Series reaches 300ms), scanning time overflow may occur (error No.30)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-35


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

To avoid scanning timeout, changes should be made to the program in order to execute several
scanning ( or scanning every time) processes.
PRECAUTIONS

Example) Calculation 1+2+3+……200,000, sum 1~200,000.


(avoid scanning time out in programming)
Programming Script
IF R1004 = OFF THEN

4
SET(R1004) 'Operation in progress
DM1000.D = 0 'DM1000.D initialization
DM1002.D = 0 'DM1002.D initialization
Control statement

END IF
IF R1004 AND DM1000.D < 200000 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).
For details please refer to "IF ~ Statement (Conditional Branch (1))", page 4-12.

4-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Control statement

■About infinite loop

SCRIPT SYNTAX AND


The situation whereby that loop process cannot ended is called infinite loop.
[inexecutable programming]

PRECAUTIONS
There is no programming for ending repeat
WHILE MR1000 = OFF control statement in progress statement.
DM1001 += 1 NO end since no programming to
MR1000 become ON.
DM1000 = DM1000 + DM1001

4
END WHILE

Add force end condition

Control statement
Infinite loop

Programming Script WHILE MR1000 = OFF 'If MR1000 is ON, loop process will be ended
DM1001 += 1
DM1000 = DM1000 + DM1001
IF DM1000 > 1000 THEN
Add end condition of repeat control
BREAK statement.
END IF Execute BREAK after DM1000 changed to
1000 above, end repeat control.
END WHILE
"BREAK Processing", page 4-31

Reference 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 ende
DM1001 += 1
DM1000 = DM1000 + DM1001 'BREAK is executed after the timer contact
IF T001.B THEN T001 is opened.
BREAK Execute no processing statement
because of without change to
END IF contact of timer.
END WHILE
"TMR function", page 5-22

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-37


help_topic_start
Precautions on Script Programming

Status of Hold Control Bit Device


SCRIPT SYNTAX AND

In KV script, the program changing the status of the previous bit device can be conducted (assign ON /
PRECAUTIONS

OFF).

Example)Turn MR1000 ON (assign ON).


[Box Script]
Programming Script
CR2008

4
MR1000 = ON

ON 1 scan
at operation start
Precautions on Script Programming

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.

Reference When you want to clear the value of the held bit data or word data, the following methods
can be used.
• Reset by RES function (for bit data)
• Assign 0 with an assignment statement (for word data)
• Select the device from "Debug (D)" → "Clear all PLC devices (L)" in the menu and
execute the clear operation.

4-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Precautions on Script Programming

■Execution timing

SCRIPT SYNTAX AND


Scan

PRECAUTIONS
Script execute ON

OFF
ON
OUT command
Bit device for holding output
OFF

■How to use
"MR1000 = ON" remains ON, so to turn it OFF, execute "MR1000 = OFF" or RES (MR1000).
4
Example)when R2000 (execute condition) is ON, MR1000 is turned to ON. When R2000 is not ON

Precautions on Script Programming


(OFF), MR1000 is turned to OFF.
Programming Script

IF R2000 = ON THEN
MR1000 = ON
+ ELSE
MR1000 = OFF
END IF

LD NCJ
R2000
#2000

CR2002 MR1000

Always ON

CR2002 CJ
#2001
Always ON

LABEL
#2000

CR2003 MR1000

Always OFF

LABEL
#2001

Reference The status of the bit data can also be controlled by the SET / RES function.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-39


Precautions on Script Programming

Precautions for using the timer / counter


SCRIPT SYNTAX AND

Timer / counter processes the current value and contact status with the same device number.
PRECAUTIONS

The contact status can be processed as .B (bit type) like other bit data (.B suffix can also be omitted).
The current value can be processed as .D (32-bit unsigned) like other word data, but the .D suffix must
be specified.
"Timer (contact) T", page 3-31
"Counter (contact) C", page 3-33

4 ● Timer/ Counter current value reading


Precautions on Script Programming

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

Point • 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 the compatible model (CPU unit used) is KV-1000, the same device number
cannot be used for the timer and counter.
Example) when T100( timer) has been used, C100 cannot be used (counter)

4-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Precautions on Script Programming

● Timer/ Counter contact

SCRIPT SYNTAX AND


Programming Script
SET(T100.B, MR1000) 'When timer contact T 100 is ON, change
'MR1000 to ON (hold).

PRECAUTIONS
SET(C200.B = OFF, MR1001) 'When counter contact C 200 is OFF, MR1001
'changes to ON (hold).

LD
T100 MR1000

4
SET
Operation destination device

Precautions on Script Programming


C200 MR1001
SET

Reference The default type of timer / counter is bit type.

■Precautions 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 condition of the timer function can omit programming, but it cannot be reset at
this time, and continues to operate as a normal execution type function.

Programming Script TMR(T100,500) Programming with execution


Ladder development
condition omitted
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-41


Precautions on Script Programming

■Precautions about use of timer function in Box Script and IF statement


SCRIPT SYNTAX AND

Box Script and IF statement are converted to NCJ command to LABEL.


When execution condition of Box Script and IF statement is FALSE, jumping is performed between NCJ
PRECAUTIONS

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.

IF MR2000 = ON THEN Program in IF statement


4
Programming Script

TMR (MR1000 = ON, T101, 500)


END IF
Precautions on Script Programming

LD Notice
MR2000 NCJ
#2000 If condition execution of statement is
FALSE, statement processed via N CJ
MR1000 #500
T101 command is jumped.In this case, keep the
status of every contact(the status before N
LABEL CJ jump), when execution condition of
#2000 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
① ③No statement
scan processing
of
ON IF statement
Execution condition
for IF statement
(MR 2000) OFF ②
Perform condition ON
for timer function
(MR1000) OFF

ON
Status for
timer contact (T101)
OFF

Timer current value 500


(timeup)


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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Precautions 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


The change for programming script are as follows.*1

PRECAUTIONS
Programming Script IF MR2000 = ON THEN
TMR (MR1000 = ON, T101, 500) Programming in IF statement
ELSE
RES (T101) Reset timer device.

END IF
Ladder development
MR2000 NCJ
4
#2000

Precautions on Script Programming


MR1000 #500
T101

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 hen 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, refer to the KV-8000 / 7000/5000/3000/1000 Series, KV Nano 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-43


Precautions on Script Programming

Operation description
① ③ ⑤
Execution condition No scan processing
SCRIPT SYNTAX AND

ON
for dialog script statement of dialog script
(MR 2000)
OFF

PRECAUTIONS

ON
Perform condition for
timer function (MR1000)
OFF

ON
Status for timer
contact (T101)
OFF

Timer current value 500

4 ④
(timeup)
Precautions on Script Programming


Restart IF statement

(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 condi-
tion 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 condition
MR2000 T101
RES
Execution condition

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, refer to the KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series Instruction
Reference Manual.

4-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Precautions on Script Programming

● MC~MCR When using timer / counter function

SCRIPT SYNTAX AND


TMR(T1 , 10)
CNT(C3 , 100 , R1000)

PRECAUTIONS
MCR

Ladder development

Timer/Counter stop (clear) when execution condition is false

MR1000 MC
4
Execution condition

Precautions on Script Programming


CR2002 #10
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 ~ MCR Statement (Master control)", page 4-22.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 4-45


Precautions on Script Programming

MEMO
SCRIPT SYNTAX AND
PRECAUTIONS

4
Precautions on Script Programming

4-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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 functions.............................................................. 5-36

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-1


Co

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


LDP

LDP Rising edge differential of specified bit

Load pulse

Return value*1 = LDP (Rising edge detection target)


Argument/Return Available suffixes Const Device / For
Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B*3*4 .T #/$ Variable mula


S Rising edge
Specifies the target to detect the
detection - - - - - - .B - - ○ ○
rising edge.
target*2
R Return value Specifies the target to operate. - - - - - - .B - - ○ -
*1 The return value can be omitted. When omitted, the operation result is stored in a work device/
work memory.
5 *2
*3
When word data is specified as the rising edge detection target, the state of the LSB is detected.
Direct I/O Relays (DR) can be specified when KV-8000/7500/7300/5500/5000/3000 or KV Nano
Contact function

Series is used.
*4 When the corresponding model is KV-8000 / 7500/7300/5500/5000/3000 and KV Nano series,
the bit position of word data can be specified.

Description of Operation
When the rising edge of S (change from OFF to ON) is detected, R is turned ON for one scan.
"About operation flag (CR2009 to CR2012)", page 1-18
For more information, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series
Instruction Reference Manual", "Contact Instruction".

● Example of format
MR2000 = LDP ( MR1000 )
MR1000 MR2000

Device for rising Return value
edge inspection

Point Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", page 2-13

5-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Example program
● When using operation formulas

MR2000 = LDP ( DM1000 + DM1001 = 1000 )

BASIC FUNCTIONS
Programmed Script

Operation Description 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).

● When combining with other functions

BMOV ( LDP ( R3000 ), DM1000, DM2000, 10 )


5
Programmed Script

Operation Description The content of ten words starting from DM1000 is block-moved to ten words starting from
DM2000 only at the scan where the rising edge (OFF ->ON) of R3000 is detected.

Contact function
Ladder conversion R3000 BMOV
↑ DM1000 DM2000 #10
Device for rising
edge inspection Conversion Conversion
source device destination device

Reference Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"BMOV function", page 7-2
The KV script is converted to a ladder program before execution. When confirming the
conversion content, please refer to "New Frame Script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-3


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LDF

LDF Falling edge differential of specified bit

Load pulse fall

Return value*1 = LDF (Falling edge detection target)


Argument/Return Available suffixes Const Device / For
Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B*3*4 .T #/$ Variable mula


S Falling edge
Specifies the target to detect the
detection - - - - - - .B - - ○ ○
falling edge.
target*2
R Return value Specifies the target to operate. - - - - - - .B - - ○ -
*1 The return value can be omitted. When omitted, the operation result is stored in a work device/
work memory.
5 *2
*3
When word data is specified as the falling edge detection target, the state of the LSB is detected.
Direct I/O Relays (DR) can be specified when KV-8000/7500/7300/5500/5000/3000 or KV Nano
Contact function

Series is used.
*4 When the corresponding model is KV-8000 / 7500/7300/5500/5000/3000 and KV Nano series,
the bit position of word data can be specified.

Description of Operation
When the falling edge of S (change from ON to OFF) is detected, R is turned ON for one scan.
"About operation flag (CR2009 to CR2012)", page 1-18
For more information, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series
Instruction Reference Manual", "Contact Instruction".

● Example of format
MR2000 = LDF ( MR1000 )
MR1000 MR2000

Device for falling Return value
edge inspection

Point Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", page 2-13

5-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Example program
● When using operation formulas

MR2000 = LDF ( DM1000 + DM1001 = 1000 )

BASIC FUNCTIONS
Programmed Script

Operation Description 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).

● When combining with other functions

Programmed Script
BMOV ( LDF ( R3000 ), DM1000, DM2000, 10 )
Operation Description The content of ten words starting from DM1000 is block-moved to ten words starting from
DM2000 only at the scan where the rising edge (ON→OFF) of R3000 is detected.
5

Contact function
Ladder conversion R3000 BMOV
↓ DM1000 DM2000 #10
Device for falling
edge inspection Move Move
source device destination device

Reference Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"BMOV function", page 7-2
The KV script is converted to a ladder program before execution. When confirming the
conversion content, please refer to "New Frame Script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-5


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LDPB

LDPB Rising edge differential bar of specified bit

Load pulse bar

Return value*1 = LDPB (Rising edge detection target)


Argument/Return Available suffixes Const Device / For
Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B*3*4 .T #/$ Variable mula


S Rising edge
Specifies the target to detect the
detection - - - - - - .B - - ○ ○
rising edge.
target*2
R Return value Specifies the target to operate. - - - - - - .B - - ○ -
*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 When word data is specified as the rising edge detection target, the state of the LSB is detected.
5 *3
*4
Setable between direct I/O Relays (DR).
The bit position of word data can be specified.
Contact function

Point The KV-1000 series does not support the LDPB function.

Description of Operation
When the rising edge of S (change from OFF to ON) is detected, R is turned ON only within
one scan.
"About operation flag (CR2009 to CR2012)", page 1-18
For more information, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series
Instruction Reference Manual", "Contact Instruction".

● Example of format
MR2000 = LDPB ( MR1000 )
MR1000 MR2000

Device for rising Return value
edge inspection

Point Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", page 2-13

5-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LDFB

LDFB Falling edge differential bar of specified bit

Load pulse bar

Return value*1 = LDFB (Falling edge detection target)


Argument/Return Available suffixes Const Device / For
Description

BASIC FUNCTIONS
Value .U .S .D .L .F .B*3*4 .T #/$ Variable mula
S Falling edge
Specifies the target to detect the falling
detection - - - - - .B - - ○ ○
edge.
target*2
R Return value Specifies the target to operate. - - - - - .B - - ○ -
*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 When word data is specified as the falling edge detection target, the state of the LSB is detected.
*3
*4
Setable between direct I/O Relays (DR).
The bit position of word data can be specified.
5

Contact function
Point The KV-1000 series does not support the LDFB function.

Description of Operation
When the rising edge of S (change from OFF to ON) is detected, R is turned OFF for one scan.
"About operation flag (CR2009 to CR2012)", page 1-18
For more information, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series
Instruction Reference Manual", "Contact Instruction".

● Example of format
MR2000 = LDFB ( MR1000 )
MR1000 MR2000

Device for falling Return value
edge inspection

Point Attention is required when using this function in box scripts or IF statements.
"Precautions When Using Box Script", page 2-13

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-7


Bit

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


BLD

BLD Specified bit information of word data

Bit load

Return value*1 = BLD (Read target, bit position)


Argument/Return Available suffixes Const Device / For
BASIC FUNCTIONS

Description
Value .U .S .D .L .F .DF .B*3*4 .T #/$ Variable mula
Specifies the target to read the bit
S Read target*2 .U .U .D .D - - - - - ○ ○
status.
Specifies the bit position to
n Bit position determine the target ON/OFF. (16- .U .U .U .U - - - - ○ ○ ○
bit binary data)
R Return value Specifies the target to operate. - - - - - - .B - - ○ -

5 *1 The return value can be omitted. When omitted, the operation result is stored in a work device/
work memory.
Bit contact function

*2 When bit data is specified to S , the bit at the specified bit + n position is specified.
Operation is normal even when relays straddle channels.
*3 The value of the bit position is specified as 0 to 15 when the suffix of the read target is .U, and 0
to 31 when it is .D.
*4 Direct I/O Relays (DR) can be specified when KV-8000/7500/7300/5500/5000/3000 or KV Nano
Series is used.
*5 When the model is KV-8000 / 7500/7300/5500/5000/3000 and KV Nano series, the bit position of
word data can be specified.

Description of Operation
The ON/OFF status of the bit position specified by n of S is 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 0bit


n bit 1bit

ON
S bit of n
OFF

ON
BLD function
OFF

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series Instruction
Reference Manual", "Position Contact Instruction".

● Example of format
R1000 = BLD ( DM1000, 10 )
DM1000 R1000
B
#10 Return value
Read device

5-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point When a value other than a constant is written in n , if the operation result
exceeds the range corresponding to the S suffix (0 to 15 for .U, 0 to 31 for .D),
the result is as follows.
When the suffix of S is .U: The values of the lower 4 bits of n are used.

BASIC FUNCTIONS
When the suffix of S is .D: The values of the lower 5 bits of n are used.

Example program
● When specifying bit data

Programmed Script

Operation Description
R1000 = BLD ( MR2009.U, 10 )
R1000 is turned ON when bit 10 (MR2103) of MR2009.U is ON.
5

Bit contact function


● When combining with other functions

Programmed Script
TMR ( BLD ( DM1000, 5 ), T001, 10 )
Operation Description Timer (T1) is started when bit 5 of DM1000 is ON.
Ladder conversion
DM1000 #10
B T1
#5
Read device

Reference Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TMR function", page 5-22
The KV script is converted to a ladder program before execution. When confirming the
conversion content, please refer to "New Frame Script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-9


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BLDB

BLDB Specified bit information bar of word data

Bit load bar

Return value*1 = BLDB (Read target, bit position)


Argument/Return Available suffixes Const Device / For
BASIC FUNCTIONS

Description
Value .U .S .D .L .F .DF .B*3*4 .T #/$ Variable mula
Specifies the target to read the bit
S Read target*2 .U .U .D .D - - - - - ○ ○
status.
Specifies the bit position to
n Bit position determine the target ON/OFF. (16- .U .U .U .U - - - - ○ ○ ○
bit binary data)
R Return value Specifies the target to operate. - - - - - - .B - - ○ -

5 *1 The return value can be omitted. When omitted, the operation result is stored to a work device /
work memory.
Bit contact function

*2 When bit data is specified to S , the bit at the specified bit + n position is specified.
Operation is normal even when relays straddle channels.
*3 The value of the bit position is specified as 0 to 15 when the suffix of the read target is .U, and 0
to 31 when it is .D.
*4 Direct I/O Relays (DR) can be specified when KV-8000/7500/7300/5500/5000/3000 or KV Nano
Series is used.
*5 When the model is KV-8000 / 7500/7300/5500/5000/3000 and KV Nano series, the bit position of
word data can be specified.

Description of Operation
The ON/OFF state of Bit n of S is inverted and 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 0bit


n bit 1bit

ON
S bit of n
OFF

ON
BLDB function
OFF

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000 / 7000/5000/3000/1000 Series, KV Nano Series Command
Reference Manual", "Position Contact Command".

● Example of format
R1000 = BLDB ( DM1000, 10 )
DM1000 R1000
B
#10 Return value
Read device

5-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point When a value other than a constant is written in n , if the operation result
exceeds the range corresponding to the S suffix (0 to 15 for .U, 0 to 31 for .D),
the result is as follows.
When the suffix of S is .U: The values of the lower 4 bits of n are used.

BASIC FUNCTIONS
When the suffix of S is .D: The values of the lower 5 bits of n are used.

Example program
● When the read object is specified as bit data

Programmed Script

Operation Description
R1000 = BLDB ( MR2009.U, 10 )
R1000 is turned ON when bit 10 (MR2103) of MR2009.U is OFF.
5

Bit contact function


● When combining with other functions

Programmed Script
TMR ( BLDB ( DM1000, 5 ), T1, 10 )
Operation Description Timer (T1) is started when bit 5 of DM1000 is OFF.
Ladder conversion
DM1000 #10
B T1
#5
Read device

Reference Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TMR function", page 5-22
The KV script is converted to a ladder program before execution. When confirming the
conversion content, please refer to "New Frame Script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-11


Ou

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


SET

SET Output ON of specified bit

Setting

SET ([execution condition,]*1 Destination device)

Argument/Return Applicable Suffix Const Device / For


Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B*2*3 .T #/$ Variable mula


Specifies the target to be held after
D Object - - - - - - .B - - ○ -
ON.
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 Direct I/O Relays (DR) can be specified when PCL KV-8000/7500/7300/5500/5000/3000 or KV
5 Nano Series is used.
*3 Devices for bit position of word device can be specified when KV-8000/7500/7300/5500/5000/
Output function

3000 or KV Nano Series is used.

Description of Operation
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. (The ON target is turned OFF
with the RES function)
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see KV-5500/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual, "Output Instructions."
"RES function", page 5-13

● Example of format
SET ( R3000, MR1000 )
R3000 MR1000
SET
Execution condition Destination device

Sample Program
● When specifying a word device to the destination device

Programmed Script
SET ( MR1000, DM2000.B )
Operation Description When MR1001 is ON, the LSB of DM2000 is set to OFF.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

5-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RES

RES Output OFF of specified bit

Reset

RES ([Execution condition,] *1Destination device)


Argument/Return Applicable Suffix Const Device / For
Description

BASIC FUNCTIONS
Value .U .S .D .L .F .DF .B*2*3 .T #/$ Variable mula
Specifies the target to be turned
D Object - - - - - - .B - - ○ -
OFF.
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 Direct I/O Relays (DR) can be specified when PCL KV-8000/7500/7300/5500/5000/3000 or KV
Nano Series is used. 5
*3 Devices for bit position of word device can be specified when KV-8000/7500/7300/5500/5000/

Output function
3000 or KV Nano Series is used.

Description of Operation
When the execution condition is TRUE, D is turned OFF. (Targets turned ON with the SET function
are turned OFF with the RES function)
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see KV-5500/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual, "Output Instructions."
"SET function", page 5-12

● Example of format
RES ( R3000, MR1000 )
R3000 MR1000
RES
Execution condition Destination device

Sample Program
● When specifying a word device to the destination device

Programmed Script
RES ( MR1001, DM2000.B )
Operation Description When MR1001 is ON, the LSB of DM2000 is set to OFF.

● When resetting the timer

Programmed Script
RES ( MR1002, T100 )
Operation Description When MR1002 is ON, the current value of T100 is changed to the same value as the
setting value.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-13


Bit

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


BOUT

BOUT Specified bit output of word device

Bit output

BOUT ([Execution condition,]*1 Destination device, bit position)

Argument/Return Applicable Suffix Const Device / For


Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the target to output the input
D Object*2 .U .U .D .D - - - - - ○ -
status.
n bit position*3 Specifies the bit position to output. .U .U .U .U - - - - ○ ○ ○
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is
specified.)
5 *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
Bit output function

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.

Description of Operation
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 bit
16 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Bit Output Instructions."

● Example of format
• D :16-bit instruction
BOUT ( MR1000, DM2000, 12 )
MR1000 DM2000
B
Execution condition #12
Target device
• D :32-bit instruction
BOUT ( MR1000 = OFF, DM2100.D, 28 )
MR1000 DM2100
B.D
Execution condition #28
Target device

5-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point 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 n are used.

BASIC FUNCTIONS
When the suffix of D is .D: The values of the lower 5 bits of n are used.

Sample Program
● When specifying a bit device to the destination device

Programmed Script

Operation Description
BOUT ( DM1000 <= 100, MR2002.U, 14 )
When DM1000 is 100 or less, bit 14 (MR2100) of MR2002.U is turned ON, and when
5
DM1000 is greater than 100, bit 14 is turned OFF.

Bit output function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-15


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BOUB

BOUB Specified bit inverted output of word device

Bit out bar

BOUB ([Execution condition,] Destination device, bit position)*1


Applicable Suffix Const Device / For
Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the target with the input state
D Object*2 .U .U .D .D - - - - - ○ -
inverted and output.
n bit position*3 Specifies the bit position to output. .U .U .U .U - - - - ○ ○ ○
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, CR2002 (always ON) is
specified.)
5 *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
Bit output function

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.

Description of Operation
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 bit
16 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Bit Output Instructions."

● Example of format
• D :16-bit instruction
BOUB ( MR1000, DM2000, 12 )
MR1000 DM2000
B
Execution condition #12
Destination device
• D :32-bit instruction
BOUB ( MR1100 = OFF, DM2100.D, 28 )
MR1100 DM2100
B.D
Execution condition #28
Destination device

5-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point 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 31for .D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of n are used.

BASIC FUNCTIONS
When the suffix of D is .D: The values of the lower 5 bits of n are used.

Sample Program
● When specifying a bit device to the destination device

Programmed Script

Operation Description
BOUB ( DM1000 <= 100, MR2002.U, 14 )
When DM1000 is 100 or less, bit 14 (MR2100) of MR2002.U is turned OFF, and when
5
DM1000 is greater than 100, bit 14 is turned ON.

Bit output function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-17


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BSET

BSET Specified bit output ON of word device

Set

BSET ([Execution condition,]*1 Destination device, bit position)


Applicable Suffix Const Device / For
Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


D Object*2 Specifies the target to be held after ON. .U .U .D .D - - - - - ○ -
Specifies the bit position to be turned
n bit position*3 .U .U .U .U - - - - ○ ○ ○
ON and held.
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).)
5 *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
Bit output function

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.

Description of Operation
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.
(The ON target can be turned OFF with 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 bit
16 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Bit Output Instructions."
"BRES function", page 5-20

● Example of format
• D :16-bit instruction
BSET ( R1000, DM1000, 10 )
R1000 DM1000
BSET
Execution condition #10
Destination device
• D :32-bit instruction
BSET ( R1100 = OFF, DM1100.D, 20 )
R1100 DM1100
BSET.D
Execution condition #20
Destination device

5-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point 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 31for .D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of n are used.

BASIC FUNCTIONS
When the suffix of D is .D: The values of the lower 5 bits of n are used.

Sample Program
● When specifying a bit device to the destination device

Programmed Script

Operation Description
BSET ( DM1000 = 100, MR2008.U, 10 )
When DM1000 is 100, bit 10 (MR2102) of MR2008.U is turned ON and is held in this
5
state.

Bit output function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-19


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BRES

BRES Specified bit output OFF of word device

Reset

BRES ([Execution condition,]*1 Destination device, bit position)

Applicable Suffix Const Device / For


Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


D Object*2 Specifies the target to be turned OFF. .U .U .D .D - - - - - ○ -
Bit position Specifies the bit position to
n bit position*3 .U .U .U .U - - - - ○ ○ ○
turn OFF.
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).)
5 *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
Bit output function

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.

Description of Operation
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 bit
16 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Bit Output Instructions."
"BSET function", page 5-18

● Example of format
• D :16-bit instruction
BRES ( MR1000, DM2000, 5 )
MR1000 DM2000
BRES
Execution condition #5
Destination device
• D :32-bit instruction
BRES ( MR1100 = OFF, DM2100.D, 30 )
MR1100 DM2100
BRES.D
Execution condition #30
Destination device

5-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point 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 31for .D suffix) of D :
When the suffix of D is .U: The values of the lower 4 bits of n are used.

BASIC FUNCTIONS
When the suffix of D is .D: The values of the lower 5 bits of n are used.

Sample Program
● When specifying a bit device to the destination device

Programmed Script

Operation Description
BRES ( DM1000 >= 100, MR2008.U, 10 )
When DM1000 is 100 or more, bit 10 (MR2102) of MR2008.U is turned OFF.
5

Bit output function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-21


Ti

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


TMR

TMR 100 ms 32-bit down timer

Timer

TMR ([Timer execution condition,]*1 timer device, timer setting value)


Applicable Suffix Const Device / For
Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the timer.
Timer - - - - - - - - - - -
D (T0 to T3999*3)
Specifies the setting value of the timer
timer setting
in 100 ms units. .D .D .D .D - - - - ○ ○ ○
n
value*2
(0 to 4294967295)
R Return value None - - - - - - - - - - -

5 *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.
Timer/Counter function

*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.
*3 For the KV Nano Series, device numbers T0 to T511 can be specified.

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 100 ms. When the current value becomes 0, the specified timer
(contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF and the
current value is reset.
Scan
ON

Execution
condition 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions."

● Example of format
TMR ( R3000, T125, 100 )
R3000 #100
T125
Execution condition

Reference The error of the TMR instruction is "within ± (100 ms + 1 scan time)."

5-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • When using KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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

BASIC FUNCTIONS
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.
• 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.
• Attention is required when using this function in box scripts and programming
5
this function in sub-routines.

Timer/Counter function
"Precautions for using the timer / counter", page 4-40

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 on the right side and the storage location for the current timer value read on the left
side using an assignment statement.

Programmed Script
DM1000.D = T125.D
Operation Description The current value of T125.D is rewritten to the value currently stored in DM1100.D.

● Rewriting the current value


Specify the storage location for the rewritten value on the right side and the timer on the left side using
an assignment statement.

Programmed Script
T125.D = DM1100.D
Operation Description The current value of T125.D is rewritten to the value currently stored in DM1100.D.

Point • 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.
• A target (32-bit unsigned) should be specified for the set value to change the set
value of the timer or read the set value.
KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions"

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-23


Reading Counter 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
BASIC FUNCTIONS

Operation Description MR1000 is substituted with the contact state of T125.B.

Point Timer contacts cannot be substituted with other bit information.


To forcibly reset a timer, reset the timer contact by the RES function.
After the timer suffix is omitted, the timer is processed as bit type.

5 Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).
Timer/Counter function

5-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

BASIC FUNCTIONS
5

Timer/Counter function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-25


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TMH

TMH 10 ms 32-bit down timer

High-speed timer

TMH ([Timer execution condition,]*1 timer device, timer setting value)


Applicable Suffix Const Device / For
Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the timer.
Timer - - - - - - - - - - -
D (T0 to T3999*3)
Specifies the setting value of the timer
timer setting
in 10ms units. .D .D .D .D - - - - ○ ○ ○
n
value*2
(0 to 4294967295)
R Return value None - - - - - - - - - - -

5 *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.
Timer/Counter function

*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.
*3 For the KV Nano Series, device numbers T0 to T511 can be specified.

Description of Operation
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
(contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF and the
current value is reset.
Scan
ON

Execution
condition 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions."

● Example of format
TMH ( R3000, T150, 100 )
R3000 #100
T150
H
Execution condition

Reference The error of the TMH instruction is "within ± (10ms + 1 scan time)."

5-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • When using KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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

BASIC FUNCTIONS
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.
• 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.
• Attention is required when using this function in box scripts and programming
5
this function in sub-routines.

Timer/Counter function
"Precautions for using the timer / counter", page 4-40

"TMR function", page 5-22

Sample Program
● When using operation formulas for the setting value

Programmed Script
TMH ( R1000, T150, DM1000 + 100 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-27


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TMS

TMS 1 ms 32-bit down timer

High-speed 1ms timer

TMS ([Timer execution condition,]*1 timer device, timer setting value)


Applicable Suffix Const Device / For
Argument/Return Value Description
BASIC FUNCTIONS

.U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the timer.
Timer - - - - - - - - - - -
D (T0 to T3999*3)
Specifies the setting value of the timer
timer setting
in 1ms units. .D .D .D .D - - - - ○ ○ ○
n
value*2
(0 to 4294967295)
R Return value None - - - - - - - - - - -

5 *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.
Timer/Counter function

*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.
*3 For the KV Nano Series, device numbers T0 to T511 can be specified.

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 1ms. When the current value becomes 0, the specified timer
(contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF and the
current value is reset.
Scan
ON
Execution
condition 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions."

● Example of format
TMS ( R3000, T175, 100 )
R3000 #100
T175
S
Execution condition

Reference The error of the TMS instruction is "within ± (1ms + 1 scan time)."

5-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • When using KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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

BASIC FUNCTIONS
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.
• 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.
• Attention is required when using this function in box scripts and programming
5
this function in sub-routines.

Timer/Counter function
"Precautions for using the timer / counter", page 4-40

"TMR function", page 5-22

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-29


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TMU

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 Device / For
Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the timer.
Timer - - - - - - - - - - -
D (T0 to T3999*3)
timer setting Specifies the timer setting value in 1 μs.
.D .D .D .D - - - - ○ ○ ○
n
value*2 (0 to 4294967295)
R Return value None - - - - - - - - - - -
*1 • "[ ]" can be omitted. The execution condition can also be used as a reset. (When the execution

5 condition is OFF, the TMU function is reset.)


• When the execution condition is omitted, use the RES function separately to reset the timer.
Timer/Counter function

*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.
*3 For the KV Nano Series, device numbers T0 to T511 can be specified.

Point The TMU function can only be used with KV-8000/7000 Series CPU units, with KV-
5500/5000/3000 Series CPU units that have CPU function version 2.0 or higher and
with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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
(contact) turns ON. When the execution condition is FALSE, the specified timer is turned OFF and the
current value is reset.
Scan
ON

Execution
condition 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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions."

● Example of format
TMU ( R3000, T200, 100 )
R3000 #100
T200
U
Execution condition

Reference The error of the TMU instruction is "within ± (10 μ s + 1 scan time)."
5-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Point • You cannot use the same device number as other TMR, TMH, TMS, TMU functions
(instructions) and UDT instructions.
• 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

BASIC FUNCTIONS
handled is - 2147483648 to +2147483647.
• 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.
• Attention is required when using this function in box scripts and programming
this function in sub-routines.
"Precautions for using the timer / counter", page 4-40
5
"TMR function", page 5-22

Timer/Counter function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-31


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CNT

CNT 32 bit up counter

Counter

CNT ([Counter execution condition,]*1 counter device, counter setting value, input
device)
BASIC FUNCTIONS

Argument/Return Applicable Suffix Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the counter.
Counter - - - - - - - - - - -
D (C0 to C3999)*3
Specifies the setting value of the
Counter
counter. .D .D .D .D - - - - ○ ○ ○
n
Set value*2
(0 to 4294967295)

5 S Input target
Specifies the target to be used for
count input. - - - - - - .B - - ○ ○

R Return value None - - - - - - - - - - -


Timer/Counter function

*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,
and when a word device has been specified, continuous two words are occupied.
*3 For the KV Nano Series, device numbers C0 to C255 can be specified.

Description of Operation
When the counter execution condition is satisfied, the current value of the specified counter is added
(+1) at the rising edge of the count input specified by S . When the current value reaches the set
value specified by n , D turns ON. When the execution condition is not satisfied, the specified
counter is turned OFF and the current value is reset.
ON
R000 ←Reset input #12 Count input S
C0 OFF

R001 ON
Execution
condition OFF
C0
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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Timer/Counter Instructions."

● Example of format
CNT ( R3000, C120, 1000, MR1000 )
R3000 #1000
C120
Execution condition MR1000

5-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • 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

BASIC FUNCTIONS
in the following instances as the range in which operation formulas can be
handled is - 2147483648 to +2147483647.
• 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.

Reading and changing the current counter value 5


Counter devices handle current values by specifying .D (unsigned 32-bit) as their suffix.

Timer/Counter function
● Reading the current value
Specify the counter on the right side and the storage location for the current counter value read on the
left side using an assignment statement.

Programmed Script
DM1000.D = C100.D
Operation Description The current value of C100.D is stored to DM1000.D.

● Rewriting the current value


Specify the storage location for the current value of the counter read on the right side and the counter
on the left side using an assignment statement.

Programmed Script
C100.D = DM1100.D
Operation Description The current value of C100.D is rewritten to the value currently stored to DM1100.D.

Point • 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.
• A target (32-bit unsigned) should be specified for the set value to change the set
value of the counter or read the set value.
KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual, "Timer/Counter Instructions"

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-33


Reading Counter Contacts
Contacts are handled by specifying .B (bit type) as the suffix of the counter device.(.B can be omitted) (.B
can be omitted)
BASIC FUNCTIONS

Programmed Script
MR1000 = C100.B
Operation Description MR1000 is substituted with the contact state of C100.B.

Point • Counter contacts cannot be substituted with other bit information.


To forcibly reset a counter, reset the counter contact by the RES function.
• The counter is processed as bit type when its suffix is omitted.

5 Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).
Timer/Counter function

5-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

BASIC FUNCTIONS
5

Timer/Counter function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-35


Dir

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


RFSX

RFSX Input refresh

Refresh X

RFSX ([Execution condition,]*1 Leading device for changing input, number of relays)

Argument/Return Applicable Suffix Const Device / For


Description
BASIC FUNCTIONS

Value .U .S .D .L .F .DF .B .T #/$ Variable mula


Input refresh Specifies the start of the input status to
D start be refreshed. - - - - - - .B - - ○ -
Specifies the number of relay points
n Number of relay with input status to be refreshed. .U .U .U .U - - - - ○ ○ ○
(1 to 256)*2
R Return value None - - - - - - - - - - -

5 *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.
Direct I/O functions

When relays other than the leading relay (e.g. R002, R1012) of a channel are specified, 16 bits
are processed straddling the next channel.
The number of relays can be specified within the range of 1 to 256.

Description of Operation
In general, this function 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 n inputs of bit devices starting from D will be
changed.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Direct I/O Instructions".

Point For the KV Nano Series, this function cannot be used with relays assigned to
expansion units.

● Example of format
RFSX ( MR1000, R3000, 128 )
MR1000 RFSX
R3000 #128
Execution condition
Input Refresh leading device Number of relay

5-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RFSY

RFSY Output refresh

Refresh Y

RFSY ([Execution condition,]*1 Leading device for changing output, number of


relays)

BASIC FUNCTIONS
Argument/Return Applicable Suffix Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Output refresh Specifies the start of the output status
D start to be refreshed. - - - - - - .B - - ○ -
Specifies the number of relay points
n Number of relay with output status to be refreshed. .U .U .U .U - - - - ○ ○ ○
(1 to 256)*2
R
*1
Return value None - - - - - - - - -
" [ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
- -
5

Direct I/O functions


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 bits
are processed straddling the next channel.
The number of relays can be specified within the range of 1 to 256.

Description of Operation
In general, this function 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 n inputs of bit devices starting from D will be
changed.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "Direct I/O Instructions".

Point For the KV Nano Series, this function cannot be used with relays assigned to
expansion units.

● Example of format
RFSY ( MR1000, R3000, 128 )
MR1000 RFSY
R3000 #128
Execution condition
Output Refresh leading device Number of relay

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 5-37


MEMO
BASIC FUNCTIONS

5
Direct I/O functions

5-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


6

APPLICATION FUNCTION
APPLICATION FUNCTION

Flow Functions ...................................................................... 6-2


Macro function....................................................................... 6-6
Function block function........................................................ 6-10
Module function ................................................................... 6-18
Index register function ......................................................... 6-20
Specifying functions indirectly ............................................. 6-26
File register function ............................................................ 6-36
Unit program function .......................................................... 6-42
Buffer memory function ....................................................... 6-52
Unit type judgment function................................................. 6-58
Array element number acquisition function ......................... 6-60
Word size get function ......................................................... 6-62

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-1


Flo

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


CALL

CALL Start specified sub-routine

Call

CALL ([Execution condition,]*1 Sub-routine No.)


Argument/Return Available suffixes Const Device/ For
Description
Value #/$ Variable mula
APPLICATION FUNCTION

.U .S .D .L .F .DF .B .T
n Specifies the sub-routine No. to start *2
Sub-routine No. - - - - - - - - ○ - ○
up.(0 to 99)
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 Specify sub-routine No. within the range of 0 to 99.Sub-routine No. cannot be specified by $
(HEX).

6 Description of Operation
Flow Functions

When the execution condition is TRUE, the sub-routine specified by n is ON.


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Flow Instructions."

● Example of format
CALL ( R3000, 10 )
R3000 #10
CALL
Execution condition

Reference The CALL function can be programmed down to a nesting level of 16.

Point • 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 executed (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 AA
プログラム #10
BMOV(DM1000,EM2000,20)
CALL(R1000,10)
Subroutine
ZRES(DM1000,DM1200)
RET
Program BB
プログラム

6-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Hint

■About the sub-routine nesting structure

BMOV(DM1000,EM2000,20)

APPLICATION FUNCTION
Sub-routine functions can be programmed down to CALL(R1000,10)
a nesting level of 16. ZRES(DM1000,DM1200)
Program A
To call a different sub-routine from inside a END
subroutine, the sub-routine to be called must
already be defined (programmed in the above rung).
SBN
#20

Subroutine
A
RET

SBN
#10
Call
6

Flow Functions
Subroutine
B

BMOV(DM1200,EM2100,20)
CALL(R1100,20)
ZRES(DM1100,DM1300)
RET

ENDH

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-3


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ECALL

ECALL Module sub-routine instruction

Ecall

ECALL ([Execution condition,]*1 "Module name (string)")


Argument/Return Available suffixes Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

S Module name *2
Specify module name with text string. ○
(Text string)
Sub-routine No. Specify the sub-routine No. to call. *2
n - - - - - - - - ○ - ○
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 Enter the macro name set on KV STUDIO enclosed by " ".
*3 Specify sub-routine No. within the range of 0 to 99.Sub-routine No. cannot be specified by $

6 (HEX).

Point The KV-1000 series does not support the ECALL function.
Flow Functions

Description of Operation
When the execution condition is TRUE, Sub-routine n specified by Module S is executed.
All types of module (every scan, initialization, stand up, fixed period) can be specified except macro.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Flow Instructions."

● Example of format
ECALL ( MR1000, "Module 1", 1 )
MR1000 ECALL
“module 1” #1
Execution condition

Point • 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.
• For the KV Nano Series, fixed period modules cannot be specified.

6-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Flow Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-5


Ma

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


MCALL

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])
APPLICATION FUNCTION

Argument/Return Available suffixes Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Macro name Specifies the macro name by a text *3
(Text string) string. - - - - - - - - ○ - -

S2 Specifies the macro argument. (The


Macro
number of arguments differs according - - - - - - - - ○ ○ ○
argument*2*4
to the macro).
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
6 at all times (at every scan).)
*2 The number and attribute of macro argument devices differ according to the argument setting
Macro function

made to the macro to execute.


"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",
"MCALL Instruction"
*3 Enter the macro name set on KV STUDIO enclosed by " ".
*4 When an ID No. is used, the format becomes "(macro name)_(ID No.)". For example)
BatchSend_2
Please see "Macro" in the User's Manual of the CPU unit used for details.

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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Macro Instructions."

● Example of format
MCALL (R3000, "Marco1", DM1000, 10)
R3000 MCALL Macro 1
DM1000 #10
Execution condition
Argument 1 Argument 2

Point • 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 when stopped may operate differently to when
executed with an instruction.
Please see "Macro" in the User's Manual of the CPU unit used for details.

6-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MSTRT

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 )

APPLICATION FUNCTION
Argument/Return Available suffixes Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Macro name Specifies the macro name by a text *4
(Text string) string. - - - - - - - - ○ - -

S2 Specifies the macro argument. (The


Macro
number of arguments differs according - - - - - - - - ○ ○ ○
argument*3*5
to the 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).) 6
*2 The number of arguments differs according to the macro to execute.

Macro function
*3 The number and attribute of macro argument devices differ according to the argument setting
made to the macro to execute.
"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",
"MSTRT Instructions"
*4 Enter the macro name set on KV STUDIO enclosed by " ".
*5 When an ID No. is used, the format becomes "(macro name)_(ID No.)". For example)
BatchSend_2
Please see "Macro" in the User's Manual of the CPU unit used for details.

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 No (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-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Macro Instructions."

● Example of format
MSTRT ( R3000, "Macro2", DM1000, 10 )
R3000 MSTRT Macro 2
DM1000 #10
Execution condition
Argument1 Argument2

Point • Text strings other than self-hold type macros enclosed by " " cannot be
programmed as macro names.
• When the MSTRT function is handled in box scripts or in IF statements, attention
is required as OFF processing when stopped may operate differently to when
executed with an instruction.
Please see "Macro" in the User's Manual of the CPU unit used for details.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-7


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MEND

MEND End self-hold type macros

Macro end

MEND ([Execution condition]*1)


Argument/Return Available suffixes Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

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 TRUE, self-hold type macros with a MEND function written to them

6
stop.
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Macro Instructions."
Macro function

● Example of format
MEND ( R3000 = OFF )
R3000 MEND

Execution condition

Reference "MSTRT function", page 6-7

Point • 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Macro function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-9


Fu

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


FB

FB Start function block

Function block

FB ([Execution condition,] *1 "Function block name (Text string)"[,Argument 1,


Argument 2, Argument 3……, Argument 64]*2)

Argument/Return Available suffixes Const Device/ For


APPLICATION FUNCTION

Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Function block
Specifies the function block name in the *4
name (Text - - - - - - - - ○ - -
text string.
string)
S2 Specifies the arguments. (The number of
variable*3*5
arguments differs according to the function 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).)

6 *2
*3
The number of arguments differs according to the function block to execute.
The number and attributes of argument devices differ according to the argument setting
configured in the function block to execute.
Function block function

"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",


"Function Block Instructions"
*4 Enter the function block name set in KV STUDIO enclosed by " ".
Refer to "Function Block" in "KV-8000 Series User's Manual" and "KV-7000 Series User's
Manual" for details.
• FB functions can be used only by KV STUDIO ver.9.0 or later.
• The FB function can be used with KV-8000 series CPU units and KV-7000 Series CPU units that
have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
When the execution condition is true (TRUE), the function block specified by S1 is activated.
Deliver the variable specified by S2 to the function block. The function block will process arguments
according to the data type in the argument settings.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Function Block Instructions"

● Example of format
FB ( R3000, " Functionblock A", 1, DM0 )
R3000 FunctionblockA

#1 Input1 Output1 DM0


Execution condition

Point • Text strings other than function block names enclosed by " " cannot be written in
function block name.
• When an FB function with the "OFF processing while execution is stopped" setting
enabled is handled in box scripts or in IF statements, attention is required as OFF
processing when stopped may operate differently to when executed with an instruction.
Refer to "Function Block" in "KV-8000 Series User's Manual" and "KV-7000
Series User's Manual" for details.

6-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FBCALL

FBCALL Function block call

Function block call

FBCALL ([Execution condition,]*1 "Function name (Text string)", [,Argument 1,


Argument 2, Argument 3……, Argument 64]*2)

Argument/Return Available suffixes Const Device/ For

APPLICATION FUNCTION
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Function block
Specifies the function block name in the *4
name (Text - - - - - - - - ○ - -
text string.
string)
S2 Function name *4
Specifies the instance with a string. - - - - - - - - ○ - -
(Text string)
S3 Independent
Specifies the arguments. - - - - - - - - ○ ○ ○
variable*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).)
6
*2 The number of arguments differs according to the function block to execute.

Function block function


*3 It varies depending on the number of arguments, attributes, or the argument settings set in the
function block to be executed.
"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",
"Function Block Instructions"
*4 Enter the function block name set in KV STUDIO enclosed by " ".

• The FBCALL function can be used only with KV STUDIO Ver.11.0 or later.
• The FBCALL function can be used only with KV-8000 with CPU function version 2.0 or later.
"KV-8000 CPU Function Version", page 2

Description of Operation
When the execution condition is true (TRUE), the instance specified by S2 of the function block
specified by S1 is executed. When the execution condition is turned OFF, the operation of the
instance stops. Deliver the variable specified by S3 to the function block. The function block will
process arguments according to the data type in the argument settings.
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Function Block Instructions"

● Example of format
FBCALL (R3000, "Function blockA", ExamplesB, #1, DM0)
FunctionB
R3000 Calling Function Blocks A
EN ENO
Execution condition #1 Input1 Output1 DM0

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-11


Reference Writing with named arguments eliminates the need to change the order in which the
arguments are specified even if their order changes in the function block argument
settings. Named arguments are written as follows.
FBCALL(R3000, "Function Block A", Examples B, Input1:=#1, OutPut1=>DM10,
ENO=>MR000)
APPLICATION FUNCTION

IN and IN-OUT arguments are specified with :=, while OUT arguments are specified with
=>. ENO can be omitted if not used.
Unit arguments cannot be written in named arguments. The function block with a unit
argument set should be written using a ladder program.

Point • Text strings other than function block names enclosed by " " cannot be written in
function block name.
• The instance need not be surrounded by "".
6 • When an FB function with the "OFF processing while execution is stopped"
setting enabled is handled in box scripts or in IF statements, attention is required
Function block function

as OFF processing when stopped may operate differently to when executed with
an instruction.
• Please refer to "Function Blocks" in "KV-8000 Series User Manual"

6-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FBSTRT

FBSTRT Function block start

Function block start

FBSTRT ( [Execution condition,]*1“"Function block name (Text string)", [,Argument 1,


Argument 2, Argument 3……, Argument 64]*2)

Available suffixes Const Device/ For

APPLICATION FUNCTION
Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Function block
Specifies the function block name in the *4
name (Text - - - - - - - - ○ - -
text string.
string)
S2 Function name
Specifies the instance with a string. - - - - - - - - ○ - -
(Text string)
S3 Independent
Specifies the arguments. - - - - - - - - ○ ○ ○
variable*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).)
6
*2 The number of arguments differs according to the function block to execute.

Function block function


*3 It varies depending on the number of arguments, attributes, or the argument settings set in the
function block to be executed.
"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",
"Function Block Instructions"
*4 Enter the function block name set in KV STUDIO enclosed by " ".

• The FBSTRT function can be used only with KV STUDIO Ver.11.0 or later.
• The FBSTRT function can be used only with KV-8000 with CPU function version 2.0 or later.
"KV-8000 CPU Function Version", page 2

Description of Operation
When the execution condition is true (TRUE), the instance specified by S2 of the function block
specified by S1 is executed. The operation of the instance continues even if the execution condition
is turned OFF. When the FEND instruction is executed in the function block, the operation stops.
Deliver the variable specified by S3 to the function block. The function block will process arguments
according to the data type in the argument settings.
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Function Block Instructions"

● Example of format
FBSTRT ( R3000, "Function block A", ExamplesB, #1, DM0 )
FunctionB
R3000 Calling Function Blocks A
EN ENO
Execution condition #1 Input1 Output1 DM0

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-13


Reference Writing with named arguments eliminates the need to change the order in which the
arguments are specified even if their order changes in the function block argument
settings. Named arguments are written as follows.
FBSTRT(R3000, "Function Block A", Examples B, Input1:=#1, OutPut1=>DM10,
ENO=>MR000)
APPLICATION FUNCTION

IN and IN-OUT arguments are specified with :=, while OUT arguments are specified with
=>. ENO can be omitted if not used.
Unit arguments cannot be written in named arguments. The function block with a unit
argument set should be written using a ladder program.

Point • Text strings other than function block names enclosed by " " cannot be written in
function block name.
• The instance need not be surrounded by "".
6 • When an FB function with the "OFF processing while execution is stopped"
setting enabled is handled in box scripts or in IF statements, attention is required
Function block function

as OFF processing when stopped may operate differently to when executed with
an instruction.
• Please refer to "Function Blocks" in "KV-8000 Series User Manual"

6-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FEND

FEND End function block

Function block end

FEND ([Execution condition,]*1 )


Argument/Return Available suffixes Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula

APPLICATION FUNCTION
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).)

• FEND functions can be used only by KV STUDIO ver.9.0 or later.


• The FEND function can be used with the KV-8000 series CPU units and KV-7000 Series CPU units
that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3
6
Description of Operation

Function block function


When the execution condition is TRUE, function blocks with an FEND function written to them stop.
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Function Block Instructions"

● Example of format
FEND ( R3000 = OFF )
R3000 FEND

Execution condition

Reference "FBSTRT function", page 6-13

Point FEND functions can only be used in function blocks.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-15


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FUN

FUN Start function

Function

FUN ([Execution condition,]*1 "Function name (Text string)" [,Argument 1,


Argument 2, Argument 3……, Argument 64])

Argument/Return Recognized Type Const Device/ For


APPLICATION FUNCTION

Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Function name Specifies the function name in the text *3
(Text string) string. - - - - - - - - ○ - -

S2 Specifies the arguments. (The number


Independent
of arguments differs according to the - - - - - - - - ○ ○ ○
variable*2
function)
R The FUN function has the data format
Return value ○ ○ ○ ○ ○ ○ ○ ○ - ○ -
set when the argument is set.* 4
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed

6 *2
at all times (at every scan).)
The number and attributes of argument devices differ according to the argument setting
configured in the function to execute.
Function block function

"KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual",


"FUN instruction"
*3 Enter the function name set on KV STUDIO enclosed by " ".
Refer to "Function Block" in "KV-8000 Series User's Manual" and "KV-7000 Series User's
Manual" for details.
*4 Only KV-8000 with CPU function version 2.0 or later has a return value. The value to be stored in
the return value is specified by the program in the function.

• FUN functions can be used only by KV STUDIO ver.9.0 or later.


• The FUN function can be used with the KV-8000 series CPU units and KV-7000 Series CPU units
that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
When the execution condition is true (TRUE), the function specified by S1 is executed.
Deliver the variable specified by S2 to the function. The function will process arguments according
to the data type in the argument settings.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Function Block Instructions"

● Example of format
FUN ( R3000, "FeaturesB", EM0, MR000 )
R3000 MCALL マクロ1
FunctionB
DM1000 #10
EM0 Input1 Output1 MR000
Execution condition
引数1 引数2

6-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference Refer to After describing by naming the independent variable, it is no longer necessary to
change the designated order of the independent variable even when the order of the
independent variable changes during the function's independent variable setting. Named
arguments are written as follows.
FUN(R3000, "Function B", Input1:=EM0, OutPut1=>MR000, ENO=>MR100)

APPLICATION FUNCTION
IN and IN-OUT arguments are specified with :=, while OUT arguments are specified with
=>. ENO can be omitted if not used.
Unit arguments cannot be written in named arguments. The function block with a unit
argument set should be written using a ladder program.

Point • The function name cannot be programmed to use anything other than the
function name surrounded by " ".
• What can be described by naming arguments is limited to KV STUDIO Ver.11.0
and later, and the model is KV-8000 with CPU function version 2.0 and later. 6

Function block function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-17


Mo

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


MDSTRT

MDSTRT Module execution start

Module start

MDSTRT ([Execution condition,]*1 "Module name (Text string)")

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

S Module name
Specify module name with 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 times (at every scan).)
*2 Enter the macro name set on KV STUDIO enclosed by " ".

Point MDSTRT function can be used only by KV STUDIO ver.4 or later.

6
Description of Operation
Module function

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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Module Instructions."

● Example of format
MDSTRT ( MR1000, "Module 1" )
MR1000 MDSTRT
Module 1
Execution condition

Point • 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-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MDSTOP

MDSTOP Module execution stop

Module

MDSTOP ([Execution condition,] *1"Module name (Text string)")

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula

APPLICATION FUNCTION
S Module name
Specify module name with 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 times (at every scan).)
*2 Enter the macro name set on KV STUDIO enclosed by " ".

Point MDSTOP function can be used only by KV STUDIO ver.4 or later.

6
Description of Operation

Module function
When the execution condition is TRUE, Module S is executed.
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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Module Instructions."

● Example of format
MDSTOP (MR1000, "Module 1")
MR1000 MDSTOP
Module 1
Execution condition

Point • 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.
• 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 CPU units once, and power on again.
• Toggle selector switch "RUN-PROG" of CPU units to "PROG" mode.
• In KV STUDIO, turn RUN mode to OFF, then ON again.
• Execution of initialization module cannot be stopped or started.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-19


Ind

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


ZPUSH

ZPUSH Batch purge of index register

Zpush

ZPUSH ([Execution condition,]*1 Purge destination device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

D Purge *3 *3 *4 *4
Specifies the leading device of the
destination
purge destination data block. .S .S .L .L - - - - - ○ -
device*2
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 T,C,CR,CTC,CTH,Z cannot be used.
*3 When the type of device for store destination is specified in .S:

6 • Continuous 13 words are occupied. When nesting functions, "number of register purges x 12
words + 1" words are occupied.
• When KV-8000/7500/7300/5500/5000/3000 or KV Nano series is used, only lower 16 bits are
Index register function

processed.
*4 When the type of device for store destination is specified in .L:
• Continuous 25 words are occupied. When nesting functions, "number of register purges x 24
words + 1" words are occupied.
• For KV-1000, it is processed as .S.

Point For Z (index register), when KV-8000/7500/7300/5500/5000/3000 or KV Nano Series


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 specified by D . After the function is executed, the value of [ D +0]is incremented by 1.

Point • 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

6-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


■When using KV-8000/7500/7300/5500/5000/3000 or KV Nano series
• 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

APPLICATION FUNCTION
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

Reference "The "ZPUSH function" and ZPOP function" are programmed nested. When nesting,
specify the same start.
6
bit bit bit bit
31 16 15 0

Index register function


ZPUSH
DM0 3 DM0

Z1 DM1・DM2
ZPUSH
DM0

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


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

Point For KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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 , 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 .

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-21


■When using KV-1000
bit bit
15 0

bit
15
bit
0
Save times D +0

Z1 Z1 D +1
APPLICATION FUNCTION

Z2 Z2 D +2


Z10 Z10 D +10
Reserved for Reserved for
system system D +11
Reserved for Reserved for
system system D +12

● Example of format
ZPUSH ( MR3000, DM1000.L )
6 MR1000 ZPUSH.L
DM1000
Execution condition
Index register function

Return value
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "3-8 Index Register Instructions."

6-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Index register function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-23


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ZPOP

ZPOP Batch restore of index registers

ZPop

ZPOP ([Execution condition,]*1 Purge destination device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

D Purge
Specifies the leading device of the *3 *3 *4 *4
destination
purge destination data block. .S .S .L .L - - - - - ○ -
device*2
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 T,C,CR,CTC,CTH,Z cannot be used.
*3 When the type of device for store destination is specified in .S:

6 • Continuous 13 words are occupied. When nesting functions, "number of register purges x 12
words + 1" words are occupied.
• When KV-8000/7500/7300/5500/5000/3000 or KV Nano Series is used, only lower 16 bits are
Index register function

processed.
*4 When the type of device for store destination is specified in .L:
• Continuous 25 words are occupied. When nesting functions, "number of register purges x 24
words + 1" words are occupied.
• For KV-1000, it is processed as .S.

Point For Z (index register), when KV-8000/7500/7300/5500/5000/3000 or KV Nano series


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.

Point • The "ZPUSH function" and "ZPOP function" are used as a pair.
• The function is not executed when either of the following conditions is
established:
• [ D +0] is "0".
• When the data block range exceeds the device range

"About operation flag (CR2009 to CR2012)", page 1-18

6-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


■When using KV-8000/7500/7300/5500/5000/3000 or KV Nano series
• 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

APPLICATION FUNCTION
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

• D : 16-bit purge destination device

6
bit bit
15 0

D +0 Saving times bit


31
bit bit
16 15
bit
0

D +1 Z1 Z1

Index register function


D +2 Z2 Z2

D +10 Z10 Extend signal to L and then restore Z10


D +11 Reserved for system Reserved for system

D +12 Reserved for system Reserved for system

Point For KV-8000/7500/7300/5500/5000/3000 or KV Nano Series, 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 , 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

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
ZPOP ( MR1000, DM1000.L )
MR1000 ZPOP.L
DM1000
Execution condition
Return value
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "3-8 Index Register Instructions."

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-25


Sp

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


ADRSET

ADRSET Address storage of indirectly specified target

Set address

ADRSET ([Execution condition,]*1 indirect specification device, destination store


address)
APPLICATION FUNCTION

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Indirectly Specifies the target that is indirectly *4
.U .S .D .D .F .DF .B .T - ○ -
specified target specified.
D Destination
Specifies the address storage location. - - .D .D - - - - - ○ -
store device*2 *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).)

6 *2
*3
Continuous two words are used.
Unable to specify CM.
*4 • The .DF suffix can only be used when the compatible model is a KV-8000/7000 Series CPU
Specifying functions indirectly

unit, KV-5500/5000/3000 Series CPU unit that has a CPU function version 2.0 or higher and a
KV Nano Series base unit.
• Z cannot be specified for the target of .DF suffix.

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
when the function is programmed by indirect specification (* destination Store device).

D +1 D
The "address" of S , rather than the values
S Address for S *
specified by S , is stored in [ D ・ D +1] .
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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Indirect Specified Instructions."

● Example of format
ADRSET ( R3000, DM1000, DM2000.D )
R3000 ADRSET
DM1000 DM2000
Execution condition
Indirect Store
designation device destination device

Point • The address storage location always occupies 2 continuous words starting with
the target number.
• 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-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When specifying a bit device to the indirect specification device

Programmed Script
ADRSET ( R3000, MR1000, DM2000.D )

APPLICATION FUNCTION
Operation Description
When R3000 is ON, the address of bit device MR1000 is stored in DM2000.D.
(one point lookup)

● When an index register is used

Programmed Script
ADRSET ( DM1000:Z1, DM2000.D:Z1 )
Operation Description
The address of the DM (1000+Z1) is stored in DM (2000+Z1) .D at every scan (no
execution condition).

Reference The KV script is converted to a ladder program before execution. To check the converted
6
content, refer to "New a box script", step 5, (page 2-10).

Specifying functions indirectly


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 )
Operation Description
The address of R1000 is stored in DM1000.D.
*When the rising edge of *DM1000.B(R1000) is detected, MR2000 is turned ON for one
scan.

Reference "LDP function", page 5-2

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-27


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ADRINC

ADRINC Add 1 to stored address

Increment address

ADRINC ([Execution condition,]*1 Address Store device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

D Address Store Specifies the storage location for the


device*2 *3 indirectly specified address. - - .D .D - - - - - ○ -

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 Unable to specify CM.

6 Description of Operation
Specifying functions indirectly

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
of the next word device, or when a bit device address is currently stored, this indicates the address of
the next bit device.
Adds 1 to the address currently stored in D

Address Address + 1

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Indirect Specified Instructions."

● Example of format
ADRINC ( R3000, DM2000.D )
R3000 ADRINC
DM2000
Execution condition
Address store
Device
\\

Point • The address storage target always occupies 2 continuous words.


• Before using the ADRINC function, be sure to set the indirectly specified address
to the address storage target using 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
established:
• D is inappropriate
• The address is inappropriate after the increment.

6-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When an index register is used

Programmed Script
ADRINC ( R3000, DM2000.D:Z1 )

APPLICATION FUNCTION
Operation Description
When the R3000 is ON, the indirect specification address currently stored in
DM(2000+Z1). D is the next address.*
*Before execution, the address must be stored in DM2000.D by the ADRSET function (instruction).

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

Hint
When the currently stored address is a bit device, the ADRINC function indicates the next bit device.
6
When the address straddles channels at this time, the address becomes the address of the next

Specifying functions indirectly


channel.

Programmed Script
ADRSET ( R3015, DM1000.D )
ADRINC ( *DM1000.B = ON, DM1000.D )
SET ( *DM1000.B )
Operation Description
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.

Reference "ADRSET function", page 6-26


"SET function", page 5-12

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-29


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ADRDEC

ADRDEC Decrement stored address by 1

Decrement address

ADRDEC ([Execution condition,]*1 Address Store device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

D Address Store Specifies the storage location for the


device*2 *3 indirectly specified address. - - .D .D - - - - - ○ -

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 Unable to specify CM.

6 Description of Operation
Specifying functions indirectly

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 of
the previous word device, or when a bit device address is currently stored, this indicates the address of
the previous bit device.

The address currently stored in D is subtracted by 1.

Address Address -1

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Indirect Specified Instructions."

● Example of format
ADRDEC ( R3000, DM2000.D )
R3000 ADRDEC
DM2000
Execution condition
Address store
Device

Point • The address storage target always occupies 2 continuous words.


• Before the ADRDEC function is used, be sure to set the indirect specification
address to the address Store device by the ADRDEC 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
established:
• D is inappropriate
• The address is inappropriate after the decrement.

6-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When an index register is used

Programmed Script
ADRDEC ( R3000, DM2000.D:Z1 )

APPLICATION FUNCTION
Operation Description
When the R3000 is ON, the indirect specification address currently stored in
DM(2000+Z1). D is made into the previous address.*
*Before execution, the address must be stored in DM2000.D by the ADRSET function (instruction).

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10).

Hint
When the currently stored address is a bit device, the ADRDEC function indicates the previous bit
6
device. When the address straddles channels at this time, the address becomes the address of the

Specifying functions indirectly


previous channel.

Programmed Script
ADRSET ( R3100, DM1000.D )
ADRDEC ( *DM1000.B, DM1000.D )
SET ( *DM1000.B )
Operation Description
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.

Reference "ADRSET function", page 6-26


"SET function", page 5-12

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-31


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ADRADD

ADRADD Add stored address

Add address

ADRADD ([Execution condition,]*1 Address add value, address store device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

S Specifies the address add data or the


Address add
device to which the data is currently .S .S .L .L - - - - ○ ○ ○
value
stored.
D Address store Specifies the storage location for the
device*2 indirectly specified address. - - .D .D - - - - - ○ -

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).)
Unable to specify CM.
6
*2

Description of Operation
Specifying functions indirectly

When the execution condition is TRUE, the indirect specification address currently stored in D is
made into the address by adding S . When the address of the word device is currently stored, this
indicates 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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Indirect Specified Instructions."

● Example of format
ADRADD ( R3000, DM1000.S, DM2000.D )
R3000 ADRADD
DM1000 DM2000
Execution condition
Address Address
addition value store Device

Point • The address storage target always occupies 2 continuous words.


• Be sure to set the indirect designated address to the address storage object
through the ADRSET function before use.
• 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
established:
• D is inappropriate
• The address is inappropriate after the increment.

6-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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

APPLICATION FUNCTION
adding the value specified by the address add value.

Programmed Script
ADRSET ( DM2000, DM1000.D )
*DM1000.D += 1
ADRADD ( 2, DM1000.D )
*DM1000.D += 1
Operation Description
The address of DM2000 is stored in 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 6
address (DM2002.D).

Specifying functions indirectly


Reference "ADRSET function", page 6-26

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-33


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ADRSUB

ADRSUB Subtract stored address

Subtract address

ADRSUB ([Execution condition,]*1 Address subtract value, address store device)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

S Address Specifies the address subtract data or


subtraction the device to which the data is currently .S .S .L .L - - - - ○ ○ ○
value stored.
D Address store Specifies the storage location for the
device*2 indirectly specified address. - - .D .D - - - - - ○ -

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).)
Unable to specify CM.
6
*2

Description of Operation
Specifying functions indirectly

When the execution condition is TRUE, the indirect specification address currently stored in D is
made into the address obtained by subtracting S . When the address of the word device is currently
stored, this 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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Indirect Specified Instructions."

● Example of format
ADRSUB ( R3000, DM1000.S, DM2000.D )
R3000 ADRSUB
DM1000 DM2000
Execution condition
Address Address
subtraction value store Device

Point • The address storage target always occupies 2 continuous words.


• Before using, please be sure to set the indirect designated address to the
address storage object through the ADRSUB 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
established:
• D is inappropriate
• The address is inappropriate after the decrement.

6-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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 ADRSUB function is handy when handling 32-bit data as it indicates the device No. obtained by

APPLICATION FUNCTION
adding the value specified by the address add value.

Programmed Script
ADRSET ( DM2000, DM1000.D )
*DM1000.D += 1
ADRSUB ( 2, DM1000.D )
*DM1000.D += 1
Operation Description
The address of DM2000 is stored in DM1000.D
"1" is added to the stored address as a 32-bit device.
"2" is subtracted from the address stored in DM1000.D, and "1" is added to the previous 6
32-bit address (DM1998.D).

Specifying functions indirectly


Reference "ADRSET function", page 6-26

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-35


Fil

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


FRSET

FRSET Switch file register mode

Switch mode

FRSET ([Execution condition,]*1 Bank No.)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

Specifies current bank No. after *2


n File No. .U .U .U .U - - - - ○ - ○
switching. (0 to 15*2)
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 scope of the bank number is 0 to 15 for KV-8000/7500/7300 and 0 to 3 for KV-5500/5000/
3000.

6 Description of Operation
File register function

When the execution condition is TRUE, switch the current file register No. to n .
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "File Register Instructions."

● Example of format
FRSET ( MR1000, 2 )
MR1000 FRSET
#2
Execution condition

6-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

File register function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-37


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FRSTM

FRSTM Batch-store file register

Batch-store file register

Return value*1 =FRSTM (Drive number*1 , Bank No., File No., result store device)

Argument/Return Recognized Type Const Device/ For


Description
Value #/$ Variable mula
APPLICATION FUNCTION

.U .S .D .L .F .DF .B .T
Set drive number to be saved.* 2 (0 to
n1 Drive number*2 .U .U .U .U - - - - *2
○ ○ ○
1)
Specifies the bank number of the file
File No. register for batch saving. .U .U .U .U - - - - *3
n2 ○ ○ ○
(0 to 15*3)
Specifies the leading No. of bit device
File No. for notifying the store result. .U .U .U .U - - - - *4
S ○ ○ ○
(0 to 999)
Save result Specifies the bit device for notifying the
- - - - - - .B - - ○ -
6
D
storage target store result.
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
File register function

when startup fails.


*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 For KV-8000/7500/7300 only, set drive number (0: memory card, 1:CPU memory). In case of KV-
5500/5000/3000, this cannot be set.
*3 Set bank number to scope of 0-15 for KV-8000/7500/7300, 0 to 3 for KV-5500/5000/3000.
*4 Please specify the number of data within the range of 0 to 999.
*5 T,C,CTC,CTH,Z cannot be specified.
*6 When a bit device has been specified to the store 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
When the execution condition is TRUE, the data in file register of the n2 bank number is batch-
stored in memory card in BIN bits on the drive number n1 as the file name specified by S file
number.
The write complete notification and abnormality end warning is stored in D .
When the FRSTM function is started normally, is ON, otherwise OFF.

Reference • The file name stored in memory card is "\FR\FR (file NO. 3-digit) .FRU" ((file extension is
FRB in case of KV-5500/5000/3000.)
(Example) When setting 10 to S , create the file \FR\FR010.FRU on the memory
card or CPU memory.
• Meaning of notification bit of D

(Example) When MR2000 has been specified

Notification bit is ON (1, TRUE) OFF (0, FALSE)


MR2000 End notification Completed Not completed
MR2001 Error notification Normal end Normal end

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "File Register Instructions."

6-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1000 = FRSTM (1, 10, MR2000)

APPLICATION FUNCTION
6

File register function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-39


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FRLDM

FRLDM Batch- read file register

Batch- read file register

Return value *1=FRLDM ( Drive number*1 , Bank No., File No., result store device )

Argument/Return Recognized Type Const Device/ For


Description
Value #/$ Variable mula
APPLICATION FUNCTION

.U .S .D .L .F .DF .B .T
Set the drive number for batch
n1 Drive number*2 .U .U .U .U - - - - *2
○ ○ ○
reading.*2 (0 to 1)
Specifies the bank number of the file
File No. register for batch reading. .U .U .U .U - - - - *3
n2 ○ ○ ○
(0 to 15*3)
Specify file No. of memory card to be *4
S File No. .U .U .U .U - - - - ○ ○ ○
read. (0 to 999)
Read result Specifies the leading No. of device for
D
storage target notifying read result - - - - - - .B - - ○ -

6 R Return value
Turns ON when the function is
successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
File register function

*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 For KV-8000/7500/7300 only, set drive number (0: memory card, 1:CPU memory). In case of KV-
5500/5000/3000, this cannot be set.
*3 The scope of the bank number is 0 to 15 for KV-8000/7500/7300 and 0 to 3 for KV-5500/5000/3000.
*4 Please specify the number of data within the range of 0 to 999.
*5 T, C, CTC, CTH, Z cannot be specified.
*6 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 used as the notification bit device.

Description of Operation
When execution conditions are satisfied (TRUE), the data saved in drive number n1 and specified

by S file number (\FR\FR(file number consisting of 3 digits).FRB) is read, and saved in the n2
bank number file register.
The write complete notification and abnormality end warning is stored in D .
When the FRSTM function is started normally, the return value is ON, otherwise OFF.

Reference • The file name read in memory card is "\FR\FR (file NO. 3-digit) .FRU" ((file extension is FRB
in case of KV-5500/5000/3000.) ((file extension is FRB in case of KV-5500/5000/3000.)
(Example) When setting 10 to S , create the file \FR\FR010.FRU on the memory
card or CPU memory.
• Meaning of notification bit of D

(Example) When MR2000 has been specified

Notification bit is ON(1、TRUE) OFF(1、FALSE)


MR2000 End notification Completed Not completed
MR2001 Error notification Normal end Normal end

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "File Register Instructions."

6-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1000 = FRLDM (1, 10, MR2000)

APPLICATION FUNCTION
6

File register function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-41


Unit

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


UPSTRT

UPSTRT Unit program start

Unit program start

UPSTRT (Execution condition, Unit No., Request details, Execution start slot
number, Execution result)
APPLICATION FUNCTION

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Execution Specifies the bit device to be used for
condition the execution condition. - - - - - - .B - - ○ ○

n1 Specifies the unit number or storage


Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
S2 Specifies the start of the unit program
Request
details that stores the execution .U .U .U .U - - - - - ○ -
details*2
request.
Execution start Specifies the storage location for the
6
D1
.U .U .U .U - - - - - ○ -
Slot number slot number for starting.
D2 Execution
Specifies the start to store the result. - - - - - - - - - ○ -
result*3
Unit program function

R Return value None - - - - - - - - - - -


*1 $ (hexadecimal specification) cannot be used.
*2 4 continuous words are occupied.
*3 2 continuous words are occupied.

Point • The UPSTRT function can be used only by KV STUDIO ver.9.0 or later.
• The UPSTRT function can be used with the KV-8000 series CPU units and KV-
7000 Series CPU units that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
At the rising edge of the execution condition S1 , the unit program specified by S2 in the n1
unit starts, following the parameters specified by S2 +2.
If the 0 bit of S2 +3 is OFF, an assignable empty slot is automatically used.
If the 0 bit of S2 +3 is ON, the slot specified by S2 +1 is used.
When the function is complete, the used slot number is stored in D1 , and the execution results are
stored in D2 and D2 +1.

6-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


S2 ~ : Request details

Request details Details


S2 Program number Specifies the unit program number to start.
S2 +1 Slot number If the 0 bit of S2 +3 is ON, specifies the slot number to use.

APPLICATION FUNCTION
Specifies the parameters of the unit program to start.
S2 +2 Parameter
For flow: specifies the first block number to execute.
Slot
ON : The slot specified by S2 +1 is used.
S2 +3 0 bit specification
OFF : An assignable empty slot is automatically used.
method

D2 ~ : Execution result device

Execution result

Completion
Details
Turns OFF when executing the function, turns ON when complete. 6
0 bit Turns ON regardless of whether the function ends normally or
bit

Unit program function


D2 abnormally.
Execution If execution of the function fails, turns ON simultaneously with the
1 bit
failed bit completion bit. Turns OFF when executing the function.
The completion code is stored when the function is complete.
0: Started normally.
1: The specified unit program does not exist.
2: There are no empty slots.
3: Operation enabled is OFF.
4: A unit program error has occurred.
5: The specified slot does not exist.
D2 +1 Completion code 6: The specified slot is in use.
7: The unit program is already being executed.
8: The specified block does not exist.
9: The unit program has already stopped being executed.
10: The specified unit program is not flow.
100: An error has occurred on the unit.
1000: The specified unit program does not exist.
1001: The specified unit is illegal.

If the unit program start function is executed at the rising edge of the execution condition, the process
will continue even if the input conditions are turned OFF at the next scan.
The completion bit and execution failure bit of the result storage location turn ON when completed, and
turn OFF when the function is executed.
For details, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual", "Unit Program Instructions."

● Example of format
UPSTRT(MR1000, #1, DM0, DM10, DM11)
MR1000 UPSTRT
#1 DM0 DM10 DM11
Execution condition Unit No. Request details Execution start Execution result
slot number

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-43


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UPSTOP

UPSTOP Unit program forced stop

Unit program forced stop

UPSTOP (Execution condition, Unit No., Slot number, Execution result)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

Execution Specifies the bit device to be used for


S
condition the execution condition. - - - - - - .B - - ○ ○
Specifies the unit number or storage
n1 Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
Specifies the storage location for the
n2 Slot number .U .U .U .U - - - - ○ ○ ○
slot number for forced end.
Execution
D1 Specifies the start to store the result. .U .U .U .U - - - - - ○ -
result*2
R Return value None - - - - - - - - - - -

6 *1
*2
$ (hexadecimal specification) cannot be used.
2 continuous words are occupied.
Unit program function

Point • The UPSTOP function can be used only by KV STUDIO ver.9.0 or later.
• The UPSTOP function can be used with the KV-8000 series CPU units and KV-
7000 Series CPU units that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
At the rising edge of the execution condition S , the unit program being executed in the slot
specified by n2 in the n1 unit is stopped forcefully, and the slot becomes empty.
When the function is complete, the execution results are stored in D1 and D1 +1.

Reference "UPSTRT function", page 6-42

For details, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual", "Unit Program Instructions."

6-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D1 ~ : Execution result storage destination device

Execution result Details


Completion Turns OFF when executing the function, turns ON when complete. Turns
0 bit
bit ON regardless of whether the function ends normally or abnormally.

APPLICATION FUNCTION
D1
Execution If execution of the function fails, turns ON simultaneously with the
1 bit
failed bit completion bit. Turns OFF when executing the function.
The completion code is stored when the function is complete.
0 : Started normally.
1 : The specified unit program does not exist.
2 : There are no empty slots.
3 : Operation enabled is OFF.
4 : A unit program error has occurred.
5 : The specified slot does not exist.
D1 +1 Completion code 6
7
: The specified slot is in use.
: The unit program is already being executed. 6
8 : The specified block does not exist.

Unit program function


9 : The unit program has already stopped being executed.
10 : The specified unit program is not flow.
100 : An error has occurred on the unit.
1000 : The specified unit program does not exist.
1001 : The specified unit is illegal.

● Example of format
UPSTOP(MR1000, #1, #0, DM0)
MR1000 UPSTOP
#1 #0 DM0
Execution condition Unit No. Slot number Execution result

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-45


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UFSUS

UFSUS Suspend flow

Suspend flow

UFSUS (Execution condition, Unit No., Slot number, Request details, Execution
result)
APPLICATION FUNCTION

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Execution Specifies the bit device to be used for
S
condition the execution condition. - - - - - - .B - - ○ ○
Specifies the unit number or storage
n1 Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
Specifies the storage location for the
n2 Slot number .U .U .U .U - - - - ○ ○ ○
slot number for temporary stop.
Specifies the target that stores the
n3 Request details .U .U .U .U - - - - ○ ○ -
temporary stop method.
6 D1
Execution
result*2
Specifies the start to store the result. .U .U .U .U - - - - - ○ -
Return value None
Unit program function

R - - - - - - - - - - -
*1 $ (hexadecimal specification) cannot be used.
*2 2 continuous words are occupied.

Point • The UFSUS function can be used only by KV STUDIO ver.9.0 or later.
• The UFSUS function can be used with the KV-8000 series CPU units and KV-7000
Series CPU units that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
At the rising edge of the execution condition S , the flow being executed in the slot specified by
n2 in the n1 unit is suspended, following the method specified in n3 .
When the function is complete, the execution results are stored in D1 and D1 +1.

6-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D1 ~ : Execution result storage destination device

Execution result Details


Turns OFF when executing the function, turns ON when complete.
Completion
0 bit Turns ON regardless of whether the function ends normally or

APPLICATION FUNCTION
bit
D1 abnormally.
Execution If execution of the function fails, turns ON simultaneously with the
1 bit
failed bit completion bit. Turns OFF when executing the function.
The completion code is stored when the function is complete.
0 : Started normally.
1 : The specified unit program does not exist.
2 : There are no empty slots.
3 : Operation enabled is OFF.
4 : A unit program error has occurred.

D1 +1 Completion code
5
6
: The specified slot does not exist.
: The specified slot is in use. 6
7 : The unit program is already being executed.

Unit program function


8 : The specified block does not exist.
9 : The unit program has already stopped being executed.
10 : The specified unit program is not flow.
100 : An error has occurred on the unit.
1000 : The specified unit program does not exist.
1001 : The specified unit is illegal.

n3 : Request details

Request details Details


ON: Blocks being executed are forcefully ended, and flow is
Suspension suspended.
n3 0 bit
method OFF: Flow is suspended when the blocks being executed are
completed.

For details, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual", "Unit Program Instructions."

● Example of format
UFSUS(MR1000, #1, DM10, #0, DM0)
MR1000 UFSUS
#1 DM10 #0 DM0
Execution condition Unit No. Slot number Request details Execution result

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-47


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UFRSM

UFRSM Resume flow

Resume flow

UFRSM (Execution condition, Unit No., Slot number, Execution result)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
APPLICATION FUNCTION

Execution Specifies the bit device to be used for


S
condition the execution condition. - - - - - - .B - - ○ ○
Specifies the unit number or storage
n1 Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
Specifies the storage location for the
n2 Slot number .U .U .U .U - - - - ○ ○ ○
slot number for restarting.
Execution
D1 Specifies the start to store the result. .U .U .U .U - - - - - ○ -
result*2
R Return value None - - - - - - - - - - -

6 *1
*2
$ (hexadecimal specification) cannot be used.
2 continuous words are occupied.
Unit program function

Point • The UFSUS function can be used only by KV STUDIO ver.9.0 or later.
• The UFSUS function can be used with the KV-8000 series CPU units and KV-7000
Series CPU units that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
At the rising edge of the execution condition S , the suspended flow in the slot specified by n2 in
the n1 unit is resumed.
When the instruction is complete, the execution results are stored in D1 and D1 +1.

Reference "UFSUS function", page 6-46

For details, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual", "Unit Program Instructions."

6-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D1 ~ : Execution result storage destination device

Execution result Details


Turns OFF when executing the function, turns ON when complete.
Completion
0 bit Turns ON regardless of whether the function ends normally or

APPLICATION FUNCTION
bit
D1 abnormally.
Execution If execution of the function fails, turns ON simultaneously with the
1 bit
failed bit completion bit. Turns OFF when executing the function.
The completion code is stored when the function is complete.
0 : Started normally.
1 : The specified unit program does not exist.
2 : There are no empty slots.
3 : Operation enabled is OFF.
4 : A unit program error has occurred.

D1 +1 Completion code
5
6
: The specified slot does not exist.
: The specified slot is in use. 6
7 : The unit program is already being executed.

Unit program function


8 : The specified block does not exist.
9 : The unit program has already stopped being executed.
10 : The specified unit program is not flow.
100 : An error has occurred on the unit.
1000 : The specified unit program does not exist.
1001 : The specified unit is illegal.

● Example of format
UFRSM(MR1000, #1, DM10, DM0)
MR1000 UFRSM
#1 DM10 DM0
Execution condition Unit No. Slot number Execution result

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-49


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UMALLOC

UMALLOC Allocate buffer memory

Allocate buffer memory

UMALLOC (Execution condition, Unit No., Allocated size, Execution result,


Allocation result storage destination)
APPLICATION FUNCTION

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Execution Specifies the bit device to be used for
S
condition the execution condition. - - - - - - .B - - ○ ○
Specifies the unit number or storage
n1 Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
Specifies the storage location for the
n2 Allocated size .U .U .U .U - - - - ○ ○ ○
number of secured words.
Execution
D1 Specifies the start to store the result. .U .U .U .U - - - - ○ ○ -
result
6 D2
Allocation result
storage
Specifies the storage location for the
.U .U .U .U - - - - - ○ -
start address of the secured area.
destination
Unit program function

R Return value None - - - - - - - - - - -


*1 $ (hexadecimal specification) cannot be used.

Point • The UMALLOC function can be used only by KV STUDIO ver.9.0 or later.
• The UMALLOC function can be used with the KV-8000 series CPU units and KV-
7000 Series CPU units that have CPU function version 2.0 or later only.
"KV-7500/7300 CPU Function Version", page 3

Description of Operation
At the rising edge of the execution condition S , an area of the number of words specified by n2
from the buffer memory of the n1 unit is allocated. The leading address of the allocated area is
stored in D2 and the execution results are stored in D1 .
If allocation fails, #0 is stored in D2 .

Reference • The area is automatically allocated.


• Values can be freely read from/written to the allocated area.
• When the unit's operation enabled relay turns OFF, the allocated area is deallocated.

D1 : Execution result

Execution result Details


Turns OFF when executing the function, turns ON when
0 bit Completion bit complete. Turns ON regardless of whether the function ends
D1 normally or abnormally.
Execution failed If memory cannot be allocated, turns ON simultaneously with the
1 bit
bit completion bit. Turns OFF when executing the function.

For details, see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual", "Unit Program Instructions."

6-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
UMALLOC(MR1000, #1, DM10, DM11, DM20)
MR1000 UMALLOC
#1 DM10 DM11 DM20
Execution condition Unit No. Allocated size Request details Allocation result

APPLICATION FUNCTION
storage destination

Unit program function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-51


Bu

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


UREAD

UREAD Read buffer

Read buffer

UREAD ([Execution condition,]*1 Unit No., leading buffer address,


Leading read data store device, number of read data)

Argument/Return Recognized Type Const Device/ For


APPLICATION FUNCTION

Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies expansion special unit/CPU
n1 Unit No.*2 Unit of buffer for data to be read. (0 to .U .U .U .U - - - - *3
○ ○ ○
48)
n2 Specify leading Specify leading device of buffer
buffer device for memory for data to be read. (0 to .U .U .U .U - - - - *3
○ ○ ○
data to be read*3 59999*3)
D Leading read
Specify leading device for read data to
data store .U .S .D .L .F - - .T - ○ -
be stored.
device*5
6 n3
Number of read Specify number of data read from buffer.
data*4 (1 to 60000*4)
.U .U .U .U - - - - ○ ○ ○
Return value None
Buffer memory function

R - - - - - - - - - ○ -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
at all times (at every scan).)
*2 Please specify a unit number within the range of 0 to 48 (0 to 15 for the Nano Series). $(HEX)
cannot be specified.
*3 Please specify the buffer memory start address as 0 to 59999 for KV-8000/7500/7300 and 0 to
32767 all others.
*4 Please specify the read data number as 1 to 60000 for KV-8000/7500/7300 and 1 to 32768 all
others.
*5 CTC,CTH,Z cannot be specified.

Description of Operation
When execution condition is TRUE, read buffer of n1 connected with CPU unit, address 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, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Buffer Memory Instructions."

● Example of format
UREAD (MR1000, 3, DM1200, DM1000, DM1100)
MR1000 UREAD
#3 DM1200 DM1000 DM1100
Execution condition
Unit No. Leading address Read data store Number of read data
for buffer memory object leading device

6-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Buffer memory function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-53


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UWRIT

UWRIT Write buffer

Write buffer

UWRIT ([Execution condition,]*1 Unit No., leading buffer address


Leading write data device, number of write data)

Recognized Type Const Device/ For


APPLICATION FUNCTION

Argument/Return Value Description


.U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies expansion special unit/CPU
n1 Unit No.*2 Unit of buffer for data to be written. (0 to .U .U .U .U - - - - *3
○ ○ ○
48)
n2 Specify leading Specify leading device of buffer
buffer device for memory for data to be read. (0 to .U .U .U .U - - - - *3
○ ○ ○
data to be read*3 59999*3)
Leading write Specify leading buffer device for data to *6
D
.U .S .D .L .F - - .T ○ ○
data device*5 be written. ○
Read number of data within specified
6 n3
Number of write
data*4 range.
(1 to 60000*4)
.U .U .U .U - - - - ○ ○ ○

Return value None


Buffer memory function

R - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
at all times (at every scan).)
*2 Please specify a unit number within the range of 0 to 48 (0 to 15 for the Nano Series). cannot be
specified by $ (HEX).
*3 Please specify the buffer memory start address as 0 to 59999 for KV-8000/7500/7300 and 0 to
32767 all others.
*4 Please specify the read data number as 1 to 60000 for KV-8000/7500/7300 and 1 to 32768 all
others.
*5 CTC,CTH,Z cannot be specified.
*6 The text string operation can only be specified. Operation other than text string operation (e.g.
DM0+DM2) cannot be programmed.

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 move source device is 16-bit (.U/.S)


CPU device Buffer memory

S Write n2

S +1 Write n2 +1
S +2 Write n2 +2

S + n3 -2 Write n2 + n3 -2
S + n3 -1 Write n2 + n3 -1

6-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When move 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]

APPLICATION FUNCTION
[ 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]

Reference • When the constant is specified in S , UWRIT function executes the operation
identical with UFILL function.
"UFILL function", page 6-56

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Buffer Memory Instructions." 6

Buffer memory function


● Example of format
UWRIT (MR1000, 3, 1000, DM3000.U, 5)
MR1000 UWRIT
#3 #1000 DM3000 #5
Execution condition
Unit No. Leading address Write data store Number of write data
for buffer memory object leading device

CPU device Buffer memory


DM3000: 1 1 :#1000
DM3001: 3 3 :#1001
DM3002: 7 7 :#1002
DM3003: 15 15 :#1003
DM3004: 31 31 :#1004
16 bits 16 bits
(1 word) (1 word)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-55


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UFILL

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 Device/ For


APPLICATION FUNCTION

Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies expansion special unit/CPU
n1 Unit No.*2 Unit of buffer for data to be written. (0 to .U .U .U .U - - - - *3
○ ○ ○
48)
n2 Specify leading Specify leading device of buffer
buffer device for memory for data to be read. (0 to .U .U .U .U - - - - *3
○ ○ ○
data to be read*3 59999*3)
D Leading write
Specifies the device for the data to be
data store .U .S .D .L .F - - .T ○ ○ ○
written or stored.
device*5
6 n3
Number of write
Read number of data within specified
range. .U .U .U .U - - - - ○ ○ ○
data*4
(1 to 60000*4)
Buffer memory function

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 a unit number within the range of 0 to 48 (0 to 15 for the Nano Series). cannot be
specified by $ (HEX).
*3 Please specify the buffer memory start address as 0 to 59999 for KV-8000/7500/7300 and 0 to
32767 all others.
*4 Please specify the read data number as 1 to 60000 for KV-8000/7500/7300 and 1 to 32768 all
others.
*5 CTC,CTH,Z cannot be specified.

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 move source device is 16-bit (.U/.S)


CPU device Buffer memory

n2

n2 +1

n2 +2

n2 + n3 -3

n2 + n3 -2
n2 + n3 -1

6-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When move source device is 32-bit (.D/.L/.F)
CPU device Buffer memory

[ n2 n2 +1]

[ n2 +2 n2 +3]

APPLICATION FUNCTION
[ n2 +4 n2 +5]


[ S S +1]

[ 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]

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Buffer Memory Instructions."

● Example of format
6

Buffer memory function


UFILL (MR1000, 3, 1000, DM3000.U, 5)
MR1000 UFILL
#3 #1000 DM3000 #5
Execution condition
Unit No. Leading address Write data Number of write data
for buffer memory store device

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-57


U
nit

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


IS_□□□

IS_□□□ Unit type judgment

Unit type judgment

IS_□□□ ([Execution condition], Unit No., Execution result)


Argument/Return Recognized Type Const Device/ For
Description
APPLICATION FUNCTION

Value .U .S .D .L .F .DF .B .T #/$ Variable mula


Specifies the unit number or storage
n1 Unit No.*1 .U .U .U .U - - - - ○ ○ ○
location. (1 to 48)
Execution Specifies the storage location for the
D .B .B .B .B - - - - - ○ -
result result notification.
*1 $ (hexadecimal specification) cannot be specified.
*2 When a word device is specified, the LSB is used as the notification bit device. Nothing except the
LSB is changed.

6 Point • The unit type judgment function can be used in KV STUDIO Ver. 9.1 or later only.
• The unit type judgment function can be used with the KV-8000 series CPU units
and KV-7000 Series CPU units that have CPU function version 2.1 or later only.
Unit type judgment function

"KV-7500/7300 CPU Function Version", page 3

Description of Operation
The unit type of the n1 unit is checked at the rising edge of the execution condition, and D turns
ON if it matches the unit type corresponding to the instruction. D turns OFF if there is no match or
if it is not connected.

Instruction and unit type


Replace "IS_" in the instruction with "KV-" to find the corresponding unit type.
Example)
(Instruction) (Unit type)
IS_XH16ML → KV-XH16ML

● Example of format
IS_XH16ML(@CR2008, #1,MR000)
@CR2008 IS_XH16ML
#1 MR000
Execution condition
Unit No. Execution result

6-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Unit type judgment function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-59


Array element number acquisition function

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


ACNT

ACNT Get the number of array elements

Get the number of array elements

Return value = ACNT (Object array, number of dimensions)


Argument/Return Recognized Type Const Device/ For
Description
Value #/$ Variable mula
APPLICATION FUNCTION

.U .S .D .L .F .DF .B .T
Array type variable for obtaining the
Object array - - - - - - - - - ○ -
S
number of elements.*1
Number of
n Specifies the number of dimensions. .U - - - - - - - ○ ○ ○
dimensions
*3
Return value The ACNT function has a .D format.*2 .U .S .D .L .F
R .DF - - - - -

*1 Variables other than array type cannot be specified. Also, variable-length arrays cannot be
specified.
*2 When the type other than .D is specified by return value, type conversion will be automatically
6 conducted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.
Array element number acquisition function

Description of Operation
The number of elements in the n dimensions of S is counted, and the result is stored in
[ R / R +1] as 32-bit BIN data.

Example When S =Array_A (2-dimensional array of 5×4) and n =2

Array_A Number of elements 4

[0,0] [0,1] [0,2] [0,3]

[1,0] [1,1] [1,2] [1,3] R +1 R


4
Number of [2,0] [2,1] [2,2] [2,3]
elements 5
[3,0] [3,1] [3,2] [3,3]

[4,0] [4,1] [4,2] [4,3]

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Get the number of array elements".

Point The ACNT instruction obtains the number of elements instead of the word size. For
example, when UDINT (2-word unsigned integer) is specified as 4 dimensions, 4 is
stored in [ R / R +1].

● Example of format
duSizeOfDimension = ACNT(Array_A, 2)

6-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

APPLICATION FUNCTION
6

Array element number acquisition function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 6-61


Word size get function

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


WSIZE□

WSIZE Get word size

Get word size

Return value*1 = WSIZE (target variable)


Argument/Return Recognized Type Const Device/ For
Description
Value #/$ Variable mula
APPLICATION FUNCTION

.U .S .D .L .F .DF .B .T
Specifies the variable to get the word
Target variable - - - - - - - - - ○ -
S
size.* 2
*4
R Return value The WSIZE function has the .D type.* 3 .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 The following variables cannot be specified.
·TIMER type variable
·COUNTER type variable
·Function block type variable
6 ·Variable-length array
·Variable-length string
Word size get function

Other arrays can be specified.


*3 When the type other than .D is specified by return value, type conversion will be automatically
conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Description of Operation
The word size of S is stored in [ R / R +1] as 32-bit binary data.

Example S = When the following structure type variables are specified

Member name Data type


R +1 R
member1 UINT
14
member2 STRING[20]
member3 REAL

→The number of words in STRING[20] is 11 after (20+1)/2 is rounded up, so 1 + 11 + 2 = 14.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Get word size".

Point • The WSIZE instruction obtains the word size. For example, when an array type
variable or structure type variable with 4 UDINT type data (2-word unsigned
integer) is specified, 8 is stored in [ R / R +1] as 2 words × 4 = 8 words. It
does not store the number of elements or the number of members.
• [ R / R +1] stores the word size including the offset. For details on the
offset, refer to the User's Manual of the CPU unit used.
• [ R / R +1] stores the result of word size rounded up. For example, 3 is
stored for BOOL[33].

● Example of format
duSizeOfTag = WSIZE(tagAxis_A)

6-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


7

ARITHMETIC OPERATION FUNCTIONS


ARITHMETIC
OPERATION FUNCTIONS

Data move function ............................................................... 7-2


Arithmetic Operation Functions ........................................... 7-14
Logic Operation Functions .................................................. 7-22
Data Shift Functions ............................................................ 7-38
Data Control Functions........................................................ 7-62
Data Conversion Functions ................................................. 7-80
Floating Point Functions .................................................... 7-114
Text Processing Functions ................................................ 7-154

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-1


Da

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


BMOV

BMOV Batch data move of word block

Block move

BMOV ([execution condition,]*1 Move source, move destination, number of move


ARITHMETIC OPERATION FUNCTIONS

data)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Move Specifies the start of the move source
S .U .U .U .U - - - - - ○ -
source*2*3 data block.
Move Specifies the start of the move Handled as same
D
destination*2*3 destination data block. type as S . - - - - ○ -
Specifies the storage location for the
Number of
n number of data to be moved or the .U .U .U .U - - - - ○ ○ ○
move data
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
*3
When device T or C is specified, the current value becomes the move source.
When bit data is specified, 16/32 continuous bits are processed. When a relay other than the
Data move function

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
When the execution condition is met (TRUE), the contents of the word block for n starting with
S are moved to the word block for the number of move data starting with D . (When the move
destination is 32-bit data, the word block becomes the "specified number of move data x 2 words".)

• S : When move source 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

• S : When move source 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]

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Move Instructions".

7-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
BMOV (MR1000, DM1000.U, EM2000, 5 )
MR1000 BMOV S :DM1000

ARITHMETIC OPERATION FUNCTIONS


DM1000 EM2000 #5 D :EM2000
Execution n :When :#5
condition Move source Move destination
device device

Move source Move destination


DM1000: 1 1 :EM2000
DM1001: 3 3 :EM2001
DM1002: 7 7 :EM2002
DM1003: 15 15 :EM2003
DM1004: 31 31 :EM2004
16 bits 16 bits
(1 word) (1 word)

Point When n =0, the function is not executed.

7
Sample Program

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.

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 1 0 0 0 0 1 1 1 1 0 1 0 0 0 0 0

Reference • Data blocks (bit) at the move source and move destination will be moved successfully
even if they partially straddle channels.
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-3


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FMOV

FMOV Substitute same value in data string

Fill move

FMOV ([execution condition,]*1 Move source, move destination, number of move


ARITHMETIC OPERATION FUNCTIONS

data)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the move source or the *3
S Move source*2 storage location for the move source .U .U .D .D .D .DF - - ○ ○ ○
data.
Move Specifies the start of the move Handled as same type as
D
destination*2 destination data block. S . - - - ○ -
Specifies the storage location for the
Number of
n number of data to be moved or the .U .U .U .U - - - - ○ ○ ○
move data
number of move data.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed

7 *2
at all times (at every scan).)
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.
Data move function

*3 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), the 16-bit / 32-bit data (unsigned / signed) stored in
S is moved to the word block of n starting with D . (When the move destination is 32-bit
data, the word block becomes the "specified number of move data x 2 words".)

• S : When move source is 16 bits (.U/.S)


D
D +1

D +2
...

S
D + n -3

D + n -2

D + n -1

• S : When move source 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]

7-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When move source is 64 bits (.DF)
[ D D +1 D +2 D +3]

[ D +4 D +5 D +6 D +7]

ARITHMETIC OPERATION FUNCTIONS


[ D +8 D +9 D +10 D +11]
S S +1 S +2 S +3]

[ D +4(n-3) D +4(n-3)+1 D +4(n-3)+2 D +4(n-3)+3]

[ D +4(n-2) D +4(n-2)+1 D +4(n-2)+2 D +4(n-2)+3]

[ D +4(n-1) D +4(n-1)+1 D +4(n-1)+2 D +4(n-1)+3]

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Move Instructions".

● Example of format
FMOV (MR1000, DM1000.U, EM2000, 5)

7
MR1000 FMOV S :DM1000
DM1000 EM2000 #5 D :EM2000
Execution condition n :#5の場合
Move source Move destination

Data move function


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)

Point When n =0, the function is not executed.

Sample Program

Programmed Script
FMOV (MR1008.U, MR1100.U, 2)
Operation Description The FMOV function can use bit data for the move source and move destination.
The content of one word (16 bits) starting from MR1008 is block-moved to two words (32
bits) starting from MR1100.

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

Reference • Data blocks (bit) at the move source and move destination will be moved successfully
even if they partially straddle channels.
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-5


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
PMOV

PMOV Move continuous bit information to a specified position

Partial move

PMOV ([execution condition,]*1 Move source, move destination start bit position,
move destination, move destination start bit
ARITHMETIC OPERATION FUNCTIONS

position, number of move bits)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Move Specifies the storage location for the *6
S .U .U .D .D .D - - - ○ ○
source*2*3 move source data. ○
Move source Specifies the storage location for the
n1 start bit start bit position of the move source or .U .U .U .U - - - - ○ ○ ○
position*4*5 the start bit position.
Move Handled as same type as
D Specifies the move destination. S . - - - ○ -
destination*2*3
Move Specifies the storage location for the
n2 destination start start bit position of the move .U .U .U .U - - - - ○ ○ ○
bit position*4*5 destination or the start bit position.
7 Number of
Specifies the storage location for the
number of data to be moved or the
n3 .U .U .U .U - - - - ○ ○ ○
move bits
number of move data.
Data move function

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 bit data is specified, it occupies continuous 16 bits (for .U) / 32 bits (for .D).
*3 S and D can be the same target.
*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 Specify 0 to 15 when the S move source is 16 bits (.U/.S), and specify 0 to 31 when it is 32
bits (.D/.L).
*6 A constant can be specified for the move source only when the following conditions are met.
• KV STUDIO Ver. 6.00 or higher
• Only when the compatible model is a KV-8000/7000 Series CPU unit, a KV-5500/5000/3000
Series CPU unit that has CPU function version 2.0 or higher, or a KV Nano Series base unit.

Description of Operation
When the execution condition is met (TRUE), the bits after the bit position specified by n1 of the 16-
bit / 32-bit data stored in S are moved to the bits after the bit position specified by n2 of D

in blocks (bits) by the number of bits specified by n3 .


• S : When move source 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-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When move source is 32 bits (.D/.L/.F)
n3
bit bit bit bit
31 16 15 0

[ S ・ S +1]

ARITHMETIC OPERATION FUNCTIONS


n1

bit bit bit bit


31 16 15 0

[ D ・ D +1]

n2

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Move Instructions".

Reference The original values of bits that are not moved (not destinationed for the move) are held as

7
they are.

● Example of format

Data move function


PMOV (R3000, DM1000.U, 2, EM2000, 4, 10)
R3000 PMOV
DM1000 #2 EM2000
Execution condition
Move source Move destination
device device
#4 #10

Point The function is not executed when either of the following conditions is established:
• When the suffix of S is .U, and n3 =0 or 16 <[ n1 + n3 ] or
16<[ n2 + n3 ].
• When the suffix of S is .D, and n3 =0 or 32 <[ n1 + n3 ] or
32<[ n2 + n3 ].

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-7


Sample Program
● To move bit data
ARITHMETIC OPERATION FUNCTIONS

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 blockmoved
(by bit) to the ten bits (MR2008 to MR2101) starting from the 4th bit of MR2004.U.
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
bit bit bit bit
15 MR2100 0 15 MR2000 0

7 ● When this function is used in combination with other functions

Programmed Script
PMOV (DM3000, EM3001, DM3100, EM3002, ANDA (EM3000, $7))
Data move function

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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function", page 7-22
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data move function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-9


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BYBMOV

BYBMOV Move continuous byte string information to specified position (H -> L)

BYBMOV

BYBMOV ([execution condition,]*1 move source byte string start, move source byte
offset, move destination byte string storage destination start,
ARITHMETIC OPERATION FUNCTIONS

move destination byte offset, number of move bytes)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Move source
Specifies the start that stores the move *3
byte string .U .S .D .L .F .DF .B .T - ○ -
source byte string data.
start*2
Specifies the storage location for the
n1
Move source position from the move source byte
.U .U .U .U - - - - ○ ○ ○
byte offset string start or specifies that position (0
to 65535).
D Move
Specifies the start of the move *3
destination byte .U .S .D .L .F .DF .B .T - ○ -
*2 destination byte string.
string start

7 n2 Move
destination byte
Specifies the storage location for the
position from the move destination byte
.U .U .U .U - - - -
string start or specifies that position (0 ○ ○ ○
offset
Data move function

to 65535).
Specifies the storage location for the
Number of
n3 number of data to move or the number .U .U .U .U - - - - ○ ○ ○
move bytes
of move data (1 to 65535).
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 data, specify the start of the channel.
• S and D can be the same target.
*3 The ".DF" suffix cannot be specified for device Z.

Point • The BYBMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used with KV-8000/7000 Series CPU units and KV-5500/5000/
3000 Series CPU units with CPU function version 2.0 or later.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), n3 bytes from the n1 th byte (counting from the
high-order byte) of S are moved to the ( n2 + n3 -1)th byte from the n2 th byte (counting
from the high-order byte) of D . The original values are saved in the bytes where data is not moved.

7-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Move source data
Position 0
Move start position n1 Data to move
bit bit
15 0

S A(41H) B(42H) S +1 C(43H) D(44H)

ARITHMETIC OPERATION FUNCTIONS


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 n3
S +3 2(32H) 3(33H) bytes S +4 F(46H) G(47H)
S +4 F(46H) G(47H)
7(37H) S(53H)
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
7

Data move function


Reference Manual", "Data Move Instructions".

● Example of format
BYBMOV (MR1000, DM2000, 4, EM4000, 2, 8)
BYBMOV
MR1000
DM2000 #4 EM4000

Execution condition Move source Move


Byte string destination
destination Byte string
destination

#2 #8

Point 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 highorder
byte) of the move destination byte string data starting with DM400.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-11


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BYLMOV

BYLMOV Move continuous byte string information to specified position (L -> H)

BYLMOV

BYLMOV ([execution condition,]*1 move source byte string start, move source byte
offset, move destination byte string storage destination start,
ARITHMETIC OPERATION FUNCTIONS

move destination byte offset, number of move bytes)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Move source byte Specifies the start that stores the move *3
.U .S .D .L .F .DF .B .T - ○ -
string start*2 source byte string data.
Specifies the storage location for the
n1 Move source
position from the move source byte string .U .U .U .U - - - - ○ ○ ○
byte offset
start or specifies that position (0 to 65535).
D Move destination Specifies the start of the move *3
.U .S .D .L .F .DF .B .T - ○ -
byte string start*2 destination byte string.
Move Specifies the storage location for the position
n2
destination byte from the move destination byte string start or .U .U .U .U - - - - ○ ○ ○
offset specifies that position (0 to 65535).
Specifies the storage location for the
7 n3
Number of
move bytes
number of data to move or the number .U .U .U .U - - - -
of move data (1 to 65535).
○ ○ ○

Return value None


Data move function

R - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
at all times (at every scan).)
*2 • For bit data, specify the start of the channel.
• S and D can be the same target.
*3 The ".DF" suffix cannot be specified for device Z.

Point • The BYLMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be used only with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or later and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), n3 bytes from the n1 th byte (counting from the low-
order byte) of S are moved to the ( n2 + n3 -1)th byte from the n2 th byte (counting from
the low-order byte) of D . The original values are saved in the bytes where data is not moved.
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 n3
S +3 2(32H) 3(33H) move bytes S +4 F(46H) G(47H)
S +4 F(46H) G(47H)
7(37H) S(53H)
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

7-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Move Instructions".

ARITHMETIC OPERATION FUNCTIONS


● Example of format
BYLMOV (MR1000, DM1000, 4, EM3000, 2, 8)
BYLMOV
MR1000
DM1000 #4 EM3000

Execution condition Move source Move


Byte string destination
destination Byte string
destination
#2 #8

Point When n3 =0, the function is not executed.

7
Sample Program

Data move function


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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-13


Ari

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


INC

INC Increament by 1

Increment memory

INC ([execution condition,]*1 Increment destination)


ARITHMETIC OPERATION FUNCTIONS

Recognized Type Const Device/ For


Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Increment Specifies the destination to increment
D .U .S .D .L - - - - - ○ -
destination*2 by 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 When bit data is specified, 16/32 continuous bits are processed.
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 The data of D is incremented by 1, and the result is stored in D .
Arithmetic Operation Functions

• D : When the increment destination is unsigned 16-bit data (.U)


An overflow occurs if the operation result is greater than 65535.
(When the count before the operation is 65535, the count becomes 0, and an overflow occurs.)
• D : When the increment destination 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.)
• D : When the increment destination 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.)
• D : When the increment destination 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.)

Point Arithmetic operation is performed normally even if an overflow occurs.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Arithmetic/Comparison Instructions".

● Example of format
INC (LDP ( MR2000 ), DM1000.U)
MR2000 DM1000
↑ INC
Execution condition Increment destination

7-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
There are two ways of incrementing the target data, by using operation formulas (DM1000 = DM1000 +

ARITHMETIC OPERATION FUNCTIONS


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 using 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 destination.

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.
7
Reference The KV script is converted to a ladder program before execution. To check the converted

Arithmetic Operation Functions


content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-15


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DEC

DEC Decrement by 1

Decrement memory

DEC ([execution condition,]*1 Decrement destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Decrement Specifies the destination to decrement
D .U .S .D .L - - - - - ○ -
destination*2 by 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 When bit data is specified, 16/32 continuous bits are processed.
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 The data of D is decremented by 1, and the result is stored in D .
Arithmetic Operation Functions

• D : When the decrement destination is unsigned 16-bit data (.U)


If operation result is less than 0, underflow will occur.
(When the count before the operation is 0, the count becomes 65535, and an underflow occurs.)
• D : When the decrement destination is signed 16-bit data (.S)
If operation result is less than -32768, underflow will occur.
(When the count before the operation is -32768, the count becomes +32767, and an underflow
occurs.)
• D : When the decrement destination is unsigned 32-bit data (.D)
If operation result is less than 0, underflow will occur.
(When the count before the operation is 0, the count becomes 4294967295, and an underflow
occurs.)
• D : When the decrement destination is signed 32-bit data (.L)
If operation result is less than -2147483648, underflow will occur.
(When the count before the operation is -2147483648, the count becomes +2147483647, and an
underflow occurs.)

Point Arithmetic operation is performed normally even if an underflow occurs.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Arithmetic/Comparison Instructions".

● Example of format
DEC (DM1000.U)
CR2002 DM1000
DEC
Always ON Decrement
destination

7-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
There are two ways of decrementing the target data, by using operation formulas (DM1000 = DM1000-

ARITHMETIC OPERATION FUNCTIONS


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 using 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 destination.

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

7
(OFF→ON) of MR1000.

Reference The KV script is converted to a ladder program before execution. To check the converted

Arithmetic Operation Functions


content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-17


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ROOT

ROOT Square root

Square root

Return value*1 = ROOT (operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .U .S .D .L .F .DF - - ○ ○ ○
destination the operation destination data.
ROOT function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Arithmetic Operation Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The square root of the data stored in S is calculated, and the result is stored in R .

• S : When operation destination is 16 bits (.U/.S)


High bit Low bit
TM0 S = R
32 bits 16 bits

• S : When operation destination is 32 bits (.D/.L)


High 32 bits Low 32 bits High bit Low bit
TM1 TM0 S +1・ S = R +1・ R
64 bits 32 bits

• S : When the operation destination is single-precision floating point type real number (.F)

S +1 S R +1 R
Single precision floating Single precision floating
point type real number point type real number
32 bits 32 bits
• S : When the operation destination 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 Double precision floating point
type real number type real number

64 bits 64 bits

7-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference When integer is specified for operation destination data:
• The 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

ARITHMETIC OPERATION FUNCTIONS


stored again as 16-bit/32-bit BIN data.
• The decimal point and below in the operation result are discarded.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Arithmetic/Comparison Instructions".

● Example of format
DM2000.U = ROOT (DM1000.U)
CR2002 DM1000 DM2000
LDA EXT ROOT STA
Always ON Operation destination Return value

Sample Program 7

Arithmetic Operation Functions


● When using operation formulas

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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-19


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SQRT

SQRT Square root

Square root

Return value*1 = SQRT (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .U .S .D .L .F .DF - - ○ ○ ○
destination the operation destination data.
SQRT function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 2
*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.

Point • The SQRT function can be used only with KV STUDIO Ver. 4.00 or higher.
• The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
7 • The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Arithmetic Operation Functions

Nano series base units.


"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
This function is similar to "ROOT function" except function name is different.
"ROOT function", page 7-18

7-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Arithmetic Operation Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-21


Lo

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


ANDA

ANDA Logical AND operation

ANDA

Return value*1 = ANDA (Operation destination, operation data)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S1 .U .U .D .D - - - - ○ ○ ○
destination*2 the operation destination data.
Specifies the storage location for the Handled as
Operation
S2 logical AND data or the logical AND same type as - - - - ○ ○ ○
data*2 S1 .
data.
ANDA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When bit data is specified, 16/32 continuous bits are processed. 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 *3 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
Logic Operation Functions

*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The logical AND operation of the data stored in S1 and binary data stored in S2 is executed.

● Example of format
• S1 : When operation destination is 16 bits (.U/.S)
DM2000.U = ANDA (DM1000.U, $00FF)
CR2002 DM1000 $FF DM2000
LDA ANDA STA
Always ON Operation destination Return value

bit bit
15 0
DM1000
S1 :Operation destination 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 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ANDA
destination
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-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When operation destination is 32 bits (.D/.L)
DM2100.D = ANDA (DM1100.D, $00FF00FF)
bit bit bit bit
31 16 15 0
DM1100

ARITHMETIC OPERATION FUNCTIONS


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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Logical Operation Functions".

● Logical AND operation truth table

Operation destination 0 0 1 1
Operation data 0 1 0 1 7
Return value 0 0 0 1

Logic Operation Functions


Sample Program
● To calculate the logical AND of the bit data

Programmed Script
DM2000.D = ANDA (MR1000.D, DM1100.D)
Operation Description 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.

● When this function is used in combination with other functions

Programmed Script
FMOV ( ANDA ( DM1000, $FF ), DM2000, 10 )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"FMOV function", page 7-4
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-23


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ORA

ORA Logical OR operation

ORA

Return value*1 = ORA (Operation destination, operation data)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S1 .U .U .D .D - - - - ○ ○ ○
destination*2 the operation destination data.
Operation Specifies the storage location for the Handled as
S2 same type as - - - - ○ ○ ○
data*2 logical OR data or the logical OR data. S1 .
ORA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When bit data is specified, 16/32 continuous bits are processed. 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 *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.
Logic Operation Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
The logical OR operation of the data stored in S1 and binary data stored in S2 is executed.

● Example of format
• S1 : When operation destination is 16 bits (.U/.S)
DM2000.U = ORA ( DM1000.U, $00FF )
CR2002 DM1000 $FF DM2000
LDA ORA STA
Always ON Operation data Return value

bit bit
15 0
DM1000
S1 :Operation destination 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 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-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When operation destination is 32 bits (.D/.L)
DM2100.D = ORA ( DM1100.D, $00FF00FF )
bit bit bit bit
31 16 15 0
DM1100

ARITHMETIC OPERATION FUNCTIONS


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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Logical Operation Functions".

● Logical OR operation truth table

Operation destination
Operation data
0 0 1 1
0 1 0 1 7
Return value 0 1 1 1

Logic Operation Functions


Sample Program
● To calculate the logical OR of the bit data

Programmed Script
DM2000.D = ORA ( MR1000.D, DM1100.D )
Operation Description The data stored in MR1000.D and the data stored in DM1100.D are ORed.
The result is stored in DM2000.D.

● When this function is used in combination with other functions

Programmed Script
R5000.U = ORA ( TBCD ( DM1000 ), $1111 )
Operation Description
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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TBCD function", page 7-80
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-25


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
EORA

EORA Exclusive OR operation

Exclusive ORAA

Return value*1 = EORA (Operation destination, operation data)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S1 .U .U .D .D - - - - ○ ○ ○
destination*2 the operation destination data.
Specifies the storage location for the Handled as
Operation
S2 exclusive OR data or the exclusive OR same type as - - - - ○ ○ ○
data*2 S1 .
data.
EORA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When bit data is specified, 16/32 continuous bits are processed. 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 *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.
Logic Operation Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
The exclusive OR operation of the data stored in S1 and the binary data stored in S2 is
executed.

● Example of format
• S1 : When operation destination is 16 bits (.U/.S)
DM2000.U = EORA ( DM1000.U, $00FF )
CR2002 DM1000 $FF DM2000
LDA EORA STA
Always ON Operation destination Return value

bit bit
15 0
DM1000
S1 :Operation destination 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 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-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When operation destination is 32 bits (.D/.L)
DM2100.D = EORA ( DM1100.D, $00FF00FF )
bit bit bit bit
31 16 15 0
DM1100

ARITHMETIC OPERATION FUNCTIONS


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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Logical Operation Functions".

● Exclusive OR operation truth table

Operation destination
Operation data
0 0 1 1
0 1 0 1 7
Return value 0 1 1 0

Logic Operation Functions


Sample Program
● To calculate the exclusive OR of the bit data

Programmed Script
DM2000.D = EORA ( MR1000.D, DM1100.D )
Operation Description The data stored in MR1000.D and the data stored in DM1100.D are exclusive ORed.
The result is stored in DM2000.D.

● 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 on data specified by the operation destination as the logic of only arbitrary bits
specified as 1 (ON) is inverted.

Programmed Script
R5000.U = EORA ( R5000.U, $00FF )
Operation Description 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.)

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-27


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ENRA

ENRA Exclusive NOR

Exclusive NORAA

Return value*1 = ENRA (Operation destination, operation data)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S1 .U .U .D .D - - - - ○ ○ ○
destination*2 the operation destination data.
Specifies the storage location for the Handled as
Operation
S2 exclusive NOR data or the exclusive same type as - - - - ○ ○ ○
data*2 S1 .
NOR data.
EORA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 When bit data is specified, 16/32 continuous bits are processed. 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 *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.
Logic Operation Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
The exclusive NOR operation of the data stored in S1 and the binary data stored in S2 is
executed, and the result is stored in R .

● Example of format
• S1 : When operation destination is 16 bits (.U/.S)
DM2000.U = ENRA ( DM1000.U, $00FF )
CR2002 DM1000 $FF DM2000
LDA ENRA STA
Always ON Operation destination Return value

bit bit
15 0
DM1000
S1 :Operation destination 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 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-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When operation destination is 32 bits (.D/.L)
DM2100.D = ENRA ( DM1100.D, $00FF00FF )
bit bit bit bit
31 16 15 0
DM1100

ARITHMETIC OPERATION FUNCTIONS


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 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Logical Operation Functions".

● Exclusive NOR operation truth table

Operation destination
Operation data
0 0 1 1
0 1 0 1 7
Return value 1 0 0 1

Logic Operation Functions


Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000 = BCNT ( ENRA ( MR1000.U, MR1100.U ) )
Operation Description 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.

Reference 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 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-29


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
COM

COM Bit inversion

Com plement

Return value*1 = COM (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
The type of COM function is identical to *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Logic Operation Functions

"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
Each of the bits of the BIN data stored in S is inverted.

• S : When the operation destination is 16 bits


bit bit
15 0

S :Operation destination 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

• S : When the operation destination is 32 bits


bit bit bit bit
31 16 15 0

S ・ S +1 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 +1 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Logical Operation Functions".

● Example of format
DM2000.U = COM ( DM1000.U )
CR2002 DM1000 DM2000
LDA COM STA
Always ON Operation destination Return value

7-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● Example of use

ARITHMETIC OPERATION FUNCTIONS


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.

Programmed Script
R5000.U = COM ( R5000.U )
Operation Description Output relays R5000 to R5015 invert (alternately turn ON/OFF) and output the current
output state at every scan.

Reference • The above script is equivalent to


R5000.U = EORA ( R5000.U, $FFFF ).
"EORA function", page 7-26
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Logic Operation Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-31


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
NEG

NEG Invert sign

Negative

Return value*1 = NEG (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .U .U .D .D .F .DF - - ○ ○ ○
destination the operation destination data.
TBCD function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Logic Operation Functions

"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
The plus/minus sign of the BIN data stored in S is inverted (2's complement is calculated).

• S : When the operation destination is 16 bits


bit bit
15 0

S :Operation destination 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

• S : When the operation destination 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
perform
#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-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination 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

ARITHMETIC OPERATION FUNCTIONS


bit bit
31 0

R ・ R +1 -1×Single precision floating point type real number

• S : When the operation destination is double-precision floating point type real number
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

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×D o u b l e p r e c i s i o n fl o a t i n g p o i n t t y p e r e a l n u m b e r

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series


Instruction Reference Manual", "Logical Operation Functions".

● Example of format
DM2000.S = NEG ( DM1000.S ) 7
CR2002 DM1000 DM2000

Logic Operation Functions


LDA.S NEG.S STA.S
Always ON Operation data Return value

Sample Program
● To invert the sign of the bit data

Programmed Script
DM2000.U = NEG ( MR1000.U )
Operation Description The plus/minus sign of the BIN data stored in MR1000 is inverted.
The result is stored in DM2000.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-33


Hint
The NEG function is used, for example, to invert the sign of a minus value to calculate the absolute
ARITHMETIC OPERATION FUNCTIONS

value as it can invert the plus/minus sign of BIN data specified by the operation destination.

Programmed Script IF DM1000.S < DM1100.S THEN


DM2000.S = NEG ( TOS ( DM1000.S - DM1100.S ) ) 'Sign of operation result inverted
ELSE
DM2000.S = TOS ( DM1000.S - DM1100.S )
END IF
Operation Description 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 Point When the NEG function is used on signed 16-bit data (.S), the range that can be
handled is -32768 to 32767. For this reason, the operation result becomes -32768
Logic Operation Functions

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-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Logic Operation Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-35


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ABS

ABS Absolute value

Absolute value

Return value*1 = ABS (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .U .S .D .L .F .DF - - ○ ○ ○
destination the operation destination data.
ABS function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 2
*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.

Point • The return value can be omitted. When omitted, the operation result is stored in
internal registers.
7 • The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Logic Operation Functions

Nano series base units.


"KV-5500/5000/3000 CPU Function Version", page -4

Description of Operation
The absolute value of binary data saved in S is saved to R .

• S :When the operation destination is unsigned 16/32-bit data (.U/.D)


S is saved to R without processing.

• S :When the operation destination is signed 16/32-bit data (.S/.L) or single/double precision
floating point type real number data (.F/.DF)
When S ≧0, it is saved to R without processing.
When S <0, it is saved to R after the sign is reverted (2's complement operation).
bit bit
15 0

S : Operation destination 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-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.S = ABS ( DM1000.S )

ARITHMETIC OPERATION FUNCTIONS


CR2002 DM1000 +0
LDA.S CMP.S
Always ON Operation destination
CR2009
NEG.S
Result of operation is minus

CR2002 DM2000
STA.S
Always ON Return value

Logic Operation Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-37


Da

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


SRA

SRA Shift right (bit unit)

Shift right A

Return value*1 = SRA (Operation destination, number of right shifts)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
Specifies the storage location for the
Number of right
n number of right shifts or the number of .U .U .U .U - - - - ○ ○ ○
shifts
right shifts.
SRA function type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Data Shift Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is right shifted by the number of bits specified with n , and "0" is stored in
the bits shifted right from the high-order bit.

• S : When the operation destination is 16 bits


bit ( n -1)
bit bit
15 0

S :Operation destination 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)

• S : When the operation destination 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-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2000.U = SRA ( DM1000.U, 5 )
CR2002 DM1000 #5 DM2000
LDA SRA STA
Always ON Operation destination Return value

Point • When n is "0", the value of S is stored in R .


• When S is .U and n ≧ 17, and S is .D and n ≧ 33, the operation
results will be 0.

Sample Program
● To shift a bit data right
7

Data Shift Functions


Programmed Script
DM2000.U = SRA ( R1000.U, 10 )
Operation Description The data currently stored in R1000.U is shifted to the right by 10 bits.
The result is stored in DM2000.U.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-39


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SLA

SLA Shift left (bit unit)

Shift left A

Return value*1 = SLA (Operation destination, number of left shifts)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
Specifies the storage location for the
Number of left
n number of left shifts or the number of .U .U .U .U - - - - ○ ○ ○
shifts
left shifts.
SLA function type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Data Shift Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is left shifted by the number of bits specified with n , and "0" is stored in
the bits shifted left from the low-order bit.

• S : When the operation destination 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

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)

• S : When the operation destination 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

1 Store 0
CR2009
(Carry)

7-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2000.U = SLA ( DM1000.U, 5 )
CR2002 DM1000 #5 DM2000
LDA SLA STA
Always ON Operation destination Return value

Point • When n is "0", the value of S is stored in R .


• When S is .U and n ≧ 17, and S is .D and n ≧ 33, the operation
results will be 0.

Sample Program
● To shift a bit data left 7

Data Shift Functions


Programmed Script
DM2000.U = SLA ( MR1000.U, 10 )
Operation Description The data currently stored in MR1000.U is shifted to the left by 10 bits.
The result is stored in DM2000.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Hint
The SLA function is used, for example, to disperse and unite data stored in word data, etc. as it can
shift any number of bits to the left.
Programmed Script
DM2000 = ANDA ( DM1000, $F )
DM2000 = ORA ( DM1000, SLA ( ANDA ( DM1001, $F ), 4 ) )
DM2000 = ORA ( DM1000, SLA ( ANDA ( DM1002, $F ), 8 ) )
DM2000 = ORA ( DM1000, SLA ( DM1003, 12 ) )
Operation Description The BCD data stored in DM1000, DM1001, DM1002, and DM1003 is united as 4-digit
BCD one digit at a time from the low-order bit, and stored in DM2000.
bit bit bit
15 4 0

DM1000: 1

DM1001: 2

DM1002: 3

DM1003: 4

bit bit bit bit


15 8 7 0

DM2000: 4 3 2 1

Reference The above script functions in an equivalent way to data conversion instruction UNIN (nibble unit).
"ANDA function", page 7-22
"ORA function", page 7-24
"UNIN function", page 7-94
KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference
Manual, "Data Conversion Instructions" "UNIN Instruction"
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-41
KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ASRA

ASRA Arithmetic right shift A (bit unit)

Arithmetic shift right A

Return value*1 = ASRA (Operation destination, number of right shifts)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .S .D .L - - - - ○ ○ ○
destination the operation destination data.
Number of Specifies the storage location for the
n arithmetic right number of right shifts or the number of .U .U .U .U - - - - ○ ○ ○
shifts right shifts.
ASRA function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 2
*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.

7 Point • The ASRA function can be used only with KV STUDIO Ver.6.00 or higher.
• This function can be used only with KV-8000/7000 Series CPU units, KV-5500/5000/3000
Series CPU units with CPU function version 2.0 or later and KV Nano Series base units.
Data Shift Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is right shifted by the number of bits specified with n . When S ≧ 0,
"0" is stored in the bits shifted right from the high-order bit, and "1" is stored when S <0.
• S : When the operation destination is unsigned 16-bit data

bit
bit( n −1) bit
15 0
S :59417
S :Operation destination 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)

• S : When the operation destination is signed 16-bit data


( n −1)
bit
bit bit
15 0
S :−1000
S :Operation destination 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-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is unsigned 32-bit data
( n −1)
bit
bit bit
31 0

S ・ S +1 11101000000110011110100000011001 3894011929

ARITHMETIC OPERATION FUNCTIONS


n=5

R ・ R +1 00000111010000001100111101000000 1 10 01 121687872

High n bits Delete

1
Store 0
CR2009
(Carry)

• S : When the operation destination is signed 32-bit data


( n −1)
bit
bit bit
31 0

S ・ S +1 CR2009
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(キャリー)
1110 −1865478994

n=4
7
R ・ R +1 11111001000011001111000011001010 1 1 1 0 −116592438

Data Shift Functions


High n bits Delete

1
Stores signed value
When S value is 0 or more: 0 CR2009
Less than 0: 1 (Carry)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

● Example of format
DM2000.U = ASRA ( DM1000.U, 5 )
CR2002 DM1000 #5 EM2000
LDA ASRA STA
Always ON Operation destination Return value

Point • When n is "0", the value of S is stored in R .


• When S is .U and n ≧ 17, and S is .D and n ≧ 33, the operation
results will be 0.

Sample Program

Programmed Script
DM2000.U = ASRA ( R1000.U, 10 )
Operation Description The data currently stored in R1000.U is shifted to the right by 10 bits.
The result is stored in DM2000.U.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-43


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ASLA

ASLA Arithmetic left shift (bit unit)

Arithmetic shift left A

Return value*1 = ASLA (Operation destination, number of left shifts)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .S .D .L - - - - ○ ○ ○
destination the operation destination data.
Number of Specifies the storage location for the number
n .U .U .U .U - - - - ○ ○ ○
arithmetic left shifts of left shifts or the number of left shifts.
ASLA function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 2
*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.

• The ASLA function can be used only with KV STUDIO Ver.6.00 or higher.
7 Point
• This function can be used only with KV-8000/7000 Series CPU units, KV-5500/5000/3000
Series CPU units with CPU function version 2.0 or later and KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
Data Shift Functions

Description of Operation
The data stored in S is left shifted by the number of bits specified with n , and "0" is stored in
the bits shifted left from the low-order bit.
• S : When the operation destination is 16-bit data
bit
bit(16− n ) bit
15 0

S : Operation destination 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)

• S : When the operation destination is 32-bit data


(32− n )
bit
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 11 10 100000011001111010000001100100000
54330144
Delete Low n bits

1
CR2009 Store 0
(Carry)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

7-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.U = ASLA ( MR1000.U, 5 )
CR2002 DM1000 #5 EM2000

ARITHMETIC OPERATION FUNCTIONS


LDA ASLA STA

Always ON Operation destination Return value

Point • When n is "0", the value of S is stored in R .


• When S is .U and n ≧ 17, and S is .D and n ≧ 33, the operation
results will be 0.

Sample Program

DM2000.U = ASLA ( R1000.U, 10 )


7
Programmed Script

Operation Description The data currently stored in R1000.U is shifted to the left by 10 bits.
The result is stored in DM2000.U.

Data Shift Functions


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-45


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RRA

RRA Right rotate (bit unit, with carry)

Rotate right A

Return value*1 = RRA (Operation destination, number of right rotates)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
Specifies the storage location for the
Number of right
n number of right rotates or the number .U .U .U .U - - - - ○ ○ ○
rotates
of right rotates.
RRA function type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Data Shift Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is rotated to the right by the number of bits specified with n with carry flag
(CR2009).

• S : When the operation destination 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
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 rotates (rotate by n bits)

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-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is 32 bits

ARITHMETIC OPERATION FUNCTIONS


Status of marking
differs for different
previous calculate result.
(1-bit rotate)

(Carry)
n rotates (rotate by n bits)


(Carry)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

● Example of format 7
DM2000.U = RRA ( DM1000.U, 10 )

Data Shift Functions


CR2002 DM1000 #10 DM2000
LDA RRA STA
Always ON Operation destination Return value

Point When the data is rotated to the right, the LSB is stored in carry flag (CR2009).

Sample Program
● To rotate a bit data right

Programmed Script
DM2000 = RRA ( R1000.U, 10 )
Operation Description The data currently stored in R1000.U is rotated to the right by 10 bits.
The result is stored in DM2000.

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.D, 1 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-47


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RLA

RLA Left rotate (bit unit, with carry)

Rotate left A

Return value*1 = RLA (Operation destination, number of left rotates)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
Specifies the storage location for the
Number of left
n number of left rotates or the number of .U .U .U .U - - - - ○ ○ ○
rotates
left rotates.
RLA function type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Data Shift Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is rotated to the left by the number of bits specified with n with carry flag
(CR2009).

• S : When the operation destination 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
previous calculate result.

CR2009

1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1
(Carry)
n rotates (rotate by n bits)

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-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination 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

ARITHMETIC OPERATION FUNCTIONS


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)
n rotates (rotate by n bits)

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

● Example of format 7
DM2000.U = RLA ( DM1000.U, 10 )

Data Shift Functions


CR2002 DM1000 #10 DM2000
LDA RLA STA
Always ON Operation destination Return value

Point When the data is rotated to the left, the MSB is stored in carry flag (CR2009).

Sample Program
● To rotate a bit data left

Programmed Script
DM2000.U = RLA ( R1000.U, 10 )
Operation Description The data currently stored in R1000.U is rotated to the left by 10 bits.
The result is stored in DM2000.

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 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-49


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RRNCA

RRNCA Right rotate (bit unit, without carry)

Rotate right A without a carry

Return value*1 = RRNCA (Operation destination, number of right rotates)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - - - ○ ○ ○
destination operation destination.
Number of right Specifies the number of right rotates or
n .U .U .U .U - - - - ○ ○ ○
rotates*2 its storage location.
RRNCA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 3
*1 The return value can be omitted. When omitted, the conversion result is stored in internal
registers.
*2 When a target has been specified to n , operation is as follows when the value of n is 16
or more (when the operation destination has a .U suffix) or 32 or more (when the operation
destination has a .D suffix).
7 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
Data Shift Functions

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
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is rotated to the right by the number of bits specified with n without a
carry, and the result is stored in R .

• S : When the operation destination is 16 bits


bit bit
15 0
Operation
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 S : destination

(1-bit rotate)

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

n rotates (rotate by n bits)

bit bit
15 0

1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 R :Return value

CR2009 (キャリー) 1

7-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination 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

ARITHMETIC OPERATION FUNCTIONS


(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 rotates (rotate by n bits)

bit bit
31 0

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

The state of the LSB as a result of having performed a rotate is entered to the carry flag
7
Reference

(CR2009).

Data Shift Functions


● Example of format
DM2000.U = RRNCA ( DM1000.U, 10 )
CR2002 DM1000 #10 DM2000
LDA RRNCA STA
Always ON Operation destination Return value

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2100.D = TBIN ( RRNCA ( DM1100.D, 16 ))
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TBIN function", page 7-82
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-51


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RLNCA

RLNCA Left rotate (bit unit, without carry)

Rotate left A without a carry

Return value*1 = RLNCA (Operation destination, number of left rotates)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - - - ○ ○ ○
destination operation destination.
Number of left Specifies the number of left rotates or
n .U .U .U .U - - - - ○ ○ ○
rotates*2 its storage location.
RLNCA function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 3
*1 The return value can be omitted. When omitted, the conversion result is stored in internal
registers.
*2 When a target has been specified to n , operation is as follows when the value of n is 16
or more (when the operation destination has a .U suffix) or 32 or more (when the operation
destination has a .D suffix).
7 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
Data Shift Functions

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
automatically conducted during conversion.
*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is rotated to the left by the number of bits specified with n without a carry,
and the result is stored in R .

• S : When the operation destination is 16 bits


bit bit
15 0
Operation
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 S : destination

(1 bit cycle)

1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1
n rotates (rotate by n bits)

bit bit
15 0

0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 R :Return value

CR2009 (Carry) 0

7-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination 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

ARITHMETIC OPERATION FUNCTIONS


(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 rotates (rotate by n bits)

bit bit
31 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 1 0 R ・ R +1

CR2009 (Carry) 0

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

The state of the MSB as a result of having performed a rotate is entered to the carry flag
7
Reference

(CR2009).

Data Shift Functions


● Example of format
DM2000.U = RLNCA ( DM1000.U, 10 )
CR2002 DM1000 #10 DM2000
LDA RLNCA STA
Always ON Operation destination Return value

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2100.D = TBIN ( RLNCA ( DM1100.D, 16 ))
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TBIN function", page 7-82
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-53


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
WSR

WSR Shift word device right

Shift word right

WSR ([execution condition,]*1 operation destination, number of operation range


ARITHMETIC OPERATION FUNCTIONS

data, number of shifts)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or
D .U .U .D .D .D - - - - ○ -
destination*2 the operation destination data.
Number of Specifies the storage location for the
n1
operation range number of data in the range to be shifted .U .U .U .U - - - - ○ ○ ○
data right or the number of right shift range data.
Number of Specifies the storage location for the number
n2 .U .U .U .U - - - - ○ ○ ○
shifts of right shifts 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).)

7 *2 When bit data is specified, 16/32 continuous bits are processed.


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.
Data Shift Functions

Description of Operation
When the execution condition is established (TRUE), data (16-bit/32-bit) stored in the range of the
number of data specified by n1 starting from D is shifted to the right (towards the larger device
No. / array subscript) by the number of data specified with n2 .
0 is stored in the part where the shift source range does not overlap with the shift target range.
• D : When the operation destination 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 + n1 −1 9000
...

n2
8000
( D + n1 −1)+ n2 9000

• D : When the operation destination 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

7-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

ARITHMETIC OPERATION FUNCTIONS


Reference When the operation destination is 32-bit data, the number of operation range data and
number of shifts becomes "number of specified data × 2 words".

● Example of format
WSR ( R3000, DM1000.U, 32, 10 )
R3000 WSR
DM1000 #32 #10
Execution condition
Conversion destination

Point • When n1 =0, the function is not executed.


• When n2 = 0, the operation result does not change with before the operation
was executed.
7
Sample Program

Data Shift Functions


● When this function is used in combination with other functions

Programmed Script
WSR ( DM3000, EM3000, ANDA ( EM3001, $F ) )
Operation Description The 16-bit data currently stored in range of words specified by EM3000 is shifted to the
right by the number of words specified by the lower 4 bits (extracted) of EM3001 starting
from DM3000 at every scan (no execution condition).
"0" is stored in sections in the shift source range that do not straddle the shift destination
range

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function"
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-55


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
WSL

WSL Shift word device left

Shift word left

WSL ([execution condition,]*1 operation destination, number of operation range


ARITHMETIC OPERATION FUNCTIONS

data, number of shifts)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the start of the range to shift
S .U .U .D .D .D - - - - ○ -
destination*2 left.
Number of Specifies the storage location for the number of
n1 operation range data in the range to be shifted left or the number .U .U .U .U - - - - ○ ○ ○
data of left shift range data.
Specifies the storage location for the
Number of
n2 number of left shifts or the number of .U .U .U .U - - - - ○ ○ ○
shifts
left shifts.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed

7 *2
at all times (at every scan).)
When bit data is specified, 16/32 continuous bits are processed.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified,
Data Shift Functions

the relay is handled in16/32 bits straddling the next channel.

Description of Operation
When the execution condition is established (TRUE), data (16-bit/32-bit) stored in the range of the
number of data specified by n1 starting from D is shifted to the left (towards the smaller device
No. / array subscript) by the number of data specified with n2 .
"0" is stored in sections in the shift source range that do not straddle the shift destination range

• D : When the operation destination is 16 bits


Before perform After perform

D - n2 1000
( D +1)- n2 2000
n2
...

D 1000
D +1 2000
8000
( + −1)- 9000
...

D n1 n2
n1
0
0
Store 0
8000 0
D + n1 −1 9000 0

7-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• D : When the operation destination is 32 bits
Before perform After perform

ARITHMETIC OPERATION FUNCTIONS


( 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
+2( −1)+1)-2 900000

...
D n1 n2 ( D +2( n1 −1)-2 n2
n1
0
0
Store 0
800000 0
D +2( n1 −1)+1 900000 D +2( n1 −1) 0

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Shift Instructions".

Reference When the operation destination is 32-bit data, the number of operation range data and 7
number of shifts becomes "number of specified data × 2 words".

Data Shift Functions


● Example of format
WSL ( R3000, DM1000.U, 32, 10 )
R3000 WSL
DM1000 #32 #10
Execution condition
Operation destination

Point • When n1 =0, the function is not executed.


• 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 ))
Operation Description The 16-bit data currently stored in range of words specified by EM3000 is shifted to the
left by the number of words specified by the lower 4 bits (extracted) of EM3001 starting
from DM3000 at every scan (no execution condition).
"0" is stored in sections in the shift source range that do not straddle the shift destination
range

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function"
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-57


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BSR

BSR Shift bit device right

Bit shift right

BSR ([execution condition,]*1 operation destination, number of operation range


ARITHMETIC OPERATION FUNCTIONS

destinations, number of shifts)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the start of the range to shift
S
destination*2*3 right. - - - - - - .B - - ○ -
Specifies the storage location for the
Number of
number of destinations in the range to
n1 operation range .U .U .U .U - - - - ○ ○ ○
be shifted right or the number of right
data
shift range destinations.
Number of Specifies the storage location for the number
n2 .U .U .U .U - - - - ○ ○ ○
shifts of right shifts 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

7 *2
at all times (at every scan).)
When bit data has been specified, the program will function normally even if the bit data straddles channels.
When word data has been specified, the LSB of n1 word data is shifted. Bits other than the
Data Shift Functions

LSB do not change.


*3 T, C, CR, CTC, CTH, Z, CM cannot be used.

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. / array subscript) by n2 shifts. When D is word
data, 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 data) in the shift source range that do not straddle
the shift destination range.

● Example of format
BSR ( R3000, MR1002, 3, 4)
R3000 BSR.D
MR1002 #3 #4
Execution condition
Operation destination

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Shift Instructions".

Point • When n2 = 0, the operation result does not change with before the operation
was executed.
• The function is not executed when either of the following conditions is established:
• When the shift destination exceeds the device or variable range
• When n1 is "0".

7-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When this function is used in combination with other functions

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
BSR ( DM3000.B, EM3000, ANDA ( EM3001, $F ) )
Operation Description The state of the LSBs of the number of word data 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 the least significant bit of the shift source range that does not overlap with
the shift target range.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function", page 7-22
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Data Shift Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-59


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BSL

BSL Shift bit device left

Bit shift left

BSL ([execution condition,]*1 operation destination, number of operation range


ARITHMETIC OPERATION FUNCTIONS

destinations, number of shifts)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the start of the range to shift
S
destination*2*3 left. - - - - - - .B - - ○ -
Specifies the storage location for the
Number of
number of destinations in the range to
n1 operation range .U .U .U .U - - - - ○ ○ ○
be shifted left or the number of left shift
data
range destinations.
Number of Specifies the storage location for the number
n2 .U .U .U .U - - - - ○ ○ ○
shifts of left shifts 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

7 *2
at all times (at every scan).)
When bit data has been specified, the program will function normally even if the bit data straddles channels.
When word data has been specified, the LSB of n1 word data is shifted. Bits other than the
Data Shift Functions

LSB do not change.


*3 T, C, CR, CTC, CTH, Z, CM cannot be used.

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. / array subscript) by n2 shifts. D is word data,
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 data) in the shift source range that do not straddle
the shift destination range.
"0" is stored in sections 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 condition
Operation destination

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Shift Instructions".

Point • When n2 = 0, the operation result does not change with before the operation
was executed.
• The function is not executed when either of the following conditions is established:
• When D - n1 >0.
• When n1 is "0".
7-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Sample Program
● When this function is used in combination with other functions

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
BSL ( DM3000.B, EM3000, ANDA ( EM3001, $F ) )
Operation Description The state of the LSBs of the number of word data 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 the least significant bit of the shift source range that does not overlap with
the shift target range.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function", page 7-22
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Data Shift Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-61


Da

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


LIMIT

LIMIT Upper/lower limit value control

Limit

Return value*1 = LIMIT (Lower limit value, upper limit value, input value)
ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Lower limit*2 Specifies the lower limit value or the
(min. output storage location for the lower limit .U .S .D .L - - - - ○ ○ ○
threshold value) value.
S2 Upper limit*2 Specifies the upper limit value or the Handled as
(max. output storage location for the upper limit same type as - - - - ○ ○ ○
threshold value) value. S1 .
Specifies the upper / lower limit control Handled as
S3 Input value*2 input value or the storage location for same type as - - - - ○ ○ ○
the input value. S1 .
LIMIT function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
7 *2 • When bit data is specified, 16/32 continuous bits are processed. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in 16/
Data Control Functions

32 bits straddling the next channel.


• When 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.

Point • When using KV-1000, please use system macro "LIMITS" and "LIMITL".
• The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
Upper/lower limit control is performed for S3 via S2 and S1 , and the result is stored in R .
Output value Output value

Upper limit
Input value

Input value

Lower limit

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Control Instructions".

7-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
• S1 : When lower limit value is 16 bits (.U/.S)

ARITHMETIC OPERATION FUNCTIONS


DM1000.U = LIMIT ( DM2000.U, DM2100, DM2200 )
CR2002 LIMIT
DM2000 DM2100 DM2200 @VMO
Always ON
Lower limit Upper limit Input value

@VM0 DM1000
LDA STA
Return value

Condition Value stored in R


(Input value)
S1 (Lower limit
value) > S3 S1 (Lower limit
value)
(Upper limit (Upper limit
S2 value) < S3 (Input value)
S2 value)
(Lower limit (Upper limit
S1 value) ≦ S3 (Input value) ≦ S2 value) S3 (Input value)

• S1 : When lower limit value is 32 bits (.D/.L)


7
DM1100.D = LIMIT ( DM2010.D, DM2110, DM2210 )

Data Control Functions


CR2002 LIMIT.D
DM2010 DM2110 DM2210 @VMO
Always ON
Lower limit Lower limit Input value

@VM0 DM1100
LDA.D STA.D
Return value

Condition Value stored in[ R ・ 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-63


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BANDC

BANDC Dead band control

Dead band control

Return value*1 = BANDC (Lower limit for dead band, upper limit for dead band,
ARITHMETIC OPERATION FUNCTIONS

input value)

Recognized Type Const Device/ For


Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Dead band
Specifies the lower limit value or the
(non-output
storage location for the lower limit .S .S .L .L - - - - ○ ○ ○
range) lower
value.
limit value*2
S2 Dead band
Specifies the upper limit value or the Handled as
(non-output
storage location for the upper limit same type as - - - - ○ ○ ○
range) upper S1 .
value.
limit value*2
Specifies the dead band control input Handled as
S3 Input value*2 value or the storage location for the same type as - - - - ○ ○ ○
input value. S1 .

7 R Return value
BANDC function type is identical to the
1st argument.* 3
*4
.U .S .D .L .F .DF - - - ○ -
Data Control Functions

*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
*2 • When bit data is specified, 16/32 continuous bits are processed. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in 16/
32 bits straddling the next channel.
• When 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.

Point • When using KV-1000, please use system macro "BANDS" and "BANDL".
• The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Control Instructions".

7-64 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
• S1 : When dead band (no output area) lower limit value is 16 bits (.S)
DM1000.S = BANDC ( DM2000.S, DM2100, DM2200 )

ARITHMETIC OPERATION FUNCTIONS


CR2002 BANDC.S
DM2000 DM2100 DM2200 @VM2
Always ON
dead spots dead spots Input value
upper limit lower limit
@VM2 DM1000
LDA.S STA.S
Return value

Condition Value stored in R


(Lower limit (Lower limit
S1 value) > S3 (Input value) S3 (Input value) − S1 value)
(Upper limit
S2 value) < S3 (Input value) S3 (Input value) − S2 (Upper limit
value)
(Upper limit
S1 (Lower limit
value) ≦ S3 (Input value)
≦ S2 value) 0
*The value with 16-bit symbol within the BIN data range is stored in R .
• R ≦-32768→ R =-32768
• R ≧+32767→ R =+32767
7
• S1 : When dead band (no output area) lower limit value is 32 bits (.L)

Data Control Functions


DM1100.L = BANDC ( DM2010.L, DM2110, DM2210 )
CR2002 BANDC.L
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 ・ 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-bit 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-65


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ZONE

ZONE Zone control

ZONE

Return value*1 = ZONE (Negative bias, positive bias, input value)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the negative bias value
S1
Negative bias*2 added to the input value or the storage .S .S .L .L - - - - ○ ○ ○
location for the negative bias value.
Specifies the positive bias value added Handled as
S2
Positive bias*2 to the input value or the storage same type as - - - - ○ ○ ○
location for the positive bias value. S1 .
Specifies the zone control input value Handled as
S3 Input value*2 or the storage location for the input same type as - - - - ○ ○ ○
value. S1 .
ZONE function type is identical to the *4
R Return value .U .S .D .L .F .DF - - - ○ -
1st argument.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
7 *2 • When bit data is specified, 16/32 continuous bits are processed. When a relay other than the
leading relay (e.g. R002, R1012) of the channel has been specified, the relay is handled in 16/
Data Control Functions

32 bits straddling the next channel.


• When 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.

Point • ZONE function is special function of KV-5500/5000/3000. When using KV-1000,


please use system macro "ZONES" "ZONEL".
• The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Control Instructions".

7-66 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
• S1 : When negative bias value is 16 bits (.S)
DM1000.S = ZONE ( DM2000.S, DM2100, DM2200 )

ARITHMETIC OPERATION FUNCTIONS


CR2002 ZONE.S
DM2000 DM2100 DM2200 @VMO
Always ON
Negative Plus deviation Input value
deviation
@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-bit symbol within the BIN data range is stored in R .
• R ≦-32768→ R =-32768
• R ≧+32767→ R =+32767
7
• S1 : When negative bias value is 32 bits (.L)

Data Control Functions


DM1100.L = ZONE ( DM2010.L, DM2110, DM2210 )
CR2002 ZONE.L
DM2010 DM2110 DM2210 @VMO
Always ON
Negative Plus deviation Input value
deviation
@VM0 DM1100
LDA.L STA.L
Return value

Condition Value stored in [ R ・ 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-bit 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-67


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
APR

APR Linear approximation (Scaling)

Linear approximation

Return value*1 = APR (Input value, start of data table, number of data records)
ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the input value of polyline *5
S1 Input value*2 approximation or the storage location .U .S .D .L .F .DF - - ○ ○ ○
for the input value.
S2 Start of data Specifies the start to store the polyline Handled as
same type as - - - - - ○ -
table*3 data table. S1 .
n Specifies the number of polyline data
Number of data
records or the storage location for the .U .U .U .U - - - - ○ ○ ○
records
number of records.
APR function type is identical to the 1st *5
R Return value .U .S .D .L .F .DF - - - ○ -
argument.*4
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.

7
*2 • When bit data is specified, 16/32/64 continuous bits are processed. 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/64 bits straddling the next channel.
Data Control Functions

• When specifying CTH, current value is processed. When using CTC, process setting value.
*3 When S1 type is .F or .DF, T and 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.
*5 The ".DF" suffix cannot be specified for device Z.

Point • When using KV-1000, please use system macro "APRS" "APRL" "APRF".
• The argument ".DF" can be used only with KV STUDIO Ver.9.0 or later.
• The argument ".DF" can be specified only with KV-8000 series CPU units and KV-
7000 series CPU units with CPU function version 2.0 or later.
• The return value ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The return value ".DF" can be specified only with KV-8000/7000 series CPU units,
KV-5500/5000/3000 series CPU units with CPU function version 2.0 or later, and
KV Nano series base units.
"KV-7500/7300 CPU Function Version", page 3
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
• S1 : When input value is 16 bits (.U/.S)
Approximate calculation is performed for the "input value" of linear approximation stored in S1
according to the "polyline data table" stored with n records starting with S2 .
The linear approximate calculation searches in which range of polyline data table S1 is located, and the
linear approximate calculation is performed at previous and next two points. The result is stored in R .
Broken data form
Y
(X 2,Y2) (X 3,Y3) Index X Y
S2 0 0 10
YP Leading
• • of table 1 8 13
2 14 20
(X 1,Y1) 3 20 20 n

(X 0,Y0) 4 23 6
(X 4,Y4) (X 5,Y5)
5 26 6
Number
6 28 0 of records

XP (X 6,Y6)
Y2−Y 1 Please remember store data of X in ascending order.
YP = (X P−X 1)+Y1
X2−X 1

7-68 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Please set X value of polyline data table according to ascending sequence. (X0 < X1 … < Xk … <Xn)
Please store the polyline data table from [ S2 ] in the order of (X0, Y0), (X1, Y1)…(Xn-1, Yn-1), (Xn,
Yn).

ARITHMETIC OPERATION FUNCTIONS


Index X Y
S2 0 S2 S2 +1

Leading 1 S2 +2 S2 +3
of table
2 S2 +4 S2 +5

3 S2 +6 S2 +7

4 S2 +8 S2 +9

5 S2 + 10 S2 + 11

6 S2 + 12 S2 + 13

Please store the number of polyline data table records to n (number of records). In addition,
n shall take the value more than 2.

When S1 (input value)<X0, Y0 is stored in R .


When
When
S1
S1
(input value)<Xn, Yn is stored in
(input value)<Xk, Yk is stored in
R
R
.
.
7

Data Control Functions


• S1 : When input value is 32 bits (.D/.L)
Approximate calculation is performed for the "input value" of linear approximation stored in [ S1 /
S1 +1] according to the "polyline data table" stored with n records starting with [ S2 /
S2 +1].

The linear approximate calculation searches in which range of polyline data table [ S1 / S1 +1] is
located, and the linear approximate calculation is performed at previous and next two points.
The calculation result is stored in [ R / R +1].
Broken data form
Y
(X 2,Y2) (X 3,Y3) Index X Y
[ S2 ・ S2 +1 ] 0 0 10
YP Leading of table 1 8 13
2 14 20
(X 1,Y1)
3 20 20 [ n ]
(X 0,Y0) 4 23 6
(X 4,Y4) (X 5,Y5)
5 26 6
Number
X 6 28 0 of records
XP (X 6,Y6)
Y2−Y 1
YP = (X P−X 1)+Y1
X2−X 1
Please store the polyline data table from [ S2 / S2 +1] in the order of (X0, Y0), (X1, Y1)…(Xn-1,
Yn-1), (Xn, Yn).
Please store the number of polyline data table records to [ n ] (number of records).
In addition, [ n ] shall take the value more than 2.

When [ S1 / S1 +1]<X0, Y0 is stored in [ R / R +1].


When [ S1 / S1 +1]<Xn, Yn is stored in [ R / R +1].
When [ S1 / S1 +1]<Xk, Yk is stored in [ R / R +1] (k=1~n).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-69


• S1 : When input value is 32 bits (.F)
Approximate calculation (single-precision floating point type) is performed for the "input value" of
linear approximation stored in [ S1 / S1 +1] according to the "polyline data table" stored with
n records starting with [ S2 / S2 +1].
ARITHMETIC OPERATION FUNCTIONS

The linear approximate calculation searches in which range of polyline data table [ S1 / S1 +1] is
located, and the linear approximate calculation is performed at previous and next two points.
The calculation result is stored in [ R / R +1].

Y Broken data form


(X 2,Y2) (X 3,Y3)
Index X Y
[ S2 ・ S2 +1 ] 0 0 5.2
YP
Leading of table 1 3.3 6.8

(X 1,Y1) 2 5.7 13.9


3 7.9 13.9 [ n ]
(X 0,Y0)
(X 4,Y4) (X 5,Y5) 4 9.9 2.1

7
5 12.2 2.1
X Number
XP (X 6,Y6) 6 15.5 0 of records
Y2−Y 1
YP = (X P−X 1)+Y1
Data Control Functions

X2−X 1

Please store the polyline data table from [ S2 / S2 +1] in the order of (X0, Y0), (X1, Y1)…(Xn-1,
Yn-1), (Xn, Yn).
Please set X value of polyline data table according to ascending sequence. (X0 < X1 … < Xk … <Xn)

Please store the number of polyline data table records to [ n ] (number of records).
In addition, [ n ] shall take the value more than 2.

When [ S1 / S1 +1]<X0, Y0 is stored in [ R / R +1].


When [ S1 / S1 +1]<Xn, Yn is stored in [ R / R +1].
When [ S1 / S1 +1]=Xk, Yk is stored in [ R / R +1] (k=1~n).

7-70 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When input value is 64 bits (.DF)
Approximate calculation (double-precision floating point type) is performed for the "input value" of
linear approximation stored in [ S1 / S1 +1/ S1 +2/ S1 +3] according to the "polyline data
table" stored with n records starting with [ S2 / S2 +1/ S2 +2/ S2 +3].

ARITHMETIC OPERATION FUNCTIONS


The linear approximate calculation searches in which range of polyline data table [ S1 / S1 +1/
S1 +2/ S1 +3] is located, and the linear approximate calculation is performed at previous and
next two points.
The calculation result is stored in [ R / R +1/ R +2/ R +3].

Y Broken data form


(X 2,Y2) (X 3,Y3)
Index X Y
[ S2 ・ S2 +1 0 0 5.2
Y•
・ S2 +2 1 3.3 6.8
・ S2 +3]
(X 1,Y1) 2 5.7 13.9
Leading of table
3 7.9 13.9 [ n ]
(X 0,Y0)

7
(X 4,Y4) (X 5,Y5) 4 9.9 2.1
5 12.2 2.1
X Number
XP (X 6,Y6) 6 15.5 0 of records

Data Control Functions


Y2−Y 1
YP = (X P−X 1)+Y1
X2−X 1

Please store the polyline data table from [ S2 / S2 +1/ S2 +2/ S2 +3] in the order of (X0, Y0),
(X1, Y1)…(Xn-1, Yn-1), (Xn, Yn).
Please set X value of polyline data table according to ascending sequence. (X0 < X1 … < Xk … <Xn)

Please store the number of polyline data table records to [ n ] (number of records).
In addition, [ n ] shall take the value more than 2.

When [ S1 / S1 +1/ S1 +2/ S1 +3]<X0, Y0 is stored in [ R / R +1/ R +2/ R +3].


When [ / S1+1/ +2/
S1 +3]<Xn, Yn is stored in [
S1 S1 R / R +1/ R +2/ R +3].
When [ S1 / S1 +1/ S1 +2/ S1 +3]=Xk, Yk is stored in [ R / R +1/ R +2/ R +3]
(k=1~n).

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Control Instructions".

● Example of format
DM1000.S = APR ( DM2000.S, DM2100, DM2200 )
CR2002 APR.S
DM2000 DM2100 DM2200 @VMO
Always ON
Input value Data table Number of
leading data
@VM0 DM1000
LDA.S STA.S
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-71


Sample Program
● To use as a scaling function
ARITHMETIC OPERATION FUNCTIONS

Programmed Script DM0.S=0


DM1.S=-1000
DM2.S=+255
DM3.S=+1000
DM100.S=APR(CM1630.s,DM0.S,2)
Operation Description Scales the KV Nano Series analog volume CM1630 (0 to 255) to -1000 to +1000 and
stores it in DM100.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7
Data Control Functions

7-72 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Data Control Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-73


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RAMP

RAMP Ramp signal

Ramp signal

RAMP ([execution condition,]*1 input value, change rate setting, time unit setting,
ARITHMETIC OPERATION FUNCTIONS

output value)

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the input value or the storage
S1 Input value*2 .S .S .S .S - - - - ○ ○ ○
location for the input value (-32768 to 32767).
Specifies the change rate per time unit
Change rate
S2 or the storage location for the change .U .U .U .U - - - - ○ ○ ○
setting*2
rate. (0 to 65535)
Time unit
S3 Specifies the time unit. (0 to 2) .U .U .U .U - - - - ○ ○ ○
setting*2*3
Stores the results of the input value plus
D Output value*2 .S .S .S .S - - - - ○ ○ ○
the inclination amount at the set interval.
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 bit data is specified, 16 continuous bits are processed. When a relay other than the
Data Control Functions

leading relay (e.g. R002 or R1012) of the channel has been specified, the relay is handled in 16
bits straddling the next channel.
• When specifying CTH, current value is processed. When using CTC, process setting value.
• T, C, CTH, CTC, and Z process the low-order 16 bits.
*3 Specify the time unit setting in the range of 0 to 2.
Explanation of S3 time unit setting
Value Time unit
0 1 second unit
1 1 minute unit
2 1 hour unit

Point • The RAMP function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/5000/3000
Series CPU units with CPU function version 2.0 or higher and KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), the value of D is approached at the specified
inclination ( S2 / S3 ) until it matches S1 .

Value

S1
(Input value)

D
(Output value)
Time
Execution TRUE
conditions
FALSE
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Control Instructions".
7-74 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
RAMP ( MR1000, DM1000.S, DM2000.U, 1, EM1000.S )
MR1000 RAMP

ARITHMETIC OPERATION FUNCTIONS


DM1000 DM2000 #1 EM1000

Execution condition Input Change Output


value rate value

Point When S3 ≧3, the function is not executed.

Sample Program

Programmed Script
RAMP (DM1500.S, DM2500.U, 2, EM1500.S )
Operation Description The output value stored in EM1500.S is changed toward the input value at the specified
inclination (DM2000/time).

Reference The KV script is converted to a ladder program before execution. To check the converted 7
content, refer to "Create a box script Step 5"(page 2-10).

Data Control Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-75


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TPOUT

TPOUT Time proportional output

Time proportional output

TPOUT ([execution condition,]*1 ON time, cycle, output relay)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the time to keep the output
S1 ON time*2 .U .U .U .U - - - - ○ ○ ○
relay ON with a ms unit (0 to 65535).
Specifies the output relay ON/OFF
S2 Cycle*2 .U .U .U .U - - - - ○ ○ ○
cycle with a ms unit (1 to 65535).
Specifies the target to be turned ON/
D Output relay*3 - - - - - - .B - - ○ -
OFF.
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 bit data is specified, 16 continuous bits are processed. 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

7 bits straddling the next channel.


• When specifying CTH, current value is processed. When using CTC, process setting value.
Data Control Functions

• T, C, CTH, CTC, and Z process the low-order 16 bits.


*3 • When word data is specified, the LSB is the storage destination for the results. (Bits other than
the LSB do not change.)
• Even if a relay other than the leading channel (R1002, R1005, etc.) is specified, the output will
function correctly crossing to the next channel.
• CTC, CTH, Z cannot be used.

Point • The TPOUT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), D is turned ON for S1 (ms) at S2 (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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Control Instructions".

7-76 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
TPOUT ( MR1000, DM1000, DM2000, MR3000 )
MR1000 TPOUT

ARITHMETIC OPERATION FUNCTIONS


DM1000 DM2000 MR3000

Execution condition ON time Control cycle Output relay

Point • The function is not executed when either of the following conditions is
established:
• When S2 < S1
• 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 instruction cannot be used in interrupt programs or in the initialization
module.
7
• Caution is required when using in a subroutine program, between the STP to STE

Data Control Functions


instructions, between the STG to JMP/ENDS instructions or between the CJ
(NCJ) to LABEL instructions.
Refer to "Cautions for using Timer Instruction" in the User's Manual of the CPU
unit used.
• Caution is required when using write during RUN.
Refer to "Writing during RUN" in the User's Manual of the CPU unit used.

Sample Program

Programmed Script
TPOUT ( DM1500, EM1000, MR2000 )
Operation Description The MR2000 ON (DM1500ms) and OFF (EM1000-DM1500ms) are switched at the
EM1000ms cycle at each scan (no execution conditions).

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-77


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LLFLT

LLFLT Lead-lag filter

Lead-lag filter

LLFLT ([execution condition,]*1 input value, parameter, output value)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Recognized Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the filter input value or the
S Input value*2*3 storage location for the input value (- .S .S .S .S - - - - ○ ○ ○
32768 to 32767).
Specifies the start to store the
D1 Parameter*2*4 .U .U .U .U - - - - - ○ -
parameter.
Stores the storage location for the
D2 Output value*2 output value .S .S .S .S - - - - - ○ -
(-32768 to 32767).
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 bit data is specified, 16 continuous bits are processed. 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.
Data Control Functions

*3 • When specifying CTH, current value is processed. When using CTC, process setting value.
• T, C, CTH, CTC and Z process the low-order 16 bits.
*4 • When bit data is specified, it occupies 48 continuous bits.
• For bit data, specify the start of the channel.
• When word data is specified, 3 continuous words are occupied.

Point • The LLFLT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is met (TRUE), the lead-lag operation is executed for S at D1 ,
and stored in D2 .
D2 is initialized with the value S at the rising edge of the execution condition.

D1 Parameter description

Parameter 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 lead-lag operation, please refer to "KV-8000/7000/5000/3000/1000 Series and KV
Nano Series Instruction Reference Manual", "LLFLT Instruction".
"About operation flag (CR2009 to CR2012)", page 1-18

7-78 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
LLFLT ( MR1000, DM1000.S, EM1000, DM3000.S )
MR1000 LLFLT

ARITHMETIC OPERATION FUNCTIONS


DM1000 EM1000 DM3000

Execution condition Input value Sampling Output


cycle value

Point • 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 ).
• This instruction cannot be used in interrupt programs or in the 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.

7
Refer to "Cautions for using Timer Instruction" in the User's Manual of the CPU
unit used.
• Caution is required when using write during RUN.

Data Control Functions


Refer to "Writing during RUN" in the User's Manual of the CPU unit used.

Sample Program

Programmed Script
LLFLT ( DM1500.S, EM2000, DM2000.S )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-79


Da

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


TBCD

TBCD Convert BIN data to BCD data

Convert BCD

Return value*1 = TBCD (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .D .D - - - - ○ ○ ○
destination the conversion destination data.
TBCD function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
arguments.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Data Conversion Functions

"KV-5500/5000/3000 CPU Function Version", page 4

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 8-digit BCD (32-bit) data, and is stored in R .

• S : When the conversion destination is 16 bits


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
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

• S : When the conversion destination is 32 bits

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions".

7-80 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.U = TBCD ( DM1000.U )
CR2002 DM1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


LDA TBCD STA
Always ON Conversion destination Return value

Point When the range 0 to 9999 is exceeded when S is 16 bits, or the range 0 to
99999999 is exceeded when it is 32 bits, the value of S is stored in R .

Sample Program
● To specify the bit data

Programmed Script
DM2000.D = TBCD ( MR1000.D )
Operation Description The BIN data stored in MR1000.D is converted to 8-digit BCD (32-bit) data.
The conversion result is stored in DM2000.D.

● Example of use 7
The TBCD function is used, for example, to output the current values as they are via BCD as it can

Data Conversion Functions


convert BIN data specified by the conversion destination to BCD data.

Programmed Script
R1000.U = TBCD ( TOU ( DM1000 + 1000 ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-81


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TBIN

TBIN Convert BCD data to BIN data

Convert BIN

Return value*1 = TBIN (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .D .D - - - - ○ ○ ○
destination the conversion destination data.
TBIN function type is identical to the 1st *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Data Conversion Functions

"KV-5500/5000/3000 CPU Function Version", page 4

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 .

• S : When the conversion destination is 16 bits


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 destination 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0

1 2 3 4

BIN
conversion

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

R :Return value 0 0 0 0 0 1 0 0 1 1 0 1 0 0 1 0

1234

• S : When the conversion destination is 32 bits


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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions".

7-82 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.U = TBIN ( DM1000.U )
CR2002 DM01000 DM02000

ARITHMETIC OPERATION FUNCTIONS


LDA TBIN STA
Always ON Conversion destination Return value

Point When S is not BCD data, the value of S is stored in R .

Sample Program
● To specify the bit data

Programmed Script
DM2000.D = TBIN ( MR1000.D )
Operation Description The 8-digit BCD (32 -bit) data stored in MR1000.D is converted to BIN data.
The conversion result is stored in DM2000.D.

● Example of use 7
The TBIN function is used, for example, to input the current BCD value as it is as BIN data as it can

Data Conversion Functions


convert BCD data specified by the conversion destination to BIN data.

Programmed Script
DM2000.U = TOU ( TBIN ( R2000.U ) + 1000 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-83


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MPX

MPX 4-bit data decode

Decode

Return value*1 = MPX (conversion destination, conversion digit position)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .D .D - - - - - ○ ○
destination*3*4 the conversion destination data.
Conversion Specifies the conversion digit position.

digit position*2 (0 to 3) - - - - - - - - ○ - -
*6
R Return value .U type MPX function available.* 5 .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. (No target can be specified.)
*3 When 32-bit data is specified for the conversion destination, the low-order 16 bits (low-order
word) will be converted (effective conversion bits).
*4 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit
7 data has been specified for the conversion destination, the function operates normally straddling
the next channel.
Data Conversion Functions

*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The 4 bits (bit 0 to 3) specified by 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 destination 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1

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

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.


R :Return value

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
DM2000 = MPX ( DM1000, 2 )
CR2002 DM1000 #2 DM2000
LDA MPX STA
Always ON Conversion destination Return value

7-84 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● To decode a bit data to 16-bit BIN data

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
DM2000 = MPX ( MR1000.U, 3 )
Operation Description The value of the 3rd digit (four bits, bit 12 to bit 15) of the data stored in MR1000.U is
decoded, and the result is stored in DM2000.
Ladder conversion CR2002 MR1000 #3 DM2000
LDA MPX STA
AlwaysON Conversion destination Return value

● When this function is used in combination with other functions

Programmed Script
R2000.U = MPX ( TBIN ( DM1000 ), 1 )
Operation Description 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). 7
• Note that this function sometimes cannot be used depending on the argument of the

Data Conversion Functions


Reference

function it is combined with.


"TBIN function", page 7-82
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-85


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DMX

DMX 4-bit data encode

Decode

Return value*1 = DMX (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .U .U - - - - ○ ○ ○
destination*2*3 the operation destination data.
*5
R Return value .U type DMX function available.* 4 .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 32-bit data is specified for the conversion destination, the low-order 16 bits (low-order
word) will be converted (effective bits).

*3 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit
data has been specified for the conversion destination, the function operates normally straddling
the next channel.

7 *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.
Data Conversion Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The MSB 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 low-order four bits) data.

Ignore

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

S :Conversion destination 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 0
Because the highest bit
is 7 in bits ON (become 1),
so store 7 (0111 in binary) to R
return value.
R :Return value 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
DM2000 = DMX ( DM1000 )
CR2002 DM1000 DM2000
LDA DMX STA
Always ON Operation destination Return value

Point When the value of S is "0", "0" is stored in R .

7-86 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● To encode a bit data to 4-bit numerical value data

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
DM2000 = DMX ( MR1000.U )
Operation Description The MSB position in the ON bits of the data stored in MR1000.D is stored in DM2000.
Ladder conversion CR2002 MR1000 DM2000
LDA DMX STA
Always ON Operation destination Return value

● When this function is used in combination with other functions

Programmed Script
R2000.U = TBCD ( DMX ( MR1000.U ) )
Operation Description The MSB 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).

Reference • Note that this function sometimes cannot be used depending on the argument of the
7
function it is combined with.

Data Conversion Functions


"TBCD function", page 7-80
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-87


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
GRY

GRY Convert BIN data to gray code

Gray code conversion

Return value*1 = GRY (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .D .D - - - - ○ ○ ○
destination the operation destination data.
GRY function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-

7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
DM2000.U = GRY ( DM1000.U )
CR2002 DM1000 DM2000
LDA GRY STA
Always ON Conversion destination Return value

7-88 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Gray code table

bit
Decimal
16 15 14 13 12 9 8 7 6 5 4 3 2 1 0

ARITHMETIC OPERATION FUNCTIONS


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
Sample Program

Data Conversion Functions


● To specify the bit data

Programmed Script
DM2000.D = GRY ( MR1000.D )
Operation Description The BIN data stored in MR1000.D is converted to gray code.
The conversion result is stored in DM2000.D.

● 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 to gray code.

Programmed Script
R1000.U = GRY ( TOU ( DM1000 + 128 ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-89


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RGRY

RGRY Convert gray code to BIN data

Gray code reverse conversion

Return value*1 = RGRY (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or
S .U .U .D .D - - - - ○ ○ ○
destination*2 the operation destination data.
RGRY function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only with KV-8000/7000 Series CPU units,
7 KV-5500/5000/3000 Series CPU units with CPU function version 2.0 or later, and
KV Nano Series base units.
Data Conversion Functions

"KV-5500/5000/3000 CPU Function Version", page 4

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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
DM2000.U = RGRY ( DM1000.U )
CR2002 DM1000 DM2000
LDA RGRY STA
Always ON Conversion destination Return value

7-90 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Gray code table
bit
Decimal
16 15 14 13 12 9 8 7 6 5 4 3 2 1 0

ARITHMETIC OPERATION FUNCTIONS


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
Sample Program

Data Conversion Functions


● To specify the bit data

Programmed Script
DM2000.D = RGRY ( MR1000.D )
Operation Description The gray code stored in MR1000.D is converted to BIN data.
The conversion result is stored in DM2000.D.

● 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 to BIN data.

Programmed Script
DM2000.U = TOU ( RGRY ( R2000.U ) – 128 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-91


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DISN

DISN Disperse nibble

Disperse N

DISN ([execution condition,]*1 Operation destination, disperse data storage


ARITHMETIC OPERATION FUNCTIONS

destination, number of data to be dispersed)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - .B - - ○ -
destination*2*4 disperse nibble data.
D Disperse data
Specifies the start to store the Handled as same
storage - - - - ○ -
dispersed nibble data. type as S .
destination*2*4
Number of Specifies the number of half-byte data
n .U .U .U .U - - - - - ○ -
disperse data*3 to be 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).)
7 *2 When bit data is specified, S processed 16/32 continuous bits. D processes 64/128
continuous bits.
Data Conversion Functions

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 word data is specified, S processes 1/2 continuous words. D processes 4/8
continuous words.
*3 0 to 4 when the data suffix specified by S is .U or .B, and 0 to 8 when it is .D.
*4 CTC, CTH, Z cannot be specified.

Point When using KV-1000, please use DISN instruction in ladder program.

Description of Operation
When the execution condition is established (TRUE), data specified by S is dispersed into n

nibbles (4-bit), and the result is stored in D .


Store 0 in high-order 4 bits.

• S : When the operation destination is unsigned 16-bit (.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-92 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is unsigned 32-bit data (.D)

ARITHMETIC OPERATION FUNCTIONS


Store 0 in high 12 bits.


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions". 7

Data Conversion Functions


● Example of format
DISN ( R3000, DM1000.U, DM2000, DM2100.U )
R3000 DISN
DM1000 DM2000 DM2100
Execution condition
Operation Separate data saving Number of
destination separateting data

Point When n is 0, the function is invalid.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-93


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UNIN

UNIN Unite nibble

Unite N

UNIN ([execution condition,]*1 Operation destination, unite data storage destination,


ARITHMETIC OPERATION FUNCTIONS

number of data to be united)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - .B - - ○ -
destination*2*4 unite nibble data.
D Unite data
Specifies the start to store the unite Handled as same
storage - - - - ○ -
nibble data. type as S .
destination*2*4
Number of unite Specifies the number of half-byte data
n .U .U .U .U - - - - - ○ -
data*3 to be 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).)
7 *2 When bit data is specified, S processes 64/128 continuous bits. D processes 16/32
continuous bits. When a relay other than the leading relay (e.g. R002, R1012) of the channel has
Data Conversion Functions

been specified, the relay is handled straddling the next channel.


When word data is specified, S processes 4/8 continuous words. D processes 1/2
continuous words.
*3 0 to 4 when the data suffix specified by S is .U or .B, and 0 to 8 when it is .D.
*4 CTC, CTH, Z cannot be specified.

Point When using KV-1000, please use UNIN instruction in ladder program.

Description of Operation
When the execution condition is established (TRUE), low-order 4 bits of the unite data starting from
S are united to n BIN data, and the result is stored in D .

• S : When the operation destination is unsigned 16-bit (.U)


bit bit bit
15 4 0

S : 1

S +1 : 2
n
S +2 : 3

S +3 : 4

bit bit bit bit


15 8 7 0

D : 4 3 2 1

7-94 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is unsigned 32-bit data (.D)
bit bit bit bit bit
15 8 7 4 0

S : 1

ARITHMETIC OPERATION FUNCTIONS


S +1 : 2

S +2 : 3

S +3 : 4
n
S +4 : 5

S +5 : 6

S +6 : 7

S +7 : 8

bit bit bit bit bit bit bit bit


31 24 23 16 15 8 7 0

D +1 : 8 7 6 5 4 3 2 1 : D

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions".
7
● Example of format

Data Conversion Functions


UNIN ( R3000, DM1000.U, DM2000, DM2100.U )
R3000 UNIN
DM1000 DM2000 DM2100
Execution condition
Operation destination Separate data saving Number of separateting data

Point When n is 0, the function is invalid.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-95


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DISB

DISB Disperse byte

Device B

DISB ([execution condition,]*1 Operation destination, disperse data storage


ARITHMETIC OPERATION FUNCTIONS

destination, number of data to be dispersed)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - .B - - ○ -
destination*2*4 disperse byte data.
D Disperse data
Specifies the start to store the disperse Handled as same
storage - - - - ○ -
byte data. type as S .
destination*2*4
Number of Specifies the number of byte data to be
n .U .U .U .U - - - - - ○ -
disperse data*3 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).)
7 *2 When bit data is specified for S , D processes 16/32 continuous bits. 32/64 continuous
bits are processed.
Data Conversion Functions

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 word data is specified, S processes 1/2 continuous words. D processes 2/4
continuous words.
*3 0 to 2 when the data suffix specified by S is .U or .B, and 0 to 4 when it is .D.
*4 CTC, CTH, Z cannot be specified.

Point When using KV-1000, please use DISB instruction in ladder.

Description of Operation
When the execution condition is established (TRUE), data specified by S is dispersed into n

bytes (8-bit), and the result is stored in D .


Store 0 in high-order 8 bits.

• S : When the operation destination is unsigned 16-bit (.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

0 is stored in high-order
bytes (8 bits).

7-96 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is unsigned 32-bit data (.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

ARITHMETIC OPERATION FUNCTIONS


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

D +3 : 0 0 1 2

0 is stored in high-ord
bytes (8 bits).

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions".

● Example of format
DISB ( R3000, DM1000.U, DM2000, DM2100.U ) 7

Data Conversion Functions


R3000 DISB
DM1000 DM2000 DM2100
Execution condition
Operation destination Separate data saving Number of separateting data

Point When n is 0, the function is invalid.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-97


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UNIB

UNIB Unite byte

Unite B

UNIB ([execution condition,]*1 Operation destination, unite data storage


ARITHMETIC OPERATION FUNCTIONS

destination, number of data to be united)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the storage location for the
S .U .U .D .D - - .B - - ○ -
destination*2*4 unite byte data.
D Unite data
Specifies the start to store the unite Handled as same
storage - - - - ○ -
byte data. type as S .
destination*2*4
Number of unite Specifies the number of byte data to be
n .U .U .U .U - - - - - ○ -
data*3 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).)
7 *2 When bit data is specified, S processes 32/64 continuous bits. D processes 16/32
continuous bits.
Data Conversion Functions

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 word data is specified, S processes 2/4 continuous words. D processes 1/2
continuous words.
*3 0 to 2 when the data suffix specified by S is .U or .B, and 0 to 4 when it is .D.
*4 CTC, CTH, Z cannot be specified.

Point When using KV-1000, please use UNIB instruction in ladder

Description of Operation
When the execution condition is established (TRUE), low-order 8 bits of the unite data starting from
S are united to n BIN data, and the result is stored in D .

• S : When the operation destination is unsigned 16-bit (.U)


bit bit bit bit
15 8 7 0

S : 3 4
n
S +1 : 1 2

bit bit bit bit


15 8 7 0

D : 1 2 3 4

7-98 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination is unsigned 32-bit data (.D)
bit bit bit bit
15 8 7 0

S : 7 8

ARITHMETIC OPERATION FUNCTIONS


S +1 : 5 6
n
S +2 : 3 4

S +3 : 1 2

bit bit bit bit bit bit bit bit


31 24 23 16 15 8 7 0

D +1 : 1 2 3 4 5 6 7 8 : D

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Data Conversion Instructions".

● Example of format
UNIB ( R3000, DM1000.U, DM2000, DM2100.U )
7

Data Conversion Functions


R3000 UNIB
DM1000 DM2000 DM2100
Execution condition
Operation destination Merge data saving Number of merging data

Point When n is 0, the function is invalid.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-99


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SWAP

SWAP High lower byte conversion

Convert BCD

Return value*1 = SWAP (swap destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Swap Specifies the swap destination or the
S .U .U .D .D - - - - ○ ○ ○
destination swap destination data.
SWAP function type is identical to the *3
R Return value .U .S .D .L .F .DF - - - ○ -
argument.* 2
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Data Conversion Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The values of high-order byte (high-order 8 bits) and low-order byte (low-order 8 bits) of 16-bit data
stored in S are swapped, and the result is stored to R .

• S : When the swap destination is 16 bits


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

• S : When the swap destination is 32 bits


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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series


Instruction Reference Manual", "Data Conversion Instructions".

● Example of format
DM2000.U = SWAP ( DM1000.U )
CR2002 DM1000 DM2000
LDA SWAP STA
Always ON Swap destination Return value

7-100 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● To specify the bit data

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
DM2000.D = SWAP ( MR1000.D )
Operation Description Swap the values of high-order word (MR1000 to MR1015) and low-order word (MR1100
to MR1115) of 32-bit data stored in MR1000.D.
The swap result is stored in DM2000.D.

● When this function is used in combination with other functions

Programmed Script
R2000.U = SWAP ( TBCD ( TOU ( DM1000 + 100 ) ) )
Operation Description Add 100 to the content of DM1000, convert the result value to 4-bit BCD, then swap high-
order 2 bits and low-order 2 bits of the BCD data and output to output relay R2000 to
R2015.

• Note that this function sometimes cannot be used depending on the argument of the
7
Reference

function it is combined with.


"TBCD function", page 7-80

Data Conversion Functions


• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-101


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BSWAP

BSWAP Block swap

Block swap

BSWAP ([execution condition,]*1 swap destination, number of destination data


ARITHMETIC OPERATION FUNCTIONS

items)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Swap
D Specifies the swap destination. .U .U .U .U - - .B - - ○ -
destination
n Number of
target data Specifies the number to be swapped. .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).)

Point • The BSWAP function can be used only with KV STUDIO Ver. 6.00 or higher.

7 • This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Data Conversion Functions

Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is established (TRUE), the high-order bytes (high-order 8 bytes) and low-
order bytes (low-order 8 bytes) of the n data items starting with D 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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
BSWAP ( MR1000, DM2000, 4 )
MR1000 BSWAP
DM2000 #4

Execution condition Switch destination

Point When n =0, the function is not executed.

7-102 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program

Programmed Script
BSWAP ( DM3000, 8 )

ARITHMETIC OPERATION FUNCTIONS


Operation Description The high-order bytes and low-order bytes of DM3000 to DM3007 are swapped.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Data Conversion Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-103


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DECO

DECO 8-bit decode

8-bit decode

DECO ([execution condition,]*1 Conversion destination, storage destination,


ARITHMETIC OPERATION FUNCTIONS

conversion destination range)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the start of the conversion
S .U .U .U .U - - - - - ○ -
destination range.
Storage Specifies the storage location for the
D
location*2 *3 decode result. - - - - - .B - - ○ -
Conversion Specifies the number of ranges *4 *4 *4 *4 *4
destination (number of bits within range 1 to 8) to
n .U .U .U .U - - - - ○ ○ ○
range convert.
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 word data has been specified, the LSB of continuous 2n word data becomes the decode
result storage destination data. (Bits other than the LSB do not change.)
Data Conversion Functions

*3 CTC, CTH, Z cannot be used.


*4 A target can be specified for the number of conversion target ranges only when the following
conditions are met.
• When the KV STUDIO version is Ver. 6.00 or higher
• Only when the compatible model is a KV-8000/7000 Series CPU unit, a KV-5500/5000/3000
Series CPU unit that has CPU function version 2.0 or higher, or a KV Nano Series base unit.

Description of Operation
When the execution condition is established (TRUE), the states (number of bits) specified by n

starting from the bit data specified by S is converted to a numerical value (0 to 255). The bit of the
start No. + numerical value (No.) in the continuou 2 n
bit data starting from D is turned ON, and
other bits are all turned OFF.
When S is a word data, n indicates the number of bits to convert to numerical values, and
when the storage destination is a word data, the LSB of the word data of the start No. + numerical value
(No.) in the continuous 2 n
word data starting from the specified word data is turend ON, and the LSBs
of other word data are all turned OFF. (Bits other than the LSB do not change.)

S :Conversion 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 n 4 bit
destination

5 Because bit 4 is “0101”


4
(5 in decimal) so connect 16 (=2 )
MR2005 ON starting from MR1000.
20072006200520042003200220012000 Others all OFF (store 0)
D :Save destination 0 0 1 0 0 0 0 0
MR2000∼MR2007

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

7-104 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DECO ( R3000, MR1000.U, MR2000, 4 )
R3000 MR1000 MR2000

ARITHMETIC OPERATION FUNCTIONS


LDA DECO
Execution condition Conversion destination #4

Point When n =0, the function is not executed.

Sample Program
● When this function is used in combination with other functions

Programmed Script
DECO ( ORA ( DM3000, DM3001 ), MR3000, 5 )
Operation Description The lower five bits of the logical "OR" operation result for the data currently stored in
DM3000 and DM3001 are decoded at every scan (no execution condition).
The bit of "start No. + converted numerical value" (nth value) in the continuous 25 bits
starting from MR3000 is turned ON, and all other bits are turned OFF. 7

Data Conversion Functions


Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ORA function", page 7-24
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-105


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ENCO

ENCO 8-bit encode

8-bit encode

Return value*1 = ENCO (conversion destination, number of conversion destination


ARITHMETIC OPERATION FUNCTIONS

ranges)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the start of the conversion
S
destination*2*3 range. - - - - - - .B - - ○ -
Number of
conversion Specifies the number of conversion *5 *5 *5 *5 *5

destination ranges (number of bits). (1 to 256) .U .U .U .U - - - - ○ ○ ○
ranges
*6
R Return value .U type ENCO function available.* 4 .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 word data has been specified, the LSB of continuous n word data becomes the

7
decode destination.
*3 CTC, CTH, Z cannot be used.
*4 When the type other than .U is specified by return value, type conversion will be automatically
Data Conversion Functions

conducted during conversion.


*5 A target can be specified for the number of conversion target ranges only when the following
conditions are met.
• When the KV STUDIO version is Ver. 6.00 or higher
• Only when the compatible model is a KV-8000/7000 Series CPU unit, a KV-5500/5000/3000
Series CPU unit that has CPU function version 2.0 or higher, or a KV Nano Series base unit.
*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The smallest device position (0 to 255) of the ON bits in the states (number of bits) specified by n
starting with the bit data specified by S is stored in R as 16-bit data.
When S is word data, n indicates the number of words, and the smallest bit position (0 to 255)
of the word with the LSB ON in the word data of conversion destination range number 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".
7-106 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
DM2000.U = ENCO ( MR1000, 8 )
CR2002 MR1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


ENCO STA
Always ON #8 Return value
Conversion destination

Point When n =0, the function is not executed.

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.U = TBCD ( ENCO ( MR3000, 32 ) )
Operation Description The position (16-bit data) with the LSB ON in 32 bit data (MR3000 to MR3115) starting
from MR3000 is converted to 4-digit BCD data and stored in DM2000.

Reference • Note that this function sometimes cannot be used depending on the argument of the 7
function it is combined with.

Data Conversion Functions


"TBCD function", page 7-80
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-107


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TOU,TOS,TOD,TOL

TOU Convert data type to .U

TOS Convert data type to .S

TOD Convert data type to .D


ARITHMETIC OPERATION FUNCTIONS

TOL Convert data type to .L

U conversion

Return value*1 = TOU (conversion destination)


S conversion

Return value*1 = TOS (conversion destination)


D conversion

Return value*1 = TOD (conversion destination)


L conversion

Return value*1 = TOL (conversion destination)


Argument/Return Supported Type Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula

7 S
Conversion
destination
Specifies the storage location for the
conversion destination data or the .U .S .D .L .F .DF - -
*2
○ ○ ○
conversion data.
Data Conversion Functions

TOU function: .U type.


*1 TOS function: .S type. *2
R Return value .U .S .D .L .F .DF - - - ○ -
TOD function: .D type.
TOL fucntion: .L type.
*1 If a type different from the function type specified in the return value, it will be automatically
converted during assignment.
*2 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
• TOU
The data stored in S is converted to unsigned 16-bit BIN data, and the result is stored in R .

Reference • When 32-bit BIN data has been specified, the lower 16 bits are targeted for conversion.
• When 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.
• The suffix of the storage location for the return value should be set to .U.

7-108 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• TOS
The data stored in S is converted to signed 16-bit BIN data, and the result is stored in R .

Reference • When 32-bit BIN data has been specified, the lower 16 bits are targeted for

ARITHMETIC OPERATION FUNCTIONS


conversion.
• When 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.
• The suffix of the storage location for the return value should be set to .S.

• TOD
The data stored in S is converted to unsigned 32-bit BIN data, and the result is stored in R .

Reference • When 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.
• When 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.
• The suffix of the storage location for the return value should be set to .D.
7

Data Conversion Functions


• TOL
The data stored in S is converted to signed 32-bit BIN data, and the result is stored in R .

Reference • When 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.
• When 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.
• The suffix of the storage location for the return value should be set to .L.

● Example of format
DM2000.L = TOL ( DM1000.S )
CR2002 DM1000 DM2000
LDA.S EXT.S STA.L
Always ON Conversion destination Return value

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 storage location for the operation result is
other than ".L", the type conversion warning will occur.
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 storage location.

● When the type of the storage location for the operation result is unsigned 32-bit data ".D"
Programmed Script
DM1000.D = TOD ( ( DM2000 + 50 ) * DM2100 + 10 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-109


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CPMSET

CPMSET CIP message creation

CPMSET ([execution condition,]*1, input data storage destination, parameter, output


ARITHMETIC OPERATION FUNCTIONS

data storage destination)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Input data
Specifies the start of the addtional
storage .U .S .D .L .F .DF .B .T - ○ -
data.
destination*2
Specifies the data type, data size (in
S2 Parameter bytes) or storage location of the .U .U .U .U - - - - ○ ○ ○
additional send data.* 2
D Output data
Specifies the start of the created send
storage .U .S .D .L .F .DF .B .T - ○ -
data.
destination*2
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 bit data, specify the start of the channel.
Data Conversion Functions

Point • The CPMSET function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is established (TRUE), the data stored in S1 is added after the data
size (in bytes) stored in D with the data type specified by the high-order 4 bits of S2 and the
data size (in bytes) specified by the low-order 12 bits.
When adding data for the first time, 0 is stored in D 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 EtherNet/IP Function 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 1 to 4095 (001H to FFFH): Specifies data size
string
1: Text string 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 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-110 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Data storage start position Data storage start position: 0
specified with data size
Additional data
S1 +0

ARITHMETIC OPERATION FUNCTIONS


S1 +1
Created data
S1 +2
Data size (Byte unit)* D +0
S1 +3
D +1
The type* and size of data specified D +2
with S2 is added to the data
D +3
storage start position.
D +4
* If the data type is a text string,
the data is converted into CIP text D +5
string type data and then added. D +6
D +7

When the function is executed, the


data size added to D1 +0 data
size is added.

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".
7

Data Conversion Functions


● Example of format
CPMSET ( MR0,DM1000,$1003,EM2000 )
MR000 CPMSET
DM1000 $1003 EM2000

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-111


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CPMGET

CPMGET CIP message retrieval

CPMGET ([execution condition,]*1, input data storage destination, parameter,


input data offset, output data storage
ARITHMETIC OPERATION FUNCTIONS

destination)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Input data
Specifies the start of the storage
storage .U .S .D .L .F .DF .B .T - ○ -
location for the receive data.
destination*2
Specifies the data type, data size (in
S2 Parameter bytes) or storage location of the receive .U .U .U .U - - - - ○ ○ ○
data to be retrieved.* 2
Specifies the byte offset from the start
D1 Receive data
to specify the receive data retrieval .U .S .D .L - - - - - ○ -
byte offset*2
position or the storage location.
D2 Output data

7
Specifies the start to store the retrieved
storage .U .S .D .L .F .DF .B .T - ○ -
data.
destination*2
R Return value None - - - - - - - - - - -
Data Conversion Functions

*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
at all times (at every scan).)
*2 When specifying bit data, specify the start of the channel.

Point • The CPMGET function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is established (TRUE), the data after the offset position specified by
D1 of the receive data stored in S1 is stored in D2 with the data type specified by the high-
order 4 bits of S2 and the data size (in bytes) specified by the low-order 12 bits of S2 . After
storing the data, D1 is updated.
The CPMGET function is used to retrieve the text string data and numeric data of the received CIP data
type.
Refer to "KV EtherNet/IP Function 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 1 to 4095 (001H to FFFH): Specifies data size
string

7-112 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


High-order 4 bits Low-order 12 bits
1: Text string 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 NUL(00H) are converted.

ARITHMETIC OPERATION FUNCTIONS


If the specified number of characters contains NUL(00H), 00H is added to the data
following NULL(00H).
2 or more: Reserved -
for system
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
S1 +5
* When the function is executed,
7
he type* and size of data specified with the retrieved data size is added

Data Conversion Functions


D1 is retrieved from the data following to D1 the receive data offset.
the S2 data retrieval start position, and
stored after D2 .
* If the data type is a text string, it is
converted into CIP text string data.

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Data Conversion Instructions".

● Example of format
CPMGET ( MR0, EM2000, $1003, DM1000, DM2000 )
MR000 CPMGET
EM2000 $1003 DM1000 DM2000

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-113


Flo

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


FLOAT

Convert BIN data to single precision floating point type real number
FLOAT data

Single precision floating point conversion

Return value*1 = FLOAT (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Supported Type Const Device/ For


Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or *3
S .U .U .D .D - .DF - - ○ ○ ○
destination the conversion destination data.
*2 *3
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.
*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The binary data (16-bit/32-bit (unsigned/signed), double precision floating point type real number data)
stored in S is converted into single precision floating point type real number data, and the result is
stored in R .

• S : When the type of conversion destination 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

• S : When the type of conversion destination is 32-bit


bit
31
S +1 S bit
0
bit
31
R +1 R bit
0

Single precision floating


32-bit BIN data point type real number

32 bits 32 bits

• S : When the conversion destination 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

Single precision floating


Double precision floating point type real number point type real number

64 bits 32 bits
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-114 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.F = FLOAT ( DM1000.U )
CR2002 DM1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


LDA FLOAT STA.F
Always ON Conversion destination Return value

Point When S integer value exceeds -16777216 to 16777215 (24-bit BIN) range, the
25th bit onwards is rounded.

Sample Program
● Example of use

Programmed Script
DM2000.F = FLOAT ( DM1000.U + 123 )
Operation Description The operation result of DM1000.U+123 is converted to single precision floating point type
real number data, and is stored in DM2000.F.
7
Reference The KV script is converted to a ladder program before execution. To check the converted

Floating Point Functions


content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-115


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TOF

Convert BIN data to single precision floating point type real number
TOF data

F conversion

Return value = TOF (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the target that stores the
Conversion *2
S conversion destination data or the .U .U .D .D .F .DF - - ○ ○ ○
destination
conversion data.
*2
R Return value .F type TOF function available.* 1 .U .S .D .L .F .DF - - - ○ -

*1 When the type other than .F is specified by return value, type conversion will be automatically
conducted during conversion.
*2 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-

7 5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
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-114

● Example of format
DM2000.F = TOF ( DM1000.D )
CR2002 DM1000 DM2000
LDA.D FLOAT.D STA.F
Always ON Conversion destination Return value

Reference • The 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)).
• If 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.
• The .F suffix must be specified for the storage location of the return value.

7-116 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-117


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DFLOAT

Convert BIN data to double precision floating point type real number
DFLOAT data

Double precision floating point conversion

Return value*1 = DFLOAT (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the target that stores the
Conversion
S conversion destination data or the .U .U .D .D .F - - - ○ ○ ○
destination
conversion data.
*3
Return value .DF type DFLOAT function available.* 2 .U .S .D .L .F
R .DF - - - ○ -

*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.

7 Point • The DFLOAT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be used with KV-8000/7000 Series CPU units, KV-5500/
5000/ 3000 Series CPU units that have CPU function version 2.0 or higher and
Floating Point Functions

with KV Nano Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The binary data (16-bit/32-bit (unsigned/signed), single precision floating point type real number data)
stored in S is converted into double precision floating point type real number data, and the result is
stored in R .

• S : When the type of conversion destination 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

• S : When the type of conversion destination 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

• S : When the type of conversion destination 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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-118 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.DF = DFLOAT ( DM1000.S )
CR2002 DM1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


LDA.S DFLOAT.S STA.DF

Always ON Conversion destination Return value

Sample Program

Programmed Script
DM2500.DF = DFLOAT (DM1500.L + 1000 )
Operation Description The operation result of DM1500.L+1000 is converted to double precision floating point
type real number data, and is stored in DM2500.DF.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Floating Point Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-119


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TODF

Convert BIN data to double precision floating point type real number
TODF data

DF conversion

Return value = TODF (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the target that stores the
Conversion *2
S conversion destination data or the .U .U .D .D .F .DF - - ○ ○ ○
destination
conversion data.
*2
R Return value .DF type TODF function available.* 1 .U .S .D .L .F .DF - - - ○ -

*1 When the type other than .DF is specified by return value, type conversion will be automatically
conducted during conversion.
*2 The ".DF" suffix cannot be specified for device Z.

Point • The TODF function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be used with KV-8000/7000 Series CPU units, KV-5500/

7 5000/ 3000 Series CPU units that have CPU function version 2.0 or higher and
with KV Nano Series base units.
Floating Point Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The data stored in S is converted to double precision floating point type real number data, and the
result is stored in R .
"DFLOAT function", page 7-118

● Example of format
DM2000.DF = TODF ( DM1000.S )
CR2002 DM1000 DM2000
LDA.S DFLOAT.S STA.DF

Always ON Conversion destination Return value

Reference • The 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).
• The .DF suffix must be specified for the storage location of the return value.

7-120 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-121


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
INTG

Convert single/double precision floating point type real number data


INTG to BIN data

Integer conversion

Return value*1 = INTG (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or *3
S
destination the conversion destination data. - - - - .F .DF - - ○ ○ ○
*2 *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.
*2 C, T, CTC, CTH, Z cannot 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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
7 • The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Floating Point Functions

Nano series base units.


"KV-5500/5000/3000 CPU Function Version", page 4
• The range of the single precision floating point type real number is shown below.

−3.4E+38 ≦ N ≦ −1.4E−45
N=0
1.4E−45 ≦ N ≦ 3.4E+38
(Number of effective digits: approx. 7 digits)
(For the KV Nano Series, an absolute value in a range of 1.4E-45 to 1.2E-38 cannot be used.)

• 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 .

• S : When the type of conversion destination 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ビッ
32 bits ト 32ビッ
32 bits ト

• S : When the type of conversion destination 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
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".
7-122 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
DM2100.L = INTG ( DM1100.F )
CR2002 DM1100 DM2100

ARITHMETIC OPERATION FUNCTIONS


LDA.F INTG.L STA.L

Always ON Conversion destination Return value

Point • When S is outside the single precision floating point type real number range,
or when the converted data is outside the signed 16/32-bit BIN range, the bit
pattern of S is stored in R .
• When S is outside the double precision floating point type real number
range, or when the converted data is outside the signed 16/32-bit BIN range, the
lower 32-bit pattern of S is stored in R .

Sample Program
● Example of use
7

Floating Point Functions


Programmed Script
DM2000.L = INTG ( DM1000.F + 1.25 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-123


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
INT

Convert single precision floating point type real number data to BIN
INT data

Integer conversion

Return value*1 = INT (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or *4
S
destination*2 the conversion destination data. - - - - .F .DF - - ○ ○ ○
*3 *4
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.
*2 C, T, CTC, CTH, Z cannot 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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
7 • The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Floating Point Functions

Nano series base units.


"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
This function is similar to "INTG function" except function name is different.

7-124 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Floating Point Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-125


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DISF

Disperse mantissa/exponent of single precision floating point type


DISF real number

Disperse F

DISF ([execution condition,]*1 Operation destination, mantissa storage destination,


ARITHMETIC OPERATION FUNCTIONS

exponent storage destination)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination of the single
Operation precision floating point type real *3
.F - - -
S
destination*2*4 number whose mantissa and exponent - - - - ○ ○ ○
are to be dispersed.
Mantissa
Specifies the destination to store the
D1 storage - .L .L - - - - - ○
dispersed mantissa.
destination*2
Exponent
Specifies the destination to store the
D2 storage .S .S - - - - - - ○
dispersed exponent.
destination

7 R
*1
Return value None - - - - - - - -
"[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
- - -

at all times (at every scan).)


Floating Point Functions

*2 When bit data is specified, 32 continuous bits are processed. 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 single precision floating point type real numbers.
*4 C, T, CTC, CTH, Z cannot be used.

Point Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point 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 specified by 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 .

Mantissa part: Signed 32-bit binary data

Single precision floating point type real number Spilit


32 bits (2 words)
32 bits (2 words)

Exponent part: Signed 16-bit binary data


Separate example for
16 bits
(1 word)

Mantissa Exponent

Mantissa part - 1234000 (Signed 32-bit binary data)


Spilit

Exponent part - 9 (Signed 16-bit binary data)


(Single precision floating
point type real number)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Floating Point Instructions".

7-126 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DISF ( R3000, DM1000.F, DM2000.L, DM2100.S )
R3000

ARITHMETIC OPERATION FUNCTIONS


DISF
DM1000 DM2000 DM2100
Execution condition
Operation Mantissa Exponent
destination saving saving

Point • 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 section (decimal).
• 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
7
Programmed Script
DISF ( LOG ( DM3000.F ), EM3000.L, EM3100 )

Floating Point Functions


Operation Description The mantissa section and exponent section of the value resulting from having converted
the 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).

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"LOG function", page 7-132
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-127


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UNIF

Unite mantissa and exponent to single precision floating point type


UNIF real number

Unite F

Return value*1 = UNIF (mantissa storage destination, exponent storage destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Mantissa
Specifies the destination that stores the
S1 storage - - .L .L - - - - - ○ ○
mantissa to unite.
destination*2
Exponent
Specifies the destination that stores the
S2 storage .S .S .S .S - - - - - ○ ○
exponent to unite.
destination
*4
R Return value .F type UNIF function available.* 3 .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 bit data is specified, 32 continuous bits are processed. When a relay other than the leading
relay (e.g. R002, R1012) of the channel has been specified, the relay is handled straddling the

7 *3
next channel.
When the type other than .F is specified by return value, type conversion will be automatically
conducted during conversion.
Floating Point Functions

*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The signed 32-bit BIN data specified by S1 is taken as the mantissa, the signed 16-bit BIN data
specified by S2 is taken as the exponent, and the united 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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Floating Point Instructions".

7-128 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.F = UNIF ( DM1000.L, DM1100.S )
CR2002 MOV.F

ARITHMETIC OPERATION FUNCTIONS


+0 @VM0
Always ON
UNIF
DM1000 DM1100 @VM0

Mantissa saving Exponent saving


CR2002 MOV.F
@VM0 DM2000
Always ON
Return value

Point • 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).
• When the operation result is outside the single precision floating point type real
number range, "0" is stored in .
7
R

Sample Program

Floating Point Functions


● When this function is used in combination with other functions

Programmed Script
DM2000.F = EXP ( UNIF ( EM3000.L, EM3100.S ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"EXP function", page 7-130
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-129


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
EXP

EXP Exponent function operation

Exponent arithmetic operation

Return value*1 = EXP (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The EXP function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The exponent function value is obtained with the single precision floating point type real number
stored in [ S +1/ S ] as the exponent.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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

• S : When the suffix of the conversion destination is .DF


The exponent function value is obtained with the double precision floating point type real number
stored in [ S +3/ S +2/ S +1/ S ] as the exponent.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".
7-130 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
DM2100.F = EXP ( DM1100.F )
CR2002 DM1100 DM2100

ARITHMETIC OPERATION FUNCTIONS


LDA.F EXP STA.F
Always ON Conversion destination Return value

Point 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 .

Sample Program
● Example of use

Programmed Script
DM2000.F = EXP ( DM1000.D )
Operation Description 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 e x is
calculated and stored in DM2000.F. (DM1000.D does not need to be converted by the 7
FLOAT function, etc.)

Floating Point Functions


Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"FLOAT function", page 7-114
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-131


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LOG

LOG Natural logarithm operation

Natural logarithm operation

Return value*1 = LOG (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The LOG function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The natural logarithm of the single precision floating point type real number stored in [ S +1/
S ] is obtained.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

S +1 S R +1 R

Log Single precision floating point type real number

32 bits
Single precision floating point type real number

32 bits

• S : When the suffix of the conversion destination is .DF


The natural logarithm of the double precision floating point type real number stored in [ S +3/
S +2/ S +1/ S ] is obtained.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-132 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2100.F = LOG ( DM1100.F )
CR2002 DM1100 DM2100

ARITHMETIC OPERATION FUNCTIONS


LDA.F LOG STA.F
Always ON Operation destination Return value

Point When the value to be operated on is 0 or a minus value, or the operation result is
outside the 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

Programmed Script
DM2000.L = INTG ( LOG ( DM1000.F ) )

7
Operation Description 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.

Floating Point Functions


Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"INTG function", page 7-122
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-133


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LOG10

LOG10 Constant logarithm operation

Log10

Return value*1 = LOG10 (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The LOG10 function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. Argument types are .U .S .D .L .F .DF - - - ○ -
automatically converted to function
types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The LOG10 function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
Floating Point Functions

5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The constant logarithm of the single precision floating point type real number stored in [ S +1/
S ] is obtained.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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
• S : When the suffix of the conversion destination is .DF
The constant logarithm of the double precision floating point type real number stored in [ S +3/
S +2/ S +1/ S ] is obtained.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-134 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.DF = Log10 ( DM1000.DF )
CR2002 DM1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


LDA.DF LOG10.DF STA.DF

Always ON Operation destination Return value

Sample Program

Programmed Script
DM2500.L = INTG ( LOG10 ( DM1500.DF ))
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted

7
content, refer to "Create a box script Step 5"(page 2-10).

Floating Point Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-135


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RAD

RAD Convert degree (°) to radian unit

Radian

Return value*1 = RAD (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the conversion destination data.
The RAD function uses the .F type if the
argument is U/S/D/L/F, and the .DF type *3
R Return value .U .S .D .L .F .DF - - - ○ -
for DF. Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Floating Point Functions

Nano series base units.


"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The angle (in °) of the single precision floating point type real number stored in [ S +1/ S ] is
converted into radian unit.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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
• S : When the suffix of the conversion destination is .DF
The angle (in °) of the double precision floating point type real number stored in [ S +3/ S +2/
S +1/ S ] is converted into radian unit.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-136 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference Angle (°) and radian (rad) are calculated as follows:
π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2100.F = RAD ( DM1100.F )
CR2002 DM1100 DM2100
LDA.F RAD STA.F
Always ON Conversion destination Return value

Point 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
Programmed Script
DM2000.F = RAD ( DM1000.D )

Floating Point Functions


Operation Description The angle (in °) 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.)

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-137


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DEG

DEG Convert radian to degree (°) unit

Degree

Return value*1 = DEG (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the conversion destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the conversion destination data.
The DEG function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The angle (in radians) of the single precision floating point type real number stored in [ S +1/
S ] is converted into degree (°) unit.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

S +1 S R +1 R
Single precision floating point type real
Single precision floating point type real
number rad number

32 bits 32 bits
• S : When the suffix of the conversion destination is .DF
The angle (in radians) of the double precision floating point type real number stored in [ S +3/
S +2/ S +1/ S ] is converted into degree (°) unit.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

Reference Angle (°) and radian (rad) are calculated as follows:


π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

7-138 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2100.F = DEG ( DM1100.F )
CR2002 DM1100 DM2100

ARITHMETIC OPERATION FUNCTIONS


LDA.F DEG STA.F
Always ON Conversion destination Return value

Point 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

Programmed Script
DM2000.L = INTG ( DEG ( DM1000.F ) )
Operation Description Convert the angle (in radians) of single precision floating point type real number stored in
DM1000.F to degree (°) unit, convert the result to signed 32-bit BIN data, and then store it
in DM2000.L. 7
• Note that this function sometimes cannot be used depending on the argument of the

Floating Point Functions


Reference

function it is combined with.


"INTG function", page 7-122
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-139


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SIN

SIN Angle (radian) to sine value

Sine

Return value*1 = SIN (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The SIN function uses the .F type if the
argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• 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
(For the KV Nano Series, an absolute value in a range of 1.4E-45 to 1.2E-38 cannot be used.)

(effective number of digits: approx. 7 digits)


• 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
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The sine (SIN) value of the single precision floating point type real number angle (in radians) stored
in [ S +1/ S ] is obtained.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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-140 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the suffix of the conversion destination is .DF
The sine (SIN) value of the double precision floating point type real number angle (in radians) stored
in [ S +3/ S +2/ S +1/ S ] is obtained.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/

ARITHMETIC OPERATION FUNCTIONS


R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

Reference Angle (°) and radian (rad) are calculated as follows:


π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

● Example of format 7
DM2100.F = SIN ( DM1100.F )

Floating Point Functions


CR2002 DM1100 DM2100
LDA.F SIN STA.F
Always ON Operation destination Return value

Point 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 ) )
Operation Description The angle (in degrees) of the single-precision floating point type real number stored in
DM1000.F is converted to radians, the sine value is calculated, and the result is stored in
DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RAD function", page 7-136
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-141


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
COS

COS Angle (radian) to cosine value

Cosine

Return value*1 = COS (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The COS function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• 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
(For the KV Nano Series, an absolute value in a range of 1.4E-45 to 1.2E-38 cannot be used.)

(effective number of digits: approx. 7 digits)


• 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
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The cosine (COS) value of the single precision floating point type real number angle (in radians)
stored in [ S +1/ S ] is obtained.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].
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-142 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the suffix of the conversion destination is .DF
The cosine (COS) value of the double precision floating point type real number angle (in radians)
stored in [ S +3/ S +2/ S +1/ S ] is obtained.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/

ARITHMETIC OPERATION FUNCTIONS


R +2/ R +1/ R ].
bit bit bit bit
63
S +3 S +2 S +1 S 0 63
R +3 R +2 R +1 R 0

COS Double precision floating point type real number Double precision floating point type real number

64 bits 64 bits

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

Reference Angle (°) and radian (rad) are calculated as follows:


π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

● Example of format 7
DM2100.F = COS ( DM1100.F )

Floating Point Functions


CR2002 DM1100 DM2100
LDA.F COS STA.F
Always ON Operation destination Return value

Point 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 ) )
Operation Description The angle (° 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RAD function", page 7-136
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-143


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TAN

TAN Angle (radian) to tangent value

Tangent

Return value*1 = TAN (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The TAN function uses the .F type if the
argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• 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
(For the KV Nano Series, an absolute value in a range of 1.4E-45 to 1.2E-38 cannot be used.)

(effective number of digits: approx. 7 digits)


• 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
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The tangent (TAN) value of the single precision floating point type real number angle (in radians)
stored in [ S +1/ S ] is obtained.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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-144 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the suffix of the conversion destination is .DF
The tangent (TAN) value of the double precision floating point type real number angle (in radians)
stored in [ S +3/ S +2/ S +1/ S ] is obtained.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/

ARITHMETIC OPERATION FUNCTIONS


R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

Reference Angle (°) and radian (rad) are calculated as follows:


π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
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 Return value

Point 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 ) )
Operation Description The angle (in °) of the single precision floating point type real number stored in DM1000.F
is converted to radian unit, the tangent value is calculated and the result is stored in
DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RAD function", page 7-136
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-145


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ASIN

ASIN Sine value to angle (radians)

Arc sine

Return value*1 = ASIN (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The ASIN function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The angle (in radians) is calculated from the sine (SIN) value of the single precision floating point
type real number stored in [ S +1/ S ].
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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
• S : When the suffix of the conversion destination is .DF
The angle (in radians) 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 ].
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-146 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference Angle (°) and radian (rad) are calculated as follows:
π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2100.F = ASIN ( DM1100.F )
CR2002 DM1100 DM2100
LDA.F ASIN STA.F
Always ON Operation destination Return value

Point 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
DM2000.F = DEG ( ASIN ( DM1000.F ) )

Floating Point Functions


Programmed Script

Operation Description 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 (° unit)
and stored in DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"DEG function", page 7-138
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-147


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ACOS

ACOS Cosine value to angle (radians)

Arc cosine

Return value*1 = ACOS (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The ACOS function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The angle (in radians) is calculated from the cosine (COS) value of the single precision floating point
type real number stored in [ S +1/ S ].
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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
• S : When the suffix of the conversion destination is .DF
The angle (in radians) 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 ].
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-148 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference Angle (°) and radian (rad) are calculated as follows:
π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2100.F = ACOS ( DM1100.F )
CR2002 DM1100 DM2100
LDA.F ACOS STA.F
Always ON Operation destination Return value

Point 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
DM2000.F = DEG ( ACOS ( DM1000.F ) )

Floating Point Functions


Programmed Script

Operation Description 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 (° unit)
and stored in DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"DEG function", page 7-138
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-149


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ATAN

ATAN Tangent value to angle (radian)

Arc tangent

Return value*1 = ATAN (Operation destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination or *3
S .F .F .F .F .F .DF - - ○ ○ ○
destination the operation destination data.
The ATAN function uses the .F type if
the argument is U/S/D/L/F, and the .DF *3
R Return value type for DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
*3 The ".DF" suffix cannot be specified for device Z.

7 Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
Floating Point Functions

5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• S : When the suffix of the conversion destination is .U/.S/.D/.L/.F
The angle (in radians) is calculated from the tangent (TAN) value of the single precision floating point
type real number stored in [ S +1/ S ].
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

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
• S : When the suffix of the conversion destination is .DF
The angle (in radians) 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 ].
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-150 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference Angle (°) and radian (rad) are calculated as follows:
π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2100.F = ATAN ( DM1100.F )
CR2002 DM1100 DM2100
LDA.F ATAN STA.F
Always ON Operation destination Return value

Point 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
DM2000.F = DEG ( ATAN ( DM1000.F ) )

Floating Point Functions


Programmed Script

Operation Description 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 (°
units) and stored in DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"DEG function", page 7-138
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-151


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ATAN2

ATAN2 Coordinates to angle (radian)

Arc tangent2

Return value*1 = ATAN2 (Operation destination 1, operation destination 2)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination 1 *3
S1 .F .F .DF .DF .F .DF - - ○ ○ ○
destination 1 or the operation destination data 1.
Operation Specifies the operation destination 2 *3
S2 .F .F .DF .DF .F .DF - - ○ ○ ○
destination 2 or the operation destination data 2.
The ATAN2 function uses the .F type if
the argument is U/S/F, and the .DF *3
R Return value type for D/L/DF. .U .S .D .L .F .DF - - - ○ -
Argument types are automatically
converted to function types.* 2
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 If a type different from the function type specified in the return value, it will be automatically
converted during conversion.
7 *3 The ".DF" suffix cannot be specified for device Z.

Point • The ATAN2 function can be used only by KV STUDIO ver.9.0 or later.
Floating Point Functions

• This function can be specified only with the KV-8000 series CPU units and KV-
7000 Series CPU units that have CPU function version 2.0 or later.
"KV-5500/5000/3000 CPU Function Version", page 4
• Refer to "INTG function", page 7-122 for details on the range of the single
precision floating point type real number and double precision floating point
type real number.

Description of Operation
• When the suffix of S1 conversion destination 1 and S2 conversion destination 2 is .U/.S/.F
The angle (in radians) relative to X axis of a single-precision floating point type real number is
calculated from the Y coordinate obtained by converting the value specified by [ S1 +1/ S1 ] to a
single-precision floating point type real number and the X coordinate obtained by converting the
value specified by [ S2 +1/ S2 ] to a single-precision floating point type real number.
The result is a 32-bit single-precision floating point type real number and stored in [ R +1/ R ].

S2 +1 S2 S1 +1 S1 R +1 R
Single precision floating point type real number Single precision floating point type real number Single precision floating point type real number
,

32 bits 32 bits 32 bits

• When the suffix of S1 conversion destination 1 and S2 conversion destination 2 is .D/.L/.DF


The angle (in radians) relative to X axis of a double-precision floating point type real number is
calculated from the Y coordinate obtained by converting the value specified by [ S1 +3/ S1 +2/
S1 +1/ S1 ] to a double-precision floating point type real number and the X coordinate obtained
by converting the value specified by [ S2 +3/ S2 +2/ S2 +1/ S2 ] to a double-precision
floating point type real number.
The result is a 64-bit double-precision floating point type real number and stored in [ R +3/
R +2/ R +1/ R ].

S2 +3 S2 +2 S2 +1 S2 S1 +3 S1 +2 S1 +1 S1 R +3 R +2 R +1 R
Double precision floating point type real number Double precision floating point type real number Double precision floating point type real number
,

64 bits 64 bits 64 bits

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Floating Point Instructions".

7-152 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference The ATAN instruction uses the TAN value to find the angle up to -π/2(rad)< R <π/2(rad).
The ATAN2 instruction uses coordinates (S2, S1) to find the angle up to -π(rad) < R ≦
π(rad).

ARITHMETIC OPERATION FUNCTIONS


Y

S1

R
S2 X

π 180
1°= ≒ 0.01745(rad), 1(rad)= ≒ 57.23°
180 π

When S1=0 and S2≧0, R (return value)=0°=0(rad).


When S1=0 and S2<0, R (return value)=180°= π(rad).
When S1>0 and S2=0, R (return value)=90°=π/2(rad).
When S1<0 and S2=0, R (return value)=-90°=-π/2(rad).

● Example of format 7
DM2100.F = ATAN2 ( DM1100.F, DM1102.F )

Floating Point Functions


CR2002 DM1100 DM2100
ATAN2 STA.F
Always ON DM1102 Return value

Point When the value to operate on is outside the single precision floating point type real
number range, the value of R does not change.

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.F = DEG ( ATAN2 ( DM1000.F, DM1002.F ) )
Operation Description The angle (in radians) relative to X axis of a single precision floating point type real
number is calculated from the single precision floating point type real number X
coordinate stored in DM1000.F and the single precision floating point type real number Y
coordinate stored in DM1002.F, and the result is converted to degree (°) unit and stored in
DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"DEG function", page 7-138
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-153


Te

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


ASC

ASC Convert BIN data to HEX ASCII code

HEX ASCII code conversion

Return value*1 = ASC (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination that stores the
Conversion
S HEX ASCII text code to be converted .U .U .U .U - - - - ○ ○ ○
destination*2
or the conversion destination data.
*4
R Return value .U type ASC function available.* 3 .U .S .D .L .F .DF - - - ○ -

*1 The return value can be omitted. When omitted, the conversion result is stored in internal
registers.
*2 Even when a relay other than the leading relay (e.g. R1002 or R1005) of the channel for the bit
data has been specified for the conversion destination, 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

7 *4
conducted during conversion.
The ".DF" suffix cannot be specified for device Z.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The value of low-order 8 bits of the BIN data stored in S is converted to HEX ASCII text code, and
the resulting 16-bit data 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

● Example of format
DM2000.U = ASC ( DM1000.U )
CR2002 DM1000 DM2000
LDA ASC STA
Always ON Conversion destination Return value

7-154 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When this function is used in combination with other functions

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
DM2000.U = ASC ( SRA ( DM1000.U, 8 ) )
Operation Description The BIN data currently stored in DM1000 is shifted to the right by 8 bits.
The value of the low-order 8 bits (high-order 8 bits before the shift) of the shift result is
converted to HEX ASCII code, and the result is stored in DM2000.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SRA function", page 7-38
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-155


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RASC

RASC Convert HEX ASCII code to BIN data

HEX ASCII code reverse conversion

Return value*1 = RASC (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the desitnation that stores the
Conversion
S BIN data to be converted or the .U .U .U .U - - - - ○ ○ ○
destination*2*3
conversion destination data.
*5
R Return value .U type RASC function available.* 4 .U .S .D .L .F .DF - - - ○ -

*1 The return value can be omitted. When omitted, the conversion result is stored in internal registers.
*2 Though 32-bit data can also be used for the conversion destination data, only the low-order 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
data has been specified for the conversion destination, 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
7 *5
conducted during conversion.
The ".DF" suffix cannot be specified for device Z.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The HEX ASCII text code (two characters) of the 16 bits stored in S are converted to BIN data, and
the 16-bit data (low-order 8 bits are the conversion value, and the high-order 8 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

"About operation flag (CR2009 to CR2012)", page 1-18


"ASCII Code Table", page A-53
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

• S must store an ASCII code with both high-order 8 bits and lower-order 8 bits being
Point
0 to 9 (30H to 39H) or A to F (41H to 46H), or a value (ASCII code) with high-order 8 bits
being NUL (00H) and low-order 8 bits being 0 to 9 (30H to 39H) or A to F (41H to 46H).
When either of the high-order 8 bits or low-order 8 bits is outside this range, the
function is not executed.
• When there is an ASCII code that cannot be used, the value of S is stored in
R .

7-156 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.U = RASC ( DM1000.U )
CR2002 DM1000 DM2000

ARITHMETIC OPERATION FUNCTIONS


LDA RASC STA
Always ON Conversion destination Return value

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.U = RASC ( SWAP ( DM1000 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
7

Text Processing Functions


function it is combined with.
"SWAP function", page 7-100
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-157


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DASC

DASC Convert BIN data to DEC ASCII text string

Decimal ASCII code conversion

Return value*1 = DASC (conversion destination, conversion parameter)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the desitnation that stores the
Conversion *4
S1 BIN data to be converted or the .U .S .D .L - - - - ○ ○
destination*2*3 ○
conversion destination data.
S2 Specifies the destination to which the
Conversion
conversion parameter is stored, or the .U .U .U .U - - - - ○ ○ ○
parameter*5
parameter. (0 to 3)
Return
R .T type DASC function available. - - - - - - - .T - ○ -
value*3*6
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 When bit data is specified, 16/32 continuous bits are processed.

7 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 For bit data, specify the start of the channel.
Text Processing Functions

*4 Constants cannot be specified by "$".


*5 Specify the conversion parameter within the range 0 to 3.
S2 conversion parameter explanation

Value Details 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

Point 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 cannot be used.

Description of Operation
The BIN data stored in S1 is converted to DEC ASCII code text string according to the conversion
parameter specified with S2 , and the result is stored in R .

• S1 : When the conversion destination 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
16 bits R +1 hundred ten
in last bit
N automatically.
R +2 one U
L
(00H)

7-158 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When the conversion destination is signed 16-bit data (.S)
bit
15
S bit
0
bit
15
bit
0

Signed 16-bit binary data R Symbols ten thousand

ARITHMETIC OPERATION FUNCTIONS


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.

• S1 : When the conversion destination 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

+5
N
U
ten

L
(00H)
one
7

Text Processing Functions


Store 00H in last No change before and
bit automatically. after command perform.

• S1 : When the conversion destination 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 ten
N
R +5 one U
L
(00H)

Store 00H in last


bit automatically.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Text Processing Instructions".

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-159


● Example of format
DM2000.T = DASC ( DM1000 , 3 )
CR2002 ADRSET
ARITHMETIC OPERATION FUNCTIONS

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

7 Always ON
DM1000

Conversion destination
*@VM2

@VM0 CR2814
Text Processing Functions

LDA STA
ASCII Conversion zero
suppression setting
CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

Point • When a constant is used for the conversion destination data, it cannot be
specified in HEX ($).
• Only 1-byte characters (ASCII code) can be specified for data conversion.
• Attention is required when changing or looking up CR2814/CR2815 by interrupt
programs.
• When any of the following conditions is established, the end code (NUL(00H)) is
stored in R .
• When a bit other than the start of the channel is specified when bit data is
specified for R .
• When a timer/counter is specified to R by indirect specification.

7-160 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When this function is used in combination with other functions

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
EM2000.T = DASC ( TBIN ( DM1000.D ), 0 )
Operation Description 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 result is stored in EM2000.T.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TBIN function", page 7-82
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-161


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
STR

STR Convert numerical value data to ASCII code

Decimal ASCII code conversion

Return value*1 = STR (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the desitnation that stores the
Conversion
S1 BIN data to be converted or the .U .S .D .L .F - - - ○ ○ ○
destination*2*4
conversion destination data.
Return
R .T type STR function available - - - - - - - .T - ○ -
value*3*5
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 When bit data is specified, 16/32 continuous bits are processed.
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 For bit data, specify the start of the channel.
7 *4
*5
Constants cannot be specified by "$".
T, C, CR, CTC, CTH, Z cannot be used.
Text Processing Functions

Description of Operation
DEC ASCII text string conversion or single precision floating point type text string conversion is
performed according to the argument type specified by S .

• When S conversion destination 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 ten thousand thousand

16 bits R +1 hundred ten Store 00H in


last bit
N
R +2 one U
L
(00H) automatically.

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, refer to "DASC function", page 7-158.

7-162 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• When S conversion destination is 32 bits: The same operation as the DASC function is
performed.
bit
31
S +1 bit bit
16 15
S bit
0
bit
15
bit
0

ARITHMETIC OPERATION FUNCTIONS


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.

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

+4
ten thousand

hundred
thousand

ten
7
N
+5 one

Text Processing Functions


R U
L
(00H)

Store 00H in last bit


automatically.

For details on operation, refer to "DASC function", page 7-158.

• When S conversion destination 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


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, refer to "FASC function", page 7-174.
"About operation flag (CR2009 to CR2012)", page 1-18

Point • When a constant is used for the conversion destination data, it cannot be
specified in HEX ($).
• When any of the following conditions is established, the end code (NUL(00H)) is
stored in R .
• When a bit other than the start of the channel is specified when bit data is
specified for R .
• When a timer/counter is specified to R by indirect specification.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-163


● Example of format
DM2000.T = STR ( DM1000 )
CR2002 ADRSET
ARITHMETIC OPERATION FUNCTIONS

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

7 DASC
DM1000 *@VM2
Text Processing Functions

MOV
@VM0 CR2800

Send turnoff signal


CR2002 SMOV
*@VM2 DM2000
Always ON
Return value

7-164 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-165


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RDASC

RDASC Convert DEC ASCII text string to BIN data

Decimal ASCII code reverse conversion

Return value*1 = RDASC (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the target that stores the
Conversion
S1 decimal ASCII string to be converted or - - - - - - - .T ○ ○ ○
destination*2*3
the decimal ASCII code string.
*6
R Return value*4 .L type RDASC function available.* 5 .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 data, specify the start of the channel.
*3 T, C, CR, CTC, CTH, Z cannot be used.
*4 When bit data is specified, 32 continuous bits are processed.
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.
*5 When the type other than .L is specified by return value, type conversion will be automatically
7 *6
conducted during conversion.
The ".DF" suffix cannot be specified for device Z.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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 一 U (00H)
L NUL (00H) shall add to end of string.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

● Example of format
DM2000.L = RDASC ( DM1000.T )

Always ON

Always ON
Return value

7-166 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • Specify a text string comprising $30 to $39 ("0" to "9") and $2B, $2D ("±": only in
the case of signed conversion) to the decimal ASCII text string specified by the
conversion destination data.

ARITHMETIC OPERATION FUNCTIONS


• When an ASCII text string other than the above has been specified to S , the
function is not executed.
• When the ASCII text string specified by S does not contain a NUL (00H), the
function converts text strings up to 11 characters.
• When any of the following conditions is established, "0" is stored in R .
• When there is an invalid character in . S
• When the value after conversion is outside the signed 32-bit BIN data range
• When a bit other than the start of the channel is specified when bit data is
specified for S .
• When a timer/counter is specified to S by indirect specification.

Sample Program
7
● When this function is used in combination with other functions

Text Processing Functions


Programmed Script
DM2000.L = RDASC ( SLEFT ( DM1000.T, 7 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SLEFT function", page 7-188
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-167


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
HASC

HASC Convert BIN data to HEX ASCII text string

HEX ASCII code conversion

Return value*1 = HASC (conversion destination, number of conversion digits)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the desitnation that stores the
Conversion BIN data to be converted or the
S .U .U .D .D - - - - ○ ○ ○
destination*2 conversion destination data.
(unsigned BIN data)
Specifies the number of digits of the
Number of
numerical value (HEX) to store the *3
n conversion .U .U .U .U - - - - ○ ○
conversion result to. ○
digits*5
(0 to 8)
Return
R .T type HASC function available. - - - - - - - .T - ○ -
value*4*6
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
7 *2 When bit data is specified, 16/32 continuous bits are processed.
When a relay other than the leading relay (e.g. R002, R1012) of the channel has been specified,
Text Processing Functions

the relay is handled in16/32 bits straddling the next channel.


*3 Constants must be specified by "$". They cannot be specified by "#".
*4 The .T suffix must be specified to the storage destination for the return value.
In addition, when bit data is specified for the return value, it is necessary to specify the start of the
channel.
*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.
(When "0" is specified, zero suppress is ON, and the number of effective digits is stored.)
*6 T, C, CR, CTC, CTH, Z cannot 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 by the specified n . (When n =0, all the data of S
is converted with zeros suppressed.)

• S : When the conversion destination 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the conversion destination 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

ARITHMETIC OPERATION FUNCTIONS


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)

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)

7
R 1(31H) 2(32H)

R +1 C(43H) D(44H)

R +2 E(45H) 0(30H)

Text Processing Functions


N
R +3 U
L
(00H)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "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
CR2002 SMOV
*@VM0 DM2000
Always ON
Store device

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-169


Point • When a constant is used for the conversion destination data, it cannot be
specified in decimal (#).
• When any of the following conditions is established, the end code (NUL(00H)) is
ARITHMETIC OPERATION FUNCTIONS

stored in R .
• When a bit other than the start of the channel is specified when bit data is
specified for R .
• When a timer/counter is specified to R by indirect specification.
• 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.

Sample Program
● When this function is used in combination with other functions

Programmed Script
EM2000.T = HASC ( SRA ( DM1000.D, 8 ), 0 )
7 Operation Description 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
Text Processing Functions

ON.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SRA function", page 7-38
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7-170 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-171


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RHASC

RHASC Convert HEX ASCII text string to BIN data

HEX ASCII code reverse conversion

Return value*1 = RHASC (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination that stores the
Conversion
S1 HEX ASCII text string to be converted - - - - - - - .T ○ ○ ○
destination*2*3
or the HEX ASCII code text string.
*6
R Return value*4 .D type RHASC function available.* 5 .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 data, specify the start of the channel.
*3 T, C, CR, CTC, CTH, Z cannot be used.
*4 When bit data is specified, 32 continuous bits are processed. 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.

7 *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.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The HEX ASCII code 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

7-172 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2000.D = RHASC ( DM1000.T )

Always ON

Conversion destination

Always ON
Return value

Point • S A value in the range $30 to $39 ("0" to "9") or $41 to $46 ("A" to "F") must
be stored in HEX ASCII text string specified by the conversion destination data.
• Use uppercase A to F (41H to 46H) in HEX ASCII text strings. Lowercase
7
characters are not supported.

Text Processing Functions


• When any of the following conditions is established, "0" is stored in R .
• When there is an invalid character in S .
• When the value after conversion is outside the unsigned 32-bit BIN data
range
• When a bit other than the start of the channel is specified when bit data is
specified for S .
• When a timer/counter is specified to S by indirect specification.

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.D = RHASC ( SLEFT ( DM1000.T, 6 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SLEFT function", page 7-188
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-173


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FASC

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
ARITHMETIC OPERATION FUNCTIONS

decimal point, conversion destination, conversion parameter)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Display Specifies the display specification
S1 specification format (decimal point format, .U .U .U .U - - - .T ○ ○ ○
format exponential format).
Total number of
S2 Specifies the total number of digits. .U .U .U .U - - - - ○ ○ ○
digits
Number of
S3 Specifies the number of decimals. .U .U .U .U - - - - ○ ○ ○
decimals
Specifies the destination that stores the
single-precision floating point type real
Conversion
number to be converted or the single- - - - - .F - - - ○ ○ ○
S4 destination*2*3*5
precision floating point type real
7 Conversion
number data.
Specifies zero suppress and sign
S5 .U .U .U .U - - - - ○ ○ ○
parameter omission.
Text Processing Functions

Return
R .T type FASC function available - - - - - - - .T - ○ -
value*4*5
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When bit data is specified, it occupies 32 continuous bits. 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.
*3 Refer to "INTG function", page 7-122 for details on the range of the single precision floating
point type real number.
*4 For bit data, specify the start of the channel.
*5 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
The single precision floating point type real number data stored in S4 is converted to a text string
appended with the end code NUL (00H) according to the conversion parameters stored in S1 to
S3 and S5 , and the result is stored in R .
The conversion parameters are specified as follows:

Display specification Specifies "0" when converting to a decimal point format text string, and "1"
S1
format when 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 Valu
e Details 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

7-174 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


bit
15
“+012.30” bit
0

R + (31H) 0 (30H)
S2 +1 S2
R +1 1 (31H) 2 (32H)
+12.3

ARITHMETIC OPERATION FUNCTIONS


R +2 .(2EH) 3 (33H)
Single precision floating point type real number N
R +3 0 (30H) U
L (00H)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

● Example of format
DM2000.T = FASC ( 0, 10, 3, DM1200.F, DM1000 )
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2
7
MOV.D

Text Processing Functions


VM0 @VM4

CR2002 MOV
#0 @VM0
Always ON
MOV
#10 @VM1

MOV
#3 @VM2

MOV
CR2814 @VM3
ASCII Conversion
DM1000 zero suppression setting CR2814
LDA STA
Conversion ASCII Conversion
parameter zero suppression setting
FASC
@VM0 DM1200 *@VM4
Conversion destination
@VM3 CR2814
LDA STA
ASCII Conversion zero
suppression setting
CR2002 SMOV
*@VM4 DM2000
Always ON
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-175


Point • When a constant is used for the conversion destination data, it cannot be
specified in HEX ($).
• Attention is required when changing or looking up CR2814/CR2815 by interrupt
ARITHMETIC OPERATION FUNCTIONS

programs.
• When any of the following conditions is established, the end code (NUL(00H)) is
stored in R .
• When the argument value is out of range
• When a single precision floating point type real number out of the range has
been specified
• When the number of digits of the text string to store has exceeded the total
number of digits
• When a bit other than the start of the channel is specified when bit data is
specified for R .
• When a timer/counter is specified to R by indirect specification.
• When the total number of digits and the number of digits past the decimal

7 point do not satisfy the following conditions.

Decimal point format display Exponent format display


Text Processing Functions

S3 =0 1≦ S2 ≦ 24 5≦ S2 ≦24
S3 +2≦ S2 S3 +6≦ S2
0< S3 ≦7
3 ≦ S2 ≦ 24 7≦ S2 ≦24

Sample Program
● When this function is used in combination with other functions

Programmed Script
EM2000.T = FASC ( 0, 10, 3, SIN ( DM1000.F ), 3 )
Operation Description 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)
The converted text string is appended with the end code NUL (00H), and is stored in
EM2000.T. (The conversion destination need not be converted to a single precision
floating point type by using the FLOAT function, etc.)

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SIN function", page 7-140
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7-176 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-177


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RFASC

Text string to single precision floating point type real number


RFASC conversion

Single precision floating point text string reverse conversion

Return value*1 = RFASC (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination that stores the
Conversion single precision floating point text string
.T
to be converted or the single precision - - - - - - - ○ ○ ○
S
destination*2*4*5
floating point type text string.
Return *7
R .F type RFASC function available.* 6 .U .S .D .L .F .DF - - - ○ -
value*3*5
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit data, specify the start of the channel.
*3 When bit data is specified, it occupies 32 continuous bits. 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 *4 A NUL (00H) is required at the end of the single precision floating point type text string that is
specified by the conversion destination.
*5 T, C, CR, CTC, CTH, Z cannot be used.
Text Processing Functions

*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".
7-178 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
DM2000.F = RFASC ( DM1000.T )
CR2002 MOV.F

ARITHMETIC OPERATION FUNCTIONS


+0 @VM0
Always ON
RFASC
DM1000 @VM0

Conversion destination
CR2002 MOV.F
@VM0 DM2000
Always ON
Return value

Point • 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.
• When any of the following conditions is established, "0" is stored in R .
• When the length of a text string is 0
• When the format of the text string is incorrect
7
• When the numerical value after conversion exceeds the single precision

Text Processing Functions


floating point type real number range
• When the number of digits of the text string to store has exceeded the total
number of digits
• When a bit other than the start of the channel is specified when bit data is
specified for 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.

+ +
E−

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-179


Sample Program
● When this function is used in combination with other functions
ARITHMETIC OPERATION FUNCTIONS

Programmed Script
DM2000.F = COS ( RFASC ( DM1000.T ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"COS function", page 7-142
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7
Text Processing Functions

7-180 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
VAL

Text string to single precision floating point type real number


VAL conversion

Single precision floating point text string reverse conversion

Return value*1 = VAL (conversion destination)

ARITHMETIC OPERATION FUNCTIONS


Argument/Return Supported Type Const Device/ For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination that stores the
Conversion single precision floating point text string
.T
to be converted or the single precision - - - - - - - ○ ○ ○
S
destination*2*3*5
floating point type text string.
*7
R Return value*4 .F type VAL function available.* 6 .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 data, specify the start of the channel.
*3 A NUL (00H) is required at the end of the single precision floating point type text string that is
specified by the conversion destination.
*4 When bit data is specified, it occupies 32 continuous bits. 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
*5 T, C, CR, CTC, CTH, Z cannot be used.

Text Processing Functions


*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.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
This function differs from the "RFASC function" in name only, and operation, etc. are the same.
For details on operation, refer to "RFASC function", page 7-178.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-181


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LEN

LEN Detect text string length

Detect text string length

Return value*1 = LEN (Destination text string)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Destination text *2
S text string for calculating the text string - - - - - - - .T ○ ○
string*3*4 ○
length, or the destination text string.
*6
R Return value .U type LEN function available.* 5 .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 To specify a text string using constants, enclose with " ".
*3 For bit data, specify the start of the channel.
*4 T, C, CR, CTC, CTH, Z cannot be used.
*5 When the type other than .U is specified by return value, type conversion will be automatically

7 *6
conducted during conversion.
The ".DF" suffix cannot be specified for device Z.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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
16 bits
S +1 c(63H) d(64H) (1 word)

S +2 e(65H) f(66H)

w(77H) x(78H)
y(79H) z(7AH)
N
U (00H)
L

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-182 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000 = LEN ( DM1000.T )
CR2002 MOV

ARITHMETIC OPERATION FUNCTIONS


#0 @VM0
Always ON
LEN
DM1000 @VM0
Destination string
CR2002 MOV
@VM0 DM2000
Always ON
Return value

Point • 2-byte characters are handled as two characters.


• End codes (NUL (00H)) are not counted.
• When any of the following conditions is established, "0" is stored in R .
• When there is no end code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000
characters 7
• When a bit other than the start of the channel is specified when bit data is

Text Processing Functions


specified for S by indirect specification.
• When a timer/counter is specified to S by indirect specification.

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 )
Operation Description 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

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
DM1008 0(30H) U
L (00H)

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SINS function", page 7-200
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-183


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SRGHT

SRGHT Cut text string on right

Cut text string on right

Return value*1 = SRGHT (cut destination, number of cut characters)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
*2
Return value
R *6 .T type SRGHT 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 data, specify the start 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 right 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.
Text Processing Functions

*6 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
The text string currently stored starting from S is cut from the right end by the number of characters
(number of bytes) specified by n , 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.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-184 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = SRGHT ( DM1000.T, 40 )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SRGHT
DM1000 *@VM0 #40
Always ON
Cut destination
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Point • When any of the following conditions is established, the end code (NUL (00H)) is stored.
• When the text string specified by
(NUL(00H))
S does not contain the end code
7
• When the text string including the end code (NUL (00H)) exceeds 2000

Text Processing Functions


characters
• When the text string to be stored in R onwards exceeds the device /
variable range
• When a bit other than the start of the channel is specified when bit data is
specified for S and R .
• 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

Programmed Script
EM2000.L = RDASC ( SRGHT ( DM1000.T, 8 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RDASC function", page 7-166
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-185


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RIGHT

RIGHT Cut text string on right

Cut text string on right

Return value*1 = RIGHT (cut destination, number of cut characters)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
*2
Return value
R *6 .T type RIGHT 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 data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".

7 *4
*5
$ cannot be used.
Specify the number of characters (number of bytes) from the right end to the number of cut
characters within the range 0 to 1999.
Text Processing Functions

When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
This function differs from the "SRGHT function" in name only, and operation, etc. are the same.
For details on operation, refer to "SRGHT function", page 7-184.

7-186 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-187


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SLEFT

SLEFT Cut text string on left

Cut text string on left

Return value*1 = SLEFT (cut destination, number of cut characters)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
*2
Return value
R *6 .T type SLEFT 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 data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".

7 *4
*5
$ cannot be used.
Specify the number of characters (number of bytes) from the left end to the number of cut
characters within the range 0 to 1999.
Text Processing Functions

When "0" has been specified, one character's worth of NUL (00H) is stored in return value.
*6 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
The text string currently stored starting from S is cut from the left end (start) by the number of
characters (number of bytes) specified by n , 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
M(4DH) N(4EH) to end of string.

S(53H) T(54H)
N
U(55H) U
L (00H)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-188 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = SLEFT ( DM1000.T, 40)
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SLEFT
DM1000 *@VM0 #40
Always ON
Cut destination
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Point • When any of the following conditions is established, the end code (NUL (00H)) is
stored.
• When the text string specified by S does not contain the end code (NUL 7
(00H))

Text Processing Functions


• When the text string including the end code (NUL (00H)) exceeds 2000
characters
• When the text string to be stored in R onwards exceeds the device /
variable range
• When a bit other than the start of the channel is specified when bit data is
specified for S and R .
• 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

Programmed Script
EM2000.D = RHASC ( SLEFT ( DM1000.T, 4 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RHASC function", page 7-172
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-189


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LEFT

LEFT Cut text string on left

Cut text string on left

Return value*1 = LEFT (cut destination, number of cut characters)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
*2
Return value
R *6 .T type LEFT 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 data, specify the start 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 left 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.
Text Processing Functions

*6 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
This function differs from the "SLEFT function" in name only, and operation, etc. are the same.
For details on operation, refer to "SLEFT function", page 7-188.

7-190 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-191


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SMID

SMID Cut text string

Cut text string

Return value*1 = SMID (cut destination, cut character position, number of cut
ARITHMETIC OPERATION FUNCTIONS

characters)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n1 Cut
Specifies the cut leading position *4
character .U .U .U .U - - - - ○ ○
(number of bytes). (0 to 1999) ○
position*7
n2 Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
Return
R .T type SMID function available - - - - - - - .T - ○ -
value*2*6

7 *1
*2
The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 $ cannot be used.
*5 Specify the number of characters (number of bytes) from the cut character to the number of cut
characters within the range of 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 cannot be used.
*7 The leading character of the text string specified by S is taken to be "0".

Description of Operation
The text string currently stored starting from S is cut from the position (number of bytes) specified
by n1 by n2 characters (number of bytes), appended with the end code NUL (00H), and the
result is stored in R .
Position 0

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
character K(4BH) L(4CH)
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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-192 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = SMID ( DM1000.T, 8, 16 )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SMID
DM1000 *@VM0 #8
Always ON Cut destination
#16

CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

• When any of the following conditions is established, the end code (NUL (00H)) is
Point
stored. 7
• When the text string specified by does not contain the end code (NUL
S

Text Processing Functions


(00H))
• When the text string including the end code (NUL (00H)) exceeds 2000
characters
• When S text string length < n1 .
• When the text string to be stored in R onwards exceeds the device /
variable range
• When a bit other than the start of the channel is specified when bit data is
specified for S and R .
• 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

Programmed Script
EM2000.D = RHASC ( SMID ( DM1000.T, 2, 4 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RHASC function", page 7-172
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-193


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MID

MID Cut text string

Cut text string

Return value*1 = MID (cut destination, cut character position, number of cut
ARITHMETIC OPERATION FUNCTIONS

characters)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
S Cut *3
text string to be cut, or the cut - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
n1 Cut
Specifies the cut leading position *4
character .U .U .U .U - - - - ○ ○
(number of bytes). (0 to 1999) ○
position*7
n2 Number of cut Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
characters*5 (number of bytes) to cut. (0 to 1999) ○
Return
R .T type MID function available - - - - - - - .T - ○ -
value*2*6

7 *1
*2
The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 $ cannot be used.
*5 Specify the number of characters (number of bytes) from the cut character to the number of cut
characters within the range of 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 cannot be used.
*7 The leading character of the text string specified by S is taken to be "0".

Description of Operation
This function differs from the "SMID function" in name only, and operation, etc. are the same.
For details on operation, refer to "SMID function", page 7-192.

7-194 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-195


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SRPLC

SRPLC Replace text string section

Replace text string section

Return value*1 = SRPLC (replace destination, replace text string destination,


ARITHMETIC OPERATION FUNCTIONS

replace leading postion, number of replaced characters)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Replace *3
S1 text string to be replaced, or the - - - - - - - .T ○ ○
destination*2*6 ○
replace destination text string.
S2 Replace text Specifies the destination to store the *3
string text string to replace, or the replace text - - - - - - - .T ○ ○

destination*2*6 string.
Replace leading Specifies the replace leading position *4
n1 .U .U .U .U - - - - ○ ○
position*7 (number of bytes). (0 to 1999) ○
Number of replaced Specifies the number of characters *4
.U .U .U .U - - - - ○ ○
n2
characters*5 (number of bytes) to replace. (0 to 1999) ○
Return Stores the value of the function
7 R
value*2*6 processed result. - - - - - - - .T - ○ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
Text Processing Functions

*2 For bit data, specify the start 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 replace leading position to the
number of replace characters within the range of 0 to 1999.
*6 T, C, CR, CTC, CTH, Z cannot be used.
*7 The leading character of the text string specified by S1 is taken to be "0".

Description of Operation
The text string currently stored starting from S1 is replaced with the text string currently stored
starting from S2 from the position (number of bytes) specified by n1 by the text string with the
number of characters (number of bytes) specified by n2 , appended with the end code NUL (00H),
and the result is stored in R .

Position 0

Replace string of Replace start position n1


object bit
15
bit
0

S1 A(41H) B(42H) R A(41H) B(42H)

S1 +1 C(43H) D(44H) R +1 C(43H) D(44H)


When number of character is
S1 +2 E(45H) F(46H) n2 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)

S(53H) T(54H) When n1 = 4, n2 =2 T(54H) U(55H)


N N
U(55H) U
L (00H)
string after replace are as follows. U
L (00H)

NUL (00H) shall add NUL (00H) shall store to


to end of string. end of string.

String shall replace

S2 X(58H) Y(59H)
N
S2 +1 Z(5AH) U
L (00H)

7-196 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

ARITHMETIC OPERATION FUNCTIONS


● 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

CR2002 SRPLC
DM1000 DM1200 *@VM0
Always ON Replace destination device Replace string device
#10 #20
CR2002

Always ON
SMOV
*@VM0 DM2000 7
Return value

Text Processing Functions


Point • When any of the following conditions is established, the end code (NUL (00H)) is stored.
• When the text string specified by S1 and S2 does not contain the end
code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000 characters
• When S1 text string length < n1 .
• When the length of the text string after the replace exceeds 2000 characters
including (NUL (00H))
• When a bit other than the start of the channel is specified when bit data is
specified for S1 , S2 and R .
• When a timer/counter is specified to S1 , S2 and R by indirect
specification.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-197


Sample Program
● When this function is used in combination with other functions
ARITHMETIC OPERATION FUNCTIONS

Programmed Script
EM2000.L = RDASC ( SRPLC ( DM1000.T, EM1000.T, 0, 4 ) )
Operation Description 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
data, and the result is stored in EM2000.L.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RDASC function", page 7-166
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7
Hint
Text Processing Functions

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 )

Example 2)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-198 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
REPLACE

REPLACE Replace text string section

Replace text string section

Return value*1 = REPLACE (replace destination, replace text string destination,

ARITHMETIC OPERATION FUNCTIONS


number of replaced characters, replace leading position)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Replace *3
S1 text string to be replaced, or the - - - - - - - .T ○ ○
destination*2*6 ○
replace destination text string.
S2 Replace text Specifies the destination to store the *3
string text string to replace, or the replace text - - - - - - - .T ○ ○

destination*2*6 string.
Number of Specifies the number of characters *4
n1 replaced (number of bytes) to replace. (0 to .U .U .U .U - - - - ○ ○

characters*5 1999)
Replace leading Specifies the replace leading position *4
.U .U .U .U - - - - ○ ○
n2
position*7 (number of bytes). (0 to 1999) ○

R
Return
value*2*6
Stores the value of the function
processed result. - - - - - - - .T - ○ -
7

Text Processing Functions


*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit data, specify the start 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 replace leading position to the
number of replace characters within the range of 0 to 1999.
*6 T, C, CR, CTC, CTH, Z cannot 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, refer to "SRPLC function", page 7-196.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-199


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SINS

SINS Insert text string

Insert text string

Return value*1 = SINS (insert destination, insert text string destination, insert
ARITHMETIC OPERATION FUNCTIONS

leading position)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Insert *3
S1 text string to be inserted, or the insert - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
S2 Insert text Specifies the destination to store the *3
string text string to insert, or the insert text - - - - - - - .T ○ ○

destination*2*6 string.
Insert leading Specifies the insert leading position *4
.U .U .U .U - - - - ○ ○

position*7 (number of bytes). (0 to 1999) ○
Return
R .T type SINS function available - - - - - - - .T - ○ -
value*4*6

7 *1
*2
The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 $ cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (start) to the number of
insert characters within the range 0 to 1999.
*6 T, C, CR, CTC, CTH, Z cannot be used.
*7 The leading character of the text string specified by S1 is taken to be "0".

Description of Operation
The text string currently stored starting from S2 is inserted to the position (number of bytes)
specified by n of the text string currently stored starting from S1 , appended with the end code
NUL (00H), and the result is stored in R .

Position 0

Insert string of Insert start position n


object bit
15
bit
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)

R +5 K(4BH) L(4CH)
When n = 6 , string after
S(53H) T(54H) R +6 M(4DH) N(4EH)
insert are as follows.
N
U(55H) U
L (00H)

S(53H) T(54H)
NUL (00H) shall add
N
to end of string. 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)

7-200 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

ARITHMETIC OPERATION FUNCTIONS


● Example of format
DM2000.T = SINS ( DM1000.T, DM1200.T, 10 )
CR2002 ADRSET
VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 SINS
DM1000 DM1200 *@VM0
Always ON

7
Insert Insert string
destination
#10

Text Processing Functions


CR2002 SMOV
*@VM0 DM2000
Always ON
Storage device

Point • When any of the following conditions is established, the end code (NUL (00H)) is stored.
• When the text string specified by S1 and S2 does not contain the end
code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000 characters
• When S1 text string length < n .
• When the length of the text string after the insert exceeds 2000 characters
including (NUL (00H))
• When a bit other than the start of the channel is specified when bit data is
specified for S1 , S2 and R .
• When a timer/counter is specified to S1 , S2 and R by indirect
specification.

Sample Program
● When this function is used in combination with other functions

Programmed Script
EM2000.D = RHASC ( SINS ( DM1000.T, EM1000.T, 2 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RDASC function", page 7-166
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-201


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
lNSERT

INSERT Insert text string

Insert text string

Return value*1 = INSERT (insert destination, insert text string destination, insert
ARITHMETIC OPERATION FUNCTIONS

leading position)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Insert *3
S1 text string to be inserted, or the insert - - - - - - - .T ○ ○
destination*2*6 ○
destination text string.
S2 Insert text Specifies the destination to store the *3
string text string to insert, or the insert text - - - - - - - .T ○ ○

destination*2*6 string.
Insert leading Specifies the insert leading position *4
.U .U .U .U - - - - ○ ○

position*7 (number of bytes). (0 to 1999) ○
Return
R .T type INSERT function available - - - - - - - .T - ○ -
value*2*6

7 *1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 For bit data, specify the start of the channel.
Text Processing Functions

*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 (start) to the number of
insert characters within the range 0 to 1999.
*6 T, C, CR, CTC, CTH, Z cannot 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 "SINS function" in name only, and operation, etc. are the same.
For details on operation, refer to "SINS function", page 7-200.

7-202 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-203


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SDEL

SDEL Delete text string section

Delete text string section

Return value*1 = SDEL (delete destination, delete leading position, number of delete
ARITHMETIC OPERATION FUNCTIONS

characters)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Delete *3
S text string to be deleted, or the delete - - - - - - - .T ○ ○
destination*2*7 ○
destination text string.
n1 Delete leading Specifies the delete leading position
.U .U .U .U - - - - ○ ○ ○
position*4*5 (number of bytes). (0 to 1999)
Number of delete Specifies the number of characters
.U .U .U .U - - - - ○ ○ ○
n2
characters*4*6 (number of bytes) to delete. (0 to 1999)
Return
R .T type SDEL function available - - - - - - - .T - ○ -
value*2*7
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.

7 *2
*3
For bit data, specify the start of the channel.
To specify a text string using constants, enclose with " ".
*4 $ cannot be used.
Text Processing Functions

*5 Specify the number of characters (number of bytes) from the left end (start) to the number of
deleted characters within the range 0 to 1999.
*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.
*7 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
The text string currently stored starting from S is deleted from the position (number of bytes)
specified by n1 by the text string with number of characters (number of bytes) specified by n2 ,
appended with the end code NUL (00H), and the result is stored in R .
Position 0 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 R +1 E(45H) F(46H)


character
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.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-204 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = SDEL ( DM1000.T, 10, 20 )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
常時ON
MOV
#0 VM2

MOV.D
VM0 @VM0
CR2002 SDEL
DM1000 *@VM0 #10
常時ON 削除対象
#20
CR2002 SMOV
*@VM0 DM2000
常時ON
戻り値

Point • When any of the following conditions is established, the end code (NUL (00H)) is stored.
• When the text string specified by S does not contain the end code (NUL
(00H))
7
• When the text string including the end code (NUL (00H)) exceeds 2000

Text Processing Functions


characters
• When S text string length < n1 .
• When the text string to be stored in R onwards exceeds the device /
variable range
• When a bit other than the start of the channel is specified when bit data is
specified for S and R .
• 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

Programmed Script
EM2000.D = RHASC ( SDEL ( DM1000.T, 2, 4 ) )
Operation Description 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.
Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RHASC function", page 7-172
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-205


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DELETE

DELETE Delete text string section

Delete text string section

Return value*1 = DELETE (delete destination, number of delete characters, delete


ARITHMETIC OPERATION FUNCTIONS

leading position)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Delete *3
S text string to be deleted, or the delete - - - - - - - .T ○ ○
destination*2*7 ○
destination text string.
Number of delete Specifies the number of characters
.U .U .U .U - - - - ○ ○ ○
n1
characters*4*6 (number of bytes) to delete. (0 to 1999)
n2 Delete leading Specifies the delete leading position
.U .U .U .U - - - - ○ ○ ○
position*4*5 (number of bytes). (0 to 1999)
Return
R .T type DELETE function available - - - - - - - .T ○ ○ -
value*2*7
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/

7 *2
memory.
For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 $ cannot be used.
*5 Specify the number of characters (number of bytes) from the left end (start) to the number of
deleted characters within the range 0 to 1999.
*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.
*7 T, C, CTC, CTH, Z cannot be used.

Description of Operation
The text string currently stored starting from S is deleted from the position (number of bytes)
specified by n2 by the text string with number of characters (number of bytes) specified by n1 ,
appended with the end code NUL (00H), and the result is stored in R .
Position 0 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 R +1 E(45H) F(46H)


character
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.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-206 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = DELETE ( DM1000.T, 20, 10 )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always ON
MOV
#0 VM2
MOV.D
VM0 @VM0
CR2002 SDEL
DM1000 *@VM0 #10
Always ON Delete destination
#20
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Point • When any of the following conditions is established, the end code (NUL (00H)) is
stored.
• When the text string specified by S does not contain the end code (NUL 7
(00H))

Text Processing Functions


• When the text string including the end code (NUL (00H)) exceeds 2000
characters
• When S text string length < n2 .
• When the text string to be stored in R onwards exceeds the device /
variable range
• When a bit other than the start of the channel is specified when bit data is
specified for S and R .
• 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

Programmed Script
EM2000.D = RHASC ( DELETE ( DM1000.T, 4, 2 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RHASC function", page 7-172
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-207


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TRIM

TRIM Trim 1-byte space and tab at ends of text string

Trim

Return value*1 = TRIM (Destination text string)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Destination text *3
S text string to be trimmed, or the trim - - - - - - - .T ○ ○
string*2 ○
destination text string.
Return
R Stores the trimmed text string. - - - - - - - .T - ○ -
value*2*4
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z cannot be used.

7 Point • The TRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Text Processing Functions

Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
All 1-byte spaces (20H) and labels (09H) at both ends (start and end) of the text string stored starting
from S are deleted, the end code NUL (00H) is appended, and the result is stored in R .

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-208 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = TRIM ( DM1000.T )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always ON
MOV
#0 VM2

MOV.D
VMO @VM2

CR2002 MOV
#0 @VM0
Always ON
@VM0
BSET
#0
@VM0
BSET
#1
CR2002 STRIM
DM1000 @VM0 *@VM2

7
Always ON Target text
string device
CR2002 SMOV
*@VM2 DM2000

Text Processing Functions


Always ON
Return value

Sample Program
● When this function is used in combination with other functions
Programmed Script
EM2500.D = RHASC ( TRIM ( DM1000.T ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-209


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LTRIM

LTRIM Trim 1-byte space and tab at left end of text string

Left trim

Return value*1 = LTRIM (Destination text string)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Destination text *3
S text string to be trimmed, or the trim - - - - - - - .T ○ ○
string*2 ○
destination text string.
Return
R Stores the trimmed text string. - - - - - - - .T - ○ -
value*2*4
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z cannot be used.

7 Point • The LTRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Text Processing Functions

Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
All 1-byte spaces (20H) and labels (09H) at the left end (start) of the text string stored starting from
S are deleted, the end code NUL (00H) is appended, and the result is stored in R .

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-210 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = LTRIM ( DM1000.T )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


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

CR2002 SMOV

Always ON
*@VM2 DM2000

Return value
7

Text Processing Functions


Sample Program
● When this function is used in combination with other functions

Programmed Script
EM2500.D = RHASC ( LTRIM ( DM1000.T ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-211


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RTRIM

RTRIM Trim 1-byte space and tab at right end of text string

Right trim

Return value*1 = RTRIM (Destination text string)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Destination text *3
S text string to be trimmed, or the trim - - - - - - - .T ○ ○
string*2 ○
destination text string.
Return
R Stores the trimmed text string. - - - - - - - .T - ○ -
value*2*4
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CTC, CTH, Z cannot be used.

7 Point • The RTRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Text Processing Functions

Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
All 1-byte spaces (20H) and labels (09H) at the right end (end) of the text string stored starting
from S are deleted, the end code NUL (00H) is appended, and the result is stored in R .

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-212 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = RTRIM ( DM1000.T )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


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
CR2002 SMOV

Always ON
*@VM2 DM2000

Return value
7

Text Processing Functions


Sample Program
● When this function is used in combination with other functions

Programmed Script
EM2500.D = RHASC ( RTRIM ( DM1000.T ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-213


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
STRIM

STRIM Trim 1-byte space and tab from specified text string position

Specified position trim

Return value*1 = STRIM (Destination text string, delete position specification


ARITHMETIC OPERATION FUNCTIONS

parameter)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Destination text *3
S1 text string to be trimmed, or the trim - - - - - - - .T ○ ○
string*2 ○
destination text string.
Delete position
Specifies the position to be trimmed (1
S2 specifying .U .U .U .U - - - - ○ ○ ○
to 3).
parameter
Return
R Stores the trimmed text string. - - - - - - - .T - ○ -
value*2*4
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 For bit data, specify the start of the channel.

7 *3
*4
To specify a text string using constants, enclose with " ".
T, C, CTC, CTH, Z cannot be used.
Text Processing Functions

Point • The STRIM function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
All 1-byte spaces and labels at the position specified by S2 are deleted from the text string stored
starting from S1 , the end code NUL (00H) is appended, and the result is stored in R .
The details specified with the delete position specifying parameter are given below.

S2 Val
Details
ue
All 1-byte spaces and tabs at the left end of the text string
1
are deleted. (Same action as LTRIM function)
All 1-byte spaces and tabs at the right end of the text string
2
are deleted. (Same action as RTRIM function)
All 1-byte spaces and tabs at both ends of the text string are
3
deleted. (Same action as TRIM function)

Point If a parameter other than the above is specified, R is stored in S1 without


executing the function.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-214 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = STRIM ( DM1000.T, 3 )
CR2002 ADRSET

ARITHMETIC OPERATION FUNCTIONS


VM2 VM0
Always
ON MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 STRIM
DM1000 #3 *@VM0
Always ON
Target text
string device
CR2002 SMOV
*@VM0 DM2000
Always ON
Return value

Sample Program 7
● When this function is used in combination with other functions

Text Processing Functions


Programmed Script
EM2500.D = RHASC ( STRIM ( DM1000.T, 3 ) )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-215


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SPLIT

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)
ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Split source text *3
S1 split source text string, or the split - - - - - - - .T ○ ○
string*2 ○
target text string.
Specifies the destination to store the
*3
S2 Limit text string*2 limit text string, or the limit target text - - - - - - - .T ○ ○

string.
D1 Split Specifies the destination to store the
text string 1 *2 split text string 1. - - - - - - - .T - ○ -

D2 Split Specifies the destination to store the


text string 2 *2 split text string 2. - - - - - - - .T - ○ -

- - - - - - - .T
···

···

···

- ○ -

7 Dn Split
text string n *2*4
Specifies the destination to store the
split text string n. - - - - - - - .T - ○ -
Return Stores the number of splitting. .U type
.U .S .D .L .F .DF - -
Text Processing Functions

R
value*2*5 SPLIT function available.* 6 - ○ -

*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/
memory.
*2 For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 Specify the argument number n in the range of 1 to 10.
*5 T, C, CTC, CTH, Z cannot be used.
*6 When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.

Point • The SPLIT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
S1 is split with S2 , and the results are stored in the D1 to Dn split text strings.
R stores the number of split text strings.

When S1 is "18,1A,35,E0,C3,EB" and S2 is "," (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-216 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Reference • When R nunber of splitting =0, the function is not executed.
• When 0 < R number of splitting < n, only the end code (NUL) is stored for the
excessive argument.
• When R number of splitting = n, Dn may contain a limit character (splitting may

ARITHMETIC OPERATION FUNCTIONS


still be possible).
If only judging whether splitting is possible, the 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 S1 in
Dn and executing the SPLIT function.
"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 )
7
The text string "date, data, record" stored in DM2000.T is split by "," (comma) and stored

Text Processing Functions


Operation Description

in EM3000.T, EM3100.T, and EM3200.T.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-217


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SFIND

SFIND Search text string

Search text string

Return value*1 = SFIND (search destination, search text string destination, search
leading position)
ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Search *3
S1 text string to be searched, or the - - - - - - - .T ○ ○
destination*2*6 ○
search destination text string.
S2 Search text string Specifies the destination to store the text *3
destination*2*6 string to search, or the search text string. - - - - - - - .T ○ ○ ○

n Search leading Specifies the search leading position *4


.U .U .U .U - - - - ○ ○
position*4*5 (number of bytes). (0 to 1999) ○
*8
R Return value .U type SFIND function available.* 7 .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 data, specify the start of the channel.

7 *3
*4
To specify a text string using constants, enclose with " ".
$ cannot be used.
*5 Specify the number of characters (number of bytes) from the start of the search target string to
Text Processing Functions

the number of search characters within the range 0 to 1999.


*6 T, C, CTC, CTH, Z cannot be used.
*7 When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.
*8 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-5500/5000/
3000 series CPU units with CPU function version 2.0 or later, and KV Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is established (TRUE), the search text string currently stored starting
from S2 is searched from the position specified by n in 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 is
first found from n onwards as a result of the search is stored in R .
When the text string specified by S2 is not found, or the text string length of S2 is 0, $FFFF is
stored in R .
Position 0
Destination text string
to be searched Position n 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) T(54H)
Search range
N
U(55H) U
L (00H)

NUL (00H) shall add to end of string.


7-218 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

● Example of format

ARITHMETIC OPERATION FUNCTIONS


DM2000.U = SFIND ( DM1000.T, DM1200.T, 8 )
CR2002 MOV
#0 @VM0
Always ON
SFIND
DM1000 DM1200 @VM0
Search destination Search string
#8

CR2002 MOV
@VM0 DM2000
Always ON
Search result

When any of the following conditions is established, "0" is stored in .


7
R
Point
• When the text string specified by S1 and S2 does not contain the end
code (NUL (00H))

Text Processing Functions


• When the text string including the end code (NUL (00H)) exceeds 2000
characters
• When (length of S1 text string) < (length of n + S2 text string).
(Length of text strings do not include end code "NUL (00H)")
• When a bit other than the start of the channel is specified when bit data is
specified for S1 and S2 .
• When a timer/counter is specified to S1 and S2 by indirect
specification.

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 )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SMID function", page 7-192
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-219


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SFINDN

SFINDN Search text string

Search text string N

Return value*1 = SFINDN (search destination, search text string destination,


ARITHMETIC OPERATION FUNCTIONS

number of search target bytes, search leading position)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Search *3
S1 text string to be searched, or the - - - - - - - .T ○ ○
destination*2*4 ○
search destination text string.
S2 Search text string Specifies the destination to store the text *3
.T
destination*2*4 string to search, or the search text string. - - - - - - - ○ ○ ○

S3 Number of search Specifies the length (number of bytes)


.U .U .U .U - - - - ○ ○ ○
target bytes of the text string to be searched.
S4 Search leading Specifies the search leading position
.U .U .U .U - - - - ○ ○ ○
position (number of bytes).
*6
R Return value .U type SFINDN function available.* 5 .U .S .D .L .F .DF - .T - ○ -

7 *1
*2
The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 T, C, CTC, CTH, Z cannot 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.

Point • The SFINDN function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
When the execution condition is established (TRUE), the text string stored starting from S2 is
searched from S4 of the text string of the number of search target bytes starting from S1 .
R stores the start position (number of bytes) of the text string specified by S2 found for the first
time after the position specified by S4 in the text string specified by S3 .
When the text string specified by S2 is not found, or 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) Search target text string
S1 +5 K(4BH) e(65H)
Search range
S1 +6 y(79H) NUL(00H)
When S3 =18 and S4 =4 the position where
S1 +7 d(64H) Z(60H) the text string "Key" is detected after position 4
is 10.
S1 +8 2(32H) K(4BH)
e(65H) y(79H)
NUL(00H) 3(33H)
A(41H) b(62H) R 10
c(63H) N(4EH)
7-220 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

ARITHMETIC OPERATION FUNCTIONS


● 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 Search
destination string

CR2002 MOV
@VM2 DM2000
Always ON

7
Search result

Text Processing Functions


Sample Program

Programmed Script
EM1000.T = "abcdefghijklmnabcdefghijklmn"
EM3000.T = "abc"
DM2000.U = SFINDN ( EM1000.T, EM3000.T, 50, 4 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-221


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
INSTR

INSTR Search text string

Search text string N

Return value*1 = INSTR (search leading position, search destination, text string
ARITHMETIC OPERATION FUNCTIONS

search destination)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
n Search leading Specifies the search leading position *4
.U .U .U .U - - - - ○ ○
position*5 (number of bytes). (0 to 1999) ○
Specifies the destination to store the
Search *3
S1 text string to be searched, or the - - - - - - - .T ○ ○
destination*2*6 ○
search destination text string.
S2 Search text Specifies the destination to store the
*3
string text string to search, or the search text - - - - - - - .T ○ ○

destination*2*6 string.
*8
R Return value .U type INSTR function available.* 7 .U .S .D .L .F .DF - - - ○ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
7 *2 For bit data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
Text Processing Functions

*4 $ cannot be used.
*5 Specify the number of characters (number of bytes) from the start of the search target string to
the number of search characters within the range 0 to 1999.
*6 T, C, CTC, CTH, Z cannot be used.
*7 When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.
*8 The ".DF" suffix cannot be specified for device Z.

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

7-222 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Description of Operation
When the execution condition is established (TRUE), the search text string currently stored starting

ARITHMETIC OPERATION FUNCTIONS


from S2 is searched from the position (number of bytes) specified by n in 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 is
first found from n onwards as a result of the search is stored in R .
When the text string specified by S2 is not found, or the text string length of S2 is 0, "$FFFF" is
stored in R .
Position 0
Position n
Destination text string
Character string shall search
to be searched

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)

7
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.

Text Processing Functions


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).

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "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 Search string
#8

CR2002 MOV
@VM0 DM2000
Always ON
Search result

Point When any of the following conditions is established, "0" is stored in R .


• When the text string specified by S1 and S2 does not contain the end
code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000 characters
• When (length of S1 text string) < (length of n + S2 text string).
(Length of text strings do not include end code "NUL (00H)")
• When a bit other than the start of the channel is specified when bit data is
specified for S1 and S2 .
• When a timer/counter is specified to S1 and S2 by indirect
specification.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-223


Sample Program
● When this function is used in combination with other functions
ARITHMETIC OPERATION FUNCTIONS

Programmed Script
DM2000.U = INSTR ( 0, DM1000.T, SMID ( DM1200.T, 4, 6 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SMID function", page 7-192
• The KV script is converted to a ladder program before execution. To check the converted
7 content, refer to "Create a box script Step 5"(page 2-10).
Text Processing Functions

7-224 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-225


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FIND

FIND Search text string

Search text string

Return value*1 = FIND (search destination, text string search destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Search *3
S1 text string to be searched, or the - - - - - - - .T ○ ○
destination*2*4 ○
search destination text string.
S2 Search text Specifies the destination to store the
*3
string text string to search, or the search text - - - - - - - .T ○ ○

destination*2*4 string.
*6
R Return value .U type FIND function available.* 5 .U .S .D .L .F .DF - - - ○ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 For bit data, specify the start 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 cannot be used.

7 *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.
Text Processing Functions

Point • The argument ".DF" can be used only with KV STUDIO Ver.6.00 or later.
• The argument ".DF" can be specified only for KV-8000/7000 series CPU units, KV-
5500/5000/3000 series CPU units with CPU function version 2.0 or later, and KV
Nano series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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 starting from S1 ) of the search text string that is
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) E(45H) S2 +1 E(45H) U
L (00H)

S1 +2 D(44H) 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).

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-226 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000 = FIND ( DM1000.T, DM1200.T )
CR2002 MOV

ARITHMETIC OPERATION FUNCTIONS


#0 @VM0
Always ON
SFIND
DM1000 DM1200 @VM0
Search
Search string
destination
#0

CR2002 MOV
@VM0 DM2000
Always ON
Search result

Point When any of the following conditions is established, "0" is stored in R .


• When the text string specified by S1 and S2 does not contain the end
code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000
characters
• When (length of S1 text string) < (length of S2 text string).
7
• When a bit other than the start of the channel is specified when bit data is

Text Processing Functions


specified for S1 and S2 .
• When a timer/counter is specified to S1 and S2 by indirect
specification.
• When S2 text string length is 0, or no text string is found, 65535 is input to
R .

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.U = FIND ( DM1000.T, SMID ( DM1200.T, 4, 6 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SMID function", page 7-192
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-227


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DISS

DISS Disperse text string

Disperse text string

DISS ([execution condition,]*1 disperse destination, storage destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Disperse *3
S text string to be dispersed, or the - - - - - - - .T ○ ○
destination*2*4 ○
disperse destination text string.
Storage Specifies the destination to store the
D .U .U .U .U - - - - - ○ -
destination*2 *5 dispersed text string (in words).
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 data, specify the start of the channel.
*3 To specify a text string using constants, enclose with " ".
*4 T, C, CR, CTC, CTH, Z cannot be used.
7 *5 T, C, CTC, CTH, Z cannot be used.
Text Processing Functions

Description of Operation
When the execution condition is established (TRUE), the text string in bytes currently stored starting
from S is dispersed in words and stored starting from D .

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.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

● Example of format
DISS ( R3000, DM1000.T, DM2000 )
R3000 DISS
DM1000 DM2000
Execution condition
Separate Store
destination destination

Point When any of the following conditions is established, "0" is stored in D .


• When the text string specified by S does not contain the end code (NUL (00H))
• When the text string including the end code (NUL (00H)) exceeds 2000 characters
• When a bit other than the start of the channel is specified when bit data is
specified for S and D .
• When a timer/counter is specified to S and D by indirect specification.

7-228 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When this function is used in combination with other functions

ARITHMETIC OPERATION FUNCTIONS


Programmed Script
DISS ( SMID ( DM1000.T, EM1000, EM1001 ), DM2000 )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SMID function", page 7-192
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-229


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
UNIS

UNIS Unite text string

Unite text string

UNIS ([execution condition,]*1 unite destination, storage destination, number of


ARITHMETIC OPERATION FUNCTIONS

unite characters)

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Unite
S text string (in words) to be united, or the .U .U .U .U - - - - - ○ ○
destination*2*5
unite destination text string (in words).
Storage Specifies the destination to store the
D
destination*2 *6 united text string. - - - - - - - .T - ○ -
Number of Specifies the number of characters
*3
n unite (number of bytes or number of words) .U .U .U .U - - - - ○ ○

characters*4 to unite. (1 to 1999)
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed

7 *2
at all times (at every scan).)
For bit data, specify the start of the channel.
*3 $ cannot be used.
Text Processing Functions

*4 Specify the number of unite characters within the range 1 to 1999.


*5 T, C, CTC, CTH, Z cannot be used.
*6 T, C, CR, CTC, CTH, Z cannot be used.

Description of Operation
When the execution condition is established (TRUE), the text string in words currently stored starting
from S is united into byte unit by the number of characters (number of words) specified by n ,
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 divisib

Omit high bit

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-230 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
UNIS ( R3000, DM1000, DM2000.T, 16 )
R3000

ARITHMETIC OPERATION FUNCTIONS


UNIS
DM1000 DM2000 #16
Execution condition
Merge destination Store destination

Point The function is not executed when any of the following conditions is established:
• When the value of n is 0 or 2000 or more.
• When the text string including the end code (NUL (00H)) exceeds 2000 characters
• When a bit other than the start of the channel is specified when bit data is
specified for S and D .
• When a timer/counter is specified to S and D by indirect
specification.

Sample Program
● To specify the bit data
7

Text Processing Functions


Programmed Script
UNIS ( MR3000.U < 10, MR1000.U, MR2000.T, 10 )
Operation Description 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.

● When this function is used in combination with other functions

Programmed Script
UNIS ( DM1000, DM2000.T, ANDA ( EM1000, $FF ) )
Operation Description 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).

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function", page 7-22
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-231


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CHR

CHR Convert HEX ASCII code to characters

Convert characters

Return value*1 = CHR (conversion destination)


ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination to store the
Conversion *2
S ASCII code to be converted or the .U .U .U .U - - - - ○ ○
destination ○
ASCII code data. (16-bit data)
R Return value*3 .T type CHR function available - - - - - - - .T - ○ -
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 The value of the constant is within the range 0 to 255. When a destination is specified and the
value of the destination is outside 0 to 255, the value obtained by discarding the high-order eight
bits is used.
*3 T, C, CR, CTC, CTH, Z cannot be used.

7 Description of Operation
The ASCII code data stored in S is converted to a 1-byte text string appended with the end code
Text Processing Functions

NUL (00H), and the result is stored in R .

● Example of format
DM1000.T = CHR ($0A)
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
CR2002 SMOV
*@VM2 DM1000
Always ON
Return value

Sample Program

Programmed Script
DM2000.T = DM2000.T + CHR ( $0D ) + CHR ( $0A )
Operation Description The CR code (0DH) and LF code (0AH) are appended at the end of the text string
DM2000.T.

Reference • Specify ASCII code (half-width) to the conversion destination data.


"ASCII Code Table", page A-53
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Create a box script Step 5"(page 2-10).

7-232 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

ARITHMETIC OPERATION FUNCTIONS


7

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-233


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CPSASC

CPSASC CIP text string conversion

Return value*1 = CPSASC (target data storage destination)


Supported Type Const Device/ For
ARITHMETIC OPERATION FUNCTIONS

Argument/Return
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Conversion
Specifies the start of the destination
target data
that stores the CIP text string data .U .S .D .L .F .DF .B .T - ○ -
storage
before conversion.
destination*2
R Return value .T type CPSASC function available - - - - - - - .T - - -
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.
*2 When specifying bit data, specify the start of the channel.

Point • The CPSASC function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
7 "KV-5500/5000/3000 CPU Function Version", page 4
Text Processing Functions

Description of Operation
The CIP text string type data stored starting from S is converted into a text string, and the result is
stored in R .
The CPSASC function is used to convert the CIP text string type data, and process it as a text string.
Refer to "KV EtherNet/IP Function User's Manual" for details on the CIP data types.
Refer to "EtherNet/IP Function User's Manual" for details on the CIP data types.

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,
and the high-order byte and
The CIP text string type data specifies low-order byte of the text string
the data size with the leading word, equivalent to the data size are
and stores the text string in the order interchanged and stored.
of low-order byte to high-order byte.

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-234 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.T = CPSASC ( DM1000 )

ARITHMETIC OPERATION FUNCTIONS


CR2002 ADRSET
VM2 VM0
Always ON

MOV
#0 VM2

MOV.D
VM0 @VM0

CR2002 CPSASC
DM1000 *@VM0
Always ON

SMOV
7
CR2002

Text Processing Functions


*@VM0 DM2000
Always ON

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-235


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RCPSASC

RCPSASC CIP text string type data reverse conversion

Return value*1 = RCPSASC (target data storage destination, converted data


storage destination)
ARITHMETIC OPERATION FUNCTIONS

Argument/Return Supported Type Const Device/ For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion target Specifies the start of the destination *3
S data storage that stores the text string before - - - - - - - .T ○ -

destination conversion.
Converted data Specifies the start of the destination
D storage that stores the converted CIP text string .U .S .D .L .F .DF .B .T - ○
destination type data.
The number of characters (in bytes)
stored in D is stored. The
R Return value*2 .U .S .D .L .F .DF - - - - -
RCPSASC function uses the .U
function.
*1 The return value can be omitted. When omitted, the conversion result is stored in a work device/memory.

7 *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 " ".
Text Processing Functions

Point • The RCPSASC function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, KV-5500/
5000/3000 Series CPU units with CPU function version 2.0 or higher and KV Nano
Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The text string stored in S is converted into CIP text string type data, and the result is stored in
D . After conversion, the number of characters (in byte) stored in D is stored in R .
The RCPSASC function is used to convert the CIP text string type data, and process it as a text string.
Refer to "KV EtherNet/IP Function User's Manual" for details on the CIP data types.
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
D +0, and the high-order bytes and 7(0007H) R
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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Text Processing Instructions".

7-236 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM3000 = RCPSASC ( DM1000.T, DM2000 )

ARITHMETIC OPERATION FUNCTIONS


CR2002 MOV
#0 @VM0
常時ON

RCPSASC
DM1000 DM2000 @VM0

CR2002 MOV
@VM0 DM3000
常時ON

Text Processing Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 7-237


MEMO
ARITHMETIC OPERATION FUNCTIONS

7
Text Processing Functions

7-238 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


8
EXTENDED FUNCTIONS

EXTENDED FUNCTIONS
Data processing function....................................................... 8-2
Table processing function.................................................... 8-48
Clock processing function ................................................... 8-70
High-speed processing function .......................................... 8-78
PID Functions...................................................................... 8-84
Log Functions...................................................................... 8-86
Storage Functions ............................................................... 8-90
Access Window Functions ................................................ 8-118
FREE RUN Counter Functions.......................................... 8-124
Sensor Setting Function .................................................... 8-126
Cyclic Communication Refresh Function .......................... 8-132

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-1


Da

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


SEG

SEG Decode 4-bit data to 7-segment

7-segment

Return value *1 = SEG (decode destination device, destination digit position)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Decode Specifies the device to which the
S destination decode destination data is stored or the .U .U .D .D - - - - - ○ ○
device*2 decode destination data.
Specifies the device to which the digit
position to decode is stored, or the
Destination
decode digit position. (0 to 3 for a .U .U .U .U .U - - - -
EXTENDED FUNCTIONS


digit position*3 - ○ ○
suffix instruction, and 0 to 7 for a .D
suffix instruction)
*5
Return value .U type SEG function available* 4 .U .S .D .L .F
R .DF - - - ○ -

*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*2 S When the decoding target is specified as bit data, consecutive 16/32 bits are processed.
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.

8 *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
Data processing function

device are used.


When the decode destination device suffix is .D: The values of the lower three bits of the specified
device are used.
For example, when the suffix of the S decode destination device is .U, DM01000 is specified
to n , and that value is 23 (2BIN: 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.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
S The four bits (one digit) of digits of the 16-bit/32-bit data stored in n are decoded to data (8
bits) for 7-segment display, and the result is stored in R .
"About operation flag (CR2009 to CR2012)", page 1-18

8-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
• 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

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
2

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

• : When decode destination device is 32 bits (.D/.L)


8
S

DM2100.U = SEG ( DM1100.D, 3 )

Data processing function


in case of 12345678
#7 #6 #5 #4 #3 #2 #1 #0

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

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-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Data table for 7-segment display

Value of 16-bit internal register Bit0


Specified Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
$0 0 0 1 1 1 1 1 1
Bit5

Bit1

$1 0 0 0 0 0 1 1 0
$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
Bit6
$5 0 1 1 0 1 1 0 1
$6 0 1 1 1 1 1 0 1
Bit4

Bit2

$7 0 0 1 0 0 1 1 1
$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 Bit3
$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-8000/7000/5000/3000/1000 Series and KV Nano 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 )
Operation Description 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)).

Reference • Note that this function sometimes cannot be used depending on the argument of the
EXTENDED FUNCTIONS

function it is combined with.


"TBCD function", page 7-80
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

8
Data processing function

8-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-5


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BCNT

BCNT ON bit count of specified device

Bit count

Return value*1 = BCNT (operation destination)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation destination
S .U .U .D .D - - - - - ○ ○
destination device or the operation destination data.
*3
R Return value .U type SEG function available* 2 .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 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.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version

8 2.0 or higher and with KV Nano Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4
Data processing function

Description of Operation
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.

• 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

• 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

8-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DM2000.U = BCNT ( DM1000.U )
CR2002 DM1000 DM2000
LDA BCNT STA
Always ON operation destination Return value

Sample Program
● To count a bit device

EXTENDED FUNCTIONS
Programmed Script
DM2000.U = BCNT ( MR1000.D )
Operation Description 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 Return value

● When this function is used in combination with other functions


8
Programmed Script
DM2000.U = BCNT ( ORA ( DM1000.D, DM1100.D ) )

Data processing function


Operation Description The data stored in DM1000.D is ORed by the data stored in DM1100.D, and the number
of ON bits of the operation result is counted and stored in DM2000.U.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ORA function", page 7-24
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-7


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DCNT

DCNT Count detected data in specified block

Data count

Return value *1 = DCNT (detection destination, detection range leading device,


number of detected data)

Recognized Type Const Device / For


Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Detection Specifies the device to which the value to
.U .U .D .D .D - - - ○ ○ ○
S1 destination*2 detect is stored, or the detection value.
Detection range
Specifies the leading device of the data Handled as same
leading - - - - ○ -
S2 block to detect. type as S1 .
EXTENDED FUNCTIONS

device*2
Specifies the device currently storing
Number of
n the number of data of the block to .U .U .U .U - - - - ○ ○ ○
detected data
detect, or the number of detected data.
*4
Return value .U type DCNT function available* 3 .U .S .D .L .F
R .DF - - - ○ -

*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
8 *3
in16/32 bits straddling the next channel.
When the type other than .U is specified by return value, type conversion will be automatically
Data processing function

conducted during conversion.


*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
S2 block data starting from n are each compared with the data in S1 , and the number of
matching data is stored in R .

• 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


device whose value equals that of
S2 +1 2345 Compare
detection destination (16-bit).
Save the result to return value
S2 +2 3456 Compare
(16-bit).
n

( 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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).


n


Save the result to return value
(2 n Word) S2 +2( n -3)+1 12345678 S2+2( n -3) Compare
(16-bit).
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

"About operation flag (CR2009 to CR2012)", page 1-18

EXTENDED FUNCTIONS
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
DM2000.U = DCNT ( DM1000.U, DM1200.U, 4 )
CR2002 DM1000 DM1200 DM2000
LDA DCNT STA
Always ON Detection destination #4 Return value
Detection range 8
leading

Data processing function


Point n When the value of is "0", the value of the S1 is stored in R .

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.U = DCNT ( COM ( DM1000.D ), MR1000.D, EM2000 )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"COM function", page 7-30
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-9


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SER

SER Detect data in specified block

Search

Return value *1 = SER (detection destination, detection range leading device,


number of detected data)

Argument/Return Recognized Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the device to which the value
Detection
to detect is stored, or the detection .U .U .D .D .D - - - ○ ○ ○
S1 destination*2
value.
Detection range
Specifies the leading device of the data Handled as same
EXTENDED FUNCTIONS

leading - - - - ○ -
S2
*2 block to detect. type as S1 .
device
Specifies the device currently storing
Number of
n the number of data of the block to .U .U .U .U - - - - ○ ○ ○
detected data
detect, or the number of detected data.
*4
Return value .UU type SER function available.* 3 .U .S .D .L .F
R .DF - - - ○ -

*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

8 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 other than .U is specified by return value, type conversion will be automatically
Data processing function

conducted during conversion.


*4 The ".DF" suffix cannot be specified for device Z.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
block data starting from S2 are each compared with the data in n , S1 and the number of
matching data is stored in R .
When multiple matching data are detected, the smallest device No. is stored.

• 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
detection destination (16-bit).
S2 +1 2345 Compare

Save the result to return value


S2 +2 3456 Compare
(16-bit).

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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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

S2 +3 23456789 S2 +2 Compare
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


(32-bit).
(2 n Word) 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

S2 +2

EXTENDED FUNCTIONS
Result

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
DM2000.U = SER ( DM1000.U, DM1200.U, 40 )
CR2002

Always ON
DM1000
LDA
DM1200
SER
#40
DM2000
STA 8
Detection Return value
destination

Data processing function


Detection range
leading

Point • When no matching devices are found, or value of n is "0", the value of
S1 is stored in R .
• 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 )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"NEG function", page 7-32
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-11


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DSER

DSER Detect MAX value in a specified block

Data retrieval

Return value *1 = DSER (Detection data, detection range leading device, number of
detection device, number of detection store device)

Argument/Return Recognized Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Detection Specify detection data or the device
.U .U .D .D .D - - - ○ ○ ○
S1 destination*2 storing detection data.
Detection range
Specifies the start of the range to be Handled as same
leading - - - - ○ -
S2 searched. type as S1 .
EXTENDED FUNCTIONS

device*2
Number of Specifies the number of targets to be
n detection store searched or the storage location for the .U .U .U .U - - - - ○ ○ ○
device*2 number.
Number of
Specifies the target to store the
D detection store .U .U .U .U - - - - - ○ -
detection result (number of detections).
device*2
Specifies the target to store the
detection position (offset from the start *4
Return value .U .S .D .L .F
.DF - - - ○ -
8
R of the detection range). .U type DSER
function available.* 3
*1 The return value can be omitted. When omitted, the operation result is stored in working memory.
Data processing function

*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 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.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
To search S1 devices starting from S2 by using n 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S1 : When detection data is16 bits (.U)

Compare
Position at first

Compare

Compare
bits



Word
+ − Compare Number of consistent

+ − Compare

− Result
+ Compare

bits

EXTENDED FUNCTIONS
Count the number of device whose value
identical to the value of detection destination
device (16 bit). Detection result (position)
is stored into return value (16 bit).

• S1 : When operation destination device is 32 bits

Position
at first

8
Compare

Compare

Compare

Data processing function


bits


× Word Number of
+ − + − Compare consistent

+ − + − Compare

− Result
+ + − Compare
bits

Count the number of device whose value


identical to the value of detection destination
device (32 bit). Detection result (position) is
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 Number of
range leading search

MOV
@VM1 DM2002
Detect number of
store

@VM0 DM2000
LDA STA
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-13


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MAX

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 Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Detection *6
Specifies the start of the range to be
destination .U .S .D .L .F
searched. .DF - - - ○ -
device*2*3*4
n Number of Specifies the device currently storing the
search range number of data in the range to search, or .U .U .U .U - - - - ○ ○ ○
data*2 the number of search range data.
EXTENDED FUNCTIONS

MAX function type is identical to the 1st *6


Return value .U .S .D .L .F .DF - - - ○ -
R argument.* 5
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*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/64 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/64 bits straddling the next channel.
*4 When S type is .F or .DF, T and C cannot be specified.
8 *5 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
Data processing function

*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument devices ".F" and ".DF" can be used in KV STUDIO Ver. 9.0 or later only.
• The argument devices ".F" and ".DF" can be specified with the KV-8000 series
CPU units and KV-7000 Series CPU units that have CPU function version 2.0 or
later only.
• The return value device ".DF" can be used in KV STUDIO Ver. 6.00 or later only.
• The return value device ".DF" can only be specified with KV-8000/7000 Series
CPU units, KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or later, and with KV Nano Series base units.
"KV-7500/7300 CPU Function Version", page 3
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The maximum value is searched in the (16-bit/32-bit/64-bit) BIN data stored in S words starting
from n . (When the search destination is 32-bit data, the search range becomes the "specified
number of data x 2 words" and when 64-bit data it becomes the "specified number of data x 4 words".)
The maximum value as a result of the search is stored in R .

• S : When the 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

8-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the 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

• S : When the search destination device is unsigned 32-bit data (.D)

EXTENDED FUNCTIONS
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
S +2 ( n −1 )+1 76543210

: When the search destination device is signed 32-bit data (.L)


S +2 ( n −1)
8

Data processing function


bit bit bit bit
31 16 15 0

S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4 Save Max. value


R

n bit
31
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)

• S : When the search destination device is a single precision floating point type (.F)
bit bit bit bit
31 16 15 0

S +1 1.234 S
S +3 2.345 S +2
3.456 Save Max. value
S +5 S +4
n bit
R Return value
bit
31 0

( 2 n Word) S +2 ( n −3)+1 −1.234 S +2 ( n −3) 3.456

S +2 ( n −2)+1 −2.345 S +2 ( n −2)


S +2 ( n −1)+1 −3.456 S +2 ( n −1)
• S : When the search destination device is a double precision floating point type (.DF)
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

S +3 1.2345678 S
S +7 2.3456789 S +4
S +11 3.4567890 S +8 Save Max. value

n bit
63
R Return value bit
0

(4 n Word) S +4 ( n −3)+1 −1.234567 S +4 ( n −3) 3.4567890

S +4 ( n −2)+1 −2.345789 S +4 ( n −2)


S +4 ( n −1)+1 −3.456890 S +4 ( n −1)

"About operation flag (CR2009 to CR2012)", page 1-18

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-15


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
DM2000.U = MAX ( DM1000.U, 32 )
CR2002 #0 DM1000 DM2000
LDA.D MAX STA
Always ON #32 Return value
Search destination device

Point n When the value of R is 0, 0 is stored in :


EXTENDED FUNCTIONS

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000 = TBCD ( MAX ( DM1000.U, EM1100.U ) )
Operation Description The maximum value is searched in the data stored in the range of EM1100 words starting

8 from DM1000. The maximum value in the search result is converted to 4-digit BCD data,
and stored in DM2000.
Data processing function

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"TBCD function", page 7-80
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, step 5, (page 2-10)

8-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-17


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MIN

MIN Detect minimum value in a specified block

Minimum search

Return value *1 = MIN (search destination device, number of search range data)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Detection *6
Specifies the start of the range to be
destination .U .U .D .D .F
S searched. .DF - - - ○ -
device*2*3*4
n Number of Specifies the device currently storing the
search range number of data in the range to search, or .U .U .U .U - - - - ○ ○ ○
data*2 the number of search range data.
EXTENDED FUNCTIONS

MIN function type is identical to the 1st *6


Return value .U .S .D .L .F .DF - - - ○ -
R argument* 5
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*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/64 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/64 bits straddling the next channel.
*4 When S type is .F or .DF, T and C cannot be specified.
8 *5 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
Data processing function

*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument devices ".F" and ".DF" can be used in KV STUDIO Ver. 9.0 or later only.
• The argument devices ".F" and ".DF" can be specified with the KV-8000 series CPU
units and KV-7000 Series CPU units that have CPU function version 2.0 or later only.
• The return value device ".DF" can be used in KV STUDIO Ver. 6.00 or later only.
• The return value device ".DF" can only be specified with KV-7000 Series CPU
units, KV-5500/5000/3000 Series CPU units that have CPU function version 2.0 or
later, and with KV Nano Series base units.
"KV-7500/7300 CPU Function Version", page 3
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The minimum value is searched in the (16-bit/32-bit/64-bit) BIN data stored in S words starting
from n . (When the search destination is 32-bit data, the search range becomes the "specified
number of data x 2 words" and when 64-bit data it becomes the "specified number of data x 4 words".)
The minimum value as a result of the search is stored in R .

• S : When the search destination device is unsigned 16-bit data (.U)

Save Min. value


Return value

Word + −

+ −

+ −

8-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the 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

• S : When the search destination device is unsigned 32-bit data (.D)


bit bit bit bit

EXTENDED FUNCTIONS
31 16 15 0

S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4 Save Min. value


R Return value

n bit
31
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)

• S : When the search destination device is signed 32-bit data (.L) 8


bit bit bit bit
31 16 15 0

Data processing function


S +1 12345678 S
S +3 23456789 S +2

S +5 34567890 S +4 Save Min. value


R

n bit
31
Return value bit
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)

• S : When the search destination device is a single precision floating point type (.F)
bit bit bit bit
31 16 15 0

S +1 1.234 S
S +3 2.345 S +2
3.456 Save Min. value
S +5 S +4
n bit
R Return value
bit
31 0

( 2 n Word) S +2 ( n −3)+1 −1.234 S +2 ( n −3) −3.456

S +2 ( n −2)+1 −2.345 S +2 ( n −2)


S +2 ( n −1)+1 −3.456 S +2 ( n −1)

• S : When the search destination device is a double precision floating point type (.DF)
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

S +3 1.2345678 S
S +7 2.3456789 S +4
S +11 3.4567890 S +8 Save Min. value
R

n bit
63
Return value bit
0

(4 n Word) S +4 ( n −3)+1 −1.234567 S +4 ( n −3) −3.456890

S +4 ( n −2)+1 −2.345789 S +4 ( n −2)


S +4 ( n −1)+1 −3.456890 S +4 ( n −1)

"About operation flag (CR2009 to CR2012)", page 1-18


- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-19
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
DM2000.U = MIN ( DM1000.U, 32 )
CR2002 #0 DM1000 DM2000
LDA.D MIN STA
Always ON #32 Return value
Search destination

Point n When the value of R is 0, 0 is stored in :


EXTENDED FUNCTIONS

Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.S = NEG ( MIN ( DM1000.S, EM1100 ) )
Operation Description The minimum value is searched in the data stored in the range of EM1100 words starting

8 from DM1000. The sign of the MIN value in the search result is inverted, and stored in
DM2000.S.
Data processing function

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"NEG function", page 7-32
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

8-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-21


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
AVG

AVG Average value of specified block

Average

Return value *1 = AVG (operation destination device, number of operation range data)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation *6
Specifies the start of the range to be
destination .U .U .D .D .F
S averaged. .DF - - - ○ -
device*2*3*4
n Number of Specifies the number of data in the
operation range range to average or the device to which .U .U .U .U - - - - ○ ○ ○
data*2 that number is currently stored.
EXTENDED FUNCTIONS

AVG function type is identical to the 1st *6


Return value .U .S .D .L .F .DF - - - ○ -
R argument.*5
*1 The return value can be omitted. When omitted, the operation result is stored in internal registers.
*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/64 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/64 bits straddling the next channel.
*4 When S type is .F or .DF, T and C cannot be specified.
8 *5 When the type different from the 1st argument is specified by return value, type conversion will be
automatically conducted during conversion.
Data processing function

*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument devices ".F" and ".DF" can be used in KV STUDIO Ver. 9.0 or later only.
• The argument devices ".F" and ".DF" can be specified with the KV-8000 series CPU
units and KV-7000 Series CPU units that have CPU function version 2.0 or later only.
• The return value device ".DF" can be used in KV STUDIO Ver. 6.00 or later only.
• The return value device ".DF" can only be specified with KV-8000/7000 Series
CPU units, KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or later, and with KV Nano Series base units.
"KV-7500/7300 CPU Function Version", page 3
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The average value of all BIN data (16-bit/32-bit (unsigned/signed)/64-bit) stored in S words is
calculated starting from n . (When the operation destination is 32-bit data, the operation range
becomes the "specified number of data x 2 words" and when 64-bit data it becomes the "specified
number of data x 4 words".)
The average value as a result of the search is stored in R .

• S : When the operation destination device is unsigned 16-bit data (.U)


bit bit
15 0

S 16

S +1 256

S +2 4096
n

( n Word) 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-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the operation destination device is signed 16-bit data (.S)
bit bit
15 0

S -32700

S +1 -16350

S +2 -8175
n


( n Word) S + n −3 8175 Average is stored in R (return value).
R Return value
S + n −2 16350 bit15 bit0

32700 Average value


S + n −1 Average

• S : When the operation destination device is unsigned 32-bit data (.D)

EXTENDED FUNCTIONS
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 Word) 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

• S : When the operation destination device is signed 32-bit data (.L)


8

Data processing function


bit bit bit bit
31 16 15 0

S +1 -90123456 S
S +3 -89012345 S +2
S +5 -78901234 S +4
n

( 2 n Word) 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

• S : When the search destination device is a single precision floating point type (.F)
bit bit bit bit
31 16 15 0

S +1 1.234 S
S +3 2.345 S +2
S +5 3.456 S +4


n
( 2 n Word) S +2 ( n -3)+1 −1.234 S +2 ( n -3) Average is stored in R (return value).
R +1 R
S +2 ( n -2)+1 −2.345 S +2 ( n -2) bit
31
bit
0

S +2 ( n -1)+1 −3.456 S +2 ( n -1) Average Average value

• S : When the search destination device is a double precision floating point type (.DF)
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

S +3 1.2345678 S
S +7 2.3456789 S +4
S +11 3.4567890 S +8
n

( 4 n Word) S +4 ( n -3)+1 −1.234567 S +4 ( n -3) Average is stored in R (return value).

S +4 ( n -2)+1 −2.345789 S +4 ( n -2) bit


63
R +3 R +2 R +1 R bit
0

S +4 ( n -1)+1 −3.456890 S +4 ( n -1) Average Average value

"About operation flag (CR2009 to CR2012)", page 1-18


- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-23
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
DM2000.U = AVG ( DM1000.U, 32 )
CR2002 #0 DM1000 DM2000
LDA.D AVG STA
Always ON #32 Return value
operation destination

Point n When the value of R is 0, 0 is stored in :


EXTENDED FUNCTIONS

8
Data processing function

8-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-25


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
WSUM

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation *6
Specifies the start of the range to be
destination .U .U .D .D .F
S summed. .DF - - - ○ -
device*2*3*4
n Number of Specifies the device currently storing
EXTENDED FUNCTIONS

operation range the number of data in the range to total, .U .U .U .U - - - - ○ ○ ○


data*2 or the total range data.
*6
R Return value .L type WSUM function available.*5 .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 range of numerical values that can be handled differs according to the instruction suffix.
*3 When a bit device has been specified, 16/32/64 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/64 bits straddling the next channel.
8 *4
*5
When S type is .F or .DF, T and C cannot be specified.
When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.
Data processing function

*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument devices ".F" and ".DF" can be used in KV STUDIO Ver. 9.0 or later only.
• The argument devices ".F" and ".DF" can be specified with the KV-8000 series CPU
units and KV-7000 Series CPU units that have CPU function version 2.0 or later only.
• The return value device ".DF" can be used in KV STUDIO Ver. 6.00 or later only.
• The return value device ".DF" can only be specified with KV-8000/7000 Series
CPU units, KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or later, and with KV Nano Series base units.
"KV-7500/7300 CPU Function Version", page 3
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
S The total value of all BIN data (16-bit/32-bit (unsigned)/64-bit) stored in the range of words
specified by is calculated with the device specified by n as the leading device. (When the operation
destination is 32-bit data, the operation range becomes the "specified number of data x 2 words" and
when 64-bit data it becomes the "specified number of data x 4 words") The operation results and total
value are stored in R .
• S : When operation destination is 16 bits (.U/.S)
bit bit
15 0

S 16

S +1 256

S +2 4096
Higher 16 bits are stored to higher 16
n

bits of returned value R and TM000.


( n word) S + n −3 16383

S + n −2 32767

S + n −1 65535 Total R Return value


32 bit

8-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When operation destination 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 word) 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

EXTENDED FUNCTIONS
• S : When the search destination device is a single precision floating point type (.F)
bit bit bit bit
31 16 15 0

S +1 1.234 S
S +3 2.345 S +2
S +5 3.456 S +4



n 個
( 2 n ワード) S +2( n -3)+1 −1.234 S +2( n -3)
S +2( n -2)+1 −2.345 S +2( n -2) 8
S +2( n -1)+1 −3.456 S +2( n -1) 合計 R 戻り値

Data processing function


32ビット

• S : When the search destination device is a double precision floating point type (.DF)
bit bit bit bit bit bit bit bit
63 48 47 32 31 16 15 0

S +3 1.2345678 S
S +7 2.3456789 S +4
S +11 3.4567890 S +8


n
(4 n word) S +4( n -3)+1 −1.234567 S +4( n -3)
S +4( n -2)+1 −2.345789 S +4( n -2)
S +4( n -1)+1 −3.456890 S +4( n -1) Total R Return value
64 bits

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

● 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

Reference 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 TM001 and TM000.

Point n When the value of R is 0, 0 is stored in :

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-27


Sample Program
● When this function is used in combination with other functions

Programmed Script
DM2000.F = FLOAT ( WSUM ( DM1000.U, EM1100.U ) )
Operation Description Calculate the total of all data in consecutive EM1100.U devices with DM1000.U as the
head device, and convert the operation result into a single-precision floating-point real
number, and store it in DM2000.F.

Reference • Note that this function sometimes cannot be used depending on the argument of the
EXTENDED FUNCTIONS

function it is combined with.


"FLOAT function", page 7-114
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, step 5, (page 2-10)

Hint

8 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.
Data processing function

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.
High bit Low bit

EM2003 EM2002 EM2001 EM2000


64 bits

Reference 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-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-29


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BSUM

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation
Specifies the start of the range to be
S destination .U .U .U .U - - - .U - ○ -
summed.
device*2*3*4
n Number of
Specifies the number of data (in byte
EXTENDED FUNCTIONS

operation range .U .U .U .U - - - - ○ ○ ○
*2 units) to calculate the total value.
data
*6
R Return value .D type BSUM function available.* 5 .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 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.
8 *4
*5
T, C, CTC, CTH, Z cannot be used.
When the type other than .D is specified by return value, type conversion will be automatically
conducted during conversion.
Data processing function

*6 The ".DF" suffix cannot be specified for device Z.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

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

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."
8-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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 target
Operation
destination

Reference 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.

EXTENDED FUNCTIONS
Point When either of the following conditions is established, 0 is stored in R :
• When a timer/counter is specified to S

• S When a device other than the leading device of the channel is specified
when a bit device is specified to
• When the value of n is "0"

Sample Program
● When this function is used in combination with other functions 8

Data processing function


Programmed Script
DM2000.D = BSUM ( DM1000.T, LEN ( DM0000.T ) )
Operation Description The ASCII text string currently stored in DM1000.T is totaled in byte units, and the result is
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
Always ON @VM0 Storage target
Operation destination

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"LEN function", page 7-182
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-31


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
CRC

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Default*5 .U .U .U .U - - - - ○ ○ ○
S2 Operation
.U .U .U .U - - - - ○ ○ ○
method*5 Specifies the operation mode.*2
*5
S3 Operation order .U .U .U .U - - - - ○ ○ ○
Invert bit order*5 .U .U .U .U - - - -
EXTENDED FUNCTIONS

S4 ○ ○ ○
S5 Data block Specifies the leading device of the data
.U .U .U .U - - - - - ○ -
leading device*3*5 block to calculate.
*4
n Number of data Specifies the number of data (1- 65535). .U .U .U .U - - - - ○ ○ ○
*7
Return value .U type CRC function available*6 .U .S .D .L .F
R .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.

8 *4 S3 When is "0", specify the number in 1-word (16-bit) units.


S3 When is "1 (other than "0")", specify the number of 1-byte (8-bit) units.
*5 T, C, CTC, CTH, Z cannot be used.
Data processing function

*6 When the type other than .U is specified by return value, type conversion will be automatically
conducted during conversion.
*7 The ".DF" suffix cannot be specified for device Z.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The CRC value of S1 S4 data starting from S5 is calculated in the operation mode specified
by to n operation data bit order inversion, and is stored in R .
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.
S2 CRC Operation Method CRC-ITU-T(CRC-CCITT) CRC-16(CRC-ANSI)
Operation is performed in order upper 8 bits
Operation is performed only on
-> lower 8 bits.
the lower 8 bits.
Even n : Odd number (The upper 8 bits are ignored.)

S3 Order of
operation

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.

8-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


S4 The following example illustrates the bit order inversion of operation data (in bytes).

Operation Data
CRC-ITU-T ( S2 =1) CRC-16 ( S2 =0)
Bit Order Inversion
Not inverted
S4 :
「0」 Operating order Operating order

Inverted
S4 :"1" (other than 0) Operating order Operating order

● Example of format

EXTENDED FUNCTIONS
EM2000.U = CRC ( 1, 0, 0, 0, DM1000.U, 256 )
CR2002 #1
LDA
Always ON
#0 @VB00
<>
#0
#0 @VB01
<>

8
#0
CR2002 @VB02

Data processing function


Always ON
#0 @VB03
<>
#0
CR2002 CRC
@VB00 DM1000 #256
Always ON
CR2002 EM2000
STA
Always ON Return value

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions", CRC Instruction.

Point When either of the following conditions is established, the value of R is stored
in S1 :
• When a word device or timer/counter has been specified to S1
• 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
• When the value of n is "0"

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-33


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
ZRES

ZRES Reset specified block

Zone reset

ZRES ([execution condition,]*1 leading device, final device)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the start of the range to be *2
Leading device .U .U .U .U .U .U .B .T - ○ -
D1 reset (0 is stored).
Specifies the final device of the range Handled as same type as
Final device - ○ -
D2 to reset. D1 .

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 The ".DF" suffix cannot be specified for device Z.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version

8 2.0 or higher and with KV Nano Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4
Data processing function

Description of Operation
When the execution condition is established (TRUE), all of the values of D1 and D2 are reset.

• To specify the word device

Reset

Reset

Reset

: :

− Reset

− Reset

Reset

* 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.

8-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• To specify the bit device

: 、 :

Reset

EXTENDED FUNCTIONS
Reference When a word device has been specified, the word becomes "0" in word units, and when

8
a bit device has been specified, the bit becomes OFF in bit units.

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series

Data processing function


Instruction Reference Manual, "Data Processing Instructions."

● Example of format
ZRES ( R3000, DM1000.U, DM1099.U )
R3000 DM1000
ZRES
Execution condition DM1099
Reset device

Point When the type of specified devices differ at D2 and S3


D1 , the ZRES function is
not executed.

Sample Program
● To specify the bit device

Programmed Script
ZRES ( R3000, MR1008, MR1207 )
Operation Description When R3000 turns ON, all of the 32 bits from M1008 to MR1207 are reset (are turned OFF).

● When an index register is used

Programmed Script
ZRES ( DM2000:Z01, DM2000:Z02 )
Operation Description All of the words in the range DM2000:Z01 to DM2000: Z02 are reset (cleared to "0") at
every scan (no execution condition).

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-35


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BCMP

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Compare Specifies the leading device of the
.U .U .D .D .D - - - - ○ -
S1 source device*2 compare source data block.
Compare
Specifies the leading device of the Handled as same
destination - - - - ○ -
S2 compare destination data block. type as S1 .
EXTENDED FUNCTIONS

device*2
S3 Result store Specifies the start to store the
device*2*3 comparison result. - - - - - - .B - - ○ -
Specifies the device currently storing the
Number of
n number of data of the block to compare, .U .U .U .U - - - - ○ ○ ○
compare data
or the number of compare data.
ON when all data matched. Otherwise,
R Return value - - - - - - .B - - ○ -
OFF
*1 The return value can be omitted. When omitted, the operation result is stored in a work device.
8 *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
Data processing function

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.
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.

Description of Operation
When the execution condition is established (TRUE), S1 block data starting from n and S2

block data starting from n 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.
D When the 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.) (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.

• 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 Word)
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-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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 Word)
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

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

EXTENDED FUNCTIONS
● Example of format
R3000 = BCMP ( DM1000.U, DM1200.U, MR2000, 40 )

CR2002 BCMP
DM1000 DM1200 MR2000
Always ON
Comparison element First Result storage target

CR2010
#40
8
R3000

Data processing function


the operation result is zero

Point 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 ) )
Operation Description 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"ANDA function", page 7-22
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-37


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
BCMPI

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Compare Specifies the leading device of the data
.U .U .D .D .D - - - - ○ ○
S1 source device*2 block to compare.
Compare value Specifies the target to store the value to Handled as same
S2 device be compared or the comparison. type as S1 . - - - - ○ -
EXTENDED FUNCTIONS

Result store Specifies the start to store the


D device*3 comparison result. - - - - - - .B - - ○ -
Specifies the device currently storing the
Number of
n number of data of the block to compare, .U .U .U .U - - - - ○ ○ ○
compare data
or the number of compare data.
ON when all data matched. Otherwise,
R Return value - - - - - - .B - - ○ -
OFF
*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, 16/32 continuous bits are handled. When a relay other
8 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.
Data processing function

*3 When a bit device has been specified, the program will function normally even if the bit device
straddles channels.
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.

Description of Operation
When the execution condition is established (TRUE), S1 block data starting from n and the
data in S2 are each compared.
When the compare result matches, ON is in D bit devices starting from n . 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.) (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.

• 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

8-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series

EXTENDED FUNCTIONS
Instruction Reference Manual, "Data Processing Instructions."

● Example of format
R3000 = BCMPI ( DM1000.U, DM1200, MR2000, 40 )

CR2002 BCMPI
DM1000 DM1200 MR2000
Always ON

8
Compare source device Compare source device Result store device

#40

CR2010 R3000

Data processing function


the operation result is zero

Point 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 = BCMPI ( DM1000.D, RRNCA( MR1000.D, 16 ), MR3000, 24 )
Operation Description 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 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RRNCA function", page 7-50
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-39


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RND

RND Generate random number

Random

Return value *1 = RND (type of random number)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the operation destination
Type of random
S *2 device of generated random number or .U .U .U .U - - - - - ○ ○
number
the operation destination data.
*4
Return value .U type RND function available.* 3 .U .S .D .L .F
R .DF - - - ○ -
EXTENDED FUNCTIONS

*1 The return value can be omitted. When omitted, the operation result is stored 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.
*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.

Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
8 • The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
Data processing function

2.0 or higher and with KV Nano Series base units.


"KV-5500/5000/3000 CPU Function Version", page 4

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. S When = 0, R stores 1
in return value.
"About operation flag (CR2009 to CR2012)", page 1-18
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

Point • Random number generation algorithm shall use "M series".


• 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.

● 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
Return value

8-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-41


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SORT

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the sorting order. (0:
Sorting order .U .U .U .U - - - - ○ ○ ○
S ascending, 1: descending)
D Data table Specifies the leading device of the byte
.U .S .D .L - - - - - ○ -
leading device*2 sequence to search for.
EXTENDED FUNCTIONS

n Number of data Specifies the number of data items to


.U .U .U .U - - - - ○ ○ ○
items to sort*3 sort.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. If the execution condition is omitted, the instruction is always executed (it is
executed every scan).
*2 When a bit device is specified, D channel is occupied if the n type is .U/.S, and 2x
n channels are occupied if the type is .D/.L.
When a word device is specified, D word is occupied if the n type is .U/.S, and 2x n

8 *3
words are occupied if the type is .D/.L.
When a bit device is specified, 16 continuous bits are occupied. When a word device is specified,
one word is occupied.
Data processing function

Point • The SORT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, with KV-
5500/5000/3000 Series CPU units that have CPU function version 2.0 or higher
and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The D number of binary data items to sort in the data table specified with n data table leading
device is sorted with the sorting order specified in S sorting order.

• 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-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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)+1
D +2(n−1)

The SORT function sorts all data when the function is executed. Therefore, if a

EXTENDED FUNCTIONS
Point
large value is specified in n , the scan time may increase.
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-44

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series

8
Instruction Reference Manual, "Data Processing Instructions."

● Example of format

Data processing function


SORT ( MR1000, EM0, DM2000.D, 100 )
MR1000 SORT.D
EM0 DM2000 #100

Execution condition Sorting Data table


order leading

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-43


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SORTN

SORTN Binary data partition sort

Partition sort

Return value *1 = SORTN (sort control flag, sort order, number of comparison times,
data table leading device, number of data items to sort)

Argument/Return Recognized Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S1 Sort control flag Specifies the sort processing. - - - - - - .B - - ○ -
S2 Specifies the sorting order. (0:
Sorting order .U .U .U .U - - - - ○ ○ ○
ascending, 1: descending)
S3 Number of Specifies the number of comparisons
.U .U .U .U - - - - ○ ○ ○
comparison times*3 to be made in one scan. (1 to 65535)
EXTENDED FUNCTIONS

D Data table Specifies the leading device of the byte


.U .S .D .L - - - - - ○ -
leading device*2 sequence to search for.
n Number of data Specifies the number of data items to
.U .U .U .U - - - - ○ ○ ○
items to sort*3 sort.
This device turns OFF during sorting,
Return value .B -
R and 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, D channel is occupied if the n type is .U/.S, and 2x

8 n channels are occupied if the type is .D/.L.


When a word device is specified, D word is occupied if the n type is .U/.S, and 2x n
words are occupied if the type is .D/.L.
Data processing function

*3 When a bit device is specified, 16 continuous bits are occupied. When a word device is specified,
one word is occupied.

Point • The SORTN function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can only be specified with KV-8000/7000 Series CPU units, with KV-
5500/5000/3000 Series CPU units that have CPU function version 2.0 or higher
and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
The D number of binary data items to sort in the data table specified with n 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-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Example D : data table leading device is 16 bits (.U/.S)
When S2 =0、S3 =3、 n data table leading device is 16 bits (.U/.S)

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

EXTENDED FUNCTIONS
D +6 71 123 D +6
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 8

Data processing function


ON
SORTN function
execution conditions
OFF

S1 : ON

Sort control flag OFF

SORTN function Execution Execution

ON
R :Return value
OFF

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Data Processing Instructions."

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-45


● Example of format
MR2000 = SORTN ( MR1000, EM10, EM20, DM1000.D, 100 )
CR2002 MOV
EM10 @VM0
Always Sorting order
ON
MOV
EM20 @VM1
Number of
comparison times
MR1000 SORTN.D
@VM0 DM1000 #100 @VB00
EXTENDED FUNCTIONS

Execution condition
Data table
leading device

@VB00 MR2000

Return valu

8
Data processing function

8-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Data processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-47


Ta

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


FIFOW

FIFOW Write to FIFO table

FIFO write

FIFOW ([execution condition,]*1 data store device, data table leading device)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Specifies the device to which the data
Data store Handled as same
to write to the FIFO data block is - - - - ○ ○
device*2 type as D .
currently stored.
D Data table Specifies the leading device of the
.U .U .D .D .D - - - - ○ -
leading device FIFO data table.
EXTENDED 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 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), S the data (16-bit/32-bit) stored in D is
Table processing function

written to the end of the data block specified by the .

● About data table and data block


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

Number of data: data that write to data block.


D n
Max. number of storage number: Max number that data block can store
D +1 max
(specifyd by user).
Data table

D +2 A
Data block: save data processed by LIFO.
D +3 B A Data saved at first; C Data that finally saved.

D +n+1 C

• 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.
• 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-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the data store device is 16 bits (.U/.S)
• The data store destination becomes D +(n+2).
• n is incremented by 1 after storage.
bit bit bit bit
15 0 15 0

n D n+1 D
max D +1 max D +1
A D +2 A D +2
B D +3 n+1 B D +3

EXTENDED FUNCTIONS
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)

• S : When the data store device is 32 bits (.D/.L/.F)


• The data store destination becomes D +(2n+4) • D +(2n+5).
• n is incremented by 1 after storage.

8
bit bit
31 0

D +1 n D
D +3 max D +2

Table processing function


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)

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-49


● Example of format
FIFOW ( R3000, DM1000, DM2000.U )
R3000 FIFOW
DM1000 DM2000
Execution condition
Data store FIFO
device FIFO data table

Point The function is not executed when either of the following conditions is established:
• When maximum number of stored data is "0"
• When the number of data n exceeds the maximum number of stored data.
EXTENDED FUNCTIONS

• 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

FIFOW ( R3000, DM1000, DM2000:Z1 )


8
Programmed Script

Operation Description 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).
Table processing function

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

8-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Hint
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

DM1000 = 0 ’when R3000 turns ON.

DM1001 = 10 ’The maximum number of stored

EXTENDED FUNCTIONS
END IF ’data is set to 10 when R3000
turns ON.
FIFOW ( LDP ( R3100 ), DM2000, DM1000 ) ’Write to the data block is
performed when R3100 turns
ON.

Operation Description When the rising 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.)
8
When the rising edge of R3100 (change from OFF to ON state) has been detected, the

Table processing function


16-bit data currently stored in DM2000 is written to the end of the data block.

Point 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).

Reference 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.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-51


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FIFOR

FIFOR Read from FIFO table

Read FIFO

FIFOR ([execution condition,]*1 data table leading device, data store device)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
D1 Data table Specifies the leading device of the
.U .U .D .D .D - - - - ○ -
leading device*2 FIFO data table.
D2 Data store Specifies the leading device to store data Handled as same
device*2 that is read from the FIFO data block. type as D1 . - - - - ○ -

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, R1012) of the channel has been specified, the relay is handled
in16/32 bits straddling the next channel.

Description of Operation

8 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
Table processing function

stored data is decremented (-1).

● About data table and data block


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

Number of data: data that write to data block.


D n
Max. number of storage number: Max number that data block can store
D +1 max
(specifyd by user).
Data table

D +2 A
Data block: save data processed by LIFO.
D +3 B A Data saved at first; C Data that finally saved.

D +n+1 C

• D1 : When the data table leading device is 16 bits (.U/.S)


(1) When the execution condition is ON, the 16-bit data currently stored in D1 +2 is stored in the
device specified by D2 .
(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.

Blank Store 0

8-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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

EXTENDED FUNCTIONS
D1 +(2n+1) D D1 +(2n)
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
D1 +5
max

B
D1 +2
D1 +4
bit
31
D2 +1
A
D2 bit
0
8

Table processing function


D1 +7 C D1 +6

D1 +(2n+1) E D1 +(2n)
D1 +(2n+3) Blank(0) D1 +(2n+2)

Store 0
"About operation flag (CR2009 to CR2012)", page 1-18
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."

● Example of format
FIFOR ( R3000 = OFF, DM2000.U, DM1000 )
R3000 FIFOR
DM2000 DM1000
Execution condition
FIFO data Result
table store

Point The function is not executed when either of the following conditions is established:
• When there is no data in the data table
• When the number of data n exceeds the maximum number of stored data.
• When the maximum number of stored data is a number that causes the data
table to exceed the device range

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-53


Sample Program
● When an index register is used

Programmed Script
FIFOR ( R3000, DM1000.D, DM2000.D:Z1 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)
EXTENDED FUNCTIONS

Hint
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.

8
'Read from the data block is performed
FIFOR ( LDP ( R3101 ), DM1000, DM2100 ) 'when R3101 turns ON.
Operation Description When the rising edge of R3100 (change from OFF to ON state) has been detected, the
Table processing function

data stored in DM2000 is written to the data block starting from DM1000.
When the rising 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 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-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-55


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LIFOW

LIFOW Write to LIFO table

Write LIFO

LIFOW ([execution condition,]*1 data store device, data table leading device)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Data store Specifies the device to which the data to write Handled as same
device*2 to the LIFO data block is currently stored. type as D . - - - - ○ ○

D Data table Specifies the leading device of the


.U .U .D .D .D - - - - ○ -
leading device LIFO data table.
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, R1012) of the channel has been specified, the relay is handled
in16/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
to the end of the data block specified by the D .
S is written
Table processing function

● About data table and data block


The LIFOW and LIFOR functions use a collection of word data called data tables to perform LIFO(Last
In First Out) processing. The figure below shows the structure of a data table.
bit bit
15 0

Number of data: data that write to data block.


D n
Max. number of storage number:
D +1 max
Data table

Max number that data block can store (specifyd by user).


D +2 A Data block: save data processed by LIFO
A Data saved at first; C Data that finally saved
D +3 B
:

D +n+1 C

• 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.
• 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.

8-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• S : When the data store device is 16 bits (.U/.S)
• The data store destination becomes D +(n+2)
• n is incremented by 1 after storage.
bit bit bit bit
15 0 15 0

n D n+1 D
max D +1 max D +1
A D +2 A D +2

n B D +3 n+1 B D +3

EXTENDED FUNCTIONS
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)

• : When the data store device is 32 bits (.D/.L/.F)


S
• The data store destination becomes D +(2n+4) • D +(2n+5).
• After storage: n plus 1.

8
bit bit
31 0

D +1 n D
D +3 max D +2

Table processing function


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)

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)

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."

● Example of format
LIFOW ( R3000, DM1000, DM2000.U )
R3000 LIFOW
DM1000 DM2000
Execution condition
Result store LIFO
data table

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-57


Point The function is not executed when either of the following conditions is established:
• When maximum number of stored data is "0"
• When the number of data n exceeds the maximum number of stored data.
• 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
LIFOW ( R3000, DM1000:Z1, DM2000 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

Hint
8
The data table used by the LIFOW function is in the same structure as the data table used by the
Table processing function

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 )
Operation Description The 16-bit data currently stored in DM1000 is written to the end of the data block starting
from DM2000 at every scan (no execution condition).
bit
bit bit
bit bit
bit bit
bit
Ladder conversion 1515 00 1515 00

DM2000
DM2000 nn n+1
n+1

DM2001
DM2001 max
max max
max

DM2002
DM2002 AA AA

DM2003
DM2003 BB BB
:: ::

DM2000+n+1
DM2000+n+1 CC CC
Add
Add data
data in
in DM1000
DM1000
DD DD
DM1000
DM1000 data
data

Add
Add data
data to
to FIFOW
FIFOW function
function in
in the
the same
same way
way

Reference The same operation as the following Programmed Script is performed:


FIFOW ( DM1000, DM2000 )
"FIFOW function", page 8-48

8-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-59


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
LIFOR

LIFOR Read from LIFO table

Read FIFO

LIFOR ([execution condition,]*1 data table leading device, data store device)
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
D1 Data table Specifies the leading device of the
.U .U .D .D .D - - - - ○ -
leading device*2 LIFO data table.
D2 Data store Specifies the leading device to store data Handled as same
device*2 that is read from the LIFO data block. type as D1 . - - - - ○ -

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 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
Table processing function

stored data is decremented (-1).


("0" is stored in last data section that is read.)

● About data table and data block


The LIFOW and LIFOR functions use a collection of word data called data tables to perform LIFO(Last
In First Out) processing. The figure below shows the structure of a data table.
bit bit
15 0

Number of data: data that write to data block.


D n
Max. number of storage number:
D +1 max
Data table

Max number that data block can store (specifyd by user).


D +2 A Data block: save data processed by LIFO
A Data saved at first; C Data that finally saved
D +3 B
:

D +n+1 C

• D1 : When the data table leading device is 16 bits (.U/.S)


(1) When the execution condition is ON, the 16- bit data currently stored in D1 +n+1 is stored in
the device specified by D2 .
(2) n is then decremented (by -1) after the data is stored.

Blank(0)

Store 0

8-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


• 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) D1 +(2n) D2 +1 D2

EXTENDED FUNCTIONS
C bit
31
bit
0

D1 +(2n+3) D D1 +(2n+2)

(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
8

Table processing function


D1 +(2n+1) C D1 +(2n) bit
31
D2 +1 D2 bit
0

D1 +(2n+3) Blank(0) D1 +(2n+2) D

Store 0

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."

● Example of format
LIFOR ( R3000 = OFF, DM2000.U, DM1000 )
R3000 LIFOR
DM2000 DM1000
Execution condition
LIFO Data store
data table

Point The function is not executed when either of the following conditions is established:
• When there is no data in the data table
• When the number of data n exceeds the maximum number of stored data.
• When the maximum number of stored data is a number that causes the data
table to exceed the device range

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-61


Sample Program
● When an index register is used

Programmed Script
LIFOR ( R3000, DM1000.D, DM2000.D:Z1 )
Operation Description 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.

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)
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.

'Read from the data block is performed


LIFOR ( LDP ( R3101 ), DM1000, DM2100 )
8
'when R3101 turns ON.

Operation Description When the rising 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 function

When the rising edge of R3101 (change from OFF to ON state) has been detected, data
is read from the table block and stored in DM2100.
bi t bi t bi t bi t bi t bi t
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-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Table processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-63


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FWRIT

FWRIT Overwrite data table specified position

Rewrite the data table

FWRIT ([execution condition,]*1 data store device, data table leading device, write
block position)

Argument/Return Recognized Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Specifies the device to which the data
Data store Handled as same
to overwrite is currently stored, or the - - - - ○ ○
device*2 type as D .
overwrite data.
D Data table
Specifies the start of the table. .U .U .D .D .D - - -
EXTENDED FUNCTIONS

leading device*2 - ○ -

n Specifies the device to which the position


Write block
of the data block to overwrite is currently .U .U .U .U - - - - ○ ○ ○
position
stored, or the overwrite 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

8 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.
Table processing function

Description of Operation
When the execution condition is established (TRUE), the data (16-bit/32-bit) stored in S is
overwritten at D of the data block specified by n .
• 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

2 st B D +3 B D +3

Data block
(for saving data) n st C E

N st D D +N+1 D D +N+1

• 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)

2 st D +7 B D +7 B
Data lis

D +6 D +6

n st D +(2n+3) C D +(2n+2) D +(2n+3) E D +(2n+2)


N st D +(2N+3) D D +(2N+2) D +(2N+3) D D +(2N+2)

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."
8-64 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
FWRIT ( R3000, DM1000.U, DM2000, 5 )
R3000 FWRIT
DM1000 DM2000 #5
Execution condition
Data store device Data table

Point The function is not executed when either of the following conditions is established:
• When the value of n is 0 or greater than number of data (N)
• When maximum number of stored data (max) is "0"
• When the number of data exceeds the maximum number of stored data

EXTENDED FUNCTIONS
• 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

FWRIT ( R3000, DM1000:Z1, DM2000:Z2, DM2100 )


8
Programmed Script

Operation Description 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).

Table processing function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

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.

Operation Description 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.
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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-65


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FINS

FINS Insert to data table specified position

Insert data table

FINS ([execution condition,]*1 data store device, data table leading device, insert
block position)

Argument/Return Recognized Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S Specifies the device to which the data
Data store Handled as same
to overwrite is currently stored, or the - - - - ○ ○
device*2 type as D .
overwrite data.
D Data table
Specifies the start of the table. .U .U .D .D .D - - -
EXTENDED FUNCTIONS

leading device*2 - ○ -

n Specifies the device to which the


Insert block
position of the data block to insert is .U .U .U .U - - - - ○ ○ ○
position
currently stored, or the insert 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. R002 or R1012) of the channel has been specified, the relay is
8 handled in 16/32 bits straddling the next channel.
Table processing function

Description of Operation
When the execution condition is established (TRUE), the data (16-bit/32-bit) stored in S is inserted
at D of the data block specified by n .
• 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

N st D D +N+1

D D +(N+1)+1

• 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
1 st D +5 A D +4 D +5 A D +4
Data block (for saving data)

Data table

2 st 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)

N st D +(2N+3) D D +(2N+2)
D +(2N+5) D D +(2N+4)

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."
8-66 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
● Example of format
FINS ( R3000, DM1000.U, DM2000, 4 )
R3000 FINS
DM1000 DM2000 #4
Execution condition
Data store Data table

Point The function is not executed when either of the following conditions is established:
• When the value of n is 0 or greater than number of data (N)
• When maximum number of stored data (max) is "0"
• When the number of data exceeds the maximum number of stored data

EXTENDED FUNCTIONS
• 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

Programmed Script

Operation Description
FINS ( R3000, DM1000:Z1, DM2000:Z2, DM2100 )
When R3000 turns ON, the 16-bit data currently stored in DM (1000+Z1) is inserted at the
8
block position indicated by DM2100 of the data block starting from DM (2000+Z2).

Table processing function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

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 LIFO table.

FINS ( DM1000, DM3000, 2 ) 'Inserts in the LIFO table.

Operation Description 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
fromDM3000 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

FIFO table LIFO table

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-67


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
FDEL

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 Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
D Data table
Specifies the start of the table. .U .U .D .D .D - - - - ○ -
leading device*2
n Specifies the device to which the
Delete block
position of the data block to delete is .U .U .U .U - - - - ○ ○ ○
position
currently stored, or the delete position.
EXTENDED 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 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
8 When the execution condition is established (TRUE), the data at D of the data block specified by
Table processing function

the n 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).
• 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

2 st B D +3 B D +3

Data block
(for saving data) n st C D D +N

0 D +N+
N st D D +N+1 Store 0.

• 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
1 個目 D +5 A D +4 D +5 A D +4
Data table
(for saving data)

2 個目 D +7 B D +6 D +7 B D +6
Data block

n 個目 D +(2n+1) C D +(2n) D +(2N+1) D D +(2N)


D +(2N+3) 0 D +(2N+2)
N 個目 D +(2N+3) D D +(2N+2) Store 0.

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Table Processing Instructions."

8-68 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
FDEL (R3000, DM2000.U, 3)
R3000 FDEL
DM2000 #3
Execution condition
Data table

Point The function is not executed when either of the following conditions is established:
• When the value of n is 0 or greater than number of data (N)
• When maximum number of stored data (max) is "0"
• When the number of data exceeds the maximum number of stored data

EXTENDED FUNCTIONS
• 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

Programmed Script

Operation Description
FDEL ( R3000, DM2000:Z1, DM2100 )
When R3000 turns ON, the data at the block position indicated by DM2100 of the data
8
block starting from DM (2000+Z1) is deleted.

Table processing function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

Hint
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.

Operation Description During every scanning (no execution condition), the data stored in the 2nd data block of
DM2000 FIFO data block, and the 2nd data block of DM3000 LIFO data block will be
deleted once.
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

FIFO table LIFO table

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-69


Cl

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


WTIME

WTIME Write time data to calendar timer

Write time

WTIME ([execution condition,]*1 Year, Month, Day, Hours, Minutes, Seconds, Week)
Recognized Type Const Device / For
Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
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 - - - - ○ ○ ○
Time setting
S4 Hour data (0 to 23) .U .U .U .U - - - - ○ ○ ○
target
S5 Minute data (0 to 59) .U .U .U .U - - - - ○ ○ ○
EXTENDED FUNCTIONS

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 times (at every scan).)

Reference When word data has been specified to S1 to S7 , it is handled entirely as


unsigned16-bit data. (The specified suffix is ignored).

8 * This function cannot be used with the KV-N14**. No error will occur when an attempt is made to
execute the function, but the function will not be executed.
Clock processing function

(A conversion error will not occur in KV-N14**, KV STUDIO)

Description of Operation
When the execution condition is established (TRUE), the time data currently stored in S1 to S7 is
written to the built-in calendar timer.
Time setting bit bit
device 15 0

S1 Year 0∼99 Year indicates solar calendar 2000's last 2 digits.

S2 Month 1∼12

S3 Day 1∼31

S4 Hour 0∼23 Data are all expressed as 16-bit binary format.

S5 Minute 0∼59

S6 Second 0∼59 Week designation are as follows.


0: (Sunday),1: (Monday),2: (Tuesday),
S7 Day of week 0∼6 3: (Wednesday),4: (Thursday),5: (Friday),6: (Saturday)

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Clock Processing Instructions."

8-70 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
WTIME ( R3000, 04, 06, 07, 22, 38, 43, 5 )
R3000 MOV
#4 @VM0
Execution
condition MOV
#6 @VM1

MOV
#7 @VM2

MOV

EXTENDED FUNCTIONS
#22 @VM3

MOV
#38 @VM4

MOV
#43 @VM5

MOV
#5 @VM6

@VMO
WTIME 8
Time setting device

Clock processing function


Point • The time data cannot be written independently and directly to control memories.
• 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.
• When the data to write is in the inappropriate format as the time data, the WTIME
function is not executed.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-71


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SEC

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 Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion
Specifies the start that stores the date
S source .U .U .U .U .F - - - - ○ -
and time of the conversion source.
device*2*3
*5
Return value .U type SEC function available*4 .U .S .D .L .F
R .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, 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 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 In device Z, the ".DF" suffix cannot be specified.

8 Point • The argument device ".DF" can be used only with the KV STUDIO Ver. 6.00 and
higher versions.
Clock processing function

• The argument device ".DF" can only be specified with KV-8000/7000 Series CPU
units, with KV-5500/5000/3000 Series CPU units that have CPU function version
2.0 or higher and with KV Nano Series base units.
"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
S The six words (96 bits) of date/time data currently stored starting from 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∼99 Second conversion Second

S +1 Month 1∼12 2 words (32 bits)

S +2 Day 1∼31 Unsigned 32-bit BIN data


S +3 Hour 0∼23

S +4 Minute 0∼59

S +5 Second 0∼59

Year indicates solar calendar 2000's last 2 digits.

Reference Date/time data is specified entirely as 16-bit BIN data, and can be used as both unsigned
and signed.

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Clock Processing Instructions."

8-72 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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

EXTENDED FUNCTIONS
Point When either of the following conditions is established, 0 is stored in R :
• When the date/time data to convert is in an inappropriate format
• 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
8
Programmed Script
RSEC ( TOL ( SEC ( CM0700 ) ) + 864000, DM2000 )

Clock processing function


Operation Description The date/time ten 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 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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"RSEC function", page 8-74
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-73


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RSEC

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 Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Conversion Specifies the storage location for the
S source seconds (total seconds) of conversion - - .D .D - - - - - ○ ○
device*2*3 source.
D Conversion Specifies the start to store the
.U .U .U .U - - - -
EXTENDED FUNCTIONS

source device*2*3 converted date and time. - ○ -

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, 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.
8
Description of Operation
Clock processing function

The total number of seconds (32-bit BIN data (unsigned)) referenced to "year 2000, January 1st, 0:0:0"
and 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 .

bit
31
S +1 bit bit
16 15
S bit
0
bit
15
bit
0

Second Second conversion Year D (0∼99)


2 words (32 bits) Month D +1 (1∼12)
Day D +2 (1∼31)
Hour D +3 (0∼23)
Minute D +4 (0∼59)
Second D +5 (0∼59)

Reference The date/time data is stored entirely as 16-bit BIN data.

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Clock Processing Instructions."

● Example of format
RSEC ( DM1000.D, DM2000 )
CR2002 RSEC
DM1000 DM2000
Always ON
Conversion Store
source

Point The function is not executed when either of the following conditions is established:
• When the second data to convert is in an inappropriate format
• When a timer/counter is specified to S and D by indirect specification

8-74 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Sample Program
● When this function is used in combination with other functions

Programmed Script
RSEC ( TOL ( SEC ( CM0700 ) ) - 259200, DM2000 )
Operation Description 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 CM0700 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

EXTENDED FUNCTIONS
(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.

Reference • Note that this function sometimes cannot be used depending on the argument of the
function it is combined with.
"SEC function", page 8-72
• The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

Clock processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-75


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
AJST

AJST Calendar timer adjustment

Adjust

AJST ([execution condition,]*1)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
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).)

* This function cannot be used with the KV-N14**. No error will occur when an attempt is made to
EXTENDED FUNCTIONS

execute the function, but the function will not be executed.


(A conversion error will not occur in KV-N14**, KV STUDIO)

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

8 "seconds" is set to "0" when "seconds is 30 to 59 to adjust the timer to the nearest minute unit ("0"
seconds).
Clock processing function

Before perform After perform


12 hours, 59 minutes, → 12 hours, 59 minutes,
15 seconds 00 seconds
12 hours, 59 minutes, → 13 hours, 00 minutes,
30 seconds 00 seconds
For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "Clock Processing Instructions."

● Example of format
AJST ( R3000 )
R3000
AJST
Execution condition

Reference When the execution condition is omitted, the script becomes as follows:

Programmed Script
AJST ( ) ’Execution condition omitted

Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "Precautions When Using Box Script""New a box script", step 5,
(page 2-10)

8-76 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Clock processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-77


Hi

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


DI,EI

DI Disable interrupt

EI Enable interrupt

Disable interrupt

DI ([execution condition,]*1 )
Enable interrupt

EI ([execution condition,]*1 )
Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
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).)

Description of Operation
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 DI function are enabled (disable canceled)
8 by the EI function.
• Once the EI function is executed, interrupts up to execution of the DI function are enabled.
• Interrupts are disabled at all times when operation is started.
High-speed processing function

• Interrupts up to a nesting level of 16 can be stored if they occur during execution of the DI function
(interrupts are disabled).
When the EI function is executed, interrupts stored in memory are executed.
• 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, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "INT/RETI Instruction" and "High-speed Processing Instructions."

● Example of format
DI ( R3000 )
R3000
DI
Execution condition

EI ( R3000 = OFF )
R3000
EI
Execution condition

Point 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.

Reference 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 factor can be enabled (nested interrupt).
Note, however, that interrupts by the same interrupt factor cannot be programmed.

8-78 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RFSCTH

RFSCTH High-speed Counter refresh

High-speed Counter refresh

RFSCTH ([Execution condition,]*1 High-speed counter No.)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
S High-speed *2
Specifies the high-speed counter No. - - - - - - - - - ○
counter No. ○
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 The high-speed counter number is specified as a single digit number (0 to 3). The high-speed
counter number that can be used differs according to the unit.

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
KV-5500/5000/3000/1000

High-speed processing function


High-speed Control relay to be refresh
counter Overflow Change method
CTH0 CR2403 CR2412
CTH1 CR2407 CR2413

KV Nano
High-speed Control relay to be refresh
counter Overflow Change method
CTH0 CR4206 CR4207
CTH1 CR4406 CR4407
CTH2 CR4606 CR4607
CTH3 CR4806 CR4807

"About operation flag (CR2009 to CR2012)", page 1-18


For details on execution timing, see KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "High-speed Processing Instructions."

● Example of format
RFSCTH ( MR1000, 1 )
MR1000 RFSCTH
#1
Execution condition

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-79


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
DIC

DIC Set interrupt disabled range

Disable interrupt

DIC ([execution condition,]*1 interrupt state store device)


Argument/Return Recognized Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
D Specifies the device to store the
Interrupt state
interrupt disabled state before - - - - - - .B - - ○ -
store device*2
instruction execution to.
R Return value None - - - - - - - - - - -
*1 [ ] can be omitted. (When the execution condition has been omitted, the instruction is executed at
EXTENDED FUNCTIONS

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.)

Description of Operation
The DIC function disables execution of the interrupt program when the execution condition is
established (TRUE).
8 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.
High-speed processing function

Reference Since the interrupt status storage target and the interrupt status before the interrupt
program is disabled are stored, they can be used when nesting is interrupted in
combination with the execution condition of the EI function (interrupt enable).

Status for interrupt forbidden Status for allow interrupt

MR1000 D MR1000 D
DIC DIC
Execution condition Execution condition

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-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual, "High-speed Processing Instructions."

8-80 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
DIC ( R3000, R2000 )
R3000 R2000
DIC
Execution condition Interrupt status store

Sample Program

Programmed Script
DIC ( R2000 )

EXTENDED FUNCTIONS
FOR DM1000 = 0 TO 10
DM2000.L = DM2000 + DM1000
NEXT
EI ( R2000 )
Operation Description 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 function


Reference The KV script is converted to a ladder program before execution. To check the converted
content, refer to "New a box script", step 5, (page 2-10)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-81


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
IEDGE

IEDGE Set interrupt condition

Set interrupt condition

IEDGE ([execution condition,]*1 unit number, input number, detection condition)


Recognized Type Const Device / For
Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies expansion unit number for *2
n1 Unit number writing input interrupt detection .U .U .U .U - - - - - -

condition. (0 to 48)
Specifies interrupt factor number. (0 to *3
n2 Input number .U .U .U .U - - - - ○ ○
31) ○
EXTENDED FUNCTIONS

Specified detection condition (rising


Detection *4
S edge: 0 or 1, falling edge: 2, rising edge .U .U .U .U - - - - ○ ○
condition ○
and falling edge: 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).)

Description of Operation
8 When the execution condition is TRUE, S the 1-word data specified by n1 is set to the detection
condition of the cause interrupt of n2 unit.
High-speed processing function

Depending on the value of S , the following detection conditions are available.


S Detection condition
0 to 1 Rising edge
2 Falling edge
3 Rising edge and falling edge

Point • Specifying to S the range of 4 to 65535 does not result in operation error, but
the detection condition is not changed.
• When execution of this instruction is completed, the detection condition is
changed.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please see KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual, "IEDGE Instructions".

● Example of format
IEDGE ( MR1000,1,0,3 )
MR1000 IEDGE KV-SIR32XT
Detection
Unit number Input number condition
#1 #0 #3

8-82 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

High-speed processing function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-83


PI

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


PIDAT

PIDAT PID control with automatic tuning

PID control with AT

PIDAT ([execution condition,]*1 measured value, parameter, manipulated value)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Measured Specifies the value measured form the
S .S .S .S .S - - - - - ○ ○
value control target.
Specifies the start to store the
D1 Parameter*2 .U .U .U .U - - - - - ○ -
parameter.
Manipulated Specifies the destination to store the
D2 .S .S .S .S - - - - - ○ -
EXTENDED FUNCTIONS

value PID operation result.


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).)
*2 The D1 parameter occupies 51 continuous words. Refer to the explanation of the PIDAT
instruction code for details on the parameter.

Point • The PIDAT function can be used only with KV STUDIO Ver. 6.00 or higher.

8
• This function can only be used with KV-8000/7000 Series CPU units, KV-5500/5000/
3000 Series CPU units with CPU function version 2.0 or higher and KV Nano Series
base units.
PID Functions

"KV-5500/5000/3000 CPU Function Version", page 4

Description of Operation
D2 (PID operation result) is retrieved from S and D1 .
At the first call, (when executing initialization), the execution condition is 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.

Reference 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 "KV-8000/7000/5000/3000/1000 Series and KV Nano Series


Instruction Reference Manual" for details on the operation flags and D1 .

● Example of format
PIDAT ( DM1000, EM1000, DM2000 )
CR2002 PIDAT
DM1000 EM1000 DM2000

Always ON Measured Parameter Manipulated


value leading device value

8-84 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

PID Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-85


Lo

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


LOGE,LOGD

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 Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the destination that stores the *2
n Logging ID logging ID for enabling/disabling .U .U .U .U - - - - ○ ○
EXTENDED FUNCTIONS

logging, or the 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).)
*2 Cannot be specified by "$".

Description of Operation
8 When the execution condition is established (TRUE), the LOGE function enables execution of logging
by the logging ID specified by n . After the function is executed, the logging execution relay of each
Log Functions

logging ID is set.
When the execution condition is established (TRUE), the LOGD function disables execution of logging
by the logging ID specified by n . After the function is executed, the logging execution relay of 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
"About operation flag (CR2009 to CR2012)", page 1-18
Refer to User's Manual of the CPU unit used.

● Example of format
LOGE ( R3000, DM1000 )
R3000 DM1000
LOGE
Execution condition Logging ID

Point When n is set to other than a constant or set to 10 or more, the function will not
be executed.

8-86 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TRGD

TRGD Acquire logging data

Acquire logging data

TRGD ([execution condition,]*1 logging ID)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
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).)
*1 Please specify the logging ID as 0 to 10. Please specify the logging ID as 10 when trigger

EXTENDED FUNCTIONS
instruction is used on real-time curve monitor.

Description of Operation
When the execution condition is established (TRUE), the data of the logging ID specified by n is
acquired.
Under general condition, data is acquired by log, trace, real-time curve monitor via END processing
timing. Using TRGD instruction can acquire data via any timing of ladder.
8
Point • Only up to eight TRGD functions (instructions) can be used per ID in one project.

Log Functions
• To acquire data using TRGD function (instruction), it is necessary to set trigger
type to "trigger instruction" via logging, trace, real-time curve monitor setting of
KV STUDIO. If it is not set to "trigger instruction", even if TRGD function
(instruction) is executed, data cannot be acquired.

"About operation flag (CR2009 to CR2012)", page 1-18


Refer to User's Manual of the CPU unit used.

● Example of format
TRGD ( MR1000, 1 )
MR1000 #1
TRGD
Execution condition

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-87


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
TRGR

TRGR Get device / variable data

Get device / variable data

TRGR ([execution condition,]*1 Operation recorder ID)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Operation Specifies the operation recorder ID. (0
n .U .U .U .U - - - - ○ ○ ○
recorder ID to 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

Description of Operation
When the execution condition is established (TRUE), the data of the operation recorder ID specified by
n is acquired.
The data is generally acquired at the time of END processing, but the data can be acquired at any time
of the ladder using the TRGR instruction.

8 Point • The TRGR instruction can be used only with KV STUDIO Ver.10.0 or later and the
compatible model of KV-8000.
Log Functions

• To acquire data using TRGR function (instruction), it is necessary to set


sampling period to "trigger instruction" in the operation recorder setting of KV
STUDIO. If it is not set to "trigger instruction", even if TRGR function (instruction)
is executed, data cannot be acquired.

"About operation flag (CR2009 to CR2012)", page 1-18


Refer to "Operation Recorder Function" in "KV-8000 Series User's Manual" for details.

● Example of format
TRGR(MR1000, 0)
MR1000 #0
TRGR
Execution condition

8-88 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Log Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-89


Stor
age

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


MWRIT

MWRIT Write to storage device (memory card/CPU memory)

Write to storage device

Return value*1 = MWRIT (save file name, save data storage destination, number of
save data storage destination, save format storage
destination, save result storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name for data saving or the save file *3
S1 Save file
name. (A text string in the range 1 to - - - - - - - .T ○ ○
name*7 ○
247 characters (including end code
EXTENDED FUNCTIONS

NUL and folder name) is specified.)


S2 Save data storage Specifies the start that stores the save
.U .U .U .U - - - - - ○ -
destination*4*5 data.
n Number of save Specifies the storage location for the
data storage number of data in the save range or the .U .U .U .U - - - - - ○ ○
destination number of save data.
Save format Specifies the start to store the
D1
storage parameters related to the save format, .U .U .U .U - - - - - ○ -
destination*5*6 etc. and the data save status.

8 D2 Save result storage Specifies the bit data to notify the save
destination*2 result. - - - - - - .B - - ○ -
Turns ON when the function is
Storage Functions

R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -


when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 When bit data is specified for the save result storage destination, 2 continuous bits are used as
notification bits; when word data is specified, the LSB of each of 2 continuous words is used as
notification bit data.
*3 To specify a text string using constants, enclose with " ".
*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 When specifying bit data, specify the start of the channel.
*6 D1 When bit data is specified, it occupies 96 continuous bits. When word data is specified, 6
continuous words are occupied.
*7 T, C, CR, CTC, CTH, Z cannot be used.

Point This function cannot be used with KV-N14 □ □/N24 □ □ /N40 □ □ /N60 □ □ . (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The data stored in the range specified by n is written to the memory card or CPU memory with the
file name (text string) specified by S1 starting from S2 .
The write process is performed according to the write parameters specified by D1 , and the write
completion notification and abnormal end alarm notification are stored in D2 .
R is turned ON when the MWRIT function is started normally, and OFF when it fails.
For details on parameters related to the save format, etc. specified in D1 , please refer to "KV-
8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual", "MWRIT
instruction".

8-90 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Reference D2 The notification bits of the save result storage destination have the following
meanings.
(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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction

EXTENDED FUNCTIONS
Reference Manual", "Storage Instructions".

● Example of format
MR1100 = MWRIT (DM5000.T, DM1000.U, DM1100.U, DM1200.U, MR2000)
CR3214
• @VB01

Execute command
of storage @VB00

8
device in progress RES

CR3214 CJ
#2000

Storage Functions
Execute command of storage
device in progress
FOR
#2

@VB00 MWRIT
DM5000 DM1000 DM1100
Save file name Save data Number of
saving data
DM1200 MR2000

@VB00 @VB00
SET

NEXT

LABEL
#2000

@VB01 MR1100

Point The function is not executed when any of the following conditions is established:
• When the text string specified by S1 does not contain the end code (NUL
(00H))
• When the text string specified by S1 exceeds 247 characters (including end
code "NUL (00H)")
• When a timer/counter is specified to S1 by indirect specification.
• When a bit other than the start of the channel is specified when bit data is
specified for S1 , S2 and D1 .
• When a value outside of the range is specified to an argument
• When a value is specified for reservation of an argument

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-91


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MREAD

MREAD Read from storage device (memory card/CPU memory)

Read from storage device

Return value*1 = MREAD (read file name, read data storage destination, number of
read data storage destination, read format storage
destination, read result storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name for data reading or the read *3
S1 Read file
file name. (A text string in the range 1 - - - - - - - .T ○ ○
name*4*7 ○
to 247 characters (including end code
EXTENDED FUNCTIONS

NUL and folder name) is specified.)


S2 Read data storage Specifies the start that stores the read
.U .U .U .U - - - - - ○ -
destination*4 data.
n Number of read Specifies the storage location for the
data storage number of data in the read range or the .U .U .U .U - - - - ○ ○ ○
destination*5 number of read data.
Read format Specifies the start to store the
D1
storage parameters related to the read format, .U .U .U .U - - - - - ○ -
destination*6 etc. and the data read status.

8 D2 Read result
storage
Specifies the bit data to notify the read
result. - - - - - .B - - - ○ -
destination*2*4
Storage Functions

Turns ON when the function is


R Return value successfully started up, and turns OFF - - - - - .B - - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 When bit data is specified for the read result storage destination, 2 continuous bits are used as
notification bits; when word data is specified, the LSB of each of 2 continuous words is used as
notification bit data.
*3 To specify a text string using constants, enclose with " ".
*4 When specifying bit data, specify the start of the channel.
*5 When reading ASCII text string data, specify the maximum number of characters (number of
bytes) in the text string.
*6 D2 When bit data is specified, it occupies 96 continuous bits. When word data is specified, 6
continuous words are occupied.
*7 T, C, CR, CTC, CTH, Z cannot be used.

Point This function cannot be used with KV-N14 □ □/N24 □ □ /N40 □ □ /N60 □ □ . (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The data of the file name (text string) specified by S is read from the storage and stored in the
range specified by n starting with D1 .
The read process is performed according to the read parameters specified by D2 , and the read
completion notification and abnormal end alarm notification are stored in D3 .
R is turned ON when the MREAD function is started normally, and OFF when it fails.
For details on parameters related to the read format, etc. specified in D2 , please refer to "KV-
8000/7000/5000/3000/1000 Series and KV Nano Series Instruction Reference Manual", "MREAD
instruction".
8-92 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Reference D3 The notification bits of the read result storage destination have the following
meanings.
(Example) When MR2000 has been specified

Notification Bit ON OFF


MR2000 Completion notification Completed Not completed
MR2001 Error notification Normal end Abnormal end

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction

EXTENDED FUNCTIONS
Reference Manual", "Storage Instructions".

● Example of format
MR1100 = MREAD (DM5000.T, DM1000.U, DM1100.U, DM1200.U, MR2000)
CR3214 @VB01

Execute command
of storage device @VB00

8
in progress RES

CR3214 CJ
#2000

Storage Functions
Execute command of
storage device in progress
FOR
#2

@VB00 MREAD
DM5000 DM1000 DM1100
Read file name Read data Number of
saving data
DM1200 MR2000

@VB00 @VB00
SET

NEXT

LABEL
#2000

@VB01 MR1100

Point The function is not executed when any of the following conditions is established:
• When the text string specified by S does not contain the end code (NUL
(00H))
• When the text string specified by S exceeds 247 characters (including end
code "NUL (00H)")
• When a timer/counter is specified to S by indirect specification.
• When a bit other than the start of the channel is specified when bit data is
specified for S , D1 and D2 .
• When a value outside of the range is specified to an argument
• When a value is specified for reservation of an argument

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-93


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MFREE

MFREE Get storage device (memory card/CPU memory) free space in bytes

Get storage device free space

Return value*1 = MFREE ((drive number,)*4 free space storage destination, get
result storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the drive number (memory
n Drive number*4 card:0, CPU memory:1) for checking .U .U .U .U - - - - - ○ -
the free space.
Specifies the destination to store the
Free space
EXTENDED FUNCTIONS

free space (in bytes) obtained from the


D1 storage - - .D .D - - - - - ○ -
memory card (CPU memory). (32-bit
destination*2
data)
D2 Get result
Specifies the bit data to notify the free
storage - - - - - - .B - - ○ -
space get result.
destination*3
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.

8 *1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 When bit data is specified, 32 continuous bits from the start of the channel are processed.
Storage Functions

*3 When bit data is specified for the get result storage destination, 2 continuous bits are used as
notification bits; when word data is specified, the LSB of each of 2 continuous words is used as
notification bit data.
*4 For KV-8000/7000 Series, you can select memory card or CPU memory for checking the free
space.

Point This function cannot be used with KV-N14 □ □/N24 □ □ /N40 □ □ /N60 □ □ . (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The free space (in bytes) of the memory card or CPU memory specified by n is acquired and
stored as 32-bit BIN data (2 words) in D1 , and the completion notification of free space acquisition
and abnormal end alarm notification are stored in D2 .
D1 +1 D1
Free Space Available
Memory 32-bit BIN data
card

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Storage Instructions".

8-94 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format (For KV-5000)
MR1100 = MFREE ( DM1000.D, R1000 )
CR3214 @VB01

Execute command
of storage device @VB00
in progress RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR

EXTENDED FUNCTIONS
#2

@VB00 MFREE
DM1000 R1000

Capacity store Result store

@VB00 @VB00
SET

NEXT

8
LABEL

Storage Functions
#2000

@VB01 MR1100

● Notification bit data ( D2 : completion notification, D2 +1: error notification)


Item Details
This device turns OFF when execution of the instruction starts, and turns
Completion ON when acquisition of free space in the memory card (or CPU memory)
D2
notification ends. The device 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.

Point • The result of END processing after execution of the instruction is completed is
written for the completion notification and error notification.
• Several scans are sometimes required for getting free space.
• 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.
• The MFREE function is not executed while a storage device function is being
executed (CR3214 is ON).
• When a relay other than the leading relay of the channel has been specified to
D1 , the function is not executed.
• This instruction cannot be used in interrupt programs or in the initialization
module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-95


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MFREEK

MFREEK Get storage device (memory card/CPU memory) free space in kilobytes

Get storage device free space

Return value*1 = MFREEK ((drive number,)*4 free space storage destination, get
result storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the drive number (memory
n Drive number*4 card:0, CPU memory:1) for checking .U .U .U .U - - - - - ○ -
the free space.
Specifies the target to store the
Free space
EXTENDED FUNCTIONS

obtained spare capacity (in kilobytes)


D1 storage - - .D .D - - - - - ○ -
of the memory card (CPU memory).
destination*2
(32-bit data)
D2 Get result
Specifies the bit data to notify the free
storage - - - - - - .B - - ○ -
space get result.
destination*3
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.

8 *1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 When bit data is specified, 32 continuous bits from the start of the channel are processed.
Storage Functions

*3 When bit data is specified for the get result storage destination, 2 continuous bits are used as
notification bits; when word data is specified, the LSB of each of 2 continuous words is used as
notification bit data.
*4 For KV-8000/7000 Series, you can select memory card or CPU memory for checking the free
space.

Point • The MFREEK function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-
5500/5000/ 3000 Series CPU unit with CPU function version 2.0 or higher, or KV-
NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The free space (in kilobytes) of the memory card or CPU memory specified by n is acquired and
stored as 32-bit BIN data (2 words) in D1 , and the completion notification of free space acquisition
and abnormal end alarm notification are stored in D2 .
D1 +1 D1
Free Space Available
Memory 32-bit BIN data
card

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "MFREEK instruction".

8-96 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format (For KV-5000)
MR1100 = MFREEK ( EM1000.D, MR2000 )
CR3214 @VB01

Execute command
@VB00
of storage device
in progress RES

CR3214 CJ
#2000
Execute command of
FOR
storage device in progress
#2

EXTENDED FUNCTIONS
@VB00 MFREEK
EM1000 MR2000

Memory card space Retrieved results


storage destination
@VB00 @VB00
SET
NEXT

8
LABEL
#2000

@VB01 MR1100

Storage Functions
● Notification bit data ( D2 : completion notification, D2 +1: error notification)

Item Details
This device turns OFF when execution of the instruction starts, and turns
Completion ON when acquisition of free space on the memory card (or CPU memory)
D2
notification ends. The device 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.

Point • The result of END processing after execution of the instruction is completed is
written for the completion notification and error notification.
• Several scans are sometimes required for getting free space.
• 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.
• The MFREEK function is not executed while a storage device function is being
executed (CR3214 is ON).
• When a relay other than the leading relay of the channel has been specified to
D1 , the function is not executed.
• This instruction cannot be used in interrupt programs or in the initialization
module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-97


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MMKDIR

MMKDIR Make storage device (memory card/CPU memory) directory

Make storage device directory

Return value*1 = MMKDIR (created path name, make result storage destination)
Supported Type Const Device / For
Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
S path name of the directory to make or
Created path *2
the created directory path name. (A text - - - - - - - .T ○ ○
name*3*5 ○
string in the range 1 to 247 characters
(including end code NUL) is specified.)
Make result
EXTENDED FUNCTIONS

D
Specifies the destination to notify the
storage - - - - - - .B - - ○ -
make result.
destination*4
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 To specify a text string using constants, enclose with " ".

8 *3
*4
When specifying bit data, specify the start of the channel.
When bit data is specified, it occupies 2 continuous bits. When word data is specified, the LSB of
each of the 2 continuous words is used as notification bit data. Bits other than the LSB do not
Storage Functions

change.
*5 T, C, CR, CTC, CTH, Z cannot be used.

Point • This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A


conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
A directory is made in the memory card or CPU memory using the path name (text string) specified by
S .
The make result is stored in D .

Example S "Directory A" "Directory A\Directory B"

Memory Memory card Memory


card
Memory card
card

Example of
directory Directory A Directory A
structure

Directory B

When a directory already exists, nothing Prepare a new directory (directory


happens, processing ends successfully, and A) in advance. It cannot be prepared
Note the completion notification relay turns ON. together withdirectory B.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Storage Instructions".

8-98 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MMKDIR ( DM1000.T, R1000 )
CR3214 @VB01

Execute command
of storage device @VB00
in progress RES

CR3214 CJ
#2000
Execute command of
storage device in progress
FOR

EXTENDED FUNCTIONS
#2

@VB00 MMKDIR
DM1000 R1000

Path name Gernarate result

@VB00 @VB00
SET

NEXT

LABEL 8
#2000

Storage Functions
@VB01 MR1100

● Notification bit data ( D : completion notification, D +1: error notification)

Item Details
Turns OFF when execution of the function starts, and turns ON when the
Completion directory has finished being made.
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.

Point • Several scans are sometimes required for making the directory.
• The notification bit data is written by END processing after the function is executed.
• The storage location when indirect specification is performed or index
modification is specified for the notification bit data is the storage location at the
rising edge of the execution condition.
• The MMKDIR function is not executed while a storage device function is being
executed (CR3214 is ON).
• The function is not executed when any of the following conditions is established:
• When the text string specified by S does not contain the end code (NUL
(00H))
• When the text string specified by S exceeds 247 characters (including
end code "NUL (00H)")
• When a timer/counter is specified to S by indirect specification.
• When a bit other than the start of the channel is specified when bit data is
specified for S .
• This instruction cannot be used in interrupt programs or in the initialization module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-99


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.
Therefore, it is necessary to use special device CR3214 (Storage instruction executing) or result (end
notification) of folder creation process as execution condition and perform exclusive control.

Programmed Script
IF MR1000 AND R5000 THEN
RES ( R5000 )
EXTENDED FUNCTIONS

MR2000 = MMKDIR ( DM1000, R5000 )


END IF
IF MR2000 = OFF THEN
SET ( R5000 )
END IF
Operation Description When MR1000 (DIR make request) is ON, and R5000 is ON (previous DIR make request
8 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)
Storage Functions

stored in DM1000.
The make result is stored in R5000 (notification of DIR make completion this time) and
R5001 (DIR make result notification this time).
When startup of the MMKDIR function fails (MR2000=OFF), R5000 is turned ON to start
up the MMKDIR function again.

8-100 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

Storage Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-101


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MRMDIR

MRMDIR Delete storage device (memory card/CPU memory) directory

Delete storage device directory

Return value*1 = MRMDIR (delete path name, delete result storage destination)
Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
S path name of the directory to delete or
Delete path *2
the deleted directory path name. (A text - - - - - - - .T ○ ○
name*3*5 ○
string in the range 1 to 247 characters
(including end code NUL) is specified.)
Delete result
EXTENDED FUNCTIONS

D
Specifies the destination to notify the
storage - - - - - - .B - - ○ -
delete result.
destination*4
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 To specify a text string using constants, enclose with " ".
*3 When specifying bit data, specify the start of the channel.

8 *4 When bit data is specified, it occupies 2 continuous bits. When word data is specified, the LSB of
each of the 2 continuous words is used as notification bit data. Bits other than the LSB do not
change.
Storage Functions

*5 T, C, CR, CTC, CTH, Z cannot be used.

Point This function cannot be used with KV-N14 □ □/N24 □ □ /N40 □ □ /N60 □ □ . (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The directory with the path name (text string) specified by S is deleted from the memory card or
CPU memory.
The delete result is stored in D .

• When the directory specified by S does not exist in the storage device
[ D +1] will be ON, and 3 is stored in CM2390 (file or directory does not exist).

• When file and directory exist in the directory specified by S


Delete all files and directories existent in the directory, and then delete the specified directory.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Storage Instructions".

8-102 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MRMDIR ( DM1000.T, MR2000 )
CR3214 @VB01

Execute command of
storage device @VB00
in progress RES

CR3214 CJ
#2000
Execute command of
storage device
in progress FOR

EXTENDED FUNCTIONS
#2

@VB00 MRMDIR
DM1000 MR2000

Delete file names Delete


result store
@VB00 @VB00
SET

NEXT

LABEL 8
#2000

Storage Functions
@VB01 MR1100

Return value

● Notification bit storage ( D : completion notification, D +1: error notification)

Item Details
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.

Point • Several scans are sometimes required for deleting the directory.
• The notification bit data is written by END processing after the function is executed.
• The storage location when indirect specification is performed or index
modification is specified for the notification bit data is the storage location at the
rising edge of the function execution.
• The MRMDIR function is not executed while a storage device function is being
executed (CR3214 is ON).
• The function is not executed when any of the following conditions is established:
• When the text string specified by S does not contain the end code (NUL
(00H))
• When the text string specified by S exceeds 247 characters (including
end code "NUL (00H)")
• When a timer/counter is specified to S by indirect specification.
• When a bit other than the start of the channel is specified when bit data is
specified for S .
• This instruction cannot be used in interrupt programs or in the initialization module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-103


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MDEL

MDEL Delete storage device (memory card/CPU memory) file

Delete storage device file

Return value*1 = MDEL (delete file name, delete result storage destination)
Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
S file name to delete or the deleted file
Delete file *2
name. (A text string in the range 1 to - - - - - - - .T ○ ○
name*3*5 ○
247 characters (including end code
NUL) is specified.)
Delete result
EXTENDED FUNCTIONS

D
Specifies the destination to notify the
storage - - - - - - .B - - ○ -
delete result.
destination*4
Turns ON when the function is
R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work relay.
*2 To specify a text string using constants, enclose with " ".
*3 When specifying bit data, specify the start of the channel.

8 *4 When bit data is specified, it occupies 2 continuous bits. When word data is specified, the LSB of
each of the 2 continuous words is used as notification bit data. Bits other than the LSB do not
change.
Storage Functions

*5 T, C, CR, CTC, CTH, Z cannot be used.

Point This function cannot be used with KV-N14 □ □/N24 □ □ /N40 □ □ /N60 □ □ . (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The file with the file name (text string) specified by S is deleted from the memory card or CPU
memory.
The delete result is stored in D .

• When the directory specified by S does not exist in the storage device
[ D +1] will be ON, and 3 is stored in CM2390 (file or directory does not exist).
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Storage Instructions".

8-104 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MDEL ( DM1000.T, MR2000 )
CR3214 @VB01

Execute command of
storage device @VB00
in progress RES

CR3214 CJ
#2000
Execute command of
storage device
in progress FOR

EXTENDED FUNCTIONS
#2

@VB00 MDEL
DM1000 MR2000

Delete file name Delete result


store device store device
@VB00 @VB00
SET

NEXT

LABEL 8
#2000

Storage Functions
@VB01 MR1100

Return value

● Notification bit storage ( D : completion notification, D +1: error notification)

Item Details
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.

Point • Several scans are sometimes required for deleting the directory.
• The notification bit data is written by END processing after the function is executed.
• The storage location when indirect specification is performed or index
modification is specified for the notification bit data is the storage location at the
rising edge of the function execution.
• The MDEL function is not executed while a storage device function is being
executed (CR3214 is ON).
• The function is not executed when any of the following conditions is established:
• When the text string specified by S does not contain the end code (NUL
(00H))
• When the text string specified by S exceeds 247 characters (including
end code "NUL (00H)")
• When a timer/counter is specified to S by indirect specification.
• When a bit other than the start of the channel is specified when bit data is
specified for S .
• This instruction cannot be used in interrupt programs or in the initialization module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-105


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MPRINT

MPRINT Write text to a file in storage device (memory card/CPU memory)

Write text string to storage device

Return value*1 = MPRINT (save file name, write text string, writing result storage
destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the file name
S1 Save file for data saving or the save file name. (A text
.U .S .D .L .F .DF .B .T ○ ○ -
name*2 string in the range 1 to 247 characters
(including end code NUL) is specified.)
EXTENDED FUNCTIONS

S2 Write result Specifies the start that stores the text string
.U .S .D .L .F .DF .B .T ○ ○ -
text string*2 to be written or the text string to be written.
D Writing result Specifies the bit data to notify the
storage destination writing result. - - - - - - .B - - ○ -
Turns ON when the function is
R Return value successfully started up, and turns OFF .U .S .D .L .F .DF - - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
8 *2 When bit data is specified for the write result storage destination, 2 continuous bits are used as
the notification bit.
Storage Functions

*3 To specify a text string using constants, enclose with " ".


*4 When specifying bit data, specify the start of the channel.
*5 T, C, CTC, CTH, Z cannot be used.

Point • The MPRINT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/ 3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The text string specified by S2 is written to the memory card at the end of the file name (text string)
specified by S1 .
When the S1 name does not exist, a new file will be created.
D stores the write completion notification and the error notification of abnormal end.
R is turned ON when the MPRINT function is started normally, and OFF when it fails.

Reference The notification bits of D have the following meanings.


(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

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Storage Instructions".

8-106 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MPRINT ( DM5000.T, DM1000.T, MR2000 )
CR3214 @VB01

Execute command of
@VB00
storage device in progress
RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR
#2

EXTENDED FUNCTIONS
@VB00 MPRINT
DM5000 DM1000 MR2000

Save file name Write text Writing results


@VB00 string @VB00
SET
NEXT

8
LABEL
#2000

@VB01 MR1100

Storage Functions
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-107


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MREADL

Read one line from file in storage device (memory card/CPU


MREADL memory)
Read one line from storage device

Return value*1 = MREADL (read file name, read text string storage destination,
read parameter, read result storage destination)

Supported Type Const Device / For


Argument/Return Value Description
.U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name for data reading or the read *4
S
Read file name*6 file name. (A text string in the range 1 - - - - - - - .T ○ ○

to 247 characters (including end code
NUL and folder name) is specified.)
EXTENDED FUNCTIONS

D1 Read text string


Specifies the start to store the read text
storage - - - - - - - .T - ○ -
*5 string.
destination
D2 Read
Specifies the parameter to read. .U .U .U .U - - - - - ○ -
parameter*2
D3 Read result
Specifies the bit data to notify the read
storage - - - - - - .B - - ○ -
result.
destination*3
Turns ON when the function is
8 R Return value successfully started up, and turns OFF - - - - - - .B -
when startup fails.
- ○ -

*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
Storage Functions

work memory.
*2 The read parameter occupies four continuous words.
*3 The read result storage destination uses 4 continuous bits as notification bits.
*4 To specify a text string using constants, enclose with " ".
*5 When specifying bit data, specify the start of the channel.
*6 T, C, CTC, CTH, Z cannot be used.

Point • The MREADL function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
One line is read from the file name (text string) specified by S to D1 .
(The character codes which express a line are 0DH (CR), 0AH (LF) and 0D0AH (CR+LF).)
The maximum number of bytes in the read characters is set with " D2 +2" (maximum number of read
bytes).
If the length of text data of one line in the file is longer than that specified by " D2 +2", " D3 +3" (no
line feed character notification) is ON, and the text data is stored in D1 up to " D2 +2" bytes.
D3 stores the read completion notification and abnormal end alarm notification.
R is turned ON when the MREADL function is started normally, and OFF when it fails.
"About operation flag (CR2009 to CR2012)", page 1-18
Refer to "MREADL instruction" of "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual" for details on the D2 and D3 parameters.

8-108 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MREADL ( DM5000.T, DM1000.T, EM1000, MR2000 )
CR3214 @VB01

Execute command of
storage device in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR
#2

EXTENDED FUNCTIONS
@VB00 MREADL
DM5000 DM1000 EM1000 MR2000

Read file Read text Read Reading results

@VB00 name string parameter @VB00


SET
NEXT

8
LABEL
#2000

@VB01 MR1100

Storage Functions
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-109


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MCOPY

MCOPY Copy file in storage device (memory card/CPU memory)

Copy storage device file

Return value*1 = MCOPY (copy source file name/folder name, copy destination file
name/folder name, copy format parameter, copy results
storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name / folder name of the copy
S1 Copy source file *4
source or the file name / folder name.
name/folder - - - - - - - .T ○ ○
(A text string in the range 1 to 247
EXTENDED FUNCTIONS


name*5*6
characters (including end code NUL
and folder name) is specified.)
Specifies the storage location for the
S2 file / folder name of the copy
Copy destination *4
destination or the file / folder name. (A
file name/folder - - - - - - - .T ○ -
*5*6 text string in the range 1 to 247 ○
name
characters (including end code NUL
and folder name) is specified.)
S3 Copy format
Specifies the parameter to read. .U .U .U .U - - - -
8 parameter*2 ○ ○ -

D Copy result storage Specifies the bit data to notify the copy
destination*3 result. - - - - - - .B - - ○ -
Storage Functions

Turns ON when the function is


R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 The copy format parameter occupies one word.
*3 The copy result storage device uses two continuous bits as notification bits.
*4 To specify a text string using constants, enclose with " ".
*5 When specifying bit data, specify the start of the channel.
*6 T, C, CTC, CTH, Z cannot be used.

Point • The MCOPY function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The file name (text string) specified by S1 is copied to the file specified by S2 .
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 according to S3 .
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.

D stores the copy completion notification and abnormal end alarm notification.
R is turned ON when the MCOPY function is started normally, and OFF when it fails.
8-110 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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

"About operation flag (CR2009 to CR2012)", page 1-18


Refer to "MCOPY instruction" of "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual" for details on the S3 parameter and D copy result.

● Example of format

EXTENDED FUNCTIONS
MR1100 = MCOPY ( DM5000.T, DM1000.T, EM1000, MR2000 )
CR3214 @VB01

Execute command of
@VB00
storage device in progress
RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR 8
#2

Storage Functions
@VB00 MCOPY
DM5000 DM1000 EM1000 MR2000

Copy source Copy destination Copy format Copy results


file name file name parameter
@VB00 @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100

Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-111


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MMOV

MMOV Move file in storage device (memory card/CPU memory)

Storage device file move

Return value*1 = MMOV (move source file name/folder name, move destination file
name/folder name, move format parameter, move result
storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name / folder name of the move
S1 Move source *4
source or the file name / folder name.
file name/folder - - - - - - - .T ○ ○
(A text string in the range 1 to 247
EXTENDED FUNCTIONS


name*5*6
characters (including end code NUL
and folder name) is specified.)
Specifies the storage location for the
S2 Move file name / folder name of the move
destination file destination or the file name / folder *4
name/folder name. (A text string in the range 1 to - - - - - - - .T ○ -

name*5*6 247 characters (including end code
NUL and folder name) is specified.)
S3 Move format
Specifies the move format parameter. .U .U .U .U - - - -
8 parameter*2 ○ ○ -

D Move result storage Specifies the bit data to notify the move
destination*3 result. - - - - - - .B - - ○ -
Storage Functions

Turns ON when the function is


R Return value successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 The move format parameter occupies one word.
*3 The move result storage device uses two continuous bits as the notification bits.
*4 To specify a text string using constants, enclose with " ".
*5 When specifying bit data, specify the start of the channel.
*6 T, C, CTC, CTH, Z cannot be used.

Point • The MMOV function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/ 3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The file name (text string) specified by S1 is moved to the file specified by S2 .
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 according to S3 .
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.

D stores the move completion notification and abnormal end alarm notification.
R is turned ON when the MMOV function is started normally, and OFF when it fails.
8-112 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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

"About operation flag (CR2009 to CR2012)", page 1-18


Refer to "MMOV instruction" of "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual" for details on the S3 parameter and D move result.

EXTENDED FUNCTIONS
● Example of format
MR1100 = MMOV ( DM5000.T, DM1000.T, EM1000, MR2000 )
CR3214 @VB01

Execute command of
storage device in progress @VB00
RES
CJ

8
CR3214
#2000
Execute command of
storage device in progress FOR

Storage Functions
#2

@VB00 MMOV
DM5000 DM1000 EM1000 MR2000

Move source Move destination Move format Move results


file name file name parameter
@VB00 @VB00
SET
NEXT

LABEL
#2000

@VB01 MR1100

Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-113


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MREN

MREN Rename file in storage device (memory card/CPU memory)

Storage device file rename

Return value*1 = MREN (file name/folder name to be renamed, new file name/folder
name, file name rename result storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
file name / folder name to be renamed
S1 File name/folder *3
or the file name / folder name. (A text
name to be - - - - - - - .T ○ ○
string in the range 1 to 247 characters ○
renamed*4*5
(including end code NUL and folder
EXTENDED FUNCTIONS

name) is specified.)
Specifies the storage location for the
S2 new file / folder name or the file / folder *3
New file name/
name. (A text string in the range 1 to - - - - - - - .T ○ ○
folder name*4*5 ○
247 characters (including end code
NUL and folder name) is specified.)
D File name
rename result Specifies the bit data to notify the file
storage name rename result. - - - - - - .B - - ○ -
destination*2
8 R Return value
Turns ON when the function is
successfully started up, and turns OFF - - - - - - .B - - ○ -
when startup fails.
Storage Functions

*1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 The move result storage device uses two continuous bits as the notification bits.
*3 To specify a text string using constants, enclose with " ".
*4 When specifying bit data, specify the start of the channel.
*5 T, C, CTC, CTH, Z cannot be used.

Point • The MREN function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/ 3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The file name / folder name (text string) specified by S1 is renamed to the file name / folder name
specified by S2 .
D stores the rename completion notification and abnormal end alarm notification.
R is turned ON when the MREN function is started normally, and OFF when it fails.
"About operation flag (CR2009 to CR2012)", page 1-18
Refer to "MREN instruction" of "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual" for details on the operation.

8-114 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MREN ( DM5000.T, DM1000.T, MR2000 )
CR3214 @VB01

Execute command of
storage device in progress @VB00
RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR
#2

EXTENDED FUNCTIONS
@VB00 MREN
DM5000 DM1000 MR2000

File name New file Rename


to rename name results
@VB00 @VB00
SET
NEXT

LABEL
#2000
8

Storage Functions
@VB01 MR1100

Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-115


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
MSTAT

MSTAT Get status of file in storage device (memory card/CPU memory)

Get storage device file status

Return value*1 = MSTAT (file name, file status storage destination, retrieved result
storage destination)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the storage location for the
name of the file for which the status is
retrieved or the file name. (A text string *3
S1 File name*5 - - - - - - - .T ○ ○
in the range 1 to 247 characters ○
EXTENDED FUNCTIONS

(including end code NUL and folder


name) is specified.)
D1 File status
Specifies the destination to store the
storage .U .U .U .U - - - - - ○ -
file status.
destination*4
D2 Retrieved result
Specifies the bit data to notify the
storage - - - - - - .B - - ○ -
retrieved result.
destination*2
R Return value .U type SEG function available - - - - - - .B - - ○ -

8 *1 The return value can be omitted. When omitted, the operation result is stored in a work device /
work memory.
*2 The read result storage destination uses 3 continuous bits as notification bits.
Storage Functions

*3 To specify a text string using constants, enclose with " ".


*4 The file status storage destination occupies 10 continuous words.
*5 T, C, CTC, CTH, Z cannot be used.

Point • The MSTAT function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/ 3000 Series CPU unit with CPU function version 2.0 or higher, or KV-NC32T.
"KV-5500/5000/3000 CPU Function Version", page 4
• This function cannot be used with KV-N14□□/N24□□/N40□□/N60□□. (A
conversion error will not occur in KV STUDIO, only a warning is displayed).

Description of Operation
The status of the file specified by S is retrieved and stored in D1 .
D2 stores the retrieval completion notification, abnormal end alarm notification and presence of the
file.
R is turned ON when the MSTAT function is started normally, and OFF when it fails.
"About operation flag (CR2009 to CR2012)", page 1-18
For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "MSTAT instruction".

8-116 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


● Example of format
MR1100 = MSTAT ( DM5000.T, EM1000, MR2000 )
CR3214 @VB01

Execute command of
@VB00
storage device in progress
RES

CR3214 CJ
#2000
Execute command of
storage device in progress FOR
#2

EXTENDED FUNCTIONS
@VB00 MSTAT
DM5000 EM1000 MR2000

File name File status Retrieved results


storage device storage
@VB00 device @VB00
SET
NEXT

8
LABEL
#2000

@VB01 MR1100

Storage Functions
Return value

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-117


Ac

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


AWNUM

AWNUM Display access window message 1

Display user message 1

AWNUM ( display switching, AW write data)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Display Specifies display switching of the
S1
switching access window. - - - - - - .B - - ○ ○
Specifies the destination to store the
S2 AW value displayed as user message 1 in
.U .U .U .U - - - - ○ ○ ○
write data*1 the access window, or the user
message 1 data.
EXTENDED FUNCTIONS

R Return value None - - - - - - - - - - -


*1 When bit data is specified, it occupies 16 continuous bits. 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.

Point There is no access window in KV-NC32T. If the expansion access window cassette
is not connected with the KV-NC32T or KV Nano Series, an error will not occur and

8 the function will not execute. (A conversion error will not occur in KV STUDIO).
Access Window Functions

Description of Operation
When S1 is ON, the value specified by S2 is displayed as the user message 1 in the access
window.
When S1 is OFF, the display of user message 1 is canceled.

● Example of format
AWNUM ( R3000, DM1000 )
CR2002 MOV
DM1000 CM1720
Always ON
User message 1
R3000 CR2900
SET
User message 1
display
R3000 CR2900
RES
User message 1
display

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Access Window Instructions".

Reference When user messages 1 and 2 are displayed simultaneously, user message 1 is given
priority and displayed.

For details on user message display, see "KV-5500/5000/3000 Series User's Manual".

8-118 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • When display switching is ON, CR2900 is set, and when it is OFF, CR2900 is
reset. In addition, the value of S2 is copied to CM01720 at all times when the
display switching is ON, and the result is reflected immediately in the access
window.
• If the value of S2 is changed when display switching is ON, the display
content of user message 1 is also changed.
• If the access window is operated even when display switching is ON, the
message display is canceled (CR2900 is also reset at this time).
If the AWNUM function is called again, CR2900 turns ON.

EXTENDED FUNCTIONS
• When a project contains multiple AWNUM functions, the state of the access
window conforms to the last executed AWNUM function.
• This instruction cannot be used in interrupt programs or in the initialization
module.

Access Window Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-119


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
AWMSG

AWMSG Display access window message 2

Display user message 2

AWMSG (display switching, AW write data)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Display Specifies display switching of the
S1
switching access window. - - - - - - .B - - ○ ○
Specifies the destination to store the
S2 AW text string data to be displayed as user
write data*1*2 message 2 in the access window, or - - - - - - - .T ○ ○ ○
the user message 2 data.
EXTENDED FUNCTIONS

R Return value None - - - - - - - - - - -


*1 The maximum number of characters in a text string that can be displayed in the access window is
24.
• Text string constants enclosed by double quotation marks can be specified.
• When using bit data, it is necessary to specify the start of the channel.
*2 T, C, CR, CTC, CTH, Z cannot be used.

8 Point There is no access window in KV-NC32T. If the expansion access window cassette
is not connected with the KV-NC32T or KV Nano Series, an error will not occur and
the function will not execute. (A conversion error will not occur in KV STUDIO).
Access Window Functions

Description of Operation
When S1 is ON, the value specified by S2 is displayed as the user message 2 in the access
window.
When S1 is OFF, the display of user message 2 is canceled.

● Example of format
AWMSG ( R3000, DM1000.T )
CR2002 SMOV
DM1000 CM1721
Always ON
User message 2-1
R3000 CR2901
SET
User message 2
display
R3000 CR2901
RES
User message 2
display

"About operation flag (CR2009 to CR2012)", page 1-18


For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Access Window Instructions".

Reference When user messages 1 and 2 are displayed simultaneously, user message 1 is given
priority and displayed.

For details on user message display, see "KV-5500/5000/3000 Series User's Manual".

8-120 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Point • The access window of KV-5500/5000/3000/1000 and KV Nano Series cannot display
2- byte characters.
• When display switching is ON, CR2901 is set, and when it is OFF, CR2901 is
reset. In addition, the value of S2 is copied to CM01721 to CM01737 at all
times when the display switching of the previously stored text string is ON, and
the result is reflected immediately in the access window.
• If the text string stored initially in S2 is changed when display switching is
ON, the display content of user message 2 is also changed.
• If the access window is operated even when display switching is ON, the

EXTENDED FUNCTIONS
message display is canceled (CR2901 is also reset at this time).
If the AWMSG function is called again, CR2900 turns ON.
• When a project contains multiple AWMSG functions, the state of the access
window conforms to the last executed AWMSG function.
• The text strings that can be displayed in the access window are only 1-byte
characters (ASCII codes 20h to 7Eh, A1h to DFh) in 24 characters from the text
string currently stored starting from S2 . 2-byte characters such as Chinese
characters cannot be displayed.
• This instruction cannot be used in interrupt programs or in the initialization 8
module.

Access Window Functions


• The function is not executed when any of the following conditions is established:
• When a bit other than the start of the channel is specified when bit data is
specified for S2 .
• When a timer/counter is specified to S2 by indirect specification.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-121


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano※
AWSHOW

AWSHOW User message display

User message display

AWSHOW (Execution condition, displayed user message ID)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
When execution conditions are turned
Execution
S1 from OFF to ON, the user message is - - - - - - .B - - ○ ○
condition
displayed in the access window.
Specifies the user message ID
S2 Displayed user
displayed in the access window. (1 to .U .U .U .U - - - - ○ ○ ○
message ID
63)
EXTENDED FUNCTIONS

R Return value None - - - - - - - - - - -

Description of Operation
When S1 turns from OFF to ON, the user message specified by S2 is displayed.

Reference To remove user message display, operate the access window or execute the AWHIDE
command.
8 "About operation flag (CR2009 to CR2012)", page 1-18
For details, see "KV-8000/7000/5000/3000/1000 Series / KV Nano Series Instruction Reference
Access Window Functions

Manual", "Access Window Instructions", the User's Manual of the CPU unit used, or "User Message".

Point • When the execution condition is ON, the S2 value does not change even if
altered.
• CR is set for user message of ID designated at the rising edge of executions
conditions.
• If the AWSHOW function and the AWHIDE function are executed simultaneously,
follow operation of the function executed last.
• If there are multiple AWSHOW functions in a project, the state of the access
window follows the first AWSHOW function that is executed.
• This instruction cannot be used in interrupt programs or in the initialization
module.

8-122 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
AWHIDE

AWHIDE Hide user message

Hide user message

AWHIDE (Execution condition, user message ID to be hidden)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
When execution conditions are turned
Execution
S1 from OFF to ON, user message display - - - - - - .B - - ○ ○
condition
is hidden from access window.
S2 User message Specifies the user message ID to be
.U .U .U .U - - - - ○ ○ ○
ID to be hidden hidden. (1 to 63)

EXTENDED FUNCTIONS
R Return value None - - - - - - - - - - -

Description of Operation
When S1 turns from OFF to ON, the user message specified by S2 is hidden.

"About operation flag (CR2009 to CR2012)", page 1-18


For details, see "KV-8000/7000/5000/3000/1000 Series / KV Nano Series Instruction Reference
Manual", "Access Window Instructions", the User's Manual of the CPU unit used, or "User Message".
8
Point • When the execution condition is ON, the S2 value does not change even if

Access Window Functions


altered.
• CR is set for user message of ID designated at the start of executions conditions.
• If the AWSHOW function and the AWHIDE function are executed simultaneously,
follow operation of the function executed last.
• This instruction cannot be used in interrupt programs or in the initialization
module.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-123


FR

KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano


RFSFRC

RFSFRC FREE RUN counter refresh

FREE RUN counter refresh

RFSFRC ([execution condition,]*1)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
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

Description of Operation
When the execution condition is established (TRUE), FREE RUN counter is refreshed to the latest
value.
The updated free run counters are as follows.
KV-8000/7500/7300 CM1030 to CM1031: 1ms counter
CM1032 to CM1033: 10us counter
CM1034 to CM1035: 1us counter
8 CM1036 to CM1037: 0.1us counter
KV-5500/5000/3000, KV Nano CM708 to CM709: 1ms counter
FREE RUN Counter Functions

For details, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "FREE RUN instruction".

● Example of format
RFSFRC ( MR1000 )
MR1000 RFSFRC

Execution condition

8-124 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


MEMO

EXTENDED FUNCTIONS
8

FREE RUN Counter Functions

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-125


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano Se

SPRD

SPRD Read sensor parameter

SPRD (execution condition, unit number, node address, slot number,


parameter number, completion code)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Execution Specifies the bit data to be used for the
S
condition execution condition. - - - - - - .B - - ○
Specifies a unit number (0 to 48, KV-
n1 Unit number*1 - - - - - - - - ○ - ○
8000/7500/5500 is "0").
Specifies the node address (1 to 256)
EXTENDED FUNCTIONS

n2 Node address*3 .U .U .U .U - - - - ○ ○ ○
or storage location
Specifies the slot number or the
n3 Slot number*3 .U .U .U .U - - - - ○ ○ ○
storage destination for the slot number.
Specifies the parameter number or the
Parameter
storage destination for the parameter .U .U .U .U - - - - ○ ○ ○
n4
number*3
number.
Specifies the start of the device to store
Completion
the completion code or parameter read .U .U .U .U .F .DF .B .T - ○ -
D
code*2*4*5
result.

8 R
*1
Return value None - - - - - - - -
$ (HEX specification) cannot be used. The range for KV Nano Series unit numbers is 0 to 15.
- - -
Sensor Setting Function

*2 CTC, CTH, Z cannot be used.


*3 When bit data is specified, 16 continuous bits are processed. 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.
*4 When specifying bit data, specify the start of the channel.
*5 The number of stored words (four words or more) differs according to the execution conditions.

Point • The SPRD function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV Nano
Series basic unit.
"KV-5500/5000/3000 CPU Function Version", page 4
"KV Nano Series CPU Function Version", page 4

Description of Operation
When S is ON, the parameter specified in the sensor n4 of the node address n2 and slot
number n3 connected to the n1 unit is read. Upon completion, the completion bit is stored in bit
0 of D , the execution failure bit in bit 1 of D , the completion code in D +1, the detailed
completion code in D +2, the number of array elements in D +3 (1 if not an array), and the
contents of the parameters read in D +4 onward.

8-126 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D ~: Execution result storage location

Result storage location Details


This device turns OFF when execution of the instruction starts,
Completion and turns ON when reading of the parameter is finished. This
Bit 0
bit device turns ON regardless of whether the instruction ends
normally or abnormally.
D If execution of the instruction fails, this device turns ON
Execution
Bit 1 simultaneously with the completion bit.
failed bit
This device turns OFF when execution of the instruction starts.
Reserved for

EXTENDED FUNCTIONS
Bits 2 to 15 OFF (fixed value)
system
The completion code is stored when reading of the parameters
D +1 Completion code is completed.
(0 when normal)
The detailed completion code is stored when reading of the
D +2 Detailed completion code
parameters is completed.
The number of array elements in the read parameter is stored.
D +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 +4~ Read results


The parameter value is stored. The number of data items
occupied differs according to the read parameter.
8

Sensor Setting Function


Point The execution will fail if an "EtherNet/IP device reserved" sensor is specified.

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 completion bit and failure bit of the result storage location are turned ON at the completion and
turned OFF at the start of execution.
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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Sensor Setting Instructions".

● 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
MR000 SPRD
#1 #1 #1

#805 DM0

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-127


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
PWR

SPWR Sensor parameter write

SPWR (execution condition, unit number, node address, slot number,


parameter number, completion code)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Execution Specifies the bit data to be used for the
S
condition execution condition. - - - - - - .B - - ○
Specifies a unit number (0 to 48, KV-
n1 Unit number*1 - - - - - - - - ○ - ○
8000/7500/5500 is "0").
Specifies the node address (1 to 256)
EXTENDED FUNCTIONS

n2 Node address*3 .U .U .U .U - - - - ○ ○ ○
or storage location
Specifies the slot number or the
n3 Slot number*3 .U .U .U .U - - - - ○ ○ ○
storage destination for the slot number.
Specifies the parameter number or the
Parameter
storage destination for the parameter .U .U .U .U - - - - ○ ○ ○
n4
number*3
number.
Specifies the start of the device to store
Completion
the completion code or parameter read .U .U .U .U .F .DF .B .T - ○ -
D
code*2*4*5
result.

8 R
*1
Return value None - - - - - - - -
$ (HEX specification) cannot be used. The range for KV Nano Series unit numbers is 0 to 15.
- - -
Sensor Setting Function

*2 CTC, CTH, Z cannot be used.


*3 When bit data is specified, 16 continuous bits are processed. 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.
*4 When specifying bit data, specify the start of the channel.
*5 The number of stored words (four words or more) differs according to the execution conditions.

Point • The SPWR function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV Nano
Series basic unit.
"KV-5500/5000/3000 CPU Function Version", page 4
"KV Nano Series CPU Function Version", page 4

Description of Operation
When S is ON, the setting value specified in D +4 onward is written into the parameter specified
in the sensor n4 of the node address n2 and slot number n3 connected to the n1 unit.
Upon completion, the completion bit is stored in bit 0 of D , the execution failure bit in bit 1 of D ,
the completion code in D +1,and the detailed completion code in D +2.

8-128 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D ~: Execution result storage location

Result storage location Details


This device turns OFF when execution of the instruction starts,
Completion and turns ON when writing of the parameter is finished. This
Bit 0
bit device turns ON regardless of whether the instruction ends
normally or abnormally.
D If execution of the instruction fails, this device turns ON
Execution
Bit 1 simultaneously with the completion bit.
failed bit
This device turns OFF when execution of the instruction starts.
Reserved for

EXTENDED FUNCTIONS
Bits 2 to 15 OFF (fixed value)
system
The completion code is stored when writing of the parameter
D +1 Completion code is completed.
(0 when normal)
The detailed completion code is stored when writing of the
D +2 Detailed completion code
parameter is completed.
D +3 Reserved for system 0 (fixed value
The setting value is stored. The number of data items
D +4~ Setting value
occupied differs according to the write parameter.
8
Point The execution will fail if an "EtherNet/IP device reserved" sensor is specified.

Sensor Setting Function


If the sensor parameter write 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 completion bit and failure bit of the result storage location are turned ON at the completion and
turned OFF at the start of execution.
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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Sensor Setting Instructions".

● 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
MR000 SPWR
#1 #1 #1

#833 DM0

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-129


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
SSVC

SSVC Sensor service execution

SSVC (execution condition, unit number, node address, slot number,


parameter number, completion code)

Argument/Return Supported Type Const Device / For


Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Execution Specifies the bit data to be used for the
S
condition execution condition. - - - - - - .B - - ○
Specifies a unit number (0 to 48, KV-
n1 Unit number*1 - - - - - - - - ○ - ○
8000/7500/5500 is "0").
Specifies the node address (1 to 256)
EXTENDED FUNCTIONS

n2 Node address*3 .U .U .U .U - - - - ○ ○ ○
or storage location
Specifies the slot number or the
n3 Slot number*3 .U .U .U .U - - - - ○ ○ ○
storage destination for the slot number.
Specifies the parameter number or the
Parameter
storage destination for the parameter .U .U .U .U - - - - ○ ○ ○
n4
number*3
number.
Specifies the start of the device to store
Completion
the completion code or parameter read .U .U .U .U .F .DF .B .T - ○ -
D
code*2*4*5
result.

8 R
*1
Return value None
$ (HEX specification) cannot be used.
- - - - - - - - - - -
Sensor Setting Function

*2 CTC, CTH, Z cannot be used.


*3 When bit data is specified, 16 continuous bits are processed. 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.
*4 When specifying bit data, specify the start of the channel.
*5 Up to six words are used depending on the specified service.

Point • The SSVC function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV Nano
Series basic unit.
"KV-5500/5000/3000 CPU Function Version", page 4
"KV Nano Series CPU Function Version", page 4

Description of Operation
S When the execution condition is ON, the service specified with the sensor n4 of the node
address n2 and slot No. n3 connected to the n1 unit is executed. Upon completion, the
completion bit is stored 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-130 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


D ~: Execution result storage location

Result storage location Details


This device turns OFF when execution of the instruction starts,
Completion and turns ON when execution of the service is finished. This
Bit 0
bit device turns ON regardless of whether the instruction ends
normally or abnormally.
D If execution of the instruction fails, this device turns ON
Execution
Bit 1 simultaneously with the completion bit.
failed bit
This device turns OFF when execution of the instruction starts.
Reserved for

EXTENDED FUNCTIONS
Bits 2 to 15 OFF (fixed value)
system
The completion code is stored when execution of the service is
D +1 Completion code
completed. (0 when normal)
The detailed completion code is stored when execution of the
D +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
Send data
D +5 the service being executed.

Point The execution will fail if an "EtherNet/IP device reserved" sensor is specified. 8

Sensor Setting Function


If the sensor service 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 completion bit and failure bit of the result storage location are turned ON at the completion and
turned OFF at the start of execution.
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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series Instruction
Reference Manual", "Sensor Setting Instructions".

● 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
MR000 SSVC
#1 #2 #3

#1 DM0

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-131


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano Cy

RFSCI

RFSCI Refresh cyclic communication input

RFSCI ([execution condition,]*1 start, number of data items)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the start to refresh the cyclic
S Start*2 .U .S .D .L .F - - - - ○ -
communication input data.
Number of data Specifies the number of data items to
n .U .U .U .U - - - - ○ - -
items refresh.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
EXTENDED FUNCTIONS

at all times (at every scan).)


*2 When specifying bit data, specify the start of the channel.

Point • The RFSCI function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV Nano
Series basic unit.
"KV-5500/5000/3000 CPU Function Version", page 4
8 "KV Nano Series CPU Function Version", page 4
Cyclic Communication Refresh Function

Description of Operation
When the execution condition is ON, the cyclic communication input data from the data assigned in
S to the number of data items specified by n is refreshed. (When the start is 32-bit data, the
number of refreshed words is the number of data × 2.)
• S : When the start is 16 bits (.U/.S)
Example) When the start is specified as DM102 (.U) and the number of data is specified as 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
DM105 Leading word+5
range is refreshed.
• S : When the start is 32 bits (.D/.L/.F)
Example) When the start is specified as DM102.D and the number of data is specified as 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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Cyclic Communication Refresh Instructions".

8-132 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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 RFSCI
MR000
DM100 #10

EXTENDED FUNCTIONS
8

Cyclic Communication Refresh Function

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-133


KV-8000 KV-7500/7300 KV-5500/5000/3000 KV-1000 KV Nano
RFSCO

RFSCO Refresh cyclic communication output

RFSCO ([execution condition,]*1 start, number of data items)


Argument/Return Supported Type Const Device / For
Description
Value .U .S .D .L .F .DF .B .T #/$ Variable mula
Specifies the start to refresh the cyclic
S Start*2 .U .S .D .L .F - - - - ○ -
communication output data.
Number of data Specifies the number of data items to
n .U .U .U .U - - - - ○ - -
items refresh.
R Return value None - - - - - - - - - - -
*1 "[ ]" can be omitted. (When the execution condition has been omitted, the instruction is executed
EXTENDED FUNCTIONS

at all times (at every scan).)


*2 When specifying bit data, specify the start of the channel.

Point • The RFSCO function can be used only with KV STUDIO Ver. 6.00 or higher.
• This function can be specified only with KV-8000/7000 Series CPU unit, KV-5500/
5000/3000 Series CPU unit with CPU function version 2.0 or higher, or KV Nano
Series basic unit.
"KV-5500/5000/3000 CPU Function Version", page 4
8 "KV Nano Series CPU Function Version", page 4
Cyclic Communication Refresh Function

Description of Operation
When the execution condition is ON, the cyclic communication output data from the data assigned in
D to the number of data items specified by n is refreshed. (When the start is 32-bit data, the
number of refreshed words is the number of data × 2.)
• D : When the start is 16 bits (.U/.S)
Example) When the start is specified as DM102 (.U) and the number of data is specified as 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
DM105 Leading word+5
range is refreshed.
• D : When the start is 32 bits (.D/.L/.F)
Example) When the start is specified as DM102.D and the number of data is specified as 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, please refer to "KV-8000/7000/5000/3000/1000 Series and KV Nano Series
Instruction Reference Manual", "Cyclic Communication Refresh Instructions".

8-134 - KV-8000/7000/5000/3000/1000 Series and KV Nano 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-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - 8-135


MEMO
EXTENDED FUNCTIONS

8
Cyclic Communication Refresh Function

8-136 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


APPENDICES

APPENDICES
CR/CM List ······················································· A-2
ASCII Code Table············································· A-53
List of Characters That Cannot Be Used ··············· A-54
List of Unusable Functions ································· A-58
Index ····························································· A-59
Functions Index ··············································· A-63

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-1


CR/CM List

Control Relays (CR) (For KV-8000)

Control relays (CR0000 - CR7915) can be used to perform operations such as checking the operation
status of the CPU unit and setting and monitoring the built-in functions.
Control relays reserved for the system cannot be used.
Attribute
CR R: Read only Function
Blank: Read/write
Logging and tracing execution (ON: enabled, OFF:
CR0000
disabled)
CR0001 R Logging or tracing operation in progress
CR0002 R Logging or tracing file writing completion
CR0003 R Logging buffer less than 50% warning
CR0004 R Logging buffer overflow
Data to be written in RUN mode during logging
CR0005 R
present
CR0006 and Logging or tracing function
− Reserved for the system
CR0007 (ID0)
CR0008 R Logging or tracing error
APPENDICES

CR0009 R Logging trace No memory space error


CR0010 R Logging or tracing device or trigger setting error
CR0011 R Tracing file save trigger monitor
CR0012 R Tracing data capture completion
CR0013 R Logging or tracing setting to be written present
CR0014 and
− Reserved for the system
CR0015
CR0100 to CR0915 Logging or tracing function (ID1 to ID9)
CR/CM List

CR1000 to CR1015 Real-time chart monitor (ID10)


CR1100 to CR2001 − Reserved for the system
CR2002 R Always turned ON
CR2003 R Always turned OFF
CR2004 R 10 ms clock pulse (duty cycle: 50%)
CR2005 R 100 ms clock pulse (duty cycle: 50%)
CR2006 R 1 s clock pulse (duty cycle: 50%)
CR2007 R Turned OFF for just one scan when operation starts
CR2008 R Turned ON for just one scan when operation starts
CR2009 Turned ON when the calculation result is negative or when an overflow occurs
CR2010 R Turned ON when the calculation result is zero
CR2011 R Turned ON when the calculation result is positive
CR2012 R Turned ON when a calculation execution error occurs
CR2013 to CR2302 − Reserved for the system
CR2303 Fixed scan time operation (ON: enabled, OFF: disabled)
Turned ON for just one scan when the scan time setting (the fixed scan time operation
CR2304 R
and END processing time settings) is exceeded
CR2305 − Reserved for the system
CR2306 R Indicates backup battery errors (ON: error, OFF: normal)
CR2307 Clears the minimum and maximum scan time values
Sets the END processing time (ON: enabled, OFF: disabled; if CR2303 is turned
CR2308
ON at the same time, CR2303 is given priority)
CR2309 and
− Reserved for the system
CR2310
CR2311 R Indicates RTC low voltage error (ON: error has occurred, OFF: normal)
CR2312 − Reserved for the system
CR2313 Forces switch of the VT sensor application screen (ON: switch, OFF: do not switch)
Project password authentication status (ON: authentication disabled, OFF:
CR2314 R
authentication enabled)
CR2315 to CR2813 − Reserved for the system

A-2 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
Zero suppression during execution of DASC and FASC instructions (all suffixes;
CR2814
ON: execute, OFF: do not execute)
Omission of "+" during execution of DASC.S, DASC.L, and FASC instructions (ON:
CR2815
execute, OFF: do not execute)
CR2900 to CR3005 − Reserved for the system
CR3100 R Inter-unit synchronization refreshing time exceeded
CR3101 to CR3115 − Reserved for the system
CR3200 CPU memory save save request
CR3201 R CPU memory save being performed
CR3202 R CPU memory save complete
CR3203 R CPU memory save error
CR3204 to CR3206 − Reserved for the system
Instruction RAM mode operation
CR3207 The RAM mode activation of file register instructions, storage device instructions
towards the CPU memory. (ON: enable, OFF: disable)
CR3208 to CR3209 − Reserved for the system
CR3210 R Arbitrary logging/trace operation

APPENDICES
CR3211 to CR3213 Reserved for the system

CR3214 R Storage instruction executing


CR3215 − Reserved for the system
CR3300 to CR3415 Alarm relay
CR3500 R Alarm operation relay (ON: one of CR3300 to CR3415 is turned ON)
Record an entry in the log when an alarm relay switches from ON to OFF (ON:
CR3501
record, OFF: do not record)
CR3502 The alarm relay log is cleared when this switches from OFF to ON
CR3503 to CR3512 Reserved for the system

CR/CM List

CR3513 R Logging internal buffer overflow
CR3514 HKEY instruction - Disables multiple keys
CR3515 R HKEY instruction - Scan completion
CR3600 to CR3615 R HKEY information storage area
CR3700 to CR3901 − Reserved for the system
CR3902 R Indicates that the serious error log is full
CR3903 R Indicates that the minor error log is full
CR3904 R RUN-PRG selector switch status (ON: RUN, OFF: PROG)
CR3905 R A serious error has occurred
CR3906 R A minor error has occurred
CR3907 to CR3908 − Reserved for the system
CR3909 Clears the current error (Set this relay in the ladder program)
CR3910 Clear all error and event history when OFF→ON
CR3911 to CR4000 − Reserved for the system
CR4001 to CR4300 R Expansion unit status (expansion units 1 - 48)
CR4301 to CR4315 − Reserved for the system
CR4400 R AW up key being pressed
CR4401 R AW down key being pressed
CR4402 R AW left key being pressed
CR4403 R AW right key being pressed
CR4404 R AW MENU key being pressed
CR4405 R AW ENT key being pressed
CR4406 to CR4414 − Reserved for the system
CR4415 R AW user message being displayed
CR4500 AW line 1 blinking
CR4501 AW line 2 blinking
CR4502 AW line 3 blinking
CR4503 AW line 4 blinking

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-3


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR4504 to CR4600 − Reserved for the system
CR4601 to CR4915 AW user message 1 to 63
CR5000 to CR5315 − Reserved for the system
CR5400 Memory card mount request
CR5401 Memory card unmount request
CR5402 R Memory card used
CR5403 R Memory card recognized
CR5404 R Memory card is available
CR5405 R Memory card is write protected
CR5406 to CR5407 − Reserved for the system
CR5408 CPU memory mount request
CR5409 CPU memory unmount request
CR5410 R CPU memory used
CR5411 R CPU memory recognized
CR5412 to CR4915 − Reserved for the system
CR5500 Project load execution request
CR5501 Reserved for the system
APPENDICES


CR5502 Project save execution request
CR5503 − Reserved for the system
CR5504 R Project load execution complete
CR5505 R Project load execution failure
CR5506 R Project save execution complete
CR5507 R Project save execution failure
CR5508 Recipe loading request
CR5509 − Reserved for the system
CR/CM List

CR5510 R Recipe loading completed


CR5511 R Recipe loading failed
CR5512 Recipe saving request
CR5513 − Reserved for the system
CR5514 R Recipe saving completed
CR5515 R Recipe saving failed
CR5600 Operation record 0 Save request
CR5601 R Operation record 0 Operating
CR5602 R Operation record 0 Save trigger monitor
CR5603 R Operation record 0 Saving
CR5604 R Operation record 0 Collecting
CR5605 R Operation record 0 Setting error
Operation record
CR5606 − Reserved for the system
function(ID0)
DR5607 R Operation record 0 Save completed
CR5608 R Operation record 0 Save error
CR5609 R Device record 0 Buffer shortage
CR5610 to CR5613 − Reserved for the system
CR5614 Operation record 0 Buffer area full save mode
CR5615 − Reserved for the system
CR5700 to CR5919 Operation record function(ID1 to ID3)
CR6000 to CR7915 Reserved for the system

A-4 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Control Memory Entries CM (For KV-8000)

Control memory entries (CM0000 - CM7599) can be used to perform operations such as checking the
operation status of the CPU unit and setting and monitoring the built-in functions.
Control memory entries reserved for the system cannot be used.
Attribute
Hold
CM R: Read only Function
Yes: Hold
Blank: Read/write
CM0000 and
− Reserved for the system
CM0699
CM0700 R Read from RTC (year)
CM0701 R Read from RTC (month)
CM0702 R Read from RTC (day)
CM0703 R Read from RTC (hour)
CM0704 R Read from RTC (minute)
CM0705 R Read from RTC (second)
CM0706 R Read from RTC (day of the week)
CM0707 to CM709 − Reserved for the system
CM0710 R File register current bank number

APPENDICES
CM0711 − Reserved for the system
CM0712 R Computing error detailed information
CM0713 to CM0899 − Reserved for the system
CM900 R CPU function version
CM901 to CM906 − Reserved for the system
CM907 R Project Version
CM908 to CM999 − Reserved for the system
CM1000 to CM1001 R Scan time measuring value (1 μs) (32-bit)
CM1002 to CM1003 R END processing time measured value (1 μs unit) (32-bit)

CR/CM List
CM1004 to CM1005 R Minimum fixed scanning time (1 μs unit) (32-bit)
CM1006 to CM1007 R Maximum fixed scanning time (1 μs unit) (32-bit)
CM1008 to CM1009 Fixed scanning time run set value (1 μs unit) (32-bit)
CM1010 to CM1011 END processing time set value (1 μs unit) (32-bit)
CM1012 to CM1013 R Scanning time when setting is exceeded (1 μs unit) (32-bit)
CM1014 to CM1015 R END processing time exceeds value (1 μs unit) (32-bit)
CM1016 to CM1029 − Reserved for the system
CM1030 to CM1031 R 32-bit 1 ms Free Run counter
CM1032 to CM1033 R 32-bit 10 μs Free Run counter
CM1034 to CM1035 R 32-bit 1 μs Free Run counter
CM1036 to CM1037 R 32-bit 0.1 μs Free Run counter
CM1038 to CM1499 − Reserved for the system
CM1500 to CM1509 R Log/trace (ID0 to ID9) File Save Counter
CM1510 to CM1629 − Reserved for the system
CM1630 to CM1639 R Log/trace Ring Buffer minimum free space (ID0 to ID9) (KBytes)
CM1640 to CM1649 − Reserved for the system
CM1650 R Number of sensor setting instruction executions
CM1651 to CM1657 − Reserved for the system
CM1658 R Number of consecutive project password authentication failures Yes
CM1659 R Total number of project password authentication failures Yes
CM1660 to CM1669 R Logging, trace ring buffer free capacity (ID0 - ID9) (in kbyte units)
CM1670 to CM1679 − Reserved for the system
CM1680 to CM1689 R Log/trace File Save Counter (ID0 to ID9) (Memory card use) Yes
CM1690 to CM1699 − Reserved for the system
CM1700 to CM1701 Digital trimmer 0 upper limit (32-bit)
CM1702 to CM1703 Digital trimmer 1 upper limit (32-bit)
CM1704 to CM1705 Digital trimmer 2 upper limit (32-bit)
CM1706 to CM1707 Digital trimmer 3 upper limit (32-bit)
CM1708 to CM1709 Digital trimmer 4 upper limit (32-bit)
CM1710 to CM1711 Digital trimmer 5 upper limit (32-bit)
CM1712 to CM1713 Digital trimmer 6 upper limit (32-bit)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-5


CR/CM List

Attribute
Hold
CM R: Read only Function
Yes: Hold
Blank: Read/write
CM1714 to CM1715 Digital trimmer 7 upper limit (32-bit)
CM1716 to CM1719 − Reserved for the system
CM1720 R AW user message display number
CM1721 to CM1735 − Reserved for the system
CM1736 AW initial display language setting
CM1737 AW initial display comment number setting
CM1738 Access window operation disabled setting
CM1739 − Reserved for the system
CM1740 to CM1772 R Ladder project name (up to 32 characters + end code)
CM1773 to CM1779 − Reserved for the system
CM1780 Access window initial screen setting, enabled
CM1781 Access window initial screen setting, device type
CM1782 Access window initial screen setting, screen ID
CM1783 Access window initial screen setting, screen ID
CM1784 Access window initial screen setting, device number
CM1785 Access window initial screen setting, device number
CM1786 Access window initial screen setting, display format
CM1787 Access window initial screen setting, device name representation
APPENDICES

CM1788 Access window initial screen setting, key lock status


CM1789 − Reserved for the system
CM1790 Automatic loading folder number (request)
CM1791 R Automatic loading complete code
CM1792 R Automatic loading folder number (complete)
CM1793 − Reserved for the system
CM1794 Run load folder number (request)
CM1795 R Run load complete code
CR/CM List

CM1796 R Run load folder number (complete)


CM1797 to CM1868 − Reserved for the system
CM1869 R Number of connected expansion units
CM1870 − Recipe loading Drive number
CM1871 Recipe loading Folder number
CM1872 Reserved for the system
CM1873 Recipe loading Completion code
CM1874 Reserved for the system
CM1875 Recipe saving Drive number
CM1876 Recipe saving Reference folder number
CM1877 Recipe saving Output folder number
CM1878 Recipe saving Completion code
CM1879 Reserved for the system
CM1880 Project load drive number (request)
CM1881 Project load folder number (request)
CM1882 R Project load drive number (complete)
CM1883 R Project load folder number (complete)
CM1884 R Project load completion code
CM1875 to CM1877 − Reserved for the system
CM1888 Project save drive number (request)
CM1889 Project save folder number (request)
CM1890 R Project save drive number (complete)
CM1891 R Project save folder number (complete)
CM1892 R Project save completion code
CM1893 to CM1999 − Reserved for the system
CM2000 to CM2001 R Device record 0 Average sampling period
CM2002 to CM2003 R Operation record Device record 0 Average number of changed devices
CM2004 to CM2005 R function(ID0) Device record 0 Maximum collection period
CM2006 to CM2009 − Reserved for the system
CM2010 to CM2039 Operation record function(ID1∼ID3)
CM2040 to CM2389 − Reserved for the system
CM2390 R Error code for storage device instruction
A-6 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
CR/CM List

Attribute
Hold
CM R: Read only Function
Yes: Hold
Blank: Read/write
Power OFF during storage access
CM2391
(Becomes value other than 0 during occurrence. Please change it to 0 from the program.)
CM2392 Memory card retry occurrence times (still hold in case of power off)
CM2393 Memory card check error times (still hold in case of power off)
CM2394 Memory card timeout occurrence times (still hold in case of power off)
CM2395 Reset delay time when error occurs on the memory card
CM2396 to CM2399 − Reserved for the system
CM2400 to CM2401 R Inter-unit synchronization refreshing beginning time (0.1μs)
CM2402 to CM2403 R Inter-unit synchronization refreshing finishing time (0.1μs)
Inter-unit synchronization refreshing beginning time maximum (0.1μs)
CM2404 to CM2405 Yes
(To reset, please change it to 0 from this program.)
Inter-unit synchronization refreshing finishing time maximum (0.1μs)
CM2406 to CM2407 Yes
(To reset, please change it to 0 from this program.)
CM2408 to CM2409 R Inter-unit synchronization refreshing operation time (0.1μs)
CM2410 to CM5099 − Reserved for the system
Year and month (Indicated as decimal values. The last
CM5100 R two digits show Month, and previous digits from Yes
hundred show Year. Example: 1210 → October 2012)
CM5101 R Day Yes

APPENDICES
CM5102 R Hour Yes
CM5103 R Minute Yes
CM5104 R Details of the latest serious Second Yes
error
CM5105 R Error number Yes
CM5106 R Number of valid pieces of data Yes
CM5107 R Detailed information, piece 01 Yes
CM5108 R Detailed information, piece 02 Yes
: R Yes
CM5126 R Detailed information, piece 20 Yes

CR/CM List
CM5127 to CM5149 − Reserved for the system
Year and month (Indicated as decimal values. The last
CM5150 R two digits show Month, and previous digits from Yes
hundred show Year. Example: 1210 → October 2012)
CM5151 R Day Yes
CM5152 R Hour Yes
CM5153 R Minute Yes
CM5154 R Details of the latest minor Second Yes
error
CM5155 R Error number Yes
CM5156 R Number of valid pieces of data Yes
CM5157 R Detailed information, piece 01 Yes
CM5158 R Detailed information, piece 02 Yes
: R Yes
CM5176 R Detailed information, piece 20 Yes
CM5177 to CM5871 − Reserved for the system
CM5872 to CM5873 R Used amount of CPU memory(32 bit, Byte unit) Yes
CM5874 to CM5999 − Reserved for the system
CM6000 Operation record 0 Save completion code
CM6001 − Reserved for the system
CM6002 Operation record 0 Save counter
CM6003 − Reserved for the system
CM6004 R Operation record Operation record 0 Save progress detail 1
CM6005 R function(ID0) Operation record 0 Save progress detail 2
CM6006 R Operation record 0 Save progress
CM6007 to CM6009 − Reserved for the system
CM6010 to CM6171 R Operation record 0 Save path
CM6172 to CM6199 − Reserved for the system
CM6200 to CM6799 Operation record function (ID1 to ID3)
CM6800 to CM7599 − Reserved for the system

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-7


CR/CM List

Error details information - For KV-8000


• Error number 128 (calculation error)
Detailed Information, Piece n Explanation
Detailed information 1 Details of errors
(CM0712/CM5157) 0 (Not used)
1 Incorrect indirect specification.
2 The indirectly specified target is T/C.
3 Incorrect simple indirect specification.
4 Outside of operand range.
5 Floating-point real number overflow
6 Incorrect device specification.
7 The ROOT instruction operand is negative.
8 No bits turned ON with the ENCO instruction.
9 Floating-point real number format error.
10 Incorrect trigonometric function instruction operand.
11 Data cannot be converted.
12 Improper table specification.
13 Incorrect time comparison instruction operand.
14 Incorrect cam switch operand.
15 Incorrect frequency counter instruction operand.
APPENDICES

16 Divide by zero.
17 Illegal logging ID.
18 Direct processing error.
19 Unit on which direct processing cannot be performed.
20 Jump destination subroutine does not exist.
21 Data being written during RUN mode, so instruction cannot be executed.
22 Error for expansion unit-dedicated instructions (unit number).
23 Reserved for the system.
24 PIDAT, outside of operation setting range.
CR/CM List

25 PIDAT, outside of sampling period range.


26 PIDAT, outside of comparison constant range.
27 PIDAT, outside of integral constant range.
28 PIDAT, outside of differential constant range.
29 PIDAT comparison constant, two-degree freedom parameters outside of range.
30 PIDAT integral constant, two-degree freedom parameters outside of range.
31 PIDAT differential constant, two-degree freedom parameters outside of range.
32 PIDAT, outside of operation quantity upper limit or lower limit range.
33 PIDAT, outside of operation quantity change width limit range.
34 PIDAT, outside of measured value change width range.
35 PIDAT, AT state transition error.
36 PIDAT, outside of operation control flag range.
37 Operation period exceeded.
38 PIDAT, outside of AT adjustment parameter range.
39 PIDAT, outside of AT hysteresis range.
40 PIDAT, outside of AT timeout range.
41 PIDAT, outside of AT calculation control mode setting range.
42 PIDAT, AT timeout.
43 PIDAT, AT comparison constant exceeded.
44 PIDAT, AT integral constant exceeded.
45 PIDAT, AT differential constant exceeded.
46 Root of negative number cannot be calculated.
47 Incorrect ABS instruction operand.
48 Calculation overflow.
49 UR, UM, or UV unit not connected.
50 Unit device (R) not assigned.
51 Unit device (DM) not assigned.
52 Unit categories disagree
53 Operation recorder ID illegal
54 Stack overflow
Detailed information 2 (CM5158) Fixed to 00H
Detailed information 3 (CM5159) Upper bits of the step number at which the error occurred

A-8 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Detailed Information, Piece n Explanation


Detailed information 4 (CM5160) Lower bits of the step number at which the error occurred
Detailed information 5 to 20 The module name is saved according to the project language settings
(CM5161 to CM5176) (any parts not occupied with the module name are "00H")
• No. 50, 53, 55, 56, 58, 59, 63 (unit number errors)
Detailed Information, Piece n Explanation
Detailed information 1 Unit number (the unit number will not be stored if it cannot be
(CM5107) determined according to the occurrence conditions of the error)
Detailed information 2 to 20
Fixed to 00H
(CM5108 to CM5126)

• No. 54 (number of units error)


Detailed Information, Piece n Explanation
Detailed information 1
The number of units as specified in the unit setup information
(CM5107)
Detailed information 2
The number of units that are actually connected
(CM5108)
Detailed information 3 to 20
Fixed to 00H
(CM5109 to CM5126)

APPENDICES
• No. 127 (automatic loading failure error)
Detailed Information, Piece n Explanation
Detailed information 1
Details of error
(CM5157)
Detailed information 2 to 20
Fixed to 00H
(CM5158 to CM5176)

CR/CM List
• No. 129 (unit error))
Expansion Information, Piece n Explanation
Expansion Information1
Unit number
(CM5157)
Expansion Information 2
Error number of each unit
(CM5158)
Expansion Information 3 to 20
Fixed to 00H
(CM5159 to CM5176)

• Error numbers other than those listed above


Expansion Information, Piece n Explanation
Expansion Information 1 to 20 Fixed to 00H

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-9


CR/CM List

Control Relays CR (For KV-7500/7300)

Control relays (CR0000 - CR7915) can be used to perform operations such as checking the operation
status of the CPU unit and setting and monitoring the built-in functions.
Control relays reserved for the system cannot be used.
Attribute
CR R: Read only Function
Blank: Read/write
CR0000 Logging and tracing execution (ON: enabled, OFF: disabled)
CR0001 R Logging or tracing operation in progress
CR0002 R Logging or tracing file writing completion
CR0003 R Logging buffer less than 50% warning
CR0004 R Logging buffer overflow
CR0005 R Data to be written in RUN mode during logging present
CR0006
and − Reserved for the system
CR0007
Logging or tracing function (ID0)
CR0008 R Logging or tracing error
APPENDICES

CR0009 R Logging trace No memory space error


CR0010 R Logging or tracing device or trigger setting error
CR0011 R Tracing file save trigger monitor
CR0012 R Tracing data capture completion
CR0013 R Logging or tracing setting to be written present
CR0014
and − Reserved for the system
CR0015
CR0100 to
Logging or tracing function (ID1 to ID9)
CR/CM List

CR0915
CR1000 to
Real-time chart monitor (ID10)
CR1015
CR1100 to
− Reserved for the system
CR2001
CR2002 R Always turned ON
CR2003 R Always turned OFF
CR2004 R 10 ms clock pulse (duty cycle: 50%)
CR2005 R 100 ms clock pulse (duty cycle: 50%)
CR2006 R 1 s clock pulse (duty cycle: 50%)
CR2007 R Turned OFF for just one scan when operation starts
CR2008 R Turned ON for just one scan when operation starts
CR2009 Turned ON when the calculation result is negative or when an overflow occurs
CR2010 R Turned ON when the calculation result is zero
CR2011 R Turned ON when the calculation result is positive
CR2012 R Turned ON when a calculation execution error occurs
CR2013 to
− Reserved for the system
CR2302
CR2303 Fixed scan time operation (ON: enabled, OFF: disabled)
Turned ON for just one scan when the scan time setting (the fixed scan time operation and END
CR2304 R
processing time settings) is exceeded
CR2305 − Reserved for the system
CR2306 R Indicates backup battery errors (ON: error, OFF: normal)
CR2307 Clears the minimum and maximum scan time values
Sets the END processing time (ON: enabled, OFF: disabled; if CR2303 is turned ON at the same
CR2308
time, CR2303 is given priority)
CR2309
and − Reserved for the system
CR2310
CR2311 R Indicates RTC low voltage error (ON: error has occurred, OFF: normal)
CR2312 − Reserved for the system
CR2313 Forces switch of the VT sensor application screen (ON: switch, OFF: do not switch)

A-10 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
Project password authentication status (ON: authentication disabled, OFF: authentication
CR2314 R
enabled)
CR2315 to
− Reserved for the system
CR2813
Zero suppression during execution of DASC and FASC instructions (all suffixes; ON: execute,
CR2814
OFF: do not execute)
Omission of "+" during execution of DASC.S, DASC.L, and FASC instructions (ON: execute,
CR2815
OFF: do not execute)
CR2900 to
− Reserved for the system
CR3115
CR3200 CPU memory save save request
CR3201 R CPU memory save being performed
CR3202 R CPU memory save complete
CR3203 R CPU memory save error
CR3204 to
− Reserved for the system
CR3206
Instruction RAM mode operation
CR3207 The RAM mode activation of file register instructions, storage device instructions towards the
CPU memory. (ON: enable, OFF: disable)

APPENDICES
CR3208 to
− Reserved for the system
CR3209
CR3210 R Arbitrary logging/trace operation
CR3211 to
− Reserved for the system
CR3213
CR3214 R Storage instruction executing
CR3215 − Reserved for the system
CR3300 to
Alarm relay
CR3415

CR/CM List
CR3500 R Alarm operation relay (ON: one of CR3300 to CR3415 is turned ON)
Record an entry in the log when an alarm relay switches from ON to OFF (ON: record, OFF: do
CR3501
not record)
CR3502 The alarm relay log is cleared when this switches from OFF to ON
CR3503 to
− Reserved for the system
CR3512
CR3513 R Logging internal buffer overflow
CR3514 HKEY instruction - Disables multiple keys
CR3515 R HKEY instruction - Scan completion
CR3600 to
R HKEY information storage area
CR3615
CR3700 to
− Reserved for the system
CR3815
CR3900 The serious error log is cleared when this switches from OFF to ON
CR3901 The minor error log is cleared when this switches from OFF to ON
CR3902 R Indicates that the serious error log is full
CR3903 R Indicates that the minor error log is full
CR3904 R RUN-PRG selector switch status (ON: RUN, OFF: PROG)
CR3905 R A serious error has occurred
CR3906 R A minor error has occurred
CR3907 The power on log is cleared when this switches from OFF to ON
CR3908 The power off log is cleared when this switches from OFF to ON
CR3909 Clears the current error (Set this relay in the ladder program)
CR3910 to
− Reserved for the system
CR4000
CR4001 to
R Expansion unit status (expansion units 1 - 48)
CR4300
CR4301 to
− Reserved for the system
CR4315
CR4400 R AW up key being pressed
CR4401 R AW down key being pressed
CR4402 R AW left key being pressed
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-11
CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR4403 R AW right key being pressed
CR4404 R AW MENU key being pressed
CR4405 R AW ENT key being pressed
CR4406 to
− Reserved for the system
CR4414
CR4415 R AW user message being displayed
CR4500 AW line 1 blinking
CR4501 AW line 2 blinking
CR4502 AW line 3 blinking
CR4503 AW line 4 blinking
CR4504 to
− Reserved for the system
CR4600
CR4601 to
AW user message 1 to 63
CR4915
CR5000 to
− Reserved for the system
CR5315
CR5400 Memory card mount request
CR5401 Memory card unmount request
APPENDICES

CR5402 R Memory card used


CR5403 R Memory card recognized
CR5404 R Memory card is available
CR5405 R Memory card is write protected
CR5406 to
− Reserved for the system
CR5407
CR5408 CPU memory mount request
CR5409 CPU memory unmount request
CR/CM List

CR5410 R CPU memory used


CR5411 R CPU memory recognized
CR5412 to
− Reserved for the system
CR7915

A-12 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Control Memory Entries CM (For KV-7500/7300)

Control memory entries (CM0000 - CM5999) can be used to perform operations such as checking the
operation status of the CPU unit and setting and monitoring the built-in functions.
Control memory entries reserved for the system cannot be used.
Attribute
R: Read only Hold
CM Function
Blank: Read/ Yes: Hold
write
CM0000 and
− Reserved for the system
CM0699
CM0700 R Read from RTC (year)
CM0701 R Read from RTC (month)
CM0702 R Read from RTC (day)
CM0703 R Read from RTC (hour)
CM0704 R Read from RTC (minute)
CM0705 R Read from RTC (second)
CM0706 R Read from RTC (day of the week)
CM0707 to
− Reserved for the system

APPENDICES
CM709
CM0710 R File register current bank number
CM0711 − Reserved for the system
CM0712 R Computing error detailed information
CM0713 to
− Reserved for the system
CM0899
CM900 R CPU function version
CM901 to
− Reserved for the system
CM906
CM907 R Project Version

CR/CM List
CM908 to
− Reserved for the system
CM999
CM1000 and
R Scan time measuring value (1 μs) (32-bit)
CM1001
CM1002 and
R END processing time measured value (1 μs unit) (32-bit)
CM1003
CM1004 and
R Minimum fixed scanning time (1 μs unit) (32-bit)
CM1005
CM1006 and
R Maximum fixed scanning time (1 μs unit) (32-bit)
CM1007
CM1008 and
Fixed scanning time run set value (1 μs unit) (32-bit)
CM1009
CM1010 and
END processing time set value (1 μs unit) (32-bit)
CM1011
CM1012 and
R Scanning time when setting is exceeded (1 μs unit) (32-bit)
CM1013
CM1014 and
R END processing time exceeds value (1 μs unit) (32-bit)
CM1015
CM1016 to
− Reserved for the system
CM1029
CM1030 and
R 32-bit 1 ms Free Run counter
CM1031
CM1032 and
R 32-bit 10 μs Free Run counter
CM1033
CM1034 and
R 32-bit 1 μs Free Run counter
CM1035
CM1036 and
R 32-bit 0.1 μs Free Run counter
CM1037
CM1038 to
− Reserved for the system
CM1499
CM1500 to
R Log/trace (ID0 to ID9) File Save Counter
CM1509

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-13


CR/CM List

Attribute
R: Read only Hold
CM Function
Blank: Read/ Yes: Hold
write
CM1510 to
− Reserved for the system
CM1629
CM1630 to
R Log/trace Ring Buffer minimum free space (ID0 to ID9) (KBytes)
CM1639
CM1640 to
− Reserved for the system
CM1649
CM1650 R Number of sensor setting instruction executions
CM1651 to
− Reserved for the system
CM1657
CM1658 R Number of consecutive project password authentication failures Yes
CM1659 R Total number of project password authentication failures Yes
CM1660 to
R Logging, trace ring buffer free capacity (ID0 - ID9) (in kbyte units)
CM1669
CM1670 to
− Reserved for the system
CM1679
CM1680 to
R Log/trace File Save Counter (ID0 to ID9) (Memory card use) Yes
CM1689
CM1690 to
− Reserved for the system
CM1699
APPENDICES

CM1700 and
Digital trimmer 0 upper limit (32-bit)
CM1701
CM1702 and
Digital trimmer 1 upper limit (32-bit)
CM1703
CM1704 and
Digital trimmer 2 upper limit (32-bit)
CM1705
CM1706 and
Digital trimmer 3 upper limit (32-bit)
CM1707
CM1708 and
Digital trimmer 4 upper limit (32-bit)
CM1709
CR/CM List

CM1710 and
Digital trimmer 5 upper limit (32-bit)
CM1711
CM1712 and
Digital trimmer 6 upper limit (32-bit)
CM1713
CM1714 and
Digital trimmer 7 upper limit (32-bit)
CM1715
CM1716 to
− Reserved for the system
CM1719
CM1720 R AW user message display number
CM1721 to
− Reserved for the system
CM1735
CM1736 AW initial display language setting
CM1737 AW initial comment number setting
CM1738 Access window operation disabled setting
CM1739 − Reserved for the system
CM1740 to
R Ladder project name (up to 32 characters + end code)
CM1772
CM1773 to
− Reserved for the system
CM1779
CM1780 Access window initial screen setting, enabled
CM1781 Access window initial screen setting, device type
CM1782 Access window initial screen setting, screen ID
CM1783 Access window initial screen setting, screen ID
CM1784 Access window initial screen setting, device number
CM1785 Access window initial screen setting, device number
CM1786 Access window initial screen setting, display format
CM1787 Access window initial screen setting, device name representation
CM1788 Access window initial screen setting, key lock status

A-14 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
R: Read only Hold
CM Function
Blank: Read/ Yes: Hold
write
CM1789 − Reserved for the system
CM1790 Automatic loading folder number (request)
CM1791 R Automatic loading complete code
CM1792 R Automatic loading folder number (complete)
CM1793 − Reserved for the system
CM1794 Run load folder number (request)
CM1795 R Run load complete code
CM1796 R Run load folder number (complete)
CM1797 to
− Reserved for the system
CM1868
CM1869 R Number of connected expansion units
CM1870 to
− Reserved for the system
CM2389
CM2390 R Error code for storage device instruction
Power OFF during storage access
CM2391 (Becomes value other than 0 during occurrence. Please change it to 0 from the
program.)
CM2392 Memory card retry occurrence times (still hold in case of power off)

APPENDICES
CM2393 Memory card check error times (still hold in case of power off)
CM2394 Memory card timeout occurrence times (still hold in case of power off)
CM2395 Reset delay time when error occurs on the memory card
CM2396 to
− Reserved for the system
CM5099
CM5100 R Year and month Yes
CM5101 R Day Yes
CM5102 R Hour Yes
CM5103 R Minute Yes

CR/CM List
CM5104 R Second Yes
Details of the latest serious
CM5105 R Number Yes
error
CM5106 R Number of valid pieces of data Yes
CM5107 R Detailed information, piece 01 Yes
CM5108 R Detailed information, piece 02 Yes
: R Yes
CM5126 R Detailed information, piece 20 Yes
CM5127 to
− Reserved for the system
CM5149
CM5150 R Year and month Yes
CM5151 R Day Yes
CM5152 R Hour Yes
CM5153 R Minute Yes
CM5154 R Second Yes
Details of the latest minor
CM5155 R Number Yes
error
CM5156 R Number of valid pieces of data Yes
CM5157 R Detailed information, piece 01* Yes
CM5158 R Detailed information, piece 02* Yes
: R Yes
CM5176 R Detailed information, piece 20* Yes
CM5177 to
− Reserved for the system
CM5871
CM5872 to
R Used amount of CPU memory(32 bit, Byte unit) Yes
CM5873
CM5874 to
− Reserved for the system
CM5999

* The detailed information which depends on the occurring error number is displayed in the following page.

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-15


CR/CM List

• Error number 128 (calculation error)


Detailed Information, Piece n Explanation
Detailed information 1 Details of errors
(CM5157) 0 (Not used)
1 Incorrect indirect specification.
2 The indirectly specified target is T/C.
3 Incorrect simple indirect specification.
4 Outside of operand range.
5 Floating-point real number overflow
6 Incorrect device specification.
7 The ROOT instruction operand is negative.
8 No bits turned ON with the ENCO instruction.
9 Floating-point real number format error.
10 Incorrect trigonometric function instruction operand.
11 Data cannot be converted.
12 Improper table specification.
13 Incorrect time comparison instruction operand.
14 Incorrect cam switch operand.
15 Incorrect frequency counter instruction operand.
16 Divide by zero.
APPENDICES

17 Illegal logging ID.


18 Direct processing error.
19 Unit on which direct processing cannot be performed.
20 Jump destination subroutine does not exist.
21 Data being written during RUN mode, so instruction cannot be executed.
22 Error for expansion unit-dedicated instructions (unit number).
23 Reserved for the system.
24 PIDAT, outside of operation setting range.
25 PIDAT, outside of sampling period range.
26 PIDAT, outside of comparison constant range.
CR/CM List

27 PIDAT, outside of integral constant range.


28 PIDAT, outside of differential constant range.
29 PIDAT comparison constant, two-degree freedom parameters outside of range.
30 PIDAT integral constant, two-degree freedom parameters outside of range.
31 PIDAT differential constant, two-degree freedom parameters outside of range.
32 PIDAT, outside of operation quantity upper limit or lower limit range.
33 PIDAT, outside of operation quantity change width limit range.
34 PIDAT, outside of measured value change width range.
35 PIDAT, AT state transition error.
36 PIDAT, outside of operation control flag range.
37 Operation period exceeded.
38 PIDAT, outside of AT adjustment parameter range.
39 PIDAT, outside of AT hysteresis range.
40 PIDAT, outside of AT timeout range.
41 PIDAT, outside of AT calculation control mode setting range.
42 PIDAT, AT timeout.
43 PIDAT, AT comparison constant exceeded.
44 PIDAT, AT integral constant exceeded.
45 PIDAT, AT differential constant exceeded.
46 Root of negative number cannot be calculated.
47 Incorrect ABS instruction operand.
48 Calculation overflow.
49 UR, UM, or UV unit not connected.
50 Unit device (R) not assigned.
51 Unit device (DM) not assigned.
Detailed information 2 (CM5158) Fixed to 00H
Detailed information 3 (CM5159) Upper bits of the step number at which the error occurred
Detailed information 4 (CM5160) Lower bits of the step number at which the error occurred
Detailed information 5 to 20 The module name is saved according to the project language settings
(CM5161 to CM5176) (any parts not occupied with the module name are "00H")

A-16 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

• No. 50, 53, 55, 56, 58, 59, 63 (unit number errors)
Detailed Information, Piece n Explanation
Detailed information 1 Unit number (the unit number will not be stored if it cannot be
(CM5107) determined according to the occurrence conditions of the error)
Detailed information 2 to 20
Fixed to 00H
(CM5108 to CM5126)

• No. 54 (number of units error)


Detailed Information, Piece n Explanation
Detailed information 1
The number of units as specified in the unit setup information
(CM5107)
Detailed information 2
The number of units that are actually connected
(CM5108)
Detailed information 3 to 20
Fixed to 00H
(CM5109 to CM5126)

• No. 127 (automatic loading failure error)


Detailed Information, Piece n Explanation
Detailed information 1
Details of error

APPENDICES
(CM5157)
Detailed information 2 to 20
Fixed to 00H
(CM5158 to CM5176)

• No. 129 (unit error))


Expansion Information, Piece n Explanation
Expansion Information1
Unit number
(CM5157)
Expansion Information 2

CR/CM List
Error number of each unit
(CM5158)
Expansion Information 3 to 20
Fixed to 00H
(CM5159 to CM5176)

• Error numbers other than those listed above


Expansion Information, Piece n Explanation
Expansion Information 1 to 20 Fixed to 00H

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-17


CR/CM List

Control Relays CR (For KV-5500/5000/3000)

The control relay (CR0000 to CR7915) can check the operating state of the CPU unit, and set up or monitor each built-in
function.
The system-reserved control relay cannot be used.
Attributes
Device No. R: Read only. Function
Blank: R/W

CR0000 Logging/trace execution (ON: enable, OFF: disable)


CR0001 R Logging/trace operation
CR0002 R Logging/trace file write end
CR0003 R Logging buffer 50% alarm
CR0004 R Logging buffer overflow
CR0005 R Logging write during RUN
Logging /tracking
CR0006 to CR0007 - Reserved for the system
function (ID0)
CR0008 R Logging/trace error
CR0009 R Logging/trace memory plugboard without capacity error
APPENDICES

CR0010 R Abnormal logging/trace device/trigger setting


CR0011 R Trace file saving trigger monitor
CR0012 R Trace data acquisition end
CR0013 to CR0015 - Reserved for the system
Logging/trace
CR0100 to CR0915 (identical with CR0000 to CR0015)
function (ID1 to ID9)
Real-time graphic
CR1000 to CR1015 (identical with CR0000 to CR0015)
monitor (ID10)
CR/CM List

CR1100 to CR2001 - Reserved for the system


CR2002 R Always ON
CR2003 R Always OFF
CR2004 R 10ms clock pulse (Duty ratio %: 50%)
CR2005 R 100ms clock pulse (Duty ratio %: 50%)
CR2006 R 1s clock pulse (Duty ratio %: 50%)
CR2007 R OFF scan period at operation start
CR2008 R ON scan period at operation start
CR2009 ON when operation result is negative or overflowed
CR2010 R ON when the operation result is 0
CR2011 R ON when the operation result is positive
CR2012 R ON when operation execution error
CR2013 to CR2015 - Reserved for the system
CR2100 R CTH0 special internal clock (1μs)
CR2101 R CTH0 special internal clock (10μs)
CR2102 R CTH0 special internal clock (100μs)
CR2103 Auto reset of CTH0 (ON: enable, OFF: disable)
Comparator match output to R500/R504 is disabled (ON: enable,
CR2104
Operation when OFF: disable)
high-speed Comparator match output to R500/R504 is set as OFF (ON:
CR2105
counter enable, OFF: disable)
comparator Comparator match output to R500/R504 is set as ON (ON:
CR2106
CTC0 is ON enable, OFF: disable)
Invert ON/OFFstate of comparator match output to R500/R504
CR2107
whenever in ON state (ON: enable, OFF: disable)

A-18 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

Comparator match output to R500/R504 is disabled (ON: enable,


CR2108
OFF: disable)
Operation when Comparator match output to R500/R504 is set as OFF (ON:
CR2109
high-speed enable, OFF: disable)
counter Comparator match output to R500/R504 is set as ON (ON:
CR2110
comparator enable, OFF: disable)
CTC1 is ON Invert ON/OFFstate of comparator match output to R500/R504 whenever
CR2111
in ON state. (ON: enable, OFF: disable)
CR2112 Auto reset of CTH0 (ON: enable, OFF: disable)
Option of 1-phase
1Override 2Override 4Override 2-phase
counting input no direction With direction
CR2113 to CR2115 methods of CR2113 OFF ON OFF ON OFF ON

high-speed CR2114 OFF OFF ON ON OFF OFF


CR2115 OFF OFF OFF OFF ON ON
counter CTH0
CR2200 R CTH1 special internal clock (1μs)
CR2201 R CTH1 special internal clock (10μs)

APPENDICES
CR2202 R CTH1 special internal clock (100μs)
CR2203 Auto reset of CTH1 (ON: enable, OFF: disable)
Comparator match output to R501/R505 is disabled (ON: enable,
CR2204
Operation when OFF: disable)
high-speed Comparator match output to R501/R505 is set as OFF (ON:
CR2205
counter enable, OFF: disable)
comparator Comparator match output to R501/R505 is set as ON (ON:
CR2206

CR/CM List
CTC2 is ON enable, OFF: disable)
Invert ON/OFFstate of comparator match output to R501/R505
CR2207
whenever in ON state (ON: enable, OFF: disable)
Comparator match output to R501/R505 is disabled (ON: enable,
CR2208
OFF: disable)
Operation when Comparator match output to R501/R505 is set as OFF (ON:
CR2209
high-speed enable, OFF: disable)
counter Comparator match output to R501/R505 is set as ON (ON:
CR2210
comparator enable, OFF: disable)
CTC3 is ON Invert ON/OFFstate of comparator match output to R501/R505
CR2211
whenever in ON state (ON: enable, OFF: disable)
CR2212 Auto reset of CTH1 (ON: enable, OFF: disable)
Option of 1-phase
1Override 2Override 4Override 2-phase
counting input no direction With direction
CR2213 to CR2215 methods of CR2213 OFF ON OFF ON OFF ON

high-speed CR2214 OFF OFF ON ON OFF OFF


CR2215 OFF OFF OFF OFF ON ON
counter CTH1
CR2300 External output disable (ON: enable, OFF: disable)
CR2301 External input refresh disable (ON: enable, OFF: disable)
CR2302 External output is disabled during interruption (ON: enable, OFF: disable)
CR2303 Fixed scanning time operation (ON: enable, OFF: disable)
In case scanning time setting (fixed scanning time operation .END processing time
CR2304 R
setting) overflow, only 1-time scanning is ON
Set input time constant of all inputs of CPU unit (ON: set→CM1620, OFF: setting
CR2305
disable [10ms])
CR2306 R ON when back-up battery is abnormal

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-19


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CR2307 Clearing of maximum/minimum value of scanning time


CR2308 END processing time setting (ON: enable, OFF: disable)
CR2309 to CR2312 - Reserved for the system
VT sensor application screen forced changeover (Change: ON, disable change:
CR2313
OFF)
CR2314 - Reserved for the system
In battery-less operation (during normal operation: OFF, during battery-less
CR2315 R
operation: ON)

Not used Rise Decline Level


CTH0 external
CR2400, CR2401 CR2400 OFF ON OFF ON
signal preset CR2401 OFF OFF ON ON

CR2402 Option of CTH0 counting method (ON: ring, OFF: linear)


CR2403 Detect CTH0 overflow/underflow (ON: detected, OFF: undetected)

Not used Rise Decline Level


CTH1 external
CR2404, CR2405 CR2404 OFF ON OFF ON
APPENDICES

signal preset CR2405 OFF OFF ON ON

CR2406 Option of CTH1 counting method (ON: ring, OFF: linear)


CR2407 Detect CTH1 overflow/underflow (ON: detected, OFF: undetected)
CR2408 CTH0 preset disable (ON: disable, OFF: not disable)
CR2409 CTH1 preset disable (ON: disable, OFF: not disable)
CR2410 CTH0 internal permit relay (ON: enable counting, OFF: disable counting)
CR2411 CTH1 internal permit relay (ON: enable counting, OFF: disable counting)
CR/CM List

CR2412 R CTH0 change direction (ON: at the side of subtraction, OFF: at the side of adding)
CR2413 R CTH1 change direction (ON: at the side of subtraction, OFF: at the side of adding)
CR2414 R CTH0 special internal block (50ns)
CR2415 R CTH1 special internal block (50ns)
CR2500 Start operation (ON: enable, OFF: disable)

Single-phase Single-phase 2-phase


Input source 2-phase
without direction with direction 1-multiple
CR2501, CR2502
Frequency setting CR2501 OFF ON OFF ON

counter CR2502 OFF OFF ON ON

CR2503 Hz/rpm switching (ON: rpm, OFF: Hz)


Use the function for updating the operation speed once (ON:
CR2504
available, OFF: not available)
CR2505 CTH0 comparator match output relay switching (ON: R504, OFF: R500)
CR2506 Specified frequency pulse output (CTH0) (ON: enable, OFF: disable)
CR2507 Specify frequency pulse output (CTH0) error
CR2508 Start operation (ON: enable, OFF: disable)

Single-phase Single-phase 2-phase


Input source 2-phase
without direction with direction 1-multiple
CR2509, CR2510
Frequency setting CR2509 OFF ON OFF ON

counter (CTH1) CR2510 OFF OFF ON ON

CR2511 Hz/rpm switching (ON: rpm, OFF: Hz)


Use the function for updating the operation speed once (ON:
CR2512
available, OFF: not available)
CR2513 CTH1 comparator match output relay switching (ON: R505, OFF: R501)
CR2514 Specified frequency pulse output (CTH1) (ON: enable, OFF: disable)
CR2515 Specify frequency pulse output (CTH1) error

A-20 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

1-phase w/o Single-phase 2phase 1


2-phase
direction with direction override
CR2600,CR2601 INT R000 interrupt polarity
CR2600 OFF ON OFF ON
CR2601 OFF OFF ON ON

CR2602,CR2603 INT R001 interrupt polarity (identical with CR2600, CR2601)


CR2604,CR2605 INT R002 interrupt polarity (identical with CR2600, CR2601)
CR2606,CR2607 INT R003 interrupt polarity (identical with CR2600, CR2601)
CR2608,CR2609 INT R004 interrupt polarity (identical with CR2600, CR2601)
CR2610,CR2611 INT R005 interrupt polarity (identical with CR2600, CR2601)
CR2612,CR2613 INT R006 interrupt polarity (identical with CR2600, CR2601)
CR2614,CR2615 INT R007 interrupt polarity (identical with CR2600, CR2601)
CR2700,CR2701 INT R008 interrupt polarity (identical with CR2600, CR2601)
CR2702,CR2703 INT R009 interrupt polarity (identical with CR2600, CR2601)
CR2704 to CR2715 - Reserved for the system
CR2800 Send BREAK signal (sending during ON)
CR2801 R 1 scanning ON when receiving file data

APPENDICES
CR2802 R Scan data load
Serial
CR2803 R 1 scanning ON in the event of occurrence of text data receiving error
communication
CR2804 Start to send text data (ON during sending)
CR2805 Receive text data in bytes (ON: enable, OFF: disable)
CR2806 Send text data in bytes (ON: enable, OFF: disable)
CR2807 to CR2813 - Reserved for the system
Zero suppression is performed when DASC instruction (all suffixes) and FASC
CR2814

CR/CM List
instruction are executed (ON: enable, OFF: disable)
When DASC.S, DASC.L and FASC instruction execution are executed, "+" is
CR2815
omitted. (ON: enable, OFF: disable)
CR2900 User message display1 (ON: display, OFF: not display)
Access window
CR2901 User message display2 (ON: display, OFF: not display)
CR2902 to CR2915 - Reserved for the system
CR3000 Limit switch CW input
CR3001 Limit switch CCW input
CR3002 Origin sensor input
CR3003 Stop sensor input
CR3004 R In the course of zero suppression
CR3005 R Origin suppression end
CR3006 Positioning end relay
CR3007 CPU positioning Error/clearing error
CR3008 function axis X Warning/clearing warning
CR3009 Pulse output/emergency stop
CR3010 Driver operation start
CR3011 Current value change request (level detection)
CR3012 Operation speed change request (level detection)
CR3013 Consistency relay of comparator 2
CR3014 -
Reserved for the system
CR3015 -

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-21


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CR3100 Limit switch CW input


CR3101 Limit switch CCW input
CR3102 Origin sensor input
CR3103 Stop sensor input
CR3104 R In the course of zero suppression
CR3105 R Origin suppression end
CR3106 Positioning end relay
CR3107 CPU positioning Error/clearing error
CR3108 function axis Y Warning/clearing warning
CR3109 Pulse output/emergency stop
CR3110 Driver operation start
CR3111 Current value change request (level detection)
CR3112 Operation speed change request (level detection)
CR3113 Consistency relay of comparator 2
CR3114 -
Reserved for the system
CR3115 -
APPENDICES

CR3200 to CR3209 - Reserved for the system


CR3210 R Random Logging / trace memory plugboard in use
CR3211 R Memory card in use
CR3212 R Memory card identification end
CR3213 R With memory card
CR3214 R Memory card instruction in execution
CR3215 R Memory plugboard write protection (ON: write protection, OFF: without write protection)
CR/CM List

CR3300 to CR3415 Warning relay


CR3500 R Warning relay in operation (ON when one of CR3300 to CR3415 is ON)
CR3501 When warning relay ON → OFF, process the log (ON: reserve, OFF: without reserve)
CR3502 When OFF turns to ON, clear Warning relay log
CR3503 to CR3513 - Reserved for the system
CR3514 HKEY Multikey disable
CR3515 R instruction Scanning end
CR3600 to CR3615 R Information storage area of HKEY instruction

A-22 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CR3700 F1 customized switch 1


CR3701 F2 customized switch 2
CR3702 F3 customized switch 3
CR3703 F4 customized switch 4
CR3704 LED1 customized indicator 1
CR3705 LED2 customized indicator 2
CR3706 LED3 customized indicator 3
CR3707 LED4 customized indicator 4
CR3708 Operator panel Green backlit lamp (highlighted during ON)
CR3709 KV-D30 Red backlit lamp (highlighted during ON)
CR3710 System information display languag e(ON: Japanese, OFF: English)
CR3711 Buzzer ON
CR3712 Screen display setting (ON: positive display, OFF: reverse display)
CR3713 Warning interruption permit (ON: enable, OFF: disable)
CR3714 Page switching (rise switching to the page of CM0401, forced OFF)
CR3715 "↑""↓" Page switching is disabled (ON: enable, OFF: disable)

APPENDICES
CR3800 External output 0 is also in ON state in the case of ON state
CR3801 External output 1 is also in ON state in the case of ON state
CR3802 to CR3815 - Reserved for the system
CR3900 OFF→ON, severe error log is cleared
CR3901 OFF→ON, slight error log is cleared
CR3902 R Severe error log represents maximum number
CR3903 R Slight error log represents maximum number

CR/CM List
CR3904 R RUN/PRG switching state (ON: RUN side, OFF: PROG side)
CR3905 R In the event of occurrence of severe error
CR3906 R In the event of occurrence of slight error
CR3907 OFF→ON, power ON log is cleared
CR3908 OFF→ON, power OFF log is cleared
CR3909 Current error is cleared (Only SET/RES instruction)
CR3910 to CR3915 - Reserved for the system

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-23


CR/CM List

Control Memory CM (For KV-5500/5000/3000)


Control memory (CM0000 - CM5999) may realize confirmation of CPU unit action state, settings or
monitoring of built-in functions etc.
Control memory reversed in the system cannot be used.
Attributes
Device No. R: Read only. Function
Blank: R/W

CM0000, CM0001 Set up 1st line display device


CM0002, CM0003 Operation panel Set up 2nd line display device
CM0004, CM0005 KV-D30 Set up 3rd line display device
CM0006, CM0007 - 0 Page Set up 4th line display device
CM0008, CM0009 Reserved for system
CM0010 to CM0199 Page 1 to 19 (same as CM0000 to CM0009)
CM0200, CM0201 Set up 1st line display attribute
CM0202, CM0203 Set up 2nd line display attribute
Operation panel
CM0204, CM0205 Set up 3rd line display attribute
KV-D30
CM0206, CM0207 Set up 4th line display attribute
0 Pages
CM0208 Setup module 1
APPENDICES

CM0209 Setup module 2


CM0210 to CM0399 Page 1 to 19 (same as CM0200 to CM0209)
CM0400 For conversion enable/inhibited setting
CM0401 For settings of page conversion
CM0402 Operation panel Current display page
CM0403 to CM0409 KV-D30 Reserved for system
CM0410 to CM0415 Direct access function
CM0416 to CM0499 - Reserved for system
CR/CM List

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 (s)
CM0706 R (week)(0: (Sun), 1 (Mon), 2: (Tues) 3: (Wed) 4: (Thur) 5: (Fri), 6 (Sat))
CM0707 - Reserved for system
CM0708, CM0709 R Free Run Counter (32-bit, 1ms)
CM0710 R Current memory No.of FM
CM0711 R If V2.0 CPU functional version is used, save "2", for other situations, save "0"
CM0712 R Execution time of constant cycle module (10μs unit)
CM0713 to CM0715 - Reserved for system
CM0716 Maximum exeuction time (10μs unit) for Fixed Period Module
CM0717 to CM0719 - Reserved for system
CM0720 R Scan time measuring value (10μs unit)
CM0721 Fixed scanning time run set value (10μs unit)
Exceeds scanning time set up (-fixed scanning time running/END processing time
CM0722 R
settings) scanning time (10μs unit)
CM0723 END processing time measured value (10μs unit)
CM0724 to CM0725 - Reserved for system
CM0726 R Minimum fixed scanning time (10μs unit)
CM0727 R Maximum fixed scanning time (10μs unit)
CM0728 END processing time set value (10μs unit)
Exceeds scanning time set up (-fixed scanning time running/END processing time
CM0729
settings) scanning time (10μs unit)

A-24 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CM0730 to CM1479 - Reserved for system


CM1480, CM1481 R Frequency Frequency measuring result(Hz or rpm)
CM1482 counter function 1Number of placed pulse
CM1483 (CTH0) Scan times
CM1484, CM1485 Specify frequency Setup frequency (Hz)
pulse output
CM1486 function. Duty ratio (0 to 100%)
CM1487 to CM1489 - Reserved for system
CM1490, CM1491 R Frequency Frequency measuring result (Hz or rpm)
CM1492 counter function Number of pulses per rotation
CM1493 (CTH1) Scan times
CM1494, CM1495 Specify frequency Setup frequency (Hz)
pulse output
CM1496 function. Duty ratio (0 to 100%)
CM1497 to CM1593 - Reserved for system
CM1594 CTH0 change direction detection constant

APPENDICES
CM1595 CTH01 change direction detection constant
CM1596, CM1597 Lower limit of CTH0 ring counter
CM1598, CM1599 Lower limit of CTH1 ring counter
CM1600, CM1601 CTH0 ring counter upper limit
CM1602, CM1603 CTH1 ring counter upper limit
CM1604, CM1605 CTH0 preset value
CM1606, CM1607 CTH1 preset value
CM1608 CTH0 start, reset, polarity set up

CR/CM List
CM1609 CTH0 start, reset, polarity set up
CM1610, CM1611 R INT R00000 Input capture (high bit, low bit) when occurred
CM1612, CM1613 R INT R00001 Input capture (high bit, low bit) when occurred
CM1614, CM1615 R INT R00002 Input capture (high bit, low bit) when occurred
CM1616, CM1617 R INT R00003 Input capture (high bit, low bit) when occurred
CM1618, CM1619 - Reserved for system
CM1620 Setup constant when inputting
CM1621 to CM1649 - Reserved for system
CM1650 R Executed number of sensor setting command
CM1651 to CM1659 R Reserved for system
CM1660 to CM1669 R Log/trace Ring Buffer free space (ID0 to ID10)
CM1670 to CM1679 - Reserved for system
CM1680 to CM1689 R Log/trace File Save 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 Access user message 2 (up to 24 characters + end character (00 H))
CM1738 Window Setting Inhibited Operation
CM1739 - Reserved for system

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-25


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CM1740 to CM1756 LD project name (up to 32 characters +end character (00 H))
CM1757 to CM1763 Access window display project name (up to 12 characters + end character (00 H))
CM1764 to CM1774 Bluetooth device identification name (up to 20 characters + terminal code (00H)) *1
CM1775 to CM1779 Reserved for system
CM 1780 AW initial menu setting is enabled
CM1781 AW initial menu setting device type
CM1782,CM1783 AW initial menu setting menu ID
CM1784,CM1785 AW initial menu setting device No.
CM1786 AW initial menu setting display format
CM1787 AW initial menu setting device name representation
CM1788 AW initial menu setting key lock state
CM1789 AW initial menu setting display language
CM1790 Automatic loading folder No. When powered on (request)
CM1791 Automatic loading folder No. When powered on (completed)
CM1792 Automatic loading folder No. For PROG/RUN (request)
CM1793 Automatic loading folder No. For PROG/RUN (completed)
APPENDICES

CM1794 to CM1799 Reserved for system


Year month (decimal number, lower two 2 digits represent month,
CM1800 digits above hundred digit represent year.
Example: 707 -> June, 2007
CM1801 Serious error log day
(latest)
CM1802 hour(0 to 23)
CM1803 minute
CM1804 Error No.
CR/CM List

CM1805 to CM1899 Error log (2 to 20 records, same as CM1800 to CM1804)


Year month (decimal number, lower two 2 digits represent month,
CM1900 digits above hundred digit represent year.
Example: 707 -> June, 2007
CM1901 Power ON log day
(latest)
CM1902 hour(0 to 23)
CM1903 minute
CM1904 second
CM1905 to CM1999 Power ON log (2 to 20 records, same as CM1800 to CM1804)
*1 Only CPU unit that supports Bluetooth communication is valid.

A-26 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CM2000 I/O setting


CM2001 Start sensor
CM2002, CM2003 Comparator 0
CM2004, CM2005 Comparator 1
CM2006 Origin return: starting speed
CM2007 Zero return: acceleration/deceleration time
CM2008, CM2009 Origin return: running speed
CM2010 JOG operation: starting speed
CM2011 CPU JOG operation: acceleration/deceleration time
CM2012, CM2013 Positioning JOG operation: running speed
CM2014, CM2015 function Current value change setting value
CM2016, CM2017 X axis Operation speed change setting value
CM2018 Set up the origin return detail
CM2019 Operation in progress point No.(M code)
CM2020, CM2021 R Current position
CM2022, CM2023 R Current speed

APPENDICES
CM2024 Error code
CM2025 Specify point No.
CM2026, CM2027 Resting position coordinate setpoint
CM2028, CM2029 Comparator 2
CM2030 I/O setting
CM2031 Start sensor
CM2032, CM2033 Comparator 0

CR/CM List
CM2034, CM2035 Comparator 1
CM2036 Origin return: starting speed
CM2037 Zero return: acceleration/deceleration time
CM2038, CM2039 Origin return: running speed
CM2040 JOG operation: starting speed
CM2041 CPU JOG operation: acceleration/deceleration time
CM2042, CM2043 Positioning JOG operation: running speed
CM2044, CM2045 function Current value change setting value
CM2046, CM2047 Y axis Operation speed change setting value
CM2048 Set up the origin return detail
CM2049 Operation in progress point No.(M code)
CM2050, CM2051 R Current position
CM2052, CM2053 R Current speed
CM2054 Error code
CM2055 Specify point No.
CM2056, CM2057 Resting position coordinate setpoint
CM2058, CM2059 Comparator 2
CM2060, CM2061 Target value/amount of movement
CM2062 Startup speed
CPU
CM2063 Positioning Acceleration/deceleration time
CM2064, CM2065 function Operation speed
CM2066 Point parameter Operation mode
0
CM2067 Specified pulse number for stop sensor
CM2068, CM2069 Reserved for system
CM2070 to CM2379 Point parameter 1 to 31 (The same with CM2060 to CM2069)
CM2380 to CM2389 - Reserved for system
CM2390 R Error code used for memory card instruction

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-27


CR/CM List

Attributes
Device No. R: Read only. Function
Blank: R/W

CM2391 Power OFF when accessing memory plug-in board (when occurred: the value other than 0)
CM2392 Memory card retry occurrence times (still hold in case of power off)
CM2393 Memory card check error times (still hold in case of power off)
CM2394 Memory card timeout occurrence times (still hold in case of power off)
When error occurs on the memory card reset delay time
CM2395
(in ms, upper limit is 10000[10 s], do not reset if set to 65535)
CM2392 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 cycle module)
CM2417 to CM2999 - Reserved for system
CM3000 Number of received texts
CM3001 to CM3999 Text received data (1998-byte)
CM4000 Number of sending texts
CM4001 to CM4999 Text send data (1998-byte)
Year month (decimal number, lower two 2 digits represent month,
CM5000 digits above hundred digit represent year.
Example: 707 -> June, 2007
APPENDICES

CM5001 Power OFF log day


(latest)
CM5002 hour(0 to 23)
CM5003 minute
CM5004 second
CM5005 to CM5099 Power OFF log (2 to 20 units the same with CM5000 to CM5004)
Year month (decimal number, lower two 2 digits represent month,
CM5100 digits above hundred digit represent year.
Example: 707 -> June, 2007
CR/CM List

CM5101 day
CM5102 HH
CM5103 minute
CM5104 Latest serious second
error detail
CM5105 Error No.
information 1 unit*
CM5106 Effective data number of expansion information
CM5107 Detailed information 1*
CM5108 Detailed information 2*
: :
: :
CM5126 Detailed information 20*
Year month (decimal number, lower two 2 digits represent month,
CM5150 digits above hundred digit represent year.
Example: 707 -> June, 2007
CM5151 day
CM5152 hour
CM5153 minute
CM5154 Latest general second
warning detail
CM5155 * Error No.
information 1 unit
CM5156 Effective data number of expansion information
CM5157 Detailed information 1*
CM5158 Detailed information 2*
: :
: :
CM5176 Detailed information 20*
CM5177 to CM5999 - Reserved for system
* Detailed information error is coded as follows:

A-28 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

• When No.128 (calculation error)


Detailed information n Description
Detailed information 1 Details of error
0 (not used)
1 Improper indirect specification
2 The indirectly specified target is T/C
3 Improper simple indirect specifying
4 Beyond operand range
5 Floating real number overflow
6 Improper device specifying
7 ROOT operand is negative
8 No ENCO instruction ON bit
9 Floating-point real number error
10 Trigonometric function operand error
11 data cannot be converted
12 Improper table specifying
13 Time comparison instruction operand error
14 Cam switch operand error

APPENDICES
15 Frequency counter instruction operand error
16 0 division operation
17 Record ID illegal
18 Direct Processing Error
19 The units cannot direct processed
20 Subroutine does not exist for transfer target
21 Writing during RUN, cannot execute command

CR/CM List
22 Expansion unit special command object error (unit No.)
23 Reserved for system
24 PIDAT operation setting out-of-range
25 PIDAT sampling period out-of-range
26 PIDAT constant of proportionality out-of-range
27 PIDAT integral constant out-of-range
28 PIDAT differential constant out-of-range
29 PIDAT constant of proportionality two degree freedom parameters are out of scope
30 PIDAT integral constant two degree freedom parameters are out of scope
31 PIDAT differential constant two degree freedom parameters are out of scope
32 PIDAT operation quantity upper limit value/lower limit value out-of-range
33 PIDAT operation quantity change amplitude critical value is out of scope
34 PIDAT measured value change amplitude is out of scope
35 PIDAT AT state transition exception
36 PIDAT operational control mark is out of scope
37 PIDAT operation period is out of scope
38 PIDAT AT adjusting parameters are out of scope
39 PIDAT AT lagging is out of scope
40 PIDAT AT timeout value is out of scope
41 PIDAT AT calculation control mode setting is out of range
42 PIDAT AT timeout
43 PIDAT AT constant of proportionality is out of scope
44 PIDAT AT integral constant is out of scope
45 PIDAT AT differential constant is out of scope
46 Root of negative number cannot be calculated
47 Independent variable of ABS command is incorrect
48 Operation overflow

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-29


CR/CM List

Detailed information n Description


Detailed information 2 00H fixed
Detailed information 3 Step number high bit error
Detailed information 4 Step number low bit error
Detailed information 5 to 20 Use SJIS to store module name. (the part other than module name is 00H)
· No.50,53,55,56,58,59 (unit ID related errors)
Detailed information n Description
Unit No. (according to occurrence state of error, when unit No. Cannot be
Detailed information 1
designated, it will not be saved.)
Detailed information 2 to 20 00H fixed

· When No.54 (error related with number of units)


Detailed information n Description
Detailed information 1 Number of units on unit setting information
Detailed information 2 Actually connected number of units
Detailed information 3 to 20 00H fixed
APPENDICES

· When No.127 (automatic read error)


Detailed information n Description
Details of error
Detailed information 1
For details, refer to "Errors during load/save execution".
Detailed information 2 to 20 00H fixed

· When No.129 (unit error)


CR/CM List

Detailed information n Description


Detailed information 1 Unit No.
Detailed information 2 Error No. of each unit
Detailed information 3 to 20 00H fixed

· In case of error numbers other than above


Detailed information n Description
Detailed information 1 to 20 00H fixed

A-30 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Control Relays CR (For KV Nano series)

Control relays (CR0000 to CR8915) can be used to perform operations such as checking the operation
status of the base unit and setting and monitoring the built-in functions.
Control relays reserved for the system cannot be used.
Attribute
CR R: Read only Function
Blank: Read/write
Logging and tracing execution (ON: enabled, OFF:
CR0000
disabled)
CR0001 R Logging or tracing operation in progress
CR0002 R Logging or tracing file writing completion
CR0003 R Logging buffer less than 50% warning
CR0004 R Logging buffer overflow
CR0005 R Data to be written in RUN mode during logging present
CR0006,
- Reserved for the system
CR0007 Logging or tracing function (ID0)
CR0008 R Logging or tracing error

APPENDICES
CR0009 R Logging or tracing insufficient memory card capacity error
CR0010 R Logging or tracing device or trigger setting error
CR0011 R Tracing file save trigger monitor
CR0012 R Tracing data capture completion
CR0013 R Logging or tracing setting to be written present
CR0014,
- Reserved for the system
CR0015
CR0100 to
Logging or tracing function (ID1 to ID9) (The same as CR0000 to CR0015)
CR0915
CR1000 to

CR/CM List
Real-time chart monitor (ID10) (The same as CR0000 to CR0015)
CR1015
CR1100 to
- Reserved for the system
CR2001
CR2002 R Always turned ON
CR2003 R Always turned OFF
CR2004 R 10 ms clock pulse (duty cycle: 50%)
CR2005 R 100 ms clock pulse (duty cycle: 50%)
CR2006 R 1 s clock pulse (duty cycle: 50%)
CR2007 R Turned OFF for just one scan when operation starts
CR2008 R Turned ON for just one scan when operation starts
CR2009 Turned ON when the calculation result is negative or when an overflow occurs
CR2010 R Turned ON when the calculation result is zero
CR2011 R Turned ON when the calculation result is positive
CR2012 R Turned ON when a calculation execution error occurs
CR2013 to
- Reserved for the system
CR2100
CR2101 R Indicates the presence of extension unit 1 (ON: connected, OFF: not connected)
CR2102 R Indicates the presence of extension unit 2 (ON: connected, OFF: not connected)
CR2103 to
- Reserved for the system
CR2200
CR2201 R Indicates the presence of expansion unit 1 (ON: connected, OFF: not connected)
CR2202 R Indicates the presence of expansion unit 2 (ON: connected, OFF: not connected)
CR2203 R Indicates the presence of expansion unit 3 (ON: connected, OFF: not connected)
CR2204 R Indicates the presence of expansion unit 4 (ON: connected, OFF: not connected)
CR2205 R Indicates the presence of expansion unit 5 (ON: connected, OFF: not connected)
CR2206 R Indicates the presence of expansion unit 6 (ON: connected, OFF: not connected)
CR2207 R Indicates the presence of expansion unit 7 (ON: connected, OFF: not connected)
CR2208 R Indicates the presence of expansion unit 8 (ON: connected, OFF: not connected)

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-31


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR2209 to
- Reserved for the system
CR2215
CR2300 External output disabled (ON: execute, OFF: do not execute)
CR2301 External input refresh disabled (ON: execute, OFF: do not execute)
CR2302 - Reserved for the system
CR2303 Fixed scan time operation (ON: enabled, OFF: disabled)
Turned ON for just one scan when the scan time setting (the fixed scan time operation and END
CR2304 R
processing time settings) is exceeded
Sets the input time constant of all inputs of the base unit
CR2305
(ON: the value is set according to CM1620, OFF: the value is not set)
CR2306 - Reserved for the system
CR2307 Clears the minimum and maximum scan time values
Sets the END processing time (ON: enabled, OFF: disabled; if CR2303 is turned ON at the same
CR2308
time, CR2303 is given priority)
CR2309 Reserved for the system
CR2310 R Indicates the presence of a calendar timer (ON: present, OFF: not present)
This is turned ON when a clock data lost error occurs (it is turned OFF when the clock data is
CR2311 R
written)
CR2312 - Reserved for the system
APPENDICES

CR2313 Forces switch of the VT sensor application screen (ON: switch, OFF: do not switch)
CR2314 Project password authentication status (ON: authentication disabled, OFF: authentication enabled)
CR2315 to
- Reserved for the system
CR2515
INT0 interrupt polarity

CR2600, Rising Edge Falling Edge Both Rising and Falling Edges
CR2601 CR2600 OFF ON OFF ON
CR2601 OFF OFF ON ON
CR/CM List

INT1 interrupt polarity

CR2602, Rising Edge Falling Edge Both Rising and Falling Edges
CR2603 CR2602 OFF ON OFF ON
CR2603 OFF OFF ON ON

INT2 interrupt polarity

CR2604, Rising Edge Falling Edge Both Rising and Falling Edges
CR2605 CR2604 OFF ON OFF ON
CR2605 OFF OFF ON ON

INT3 interrupt polarity

CR2606, Rising Edge Falling Edge Both Rising and Falling Edges
CR2607 CR2606 OFF ON OFF ON
CR2607 OFF OFF ON ON

CR2608 to
Reserved for the system
CR2813
Zero suppression during execution of DASC and FASC instructions (all suffixes; ON: execute,
CR2814
OFF: do not execute)
Omission of "+" during execution of DASC.S, DASC.L, and FASC instructions (ON: execute, OFF:
CR2815
do not execute)
User message display 1
CR2900
(ON: displayed, OFF: hidden)
Access window
User message display 2
CR2901
(ON: displayed, OFF: hidden)
CR2902 to
- Reserved for the system
CR2914
CR2915 R Indicates the presence of an access window cassette (ON: connected, OFF: not connected)
CR3000 Project load execution request
CR3001 - Reserved for the system
CR3002 Project save execution request
CR3003 - Reserved for the system
CR3004 Project load execution completion
A-32 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR3005 Project load execution failure
CR3006 Project save execution completion
CR3007 Project save execution failure
CR3008 to
- Reserved for the system
CR3209
CR3210 R Optional logging or tracing memory card is in use
CR3211 R Memory card is in use
CR3212 R Memory card recognition complete
CR3213 R Memory card present
CR3214 R Memory card executing instructions
CR3215 R Memory card write protection
CR3300 to
- Alarm relays
CR3415
CR3500 R Alarm operation relay (ON: one of CR3300 to CR3415 is turned ON)
Record an entry in the log when an alarm relay switches from ON to OFF (ON: record, OFF: do not
CR3501
record)
CR3502 The alarm relay log is cleared when this switches from OFF to ON
CR3503 to
Reserved for the system

APPENDICES
CR3513
CR3514 Disables multiple keys
HKEY instruction
CR3515 R Scan completion
CR3600 to
R HKEY information storage area
CR3615
CR3700 F1 customize switch 1
CR3701 F2 customize switch 2
CR3702 F3 customize switch 3
CR3703 F4 customize switch 4

CR/CM List
CR3704 LED1 customize indicator 1
CR3705 LED2 customize indicator 2
CR3706 LED3 customize indicator 3
CR3707 LED4 customize indicator 4
CR3708 Green back light (lights when this is turned ON)
CR3709 Red back light (lights when this is turned ON)
Operator panel KV-D30 System message display language (ON: Japanese, OFF:
CR3710
English)
CR3711 Buzzer ON
Screen display setting (ON: positive display, OFF:
CR3712
negative display)
CR3713 Alarm interrupt enable (ON: enabled, OFF: disabled)
Page switching (switches to the page indicated by the
CR3714
value of CM0401 on a rising edge; forced OFF)

CR3715 Disables page switching using the "▲" and "▼" keys
(ON: disabled, OFF: enabled)
CR3800 Sets external output 0 to ON when this is turned ON
CR3801 Sets external output 1 to ON when this is turned ON
CR3802 to
- Reserved for the system
CR3815
CR3900 The serious error log is cleared when this switches from OFF to ON
CR3901 The minor error log is cleared when this switches from OFF to ON
CR3902 R Indicates that the serious error log is full
CR3903 R Indicates that the minor error log is full
CR3904 R RUN-PROG selector switch status (ON: RUN, OFF: PROG)
CR3905 R A serious error has occurred
CR3906 R A minor error has occurred
CR3907 The power on log is cleared when this switches from OFF to ON
CR3908 The power off log is cleared when this switches from OFF to ON
CR3909 Clears the current error

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-33


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR3910 to
- Reserved for the system
CR4115
CR4200 R CTH0 dedicated internal clock (50 ns)
CR4201 R CTH0 dedicated internal clock (1 μs)
CR4202 R CTH0 dedicated internal clock (10 μs)
CR4203 R CTH0 dedicated internal clock (100 μs)
CR4204 - Reserved for the system
CR4205 R Indicates the presence of CTH0 (ON: present, OFF: not present)
CR4206 Detects overflows and underflows of CTH0 (ON: detected, OFF: not detected)
CR4207 R Indicates the change direction of CTH0 (ON: down counting, OFF: up counting)
CTH0 external signal preset

CR4208, Not Used Rising Edge Falling Edge Level


CR4209 CR4208 OFF ON OFF ON
CR4209 OFF OFF ON ON

CR4210 CTH0 count mode selection (ON: ring, OFF: linear)


CR4211 CTH0 preset disabled (ON: execute, OFF: do not execute)
CR4212 CTH0 internal enable relay (ON: counting enabled, OFF: counting disabled)
APPENDICES

CR4213 to
- Reserved for the system
CR4302
Automatic reset of CTH0 (ON: execute, OFF: do not
CR4303
execute)
Comparator matching output disabled when comparator
CR4304
CTC0 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4305 Action when high-speed counter comparator CTC0 is turned ON (ON: execute, OFF: do
comparator CTC0 is turned ON not execute)
Comparator matching output turned ON when comparator
CR/CM List

CR4306
CTC0 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
CR4307 time that comparator CTC0 is turned ON (ON: execute,
OFF: do not execute)
Comparator matching output disabled when comparator
CR4308
CTC1 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4309 comparator CTC1 is turned ON (ON: execute, OFF: do
not execute)
Action when high-speed counter Comparator matching output turned ON when comparator
CR4310
comparator CTC1 is turned ON CTC1 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
CR4311 time that comparator CTC1 is turned ON (ON: execute,
OFF: do not execute)
Automatic reset of CTH0 (ON: execute, OFF: do not
CR4312
execute)
High-speed counter CTH0 count input mode selection

Single Phase
1x 2x 4x 2-Pulse
CR4313 to W/O Direction W/ Direction
CR4315 CR4313 OFF ON OFF ON OFF ON
CR4314 OFF OFF ON ON OFF OFF
CR4315 OFF OFF OFF OFF ON ON

CR4400 R CTH1 dedicated internal clock (50 ns)


CR4401 R CTH1 dedicated internal clock (1 μs)
CR4402 R CTH1 dedicated internal clock (10 μs)
CR4403 R CTH1 dedicated internal clock (100 μs)
CR4404 - Reserved for the system
CR4405 R Indicates the presence of CTH1 (ON: present, OFF: not present)
CR4406 Detects overflows and underflows of CTH1 (ON: detected, OFF: not detected)
CR4407 R Indicates the change direction of CTH1 (ON: down counting, OFF: up counting)

A-34 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CTH1 external signal preset

CR4408, Not Used Rising Edge Falling Edge Level


CR4409 CR4408 OFF ON OFF ON
CR4409 OFF OFF ON ON

CR4410 CTH1 count mode selection (ON: ring, OFF: linear)


CR4411 CTH1 preset disabled (ON: execute, OFF: do not execute)
CR4412 CTH1 internal enable relay (ON: counting enabled, OFF: counting disabled)
CR4413 to
- Reserved for the system
CR4502
Automatic reset of CTH1 (ON: execute, OFF: do not
CR4503
execute)
Comparator matching output disabled when comparator
CR4504
CTC2 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4505 Action when high-speed counter comparator CTC2 is turned ON (ON: execute, OFF: do
comparator CTC2 is turned ON not execute)
Comparator matching output turned ON when comparator
CR4506
CTC2 is turned ON (ON: execute, OFF: do not execute)

APPENDICES
Comparator matching output inversion (ON/OFF) each
CR4507 time that comparator CTC2 is turned ON (ON: execute,
OFF: do not execute)
Comparator matching output disabled when comparator
CR4508
CTC3 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4509 comparator CTC3 is turned ON (ON: execute, OFF: do
not execute)
Action when high-speed counter Comparator matching output turned ON when comparator
CR4510
comparator CTC3 is turned ON CTC3 is turned ON (ON: execute, OFF: do not execute)

CR/CM List
Comparator matching output inversion (ON/OFF) each
CR4511 time that comparator CTC3 is turned ON (ON: execute,
OFF: do not execute)
Automatic reset of CTH1 (ON: execute, OFF: do not
CR4512
execute)
CTH1 count input mode selection
Single Phase
1x 2x 4x 2-Pulse
CR4513 to W/O Direction W/ Direction
CR4515 CR4513 OFF ON OFF ON OFF ON
CR4514 OFF OFF ON ON OFF OFF
CR4515 OFF OFF OFF OFF ON ON

CR4600 R CTH2 dedicated internal clock (50 ns)


CR4601 R CTH2 dedicated internal clock (1 μs)
CR4602 R CTH2 dedicated internal clock (10 μs)
CR4603 R CTH2 dedicated internal clock (100 μs)
CR4604 - Reserved for the system
CR4605 R Indicates the presence of CTH2 (ON: present, OFF: not present)
CR4606 Detects overflows and underflows of CTH2 (ON: detected, OFF: not detected)
CR4607 R Indicates the change direction of CTH2 (ON: down counting, OFF: up counting)
CTH2 external signal preset

CR4608, Not Used Rising Edge Falling Edge Level


CR4609 CR4608 OFF ON OFF ON
CR4609 OFF OFF ON ON

CR4610 CTH2 count mode selection (ON: ring, OFF: linear)


CR4611 CTH2 preset disabled (ON: execute, OFF: do not execute)
CR4612 CTH2 internal enable relay (ON: counting enabled, OFF: counting disabled)
CR4613 to
- Reserved for the system
CR4702

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-35


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
Automatic reset of CTH2 (ON: execute, OFF: do not
CR4703
execute)
Comparator matching output disabled when comparator
CR4704
CTC4 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4705 Action when high-speed counter comparator CTC4 is turned ON (ON: execute, OFF: do
comparator CTC4 is turned ON not execute)
Comparator matching output turned ON when comparator
CR4706
CTC4 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
CR4707 time that comparator CTC4 is turned ON (ON: execute,
OFF: do not execute)
Comparator matching output disabled when comparator
CR4708
CTC5 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4709 comparator CTC5 is turned ON (ON: execute, OFF: do
not execute)
Action when high-speed counter Comparator matching output turned ON when comparator
CR4710
comparator CTC5 is turned ON CTC5 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
APPENDICES

CR4711 time that comparator CTC5 is turned ON (ON: execute,


OFF: do not execute)
Automatic reset of CTH2 (ON: execute, OFF: do not
CR4712
execute)
CTH2 count input mode selection

Single Phase
1x 2x 4x 2-Pulse
CR4713 to W/O Direction W/ Direction
CR4715 CR4713 OFF ON OFF ON OFF ON
CR4714 OFF OFF ON ON OFF OFF
CR/CM List

CR4715 OFF OFF OFF OFF ON ON

CR4800 R CTH3 dedicated internal clock (50 ns)


CR4801 R CTH3 dedicated internal clock (1 μs)
CR4802 R CTH3 dedicated internal clock (10 μs)
CR4803 R CTH3 dedicated internal clock (100 μs)
CR4804 - Reserved for the system
CR4805 R Indicates the presence of CTH3 (ON: present, OFF: not present)
CR4806 Detects overflows and underflows of CTH3 (ON: detected, OFF: not detected)
CR4807 R Indicates the change direction of CTH3 (ON: down counting, OFF: up counting)
CTH3 external signal preset

CR4808, Not Used Rising Edge Falling Edge Level


CR4809 CR4808 OFF ON OFF ON
CR4809 OFF OFF ON ON

CR4810 CTH3 count mode selection (ON: ring, OFF: linear)


CR4811 CTH3 preset disabled (ON: execute, OFF: do not execute)
CR4812 CTH3 internal enable relay (ON: counting enabled, OFF: counting disabled)
CR4813 to
- Reserved for the system
CR4902
Automatic reset of CTH3 (ON: execute, OFF: do not
CR4903
execute)
Comparator matching output disabled when comparator
CR4904
CTC6 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4905 Action when high-speed counter comparator CTC6 is turned ON (ON: execute, OFF: do
comparator CTC6 is turned ON not execute)
Comparator matching output turned ON when comparator
CR4906
CTC6 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
CR4907 time that comparator CTC6 is turned ON (ON: execute,
OFF: do not execute)

A-36 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
Comparator matching output disabled when comparator
CR4908
CTC7 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output turned OFF when
CR4909 comparator CTC7 is turned ON (ON: execute, OFF: do
not execute)
Action when high-speed counter Comparator matching output turned ON when comparator
CR4910
comparator CTC7 is turned ON CTC7 is turned ON (ON: execute, OFF: do not execute)
Comparator matching output inversion (ON/OFF) each
CR4911 time that comparator CTC7 is turned ON (ON: execute,
OFF: do not execute)
Automatic reset of CTH3 (ON: execute, OFF: do not
CR4912
execute)
Multiplication mode selection of CTH3

Single Phase
1x 2x 4x 2-Pulse
CR4913 to W/O Direction W/ Direction
CR4915 CR4913 OFF ON OFF ON OFF ON
CR4914 OFF OFF ON ON OFF OFF
CR4915 OFF OFF OFF OFF ON ON

APPENDICES
CR5000 to
- Reserved for the system
CR5315
CR5400 Start operation (ON: execute, OFF: do not execute)
CTH0 input source setting
Single Phase Double
CR5401, W/O W/ Phase 2-Pulse
CR5402 Direction Direction 1x
CR5401 OFF ON OFF ON
Frequency counter (CTH0)
CR5402 OFF OFF ON ON

CR/CM List
CR5403 Switches between Hz and rpm (ON: rpm, OFF: Hz)
Function in which one rotation is performed to update the
CR5404
rotation speed (ON: use, OFF: do not use)
Input source switching function (ON: use, OFF: do not
CR5405
use)
CR5406,
- Reserved for the system
CR5407
CR5408 Specified frequency pulse output (CTH0; ON: execute, OFF: do not execute)
CR5409 Specified frequency pulse output (CTH0) error
CR5410 to
- Reserved for the system
CR5415
CR5500 Start operation (ON: execute, OFF: do not execute)
CTH1 input source setting
Single Phase Double
CR5501, W/O W/ Phase 2-Pulse
CR5502 Direction Direction 1x
CR5501 OFF ON OFF ON
Frequency counter (CH1)
CR5502 OFF OFF ON ON

CR5503 Switches between Hz and rpm (ON: rpm, OFF: Hz)


Function in which one rotation is performed to update the
CR5504
rotation speed (ON: use, OFF: do not use)
Input source switching function (ON: use, OFF: do not
CR5505
use)
CR5506,
- Reserved for the system
CR5507
CR5508 Specified frequency pulse output (CTH1; ON: execute, OFF: do not execute)
CR5509 Specified frequency pulse output (CTH1) error
CR5510 to
- Reserved for the system
CR5515

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-37


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR5600 Start operation (ON: execute, OFF: do not execute)
CTH2 input source setting
Single Phase Double
CR5601, W/O W/ Phase 2-Pulse
CR5602 Direction Direction 1x
CR5601 OFF ON OFF ON
Frequency counter (CH2)
CR5602 OFF OFF ON ON

CR5603 Switches between Hz and rpm (ON: rpm, OFF: Hz)


Function in which one rotation is performed to update the
CR5604
rotation speed (ON: use, OFF: do not use)
Input source switching function (ON: use, OFF: do not
CR5605
use)
CR5606,
- Reserved for the system
CR5607
CR5608 Specified frequency pulse output (CTH2; ON: execute, OFF: do not execute)
CR5609 Specified frequency pulse output (CTH2) error
CR5610 to
- Reserved for the system
CR5615
APPENDICES

CR5700 Start operation (ON: execute, OFF: do not execute)


CTH3 input source setting
Single Phase Double
CR5701, W/O W/ Phase 2-Pulse
CR5702 Direction Direction 1x
CR5701 OFF ON OFF ON
Frequency counter (CTH3)
CR5702 OFF OFF ON ON
CR5703 Switches between Hz and rpm (ON: rpm, OFF: Hz)
CR/CM List

Function in which one rotation is performed to update the


CR5704
rotation speed (ON: use, OFF: do not use)
Input source switching function (ON: use, OFF: do not
CR5705
use)
CR5706,
- Reserved for the system
CR5707
CR5708 Specified frequency pulse output (CTH3; ON: execute, OFF: do not execute)
CR5709 Specified frequency pulse output (CTH3) error
CR5710 to
- Reserved for the system
CR5715
CR5800 to
- Reserved for the system
CR5915
CR6000 to
For built-in serial assignment
CR6515
CR6600 to
For extension function assignment 1
CR7115
CR7200 to
For extension function assignment 2
CR7715
CR7800 to
- Reserved for the system
CR7915
CR8000 Forced stop
CR8001 Deceleration stop
CR8002 Error clear
CR8003 Warning clear
CR8004 Current coordinate change request (level detection)
CR8005 Operating speed change request (level detection)
CR8006 CPU positioning function, axis 1 Target coordinate change request (level detection)
CR8007 to
- Reserved for the system
CR8011
CR8012 Limit switch CW direction input
CR8013 Limit switch CCW direction input
CR8014 Origin sensor input
CR8015 Stop sensor input

A-38 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR8100 Forced stop
CR8101 Deceleration stop
CR8102 Error clear
CR8103 Warning clear
CR8104 Current coordinate change request (level detection)
CR8105 Operating speed change request (level detection)
CR8106 CPU positioning function, axis 2 Target coordinate change request (level detection)
CR8107 to
- Reserved for the system
CR8111
CR8112 Limit switch CW direction input
CR8113 Limit switch CCW direction input
CR8114 Origin sensor input
CR8115 Stop sensor input
CR8200 Forced stop
CR8201 Deceleration stop
CR8202 Error clear
CR8203 Warning clear
CR8204 Current coordinate change request (level detection)

APPENDICES
CR8205 Operating speed change request (level detection)
CR8206 CPU positioning function, axis 3 Target coordinate change request (level detection)
CR8207 to
Reserved for the system
CR8211
CR8212 Limit switch CW direction input
CR8213 Limit switch CCW direction input
CR8214 Origin sensor input
CR8215 Stop sensor input
CR8300 Forced stop

CR/CM List
CR8301 Deceleration stop
CR8302 Error clear
CR8303 Warning clear
CR8304 Current coordinate change request (level detection)
CR8305 Operating speed change request (level detection)
CR8306 CPU positioning function, axis 4 Target coordinate change request (level detection)
CR8307 to
Reserved for the system
CR8311
CR8312 Limit switch CW direction input
CR8313 Limit switch CCW direction input
CR8314 Origin sensor input
CR8315 Stop sensor input
CR8400 R Turned ON during pulse output
CR8401 R Positioning complete relay
CR8402 R Error
CR8403 R Warning
CR8404 R Origin returning operation in progress
CR8405 R CPU positioning function, axis 1 Origin returning operation complete
CR8406 to
- Reserved for the system
CR8413
Indicates the presence of axis 1 (ON: present, OFF: not
CR8414 R
present)
CR8415 R Comparator 2 matching relay

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-39


CR/CM List

Attribute
CR R: Read only Function
Blank: Read/write
CR8500 R Turned ON during pulse output
CR8501 R Positioning complete relay
CR8502 R Error
CR8503 R Warning
CR8504 R Origin returning operation in progress
CR8505 R CPU positioning function, axis 2 Origin returning operation complete
CR8506 to
- Reserved for the system
CR8513
Indicates the presence of axis 2 (ON: present, OFF: not
CR8514 R
present)
CR8515 R Comparator 2 matching relay
CR8600 R Turned ON during pulse output
CR8601 R Positioning complete relay
CR8602 R Error
CR8603 R Warning
CR8604 R Origin returning operation in progress
CR8605 R CPU positioning function, axis 3 Origin returning operation complete
CR8606 to
- Reserved for the system
APPENDICES

CR8613
Indicates the presence of axis 3 (ON: present, OFF: not
CR8614 R
present)
CR8615 R Comparator 2 matching relay
CR8700 R Turned ON during pulse output
CR8701 R Positioning complete relay
CR8702 R Error
CR8703 R Warning
CR8704 R Origin returning operation in progress
CR/CM List

CR8705 R CPU positioning function, axis 4 Origin returning operation complete


CR8706 to
R Reserved for the system
CR8713
Indicates the presence of axis 4 (ON: present, OFF: not
CR8714 R
present)
CR8715 R Comparator 2 matching relay
CR8800 to
- Reserved for the system
CR8915

A-40 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Control Memory Entries CM (For KV Nano series)

Control memory entries (CM0000 to CM8999) can be used to perform operations such as checking the
operation status of the base unit and setting and monitoring the built-in functions.
Control memory entries reserved for the system cannot be used.
Hold
Attribute
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM0000,
Device setting displayed on the first line Set
CM0001
CM0002,
Device setting displayed on the second line Set
CM0003
CM0004, Operator panel KV-D30
Device setting displayed on the third line Set
CM0005 Page 0
CM0006,
Device setting displayed on the fourth line Set
CM0007
CM0008,
Reserved for the system Set
CM0009
CM0010 to
Page 1 to 19 (the same as CM0000 to CM0009) Set

APPENDICES
CM0199
CM0200,
Attribute setting displayed on the first line Set
CM0201
CM0202,
Attribute setting displayed on the second line Set
CM0203
CM0204,
Operator panel KV-D30 Attribute setting displayed on the third line Set
CM0205
Page 0
CM0206,
Attribute setting displayed on the fourth line Set
CM0207
CM0208 Template 1 setting Set
CM0209 Template 2 setting Set

CR/CM List
CM0210 to
Page 1 to 19 (the same as CM0200 to CM0209) Set
CM0399
CM0400 For enabling and disabling transitions Set
CM0401 For the page switching setting Set
CM0402 Current page displayed Set
CM0403 to Operator panel KV-D30 Reserved for the system Set
CM409
CM0410 to
Direct access function Set
CM415
CM0416 to
Reserved for the system Set
CM0499
CM0500 to
- Reserved for the system
CM699
CM0700 R Read from RTC (year)
CM0701 R Read from RTC (month)
CM0702 R Read from RTC (day)
CM0703 R Read from RTC (hour)
CM0704 R Read from RTC (minute)
CM0705 R Read from RTC (second)
CM0706 R Read from RTC (day of the week)
CM0707 - Reserved for the system
CM0708,
R 32-bit, 1 ms, free-run counter
CM709
CM0710 Reserved for the system
CM0711 R CPU function version

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-41


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM0712 to
- Reserved for the system
CM719
CM0720 R Scan time measured value (in units of 10 μs)
CM0721 Set value during fixed scan time operation (in units of 10 μs)
Scan time (in units of 10 μs) when the scan time setting (the fixed scan time
CM0722 R
operation and END processing time settings) is exceeded
CM0723 R END processing time measured value (in units of 10 μs)
CM0724,
- Reserved for the system
CM725
CM0726 R Minimum scan time value (in units of 10 μs)
CM0727 R Maximum scan time value (in units of 10 μs)
CM0728 END processing time set value (in units of 10 μs)
END processing time (in units of 10 μs) when the scan time setting (the fixed
CM0729 R
scan time operation and END processing time settings) is exceeded
CM0730 to
- Reserved for the system
CM1599
CM1600,
R Input capture when INT0 occurs
CM1601
APPENDICES

CM1602,
R Input capture when INT1 occurs
CM1603
CM1604,
R Input capture when INT2 occurs
CM1605
CM1606,
R Input capture when INT3 occurs
CM1607
CM1608 to
- Reserved for the system
CM1619
CM1620 Input time constant setting ○
CM1621 to
- Reserved for the system
CR/CM List

CM1629
CM1630,
R Analog volume 0
CM1631
CM1632,
R Analog volume 1
CM1633
CM1634 to
- Reserved for the system
CM1649
CM1650 R Number of sensor setting instruction executions
CM1651 to
- Reserved for the system
CM1657
CM1658 R Number of consecutive project password authentication failures ○
CM1659 R Total number of project password authentication failures ○
CM1660 to
R Free space in the logging or tracing ring buffer (in units of kB; ID0 to ID9)
CM1669
CM1670 to
- Reserved for the system
CM1679
CM1680 R Logging or tracing 0 file save counter ○
CM1681 R Logging or tracing 1 file save counter ○
CM1682 R Logging or tracing 2 file save counter ○
CM1683 R Logging or tracing 3 file save counter ○
CM1684 R Logging or tracing 4 file save counter ○
CM1685 R Logging or tracing 5 file save counter ○
CM1686 R Logging or tracing 6 file save counter ○
CM1687 R Logging or tracing 7 file save counter ○
CM1688 R Logging or tracing 8 file save counter ○
CM1689 R Logging or tracing 9 file save counter ○

A-42 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM1690 to
- Reserved for the system
CM1699
CM1700 R AutoLoad folder No. (request) ○
CM1701 R RunLoad folder No. (request) ○
CM1702 R Folder No. during project load (request) ○
CM1703 R Folder No. during project save (request) ○
CM1704 to
Reserved for the system
CM1709
CM1710 R Completion code of automatic loading when power is turned on
CM1711 R Automatic loading folder No. during power-on (complete)
CM1712 R Automatic loading completion code during PROG→RUN ○
CM1713 R Automatic loading folder No. during PROG→RUN (complete) ○
CM1714 R Completion code during project load ○
CM1715 R Folder No. during project load (complete) ○
CM1716 R Completion code during project save ○
CM1717 R Folder No. during project save (complete) ○

APPENDICES
CM1718,
- Reserved for the system
CM1719
CM1720 User message 1 ○
CM1721 to User message 2
CM1737 (up to 24 characters + end code (00H)) ○
CM1738 Access window operation disabled setting ○
CM1739 Reserved for the system
CM1740 to Ladder project name
CM1756 (up to 32 characters + end code (00H))

CR/CM List
CM1757 to Project name to be displayed in the access window
CM1763 (up to 12 characters + end code (00H))
CM1764 to
- Reserved for the system
CM1779
CM1780 Access window initial screen setting, enabled ○
CM1781 Access window initial screen setting, device type ○
Access window
CM1782 Access window initial screen setting, screen ID ○
CM1783 Access window initial screen setting, screen ID ○
CM1784 Access window initial screen setting, device number ○
CM1785 Access window initial screen setting, device number ○
CM1786 Access window initial screen setting, display format ○
Access window initial screen setting, device name
CM1787 ○
representation
CM1788 Access window initial screen setting, key lock status ○
Access window initial screen setting, display
CM1789 ○
language
CM1790 to
- Reserved for the system
CM2199
CM2200 Year and month ○
CM2201 Day ○
CM2202 Hour ○
CM2203 Minute ○
CM2204 Seconds ○
CM2205 Detailed information of Number ○
the latest serious error, 1
CM2206 Detailed information, number of valid pieces of data ○
unit
CM2207 Detailed information, piece 01 ○
CM2208 Detailed information, piece 02 ○
: ○
CM2226 Detailed information, piece 20 ○
CM2227 to
- Reserved for the system
CM2249

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-43


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM2250 Year and month ○
CM2251 Day ○
CM2252 Hour ○
CM2253 Minute ○
CM2254 Seconds ○
Detailed information of
CM2255 the latest minor error, Number ○
1 unit*1
CM2256 Detailed information, number of valid pieces of data ○
CM2257 Detailed information, piece 01 ○
CM2258 Detailed information, piece 02 ○
: ○
CM2276 Detailed information, piece 20 ○
CM2277 to
- Reserved for the system
CM2388
CM2389 R Number of connected expansion units
CM2390 R Error code for memory card instructions
APPENDICES

CM2391 Power OFF when accessing memory card ○


CM2392 Memory card retry occurrence times ○
CM2393 Memory card check error times ○
CM2394 Memory card timeout occurrence times ○
CM2395 - Reset delay time during memory card errors ○
CM2396 to
- Reserved for the system
CM2399
CM2400 to Number of interrupts (INT0 to INT3, CTC0 to CTC7, and positioning axis 1 to
CM2415 axis 4)
CR/CM List

CM2416 to
- Reserved for the system
CM4799
CM4800 Constant when rotation direction is detected ○
CM4801 Enable, clear, and sign setting ○
CM4802,
Ring counter lower limit ○
CM4803
High-speed counter
CM4804,
function (CTH0) Ring counter upper limit ○
CM4805
CM4806,
Preset input ○
CM4807
CM4808,
- Reserved for the system
CM4809
CM4810 Constant when rotation direction is detected ○
CM4811 Enable, clear, and sign setting ○
CM4812,
Ring counter lower limit ○
CM4813
High-speed counter
CM4814,
function (CTH1) Ring counter upper limit ○
CM4815
CM4816,
Preset input ○
CM4817
CM4818,
- Reserved for the system
CM4819
CM4820 Constant when rotation direction is detected ○
CM4821 Enable, clear, and sign setting ○
CM4822,
High-speed counter Ring counter lower limit ○
CM4823
function (CTH2)
CM4824,
Ring counter upper limit ○
CM4825
CM4826,
Preset input ○
CM4827

A-44 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM4828,
- Reserved for the system
CM4829
CM4830 Constant when rotation direction is detected ○
CM4831 Enable, clear, and sign setting ○
CM4832,
High-speed counter Ring counter lower limit ○
CM4833
function (CTH3)
CM4834,
Ring counter upper limit ○
CM4835
CM4836,
Preset input ○
CM4837
CM4838,
- Reserved for the system ○
CM4839
CM4840 to
- Reserved for the system
CM4899
CM4900,
R Frequency measured result (Hz or rpm)
CM4901
CM4902 Number of pulses per rotation ○
Frequency counter
CM4903 function (CTH0) Number of scans ○
CM4904 External input source ○

APPENDICES
CM4905 - Reserved for the system
CM4906 Set frequency (Hz) ○
Specified frequency pulse
CM4908 Duty cycle (0 to 100%) ○
output function (CH0)
CM4909 - Reserved for the system
CM4910,
R Frequency measured result (Hz or rpm)
CM4911
CM4912 Number of pulses per rotation ○
Frequency counter
CM4913 function (CTH1) Number of scans ○

CR/CM List
CM4914 External input source ○
CM4915 - Reserved for the system
CM4916 Set frequency (Hz) ○
Specified frequency pulse
CM4918 Duty cycle (0 to 100%) ○
output function (CH1)
CM4919 - Reserved for the system
CM4920,
R Frequency measured result (Hz or rpm)
CM4921
CM4922 Number of pulses per rotation ○
Frequency counter
CM4923 function (CTH2) Number of scans ○
CM4924 External input source ○
CM4925 - Reserved for the system
CM4926 Set frequency (Hz) ○
Specified frequency pulse
CM4928 Duty cycle (0 to 100%) ○
output function (CH2)
CM4929 - Reserved for the system
CM4930,
R Frequency measured result (Hz or rpm)
CM4931
CM4932 Number of pulses per rotation ○
Frequency counter
CM4933 function (CTH3) Number of scans ○
CM4934 External input source ○
CM4935 - Reserved for the system
CM4936 Set frequency (Hz) ○
Specified frequency pulse
CM4938 Duty cycle (0 to 100%) ○
output function (CH3)
CM4939 Reserved for the system
CM4940 to
- Reserved for the system
CM4999
CM5000 to
For built-in serial assignment
CM5999

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-45


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM6000 to
For extension function assignment 1
CM6999
CM7000 to
For extension function assignment 2
CM7999
CM8000,
Target value or travel Set
CM8001
CM8002 Acceleration rate Set
CM8003 Deceleration rate Set
CM8004, CPU positioning function,
axis 1
Operation frequency Set
CM8005
CM8006 Point parameter 1 Operation mode Set
CM8007 Reserved for the system Set
CM8008 Travel after stop sensor input Set
CM8009 - Reserved for the system
CM8010 to CPU positioning function, Point parameters 2 to 20
Set
CM8199 axis 1 (the same as CM8000 to CM8009)
CM8200,
Target value or travel Set
CM8201
APPENDICES

CM8202 Acceleration rate Set


CM8203 Deceleration rate Set
CM8204, CPU positioning function,
axis 2
Operation frequency Set
CM8205
CM8206 Point parameter 1 Operation mode Set
CM8207 Reserved for the system Set
CM8208 Travel after stop sensor input Set
CM8209 - Reserved for the system
CR/CM List

CM8210 to CPU positioning function, Point parameters 2 to 20


Set
CM8399 axis 2 (the same as CM8200 to CM8209)
CM8400,
Target value or travel Set
CM8401
CM8402 Acceleration rate Set
CM8403 Deceleration rate Set
CM8404, CPU positioning function,
axis 3
Operation frequency Set
CM8405
CM8406 Point parameter 1 Operation mode Set
CM8407 Reserved for the system Set
CM8408 Travel after stop sensor input Set
CM8409 - Reserved for the system
CM8410 to CPU positioning function, Point parameters 2 to 20
Set
CM8599 axis 3 (the same as CM8400 to CM8409)
CM8600,
Target value or travel Set
CM8601
CM8602 Acceleration rate Set
CM8603 Deceleration rate Set
CM8604, CPU positioning function,
axis 4
Operation frequency Set
CM8605
CM8606 Point parameter 1 Operation mode Set
CM8607 Reserved for the system Set
CM8608 Travel after stop sensor input Set
CM8609 - Reserved for the system
CM8610 to CPU positioning function, Point parameters 2 to 20
Set
CM8799 axis 4 (the same as CM8600 to CM8609)

A-46 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM8800 I/O setting
CM8801 Sensor enable
CM8802,
Comparator 0, current value
CM8803
CM8804,
Comparator 1, current value
CM8805
CM8806,
Comparator 2, positioning
CM8807
CM8808 Starting speed
CM8809 Origin returning operation: starting frequency
CM8810 Origin returning operation: acceleration rate
CM8811 Origin returning operation: deceleration rate
CM8812,
Origin returning operation: operation frequency
CM8813
CM8814 Origin returning operation: detailed settings
CM8815 JOG operation: starting frequency
CM8816 JOG operation: acceleration rate

APPENDICES
CM8817 CPU positioning function, JOG operation: deceleration rate
axis 1
CM8818,
JOG operation: operation frequency
CM8819
CM8820,
Home position
CM8821
CM8822,
- Reserved for the system
CM8823
CM8824,
Current coordinate change value
CM8825
CM8826, Operation speed change value during speed control

CR/CM List
CM8827 mode
CM8828,
Target coordinate change value
CM8829
CM8830,
R Output pulse, current coordinate
CM8831
CM8832,
R Output frequency, current value
CM8833
CM8834 R Error code
CM8835 R Execution point number
CM8836 to
- Reserved for the system
CM8839

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-47


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM8840 I/O setting
CM8841 Sensor enable
CM8842,
Comparator 0, current value
CM8843
CM8844,
Comparator 1, current value
CM8845
CM8846,
Comparator 2, positioning
CM8847
CM8848 Starting speed
CM8849 Origin returning operation: starting frequency
CM8850 Origin returning operation: acceleration rate
CM8851 Origin returning operation: deceleration rate
CM8852,
Origin returning operation: operation frequency
CM8853
CM8854 Origin returning operation: detailed settings
CM8855 JOG operation: starting frequency
CM8856 JOG operation: acceleration rate
APPENDICES

CM8857 CPU positioning function, JOG operation: deceleration rate


axis 2
CM8858,
JOG operation: operation frequency
CM8859
CM8860,
Home position
CM8861
CM8862,
- Reserved for the system
CM8863
CM8864,
Current coordinate change value
CM8865
CM8866, Operation speed change value during speed control
CR/CM List

CM8867 mode
CM8868,
Target coordinate change value
CM8869
CM8870,
R Output pulse, current coordinate
CM8871
CM8872,
R Output frequency, current value
CM8873
CM8874 R Error code
CM8875 R Execution point number
CM8876 to
- Reserved for the system
CM8879

A-48 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM8880 I/O setting
CM8881 Sensor enable
CM8882,
Comparator 0, current value
CM8883
CM8884,
Comparator 1, current value
CM8885
CM8886,
Comparator 2, positioning
CM8887
CM8888 Starting speed
CM8889 Origin returning operation: starting frequency
CM8890 Origin returning operation: acceleration rate
CM8891 Origin returning operation: deceleration rate
CM8892,
Origin returning operation: operation frequency
CM8893
CM8894 Origin returning operation: detailed settings
CM8895 JOG operation: starting frequency
CM8896 JOG operation: acceleration rate

APPENDICES
CM8897 CPU positioning function, JOG operation: deceleration rate
axis 3
CM8898,
JOG operation: operation frequency
CM8898
CM8900,
Home position
CM8901
CM8902,
Reserved for the system
CM8903
CM8904,
Current coordinate change value
CM8905
CM8906, Operation speed change value during speed control

CR/CM List
CM8907 mode
CM8908,
Target coordinate change value
CM8909
CM8910,
R Output pulse, current coordinate
CM8911
CM8912,
R Output frequency, current value
CM8913
CM8914 R Error code
CM8915 R Execution point number
CM8916 to
Reserved for the system
CM8919

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-49


CR/CM List

Attribute Hold
CM Function ○: Hold
R: Read only
Set: Holding can
Blank: Read/write
be set
CM8920 I/O setting
CM8921 Sensor enable
CM8922,
Comparator 0, current value
CM8923
CM8924,
Comparator 1, current value
CM8925
CM8926,
Comparator 2, positioning
CM8927
CM8928 Starting speed
CM8929 Origin returning operation: starting frequency
CM8930 Origin returning operation: acceleration rate
CM8931 Origin returning operation: deceleration rate
CM8932,
Origin returning operation: operation frequency
CM8933
CM8934 Origin returning operation: detailed settings
CM8935 JOG operation: starting frequency
CM8936 JOG operation: acceleration rate
APPENDICES

CM8937 CPU positioning function, JOG operation: deceleration rate


axis 4
CM8938,
JOG operation: operation frequency
CM8939
CM8940,
Home position
CM8941
CM8942,
Reserved for the system
CM8943
CM8944,
Current coordinate change value
CM8945
CM8946, Operation speed change value during speed control
CR/CM List

CM8947 mode
CM8948,
Target coordinate change value
CM8949
CM8950,
R Output pulse, current coordinate
CM8951
CM8952,
R Output frequency, current value
CM8953
CM8954 R Error code
CM8955 R Execution point number
CM8956 to
Reserved for the system
CM8959

A-50 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


CR/CM List

• Error number 128 (calculation error)


Detailed Information, Piece n Explanation
Detailed information, piece 1 Error details
0 (Not used.)
1 Incorrect indirect specification.
2 The indirectly specified target is T/C.
3 Incorrect simple indirect specification.
4 Outside of operand range.
5 Floating-point real number overflow.
6 Incorrect device specification.
7 The ROOT instruction operand is negative.
8 No bits turned ON with the ENCO instruction.
9 Floating-point real number format error.
10 Incorrect trigonometric function instruction operand.
11 Data could not be converted.
12 Incorrect table specification.
13 Incorrect time comparison instruction operand.
14 Incorrect cam switch operand.
15 Incorrect frequency counter instruction operand.
16 Divide by zero.

APPENDICES
17 Illegal logging ID.
18 Direct processing error.
19 Unit on which direct processing cannot be performed.
20 Jump destination subroutine does not exist.
21 Data being written during RUN mode, so instruction cannot
be executed.
22 Error for expansion unit-dedicated instructions (unit number).
23 Reserved for the system.

CR/CM List
24 PIDAT, outside of operation setting range.
25 PIDAT, outside of sampling period range.
26 PIDAT, outside of comparison constant range.
27 PIDAT, outside of integral constant range.
28 PIDAT, outside of differential constant range.
29 PIDAT comparison constant, two-degree freedom
parameters outside of range.
30 PIDAT integral constant, two-degree freedom parameters
outside of range.
31 PIDAT differential constant, two-degree freedom
parameters outside of range.
32 PIDAT, outside of operation quantity upper limit or lower limit
range.
33 PIDAT, outside of operation quantity change width limit range.
34 PIDAT, outside of measured value change width range.
35 PIDAT, AT state transition error.
36 PIDAT, outside of operation control flag range.
37 Operation period exceeded.
38 PIDAT, outside of AT adjustment parameter range.
39 PIDAT, outside of AT hysteresis range.
40 PIDAT, outside of AT timeout range.
41 PIDAT, outside of AT calculation control mode setting range.
42 PIDAT, AT timeout.
43 PIDAT, AT comparison constant exceeded.
44 PIDAT, AT integral constant exceeded.
45 PIDAT, AT differential constant exceeded.
46 Root of negative number cannot be calculated.
47 Incorrect ABS instruction operand.
48 Calculation overflow.
49 UR, UM, or UV unit not connected.
50 Unit device (R) not assigned.
51 Unit device (DM) not assigned.
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-51
CR/CM List

Detailed Information, Piece n Explanation


Detailed information, piece 2 Fixed to 00H
Detailed information, piece 3 Upper bits of the step number at which the error occurred
Detailed information, piece 4 Lower bits of the step number at which the error occurred
Detailed information, pieces 5 to 20 The module name is saved in SJIS format (any parts not occupied with
the module name are "00H")
• Error numbers 50, 53, 55, 56, 58, and 59 (unit number errors)
Detailed Information, Piece n Explanation
Unit number (the unit number will not be stored if it cannot be
Detailed information, piece 1
determined according to the occurrence conditions of the error)
Detailed information, pieces 2 to 20 Fixed to 00H

• Error number 54 (number of units error)


Detailed Information, Piece n Explanation
Detailed information, piece 1 The number of units as specified in the unit setup information
Detailed information, piece 2 The number of units that are actually connected
Detailed information, pieces 3 to 20 Fixed to 00H
APPENDICES

• Error number 60 (number of expansion I/O points error)


Detailed Information, Piece n Explanation
Detailed information, piece 1 Upper limit of the number of base unit expansion I/O points
Detailed information, piece 2 Actually connected number of expansion I/O points
Detailed information, pieces 3 to 20 Fixed to 00H

• Error number 61 (assigned device overlap error)


Detailed Information, Piece n Explanation
CR/CM List

Detailed information, piece 1 Unit number of the expansion unit whose assignment is being overlapped
Detailed information, piece 2 Type of device that is being overlapped (R—relay: 1, DM: 2)
Number of the device that is being overlapped
Detailed information, piece 3
(channel number when the device type is R—relay, example: R1000  10)
Detailed information, pieces 4 to 20 Fixed to 00H

• Error numbers 96, 97, 98, 99, and 101 (extension adapter error)
Detailed Information, Piece n Explanation
Extension adapter number (left: 1, right: 2)
Detailed information, piece 1
(0 is stored when the slot cannot be determined)
Detailed information, piece 2 Reserved for the system
Detailed information, pieces 3 to 20 Fixed to 00H

• Error number 127 (automatic loading failure error)


Detailed Information, Piece n Explanation
Details of error
Detailed information, piece 1
For details, refer to "Errors during load/save execution".
Detailed information, pieces 2 to 20 00H Fixed

• Error number 129 (unit error)


Expansion Information, Piece n Explanation
Expansion information, piece 1 Unit number
Expansion information, piece 2 Error number of each unit
Detailed information, pieces 3 to 20 Fixed to 00H

• Error numbers other than those listed above


Expansion Information, Piece n Explanation
Detailed information, pieces 1 to 20 Fixed to 00H

A-52 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


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 T ’ 7 G W g w ァ キ ヌ ラ

APPENDICES
L B

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
ォ サ ヒ ロ

ASCII Code Table


C FF → , < L \ l | ャ シ フ ワ
D CR ← ー = M ] m } ュ ス ヘ ン
E SO ↑ . > N ^ n ~ ョ セ ホ ゛
D
F SI ↓ / ? O _ o E
L ッ ソ マ °

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-53


List of Characters That Cannot Be Used
This appendix describes the characters that cannot be used in project names, module names, macro
names, labels, and device comments.

 Characters that cannot be used in project names

Characters that cannot be used


(space)

 Characters that cannot be used in program names

Characters that cannot be used


(space) *1 *1

Characters that cannot be used as the


*2 *2
first character
Character and character strings that cannot
be used as the last character or characters
Character string that cannot be used Global グローバル Global 全局

*1 String that cannot be used only with KV-8000 with CPU function version 2.0 or later.
APPENDICES

*2 String that cannot be used at positions other than the start when using KV-8000 with CPU function
version 2.0 or later.

 Characters that cannot be used in function / function block / structure names

Characters that cannot be used


(スペース) (__) *1 *1

Characters that cannot be used at the start *2 *2


List of Characters That Cannot Be Used

Characters or strings that cannot be used at the end

グローバル Global 全局 全域 글로벌

The following are strings that cannot be used only with KV-8000 with CPU
function version 2.0 or later
Strings that cannot be used • TIMER 定时器 定時器 타이머 COUNTER 计数器 計數器 카운터
FUN_ENO
• Keywords specified in IEC61131-3
(For the contents of keyword, refer to "Characters that cannot be used in
variable names".)
*1 This string cannot be used only with KV-8000 with CPU function version 2.0 or later.
*2 String that cannot be used at positions other than the start when using KV-8000 with CPU function
version 2.0 or later.

 Characters that cannot be used in variable

Characters that cannot be used


(space)
Characters that cannot be used as the
first character
Global グローバル Global 全局

The same names as instructions


Device names
Character strings that cannot be used • (1) One alphabet character + or (2) + a number
• One alphabet character + a number
• +( to )
• +( to )
A-54 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
List of Characters That Cannot Be Used

• The following keywords, which are prescribed in KV script


!!, #PRAGMA, ', (, ), *, *=, +, +=, -, -=, .B, .D, .DF, .F, .L, .S, .T, .U,
/, /=, <, <=, <>, =, >, >=, ABS, ACNT※1, ACOS, ADRADD,
ADRDEC, ADRINC, ADRSET, ADRSUB, AJST, AND, ANDA,
APR, AS, ASC, ASIN, ASLA, ASRA, ATAN, ATAN2, AVG,
AWHIDE, AWSHOW, B, BANDC, BCMP, BCMPI, BCNT, BLD,
BLDB, BMOV, BOUB, BOUT, BREAK, BRES, BSET, BSL, BSR,
BSUM, BSWAP, BYBMOV, BYLMOV, C, CALL, CASE, CHR, CM,
CNT, COM, COS, CPMGET, CPMSET, CPSASC, CR, CRC,
CTC, CTH, DASC, DCNT, DEC, DECO, DEG, DELETE, DFLOAT,
DI, DIC, DIM, DISB, DISF, DISN, DISS, DM, DMX, DO, DOUBLE,
DR, DSER, ECALL, EI, ELSE, ELSE IF, EM, ENCO, END, END
IF, END SELECT, END TYPE, END WHILE, ENRA, EORA, EXP,
FALSE, FASC, FB, FBCALL※1, FBSTRT※1, FDEL, FEND,
FIFOR, FIFOW, FIND, FINS, FLOAT, FM, FMOV, FOR, FRLDM,
FRSET, FRSTM, FUN, FWRIT, GRY, HASC, IEDGE, IF, INC,
INSERT, INSTR, INT, INTG, IS, IS_7500, IS_8000, IS_AD40,
IS_AD40G, IS_AD40V, IS_AM40V, IS_B16R, IS_B16T, IS_B16X,
IS_B8RC, IS_B8XTD, IS_C16XTD, IS_C32T, IS_C32X,

APPENDICES
IS_C32XTD, IS_C64T, IS_C64X, IS_CA02, IS_CL20, IS_DA40,
IS_DA40V, IS_DN20, IS_EP21V, IS_FL20V, IS_H20G, IS_H20S,
IS_H40S, IS_L21V, IS_LE21V, IS_LH20V, IS_LM21V, IS_MC20V,
IS_MC40V, IS_ML16V, IS_MVL40, IS_N20V, IS_SAD04,
IS_SC20, IS_SDA04, IS_SFP24XT, IS_SFP32XT, IS_SH04PL,
IS_SIR32XT, IS_SSC02, IS_TF40, IS_TP40, IS_XCA02,
IS_XCM02※1, IS_XH04ML, IS_XH16EC, IS_XH16ML,
IS_XL202, IS_XL402, IS_XLE02, LDF, LDFB, LDP, LDPB, LEFT,

List of Characters That Cannot Be Used


LEN, LIFOR, LIFOW, LIMIT, LLFLT, LOG, LOG10, LOGD, LOGE,
Character strings that cannot be used LR, LTRIM, MAX, MC, MCALL, MCOPY, MCR, MDEL, MDSTOP,
MDSTRT, MEND, MFREE, MFREEK, MID, MIN, MMKDIR,
MMOV, MOD, MPRINT, MPX, MR, MREAD, MREADL, MREN,
MRMDIR, MSTAT, MSTRT, MWRIT, NEG, NEXT, NOT, OFF, ON,
OR, ORA, P, PIDAT, PMOV, R, RAD, RAMP, RASC, RCPSASC,
RDASC, REM, REPLACE, RES, RFASC, RFSCI, RFSCO,
RFSFRC, RFSX, RFSY, RGRY, RHASC, RIGHT, RLA, RLNCA,
RND, ROOT, RRA, RRNCA, RSEC, RTRIM, SDEL, SEC, SEG,
SELECT, SELECT CASE, SER, SET, SFIND, SFINDN, SIN,
SINS, SLA, SLEFT, SMID, SORT, SORTN, SPLIT, SPRD, SPWR,
SQRT, SRA, SRGHT, SRPLC, SSVC, STEP, STR, STRIM,
STRWORK, SWAP, T, TAN, TBCD, TBIN, THEN, TM, TMH, TMR,
TMS, TMU, TO, TOD, TODF, TOF, TOL, TOS, TOU, TPOUT,
TRGD, TRGR, TRIM, TRUE, TYPE, UFILL, UFRSM, UFSUS,
UM, UMALLOC, UNIB, UNIF, UNIN, UNIS, UNTIL, UPSTOP,
UPSTRT, UR, UREAD, UV, UWRIT, U_CCTRCV, U_CCTSND,
U_CCTST, U_CCTTO, U_CERR, U_CREG, U_CSTOP,
U_CSTRT, U_DISOCP, U_DISOVP, U_ELCYC, U_ELSTAT,
U_FCSTAT, U_MLATTA, U_MLSTAT, U_MLSUB, U_MLTEXT,
U_MLTO, U_MLTOGR, U_MSGRCV, U_MSGSND, U_MSGST,
U_MSGTO, U_NDSTAT, U_NDTO, U_PLCYC, U_PLSTAT,
U_PRDBUF, U_RDAD, U_RDADB, U_RDAERC, U_RDBF,
U_RDCNT, U_RDCPOS, U_RDCPT0, U_RDCPT1, U_RDCVEL,
U_RDFPOS, U_RDFTRQ, U_RDFVEL, U_RDHZ, U_RDMD,
U_RDMERC, U_RDPMC, U_RDPPB, U_RDPPNT, U_RDPSB,
U_RDRPM, U_RDSERC, U_RDSPB, U_RDSVPB, U_RDSYSB,
U_SBMON, U_SBNAME, U_SELSP, U_SLREG, U_SOPEN,
U_SRCVNP, U_SRDBUF, U_SSELPT, U_SSTAT, U_STMON,
U_SUDPTO, U_SWRBUF, U_WRAVG, U_WRBNK, U_WRCNT,

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-55


List of Characters That Cannot Be Used

• The following keywords, which are prescribed in KV script


U_WRCPOS, U_WRCTC0, U_WRCTC1, U_WRDA,
U_WRFBNO, U_WRFNO, U_WRFRNO, U_WRFVR, U_WRLMT,
U_WRMD, U_WROFST, U_WRPOR, U_WRPPB, U_WRPPNT,
U_WRPPS, U_WRPPSS, U_WRPSB, U_WRPST, U_WRPVEL,
U_WRSCAM, U_WRSCL, U_WRSCOF, U_WRSCON,
U_WRSPB, U_WRSVPB, U_WRSYSB, U_WRTTRQ,
U_WRTVL, U_WRVTL, U_WRVVEL, V, VAL, W, WHILE,
WSIZE*1, WSL, WSR, WSUM, WTIME, XOR, Z, ZF, ZONE,
ZPOP, ZPUSH, ZRES, [, \\, \\A, \\B, \\F, \\N, \\R, \\T, \\V, ]
• The following keywords, which are prescribed in IEC61131-3
TRUE, FALSE,
TIME, DATE,TIME_OF_DAY, TOD, DATE_AND_TIME, DT,
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,
APPENDICES

ANY_DATE,
ACTION, END_ACTION,
ARRAY, OF,
AT,
CASE, END_CASE,
CONFIGURATION, END_CONFIGURATION,
CONSTANT,
EN, ENO,
List of Characters That Cannot Be Used

EXIT,
Character strings that cannot be used
• 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,
RETURN,
STEP,
STRUCT, END_STRUCT,
TASK,
TRANSITION, FROM, END_TRANSITION,
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
• Other character strings (see the IEC61131-3 specifications)
• A variable name cannot have two or more consecutive
underscore characters.
The string "a_b_c" is acceptable, but "a__bc" cannot be used.
*1 String that cannot be used only with KV-8000 with CPU function version 2.0 or later.
A-56 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
List of Characters That Cannot Be Used

 Characters that cannot be used in structure member names

Characters that cannot be used


(Half-width space) (Full-width space) (__)
Characters that cannot be used at the
start
Characters or strings that cannot be used
at the end

グローバル Global 全局 全域 글로벌

• Strings that cannot be distinguished from numeric values


• K
• K + value
• K + value + suffix(U/S/D/L/F/DF)
• K + value + E
• K + value + E + value
Strings that cannot be used

APPENDICES
• K + value + E + value + suffix(F/DF)
• H + hexadecimal value (decimal value or ABCDEF string)
• The following key words, which are prescribed in KV script
(For the contents of keyword, refer to "Characters that cannot be
used in variable names".)
• Keywords specified in IEC61131-3
(For the contents of keyword, refer to "Characters that cannot be
used in variable names".)

List of Characters That Cannot Be Used


 Character that cannot be used in device comments
Character that cannot be used

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-57


List of Unusable Functions
The functions which cannot be used in the initialization module, function block, 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 storage device / read storage device /
MFREE/MMKDIR get storage device open space / create storage device folder
MRMDIR/MDEL Delete storage device folder / delete storage device file
Storage device
MPRINT/MREADL/ Write storage device text / read one line of storage device /
functions
MCOPY/MMOV/ copy storage device file / move storage device file /
MREN/MFREEK/ rename storage device file / get storage device open space /
MSTAT get storage device status
APPENDICES

Access window AWNUM/AWMSG User message 1 / user message 2


functions AWSHOW/AWHIDE User message display/hide user message

● Function block
Type of function Function
Macro functions MCALL/MSTRT Macro call / macro start
* The FEND (function block end) function is written in the function block. It cannot be used in other types of programs such
List of Unusable Functions

as functions or modules.

● Function
Type of function Function
Macro functions MCALL/MSTRT Macro call / macro start
Function block FB/FBSTRT/
Function block
functions FBCALL

● Macros
Type of function Function
Macro functions MCALL/MSTRT Macro call / macro start
Function block FB/FBSTRT/
Function block / function
functions FBCALL/FUN
* The MEND (macro end) function is written in the self-holding type macro. It cannot be used in other types of programs
such as sub-routine type macros or modules.

A-58 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index
Characters that cannot be used in
Symbol project names .............................................. A-54
Combination of index modification
(#) DEC constant ............................................. 3-52 and indirect specifying ..................................3-62
Comment writing method .................................2-69
Comparison operator .........................................4-6
A Comparison operator priority .............................4-8
Conditional transfer control statements ...........1-12
Considerations when using the counter ...........4-40
About assignment statement ........................... 1-10 Timer/ Counter contact .................................4-41
Bit assignment ............................................. 1-10 Timer/ Counter current value reading ..........4-40
Numerical value assignment ........................ 1-10 Const .............................. 3-4, 3-8, 3-14, 3-19, 3-52
Text string assignment ................................. 1-10 Constant ..........................................................3-52
About Comments Function .............................. 2-69 Control memory CM .........................................3-45
About control statement ................................... 1-12 Control relay (contact) .....................................3-35
Conditional transfer control statements ....... 1-12 Control Relays .......................................A-10, A-18
Loop control statement ................................ 1-13 Control Statement List .....................................4-10
About control statements nesting .................... 4-32 Copy area script ...............................................2-24
About infinite loop ............................................ 4-37 Copy box script ................................................2-12
About Input Auxiliary Function ......................... 2-64 Counter (contact) .............................................3-34
About label suffix ....................................1-16, 2-44 Counter (current value) C ................................3-43
About label type ............................................... 2-44 Customizing script window ..............................2-73
About Operation Type ...................................... 3-71

APPENDICES
About Parallel Connection of Box Script .......... 2-51
About processing time ..................................... 4-35 D
About script function ........................................ 1-17
About Script Work Memory (Work Devices) .... 2-74
About suffix ...................................................... 1-14 Data memory/Extended data memory
About the bit of global label ............................. 2-45 DM/EM/FM ...................................................3-36
About timer actions in a loop control Data processing .................................................3-1
statement ..................................................... 4-37 Data range processed by operation formula ....3-71
About warning level ......................................... 2-53 Data Type (suffix) .............................................3-63
Actual nesting actions ...................................... 4-34 About Type Declaration (TYPE) ...................3-70

Index
AND ................................................................... 4-7 Device type declaration ................................1-16
Application area of work devices ..................... 2-75 Value change when exceeding
Application method of indirect specifying ........ 3-59 max./min. value ........................................3-69
Area Script ....................................................... 2-16 Delete area script .............................................2-23
Area script ......................................................... 1-9 Delete box script .............................................. 2-11
Area script is used in the following Device name ......................................................3-2
cases ...................................................2-16, 2-18 Device notation method ...................................3-21
Array ................................................................ 2-46 Device number list ............................................ A-2
ASCII Code Table ........................................... A-53 Device table (for KV Nano) ..............................3-17
Device table
(for KV-5500 / 5000/3000/1000) ...................3-10
B Device type designation ...................................3-14
Differences in CPU function version .....................5
Differences in CPU functions according to
Batch register of local label ............................. 2-43 CPU function version .....................................5
Bit assignment ................................................. 1-10 Differences in Ethernet functions according to
Bit assignment statement .................................. 4-2 CPU function version .....................................6
Bit Device ......................................... 3-2, 3-6, 3-24 Restrictions for using extended
Bit status .................................................3-21, 3-24 input/output unit .............................................6
Box script ....................................................1-8, 2-4 Direct input (default) ..........................................2-3
BREAK Processing .......................................... 4-31 Display help of the specified function on
Script Edit Screen ........................................2-67
DO ~ UNTIL ....................................................4-29
C About difference between WHILE
statement between DO statement ............4-30
Call function list ............................................... 2-64
Call script function format hints ....................... 2-65
Calling functions .............................................. 2-58 E
Calling self-hold type macro ............................ 2-60
Calling subroutine macro ................................. 2-60 Error display in output window .........................2-55
Change priority .................................................. 4-8 Error Message .................................................2-54
Characters that cannot be used in labels ....... A-54 Error message when script conversion ............2-54
Characters that cannot be used in Example for indirect specifying ........................3-61
program names ........................................... A-54

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-59


Index

Example for programming using box scripts ..... 2-5 When the type on right side is different
Example for programming using global label .. 2-40 from that on left side ...................................4-4
Example for programming with area scripts .... 2-17 How to Use KV Scripts ......................................1-3
How to use output window ...............................2-56

F
I
Features of Area Script .................................... 2-16
Features of Box Script ....................................... 2-4 I/O relay R ........................................................3-24
Features of KV script ......................................... 1-2 IF ~ ................................................................4-12
File register ZF/FM .......................................... 3-38 IF ~ ELSE .......................................................4-14
Fixed text string (text string type constant) ...... 3-54 IF ~ ELSE IF ...................................................4-16
Flow Functions ................................. 6-2, 6-4, 6-18 Index modification ............................................3-56
FM Index Modification and Indirect Specifying .......3-55
when File Register is processed in Bank Index modification programming ......................3-19
switching mode ......................................... 3-39 Index register Z ................................................3-44
FOR ~ NEXT (specified loop control times) ... 4-24 Indirect specifying principle ..............................3-58
When FOR ~ NEXT statements are Indirect specifying programming ......................3-58
imperatively ended ................................... 4-26 Inline Mnemonics .............................................2-72
Precautions on Using FOR ~ NEXT Internal auxiliary relay
statement .................................................. 4-26 B ...................................................................3-29
The range that can be specified LR (Latch relay) ............................................3-31
APPENDICES

with STEP ................................................. 4-26 MR ................................................................3-30


When specifying single precision floating R ...................................................................3-28
point type constant with STEP ................. 4-26 Internal auxiliary relay R/B/MR/LR ...................3-28
Function ........................................................... 1-17 Internal register ................................. 3-4, 3-8, 3-19
About script function .................................... 1-17
Function argument error .................................. 2-54
Function block ................................................. 2-58 K
Function block call ........................................... 2-58
Function block function .................................... 6-10 KV Nano Series bit device ...............................3-17
Function Version .............................................-3, -4
Index

KV Nano series of word devices ......................3-18


Functions that cannot be executed KV-1000 bit device ...........................................3-12
with the current model .................................. 2-52 KV-1000 series of word devices ......................3-13
KV-5500/5000/3000 bit device .........................3-10
KV-5500/5000/3000 word device ..................... 3-11
G
Global label ...................................................... 2-38 L
Global label array ............................................ 2-47
Label array .......................................................2-46
Label Programming .........................................2-37
H Ladder program equivalent to
OR connection .............................................2-51
HELP Function ................................................ 2-66 Link register W .................................................3-40
HEX constant ................................................... 3-53 Link relay B ......................................................3-26
High-speed counter (current value) CTH ......... 3-43 List of Characters That Cannot Be Used ........ A-54
High-speed counter comparator (contact) ....... 3-35 Character that cannot be used in device
High-speed counter comparator comments ................................................ A-57
(setting value) CTC ...................................... 3-44 Characters that cannot be used in function /
How to Input Scripts .......................................... 2-3 function block / structure names .............. A-54
How to process setting/current value of Characters that cannot be used in labels .... A-54
the counter ................................................... 3-34 Characters that cannot be used in program
How to process setting/current value of names ...................................................... A-54
the timer ....................................................... 3-33 Characters that cannot be used in
How to Program Script ...................................... 2-2 project names .......................................... A-54
How to program the counter when counter Characters that cannot be used in
function is operated via scripts ..................... 3-34 structure member names ......................... A-57
How to use ..............................................2-58, 2-60 List of control relay control memory .................. A-2
How to Use An Assignment Statement .............. 4-2 Local device list ................................ 3-5, 3-9, 3-20
Bit assignment statement ............................... 4-2 Local device list (At KV-1000) ..........................3-16
Numerical value assignment statement ......... 4-2 Local device list
Operation assignment statement ................... 4-3 (When KV-5500 / 5000/3000) .......................3-15
String assignment statement .......................... 4-2 Local label ........................................................2-41
When it can not be assigned to left side ........ 4-4 Local label array ..............................................2-49

A-60 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Index

Loop control statement ........................... 1-13, 4-11 Precautions for using the timer ........................4-40
Loop control statement and processing time ... 4-35 Timer/ Counter contact .................................4-41
Timer/ Counter current value reading ..........4-40
Precautions on Edit Screen and
M Customization ..............................................2-73
Precautions on Script Programming ................4-38
Macro ............................................................... 2-60 Status of Hold Control Bit Device .................4-38
Macro argument device ................................... 3-14 Precautions on using assignment statement .....4-4
Macro Call .................................... 2-58, 2-59, 2-60 Precautions on Using Control Statement .........4-32
Macro function ................................................... 6-6 About timer actions in a loop
Macro operand device ................................3-4, 3-8 control statement ......................................4-37
Making Area Script .......................................... 2-18 Loop control statement and
Making Box Script .............................................. 2-6 processing time ........................................4-35
Precautions when programming script .. 2-51, 2-73
MC ~ MCR ..................................................... 4-22
MC ~ MCR When using timer / Precautions When Using Box Script ................2-13
counter function ........................................... 4-45 Precautions when using label ..........................2-44
MOD .................................................................. 4-6 Processing Bit Device in Word Unit .................3-46
Monitor Function .............................................. 2-62 Processing Word Device as Bit Device ...........3-47
Monitoring with tool tip ..................................... 2-63 Programming control statements with
KV Scripts ......................................................1-7
For multi-branch control .................................1-7
N Programming example for

APPENDICES
device using suffix ........................................1-14
Programming flow using global label ...............2-38
New a area script ............................................. 2-19 Programming flow using local label .................2-41
New a box script ................................................ 2-7 Programming Macro by Using Script ...............2-61
NOT ................................................................... 4-7 Programming operation processing with
KV scripts .......................................................1-3
PROGRAMMING SCRIPT ......................... 2-1, 2-2
O Programming Script ...........................................2-2
Programming text string processing with
Omitting suffix .................................................. 1-15 KV Script ........................................................1-5

Index
Operation assignment statement........................ 4-3
Operation flag .................................................. 1-18
Operation Flow .................................................. 2-6 R
Operator .......................................................... 1-11
Operator List ............................................. 1-11, 4-6 Reedit area script .............................................2-22
Arithmetic operator ......................................... 4-6 Reedit Box Script ............................................. 2-11
Change priority ............................................... 4-8 Register global label ........................................2-38
Comparison operator ..................................... 4-6 Register local label ..........................................2-41
Comparison operator priority ......................... 4-8 Register monitor ..............................................2-62
Differences between assignments Reserved word .................................................2-66
statements and compare operators ............ 4-9
Logic operator ................................................ 4-7
Logic operator priority .................................... 4-8 S
String Connection Operator ........................... 4-6
The priority between multiplication,
division, addition, and subtraction .............. 4-8 Script ..................................................................1-2
Operator priority ................................................. 4-7 Script Conversion Output Message .................2-52
Operator type ..................................................... 4-6 Script function ..................................................1-10
OR ..................................................................... 4-7 Script function format hints ..............................2-65
Order of prionity low .......................................... 4-6 Script Function List ..........................................2-64
Other precautions ............................................ 2-45 Script program via XYM mark. .........................2-77
Others .............................................................. 2-55 SCRIPT SYNTAX AND PRECAUTIONS ...........4-1
Script type ..........................................................1-8
Script warning level setting ..............................2-53
P SELECT CASE ................................................4-18
Setting method of warning level .......................2-53
Simple indirect specifying #TM ........................3-62
PRAGMA Directive .......................................... 3-73 Single precision floating point type constant ....3-53
Precautions about the use of Specify invalid type ..........................................2-54
timer function ......................................3-33, 4-41 Specify timer function using Box Script ............4-43
Specify timer function using Box Script ........ 4-43 Start script function help ..................................2-66
Use timer function in IF statement of String assignment ............................................1-10
area script ................................................. 4-42 String assignment statement .............................4-2
Precautions about use of timer function in String Connection Operator ...............................4-6
Box Script and IF statement ......................... 4-42
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-61
Index

Suffix ................................................................ 3-63 When WHILE statement is imperatively


About .B ....................................................... 3-68 terminated ....................................................4-28
About .D and .L ............................................ 3-65 When work devices are insufficient .................2-75
About .DF ..................................................... 3-67 WHILE ~ ........................................................4-27
About .F ....................................................... 3-66 Window input .....................................................2-3
About .T ....................................................... 3-68 Word device ...................................... 3-3, 3-7, 3-36
About .U and .S ............................................ 3-64 Work memory (work device) ............................2-74
Suffix (Data Type (suffix)) ................................ 3-63 Write Easy-reading Script ................................2-70
Suffix type ........................................................ 1-14 Writing index modification
Syntax error ..................................................... 2-54 Invalid index modification .............................3-57
Modify by index register ...............................3-56
Modify the device with suffix ........................3-57
T Modify via index constant .............................3-57
Modify via the device and expression ..........3-57
Temporary data memory TM ........................... 3-42 Writing indirect specification (*) .......................3-21
Timer (contact) T ............................................. 3-32 Writing local devices ........................................3-22
Timer (current value) T .................................... 3-42
Timer error ....................................................... 3-33
TYPE ............................................................... 3-70 X
Type conversion leads to data loss ................. 2-52
Type of indirect specifying device .................... 3-60 XOR ...................................................................4-7
Typing error ..................................................... 2-54 XYM Marking ...................................................2-77
APPENDICES

U Z
Use timer function in IF statement of ZF
area script .................................................... 4-42 when file register is processed with consecutive
number method ........................................3-39

V
Index

Variable suffix .................................................. 1-15


Variables .......................................................... 3-50

W
Warning Message ............................................ 2-52
Watch window ................................................. 2-63
What is indirect specifying (*) ....................... 3-58
When conversion error occurs ......................... 2-55
When conversion fails ..............................2-9, 2-21
When conversion successful ....................2-9, 2-20
When looking up notes on indirect
specifying and index modification ................ 1-18
Every function operation table
when invalid address is specified ............. 1-18
When processing 16-bit data ........ 3-37, 3-39, 3-41
When processing 32-bit data ........ 3-37, 3-40, 3-41
When processing as the bit device
at any bit. ..................................................... 3-47
When processing as the bit device
at the lowerest bit ......................................... 3-47
When using box scripts in the
following cases ............................................... 2-4
When using differential execution
type functions ............................................... 2-13
When using KV-7000 ..................................3-2, 3-6
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

A-62 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Functions Index

A D
ABS ................................................................. 7-36 DASC .............................................................7-158
ACNT ............................................................... 6-60 DCNT .................................................................8-8
ACOS ............................................................ 7-148 DEC .................................................................7-16
ADRADD ......................................................... 6-32 DECO ............................................................7-104
ADRDEC ......................................................... 6-30 DEG ...............................................................7-138
ADRINC ........................................................... 6-28 DELETE .........................................................7-206
ADRSET .......................................................... 6-26 DFLOAT .........................................................7-118
ADRSUB .......................................................... 6-34 DI .....................................................................8-78
AJST ................................................................ 8-76 DIC ...................................................................8-80
ANDA ............................................................... 7-22 DISB ................................................................7-96
APR ................................................................. 7-68 DISF ...............................................................7-126
ASC ............................................................... 7-154 DISN ................................................................7-92
ASIN .............................................................. 7-146 DISS ..............................................................7-228
ASLA ............................................................... 7-44 DMX .................................................................7-86
ASRA ............................................................... 7-42 DSER ...............................................................8-12
ATAN ............................................................. 7-150
ATAN2 ........................................................... 7-152
AVG ................................................................. 8-22 E
AWHIDE ........................................................ 8-123

APPENDICES
AWMSG ......................................................... 8-120 ECALL ...............................................................6-4
AWNUM ......................................................... 8-118 EI .....................................................................8-78
AWSHOW ...................................................... 8-122 ENCO ............................................................7-106
ENRA ...............................................................7-28
EORA ...............................................................7-26
B EXP ................................................................7-130

BANDC ............................................................ 7-64


BCMP .............................................................. 8-36 F
BCMPI ............................................................. 8-38

Functions Index
BCNT ................................................................. 8-6 FASC .............................................................7-174
BLD .................................................................... 5-8 FB ....................................................................6-10
BLDB ............................................................... 5-10 FBCALL ...........................................................6-11
BMOV ................................................................ 7-2 FBSTRT ...........................................................6-13
BOUB .............................................................. 5-16 FDEL ................................................................8-68
BOUT ............................................................... 5-14 FEND ...............................................................6-15
BRES ............................................................... 5-20 FIFOR ..............................................................8-52
BSET ............................................................... 5-18 FIFOW .............................................................8-48
BSL .................................................................. 7-60 FIND ..............................................................7-226
BSR ................................................................. 7-58 FINS .................................................................8-66
BSUM .............................................................. 8-30 FLOAT ...........................................................7-114
BSWAP .......................................................... 7-102 FMOV ................................................................7-4
BYBMOV ......................................................... 7-10 FRLDM ............................................................6-40
BYLMOV .......................................................... 7-12 FRSET .............................................................6-36
FRSTM ............................................................6-38
FUN .................................................................6-16
C FWRIT .............................................................8-64

CALL .................................................................. 6-2


CHR ............................................................... 7-232 G
CNT ................................................................. 5-32
COM ................................................................ 7-30 GRY .................................................................7-88
COS ............................................................... 7-142
CPMGET ....................................................... 7-112
CPMSET ........................................................ 7-110 H
CPSASC ........................................................ 7-234
CRC ................................................................. 8-32
HASC .............................................................7-168

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-63


Functions Index

I P
IEDGE ............................................................. 8-82 PIDAT ..............................................................8-84
INC .................................................................. 7-14 PMOV ................................................................7-6
INSERT ......................................................... 7-202
INSTR ............................................................ 7-222
INT ................................................................. 7-124 R
INTG .............................................................. 7-122
IS_ □□□ ....................................................... 6-58 RAD ...............................................................7-136
RAMP ..............................................................7-74
RASC .............................................................7-156
L RCPSASC .....................................................7-236
RDASC ..........................................................7-166
LDF .................................................................... 5-4 REPLACE ......................................................7-199
LDFB ................................................................. 5-7 RES .................................................................5-13
LDP .................................................................... 5-2 RFASC ...........................................................7-178
LDPB ................................................................. 5-6 RFSCI ............................................................8-132
LEFT .............................................................. 7-190 RFSCO ..........................................................8-134
LEN ................................................................ 7-182 RFSCTH ..........................................................8-79
LIFOR .............................................................. 8-60 RFSFRC ........................................................8-124
LIFOW ............................................................. 8-56 RFSX ...............................................................5-36
APPENDICES

LIMIT ............................................................... 7-62 RFSY ...............................................................5-37


LLFLT .............................................................. 7-78 RGRY ..............................................................7-90
LOG ............................................................... 7-132 RHASC ..........................................................7-172
LOG10 ........................................................... 7-134 RIGHT ............................................................7-186
LOGD .............................................................. 8-86 RLA ..................................................................7-48
LOGE ............................................................... 8-86 RLNCA .............................................................7-52
LTRIM ............................................................ 7-210 RND .................................................................8-40
ROOT ..............................................................7-18
RRA .................................................................7-46
M
Functions Index

RRNCA ............................................................7-50
RSEC ...............................................................8-74
MAX ................................................................. 8-14 RTRIM ...........................................................7-212
MCALL ............................................................... 6-6
MCOPY ......................................................... 8-110
MDEL ............................................................. 8-104 S
MDSTOP ......................................................... 6-19
MDSTRT .......................................................... 6-18 SDEL .............................................................7-204
MEND ................................................................ 6-8 SEC .................................................................8-72
MFREE ............................................................ 8-94 SEG ...................................................................8-2
MFREEK .......................................................... 8-96 SER .................................................................8-10
MID ................................................................ 7-194 SET ..................................................................5-12
MIN .................................................................. 8-18 SFIND ............................................................7-218
MMKDIR .......................................................... 8-98 SFINDN .........................................................7-220
MMOV ........................................................... 8-112 SIN .................................................................7-140
MPRINT ......................................................... 8-106 SINS ..............................................................7-200
MPX ................................................................. 7-84 SLA ..................................................................7-40
MREAD ............................................................ 8-92 SLEFT ............................................................7-188
MREADL ........................................................ 8-108 SMID ..............................................................7-192
MREN ............................................................ 8-114 SORT ...............................................................8-42
MRMDIR ........................................................ 8-102 SORTN ............................................................8-44
MSTAT .......................................................... 8-116 SPLIT .............................................................7-216
MSTRT .............................................................. 6-7 SPRD .............................................................8-126
MWRIT ............................................................ 8-90 SPWR ............................................................8-128
SQRT ...............................................................7-20
SRA .................................................................7-38
N SRGHT ..........................................................7-184
SRPLC ...........................................................7-196
NEG ................................................................. 7-32 SSVC .............................................................8-130
STR ................................................................7-162
STRIM ............................................................7-214
O SWAP ............................................................7-100

ORA ................................................................. 7-24


A-64 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -
Functions Index

KV-SC20V/SSC02
T U_RDCNT .................................................... *1
U_RDCPT0................................................... *1
TAN ............................................................... 7-144 U_RDCPT1................................................... *1
TBCD ............................................................... 7-80 U_RDHZ ....................................................... *1
TBIN ................................................................ 7-82 U_RDRPM.................................................... *1
TMH ................................................................. 5-26 U_WRCNT................................................... *1
TMR ................................................................. 5-22 U_WRCTC0.................................................. *1
TMS ................................................................. 5-28 U_WRCTC1.................................................. *1
TMU ................................................................. 5-30 U_WRPST .................................................... *1
TOD ............................................................... 7-108 KV-SSC02
TODF ............................................................. 7-120 U_DISOCP ................................................... *1
TOF ............................................................... 7-116 U_RDBF ....................................................... *1
TOL ................................................................ 7-108 KV-AD40V/KV-SAD04
TOS ............................................................... 7-108 U_RDAD....................................................... *1
TOU ............................................................... 7-108 U_RDADB .................................................... *1
TPOUT ............................................................ 7-76 U_WRAVG ................................................... *1
TRGD .............................................................. 8-87 U_WRLMT.................................................... *1
TRGR .............................................................. 8-88 U_WROFST ................................................. *1
TRIM .............................................................. 7-208 U_WRSCL .................................................... *1
KV-SAD04
U_RDBF ....................................................... *1

APPENDICES
U KV-DA40V/KV-SDA04
U_WRDA ...................................................... *1
U_WRLMT.................................................... *1
U_*****(Unit specific function) U_WROFST ................................................. *1
KV-XLE02/EP21V U_WRSCL .................................................... *1
U_CSTOP .....................................................*1 KV-ML16V/MC40V/MC20V
U_CSTRT......................................................*1 U_WRPPNT ................................................. *1
U_CREG .......................................................*1 U_RDPPNT .................................................. *1
U_CERR........................................................*1 U_RDPMC.................................................... *1
U_MSGTO.....................................................*1 U_RDFPOS .................................................. *1

Functions Index
U_MSGSND ..................................................*1 U_RDFVEL................................................... *1
U_MSGRCV ..................................................*1 U_RDFTRQ(KV-ML16V) .............................. *1
U_MSGST .....................................................*1 U_RDCPOS.................................................. *1
U_NDTO........................................................*1 U_RDCVEL .................................................. *1
U_NDSTAT ...................................................*1 U_RDCNT.D................................................. *1
U_SBMON.....................................................*1 U_WRCPOS................................................. *1
U_SBNAME...................................................*1 U_WRPPS.................................................... *1
U_STMON.....................................................*1 U_WRPVEL.................................................. *1
U_SLREG......................................................*1 U_WRPOR .................................................. *1
KV-XLE02/EP21V/LE21V/LE20V U_RDMD ...................................................... *1
U_ELCYC(KV-EP21V/LE21V) ......................*1 U_WRMD(KV-ML16V).................................. *1
U_ELSTAT(KV-EP21V/LE21V).....................*1 U_WRVVEL(KV-ML16V) .............................. *1
U_FCSTAT(KV-XLE02/EP21V/LE21V).........*1 U_WRVTL(KV-ML16V)................................. *1
U_MLATTA....................................................*1 U_WRTTRQ(KV-ML16V) ............................. *1
U_MLSTAT....................................................*1 U_WRTVL(KV-ML16V)................................. *1
U_MLSUB .....................................................*1 U_WRFRNO................................................. *1
U_MLTEXT....................................................*1 U_WRFBNO ................................................. *1
U_MLTO........................................................*1 U_WRFNO ................................................... *1
U_MLTOGR ..................................................*1 U_WRFVR.................................................... *1
U_SOPEN .................................................... *1 U_RDMERC ................................................. *1
U_SRCVNP...................................................*1 U_RDSERC.................................................. *1
U_SRDBUF ...................................................*1 U_RDAERC.................................................. *1
U_SSTAT ......................................................*1 U_WRBNK.................................................... *1
U_SUDPTO...................................................*1 U_WRPPB.................................................... *1
U_SWRBUF ..................................................*1 U_RDPPB..................................................... *1
KV-XLE02/XL202/XL402 U_WRSVPB(KV-ML16V).............................. *1
U_PLSTAT ....................................................*1 U_RDSVPB(KV-ML16V) .............................. *1
U_PLCYC......................................................*1 U_WRSYSB ................................................. *1
U_PRDBUF ...................................................*1 U_RDSYSB .................................................. *1
KV-XLE02 U_WRPSB.................................................... *1
U_CCTTO .....................................................*1 U_RDPSB..................................................... *1
U_CCTSND...................................................*1 U_WRSPB.................................................... *1
U_CCTRCV...................................................*1 U_RDSPB..................................................... *1
U_CCTST......................................................*1 U_WRSCON................................................. *1
U_SSELPT ....................................................*1 U_WRSCOF ................................................. *1
- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-65
Functions Index

U_WRSCAM .................................................*1 *1 See the user's manual of the corresponding


KV-SIR32XT unit.
U_DISOCP ....................................................*1
U_DISOVP ....................................................*1 *2 See the user's manual of the corresponding
U_RDBF ........................................................*1 base unit.
KV-XH16ML/XH04ML/SH04PL
U_RDAERC...................................................*1
U_RDFPOS...................................................*1
U_RDFVEL....................................................*1
U_RDMD .......................................................*1
U_RDPMC.....................................................*1
U_RDPPNT ...................................................*1
U_SELSP ......................................................*1
U_WRCPOS..................................................*1
U_WRPOR ....................................................*1
U_WRPPNT ..................................................*1
U_WRPPS.....................................................*1
U_WRPPSS ..................................................*1
U_WRPVEL...................................................*1
KV-XH16ML/XH04ML
U_RDCPOS ..................................................*1
U_RDCVEL ...................................................*1
APPENDICES

U_RDFTRQ...................................................*1
U_WRMD ......................................................*1
U_WRTTRQ ..................................................*1
U_WRTVL .....................................................*1
U_WRVTL .....................................................*1
U_WRVVEL...................................................*1
KV-SH04PL
U_DISOCP ....................................................*1
UFILL ............................................................... 6-56
UFRSM ............................................................ 6-48
Functions Index

UFSUS ............................................................ 6-46


UMALLOC ....................................................... 6-50
UNIB ................................................................ 7-98
UNIF .............................................................. 7-128
UNIN ................................................................ 7-94
UNIS .............................................................. 7-230
UPSTOP .......................................................... 6-44
UPSTRT .......................................................... 6-42
UREAD ............................................................ 6-52
UWRIT ............................................................. 6-54

V
VAL ................................................................ 7-181

W
WSIZE ............................................................. 6-62
WSL ................................................................. 7-56
WSR ................................................................ 7-54
WSUM ............................................................. 8-26
WTIME ............................................................. 8-70

Z
ZONE ............................................................... 7-66
ZPOP ............................................................... 6-24
ZPUSH ............................................................ 6-20
ZRES ............................................................... 8-34

A-66 - KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Functions Index

APPENDICES
Functions Index

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual - A-67


Revision History
Printing Date Version Details of Revision

Apr 2015 Second version


Jan 2016 Third version
Aug 2016 Fourth version
Sep 2017 Sixth version
Aug 2019 First version
May 2020 1st revision
1st version
WARRANTIES AND DISCLAIMERS
(1) KEYENCE warrants the Products to be free of defects in materials and workmanship for a period of one (1)
year from the date of shipment. If any models or samples were shown to Buyer, such models or samples were
used merely to illustrate the general type and quality of the Products and not to represent that the Products
would necessarily conform to said models or samples. Any Products found to be defective must be shipped to
KEYENCE with all shipping costs paid by Buyer or offered to KEYENCE for inspection and examination. Upon
examination by KEYENCE, KEYENCE, at its sole option, will refund the purchase price of, or repair or replace
at no charge any Products found to be defective. This warranty does not apply to any defects resulting from
any action of Buyer, including but not limited to improper installation, improper interfacing, improper repair,
unauthorized modification, misapplication and mishandling, such as exposure to excessive current, heat,
coldness, moisture, vibration or outdoors air. Components which wear are not warranted.
(2) KEYENCE is pleased to offer suggestions on the use of its various Products. They are only suggestions, and it
is Buyer's responsibility to ascertain the fitness of the Products for Buyer’s intended use. KEYENCE will not be
responsible for any damages that may result from the use of the Products.
(3) The Products and any samples ("Products/Samples") supplied to Buyer are not to be used internally in
humans, for human transportation, as safety devices or fail-safe systems, unless their written specifications
state otherwise. Should any Products/Samples be used in such a manner or misused in any way, KEYENCE
assumes no responsibility, and additionally Buyer will indemnify KEYENCE and hold KEYENCE harmless from
any liability or damage whatsoever arising out of any misuse of the Products/Samples.
(4) OTHER THAN AS STATED HEREIN, THE PRODUCTS/SAMPLES ARE PROVIDED WITH NO OTHER
WARRANTIES WHATSOEVER. ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES, INCLUDING,
WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EXPRESSLY DISCLAIMED. IN
NO EVENT SHALL KEYENCE AND ITS AFFILIATED ENTITIES BE LIABLE TO ANY PERSON OR ENTITY
FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RESULTING FROM LOSS OF USE, BUSINESS
INTERRUPTION, LOSS OF INFORMATION, LOSS OR INACCURACY OF DATA, LOSS OF PROFITS,
LOSS OF SAVINGS, THE COST OF PROCUREMENT OF SUBSTITUTED GOODS, SERVICES OR
TECHNOLOGIES, OR FOR ANY MATTER ARISING OUT OF OR IN CONNECTION WITH THE USE OR
INABILITY TO USE THE PRODUCTS, EVEN IF KEYENCE OR ONE OF ITS AFFILIATED ENTITIES WAS
ADVISED OF A POSSIBLE THIRD PARTY’S CLAIM FOR DAMAGES OR ANY OTHER CLAIM AGAINST
BUYER. In some jurisdictions, some of the foregoing warranty disclaimers or damage limitations may not
apply.

BUYER'S TRANSFER OBLIGATIONS:


If the Products/Samples purchased by Buyer are to be resold or delivered to a third party, Buyer must provide
such third party with a copy of this document, all specifications, manuals, catalogs, leaflets and written
information provided to Buyer pertaining to the Products/Samples.

E 1101-3

- KV-8000/7000/5000/3000/1000 Series and KV Nano Series Script Programming Manual -


Copyright (c) 2018 KEYENCE CORPORATION. All rights reserved. 084576GB 2050-1 910GB Printed in Japan

You might also like