Keyence Programming
Keyence Programming
INDEX
Installation
Support
Software
Programming
2. System Installation
3. Access Window
4. KV-D20 Operator
Interface Panel
1. Introduction
1. Programming
2. Editor
2. Instructions
3. Simulator
3. Interrupts
4. Monitor
4. High-speed Counters
5. Appendices
5. Positioning Control
6. Interrupts, High-speed
Counters, Positioning
Control
5. KV-10/80 Hardware
6. Handheld Programmer
7. Serial Communication
8. Programming
Examples
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima,
Higashi-Yodogawa-ku,
Osaka, 533-8555, Japan
PHONE: 81-6-6379-2211
FAX: 81-6-6379-2131
User's Manual
Visual KV Series 3 Programming
1. Configuration and
Specifications
Visual KV Series
Programming
Safety Precautions
This instruction manual describes the operation and function of the KV Series PLC.
Read this manual carefully to ensure safe use and maximum performance from your
KV Series PLC.
Symbols
The following symbols alert you to important messages. Be sure to read these
messages carefully.
Failure to follow instructions may lead to injury. (electric
CAUTION
Note:
Conventions
This manual describes the operation/function of all Keyence KV Series PLC.
Note following conventions when you use.
Visual KV (Series)
KV-10xx, 16xx, 24xx, 40xx
KV-10AR/AT/DR/DT
KV-24AR/AT/DR/DT
KV-16AR/AT/DR/DT
KV-40AR/AT/DR/DT
Conventional KV (Series)
KV-300 (Series)
KV-10/80 (Series)
KV-10R(W)/T(W)
KV-24R(W)/T(W)
KV-80R(W)/T(W)
KV-300
KV-16R(W)/T(W)
KV-40R(W)/T(W)
General Precautions
At startup and during operation, be sure to monitor the functions and performance of the KV Sereis PLC.
We recommend that you take substantial safety measures to avoid any damage
in the event a problem occurs.
Do not open or modify the KV Series PLC or use it in any way other than described in the specifications.
When the KV Series PLC is used in combination with other instruments, functions and performance may be degraded, depending on operating conditions and
the surrounding environment.
Do not use the KV Series PLC for the purpose of protecting the human body.
Note: The built-in display may show the error message "Error 40" blinking the very
first time you turn on the power supply to the Visual KV Series. Press any key
around the display to cancel this message.
The Visual KV Series shows this message when no program is loaded.
(1)
Note to User
When using the Visual KV Series in the following conditions or environments, be
sure to use the Visual KV Series with sufficient margin regarding the rating and
functions, take appropriate safety precautions such as fail-safe, and contact our
sales personnel if any questions arise.
Use for nuclear power control, railway facilities, air service facilities, vehicles,
combustion devices, medical equipment, amusement machines, safety equipment, etc.
Use for applications where large effects are predicted to be given on human lives
and properties and safety is especially requested.
For wiring materials, use lead wires whose sheath is 0.4 mm or more.
(2)
(3)
Interrupt function
The Visual KV Series is equipped with four high-speed interrupt inputs of
10 s maximum.
Input time constant change function
The time constant can be set in 7 steps from 10 s to 10 ms.
Double memory backup functions
In addition to a conventional SRAM battery backup function, the Visual KV Series
is also equipped with an EEPROM backup function.
The time constant for an input relay specified by the HSP instruction is 10 s.
The analog trimmer function is set with the Access Window built into the basic
unit.
The available device setting range of the TMIN instruction is from 0 to 65535.
[Handheld programmer KV-P3E(01) can display 0 to 9999 .]
The specifications for output current of transistor outputs Nos. 500 to 502 is 100
mA.
Conventional KV Series expansion units are not available as expansion units for
the Visual KV Series.
The channel setting switch is not provided for expansion units. Channels are
determined in connection order.
Scans in expansion I/O units are not synchronous with the scan time in Visual KV
Series basic units.
Data memory device Nos. DM1000 to DM1999 are assigned as special data
memories.
(4)
CAUTION
When using the ladder support software "KV IncrediWare (DOS)" or "LADDER
BUILDER for KV Ver. 1.0x", set the model to "KV-300".
DM0 to DM1999 are only available.
When the ladder support software "LADDER BUILDER for KV Ver. 1.0x" is
used, do not use the monitors Change All function. If the Change All function
is used, the basic unit may be damaged. Never use the Change All function.
Peripheral units and other units incompatible with the Visual KV Series
Peripheral units in the conventional KV Series and other units shown below are not
compatible with the Visual KV Series.
(5)
Never leave both the KV-D20 operator interface panel and KV-P3E(01) handheld
programmer on simultaneously for a long period of time.
(6)
1 Installation
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Handheld Programmer
Describes how to use the handheld programmer and memory card.
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Troubleshooting
This chapter describes the error code list, countermeasures against problems, and error
indications for each unit.
Appendices
The appendix includes a list of ladder program applications and the index.
2 Support Software
Chapter 1
Introduction
Describes the items included in the package, the product outline, the method to connect
a personal computer, the installation method, etc.
(7)
Chapter 2
Editor
Describes the operating procedures in Editor mode.
Chapter 3
Simulator
Describes the operating procedures in Simulator mode.
Chapter 4
Monitor
Describes the operating procedures in Monitor mode.
Appendices
Includes instructions list, devices list, sample program list and quick reference for key
operation and shortcuts.
3 Programming
Chapter 1
Programming
Describes basic knowledge including program creation procedures, device configuration,
relay assignments, special functions to set and confirm Visual KV Series operations, as
well as the extended ladder diagrams. Understand the contents described here completely at first before creating programs.
Chapter 2
Instructions
Describes the concrete usage of instructions in the KV Series.
Refer to "Chapter 3 Interrupts" on page 3-183 for details of interrupt instructions.
Refer to "Chapter 4 High-speed counters" on page 3-195 for details of the high-speed
counters used in the application instruction.
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Serial Communication
The KV Series can be connected to an external device with an RS-232C interface to
establish communication.
This chapter describes communications specifications, how to connect the KV Series to
external devices, and how to perform communication.
Chapter 8
Programming Examples
Describes the typical programming examples for KV-10/80 Series. These programs can
be used for Visual KV Series. However, pay attention to the I/O addressing compatibility
before use.
(8)
Contents
3
Programming
Chapter 1
Programming
1.1
Before Creating Programs .............................................................................. 3-2
1.1.1 Flow from Introduction to Operation ................................................................... 3-2
1.1.2 Scan Time ........................................................................................................... 3-3
Scan time ..................................................................................................... 3-3
Input response time delay ............................................................................ 3-3
1.2
User Memory .................................................................................................... 3-4
1.2.1 Program Capacity ............................................................................................... 3-4
Maximum number of lines in a program ....................................................... 3-4
Calculating the byte count used ................................................................... 3-4
1.3
Device Configuration ....................................................................................... 3-5
1.3.1 Device List .......................................................................................................... 3-5
Relay list ...................................................................................................... 3-5
List of I/O relays in basic units ..................................................................... 3-5
List of relays in expansion units ................................................................... 3-6
1.3.2 Relay No. ............................................................................................................ 3-7
Address No. ................................................................................................. 3-7
Contact No. .................................................................................................. 3-8
Channel No. ................................................................................................. 3-8
1.3.3 Assigning Relay Nos. .......................................................................................... 3-8
1.3.4 Input Relays ........................................................................................................ 3-9
Basic unit ..................................................................................................... 3-9
Expansion unit ........................................................................................... 3-10
1.3.5 Output Relays ................................................................................................... 3-10
Output operation time ................................................................................ 3-10
1.3.6 Internal Utility Relays ........................................................................................ 3-11
Retentive function of internal utility relays .................................................. 3-11
1.3.7 Special Utility Relays ........................................................................................ 3-12
Description ................................................................................................. 3-12
1.3.8 Special Utility Relay List ................................................................................... 3-14
Special relays and arithmetic operation flags ............................................ 3-14
Special utility relays for high-speed counter(0) .......................................... 3-14
Special utility relays for high-speed counter(1) .......................................... 3-15
Other special utility relays .......................................................................... 3-15
1.3.9 Timers and Counters ........................................................................................ 3-18
Timer/Counter list ....................................................................................... 3-18
Description ................................................................................................. 3-18
1.3.10 Data Memories ................................................................................................. 3-19
1.3.11 Temporary Data Memory .................................................................................. 3-21
1.3.12 Relay Nos. and Functions ................................................................................. 3-22
1.4
Special Functions .......................................................................................... 3-23
1.4.1 Input Time Constant Change Function ............................................................. 3-23
Setting the input time constant for basic units using special utility relays .. 3-23
1.4.2 Modifying the Input Relay Time Constant ......................................................... 3-24
Modification within the CPU ....................................................................... 3-24
1.4.3 Constant Scan Time Mode ............................................................................... 3-25
1.4.4 Output Disabled Function ................................................................................. 3-26
1.4.5 Input Refresh Disabled Function ...................................................................... 3-26
1.4.6 Contact Comment Save Function ..................................................................... 3-27
1.4.7 Special Functions ............................................................................................. 3-28
Constant Scan Time Mode ........................................................................ 3-28
Output Disabled Function .......................................................................... 3-28
Input Refresh Disabled Function ................................................................ 3-28
1.5
1.5.1
1.5.2
1.5.3
(9)
Chapter 2
Chapter 3
Instructions
2.1
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.2
2.2.1
2.2.2
2.2.3
2.2.4
2.3
2.4
2.4.1
2.4.2
2.4.3
2.5
Interrupts
Visual KV
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.3
Direct Input/Output ...................................................................................... 3-197
3.3.1 Direct Input ..................................................................................................... 3-197
3.3.2 Direct Output ................................................................................................... 3-197
3.4
3.4.1
3.4.2
3.4.3
3.4.4
Chapter 4
High-speed Counters
4.1
Visual KV
4.2
Outline of High-speed Counters ................................................................. 3-206
4.2.1 High-speed Counters and High-speed Counter Comparators ........................ 3-206
Structure of high-speed counters and high-speed counter comparators . 3-206
Specifications of high-speed counters ..................................................... 3-208
High-speed counter comparators ............................................................. 3-209
4.2.2 Internal Clock for High-speed Counters .......................................................... 3-210
4.3
4.3.1
4.3.2
4.3.3
4.3.4
4.3.5
4.3.6
4.5
(10)
4.5.1
4.5.2
4.5.3
4.5.4
4.5.5
Chapter 5
Positioning Control
Visual KV
5.1
Outline of Positioning Control .................................................................... 3-254
5.1.1 Ramp-up/down Control ................................................................................... 3-254
5.2
Parameter Setting and Operating Procedures .......................................... 3-255
5.2.1 Parameter Setting Procedure ......................................................................... 3-255
5.2.2 Operating Procedure ...................................................................................... 3-257
5.3
5.3.1
5.3.2
5.3.3
Chapter 6
KV-300, KV-10/80
6.1
Interrupt Instructions ................................................................................... 3-268
6.1.1 Description of Interrupts .................................................................................. 3-268
Input processing for routine program and interrupt routine ...................... 3-268
Types of interrupt ..................................................................................... 3-268
Interrupt priority ........................................................................................ 3-269
Interrupt routine ........................................................................................ 3-269
Direct output ............................................................................................. 3-270
Direct input ...............................................................................................3-270
6.1.2 Interrupt Instructions ....................................................................................... 3-271
6.2
Direct Clock Pulse ........................................................................................ 3-276
6.2.1 Output of Direct Clock Pulse ........................................................................... 3-276
Outline of High-Speed Counters .............................................................. 3-276
Outline of Pulse Output ............................................................................ 3-279
Examples of Pulse Output ....................................................................... 3-284
6.3
Positioning Control ...................................................................................... 3-296
6.3.1 Positioning Control (Ramp-up/down Control) ................................................. 3-296
Outline of positioning control .................................................................... 3-296
Setting and application of parameters ..................................................... 3-297
Examples of stepping motor control ......................................................... 3-300
Chapter 7
Serial Communication
7.1
7.1.1
7.1.2
7.1.3
7.2
Serial Communication ................................................................................. 3-308
7.2.1 Command Transmission Procedure ............................................................... 3-308
(11)
Chapter 8
7.2.2
7.2.3
7.2.4
7.2.5
7.2.6
7.2.7
7.3
7.3.1
7.3.2
7.3.3
7.4
Programming Examples
8.1
List
......................................................................................................... 3-324
8.2
Details ......................................................................................................... 3-326
8.2.1 Reference Program Examples ........................................................................ 3-326
Basic Instructions ..................................................................................... 3-326
Application Instructions ............................................................................ 3-334
Arithmetic Instructions .............................................................................. 3-343
3-367
Installation
Chapter 1
Visual KV
1.1
System Configuration ...................................................................................... 1-2
1.1.1 System Configuration ......................................................................................... 1-2
1.2
Specifications ................................................................................................... 1-4
1.2.1 General Specifications ........................................................................................ 1-4
1.2.2 AC Power Specifications .................................................................................... 1-5
Visual KV Series operation at power interruption ........................................ 1-5
1.2.3 Performance Specifications ................................................................................ 1-6
Data backup function against instantaneous power interruption ................. 1-7
1.3
Common I/O Specifications of Basic Units ................................................... 1-8
1.3.1 Model of a Basic Unit .......................................................................................... 1-8
1.3.2 Common I/O Specifications ................................................................................ 1-8
1.4
KV-10AR/AT(P)/DR/DT(P) (10-I/O Basic Unit) ............................................. 1-10
1.4.1 Part Names and Functions ............................................................................... 1-10
1.4.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................ 1-11
KV-10AR/DR (Relay output type) .............................................................. 1-11
KV-10AT(P)/DT(P) (Transistor output type) ............................................... 1-13
1.4.3 AC Power Input (KV-10AR/AT(P)) .................................................................... 1-14
1.4.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-15
1.4.5 Dimensions ....................................................................................................... 1-16
1.5
KV-16AR/AT(P)/DR/DT(P) (16-I/O Basic Unit) ............................................. 1-17
1.5.1 Part Names and Functions ............................................................................... 1-17
1.5.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................ 1-18
KV-16AR/DR (Relay output type) .............................................................. 1-18
KV-16AT(P)/DT(P) (Transistor output type) ............................................... 1-20
1.5.3 AC Power Input (KV-16AR/AT(P)) .................................................................... 1-21
1.5.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-22
1.5.5 Dimensions ....................................................................................................... 1-23
1.6
KV-24AR/AT(P)/DR/DT(P) (24-I/O Basic Unit) ............................................. 1-24
1.6.1 Part Names and Functions ............................................................................... 1-24
1.6.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................ 1-25
KV-24AR/DR (Relay output type) .............................................................. 1-25
KV-24AT(P)/DT(P) (Transistor output type) ............................................... 1-27
1.6.3 AC Power Input (KV-24AR/AT(P)) .................................................................... 1-28
1.6.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-29
1.6.5 Dimensions ....................................................................................................... 1-30
1.7
(12)
Chapter 2
System Installation
Visual KV
2.1
2.1.1
2.1.2
2.1.3
(13)
Chapter 3
Access Window
Visual KV
3.1
Overview of the Access Window .................................................................. 1-80
3.1.1 What is the Access Window ............................................................................. 1-80
3.1.2 Access Window Use Examples ........................................................................ 1-80
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.3
Digital Trimmer Mode .................................................................................... 1-84
3.3.1 Function and Operating Procedure ................................................................... 1-84
Key operation and screen display .............................................................. 1-84
Function and operating procedure ............................................................. 1-84
3.4
Device Mode ................................................................................................... 1-87
3.4.1 Function and Operating Procedure ................................................................... 1-87
Devices that can be displayed and changed ............................................. 1-87
Key operation and screen display .............................................................. 1-87
Selecting the device and displaying the current value/set value ................ 1-88
Changing a numeric value ......................................................................... 1-89
Holding the setting ..................................................................................... 1-91
3.4.2 Screen Display for Each Device Type .............................................................. 1-91
Data memory (DM) .................................................................................... 1-91
Temporary data memory (TM) ................................................................... 1-91
Timer/counter (T/C) .................................................................................... 1-92
High-speed counter comparator (CTC) ...................................................... 1-92
Trimmer (TRM) .......................................................................................... 1-93
Relay (RLY) ...............................................................................................1-93
3.5
System Mode .................................................................................................. 1-94
3.5.1 Function and Operating Procedure ................................................................... 1-94
Key operation and screen display .............................................................. 1-94
LOAD mode and SAVE mode .................................................................... 1-96
Display in LOAD/SAVE mode .................................................................... 1-96
3.6
Message Display ............................................................................................ 1-97
3.6.1 Error Messages and Error Status ..................................................................... 1-97
3.6.2 User Messages ................................................................................................. 1-97
How to use the user messages .................................................................. 1-98
Chapter 4
Visual KV
4.1
4.1.1
4.1.2
4.1.3
(14)
Chapter 5
KV-300, KV-10/80
5.1
System Configuration .................................................................................. 1-166
5.1.1 KV-300 ............................................................................................................1-166
5.1.2 KV-10/80 ......................................................................................................... 1-167
5.2
Module/Unit Specifications ......................................................................... 1-168
5.2.1 Wiring: KV-U4 Power Supply Module ............................................................. 1-168
Parts and functions .................................................................................. 1-168
5.2.2 Wiring: KV-U5 DC Power Distribution Module ................................................ 1-169
Parts and functions .................................................................................. 1-169
5.2.3 Wiring: KV-300 CPU ....................................................................................... 1-170
Parts and functions .................................................................................. 1-170
5.2.4 Wiring: KV-C16X/C32X Connector Input Module ........................................... 1-171
Parts and functions .................................................................................. 1-171
5.2.5 Wiring: KV-C32T/B16R/B16S Connector Output Module ............................... 1-172
Parts and functions .................................................................................. 1-172
5.2.6 Wiring: KV-R1A I/O Distribution Module ......................................................... 1-173
Parts and functions .................................................................................. 1-173
5.2.7 Wiring: KV-R8X/R16X/R8R/R16R/R8T/R16T I/O Terminal Modules ............. 1-174
Parts and functions .................................................................................. 1-174
5.2.8 Module Names and Functions ........................................................................ 1-175
5.2.9 Peripheral Equipment Names and Functions ................................................. 1-176
5.3
5.3.1
5.3.2
5.3.3
(15)
5.3.6 Connecting the AC Power Supply Module and DC Power Distribution Module .... 1-182
KV-U4 AC Power Supply Module ............................................................ 1-182
KV-U5 DC Power Distribution Module ..................................................... 1-182
5.3.7 I/O Connectors ................................................................................................ 1-183
KV-300 CPU ............................................................................................ 1-183
KV-C16X/C32X ........................................................................................ 1-184
KV-C32T/B16R/B16S .............................................................................. 1-185
KV-R8X/R16X/R8R/R16R/R8T/R16T ...................................................... 1-186
5.3.8 I/O Terminal Modules: Communication Cables and Power Distribution ......... 1-187
Transmission distance by cable type ....................................................... 1-187
Connection patterns ................................................................................. 1-187
Incorrect wiring patterns ........................................................................... 1-188
Power distribution .................................................................................... 1-188
5.3.9 Connector Assembly Instructions ................................................................... 1-189
5.3.10 KV-300 CPU I/O Indicators ............................................................................. 1-191
5.3.11 KV-10/80 Expansion Units .............................................................................. 1-192
5.3.12 Mounting Environment .................................................................................... 1-194
Chapter 6
Handheld Programmer
6.1
Using the Handheld Programmer ............................................................... 1-196
6.1.1 Outline of the Handheld Programmer ............................................................. 1-196
6.1.2 Precautions ..................................................................................................... 1-198
6.2
Basic Operations ......................................................................................... 1-200
6.2.1 Basic Programming Operation ........................................................................ 1-200
6.3
6.4
Memory Card ................................................................................................ 1-230
6.4.1 Functions [used with KV-P3E(01)] .................................................................. 1-230
6.4.2 Storage Capacity ............................................................................................ 1-230
CLEAR ..................................................................................................... 1-232
NEW ......................................................................................................... 1-233
ACCS ....................................................................................................... 1-234
ACCS: SAVE ........................................................................................... 1-235
ACCS: LOAD ........................................................................................... 1-236
ACCS: VERIFY ........................................................................................ 1-236
ACCS: DELETE ....................................................................................... 1-237
Chapter 7
KV-300
7.1
Outline ......................................................................................................... 1-240
7.1.1 Features .......................................................................................................... 1-240
7.2
7.2.1
7.2.2
7.2.3
7.3
7.3.1
7.3.2
7.3.3
(16)
Chapter 8
KV-300
8.2
Configuration ...............................................................................................1-313
8.2.1 Parts and Functions ........................................................................................ 1-313
8.2.2 System Configuration ..................................................................................... 1-314
8.3
Installation .................................................................................................... 1-315
8.3.1 Terminal Nos. ................................................................................................. 1-315
(17)
8.3.2
8.3.3
8.3.4
8.3.5
8.4
8.4.1
8.4.2
8.4.3
8.4.4
8.4.5
8.4.6
8.4.7
8.4.8
8.4.9
8.5
8.5.1
8.5.2
8.5.3
Chapter 9
KV-10/80
9.2
Configuration ............................................................................................... 1-335
9.2.1 Part Names and Functions ............................................................................. 1-335
KV-AD4 .................................................................................................... 1-335
KV-DA4 .................................................................................................... 1-336
9.2.2 Specifications .................................................................................................. 1-337
KV-AD4 .................................................................................................... 1-337
KV-DA4 .................................................................................................... 1-339
9.2.3 System Configuration ..................................................................................... 1-341
9.3
9.3.1
9.3.2
9.3.3
9.6
(18)
Chapter 10
Troubleshooting
10.1
10.1.1
10.1.2
10.1.3
10.1.4
10.2
Appendices
Appendix A. Specifications and Dimensions [Visual KV Series] .................... 1-382
A.1
System Specifications [Visual KV Series] ....................................................... 1-382
Hardware ................................................................................................. 1-382
Software and Programming ..................................................................... 1-383
AC power supply unit ............................................................................... 1-384
A.2
Common I/O Specifications of Basic Units ..................................................... 1-384
Input specifications .................................................................................. 1-384
Output specifications (relay output): KV-10AR/DR, KV-16AR/DR,
KV-24AR/DR, and KV-40AR/DR .............................................................. 1-385
Output specifications (transistor output): KV-10AT(P)/DT(P),
KV-16AT(P)/DT(P), KV-24AT(P)/DT(P), and KV-40AT(P)/DT(P) ............ 1-385
A.3
Expansion Unit Specifications ........................................................................ 1-385
A.4
Dimensions .....................................................................................................1-389
Appendix B. Specifications and Dimensions [KV-300 Series] ......................... 1-392
B.1
System Specifications [KV-300 Series] .......................................................... 1-392
Hardware ................................................................................................. 1-392
Software and Programming ..................................................................... 1-393
AC Power supply module/DC power distribution module ........................ 1-394
B.2
Module Specifications ..................................................................................... 1-398
KV-300 CPU ............................................................................................ 1-398
KV-C16X/C32X Input Modules ................................................................ 1-399
KV-C32T/B16R/B16S Output Modules ................................................... 1-400
KV-R8X/R16X I/O Terminal Modules ....................................................... 1-401
KV-R8T/R16T/R8R/R16R I/O Terminal Modules ..................................... 1-402
KV-R8T/R16T/R8R/R16R I/O Terminal Modules (RUN Output) .............. 1-403
KV-R1A I/O Distribution Module .............................................................. 1-403
B.3
Dimensions .....................................................................................................1-404
Appendix C.
1-419
Support software
Chapter 1
Introduction
1.1
1.2
Outline of the Ladder Builder for KV .............................................................. 2-3
1.2.1 Operating environment and system configuration .............................................. 2-3
1.2.2 Features and functions of the Ladder Builder for KV .......................................... 2-4
Features of the Ladder Builder for KV ......................................................... 2-4
Functions of the Ladder Builder for KV ........................................................ 2-6
1.3
(19)
Chapter 2
1.5
1.6
1.6.1
1.6.2
1.6.3
1.6.4
1.6.5
Editor
KV-300
2.1
Outline of the Editor Functions .................................................................... 2-26
2.1.1 Cautions for editing ladder programs ................................................................ 2-26
2.2
Edit Screen .....................................................................................................2-27
2.2.1 Name and function of each part of the screen .................................................. 2-27
2.2.2 Ladder program window screen ....................................................................... 2-28
2.3
2.3.1
2.3.2
2.3.3
2.3.4
2.3.5
2.3.6
2.3.7
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5
2.5.1
2.5.2
2.5.3
2.6
Edit and Arrangement .................................................................................. 2-52
2.6.1 Copy, move, and delete .................................................................................... 2-52
2.6.2 Inserting and deleting lines ............................................................................... 2-57
2.7
2.7.1
2.7.2
2.7.3
2.7.4
2.7.5
2.8
Editing the Mnemonic List ........................................................................... 2-67
2.8.1 Displaying and terminating a mnemonic list ..................................................... 2-67
2.8.2 Copy, move, and delete .................................................................................... 2-69
2.9
Displaying the Use Status ............................................................................. 2-70
2.9.1 Displaying a use status list ............................................................................... 2-70
2.10 Setting the System .........................................................................................2-71
2.10.1 Setting the system ............................................................................................ 2-71
2.11 Entering and Developing Macros ................................................................ 2-72
2.11.1 Creating a macro file .........................................................................................2-72
2.11.2 Entering and developing macros ...................................................................... 2-74
2.12
2.12.1
2.12.2
2.12.3
2.13
(20)
Chapter 3
Simulator
3.1
Outline of the Simulator Functions .............................................................. 2-84
3.1.1 Outline of the functions ..................................................................................... 2-84
3.1.2 Restrictions in the simulator .............................................................................. 2-84
3.2
Starting up and Exiting from the Simulator ................................................. 2-86
3.2.1 Operating procedure for startup and exit .......................................................... 2-86
3.2.2 Name and function of each part of the screen .................................................. 2-88
Chapter 4
3.3
3.3.1
3.3.2
3.3.3
3.3.4
3.3.5
3.4
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.5
3.5.1
3.5.2
3.5.3
3.5.4
3.5.5
3.5.6
3.5.7
Monitor
4.1
4.1.1
4.1.2
4.1.3
4.2
Communicating with the PLC ..................................................................... 2-136
4.2.1 Setting the PLC communication parameters .................................................. 2-136
4.2.2 Setting the comment transfer .......................................................................... 2-138
4.3
Starting up and Exiting from the Monitor .................................................. 2-139
4.3.1 Operating procedures for startup and exit ...................................................... 2-139
4.3.2 Name and function of each part of the screen ................................................ 2-143
4.4
4.4.1
4.4.2
4.4.3
4.4.4
4.4.5
4.4.6
4.4.7
4.5
Monitor All and Registration Monitor ......................................................... 2-148
4.5.1 Functions of the monitor all window ................................................................ 2-148
4.5.2 Functions of the registration monitor .............................................................. 2-148
4.6
4.6.1
4.6.2
4.6.3
(21)
Appendices
Appendix A Error Message List ......................................................................... 2-156
A-1
System errors ................................................................................................. 2-156
A-2
Memory errors ................................................................................................ 2-156
A-3
File errors ........................................................................................................ 2-157
A-4
Installation errors ............................................................................................ 2-157
A-5
Errors that occur in the editor ......................................................................... 2-158
A-6
Errors that occur in the monitor/simulator ....................................................... 2-159
A-7
Communication errors (displayed in the monitor) ........................................... 2-159
A-8
PLC errors ...................................................................................................... 2-160
A-9
Errors that occur during compilation ............................................................... 2-161
Appendix B Instruction List ............................................................................... 2-163
B-1
Basic instructions ............................................................................................ 2-163
B-2
Application instructions ................................................................................... 2-164
B-3
Arithmetic instructions ..................................................................................... 2-165
B-4
Interrupt instructions ....................................................................................... 2-166
Appendix C Relay No. List .................................................................................. 2-167
C-1
Relays, timers, counters, and memory numbers for each model ................... 2-167
Appendix D Special Utility Relay List ................................................................ 2-168
D-1
Special relays and arithmetic operation flags ................................................. 2-168
D-2
Special utility relays for high-speed counter (0) .............................................. 2-168
D-3
Special utility relays for high-speed counter (1) .............................................. 2-169
D-4
Other special utility relays ............................................................................... 2-169
D-5
Memory switches ............................................................................................ 2-172
D-6
Special memory list ......................................................................................... 2-172
Appendix E Devices for KV-10R(W)/T(W) to 80R(W)/T(W), KV-300 ................ 2-174
E-1
Special utility relays ........................................................................................ 2-174
E-2
Memory switches ............................................................................................ 2-176
E-3
Special memory list ......................................................................................... 2-176
Appendix F Sample Program List ..................................................................... 2-178
F-1
Description of sample ladder programs .......................................................... 2-178
Appendix G Quick Reference ............................................................................. 2-180
G-1 Editor .............................................................................................................. 2-180
G-2 Simulator ......................................................................................................... 2-188
G-3 Monitor ............................................................................................................ 2-195
Appendix H Notes for Programming ................................................................. 2-201
H-1
Circuits that must be modified ........................................................................ 2-201
H-2
Precautions for programming ......................................................................... 2-202
H-3
Programs which cannot be decompiled .......................................................... 2-203
Appendix I
Appendix J
2-215
(22)
Caution
KEYENCE has thoroughly checked and reviewed this manual. Please contact
the sales office listed at the end of this manual if you have any questions or
comments regarding this manual or if you find an error.
KEYENCE assumes no liability for damages resulting from the use of the information in this manual, item 3 above notwithstanding.
All company names and product names in this manual are registered trademarks or
trademarks of their respective owners.
(23)
Chapter 1
Programming
This chapter describes basic knowledge including program creation procedures,
device configuration, relay assignments, special functions to set and confirm Visual
KV Series operations, as well as the extended ladder diagrams. Understand the
contents described here completely at first before creating programs.
1.1
1.1.1
1.1.2
1.2
1.2.1
1.3
1.3.1
1.3.2
1.3.3
1.3.4
1.3.5
1.3.6
1.3.7
1.3.8
1.3.9
1.3.10
1.3.11
1.3.12
1.4
1.4.1
1.4.2
1.4.3
1.4.4
1.4.5
1.4.6
1.4.7
1.5
1.5.1
1.5.2
1.5.3
3-23
3-24
3-25
3-26
3-26
3-27
3-28
Fig. 1
PB1 = N.O. contact switch
PB2 = N.C. contact switch
PB1
PB2
RL
(Relay)
Time chart
PB1 contact
PB2 contact
PL
ON
OFF
ON
OFF
ON
PL
OFF
Next, a program is created that will use the same operation as this circuit to control a PLC.
Program examination
Circuit 1 shows relay symbols for the latch circuit.
Examine which contact in the Visual KV Series is used for each pushbutton switch and pilot lamp
(Table 1). When many I/O devices are required for control, expansion units should also be considered.
Table 1
Circuit 1
RL
PB1 PB2
RL
Relay (coil)
Relay (contact)
RL
Relay (contact)
PL
Pilot lamp
I/O device
Pushbutton switch PB1 (N.O. contact)
Pushbutton switch PB2 (N.C. contact)
Relay RL
Pilot lamp PL
Contact No.
Input relay (0000)
Input relay (0001)
Internal relay (1000)
Output coil (0500)
Program creation
Edit a program using the "LADDER BUILDER for KV" programming support software creation tool.
Ladder diagram
0000
0001*
1000
1000
1000
0500
Coding list
LD
0000
OR
1000
AND 0001
OUT 1000
LD
1000
OUT 0500
END
Operation
3-2
Chapter 1 Programming
Input processing
Program execution
Output processing
The duration of time required to perform one cycle is called the scan time (or cycle
time). The scan time varies based on program size and the instructions used in the
program.
Input signal
ON
OFF
Scan time
Input processing
Program
execution
Output processing
Input processing
Program
execution
Output processing
Program
execution
Input processing
Read
Output processing
Input processing
Program
execution
Output processing
Input processing
Output processing
Read
Scan time
Reference: The maximum and minimum values of the input response time are as
follows.
Maximum value: Input time constant + Scan time x 2 + Output response delay time
Minimum value: Input time constant + Scan time + Output response delay time
Note 1: When the input time constant is made small by setting the HSP instruction,
special utility relay 2813, and data memory DM1940, a signal may not be received if
its ON time is shorter than the scan time.
Note 2: The INT instruction is independent of the scan time.
Note 3: The minimum scan time is 140 s (with the basic unit).
Chapter 1 Programming
3-3
11
For more about byte counts for each instruction, refer to "2.1 Instruction List" (p.3-34).
Total byte count of the memory used by instructions 6,000 bytes / 12,000
bytes
For example, the allowable number of steps to be written can be calculated from the
memory occupied by the instructions as follows.
12,000 bytes / 3 bytes (average byte count of an instruction) = 4,000 steps
Note: If either the memory occupied by the instructions or the memory occupied by
objects of a program exceeds the specified memory capacity, the program cannot
be written or executed.
0000
0500
T000
0500
Line No.
Instruction
Operand
Byte count
00000
LD
0000
00001
OR
0500
00002
TMR
000#00020
00003
ANB
T000
OUT
0500
00004
Total
3-4
Chapter 1 Programming
Number of objects
14 bytes
32 bytes
Normal use
High-speed
use (1)
0000
0001
0002
Input relays
(Direct input
allowed area)
Interrupt inputs
INT0 to INT3
Remarks
(Polarity inversion
allowed)
Input captures
0003
High-speed
counter 0 input
High-speed
counter 1 input
0004
0005
0006
Input relays
0007
0008
0009
0010 to 0415
0502
A phase
input
B phase
input
Output relays
(Direct output
allowed area)
11
Preset
input
Input relays
0500
0501
High-speed
counter 0
High-speed
counter 1
High-speed
counter 0
High-speed
counter 1
High-speed
counter 0
High-speed
counter 1
0503
70 points
0504 to 0915
Output relays
76 points
1000 to 1915
160 points
2000 to 2815
144 points
2900 to 2915
2,144 points
Note 1: The ON/OFF status of the set functions is always cleared when the operation mode is changed from PROGRAM to RUN. However, special utility relays 2700
to 2715 are held even when the operation mode is changed from PROGRAM to
RUN or when the power is turned off.
Note 2: Internal utility relays can be held by setting the MEMSW instruction
KV-10xx
KV-16xx
KV-24xx
KV-40xx
0000 to 0005
0000 to 0009
0000 to 0015
0000 to 0107
0500 to 0503
0500 to 0505
0500 to 0507
0500 to 0515
Chapter 1 Programming
3-5
KV-E4X
KV-E8X
KV-40
KV-10/16/24
KV-10/16/24
KV-E16X
KV-40
KV-40
KV-10/16/24
100 to 103 200 to 203 100 to 107 200 to 207 100 to 115 200 to 215
200 to 203 300 to 303 200 to 207 300 to 307 200 to 215 300 to 315
300 to 303 400 to 403 300 to 307 400 to 407 300 to 315 400 to 415
400 to 403
400 to 407
400 to 415
Output units
Connection
order
1st output
module
2nd output
module
3rd output
module
4th output
module
KV-E4T(P)/R
KV-E8T(P)/R
KV-E16T(P)/R
600 to 603
600 to 607
600 to 615
700 to 703
700 to 707
700 to 715
800 to 803
800 to 807
800 to 815
900 to 903
900 to 907
900 to 915
I/O units
KV-E4XR/T(P)
Connection
order
1st input
module
2nd input
module
3rd input
module
4th input
module
1st output
module
2nd output
module
3rd output
module
4th output
module
*
*
3-6
Input relays
Output relays
KV-10/16/24
KV-40
100 to 103
200 to 203
200 to 203
300 to 303
300 to 303
400 to 403
KV-10/16/24
KV-40
603 to 606
603 to 606
703 to 703
703 to 703
803 to 803
803 to 803
903 to 903
903 to 903
400 to 403
Relay Nos. of expansion units are automatically assigned in the order of connection.
The connection order is counted only for input and output units. When I/O units are
connected, they are counted as input units and output units separately.
Chapter 1 Programming
12515
Contact No.
(00 to 15)
Address No.
(Input: 0 to 4, output: 5 to 9)
Address No.
Address Nos. are assigned to basic units, input expansion units, output expansion
units, and I/O expansion units. Zero to 4 are assigned to input units, while 5 to 9 are
assigned to output units. Address Nos. assigned in a unit vary based on the number
of I/O terminals and the connection position of the unit.
Model
Basic units
Address Nos.
KV-10xx
0, 5
KV-16xx
0, 5
KV-24xx
0, 5
KV-40xx
0, 1, 5
kV-E4X
1 to 4*
KV-E8X
1 to 4*
KV-E16X
1 to 4*
KV-E4R/E4T(P)
6 to 9
KV-E8R/E8T(P)
6 to 9
KV-E16R/E16T(P)
6 to 9
KV-E4XR/E4XT(P)
1 to 4*, 6 to 9
11
* 2 to 4 in KV-40xx
Chapter 1 Programming
3-7
Contact No.
Contact Nos. are input/output terminal Nos. of basic units, input expansion units,
output expansion units, and I/O expansion units.
Example
In the KV-E4X, with 4 input terminals, the contact Nos. are 0 to 3. In the KVE16T(P), with 16 input terminals, the contact Nos. are 0 to 15.
In a unit with 16 or more terminals, the contact No. of the 17th terminal returns to
0 and its address No. is increased by 1.
Example
In the KV-40AR, with 40 terminals (24 input and 16 output terminals), address
No. 0 is assigned to input terminal Nos. 1 to 16 and address No. 1 is assigned to
input terminal Nos. 17 to 24
Channel No.
The channel No. is the higher order digit in the contact No.
b) KV-E4X Input
expansion
unit
Input: 4 points
c) KV-E8R Output
expansion unit
Output: 8 points
With the connections above, the relay Nos. for each unit are assigned as shown in
the table below.
3-8
Unit
a) KV-16AR
b) KV-E4X
c) KV-E8R
Chapter 1 Programming
Basic unit
Input relay time constant
Though the time constant is usually 10 ms 20%, it can be changed using the
following settings.
While special utility relay 2813 remains ON, the time constant can be changed in
7 steps by setting data memory DM1940 as follows.
When DM1940 is set to 0: 10s 20%
1: 20 s 20%
2: 500 s 20%
3: 1 ms 20%
4: 2.5 ms 20%
5: 5 ms 20%
6: 10 ms 20%
Never set a numeric value of 7 or larger.
11
For more about changing the input time constant, refer to "1.4.1 Input Time Constant Change
Function" (p.3-23).
"HSP instruction" (p.3-86), "INT instruction" (p.3-192), "4.1 High-speed Counter Instructions"
(p.3-204)
Note 1: While special utility relay 2813 remains ON, the input time constant can be
specified for all input relays in a basic unit.
Note 2: Never enter a number of 7 or larger to data memory DM1940.
Note 3: The input time constant specified by data memory DM1940 becomes
effective at the rising edge of special utility relay 2813. To change the input time
constant, first change data memory DM1940, then set special utility relay 2813 to
OFF and ON again. Or change the operation mode of a KV basic unit from PROGRAM to RUN.
Note 4: If the HSP instruction and special utility relay 2813 are used at the same
time, priority is given to the HSP instruction.
Note 5: Only when a high-speed counter input or INT instruction is given, available
input signals do not depend on the scan time.
Chapter 1 Programming
3-9
Expansion unit
Input relay time constant
By setting special utility relays 2609 to 2612 to ON, the time constant in input expansion units can be set to 10 s.
Special utility
relay No.
2609*
2610
2611
2612
*
Function
Input time constant of input expansion unit
with relay Nos. 0100 to 0115
Input time constant of input expansion unit
with relay Nos. 0200 to 0215
Input time constant of input expansion unit
with relay Nos. 0300 to 0315
Input time constant of input expansion unit
with relay Nos. 0400 to 0415
Transistor output
OFF ON: 50 s or less (10 s or less in 500 to 502)
ON OFF: 250 s or less (10 s or less in 500 to 502, 100 s or less for other
outputs in the basic unit)
Relay output
OFF ON: 10 ms or less
ON OFF: 10 ms or less
Transistor output type
KV-10AT(P)/DT(P)
KV-16AT(P)/DT(P)
KV-16AR/DR
KV-24AT(P)/DT(P)
KV-40AT(P)/DT(P)
KV-24AR/DR
KV-40AR/DR
KV-E4T
KV-E8T(P)
KV-E4R
KV-E8R
KV-E16T(P)
KV-E4XT(P)
KV-E16R
KV-E4XR
Note 1: When programming direct clock pulses, output relays 0500 and 0501 are
used to output pulses in a transistor-type output unit.
Note 2: When the ramp-up/down control function is used, output relay 0502 outputs
positioning pulses in a transistor-type output unit.
"Chapter 5. Positioning Control" (p.3-253)
Note 3: When the specified frequency pulse output function is used, output relay
0501 outputs pulses in a transistor-type output unit.
"4.5.1 Specified Frequency Pulse Output Function" (p.3-228)
3-10
Chapter 1 Programming
For more about setting the memory switch, refer to "MEMSW instruction" (p.3-92).
Upper limit
switch
(0000)
0001
1000
0001
#00010
T000
0000
1001
Lower limit
switch
(0001)
Move-down
(0500)
1000
1001
#00010
T001
T000
0501
0500
T001
0500
0501
END
Move-up
(0501)
ENDH
Note: The retentive function is effective only when internal utility relays retained by
the self-retentive circuit or the SET/SFT/KEEP instruction are also retained by the
memory switch.
Internal utility relays are not retained in the program shown below.
0000
1001
Chapter 1 Programming
3-11
11
Description
Relay 2002: Always ON
By setting an output relay to ON using relay 2002, the output relay can be used as a
"running indicator output".
2002
HSP
0100
2002
00000
LDA
DM0000
STA
#03600
C000
2006
1000
C000
Relay 2007: Remains OFF during only one scan when operation is started.
This relay can be used when a signal needs to be sent after a specific period
(equivalent to one scan) after operation is started. This relay can also be used for
an initial reset at the start of operation.
After one scan, this relay remains ON.
1000
2007
#00100
C005
0000
3-12
Chapter 1 Programming
SFT
D
1100
CLK
1100
2008
RES
2008
#00000
LDA
DM0000
STA
Chapter 1 Programming
3-13
11
Relay No.
Always ON.
2003*
Always OFF.
2004*
2005*
2006*
2007*
2008*
2010*
2011*
2012*
2009*
Function
2002*
Read-only relay.
Relay No.
Function
2100*
2101*
Multiplication
mode
2113
2114
ON: Cleared
OFF: Not cleared
ON: Prohibited
OFF: Permitted
ON: Set to OFF
OFF: Not set to OFF
ON: Set to ON
OFF: Not set to ON
ON: Reversed
OFF: Not reversed
ON: Prohibited
OFF: Permitted
ON: Set to OFF
OFF: Not set to OFF
ON: Set to ON
FF: Not set to ON
ON: Reversed
OFF: Not reversed
ON: Cleared
OFF: Not cleared
1 pulse
x2
x4
2 pulses
OFF
ON
OFF
ON
OFF
OFF
ON
ON
Note: Never use special utility relays that are not shown above.
3-14
Chapter 1 Programming
Relay No.
2200*
2201*
2202*
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
*
Function
ON: Cleared
OFF: Not cleared
ON: Prohibited
OFF: Permitted
ON: Set to OFF
OFF: Not set to OFF
ON: Set to ON
OFF: Not set to ON
ON: Reversed
OFF: Not reversed
ON: Prohibited
OFF: Permitted
ON: Set to OFF
OFF: Not set to OFF
ON: Set to ON
OFF: Not set to ON
ON: Reversed
OFF: Not reversed
ON: Cleared
OFF: Not cleared
Read-only relay.
Multiplication
mode
2213
2214
1 pulse
x2
x4
2 pulses
OFF
ON
OFF
ON
OFF
OFF
ON
ON
Note: Never use special utility relays that are not shown above.
2305
Function
External outputs disabled
(outputs 0500 to 0915)
External refresh inputs disabled
(inputs 0000 to 0415)
Constant scan time mode
(write preset value in TM29)
Remains ON for one scan when scan time exceeds
preset constant scan time.
Start flag for frequency counter operation.
2306
2307
2308
2300
2301
2303
2304
2309
2310
2314
2315
ON: Disabled
OFF: Not disabled
ON: Disabled
OFF: Not disabled
ON: Enabled
OFF: Disabled
ON: Enabled
OFF: Disabled
* Read-only relay.
Chapter 1 Programming
3-15
11
2415
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2515
3-16
Function
Timing of CTH0 external signal
OFF
External preset
OFF
OFF
not used
ON
At falling edge
ON
OFF
At rising edge
ON
ON
Level
At rising edge
OFF
ON
At falling edge
ON
OFF
At rising edge
ON
ON
At both edges
At rising edge
OFF
ON
At falling edge
ON
OFF
At rising edge
ON
ON
At both edges
External preset
OFF
OFF
not used
ON
At falling edge
ON
OFF
At rising edge
ON
ON
Level
At rising edge
OFF
ON
At falling edge
ON
OFF
At rising edge
ON
ON
At both edges
At rising edge
OFF
ON
At falling edge
ON
OFF
At rising edge
ON
ON
At both edges
Chapter 1 Programming
Function
Input time constant of input expansion unit with relay
Nos. 0100 to 0115
Input time constant of input expansion unit with relay
Nos. 0200 to 0215
Input time constant of input expansion unit with relay
Nos. 0300 to 0315
Input time constant of input expansion unit with relay
Nos. 0400 to 0415
Clearing of input at expansion disconnect
2712
2714
OFF: 10 ms
ON: 10 s
OFF: 10 ms
ON: 10 s
OFF: 10 ms
ON: 10 s
OFF: 10 ms
ON: 10 s
OFF: Cleared
ON: Not cleared
This area is stored
even when the
operation mode is
changed from
PROGRAM to RUN,
or when the power is
turned off (without
being affected by the
MEMSW instruction).
This area is not
cleared even if the
utility relay All Clear
function is activated.
However, this area is
cleared when an All
Clear is executed
without registering a
program.
2715
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2812
2813
Sets input time constant to all inputs in basic module (except inputs used by
HSP instruction).
OFF: Sets input time constant to 10 ms.
ON: Refers to value stored in DM1940, then determines input time constant.
2814
HKEY instruction: Multiple keys are prohibited.
2815
HKEY instruction: Scan is finished.
2900 to 2915 HKEY information storage area.
Note: Never use special utility relays that are not shown above.
Chapter 1 Programming
3-17
11
Timer/Counter list
Name
Timer
Counter
Contact
T000 to T249
Coil
(instruction)
TMR000 to 249
TMH000 to 249
TMS000 to 249
C000 to C249
Number
250 in total
C000 to 249
UDC000 to 249
Description
Timers
When 0.1-s timers (TMR) and high-speed 0.001-s timers (TMS) are used as
contacts, the "Tnnn" No. is used for both types. However, the form for setting is
different. "TMRnnn#ddddd" is used for 0.1-s timers, "TMHnnn#ddddd" is used for
high-speed 0.01-s timers, and "TMSnnn#ddddd" is used for high-speed 1-ms
timers (nnn = timer No, ddddd = timer set value).
When the PLC is stopped, all timers are reset and their current values become
equivalent to set values.
Counters
When counters (C) and up/down counters (UDC) are used as contacts, the
"Cnnn" No. is used for both types. However, the form for setting is different.
"Cnnn#ddddd" is used for counters, while "UDCnnn#ddddd" is used for up/down
counters.
In one program, different numbers must be assigned to each of the counters and
up/down counters.
Even when operation is stopped, each counter stores whatever value it has at
that time.
"TMR instruction" (p.3-67), "TMH instruction" (p.3-68), "TMS instruction" (p.3-69), "C instruction" (p.372), "UDC instruction" (p.3-76).
3-18
For details about high-speed counters and high-speed counter comparators, refer to "Chapter 4 Highspeed Counters" (p.3-203).
Chapter 1 Programming
Description
Not specified (can be used by user)
DM1000 to DM1099
DM1100 to DM1199
DM1200 to DM1299
DM1300 to DM1399
DM1400
DM1403
DM1404
DM1405
DM1401
DM1402
DM1406/DM1407
DM1408/DM1409
:
DM1468/DM1469
DM1470
DM1471 to DM1479
DM1480
DM1481
DM1482
DM1483
DM1484
DM1485
DM1486
DM1487 to DM1499
DM1565 to DM1569
DM1664 to DM1699
DM1670 to DM1675
DM1676
Chapter 1 Programming
3-19
11
DM1680 to DM1699
Description
Area for direct access mode for the KV-D20 operator interface
panel
KV-D20 Operator interface panel: Display device attributes
DM1764 to DM1799
DM1806 to DM1809
DM1826 to DM1899
DM1677 to DM1679
DM1900/DM1901*
DM1902/DM1903*
DM1904/DM1905*
DM1906/DM1907*
DM1908/DM1909*
DM1910/DM1911*
DM1912/DM1913
DM1914/DM1915
DM1916/DM1917
DM1918/DM1919
DM1920/DM1921
DM1922/DM1923
DM1924/DM1925
DM1926/DM1927
DM1928/DM1929*
DM1930/DM1931*
DM1932/DM1933*
DM1934/DM1935*
DM1936
DM1937
DM1938
DM1939
DM1940
DM1941 to DM1943
DM1944
DM1945 to DM1949
DM1950
DM1951 to DM1999
Read-only relay.
Note 1: 16-bit binary data is stored in each of the data memories as for internal
registers.
Note 2: The data stored in data memories is held even when the power is turned off
or when the All Clear function is executed. The backup time is 20 days or more in
the KV-10xx, and 2 months or more in other models.
Note 3: DM1000 to DM1999 are assigned as special data memories.
3-20
Chapter 1 Programming
Usage
Attribute
TM00
R/W
TM01
R/W
Attribute
*
R: Read
R/W
R*
R/W
R*
R
W: Write
Both R and W are enabled when special functions are not used.
Note 1: Temporary data memories are initialized when the power is turned on.
Note 2: TM20, TM30, and TM31 are read-only, so cannot be used for writing.
However, TM28 can be used for both reading and writing if special functions are not
used.
Note 3: TM00 and TM01 are used by the MUL and DIV instructions. Never use them
for any other purpose.
Chapter 1 Programming
3-21
11
0 7 5 1 5
Channel No.
Unit Nos.
Unit nos. are assigned to units within the KV-300 system, with the unit connected to
the right of the KV-300 CPU (see the figure below) assigned as no. 7. The CPU is
assigned as unit no. 0.
CPU
0
16
17
Address Nos.
Address nos. are assigned to the input units, output units, and I/O terminal units.
The following table shows the assignment of address nos. to units.
Unit
KV-300 CPU
CPU
0, 5
KV-C16X
16-input unit
KV-C32X
32-input unit
0. 1
KV-B16R
16-output unit
KV-B16S
16-output unit
KV-C32T
32-output unit
5, 6
KV-R8X
0 to 4 *
KV-R16X
KV-R8R
KV-R16R
KV-R8T
KV-R16T
3-22
Address No.
5 to 9 *
The KV-R1A I/O Distribution Unit accommodates 5 input units and 5 output units.
Addresses are set with address switches.
Chapter 1 Programming
Setting the input time constant for basic units using special utility relays
The input time constant for a basic unit can be changed using data memory DM1940
and special utility relay 2813.
Though the input time constant is usually 10 ms, it can be changed to a value that
corresponds to the number stored in DM1940 by setting special utility relay 2813 to
ON.
If the HSP instruction and special utility relay 2813 are used at the same time,
priority is given to the HSP instruction and the number stored in DM1940 is ignored.
Special utility relay 2813
OFF: Sets the input time constant to 10 ms.
ON: Refers to the number stored in DM1940, then determines the input time
constant.
Number stored in DM1940
0
1
2
3
4
5
6
7 or more
Note 1: Be sure to set the input time constant to 10 s when using the 30-kHz high-speed
counter input.
Note 2: Never enter a number that is 7 or larger to data memory DM1940.
Note 3: The input time constant specified by data memory DM1940 becomes effective at the
rising edge of special utility relay 2813.
To change the input time constant, first change data memory DM1940, then set special utility
relay to OFF and ON again. Or change the operation mode of the KV basic unit from
PROGRAM to RUN.
Note 4: The input time constant for input relays set by the HSP instruction is 10 s.
For more about the HSP instruction, refer to "HSP instruction" (p.3-86).
For more about setting the input time constant for expansion units, refer to "Input time
constant for expansion units" (p.1-76).
Note 5: Set the special utility relay using the SET/RES instructions.
Note 6: When the input time constant is set to 1 ms or less, connect the output equipment
without contacts. If connecting output equipment with contacts, contact bounds may enter.
Note 7: Except for interrupts and high-speed counters, signals whose ON time is shorter than
the scan time may not be received even if the input time constant is set to a small value.
Chapter 1 Programming
3-23
11
24V
1 ms
0 ms 10 ms
5V 0 ms 10 ms
1 ms
As shown in above figures, an external switch can be used to select the input time
constant only on the KV-C32X/C16X Connector Input Units and KV-R16X/R8X I/O
Terminal Units.
KV-C32X/C16X
KV-R16X/R8X
0ms 1ms 10ms
25 s 20%
1 ms 20%
10 ms 20%
Note: Connect a solid-state contact output device when the input time constant is
set to 1 ms for 25 s. Connection of a contact output device may result in contact
bounce.
Setting
10 s 20%
25 s 20%
10 ms 20%
Default
Note 1: When using the 30 kHz high-speed counter input, turn ON special utility
relay 2813.
Note 2: When special utility relay 2813 is ON, the input time constant of input relays
0000 to 0009 is set to 10 s 20%.
Note 3: The input time constant remains 10 ms 20% if the HSP instruction is used
when special utility relay 2813 is ON.
Note 4: When the input time constant is set to 10 s or 25 s, a solid-state output
device must be connected. Connection of a contact output device may result in
contact bounce.
3-24
Chapter 1 Programming
2008
#00020
LDA
TM29
STA
11
2303
SET
Note 1: Be sure to set the constant scan time value so it is larger than the actual
scan time.
Note 2: If the actual scan time exceeds the set scan time, special utility relay 2304
turns ON (during the next 1 scan) while the actual scan time is written to TM28 (unit:
1 ms).
Note 3: The scan time can be set up to 200 ms in temporary data memory TM29. If
a value larger than 200 ms is input, it will be treated as 200 ms.
Chapter 1 Programming
3-25
2300
For more about operating procedures, refer to the "Chapter 6. Handheld Programmer" (p.1-195).
2301
For more about operating procedures, refer to the "Chapter 6. Handheld Programmer" (p.1-195).
Note: Once external input refresh is prohibited, it can be permitted only by setting
special utility relay 2301 to OFF from the Access Window, the "KV IncrediWare
(DOS)" or "LADDER BUILDER for KV" programming support software, or the KVP3E(01) handheld programmer.
3-26
Chapter 1 Programming
This function transfers contact comments to the Visual KV Series using the "KV
IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support
software.
The Visual KV Series can store not only programs but also comments registered
to each contact using the "KV IncrediWare (DOS)" or "LADDER BUILDER for
KV" programming support software.
A program may not be easy to understand if only device Nos. are used. By
registering comments to the contacts, the program can be easily debugged and
more efficiently maintained.
The number of contact comments that can be transferred is up to 1,000 for both
normal transfer and compression transfer.
The KV-D20 operator interface panel includes the contact comment display
function.
For more about operating procedures, refer to "2.5 Entering Comments/Labels" (p.1-46) and "4.2.2
Setting the comment transfer" (p.2-138).
Chapter 1 Programming
3-27
11
Example
Set the constant scan time to 20 ms.
02008
#00200
LDA
TM29
STA
2303
SET
Note 1: The set value for the constant scan time must be greater than the actual
scan time. Otherwise, special utility relay 2304 turns on during every scan to disable
constant scan time mode.
Note 2: If the scan time exceeds the set value, special utility relay no. 2304 turns on
during the next scan.
Example
Use the output disabled function by executing FORCED RESET/RESET to special
utility relay No. 2300 from the monitor display.
Example
Set input relay No. 0000 to ON to disable input refresh; set to OFF to enable input
refresh.
0000
2301
Note: If input refresh is disabled, it is not enabled until input relay No. 0000 is turned
on from the handheld programmer.
3-28
Chapter 1 Programming
Only output
circuits can
be written.
Only input
circuits can
be
assembled.
Both input
circuits and
output circuits
can be
assembled.
Only output
circuits can
be
assembled.
Chapter 1 Programming
3-29
11
Example
When DM0000 stores 1000, 0500 turns ON.
2000, 0501 turns ON.
3000, 0502 turns ON.
Conventional ladder diagram
2010
0500
#01000
CMP
#02000
CMP
2010
0501
2010
0500
#03000
CMP
2010
0502
2002
#02000
CMP
2010
0501
2002
#03000
CMP
2010
0502
DM0000
LDA
2002
2002
Example
When the start switch is set to ON, a lamp is lit for three seconds, a buzzer is
sounded for two seconds, and then the motor starts to rotate.
0000
1100
DIFU
1100
1000
STG
0500
#00030
T000
T000
1001
JMP
1001
STG
0501
#00020
T001
T001
1002
JMP
1002
STG
0502
0000
1000
SET
ENDS
T000
1001
T001
T001
T002
1001
#00020
T001
#00030
T002
1001
0500
1003
3-30
Chapter 1 Programming
1001
STG
1003
1003
When the start switch (0000) is set to OFF, the motor is stopped
and all operations are reset.
#00010
T000
1003
1002
0000
1002
1002
When timer 0 turns ON three seconds later, the lamp goes out, a
buzzer (0501) is sounded, and timer 1 is activated.
1000
DIFU
T002
T000
When the start switch (0000) is set to ON, a lamp (0500) is lit and
timer 0 is activated.
0501
1000
DIFU
1000
1001
SET
0500
#00010
T000
T000
1002
JMP
1002
STG
0501
#00020
T001
T001
1003
JMP
1003
STG
0500
#00030
T002
T002
1001
JMP
0501
0500
0000
0500
0501
0501
LD 0000
OUT 0500
OUT 0501
LD 0000
OUT 0500
CON
OUT 0501
The CON instruction for connection is added.
(The scan time is not affected.)
0001
0002
1002
1003
DIFU
0000
1000
1000
1001
1000
1003
0001
1000
1000
0002
1001
0500
1001
1001
1001
0500
Because the program can be written in only one line when an extended adder
diagram is used, it is easier to look at and understand compared with a program
written using a conventional ladder diagram.
Chapter 1 Programming
3-31
11
3-32
Chapter 1 Programming
Chapter 2
Instructions
Describes the concrete usage of instructions in the KV Series.
Refer to "Chapter 3 Interrupts" on page 3-191 for details of interrupt instructions.
Refer to "Chapter 4 High-speed counters" on page 3-203 for details of the highspeed counters used in the application instruction.
2.1
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
2.2
2.2.1
2.2.2
2.2.3
2.2.4
2.3
2.4
2.4.1
2.4.2
2.4.3
2.5
Visual KV Series
Visual KV Series
Symbol
nnnn
LOAD
LOAD BAR
nnnn
AND
nnnn
Function
Exec.time
(s)
Bytes
Page
LD
0.7 to 1.6
3 (12)
3-57
LDB
0.7 to 1.6
3 (12)
3-57
0.7 to 0.9
3 (8)
3-58
0.7 to 0.9
3 (8)
3-58
AND
R No.
T/C No.
AND BAR
nnnn
OR
nnnn
OR
0.7 to 0.9
3 (8)
3-60
OR BAR
nnnn
ORB
0.7 to 0.9
3 (8)
3-60
0.8
1 (4)
3-61
0.8
1 (4)
3-63
1.5
3 (12)
3-65
1.5
3 (12)
3-65
1.9 to 12.8
3 (14)
3-66
0500 to 1915
2009
2100 to 17915
Forces R/T/C OFF when input 1.9 to 20.5
T000 to T249
is ON.
C000 to C249
CTH0 to CTH1
CTC0 to CTC3
3 (14)
3-66
ANB
AND LOAD
ANL
OR LOAD
ORL
OUT
nnnn
OUT
R No.
OUT BAR
SET
nnnn
nnnn
SET
OUB
0500 to 1915
2009
2300 to 17915 Forces relay ON and holds
T000 to T249 this status when input is ON.
C000 to C249
SET
R No.
T/C No.
nnnn
RES
RES
0.1-s
TIMER
#ddddd
Txxx
TMR
0.01-s
TIMER
#ddddd
T
Txxx
H
TMH
(FUN49)
RESET
3-34
T No.,
# preset
value
Chapter 2 Instructions
000 to 249
#00000 to
#65535
12.0 to 17.8
2 (6)
3-67
12.0 to 17.8
2 (6)
3-68
Exec.time
(s)
Bytes
Page
12.0 to 17.8
2 (7)
3-69
#00000 to
# preset value,
#65535
Sets 16-bit up-counter.
C No., counter 000 to 249
input R
0000 to 17915
12.0 to 17.8
4 (7)
3-72
13.0 to 24.0
2 (10)
3-76
3 (10)
3-78
3 (10)
3-78
3 (11)
3-80
(*)
5 (15)
3-82
3.8 to 9.4
3 (8)
3-86
MC
(FUN24)
0.2
1 (4)
3-89
MCR
MCR
(FUN25)
0.2
1 (0)
3-89
MEMSW
$xxxx
MEMSW
(FUN26)
3 (0)
3-92
Performs no operation.
1 (0)
3-94
END
1 (1)
3-94
ENDH
1 (0)
3-94
Instruction
Symbol
Mnemonic
1-ms
TIMER
#ddddd
T
S Txxx
TMS
(FUN51)
COUNTER
#ddddd
Cxxx
nnnn
UP-DOWN
COUNTER
UP
DW #ddddd
RES
DIFFERENTIATE UP
nnnn
DIFU
DIFFERENTIATE
DOWN
nnnn
DIFD
KEEP
UDC xxx
UDC
(FUN52)
DIFD
(FUN09)
KEEP
KEEP
(FUN22)
SET nnnn
RES
SFT
(FUN39)
D
nnnn
CLK
RES mmmm
HSP
nnnn
MASTER
CONTROL
MC
MEMORY
SWITCH
HSP
(FUN18)
END HI
R No.
nnnn: 1st R
No. mmmm:
Last R No.
R No.
$ constant
NOP
(FUN30)
NOP
END
C No.,
# preset value
R No.
HIGH
SPEED
MASTER
CONTROL
RESET
Operand
DIFU
(FUN10)
SFT
SHIFT
Visual KV Series
END
ENDH
Operand value
000 to 249
#00000 to
#65535
1000 to 1915
3000 to 9915
0500 to 1915
2009
2100 to 17915
Function
1000 to 1915
Sets shift register.
3000 to 9915
(KV-10)
0000 to 0005
(KV-16)
0000 to 0009
(KV-24)
0000 to 0015
(KV-40)
0000 to 0107
$ 0000 to
$ FFFF
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
*1 34 + 0.25 + n x 0.25 (n: No. of shift steps)
All operand values are shown in normal notation. The corresponding relay numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F
Chapter 2 Instructions
3-35
12
Visual KV Series
Symbol
Mnemonic
WAIT ON
nnnn
ON
mmmm
W-ON
WAIT OFF
nnnn
OFF
mmmm
W-OFF
17915
T000 to T249
nnnn:
R, T, C C000 to C249
CTC0 to CTC3
Nos.
mmmm:
mmmm: 1000 to 1915
3000 to 9915
R No.
1000 to 1915
R No.
WAIT UP
EDGE
WAIT
DOWN
EDGE
W-UE
nnnn
mmmm
CON
(FUN 06)
PUSH
MPS
READ
MRD
POP
MPP
nnnn
STG
nnnn
JMP
JMP
(FUN 21)
END
STAGE
ENDS
ENDS
(FUN 14)
STEP
STEP END
STP
nnnn
STP
(FUN 45)
STE
STE
(FUN 43)
Page
5 (12)
3-96
5 (12)
3-96
5 (12)
3-98
1 (0)
3-98
1 (4)
3-102
3.2
1 (4)
3-103
6.8
1 (4)
3-103
10.5 to 13.0
3 (10)
3-103
3 (8)
3-106
1 (4)
3-106
2.5
3 (10)
3-106
5 (12)
1 (0)
3-114
Turns ON
3-114
R, T, C
Nos.
3000 to 9915
0000 to 0009 When input is ON, turns R of
current stage OFF and moves 4.3 to 7.5
to stage specified by operand.
Turns current stage OFF and
next stage ON when input is
ON.
R No.
nnnn:
0000 to
0500 to 9915
Executes program between
T000 to T249 STP & STE when R (operC000 to C249 and) is ON.
CTC0 to CTC3
11.2 to 13.4
Is used with STEP to make
program step.
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
3-36
Bytes
STG
(FUN 44)
JUMP
Exec.time
(s)
W-DE
CONNECT
STAGE
nnnn
mmmm
Function
Chapter 2 Instructions
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F
Instruction
INTERVAL
TIMER
16-BIT
COUNTER
16-BIT
COUNTER
COMPARATOR
16-BIT
COUNTER
Symbol
ITVL
PLS
DMnnnn
PAUSE
mmmm
RES
CTH0
nnnn
#ddddd
CTCn
CTH1
nnnn
16-BIT
COUNTER
COMPARATOR
#ddddd
CTCn
SUBROUTINE
CALL
nn
CALL
Mnemonic
CTH
Count input
R
CTC
n:
Comparator
n: 0,1
No.
ddddd: #00001
ddddd:
to #65535
# preset
value
5 (10)
3-117
0004
2100
2101
2102
14.4
4 (6)
3-204
Hardware-based comparator
between preset & current
values of high-speed counter
2.3 to 3.5
(CTH0). This comparator is
turned ON when these
values are equal.
2 (6)
3-204
0005
0500
2200
2201
2202
14.4
4 (6)
3-204
CTC
Hardware-based comparator
between preset & current
values of high-speed counter
(CTH1). This comparator is
turned ON when these
values are equal.
2.3 to 3.5
2 (6)
3-204
CALL
(FUN 03)
Subroutine
No.
00 to 99
Executes subroutine
specified by operand.
5.4 to 6.5
2 (8)
3-122
Subroutine
No.
00 to 99
Represents beginning of
subroutine specified by
operand.
2 (4)
3-122
4.3
1 (4)
3-122
12.0 to
18.0
3 (20)
3-125
0.5
1 (4)
3-125
22.1 to
180.0
5 (10)
3-131
RET
(FUN 33)
REPEAT
START
FOR
nnnn
FOR
(FUN 16)
Represents end of
subroutine.
# constant,
DM No.
TMxx
#00000 to
#65535
DM0000 to
DM1999
TM00 to TM29
HKEY
(FUN 17)
Executes program
between FOR & NEXT
for number of times
specified by operand.
Represents end of
repetition.
NEXT
(FUN 29)
20.0 to 80.0
n:
Comparator
n: 2,3
No.
ddddd: #00001
ddddd:
to #65535
# preset
value
RET
Page
Count input
R
SUBROUTINE
RETURN
HKEY
nnnn
mmmm
Bytes
CTH
SBN
(FUN 38)
16-KEY INPUT
Exec.time
(s)
Function
DMnnnn:
DM0000 to Measures pulse-to-pulse
DM1985
interval & pulse width in
mmmm:
specified mode.
1000 to 1912
3000 to 9912
ITVL
SBN
nn
NEXT
Operand value
DMnnnn:
DM No.
mmmm: R
No.
SUBROUTINE
ENTRY
REPEAT END
Operand
Visual KV Series
nnnn:
Input R
mmmm:
Output R
nnnn:
0000 to 415
mmmm:
0500 to 915
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F
Chapter 2 Instructions
3-37
12
Visual KV Series
DATA
MEMORY
WRITE
TRIMMER
SETTING
Symbol
Mnemonic
nnnn
DW
DMmmmm
DW
n
TMIN
TMIN
(FUN 50)
Operand value
nnnn:
#/$ constant
DMmmmm:
DM No.
nnnn:
#0000 to
#65535
$0000 to
$FFFF
DMmmmm:
DM0000 to
DM1999
0 to 1
Trimmer No.
n
TMIN
nnnn
LDA
LOAD A
nnnn
LDA
@TMIN
@(FUN 50)
0000 to 17915
T000 to T249
C000 to C249
LDA
CTH0 to CTH1
(FUN 23)
R No.,
DM0000 to
C/T No.,
DM1999
DM No,
TM00 to TM31
TM xx,
#00000 to
#/$ constant,
#65535
@LDA
#TMxx
$0000 to $FFFF
@(FUN 23)
#TM00 to
#TM29
2
STA
(FUN 42)
nnnn
STA
STORE A
nnnn
STA
@STA
@(FUN 42)
nnnn
CMP
CMP
(FUN 04)
nnnn
CMP
@CMP
@(FUN 04)
nnnn
ADD
ADD
(FUN00)
R No.,
C/T No.,
DM No.,
TM xx,
#TMxx
0500 to 1915
2100 to 17915
T000 to T249
C000 to C249
CTH0 to
CTC3
DM0000 to
DM1999
TM00 to TM29
#TM00 to
#TM29
COMPARE
ADD
nnnn
ADD
nnnn
SUB
SUBTRACT
nnnn
SUB
DM0000 to
DM1999
TM00 to TM31
@ADD
#00000 to
@(FUN 00) DM/TM No.
#65535
TMxx,
$0000 to
#/$ constant,
$FFFF
SUB
#TMxx
#TM00 to
(FUN 46)
#TM29
@SUB
@(FUN 46)
nnnn
MUL
MUL
(FUN 28)
nnnn
MUL
@MUL
@(FUN28)
MULTIPLY
3-38
Function
Operand
Transfers content of
internal register to
location specified by
operand, or changes
preset value when T/C is
specified as operand.
Compares content of
internal register and
value specified by
operand.
Exec.time
(s)
Bytes
Page
8.0
5 (8)
3-136
8.9
1 (6)
3-138
20.9
1 (16)
6.4 to 14.0
3 (8)
3-140
18.4 to 26.0
3 (18)
6.6 to 28.5
3 (8)
3-140
18.0 to 40.5
3 (18)
10.8 to 35.6
3 (6)
3-146
22.8 to 47.6
3 (16)
3 (6)
3-150
3 (16)
3 (6)
3-150
3 (16)
3 (6)
3-150
3 (16)
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
Chapter 2 Instructions
Instruction
Symbol
nnnn
DIV
DIVIDE
nnnn
DIV
nnnn
ANDA
AND A
nnnn
ANDA
nnnn
ORA
OR A
nnnn
ORA
nnnn
EORA
EXCLUSIVE
OR A
nnnn
EORA
SHIFT
RIGHT A
SHIFT LEFT
A
Mnemonic
Operand
DM0000 to
DM1999
TM00 to TM31
R No.,
#00000 to
DM No.,
#65535
TM xx,
$0000 to
#/$ constant,
@DIV
$FFFF
#TMxx
@(FUN 11)
#TM00 to
#TM29
DIV
(FUN 11)
ANDA
(FUN 01)
0000 to 17915
DM0000 to
DM1999
@ANDA
R No.,
TM00 to TM31
@(FUN 01) DM No.,
#00000 to
TM xx,
#65535
#/$
constant,
ORA
$0000 to
#TMxx
(FNC 31)
$FFFF
#TM00 to
@ORA
#TM29
@(FUN 31)
0000 to 17915
DM0000 to
DM1999
R No.,
TM00 to TM31
DM No.,
#00000 to
TM xx,
#65535
#/$ constant,
$0000 to
#TMxx
@EORA
$FFFF
@(FUN 15)
#TM00 to
#TM29
EORA
(FUN 15)
#dd
SRA
SRA
(FNC 41)
#dd
SRA
@SRA
@(FUN 41)
#dd
SLA
SLA
(FNC 40)
#dd
SLA
@SLA
@(FUN 40)
#dd
RRA
RRA
(FUN 37)
#dd
RRA
@RRA
@(FUN 37)
#dd
RLA
RLA
(FUN 35)
ROTATE
LEFT A
#dd
RLA
@RLA
@(FUN 35)
Exec.time
(s)
Function
17.4 to 43.3
Divides content of internal
register by value specified
by operand and inputs
result back to same
29.4 to 55.3
register.
EXCLUSIVE-ORs each of
16 bits of internal register
and that of value specified
by operand, and inputs
result back to same
register.
ROTATE
RIGHT A
Operand value
Visual KV Series
8.2 to 33.1
Bytes
Page
3 (6)
3-150
3 (16)
3 (8)
3-159
3 (18)
3 (8)
3-161
3 (18)
3 (8)
3-164
20.2 to 45.1
3 (18)
9.3 to 27.6
2 (6)
12
3-166
21.3 to 39.6
2 (16)
9.2 to 27.6
2 (6)
3-166
21.2 to 39.6
2 (16)
#01 to #16
10.3 to 28.6
Rotates contents of
internal register and carry
bit (2009) clockwise by
operand value.
22.3 to 40.6
10.3 to 28.6
Rotates contents of
internal register and carry
bit (2009) counterclock22.3 to 40.6
wise by operand value.
2 (6)
3-169
2 (16)
2 (6)
3-169
2 (16)
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
All operand values are shown in normal notation. The corresponding relay numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F
Chapter 2 Instructions
3-39
Instruction
Visual KV Series
Symbol
Mnemonic
COM
COM
(FUN 05)
COMPLEMENT
INCREMENT
MEMORY
DECREMENT
MEMORY
MULTIPLEXER
COM
@COM
@(FUN 05)
nnnn
INC
INC
(FNC 19)
nnnn
INC
@INC
@(FUN 19)
nnnn
DEC
DEC
(FNC 07)
nnnn
DEC
@DEC
@(FUN 07)
#n
MPX
MPX
(FUN 27)
#n
MPX
@MPX
@(FUN 27)
DMX
DMX
(FUN 12)
DMX
@DMX
@(FUN 12)
TBCD
TBCD
(FUN 47)
TBCD
@TBCD
@(FUN 47)
TBIN
TBIN
(FUN 48)
TBIN
@TBIN
@(FUN 48)
Operand
DM/TM No.
# constant
2
TRANSFER
BCD
TRANSFER
BIN
ASC
ASC
(FUN 02)
ASC
@ASC
@(FUN 02)
RASC
RASC
(FUN 32)
RASC
@RASC
@(FUN 32)
ROOT
ROOT
(FUN 36)
ROOT
@ROOT
@(FUN 36)
ASCII
CONVERT
REVERSE
ASCII
CONVERT
SQUARE
ROOT
Exec.time
(s)
Bytes
5.6
1 (4)
3-171
17.6
1 (14)
9.8
3 (6)
21.8
3 (16)
10.4
3 (6)
22.4
3 (16)
DM0000 to
DM1999
TM00 to
TM29
DM0000 to
DM1999
TM00 to
TM29
10.1
1 (6)
#0 to #3
22.1
1 (16)
Converts position of
highest order bit with 1 in
internal register into 4-bit
data.
22.6
1 (4)
34.6
1 (14)
Converts content of
internal register (16-bit
binary) into 4-digit BCD
data.
5.6
1 (4)
17.6
1 (14)
9.6
1 (4)
21.6
1 (14)
9.7
1 (4)
21.7
1 (14)
9.3
1 (4)
21.3
1 (14)
95.7
1 (4)
107.7
1 (14)
Converts content of
internal register (4-digit
BCD) into 16-bit binary
data.
Page
3-172
3-172
3-176
3-176
3-180
3-180
3-183
3-183
3-185
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
3-40
Function
DM/TM No.
DEMULTIPLEXER
Operand
value
Chapter 2 Instructions
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F (OUTPUT)
Visual KV Series
Symbol
Mnemonic
INTERRUPT
DISABLED
DI
DI
(FUN 08)
INTERRUPT
ENABLED
EI
EI
(FUN 13)
INT
nnnn
INT
CTCn
RETI
R No.
000 to 003
Comparator
No.
CTC0 to
CTC3
RETI
(FUN 34)
Exec.time
(s)
Bytes
Page
Disables execution of
interrupt.
2.2
1 (12)
3-193
Enables execution of
interrupt.
4.0
1 (10)
3-193
Executes interrupt
instructions between INT
and RETI at rising/falling
edge of input relays 0000
through 0003.
60.0 to
90.0
1 (8)
3-192
60.0 to
90.0
1 (8)
3-192
Represents end of
interrupt.
18.0 to
22.0
1 (4)
3-192
Function
Operand value
INT
(FUN 20)
INTERRUPT
RETURN
INTERRUPT
Operand
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation
0000 to 0415
0500 to 0915
1000 to 6915
7000 to 17915
X-Y-M notation
X000 to X04F
Y050 to Y09F
M1000 to M6915
X700 to X174F or Y750 to Y179F
00
ADD
13
EI
26
MEMSW
39
SFT
01
ANDA
14
ENDS
27
MPX
40
SLA
02
ASC
15
EORA
28
MUL
41
SRA
03
CALL
16
FOR
29
NEXT
42
STA
04
CMP
17
HKEY
30
NOP
43
STE
05
COM
18
HSP
31
ORA
44
STG
06
CON
19
INC
32
RASC
45
STP
07
DEC
20
INT
33
RET
46
SUB
08
DI
21
JMP
34
RET1
47
TBCD
09
DIFD
22
KEEP
35
RLA
48
TBIN
10
DIFU
23
LDA
36
ROOT
49
TMH
11
DIV
24
MC
37
RRA
50
TMIN
12
DMX
25
MCR
38
SBN
51
TMS
52
UDC
Chapter 2 Instructions
3-41
12
KV-300
KV-300 Series,
Series, KV-10/80
Number of bytes represents the memory capacity required for each instruction.
Number in ( ) represents the memory capacity required for object code of each
instruction.
Abbreviations: R: Relay, T: Timer, C: Counter, #: Decimal, $: Hex.
KV-10/16/24/40/80
Mnemonic Operand Operand value Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
nnnn
LOAD
LOAD BAR
nnnn
AND BAR
1.5 to 2.5
3 (4)
3-57
LDB
2.1 to 3.5
3 (6)
3-57
AND
1.5 to 2.5
R No.
T/C No.
ANB
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
0000 to 6915
T000 to T119
C000 to C119
2.7 to 4.5
CTC0 to CTC3
OR
nnnn
OR
1.5 to 2.5
OR BAR
nnnn
ORB
2.7 to 4.5
AND LOAD
ANL
1.0 to 1.4
OR LOAD
ORL
1.0 to 1.4
nnnn
OUT
OUT
0500 to 1915
2009
2300 to 2915
nnnn
OUT BAR
OUB
nnnn
SET
(SET)
nnnn
RESET
(RES)
0.1-s TIMER
#ddddd
T xxx
SET
R No.
0500 to 1915
2009
2100 to 2915
T000 to T063
C000 to C063
CTH0 to CTH1
CTC0 to CTC3
RES
5.2 to 8.4
0500 to 1915
2009
2300 to 6915 6.4 to 10.4 3 (17) ON/OFF status to R
coil.
0500 to 1915
2009
2100 to 6915
T000 to T119 3.1 to 24.0 3 (8)
C000 to C119
CTH0 to CTH1
CTC0 to CTC3
TMR
000 to 063
#00000 to
#65535
#ddddd
H xxx
TMH
(FNC49)
1-ms TIMER
#ddddd
S xxx
TMS
(FNC51)
COUNTER
#ddddd
C xxx
nnnn
# preset
value, C
No., clock
source R
#00000 to
65535
000 to 063
0000 to 6915
UP-DOWN
COUNTER
UP #ddddd
DW
RES
UDC
(FNC52)
C No.,
# preset
value
000 to 063
#00000 to
#65535
3-42
000 to 119
#00000 to
#65535
Chapter 2 Instructions
3-58
3-58
3-60
3-60
3-61
3-63
3-65
3-65
0.01-s
TIMER
UDC xxx
Page
LD
nnnn
nnnn
AND
Function
#00000 to
#65535
19.0 to 21.0 4 (7)
000 to 119
0000 to 6915
000 to 119
#00000 to
#65535
3-66
3-67
3-68
3-69
3-72
3-76
Instruction
Symbol
DIFFERENTIATE UP
nnnn
DIFU
DIFFERENTIATE
DOWN
KEEP
KEEP
(FNC22)
R No.
0500 to 1915
2009
2100 to 2915
SFT
(FNC39)
R No.1st
& last R
Nos.
1000 to 1915
HSP
(FNC18)
R No.
(KV-10)
0000 to 0005
(KV-16)
0000 to 0009
D
nnnn
CLK
RES mmmm
HIGH
SPEED
HSP
MASTER
CONTROL
MC
nnnn
SFT
nnnn
MCR
MEMSW
$xxxx
$xxxx
NOP
END
END HI
1000 to 1915
DIFD
(FNC09)
SHIFT
MEMORY
SWITCH
DIFU
(FNC10)
nnnn
DIFD
SET
RES
MASTER
CONTROL
RESET
KV-10/16/24/40/80
Operand
value
Mnemonic Operand
Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
R No.
KEEP
END
ENDH
1000 to 1915
3000 to 6915
0500 to 1915
2009
2100 to 6915
1000 to
19153000 to
6915
(KV-24)
0000 to 0015
(KV-40)
0000 to 0107
Page
Turns ON R for 1
11.0 to 13.0 3 (5) scan time at rising
edge of input.
Turns ON R for 1
11.0 to 13.0 3 (5) scan time at falling
edge of input.
Turns ON R and
9.0 to 26.0 3 (5) holds this status when
SET input is ON.
5 (7) Turns OFF R when
RESET input is ON.
(*)
8.0 to 9.0
MC
(FNC24)
1.8 to 3.2
MCR
(FNC25)
0.6 to 1.0
MEMSW $ constant
(FNC26)
Function
3 (4)
3-78
3-78
3-80
3-82
3-86
3-89
3-89
3 (0)
NOP
(FNC30)
3-94
END
3-94
ENDH
3-94
$ 0000 to $ FFFF
3-92
KV-300
KV-300
Instruction
Symbol
Exec.time
Bytes
(s)
Function
Page
LD
3-57
LDB
3-57
Mnemonic Operand
Operand value
nnnn
LOAD
nnnn
LOAD BAR
nnnn
AND
AND BAR
AND
R No.
T/C No.
nnnn
ANB
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
OR
nnnn
OR
OR BAR
nnnn
ORB
AND LOAD
ANL
0.55
1 (3)
OR LOAD
ORL
0.55
1 (3)
Chapter 2 Instructions
3-58
3-58
3-60
3-60
3-61
3-63
3-43
12
KV-300
KV-300 Series,
Series, KV-10/80
KV-300
Instruction
Symbol
Mnemonic Operand
Operand value
Exec.time
Bytes
(s)
0500 to 1915
2009
2300 to 17915
0.20 to 0.56
nnnn
OUT
OUT
nnnn
OUB
OUT BAR
nnnn
(SET)
SET
nnnn
RESET
(RES)
0.1-s TIMER
#ddddd
T xxx
SET
RES
#ddddd
H xxx
TMH
(FNC49)
1-ms TIMER
#ddddd
S xxx
TMS
(FNC51)
COUNTER
#ddddd
C xxx
nnnn
UP-DOWN
COUNTER
UP #ddddd
DW
RES
UDC xxx
# preset
value, C
No., clock
source R
C No.,
UDC
(FNC52) # preset
value
000 to 249
#00000 to 65535
#00000 to #65535
000 to 249
0000 to 0009
0500 to 17915
7.60 to 9.45
000 to 249
#00000 to #65535
DIFU
FNC10)
DIFFERENTIATE DOWN
nnnn
DIFD
DIFD
(FNC09)
KEEP
KEEP
(FNC22)
R No.
SFT
(FNC39)
1st &
last R
Nos.
0500 to 1915
2009
2100 to 17915
1000 to 1915
3000 to 6915
(*) 7000 to 9915
HSP
(FNC18)
R No.
0000 to 0009
R No.
SHIFT
D
nnnn
CLK
RES mmmm
nnnn
SFT
HSP
HIGH
SPEED
nnnn
T No.,
# preset
value
3-65
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
CTH0 to CTH1
CTC0 to CTC3
nnnn
DIFU
SET
RES
3-65
DIFFERENTIATE UP
KEEP
Page
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
TMR
0.01-s TIMER
R No.
3 (8)
Function
1000 to 1915
3000 to 6915
(*) 7000 to 9915
4 (7)
3-66
3-67
3-68
3-69
3-72
3-76
3-78
3-82
6.70
4.66 to 4.92
3-78
3-80
3-86
3-89
MASTER
CONTROL
MC
MC
(FNC24)
0.20
MASTER
CONTROL
RESET
MCR
MCR
(FNC25)
1 (0)
3-89
MEMORY
SWITCH
MEMSW
$xxxx
$xxxx
3 (0)
3-92
NOP
(FNC30)
1 (0)
Performs no operation.
3-94
END
0.95
1 (1)
3-94
ENDH
1 (0)
3-94
NOP
END
END HI
END
ENDH
MEMSW $ constant
(FNC26)
$0000 to $FFFF
Note: 14.0 + 3.0 x (n) to 17.0 + 3.0 x (n) (n represents number of times the original
data is generated.)
3-44
Chapter 2 Instructions
KV-10/16/24/40/80
Mnemonic Operand Operand value Operand value Exec.time
Bytes
(s)
KV-10/16
KV-24/40/80
nnnn
ON
mmmm
W-ON
WAIT OFF
nnnn
OFF
mmmm
W-OFF
WAIT UP
EDGE
nnnn
mmmm
W-UE
WAIT DOWN
EDGE
nnnn
mmmm
W-D
WAIT ON
nnnn:
0000 to 2915
T000 to T063
nnnn: C000 to C063
R,T, or C CTC0 to CTC3
No.
mmmm:
1000 to 1915
nnnn:
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
11.0 to
13.0
11.0 to
13.0
14.0 to
18.0
14.0 to
18.0
CONNECT
CON
[FNC 06]
0.4 to
0.6
PUSH
MPS
11.0 to
14.0
READ
MRD
8.0 to
10.0
POP
MPP
10.0 to
12.0
nnnn
STG
STG
[FNC 44]
11.0 to
14.0
JUMP
nnnn
JMP
JMP
[FNC 21]
END
STAGE
ENDS
ENDS
[FNC 14]
STEP
STP
nnnn
STP
[FNC 45]
STAGE
R No.
STEP END
STE
ITVL
SUBROUTINE ENTRY
SUBROUTINE
RETURN
DM0000 to
DM1985
1000 to 1912
3000 to 6912
3-96
3-98
3-98
3-102
3-103
3.7 to
5.3
0.00
DM0000 to
DM0985
1000 to 1912
3-96
7.0 to
9.0
29.0 to
79.0
Clock
source Rs
0004
2100 to 2102
9.0 to
39.0
#ddddd
CTCn
CTC
n:
Comparator
No.
ddddd: #
preset value
n: 0,1
ddddd: #00000 to #00255
3.0 to 4.0
CTH1
nnnn
CTH
Clock
source Rs
0005
2200 to 2202
8.0 to
48.0
#ddddd
CTCn
CTC
n: Comparator No.
ddddd: #
preset value
n: 2,3
ddddd: #00000 to #65535
3.0 to 4.0
nn
CALL
CALL
[FNC 03]
Subroutine No.
00 to 99
8.0 to
10.0
SBN
nn
SBN
[FNC 38]
Subroutine No.
00 to 99
0.00
RET
RET
[FNC 33]
CTH0
nnnn
SUBROUTINE CALL
STE
[FNC 43]
CTH
8-BIT
COUNTER
16-BIT
COUNTER
COMPARATOR
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
Page
10.0 to
13.0
DM & R
No.
PLS
nnnn
DM
PAUSE mmmm
RES
16-BIT
COUNTER
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
1000 to 1915
3000 to 6915
ITVL
INTERVAL
TIMER
8-BIT
COUNTER
COMPARATOR
R, T, C
Nos.
1000 to 1915
Function
3-106
3-114
Measures pulse-to-pulse
5 (7) interval & pulse width in
specified mode.
3-117
3-277
3-277
3-204
3-204
3-122
Represents beginning of
2 (0) subroutine specified by
operand.
3-122
Chapter 2 Instructions
3-45
12
Instruction
Symbol
KV-300
KV-300 Series,
Series, KV-10/80
Mnemonic Operand
REPEAT
START
FOR
nnnn
FOR
[FNC 16]
REPEAT
END
NEXT
NEXT
[FNC 29]
HKEY
nnnn
mmmm
16-KEY
INPUT
HKEY
[FNC 17]
# constant,
DM No.
KV-10/16/24/40/80
Operand value Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
Function
Page
#00000 to
#00000 to
#65535
#65535
DM0000 to 5.0 to 20.0 3 (15)
DM0000 to
DM1999
DM0999
TM00 to TM29 TM00 to TM29
Executes program
between FOR & NEXT
for number of times
specified by operand.
3-125
1 (3)
Represents end of
repetition.
3-125
5 (7)
1.7 to 2.3
I/O R
nnnn:0000 to 0009
10000 to 10415
:
17000 to 17415
mmmm:10500 to 10915
:
17500 to 17915
71 to 370
KV-300
KV-300
Instruction
Symbol
Mnemonic Operand
WAIT ON
nnnn
ON
mmmm
W-ON
WAIT OFF
nnnn
OFF
mmmm
W-OFF
WAIT UP
EDGE
nnnn
mmmm
W-UE
WAIT DOWN
EDGE
nnnn
mmmm
W-DE
nnnn:
R,T, or
C No.
Operand value
nnnn:
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
(*)7000 to 9915
Exec.time
Bytes
(s)
Function
CONNECT
CON
[FNC 06]
PUSH
MPS
1.30
1 (9)
READ
MRD
2.70
POP
MPP
nnnn
STG
STAGE
STG
[FNC 44]
R No.
JUMP
nnnn
JMP
JMP
[FNC 21]
END
STAGE
ENDS
ENDS
[FNC 14]
STEP
STEP END
INTERVAL
TIMER
16-BIT
COUNTER
3-46
STP
nnnn
STP
[FNC 45]
STE
STE
[FNC 43]
ITVL
PLS
nnnn
DM
PAUSE mmmm
RES
CTH0
nnnn
R, T,
C Nos.
1000 to 1915
3000 to 6915
(*)7000 to 9915
0000 to 0009
0500 to 6915
(*)7000 to 9915
T000 to T249
C000 to C249
CTC0 to CTC3
ITVL
DM & R No.
DMnnnn:
DM0000 to DM9985
mmmm:
1000 to 1912
3000 to 6912
(*)7000 to 9912
CTH
Clock
source Rs
0004
2100
2101
2102
Chapter 2 Instructions
Page
3-96
3-96
3-98
3-98
3-102
3-103
3-103
1 (9)
1 (0)
3-106
1.30
3 (9)
3-114
1 (0)
3-114
13.80 to
17.30
3.85
Measures pulse-to-pulse
5 (11) interval & pulse width in
specified mode.
4 (7)
3-117
KV-300
Instruction Symbol
Mnemonic Operand
Operand value
Exec.time
Bytes
(s)
CTC
n:
Comparator
No.
ddddd: #
preset value
n: 0, 1
ddddd:
#00000 to #65535
CTH
Clock
source Rs
0005
2200
2201
2202
CTC
n:
Comparator
No.
ddddd: #
preset value
n: 2, 3
ddddd:
#00000 to #65535
CALL
Subroutine
[FNC 03]
No.
00 to 99
3.16
SBN
nn
SBN
[FNC 38]
00 to 99
RET
RET
[FNC 33]
REPEAT
START
FOR
nnnn
FOR
[FNC 16]
REPEAT
END
NEXT
NEXT
[FNC 29]
16-BIT
COUNTER
COMPARATOR
#ddddd
CTCn
16-BIT
COUNTER
CTH1
nnnn
16-BIT
COUNTER
COMPARATOR
#ddddd
CTCn
SUBROUTINE CALL
nn
CALL
SUBROUTINE ENTRY
SUBROUTINE
RETURN
16-KEY
INPUT
HKEY
nnnn
mmmm
HKEY
[FNC 17]
Subroutine
No.
#00000 to #65535
DM0000 to DM9999
TM00 to TM29
3.85
1.55
I/O R
nnnn:0000 to 0009
10000 to 10415
:
17000 to 17415
mmmm:0500 to 0503
10500 to 10915
:
17500 to 17915
16.50
Page
Hardware-based comparator
between preset & current
2 (0) values of high speed counter. 3-204
This comparator is turned ON
when these values are equal.
3-204
Hardware-based comparator
between preset & current
2 (0) values of high speed counter. 3-204
This comparator is turned ON
when these values are equal.
1.15 to 1.45
# constant,
DM No.
Function
3-122
Represents beginning of
2 (0) subroutine specified by
operand.
3-122
Represents end of
subroutine.
3-122
3-125
1 (6)
Chapter 2 Instructions
3-131
3-47
12
KV-300
KV-300 Series,
Series, KV-10/80
DATA
MEMORY
WRITE
Symbol
nnnn
< DW >
DMmmmm
TRIMMER
SETTING
KV-10/16/24/40/80
Mnemonic Operand Operand value Operand value Exec.time
Function
Bytes
KV-10/16
(s)
KV-24/40/80
#00000 to
#0000 to
#65535
#65535
#/$
$0000 to
$0000 to
3.6 to 6.0 5 (6) Writes constant into
constant,
DW
data memory.
$FFFF
$FFFF
DM No.
DM0000 to
DM0000 to
DM0999
DM1999
TMIN
[FNC 50]
@TMIN
TMIN > @[FNC 50]
Trimmer
No.
0 to 1
nnnn
LOAD A
nnnn
LDA >
nnnn
STORE A
nnnn
STA >
nnnn
COMPARE
nnnn
CMP >
nnnn
ADD
nnnn
ADD >
nnnn
0000 to 2915
T000 to T063
C000 to C063
LDA
R No., CTH0 to CTH1
[FNC 23]
C/T No.,
DM0000 to
DM/TM
DM0999
No.,
TM00 to TM31
#/$
#00000 to
constant,
#65535
@LDA
$0000 to
#TMxx
@[FNC 23]
$FFFF
#TM00 to
#TM29
R No.,
C/T No.,
DM/TM
No.,
#/$
@STA
constant,
@[FNC 42] #TMxx
STA
[FNC 42]
CMP
[FNC 04]
nnnn
SUB >
nnnn
MULTIPLY
nnnn
MUL >
nnnn
SUB
[FNC 46]
@SUB
@[FNC 46]
DIV >
@DIV
@[FNC 11]
Chapter 2 Instructions
3-136
3-138
3-140
Transfers content of
internal register to
location specified by
operand, or changes
preset value when T/
C is specified as
operand.
3-140
3-146
Adds content of
13.0 to 65.0 3 (5) internal register and
value specified by
operand and inputs
25.0 to 79.0 3 (12) result back to same
register.
Subtracts value
15.0 to 68.0 3 (5) specified by operand
from content of
register and inputs
27.0 to 82.0 3 (12) result back to same
register.
DM0000 to
DM0000 to
DM0999
DM1999
TM00 to TM31 TM00 to TM31
MUL
#00000 to
#00000 to 17.0 to 71.0 3 (5)
[FNC 28] DM/TM
#65535
#65535
No.,
$0000 to
$0000 to
#/$
No.,
@MUL
$FFFF
$FFFF
29.0 to 85.0 3 (12)
@[FNC 28] #TMxx
#TM00 to
#TM00 to
#TM29
#TM29
DIV
22.0 to 79.0 3 (5)
[FNC 11]
DIVIDE
nnnn
0500 to 1915
2100 to 2915
T000 to T063
C000 to C063
DM0000 to
DM0999
TM00 to TM29
#TM00 to
#TM29
0000 to 6915
T000 to T119
C000 to C119 10.0 to 46.0 3 (5)
CTH0 to CTH1
DM0000 to
DM1999
TM00 to TM31
#00000 to
#65535
22.0 to 60.0 3 (12)
$0000 to
$FFFF
#TM00 to
#TM29
0500 to 1915
2100 to 6915
T000 to T119 9.0 to 99.0 3 (5)
C000 to C119
DM0000 to
DM1999
TM00 to TM29 21.0 to 113.0 3 (12)
#TM00 to
#TM29
DM0000 to
DM0000 to
DM1999
DM0999
DM/TM TM00 to TM31 TM00 to TM31
@CMP
#00000 to
#00000 to
No.,
@[FNC 04]
#65535
#65535
#/$
$0000 to
$0000 to
constant,
ADD
$FFFF
$FFFF
#TMxx
[FNC 00]
#TM00 to
#TM00 to
#TM29
#TM29
@ADD
@[FNC 00]
SUBTRACT
3-48
Page
Multiplies content of
internal register by
value specified by
operand and inputs
result back to same
register.
Divides content of
internal register by
value specified by
operand and inputs
34.0 to 93.0 3 (12) result back to same
register.
3-150
3-150
3-150
3-150
Instruction
Symbol
nnnn
<ANDA>
AND A
nnnn
ANDA>
nnnn
OR A
nnnn
ORA >
EXCLUSIVE
OR A
SHIFT
RIGHT A
#dd
SRA
[FNC 41]
#dd
@SRA
@[FNC 41]
#dd
SLA
[FNC 40]
#dd
RLA
[FNC 35]
Moves content of
internal register serially
right, allowing each bit
3-169
that leaves right end to
24.0 to 44.0 2 (11) enter carry bit and then
leftmost bit.
Moves content of
12.0 to 29.0 2 (4) internal register serially
left, allowing each bit 3-169
that leaves left end to
24.0 to 43.0 2 (11) enter carry bit and then
rightmost bit.
12.0 to 30.0 2 (4)
COM
[FNC 05]
COM >
@COM
@[FNC 05]
INC
[FNC 19]
nnnn
INC >
nnnn
DEC >
#n
MULTIPLEXER
#01 to #16
@RLA
@[FNC 35]
COMPLEMENT
5.0 to 6.0
DM/TM No.
MPX >
3-171
DM0000 to
DM0000 to
DM0999
DM1999TM00
TM00 to TM29
to TM29
14.0 to 17.0 3 (5)
@DEC
@[FNC 07]
MPX
[FNC 27]
@MPX
@[FNC 27]
Inverts content of
each bit in internal
register.
Subtracts 1 from
content of data
memory specified by
26.0 to 31.0 3 (12) operand.
3-172
#n
1 (3)
Adds 1 to content of
data memory
3-172
24.0 to 29.0 3 (12) specified by operand.
@INC
@[FNC 19]
DEC
[FNC 07]
12
Moves content of
internal register
3-166
serially left by value
22.0 to 42.0 2 (11) specified by operand.
RLA >
#dd
3-166
RRA
[FNC 37]
@RRA
@[FNC 37]
DECREMENT
MEMORY
Moves content of
internal register
serially right by
value specified by
23.0 to 42.0 2 (11) operand.
@SLA
@[FNC 40]
#dd
RRA >
INCREMENT
MEMORY
Page
# constant
#dd
ROTATE
LEFT A
Function
SLA >
ROTATE
RIGHT A
KV-10/16/24/40/80
Operand value Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
ANDA
[FNC 01]
nnnn
SRA >
SHIFT
LEFT A
Mnemonic Operand
#0 to #3
Chapter 2 Instructions
3-176
3-49
Instruction
Symbol
DMX
[FNC 12]
DMX >
@DMX
@[FNC 12]
<TBCD>
TBCD
[FNC 47]
TBCD>
@TBCD
@[FNC 47]
TBIN
[FNC 48]
TBIN>
@TBIN
@[FNC 48]
ASC
[FNC 02]
ASC >
@ASC
@[FNC 02]
<RASC>
RASC
[FNC 32]
TRANSFER
BIN
ASCII
CONVERT
REVERSE
ASCII
CONVERT
Function
Page
Converts position of
highest order bit with
1 in internal register
40.0 to 44.0 1 (10) into 4-bit data.
3-176
Converts content of
internal register (16bit binary) into 4-digit
31.0 to 35.0 1 (10) BCD data.
3-180
Converts content of
internal register (4digit BCD) into 16-bit
30.0 to 34.0 1 (10) binary data.
8.0
12.0 to 14.0
ROOT
[FNC 36]
3-183
1 (3)
3-183
3-185
102.0 to
103.0
@ROOT
ROOT>
@[FNC 36]
3-180
1 (3)
Converts content of
lower order byte of
internal register into
20.0 to 22.0 1 (10) 2-digit ASCII code.
@RASC
RASC>
@[FNC 32]
<ROOT>
SQUARE
ROOT
KV-10/16/24/40/80
Operand
value
Mnemonic Operand
Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
DEMULTIPLEXER
TRANSFER
BCD
KV-300
KV-300 Series,
Series, KV-10/80
114.0 to
117.0
1 (3)
KV-300
KV-300
Instruction
Symbol
DATA
MEMORY
WRITE
nnnn
< DW >
DMmmmm
TRIMMER
SETTING
DW
@TMIN
TMIN > @[FNC 50]
LOAD A
nnnn
LDA >
nnnn
STORE A
nnnn
STA >
#/$
constant,
DM No.
Operand value
nnnn:
#0000 to #65535
$0000 to $FFFF
DMmmmm:
DM0000 to DM9999
TMIN
[FNC 50]
nnnn
3-50
Mnemonic Operand
Trimmer
No.
LDA
[FNC 23]
R No.,
C/T No.,
DM/TM
No.,
#/$
@LDA
@[FNC 23] constant,
#TMxx
STA
[FNC 42]
R No.,
C/T No.,
DM/TM
No.,
#/$
@STA
constant,
@[FNC 42]
#TMxx
Chapter 2 Instructions
0, 1
Exec.time
Bytes
(s)
0500 to 1915
2100 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
DM0000 to DM9999
TM00 to TM29
#TM00 to #TM29
Page
0.60 to
1.40
3-136
5.10 to
5.60
3-138
2.00 to
5.70
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
CTH0 to CTH1
DM0000 to DM9999
TM00 to TM31
#00000 to #65535
$0000 to $FFFF
#TM00 to #TM29
Function
0.30 to
28.00
3 (12)
2.30 to
30.00
3 (26)
0.20 to
30.00
2.20 to
32.00
KV-300
Instruction
Symbol
nnnn
Mnemonic Operand
Operand value
Exec.time
Bytes
(s)
9.20 to
36.00
CMP
[FNC 04]
COMPARE
nnnn
CMP >
nnnn
@CMP
@[FNC 04]
ADD
[FNC 00]
ADD
DM/TM
No.,
#/$
constant,
#TMxx
DM0000 to DM9999
TM00 to TM31
#00000 to #65535
$0000 to $FFFF
#TM00 to #TM29
11.20 to
38.00
7.70 to
35.00
9.70 to
37.00
nnnn
SUB
[FNC 46]
8.40 to
35.00
nnnn
@SUB
@[FNC 46]
10.40 to
37.00
nnnn
MUL
[FNC 28]
SUBTRACT
SUB >
MULTIPLY
DM/TM
No.,
#/$ No.,
#TMxx
DM0000 to DM9999
TM00 to TM31
#00000 to #65535
$0000 to $FFFF
#TM00 to #TM29
9.80 to
37.00
nnnn
@MUL
@[FNC 28]
nnnn
DIV
[FNC 11]
13.70 to
41.00
nnnn
@DIV
@[FNC 11]
15.70 to
42.00
nnnn
ANDA
[FNC 01]
6.90 to
33.00
MUL >
11.80 to
39.00
DIVIDE
DIV >
<ANDA>
AND A
nnnn
@ANDA
@[FNC 01]
nnnn
ORA
[FNC 31]
nnnn
@ORA
@[FNC 31]
ANDA>
OR A
ORA >
R No.,
DM/TM
No.,
#/$ No.,
nnnn
@EORA
EORA> @[FNC 15] #TMxx
nnnn
EXCLUSIVE
OR A
EORA
[FNC 15]
R No.,
DM/TM
No.,
#/$ No.,
#TMxx
<EORA>
0000 to 0009
0500 to 17915
DM0000 to DM9999
TM00 to TM31
#00000 to #65535
$0000 to $FFFF
#TM00 to #TM29
8.90 to
35.00
6.90 to
33.00
8.90 to
35.00
0000 to 0009
0500 to 17915
DM0000 to DM9999TM00 to
TM31
#00000 to #65535
$0000 to $FFFF
#TM00 to #TM29
6.90 to
33.00
8.9 to
35.00
3-146
@ADD
@[FNC 00]
Page
3 (12)
nnnn
ADD >
Function
Subtracts value
3 (12) specified by operand
from content of register
and inputs result back
3 (26) to same register.
3-150
Multiplies content of
3 (12) internal register by
value specified by
operand and inputs
3 (26) result back to same
register.
3-150
Divides content of
3 (12) internal register by
value specified by
3-150
operand and inputs
3 (26) result back to same
register.
ANDs each of 16 bits of
3 (12) internal register and that
of value specified by
3-159
operand, and inputs
3 (26) result back to same
register.
ORs each of 16 bits of
3 (12) internal register and
that of value specified
by operand, and inputs 3-161
3 (26) result back to same
register.
EXCLUSIVE-ORs each
3 (12) of 16 bits of internal
register and that of value 3-164
specified by operand,
3 (26) and inputs result back to
same register.
Chapter 2 Instructions
3-51
12
KV-300
KV-300 Series,
Series, KV-10/80
KV-300
Instruction Symbol
#dd
@SRA
@[FNC 41]
12.80
#dd
SLA
[FNC 40]
10.80
SLA >
10.80
@SLA
@[FNC 40]
12.80
# constant
12.00
@RRA
@[FNC 37]
14.00
RLA
[FNC 35]
12.00
RLA >
@RLA
@[FNC 35]
14.00
COM
[FNC 05]
6.10
#dd
RRA >
#dd
ROTATE
LEFT A
#dd
COMPLEMENT
COM >
nnnn
INCREMENT
MEMORY
nnnn
INC >
nnnn
DECREMENT
MEMORY
3-52
Moves content of
2 (11) internal register serially
left, allowing each bit
that leaves left end to
2 (25) enter carry bit and then
rightmost bit.
3-169
1 (9)
7.70
3 (12)
@INC
@[FNC 19]
9.70
3 (26)
7.70
3 (12)
@DEC
@[FNC 07]
9.70
#n
MPX
[FNC 27]
7.30
3-171
Adds 1 to content of
data memory specified
by operand.
3-172
MPX >
@MPX
@[FNC 27]
9.30
DMX
[FNC 12]
6.70
1 (9)
DMX >
@DMX
@[FNC 12]
DEMULTIPLEXER
3-169
INC
[FNC 19]
DM0000 to DM9999
TM00 to TM29
# constant
#n
Chapter 2 Instructions
#0 to #3
8.70
3-166
Moves content of
2 (11) internal register serially
right, allowing each bit
that leaves right end to
2 (25) enter carry bit and then
leftmost bit.
1 (23)
DM/TM
No.
Page
8.10
DEC
[FNC 07]
Function
@COM
@[FNC 05]
nnnn
DEC >
MULTIPLEXER
#01 to #16
RRA
[FNC 37]
#dd
ROTATE
RIGHT A
Exec.time
Bytes
(s)
SRA
[FNC 41]
SRA >
SHIFT
LEFT A
Operand value
#dd
SHIFT
RIGHT A
Mnemonic Operand
Converts position of
highest order bit with 1
in internal register into
1 (23) 4-bit data.
3-176
3-176
KV-300
Instruction
TRANSFER
BCD
Symbol
Mnemonic
<TBCD>
TBCD
[FNC 47]
@TBCD
TBCD> @[FNC 47]
Exec.time
Bytes
(s)
13.20
15.20
TBIN
[FNC 48]
14.00
TBIN>
@TBIN
@[FNC 48]
16.00
ASC
[FNC 02]
8.50
ASC >
@ASC
@[FNC 02]
10.50
<RASC>
RASC
[FNC 32]
6.80
ASCII
CONVERT
@RASC
<ROOT>
SQUARE
ROOT
Operand value
TRANSFER
BIN
REVERSE
ASCII
CONVERT
Operand
Page
Converts content of
internal register (16-bit
binary) into 4-digit BCD
1 (23) data.
3-180
Converts content of
internal register (4-digit
BCD) into 16-bit binary
1 (23) data.
3-180
1 (9)
1 (9)
1 (9)
Converts content of
lower order byte of
internal register into 21 (23) digit ASCII code.
3-183
1 (9)
Converts 2-digit ASCII
code into one byte data. 3-183
8.80
ROOT
[FNC 36]
77.70
@ROOT
79.70
Function
1 (23)
Takes square root of 32bit data (TM00: higher
order byte, internal
3-185
register: lower order
1 (23) byte) and inputs result
back to same register.
1 (9)
Chapter 2 Instructions
3-53
12
KV-300
KV-300 Series,
Series, KV-10/80
Function
Page
Symbol
INTERRUPT
DISABLED
< DI >
DI
[FNC 08]
3.0 to 4.6
1 (4)
Disables execution
of interrupt.
3-193
INTERRUPT
ENABLED
< EI >
EI
[FNC 13]
3.0 to 4.6
1 (4)
Enables execution
of interrupt.
3-193
INT
nnn
R No.
RETI
1 (8)
Comparator
No.
INT
CTCn
RETURN
INTERRUPT
35.0 to 48.0
000 to 003
INT
[FNC 20]
INTERRUPT
KV-10/16/24/40/80
Operand value Operand value Exec.time
Bytes
KV-10/16
(s)
KV-24/40/80
Instruction
35.0 to
48.8
CTC0 to CTC3
RETI
[FNC 34]
20.0 to
23.0
1 (3)
Represents end of
interrupt.
3-192
KV-300
KV-300
Mnemonic Operand
Exec.time
Bytes
(s)
Instruction
Symbol
INTERRUPT
DISABLED
< DI >
DI
[FNC 08]
3.20
INTERRUPT
ENABLED
< EI >
EI
[FNC 13]
5.80
INT
nnn
R No.
INT
CTCn
3-54
000 to 003
Function
Page
1 (9)
Disables execution
of interrupt.
3-193
1 (0)
Enables execution
of interrupt.
3-193
40.00 to
80.00
1 (0)
Executes instructions
between INT and
RETI at rising edge
3-192
of any of input 000 to
003 or at falling edge
of 003.
40.00 to
80.00
1 (0)
60 to 100
1 (0)
INT
[FNC 20]
INTERRUPT
RETURN
INTERRUPT
Operand value
RETI
Comparator
No.
RETI
[FNC 34]
Chapter 2 Instructions
CTC0 to CTC3
3-192
Ladder symbol
Represents the form
of the instruction on a
ladder diagram.
Instruction key
Represents the key or
function No. for entry.
Instruction
Describes the name
and brief function of
the instruction.
SET / RES
SET: Set
Mnemonic
Represents the instruction in ladder language.
RES: Reset
SET
RES
Example
Example
Timing diagram
Description
Perform programming
using the given example
to gain experience.
nnnn
SET
nnnn
RES
0000
0500
SET
0001
0500
RES
Coding
Line No.
Instruction
LD
0000
0001
SET
0500
0002
LD
0001
0003
OUB
0500
Description
Output relay 0500 remains ON after input relay 0000 turns OFF. Output relay
0500 turns OFF when input relay 0001 turns ON.
SET instruction sets a latch whereas RES instruction resets it.
RES instruction not only turns OFF relay coils but serves as a reset signal when
a timer or counter is used as an operand.
0001
#00100
C000
00000
C000
RES
0002
Note
Describes the notes
for the instruction.
0001
0002
Coding
Shows the
coding for
the given
example.
#00100
C000
0000
Note: The SET and RES instructions can be entered in any order. Note, however,
that priority is given to the instruction that is entered last.
In the above example, when both 0000 and 0001 are ON, RES has priority over
SET, causing 0500 to remain OFF.
Tips
Differences between SET/RES and KEEP
Basically , SET/RES and KEEP ( p. 3-57 and p. 3-71) serve the same purpose.
SET and RES can be used separately. Therefore, RES can be placed before
SET.
Another instruction may be placed between SET and RES.
KEEP needs only three lines of program, therefore saving memory space when
used a number of times.
Tips
Describes hands-on
techniques for efficient
programming.
Operand
Shows operands (element
Nos.) that can be used for
the instruction.
Operand
0000
0000
0500
RES
0001
0500
SET
LD
RES
LD
SET
0000
0000
0500
0001
0500
KEEP
SET
0500
0001
LD
0000
LD
0001
KEEP 0500
RES
Operands
NEW KV
KV-300
KV-10/16
KV-24/40/80
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
0500 to 1915
2009
2100 to 2915
T000 to T063
C000 to C063
0500 to 1915
2009
2100 to 6915
T000 to T119
C000 to C119
Key operation
Describes the basic key
operations on the handheld
programmer. Set the mode
switch to PROGRAM.
Key operation
SET
3-66
Operand
ENT
R-SRCH
RES
Operand
ENT
R-SRCH
Chapter 2 Instructions
Chapter 2 Instructions
3-55
12
3-57
LDB
3-57
And
AND
3-58
And Bar
ANB
3-58
OR: Or
OR
3-60
ORB
3-60
ANL
3-61
Or Load
ORL
3-63
OUT: Out
OUT
3-65
OUB
3-65
SET: Set
SET
3-66
RES: Reset
RES
3-66
TMR
3-67
TMH (FUN49)
3-68
TMS (FUN51)
3-69
3-72
C: Counter
UDC: Up-Down Counter
UDC (FUN52)
3-76
DIFU: Differentiate Up
DIFU (FUN10)
3-78
DIFD (FUN09)
3-78
KEEP: Keep
KEEP (FUN22)
3-80
SFT: Shift
SFT (FUN39)
3-82
HSP (FUN18)
3-86
MC (FUN24)
3-89
MCR (FUN25)
3-89
MEMSW (FUN26)
3-92
NOP: No Operation
NOP
3-94
END: End
END
3-94
ENDH: End Hi
END
3-94
3-56
Reference page
LD
Load Bar
ORB: Or Bar
Mnemonic
Chapter 2 Instructions
LD / LDB
2.4 Instruction Details
LD: Load
LD
nnnn
LDB
nnnn
7
4
Example
0000
0500
0001
0501
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OUT
0500
0002
LDB
0001
0003
OUT
0501
When input relay 0000 turns ON, output relay 0500 turns ON.
When input relay 0001 turns OFF, output relay 0501 turns ON.
12
Description
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
CTC0 to CTC3
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
Key operation
Example: LD C014
LD
LDB
Operand
ENT
R-SRCH
ENT
R-SRCH
Chapter 2 Instructions
3-57
AND / ANB
2.4 Instruction Details
AND: And
AND
nnnn
ANB
nnnn
Example
0000
0001
0500
0002
0003
0501
0502
0004
0503
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
AND
0001
0002
OUT
0500
0003
LD
0002
0004
ANB
0003
0005
OUT
0501
0006
OUT
0502
0007
AND
0004
0008
OUT
0503
To turn ON 0503, 0002 must be ON, 0003 OFF, and 0004 ON at the same time. The
AND and ANB instructions are used when two or more conditions (in this case,
0002: ON, 0003: OFF, 0004: ON) must be satisfied at the same time.
Description
0001
0000
0501
0001
0500
0500
Coding
Line No.
Coding
Instruction
Operand
Line No.
Instruction
Operand
0000
0000
LD
0000
0000
LD
0001
OUT
0500
0001
MPS
0002
AND
0001
0002
AND
0001
0003
OUT
0501
0003
OUT
0501
0004
MPP
0005
OUT
3-58
0501
Chapter 2 Instructions
0500
AND / ANB
2.4 Instruction Details
Operand
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
Key operation
Example: AND T012
AND
ANB
Operand
ENT
R-SRCH
ENT
R-SRCH
12
Chapter 2 Instructions
3-59
OR / ORB
2.4 Instruction Details
OR: Or
OR
nnnn
ORB
nnnn
ORB: Or Bar
Example
0000
0500
0003
0001
0002
0004
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OR
0000
0002
ORB
0002
0003
AND
0003
0004
OR
0004
0005
OUT
0500
0000 must be ON or
To turn ON 0500,
0001 ON or
or,
0002 OFF.
The OR and ORB instructions are used when at least one of the conditions (here,
two sets of conditions: <0003: ON, 0004: ON>, and <0000: ON, 0001: ON, 0002:
OFF> are given) must be satisfied.
Description
The OR and ORB instructions are used to connect in parallel the contacts for
these instructions with contacts on the previous line. An LD or LDB instruction is
used together with the OR and ORB instructions.
As many contacts as desired can be connected in parallel provided they are used
in the same program.
0500
0000
Incorrect
0001
0501
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
Key operation
Example: OR T018
OR
ORB
Operand
3-60
Chapter 2 Instructions
ENT
R-SRCH
ENT
R-SRCH
ANL
2.4 Instruction Details
ANL
Example
0000
0001
0002
0003
0500
ANL
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OR
0002
0002
LD
0001
0003
OR
0003
0004
ANL
0005
OUT
0500
12
Description
0000
0002
0001
and Block B
series.
0003
Operands
Key operation
ANL
ENT
R-SRCH
Chapter 2 Instructions
3-61
ANL
2.4 Instruction Details
0002
0004
0001
0003
0005
0500
Coding (1)
Line No.
Coding (2)
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0000
0000
LD
0000
0001
OR
0001
0001
OR
0001
0002
LD
0002
0002
LD
0002
0003
OR
0003
0003
OR
0003
0004
ANL
0004
LD
0004
0005
LD
0004
0005
OR
0005
0006
OR
0005
0006
ANL
0007
ANL
0008
OUT
0500
0007
ANL
0008
OUT
0500
The ANL instruction can be used as many times as desired. Note, however, that
in example (2) above, ANL is entered one less time than the number of blocks to
be connected.
Also, ANL can be used only 8 times or less in example (2), whereas in example
(1) it can be used as many times as desired.
3-62
Chapter 2 Instructions
ORL
2.4 Instruction Details
ORL: Or Load
ORL
Example
0000
0001
0002
0003
0050
ORL
Coding
Line No.
Instruction
0000
LD
Operand
0000
0001
AND
0001
0002
LD
0002
0003
AMD
0003
0004
ORL
0005
OUT
0500
Description
The above example shows a parallel connection of Block A
and Block B
parallel.
0002 0003
0000 0001
12
Operands
Key operation
ORL
ENT
R-SRCH
Chapter 2 Instructions
3-63
ORL
2.4 Instruction Details
0001
Block
0002
0003
Block
0004
0005
Block
0500
Coding (1)
Line No.
Coding (2)
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0000
0000
LD
0000
0001
AND
0001
0001
AND
0001
0002
LD
0002
0002
LD
0002
0003
AND
0003
0003
AND
0003
0004
ORL
0004
LD
0004
0005
0005
LD
0004
0005
AND
0006
AND
0005
0006
ORL
0007
ORL
0008
OUT
0500
0007
ORL
0008
OUT
0500
The ORL instruction can be used as many times as desired. Note, however, that
in example (2) above, ORL is entered one less time than the number of blocks to
be connected.
Also, ORL can be used only 8 times or less in example (2), whereas in example
(1) it can be used as many times as desired.
Note: "LOGIC ERROR" is displayed on the programmer when ORL is used 9 times
or more in example (2).
3-64
Chapter 2 Instructions
OUT / OUB
2.4 Instruction Details
OUT: Out
OUB: Out Bar
OUT
nnnn
OUB
nnnn
Example
0500
0000
0501
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OUT
0500
0002
OUB
0501
Description
When input relay 0000 turn ON, output relay 0500 turns ON and output relay
0501 turns OFF.
The OUT and OUB instructions are used to drive relay coils for output relays,
internal utility relays, and latch relays. These instructions are not used for input
relays, timers, counters, or data memories.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 1915
2009
2300 to 17915
0500 to 1915
2009
2300 to 17915
0500 to 1915
2009
2300 to 2915
0500 to 1915
2009
2300 to 6915
Key operation
OUT
Operand
ENT
R-SRCH
OUB
Operand
ENT
R-SRCH
Chapter 2 Instructions
3-65
12
SET / RES
SET: Set
RES: Reset
SET
nnnn
SET
RES
nnnn
RES
1
0
Example
0000
0500
SET
0001
0500
RES
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
SET
0500
0002
LD
0001
0003
OUB
0500
Description
Output relay 0500 remains ON after input relay 0000 turns OFF. Output relay
0500 turns OFF when input relay 0001 turns ON.
SET instruction sets a latch whereas RES instruction resets it.
RES instruction not only turns OFF relay coils but serves as a reset signal when
a timer or counter is used as an operand.
#00100
C000
00000
C000
RES
0001
0002
0001
#00100
C000
0000
0002
Note: The SET and RES instructions can be entered in any order. Note, however,
that priority is given to the instruction that is entered last.
In the above example, when both 0000 and 0001 are ON, RES has priority over
SET, causing 0500 to remain OFF.
Tips
Differences between SET/RES and KEEP
Basically , SET/RES and KEEP ( See above and p. 3-80) serve the same purpose.
SET and RES can be used separately. Therefore, RES can be placed before
SET.
Another instruction may be placed between SET and RES.
KEEP needs only three lines of program, therefore saving memory space when
used a number of times.
0000
0500
RES
0001
0500
SET
LD
RES
LD
SET
0000
0000
0500
0001
0500
KEEP
SET
0500
0001
LD
0000
LD
0001
KEEP 0500
RES
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
0500 to 1915
2009
2100 to 17915
T000 to T249
C000 to C249
0500 to 1915
2009
2100 to 2915
T000 to T063
C000 to C063
0500 to 1915
2009
2100 to 6915
T000 to T119
C000 to C119
Key operation
SET
3-66
Operand
Chapter 2 Instructions
ENT
R-SRCH
RES
Operand
ENT
R-SRCH
TMR
TMR
(T)
#ddddd
Txxx
Example
0000
#00010
T000
Preset value: 1 s
#00035
T001
T000
0500
T001
0501
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
TMR
TMR
LD
OUT
LD
OUT
Operand
0000
000 #00010*1
001 #00035*2
T000
0500
T001
0501
*1 0.1 s x 10 = 1 s
*2 0.1 s x 35 = 3.5 s
12
ON
OFF
Current #00010
value of
TMR000
#00000
ON
Output 0500
0500 and 0501 turn ON 1 second and 3.5 seconds respectively after 0000 turns
ON.
TMR000 is a subtraction timer. When the current value reaches "#00000",
contact T000 turns ON, and then output relay 0500 turns ON.
When input relay 0000 turns OFF, contact T000 and T001 turn OFF and the
current values of TMR000 and TMR001 are reset.
Note 1: The TMR number cannot be the same as any other TMS, TMH, TMR, C, or UDC
instructions in the same program.
Note 2: The current value of TMR is not retained but is reset to the preset value if a power
failure occurs or if power is turned OFF.
Tips
When the number specified by TMR is used as a contact (T000 in the above
example), this contact can be used as many times as desired. It can also be
used as both N.O. and N.C. contacts.
Timer accuracy = 0.1 sec. + (1 scan time) (max.)
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
TMR
(T)
Operand
Operand
(TMR No.)
(Preset value)
ENT
R-SRCH
Chapter 2 Instructions
3-67
TMH
FUN
LDB
OR
#ddddd
T
Txxx
H
Example
0000
#00010
T
T000
H
T000
0500
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
TMH
000 #00010*1
0002
LD
T000
0003
OUT
0500
*1 0.01 s x 10 = 0.1 s
Description
Note 1: The TMH number cannot be the same as any other TMS, TMH, TMR, C, or
UDC instructions in the same program.
Note 2: The current value of TMH is not retained but is reset to the preset value if
power failure occurs or if power is turned OFF.
When the number specified by TMH is used as a contact (T000 in the above
example), this contact can be used as many times as desired. It can also be
used as both N.O. and N.C. contacts.
Timer accuracy = 0.01 sec. + (1 scan time) (max.)
Operand
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operations
FUN
3-68
LDB
Chapter 2 Instructions
OR
ENT
Operand
Operand
ENT
R-SRCH
(TMH No.)
(Preset value)
R-SRCH
TMS
ANB SET
FUN 5
#ddddd
T Txxx
S
Example
0000
#00100
T
T000
S
T000
0500
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
TMS
000 #00010*1
0002
LD
T000
0003
OUT
0500
Description
Note 1: The TMS number cannot be the same as any other TMS, TMH, TMR, C, or
UDC instructions in the same program.
Note 2: The current value of TMS is not retained but is reset to the preset value if
power failure occurs or if power is turned OFF.
When the number specified by TMS is used as a contact (T000 in the above
example), this contact can be used as many times as desired. It can also be
used as both N.O. and N.C. contacts.
Timer accuracy = 0.001 sec. + (1 scan time) (max.)
Operand
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operations
FUN
ANB
SET
ENT
Operand
Operand
ENT
R-SRCH
(TMS No.)
(Preset value)
R-SRCH
Chapter 2 Instructions
3-69
12
TMR
0000
T000
0500
2 sec.
0500
Timing diagram
ON
OFF
0000
ON
ON
2 sec.
2 sec.
0500
Coding
Line No.
Instruction
0000
LD
Operand
0000
0001
OR
0500
0002
TMR
000 #00020
0003
ANB
T000
0004
OUT
0500
Off-delay circuit
When input relay 0000 turns ON, output relay 0500 turns ON. 0500 turns OFF in a
specified time after 0000 turns OFF.
0000
0500
T000
0000
0500
#00020
T000
Timing diagram
ON
0000
OFF
0500
ON
2 sec.
Coding
Line No.
3-70
Instruction
Operand
0000
LD
0000
0001
OR
0500
0002
ANB
T000
0003
OUT
0500
0004
ANB
0000
0005
TMR
000 #00020
Chapter 2 Instructions
2 sec.
TMR
#00020
T000
T000
0500
2 sec.
Timing diagram
ON
OFF
0000
ON
0500
1s
2s
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
TMR
000 #00020
0002
LD
T000
0003
OUT
0500
12
Flicker circuit
Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
0000
T001
T000
#00020
T000
2 sec.
#00010
T001
1 sec.
0500
Timing diagram
ON
0000
OFF
0500
ON
ON
ON
2s 1s 2s 1s 2s 1s
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
ANB
T001
0002
TMR
000 #00020
0003
LD
T000
0004
AMR
001 #00010
0005
OUT
0500
Chapter 2 Instructions
3-71
CTR
(C)
C: Counter
#ddddd
Cxxx
nnnn
Example
Reset input
Preset value
#00010
C000
0000
0500
Counter No.
Line No.
Instruction
Operand
0000
LDB
0001
0001
0002
LD
C000
0003
OUT
0500
0001
C000
Count input
Coding
ON
OFF
0001
(Reset input)
Current value
of C000
#00010
C000
0500
10
ON
Description
The counter performs one counting at the rising edge of clock pulse. When the
current value reaches the preset value, the coil of specified No. turns ON.
When a reset input (b [N.C.] contact) turns ON, the current counter value is reset
to "00000".
Since C is software counter which is set on the program, the response speed
depends on the scan time.
Note 1: When a reset input is provided using an a (N.O.) contact, the current
counter value is reset at power-off.
Note 2: The C number cannot be the same as any other TMS, TMH, TMR, C, or
UDC instructions in the same program.
Note 3: The current C value is stored more than two months (KV-10xx: More than
20 days) at 25C even when the KV is not in operation or is turned off.
Tips
By entering relay 2007 (which can turn the counter OFF for only the first scan time
when the operation is started) using an 'a' (N.O.) contact in series as the input relay
for resetting counter, you can reset the current C value whenever the operation is
started.
0001
3-72
Chapter 2 Instructions
#00010
C000
0000
Details of counter
Extended ladder
The counter for the KV Series supports the extended ladder method.
KV counter
0001
#00010
C005
0000
2007
The extended ladder allows you to connect contacts or output coils after the
counter in series, reducing the number of ladder program lines.
In the following example, the counter starts counting when counter input relay 0004
turns ON. When the current counter value reaches "300", output relay 0500 turns
ON.
0002
#00300
C002
0004
C002
0500
Coding
Line No.
Instruction
Operand
0000
LDB
0002
0001
0002
CON
0003
AND
C002
0004
OUT
0500
12
For details of the extended ladder, refer to "1.5 Extended Ladder Diagrams"
(p.3-29).
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Preset value:
#00000 to #65535
Preset value:
#00000 to #65535
Preset value:
#00001 to #65535
Key operation
CTR
(C)
Operand
Operand
Operand
ENT
(Counter No.)
(Preset value)
(Count input)
R-SRCH
Chapter 2 Instructions
3-73
0000
C002
Coding
Line No.
Instruction
Operand
0000
LDB
0000
0001
C
002 #03600 2006
0002
LD
C002
0003
OUT
0500
"1.3.7 Special Utility Relays" (p. 3-12)
#03600
C001
2006
1000
C001
C001
#00600
C002
1000
0001
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LDB
ANB
C
LD
OUT
LDB
C
Operand
0001
C001
001 #03600 2006
C001
1000
0001
002 #00600 1000
Instruction
LDB
ANB
C
LD
OUT
LDB
C
Operand
0002
C001
001 #10000 0000
C000
1000
0002
001 #65535 1000
#10000
C000
0000
1000
C000
C000
#65535
C001
1000
0002
Line No.
0000
0001
0002
0003
0004
0005
0006
Multi-level setting
Sets a multi-level counter using arithmetic instructions.
#01000
CMP
2009
#09999
C002
0000
0500
#02000
CMP
2009
0501
#03000
CMP
2009
0502
0001
2002
C002
LDA
3-74
Chapter 2 Instructions
Instruction
LDB
C
LD
LDA
CON
MPS
CMP
CON
ANB
OUT
Operand
0002
002 #09999 0000
2002
C002
#01000
2009
0500
Line No.
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
Instruction
MRD
CMP
CON
ANB
OUT
MPP
CMP
CON
ANB
OUT
Operand
#02000
2009
0501
#03000
2009
0502
#00999 2011
CMP
#01999 2011 0500
CMP
#09999
C000
0000
0500
0501
12
Instruction
LDB
C
LD
LDA
CON
MPS
CMP
CON
ANB
OUT
MRD
CMP
CON
ANB
ANB
OUT
MPP
CMP
CON
ANB
ANB
ANB
OUT
Operand
0001
000 #09999 0000
2002
C000
#00999
2011
0500
#01999
2011
0500
0501
#02999
2011
0500
0501
0502
Chapter 2 Instructions
3-75
UDC
2.4 Instruction Details
ANB ANL
FUN 5
UDC xxx
UP
DW #ddddd
RES
Example
UP input
UDC 000
0001
UP
DOWN input
#00009
0002
DW
RESET input
0003
RES
0500
C000
Coding
Line No.
Instruction
Operand
0000
LD
0001
0001
LD
0002
0002
LD
0003
0003
UDC
000 #00009
0004
LD
C000
0005
OUT
0500
Timing diagram
2 3
Carry
Carry
ON
Time
ON
OFF
C000
ON
OFF
ON
OFF
ON
OFF
When UP input relay (0001) turns ON, the current value of the counter is
incremented by one. When DOWN input relay (0002) turns ON, the current value
is decremented by one.
C000 turns ON when the digit shifts (#00009 to #00000, or #00000 to #00009).
Note 1: The UDC number cannot be the same as any other TMS, TMH, TMR, C, or
UDC instructions in the same program.
Note 2: The current UDC value is stored more than two months (KV-10xx: More
than 20 days) at 25C even when the KV is not in operation or is turned off.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
FUN
3-76
ANB
Chapter 2 Instructions
ANL
ENT
Operand
Operand
ENT
R-SRCH
(C No.)
(Preset value)
R-SRCH
UDC
0001
UP
#09999
BCD
Low-order 4 digits
0002
DW
0003
RES
C000
UDC 001
0001
UP
#09999
C000
BCD
High-order 4 digits
0002
DW
0003
RES
Up-input
0001
Down-input 0002
Coding
Line No.
Instruction
Operand
0000
LD
0001
0001
LD
0002
0002
LD
0003
0003
UDC
000 #09999
0004
LD
C000
0005
AND
0001
0006
LD
C000
0007
AND
0002
0008
LD
0003
0009
UDC
001 #09999
12
The example below outputs the high-order 4 digits of 8-digit BCD to UDC001 and
the low-order 4 digits of 8-digit BCD to UDC000.
0004
C000
LDA
TBCD
0500
STA
C001
LDA
TBCD
0600
STA
Low-order
4 digits
High-order
4 digits
Chapter 2 Instructions
3-77
DIFU / DIFD
2.4 Instruction Details
SET RES
nnnn
DIFU
RES OR
nnnn
DIFD
DIFU: Differentiate Up
FUN 1
FUN 0
0
9
Example
1000
DIFU
0000
1001
DIFD
Coding
Line No.
Instruction
0000
LD
Operand
0000
0001
DIFU
1000
0002
DIFD
1001
0000
OFF
ON
1000
1001
The DIFU instruction turns ON the relay specified by the operand for only the 1st
scan time at the rising edge of input signal (0000).
The DIFD instruction turns ON the relay specified by the operand for only the 1st
scan time at the falling edge of input signal (0000).
1000
DIFU
1000
0500
1000
DIFD
0000
1000
0500
1000
DIFD
1000
0500
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
1000 to 1915
3000 to 9915
1000 to 1915
3000 to 6915
*7000 to 9915
1000 to 1915
1000 to 1915
3000 to 6915
Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or I/O
terminal module ports can be used for internal utility relays.
Key operation
FUN
3-78
Chapter 2 Instructions
R-SRCH
(Relay No.)
OR
ENT
Operand ENT
R-SRCH
R-SRCH
(Relay No.)
DIFU / DIFD
2.4 Instruction Details
0000
1001
DIFD
1000
0500
T001
#00010
T001
0500
1001
0501
T002
#00010
T002
0501
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
Instruction
LD
DIFU
DIFD
LD
OR
ANB
OUT
TMR
LD
OR
ANB
OUT
TMR
Operand
0000
1000
1001
1000
0500
T001
0500
001 #00010
1001
0501
T002
0501
002 #00010
Timing diagram
0000
1000
1001
ON
OFF
12
ON
OFF
ON
OFF
ON
0500
1s
ON
0501
1s
Alternating circuit
Every time input relay 0000 turns ON, output relay 0500 turns ON and OFF alternately.
Coding
0000
1000
DIFU
1000
0500
1000
0500
0500
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LD
DIFU
LD
ANB
LDB
AND
ORL
OUT
Operand
0000
1000
1000
0500
1000
0500
0500
Chapter 2 Instructions
3-79
KEEP
KEEP: Keep
ORL OR
FUN 3
KEEP
SET
nnnn
RES
Example
KEEP
0001
SET input
SET
0500
0002
RES
RESET input
Coding
Line No.
0000
0001
0002
Instruction
LD
DIFU
DIFD
Operand
0000
1000
1001
Description
When SET input relay No. 0001 is ON and RESET input relay No. 0002 is OFF,
0500 turns ON.
When RES input (0002) is ON, output relay 0500 turns OFF.
When both 0001 and 0002 are OFF, the previous status is retained.
Note 1: When 0500 used for KEEP instruction in the above example is changed to
0500
OUT instruction (
), it forms a double coil. In such a case, priority is given to the
instruction that is entered last "Double coil" (p. 3-65)
Note 2: When both 0001 and 0002 are ON, RESET (0002) has priority over SET
(0001), causing 0500 to turn OFF.
Tips
Internal utility relay latching function
The ON/OFF status of an internal utility relay immediately before power-off can be
stored by setting the memory switch (MEMSW).
If this stored utility relay is used for a latching instruction (SET or KEEP), the relay
settings can be stored while the power is off.
Stores the status of
internal utility relays
1000 through 1915.
MEMSW
Coding
Line No.
0000
0001
0002
0003
0004
0005
$0004
KEEP
0001
SET
1000
0002
RES
0500
1000
Instruction
MEMSW
LD
LD
KEEP
LD
OUT
Operand
$0004
0001
0002
1000
1000
0500
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0500 to 1915
2009
2100 to 17915
0500 to 1915
2009
2100 to 17915
0500 to 1915
2009
2100 to 2915
0500 to 1915
2009
2100 to 6915
Key operation
FUN
3-80
ANL
Chapter 2 Instructions
ANL
ENT
Operand
ENT
R-SRCH
(Relay No.)
R-SRCH
KEEP
Executes SET when all input relays 0000 to 0003 are ON.
Detects presence/absence of chewing gum packs at DOWN edge of 0000.
Outputs 1-s one-shot pulse from output relay 0500 when 1000 is OFF.
Reflector R-2
ES
ON
OFF
ON
ES
Gum
Gum
Gum Gum Gum
Gum Gum Gum
PZ2-61
KEEP
SET
1000
1001
12
RES
0000
1001
DIFD
0500
#00010
T001
0500
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
AND
AND
AND
LD
KEEP
LD
Operand
0000
0001
0002
0003
1001
1000
0000
Line No.
0007
0008
0009
0010
0011
0012
0013
Instruction
DIFD
LD
ANB
OR
ANB
OUT
TMR
Operand
1001
1001
1000
0500
T001
0500
001 #00010
Timing diagram
ON
0000
OFF
ON
0001
OFF
ON
0002
OFF
ON
0003
OFF
ON
0500
OFF
ON
ON
1s
Chapter 2 Instructions
3-81
SFT
2.4 Instruction Details
SFT: Shift
ORL O R
FUN 3
SFT
D
nnnn
CLK
RES mmmm
Example
Relay shift
operation
Data input
SFT
0001
D
1000
0002
CLK
Clock
1002
0003
RES
RESET input
0500
1002
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
LD
LD
SFT
LD
OUT
Operand
0001
0002
0003
1000 1002
1002
0500
Timing diagram
RESET input
0003
ON
Data input
0001
ON
Clock
0002
ON
1000
1001
1002
0500
0
1
Lost
1001
0
1000
1
0001
1
A)
Lost
1002
0
1001
1
1000
1
0001
1
B)
Lost
1002
1
1001
1
1000
1
0001
1
C)
Lost
1002
1
1001
1
1000
1
0001
1
D)
ON
Lost
1002
1
1001
1
1000
0
0001
0
E)
ON
Lost
1002
1
1001
0
1000
0
0001
1
F)
Lost
1002
0
1001
0
1000
1
0001
1
G)
OFF
OFF
A
OFF
ON
ON
ON
ON
ON
ON
OFF
ON
1002
0
ON
Description
First relay No. 1000 turns ON (OFF) when the data input relay is ON (OFF) at the
rising edge of the clock pulse.
Clock pulse A) shifts the ON status of input relay 0001 to relay 1000, and shifts
the status of other relays in sequence as shown in A) on the right.
When the data input is OFF as for clock pulse E), OFF status is shifted to relay
1000.
When the RESET input relay turns ON, all the relays (from the first one to the last
one) turn OFF.
Several SFT instructions can be used in a program.
3-82
Chapter 2 Instructions
SFT
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
1000 to 1915
3000 to 6915
1000 to 1915
3000 to 6915
*7000 to 9915
1000 to 1915
1000 to 1915
3000 to 6915
Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or remote I/O
unit ports can be used for internal utility relays.
Key operation
FUN
ORL
OR
ENT
Operand
Operand
ENT
R-SRCH
(Relay No.)
(Relay No.)
R-SRCH
SFT
1000
D
Line No.
0000
0001
0002
0003
0004
0005
1000
0000
CLK
1000
2003
RES
0500
1000
Instruction
LDB
LD
LD
SFT
LD
OUT
Operand
1000
0000
2003
1000 1000
1000
0500
Timing diagram
0000
ON
OFF
0500
ON
ON
ON
ON
ON
Coding
0000
1000
DIFU
1000
0500
1000
0500
0500
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LD
DIFU
LD
ANB
LDB
AND
ORL
OUT
Operand
0000
1000
1000
0500
1000
0500
0500
Chapter 2 Instructions
3-83
12
SFT
2.4 Instruction Details
Resetting internal utility relays
When input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915
turn OFF.
SFT instruction can be substituted for RES instruction. This application can be used
to reset many relays at one time.
(All relays 3000 through 9915 can also be turned OFF at one time.)
Coding
SFT
2003
D
1000
2003
CLK
1915
0000
Line No.
0000
0001
0002
0003
Instruction
LD
LD
LD
SFT
Operand
2003
2003
0000
1000 1915
RES
1000
SET
Line No.
Instruction
0000
LD
2008
#00010
T001
0001
SET
1000
2008
T001
SFT
2003
D
1000
T001
CLK
1005
2003
RES
1000
1001
0501
1002
0502
1003
0503
1004
0504
1005
3-84
0500
Chapter 2 Instructions
1000
SET
Operand
0002
LDB
T001
0003
T001
#00010
0004
LD
2003
0005
LD
T001
0006
LD
2003
0007
SFT
1000 1005
0008
LD
1000
0009
OUT
0500
0010
LD
1001
0011
OUT
0501
0012
LD
1002
0013
OUT
0502
0014
LD
1003
0015
OUT
0503
0016
LD
1004
0017
OUT
0503
0018
LD
1005
0019
SET
1000
SFT
1100
DIFU
1100
1000
SET
SFT
2003
D
1000
0001
CLK
1010
0002
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LD
DIFU
LD
SET
LD
LD
LD
SFT
Operand
0000
1100
1100
1000
2003
0001
0002
1000 1010
RES
Timing diagram
Scan
0001
ON
OFF
0000
ON
OFF
1000
ON
OFF
1001
ON
OFF
1002
ON
OFF
12
Chapter 2 Instructions
3-85
HSP
2.4 Instruction Details
SET AND
FUN 1
HSP
nnnn
Example
Enable input
0000
HSP
0001
0001
0500
SET
0002
0501
SET
0003
0500
RES
0501
RES
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
HSP
0001
0002
LD
0001
0003
SET
0500
0004
LD
0002
0005
SET
0501
0006
LD
0003
0007
RES
0500
0008
RES
0501
Timing diagram
0000
0001
0002
ON
OFF
ON
ON
ON
ON
5 ms
0501
ON
5 ms
15 ms
ON
0003
0500
ON
ON
ON
ON
ON
Description
When enable input 0000 turns ON, the time constant of input 0001 (specified by
HSP) changes from 10 ms to 10 s.
When enable input relay 0000 is ON and the scan time is 1 ms, and when the
ON time ( ) of input relays 0001 and 0002 is 5 ms, output relay 0500 turns ON
but 0502 does not.
Note 1: The time constant is switched by special utility relays 2609 through 2612
with the expansion units, or by the provided switches with I/O distribution module.
Note 2: The HSP instruction is used for the input to basic units only.
3-86
Chapter 2 Instructions
HSP
Scan time
Inputdevice
Program
execution
Output device
Inputdevice
Program
execution
3)
Output device
2)
Inputdevice
1)
Output device
OFF
Scan time
Program
execution
Scan time
Even if the input signal width is shorter than the scan time, the signal can be fetched
when it turns ON during input process as in 1). However, it cannot be fetched when
it turns ON any other time than the input process as in 2).
For reliable signal reception, the input signal width must be longer than the scan
time as in 3).
Scan time < Input signal width < Normal time constant (10 ms 20%)
Switching the input time constant of expansion units
Expansion input unit
Expansion I/O unit
KV-E4X
KV-E4XT(P)
KV-E8X
KV-E4XR
KV-E16X
The input time constant of an expansion unit is initially set to 10 ms.
It can be changed to 10 s by creating a ladder program or by using the Access
Window, the LADDER BUILDER for KV programming support software, or with the
KV-P3E(01) handheld programmer.
Change the values of special utility relays 2609 to 2612.
Special utility relay
2609
2610
2611
2612
Description
Input time constant of 1st unit. OFF: 10 ms, ON: 10 s
Input time constant of 2nd unit. OFF: 10 ms, ON: 10 s
Input time constant of 3rd unit. OFF: 10 ms, ON: 10 s
Input time constant of 4th unit. OFF: 10 ms, ON: 10 s
Operands
KV-300
KV-10
KV-16
KV-24
KV-40/80
0000 to 0009
0000 to 0005
0000 to 0009
0000 to 0015
0000 to 0107
Key operation
FUN
SET
AND
ENT
R-SRCH
Operand
(Relay No.)
ENT
R-SRCH
Chapter 2 Instructions
3-87
12
HSP
0001
1-s timer
#00010
T000
0000
0500
0500
T000
Turns ON
timer for 1s
when 0500
is ON.
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
HSP
LD
OR
TMR
ANB
OUT
Operand
0001
0000
0000
0500
000 #00010
T000
0500
Timing diagram
Scan
0000
ON
OFF
0001
ON
OFF
0500
ON
1s
To input a signal having pulse interval shorter than the scan time, use the interrupt instruction.
#00010
T000
0500
RES
Interrupt enabled
Input time constant 10 s
Initial settings
END
2002
INT
0000
0500
SET
RETI
ENDH
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
3-88
Chapter 2 Instructions
Instruction
LD
EI
SET
LD
T000
LD
RES
Operand
2008
2813
0500
#00010
T000
0500
Line No.
0007
0008
0009
0010
0011
0012
Instruction
END
INT
LD
SET
RET1
ENDH
Operand
0000
2002
0500
MC / MCR
ANL LDB
MC
ANL ANB
MCR
FUN 2
FUN 2
4
5
Example
0000
MC
0001
0500
0501
MCR
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
MC
LD
OUT
OUB
MCR
Operand
0000
0001
0500
0501
12
Description
When 0000 is OFF, both 0500 and 0501 do not turn ON, even if 0001 is turned
ON.
When 0000 is ON, 0500 turns ON and 0501 turns OFF as soon as 0001 is turned
ON.
Regard the function of MC-MCR instructions as "power switch" or "main switch".
When the input relay for MC is OFF, the instructions entered between MC and
MCR instructions function as follows:
Instructions
Function
Timer is reset
STP
xxxx
MC
MC
MCR
STE
MCR
MCR
Operands
Key operation
FUN
ANL
LDB ENT
ENT
R-SRCH
R-SRCH
FUN
ANL
ANB ENT
ENT
R-SRCH
R-SRCH
Chapter 2 Instructions
3-89
MC / MCR
2.4 Instruction Details
STP
xxxx
STP
xxxx
MC
STE
MC
STP
xxxx
MC
MCR
STE
MCR
STE
MCR
0001
0003
0002
MC
0500
MCR
Note: The scan time is not shortened even if the input relay of the MC instruction is
OFF.
Output relays 0500 within and outside of the MC-MCR instructions form a double
coil as shown below. "Double coil" (p. 3-65)
0500
0001
MC
0002
0500
MCR
3-90
Chapter 2 Instructions
MC / MCR
ON
OFF
ON
OFF
ON
OFF
ON
OFF
0003
0500
0501
0502
ON
ON
ON
ON
ON
ON
Coding
ON
ON
ON
0000
1000
1001
1101
RES
1102
RES
0001
0000
0002
1002
DIFU
1100
RES
1002
MC
1000
0003
1100
STG
1200
#00010
T000
T000
0004
1101
JMP
1201
#00020
T001
T001
0005
1101
STG
1102
JMP
1202
#00030
T002
T002
0006
1102
STG
1100
JMP
MCR
0007
1001
MC
0001
1203
0002
1204
0003
1205
0008
0009
0010
0011
MCR
0012
1200
0500
0013
1203
0014
1201
0501
0015
1204
0016
1202
0502
0017
1205
0018
END
0019
ENDH
0020
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
Instruction
LD
OUT
CON
OUB
LD
DIFU
CON
AND
RES
CON
RES
CON
RES
LD
MC
STG
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
TMR
CON
AND
JMP
MCR
LD
MC
LD
OUT
LD
OUT
LD
OUT
MCR
LD
OR
OUT
LD
OR
OUT
LD
OR
OUT
END
ENDH
Operand
0000
1000
1001
0000
1002
1002
1100
1101
1102
1000
1100
1200
000 #00010
T000
1101
1101
1201
001 #00020
T001
1102
1102
1202
002 #00030
Chapter 2 Instructions
T002
1100
1001
0001
1203
0002
1204
0003
1205
1200
1203
0500
1201
1204
0501
1202
1204
0502
3-91
12
MEMSW
MEMSW:
Memory Switch
FUN
ANL ORB
MEMSW
$nnnn
Key operation
FUN
ANL
ORB
ENT
R-SRCH
Operand
ENT
R-SRCH
Operands
$0000 to $FFFF
Example
MEMSW
$3800
Coding
Line No.
Instruction
Operand
0000
MEMSW
$3800
Specify 3 of SW3 and 0 and 1 of SW4 to reset the values of DM1900 to DM1999, counter,
up-down counter, CTH, and CTC when the operation is started.
Description
Switch Nos. and functions are as follows. The switch consists of 16 bits. The function of the switch is specified by turning a certain bit ON or OFF.
2
SW4
SW3
SW2
SW1
MEMSW
$3800
3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
0 0 1 1
1 0 0 0
0 0 0 0
0 0 0 0
Switch
Function of switch
No.
0
Cancels error when power is ON.
1
1
2
2
3
0
1
2
3
0
1
2
3
0
3-92
Chapter 2 Instructions
ON
Retains error.
OFF
Cancels error and
starts operation.
Doesn't use
latch function.
Doesn't use
latch function.
Clears DM.
Clears DM.
24-bit
Retains DM.
Retains DM.
24-bit
16-bit
Clears values.
Write-protects
program.
Read-protects
program.
Retains values.
Doesn't writeprotect program.
Doesn't readprotect program.
16-bit
MEMSW
2.4 Instruction Details
Note 1: When a read-protected program is transferred into the KV PLC it cannot
be read or modified from this PLC. Before read-protecting a program, be sure to
create a backup copy of the program.
Note 2: When a 24-bit high-speed counter comparator is used, the ladder program
which specifies the numerical values of a 24-bit CTC is required before starting the
high-speed counter.
Note 3: The value of MEMSW can be changed even during operation. However,
the new operation is not actually performed. The change is effective only after the
KV is turned off or stopped once and then restarted.
Details of MEMSW
Setting memory switches
Specify a hexadecimal number for each switch No.
SW4
SW3
SW2
SW1
(Switch No.)
3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0
(8)
(4)
(2)
(Example)
(1)
23
22
21
20
Hexadecimal number
0 0 0 0
0 0 1 0
0 1 1 0
1 0 0 1
MEMSW
$0269
Hexadecimal
number
12
Tips
Description
The data entered for the memory switch is set into the KV PLC when the program is transferred to the KV PLC.
When MEMSW instruction is not entered into the program, "$0000" is set.
If you try transfer a program into the KV PLC which is write-disabled, warning
message "WRITE PROTECTED REPLACE OK?" is displayed. When executing
the transfer regardless of the message, press ENT
.
R-SRCH
To use internal utility
relays 1000 through
1915 as latch relays.
MEMSW
$0004
To clear a DM when
operation is started.
MEMSW
$0E00
To read-protect a
program.
MEMSW
$8000
MEMSW
$2000
MEMSW
$0800
MEMSW
$1000
Chapter 2 Instructions
3-93
END / ENDH
NOP
2.4 Instruction Details
NOP: No Operation
ORL RES
FUN 3
Performs no operation.
END: End
END
DM
ENDH: End Hi
ENDH
TM
END
ENDH
Description
2
Normal program
END
Normal program
END
Subroutine program
Interrupt program
ENDH
ENDH
Note: When a program does not have END or ENDH, "ENTER END", "ENTER
ENDH" or "LOGIC ERROR" occurs when the program is converted or transferred.
Operands
Key operation
END
DM
3-94
ENT
R-SRCH
Chapter 2 Instructions
ENDH
TM
ENT
R-SRCH
Instruction
Mnemonic
Reference page
W-ON: Wait ON
W-ON
3-96
W-OFF
3-96
W-UE
3-98
W-DE
3-98
CON (FUN06)
3-102
CON: Connect
MPS: Push
MPS
3-103
MRD: Read
MRD
3-103
MPP: Pop
MPP
3-103
STG: Stage
STG (FUN44)
3-106
JMP: Jump
JMP (FUN21)
3-106
END (FUN14)
3-106
STP: Step
STP (FUN45)
3-114
STE (FUN43)
3-114
ITVL
3-117
CTH
3-204
CTC
3-204
CTH
3-204
CTC
3-204
CALL (FUN03)
3-122
SBN (FUN38)
3-122
RET (FUN33)
3-122
FOR (FUN16)
3-125
NEXT (FUN29)
3-125
HKEY (FUN17)
3-131
Chapter 2 Instructions
12
3-95
W-ON / W-OFF
W-ON: Wait ON
W-OFF: Wait OFF
W-ON
nnnn
ON
mmmm
W-OFF
Li
nnnn
OFF
mmmm
Example
0001
ON
1000
0500
0000
1000
0003
OFF
1001
0501
0002
1001
W-ON
W-OFF
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
W-ON
0001 1000
0002
LD
1000
0003
OUT
0500
0004
LD
0002
0005
W-OFF
0003 1001
0006
LD
1001
0007
OUT
0501
Timing chart
W-ON
ON
0000
OFF
ON
0001
OFF
ON
1000
0500
ON
When input relay 0000 is ON, output relay 0500 turns ON as soon as input operand
0001 turns ON. 0500 remains ON until 0000 turns OFF.
W-OFF
ON
0002
0003
OFF
ON
OFF
1001
0501
ON
ON
When input relay 0002 is ON, output relay 0501 turns ON as soon as input operand
0003 turns OFF. 0501 remains ON until 0002 turns OFF.
3-96
Chapter 2 Instructions
W-ON / W-OFF
Description
W-ON
Input operand
0000
Same
operation
0001
ON
1000
0001
0000
1000
1000
Output operand
When input relay 0000 is ON, output operand 1000 turns ON as soon as the
contact of input operand 0001 turns ON.
W-OFF
Input operand
0002
Same
operation
0003
OFF
1001
0003
0002
1001
1001
Output operand
When input relay 0002 is ON, output operand 1001 turns ON as soon as the
contact of input operand 0003 turns OFF.
Note: Output operand relay Nos. for W-ON/W-OFF instructions cannot be duplicated in a program.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
nnnn:
0000 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 9915
nnnn:
0000 to 0009
0500 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
*7000 to 9915
nnnn:
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
mmmm:
1000 to 1915
nnnn:
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or
remote I/O unit ports can be used for internal utility relays.
Key operation
W-ON
W-OFF
Li
First operand
Second operand
ENT
(nnnn)
(mmmm)
R-SRCH
Chapter 2 Instructions
3-97
12
W-UE / W-DE
W-UE
W-DE
Lo
nnnn
mmmm
nnnn
mmmm
Example
0000
0001
1000
1000
0500
0002
0003
1001
1001
0501
W-UE
W-DE
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
W-UE
0001 1000
0002
LD
1000
0003
OUT
0500
0004
LD
0002
0005
W-DE
0003 1001
0006
LD
1001
0007
OUT
0501
Timing chart
W-UE
0000
0001
ON
OFF
ON
OFF
ON
1000
0500
When input relay 0000 is ON, output relay 0500 turns ON at rising edge of first
operand relay 0001.
As soon as input relay 0000 turns OFF, output relay 0500 turns OFF.
W-DE
ON
0002
0003
OFF
ON
OFF
1001
0501
3-98
ON
When input relay 0002 is ON, output relay 0501 turns ON at falling edge of first
operand relay 0003.
As soon as input relay 0002 turns OFF, output relay 0501 turns OFF.
Chapter 2 Instructions
W-UE / W-DE
Description
W-UE
0000
Input operand
Same
operation
0001
1000
1002
DIFU
0001
1002
0000
1000
1000
Output operand
When input relay 0000 is ON, the output operand turns ON at the rising edge of
the input operand.
W-DE
0002
Input operand
Same
operation
0003
1001
1003
DIFD
0003
1003
0002
1001
1001
Output operand
When input relay 0002 is ON, the output operand turns ON at the falling edge of
the input operand.
Note 1: If the input operand is already ON before input relay 0000 turns ON, the
output operand does not turn ON.
Note 2: The W-UE/W-DE instruction must be used in subroutine programs that are
executed every scan time (because rising and falling edges cannot be recognized).
Note 3: Output operand relay Nos. for W-UE/W-DE instructions cannot be duplicated in a program.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
nnnn:
0000 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 9915
nnnn:
0000 to 0009
00500 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
*7000 to 9915
nnnn:
0000 to 6915
0000 to 2915
T000 to T063
CTC0 to CTC3
mmmm:
1000 to 1915
nnnn:
T000 to T119
C000 to C119
CTC0 to CTC3
mmmm:
1000 to 1915
3000 to 6915
Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or
remote I/O unit ports can be used for internal utility relays.
Key operation
W-UE
W-DE
Lo
First operand
(nnnn)
Second operand
ENT
(mmmm)
R-SRCH
Chapter 2 Instructions
3-99
12
W-UE / W-DE
2.4 Instruction Details
0000
0100
1001
0500
1001
0501
ON
0000
OFF
ON
0001
1000
0500
OFF
ON
1001
0501
ON
ON
(W-ON)
(W-UE)
2
W-ON:
Output relay 0500 turns ON when both input relays 0000 and 0001 turn
ON in any order.
W-UE:
Output relay 0501 turns ON only when input relay 0000 turns ON before
input relay 0001.
Note: An input operand relay No. for these instructions can be duplicated in a
program, but output operand relay Nos. cannot be duplicated.
As shown above, W-UE requires a certain order for turning ON relays 0000 and
0001, but W-ON does not. Therefore, W-UE is suitable for circuits to be executed at
every input; W-ON is suitable for circuits that go on to the next operation when a
certain condition is satisfied.
The operation of W-OFF and W-DE instructions are same as above by the operation
which turns relays OFF.
3-100
Chapter 2 Instructions
W-UE
2.4 Instruction Details
0001
1000
1000
0002
Line No.
Instruction
Operand
0000
LD
0000
W-UE
0001 1000
1001
1001
0003
0001
0002
LD
1000
1002
0500
0003
W-UE
0002 1001
1002
0004
LD
1001
0005
W-UE
0003 1002
0006
LD
1002
0007
OUT
0500
Timing diagram
Scan
0000
ON
OFF
0001
ON
OFF
0002
ON
OFF
0003
ON
OFF
12
0500
ON
1001
1000
0500
0001
1000
0000
1001
0501
Leave warehouse
Enter warehouse
1001
Coding
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0000
0005
LD
0001
0001
W-UE
0001 1000
0006
W-UE
0000 1001
0002
CON
0007
CON
0003
AND
1000
0008
AND
1001
0004
OUT
0500
0009
OUT
0501
Timing diagram
Scan
0000
ON
OFF
0001
ON
OFF
0500
0501
ON
ON
Chapter 2 Instructions
3-101
CON
CON: Connect
RES ORB
FUN 0
Example
0500
0000
0501
CON
CON
0502
0503
CON
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OUT
0500
0002
CON
0003
OUT
0004
CON
0005
OUT
0006
CON
0007
OUT
0501
0502
0503
Description
When input relay 0000 turns ON, 0500, 0501, 0502, and 0503 turn ON.
When input relay 0000 turns OFF, 0500, 0501, 0502, and 0503 turn OFF.
The CON instruction is used to connect instructions after output instructions
when the extended ladder is used.
When the LADDER BUILDER for KV programming support software is used, the
CON instruction is automatically converted into a mnemonic and entered in the
ladder diagram by just writing a connection line.
The CON instruction does not affect the scan time.
Refer to "1.5 Extended Ladder Diagrams" (p. 3-29) for details of eetecded ladders.
Operands
Key operation
FUN
3-102
RES
Chapter 2 Instructions
ORB
ENT
ENT
R-SRCH
R-SRCH
MPS: Push
MPS
MRD: Read
MRD
MPP: Pop
MPP
ch
Example
0000
MPS
0001
0500
0002
0501
0003
0502
MRD
MPP
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
MPS
0002
AND
0001
0003
OUT
0500
0004
MRD
0005
AND
0002
0006
OUT
0501
0007
MPP
0008
AND
0003
0009
OUT
0502
12
Description
Operands
Key operation
MPS
MRD
ENT
R-SRCH
MPP
ch
Chapter 2 Instructions
3-103
MPS/MRD/MPP applications
MPS, MRD, and MPP instructions are used as follows:
0002
0003
0004
0500
Start of branch
0006
MPS
0501
Connection of branch
0007
MRD
0502
Connection of branch
0008
MRD
0503
End of branch
MPP
Coding
Line No.
Instruction
Operand
Line No.
0000
LD
0002
0001
AND
0003
0002
MPS
0003
AND
0004
0004
OUT
0500
0005
MRD
0012
AND
0008
0006
AND
0013
OUT
0503
Operand
0000
0002
0500
MPS
0003
0501
MPP
0005
0502
MPS
0006
0503
0001
MPS
0004
0006
MPP
Instruction
Operand
0007
OUT
0501
0008
MRD
0009
AND
0007
0010
OUT
0502
0011
MPP
MPP
Coding
3-104
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
0000
0009
MPP
0001
MPS
0010
AND
0002
AND
0001
0011
MPS
0003
MPS
0012
AND
0005
0004
AND
0002
0013
OUT
0502
0005
OUT
0500
0014
MPP
0006
MPP
0015
AND
0006
0007
AND
0003
0016
OUT
0503
0008
OUT
0501
Chapter 2 Instructions
0004
0001
MPS
0002
MPS
0003
0004
0500
MPS
0501
MPP
0502
0503
MPP
0504
MPP
MPP
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
MPS
0002
AND
0003
MPS
0004
AND
0005
MPS
0001
0002
0006
AND
0007
MPS
0008
AND
0004
0009
OUT
0500
0010
MPP
0011
OUT
0012
MPP
0013
OUT
0014
MPP
0015
OUT
0016
MPP
0017
OUT
0003
12
0501
0502
0503
0504
Chapter 2 Instructions
3-105
STG: Stage
JMP: Jump
ANL SET
nnnn
JMP
SET LDB
ENDS
FUN 2
nnnn
STG
LDB LDB
FUN 4
FUN 1
Example
1000
SET
2008
1)
1000
STG
2)
1001
STG
3)
1002
STG
0000
1001
JMP
0500
0001
1002
JMP
0501
0002
1001
JMP
0003
1000
JMP
Initial setting
1003
JMP
1003
STG
4)
0502
0004
ENDS
2
1) When transition condition relay 0000 is ON, transfers execution to STG1001.
2) 0500 turns ON. When transition condition relay 0001 is ON, transfers execution
to STG1002.
3) 0501 turns ON. When transition condition relay 0002 is ON, transfers execution
to STG1001 and repeats the process above.
When transition condition relay 0003 turns ON, transfers execution to STG1000
and 1003.
4) 0502 turns ON. The process finishes when transition condition relay 0004 turns
ON.
Coding
3-106
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
2008
0013
MPS
Operand
0001
SET
1000
0014
AND
0002
1001
0002
STG
1000
0015
JMP
0003
AND
0000
0016
MPP
0004
JMP
1001
0017
AND
0003
0005
STG
1001
0018
JMP
1000
0006
OUT
0500
0007
CON
0008
AND
0009
0010
0011
OUT
0012
CON
Chapter 2 Instructions
0019
JMP
1003
0020
STG
1003
0001
0021
OUT
0502
JMP
1002
0022
CON
STG
1002
0023
AND
0501
0024
ENDS
0004
Function
Turned OFF.
Turned ON.
Reset.
Other instructions
Not executed.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
1000 to 1915
3000 to 9915
1000 to 1915
3000 to 6915
*7000 to 9915
1000 to 1915
1000 to 1915
12
Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or
remote I/O unit ports can be used for internal utility relays.
Key operation
FUN
LDB
FUN
ANL
FUN
SET
4
2
1
LDB
SET
LDB
ENT
Operand
ENT
R-SRCH
(nnnn)
R-SRCH
ENT
Operand
ENT
R-SRCH
(nnnn)
ENT
ENT
R-SRCH
R-SRCH
R-SRCH
Chapter 2 Instructions
3-107
STG
These five steps are sequentially performed in order as shown in the flowchart
below.
If a ladder program is written for such sequential processing without any STG
instructions, the resulting program may be complicated and difficult to review by
others.
Sequential processing
Start
Start
SW ON?
NO
YES
Turn on lamp 1
for 1 second.
Turn on lamp 2
for 3 second.
Turn on lamp 3
for 5 second.
Turn on lamps 1, 2,
and 3 simultaneously
for 7 seconds.
I/O assignments
Assign the input and output of the Visual KV Series as follows:
1)
2)
3)
4)
KV
0000
0500
Start SW
Lamp 2
0501
Lamp 3
COM
3-108
Chapter 2 Instructions
0502
COM
STG
The following is the ladder diagram for the I/O assignments above, and is written
with and without STG instructions.
1000
T000
#00010
T000
1000
T000
1001
T001
#00030
T001
1001
T001
1002
T002
#00050
T002
1002
T002
1100
T003
1101
1100
1102
12
#00070
T003
T003
1000
SET
1000
0500
1100
0501
1001
1101
0502
1002
1102
2008
1001
STG
0000
1002
STG
0500
#00010
T000
T000
1002
JMP
0501
#00030
T001
T001
1003
JMP
1003
STG
0502
#00050
T002
T002
1004
JMP
1004
STG
0500
0501
0502
#00070
T003
T003
1001
JMP
Chapter 2 Instructions
3-109
STG
2008
0000
1100
1001
JMP
0500
1100
0000
1101
1002
JMP
0501
1101
0000
1102
1003
JMP
0502
1102
0000
1103
1004
JMP
0500
1103
0501
0502
0000
1104
1000
STG
1001
STG
1002
STG
1003
STG
1004
STG
1000
JMP
1104
Description
When using the W-UE instruction in a program with STG instructions on the previous page, you can create a program for an operation which moves to the next stage
every time when start switch 0000 turns ON (process progression).
Tips
Resetting STG instructions (in the above example)
Use the SFT instruction to turn OFF all STG instructions in an emergency.
SFT
2003
D
2003
1000
1004
CLK
Reset input
RES
Reset input
1000
SET
Initial setting
Enter the initial setting process depending on the program. The above example
cannot start the next operation without the initial setting.
Note 1: The scan time is not affected by any instructions between STG and JMP/
ENDS instructions which are not executed.
Note 2: STG operand relay Nos. cannot be duplicated in a program.
Note 3: The STG instruction must be connected to the bus.
Note 4: The STG, JMP, or ENDS instruction cannot be used in subroutines.
3-110
Chapter 2 Instructions
STG
0501
0500
0001
1001
JMP
1001
STG
0500
0501
0002
1002
JMP
Interlock
Double coil
A double coil can be used for an STG instruction.
1000
STG
0500
1001
STG
0501
1002
STG
0500
0001
ON
1100
0002
ON
1101
0003
ON
1102
1100
1001
JMP
1101
1002
JMP
1102
1003
JMP
Double coil
Note: When STG 1000 and 1002 turn ON simultaneously, priority is given to output
relay 0500 of STG 1002, which is entered last.
Retaining output
Use the SET instruction to retain output.
1000
STG
0500
SET
0000
1001
JMP
1001
STG
0501
SET
0001
1002
JMP
12
0500
0001
0501
STG operand
When the STG operand relay remains ON, 0500 does not turn OFF even if 0001
turns ON.
0000
1000
STG
1000
SET
0500
0001
1001
JMP
Use a differentiation type instruction for the condition of the first STG instruction.
0000
1100
DIFU
1100
1000
SET
1000
STG
0500
0001
1001
JMP
Chapter 2 Instructions
3-111
STG / JMP
0001
0500
1001
JMP
1002
JMP
1001
STG
0002
0501
1002
JMP
3000
DIFU
0001
0500
3000
1001
JMP
0501
0000
1100
DIFU
1000
STG
1100
1000
SET
0500
#00010
T000
T000
1001
JMP
1002
JMP
1001
STG
0500
0501
#00020
T001
T001
1002
STG
0500
0501
0502
#00030
T002
T002
1000
JMP
Coding
3-112
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
0000
0016
CON
0001
DIFU
1100
0002
CON
0003
AND
1100
Operand
0017
TMR
0018
CON
001 #00020
0019
AND
T001
0004
SET
1000
0020
JMP
1002
0005
STG
1000
0021
STG
1002
0006
OUT
0500
0500
0007
CON
0008
TMR
0009
CON
0010
0022
OUT
0023
CON
000 #00010
0024
OUT
0025
CON
AND
T000
0026
OUT
0011
JMP
1001
0027
CON
0012
STG
1001
0028
TMR
0013
OUT
0500
0029
CON
0014
CON
0030
AND
T002
0015
OUT
0031
JMP
1000
Chapter 2 Instructions
0501
0501
0502
002 #00030
STG / JMP
1100
DIFU
1100
1000
SET
1000
STG
0500
0001
1001
JMP
0002
1002
JMP
1001
STG
0501
#00010
T000
T000
1000
JMP
1002
STG
0502
#00020
T001
T001
1000
JMP
Coding
Line No.
Instruction
12
Operand
0000
LD
0000
0001
DIFU
1100
0002
CON
0003
AND
1100
0004
SET
1000
0005
STG
1000
0006
OUT
0500
0007
CON
0008
MPS
0009
AND
0001
0010
JMP
1001
0011
MPP
0012
AND
0002
0013
JMP
1002
0014
STG
1001
0015
OUT
0501
0016
CON
0017
TMR
0018
CON
000 #00010
0018
AND
T000
0020
JMP
1000
0021
STG
1002
0022
OUT
0502
0023
CON
0024
TMR
0025
CON
001 #00020
0026
AND
T001
0027
JMP
1000
Chapter 2 Instructions
3-113
STP / STE
LDB ANB
LDB ORL
FUN 4
STP: Step
STE: Step End
FUN 4
5
3
STP
nnnn
STE
Example
1000
0000
STP
1000
0500
0001
STE
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
OUT
1000
0002
STP
1000
0003
LD
0001
0004
OUT
0500
0005
STE
Description
When 1000 is ON, 0500 turns ON/OFF as soon as 0001 turns ON/OFF.
When 1000 is OFF, 0500 remains OFF after 0001 turns ON. When 0001 and
0500 are ON, 0500 remains ON after 0001 turns OFF.
STP
1000
STE
B
STP
Fig. 1
1000
1)
STP
1001
2)
STE
3)
STE
4)
Fig. 2
3-114
Chapter 2 Instructions
STP / STE
Tips
Operation when STP turns OFF
Using a timer in an STP block
When a timer is used in a program defined with an STP instruction, the operation is
as follows:
a) 1000 is reset immediately when the
timer turns ON. The STE instruction is
started with the timer remaining ON.
a)
0000
Scan
1000
SET
STP
1000
T000
0500
1000
#00050
T000
T000
1000
RES
Timer
remains
ON.
Jump
STE
b)
0000
Scan
1000
SET
STP
1000
T000
1000
RES
T000
0500
1000
#00050
T000
Timer
remains
ON.
Timer is reset.
Jump
STE
0000
1000
STG
0500
0001
1001
JMP
0002
1002
JMP
1001
STG
0501
0003
1002
STG
0502
0004
ENDS
ENDS
STP instruction
Use the STP instruction for process progression without branches.
1000
SET
0000
STP
1000
0002
1000
RES
1001
SET
0500
0001
STE
STP
1001
0003
0004
1001
RES
1002
SET
0501
STE
Chapter 2 Instructions
3-115
12
STP / STE
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
T000 to T249
C000 to C249
CTC0 to CTC3
0000 to 0009
0500 to 6915
*7000 to 9915
T000 to T249
C000 to C249
CTC0 to CTC3
0000 to 2915
T000 to T063
C000 to C063
CTC0 to CTC3
0000 to 6915
T000 to T119
C000 to C119
CTC0 to CTC3
Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or remote I/O
unit ports can be used for internal utility relays.
Key operation
FUN
LDB
FUN
LDB
4
4
ANB
ORL
ENT
R-SRCH
Operand
(nnnn)
ENT
ENT
R-SRCH
R-SRCH
ENT
R-SRCH
2
0000
1000
DIFU
1000
1001
SET
STP
1001
T000
1001
RES
T000
0500
1001
#00020
T000
T000
1002
SET
STE
STP
1002
T001
1002
RES
T001
0501
1002
#00030
T001
STE
END
ENDH
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
3-116
Chapter 2 Instructions
Instruction
LD
DIFU
CON
AND
SET
STP
LD
RES
LDB
OUT
LD
TMR
LD
SET
STE
STP
LD
RES
LDB
OUT
LD
TMR
STE
END
ENDH
Operand
0000
1000
1000
1001
1001
T000
1001
T000
0500
1001
000 #00020
T000
1002
1002
T001
1002
T001
0501
1002
001 #00030
ITVL
ITVL
#TM
ITVL
PLS
DMnnnn
PAUSE
mmmm
RES
Example
"Pulse" input
ITVL
PLS
0000
DM0000
0001
PAUSE
1000
0002
RES
"Reset" input
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
LD
0001
0002
LD
0002
0003
ITVL
DM0000 1000
PAUSE
Pauses the measurement when turned ON.
RES
Initializes the contents of data memory (DM) when turned ON.
In the above example, DM0004 to DM0015 are reset to "#00000".
DM0000 to DM0003 are designated as the area to write the initial setting.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
ITVL
#TM
First operand
Second operand
ENT
(nnnn)
(mmmm)
R-SRCH
Chapter 2 Instructions
3-117
12
ITVL
Setting procedure
The ITVL instruction reserves 16 data memories: 1 specified data memory and 15
successive data memories. It also reserves 4 relays: 1 specified relay and 3 successive relays.
Note: Do not use the 16 data memories and 4 relays specified with the ITVL instruction for any other purpose.
Data memory (DM) assignment
Set the initial setting data to the first four data memories.
Data memory
DM XX + 00
01
02
Mode
MAX value
MIN value
04
Preset No.of
measurements
Measured value
05
06
07
Mean
08
No.of measurements
performed*
09
Higher digits*
10
Lower digits*
11 to 12
Work memory
03
Initial
setting
is to be
specified
by user.
Relay assignment
Relay
MAX error
MIN error
+2
Every
measurements
completion
+3
Measurements
completion for
mean calculation
Relay +0
+1
3-118
Chapter 2 Instructions
ITVL
Pulse width
Unit
10 m sec
10 m sec
100 m sec
100 m sec
1 sec
1 sec
Example
Write "#0006" to obtain the average of the contents of DM0006.
Mode No.
DM No.
Description
10000
DM0000
10001
DM0001
10005
DM0005
10006
DM0006
0007
10007
DM0007
1999
11999
DM1999
0006
2000 to 9999
Note 1: When the mode No. is set to 10000 through 11999, values are fetched at
the scan only when the PLS input relay is ON.
Note 2: When the average of a data memory is calculated, values "32768" to
"65535" are converted into corresponding compliment numbers (-32767 to -1) .
Note 3: Some data memories after DM1000 are assigned to special functions. Be
careful when specifying data memory for the ITVL instruction.
Refer to "1.3.10 Data Memories" (p. 3-19) for data memory assignments.
Chapter 2 Instructions
3-119
12
ITVL
#00000 DM0000
Sets mode 0 (Unit:10 ms).
LDA
STA
2008
#00051 DM0001
Sets max. setting value of measurement range to 510 ms.
LDA
STA
2008
#00049 DM0002
Sets min. setting value of measurement range to 490 ms.
LDA
STA
2008
#00010 DM0003
LDA
STA
Sets number of averaging measurements to 10.
ITVL
0000
PLS
0001
PAUSE
RES
1000
0002
1000
DM0000
0500
T000
1001
#00030
T000
0500
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
Instruction
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
Operand
2008
#00000
Line No.
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
DM0000
2008
#00051
DM0001
2008
#00049
DM0002
2008
Instruction
Operand
LDA
#00010
CON
STA
DM0003
LD
0000
LD
0001
LD
0002
ITVL
DM0000 1000
LD
1000
OR
1001
OR
0500
ANB
T000
OUT
0500
TMR
000 #00030
Timing diagram
0000
ON
OFF
500ms
400ms
600ms
1000
ON
1 scan
1001
ON
1 scan
0500
ON
3 sec.
3-120
Chapter 2 Instructions
ON
3 sec.
ITVL
#01600 DM0000
LDA
STA
2008
#02000 DM0001
Sets max. setting value to +3 V (2000).
LDA
STA
2008
#01000 DM0002
Sets min. setting value to +2 V (1000).
LDA
STA
2008
#00100 DM0003
Sets number of averaging measurements to 100.
LDA
STA
ITVL
2003
PLS
DM0000
0001
PAUSE
1000
0002
12
RES
1000
0500
0500 turns ON when measured value exceeds max. setting value.
0501
1001
1003
DM0007 DM0100
LDA
STA
Writes average into DM0100 every 100 measurement.
Coding
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
2008
0014
CON
Operand
0001
LDA
#01600
0015
STA
DM0003
0002
CON
0003
STA
0016
LD
2003
DM0000
0017
LD
0001
0004
LD
2008
0018
LD
0002
0005
LDA
#02000
0019
ITVL
DM0000 1000
0006
CON
0020
LD
1000
0007
STA
DM0001
0021
OUT
0500
0008
LD
2008
0022
LD
1001
0009
LDA
#01000
0010
CON
0011
STA
0012
LD
0013
LDA
#00100
0023
OUT
0501
0024
LD
1003
DM0002
0025
LDA
DM0007
2008
0026
STA
DM0100
Chapter 2 Instructions
3-121
FUN 3
nn
CALL
SBN
nn
RET
Example
00
CALL
0000
END
SBN
00
RET
ENDH
Coding
Line No.
0000
:
:
:
:
:
:
:
:
:
Instruction
:
:
LD
CALL
:
END
SBN
:
RET
ENDH
Operand
:
:
0000
00
:
:
00
:
:
:
Description
When input relay 0000 turns ON, the subroutine specified by SBN00 and RET is
executed. When the subroutine ends, instructions following CALL are executed.
When the input relay is ON, the CALL instruction executes the subroutine specified by the operand.
A subroutine program must be defined between the SBN and RET instructions.
A subroutine must be defined between END and ENDH instructions.
Once a CALL instruction has been encountered, program execution transfers to
the subroutine specified by the SBN and RET instructions. Once a RET instruction has been encountered, program execution returns to the instruction immediately following the CALL instruction.
Operand
CALL
00 to 99
SBN
00 to 99
RET
Key operations
3-122
FUN
RES
ORL
AND
R-SRCH
FUN
ORL
FUN
ORL
ORL
ENT
ENT
R-SRCH
R-SRCH
0
3
3
ENT
Operand
Chapter 2 Instructions
ENT
R-SRCH
Application of subroutine
Program
A)
00
CALL
2008
Normal scan
Program
B)
END
SBN
00
Subroutine program
Subroutine
RET
ENDH
A)
A)
12
00
CALL
0000
Program
00
CALL
0000
Program
B)
Subroutine program
B)
0001
Program
END
SBN
01
Subroutine program
RET
SBN
00
0000
01
CALL
Call
RET
ENDH
Chapter 2 Instructions
3-123
0001
Program
END
SBN
00
Subroutine program
RET
INT
0000
0002
00
CALL
Call
RETI
ENDH
3-124
Chapter 2 Instructions
FOR / NEXT
ANL OR
FUN 1
FUN 2
6
9
FOR
nnnn
NEXT
Example
2008
00
CALL
END
SBN
00
#00100
LDA
2002
TM02
STA
2002
STA
#00000
LDA
FOR
#00050
TM02
INC
NEXT
RET
12
ENDH
Coding
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0001
CALL
2008
0107
FOR
#00050
00
0108
LD
2002
0109
STA
#TM02
0099
END
0100
SBN
0110
CON
0111
INC
00
0101
LD
2002
0112
NEXT
0102
LDA
#00100
0113
RET
0103
CON
0104
STA
0105
CON
0106
LDA
TM02
:
TM02
:
:
#00000
0199
ENDH
Description
Use FOR-NEXT instructions in a subroutine program (between SBN and RET) to
initialize data memory (DM0100 through DM0149) when the operation is started.
The indirect addressing method is used to change the data memory, so the initialization is completed when the TM02 value becomes "50 + 1" between the FOR and
NEXT instructions.
The FOR instruction takes either of the following two types of operands: the
number of repetitions or the location (DM No.) of the data memory containing the
number of repetitions.
Define the program to be repeated between the FOR and NEXT instructions.
The FOR instruction repeats the desired sequence by the specified number of
times during each scan time.
Chapter 2 Instructions
3-125
FOR / NEXT
Tips
Note 1: The FOR-NEXT instruction pair repeats the program for a specified time
period at each scan. It usually is used in steps or subroutines.
Note 2: When a large number of loops or long programs are defined between FOR
and NEXT instructions, the processing time for one scan may become too long,
resulting in "Cycle time error". In such a case, reduce the number of loops or shorten
the ladder program.
The FOR-NEXT instruction set can be nested up to 8 levels deep. Nine or more
nested levels will result in a FOR-NEXT error.
FOR
#05
FOR
#02
FOR
#05
1) 2) 3)
NEXT
NEXT
NEXT
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
FUN
FUN
3-126
SET
ORB
ANL
Chapter 2 Instructions
OR
ENT
R-SRCH
Operand
ENT
ENT
R-SRCH
R-SRCH
ENT
R-SRCH
FOR / NEXT
Indirect addressing
Indirect addressing
Indirect addressing is used to so you don't have to use fixed data memories or relay
Nos. when the contents of data memory or a relay is stored in internal registers, or
when the contents of the internal memory is stored in data memory or a relay.
Method for indirect addressing
Specify the operand for instructions as "#TMxx". The contents of "TMxx" is
considered to be the specification No. (indirect addressing).
Example
When TM02 value is "0000", "#TM02" represents DM0000.
When TM02 value is "10000", "#TM02" represents 0000 (relay).
20
DM0020
11000
1000 to 1015
This is the same operation whether "LDA DM0020" or "LDA 1000" is specified. The
specified data memory or relay can be changed as desired by changing the value of
TM15.
Example: STA #TM02
TM02 value
Specified destination
00
DM0000
13000
3000 to 3015
This is the same operation whether "STA DM0000" or "STA 3000" is specified. The
specified data memory or relay can be changed as desired by changing the value of
TM02.
Range of DM and relay Nos. that can be specified by "TMxx"
TMxx value
DM/relay
0000 to 1999
DM0000 to DM1999
2000 to 9999
Cannot be used.
10000 to 27915
0000 to 17915
Chapter 2 Instructions
3-127
12
FOR / NEXT
DM0000
DM0099
DM0100
DM0199
Comparison between a program with normal addressing and one with indirect
addressing.
0000
1000
DIFU
0000
1000
DIFU
1000
DM0000 DM0100
LDA
STA
1000
00
CALL
1000
DM0001 DM0101
LDA
STA
1000
DM0002 DM0102
LDA
STA
1000
DM0003 DM0103
LDA
STA
1000
DM0098 DM0198
LDA
STA
1000
DM0099 DM0199
LDA
STA
Program steps
are reduced by
one-eighth.
No. of data
memory to be
transferred.
SBN
00
2002
2002
#00000
LDA
#TM02
LDA
TM02
STA
#TM03
STA
#00100
LDA
TM02
INC
TM03
STA
1)
FOR
#0100
2)
TM03
INC
3)
NEXT
RET
ENDH
ENDH
4)
Chapter 2 Instructions
END
END
3-128
FOR / NEXT
Description
On line 1), "TM02" is assigned to the first No. of the source 0000 and "TM03" is
assigned to the first No. of the destination 0100. This is the initial setting.
On lines 2) to 4), the contents of DM0000 to DM0099 are transferred to DM0100
to DM0199.
The ladder program on line 3) is executed 100 times in one scan.
#TM02
LDA
#TM03
STA
DM0000 is
indirectly
addressed.
DM0100 is
indirectly
addressed.
TM02
INC
Add "1" to the
current value of
"TM02".
TM03
INC
Add "1" to the
current value of
"TM03".
#TM03
STA
DM0001 is
indirectly
addressed.
DM0101 is
indirectly
addressed.
TM02
INC
Add "1" to the
current value of
"TM02".
TM03
INC
Add "1" to the
current value of
"TM03".
2002
12
#TM02
LDA
#TM03
STA
DM0099 is
indirectly
addressed.
DM0199 is
indirectly
addressed.
TM02
INC
Add "1" to the
current value
of "TM02".
TM03
INC
Add "1" to the
current value
of "TM03".
When the ladder program on line 3) is repeated 100 times, the contents of the
specified DM block are transferred.
Chapter 2 Instructions
3-129
FOR / NEXT
#00010 TM02
LDA
STA
Shift start DM
No. (DM0010)
is designated.
1000
#00030 TM03
LDA
STA
Shift end DM
No. (DM0030)
is designated.
00
CALL
END
SBN
00
TM03
LDA
2002
#00001
ADD
TM04
STA
TM02
SUB
TM05
STA
Shift level
TM03
DEC
2002
2002
TM04
DEC
#TM03 #TM04
LDA
STA
Indirect addressing is used
to designate DM Nos.
#00000 #TM02
LDA
STA
Shift start DM No. is cleared to
"#00000" after data is shifted.
FOR
TM05
NEXT
RET
ENDH
Coding
3-130
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0000
0020
STA
TM04
0001
DIFU
1000
0021
CON
0002
CON
0003
AND
1000
0004
LDA
#00010
0005
CON
0006
STA
0007
CON
0008
LDA
0009
CON
0010
STA
TM02
#00030
TM03
0022
SUB
0023
CON
TM02
0024
STA
TM05
0025
FOR
TM05
0026
LD
2002
0027
DEC
TM03
0028
CON
0029
DEC
0030
CON
0011
CON
0012
CALL
0013
END
0033
STA
0014
SBN
00
0034
NEXT
0015
LD
2002
0035
LD
2002
0016
LDA
TM03
0036
LDA
#00000
0017
CON
0037
CON
0018
ADD
0019
CON
Chapter 2 Instructions
00
#00001
0031
LDA
0032
CON
TM04
0038
STA
0039
RET
0040
ENDH
#TM03
#TM04
#TM02
HKEY
SET LD
FUN 1
Reads hexadecimal key data on timesharing basis and outputs these data to
special utility relays 2900 to 2915.
HKEY
nnnn
mmmm
Input relay
Example
HKEY
0000
0500
0005
Output relay
Coding
Line No.
Instruction
Operand
0000
LD
0005
0001
HKEY
0000 0500
Description
When input relay 0005 turns ON, the operand hexadecimal key data is read.
HKEY instruction employs four inputs and four outputs arranged as shown below.
Refer to "Fetching 16-key input" (p. 3-133) for the programming example.
12
24
VDC
COM
000
COM
500
002
003
502
503
The HKEY instruction employs four input relays and four output relays from the
specified number.
Inputs are processed on a time-sharing basis, so that input processing requires 8
scan time cycles (approx. 160 msec when the scan time is 20 msec or less).
When a hexadecimal key is pressed, the HKEY instruction turns ON the corresponding special utility relay (2900 to 2915).
Relay No. 2900
Hex key
001
KV
501
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
The special utility relay status indicates whether two or more keys can be
pressed simultaneously or whether a key input read operation has completed, as
shown in the following table:
Relay No.
Status
R: Reading
2814 R/W
ON: Pressing two or more keys
simultaneously is not valid.
2815 R
ON: Key input read operation has
completed.
W: Writing
Chapter 2 Instructions
3-131
HKEY
Operands
Visual KV
KV-300
KV-10/16/24/40/80
Input relay Output relay Input relay Output relay Input relay Output relay
0000 to
0415
0500 to
0915
00000 to
00009
10000 to
10415
:
17000 to
17415
00500 to
00503
10500 to
10915
:
17500 to
17915
0000 to
0415
0500 to
0915
Key operation
FUN
SET
LD
ENT
R-SRCH
Input relay
Output relay
ENT
R-SRCH
0001
#09999
C000
0000
C000
0600
2900
LDA
HKEY
0104
0512
C000
STA
0005
2815
TBIN
END
ENDH
Instruction
Operand
LD
2002
ANB
0001
C
000 #09999 0000
CON
AND
C000
OUT
0600
LD
0005
HKEY
0104 0512
LD
2815
LDA
2900
CON
TBIN
CON
STA
C000
END
ENDH
As soon as 0005 turns ON, the preset value is replaced with the new preset
value specified by the digital switches.
The digital switches are connected to the KV PLC as shown in the following
diagram: (Be sure to add the diodes at the specified points.)
The preset values range from #0000 to #9999.
The preset value is updated as soon as special utility relay 2815 turns ON.
3-132
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
Chapter 2 Instructions
HKEY
100
101
102
103
Diode
24
VDC
COM
1
0104
COM
0512
2
0105
KV
0513
4
0106
8
0107
0514
0515
2814
SET
2002
HKEY
0000
0500
TM06
STA
2815
2900
LDA
2010
$03FF
ANDA
TM05
CMP
2010
TM05
STA
2815
2900
LDA
2010
$03FF
ANDA
TM05
CMP
2010
TM05
STA
DM0000
LDA
#04
SLA
2815
DMX
12
TM06
STA
DM0000
STA
#00000
DW
DM0000
END
2915
ENDH
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
Instruction
LD
SET
LD
HKEY
LD
LDA
CON
ANB
ANDA
CON
CMP
CON
ANB
STA
CON
DMX
CON
STA
LD
LDA
Operand
2008
2814
2002
0000 0500
2815
2900
2010
$03FF
TM05
2010
TM05
TM06
2815
2900
Line No.
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
Instruction
Operand
CON
AND
2010
ANDA
$03FF
CON
CMP
TM05
CON
ANB
2010
STA
TM05
CON
LDA
DM0000
CON
SLA
#04
CON
ORA
TM06
CON
STA
DM0000
LD
2815
AND
2915
DW
#0000 DM0000
END
ENDH
Chapter 2 Instructions
3-133
3-134
Instruction
Mnemonic
DW
3-136
Trimmer In
3-138
LDA/@LDA: Load A
3-140
STA/@STA: Store A
3-140
CMP/@CMP: Compare
3-146
ADD/@ADD: Add
3-150
SUB/@SUB: Subtract
3-150
MUL/@MUL: Multiply
3-150
DIV/@DIV: Divide
3-150
ANDA/@ANDA: And A
3-159
ORA/@ORA: Or A
3-161
EORA/@EORA: Exclusive Or A
3-164
3-166
3-166
3-169
3-169
COM/@COM: Complement
3-171
3-172
3-172
MPX/@MPX: Multiplexer
3-176
DMX/@DMX: Demultiplexer
3-176
3-180
3-180
3-183
3-183
3-185
Chapter 2 Instructions
Reference page
Internal register
KV executes all arithmetic instructions (i.e. data exchange) by using an internal
register, in order to increase the processing speed.
This section begins by describing details of the internal register.
Internal register
An internal register stores 16-digit binary data. That is, the resister uses 16 bits for
storing ON-OFF status data (1-0 status data). The internal register is required when
the KV performs arithmetic operation. Because this is not an instruction nor operand,
it is not necessary to take into consideration how the internal register functions or
operates.
Arithmetic instructions executed using internal register
(Arithmetic instructions executed as binary code.)
Data memory,
temporary
memory
Constant 3. 4.
(decimal,
hexadecimal)
Current T/C
value. 2.
Relay No.1.
LDA instruction
TMIN
D15
D14
D13
D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
STA direction
Relay No
Preset T/C
value. 5.
Data memory,
temporary
memory
MPX
DMX
TBCD
TBIN
ASC
RASC
Constant
Data memories,
temporary memories
Internal register
CMP
ADD
SUB
MUL
DIV
ANDA
ORA
EORA
SRA
SLA
RRA
RLA
COM
INC
DEC
1. ON-OFF status of the specified relay and 15 successive relays is stored into the
resister.
2. Current T/C value (decimal value = #*****) is automatically converted into a
binary value and input to the internal register.
3. Constant (decimal value = #*****, hexadecimal value = $****) is automatically
converted into a binary value and input to the internal register.
4. The range of numbers that can be specified is as follows:
Decimal #00000 to #65535
Hexadecimal $0000 to $FFFF
The constants can be entered by using #,@$ and the corresponding alphanumeric
keys.
(Pressing #,@$ once allows you to enter decimal values, and pressing twice to enter
hexadecimal values.)
5. The contents of the internal register (binary) is automatically converted into a
decimal value and (#*****) input to a timer/counter as the preset value.
Note 1: The internal structure of the internal register is the same as that of the data
memories. Although the data memories can store data when the power is being
OFF, the internal register cannot do so.
Note 2: Even for running one program, the contents of the internal register is rewritten each time when an instruction is executed.
Note 3: The internal register cannot be monitored.
Chapter 2 Instructions
3-135
12
DW
2.4 Instruction Details
DW
nnnn
DW
DMmmmm
Example
First operand
$0018 #00050
DW
DW
DM0000 DM0001
2008
Second operand
Coding
Line No.
Instruction
Operand
0000
LD
2008
0001
DW
$0018 DM0000
0002
CON
0003
DW
#00050 DM0001
When starting operation, $0018 is written into DM0000 and #00050 into DM0001.
Values are directly written into data memories, without using the internal register.
Description
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
D9
D8
D7
D6
D5
D4
D3
D2
D1
D0
Operand
Data memory
Note: The contents of the internal register and the arithmetic flag do not change
even after the DW instruction is executed.
Tips
#00000 #00000
DW
DW
DM0000 DM0001
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
nnnn:
nnnn
nnnn
nnnn
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
$0000 to $FFFF
$0000 to $FFFF
$0000 to $FFFF
$0000 to $FFFF
DM mmmm:
DMmmmm
DMmmmm
DMmmmm
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999
Key operation
DW
reraly
First operand
Second operand
ENT
R-SRCH
Arithmetic flag
2009, 2010, 2011
2012
3-136
Chapter 2 Instructions
No change
No change
@xxxx
2.4 Instruction Details
@xxxx: Differentiation
#,$ FUN
xxxx
Example
Every-scan type instruction
DM0000
INC
0000
DM0000
INC
0000
Description
Arithmetic instructions have two instruction types: differentiation type and everyscan type.
The differentiation type instruction is executed only at the rising edge of input
relay 0000.
The every-scan type instruction is executed every scan time while input relay
0000 is ON.
Timing diagram
Differentiation type instruction
ON
OFF
0000
INC
0000
Stopped
Executed
Stopped
INC
ON
OFF
Stopped
12
Stopped
Note:
0000
DM0000
INC
0000
DM0000
INC
0000
1000
DIFU
1000
DM0000
INC
Operands
Key operation
#,$
FUN
Function No.
ENT
R-SRCH
Chapter 2 Instructions
3-137
TMIN / @TMIN
2.4 Instruction Details
ANB RES
TMIN: Trimmer In
FUN 5
@
#,$ FUN
ANB RES
n
TMIN
n
TMIN
T000 preset value can be changed with trimmer as follows (#00000 to #65535):
Inputs trimmer rotation angle of 0 to internal register.
Transfers contents of internal register to timer T000
for use as preset value.
2002
0
TMIN
0000
#00010
T000
T000
STA
T000 0500
Turns ON output 0500 when current value of
T000 reaches "#00000".
Timer T000 operates as ON-delay timer when 0000 is ON.
Coding
Line No.
0000
0001
0002
0003
0004
Instruction
LD
TMIN
CON
STA
LD
Operand
2002
0
T000
0000
Line No.
0005
0006
0007
0008
Instruction
TMR
CON
AND
OUT
Operand
000 #65535
T000
0500
Description
The TMIN instruction transfers the value of the KV series digital trimmer (0 to
65535) to the internal register. Additionally, if this value is transferred to a timer,
counter, relay, or data memory (by using the STA instruction), the numeric data of
the destination can be changed without modifying the program.
Internal
register
TMIN
Digital trimmer
value of access
window [0 to 65535]
Input
STA
Transfer
Numeric data
0 to 65535
Timer/counter preset
value
Relay ch No.
Data memory
Temporary memory
Destination
Note: To check the setting value of the digital trimmer with the KV-P3E(01)
handheld programmer, select the "READ TRIMMER SETTING" function (FUN73).
(Only values 0 to 9999 can be displayed.)
The @TMIN instruction is executed only once at the rising edge of the input relay.
Refer to "Chapter 3: Access Window" on page 1-79 for the functions and operation
procedures for the digital trimmer of the Access Window.
Operands
Visual KV
KV-300/24/40/80
KV-10/16
0, 1
0, 1
Key operation
FUN
@
Arithmetic flag
#,$
ANB
FUN
2009
2010
RES
ENT
R-SRCH
Operand
ENT
R-SRCH
No change
Turns ON when "0" is entered by the TMIN instruction. Turns
OFF at other times.
2011, 2012 No change
3-138
Chapter 2 Instructions
TMIN / @TMIN
2.4 Instruction Details
2002
T000
STA
#00010
T000
0000
T000
0500
0500
Coding
Line No.
0000
0001
0002
0003
0004
Instruction
LD
TMIN
CON
STA
LD
Operand
2002
0
T000
0000
Line No.
0005
0006
0007
0008
Instruction
OR
TMR
ANB
OUT
Operand
0500
000 #00010
T000
0500
0
TMIN
T000
STA
T001
STA
T002
STA
#00010
T000
0000
0500
T000
0500
#00010
T001
0001
T001
0501
0501
#00010
T002
0002
T002
0502
0502
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
TMIN
CON
STA
CON
STA
CON
STA
LD
OR
TMR
ANB
Operand
2002
0
T000
T001
T002
0000
0500
000 #00010
T000
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
Instruction
OUT
LD
OR
TMR
ANB
OUT
LD
OR
TMR
ANB
OUT
Operand
0500
0001
0501
001 #00010
T001
0501
0002
0502
002 #00010
T002
0502
In the above example, T000, T001, and T002 have the same setting value.
Chapter 2 Instructions
3-139
12
ANL ORL
FUN 2
LDA: Load A
#,$ FUN
@LDA: Load A
@STA: Store A
LDB ORL
nnnn
STA
LDB ORL
@
#,$ FUN 4
3
nnnn
STA
FUN 4
STA: Store A
nnnn
LDA
ANL ORL
The LDA instruction inputs each data item to the internal register.
The STA instruction transfers the contents of the internal register to the specified
destination.
Source
T/C current
value
Decimal
Hexadecimal
T
C
Relay No.
LDA
XXXX
XX
STA
T
C
Data memory DM
Temporary memory TM
Relay No.
Operands
Visual KV
LDA
STA
0000 to
0500 to
17915
1915
T000 to
2100 to
T249
17915
(Current
value)
C000
T000 to
to 249
T249
(Current
(Preset
value)
value)
CTH0 to
C000
CTH1
to C249
(Preset
value)
DM0000 to CTC0 to
DM1999
CTC3
TM00 to DM0000 to
TM31
DM1999
#00000 to
TM00
#65535
to TM29
$0000 to #TM00 to
$FFFF
#TM29
#TM00 to
#TM29
KV-300
LDA
STA
0000 to
0009
0500 to
0500 to
17915
1915
KV-10/16
LDA
STA
0000 to
2915
T000 to
0500 to
T063
1915
KV-24/40/80
LDA
STA
0000 to
6915
T000 to
0500 to
T119
1915
T000 to
T249
2100 to
17915
C000 to
C063
2100 to
2915
C000 to
C119
2100 to
6915
C000 to
C249
T000 to
T249
CTH0 to
CTH1
T000 to
T063
CTH0 to
CTH1
T000 to
T119
CTH0 to
CTH1
DM0000 to
DM9999
TM00 to
TM31
#00000 to
#65535
$0000 to
$FFFF
#TM00 to
#TM29
C000 to
C249
CTC0 to
CTC3
DM0000 to
DM9999
TM00 to
TM29
#TM00 to
#TM29
DM0000 to
DM0999
TM00 to
TM31
#00000 to
#65535
$0000 to
$FFFF
#TM00 to
#TM29
C000 to
C063
CTC0 to
CTC3
DM0000 to
DM0999
TM00 to
TM29
#TM00 to
#TM29
DM0000 to
DM1999
TM00 to
TM31
#00000 to
#65535
$0000 to
$FFFF
#TM00 to
#TM29
C000 to
C119
CTC0 to
CTC3
DM0000 to
DM1999
TM00 to
TM29
#TM00 to
#TM29
Key operation
FUN
@
#,$
#,$
3-140
FUN
FUN
ANL
LDB
FUN
Chapter 2 Instructions
ORL
ANL
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
XXX
XXX
XXXX
XX
Destination
T/C preset
value
XXX
XXX
Data memory DM
3 Temporary memory
TM
Transfer
(#XXXXX)
($XXXXX)
Internal register
1 Constant
Storage
Input
Arithmetic flag
2009
2010
No change
Turns ON when the contents of the internal register is "0" after
"LDA #00000" is executed. Turns OFF at other times.
No change
Turns ON when the DM or relay indirectly addressed with #TM is
out of range.
2011
2012
#00100
LDA
C001
STA
0000
#00200
LDA
C001
STA
C001
0500
a)
b)
0002
#09999
C001
0001
Coding
Line No.
Instruction
0000
LD
Operand
0000
0001
LDA
#00100
0002
CON
0003
STA
0004
LDB
0000
0005
LDA
#00200
0006
CON
0007
STA
C001
0008
LD
0002
0009
0010
CON
0011
AND
C001
0012
OUT
0500
12
C001
Description
In step a), contents of DM00100 is transferred to C001 via the internal register for
use as the C001 preset value, when 0000 is ON.
In step b) , contents of #00200 is transferred to C001 via the internal register for
use as the C001 preset value, when 0002 is OFF.
Although the C001 preset value is #09999 in the above example, any value
except #00000 can be given because the preset value is changed to the specified value by turning ON/OFF 0000.
Note 1: If an STA instruction is executed when the current value is larger than the
preset value, the current value will be changed to the preset value.
Note 2: Do not specify "#00000" as the setting value for C001.
Chapter 2 Instructions
3-141
0001
2002
a)
C010
LDA
Coding
Line No.
Instruction
0000
LDB
Operand
0001
0001
0002
LD
2002
0003
LDA
C010
0004
CON
0005
STA
DM0000
Description
In step a), the C010 current value is transferred via the internal register and stored
into DM0000, throughout the operation.
Transferring the contents of data memory as a setting value for a timer
0002
DM0010
LDA
T002
STA
0002
DM0011
LDA
T002
STA
T002
0500
a)
2
b)
0003
#00010
T002
Coding
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
0002
0007
STA
T0002
0001
LDA
DM0010
0008
LD
0003
0002
CON
0009
TMR
002 #00010
0003
STA
T002
0010
CON
0004
LDB
0002
0011
AND
T002
0005
LDA
DM0011
0012
OUT
0500
0006
CON
Description
In step a), contents of DM0010 is transferred to T002 via the internal register for
use as the T002 preset value, when 0002 is ON.
In step b), contents of DM0011 is transferred to T002 via the internal register for
use as the T002 preset value, when 0002 is OFF.
Although the preset value of T002 is #00010 in the above example, any value
except #00000 can be given because the preset value is changed to the specified value by turning ON/OFF 0002. Once the counter value has been changed,
the changed value will be stored until it is changed again.
The setting values of timers and counters are reset to the original setting values
after the power is turned OFF once and then ON again.
Note 1: If an STA instruction is executed when the current value is larger than the
preset value, the current value will be changed to the preset value.
Note 2: Do not change the setting value of T002 to "#00000".
3-142
Chapter 2 Instructions
2002
0600
STA
Coding
Line No.
Instruction
0000
LD
Operand
2002
0001
LDA
0000
0002
CON
0003
STA
0600
Description
Input
(KV basic unit)
Input
Output
(KV-E16T(P))
(Internal register)
1 : ON
16-bit
0 : OFF
000
ON
0000
D0
0600
ON
00
001
ON
0001
D1
0601
ON
01
002
ON
0002
D2
0602
ON
02
003
ON
0003
D3
0603
ON
03
004
OFF
0004
D4
0604
OFF
04
005
OFF
0005
D5
0605
OFF
05
006
OFF
0006
D6
0606
OFF
06
007
OFF
0007
D7
0607
OFF
07
008
ON
0008
D8
0608
ON
08
009
ON
0009
D9
0609
ON
09
010
ON
0010
D10
0610
ON
10
011
ON
0011
D11
0611
ON
11
012
OFF
0012
D12
0612
OFF
12
013
OFF
0013
D13
0613
OFF
13
014
OFF
0014
D14
0614
OFF
14
015
OFF
0015
D15
0615
OFF
15
0000
<LDA>
0600
<STA>
12
Output
Binary number
The LDA instruction transfers the input (ON/OFF status) of the KV basic unit to
the internal register using binary numbers.
The STA instruction outputs the binary data in the internal register as the ON/
OFF status from the KV-E16T(P) (output unit).
Refer to "1.3 Device Configuration" (p. 3-5) for relay number assignments.
Note 1: When "LDA 0004" and "STA 0604" are programmed in the above example,
the LDA instruction can transfer inputs 0100 through 0103 to the internal register;
however, the STA instruction cannot output data across the channels. As a result,
the ON/OFF status of inputs 0100 through 0103 cannot be output even if they are
fetched by the LDA instruction.
Note 2: Relays 0000 through 0415 are assigned as input relays, and 0500 through
0915 are assigned as output relays.
Chapter 2 Instructions
3-143
a)
0011
b)
0000
LDA
$00FF
ANDA
TBIN
C001
LDA
TBCD
0500
STA
#09999
C001
0009
C001
STA
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
Instruction
LDB
C
LD
LDA
CON
ANDA
CON
TBIN
CON
STA
LD
LDA
CON
TBCD
CON
STA
Operand
0008
001 #09999 0009
0010
0000
$00FF
C001
0011
C001
0500
Description
Digital switch
Counter
setting
value
Internal register
(C001)
<59>
000 ON
D0
D0
001 OFF
D1
D1
002 OFF
D2
D2
003 ON
D3
D3
004 ON
D4
D4
005 OFF
D5
D5
D6
D6
007 OFF
D7
D8
D9
D10
D11
D12
013 OFF
D13
014 OFF
015 OFF
006 ON
Reset input
Proximity
SW input
SW input
07000
<LDA>
$00FF
<ANDA>
<TBIN>
C001
<STA>
D7
D8
D9
D10
D11
D12
D13
D14
D14
D15
D15
Only loworder 2
digits is
used.
0
0
BCD
data is
converted
into binary
data.
0
0
0
Data is
transferred
as setting
value of
counter.
2 + 2 + 2 + 2 + 2 = 1 + 2 + 8 + 16 + 32 = 59 (Decimal
number)
In example a), the LDA instruction reads the ON/OFF status of input relays 0000
through 0015 to the internal register.
"ANDA $00FF" instruction is used to leave only the digital switch input (2 digits).
BCD data is then converted into BIN (binary) data. (BIN is used in the KV series.)
The contents of the internal register is input as the setting value of C001.
In example b), the current value of counter C001 is read and output to output
relays 0500 through 0515.
Note 1: An LDA instruction can read the current value of a counter or a timer, but
cannot read the setting value.
Note 2: An STA instruction can change the setting value of a counter or a timer, but
cannot change the current value.
3-144
Chapter 2 Instructions
OK/NG
judgment
Data
shift
DM0000
DM0001
DM0002
DM0003
DM0004
Unloading
timing
The OK/NG judgment and unloading timings can be used in asynchronous programs.
0000
1000
DIFU
1000
OK/NG judgment
timing
$1111
DM0000
LDA
STA
"$1111" is transferred to
DM0000.
OK/NG judgment
$5555
DM0000
0001
LDA
STA
"$5555" is transferred to DM0000.
0001
2002
DM0004
LDA
$0000
CMP
2010
DM0003 DM0004
LDA
STA
$0000
LDA
DM0003
STA
2002
DM0003
LDA
$0000
CMP
2010
DM0002 DM0003
LDA
STA
$0000
LDA
DM0002
STA
2002
DM0002
LDA
$0000
CMP
2010
DM0001 DM0002
LDA
STA
$0000
LDA
DM0001
STA
2002
DM0001
LDA
$0000
CMP
2010
DM0000 DM0001
LDA
STA
$0000
LDA
DM0000
STA
0002
Unloading
timing
$0000
LDA
DM0004
STA
"$0000" is transferred to DM
at unloading timing.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
Instruction
LD
DIFU
CON
AND
MPS
AND
LDA
CON
STA
MPP
ANB
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
Operand
0000
1000
1000
0001
$1111
DM0000
0001
$5555
DM0000
2002
DM0004
$0000
2010
DM0003
DM0004
$0000
DM0003
0002
DM0003
$0000
2010
DM0002
Line No.
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
Instruction
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
@LDA
CON
@STA
Chapter 2 Instructions
Operand
DM0003
$0000
DM0002
2002
DM0002
$0000
2010
DM0001
DM0002
$0000
DM0001
2002
DM0001
$0000
2010
DM0000
DM0001
$0000
DM0000
0002
$0000
DM0004
3-145
12
CMP / @CMP
2.4 Instruction Details
RES LDB
CMP: Compare
FUN 0
@CMP: Compare
#,$ FUN
RES LDB
nnnn
CMP
nnnn
CMP
CMP instruction compares the contents of the internal register with the value specified by the operand, and turns ON/OFF the special utility relays (2009, 2010, 2011)
according to the result of comparison.
2009
2010
2011
ON
OFF
OFF
OFF
ON
OFF
OFF
OFF
ON
2002
C001
LDA
C001
LDA
#01000
CMP
#02000
CMP
2009
#09999
C001
0003
0500
2010
0501
2011
0502
2009
0503
1) (<)
2) (=)
3) (>)
4) ()
1) Output relay 0500 turns ON when the counter value is smaller than "1000" (C001
< #01000).
2) Output relay 0501 turns ON when the counter value is equal to "1000" (C001 =
#01000).
3) Output relay 0502 turns ON when the counter value is greater than "1000" (C001
> #01000).
4) Output relay 0503 turns ON when the counter value is equal to or greater than
"2000" (C001 #02000).
Coding
3-146
Line No.
Instruction
Operand
0000
LDB
0001
0001
Line No.
Instruction
Operand
0012
OUT
0501
0013
MPP
0002
LD
2002
0014
AND
2011
0003
LDA
C001
0015
OUT
0502
0004
CON
0016
LD
2002
0005
CMP
0017
LDA
C001
0006
CON
0018
CON
0007
MPS
0019
CMP
0008
AND
2009
0020
CON
0009
OUT
0500
0010
MRD
0011
AND
Chapter 2 Instructions
#01000
2010
#02000
0021
ANB
2009
0022
OUT
0503
CMP / @CMP
2.4 Instruction Details
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
FUN
@
#,$
FUN
RES
LDB
ENT
R-SRCH
Operand
ENT
R-SRCH
Arithmetic flag
2009 Turns ON when the result of the CMP operation is negative. Turns OFF at
other times.
2010 Turns ON when the result of the CMP operation is "0". Turns OFF at other
times.
2011 Turns ON when the result of the CMP operation is positive. Turns OFF at
other times.
2012 The DM or relay indirectly addressed with #TM is out of range.
12
Description
As shown in the above example, the CMP instruction is used by connecting the
special utility relay (2009 to 2011) immediately after the instruction.
The operation of the CMP instruction varies depending on the contents of the
internal register.
Note: Special utility relays 2009 to 2011 are used as arithmetic flags. The function
varies depending on the execution of other arithmetic instructions.
Tips
An operand is compared with the internal register using the following program.
DM0000 #00999
LDA
CMP
2009
When the internal register is assumed as "a" and the operand is "b" such as , the
statuses of the special utility relays are as follows:
a
LDA
2009
b
CMP
a < b,
2011
a b,
2010
a = b,
2009
a b,
2011
a>b
Chapter 2 Instructions
3-147
CMP / @CMP
2.4 Instruction Details
C000
LDA
#00999
CMP
2011
#01999
CMP
2011
0500
#02999
CMP
2011
0500
#09999
C000
0000
0500
Line No.
0000
0001
0501
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0502
0501
Instruction
Operand
LDB
0001
C
000 #099999
0000
LD
2002
LDA
C000
CON
MPS
CMP
#00999
CON
ANB
2011
OUT
0500
MRD
CMP
#01999
CON
ANB
2011
ANB
0500
OUT
0501
MPP
CMP
#02999
CON
ANB
2011
ANB
0500
ANB
0501
OUT
0502
Description
The following outputs are provided according to the current value of the counter.
(Current value)
(Output)
0000 to 0999
0500 turns ON.
1000 to 1999
0501 turns ON.
2000 to 2999
0502 turns ON.
When comparing values with no specific range
Turns ON 0500 when the DM0000 value is smaller than the CMP value.
Turns ON 0501 when the DM0000 value is equal to the CMP value.
Turns ON 0502 when the DM0000 value is greater than the CMP value.
2002 DM0000 #01000
LDA
CMP
2009
0500
DM0000<#01000
2010
0501
DM0000=#01000
2011
0502
DM0000>#01000
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
3-148
Instruction
LD
LDA
CON
CMP
MPS
AND
OUT
Chapter 2 Instructions
Operand
2002
DM0000
#01000
2009
0500
Line No.
0007
0008
0009
0010
0011
0012
Instruction
MRD
AND
OUT
MPP
AND
OUT
Operand
2010
0501
2011
0502
CMP / @CMP
2.4 Instruction Details
Setting the upper/lower limit
Turns ON 0500 when the C001 value is 1000 or less.
Turns ON 0501 when the C001 value is 2000 or more.
0001
2002
2002
C001
LDA
#01000
CMP
2011
C001
LDA
#02000
CMP
2009
#09999
C001
0000
0500
C001#01000
0501
C001#02000
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
Operand
LDB
0001
C
001 #09999 0000
LD
2002
LDA
C001
CON
CMP
#01000
CON
ANB
2011
Line No.
0008
0009
0010
0011
0012
0013
0014
0015
Instruction
OUT
LD
LDA
CON
CMP
CON
ANB
OUT
Operand
0500
2002
C001
#02000
2009
0501
0
DM0000
STA Sets range of TMIN from 0 to 100.
TMIN
0001
#09999
C000
00000
2009 0500
2002
C000 DM0000
LDA
CMP
2009
0501
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
Instruction
LD
TMIN
CON
ADD
CON
MUL
CON
DIV
CON
STA
LDB
Operand
2002
0
#00001
#00004
#00010
DM0000
0001
Line No.
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
Instruction
Operand
C
000 #09999 0000
LD
02002
LDA
C000
CON
CMP
DM0000
MPS
AND
2009
OUT
0500
MPP
ANB
2009
OUT
0501
Chapter 2 Instructions
3-149
12
RES RES
ADD: Add
FUN 0
@
@ADD: Add
#,$ FUN
RES RES
LDB ORB
SUB: Subtract
FUN 4
@
@SUB: Subtract
#,$ FUN
LDB ORB
ANL AND
MUL: Multiply
FUN 2
@
@MUL: Multiply
#,$ FUN
ANL AND
SET SET
DIV: Divide
FUN 1
@
@DIV: Divide
#,$ FUN
SET SET
nnnn
ADD
nnnn
ADD
:
:
nnnn
SUB
nnnn
SUB
nnnn
MUL
nnnn
MUL
nnnn
DIV
nnnn
DIV
MUL
DIV
Decimal
(#XXXXX)
Hexadecimal
($XXXX)
DM0000 to DM1999
TM00 to TM31
#TM00 to #TM29
Arithmetic operation
Internal register
SUB
Data memories
Operand
Internal register
ADD
Constants
ADD, SUB, MUL, and DIV allow arithmetic instructions between the contents of
internal register and the value specified by the operand.
Result
Note: Arithmetic instructions use binary numbers (BIN). Therefore, the contents of
the internal register used for the arithmetic instruction must be BIN data. Use the
TBIN instruction to convert BCD data into BIN data.
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
Key operation
FUN
@
#,$
FUN
FUN
#,$
FUN
FUN
#,$
FUN
FUN
#,$
3-150
FUN
RES
LDB
ANL
SET
Chapter 2 Instructions
RES
ORB
AND
SET
ENT
R-SRCH
ENT
R-SRCH
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
R-SRCH
R-SRCH
ADD / @ADD
ADD (Addition)
DM0000 #00100 DM0001
LDA
ADD
STA
2002
Coding
Line No.
Instruction
Operand
0000
LD
2002
0001
LDA
DM0000
0002
CON
0003
ADD
0004
CON
0005
STA
#00100
DM0001
Description
The ADD instruction adds the operand value to the contents of the internal
register and inputs the result back to the internal register.
In the above example, "#00100" is added to the contents of DM0000 and the
result is stored in DM0001.
When the contents of DM0000 is "#00100", for example, "#00200" is stored in
DM0001.
DM0000 (#00100) + #00100 DM0001(#00200)
Note 1: An overflow occurs when the operation result exceeds 16 bits ($FFFF,
#65535). In such a case, only the data of the low-order 16 bits is input back to the
internal register. For example, when the contents of the internal register is "$FFFF"
and the operand is "$0001", the result will overflow.
Note 2: When an overflow occurs, special utility relay 2009 turns ON.
Example:
Internal register
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 = $FFFF
Operand + 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 = $0002
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 = $0001
Overflow 1
Special
utility relay
2009
Result
Tips
Solution when operation result overflows 16 bits
2002
DM0000 DM0001
LDA
ADD
2009
2009
Arithmetic flag
2009
2010
2011
2012
Turns ON when the result of an ADD operation exceeds the range of 16 bits
($FFFF). Turns OFF at other times.
Turns ON when the contents of the internal register is "0" after an ADD
operation. Turns OFF at other times.
No change
The DM or relay indirectly addressed with #TM is out of range.
Chapter 2 Instructions
3-151
12
ADD / @ADD
#09999 C001
LDA
C001
0001
0000
#09999 C002
LDA
C002
0002
0000
#09999 C003
LDA
C003
0003
2002 DM0001 DM0002 DM0003
LDA
ADD
ADD
DM0001
STA
DM0002
STA
DM0003
STA
DM0100
STA
Coding
3-152
Line No.
Instruction
0000
LDB
0001
0001
0002
CON
0003
LDA
0004
CON
Operand
C001
0005
STA
0006
LDB
DM0001
0000
0007
0008
CON
0009
LDA
0010
CON
C002
0011
STA
DM0002
0012
LDB
0000
0013
0014
CON
0015
LDA
0016
CON
0017
STA
0018
LD
2002
0019
LDA
DM0001
0020
CON
0021
ADD
0022
CON
0023
ADD
0024
CON
0025
STA
Chapter 2 Instructions
C003
DM0003
DM0002
DM0003
DM0100
SUB / @SUB
SUB (Subtraction)
2002
Coding
Line No.
Instruction
Operand
0000
LD
2002
0001
LDA
DM0000
0002
CON
0003
SUB
0004
CON
0005
STA
#00100
DM0001
Description
The SUB instruction subtracts the operand value from the contents of the internal
register and inputs the result back into the internal register.
In the above example, "#00100" is subtracted from the contents of DM0000 and
the result is stored in DM0001.
When the contents of DM0000 is "#00150", for example, "#00050" is stored in
DM0001.
DM0000 (#00150) #00100 DM0001 (#00050)
Note 1: When the operation result is a negative value (-), the 2's complement value
is also stored in the internal register.
Special utility relay 2009 turns ON.
Internal register
Operand -
Underflow 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 = $0001
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 = $FFFF
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 = $0002
2009
Note 2: To convert the complement into an antilogarithm, add the following operation:
Inverted bit of complement + 1 = Antilogarithm
Tips
Solution when operation result is a negative value
2002
DM0000 DM0001
LDA
SUB
2009
2009
COM
DM0000 - DM0001 =
#0001
ADD
DM0002
STA
DM0003
STA
Positive value
DM0002
Negative value
DM0003
Absolute value
is stored.
Arithmetic flag
2009
2010
2011
2012
Chapter 2 Instructions
3-153
12
SUB / @SUB
DM0000 DM0001
LDA
SUB
2009
#0005
CMP
2009
1000
2009
2009
1001
0500
1000
1001
Coding
3-154
Line No.
Instruction
Operand
0000
LD
2002
0001
LDA
DM0000
0002
CON
0003
SUB
0004
MPS
DM0001
0005
ANB
2009
0006
CMP
#00005
0007
CON
0008
ANB
2009
0009
OUT
1000
0010
MPP
0011
AND
2009
0012
LDA
DM0001
0013
CON
0014
SUB
0015
CON
0016
CMP
0017
CON
DM0000
#00005
0018
ANB
2009
0019
OUT
1001
0020
LD
1000
0021
OR
1001
0022
OUT
0500
Chapter 2 Instructions
MUL / @MUL
MUL (Multiplication)
DM0000 #00100 DM0001
LDA
MUL
STA
2002
Coding
Line No.
Instruction
Operand
0000
LD
2002
0001
LDA
DM0000
0002
CON
0003
MUL
0004
CON
0005
STA
#00100
DM0001
Description
The MUL instruction multiplies the contents of the internal register by the operand value and inputs the result back to the internal register.
In the above example, the contents of DM0000 are multiplied by "#00100" and
the result is stored in DM0001.
When the contents of DM0000 is "#00200", for example, "#20000" is stored in
DM0001.
DM0000 (#00200) x #00100DM0001 (#20000)
Note 1: An overflow occurs when the operation result exceeds 16 bits (#65535). In
such a case, only the data of the low-order 16 bits are stored in the internal register,
and the overflow data of the high-order 16 bits is stored in TM00. (The data of the
high-order 16 bits is always stored in TM00.)
Note 2: When an overflow occurs, special utility relay 2009 turns ON.
Internal register F F F F
Operand
0 0 0 2
Hexadecimal number
0 0 0 1 F F F F
(TM00) (Internal register)
Tips
Solution when operation result overflows 16 bits
2002
TM00
LDA
DM0003
STA
Arithmetic flag
2009
2010
2011
2012
Turns ON when the result of a MUL operation exceeds 16 bits. Turns OFF at
other times.
Turns ON when all 32 bits are "0" after a MUL operation. Turns OFF at other
times.
No change
The DM or relay indirectly addressed with #TM is out of range.
Chapter 2 Instructions
3-155
12
2002
DM0000 DM0100
MUL
STA
TM00
LDA
#09999
C001
0000
DM0101
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LDB
C
LD
LDA
CON
MUL
CON
STA
CON
LDA
CON
STA
Operand
0001
001 #099999 0000
2002
C001
DM0000
DM0100
TM00
DM0101
DIV (Division)
DM0001
LDA
2002
TM00
STA
High-order
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
3-156
Instruction
LD
LDA
CON
STA
CON
LDA
CON
DIV
CON
STA
CON
LDA
CON
STA
CON
LDA
CON
STA
Chapter 2 Instructions
Operand
2002
DM0001
TM00
DM0000
#00100
DM0002
TM00
DM0003
TM01
DM0004
Low-order
TM00
LDA
DM0003
STA
High-order
TM01
LDA
DM0004
STA
Remainder
DIV / @DIV
Arithmetic flag
2009
2010
2011
2012
No change
Turns ON when all 32 bits are "0" after a DIV operation. Turns OFF at other
times.
No change
Turns ON when the divisor of a DIV operation is "0" or the DM or relay
indirectly addressed with #TM is out of range.
The 32-bit value (binary) consisting of the higher 16 bits from TM00 and lower 16
bits from the internal register is divided by the value specified by the operand.
The higher 16 bits of the result is input back to TM00 and lower 16 bits to the
same internal register. The remainder is stored in TM01.
Description
TM00
Internal register
High-order 16 bits
Low-order 16 bits
TM00
Internal register
High-order 16 bits
Low-order 16 bits
Operand
TM01
Remainder (16 bits)
Quotient
Example
DM0001
12
#00100
DM0000
DM0003
DM0002
DM0004
Remainder (16 bits)
Note 1: When data of 16 bits or less is divided by the operand value, the contents of
TM00 must be cleared (set to "#00000") before the DIV operation.
Note 2: If the contents of TM00 are not cleared, the data stored in TM00 is also
used for the operation.
Tips
Solution when data of 16 bits or less is divided
02002
#00000
LDA
TM00
STA
TM01
LDA
DM0003
STA
Low-order
16 bits
High-order
16 bits
Low-order
16 bits
Remainder
Quotient
Chapter 2 Instructions
3-157
DIV / @DIV
C001
#09999
LDA
C001
0001
C002
#09999
LDA
C002
0002
C003
#09999
LDA
C003
0003
DM0001 DM0002
LDA
ADD
2002
2002
#00003
DIV
DM0001
STA
DM0002
STA
DM0003
STA
DM0003
ADD
#00000
LDA
TM00
STA
TBCD
0500
STA
(DM0001+DM0002+DM0003)
Coding
3-158
Line No.
Instruction
0000
LDB
0000
0001
0002
CON
0003
LDA
0004
CON
Operand
C001
0005
STA
DM0001
0006
LDB
0000
0007
0008
CON
0009
LDA
0010
CON
0011
STA
0012
LDB
0000
0013
0014
CON
C002
DM0002
0015
LDA
0016
CON
C003
0017
STA
0018
LD
2002
0019
LDA
DM0001
0020
CON
0021
ADD
0022
CON
0023
ADD
DM0003
DM0002
DM0003
0024
LD
2002
0025
DIV
#0003
0026
CON
0027
TBCD
0028
CON
0029
STA
Chapter 2 Instructions
500
ANDA / @ANDA
2.4 Instruction Details
ANDA:
AND A
@ANDA: (Logical product)
RES SET
FUN 0
#,$ FUN
RES SET
nnnn
ANDA
nnnn
ANDA
Example
0000
DM0000
LDA
$00FF
ANDA
DM0001
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
LDA
CON
ANDA
CON
STA
Operand
0000
DM0000
$00FF
DM0001
Description
The contents of DM0000 are transferred to the internal register when input relay
0000 is ON.
The contents of the internal register (DM0000) and the value specified by the
operand ($00FF) are ANDed for each bit and the result (logical product) is input
back to the same register.
When the operation result is "0", special utility relay 2010 turns ON.
The contents of the internal register are transferred to DM0001.
The following shows the case when DM0000 is "$F0F0".
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
Contents of DM0000
are transferred to the
internal register.
DM0000 ($F0F0)
DM0000
LDA
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
Internal
($F0F0)
register
AND
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
$00FF
ANDA
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
Operand ($F0F0)
Internal ($F0F0)
register
Operand
Internal
register
1
0
0
0
1
0
1
0
DM0001
STA
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
DM0001 ($00F0)
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
0000 to 17915
0000 to 2915
0000 to 6915
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999
TM00 to TM31
TM00 to TM31
TM00 to TM31
TM00 to TM31
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
$0000 to $FFFF
$0000 to $FFFF
$0000 to $FFFF
$0000 to $FFFF
#TM00 to #TM29
#TM00 to #TM29
#TM00 to #TM29
#TM00 to #TM29
Key operation
FUN
@
#,$
FUN
RES
SET
ENT
R-SRCH
Operand
ENT
R-SRCH
Chapter 2 Instructions
3-159
12
ANDA / @ANDA
2.4 Instruction Details
Arithmetic flag
2009
2010
2011
2012
No change
Turns ON when the internal register is "0" after an ANDA operation.
Turns OFF at other times.
No change
The DM or relay indirectly addressed with #TM is out of range.
Tips
Solution when connecting one-digit data of a BCD digital switch to inputs 0100
to 0103, while ignoring other inputs
Only one-digit data of the BCD digital switch is transferred as the setting value of the
fetching counter (C004).
Other inputs (0104 to 0115) are ignored.
#00300
C004
0005
C004
STA
0004
2002
0100
LDA
$000F
ANDA
TBIN
2
2002
2002
7000
LDA
$00FF
ANDA
TBIN
C000
STA
7000
LDA
$FF00
ANDA
#08
SRA
TBIN
T001
STA
#09999
C000
0000
#09999
T001
0001
0001
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
3-160
Instruction
LD
LDA
CON
ANDA
CON
TBIN
CON
STA
LD
LDA
CON
ANDA
CON
SRA
CON
TBIN
CON
STA
LDB
C
LDB
T
Chapter 2 Instructions
Operand
2002
7000
$00FF
C000
2002
7000
$FF00
#08
T001
0001
000 #09999 0000
0001
001 #09999
ORA / @ORA
2.4 Instruction Details
ORL SET
FUN 3
ORA:
Or A
@ORA: (Logical sum)
Example
#,$ FUN
0000
DM0000
LDA
ORL SET
$00FF
ORA
nnnn
ORA
nnnn
ORA
DM0001
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
LDA
CON
ORA
CON
STA
Operand
0000
DM0000
$00FF
DM0001
Description
The contents of DM0000 are transferred to the internal register when input relay
0000 is ON.
The contents of the internal register (DM0000) and the value specified by the
operand ($00FF) are ORed for each bit and the result (logical sum) is input back
to the same register.
When the operation result is "0", special utility relay 2010 turns ON.
The contents of the internal register are transferred to DM0001.
The following shows the case when DM0000 is "$F0F0".
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
Contents of DM0000 are
transferred to the internal
register.
DM000 ($F0F0)
DM0000
LDA
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
Internal
($F0F0)
register
OR
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
$00FF
ORA
1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1
The result is transferred
to DM0001.
Operand ($00FF)
Internal
($F0FF)
register
OR (Logical sum)
truth table
Internal
register
1
1
0
0
Operand
1
0
1
0
(Result)
Internal
register
1
1
1
0
DM0001
STA
1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
0000 to 0009
0000 to 2915
0000 to 6915
DM0000 to DM1999
0500 to 17915
DM0000 to DM0999 DM0000 to DM1999
TM00 to TM31
DM0000 to DM9999
TM00 to TM31
TM00 to TM31
#00000 to #65535
TM00 to TM31
#00000 to #65535 #00000 to #65535
$0000 to $FFFF
#00000 to #65535
$0000 to $FFFF
$0000 to $FFFF
#TM00 to #TM29
$0000 to $FFFF
#TM00 to #TM29
#TM00 to #TM29
#TM00 to #TM29
Key operation
FUN
@
#,$
FUN
ORL
SET
ENT
R-SRCH
Operand
ENT
R-SRCH
Chapter 2 Instructions
3-161
12
ORA / @ORA
2.4 Instruction Details
Arithmetic flag
2009
2010
2011
2012
No change
Turns ON when the internal register is "0" after an ORA operation. Turns
OFF at other times.
No change
The DM or relay indirectly addressed with #TM is out of range.
Tips
Solution when connecting two-digit data of a BCD digital switch (inputs 0100
to 0103 for the first digit and 0200 to 0203 for the second digit) separately
Fetches the two-digit data of the BCD digital switch, which are separated into the
first digit (0100 to 0103) and the second digit (0200 to 0203), and transfers the
values as the setting value of a counter (C004).
0004
#00300
C004
0005
2002
0100
LDA
$000F
ANDA
DM0000
STA
0200
LDA
$000F
ANDA
#04
SLA
DM0000
ORA
TBIN
C004
STA
2
Application of ORA instruction
Output of BCD 2-digit data
Converts the current value of counter C000 to BCD and sends 2 digits of BCD data
to output relays 0500 to 0507.
However, retain ON/OFF of 0508 to 0515 which are loaded.
0000
2002
0500
LDA
2002
2002
#00099
C000
0001
$FF00 DM0000
ANDA
STA
C000
LDA
TBCD
DM0000
ORA
0500
STA
$00FF
ANDA
Sets C000.
Coding
Line No.
0000
0001
3-162
Instruction
Operand
LDB
0000
C
001 #00099 0001
Line No.
0009
0010
Instruction
LDA
CON
Operand
C000
0002
LD
2002
0011
TBCD
0003
LDA
0500
0012
CON
0013
ANDA
$00FF
$FF00
0014
LD
2002
DM0000
0004
CON
0005
ANDA
0006
CON
0015
ORA
0007
STA
DM0000
0016
CON
0008
LD
2002
0017
STA
Chapter 2 Instructions
0500
ORA / @ORA
2.4 Instruction Details
Separate input of 2-digit BCD
Fetches only 2 digits of the BCD digital switch (0000 to 0003 for the 1st digit, 0100
to 0103 for the 2nd digit) and sets it as the counter value.
0000
0000
LDA
#00099
C000
0001
$000F DM0000
STA
ANDA
2002
0100
LDA
$000F
ANDA
2002
#04
SLA
DM0000
ORA
2002
Sets C001.
TBIN
C001
STA
Coding
Line No.
Instruction
Operand
0000
LDB
0001
0001
0002
LD
2002
0003
LDA
0000
0004
CON
0005
ANDA
0006
CON
0007
STA
$000F
0008
LD
2002
0009
LDA
0100
0010
CON
0011
ANDA
$000F
0012
LD
2002
0013
SLA
#04
0014
CON
0015
ORA
0016
CON
0017
TBIN
0018
CON
0019
STA
12
DM0000
DM0000
C001
Chapter 2 Instructions
3-163
EORA / @EORA
2.4 Instruction Details
EORA: Exclusive Or A
@EORA: (Exclusive
logical sum)
SET ANB
FUN 1
@
#,$ FUN
SET ANB
nnnn
EORA
nnnn
EORA
Example
0000
DM0000
LDA
$00FF
EORA
DM0001
STA
Exclusive
logical sum
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
LDA
CON
EORA
CON
STA
Operand
0000
DM0000
$00FF
DM0001
Description
The contents of DM0000 is transferred to the internal register when input relay
0000 is ON.
The contents of the internal register (DM0000) and the value specified by the
operand ($00FF) are EORed (exclusive OR) for each bit and the result is input
back to the same register.
When the operation result is "0", special utility relay 2010 turns ON.
The contents of the internal register is transferred to DM0001.
The following shows the case when DM0000 is "$F0F0".
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 DM0000 ($F0F0)
DM0000
LDA
Internal
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 register ($F0F0)
EORA
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Operand ($00FF)
$00FF
EORA
Internal
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 register ($F00F)
The result is transferred to DM0001.
Operand
1
0
1
0
DM0001
STA
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
DM0000 ($F00F)
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
0000 to 17915
00000 to 0009
0000 to 2915
0000 to 6915
DM0000 to DM1999
0500 to 17915
DM0000 to DM0999 DM0000 to DM1999
TM00 to TM31
DM0000 to DM9999
TM00 to TM31
TM00 to TM31
#00000 to #65535
TM00 to TM31
#00000 to #65535 #00000 to #65535
$0000 to $FFFF
#00000 to #65535
$0000 to $FFFF
$0000 to $FFFF
#TM00 to #TM29
$0000 to $FFFF
#TM00 to #TM29
#TM00 to #TM29
#TM00 to #TM29
Key operation
FUN
@
#,$
3-164
FUN
SET
Chapter 2 Instructions
ANB
ENT
R-SRCH
Operand
ENT
R-SRCH
(Result)
Internal
register
0
1
1
0
EORA / @EORA
2.4 Instruction Details
Arithmetic flag
2009 No change
2010 Turns ON when the internal register is "0" after an EORA operation. Turns
OFF at other times.
2011 No change
2012 The DM or relay indirectly addressed with #TM is out of range.
Tips
Turning output 0500 ON when inputs 0000 through 0015 have the same value as a
constant ($0F0F)
When the values match, special internal relay 2010 turns ON and output relay 0500
turns ON.
In this example, the constant is "$0F0F", or "0000 1111 0000 1111". Therefore,
output relay 0500 turns ON when input relays 0000 through 0003 and 0008 through
0011 are ON.
0000
LDA
2002
$0F0F
EORA
2010
0500
$00AA
LDA
DM0000
STA
2002
0100
LDA
$00FF
ANDA
DM0000
EORA
2010
0500
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
LDA
CON
STA
LD
LDA
CON
Operand
2008
$00AA
DM0000
2002
0100
Line No.
0007
0008
0009
0010
0011
0012
Instruction
ANDA
CON
EORA
CON
AND
OUT
Operand
$00FF
DM0000
2010
0500
$00FF 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Operand
$00AA 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 DM0000
$0011
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 Internal register
Chapter 2 Instructions
3-165
12
FUN 4
#,$ FUN
LDB SET
#dd
SRA
#dd
SRA
#dd
SLA
LDB RES
:
LDB RES :
FUN 4
0
FUN 4
@
#,$
#dd
SLA
Example
0000
DM0000
LDA
#05
SRA
DM0001
STA
0001
DM0010
LDA
#10
SLA
DM0011
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
SRA
CON
STA
LD
LDA
CON
SLA
CON
STA
Operand
0000
DM0000
#05
DM0001
0001
DM0010
#10
DM0011
Operands
#01 to #16
Key operation
FUN
@
#,$
#,$
FUN
FUN
LDB
LDB
FUN
SET
RES
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009
2010
2011
2012
3-166
Turns ON when "1" enters 2009 after an SRA/SLA operation. Turns OFF at
other times.
Turns ON when the internal register is "0" after an SRA/SLA operation.
Turns OFF at other times.
No change
No change
Chapter 2 Instructions
Description
Operations using the SRA instruction
When input relay 0000 is ON, the contents of DM0000 are transferred to the internal
register and shifted serially right by the operand value (5). The operation result is
written into DM0001. The contents of D0 are shifted to carry bit 2009.
In the above example, the contents shift to the right by the operand value (5) every
scan time while input relay 0000 is ON.
Use @SRA, a differentiation type instruction, to execute the instruction only once
when input relay 0000 turns ON.
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Carry
2009
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
Carry
2009
0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
Carry
2009
1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Note: Special utility relay 2009 may turn ON in accordance with the operation
results; however, it changes immediately when another operation is executed.
Chapter 2 Instructions
3-167
12
0000
LDA
$0FF0
ANDA
#04
SRA
DM0000
STA
0100
LDA
$00FF
ANDA
#08
SLA
DM0000
ORA
C004
STA
#09999
C004
0000
0001
#00099
C001
0000
$F000
ANDA
2002
#12
SRA
DM0000
STA
2002
0000
LDA
$000F
ANDA
#04
SLA
DM0000
ORA
TBIN
C001
STA
2002
2002
2002
Sets C001.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
3-168
Instruction
LD
C
LD
LDA
CON
ANDA
LD
SRA
CON
STA
LD
LDA
CON
ANDA
LD
SLA
CON
ORA
LD
TBIN
CON
STA
Chapter 2 Instructions
Operand
0001
001 #00099 0000
2002
0100
$F000
2002
#12
DM0000
2002
0000
$000F
2002
#04
DM0000
2002
C001
ORL LD
FUN 3
@
#,$ FUN
ORL LD
ORL ANB
FUN 3
@
#,$ FUN
ORL ANB
#dd
RRA
#dd
RRA
#dd
RLA
#dd
RLA
Example
0000
DM0000
LDA
#01
RRA
DM0001
STA
0001
DM0010
LDA
#04
RLA
DM0011
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
RRA
CON
STA
LD
LDA
CON
RLA
CON
STA
Operand
0000
DM0000
#01
DM0001
0001
DM0010
12
#04
DM0011
Operands
#01 to #16
Key operation
FUN
@
#,$
FUN
FUN
#,$
FUN
ORL
ORL
LD
ANB
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009
Description
Operation when using the RRA instruction
When input relay 0000 is ON, the contents of DM0000 are transferred to the internal
register. The contents of the internal register and carry (2009) are rotated clockwise
by the operand value.
In the above example, the contents are rotated clockwise every scan time while
input relay 0000 is ON.
Chapter 2 Instructions
3-169
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
Carry
2009
0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0
Carry
2009
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
Carry
2009
1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 0
Note: Special utility relay 2009 may turn ON in accordance with the operation
results; however, it changes immediately when another operation is executed.
0000
LDA
FOR
#00016
2002
#01
RRA
2009
TM10
INC
NEXT
2002
TM10
LDA
DM0000 #00000
LDA
STA
TM10
STA
Coding
3-170
Line No.
0000
0001
Instruction
LD
LDA
Operand
2002
0000
Line No.
0009
0010
Instruction
LD
LDA
0002
FOR
#00016
0011
CON
0003
LD
02002
0012
STA
0004
RRA
#01
0005
CON
0006
AND
0007
INC
0008
NEXT
Chapter 2 Instructions
0013
CON
0014
LDA
2009
0015
CON
TM10
0016
STA
Operand
2002
TM10
DM0000
#00000
TM10
COM / @COM
2.4 Instruction Details
COM: Complement
@COM: (Bit inversion)
RES ANB
FUN 0
RES ANB
@
#,$ FUN 0
5
COM
COM
Example
DM0000
LDA
0000
COM
DM0001
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
@LDA
CON
@COM
CON
@STA
Operand
0000
DM0000
DM0001
Description
Each time input relay 0000 turns from OFF to ON, the contents of DM0000 are
transferred to the internal register. The COM instruction inverts the status of each
bit and transfers the result to DM0001.
Special utility relay 2010 turns ON when the result is "0".
The following shows the case when DM0000 is "$5F5F".
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
DM0000
0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 = $5F5F
COM instruction
Bit inversion
DM0001
1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 = $A0A0
Note:
0000
DM0000
LDA
COM
DM0001
STA
When an every-scan type COM instruction is used, the status of bits are inverted
every scan time while input relay 0000 is ON.
Use @COM, a differentiation type instruction, to execute the instruction only once
when input relay 0000 turns ON, as shown in the example.
Operands
Key operation
FUN
@
#,$
FUN
RES
ANB
ENT
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009
2010
2011
2012
No change
Turns ON when the internal register is "0" after a COM operation. Turns
OFF at other times.
No change
No change
Chapter 2 Instructions
3-171
12
nnnn
INC
SET OR
@
#,$ FUN 1
9
nnnn
INC
RES LD
nnnn
DEC
nnnn
DEC
FUN 0
SET OR
FUN 1
#,$ FUN
RES LD
DM0000
INC
0000
DM0001
DEC
Coding
Line No.
0000
0001
0002
Instruction
LD
@INC
@DEC
Operand
0000
DM0000
DM0001
Description
Operation using the @INC instruction
Every time input relay 0000 turns ON, "1" is added to the contents of the data
memory specified by the operand. The result is then input back to the same data
memory. (In the above example, "1" is added to the contents of DM0000. DM0000 +
1 DM0000) When the data memory specified by the operand is "#65535", the
result of the addition is "#00000" so that special utility relay 2009 turns ON.
@ INC instruction
0 0
1 0
0 0
0 1
1 is added.
0 0
1 1
1 1
0 0
0 1
1 is subtracted.
0 0
1 0
Operands
Visual KV
KV-300
KV-10/16
KV-24/40/80
3-172
Chapter 2 Instructions
Key operation
FUN
@
FUN
#,$
FUN
@
FUN
#,$
SET
OR
RES
LD
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009
Turns ON when the result is "0" after an INC operation, or when the
result is "$FFFF (#65535)" after DEC operation. Turns OFF at other
times.
2010
Turns ON when the internal register is "0" after an INC or DEC operation. Turns OFF at other times.
2011, 2012 No change
Note: When an every-scan type INC/DEC instruction is used, INC (+1) or DEC (-1)
instruction is executed every scan time while input relay 0000 is ON.
Use a differentiation type instruction (@INC or @DEC) to execute the instruction
only once when input relay 0000 turns ON, as shown in the example.
0000
DM0000
INC
DM0000
INC
0000
12
Tips
When using DM0000 as an UP/DOWN counter
Performs an UP count (addition) when input relay 0000 turns ON.
Performs a DOWN count (subtraction) when input relay 0001 turns ON.
0000
DM0000
INC
0001
DM0000
DEC
#00000 DM0000
LDA
STA
0000
DM0000
INC
0001
DM0000
DEC
0005
#00000
DW
DM0000
Coding
Line No.
0000
Instruction
LD
Operand
2008
Line No.
0005
Instruction
@INC
Operand
DM0000
0001
LDA
#00000
0006
LD
0001
0002
CON
0007
@DEC
DM0000
0003
STA
DM0000
0008
LD
0005
0004
LD
0000
0009
DW
#00000 DM0000
Chapter 2 Instructions
3-173
#00000 DM0000
LDA
STA
DM0000
INC
0001
DM0000
INC
0002
DM0000
INC
DM0000
INC
0000
0003
0005
#00000
DW
DM0000
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
Instruction
LD
LDA
CON
STA
LD
@INC
LD
@INC
LD
@INC
LD
@INC
LD
DW
Operand
2008
#00000
DM0000
0000
DM0000
0001
DM0000
0002
DM0000
0003
DM0000
0005
#00000 DM0000
Total count 2
Counts the number of boxes transferred on 5 production lines. Produces output
when the number becomes 100 or more.
0000
DM0000
INC
0001
DM0000
INC
0002
DM0000
INC
0003
DM0000
INC
0004
DM0000
INC
0005
$0000
DW
DM0000
2002 DM0000 #00100 2009 0500
LDA
CMP
3-174
Chapter 2 Instructions
Instruction
LD
@INC
LD
@INC
LD
@INC
LD
@INC
LD
@INC
LD
Operand
0000
DM0000
0001
DM0000
0002
DM0000
0003
DM0000
0004
DM0000
0005
Line No.
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
Instruction
Operand
DW
#00000 DM0000
LD
2002
LDA
DM0000
CON
CMP
#00100
CON
ANB
2009
OUT
0500
END
ENDH
Programming technique
Two kinds of instructions can be used for the counting operation: a C (counter)
instruction and an INC instruction with data memory.
The following examples show how to program the total count with each instruction.
Programming with the C instruction
0005
2002
#09999 C001
C001
LDA
0000
#09999 C002
C002
LDA
0001
#09999 C003
C003
LDA
0002
#09999 C004
C004
LDA
0003
#09999 C005
C005
LDA
0004
DM0001 DM0002 DM0003 DM0004 DM0005
LDA
ADD
ADD
ADD
ADD
DM0001
STA
0000
DM0000
INC
DM0002
STA
0001
DM0000
INC
DM0003
STA
0002
DM0000
INC
DM0004
STA
0003
DM0000
INC
DM0005
STA
0004
DM0000
INC
DM0000
STA
0005
$0000
DW
DM0000
12
As the example of the INC instruction shows, using different instructions sometimes
simplifies the program even for the same control.
Simpler programming reduces the time for debugging.
It is convenient to use the CMP instruction for comparator outputs.
OR instruction
Compare the following two programs.
With program 1), input relays 0000 through 0004 are individually counted even when
they turn ON simultaneously.
With program 2), when some input relays 0000 through 0004 turn ON simultaneously, duplicated inputs are ignored.
Use the appropriate program according to your application.
0000
DM0000
INC
0000
0001
DM0000
INC
0001
0002
DM0000
INC
0002
0003
DM0000
INC
0003
0004
DM0000
INC
0004
1)
DM0000
INC
2)
Chapter 2 Instructions
3-175
MPX:
ANL LD
Multiplexer
FUN 2
@
Demultiplexer
#,$ FUN
ANL LD
SET ANL
FUN 1
#,$ FUN
SET ANL
#n
MPX
#n
MPX
DMX
DMX
Example
0000
0000
LDA
#1
MPX
1000
STA
0001
0100
LDA
DMX
DM0000
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
MPX
CON
STA
LD
LDA
CON
DMX
CON
STA
Operand
0000
0000
#1
1000
0001
0100
DM0000
Operands
#0 to #3
Key operation
FUN
@
#,$
FUN
FUN
#,$
FUN
SET
RES
OR
LD
ENT
R-SRCH
ENT
R-SRCH
Operand
ENT
Operand
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009, 2010, 2011 No change
2012
Turns ON when no bit is ON after a DMX operation (the result is
"0"). Turns OFF at other times.
3-176
Chapter 2 Instructions
Description
Operation with the MPX instruction
When input relay 0000 is ON, the ON/OFF status of input relays 0000 through 0015
is transferred to the internal register. The section of the internal register specified by
the operand (input relays 0004 through 007: 4 bits) is converted into a hexadecimal
number (0 to F). Only the bit at the position specified by the hexadecimal number is
set to "1" and other bits are set to "0". The resulting ON/OFF status is input back to
the internal register, and then output to inputs 1000 to 1015.
In the example, when the value specified by inputs 0004 to 0007 are converted into
"A", internal relay 1010 turns ON.
#3
#2
#1
Operand
#0
Internal register
1 0 1 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Internal register
F E D C B A 9 8 7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
0 to F
The DMX instruction is disabled when all bits in the internal register are OFF. In
such a case, special utility relay 2012 turns ON.
0000
LDA
#1
MPX
0500
STA
When the digital switch shows "8", output 0508 turns ON, therefore, lamp 8 lights.
Chapter 2 Instructions
3-177
12
0000
LDA
0500
STA
DMX
0000
LDA
DMX
TBCD
$00FF
ANDA
2002
0500
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
Instruction
LD
LDA
CON
DMX
LD
TBCD
CON
ANDA
CON
STA
Operand
2002
0000
2002
$00FF
0500
c
d
3-178
Chapter 2 Instructions
a : 0600
d : 0603
g : 0606
b : 0601
c : 0604
c : 0607
f : 0605
Auto-reset
counter
C000
#00009
C000
0000
C000
LDA
#0
MPX
1000
STA
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
$003F
LDA
0600
STA
$0006
LDA
0600
STA
$005B
LDA
0600
STA
$004F
LDA
0600
STA
$0066
LDA
0600
STA
$006D
LDA
0600
STA
$007D
LDA
0600
STA
$0007
LDA
0600
STA
$007F
LDA
0600
STA
$006F
LDA
0600
STA
7-segment display
12
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
Instruction
Operand
LDB
C000
C
000 #00009 0000
CON
LDA
C000
CON
MPX
#0
CON
STA
1000
LD
1000
LDA
$003F
CON
STA
0600
LD
1001
LDA
$0006
CON
STA
0600
LD
1002
LDA
$005B
CON
STA
0600
LD
1003
LDA
$004F
CON
STA
0600
Line No.
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
Instruction
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
Operand
1004
$0066
Chapter 2 Instructions
0600
1005
$006D
0600
1006
$007D
0600
1007
$0007
0600
1008
$007F
0600
1009
$006F
0600
3-179
LDB LD
FUN 4
LDB LD
LDB AND
FUN 4
@
Example
#,$ FUN
#,$ FUN
0000
0001
LDB AND
TBCD
TBCD
TBIN
TBIN
DM0000
LDA
TBCD
DM0001
STA
DM0010
LDA
TBIN
DM0011
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
@TBCD
CON
@STA
LD
LDA
CON
@TBIN
CON
@STA
Operand
0000
DM0000
DM0001
0001
DM0010
DM0011
Operands
Key operation
FUN
@
#,$
#,$
FUN
FUN
LDB
LDB
FUN
LD
AND
ENT
ENT
R-SRCH
R-SRCH
ENT
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009, 2010, 2011 No change
2012
Turns ON when the contents of the internal register are greater
than "$270F (#09999)" before TBCD operation, or when the
contents of the internal register are not BCD data before the
TBIN operation (In these cases, the TBCD or TBIN instruction
will not be executed.). Turns OFF at other times.
3-180
Chapter 2 Instructions
Description
Operation using the TBCD instruction
When input relay 0000 turns ON, the contents of DM0000 are transferred to the
internal register. The contents of the internal register (16-bit binary data) are converted into 4-digit BCD data, which is input back to the internal register, and then
transferred to DM0001.
216
20
0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
102
(0)
101
(2)
100
(4)
12
0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1
Note 1: The TBCD instruction can only convert data up to "#09999". When the
conversion of data of "#10000" or greater is attempted, special utility relay 2012
turns ON and the conversion is disabled.
Note 2: When the data in the internal register is not BCD data, special utility relay
2012 turns ON and the TBIN instruction is disabled.
C001
LDA
TBCD
#09999
C001
0000
0700
STA
Sets C001.
Converts current value of C001 into BCD data,
and outputs it to 0700 to 0715.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LDB
C
LD
LDA
CON
TBCD
CON
STA
Operand
0001
001 #00009 0000
2002
C001
0700
Chapter 2 Instructions
3-181
Internal register
TM00
Internal register
TM00
TM00
#10000
... TM01
Internal register
High-order 4 digits
Low-order 4 digits
Remainder
Display
0600 to 0615
High-order 4 digits
2002
0500 to 0515
Low-order 4 digits
TBCD
TM01
LDA
0500
STA
TBCD
0600
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
Instruction
LD
LDA
CON
MUL
CON
DIV
CON
STA
CON
LDA
Operand
2002
DM0000
DM0001
#10000
DM0101
TM01
Line No.
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
Instruction
CON
TBCD
CON
STA
CON
LDA
CON
TBCD
CON
STA
Operand
0500
DM0101
0600
0400
LDA
TBIN
C001
STA
#09999
C001
0000
0001
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
3-182
Instruction
LD
LDA
CON
TBIN
CON
STA
LDB
C
Chapter 2 Instructions
Operand
2002
0400
C001
0001
001 #09999 0000
RES ANL
Example
ASC
RES ANL
@
#,$ FUN 0
2
ASC
ORL ANL
RASC
RASC
FUN 0
FUN 3
@
#,$ FUN
0000
0001
ORL ANL
DM0000
LDA
ASC
DM0001
STA
DM0010
LDA
RASC
DM0011
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
@ASC
CON
@STA
LD
LDA
CON
@RASC
CON
@STA
Operand
0000
DM0000
DM0001
0001
DM0010
12
DM0011
Operands
Key operation
FUN
@
#,$
FUN
FUN
#,$
FUN
RES
ORL
ANL
ANL
ENT
ENT
R-SRCH
R-SRCH
ENT
ENT
R-SRCH
R-SRCH
Arithmetic flag
2009, 2010, 2011 No change
2012
Turns ON when the high- and low-order 8-bit value is not within
the range of "$30" to "$39" and "$41" to "$46", respectively,
before the RASC instruction is executed (In this case, the RASC
instruction will not be executed.). Turns OFF at other times.
Chapter 2 Instructions
3-183
Description
Operation using the ASC instruction
When input relay 0000 turns ON, the contents of DM0000 are transferred to the
internal register. The contents of the internal register (low-order 8-bit, 2-digit numerical value) are converted into 2-digit ASCII code. This 2-digit code is input back to the
internal register, and then transferred to DM0001.
1 0 1 0 0 1 0 1
0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 1
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0
The value is converted only when the high- and low-order 8-bit value of the internal
register is within the range of "$30" to "$39" and "$41" to "$46", respectively, before
the conversion. (When either of the high- or low-order 8-bit value is not within the
range, the conversion is disabled. In this case, special utility relay 2012 turns ON.)
Example of conversion between hex and ASCII numbers
Hex number
3-184
Bit configuration
Code
Bit configuration
$30
$31
$32
$33
$34
$35
$36
$37
$38
$39
$41
$42
$43
$44
$45
$46
Chapter 2 Instructions
ROOT / @ROOT
ORL ORB
FUN 3
#,$ FUN
ORL ORB
ROOT
ROOT
Example
0000 DM0001
LDA
TM00
STA
DM0000
LDA
ROOT
DM0100
STA
Coding
Line No.
Instruction
Operand
0000
LD
0000
0001
LDA
DM0001
0002
CON
0003
STA
0004
CON
0005
LDA
0006
CON
0007
ROOT
0008
CON
0009
STA
TM00
DM0000
DM0100
12
Description
The ROOT instruction takes the square root of 32-bit data (binary number) of
which the high-order 16 bits are contained in DM0001 and low-order 16 bits are
contained in DM0000, and then input the result to DM0100.
The figures to the right the decimal point of the obtained square root are omitted,
and the result is input back to the same register.
When the result is 0, special utility relay No. 2010 turns ON.
The ROOT instruction takes the square root of a 32-bit numerical value. In this
case, the high-order 16 bits are contained in TM00, and the low-order 16 bits are
contained in the internal register.
TM00
Internal register
Internal register
Operands
Key operation
FUN
@
#,$
FUN
ORL
ORB
ENT
ENT
R-SRCH
R-SRCH
Chapter 2 Instructions
3-185
DW
Operand
A<0
2009
A=0
2010
A>0
2011
Error
2012
$,# constant
Relay No.
LOAD A
LDA
Timer/counter No.
3-140
[FUN23]
$,# constant
# TM
STORE A
3-140
COMPARE
3-146
ADD
3-150
Mnemonic
SUBTRACT
3-150
MULTIPLY
3-150
DIVIDE
3-150
AND A
3-159
Relay No.
STA
Timer/counter No.
[FUN42]
# TM
$,# constant
# TM
CMP
[FUN04]
ADD
[FUN00]
SUB
[FUN46]
MUL
[FUN28]
DIV
[FUN11]
ANDA
[FUN01]
$,# constant
# TM
$,# constant
# TM
$,# constant
# TM
$,# constant
# TM
H9
$,# constant
# TM
3-186
Chapter 2 Instructions
3-161
EXCLUSIVE
OR A
3-164
SHIFT
RIGHT A
3-166
SHIFT
LEFT A
3-166
ROTATE
RIGHT A
3-169
ROTATE
LEFT A
3-169
COMPLEMENT
3-171
INCREMENT
MEMORY
3-172
DECREMENT
MEMORY
3-172
MULTIPLEXER
3-176
DEMULTIPLEXER
3-176
TRANSFER
BCD
3-180
TRANSFER
BIN
3-180
ASCII
CONVERT
3-183
REVERSE
ASCII
CONVERT
3-183
SQUARE
ROOT
3-185
TRIMMER
SETTING
3-138
Mnemonic
ORA
[FUN31]
EORA
[FUN15]
SRA
[FUN41]
SLA
[FUN40]
RRA
[FUN37]
RLA
[FUN40]
Operand
A<0
2009
A=0
2010
A>0
2011
Error
2012
$,# constant
# TM
$,# constant
# TM
Number of shifts
Number of shift
Number of rotations
Number of rotations
COM
[FUN05]
INC
[FUN19]
DEC
[FUN07]
MPX
[FUN27]
DMX
[FUN12]
TBCD
[FUN47]
TBIN
[FUN48]
ASC
[FUN02]
RASC
[FUN32]
ROOT
[FUN36]
TMIN
[FUN50]
12
Data memory No.
Digit No.
Chapter 2 Instructions
3-187
0 When, as a result of SHIFT or ROTATE, "1" is entered into 2009, it turns ON.
When "1" is not entered, it remains OFF.
A When as a result of INCREMENT MEMORY, the data of the data memory is "0",
the relay turns ON. When the data is not "0", the relay remains OFF.
B When as a result of DECREMENT MEMORY, the data of the data memory
EXCEEDS 16 BIT RANGE ($FFFF), the relay turns ON. When the data is within
the 16-bit range, the relay remains OFF.
C When there is no "ON" bit in the internal register at execution of
DEMULTIPLEXER, the relay turns ON. (In this case, "0" is entered in the internal
register.) When there is a "ON" bit(s), the relay remains OFF.
D When the data in the internal register exceeds $270F (#09999) at execution of
TRANSFER BCD, the relay turns ON. (In this case, TRANSFER BCD is not
executed.) When the data does not exceed $270F, the relay remains OFF.
E When the data in the internal register is not BCD data at execution of TRANSFER BIN, the relay turns ON. (In this case, TRANSFER BIN is not executed.)
When the data is BCD, the relay remains OFF.
F When the higher-order byte or lower-order byte in the internal register is respectively not within the range of $30 through $39, or the range of $41 through $46 at
execution of REVERSE ASCII CONVERT, the relay turns ON. (In this case,
REVERSE ASCII CONVERT is not executed.)
When the value is within the range, the relay remains OFF.
G When the input value for TRIMMER SETTING is "0", the relay turns ON.
When the value is not "0", the relay remains OFF.
H During indirect addressing, there is no data memory or relay by the number
specified by "TMxx".
I When the result of the arithmetic operation exceeds the 16-bit range, the relay
turns ON. When the result is within the 16-bit range, the relay remains OFF.
3-188
Chapter 2 Instructions
0500
0500
E
C
A
C
1000
1000
0500
0500
1000
1000
12
3. If the same coil is used in two positions, the latter position has priority and the
coil in the former position is ignored.
A
0500
0500
0500
4. The circuit shown below left cannot be programmed. Modify it as shown on the
right.
A
0500
0500
5. The circuit shown below left cannot be programmed. Modify it as shown on the
right.
A
C
0500
D
E
0500
A
0501
0501
Chapter 2 Instructions
3-189
Programming precautions
1. A coil output or timer/counter cannot be connected directly from a bus. When an
output coil or a timer/counter is required, insert a 'b' contact of an unused internal
utility relay, a 'b' contact of an unused special utility relay, or a special utility relay
2002 (always ON) as a dummy.
0500
0500
2002
#0010
T000
#0010
T000
0500
3. Make sure that every contact/coil is located on a path from a bus to an output
line. Make sure that there are no unconnected portions.
A
B
C
0500
4. Make sure that illegal short-circuits are not generated in parallel connections.
0500
A
0501
0500
B
D
0500
0501
6 . When the following program is entered with the programming support software
and sent to the KV, and then read from the KV with the software, reading is
disabled due to a "Reverse Compilation Error".
When a return is included in parallel connection in a ladder program, a
decompilation (reverse compilation) error is generated as shown below.
To prevent this error, change the ladder diagram to eliminate the return, or
separate the parallel connection.
3-190
Chapter 2 Instructions
Visual KV
Series
Chapter 3
Interrupts
The interrupt processing function executes an interrupt program when an external
input or request from the high-speed counter comparator (interrupt factor) is encountered during KV operation.
This chapter describes the types of interrupt factors as well as inputs and outputs
encountered during interrupt processing.
For KV-10/80 Series, see Chapter 6.
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3-194
3-195
3-196
3-196
3.3
3.3.1
3.3.2
3.4
3.4.1
3.4.2
3.4.3
3.4.4
3-198
3-199
3-200
3-201
This section describes the INT, RETI, DI, and EI instructions used for interrupt
processing.
INT: Interrupt
FUN
ANL RES
INT
nnnn
ORL LDB
RETI
FUN
Example
Coding for normal input
a)
0000
Normal
input
0000
#00020
T000
0500
T000
Line No.
0000
0001
0002
0003
0004
0500
Instruction
LD
OR
TMR
ANB
OUT
Operand
0000
0500
00 #00020
T000
0500
b)
Interrupt
input
2008
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
EI
0000
2002
HSP
0000
1000
#00020
T000
0500
T0
1000
(RES)
END
INT
0000
2002
1000
RETI
Instruction
LD
EI
LD
HSP
LD
OR
TMR
OUT
LD
RES
END
INT
LD
OUT
RETI
ENDH
Operand
2008
2002
0000
1000
0500
000 #00020
0500
T0
1000
0000
2002
1000
ENDH
(Input ON time: 10 s min.)
Description
Example a) shows a normal input and is used when input relay 0000 turns ON
longer than the input time constant (10 ms).
Example b) is used when input relay 0000 turns ON shorter than the scan time.
Operands
0000 to 0003
CTC0 to CTC3
Key operation
3-192
FUN
ANL
FUN
ORL
2
3
Chapter 3 Interrupts
RES
LDB
ENT
R-SRCH
Operand
ENT
ENT
R-SRCH
R-SRCH
ENT
R-SRCH
FUN
RES AND
DI
FUN
SET ORL
EI
8
3
Visual KV
Series
Example
1000
EI
1000
DI
Coding
Line No.
0000
0001
0021
0022
Instruction
LD
EI
LDB
DI
Operand
0000
1000
Description
Note 1: When any interrupt occurs between DI and EI instructions (interrupt disabled
period), the disabled interrupt is stored (to 8 levels max.). The stored interrupt is
executed as soon as an EI instruction is executed.
Note 2: If an INT CTC instruction is stored before a RES CTC instruction is executed, the stored INT CTC is deleted.
Operands
Key operation
FUN
RES
AND
FUN
SET
ORL
0
1
ENT
ENT
R-SRCH
R-SRCH
Chapter 3 Interrupts
3-193
13
For more about scan time, refer to "1.1.2 Scan Time" (p. 3-3).
Input
processing
Direct input *
Interrupt input
Scan
time
Program
execution
(0000 to 0015)
Interrupt
processing
Direct output
Output
processing
(0500 to 0503)
Direct input/output
The direct input/output functions are used during interrupt processing. Direct input
allows the KV PLC to fetch the input status of input relays 0000 through 0015 (KV10xx: 0000-0005, KV-16xx: 0000-0009) during execution of the interrupt program.
Direct output allows the Visual KV PLC to output the ON/OFF status of output relays
0500 through 0503 during execution of the interrupt program.
No special setting is required to use the direct input/output functions. The functions
can be used only by using the devices assigned for direct input/output within the
interrupt program.
Executing interrupts
The INT (Interrupt) instruction is used to execute an interrupt. Since an interrupt is
disabled at the start of operation, it is necessary to execute an EI (Interrupt enable)
instruction before using the INT instruction. In addition, the input time constant
should be set shorter by using the HSP instruction (to 10 s) or by specifying the
desired value in DM1940 and turning ON special utility relay 2813.
For more about the input time constant, refer to "1.4.1 Input Time Constant Change Function" (p. 323).
2002
2008
EI
3-194
Chapter 3 Interrupts
#00000
DW
DM1940
2813
SET
EI
or
2002
HSP
0000
Visual KV
Series
Interrupts can be divided into two types: an interrupt by an external input, and an
interrupt by the high-speed counter comparator. This section describes both of these
interrupt types.
INT0
Relay
No.
2402
Status
Relay
No.
OFF
OFF
ON
OFF
OFF
2403
ON
INT1
INT2
INT3
2404
2410
2412
OFF
OFF
2405
ON
ON
OFF
Description
ON
OFF
13
ON
ON
ON
OFF
OFF
ON
OFF
2411
OFF
ON
ON
OFF
ON
OFF
OFF
2413
ON
OFF
ON
CAUTION
Status
ON
ON
Input capture
Each external interrupt factor is provided with the input capture function. This is a
function which writes the value of the high-speed counter into the data memory
when an interrupt occurs. Without any particular settings, the value of the highspeed counter is automatically transferred to DM1928 through DM1935 when an
interrupt occurs.
External interrupt factor
Description
Occurrence of INT0
Occurrence of INT1
Occurrence of INT2
Occurrence of INT3
Chapter 3 Interrupts
3-195
CAUTION
Visual KV
Series
Timing of the input capture execution depends on the input polarity setting
specified with special utility relays 2402 through 2405 and 2410 through
2413.
END
INT
0000
Note 1: To shorten the input time constant, use the HSP instruction (to 10 s) or
specify the desired value in DM1940 and turn ON special utility relay 2813.
Note 2: For more about the input time constant, refer to "1.4.1 Input Time Constant
Change Function" (p. 3-23).
Note 3: Use SET-RES instructions instead of OUT-OUTB instructions within interrupt programs.
The following instructions cannot be used within interrupt programs:
TMR, TMH, TMS, DIFU, DIFD, W-ON, W-OFF, W-UE, W-DE, STG, JMP, ENDS,
HKEY, ITVL, @xxxx (differentiation type instructions), C, UDC, SFT
3-196
Chapter 3 Interrupts
Visual KV
Series
Direct input is available only with input relays 0000 through 0015 (KV-10xx: 00000005, KV-16xx: 0000-0009). (KV-300: 0000-0005)
The input time constant must be set to 10 s by using the HSP instruction or by
turning ON special utility relay 2813.
The direct input data is effective only within the interrupt program so that the
internal utility relay must be provided.
2008
EI
2002
HSP
0000
HSP
0005
1000
0500
END
INT
0000
0005
13
1000
SET
RETI
ENDH
HSP
0000
HSP
0001
END
INT
0000
2002
0500
SET
RETI
INT
0001
2002
0501
SET
RETI
ENDH
Chapter 3 Interrupts
3-197
Input 0000
ON
OFF
ON
Output 0500
ON
ON
ON
1 sec.
1 sec.
1 sec.
OFF
Ladder diagram
Converts the short pulses input from input relay 0000 into pulses of 1-second ON
width and then outputs them from output relay 0500.
Output relay 0500 turns ON for 1 second from the rising edge of input relay 0000.
2008
EI
0001
0002
HSP
0000
2002
0500
0003
#00010
T000
T0000
0500
RES
END
0004
INT
0002
0005
2002
0006
0500
SET
RETI
0007
ENDH
0008
3-198
Chapter 3 Interrupts
Visual KV
Series
Outline
Uses the input value of a high-speed counter from one input relay and the ON/OFF
status of another input relay to control the ON/OFF status of an output relay.
Scan
Input 0004
ON
OFF
Input 0000
ON
OFF
Output 0500
ON
OFF
ON
Visual KV
Sensor
13
Ladder diagram
Output relay 0500 turns ON when the input value of the high-speed counter from
input relay 0004 reaches "10000".
Output relay 0500 turns OFF when input relay 0000 turns ON.
0001
0002
0003
2008
EI
2002
2002
0000
0010
CTH0
0004
0500
RES
INT
CTC0
0007
0009
HSP
0004
END
0006
0008
CTH0
RES
# 10000
CTC0
0004
0005
2103
SET
2002
0500
SET
RETI
ENDH
Chapter 3 Interrupts
3-199
Visual KV
Series
Outline
Measures the pulse width of the pulse input to an input relay.
ON
Sensor input 0000
OFF
Pulse width (s)
Sensor
Visual KV
Ladder diagram
Special utility relay 2100 is turned ON to measure the pulse width using 1-s
units.
The values when input relay 0000 is ON is written into temporary data memory
TM02, and the values when input relay 0000 is OFF is written into data memory
DM1912. The pulse width can be obtained by subtracting the value of TM02 from
the value of DM1912.
The obtained value is written into data memory DM0000 (Unit: s).
2008
0001
EI
2002
HSP
0000
2002
CTH0
2100
0002
0003
END
0004
INT
0000
0005
2403
0006
2403
0007
DM1928
LDA
TM02
STA
DM1928
LDA
TM02
SUB
KEEP
SET
2403
DM0000
STA
RES
RETI
0008
ENDH
0009
3-200
Chapter 3 Interrupts
ON
OFF
ON
OFF
Visual KV
Series
Outline
Measures the period in which two input relays turn ON.
Visual KV
Sensor 1
Sensor 2
Ladder diagram
Measures the time from when input relay 0002 turns ON until input relay 0003
turn ON.
The measured value is written to data memory DM0000 (Unit: s).
2008
EI
2410
RES
2411
RES
2412
RES
2413
RES
0001
2002
0002
HSP
0002
0003
HSP
0003
2002
0004
CTH1
2200
END
0005
INT
0002
0006
RETI
0007
INT
0003
0008
2002
0009
0010
ENDH
0011
Chapter 3 Interrupts
3-201
13
Visual KV
Series
3-202
Chapter 3 Interrupts
Visual KV
Series
Chapter 4
High-speed Counters
This chapter describes high-speed counters and high-speed counter comparators,
which allow high-speed pulse measurement and pulse output, independent of the
scan time.
For KV-10/80 Series, see Chapter 6.
4.1
4.2
4.2.1
4.2.2
4.3
4.3.1
4.3.2
4.3.3
4.3.4
4.3.5
4.3.6
4.3.7
4.4
4.4.1
4.4.2
4.4.3
4.4.4
4.4.5
4.5
4.5.1
4.5.2
4.5.3
4.5.4
4.5.5
4.5.6
4.6
4.6.1
4.6.2
4.7
4.7.1
4.7.2
4.7.3
4.7.4
3-211
3-211
3-211
3-212
3-214
3-216
3-217
3-228
3-229
3-231
3-232
3-233
3-236
3-242
3-245
3-249
3-251
This section describes the CTH0, CTH1, and CTC instructions, which are used for
high-speed counters.
CTH
RES
CTH0
nnnn
CTH
SET
CTH1
nnnn
CTC: High-speed
counter comparator
CTC
#ddddd
CTCn
Example
2008
1)
2008
0000
HSP
0004
2103
SET
Input-enable relay
CTH0
RES
2)
CTH0
0004
3)
#60000
CTC0
0500
SET
CTC0
4)
0500
5)
Count input
#00030
T000
T000
CTC0
RES
0500
RES
Coding
3-204
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
2008
0009
LD
CTC0
0001
HSP
0004
0010
SET
0500
0002
LD
2008
0011
LD
0500
0003
SET
2103
000 #00030
0004
CON
0005
RES
CTH0
0012
TMR
0013
AND
T000
0014
RES
CTC0
0006
LD
0000
0015
CON
0007
CTH0
0004
0016
RES
0008
CTC0
#6000
0500
CTH0:
0004
2100 to 2102
CTH1:
0005
0500
2200 to 2202
CTC0 to 3:
Preset value
#00001 to #65535
Visual KV
Series
Operands
Key operation
RES
CTH
Clock input
SET
ENT
R-SRCH
CTC
Operand
Preset
value
ENT
R-SRCH
Description
1) Initializes the setting when power is turned on.
The HSP instruction sets the input time constant of input relay 0004 to 10 s.
The current value of CTH0 is reset as soon as it matches the preset value of
CTC0 when special utility relay 2103 is ON.
2) The counting is disabled when input relay 0000 is OFF. Counting starts (at 0004)
when input relay 0000 turns ON.
3) Sets "60000" as the preset value of the high-speed counter comparator.
4) When the current value of CTH0 reaches "60000", output relay 0500 turns ON
and the current value is reset.
5) Turns OFF both CTC0 and 0500 for three seconds after output relay 0500 turns
ON.
Tips
Unlike software-based counters, the high-speed counter is a hardware-based,
program-independent counter. It achieves an input response frequency of 30 kHz
without being affected by the scan time.
Input relays 0004 and 0005 can independently count the pulses with a 30 kHz
input response frequency.
Two-phase encoder input can be captured through two channels (30 kHz).
CTH0 uses input from relay 0004 as phase A input and input from relay 0006 as
phase B input (KV-10xx: 0000). CTH1 uses input from 0005 as phase A input
and input from 0007 as phase B input (KV-10xx: 0001).
Note: When phase differential input is used, pulses with a maximum frequency of 30
kHz can be counted, provided the pulses have a duty ratio of 1:1 (50%) and phase
difference of 90. Inputting pulses with an irregular duty ratio or phase difference will
decrease the allowable input frequency.
3-205
14
This section describes the outline and specifications for high-speed counters and
high-speed counter comparators featured with the Visual KV Series.
4.2.1
Internal clocks*
2100 (1.0 s)
2101 (10.0 s)
2102 (100.0 s)
16-bit high-speed
counter
CTH0
DM1928, DM1929(INT0)
DM1930, DM1931(INT1)
2103 to 2114
Control circuit
Phase A 0004
Phase B(0006)
External input
0004/0006
Internal clocks*
2200 (1.0 s)
2201 (10.0 s)
2202 (100.0s)
high-speed
counter
comparator
high-speed
counter
comparator
CTC0
CTC1
16-bit high-speed
counter
CTH1
(0007)
0005/0007
DM1932, DM1933(INT2)
DM1934, DM1935(INT3)
2203 to 2214
Control circuit
0500
External input
INT CTC0
INT CTC1
0501
Internal connection
for external clock
Phase A
Phase B 0005
0500
high-speed
counter
comparator
high-speed
counter
comparator
CTC2
CTC3
INT CTC2
INT CTC3
0009 (RESET) 2.
1. With the KV-10xx, the external input relay for CTH0 is 0004 (phase A)/0000
(phase B), and for CTH1 is 0005 (phase A)/0001 (phase B).
2. With the KV-10xx, the preset input relay for CTH0 is 0002, and for CTH1 is 0003.
For KV-10/80 user's
Max. response frequency: 10 kHz
* 2100 0.8 s
2101 6.4 s
2102 102.4 s
2200 0.4 s
2201 0.8 s
2202 3.2 s
3-206
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
Function
Internal clock used only for CTH0 (1 s)
Internal clock used only for CTH0 (10 s)
Internal clock used only for CTH0 (100 s)
Automatically clears CTH0 when comparator CTC0 turns ON.
Disables/enables direct output from 0500 when comparator CTC0
turns ON.
Turns OFF direct output from 0500 when comparator CTC0 turns ON.
Turns ON direct output from 0500 when comparator CTC0 turns ON.
Reverses ON/OFF status of output from 0500 each time comparator
CTC0 turns ON.
Disables/enables direct output from 0500 when comparator CTC1
turns ON.
Turns OFF direct output from 0500 when comparator CTC1 turns ON.
Turns ON direct output from 0500 when comparator CTC1 turns ON.
Reverses ON/OFF status of output from 0500 each time comparator
CTC1 turns ON.
Automatically clears CTH0 when comparator CTC1 turns ON.
Selects multiplication mode for CTH0.
OFF/OFF: No multiplication (1 pulse) ON/OFF: x2 OFF/ON: x4
ON/ON: 2 pulses
Visual KV
Series
Relay
No.
2100*
2101*
2102*
2103
* Read-only relay.
Multiplication
mode
2113
2114
No multiplication
(1 pulse)
OFF
OFF
x2
x4
2 pulses
ON
OFF
OFF
ON
ON
ON
14
Function
Internal clock used only for CTH1 (1 s)
Internal clock used only for CTH1 (10 s)
Internal clock used only for CTH1 (100 s)
Automatically clears CTH1 when comparator CTC2 turns ON.
Disables/enables direct output from 0501 when comparator CTC2
turns ON.
Turns OFF direct output from 0501 when comparator CTC2 turns ON.
Turns ON direct output from 0501 when comparator CTC2 turns ON.
Reverses ON/OFF status of output from 0501 each time comparator
CTC2 turns ON.
Disables/enables direct output from 0501 when comparator CTC3
turns ON.
Turns OFF direct output from 0501 when comparator CTC3 turns ON.
Turns ON direct output from 0501 when comparator CTC3 turns ON.
Reverses ON/OFF status of output from 0501 each time comparator
CTC3 turns ON.
Automatically clears CTH1 when comparator CTC3 turns ON.
2212
ON: Yes OFF: No
2213 Selects multiplication mode for CTH1.
2214 OFF/OFF: No multiplication (1 pulse) ON/OFF: x2 OFF/ON: x4 ON/ON: 2 pulses
* Read-only relay.
Multiplication
mode
2213
2214
No multiplication
(1 pulse)
OFF
OFF
x2
x4
2 pulses
ON
OFF
OFF
ON
ON
ON
3-207
Visual KV
Series
Relay
Function
No.
2400 Changes current value of CTH0 to preset value by external signal
2401 OFF/OFF: Not used ON/OFF: At rising edge OFF/ON: At falling edge ON/ON: Level
2406 Sets CTH0 as ring counter. ON: Yes OFF: No
2407
Data memory
DM No.
DM1900/DM1901
DM1902/DM1903
DM1904/DM1905
DM1906/DM1907
DM1908/DM1909
DM1910/DM1911
DM1912/DM1913
DM1914/DM1915
DM1916/DM1917
DM1918/DM1919
DM1920/DM1921
DM1922/DM1923
DM1924/DM1925
DM1926/DM1927
Description
Current value of 24-bit CTH0 (low-order bits/high-order bits) is read.
Current value of 24-bit CTH1 (low-order bits/high-order bits) is read.
Current value of 24-bit CTC0 (low-order bits/high-order bits) is read.
Current value of 24-bit CTC1 (low-order bits/high-order bits) is read.
Current value of 24-bit CTC2 (low-order bits/high-order bits) is read.
Current value of 24-bit CTC3 (low-order bits/high-order bits) is read.
Current value of 24-bit CTH0 (low-order bits/high-order bits) is written.
Current value of 24-bit CTH1 (low-order bits/high-order bits) is written.
Preset value of 24-bit CTC0 (low-order bits/high-order bits) is written.
Preset value of 24-bit CTC1 (low-order bits/high-order bits) is written.
Preset value of 24-bit CTC2 (low-order bits/high-order bits) is written.
Preset value of 24-bit CTC3 (low-order bits/high-order bits) is written.
Preset value of CTH0 (low-order bits/high-order bits) is written.
Preset value of CTH1 (low-order bits/high-order bits) is written.
4
Note 1: As with the internal register, the contents of data memory are stored as 16bit binary data.
Note 2: The contents of data memory are stored even when the Visual KV is turned
off or "ALL DATA MEMORY CLEAR" is executed. It is stored more than 20 days
with the KV-10xx, and more than two months with other models.
3-208
Operand
CTH0
CTH1
Measurement range
#00000 to 65535
When input relays 0004 and 0005 are selected as operands, they can be used as
high-speed counters with a response frequency of 30 kHz.
When special utility relays 2100 through 2102 and 2200 through 2202 are selected as operands, the high-speed counters can be used as high-speed timers.
When relay 0500 is selected as an operand for CTH1, CTH1 can count the clock
pulses produced by CTH0.
CTH0 and CTH1 can be used as 24-bit high-speed counters when the MEMSW
instruction is set.
"MEMSW instruction" (p. 3-92), "4.4.1 24-bit High-speed Counter" (p. 3-221), "4.3.4 Count Input
Method" (p. 3-212), "When using comparator output from other counters as count input" (p. 3-213).
The high-speed counter comparator (CTC) compares its preset value with the
value of the high-speed counter (CTH).
The CTC contact turns ON when the current value of the CTH matches the
preset value of the CTC.
Among CTC contacts, the ON/OFF status of output relays 0500 and 0501 can be
changed with hardware (direct output) or can be used to execute an interrupt. Set
special utility relays (2103 to 2112, 2203 to 2212) to change the ON/OFF status
of output relays 0500 and 0501.
The following table shows the relationship between the high-speed counters and
high-speed counter comparators.
High-speed
counter
CTH0
CTH1
High-speed counter
comparator
CTC0, CTC1
CTC2, CTC3
Preset value
range
#1 to 65535
Direct
output
0500
0501
Interrupts
INT CTC0, INT CTC1
INT CTC2, INT CTC3
Note 1: Once the high-speed counter comparator turns ON, it remains ON until a
RES instruction is encountered.
Note 2: When a high-speed counter comparator is used as an interrupt, the interrupt
is executed as soon as the current value of the high-speed counter reaches the
preset value of the comparator. At the same time, the contact for the high-speed
counter comparator automatically turns OFF.
Note 3: CTC2 or CTC3 cannot be used as comparators for CTH0; CTC0 or CTC1
cannot be used as comparators for CTH1.
Note 4: Do not specify "#00000" as the preset value for CTC0 through CTC3.
3-209
Visual KV
Series
14
Visual KV
Series
CTH0
2100
2101
2102
3-210
CTH1
2200
2201
2202
Period
1.0 s
10.0 s
100.0 s
The high-speed counters and high-speed counter comparators operate using data
specified with special utility relays.
Visual KV
Series
Current value
0 to 65535
Refer to "4.4.1 24-bit High-speed Counter" (p. 3-221) when using the 24-bit high-speed counter.
High-speed counter
comparator
CTC0
CTC1
CTC2
CTC3
14
Refer to "4.4.1 24-bit High-speed Counter" (p. 3-221) when using the 24-bit high-speed counter.
High-speed
counter
comparator
CTC0
CTC1
CTC2
CTC3
Special utility
relay
2104
2108
2204
2208
3-211
Visual KV
Series
Operation mode
CTH1
2113
2114
2407
2213
2214
2415
OFF
OFF
OFF
OFF
OFF
OFF
OFF
OFF
ON
OFF
OFF
ON
x2
ON
OFF
ON
OFF
x4
OFF
ON
OFF
ON
2-pulse method
(Phase A: count up, phase B: count down)
ON
ON
ON
ON
No multiplication
(single-phase
input)
Phase differential
input
Operation mode
The counting method can be selected from the following when external inputs are
used.
The ring counter function is available for each counting method.
For more about the ring counter, refer to "4.4.4 Ring Counter Function" (p. 3-225).
ON
OFF
ON
OFF
(Counter value)
CTH0
ON
OFF
ON
OFF
(Counter value)
CTH0
Phase B input can be ignored by turning ON special utility relay 2407 (for CTH0) or
2415 (for CTH1).
3-212
(Phase B)
0006
ON
OFF
Visual KV
Series
(Phase A)
0004
ON
OFF
(Counter value)
CTH0
0
(Phase A)
0004
(Phase B)
0006
ON
OFF
ON
OFF
(Counter value)
CTH0
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ON
OFF
ON
OFF
(Counter value)
CTH0
0500
OFF
(Counter value)
CTH1
3-213
14
Visual KV
Series
High-speed
counter
comparator
Relay No.
Operation
CTC0
2103
CTC1
2112
CTC2
2203
CTC3
2212
CTH0
CTH1
Note: Do not specify the same values for CTC0 and 1 (2 and 3) to automatically
reset the counter with both comparators.
Scan
CTH
CTH = CTC
CTH is reset by the output process of the scan which executes the RES CTH
instruction.
3-214
CTH is reset at execution of the CTH instruction during the scan after the inputenable relay turns OFF.
Resets the counter at the instant the external reset input relay turns ON.
The external reset is assigned to input relay 0008 (KV-10xx: 0002) for CTH0, and
input relay 0009 (KV-10xx: 0003) for CTH1.
The timing of the reset can be changed by setting relays 2400 and 2401 (for CTH0)
or 2408 and 2409 (for CTH1) as follows.
This reset operation is independent of the scan time.
High-speed
counter
CTH0
Relay No.
Status
2400
Relay No.
2408
Operation
OFF
OFF
ON
OFF
ON
ON
ON
OFF
OFF
OFF
ON
ON
OFF
2401
ON
CTH1
Status
OFF
2409
ON
Visual KV
Series
Scan
External
reset input
CTH
14
CTH is reset at the instant the external reset input relay turns ON.
Preset function
The current value of CTH can be changed to any desired value by using the external
reset function of input relays 0008 (KV-10xx: 0002) (for CTH0) or 0009 (KV-10xx:
0003) (for CTH1) specified with special utility relays 2400 and 2401 (for CTH0) or
2408 and 2409 (for CTH1). (The external reset function sets the value to "0".)
Write the desired value of the preset input into the following data memories:
DM No.
Description
3-215
The Visual KV Series has some different high-speed counter operations from the
conventional KV Series [KV-10/16/24/80R(W)/T(W)].
Input-enable relay
0001
Input-enable relay
CTH0
0004
Count input
With the conventional KV Series, the current value of the high-speed counter is
reset when the CTH instruction is executed while the input-enable relay is OFF.
However, the counter continues counting until the end of the scan time. As a
result, when the input-enable relay starts counting again, the counter may already be incremented by the length of the scan time.
With the Visual KV Series, the current value of the high-speed counter is reset at
the falling edge of the input-enable relay, so that the counter does not continue
counting.
3-216
2008
EI
2113
SET
2114
RES
2213
SET
2214
RES
2002
CTH0
RES
HSP
0004
Initial setting
SET 2113
Setting for CTH0
RES 2114
SET 2213 Setting for CTH1
RES 2214
Visual KV
Series
HSP
0005
HSP
0006
HSP
0007
0000
CTH0
0004
#60000
CTC0
CTH1
0005
END
INT
CTC0
2002
CTH1
LDA
#60000
CMP
2009
0500
RES
2009
0500
SET
CTH0
RES
2002
CTH1
RES
RETI
ENDH
#01000
LDA
DM0000
STA
#02000
LDA
DM0001
STA
#03000
LDA
DM0002
STA
2002
HSP
0005
0001
CTH1
0005
2002
CTH1
LDA
DM0000
CMP
2009
0500
DM0001
CMP
2009
0501
DM0002
CMP
2009
0502
3-217
14
Visual KV
Series
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
Instruction
LD
LDA
CON
STA
CON
LDA
CON
STA
CON
LDA
CON
STA
LD
HSP
LDB
Operand
2008
#01000
DM0000
#02000
DM0001
#03000
DM0002
2002
0005
0001
Line No.
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
Instruction
CTH1
LD
LDA
MPS
CMP
ANB
OUT
MRD
CMP
ANB
OUT
MPP
CMP
ANB
OUT
Operand
0005
2002
CTH1
DM0000
2009
0500
DM001
2009
0501
DM0002
2009
0502
2008
2002
4
2002
CTC2
3-218
0502
#00030
T001
T001
CTH1
RES
Line No.
Instruction
Operand
0000
LD
2008
HSP
0005
0001
SET
2203
0002
CON
CTH1
0005
0003
RES
0004
LD
2002
#60000
CTC2
0005
HSP
0005
CTC2
RES
CTH
0006
LD
2002
0007
CTH1
0005
0008
CTC2
#60000
0009
LD
CTC2
0010
OUT
0502
0011
CON
0012
TMR
0013
CON
0015
AND
T001
0016
RES
CTC2
001 #00030
Inputs phase differential signals from input relays 0004 and 0006 and counts
pulses at CTH0.
The count value is written to DM0000.
When the current value of CTH0 reaches "60000", clears the value, turns ON
output 0500, and stops counting at CTH0.
Input relay 0008 is used as an external reset.
2008
EI
2103
SET
2113
SET
2114
RES
2400
SET
2401
RES
CTH0
RES
Initial setting
Visual KV
Series
HSP
0004
2002
HSP
0006
HSP
0008
CTH0
0004
0500
#60000
CTC0
2002
CTH0
LDA
DM0000
STA
END
INT
CTC0
2002
0500
SET
RETI
ENDH
Cording
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
Instruction
LD
EI
CON
SET
CON
SET
CON
RES
CON
SET
CON
RES
CON
RES
LD
HSP
Operand
2008
2103
2113
2114
2400
2401
CTH0
2002
0004
Line No.
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
Instruction
HSP
HSP
LDB
CTH
CTC
LD
LDA
CON
STA
END
INT
LD
SET
RETI
ENDH
Operand
0006
0008
0500
0 0004
0 #60000
2002
CTH0
DM0000
CTC0
2002
0500
Initial setting
Special utility relays
Turn ON 2013 to reset the current value of CTH0 when CTC0 turns ON.
Turn ON 2113 and turn OFF 2114 to set the high-speed counter to double (x2)
multiplication mode.
Turn ON 2400 and turn OFF 2401 to enable the external reset.
3-219
14
Visual KV
Series
Uses the double (x2) multiplication mode to fetch phase differential input from the
encoder.
The fetched data is output as BCD data. Phase differential input: 0004, 0006 BCD
output: 0600 to 0615 (4 digits)
2008
2103
SET
2113
SET
2114
RES
CTH0
RES
2400
SET
Initial setting
HSP
0004
2002
HSP
0006
HSP
0008
CTH0
0004
0000
2002 #00000 TM00
LDA
STA
CTH0 #00002
LDA
DIV TBCD
0600
STA
END
ENDH
Cording
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0 0004
0000
LD
2008
0015
CTH
0001
SET
2103
0016
LD
2002
0002
CON
0017
LDA
#0000
0018
CON
0019
STA
0003
SET
0004
CON
0005
RES
0006
CON
0007
RES
0008
CON
0009
SET
0010
0011
0012
0013
0014
2113
2114
CTH0
0020
CON
0021
LDA
0022
CON
0023
DIV
2400
0024
CON
LD
2002
0025
TBCD
HSP
0004
0026
CON
HSP
0006
0027
STA
HSP
0008
0028
END
LD
0000
0029
ENDH
TM00
CTH0
#00002
0600
Initial setting
Special utility relays
Turn ON 2013 to reset the current value of CTH0 when CTC0 turns ON.
Turn ON 2113 and turn OFF 2114 to set the high-speed counter to double (x2)
multiplication mode.
Turn ON 2400 to enable the external reset.
3-220
This section describes the 24-bit high-speed counter and ring counter functions.
Visual KV
Series
Function of switch
ON
OFF
24-bit
16-bit
Function of switch
ON
OFF
24-bit
16-bit
Description
DM No.
14
Description
DM1900
DM1906
DM1901
DM1907
DM1902
DM1908
DM1903
DM1909
DM1904
DM1910
DM1905
DM1911
Write areas
DM No.
Description
DM No.
Description
DM1912
DM1918
DM1913
DM1919
DM1914
DM1920
DM1915
DM1921
DM1916
DM1922
DM1917
DM1923
3-221
Visual KV
Series
"Setting the 24-bit high-speed counter comparator" (below) and "4.4.2 Changing the Current Value of
a 24-bit High-speed Counter" (p. 3-223)
Note 1: Use the SET, RES instruction pair to set the special utility relays.
Note 2: The 16-bit/24-bit high-speed counter setting with the MEMSW instruction is
effective when the Visual KV is in RUN mode.
You must change the program to change between 16-bit and 24-bit settings.
For more about detailed operation, refer to "Chapter 3 Access Window" (p. 1-79), "Chapter 6
Handheld Programmer" (p. 1-195) and "Chapter 2 Instructions" (p. 3-33).
Note 1: When the preset value of a 24-bit CTC is changed with an instruction such
as STA CTC0, the value entered as an operand is ignored but the value written in
DM1916 through DM1923 is referred to and used as the preset value.
Note 2: Be sure to write the desired value to the write area of the high-speed
counter comparator preset value (DM1916 through DM1923) before executing the
change operation (e.g., STA instruction).
3-222
Change the current value of the 24-bit high-speed counter with the Access Window,
programming support software, handheld programmer, or operator panel with the
following procedure.
1. Write the desired current value into data memory.
Write the desired current value to the CTH current value write areas DM1912
through DM1915.
Visual KV
Series
For more about detailed operation, refer to "Chapter 3 Access Window" (p.1-79), "Chapter 6
Handheld Programmer" (p.1-195) and "Chapter 2 Instructions" (p.3-33).
Note 1: The current value of the high-speed counter cannot be changed in the
ladder program.
Note 2: DM1900 to DM1923, the data memories for 24-bit high-speed counters, can
be used only when a 24-bit high-speed counter is specified with the MEMSW instruction.
3-223
14
The following is a ladder program using a 24-bit high-speed counter and high-speed
counter comparator with a preset value of "1000000".
MEMSW
$0800
0001
0002
0003
0004
2008
2002
CTH0
RES
2)
HSP
0004
3)
CTH0
0004
4)
#65535
CTC0
5)
6)
Low-order 16 bits of
high-speed counter
comparator
CTC0
STA
Writes preset value of
high-speed counter
comparator
2002
0005
0006
2002
0007
High-order 16 bits of
current value of highspeed counter
Low-order 16 bits of
current value of highspeed counter
0008
END
ENDH
1) Sets CTH0 as the 24-bit high-speed counter with the MEWSW instruction. (Turn
on 3 of SW3.)
2) When power is turned on, writes the preset value "1000000" of the high-speed
counter comparator (CTC0) and sets the value with the STA CTC0 instruction.
3-224
1)
Visual KV
Series
Normally, the counter reads "#65535 ($FFFF)" by counting down from "0" by one.
The ring counter function is an additional function of the automatic clear function. It
reads "preset value - 1" when it counts down from "0" by one.
Operation of the ring counter function
Normal counter
0
65535
Ring counter
0
CTC1 -1
65535
( CTC3 -1)
Not used
Setting procedure
When setting the ring counter, use CTC1 for CTH0 and CTC3 for CTH1.
Set the upper limit (preset value) to CTC1 or CTC3 and turn ON special utility
relay 2406 (for CTH0) or 2414 (for CTH1). The ring counter is set to read "CTC1/
CTC3 preset value - 1" when it counts down from "0" by one.
To use the ring counter for both counting up/down operations, turn ON special
utility relay 2112 (for CTH0) or 2212 (for CTH1).
High-speed counter
14
Note 1: Use the SET-RES instruction pair to set the special utility relays.
Note 2: The flag or the count-up interrupt for each CTC is effective in counting up
operations, but is disabled in counting down operations.
Example: When CTC = 100
Count
up
Count
down
Turns ON.
CTC
CTH
0
97
98
99
99
98
97
3-225
Visual KV
Series
The following is a ladder program that uses the ring counter of a 16-bit high-speed
counter with the preset value of "10000".
0001
0002
9999
2008
EI
2113
SET
2114
RES
2406
SET
Sets ring
Sets high-speed counter in
counter.
double (x2) multiplication mode.
2002
2112
SET
0004
HSP
0006
2002
0005
0006
0500
#00010
T000
T000
CTH0
0004
3)
#10000
CTC1
4)
0500
RES
5)
INT
CTC1
0008
0009
2)
END
0007
1)
Automatic reset
of high-speed
HSP
counter
0003
0004
CTH0
RES
2002
0010
0011
0500
SET
6)
RETI
ENDH
1) When the power is turned on, an EI instruction enables interrupts. Sets highspeed counter CTH0 in double (x2) multiplication mode, CTH0 as a ring counter,
and the high-speed counter automatic reset function at counting up. Resets the
high-speed counter.
2) Sets the input time constant for input relays 0004 and 0006 to 10 s.
3) Counts 2-phase pulses of input relays 0004 and 0006 at CTH0.
4) Sets the preset value of high-speed counter comparator CTC1 to "10000".
5) Output relay 0500 turns ON for 1 second and then turns OFF.
6) When CTC1 turns ON, an interrupt is executed. Output relay 0500 turns ON.
3-226
Visual KV
Series
The following is a ladder program that uses the ring counter of a 24-bit high-speed
counter with the preset value of "100000".
99999
MEMSW
$0800
0001
0002
2008
EI
2114
RES
2406
SET
Sets high-speed
counter in double (x2)
multiplication mode.
Sets ring
counter.
CTH0
RES
2112
SET
High-order 16
bits of highspeed counter
comparator
2002
2)
Automatic reset of
high-speed counter
0003
0004
2113
SET
1)
Low-order 16
bits of highspeed counter
comparator
CTC1
STA
3)
Writes preset
value of highspeed counter
comparator.
HSP
0004
4)
HSP
0006
0005
0006
2002
0007
0008
0500
#00010
T000
T000
5)
#65535
CTC1
6)
0500
RES
7)
END
0009
INT
CTC1
0010
0011
CTH0
0004
0500
SET
2002
8)
RETI
0012
ENDH
0013
1) Sets CTH0 as a 24-bit high-speed counter using the MEMSW instruction (Turn
on 3 of SW3.).
2) When the power is turned on, an EI instruction enables interrupts. Sets highspeed counter CTH0 in double (x2) multiplication mode, CTH0 as a ring counter,
and high-speed counter automatic reset function at counting up. Resets the highspeed counter.
3) Writes the preset value "100000" of high-speed counter comparator (CTC1) for
the 24-bit high-speed counter (CTH0). Sets the preset value with the STA CTC0
instruction.
4) Sets the input time constant for input relays 0004 and 0006 to 10 s.
5) Counts 2-phase pulses of input relays 0004 and 0006 at CTH0.
6) Describes a dummy high-speed counter comparator.
7) Output relay 0500 turns ON for 1 second and then turns OFF.
8) When CTC1 turns ON, an interrupt is executed. Output relay 0500 turns ON.
3-227
14
Visual KV
Series
Stops pulse output when special utility relay 2306 is turned OFF.
Sets the preset value so that pulses are output at the frequency specified with
the DM. (Pulse duty ratio: fixed to 50%)
Starts pulse output.
Pulse duty
Pulse duty is the ratio of the pulse widths between ON time and OFF time. A pulse
duty of 50% means that the pulse widths between ON time and OFF time are the
same, as follows.
ON
OFF
Description
2306
2307
Data memory
DM No.
DM1936
3-228
Description
Preset value for specified frequency pulse output is written.
Setting method
Set the desired output frequency (Hz) into DM1936. The available range is 16 Hz
to 50 kHz (16 to 50000).
Pulses are output when special utility relay 2306 is ON. The output is stopped
when the relay is turned OFF.
If an unacceptable frequency is specified, special utility relay 2307 (error relay)
turns ON. Special utility relay 2306 is turned OFF and pulse output is stopped.
Note 1: The available minimum frequency specified in DM1936 is 16 Hz.
Note 2: The output is stopped when a value of 15 or less is specified in DM1936.
Note 3: Starts and stops of pulse output or frequency changes are executed after
each scan.
Note 4: It takes a maximum of 200 s from when the output command is issued until
pulses are output.
Note 5: CTH1 and special utility relays 2200 through 2215 cannot be used when the
specified frequency pulse output function is used.
Visual KV
Series
0001
0002
0003
2008
2002
2306
SET
#10000 DM1938
LDA
STA
0
TMIN
1)
DM1936
2)
STA
0500
2307
3)
END
0004
ENDH
0005
1) Sets the upper limit of the digital trimmer to "10000" and turns ON special utility
relay 2306 to start the specified frequency pulse output.
2) Sets the input value of the digital trimmer as the output frequency value.
3) Output relay 0500 turns ON when a setting error occurs.
3-229
14
Visual KV
Series
0000
1000
DIFU
1000
0001
1001
DIFU
1001
1101
1100
T000
2306
RES
1100
RES
DM1936 DM0000
LDA
CMP
2009
2011
1100
SET
1)
1101
SET
2)
1101
RES
3)
#00100
T
S 000
4)
00
CALL
5)
01
CALL
0500
2307
0008
END
0009
SBN
00
0010
2002
2011
TM02
STA
DM1936
LDA
TM02
ADD
7)
DM1936
STA
RET
0012
SBN
01
0013
0014
6)
2011
0011
2010
2306
SET
T000
0006
0007
#00016 DM1936
LDA
STA
2002
0015
0016
0017
2011
2011
TM02
STA
DM1936
LDA
TM02
SUB
8)
DM1936
STA
1) Sets "16" as the preset speed at the rising edge of input relay 0000. Turns ON
special utility relay 2306 to start the specified frequency pulse output. Then, turns
ON the operating flag.
2) Turns ON slow-down-stop flag 1101 at the rising edge of input 0001.
3) When the slow-down-stop flag turns ON, sets the preset speed to "16". When the
output frequency reaches "16", turns OFF the operation start flag, operating flag,
and slow-down-stop flag.
4) Activates a 100-ms flicker circuit while the operating flag turns ON.
5) Compares the current speed and preset speed every 100 ms. Executes subroutine 0 when the preset speed is faster, and executes subroutine 1 when the
preset speed is slower.
6) Output relay 0500 turns ON when a setting error occurs.
7) Acceleration process. When the current speed is slower than the preset speed by
less than "100", the speed is accelerated by the difference. When the difference
is "100" or more, the speed is accelerated by "100".
8) Deceleration process. When the current speed is faster than the preset speed by
less than "100", the speed is decelerated by the difference. When the difference
is "100" or more, the speed is decelerated by "100".
3-230
High-speed counter CTH0 is used. Write the interval (ms) of frequency measurement into data memory DM1404 and turn ON special utility relay 2305. The measurement result (Hz) is written into DM1405.
Input relay 0004 is for pulse input (single-phase input). Input relay 0006 (phase B
input) is ignored.
Devices used with the frequency counter
Special utility relays
Relay No.
2305
Visual KV
Series
Description
Use frequency counter. ON: Yes, OFF: No
Data memory
DM No.
Description
DM1404
DM1405
Operation flow
1. Set the high-speed counter with external input. Use the END instruction and
measure how much time has elapsed since the last measurement in units of 10
s. After each scan, pulses are counted within the time specified with the data
memory. The frequency is calculated from the count value and written into data
memory.
2. When the time specified with DM1404 elapses from the last measurement, the
current value of CTH0 is fetched and divided by the elapsed time (Unit: 10 s).
The frequency is obtained with the following calculation.
Frequency (Hz) = (100,000 x Pulse count)/Elapsed time (Unit: 10 s)
3. The calculation result (Hz) is written into DM1405.
Setting method
1. Specify the counting period for the frequency counter (the interval of frequency
measurement [Unit: ms]) in data memory DM1404.
2. The preset value must be greater than the scan time. When a value smaller than
the scan time is specified, the frequency is measured each scan time.
Note 1: To use the frequency counter function, set the input time constant to 10 s
with the HSP instruction or the special utility relay. (A maximum frequency of 30 kHz
can be measured.).
Note 2: The counting start/stop or measurement result is updated after each scan.
Therefore, the counting period includes some scan time errors for the time specified
with DM1404. Set the counting period so that overflow does not occur at CTH.
Note 3: Specify the counting period so that the number of pulse inputs in one period
is between 2 and 65535, inclusive.
Note 4: Measurement may fail when the pulse period is 5000 ms or more.
Note 5: The frequency counter cannot be used when CTH0 is used in the ladder
program.
Note 6: Special utility relays concerning CTH0, CTC0/1, and the cam switch cannot
be used.
Note 7: CTH0 and the cam switch function cannot be used when the frequency
counter is used.
3-231
14
Visual KV
Series
0001
0002
0003
2008
#01000 DM1404
LDA
STA
2002
2002
2305
SET
1)
HSP
0004
2)
DM1405 DM0000
3)
LDA
STA
END
0004
ENDH
0005
1) Sets the counting period to "1000 ms (1 second)" and turns ON special utility
relay 2305 to start the frequency counter function.
2) Sets the input time constant for input relay 0004 to 10 s.
3) Stores the measured frequency (Hz) into data memory DM0000.
Program for synchronous control
The following ladder program illustrates synchronous control using the frequency
counter and pulse output functions.
Measures the frequency of pulses at input relay 0004 every 100 ms and outputs
pulses of the same frequency from output relay 0501.
4
0001
0002
0003
0004
2008
2002
2002
2307
0005
0006
#00100 DM1404
LDA
STA
2305
SET
2306
SET
1)
HSP
0004
2)
DM1405 DM1936
LDA
STA 3)
0500
4)
END
ENDH
1) Sets the counting period to "100 ms" and turns ON special utility relays 2305 and
2306 to start the frequency counter and the specified frequency pulse output
functions.
2) Sets the input time constant for input relay 0004 to 10 s.
3) Uses the measured frequency (Hz) as the preset value for the output frequency
(Hz).
4) Turns on output relay 0500 when an error occurs in the setting of the specified
frequency pulse output.
3-232
Visual KV
Series
The cam switch function has two modes: cam switch mode, which simulates cam
operation; and multi-step comparator mode, which compares the value written in
DM1401 with multiple values.
Devices used with the cam switch function
Special utility relays
Relay No.
2314
2315
2715
Description
Start relay
Error relay
In-operation relay
The preset value in the data memory is registered at the rising edge of the start
relay. When the preset value is changed, turn OFF special utility relay 2314 once
and then turn it ON again to register the new value.
Timing diagram of cam switch function
Start relay
2314
In-operation
relay
2715
Cam switch
Stopped
function
Executed
Stopped
Description
DM1400
DM1402
Twice the pulse numbers for one rotation of the device connected to
CTH0 (1 to 65534)
DM1406/DM1407
DM1408/ DM1409
Angle at which first output relay turns ON/OFF (Unit: 0.1 deg.)
(0 to 65534)
Angle at which second relay turns ON/OFF (Unit: 0.1 deg.)
(0 to 65534)
DM1468/DM1469
DM1470
3-233
14
Visual KV
Series
Even a single phase incoder can be used by changing a part of the cam switch
function.
To activate the multi-step comparator mode, write the value to be compared into
data memory DM1401 to replace the CTH0 value. This value determines the resolution. If 360 is written in DM1401, and 60 is written in DM1406, the 1st relay is turned
ON at 60/360 i.e. 60.
Devices used in multi-step comparator mode
Data memory
DM No.
Description
DM1400
DM1401
DM1402
DM1406/DM1407
DM1408/ DM1409
DM1468/DM1469
DM1470
Setting method
In cam switch mode
1. Write the initial number of output relays to be used into DM1400.
Be sure to write the initial relay number of each channel.
Example
0500, 0600: Acceptable, 0501, 0610: Unacceptable
3-234
3-235
Visual KV
Series
7. Repeat steps 3 through 6 as many times as the number of relays to be used (32
relays max.).
14
Visual KV
Series
The following ladder program illustrates the basic setting of the cam switch function.
Connect the encoder with a resolution of 360 pulses.
Use output relays 0600 through 0603.
Output relay 0600: Turns ON within the range 30 to 90
Output relay 0601: Turns ON within the range 45 to 80
Output relay 0602: Turns ON within the range 70 to 150
Output relay 0603: Turns ON within the range 120 to 270
0001
2008
0002
0003
2002
2)
3)
0004
HSP
0006
4)
0005
HSP
0008
5)
0006
0007
0000
0001
1000
DIFU
1000
1001
DIFU
1001
2314
SET
6)
2715
RES
7)
END
0008
ENDH
0009
1)
1) Sets "0600", which is the initial number of relays used for the cam switch function, to
DM1400 and sets twice the number of pulses for one encoder rotation (360 x 2 = 720) to
DM1402.
2) Specifies the preset angles at which output relays 0600 through 0603 turn ON/OFF.
3) Sets the input time constant for input relay 0004 to 10 s.
4) Sets the input time constant for input relay 0006 to 10 s.
5) Sets the input time constant for input relay 0008 to 10 s.
6) The cam switch operation starts when input relay 0000 turns ON.
7) The cam switch operation stops when input relay 0001 turns ON.
3600
(360)
30 DM1406
45 DM1408
70 DM1410
80 DM1409
270
DM1413
90 DM1407
120 DM1412
150 DM1412
Timing Diagram
DM1406
ON
OFF
DM1407
DM1408
DM1409
DM1410
DM1412
3-236
DM1411
90
DM1413
180
270
360
Rotation ()
Visual KV
Series
This section describes the outline and setting method for direct clock pulse output.
The period (frequency) and width of the pulses are determined by the period of the
internal clock used for the high-speed counter (CTH) and high-speed counter comparator (CTC).
The period of the clock pulse (frequency) can be changed with the program within
the following ranges.
Output
Internal clock
0500
0501
2100 (1.0 s)
2101 (10.0 s)
2102 (100.0 s)
2200 (1.0 s)
2201 (10.0 s)
2202 (100.0 s)
Pulses of the internal clock are counted with the high-speed counter (CTH). When
the number of current pulses reaches the preset value of the high-speed counter
comparator (CTC), the ON/OFF status of output relays 0500 and/or 0501 is toggled
to output direct clock pulses.
Count value
CTC
ON
ON
Note 1: The operation of output relays 0500 and 0501 are determined by setting the
special utility relays.
Note 2: For more about setting special utility relays, refer to "4.2 Outline of Highspeed Counters" on page 3-206.
Note 3: The ON/OFF status when the direct clock pulse output is started is the
same as when the last direct clock pulse output is stopped. (Initial status: OFF)
Note 4: Output relays 0500 and 0501 cannot be used in a normal program during
direct clock pulse output.
3-237
14
Pulse width
Pulse period
ON
OFF
Pulse
width
Pulse period
Note: The pulse width determined above is the pulse width produced inside the
Visual KV PLC. In reality, the output pulse width may vary depending on the response delay of the output circuit and the load connected to this circuit. Be sure to
determine the pulse width after monitoring the actual output waveform with an
oscilloscope. (Monitor the pulses of variable pulse width.)
3-238
Pulse period
Pulse period (s) = 1,000,000 Frequency (Hz)
CTC preset value for pulses with 1:1 ON/OFF ratio (using one comparator)
CTC preset value = Pulse period (s) Internal clock (s) 2
Visual KV
Series
ON
Pulse
width
OFF
Pulse period
Pulse
width
Pulse period
Period
2100
2200
1.0 s
10 to 65535
2101
2201
10.0 s
1 to 65535
2102
2202
100.0 s
1 to 65535
Note 1: Set the CTC preset value to 10 or more when the operands for the highspeed counter (CTH) is 2100 and 2200. The clock pulse output may be improper
when the preset value is set to less than 10.
Note 2: The pulse width may vary depending on the load connected to the circuit.
Be sure to determine the pulse width after monitoring actual output waveform with
an oscilloscope.
Note 3: When CTC0 and CTC1, or CTC2 and CTC3, are used to output the clock
pulse, do not specify the same value for the preset values of CTC0 and CTC1, or of
CTC2 and CTC3.
3-239
14
Visual KV
Series
High-speed
counter
comparator
CTC0
CTC1
Special
utility
relay
2103
ON: Yes
OFF: No
2104
ON:
Disable
OFF:
Enable
2105
ON: Yes
OFF: No
2106
ON: Yes
OFF: No
2107
ON: Yes
OFF: No
2108
ON:
Disable
OFF:
Enable
2109
ON: Yes
OFF: No
211
ON: Yes
OFF: No
2111
ON: Yes
OFF: No
2112
ON: Yes
OFF: No
Note: If two or more relays of special utility relays 2104 through 2107 or 2108
through 2111 are turned ON, priority is given to the relay with the smaller number.
Operation of output 0500 by setting special utility relays
Outputting a pulse with 1:1 ON/OFF ratio
2108 OFF
2103 ON
2108 OFF
2104 OFF
2109 OFF
2104 OFF
2109 ON
2105 OFF
2110 OFF
2105 OFF
2110 OFF
2106 OFF
2111 OFF
2106 ON
2111 OFF
2107 ON
2112 OFF
2107 OFF
2112 OFF
Count value
Count value
CTC0
CTC1
CTC0
ON
3-240
ON
ON
ON
ON
ON
Special
utility relay
CTC2
2203
ON: Yes
OFF: No
2204
ON:
Disable
OFF:
Enable
2205
2206
2207
2208
2209
CTC3
2210
2211
2212
OFF: No
OFF: No
OFF: No
OFF:
Enable
OFF: No
OFF: No
OFF: No
OFF: No
2208 ON
2204 OFF
2205 OFF
2208 OFF
2209 OFF
2204 OFF
2209 ON
2210 OFF
2205 OFF
2210 OFF
2206 OFF
2211 OFF
2206 ON
2211 OFF
2207 ON
2212 OFF
2207 OFF
2212 OFF
Count value
Count value
CTC2
CTC2
CTC3
ON
ON
ON
ON
ON
Visual KV
Series
ON
3-241
14
This section describes programming examples of the direct clock pulse output.
Setting
2103
ON
2104
OFF
2105
OFF
2106
OFF
2107
ON
Obtain the preset value of CTC0 by substituting 1 ms for the pulse period and 10 s
for the internal clock (special utility relay 2101).
In this case, the preset value of CTC0 is "50".
Refer to the following table for the preset value of CTC0 with other internal clocks.
Special utility relay
Internal clock
2100
1.0 s
500
2101
10.0 s
50
2102
100.0 s
Example
Count value
0001
2008
2103
SET
2104
RES
2105
RES
3-242
2107
SET
CTH0
RES
0002
CTH0
2101
0003
#00050
CTC0
2002
2106
RES
CTC0
ON
ON
Sets the pulse output from output relay 0500 with special utility relays 2104 through 2107.
In this example, turns OFF 2104 to enable direct output from 0500 and turns ON 2107 to
reverse the output each time the CTH0 value reaches the CTC0 value.
Turns ON 2103 to set CTH0 to be cleared when its value reaches the CTC0 value.
With this setting, the operation which clears the CTH0 current value when it reaches the
CTC0 preset value is repeated.
The RES CTH0 instruction resets the CTH0 current value when operation starts. This
ensures that the first clock pulse is output at the proper pulse width.
Turn ON the input enable relay for CTH0 all the time when CTH0 is used to output the
clock pulse.
Operand
2008
2103
2104
2105
Line No.
0008
0009
0010
0011
0012
0013
0014
Instruction
CON
SET
CON
RES
LD
CTH
CTC
Operand
2107
CTH0
2002
0 2101
0 #00050
Visual KV
Series
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
2106
Note :When the input enable relay for the high-speed counter is used to start/stop
the clock pulse, the response is delayed by a maximum of one scan when output
starts. Moreover, if the response is delayed by one scan when output stops, the
clock pulse stops but the output may remain ON.
Tips
Use special utility relay 2105 to control (enable/disable) the clock pulse output by
external inputs.
Use the SET-RES pair or KEEP instruction to turn special utility relay 2105 ON/
OFF.
With this setting, the clock pulse is always turned OFF when it starts as well as
stops.
When either of the following programs is added to the example on the previous
page, the clock pulse is output from 0500 only when 0000 is ON.
When SET-RES instructions are used
0000
2105
SET
0000
0000
2105
RES
0000
KEEP
SET
2105
RES
Setting
2203
ON
2204
OFF
2205
OFF
2206
OFF
2207
ON
3-243
14
Visual KV
Series
Internal clock
2200
1.0 s
500
2201
10.0 s
50
2202
100.0 s
Example
Count value
0001
2008
2203
SET
2204
RES
2205
RES
2206
RES
2207
SET
CTH1
RES
0002
CTH1
2201
0003
#00050
CTC2
2002
CTC2
ON
ON
Sets the pulse output from output relay 0501 with special utility relays 2204 through 2207.
In this example, turns OFF 2204 to enable direct output from 0501 and turns ON 2207 to
reverse the output each time the CTH1 value reaches the CTC2 value.
Turns ON 2203 to set CTH1 to be cleared when its value reaches the CTC2 value.
With this setting, the operation which clears the CTH1 current value when it reaches the
CTC2 preset value is repeated.
The RES CTH1 instruction resets the CTH1 current value when operation starts. This
ensures that the first clock pulse is output at the proper pulse width.
Turn ON the input enable relay for CTH1 all the time when CTH1 is used to output the
clock pulse.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LD
SET
CON
RES
CON
RES
CON
RES
Operand
2008
2203
2204
2205
Line No.
0008
0009
0010
0011
0012
0013
0014
Instruction
CON
SET
CON
RES
LD
CTH
CTC
Operand
2207
CTH1
2002
1 2201
2 #00050
2206
Note :When the input enable relay for the high-speed counter is used to start/stop
the clock pulse, the response is delayed by a maximum of one scan when output
starts. Moreover, if the response is delayed by one scan when output stops, the
clock pulse stops but the output may remain ON.
Tips
Use special utility relay 2205 to control (enable/disable) the clock pulse output by
external inputs.
Use the SET-RES pair or KEEP instruction to turn special utility relay 2205 ON/
OFF.
With this setting, the clock pulse is always turned OFF when it starts as well as
stops.
When either of the following programs is added to the example on the previous
page, the clock pulse is output from 0501 only when 0000 is ON.
When SET-RES instructions are used
3-244
0000
2205
SET
0000
0000
2205
RES
0000
KEEP
SET
2205
RES
Setting
Relay No.
Setting
2103
ON
2108
OFF
2104
OFF
2109
ON
2105
OFF
2110
OFF
2106
ON
2111
OFF
2107
OFF
2112
OFF
Visual KV
Series
To output a clock pulse of 500 s (2 kHz)-period and 200 s-width from output relay 0500
Internal clock
2100
1.0 s
500
200
2101
10.0 s
50
20
2102
100.0s
Example
Count value
0001
2008
0002
2103
SET
2104
RES
2105
RES
2106
SET
2107
RES
2108
RES
2109
SET
2110
RES
2111
RES
CTH0
RES
0003
CTH0
2101
0004
#00050
CTC0
0005
#00020
CTC1
2002
CTC0
CTC1
ON
ON
ON
ON
Sets the pulse output from output relay 0500 with special utility relays 2104 through 2107
and 2108 through 2111.
In this example, turns OFF 2104 to enable direct output from 0500. Turns ON 2106 to turn
ON the output from 0500 when the CTH0 value reaches the CTC0 value, and turns ON
2109 to turn OFF the output when the CTH0 value reaches the CTC1 value.
Turns ON 2103 to set CTH0 to be cleared when its value reaches the CTC0 value. This
ensures that the first clock pulse is output at the proper pulse width.
Turn ON the input enable relay for CTH0 all the time when CTH0 is used to output the
clock pulse.
3-245
14
Visual KV
Series
Coding
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
2008
0013
CON
0001
MPS
0002
SET
0003
CON
0004
RES
0005
CON
0006
RES
0007
CON
0008
RES
0009
CON
0010
RES
0011
MPP
0012
RES
2103
2104
2105
2106
2107
0014
SET
0015
CON
0016
RES
0017
CON
0018
RES
0019
CON
0020
RES
Operand
2109
2110
2111
CTH0
0021
LD
2002
0022
CTH
0 2101
0023
CTC
0 #00050
0024
CTC
1 #00020
2108
Note 1: When the input enable relay for the high-speed counter is used to start/stop
the clock pulse, the response is delayed by a maximum of one scan when output
starts. The response is also delayed by a maximum of one scan when output stops.
Note 2: Refer to the following "Tips" to start and stop the clock pulse.
Tips
Use special utility relay 2105 to control (enable/disable) the clock pulse output by
external inputs.
Use the SET-RES pair or KEEP instruction to turn special utility relay 2105 ON/
OFF.
With this setting, the clock pulse is always turned OFF when it starts as well as
stops.
When either of the following program is added to the example on the previous
page, the clock pulse is output from 0500 only when 0000 is ON.
3-246
0000
2105
SET
0000
0000
2105
RES
0000
KEEP
SET
2105
RES
You can change the period (frequency) of the clock pulse by changing the CTC0
preset value using the LDA and STA instructions.
To change the period of the clock pulse, refer to "4.3.4 Count Input Method" (p.3212).
Setting
Relay No.
Setting
2203
ON
2208
ON
2204
OFF
2209
OFF
2205
OFF
2210
OFF
2206
ON
2211
OFF
2207
OFF
2212
OFF
Visual KV
Series
This section describes a programming example that will output a clock pulse with
variable ON/OFF ratio from output relay 0501 by using the high-speed counter
(CTH1) and high-speed counter comparator (CTC2 and CTC3).
Internal clock
2200
1.0 s
500
200
2201
10.0 s
50
20
2202
100.0 s
Example
Count value
0001
2008
2208
RES
0002
2203
SET
2204
RES
2206
SET
2207
RES
2209
SET
2210
RES
2211
RES
CTH1
RES
0003
CTH1
2201
0004
#00050
CTC2
0005
#00020
CTC3
2002
CTC2
CTC3
ON
ON
ON
ON
Sets the pulse output from output relay 0501 with special utility relays 2204 through 2207
and 2208 through 2211.
In this example, turns OFF 2204 to enable direct output from 0501. Turns ON 2206 to turn
ON the output from 0501 when the CTH1 value reaches the CTC2 value and turns ON
2209 to turn OFF the output when the CTH1 value reaches the CTC3 value.
Turns ON 2203 to set CTH1 to be cleared when its value reaches the CTC2 value. This
ensures that the first clock pulse is output at the proper pulse width.
Turn ON the input enable relay for CTH1 all the time when CTH1 is used to output the
clock pulse.
3-247
14
Visual KV
Series
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
MPS
SET
CON
RES
CON
SET
CON
RES
MPP
RES
CON
Operand
2008
2203
2204
2205
2207
2208
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
Instruction
SET
CON
RES
CON
RES
CON
RES
LD
CTH
CTC
CTC
Operand
2209
2210
2211
CTH1
2002
1 2201
2 #00050
3 #00020
Note :When the input enable relay for the high-speed counter is used to start/stop
the clock pulse, the response is delayed by a maximum of one scan when output
starts. The response is also delayed by a maximum of one scan when the output
stops.
Tips
Use special utility relay 2205 to control (enable/disable) the clock pulse output by
external inputs.
Use the SET-RES pair or KEEP instruction to turn special utility relay 2205 ON/
OFF.
With this setting, the clock pulse is always turned OFF when it starts as well as
stops.
When either of the following programs is added to the example on the previous
page, the clock pulse is output from 0501 only when 0000 is ON.
3-248
0000
2205
SET
0000
0000
2205
RES
0000
KEEP
SET
2205
RES
You can change the period (frequency) of the clock pulse by changing CTC2
preset value using LDA and STA instructions.
To change the period of the clock pulse, refer to "4.3.4 Count Input Method" on
page 3-212.
This section describes a programming example that will output a clock pulse of 500
s (2 kHz)-period and 200 s-width from output relay 0500 and then stop it after
10000 pulses are output.
Special utility relay, internal clock, and CTC settings
Set the special utility relay according to the following table.
Relay No.
2103
2104
2105
2106
2107
Setting
ON
OFF
OFF
ON
OFF
Relay No.
2108
2109
2110
2111
2112
Visual KV
Series
Setting
OFF
ON
OFF
OFF
OFF
Specify the internal clock and CTC0/CTC1 preset values according to the following
table.
Special utility relay
2100
2101
2102
Internal clock
1.0 s
10.0 s
100.0 s
Example
2103
SET
2104
RES
2105
SET
2106
SET
2107
RES
0002
2108
RES
2109
SET
2110
RES
2111
RES
CTH0
RES
0003
2203
SET
#00000
DW
DM1940
2813
SET
CTH1
RES
1000
DIFU
1000
0001
2008
EI
0000
0004
0005
CTH0
2101
0006
#00050
CTC0
0007
#00020
CTC1
2002
0008
CTH1
0500
0009
#10000
CTC2
2002
14
2105
RES
END
0010
INT
CTC2
0011
2002
0012
2105
SET
RETI
0013
ENDH
0014
Sets the pulse output from output relay 0500 with special utility relays 2104 through 2107
and 2108 through 2111.
In this example, turns OFF 2104 to enable direct output from 0500. Turns ON 2106 to turn
ON the output from 0500 when the CTH0 value reaches the CTC0 value and turns ON
2109 to turn OFF the output when the CTH0 value reaches the CTC1 value.
Turns ON 2103 to set CTH0 to be cleared when its value reaches the CTC0 value. This
ensures that the first clock pulse is output at the proper pulse width.
Uses an EI instruction to enable interrupts.
The interrupt program (INT CTC2) stops the clock pulse when the CTH1 current value
reaches the CTC2 preset value (when 10000 pulses are output).
Turns ON 2203 to set CTH1 to be cleared when its value reaches the CTC2 value. This
forces the operation to repeat by the specified pulses (10000).
Relay 2813 must be turned ON when counting pulses with CTH1.
3-249
Visual KV
Series
The input enable relay for CTH0 must be ON all the time when CTH0 is used to output the
clock pulse.
The input enable relay for CTH1 must be ON all the time when CTH1 is used to count the
clock pulse.
Specifies the internal clock (2101) as the clock input for CTH0. Specifies 0500 as the
clock input for CTH1. With this setting, CTH0 is used to output the clock pulse, and CTH1
is used to count the clock pulse.
Specifies the number of clock pulses to the CTC2 preset value.
The clock pulse output starts when input 0000 is turned ON.
To restart the clock pulse output after it stops, turn ON input 0000 again.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
Instruction
LD
EI
CON
MPS
SET
CON
RES
CON
SET
CON
SET
CON
RES
MRD
RES
CON
SET
CON
RES
CON
RES
CON
RES
MPP
Operand
2008
Line No.
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
2103
2104
2105
2106
2107
2108
2109
2110
2111
CTH0
Instruction
Operand
SET
2203
CON
DW
#00000 DM1940
CON
SET
2813
CON
RES
CTH1
LD
0000
DIFU
1000
CON
AND
1000
RES
2105
LD
2002
CTH
0 2101
CTC
0 #00050
CTC
1 #00020
LD
2002
CTH
1 0500
CTC
2 #10000
END
INT
CTC2
LD
2002
SET
2105
RET1
ENDH
Tips
Special utility relays 2103 through 2111 can be turned ON/OFF by using the LDA
and STA instructions instead of the SET-RES instructions.
The example program below can be changed as follows by using the LDA and STA
instructions. The number of lines and steps can be reduced.
2008
EI
2103
SET
2104
RES
2105
SET
2106
SET
2107
RES
2108
RES
2109
SET
2110
RES
2111
RES
CTH0
RES
2203
SET
2813
SET
CTH1
RES
$0268
LDA
2008
EI
2100
STA
CTH0
RES
2203
SET
2813
SET
CTH1
RES
LDA $0268
When LDA $0268 is executed, the value specified by the operand is written into
the internal register as follows.
[0]
Internal register
[2]
0
[6]
1
[8]
1
When STA 2100 is executed, the value in the internal register is assigned to
special utility relays 2100 through 2115.
xx 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Special utility
relay 21xx
3-250
Sta
rt
Re
ou vers
tpu e
t
Em
sto erge
p
nc
Visual KV
Series
24 VDC
Twisted-pair cable
COM
0001
+
CW (Pulse)
+
CCW (Rotation
0003
0002
0000
KV
COM
direction)
0502
0500
0501
0503
5 VDC
FG
Setting parameters
DM0000: fH [Hz] (Running frequency)
DM0001: fL [Hz] (Start-up frequency)
DM0002: Acceleration rate [Hz/10 ms]
DM0003: No. of pulses for positioning
Stepping motor
Note 1: A smaller acceleration rate allows smoother control but extends the acceleration time.
Note 2: Be sure to turn OFF input 0007 (phase B input).
Operation
In the example on the next page, each parameter is set as follows:
DM0000: 8000 [Hz]
DM0001: 700 [Hz]
DM0002: 400 [Hz/10 ms]
DM0003: 4000 pulses
When start switch 0000 is pressed, ramp-up/down control is performed as shown
below. Control is stopped when the pulse count reaches "4000".
Pressing the start switch restarts the operation. The operation is reversed while
reverse switch 0001 is ON.
Connection example
The above diagram shows a connection example between the KV PLC and a
stepping motor driver.
Refer to the instruction manual for your stepping motor driver for details.
Set the pulse input method of the stepping motor driver to "1-pulse input method".
Frequency (Hz)
H
(DM0000)
Total pulses
for positioning
(DM0003)
Acceleration
rate
(DM0002)
L
(DM0001)
0
10ms
(Acceleration
change period)
Acceleration
time
Time (ms)
Constant
speed time
Deceleration
time
3-251
14
0001
0002
2002
Visual KV
Series
0003
#00010
CTC1
#65535
CTC0
CTH0
2100
#65535
CTC2
#65535
CTC3
CTH1
0500
0004
0005
Starts positioning
2008
0003
0000
0006
1001
DIFU
1001
2100
STA
01
CALL
2813
SET
2105
SET
$0268
LDA
0007
0008
1200
SET
CTH1
RES
CTH0
RES
EI
2105
RES
0502
0001
0009
Emergency stop
0010
0003
2105
SET
0011
END
0012
0013
SBN
02
0014
0015
#01000
LDA
#00010
DIV
0016
#00010
LDA
#00010 DM0011
DIV
ADD
2002
CTC0
STA
DM0010
STA
CTC2
STA
DM0011
STA
RET
0017
Initialization routine
0018
SBN
01
0019
2002
0020
DM0003
LDA
CTC3
STA
02
CALL
RET
0021
0022
SBN
03
0023
2002
0024
0025
0026
INT
CTC2
0027
Acceleration process
0028
1200
0029
2011
03
CALL
2011
02
CALL
2011
1201
0030
2011
0031
DM0003 DM0011
LDA
SUB
1201
1200
RES
2011
02
CALL
2011
02
CALL
0032
CTC2
STA
DM0011
STA
Deceleration process
0033
1200
0034
0035
#65535
LDA
CTC2
STA
RETI
0036
0037
INT
CTC3
0038
2002
0039
2105
SET
RETI
0040
ENDH
0041
3-252
Visual KV
Series
Chapter 5
Positioning Control
This chapter describes ramp-up/down control of stepping motors and servo motors.
For KV-10/80 Series, see Chapter 6.
5.1
5.1.1
5.2
5.2.1
5.2.2
5.3
5.3.1
5.3.2
5.3.3
Frequency (Hz)
Lower digit
Operating
frequency
DM1481
Startup
frequency
DM1480
Acceleration
time DM1482
Deceleration
time DM1482
Time (ms)
By using the ramp-up/down control output function, ramp-up/down control of stepping motors and AC servo motors (pulse input types) is possible.
Clock pulse
Rotation direction
0502
NEW KV
Lo: CW
Hi: CCW
Stepping motor
Servo motor
0503
Motor driver
3-254
This section describes the parameter setting and operating procedures for positioning control.
Visual KV
Series
For more about special utility relays, refer to "5.2.2 Operating Procedure" (p. 3-257).
The table below shows the relationship between parameters and data memories.
Data memories for ramp-up/down control
Data memory
DM1480
DM1481
DM1482
DM1484
DM1485
DM1486
Setting contents
Setting range
200 to 50,000
200 to 50,000
(value larger than startup frequency)
0 to 4000
0 to 65,535
(2 or more when DM1485 is 0)
0 to 65,535
When an error occurs, a corresponding error code 11 to 17 is stored.
Note: When pulse output is started, the scan time is extended by 10 ms maximum
(if the acceleration/deceleration time is set to 4 s).
Description
Countermeasures
11
12
13
14
15
16
17
3-255
15
Visual KV
Series
Note: If the startup frequency is the same as the operating frequency, the timing
chart becomes as shown below.
Operating (startup)
frequency
0
Startup frequency
5ms
Acceleration/deceleration time
3-256
R/W* Function
2308
Stop
2309
R
W
Run
RESET
2310
Start
Description
Performs deceleration at rising edge, then stops
operation.
Remains ON while pulses are output.
Stops operation immediately when being reset in an
interrupt program.
Starts up operation at rising edge.
Visual KV
Series
* R: Read W: Write
Operation chart
DM1481
DM1480
DM1485
DM1484
0
DM1482
2310
(START)
2309
(RUN)
2308
(STOP)
Note 1: If there is no error in the parameter setting when special utility relay 2310
turns ON at startup of the clock pulses, special utility relay 2309 turns ON and clock
pulses are output.
Note 2: If there is an error in the parameter setting, special utility relay 2309 does
not turn ON but a corresponding error code is written to DM1486.
Confirm the error code, and change the erroneously set parameter.
Note 3: By setting special utility relay 2309 to OFF in an interrupt program, clock
pulses can be immediately stopped.
Note 4: Rising of special utility relay 2310, falling of special utility relay 2309, and
rising of special utility relay 2308 are performed by end processing and RETI.
(Special utility relay 2309 turns ON at that time.)
Note 5: It takes a maximum of 10 ms from when special utility relay 2310 turns ON
until pulses are output.
Note 6: Even if special utility relay 2310 is set to ON while special utility relay 2308
or 2309 is ON, it is ignored.
Note 7: When pulse output has finished, special utility relay 2309 is immediately set
to OFF (without regard to the scan time).
3-257
15
Visual KV
Series
Em
24 VDC
erg
enc
ys
Sto
top
p
Sta
rt
Connect the Visual KV Series and stepping motor driver as shown below.
This example is only for reference. For details, refer to the instruction manual for the
stepping motor driver.
Set the pulse input type of the stepping motor driver to "1 pulse input type".
0001
0000
0002
Visual KV
COM
+
CW (pulse)
+
CCW
(rotation
direction)
R0502
R0503
5 VDC*
FG
Stepping motor
When using a 24 VDC power supply, be sure to use the outputs with current limiting
resistors (R500, R501, and R502) or use the normal outputs with external current limiting
resistors.
5.3.2 Tips
When using a servo motor, also refer to the connection example above. However,
I/O control dedicated to a servo motor such as servo ON is also required.
3-258
5.3.3
Visual KV
Series
Speed (Hz)
1000
500
100000
Coordinate (pulses)
Program example
2008
EI
0001
2002
HSP
0002
0002
0000
0003
0001
2310
2308
0004
END
0005
INT
0002
0006
2002
0007
2309
RES
RETI
0008
ENDH
0009
3-259
15
Visual KV
Series
CW direction
1000
500
Coordinate (pulses)
Input 0000
(CW direction)
Input 0001
(CCW direction)
While input 0000 is ON, the machine continues to move in the CW direction.
When input 0000 turns OFF, the machine decelerates and stops.
While input 0001 is ON, the machine continues to move in the CCW direction.
When input 0001 turns OFF, the machine decelerates and stops.
Program example
0000
0001
2309
0503
SET
1000
DIFU
0001
0000
2309
0503
RES
1001
DIFU
0001
0002
1000
0003
2310
1001
0004
0000
0001
0005
1100
DIFU
1100
2308
END
0006
ENDH
0007
3-260
Visual KV
Series
Speed (Hz)
5000
500
Point 3: 14,000
Coordinate (pulses)
Point 2: 12,000
Point 1: 10,000
500
5000
When start signal 0000 is set to ON, a moving body moves to point 1, returns to the
start position, moves to point 2, and then returns to the start position again. Afterwards, the moving body moves to point 3, then returns to the start position, output
05000 remains ON for 3 seconds, and then the operation is finished.
Program example
Point 2: 12,000
0000
0003
Point 3: 14,000
#00500 #05000 #03000 #00000
DW
DW
DW
DW
DM1480 DM1481 DM1482 DM1485
1000
SET
#10000
DW
DM1484
1200
1001
JMP
1201
1002
JMP
1202
1003
JMP
1203
1004
JMP
1204
1005
JMP
2310
1006
JMP
0503
SET
1000
STG
2310
2309
15
1200
1001
STG
2309
1100
0503
RES
2310
1100
2309
1201
1002
STG
2309
1101
0503
SET
1101
#12000
DW
DM1484
2310
2309
1202
1003
STG
2309
1102
0503
RES
2310
1102
2309
1203
1004
STG
2309
1103
0503
SET
1103
#14000
DW
DM1484
2310
2309
1204
1005
STG
2309
1104
0503
RES
1104
0016 When operation has completed, output 500 remains ON for 3 seconds.
0017
1006
STG
2309
1105
0500
#00030
T000
T000
ENDS
1105
END
0018
ENDH
0019
3-261
Visual KV
Series
Range detected by
zero point sensor
Start
Low speed
Forced stop
Deceleration
and stop
High-speed
When start signal 0000 turns ON, the machine moves at a high speed in the CCW
direction. When the zero point sensor turns ON, the machine decelerates, moves at
a low speed in the CW direction, then stops in the position at which the zero point
sensor turns OFF (at the end of the CW direction).
Program example
0001
0002
Zero point sensor: 0003 Start signal: 0000 Pulse output: 0502
Rotation direction: 0503
0004
2002
HSP
0003
0005
0006
0007
1000
DIFU
1000
0008
2309
1005
SET
0503
RES
0009 When the zero point sensor turns ON, moves at low speed in the CW direction.
1006
2309
2308
RES
1005
2309
1007
DIFU
0010
0011
2413
SET
0503
SET
2310
1006
0012
END
0013
0014
Detects the rising/falling edge of the zero point sensor (003), stops, and
then changes direction.
INT
0003
0015
1006
0016
1005
0017
2308
SET
2309
RES
1006
RES
1006
SET
1005
RES
RETI
0018
ENDH
0019
3-262
10000
7000
5000
500
0
250000
320000
Wait
Wait
460000
Coordinate
(pulses)
Visual KV
Series
Speed (Hz)
When start signal 0000 turns ON, the machine moves to point 1 and stops there. At
the rising edge of wait status reset switch 1, the machine automatically moves to
point 2 and stops there. At the rising edge of waiting status reset switch 1, the
machine automatically moves to point 3. When the machine reaches point 3, output
0500 remains ON for 3 seconds and the operation is finished.
Program example
0001
0002
0003
0004
0005
0006
0007
0008
0000
#00500
DW
DM1480
1000
STG
1001
STG
2309
1400
1400
0001
1000
SET
2310
2309
1300
1001
JMP
1300
1301
15
1301
0009
0503
SET
0010
0011
0012
2309
1401
1401
0001
2310
2309
1302
1002
JMP
1302
1303
1303
0013
0503
SET
0014
0015
0016
2310
2309
1304
1003
JMP
1304
2309
1305
0500
#00030
T000
T000
ENDS
1305
0017
0018
END
ENDH
3-263
Visual KV
Series
This is a program example which offers control using both automatic and manual
operations.
In automatic operation, when input 000 is set to ON, the following operation is
performed.
Speed (Hz)
8000
2000
300
0
15000
17500
Coordinate
(pulses)
15000
In manual operation, the machine moves forward while input 0008 is ON, and moves
backward while input 0009 is ON. When input 0007 is set to ON, the machine
returns to the zero point.
Output 0502 outputs pulses. The rotation direction is changed by an ON/OFF of
0503.
This machine is equipped with a zero-point sensor (0002), a forward limit switch
(0006), and a backward limit switch (0004).
Program example
Pulse motor application circuit (with zero point sensor, forward
limit switch, and backward limit switch)
0002 Specifications
0001
0003
0005 0007
0006
0007 Automatic operation start: 0000
2008
0008
1200
RES
EI
2002
0009
HSP
0000
0010
HSP
0002
0009
2309
0503
RES
0006
1100
DIFU
0008
0009
2309
0503
SET
0004
1101
DIFU
0012
0013
1100
0014
1103
DIFU
1101
0015
0008
0009
0016
3-264
1105
DIFU
0015
0016 Limit switch
0007
1205
DIFU
0017
0018 Move forward.
1205
0503
SET
0019
0020
1300
DIFU
1200
SET
0021
2309
ON
1201
1201
2309
OFF
1202
1202
1203
DIFU
1203
0503
RES
1301
DIFU
1200
RES
0006
1301
0004
In a zero-point-return
operation, the machine
moves forward once, and
then backward. When the
zero point limit switch
(0002) turns ON, the
machine stops.
Settings for forward
movement
Visual KV
Series
2310
0025
0026
1103
0027
1506
2308
0028
0029 Decelerate and stop (in manual/automatic operation).
0006
0009
0004
0008
2308
0030
0031
1105
0032
Automatic operation
0033
2308
0036
15
1400
SET
2008
0035
1408
DIFU
1408
1401
RES
1402
RES
1403
RES
1400
SET
1400
STG
0000
2308
2309
1401
JMP
1401
STG
0041
1402
STG
0042
1403
STG
1407
RES
1405
RES
1406
RES
#00010
T001
#00005
T002
#00005
T003
T001
T002
T003
1500
DIFU
1501
DIFU
1502
DIFU
2309
1405
1402
JMP
1405
2309
1406
1403
JMP
1406
2309
1407
1400
JMP
1407
3-265
0503
SET
1501
0503
SET
1502
0503
RES
0044
Visual KV
Series
0045
0046
#00300
DW
DM1480
#00300
DW
DM1480
#00300
DW
DM1480
#08000
DW
DM1481
#02000
DW
DM1481
#15000
DW
DM1481
#00150
DW
DM1482
#00250
DW
DM1482
#00250
DW
DM1482
#00000
DW
DM1485
#00000
DW
DM1485
#00000
DW
DM1485
#15000
DW
DM1484
#02500
DW
DM1484
#17500
DW
DM1484
1503
DIFU
1504
DIFU
1505
DIFU
1506
0048
1504
0049
1505
0050
END
0051
0052 Interrupt for instantaneous stop (to return to zero point)
INT
0002
0053
1200
0008
0009
0000
0054
2309
RES
RETI
0055
ENDH
0056
3-266
6.1.1
6.1.2
6.2
6.2.1
6.3
6.3.1
KV-10/80
KV-300
Chapter 6
6.1
Interrupt Instructions
KV-10/80
KV-300
Input processing
pt
Scan time
rru
Processing of
direct inputs
te
f in
no
tio
era
Routine program
execution
Output processing
n
Ge
(00000 to 00005)
Interrupt routine
execution
Re
tu
at rns
the to
po sus
int pe
of nd
su ed
sp pr
en og
sio ram
n.
Processing of
direct outputs
(00500 to 00503)
Fig. 1
Routine program flow is shown by the thick arrow on the left of Fig.1. In this case,
input signals can be received only during input processing.
Although input time constant can be made shorter by using HSP or by turning ON
special utility relay 2813, input signals can be received only if they are longer than
the duration of one scan time.
When an interrupt initiation input turns ON, the currently running program is suspended to immediately execute the interrupt routine.
During execution of interrupt routine, input signals shorter than one scan time can be
received by the PLC.
2813
SET
2002
EI
or
2002
HSP
0000
Types of interrupt
High speed counter comparators
Input relays
Interrupt by CTC can be generated when the CTC preset value and CTH current
value are equal.
A signal received through any of inputs 0000 to 0003 can generate an interrupt.
3-268
Interrupt priority
If two or more interrupts are generated at different timings, interrupt routines are
executed in the order that interrupts are generated.
If two or more interrupts are generated simultaneously, interrupt routines are
executed according to the priority shown below.
CTC0 > CTC1 > CTC2 > CTC3 > 0000 > 0001 > 0002 > 0003
Note that the above priority differs from that for other KV PLCs (KV-10/16/24/40/
80).
The priority is: 0000 > 0001 > 0002 > 0003 > CTC2 > CTC3 > CTC0 > CTC1.
KV-10/80
Note 1: During execution of one interrupt routine, execution of other interrupt routines is inhibited. (One interrupt routine can be executed inside another interrupt
routine by inserting EI.)
Note 2: If other interrupts are generated during execution of one interrupt routine,
the routines of these interrupts are executed after completion of the first interrupt
routine in the order that they are generated. Note that generation of up to 8 levels of
interrupt nesting or up to 8 individual interrupts can be stored during execution of
interrupt routine. However, generation of an interrupt is ignored if generation of the
same interrupt has already been stored.
KV-300
Interrupt routine
2008
EI
2813
SET
END
INT
XXXXX
RETI
ENDH
16
3-269
Direct output
2008
EI
2813
SET
END
INT
0000
2002
0500
( SET )
KV-300
RETI
KV-10/80
INT
0001
2002
0500
( SET )
ENDH
Direct output is enabled only through output relays 0500, 0501, 0502, and 0503.
This function allows ON/OFF status of any of output relays 0500, 0501, 0502, and
0503 to be output during execution of interrupt routine.
This function allows immediate ON/OFF status output without delay caused by scan
time.
Note: Be sure to turn ON special utility relay 2813 to shorten the input time constant.
Direct input
2008
1000
2813
SET
0500
END
INT
0000
0005
1000
RETI
ENDH
3-270
DI / EI
FNC
RES AND
0
8
DI
ORL
FNC SET
1
3
EI
Key operations
AND
8
FNC
SET
1
ORL
3
ENT
R-SRCH
ENT
R-SRCH
KV-10/80
RES
0
KV-300
FNC
Operand
Example
1000
EI
1000
DI
Coding
Line No.
Instruction
Operand
0000
LD
1000
0001
EI
0021
LDB
0022
DI
1000
16
Description
When 1000 is ON, execution of interrupt is enabled. When 1000 is OFF, execution
of interrupt is disabled. Interrupts are enabled between EI instruction and DI instruction.
Therefore, once EI is executed, interrupt is enabled until it is disabled by DI.
With the KV, any interrupt is disabled when the operation is started.
DI instruction disables execution of interrupt. Use this instruction to temporarily
disable interrupt.
EI instruction enables the execution of interrupt. Use this instruction to release
interrupt disabled by DI instruction.
During execution of an interrupt, any other interrupt is disabled.To execute another
interrupt during execution of the previous interrupt, include EI instruction in this first
interrupt. Interrupts can be nested up to 8 levels by executing EI in each interrupt
routine.
Note 1: Generation of up to 8 levels of interrupt nesting or up to 8 individual interrupts can be stored while interrupt is disabled. These interrupts are executed after EI
has been executed.
Note 2: Generation of INT CTC is erased from the storage when RES CTC is
executed.
3-271
INT / RETI
INT: Interrupt
RES
FNC ANL
2
0
LDB
FNC ORL
3
4
INT
nnnn
RETI
KV-10/80
KV-300
Key Operations
FNC
ANL
2
RES
0
ENT
R-SRCH
FNC
ORL
3
LDB
4
ENT
R-SRCH
Operand
ENT
R-SRCH
ENT
R-SRCH
Operand
0000 to 0003
CTC0 to CTC3
Example 1
Input pulse width shorter than one scan time (eg. one-shot circuit)
(a)
0000
Input for
routine
program
0500
#00020
T000
T000
0500
0000
(Input remains ON for 1 ms or more.)
(b)
2008
Input for
interrupt
routine
2813
SET
EI
1000
#00020
T000
0000
0500
T000
0500
END
INT
0000
1000
2002
RETI
ENDH
(Input remains ON for 10 s or more.)
Program (a) can be used when input 0000 remains ON longer than the input time constant (8
to 12 ms).
Program (b) is used when input 0000 remains ON shorter than one scan time.
Routine program coding
3-272
Line No.
Instruction
Operand
0000
LD
0000
0001
OR
0500
0002
TMR
000 #00020
0003
ANB
T000
0004
OUT
0500
INT / RETI
6.1 Interrupt Instructions
Interrupt routine coding
Operand
2008
Line No.
0008
0009
0010
0011
0012
0013
0014
2813
1000
0500
000 #00020
T000
Instruction
OUT
END
INT
LD
OUT
RETI
ENDH
Operand
0500
0000
2002
1000
Example 2
Features of INT0003
Upon generation of interrupt by INT0003, the CTH1 current value is automatically
transferred to TM30.
Interrupt generated by any of INT0000 to INT0002 is executed at the rising edge of
the input signal. Interrupt generated by INT0003 can be executed either at the rising
or falling edge of the input signal.
Relay No.
ON
OFF
2206
KV-10/80
Instruction
LD
EI
CON
SET
LD
OR
TMR
ANB
KV-300
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
2008
2206(ON)
1
Pulse width
EI
$0000
LDA
2200
STA
DM0000
STA
2002
CTH1
2200
END
INT
0003
3
2206
2206
TM30
LDA
TM02
STA
TM30
LDA
TM02 DM0000
SUB
STA
KEEP
SET
2206
(a)
RES
(b)
RETI
ENDH
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
Instruction
LD
EI
CON
LDA
CON
STA
CON
STA
LD
CTH
END
INT
LDB
LDA
Operand
2008
$0000
2200
DM0000
2002
1 2200
0003
2206
TM30
Line No.
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
Instruction
CON
STA
CON
LD
LDA
CON
SUB
CON
STA
CON
KEEP
RETI
ENDH
Operand
TM02
2206
TM30
TM02
DM0000
2206
3-273
16
INT / RETI
KV-10/80
KV-300
Initial setting
When the operation is started, EI instruction enables interrupts.
Special utility relays No. 2200 through 2215 are turned OFF. Turning OFF 2203
disables CTC2 from resetting the CTH1 current value to 0.
Turning OFF 2206 allows interrupt to be generated at the rising edge of INT0003.
Turning ON special utility relay 2813 changes the input time constant to 10 s.
When interrupt is generated for the first time, 2206 is OFF. Therefore, program in
rung (a) is executed. Then, KEEP turns 2206 ON.
When interrupt is generated for the second time, 2206 is ON. Therefore, program
in rung (b) is executed to calculate the following:
(TM30 at 2nd execution) - (TM30 at 1st execution) = pulse width (unit: 1.0 s)
The result is stored in DM0000.
Example 3
Interrupt by CTC
Pulses input to 0005 are counted. 0501 is turned ON when the number of pulses
reaches 5,000.
2008
1
EI
2203
SET
CTH1
RES
#05000
CTC2
2813
SET
2002
CTH1
0005
0000
0501
RES
END
INT
CTC2
4
2002
0501
SET
RETI
ENDH
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
3-274
Instruction
LD
EI
CON
SET
CON
RES
CON
CTC
CON
SET
Operand
2008
2203
CTH1
2 #05000
2813
Line No.
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
Instruction
LD
CTH
LD
RES
END
INT
LD
SET
RETI
ENDH
Operand
2002
1 0005
0000
0501
CTC2
2002
0501
INT / RETI
Turning ON special utility relay 2203 allows CTC2 to reset the CTH1 current
value to 0.
Turning ON special utility relay 2813 changes the input time constant to 10 s.
INT CTC2 is used to execute the interrupt. (Interrupt routine is executed when
the CTH1 current value and CTC2 preset value are equal.)
KV-10/80
KV-300
Initial setting
When the operation is started, EI instruction enables interrupts.
Note 1: When the interrupt is executed, the contact of CTC2 is automatically reset.
Note 2: The operand used for INT instruction is not allowed for use with other INT
instructions.
16
3-275
6.2
KV-10/80
KV-300
The KV-300 CPU has two 16-bit (CTH0, CTH1) double-phase counter, each
equipped with two high-speed counter comparators (CTC0, 1, 2, 3). These counters
can be used as a stepping motor controller or are used to measure pulse width.
Block diagram of high-speed counters
0008 (RESET)
Phase A 0004
Phase B (0006)
Internal clocks
2100(1.0 s)
2101(10.0 s)
2102(100.0 s)
External pulse
0004/0006
Phase A 0005
Phase B (0007)
Internal clocks
2200(1.0 s)
2201(10.0 s)
2202(100.0 s)
External pulse
0005/0007
0500
16-bit
high-speed counter
CTH0
Control circuit
High-speed
counter comparator
CTC0, CTC1
16-bit highspeed counter
CTH1
0500
INT CTC0
INT CTC1
TM30
High-speed
counter comparator
CTC2, CTC3
0501
INT CTC2
INT CTC3
0009 (RESET)
3-276
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
KV-10/80
KV-300
2200
0.8 s
2200
0.4 s
2101
6.4 s
2201
0.8 s
2102
102.4 s
2202
3.2 s
3. Special utility relays of 2112, 2113, 2114, 2115, 2212, 2213, 2214, and 2215
are not available.
3-277
16
KV-10/80
KV-300
You can specify the operands listed in the table below as the count input.
You can specify one operand from the table below.
Operand cannot be modified externally during execution of the program.
When the external pulse (0004, 0005) is selected, CTH1 is used as a High-speed
counter with a response frequency of 30 kHz.*
When one of the internal clocks (2100 to 2102, 2200 to 2202) is selected, CTH1
is used as a High-speed timer.
When the external pulse 0500 is selected as input to CTH1, CTH1 can count
direct clock pulses generated by CTH0.
High-speed counter
CTH0
CTH1
Operand
2100
2101
2102
0004
2200
2201
2202
0005
0500
Countable range
0 to 65535
* KV-10/80: 10 kHz
High-speed counter comparator (CTC)
High-speed counter comparators (CTC) is used only for High-speed counters (CTH).
When the current value of CTH reaches the preset value of one of the comparators
(CTC), the comparator turns ON.
At the contact of High-speed counter comparator (CTC), the level of output (0500,
0501) can be changed (directly output) through hardware or an interrupt can be
generated. To change the level of output 0500 and 0501, set the desired value (ON/
OFF) to special utility relays 2103 to 2112, 2203 to 2205, and 2207 to 2212.
The High-speed counters correspond to the High-speed counter comparators as
shown in the table below.
High-speed
counter
High-speed
counter
comparator
Range of
setting value
Output
CTC0
0 TO 65535
0500
CTH0
CTC1
CTH1
Interrupt
INT CTC0
INT CTC1
CTC2
0501
CTC3
INT CTC2
INT CTC3
3-278
High-speed counter
CTH0
CTH1
Relay No.
2100
2200
1.0 s
2101
2201
10.0 s
2102
2202
100.0 s
Period
CAUTION
* KV-10/80 : 10 kHz
KV-10/80
The KV PLC can output clock pulses through 0500 and/or 0501 without any delays
caused by scan time. (Through CPU only)
Direct clock pulses, used with the high-speed counters, are applicable for various
types of production control such as for controlling target positions at desired speed.
To perform ramp-up/down control, see "Controlling stepping motors" in Chapter 5.
A setting of the clock pulse cycle (frequency) can be changed by the program within
the allowable range as shown in the table below.
KV-300
Internal clock
0500
2100
2101
0501
2102
2200
2201
2202
Direct clock pulses are output through 0500 and/or 0501 according to the settings on
the special utility relays when the number of internal clock pulses counted by the
high-speed counter reaches the preset value of the comparator.
Output example
16
0500
0501
ON
OFF
CAUTION
ON/OFF of output relay 0500/0501 depends on the setting of the special utility
relay. Refer to page 3-281.
Output
500
500 ms to 52.2 ms
(2 kHz to 19 Hz)
501
666 ms to 419.4 ms
(1.5 kHz to 2.4 Hz)
500
50 ms to 52.2 ms
(20 kHz to 19 Hz)
501
666 ms to 419.4 ms
(1.5 kHz to 2.4 Hz)
KV-80
3-279
KV-300
ON
OFF
Pulse
width
Pulse period
CAUTION
The pulse width determined as above is used to pulses generated from the
KV-300 CPU.
Pulses are output through the output circuit. The pulse width varies depending on the response delay from the output circuit and influence of the connected load. Before setting the pulse width, you should measure the actual
waveform using an oscilloscope. (Use pulses with variable pulse width.)
3-280
To obtain the pulse cycle from frequency, use the following expression:
Pulse cycle (s) = 1000 Frequency (kHz)
CTC0
2103
2104
2105
2106
Outputs ON to 0500.
CTC1
CAUTION
KV-10/80
KV-300
Comparator No.
2107
2112
2108
2109
2110
Outputs ON to 0500.
2111
Only one of relays 2104 to 2107 and one of relays 2108 to 2111 can be
turned ON. When two or more of the relays among each group are ON,
priority is given to the relay with the smallest No.
Turning OFF special utility relays 2104 and 2108 enable direct output.
Because these relays are factory-set to ON, be sure to set them to OFF.
ON/OFF status of special utility relays 2104 to 2112 is set using SET and
RES instructions or STA instruction.
Be sure to turn the special utility relay 2103 or 2112 ON to change the
pulse width. Turn ON 2103 or 2112 to change the pulse cycle.
Turn OFF 2105 to start clock pulse output. Turn ON 2105 to stop pulse
output.
When special utility relays 2104 and 2108 are turned ON while the direct
clock pulses are being output, the status of the output relay 0500 is output
and the pulses will be stopped.
ON
2112
OFF
2103
ON
2112
OFF
2104
OFF
2108
OFF
2104
OFF
2108
OFF
2105
OFF
2109
OFF
2105
OFF
2109
ON
2106
OFF
2110
OFF
2106
ON
2110
OFF
2107
ON
2111
OFF
2107
OFF
2111
OFF
CTH0 value
CTH0 value
CTC0
CTC0
CTC1
ON
OFF
ON
OFF
3-281
16
KV-10/80
KV-300
Relay No.
CTC2
2203
2204
2205
CTC3
CAUTION
2207
2212
2208
2209
2210
Outputs ON to 0501.
2211
Only one of relays 2208 to 2211 can be turned ON. When two or more of the
relays among each group are ON, priority is given to the relay with the
smallest No.
Turning ON special utility relay 2204 and turning OFF special utility relay
2208 enable direct output.
ON/OFF status of special utility relays 2204 to 2212 is set using SET and
RES instructions or STA instruction.
Be sure to turn the special utility relay 2203 or 2212 ON to change the pulse
width.
When special utility relays 2204 and 2208 are turned ON while the direct
clock pulses are being output, the status of the output relay 0501 which is
used in the program is output and the pulses will be stopped.
ON
2212
OFF
2203
ON
2212
OFF
2204
ON
2208
OFF
2204
ON
2208
OFF
2205
OFF
2209
OFF
2205
ON
2209
ON
2206
OFF
2210
OFF
2206
OFF
2210
OFF
2207
ON
2211
OFF
2207
OFF
2211
OFF
CTH1 value
3-282
CTH1 value
CTC2
CTC2
CTC3
ON
OFF
ON
OFF
KV-300
OFF
KV-10/80
Pulse
width
Pulse cycle
Pulse
width
Pulse cycle
CAUTION
Cycle
2100
2200
1.0 s
2101
2201
10.0 s
1 to 65535
2102
2202
100.0 s
1 to 65535
When setting 2100 or 2200 for the operand of High-speed counter CTH, set
10 or greater value to CTC. Otherwise, clock pulse is not correctly output.
The pulse width varies depending on the influence of the connected load.
Before setting the pulse width, you should measure the actual waveform
using an oscilloscope.
When generating clock pulse using CTC0 and CTC1, or CTC2 and CTC3,
do not set the same value to CTC0 and CTC1, or CTC2 and CTC3. If setting
the same value, clock pulse is output at the double clock cycle.
3-283
16
KV-10/80
KV-300
Setting
Relay No.
Setting
2103
ON
2112
OFF
2104
OFF
2108
OFF
2105
OFF
2109
OFF
2106
OFF
2110
OFF
2107
ON
2111
OFF
Internal clock*
CTC0 value
1.0 s
500
2101
10.0 s
50
2102
100.0 s
2100
Programming example
2008
0001
2103
2104
2105
2106
2107
CTH0
SET
RES
RES
RES
SET
RES
2002
0002
0003
3-284
CTH0
2101
#00050
CTC0
CTH0 value
CTC0
ON
OFF
The status of output 0500 is set by turning ON one of the relays 2104 to 2107 at
the beginning of the program. In Example, output of direct clock pulses to 0500 is
enabled, and the status of output 0500 is inverted each time CTH0 = CTC0.
Turns ON special utility relay 2103 and specifies to clear CTH0 using CTC0. The
program repeats clearing the CTH0 current value with the value set to CTC0.
Resetting the current value of CTH0 at the beginning of the program allows direct
clock pulses of specified width to be output starting from the 1st pulse.
Input relay which enables CTH0 remains ON during clock pulse output.
CAUTION
Instruction
Operand
0000
LD
2008
0001
SET
2103
0002
CON
RES
0004
CON
0005
RES
0006
CON
0007
RES
0008
CON
0009
SET
0010
CON
0011
RES
2104
2105
2106
KV-10/80
0003
KV-300
Line No.
2107
CTH0
0012
LD
2002
0013
CTH
0 2101
0014
CTC
0 #00050
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2105 turns OFF.
Turn ON/OFF special utility relay 2105 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0500 only when 0000 is ON.
SET/RES Instructions
KEEP Instructions
0000
2105
SET
0000
0000
2105
RES
0000
16
KEEP
SET
2105
RES
Setting
Relay No.
Setting
2203
ON
2212
OFF
2204
OFF
2208
OFF
2205
OFF
2209
OFF
2206
OFF
2210
OFF
2207
ON
2211
OFF
3-285
KV-10/80
KV-300
Internal clock*
CTC0 value
2200
1.0 s
500
2201
10.0 s
50
2202
100.0 s
Programming example
2008
0001
2203
2204
2205
2207
CTH1
SET
SET
RES
SET
RES
CTC2
CTH1
2201
#00050
CTC2
ON
OFF
2002
0002
0003
CTH1 value
The status of output 0501 is set by turning ON one of the relays 2204 to 2207 at
the beginning of the program. In Example, output of direct clock pulses to 0501 is
enabled, and the status of output 0501 is inverted each time CTH1 = CTC2.
Turns ON special utility relay 2203 and specifies to clear CTH1 using CTC2. The
program repeats clearing the CTH1 current value with the value set to CTC2.
Resetting the current value of CTH1 at the beginning of the program allows direct
clock pulses of specified width to be output starting from the 1st pulse.
Input relay which enables CTH1 remains ON during clock pulse output.
Coding
Line No.
3-286
Instruction
Operand
0000
LD
2008
0001
SET
2203
0002
CON
0003
SET
0004
CON
0005
RES
0006
CON
0007
SET
0008
CON
0009
RES
2204
2205
2207
CTH1
0010
LD
2002
0011
CTH
1 2201
0012
CTC
2 #00050
CAUTION
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2204 turns OFF.
Turn ON/OFF special utility relay 2204 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0501 only when 0000 is ON.
KEEP Instructions
2204
SET
0000
0000
2204
RES
0000
KV-10/80
0000
KV-300
SET/RES Instructions
KEEP
SET
2204
RES
Setting
Relay No.
Setting
2103
ON
2112
OFF
2104
OFF
2108
OFF
2105
OFF
2109
ON
2106
ON
2110
OFF
2107
OFF
2111
OFF
16
Internal clock*
CTC0 value
CTC1 value
2100
1.0 s
500
200
2101
10.0 s
50
20
2102
100.0 s
3-287
2103
SET
2104
RES
2105
RES
2106
SET
2107
RES
0002
2108
RES
2109
SET
2110
RES
2111
RES
CTH0
RES
2002
CTH0
2101
#00050
CTC0
#00020
CTC1
0003
0004
0005
ON
OFF
The status of output 0500 is set by turning ON one of the relays 2104 to 2107
and 2108 to 2111 at the beginning of the program. In Example, output of direct
clock pulses to 0500 is enabled, and the status of output 0500 is turned ON at
CTC0 and is turned OFF at CTC1.
Turns ON special utility relay 2103 and specifies to clear CTH0 using CTC0. The
program repeats clearing the CTH0 current value with the value set to CTC0.
Input relay which enables CTH0 remains ON during clock pulse output.
KV-10/80
KV-300
CTH0 value
CTC0
CTC1
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
CAUTION
Instruction
LD
MPS
SET
CON
RES
CON
RES
CON
SET
CON
RES
MPP
RES
Operand
2008
2103
2104
2105
2106
2107
Line No.
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
Instruction
CON
SET
CON
RES
CON
RES
CON
RES
LD
CTH
CTC
CTC
Operand
2109
2110
2111
CTH0
2002
0 2101
0 #00050
1 #00020
2108
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls clock pulse so that it always starts and stops when 2105 turns OFF.
Turn ON/OFF special utility relay 2105 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0500 only when 0000 is ON.
SET/RES Instructions
KEEP Instructions
0000
2105
SET
0000
0000
2105
RES
0000
KEEP
SET
2105
RES
By overwriting the setting value of high-speed counter comparator CTC0 using the
LDA and STA instructions, you can change the clock pulse cycle (frequency).
Refer to "Example of pulse output "on page 3-293.
3-288
Relay No.
Setting
2203
ON
2212
OFF
2204
ON
2208
OFF
2205
ON
2209
ON
2206
OFF
2210
OFF
2207
OFF
2211
OFF
KV-10/80
KV-300
Relay No.
Internal clock*
CTC2 value
CTC3 value
2100
1.0 s
500
200
2101
10.0 s
50
20
2102
100.0 s
Programming example
2008
0001
2208
RES
0002
2002
0003
0004
0005
16
2203
SET
2204
SET
2205
SET
2207
RES
2209
SET
2210
RES
2211
RES
CTH1
RES
CTC2
CTC3
CTH1
2201
#00050
CTC2
#00020
CTC3
ON
OFF
CTH1 value
The status of output 0501 is set by turning ON one of the relays 2204 to 2207
and 2208 to 2211 at the beginning of the program. In Example, output of direct
clock pulses to 0501 is enabled, and the status of output 0501 is turned ON at
CTC2 and is turned OFF at CTC3.
Turns ON special utility relay 2203 and specifies to clear CTH1 using CTC2.
The program repeats clearing the CTH1 current value with the value set to
CTC2.
Input relay which enables CTH1 remains ON during clock pulse output.
3-289
KV-10/80
KV-300
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
CAUTION
Instruction
LD
MPS
SET
CON
SET
CON
SET
CON
RES
MPP
RES
CON
Operand
2008
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
2203
2204
2205
2207
2208
Instruction
SET
CON
RES
CON
RES
CON
RES
LD
CTH
CTC
CTC
Operand
2209
2210
2211
CTH1
2002
1 2201
2 #00050
3 #00020
When start/stop of clock pulse is controlled by the input relay which enables/
disables the high-speed counter, response relay of up to 1 scan is generated
at start. Also, the same response relay is generated at stop, which may stop
clock pulse output while the output relay is still ON.
This controls the clock pulse so that it always starts and stops when 2205 turns
OFF.
Turn ON/OFF special utility relay 2205 as required to enable or disable output of
direct clock pulses using one of the external clocks. Use SET and RES instructions
together or only KEEP instruction to turn ON/OFF this relay.
The diagram below can be added to the sample diagram so that direct clock pulses
are output through 0501 only when 0000 is ON.
SET/RES Instructions
KEEP Instructions
0000
2204
SET
0000
0000
2204
RES
0000
KEEP
SET
2204
RES
6
By overwriting the setting value of high-speed counter comparator CTC2 using the
LDA and STA instructions, you can change the clock pulse cycle (frequency).
Example of stopping clock pulse after reaching the specified output pulse count
The following example stops clock pulse having the pulse width of 200 s which is
output from 0500 at cycle of 500 s (2 kHz) after reaching the pulse count value of
10000.
Setting special utility relay, internal clock, and CTC
Settings of the special utility relays, internal clock, CTC0, and CTC1 are listed
below.
Relay No.
Setting
Relay No.
Setting
2103
ON
2112
OFF
2104
OFF
2108
OFF
2105
OFF
2109
ON
2106
ON
2110
OFF
2107
OFF
2111
OFF
Internal clock*
CTC0 value
CTC1 value
1.0 s
500
200
2101
10.0 s
50
20
2102
100.0 s
2100
3-290
0002
0003
0000
0004
2002
0005
0006
0007
2002
0008
0009
2002
0014
2108
RES
2203
SET
2109
SET
2813
SET
2105
SET
2106
SET
2107
RES
2110
2111
RES
RES
CTH1
RES
1000
1000
DIFU
CTH0
RES
2105
RES
CTH0
2101
#00050
CTC0
#00020
CTC1
CTH1
0500
#10000
CTC2
INT
CTC2
0011
0013
2104
RES
END
0010
0012
2103
SET
KV-10/80
EI
KV-300
2008
0001
2105
SET
RET1
ENDH
Sets pulse output to 0500 using special utility relays 2104 to 2107 and 2108 to
2111.
The example on the left sets special utility relays to enable direct output to 0500
(2104: OFF), and turn 0500 output ON at CTC0 (2106: ON) and OFF at CTC1
(2109: ON).
Turns ON special utility relay 2103 to clear CTH0 using CTC0. This allows output
with correct clock pulse width starting from the 1st pulse.
Turns ON special utility relay 2203 to clear CTH1 using CTC2. This allows
program to operate repeatedly at the specified pulse count (10000 pulses).
Always turns ON 2813 when counting pulses using high-speed counter CTH1.
Input relay which enables CTH0 remains ON during clock pulse output.
Input relay which enables CTH1 remains ON during clock pulse counting.
Specifies internal clock (2101) for clock input of high-speed counter CTH0.
Specifies 0500 for clock input of high-speed counter CTH1. Then, CTH0 is used
for clock pulse output and CTH1 is used for clock pulse counting.
Sets the clock pulse count using the setting value of high-speed counter comparator CTC2.
3-291
16
KV-10/80
KV-300
Coding
Line No.
Instruction
Operand
Line No.
Instruction
Operand
0000
LD
2008
0024
SET
2203
0001
EI
0025
CON
0002
CON
0026
SET
0003
MPS
0027
CON
0004
SET
0028
RES
0005
CON
0006
RES
0007
CON
0008
SET
0009
CON
0010
SET
0011
CON
0012
RES
0013
MRD
0014
RES
0015
CON
0016
SET
0017
CON
0018
RES
0019
CON
0020
RES
0021
CON
0022
RES
0023
MPP
2103
2104
2105
2106
2107
2108
2109
2110
2111
CTH0
2813
CTH1
0029
LD
0000
0030
DIFU
1000
0031
CON
0032
AND
1000
0033
RES
2105
0034
LD
2002
0035
CTH
0 2101
0036
CTC
0 #00050
0037
CTC
1 #00020
0038
LD
2002
0039
CTH
1 0500
0040
CTC
2 #10000
0041
END
0042
INT
CTC2
0043
LD
2002
2105
0044
SET
0045
RETI
0046
ENDH
Special utility relays 2103 to 2111 can be set to turn ON or OFF using LDA and STA
instructions as well as SET and RES instructions. Example below illustrates how
one program can be made shorter using LDA and STA instructions.
2008
EI
2103
SET
2104
RES
2105
SET
2106
SET
2107
RES
2108
RES
2203
SET
2109
SET
2813
SET
2110
RES
CTH1
RES
2111
RES
CTH0
RES
2008
$0268 $2100
LDA
STA
EI
2203
SET
CTH0
RES
2813
SET
CTH1
RES
LDA $0268
When LDA $0268 is executed, the following data is input to the internal register.
[0]
Internal
register
[2]
[6]
[8]
Internal register
When STA 2100 is executed, the data in the internal register is assigned to 16
special utility relays starting from 2100 to 2115.
Special utility
relays 21**
15
0
14
0
13
0
12
0
11
0
10
0
09
08
07
0
06
1
05
1
04
0
3-292
03
1
02
0
01
0
00
0
KV-10/80
24 VDC
KV-300
rt
Sta
KV-300
Re
ve
rs
Connection example
The following chart shows an operation example when the KV-300 CPU is connected to the stepping motor driver. See the stepping motor driver instruction
manual for details.
Set the pulse input mode of the stepping motor driver to "1 pulse input mode".
+
Twisted pair cable
COM 1
0000 11
0001 2
0500
0501
0502
0503
COM
7
8
9
10
20
CW (pulse)
CCW
(rotating
direction)
Stepping motor
24 VDC
FG
Frequency (Hz)
fH
(DM0000)
Positioning
pulse total
count
(DM0003)
Acceleration
rate
(DM0002)
fL
(DM0001)
0
10 ms
Acceleration
change time
Acceleration time
Time (ms)
Constant
rate time
Deceleration time
Setting parameters
DM0000: fH [Hz] (Run frequency) 153 Hz to 50000 Hz fH must be greater than
fL.
DM0001: fH [Hz] (Start frequency)
DM0002: Acceleration rate [Hz/10 ms] (fH-fL) (Acceleration time 10 ms)
DM0003: Positioning pulse count 65534 pulses max.
CAUTION
Operation
This program sets the parameters as below:
DM0000 = 8000 [Hz], DM0001 = 700 [Hz], DM0002 = 400 [Hz/10 ms], DM0003 =
4000 pulses
The program performs trapezoidal control as shown above when start switch 0000 is
pressed, and stops control when pulse count reaches 4000.
The program restarts operation by re-pressing the start switch. It performs reverse
operation while reverse switch 0001 is ON.
3-293
16
0002
#00010
CTC1
#65535
CTC0
CTH0
2100
0003
#65535
CTC2
#65535
CTC3
CTH1
0500
2008
0004
KV-10/80
KV-300
0005
#00700
DW
DM0001
#08000
DW
DM0000
#00400
DW
DM0002
2813 2105
(SET ) (SET )
#04000
DW
DM0003
STARTS POSITIONING
0003
0000
1001
DIFU
0006
1001
0007
$0268
LDA
0008
2100
STA
01
CALL
EI
0001
0502
( )
0009
0010
2105
(RES )
Reverse output
EMERGENCY STOP
0003
2105
(SET)
0011
END
0012
0013
0014
2002
0015
#01000
LDA
#10000
MUL
DM0012
DIV
#00005
ADD
#00010
DIV
CTC0
STA
DM0010
STA
0016
#00010
LDA
#10000
MUL
DM0010
DIV
#00005
ADD
#00010
DIV
DM0011
ADD
CTC2
STA
DM0011
STA
RET
0017
0018
Emergency stop
Sets CTC0.
Setting value of CTC0 =
1 DM0012 x 103 x 103 6.4
Sets CTC2.
DM0010: Pulse cycle T (s) x 10
DM0011: Accumulated pulse count
DM0012: Current frequency f [Hz]
1200: Acceleration flag
INITIALIZING SUBROUTINE
SBN
01
0019
2002
0020
DM0003
LDA
CTC3
STA
#00002
DIV
#00000
DW
DM0011
02
CALL
RET
0021
0022
0023
2002
0024
3-294
DM0012
LDA
#00100
DIV
DM0011 DM0004
ADD
CMP
RET
0025
INTERRUPT ROUTINE FOR SPEED-UP/SLOW-DOWN
INT
CTC2
0027
SPEED-UP
1200
0029
2011
03
CALL
2011
02
CALL
2011
1201
( )
0030
2011 DM0003 DM0011
LDA
SUB
0031
1201
0032
0033
CTC2
STA
DM0011
STA
1200
(RES )
SPEED-UP
1200
0034
0035
2011
02
CALL
2011
02
CALL
#65535
LDA
CTC2
STA
RETI
0036
0037
0038
2002
0039
KV-10/80
0028
KV-300
0026
2105
(SET )
RETI
0040
ENDH
0041
16
3-295
KV-10/80
KV-300
The KV-300 CPU outputs clock pulses, independent of scan time, directly through
output relay 0500 or 0501. When the clock pulse frequency, output pulse count, and
acceleration/deceleration time are set to the data memory addresses in advance,
the KV-300 CPU automatically performs ramp-up/down control. Output frequency
can be set within the range of 153 Hz to 50000 Hz.
Frequency (Hz)
Operation
Start
Deceleration time
Acceleration time
Time (ms)
With this function, ramp-up/down control over stepper motors and AC servo motors
(pulse input type) becomes possible.
The following section describes setting and application of positioning control
parameters.
Clock pulse
6
0500
0501
Rotation direction
Lo : CW
Hi : CCW
0502
0503
KV-300
3-296
Stepping motor
/servo motor
Motor driver
Setting parameters
Set the parameters to the assigned data memory addresses. To operate the
positioning control function, the special utility relays must be set. Refer to page 3-299.
The following table shows the parameters and assigned DM Nos.
Parameter
X-axis
DM9408
153 to 50000
(0500)
DM9409
153 to 50000
DM9410
0500 Acceleration/deceleration
time (ms)
0 to 4096
DM9411
0 to 65535
DM9412
0 to 65535
Y-axis
DM9413
153 to 50000
(0501)
DM9414
153 to 50000
DM9415
0501 Acceleration/deceleration
time (ms)
0 to 4096
DM9416
0 to 65535
DM9417
0 to 65535
KV-10/80
KV-300
DMNo.
DM9407
Note: Refer to the following expression to determine the output pulse count.
Output pulse count < (65535 x pulse change cycle [ms]) (1000 x run frequency
[Hz])
Pulse change cycle (t)
The pulse change cycle is the cycle in which the output clock pulse frequency is
changed for acceleration or deceleration. The pulse change cycle is obtained from
one of the following expressions, whichever produces the smaller solution. However,
when the start pulse is less than 500 Hz, the pulse change cycle becomes 14 ms or
more.
Pulse change cycle (t) [ms] = (acceleration time [ms] + 199) 200 x 4
or
Pulse change cycle (t) [ms] = 1000 (run frequency [Hz] 1000)
Run
Start
3-297
16
KV-10/80
KV-300
Code
Error description
Corrective action
11
12
13
14
15
Acceleration/deceleration time
exceeds allowable range.
16
17
FFFF
Run frequency
x Pulse change cycle x 65535
1000
Here, the acceleration/deceleration time is ignored. The output count should be less
than 65535.
3-298
KV-10/80
KV-300
Procedure
When the positioning control function is used, the KV-300 CPU controls start, stop,
and emergency stop by turning ON/OFF the utility relays. The table below shows the
operations and assigned utility relays.
Relay No.
R/W
Function
Description
0500
0501
2308
2311
STOP
2309
2312
R
W
RUN
RESET
2310
2313
START
3-299
16
DM9411
DM9412
DM9410
DM9410
2310
(START)
KV-10/80
KV-300
2309
(RUN)
2308
(STOP)
Note 1: When special utility relay 2310 (2313) is turned ON at start of clock pulse,
2309 (2312) turns ON and the clock pulse is output, assuming parameter settings
are correct.
Note 2: If a parameter setting for the X-axis or Y-axis is incorrect, 2309 (2312) does
not turn ON and an error code is written into DM9407. Check the error code and
adjust the parameter setting.
Note 3: By resetting 2309 (2312) within the interrupt program, you can stop the
clock pulse immediately. You must reset 2309 within the interrupt program; otherwise, the clock pulse is not stopped.
Note 4: Because the clock pulse is output under software control, the pulse width is
extended by 10 s to 20 s in the pulse change cycle. Test the clock pulse output on
the KV-300 system before using it in practical applications.
24 VDC
Sta
rt
Em
erg
enc
ys
Sto
top
p
Connection example
The following reference example shows how to connect the KV-300 CPU to a
stepping motor driver. Refer to the stepping motor driver instruction manual for
details.
Set the pulse input mode for the stepping motor driver to "Pulse input mode 1".
+
Stepping motor driver
KV-300
1
11
2
12
0500
0501
0502
0503
COM
7
8
9
10
20
+ CW (pulse)
+ CCW
(rotation
direction)
Stepping motor
24 VDC
+
FG
3-300
Ramp-up/down control
When start switch 0002 is turned ON, 0500 outputs 100000 pulses under the
following conditions: start frequency 1 kHz, run frequency 5 kHz, and acceleration/
deceleration time 3 s.
Turn ON 0001 to decelerate and stop pulse output. When 0000 is turned ON, pulse
output is immediately stopped.
0002
0001
0003
END
0004
INT
0000
0005
2002
2309
RES
0006
KV-10/80
EI
0002
KV-300
2008
0001
RET1
0007
ENDH
0008
8000
2000
300
0
15000
17500
16
15000
In manual mode, the system goes forward while 0008 is ON and rearward while
0009 is ON. It returns to the origin when 0007 turns ON.
A pulse is output from 0500. Reverse the rotation direction by turning ON/OFF 0502.
The system is equipped with an origin sensor (0002), forward end limit (0006), and
rearward end limit (0004).
3-301
KV-10/80
KV-300
Program example
0001
0002
SPECIFICATION
0003
0004
0005
0006
0007
0008
0009
1200
(RES)
< EI >
0009
2309
0502
(SET)
0006
1100
DIFU
0009
0008
2309
0502
(RES)
0004
1101
DIFU
0010
0011
1100
0012
#00001 #00000
< DW > < DW >
DM9411 DM9412
1103
DIFU
1101
0013
0008
0009
1105
DIFU
0014
0015
* * * * * * * * * * * * * * * * * * * * * * * * * * ORIGIN * * * * * * * * * * * * * * * * * * * * * * * * * * * *
0016
LIMIT SWITCHES
0007
1205
DIFU
0017
6
0018
FORWARD IN ADVANCE
0502
(SET)
1205
0019
0020
#00000 #03500
< DW > < DW >
DM9411 DM9412
1300
DIFU
1200
(SET)
#00001 #00000
< DW > < DW >
DM9411 DM9412
1301
DIFU
1200
(RES)
STOP FORWARDING
1200
0021
0022
2309
ON
1201
1201
2309
OFF
1202
1202
1203
DIFU
0023
3-302
0502
(RES)
STARTS MOTOR
1300
0006
1301
0004
2310
( )
0025
0026
1103
0027
1506
2308
0028
0004
0008
2308
( )
KV-10/80
0006
0030
KV-300
0029
0031
1105
0032
0033
0034
2008
0035
2308
0036
0037
0038
0039
1401
(RES)
1408
1408
DIFU
1402
(RES)
1403
(RES)
1400
(SET)
0000
1401
JMP
#00010
T001
T001
0040
1401
STG
1500
DIFU
1405
(RES)
#00005
T002
T002
0041
1402
STG
1501
DIFU
1406
(RES)
#00005
T003
T003
0042
1403
STG
1502
DIFU
2309
1405
1402
JMP
1405
2309
1406
1403
JMP
1406
2309
1407
1400
JMP
1407
0043
0502
(SET)
#00000 #15000
< DW > < DW >
DM9411 DM9412
1503
DIFU
1501
0502
(SET)
#00000 #02500
< DW > < DW >
DM9411 DM9412
1504
DIFU
1502
0502
(RES)
#00000 #17500
< DW > < DW >
DM9411 DM9412
1505
DIFU
0044
0045
0046
0047
STARTS MOTOR
1506
( )
1503
0048
1504
0049
1505
0050
END
0051
0052
0053
1200
0054
0008
0009
0000
2309
( RES )
RETI
0055
ENDH
0056
3-303
16
KV-10/80
KV-300
3-304
Chapter 7
Serial Communication
The KV Series can be connected to an external device with an RS-232C interface
to establish communication.
This chapter describes communications specifications, how to connect the KV
Series to external devices, and how to perform communication.
7.1
7.1.1
7.1.2
7.1.3
7.2
7.2.1
7.2.2
7.2.3
7.2.4
7.2.5
7.2.6
7.2.7
7.3
7.3.1
7.3.2
7.3.3
7.4
Full
Synchronization
Start/stop
Data format
ASCII
Baud rate
9,600 bps
Data length
8 bits
Parity check
Even
1 bit
Delimiter
CR
Note 1: Be sure to specify the same communication parameters for the KV and any
external devices to be connected. Communication will fail if different parameters are
used.
Note 2: Refer to the instruction manual supplied with each device when setting
communications parameters on the device.
Communication port B
Communication port A
KV
Note: The KV-10xx and KV-10/80 Series include only communication port A.
Wiring diagram
The following is the wiring diagram for the RS-232C cable. Be sure to use the
special connection cable to connect the KV with each device.
Device designated as modem
KV
SD
RD
SG
3
5
4
Connection
cable
(Reverse:
OP-96607)
3-306
2
3
7
4
5
6
20
SD
RD
SG
RS
CS
DR
ER
25-pin D-sub
connector
(OP-26485)
Device designated
as terminal
KV
SD
RD
SG
3
5
4
Connection
cable
(Straight:
OP-26487)
2
3
7
4
5
6
20
SD
RD
SG
RS
CS
DR
ER
25-pin D-sub
connector
(OP-26485)
Connecting cable
Standard cable:OP-26486
KV-300
Recommended pin assignments for the RS-232C communication cable are shown
below. When connecting the KV-300 CPU, use only the connecting cable supplied.
SD
RD
23
45
SG
KV-300
3
5
DCE
2
3
4
5
6
20
7
SD
RD
RS
CS
DR
ER
SG
SD
RD
KV-300
3
5
SG
DTE
2
3
4
5
6
20
7
SD
RD
RS
CS
DR
ER
SG
3
5
SG
Modular
Connector
2
3
4
5
6
7
8
17
3-307
Transmits communications
start command (CR)
Transmits a command
Receiving a response
Transmits communications
end command (CQ)
+V
100 ms or longer
SD
-V
10 ms or longer
Note 1: For the first serial communication with a personal computer after the KVP3E(01) handheld programmer is connected to the KV, or after the "KV IncrediWare
(DOS)" or "LADDER BUILDER for KV" programming support software is evoked, be
sure to transmit a break signal. A break signal is unnecessary at other times.
Note 2: If you cannot transmit a break signal, turn OFF the KV once to initialize the
communication program. After that, restart communication between the KV and the
personal computer.
Note 3: Be sure to stop the communication for 10 ms or longer after transmitting a
break signal.
3-308
Or
Command
Command
R
R
L
F
Response format
The KV sends back a response to the received command in the following format.
When creating a program using a personal computer, create it so that the personal
computer can process the response in this format.
Response
L
F
17
3-309
Command
Response
Starts communication.
CR
CC
Ends communication.
CQ
CF
Changes mode.
Mn
OK
Description
n= 0: PROGRAM mode
1: RUN mode
Clears error.
ER
OK
?E
dd
f= 0: PROGRAM mode
1: RUN mode
?M
Counter
RD_Cnnn
High-speed
counter CTH
RD_CTHn
High-speed
counter
RD_CTCn
comparator CTC
Reads
Timer
RD_Tnnn
Digital trimmer
RD_AT
f, ddddd, ddddd
f, ddddd, ddddd
ddddd_ddddd_00000_00000
(Trimmer 0) (Trimmer 1)
Relay contact
RD_nnnnn
Data memory
RD_DMnnnn
Temporary data
RD_TMnn
memory
Writes
Counter current
value
WR_Cnnn_ddddd
Timer current
value
WR_Tnnn_ddddd
CTH current
value
WR_CTHn_ddddd
Counter preset
value 2.
WS_Cnnn_ddddd
Timer preset
value 2.
WS_Tnnn_ddddd
CTC preset
value 2.
WS_CTCn_ddddd
Data memory
WR_DMnnnn_ddddd
Temporary data
WR_TMnn_ddddd
memory
Relay
Forces ON
ddddd
OK
n/nnn= Timer/counter
No. dddddd= 00000 to 65535 (in decimal)
OK
n/nnn= Timer/counter
No. dddddd= 00000 to 65535 (in decimal)
OK
OK
OK
ST_nnnnn
ST_Tnnn
Relay
RS_nnnnn
Timer contact
RS_Tnnn
High-speed
counter
RS_CTCn
comparator CTC
contact
Note 1: Temporary data memories TM28, TM30, and TM31 are read-only. Values cannot be written into
these memories. However, these memories can be used when special functions are not used.
Note 2: Visual KV Series: When the preset values of timers and counters are changed using "WS", the
ladder program in EEPROM is updated the next time the KV is turned on.
KV-300, 10/80 Series: The "WS" command changes the content of the program stored in the
PLCs EEPROM.
Contact Keyence if you need to change it frequently.
3-310
17
Command: ?E
Response: dd
Error code (2- or 3-digit number)
Checking current mode
The KV responds with 0 or 1 indicating a current mode.
Command: ?M
Response: f
0: PROGRAM mode 1: RUN mode
3-311
3-312
3-313
17
3-314
E1
Description
Relay No.
error
Command
error
Cause
Remedy
Check a command.
E2
E3
Base unit
fault
E4
Writeprotected
E5
Base unit
error
3-315
17
Description
Cause
Remedy
00
No error
10
11
12
13
20
Memory error
30
40
NO PROGRAM
50
SND/RTN failure
51
Division by zero
52
Address error
53
Invalid instruction
54
Hardware error was detected in a KV Turn off the power for the KV, and
base unit.
then turn it on again. If the cause of
the error is not removed, the KV may
be faulty. Contact your nearest
KEYENCE office.
3-316
PortCtrl%=&H3FBCOM1
Port1Modem%=&H3FCMODEMCtrl
PortBpsLow%=&H3F8BitrateLow
PortBpsHigh%=&H3F9BitrateHigh
*****ControlCode*****
Port1CtrlCode1%=&H5BBreak&8bitEven1Stopbit
Port1CtrlCode2%=&H1B8bitEven1Stopbit
Note: No parity check is specified due to the
*****InitializesRS-232C*****
limitations of the version of BASIC being used.
OPEN"COM1:9600,N,8,1"FORRANDOMAS#1'
*****RS-232CPortInit*****
OUTPortCtrl %,Port1CtrlCode1%Start transmitting a break signal
SLEEP1wait 1 sec.
OUTPortCtrl%,Port1CtrlCode2%Ends transmitting a break signal
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-******DebugPrint*****
status=INP(&H3FE):PRINT"ModemStatus1";status
status=INP(&H3FD):PRINT"LineStatus1";status
*****SelfInit.*****
linectrl=INP(PortCtrl%)ReadLine-Control-Register
linectrl=linectrlOR&H80'
OUTPortCtrl%,linectrlDLAB=ON
OUTPortBpsLow%,12SetBitRate(9600BPS)
OUTPortBpsHigh%,0'
linectrl=linectrlAND&H7FDLAB=OFF
OUTPortCtrl%,linectrl
*****CtrlLine*****
OUTPort1Modem%,&HBRTS,DTRON !!
*****DebugPrint*****
status=INP(&H3FE):PRINT"ModemStatus2";status
status=INP(&H3FD):PRINT"LineStatus2";status
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**********************************************************
*****Transmitting a command/receiving a response*****
*********************************************************
a$=""
WHILEa $>"END"
PRINT"Command>>":
INPUTa$
PRINT#1,a $
b$=""
LINEINPUT#1,b$
PRINT"RsP[";b$;"]"
PRINT
WEND
PRINT"GoodBy!!"
CLOSE#1
END
Note 1: MS-DOS executable files (KVCOM.EXE) and BASIC source code files
(KVCOM.BAS) are included in the KV Incrediware (DOS) Software (KV-H4E,
version 2.00 or higher).
Note 2: Type in "KVCOM" and press ENTER to call the MS-DOS command line.
3-317
17
Last byte
Text data (less than 100 bytes)
STX
ETX
Dat a
memory
NEW PO RT A
KV
PO RT B
KV- 300
KV- 10/ 80
Dat a No.
DM1000
DM1200
DM9200
Data 2
Data 3 to Data 98
Data 99
The KV writes "00" into the high-order 8 bits and text data in ASCII code into the
low-order 8 bits of the data memory.
7
Byte count of data
Received data
Data memory
1st DM
(Byte count of data)
Data 99 ETX
3rd DM
2nd DM
100th DM
4th DM
15
Bits in
data memory
00
3-318
Relay No.
( PO RT B)
Relay No.
( KV- 300/ 10/ 80)
Descript ion
2801
2806
2804
2802
2807
2805
2803
2808
2806
Note 1: Be sure to transmit a break signal for the first serial communication with a
personal computer after the KV-P3E(01) handheld programmer is connected to the
KV, or after the "KV IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software is evoked.
A break signal initializes the communication setting for the KV. If you cannot transmit
a break signal, turn the KV OFF once to initialize the communication setting. The KV
will not receive text data unless its communication setting has been initialized.
Note 2: If [ETX] exists at some point in the text data, the KV writes the data before
[ETX] into the data memory. The data after [ETX] is not written.
Note 3: If KV receives text data while special utility relay 2804 (2809)*1 is ON, the
received data is not written into the data memory. In this case, special utility relay
2802 (2807)*2 turns ON for one scan.
Note 4: When parity errors or other errors occur during text data reception, the
received data is not written into the data memory. In this case, special utility relays
2802 (2807) and 2803 (2808)*3 turn ON for one scan.
Note 5: The KV-10xx includes only communication port A.
*1: 2804 with KV-300/10/80 *2: 2805 with KV-300/10/80 *3: 2806 with KV-300/10/80
DM1100
DM1101
DM1102
Dat a
PO R T B
memory
K V- 3 0 0 /
10/ 80
DM1300
DM1301
DM1302
DM9300
DM9301
DM9302
Dat a No.
Byte count
Data 1
Data 2
Data 3 to Data 98
Data 99
The KV writes "00" into the high-order 8 bits and text data in ASCII code into the
low-order 8 bits of the data memory.
Low-order 8 bits (ASCII code)
00
Data memory
1st DM
(Byte count of data)
Transmitted data
2nd DM
3rd DM
4th DM
100th DM
Data 99
3-319
17
Relay No.
(Port B)
Relay No.
(KV-300/10/80)
2804
2809
2807
2800
2805
2803
Description
Note 1: Be sure to transmit a break signal for the first serial communication with a
personal computer after the KV-P3E(01) handheld programmer is connected to the
KV, or after the "KV IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software is evoked.
A break signal initializes the communication setting for the KV. If you cannot transmit
a break signal, turn the KV OFF once to initialize the communication setting.
The KV will not transmit/receive text data unless its communication setting has been
initialized.
Note 2: Turn ON special utility relay 2804 (2809) (SET 2804 [2809])*1 to transmit text
data. Special utility relay 2804 (2809)*1 remains ON during text data transmission,
and automatically turns OFF when the transmission completes.
To forcefully stop the text data transmission, turn OFF special utility relay 2804
(2809) (RES 2804 [2809])*1.
Note 3: A break signal is transmitted while special utility relay 2808*2 is turned ON.
Use the SET-RES instruction pair or OUT-OUB instruction pair to control a break
signal. The communication program of the destination KV is initialized after a break
signal has been transmitted.
*1: 2807 with KV-300/10/80 *2: 2803 with KV-300/10/80
0001
2800
T000
0002
One scan ON
2800
#00010
T000
0003
Break signal
0004
0005
0006
1001
#00009 $0002
$004B
$0045
$0059
$0045
DW
DW
DW
DW
DW
DW
DM1100 DM1101 DM1102 DM1103 DM1104 DM1105
No. of
STX
K
E
Y
E
transmitted
data
0007
0008
0009
2804
$004E
$0043
$0045
$0003
SET
DW
DW
DW
DW
DM1106 DM1107 DM1108 DM1109 Transmission
N
C
E
ETX
relay
0010
Reception error
0500
0011
#00030
T001
END
0012
ENDH
0013
3-320
High-order 4 bits
0
1
2
3
4
Low-order 4 bits
5
6
7
8
9
A
B
C
D
17
E
F
Characters in the shaded area can be used for data transmission with the KV.
[STX], [ETX], [LF], and [CR] are used as data delimiters.
Only use characters in the shaded area because the other characters are used for
control purposes.
3-321
3-322
Chapter 8
Programming Examples
This chapter describes the typical programming examples for KV-300, KV-10/80
Series. These programs can be used for Visual KV Series. However, pay attention
to the I/O addressing compatibility before use.
8.1
8.2
8.2.1
8.1 List
8.1 List
Instruction
Program title
One-shot circuit
3-326
Off-delay circuit
3-326
C [Counter]
3-327
Flicker circuit
3-327
Accumulator timer
3-327
3-328
3-328
3-328
DIFU, DIFD
One-shot circuit
3-329
KEEP
3-329
SFT
Alternating circuit
3-330
3-331
3-331
3-332
HSP
3-332
MC-MCR
3-333
W-UE
3-334
3-334
3-335
Conditional branching
3-335
STP-STE
Process progression
3-336
ITVL
3-336
3-337
3-338
3-339
3-339
SBN [Sub-routine]
DM shift
3-340
FOR-NEXT
3-341
HKEY
3-342
3-343
3-343
3-343
3-345
LDA/STA
CMP
ADD
3-345
3-345
3-345
3-346
Multi-level comparator
3-346
3-347
Total count
3-348
SUB
3-348
MUL
3-349
DIV
3-349
ANDA
3-350
3-350
3-351
3-351
ORA
3-324
On-delay circuit
STG-JMP
Reference
Page
8.1 List
Instruction
Program title
EORA
3-352
SRA/SLA
3-352
RRA/RLA
3-353
INC/DEC
Reference
Page
Total count
3-353
Up/Down count
3-354
MPX
3-355
DMX
3-356
TBCD
3-356
3-356
3-357
TBIN
18
3-325
8.2 Details
8.2
Details
0000
0500
2s
2s
Ladder diagram
Coding
2-s timer
0000
#00020
T000
0500
T000
00500
Line No.
0000
0001
0002
0003
0004
Instruction
LD
OR
TMR
ANB
OUT
Operand
0000
0500
000#00020
T000
0500
Off-delay circuit
When input relay 0000 turns ON, output relay 0500 turns ON. 0500 turns OFF in a
specified time after 0000 turns OFF.
Timing diagram
0000
0500
2s
Ladder diagram
0000
0500
Coding
0500
T000
00000
#00020
T000
2-s timer
3-326
Line No.
0000
0001
0002
0003
0004
0005
Instruction
LD
OR
ANB
OUT
ANB
TMR
Operand
0000
0500
T000
0500
0000
000 #00020
8.2 Details
On-delay circuit
Output relay 0500 turns ON in a specified time after input relay 0000 turns ON.
When input relay 0000 turns OFF, output relay 0500 also turns OFF.
Timing diagram
0000
0500
2s
1s
Ladder diagram
Coding
2-s timer
0000
#00020
T000
T000
0500
Line No.
0000
0001
0002
0003
Instruction
LD
TMR
LD
OUT
Operand
0000
000 #00020
T000
0500
Flicker circuit
Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
Timing diagram
0500
1s
1s
0000
2s
2s
Ladder diagram
0000
T001
Coding
2-s timer
1-s timer
T000
Line No.
#00020
T000
#00010
T001
0500
Instruction
Operand
0000
LD
0000
0001
ANB
T001
0002
TMR
000 #00020
0003
LD
T000
0004
TMR
001 #00010
0005
OUT
0500
Coding
0000
C001
1-s pulse
0001
10000-s counter
#03600
C001
2006
1000
#10000
C002
1000
Operand
0000
LD
0000
0001
ANB
C001
0002
0003
LD
C001
0004
OUT
1000
0005
LDB
0001
0006
3-327
18
8.2 Details
Large capacity counter
Accumulates 1 count to C001 for every 10000 counts by C000. This example can
count up to 655350000.
Count input relay 0000
Reset relay 0001
Ladder diagram
0001
Coding
C000
#10000
C000
0000
1000
C000
0001
#65535
C001
1000
Operand
0000
LDB
0001
0001
ANB
C000
0002
0003
LD
C000
0004
OUT
1000
0005
LDB
0001
0006
C000
LDA
TBCD
8500
STA
C001
LDA
TBCD
8600
STA
Low-order
4 digits
High-order
4 digits
Ladder diagram
Coding
UDC000
UP
#09999
DW
0001
0002
BCD:
Low-order
4 digits
0003
RES
C000
0001
C000
0002
UDC001
UP
#09999
DW
BCD:
High-order
4 digits
0003
RES
LD
LD
LD
UDC
LD
AND
LD
AND
LD
UDC
2002 C000
LDA
#09999
C000
0000
#00999 2011
CMP
#01999 2011 0500
CMP
0500
00000 to
00999
0501
01000 to
01999
3-328
Operand
0001
0002
0003
000 #09999
C000
0001
C000
0002
0003
001 #09999
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LDB
C
LD
LDA
CON
MPS
CMP
CON
ANB
OUT
MRD
CMP
Operand
0001
000 #09999 0000
2002
C000
#00999
2011
0500
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
Instruction
CON
ANB
ANB
OUT
MPP
CMP
CON
ANB
ANB
ANB
OUT
Operand
2011
0500
0501
#02999
2011
0500
0501
0502
#01999
1S
0501
1S
Ladder diagram
Coding
0000
1000
DIFU
1001
DIFD
1000
T001
0500
0500
1001
#00010
T001
T002
0501
0501
#00010
T002
Refer to p. 3-78.
Operand
0000
1000
1001
1000
0500
T001
0500
001 #00010
1001
0501
T002
0501
002 #00010
ing ck
ew
Ch m pa
gu
ON
OFF
ing ck
ew
Ch m pa
gu
ON
ES Series
Gum
Gum
Gum
Gum
Gum
Gum
Gum
Gum
PZ2-61
3-329
18
8.2 Details
Timing diagram
0000
0001
0002
0003
0500
1s
Ladder diagram
0000 0001 0002 0003
KEEP
SE T
1000
1001
RES
0000
1001
DIFD
0500
0500
#00010
T001
Detects presence/absence
of chewing gum packs at
DOWN edge of 0000.
Executes SET when all input relays 0000 to 0003 are ON.
Detects presence/absence of chewing gum packs at DOWN edge of 0000.
Outputs 1-s one-shot pulse from output relay 0500 when 1000 is OFF.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
AND
AND
AND
LD
KEEP
LD
Operand
0000
0001
0002
0003
1001
1000
0000
Line No.
0007
0008
0009
0010
0011
0012
0013
Instruction
DIFD
LD
ANB
OR
ANB
OUT
TMR
Operand
1001
1001
1000
0500
T001
0500
001 #00010
Refer to p. 3-80.
Ladder diagram
Coding
SFT
1000
D
1000
0000
CLK
1000
2003
RES
1000
0500
Refer to p. 3-82.
3-330
Operand
0000
LDB
1000
0001
LD
0000
0002
LD
2003
0003
SFT
1000 1000
0004
LD
1000
0005
OUT
0500
8.2 Details
Repeat shift circuit
Turns ON every output for a second sequentially. Sets 1000 to 2008 (ON for 1st
scan only at startup) and shifts outputs from 7500 to 7504 every second at T001.
When 1005 turns ON, 1000 is set and the same sequence as above repeats.
Ladder diagram
Coding
1000
SET
#00010
T001
2008
T001
SFT
2003
D
1000
T001
CLK
1000
1005
RES
7500
1001
7501
1002
7502
1003
7503
1004
7504
2003
1000
SET
1005
Operand
2008
1000
T001
#00010
2003
T001
2003
1000 1005
1000
7500
1001
0011
OUT
7501
0012
LD
1002
0013
OUT
7502
0014
LD
1003
0015
OUT
7503
0016
LD
1004
0017
OUT
7504
0018
LD
1005
0019
SET
1000
18
1001
1002
.
.
.
Ladder diagram
Coding
1100
DIFU
0000
1100
1000
SET
2003
SFT
D
1000
0001
CLK
1010
0002
RES
Operand
0000
LD
0000
0001
DIFU
1100
0002
LD
1100
0003
SET
100
0004
LD
2003
0005
LD
0001
0006
LD
0002
0007
SFT
1000 1010
3-331
8.2 Details
Resetting internal utility relays
When input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915
turn OFF.
SFT instruction can be substituted for RES instruction. This application can be used
to reset many relays at one time.
Ladder diagram
Coding
SFT
2003
D
1000
2003
CLK
1915
0000
RES
Line No.
0000
Instruction
LD
Operand
2003
0001
LD
2003
0002
LD
0000
0003
SFT
1000 1915
1s
Ladder diagram
Coding
0001
0000
0500
HSP
0000
1-s timer
#00010
T000
T000
0500
Outputs
1-s one-shot
pulse from
output relay
0500.
Line No.
0000
0001
0002
0003
0004
0005
0006
To input a signal having pulse interval shorter than the scan time, use the interrupt instruction. Refer to p. 3-192.
0500
#00010
T000
T000
0500
RES
Interrupt enabled
Initial settings
Input time constant
10 s
Turns ON timer for
1s when 0500 is ON.
Resets 0500 when
T000 turns ON.
END
2002
INT
0000
0500
SET
RETI
ENDH
3-332
Instruction
Operand
LD
0001
HSP
0000
LD
0000
OR
0500
TMR
000 #00010
ANB
T000
OUT
0500
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
EI
SET
LD
T000
LD
RES
Operand
2008
2813
0500
#00010
T000
0500
Line No.
0007
0008
0009
0010
0011
0012
Instruction
END
INT
LD
SET
RETI
ENDH
Operand
0000
2002
0500
Refer to p. 3-86.
Coding
0000
0001
0002
0003
0500
0501
0502
Ladder diagram
0000
1000
1001
0001
0002
1100
SET
1101
RES
1102
RES
MC
0003
1100
STG
1200
0004
#00010 T000
T000
1101
JMP
1101
STG
1201
0005
#00020 T001
T001
1102
JMP
1102
STG
1202
0006
#00030 T002
T002
1100
JMP
MCR
0007
1001
MC
0001
1203
0002
1204
0003
1205
0008
0009
0010
0011
MCR
0012
1200
0500
0013
1203
0014
1201
0501
0015
1204
0016
1202
0502
0017
1205
0018
END
0019
ENDH
0020
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
Instruction
LD
OUT
CON
OUB
LD
DIFU
CON
AND
SET
CON
RES
CON
RES
LD
MC
STG
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
TMR
CON
AND
JMP
MCR
LD
MC
LD
OUT
LD
OUT
LD
OUT
MCR
LD
OR
OUT
LD
OR
OUT
LD
OR
OUT
END
ENDH
Operand
0000
1000
1001
0000
1002
1002
1100
1101
1102
1000
1100
1200
000 #00010
T000
1101
1101
1201
001 #00020
T001
1102
1102
1202
002 #00030
T002
1100
1001
0001
1203
0002
1204
0003
1205
1200
1203
0500
1201
1204
0501
1202
1205
0502
3-333
18
8.2 Details
Application Instructions
Application of W-UE instruction
Input sequence check
Output relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and
0003 turn ON in this sequence.
Output relay 0500 turns OFF when input relay 0000 is OFF.
Timing diagram
0000
0001
0002
0003
0500
Ladder diagram
Coding
0001
0000
Operand
1000
1000
0002
0000
LD
0000
0001
W-UE
0002
LD
1000
1001
1001
0003
0001 1000
0003
W-UE
0002 1001
1002
0500
0004
LD
1001
1002
0005
W-UE
0003 1002
0006
LD
1002
0007
OUT
0500
Ladder diagram
0000
0001
0001
1000
0000
1000
1001
Coding
Operand
Leave
warehouse
0000
LD
0000
0001
W-UE
0001 1000
Enter
warehouse
0002
CON
0003
AND
1000
0004
OUT
0500
0005
LD
0001
0006
W-UE
0000 1001
0007
CON
0008
AND
1001
0009
OUT
0501
0501
1001
3-334
0500
8.2 Details
0000
1000
STG
1000
SET
1100
1001
JMP
#00020 T001
T001
1002
JMP
1000
JMP
1001
STG
0500 0501
1002
STG
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
CAUTION
Instruction
LD
DIFU
CON
AND
SET
STG
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
OUT
Operand
0000
1100
1100
1000
1000
0500
000 #00010
T000
1001
1001
0500
0501
Line No.
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
Instruction
CON
TMR
CON
AND
JMP
STG
OUT
CON
OUT
CON
OUT
CON
TMR
CON
AND
JMP
Operand
001 #00020
T001
1002
1002
0500
0501
0502
002 #00030
T002
1000
1100
DIFU
1100
1000
STG
0500
0001
1001
JMP
0002
1002
JMP
1000
SET
1001
STG
0501
#00010
T000
T000
1000
JMP
1002
STG
0502
#00020
T001
T001
1000
JMP
3-335
18
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
Instruction
LD
DIFU
CON
AND
SET
STG
OUT
MPS
AND
JMP
MPP
AND
JMP
STG
Operand
0000
1100
1100
1000
1000
0500
0001
1001
0002
1002
1001
Line No.
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
Instruction
OUT
CON
TMR
CON
AND
JMP
STG
OUT
CON
TMR
CON
AND
JMP
Operand
0501
000 #00010
T000
1000
1002
0502
001 #00020
T001
1000
Coding
1001
SET
STP
1001
0002
T000
1001
RES
T000
0500
1001
#00020
T000
T000
1002
SET
0003
0004
0005
0006
STE
0007
STP
1002
0008
T001
1002
RES
T001
0501
1002
#00030
T001
0009
0010
0011
STE
0012
END
0013
ENDH
0014
Refer to p. 3-114.
LD
DIFU
CON
AND
SET
STP
LD
RES
LDB
OUT
LD
TMR
LD
SET
STE
STP
LD
RES
LDB
OUT
LD
TMR
STE
END
ENDH
Operand
0000
1000
1000
1001
1001
T000
1001
T000
0500
1001
000 #00020
T000
1002
1002
T001
1002
T001
0501
1002
001 #00030
3-336
8.2 Details
Reset input relay 0002
Output relay 0500 turns ON
when the pulse interval is not within the range from 490 to 510 mm.
Measure the pulse interval
ON
OFF
500ms
Ladder diagram
2008
2008
2008
2008
#00001
LDA
DM0000
STA
#00051
LDA
DM0001
STA
#00049
LDA
DM0002
STA
#00010
LDA
DM0003
STA
0000
0001
1002
ITVL
PLS
DM0000
PAUSE
1000
RES
0002
DM0007
LDA
DM0100
STA
0500
RES
0500
SET
1000
1001
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
Instruction
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
Operand
2008
#00001
DM0000
2008
#00051
DM0001
2008
#00049
DM0002
2008
#00010
Line No.
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
Instruction
STA
LD
LD
LD
ITVL
LD
LDA
CON
STA
CON
RES
LD
OR
SET
Operand
DM0003
0000
0001
0002
DM0000 1000
1002
DM0007
DM0100
0500
1000
1001
0500
3-337
18
8.2 Details
Ladder diagram
Coding
2008
#09000
LDA
DM0000
STA
2008
#02000
LDA
DM0001
STA
2008
#00900
LDA
DM0002
STA
2008
#00010
LDA
DM0003
STA
ITVL
PLS
DM0000
2003
0001
PAUSE
1000
RES
0002
DM0007
LDA
1003
DM0100
STA
Refer to p. 3-117.
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
Instruction
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LDA
CON
STA
LD
LD
LD
ITVL
LD
LDA
CON
STA
Operand
2008
#09000
DM0000
2008
#02000
DM0001
2008
#00900
DM0002
2008
#00010
DM0003
2003
0001
0002
DM0000 1000
1003
DM0007
DM0100
#0100 DM0000
#0200 DM0001
#0300 DM0002
Ladder diagram
Coding
CTH1
00005
8
2002
3-338
CTH1
LDA
DM0000 2009
CMP
0500
DM0001 2009
CMP
0501
DM0002 2009
CMP
0502
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
Instruction
LD
SET
CON
LDA
CON
STA
CON
LDA
CON
STA
CON
LDA
CON
STA
LDB
CTH1
LD
LDA
MPS
CMP
ANB
OUT
MRD
CMP
ANB
OUT
MPP
CMP
ANB
OUT
Operand
2008
2813
#01000
DM0000
#02000
DM0001
#03000
DM0002
0001
0005
2002
CTH1
DM0000
2009
0500
DM0001
2009
0501
DM0002
2009
0502
8.2 Details
High-speed counter current value clear
Counts pulses at input relay 0005. When the count value reaches setting value
60000, clears the current value of high speed counter CTH1 and turns ON output
relay 0502 for 3 s.
Ladder diagram
Coding
2813
SET
2008
2203
SET
2002
CTH1
RES
CTH1
0005
#60000
CTC2
CTC2
0502
#00030
T001
T001
CTC2
RES
0502
RES
Operand
2008
2813
2203
CTH1
2002
0005
#60000
CTC2
0502
001 #00030
T001
CTC2
0502
2813 2103
SET SET
0500
2002
CTH0
LDA
DM0000
STA
Initial settings*Note
CTH0
00004
#60000
CTC0
18
END
2002
INT
CTC0
0500
SET
RETI
ENDH
3-339
8.2 Details
CAUTION
Instruction
LD
EI
CON
SET
CON
SET
CON
SET
CON
RES
CON
SET
CON
RES
Operand
2008
2813
2103
2113
2114
2115
Line No.
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
Instruction
LDB
CTH
CTC
LD
LDA
CON
STA
END
INT
LD
SET
RETI
ENDH
Operand
0500
1 0004
0 #60000
2002
CTH0
DM0000
CTC0
2002
0500
CTH0
Designates the
Designates the
shift end
shift start
DM No. (DM0010). DM No. (DM0030).
00
Shifts data from
CALL DM0010 to DM0030.
END
SBN
00
2002
TM03 #00001
LDA
ADD
TM04
STA
TM02
SUB
TM05
STA
Shift level
8
2002
TM03
DEC
TM04
DEC
#TM03
LDA
FOR
TM05
#TM04
STA
NEXT
2002
#00000
LDA
#TM02
STA
RET
ENDH
3-340
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
Instruction
LD
DIFU
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
CON
CALL
END
SBN
LD
LDA
CON
ADD
CON
STA
Operand
0000
1000
1000
#00010
TM02
#00030
TM03
00
00
2002
TM03
#00001
Line No.
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
Instruction
CON
SUB
CON
STA
FOR
LD
DEC
CON
DEC
CON
LDA
CON
STA
NEXT
LD
LDA
CON
STA
RET
ENDH
Operand
TM02
TM05
TM05
2002
TM03
TM04
#TM03
#TM04
2002
#00000
#TM02
TM04
Refer to p. 3-122.
Application of FOR-NEXT
Transfer of a block of DM data
Uses the indirect addressing function to transfer a block of data from DM0000 DM0099 to DM0100 - DM0199.
Ladder diagram
Coding
SBN
01
2002
#0000
LDA
TMO2
STA
1st DM No. of
transfer source
#00100
LDA
TMO3
STA
1st DM No. of
transfer destination
FOR
#00100
2002
#TM02
LDA
#TM03
STA
TM02
INC
TM03
INC
NEXT
RET
Data memory
DM0000
DM0099
DM0100
Transfer
a block of data
Operand
01
2002
2002
#TM02
#0000
18
#TM03
TM02
TM02
#00100
TM03
TM03
#00100
DM0199
Refer to p. 3-125.
3-341
8.2 Details
24 VDC
Ladder diagram
2008
2814
SET
2002
HKEY
0000
0500
DMX
KEY IN
TM06
STA
TM06 DM0000
Input value
ORA
STA
(BCD)
#00000
Input value
DW
(BCD)
DM0000
END
ENDH
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
Instruction
LD
SET
LD
HKEY
LD
LDA
CON
ANB
ANDA
CON
CMP
CON
ANB
STA
CON
DMX
CON
STA
LD
LDA
CON
Operand
2008
2814
2002
0000 0500
2815
2900
Refer to p. 3-131.
3-342
2010
$03FF
TM05
2010
TM05
TM06
2815
2900
Line No.
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
Instruction
AND
ANDA
CON
CMP
CON
ANB
STA
CON
LDA
CON
SLA
CON
ORA
CON
STA
LD
AND
DW
END
ENDH
Operand
2010
$03FF
TM05
2010
TM05
DM0000
#04
TM06
DM0000
2815
2915
#0000 DM0000
8.2 Details
Arithmetic Instructions
Applications of TMIN (Analog timer) instruction
Changing timer setting value
Uses analog timer (TMIN0) to change the timer setting value (0 to 24.9 s).
Ladder diagram
Coding
2002
0
TMIN
T000
STA
0000
#00010
T000
0500
T000
0500
Operand
2002
0
T000
0000
0500
000 #00010
T000
0500
0
TMIN
Coding
T000
STA
T001
STA
0000
#00010
T000
0500
T000
0500
0001
#00010
T001
0501
T001
0501
0002
#00010
T002
0502
T002
STA
T002
0502
Refer to p. 3-138.
Operand
2002
0
T000
T001
T002
0000
000 #00010
T000
0500
0001
0501
001 #00010
T001
0501
0002
0502
002 #00010
0500
T002
0502
OK/NG judgement
DM0000
DM0001
Data shift
DM0002
DM0003
DM0004
Unloading timing
3-343
18
8.2 Details
The data once fetched is written into DM0004, DM0003, ..., DM0000 in this order. At
the unloading timing, unload the data from DM0004 and shifts the data value to the
next DM.
The ON/NG judgement and unloading timings can be used in asynchronous programs.
Ladder diagram
0000
1000
DIFU
1000
0001
$1111
LDA
DM0000
STA
0001
$5555
LDA
DM0000
STA
$0000
DM0004
LDA
STA
Unloading timing
Transfers $0000 to DM at unloading timing.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
3-344
Instruction
LD
DIFU
CON
AND
MPS
AND
LDA
CON
STA
MPP
ANB
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
Operand
0000
1000
1000
0001
$1111
DM0000
0001
$5555
DM0000
2002
DM0004
$0000
2010
DM0003
DM0004
$0000
DM0003
2002
DM0003
$0000
2010
DM0002
Line No.
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
Instruction
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
LDA
CON
CMP
CON
AND
LDA
CON
STA
CON
LDA
CON
STA
LD
@LDA
CON
@STA
Operand
DM0003
$0000
DM0002
2002
DM0002
$0000
2010
DM0001
DM0002
$0000
DM0001
2002
DM0001
$0000
2010
DM0000
DM0001
$0000
DM0000
0002
$0000
DM0004
8.2 Details
Changing the counter setting value
Sets the setting value of counter C000 to DM0000. Reset input is 0005.
Ladder diagram
2002
Coding
DM0000
LDA
0005
C000
STA
#9999
C000
0001
Coding
DM0000
LDA
0005
T000
STA
#9999
T000
Refer to p. 3-140.
Operand
2002
DM0000
T000
0005
0000 #9999
Coding
2009
0500
CMP
2010
0501
2011
0502
DM0000
<#01000
DM0000
=#01000
DM0000
>#01000
Operand
2002
DM0000
#01000
2009
0500
2010
0501
2011
0502
2002
2002
C001
#01000
LDA
CMP
C001
#02000
LDA
CMP
2011
#09999
C001
0000
0500
2009
0501
C001 #1000
C001 #02000
3-345
18
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
Instruction
LDB
C
LD
LDA
CON
CMP
CON
ANB
Operand
0001
001 #09999 0000
2002
C001
#01000
2011
Line No.
0008
0009
0010
0011
0012
0013
0014
0015
Instruction
OUT
LD
LDA
CON
CMP
CON
ANB
OUT
Operand
0500
2002
C001
#02000
2009
0501
2009
0501
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
Instruction
LD
TMIN
CON
ADD
CON
MUL
CON
DIV
CON
STA
LDB
Operand
2002
0
#00001
#00004
#00010
DM0000
0001
Line No.
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
Instruction
C
LD
LDA
CON
CMP
MPS
AND
OUT
MPP
ANB
OUT
Operand
000 #09999 0000
02002
C000
Multi-level comparator
Compares the counter current value according to the following range:
0 to 999 0500 turns ON.
1000 to 1999 0501 turns ON.
2000 to 2999 0502 turns ON.
Counter reset relay 0001
Counter input relay 0000
3-346
DM0000
2009
0500
2009
0501
8.2 Details
Ladder diagram
0001
2002 C000
LDA
#09999
C000
0000
#00999 2011
CMP
#01999 2011 0500
CMP
0500
C000 00999
0501
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LDB
C
LD
LDA
CON
MPS
CMP
CON
ANB
OUT
MRD
CMP
Operand
0001
000 #09999 0000
2002
C000
#00999
2011
0500
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
Instruction
CON
ANB
ANB
OUT
MPP
CMP
CON
ANB
ANB
ANB
OUT
Operand
2011
0500
0501
#02999
2011
0500
0501
0502
#01999
Refer to p. 3-146.
7000
DM0000
LDA
TBIN
STA
C001
DM0000
DM0100
LDA
ADD
0001
18
STA
#09999
C001
0000
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
LDA
CON
TBIN
CON
STA
LD
Operand
2002
7000
DM0000
2002
Line No.
0007
0008
0009
0010
0011
0012
0013
Instruction
LDA
CON
ADD
CON
STA
LDB
C
Operand
C001
DM0000
DM0100
0001
001 #09999 0000
3-347
8.2 Details
Total count
Writes total count of counters C001 to C003 into DM0100. The total count must be
within 65535.
Ladder diagram
#09999 C001
C001
LDA
0001
#09999 C002
0000
C002
LDA
0002
#09999 C003
0000
C003
LDA
0003
2002 DM0001 DM0002 DM0003
LDA
ADD
ADD
0000
DM0001
STA
DM0002
STA
DM0003
STA
DM0100
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
Instruction
Operand
LDB
0000
C
001 #09999 0001
CON
LDA
C001
CON
STA
DM0001
LDB
0000
C
002 #09999 0002
CON
LDA
C002
CON
STA
DM0002
LDB
0000
Line No.
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
Instruction
Operand
C
003 #09999 0003
CON
LDA
C003
CON
STA
DM0003
LD
2002
LDA
DM0001
CON
ADD
DM0002
CON
ADD
DM0003
CON
STA
DM0100
Refer to p. 3-150.
1000
1001
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
Instruction
LD
LDA
CON
SUB
MPS
ANB
CMP
CON
ANB
OUT
MPP
AND
Operand
2002
DM0000
DM0001
Refer to p. 3-150.
3-348
2009
#00005
2009
1000
2009
Line No.
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
Instruction
LDA
CON
SUB
CON
CMP
CON
ANB
OUT
LD
OR
OUT
Operand
DM0001
DM0000
#00005
2009
1001
1000
1001
0500
8.2 Details
Coding
0001
#09999
C001
0000
2002 C001 DM0000 DM0100 TM00 DM0101
STA
LDA
MUL
STA
LDA
Refer to p. 3-150.
0000
0000
2002
2002
#09999
C001
00001
#09999
C002
00002
#09999
C003
00003
DM0001
LDA
C001
LDA
DM0001
STA
C002
LDA
DM0002
STA
C003
LDA
DM0003
STA
DM0002 DM0003
ADD
ADD
#00003
DIV
TBCD
07500
STA
18
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
Instruction
LDB
C
CON
LDA
CON
STA
LDB
C
CON
LDA
CON
STA
LDB
C
CON
Operand
0000
001 #09999 0001
C001
DM0001
0000
002 #09999 0002
C002
DM0002
0000
003 #09999 0003
Line No.
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
Instruction
LDA
CON
STA
LD
LDA
CON
ADD
CON
ADD
LD
DIV
CON
TBCD
CON
STA
Operand
C003
DM0003
2002
DM0001
DM0002
DM0003
2002
#00003
7500
Refer to p. 3-150.
3-349
8.2 Details
0000
LDA
$000F
ANDA
TBIN
C000
STA
2002
#09999
C000
7001
7000
Sets C000.
Coding
Line No.
0000
0001
0002
0003
0004
Instruction
LD
LDA
CON
ANDA
LD
Operand
2002
0000
$000F
2002
Line No.
0005
0006
0007
0008
0009
Instruction
TBIN
CON
STA
LDB
C
Operand
C000
7000
000 #09999 7001
$00FF
ANDA
TBIN
C000
STA
2002 7000
LDA
$FF00
ANDA
#08
SRA
TBIN
0001
#09999
C000
0000
0001
#09999
T001
Sets T001.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
Instruction
LD
LDA
CON
ANDA
CON
TBIN
CON
STA
LD
LDA
CON
Operand
2002
7000
Refer to p. 3-159.
3-350
$00FF
C000
2002
7000
Line No.
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
Instruction
ANDA
CON
SRA
CON
TBIN
CON
STA
LDB
C
LDB
T
Operand
$FF00
#08
T001
0001
000 #09999 0000
0001
001 #09999
8.2 Details
7500
LDA
#00099
C000
0001
$FF00
ANDA
DM0000
STA
C000
LDA
TBCD
$00FF
ANDA
DM0000
ORA
7500
STA
0000
2002
2002
2002
Sets C000.
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
Instruction
LDB
C
LD
LDA
CON
ANDA
CON
STA
LD
Operand
0000
000 #00099 0001
2002
7500
$FF00
DM0000
2002
Line No.
0009
0010
0011
0012
0013
0014
0015
0016
0017
Instruction
LDA
CON
TBCD
CON
ANDA
LD
ORA
CON
STA
Operand
C000
$00FF
2002
DM0000
7500
2002
7000
LDA
#00099
C001
0001
$000F
ANDA
2002
8000
LDA
$000F
ANDA
2002
#04 DM0000
SLA
ORA
TBIN
18
DM0000
STA
C001
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
Instruction
LDB
C
LD
LDA
CON
ANDA
CON
STA
LD
LDA
Operand
0000
001 #00099 0001
2002
7000
$000F
DM0000
2002
8000
Line No.
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
Instruction
CON
ANDA
LD
SLA
CON
ORA
CON
TBIN
CON
STA
Operand
$000F
2002
#04
DM0000
C001
Refer to p. 3-161.
3-351
8.2 Details
2002
Coding
$00AA DM0000
LDA
STA
7000
LDA
$00FF
ANDA
Operand
2008
$00AA
DM0000
2002
7000
$00FF
DM0000
2010
0500
Judges match between the operand and the data of 7000 to 7015.
2002
7000
LDA
#00099
C001
0000
$F000
ANDA
2002
#12
SRA
DM0000
STA
2002
08000
LDA
$000F
ANDA
2002
#04
SLA
DM0000
ORA
TBIN
C001
STA
2002
3-352
Sets C001.
8.2 Details
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
Instruction
LD
C
LD
LDA
CON
ANDA
LD
SRA
CON
STA
LD
Operand
0001
001 #00099 0000
2002
7000
$F000
2002
#12
DM0000
2002
Line No.
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
Instruction
LDA
CON
ANDA
LD
SLA
CON
ORA
LD
TBIN
CON
STA
Operand
8000
$000F
2002
#04
DM0000
2002
C001
Refer to p. 3-166.
2002
FOR
#00016
2002
#01
RRA
2009
TM10
INC
NEXT
2002 TM10
LDA
DM0000 #00000
STA
LDA
TM10
STA
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
0007
0008
Instruction
LD
LDA
FOR
LD
RRA
CON
AND
INC
NEXT
Operand
2002
7000
#00016
02002
#01
2009
TM10
Line No.
0009
0010
0011
0012
0013
0014
0015
0016
Instruction
LD
LDA
CON
STA
CON
LDA
CON
STA
Operand
2002
TM10
18
DM0000
#00000
TM10
Refer to p. 3-169.
3-353
8.2 Details
Ladder diagram
2008
#00000
LDA
DM0000
STA
0000
DM0000
INC
0001
DM0000
INC
0002
DM0000
INC
0003
DM0000
INC
0005
#00000
DW
DM0000
Coding
Line No.
0000
0001
0002
0003
0004
0005
0006
Instruction
LD
LDA
CON
STA
LD
@INC
LD
Operand
2008
#00000
DM0000
0000
DM0000
0001
Line No.
0007
0008
0009
0010
0011
0012
0013
Instruction
@INC
LD
@INC
LD
@INC
LD
DW
Operand
DM0000
0002
DM0000
0003
DM0000
0005
#00000 DM0000
UP/DOWN count
Performs UP count when input relay 0000 turns ON.
Performs DOWN count when input relay 0001 turns ON.
Writes the count value into DM0000.
Reset input relay is 0005.
Ladder diagram
#00000
LDA
2008
DM0000
STA
0000
DM0000
INC
0001
DM0000
DEC
0005
#00000
DW
DM0000
Coding
Line No.
0000
0001
0002
0003
0004
Instruction
LD
LDA
CON
STA
LD
Operand
2008
#00000
DM0000
0000
Refer to p. 3-172.
3-354
Line No.
0005
0006
0007
0008
0009
Instruction
@INC
LD
@DEC
LD
DW
Operand
DM0000
0001
DM0000
0005
#00000 DM0000
8.2 Details
a. 7500
b. 7501
c. 7502
d. 7503
e. 7504
c
d
f. 7505
g. 7506
Ladder diagram
Converts the counter value to 16-bit
data using the MPX instruction.
C000
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
#00009
C000
0000
Coding
C000
LDA
#0
MPX
1000
STA
$003F
LDA
7500
STA
$0006
LDA
7500
STA
$005B
LDA
7500
STA
$004F
LDA
7500
STA
$0066
LDA
7500
STA
$006D
LDA
7500
STA
$007D
LDA
7500
STA
$0007
LDA
7500
STA
$007F
LDA
7500
STA
$006F
LDA
7500
STA
7-segment display
Refer to p. 3-176.
3-355
18
8.2 Details
07000
LDA
DMX
TBCD
$00FF
ANDA
2002
8000
STA
Coding
Line No.
0000
0001
0002
0003
0004
Instruction
LD
LDA
CON
DMX
LD
Operand
2002
7000
2002
Line No.
0005
0006
0007
0008
0009
Instruction
TBCD
CON
ANDA
CON
STA
Operand
$00FF
8000
Refer to p. 3-176.
0001
2002
C001
LDA
TBCD
Coding
Line No.
Instruction
Operand
Line No.
Instruction
0000
LDB
0001
0004
CON
0001
0005
TBCD
0002
LD
2002
0006
CON
0003
LDA
C001
0007
STA
Operand
7500
Internal register
(High-order 4 digits)
(Low-order 4 digits)
(Display)
3-356
(Remainder)
8.2 Details
Ladder diagram
2002 DM0000 DM0001
LDA
MUL
DM0101
LDA
#10000 DM0101
DIV
STA
TBCD
TM01
LDA
TBCD
7500
STA
8500
STA
Coding
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
2002
0010
CON
0001
LDA
DM0000
0011
TBCD
0002
CON
0012
CON
0003
MUL
0004
CON
0005
DIV
0006
CON
0007
STA
0008
CON
0009
LDA
DM0001
#10000
0013
STA
0014
CON
0015
LDA
0016
CON
DM0101
0017
TBCD
0018
CON
TM01
0019
STA
Operand
750
DM0101
8500
Refer to p. 3-180.
7000
LDA
C001
STA
TBIN
0001
#09999
C001
0000
Sets C001.
Coding
Line No.
Instruction
Operand
Line No.
Instruction
0000
LD
2002
0004
CON
0001
LDA
7000
0005
STA
Operand
C001
0002
CON
0006
LDB
0001
0003
TBIN
0007
Refer to p. 3-183.
3-357
18
8.2 Details
3-358
Index
Title
Page
A
Access Window, changing device value in
Device mode
1-87
1-82
User messages
1-97
1-97
Error List
1-372
Turbo function
1-83
1-82
System Mode
1-94
1-84
Application instructions
3-36
Arithmetic instructions
3-38
Basic instructions
3-34
3-233
3-233
CE marking, acquiring
B
Basic instructions, learning about
C
Cam switch function, setting item for
(2)
3-310
3-316
Communications Specification
3-306
3-27
1-69
Contacts, protecting
Contact protection
(4)
Current consumption
General specifications
1-4
Data memories
3-19
3-237
3-238
3-238
3-238
Index
1-75
1-71
1-73
Expansion unit, setting its height flush with AC-type basic unit
1-66
3-26
3-26
F
Forcing input ON/OFF without switch
Frequency counter function, setting item for
3-231
3-221
3-231
3-237
3-211
Preset function
3-215
3-360
Index
Title
Page
3-214
3-212
3-208
3-211
3-225
I
Input time constant of basic unit, changing
3-23
1-76
Direct Input/Output
3-197
Interrupt instruction
3-41
3-196
Input capture
3-195
3-195
Interrupt priority
3-196
K
KV IncrediWare (DOS)/LADDER BUILDER for KV, using
(5)
3-41
1-216
KV-P3E(01), operating
1-200
M
Memory card, capacity of
Storage capacity
1-230
To replace battery
1-238
3-234
3-26
1-66
O
Output, disabling output from KV
3-318
3-319
3-4
Program capacity
3-4
1-230
3-255
3-228
Relay list
3-5
3-6
3-8
1-96
S
Saving current value of counter/DM into ROM
Scan time
Scan time
3-3
1-67
3-186
3-86
3-228
T
Temporary data memory, functions assigned to
3-21
Timer/Counter list
3-18
Index
3-361
Index
P
Panel mounting of KV
B
Basic Instructions ................................ 3-34, 3-42, 3-56
Baud rate ......................................... 2-136, 1-247 [KV-L2]
Break signal .......................................................... 3-308
C
C: Counter .............................................................. 3-72
CALL: Subroutine Call ......................................... 3-122
CMP/@CMP: Compare ......................................... 3-146
COM/@COM: Complement .................................. 3-171
Commands [Serial communication] ................... 3-310
Communications ....................................... 2-135, 3-306
CON: Connect ....................................................... 3-102
Connector wiring ....................................................... 1-72
CTC: Counter Comparator .................................. 3-204
CTH1: 16-Bit Counters ......................................... 3-204
Index
D
Data Memory ........................................................... 3-19
D/A converter ........................... 1-312 [AN6], 1-334 [AD4]
D/A conversion table ................ 1-408 [AN6], 1-357 [DA4]
DEC/@DEC: Decrement Memory ........................ 3-172
DI: Interrupt Disabled ........................................... 3-193
DIFD: Differentiate Down ....................................... 3-78
DIFU: Differentiate Up ........................................... 3-78
Dimensions ............................................................. 1-404
DIN rail (mounting) .................................................. 1-180
Direct Clock Pulse ................................................ 3-276
Display Interface Mode [KV-L2] .............................. 1-244
DIV/@DIV: Divide .................................................. 3-150
DMX/@DMX: Demultiplexer ................................. 3-176
DW: Data Memory Write ...................................... 3-136
H
High-Speed Counters .......................................... 3-276
HKEY: 16 Key Input .............................................. 3-131
HSP: High Speed .................................................... 3-86
I
INC/@INC: Increment Memory ............................ 3-172
Indirect Addressing of Data Memory or Relay .. 3-127
Input Relays .............................................................. 3-9
Instruction List .............................................. 3-34, 3-42
INT: Interrupt ........................................................ 3-192
Interface [RS-232C] .............................................. 3-306
Internal register .................................................... 3-135
Internal Utility Relays ............................................. 3-11
Internal Clocks for CTH0 and CTH1 ................... 3-278
Interrupt Instructions ........................................... 3-268
I/O distribution ......................................................... 1-187
ITVL: Interval Timer .............................................. 3-117
J
JMP: Jump ............................................................ 3-106
K
KEEP: Keep ............................................................ 3-80
KV-10/16/24/40/80 ............................ 1-167, 1-175, 1-177
KV-300 ......................................................... 1-166, 1-170
KV-AD4 ................................................................... 1-334
KV-AN6 ................................................................... 1-312
KV-B16R/B16S/C32T .............................................. 1-172
KV-C16X/C32X ....................................................... 1-171
KV-DA4 ................................................................... 1-334
KV-L2 ...................................................................... 1-240
KV-R1A/R16X/R16R/R16T/R8X/R8R/R8T .. 1-173, 1-174
KV-U4/U5 ..................................................... 1-168, 1-169
KV mode [KV-L2] .................................................... 1-253
L
LD: Load .................................................................. 3-57
LDA/@LDA: Load A .............................................. 3-140
LDB: Load Bar ........................................................ 3-57
E
EI: Interrupt Enabled ............................................ 3-193
END: End ................................................................. 3-94
ENDH: End Hi ......................................................... 3-94
ENDS: End Stage ................................................. 3-106
Environment requirements ........................................ 1-64
EORA/@EORA: Exclusive Or A .......................... 3-164
Error code list .......................................................... 1-372
Extended Ladder Diagrams ................................... 3-29
3-362
Index
N
NEXT: Repeat End ................................................ 3-125
Non-procedure mode [KV-L2] ................................. 1-292
NOP: No Operation ................................................ 3-94
O
OR: Or ..................................................................... 3-60
ORA/@ORA: Or A ................................................. 3-161
ORB: Or Bar ............................................................ 3-60
ORL: Or Load .......................................................... 3-63
OUB: Out Bar .......................................................... 3-65
OUT: Out ................................................................. 3-65
Output Relays ......................................................... 3-10
P
Peripheral equipments ............................................ 1-176
Port1/Port2 [KV-L2] ................................................. 1-245
Positionning control ............................................ 3-296
Programming examples ...................................... 3-324
R
RASC/@RASC: Reverse ASCII Convert ............. 3-183
Receiving text data .............................................. 3-318
Relay/Memory/Memory Switch Lists ....................... 2-167
Relay/Memory Nos. ................................................. 2-167
Relay No. List .......................................................... 2-167
Relay Nos. and Functions ....................................... 2-167
RES: Reset .............................................................. 3-66
RET: Subroutine Return ...................................... 3-122
RETI: Return Interrupt ......................................... 3-192
RLA/@RLA: Rotate Left A ................................... 3-169
ROOT/@ROOT: Square Root .............................. 3-185
RRA/@RRA: Rotate Right .................................... 3-169
RS-232C cable connection .................................. 3-307
RS-232C Protocol ................................................. 3-306
RS-422A [KV-L2] ..................................................... 1-248
T
TBCD/@TBCD: Transfer BCD ............................. 3-180
TBIN/@TBIN: Transfer BIN .................................. 3-180
Temporary Memory ...................................... 2-172, 2-176
Timers and Counters ............................................... 2-169
TMH: 0.01-s Timer .................................................. 3-68
TMIN: Trimmer In .................................................. 3-138
@TMIN: Trimmer Setting ..................................... 3-138
TMR: 0.1-s Timer .................................................... 3-67
TMS: 1-ms Timer .................................................... 3-69
Transmitting text data .......................................... 3-319
Troubleshooting ...................................................... 1-372
U
UDC: Up-Down Counter ......................................... 3-76
W
W-DE: Wait Down Edge ......................................... 3-98
W-OFF: Wait OFF ................................................... 3-96
W-ON: Wait ON ....................................................... 3-96
W-UE: Wait Up Edge .............................................. 3-98
X
@xxxx: Differentiation ......................................... 3-137
Index
S
SBN: Subroutine Entry ........................................ 3-122
Serial Communication ......................................... 3-306
SET: Set .................................................................. 3-66
SFT: Shift ................................................................ 3-82
SLA/@SLA: Shift Left A ....................................... 3-166
Special Utility Relays ............................................... 2-174
SRA/@SRA: Shift Right A .................................... 3-166
STA/@STA: Store A ............................................. 3-140
Station No. [KV-L2] ................................................. 1-246
STE: Step End ...................................................... 3-114
STG: Stage ............................................................ 3-106
STP: Step .............................................................. 3-114
SUB/@SUB: Subtract ........................................... 3-150
System configuration ............................................... 1-166
Index
3-363
A
ACCS ...................................................................... 1-234
ALL CLEAR [FNC60] [P3E] ..................................... 1-217
ALL DATA MEMORY CLEAR
(DM ALL CLEAR): [FNC64] [P3E] ...................... 1-219
ALL LATCHING RELAYS RESET
(L-RELAY ALL RST): [FNC65] [P3E] ................... 1-219
B
Break signal .......................................................... 3-308
C
CLEAR [P3E] .......................................................... 1-232
Comments (Relay comment, Line comment) ............ 2-46
Compile ..................................................................... 2-75
Converting N.O./N.C. ................................................ 2-65
Copy, move and delete ............................................. 2-69
COUNTER CLEAR (CTR CLEAR): [FNC62] [P3E] 1-218
Customizing KV-LADDER ,
Defining Environment Strings ................................ 2-19
Copy, move and delete operation ............................. 2-52
D
Data Communications between KV
and Personal Computer .................................... 3-306
Display mode ........................................................... 2-19
Double coil check ...................................................... 2-76
E
Edit screen ................................................................ 2-27
Entering symbols ....................................................... 2-37
Environment requirements .......................................... 2-3
Error message list ................................................... 2-156
Index
H
HANDHELD PROGRAMMER CLEAR (P3E CLEAR):
[FNC61] .............................................................. 1-217
Handheld Programmer KV-P3E .............................. 1-196
HIGH-SPEED COUNTER CLEAR
(HIGH SPEED CTR CLR): [FNC63] [P3E] .......... 1-218
I
Installing Ladder Builder .............................................. 2-9
J
Jump ......................................................................... 2-58
L
Ladder Monitor ........................................................ 2-134
Ladder Simulator ....................................................... 2-84
Line comment ........................................................... 2-46
M
Macros ...................................................................... 2-72
Memory Card [P3E] ................................................. 1-230
Monitor Mode .......................................................... 2-134
Monitor screen ........................................................ 2-143
MOVE CURSOR [P3E] ........................................... 1-202
3-364
Index
O
OFFLINE EDITOR START (OFFLINE EDITOR):
[FNC67] [P3E] .................................................... 1-221
OFFLINE EDITOR STOP (QUIT OFF-L EDIT):
[FNC68] [P3E] .................................................... 1-221
ON/OFF MONITOR [P3E] ....................................... 1-215
P
Printer Setting, Defining Environment Strings .......... 2-77
Printing examples ...................................................... 2-81
PROGRAM CAPACITY CHECK (PROGRAM SIZE):
[FNC75] [P3E] .................................................... 1-229
PROGRAM SENT OR RECEIVED
(COMMUNICATION): [FNC66] [P3E] ............. 1-220
Q
Quitting software ....................................................... 2-16
R
READ TRIMMER SETTING (TRIMMER MONITOR):
[FNC73] [P3E] .................................................... 1-228
Registration of cursor position and
jump to registered position ................................... 2-59
RELAY ON/OFF (FORCED SET/RESET):
[FNC71] [P3E] .................................................... 1-226
Replacing relays ........................................................ 2-64
RS-232C cable connection ......................................... 2-7
RS-232C Protocol ....................................................... 2-3
S
SCAN TIME MONITOR [P3E] ................................. 1-212
SCROLL [P3E] ........................................................ 1-202
Search ....................................................................... 2-58
Searching Program [P3E] ....................................... 1-207
Selecting display mode ............................................. 2-19
Setting print range ..................................................... 2-77
Simulator Mode ......................................................... 2-84
Simulator screen ....................................................... 2-86
Starting and quitting software ................................... 2-16
Starting edit mode .................................................... 2-29
Starting the Monitor Function .................................. 2-139
Starting the Simulator ................................................ 2-86
SYNTAX CHECK (PROGRAM CHECK):
[FNC74] [P3E] .................................................... 1-228
T
Temporary Memory ................................................ 3-21
Time Chart Monitor ................................................. 2-157
Time Chart Viewer ....................................... 2-148, 2-167
TIMER/COUNTER SETTING CHANGE
(CHG: T/C SET-V): [FNC70] [P3E] .................... 1-224
TIMER/COUNTER CURRENT VALUE CHANGE
(CHG: T/C CURT-V): [FNC69] [P3E] ................. 1-222
W
WRITE INTO DATA MEMORY (DM WRITE):
[FNC72] [P3E] .................................................... 1-227
Index
Index
3-365
Index
3-366
Index
Index
Index
3-367
96M0366
INDEX
Installation
Support
Software
Programming
2. System Installation
3. Access Window
4. KV-D20 Operator
Interface Panel
1. Introduction
1. Programming
2. Editor
2. Instructions
3. Simulator
3. Interrupts
4. Monitor
4. High-speed Counters
5. Appendices
5. Positioning Control
6. Interrupts, High-speed
Counters, Positioning
Control
5. KV-10/80 Hardware
6. Handheld Programmer
7. Serial Communication
8. Programming
Examples
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima,
Higashi-Yodogawa-ku,
Osaka, 533-8555, Japan
PHONE: 81-6-6379-2211
FAX: 81-6-6379-2131
User's Manual
Visual KV Series 3 Programming
1. Configuration and
Specifications
Visual KV Series
Programming