Professional Documents
Culture Documents
96M0366
INDEX
1 2 3
Installation Support Programming
1. Configuration and Software 1. Programming
3
Specifications 1. Introduction 2. Instructions
User’s Manual
Programming
2. System Installation
2. Editor 3. Interrupts
3. Access Window
3. Simulator 4. High-speed Counters
4. KV-D20 Operator
Interface Panel 4. Monitor 5. Positioning Control Visual KV Series
5. Appendices 6. Interrupts, High-speed
5. KV-10/80 Hardware
Counters, Positioning
6. Handheld Program-
mer
Control 3
7. Serial Communication
Programming
User’s Manual
7. KV-L2 Serial Interface
8. Programming
Module
Examples
8. KV-AN6 Analog I/O
Module
9. KV-AD4/DA4 Analog
I/O Unit
10. Troubleshooting
11. Appendices
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima, Higashi-Yodogawa-ku, Osaka, 533-8555, Japan PHONE: +81-6-6379-2211
• When the KV Series PLC is used in combination with other instruments, func-
tions 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) 3-367
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 in conditions or environments not described in this manual
• Use for nuclear power control, railway facilities, air service facilities, vehicles,
combustion devices, medical equipment, amusement machines, safety equip-
ment, etc.
• Use for applications where large effects are predicted to be given on human lives
and properties and safety is especially requested.
Note: The contents above do not by themselves ensure that the entire machine
manufactured in accordance with the above contents is compatible with EMC
directives.
You must judge by yourself whether or not the entire machine is compatible with
EMC directives because compatibility may change depending on the component
configuration, wiring and location inside of the machine.
96M0366
(2)
● Extremely fast
The minimum scan time is 140 µs and minimum instruction execution time is 0.7
µs, which is the fastest control in its class.
(3)
• The internal clock cycle of high-speed counters consists of three types: 1 µs, 10
µs, and 100 µs.
• 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 RUN/PROGRAM LED is displayed in the Access Window provided on the
front face of the basic unit.
• Transistor output is not independent, but is common.
• With the transistor type, the output terminal layout is different.
• 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.
• Assignment of special utility relays has partially changed.
• Data memory device Nos. DM1000 to DM1999 are assigned as special data
memories.
(4)
When the ladder support software "LADDER BUILDER for KV Ver. 1.0x" is
CAUTION used, do not use the monitor’s 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.
• Expansion I/O units for the conventional KV Series: KV-8ER/8ET/8EX/16EX/
8EYR/8EYT/16EYR/16EYT
• Analog I/O units for the conventional KV Series: KV-AD4/DA4
(5)
1 Installation
Chapter 1 Configuration and Specifications [Visual KV Series Only]
Describes the system configuration of the Visual KV Series, the names and functions of
each part, and the specifications.
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 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 com-
pletely 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 6 Interrupts, High-speed Counters, Positioning Control [KV-300, KV-10/80 Series Only]
Describes ramp-up/down control of stepping motors and servo motors.
(8)
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 Extended Ladder Diagrams .......................................................................... 3-29
1.5.1 Features of Extended Ladder Diagrams ........................................................... 3-29
1.5.2 Advantages of Extended Ladder Diagrams ...................................................... 3-30
1.5.3 Example of an Extended Ladder Diagram ........................................................ 3-31
(9)
(10)
(11)
1 Installation
Chapter 1 Configuration and Specifications 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 KV-40AR/AT(P)/DR/DT(P) (40-I/O Basic Unit) .............................................. 1-31
(12)
(13)
(14)
(15)
(16)
(17)
(18)
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. Ladder Program List ...................................................................... 1-406
Appendix D. A/D and D/A Conversion Tables [KV-AN6] ..................................... 1-408
Voltage conversion table .......................................................................... 1-408
Current conversion table .......................................................................... 1-409
WARRANTIES AND DISCLAIMERS 1-419
2 Support software
Chapter 1 Introduction
1.1 Items Included in the Package ........................................................................ 2-2
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 Before Programming ....................................................................................... 2-7
Machines to be prepared ............................................................................. 2-7
1.3.1 Differences from the KV IncrediWare (DOS) ...................................................... 2-8
1.3.2 Differences from the Ladder Builder for KV Ver 1.0 ........................................... 2-8
1.4 Installing the Software ..................................................................................... 2-9
(19)
(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
3.3 Ladder Monitor ............................................................................................... 2-89
3.3.1 Outline of the ladder monitor ............................................................................ 2-89
3.3.2 Executing scans ................................................................................................ 2-89
3.3.3 Executing steps .............................................................................................. 2-101
3.3.4 Jump and search ............................................................................................ 2-105
3.3.5 Stop/reset and device all clear ........................................................................ 2-108
3.4 Monitor All .................................................................................................... 2-109
3.4.1 Outline of monitor all ....................................................................................... 2-109
3.4.2 Displaying, saving, and reading the monitor all window ................................. 2-109
3.4.3 Monitor all window .......................................................................................... 2-113
3.4.4 Registering devices ........................................................................................ 2-113
3.4.5 Selecting and changing devices ..................................................................... 2-116
3.5 Registration Monitor .................................................................................... 2-119
3.5.1 Outline of the registration monitor ................................................................... 2-119
3.5.2 Displaying, saving, and reading the registration monitor ................................ 2-119
3.5.3 Registration monitor window ........................................................................... 2-122
3.5.4 Registering devices ........................................................................................ 2-122
3.5.5 Selecting and changing devices ..................................................................... 2-123
3.5.6 Manipulating timing charts .............................................................................. 2-128
3.5.7 Printing out the registration monitor ................................................................ 2-131
Chapter 4 Monitor
4.1 Outline of the Monitor Functions ............................................................... 2-134
4.1.1 Outline of the functions ................................................................................... 2-134
4.1.2 Restrictions in the monitor .............................................................................. 2-134
4.1.3 Precautions for communication ...................................................................... 2-135
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 Ladder Monitor ............................................................................................. 2-144
4.4.1 Outline of the ladder monitor .......................................................................... 2-144
4.4.2 Displaying the ladder monitor window ............................................................ 2-144
4.4.3 PLC error check .............................................................................................. 2-144
4.4.4 Starting the monitor ........................................................................................ 2-145
4.4.5 Stopping the monitor ....................................................................................... 2-145
4.4.6 Screen displayed while the monitor is running ............................................... 2-146
4.4.7 Setting the PLC operation mode ..................................................................... 2-147
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 Monitor Function .......................................................................................... 2-149
4.6.1 Disabling the input refresh/Disabling the output ............................................. 2-149
4.6.2 Changing the current values all at once ......................................................... 2-150
4.6.3 Device all clear ............................................................................................... 2-154
(21)
(22)
Caution
• No part of this manual may be reprinted or reproduced in any form or by any
means without the prior written permission of KEYENCE CORPORATION.
• The content of this manual is subject to change without notice.
• 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 infor-
mation in this manual, item 3 above notwithstanding.
• KEYENCE will replace any incomplete or incorrectly collated manual.
All company names and product names in this manual are registered trademarks or
trademarks of their respective owners.
(23)
➞
Examining contents of operations
Figure 1 shows a latch circuit which operates as follows. Fig. 1
PB1 = N.O. contact switch
Pushbutton switch PB1: ON
➞Pilot lamp (PL) turns on. PB2 = N.C. contact switch
Pushbutton switch PB2: OFF
▲ PB1 PB2
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.
Circuit 1 Table 1
I/O device Contact No.
RL
PB1 PB2 Pushbutton switch PB1 (N.O. contact) Input relay (0000)
RL Relay (coil)
Relay (contact) Pushbutton switch PB2 (N.C. contact) Input relay (0001)
RL
Relay (contact)
PL
Relay RL Internal relay (1000)
Pilot lamp
Pilot lamp PL Output coil (0500)
➞
Program creation
Edit a program using the "LADDER BUILDER for KV" programming support software creation tool.
Operation
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.
1 2 3
Input signal
ON
OFF
Read Read
Output processing
Output processing
Output processing
Output processing
Output processing
Input processing
Input processing
Input processing
Input processing
Input processing
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).
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.
Note 1: The ON/OFF status of the set functions is always cleared when the opera-
tion 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
■ Output units
Connection
KV-E4T(P)/R KV-E8T(P)/R KV-E16T(P)/R
order
1st output
600 to 603 600 to 607 600 to 615
module
2nd output
700 to 703 700 to 707 700 to 715
module
3rd output
800 to 803 800 to 807 800 to 815
1 module
4th output
900 to 903 900 to 907 900 to 915
module
■ I/O units
KV-E4XR/T(P)
Connection
Input relays Output relays
order
KV-10/16/24 KV-40 KV-10/16/24 KV-40
1st input
100 to 103 200 to 203
module
2nd input
200 to 203 300 to 303
module
3rd input
300 to 303 400 to 403
module
4th input
400 to 403
module
1st output
600 to 603 600 to 603
module
2nd output
700 to 703 700 to 703
module
3rd output
800 to 803 800 to 803
module
4th output
900 to 903 900 to 903
module
* 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.
Channel No.
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.
Contact No.
• Contact Nos. are input/output terminal Nos. of basic units, input expansion units,
output expansion units, and I/O expansion units.
• The contact No. is represented as a number 0 to 15.
Example
In the KV-E4X, with 4 input terminals, the contact Nos. are 0 to 3. In the KV-
E16T(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.
With the connections above, the relay Nos. for each unit are assigned as shown in
the table below.
Unit Assigned relay Nos.
a) KV-16AR 0000 to 0009 (input) and 0500 to 0505 (output)
b) KV-E4X 0100 to 0103 (input)
c) KV-E8R 0600 to 0607 (output)
Note 1: Input relays function as contacts in programs. They cannot be used as relay
coils (outputs).
Note 2: There is no restriction of the contact type (N.O. or N.C.) used, the order the
relay Nos. are used, or the number of relays used.
Basic unit
■ Input relay time constant
Though the time constant is usually 10 ms ±20%, it can be changed using the
following settings.
• When the HSP instruction is used: 10 µs ±20%
• 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: 10µs ±20%
1: 20 µs ±20%
2: 500 µs ±20%
3: 1 ms ±20%
4: 2.5 ms ±20% 11
5: 5 ms ±20%
6: 10 ms ±20%
Never set a numeric value of 7 or larger.
➮ 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 PRO-
GRAM 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.
Expansion unit
■ Input relay time constant
By setting special utility relays 2609 to 2612 to ON, the time constant in input expan-
sion units can be set to 10 µs.
Special utility
Function
relay No.
Input time constant of input expansion unit
2609* OFF: 10 ms, ON: 10 µs
with relay Nos. 0100 to 0115
Input time constant of input expansion unit
2610 OFF: 10 ms, ON: 10 µs
with relay Nos. 0200 to 0215
Input time constant of input expansion unit
2611 OFF: 10 ms, ON: 10 µs
with relay Nos. 0300 to 0315
Input time constant of input expansion unit
2612 OFF: 10 ms, ON: 10 µs
with relay Nos. 0400 to 0415
* Not available with the KV-40xx
• Relay output
OFF ➞ ON: 10 ms or less
ON ➞ OFF: 10 ms or less
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)
Note 1: Internal utility relays function as contacts and relay coils in programs.
Note 2: There is no restriction of the contact type (N.O. or N.C.) used, the order the
relay Nos. are used, or the number of relays used.
When an internal utility relay is set to be retained, its ON/OFF status is stored even if
the power is turned off. By using the retained relay all clear function (FUN65), all
relays which are set to be retained can be set to OFF. 11
➮ For more about setting the memory switch, refer to "MEMSW instruction" (p.3-92).
MEMSW
$0004
1001 #00010
Lower limit T001
switch
(0001) T000 0501 0500
Move-down
(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
Note 1: A special utility relay can be used as many times as desired in one program.
Note 2: Special utility relays dedicated for reading can be used as contacts, but
cannot be used as outputs.
➮ For more about relays dedicated for reading, refer to "1.3.8 Special Utility Relay List" (p.3-14).
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
1000 #03600
C000
2006
C000 1000
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.
Relay 2008: Remains ON during only one scan when operation is started.
This relay can be used for an initial reset at the start of operation.
After one scan, this relay remains OFF.
0000 SFT
D
1100
1000
CLK
1100
2008
RES
2008 #00000
LDA
DM0000
STA
Note: Never use special utility relays that are not shown above.
Note: Never use special utility relays that are not shown above.
1 2414 CTH1 set as ring counter ON: Set OFF: Not set
Ignore phase B input when CTH1 is set to no multiplication mode.
2415 ON: Ignore phase B input and always count up.
OFF: Use phase B as usual.
Note: Never use special utility relays that are not shown above.
Timer/Counter list
Coil
Name Contact Number
(instruction)
Timer (0.1-s timer) TMR000 to 249
High-speed timer
TMH000 to 249
Timer (0.01-s timer) T000 to T249
High-speed 1-ms timer 250 in total
TMS000 to 249
(0.001-s timer)
Counter C000 to 249
Counter C000 to C249
Up/down counter UDC000 to 249
Description
1 ■ 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).
• In a single program, different timer Nos. must be assigned to each of TMRnnn,
TMHnnn, and TMSnnn.
• 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.3-
72), "UDC instruction" (p.3-76).
DM No. Description
DM0 to DM999 Not specified (can be used by user)
DM1000 to DM1099 Text receive port A
DM1100 to DM1199 Text send port A
DM1200 to DM1299 Text receive port B
DM1300 to DM1399 Text send port B
DM1400 Cam switch function: The first output relay No.
Cam switch function: Comparison value in multi-step comparator
DM1401
mode
Cam switch function: Pulse count of one cycle of equipment input
DM1402
to CTH0
DM1403 Not specified (can be used by user)
DM1404 Measurement cycle (ms)
DM1405 Result of frequency count (Hz) 11
Cam switch function: Set value of angle at which output relay
DM1406/DM1407
turns ON/OFF
Cam switch function: Set value of angle at which output relay +1
DM1408/DM1409 turns ON/OFF
: :
DM1468/DM1469 Cam switch function: Set value of angle at which output relay +31
turns ON/OFF
DM1470 Reserved by system (cannot be used by user)
DM1471 to DM1479 Not specified (can be used by user)
Ramp-up/down control function: Startup frequency (Hz) (200 to
DM1480
50,000)
Ramp-up/down control function: Operating frequency (Hz) (200 to
DM1481
50,000)
Ramp-up/down control function: Acceleration time (ms)
DM1482
(0 to 4,000)
DM1483 Not specified (can be used by user)
Ramp-up/down control function: Output pulse count (lower digit)
DM1484
(0 to 65,535)
Ramp-up/down control function: Output pulse count (upper digit)
DM1485
(0 to 65,535)
DM1486 Ramp-up/down control function: Error code (11 to 17)
DM1487 to DM1499 Not specified (can be used by user)
DM1565 to DM1569 Not specified (can be used by user)
DM1578 and DM1579 Not specified (can be used by user)
DM1580 to DM1599 KV-D20 Operator interface panel: Display device No.
DM1664 to DM1699 Not specified (can be used by user)
DM1670 to DM1675 Reserved by system (cannot be used by user)
KV-D20 Operator interface panel: Screen shift permission setting
DM1676
in operator mode
DM No. Description
Area for direct access mode for the KV-D20 operator interface
DM1677 to DM1679
panel
DM1680 to DM1699 KV-D20 Operator interface panel: Display device attributes
DM1764 to DM1799 Not specified (can be used by user)
DM1806 to DM1809 Not specified (can be used by user)
DM1826 to DM1899 Not specified (can be used by user)
DM1900/DM1901* 24-bit value read from CTH0 (lower digit/upper digit)
DM1902/DM1903* 24-bit value read from CTH1 (lower digit/upper digit)
DM1904/DM1905* 24-bit value read from CTC0 (lower digit/upper digit)
DM1906/DM1907* 24-bit value read from CTC1 (lower digit/upper digit)
DM1908/DM1909* 24-bit value read from CTC2 (lower digit/upper digit)
DM1910/DM1911* 24-bit value read from CTC3 (lower digit/upper digit)
DM1912/DM1913 24-bit current value written to CTH0 (lower digit/upper digit)
DM1914/DM1915 24-bit current value written to CTH1 (lower digit/upper digit)
DM1916/DM1917 24-bit current value written to CTC0 (lower digit/upper digit)
DM1918/DM1919 24-bit current value written to CTC1 (lower digit/upper digit)
DM1920/DM1921 24-bit current value written to CTC2 (lower digit/upper digit)
DM1922/DM1923 24-bit current value written to CTC3 (lower digit/upper digit)
DM1924/DM1925 CTH0 preset input (lower digit/upper digit)
1 DM1926/DM1927 CTH1 preset input (lower digit/upper digit)
DM1928/DM1929* Input capture when INT0 is generated (lower digit/upper digit)
DM1930/DM1931* Input capture when INT1 is generated (lower digit/upper digit)
DM1932/DM1933* Input capture when INT2 is generated (lower digit/upper digit)
DM1934/DM1935* Input capture when INT3 is generated (lower digit/upper digit)
DM1936 Specified frequency pulse output function: Set frequency (Hz)
DM1937 I/O expansion unit connection information
DM1938 Digital trimmer No. 0: Upper limit value
DM1939 Digital trimmer No. 1: Upper limit value
Input time constant setting
0: 10 µs 1: 20 µs 2: 500 µs
DM1940
3: 1 ms 4: 2.5 ms 5: 5 ms 6: 10 ms
Any other value cannot be set.
DM1941 to DM1943 Reserved by system (cannot be used by user)
Number of instructions converted into 1 scan when division
DM1944
conversion is performed
DM1945 to DM1949 Not specified (can be used by user)
DM1950 Access window error display (0 to 255)
DM1951 to DM1999 Not specified (can be used by user)
* 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.
* 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.
11
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.
0 7 5 1 5
Channel No. Relay No. (00 to 15)
■ 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.
■ 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.
* The KV-R1A I/O Distribution Unit accommodates 5 input units and 5 output units.
Addresses are set with address switches.
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.
11
■ 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 Input time constant
0 10 µs
1 20 µs
2 500 µs
3 1 ms
4 2.5 ms
5 5 ms
6 10 ms
7 or more Not allowed
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.
1.4.2 Modifying the Input Relay Time Constant KV-300 PLC Only
KV-C32X/C16X KV-R16X/R8X
2
24V 5V 0 ms 10 ms
1
0
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.
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.
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.
Though the scan time changes usually depending on the processing contents, it can
be kept at a constant value by using this function. This function can be used to
acquire data from external equipment at a constant time interval.
The set value should be longer than the maximum scan time because the scan time
is kept at a constant value until the end of processing.
■ Setting procedure
Set the desired scan time to temporary data memory TM29.
Set special utility relay 2303 to ON.
The scan time is written to TM31.
The scan time can be set in 1-ms increments.
Enter the desired scan time (ms) to the temporary data memory.
■ Setting example
In this example, the scan time is kept at 20 ms.
11
2008 #00020 TM29 2303
LDA STA 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.
■ Setting procedure
When special utility relay 2300 turns ON, all outputs from all output relays (0500 to
0915) to the outside are cleared after 1 scan is finished.
However, the display in the Access Window and the output indicator lamps are not
cleared.
■ Setting example
By setting/resetting special utility relay 2300 using the Access Window, the "KV
IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,
or the KV-P3E(01) handheld programmer, the external output prohibition function
can be used.
External outputs are prohibited while input 0000 is ON. External outputs are permit-
ted, though, while input 0000 is OFF.
0000 2300
1
➮ For more about operating procedures, refer to the "Chapter 6. Handheld Programmer" (p.1-195).
■ Setting procedure
When special utility relay 2301 turns ON, input refresh (read of input relays) for all
input relays (0000 to 0415 used by the QL Series) is skipped.
In this status, inputs can be set to ON/OFF from the Access Window, the "KV
IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,
or the KV-P3E(01) handheld programmer.
■ Setting example
By setting/resetting special utility relay 2301 using the Access Window, the "KV
IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,
or the KV-P3E(01) handheld programmer, the external input refresh prohibition
function can be used.
External input refresh is prohibited while input 0000 is ON. External input refresh is
permitted, though, while input 0000 is OFF.
0000 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 KV-
P3E(01) handheld programmer.
➮ 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).
■ Setting
Write the desired scan time into TM29 (temporary data memory), then turn on
special utility relay No. 2303. The scan time can also be written into TM31. Specify a
scan time in increments of 10 ms (a value of less than 10 ms is invalid).
Here, write a value into TM equivalent to 10 times the scan time.
Example
Set the constant scan time to 20 ms.
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
1 during the next scan.
■ Setting
Turn on special utility relay No. 2300. After one scan is completed, all output relays
(00500 to 00503, 07500 to 17915) are cleared.
Example
Use the output disabled function by executing FORCED RESET/RESET to special
utility relay No. 2300 from the monitor display.
➮ To execute FORCED RESET or RESET, refer to "Chapter 6 Handheld Programmer" (p.1-195).
■ Setting
Turn ON special utility relay No. 2301 to skip input refresh (reading from input
relays). Input relays can then be turned ON/OFF with the KV-P3E(01) or with KV
IncrediWare (DOS) on 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.
Only input circuits Only output Only input Both input Only output
can be written. circuits can circuits can circuits and circuits can
be written. be output circuits be
assembled. can be
assembled.
assembled. 11
Branches can be made only from input Branches can also be made from output
contacts. coils.
2002 #02000
CMP In a conventional ladder diagram, operations
2010 0501
performed by the program cannot be easily
understood. In an extended ladder diagram,
2002 #03000
operations performed by the program can be
CMP understood at a glance.
2010 0502
1
Processing sequence is clear.
Ladder symbols can be laid out in processing sequence, so the program flow is
easier to understand. In addition, maintainability is considerably improved.
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 1100 1000 When the start switch (0000) is set to ON, a lamp (0500) is lit and
DIFU SET timer 0 is activated.
1000 0500 #00030 T000 1001 When timer 0 turns ON three seconds later, the lamp goes out, a
STG T000 JMP
buzzer (0501) is sounded, and timer 1 is activated.
1001 0501 #00020 T001 1002
STG T001 JMP When timer 1 turns ON two seconds later, the buzzer is stopped
and the motor (0502) starts to rotate.
1002 0502 0000
STG ENDS When the start switch (0000) is set to OFF, the motor is stopped
and all operations are reset.
1003
1002 0501
1003
Note: When an extended ladder diagram is used, the number of lines in ladder
diagram may be reduced. However, this may not necessarily reduce the number of
mnemonics in the program.
0501
LD 0000 LD 0000
OUT 0500 OUT 0500
OUT 0501 CON
OUT 0501
The CON instruction for connection is added.
(The scan time is not affected.)
1001 0500
When 1001 turns ON, output 0500
turns ON.
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.
Instruction Exec.time
Symbol Mnemonic Operand Operand value Function Bytes Page
(µs)
nnnn
LOAD LD Connects N.O. contact to bus. 0.7 to 1.6 3 (12) 3-57
nnnn
LOAD BAR LDB Connects N.C. contact to bus. 0.7 to 1.6 3 (12) 3-57
0500 to 1915
2009
nnnn
SET SET SET 2300 to 17915 Forces relay ON and holds 1.9 to 12.8 3 (14) 3-66
T000 to T249 this status when input is ON.
C000 to C249
R No.
T/C No. 0500 to 1915
2009
nnnn 2100 to 17915
Forces R/T/C OFF when input 1.9 to 20.5 3 (14) 3-66
RESET RES RES T000 to T249
is ON.
C000 to C249
CTH0 to CTH1
CTC0 to CTC3
Exec.time
Instruction Symbol Mnemonic Operand Operand value Function Bytes Page
(µs)
T No., 16-bit on-delay T that
1-ms #ddddd TMS 000 to 249
12.0 to 17.8 2 (7) 3-69
TIMER
T
S Txxx (FUN51) # preset value #0000 to #65535 counts down in 1-ms
decrements.
#00000 to
#ddddd
# preset value, #65535
COUNTER Cxxx C C No., counter 000 to 249 Sets 16-bit up-counter. 12.0 to 17.8 4 (7) 3-72
nnnn
input R 0000 to 17915
(KV-10)
0000 to 0005
(KV-16) Reduces input relay time
HIGH HSP
HSP 0000 to 0009
SPEED nnnn
(FUN18)
R No.
(KV-24)
constant to 10 µs for
higher input response.
3.8 to 9.4 3 (8) 3-86
12
0000 to 0015
(KV-40)
0000 to 0107
NOP
NOP (FUN30) Performs no operation. –– 1 (0) 3-94
• 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 num-
bers in X-Y-M notation are shown below:
nnnn
R (output operand [mmmm])
WAIT ON ON W-ON 17915 when R, T, or C (input operand 10.4 to 12.6 5 (12) 3-96
mmmm [nnnn]) is ON.
nnnn: T000 to T249
R, T, CC000 to C249 Turns ON R (output operand
nnnn
WAIT OFF OFF W-OFF Nos. CTC0 to CTC3 [mmmm]) when R, T, or C (input 13.6 to 18.5 5 (12) 3-96
mmmm mmmm: operand [nnnn]) is OFF.
nnnn mmmm: 1000 to 1915 Turns ON R (output operand
WAIT UP 3000 to 9915 [mmmm]) at rising edge of R, T, 13.6 to 18.5 3-98
W-UE R No. 5 (12)
EDGE mmmm 1000 to 1915 or C (input operand [nnnn]).
R No.
WAIT nnnn Turns ON R (output operand
DOWN W-DE [mmmm]) at falling edge of R, T, 6.8 to 5.3 1 (0) 3-98
mmmm
EDGE or C (input operand [nnnn]).
CON Represents series connection
CONNECT (FUN 06) of output instruction together 1 (4) 3-102
with another instruction.
• 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:
Exec.time
Instruction Symbol Mnemonic Operand Operand value Function Bytes Page
(µs)
ITVL
DMnnnn:
PLS DMnnnn: DM0000 to Measures pulse-to-pulse
DMnnnn DM No. DM1985
INTERVAL ITVL interval & pulse width in 20.0 to 80.0 5 (10)
PAUSE 3-117
TIMER mmmm mmmm: R mmmm: specified mode.
RES No. 1000 to 1912
3000 to 9912
0004 16-bit (0 to 65535) up-
16-BIT CTH0 Count input 2100 down counter for clock
nnnn CTH 14.4 4 (6) 3-204
COUNTER R 2101 pulses with input response
2102 frequency of 30 kHz.
n: Hardware-based comparator
16-BIT Comparator between preset & current
No. n: 0,1
COUNTER #ddddd values of high-speed counter
CTCn CTC ddddd: #00001 2.3 to 3.5 2 (6) 3-204
COMPARA- ddddd: (CTH0). This comparator is
to #65535
TOR # preset turned ON when these
value values are equal.
n: Hardware-based comparator
16-BIT Comparator between preset & current
No. n: 2,3
COUNTER #ddddd values of high-speed counter 2.3 to 3.5 2 (6) 3-204
CTCn CTC ddddd: ddddd: #00001
COMPARA- (CTH1). This comparator is
# preset to #65535
TOR turned ON when these
value values are equal.
SUBROUTINE nn Subroutine Executes subroutine
CALL CALL
CALL
(FUN 03) No. 00 to 99 specified by operand.
5.4 to 6.5 2 (8) 3-122 12
Represents beginning of
SUBROUTINE SBN SBN Subroutine
nn 00 to 99 subroutine specified by 2 (4) 3-122
ENTRY (FUN 38) No. operand.
SUBROUTINE RET RET Represents end of
4.3 1 (4) 3-122
RETURN (FUN 33) subroutine.
#00000 to
# constant, Executes program
FOR #65535
REPEAT FOR between FOR & NEXT 12.0 to
nnnn DM No. DM0000 to 3 (20) 3-125
START (FUN 16) for number of times 18.0
TMxx DM1999 specified by operand.
TM00 to TM29
NEXT
NEXT Represents end of
REPEAT END 0.5 1 (4) 3-125
repetition.
(FUN 29)
• 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:
n TMIN
TMIN Inputs value set by 8.9 1 (6)
(FUN 50) access window’s digital
TRIMMER Trimmer No. 0 to 1 trimmer (0 to 65535) to 3-138
SETTING
n @TMIN internal register.
TMIN 20.9 1 (16)
@(FUN 50)
0000 to 17915
T000 to T249
nnnn LDA C000 to C249
LDA CTH0 to CTH1 6.4 to 14.0 3 (8)
(FUN 23) R No.,
C/T No., DM0000 to Inputs value specified by
DM No, DM1999 operand into internal
LOAD A TM00 to TM31 3-140
TM xx, register or inputs current
#00000 to value when T/C is
#/$ constant, #65535
nnnn @LDA #TMxx specified as operand.
LDA $0000 to $FFFF 18.4 to 26.0 3 (18)
@(FUN 23) #TM00 to
#TM29
2 0500 to 1915
STA 2100 to 17915
nnnn
STA (FUN 42) T000 to T249 Transfers content of 6.6 to 28.5 3 (8)
R No., C000 to C249 internal register to
C/T No., CTH0 to location specified by
STORE A DM No., CTC3 operand, or changes 3-140
TM xx, DM0000 to preset value when T/C is
nnnn @STA #TMxx DM1999 specified as operand.
STA TM00 to TM29 18.0 to 40.5 3 (18)
@(FUN 42)
#TM00 to
#TM29
nnnn CMP
CMP (FUN 04) Compares content of 10.8 to 35.6 3 (6)
internal register and
COMPARE 3-146
value specified by
nnnn @CMP operand. 22.8 to 47.6 3 (16)
CMP
@(FUN 04)
• Number of bytes represents the memory capacity required for each instruction.
• Number in ( ) represents the memory capacity required for object code of each
instruction.
Exec.time
Instruction Symbol Mnemonic Operand Operand value Function Bytes Page
(µs)
DM0000 to
nnnn DIV DM1999
DIV 17.4 to 43.3 3 (6)
(FUN 11) R No., TM00 to TM31 Divides content of internal
DM No., #00000 to register by value specified
DIVIDE TM xx, #65535 3-150
by operand and inputs
#/$ constant, $0000 to result back to same
nnnn @DIV #TMxx $FFFF 3 (16)
DIV register. 29.4 to 55.3
@(FUN 11) #TM00 to
#TM29
nnnn ANDA ANDs each of 16 bits of
ANDA 0000 to 17915 8.2 to 33.1 3 (8)
(FUN 01) internal register and that
AND A DM0000 to of value specified by 3-159
nnnn @ANDA R No., DM1999 operand, and inputs result
ANDA TM00 to TM31 back to same register. 20.2 to 45.1 3 (18)
@(FUN 01) DM No.,
TM xx, #00000 to
#/$ constant, #65535
nnnn ORA ORs each of 16 bits of
ORA #TMxx $0000 to 8.2 to 33.1 3 (8)
(FNC 31) internal register and that
$FFFF
OR A of value specified by 3-161
#TM00 to
nnnn @ORA operand, and inputs result 20.2 to 45.1
ORA #TM29 3 (18)
@(FUN 31) back to same register.
0000 to 17915
nnnn EORA
EORA DM0000 to 8.2 to 33.1 3 (8)
(FUN 15) DM1999 EXCLUSIVE-ORs each of
R No.,
TM00 to TM31 16 bits of internal register
DM No.,
EXCLUSIVE #00000 to and that of value specified
TM xx, 3-164
OR A #65535 by operand, and inputs
#/$ constant,
$0000 to result back to same
nnnn
@EORA #TMxx
$FFFF register.
EORA
@(FUN 15) #TM00 to
20.2 to 45.1 3 (18) 12
#TM29
#dd SRA
SRA Moves content of internal 9.3 to 27.6 2 (6)
(FNC 41)
SHIFT register serially right by
value specified by 3-166
RIGHT A #dd @SRA
SRA operand. 21.3 to 39.6 2 (16)
@(FUN 41)
#dd SLA
SLA Moves content of internal 9.2 to 27.6 2 (6)
(FNC 40)
SHIFT LEFT register serially left by 3-166
A value specified by
#dd @SLA operand.
SLA 21.2 to 39.6 2 (16)
@(FUN 40)
# constant #01 to #16
#dd RRA 10.3 to 28.6 2 (6)
RRA Rotates contents of
(FUN 37)
ROTATE internal register and carry 3-169
RIGHT A bit (2009) clockwise by
#dd @RRA operand value.
RRA @(FUN 37) 22.3 to 40.6 2 (16)
#dd RLA
RLA (FUN 35) Rotates contents of 10.3 to 28.6 2 (6)
ROTATE internal register and carry 3-169
LEFT A @RLA bit (2009) counterclock-
#dd
RLA wise by operand value. 22.3 to 40.6 2 (16)
@(FUN 35)
• 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 num-
bers in X-Y-M notation are shown below:
Operand Exec.time
Instruction Symbol Mnemonic Operand Function Bytes Page
value (µs)
COM
COM 5.6 1 (4)
(FUN 05)
COMPLE- Inverts content of each bit
3-171
MENT in internal register.
@COM
COM 17.6 1 (14)
@(FUN 05)
nnnn INC
INC
Adds 1 to content of data 9.8 3 (6)
(FNC 19) DM0000 to
INCREMENT DM1999 memory specified by 3-172
DM/TM No.
MEMORY TM00 to operand.
nnnn @INC 21.8 3 (16)
INC TM29
@(FUN 19)
nnnn DEC
DEC (FNC 07) 10.4 3 (6)
DECRE- DM0000 to Subtracts 1 from content
MENT DM/TM No. DM1999 of data memory specified 3-172
MEMORY nnnn @DEC TM00 to by operand.
DEC @(FUN 07) TM29 22.4 3 (16)
#n MPX
MPX Converts 4-bit data 10.1 1 (6)
(FUN 27)
MULTI- # constant #0 to #3 (specified by operand) of 3-176
PLEXER @MPX internal register into 16-bit
#n data. 22.1 1 (16)
MPX @(FUN 27)
DMX
DMX Converts position of 22.6 1 (4)
(FUN 12)
DEMULTI- highest order bit with 1 in
internal register into 4-bit 3-176
PLEXER
DMX
@DMX data. 34.6
@(FUN 12) 1 (14)
TBIN 9.6
TBIN (FUN 48) Converts content of 1 (4)
TRANSFER internal register (4-digit
BCD) into 16-bit binary 3-180
BIN @TBIN
TBIN
data. 21.6 1 (14)
@(FUN 48)
ASC 9.7
ASC (FUN 02) Converts content of lower 1 (4)
ASCII order 8 bytes of internal
CONVERT 3-183
register into 2-digit ASCII
@ASC 21.7 1 (14)
ASC code.
@(FUN 02)
• 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:
Executes interrupt
INT
instructions between INT
60.0 to 1 (8)
nnnn R No. 000 to 003 and RETI at rising/falling 3-192
90.0
edge of input relays 0000
through 0003.
INTERRUPT INT
(FUN 20)
Used with comparators
INT Comparator CTC0 to CTC0 to CTC3 and 60.0 to
CTCn 1 (8) 3-192
No. CTC3 executes instructions 90.0
between INT and RETI.
• 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: 12
Normal notation X-Y-M notation
0000 to 0415 X000 to X04F
0500 to 0915 Y050 to Y09F
1000 to 6915 M1000 to M6915
7000 to 17915 X700 to X174F or Y750 to Y179F
Function No. Instruction Function No. Instruction Function No. Instruction Function No. Instruction
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
• 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
Instruction Symbol Mnemonic Operand Operand value Operand value Exec.time Function Page
Bytes
KV-10/16 KV-24/40/80 (µs)
nnnn Turns ON R for 1
DIFFEREN- DIFU
DIFU 11.0 to 13.0 3 (5) scan time at rising 3-78
TIATE UP (FNC10) edge of input.
R No. 1000 to 1915 1000 to 1915
DIFFEREN- nnnn
3000 to 6915 Turns ON R for 1
TIATE DIFD 11.0 to 13.0 3 (5)
DIFD scan time at falling 3-78
DOWN (FNC09)
edge of input.
KEEP 0500 to 1915 0500 to 1915 Turns ON R and
SET KEEP R No. 2009 9.0 to 26.0 3 (5) holds this status when
KEEP nnnn 2009 3-80
RES (FNC22) 2100 to 6915
2100 to 2915 SET input is ON.
SFT R No.1st 1000 to
D SFT & last R (*) 5 (7) Turns OFF R when 3-82
SHIFT CLK
nnnn
1000 to 1915 19153000 to
RES mmmm (FNC39) Nos. RESET input is ON.
6915
(KV-10) (KV-24)
HIGH HSP HSP 0000 to 0005 0000 to 0015
nnnn R No. 8.0 to 9.0 3 (4) Sets shift register. 3-86
SPEED (FNC18) (KV-16) (KV-40)
0000 to 0009 0000 to 0107
Reduces input relay time
MASTER MC MC
1.8 to 3.2 1 (7) constant to 25 ms for 3-89
CONTROL (FNC24)
higher input response.
MASTER Selects ON/OFF
MCR MCR
CONTROL 0.6 to 1.0 1 (2) status of R coils, Ts, 3-89
(FNC25)
RESET or Cs.
MEMORY MEMSW MEMSW $ constant Represents end of MC.
$xxxx
$xxxx $ 0000 to $ FFFF –– 3 (0) 3-92
SWITCH (FNC26) Sets memory switches.
END
END
END –– 1 (3) Indicates end of each 3-94
12
routine of program.
KV-300
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
nnnn Connects N.O. contact
LOAD LD 0.15 to 0.70 3 (5) 3-57
to bus.
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time Function Page
Bytes
(µs)
nnnn
OUT 0.20 to 0.56 3 (8) Outputs input ON/OFF 3-65
OUT 0500 to 1915 status to R coil.
2009
nnnn 2300 to 17915 Outputs inverted input
OUT BAR OUB 0.50 to 1.20 3 (11) ON/OFF status to R 3-65
coil.
0500 to 1915
nnnn 2009 Forces R ON and holds
SET (SET) SET R No. 2100 to 17915 0.20 to 5.70 3 (12) this status when input 3-66
T000 to T249 is ON.
C000 to C249
0500 to 1915
2009
nnnn 2100 to 17915
T000 to T249 Forces R/T/C OFF 3-66
RESET (RES) RES 0.50 to 4.40 3 (12) when input is ON.
C000 to C249
CTH0 to CTH1
CTC0 to CTC3
#ddddd
16-bit on-delay T that
0.1-s TIMER TMR 5.60 to 10.40 2 (7) counts down in 0.1-s 3-67
T xxx
decrements.
T No., 000 to 249 16-bit on-delay T that
#ddddd TMH # preset 5.60 to 10.40 2 (7) counts down in 0.01-s 3-68
0.01-s TIMER H xxx (FNC49) #00000 to 65535
value decrements.
16-bit on-delay T that
#ddddd TMS 2 (7)
1-ms TIMER S xxx
5.60 to 10.40 counts down in 1-ms 3-69
(FNC51)
decrements.
2 #ddddd
# preset
value, C
#00000 to #65535
COUNTER C 000 to 249 4 (7) Sets 16-bit up-counter.
C xxx
No., clock 7.60 to 9.45 3-72
nnnn 0000 to 0009
source R 0500 to 17915
UDC xxx C No., 000 to 249
UP-DOWN UP #ddddd UDC 8.00 to 11.60 2 (10) Sets a 16-bit up-down
COUNTER
DW
RES (FNC52) # preset #00000 to #65535 counter. 3-76
value
DIFFEREN- Turns ON R for 1 scan
nnnn DIFU 6.70 3 (10) time at rising edge of 3-78
TIATE UP DIFU FNC10) 1000 to 1915
3000 to 6915 input.
R No. Turns ON R for 1 scan
DIFFEREN- nnnn DIFD (*) 7000 to 9915
6.70 3 (10) time at falling edge of 3-78
TIATE DOWN DIFD (FNC09)
input.
KEEP 0500 to 1915 Turns ON R and holds
KEEP 6.10 to 7.90 3 (11) this status when SET
KEEP
SET
nnnn R No. 2009 3-80
RES (FNC22)
2100 to 17915 input is ON.
SFT SFT 1st & 1000 to 1915
SHIFT
D
CLK
nnnn
last R 3000 to 6915 6.40 to 8.20 5 (15) Turns OFF R when 3-82
RES mmmm (FNC39) RESET input is ON.
Nos. (*) 7000 to 9915
HIGH HSP HSP 0000 to 0009 4.66 to 4.92 3 (8) Sets shift register. 3-86
nnnn R No.
SPEED (FNC18)
NOP
NOP — 1 (0) Performs no operation. 3-94
(FNC30)
END
END
0.95 1 (1) Indicates end of each 3-94
END
routine of program.
Note: 14.0 + 3.0 x (n) to 17.0 + 3.0 x (n) (n represents number of times the original
data is generated.)
STAGE
nnnn
STG
STG 11.0 to
Executes instructions between
3 (7) STG & JMP when R 3-106
12
[FNC 44] 1000 to 1915 14.0 (operand) is ON.
R No. 1000 to 1915
3000 to 6915 Turns current stage OFF and
nnnn JMP 10.0 to
JUMP 3 (5) next stage ON when input is 3-106
JMP [FNC 21] 13.0
ON.
ENDS 7.0 to
END
ENDS [FNC 14] 1 (3) Turns current stage OFF when 3-106
STAGE 9.0 input is ON.
0000 to 2915 0000 to 6915
STP T000 to T119 Executes program between
STP R, T, C T000 to T063 3.7 to 3 (7) STP & STE when R (operand) 3-114
STEP nnnn [FNC 45] C000 to C119
Nos. C000 to C063 5.3 is ON.
CTC0 to CTC3 CTC0 to CTC3
STE
1 (0) Is used with STEP to make
STE
STEP END 0.00 3-114
[FNC 43] program step.
DM0000 to
ITVL DM0000 to DM1985 Measures pulse-to-pulse
INTERVAL PLS DM & R 29.0 to 5 (7) interval & pulse width in
DM nnnn ITVL DM0985 3-117
TIMER PAUSE mmmm
No. 1000 to 1912 79.0
RES 1000 to 1912 specified mode.
3000 to 6912
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand value Operand value Exec.time Function Page
Bytes
KV-10/16 KV-24/40/80 (µs)
#00000 to #00000 to
#65535 #65535 Executes program
REPEAT FOR FOR # constant, between FOR & NEXT
nnnn
[FNC 16] DM No. DM0000 to DM0000 to 5.0 to 20.0 3 (15) 3-125
START for number of times
DM0999 DM1999
specified by operand.
TM00 to TM29 TM00 to TM29
nnnn:0000 to 0009
10000 to 10415 Reads 16-key data by
HKEY HKEY : time-sharing and
16-KEY nnnn
mmmm
I/O R 71 to 370 5 (7) outputs these data into 3-131
[FNC 17] 17000 to 17415
INPUT special utility Rs 2900
mmmm:10500 to 10915
: to 2915.
17500 to 17915
KV-300
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
nnnn Turns ON R (2nd operand
WAIT ON W-ON nnnn: [mmmm]) when R, T, or C (1st
ON 5.00 to 6.10 5 (9) 3-96
mmmm 0000 to 0009 operand [nnnn]) turns ON.
0500 to 17915
nnnn
T000 to T249 When R, T, or C (1st operand
WAIT OFF OFF W-OFF 5.00 to 6.10 5 (9) [nnnn]) turns OFF, R (2nd 3-96
mmmm C000 to C249
nnnn: operand [mmmm]) turns ON.
2 WAIT UP
nnnn R,T, or
CTC0 to CTC3
R (2nd operand [mmmm])
↑ W-UE C No. mmmm: 6.10 to 7.50 5 (10) turns ON at rising edge of R, 3-98
EDGE mmmm T, or C (1st operand [nnnn]).
1000 to 1915
nnnn 3000 to 6915 R (2nd operand [mmmm])
WAIT DOWN W-DE 6.10 to 7.50 5 (10) turns ON at falling edge of R,
↓ (*)7000 to 9915 3-98
EDGE mmmm T, or C (1st operand [nnnn]).
CON Represents series connection
CONNECT — 1 (0) of output instruction together 3-102
[FNC 06]
with another instruction.
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
n: Hardware-based comparator
16-BIT Comparator between preset & current
COUNTER #ddddd
CTC n: 0, 1 —
CTCn
No. ddddd: 2 (0) values of high speed counter. 3-204
COMPARA- ddddd: # This comparator is turned ON
TOR #00000 to #65535
preset value when these values are equal.
nnnn:0000 to 0009
10000 to 10415
: Reads 16-key data by time-
16-KEY HKEY HKEY
nnnn
mmmm
I/O R 17000 to 17415 16.50 5 (9) sharing and outputs these 3-131
INPUT [FNC 17] mmmm:0500 to 0503 data into special utility Rs
10500 to 10915 2900 to 2915.
:
17500 to 17915
n TMIN
< TMIN > [FNC 50] 13.0 to 15.0 1 (4) Converts trimmer
TRIMMER Trimmer rotation angle into 0
No. 0 0 to 1 3-138
SETTING to 249 and inputs it
n @TMIN 25.0 to 29.0 1 (11) into internal register.
↑ TMIN > @[FNC 50]
0000 to 2915 0000 to 6915
T000 to T063 T000 to T119
nnnn LDA C000 to C063 C000 to C119 10.0 to 46.0 3 (5)
< LDA > [FNC 23] R No., CTH0 to CTH1 CTH0 to CTH1
C/T No., DM0000 to DM0000 to Inputs value specified
DM/TM DM0999 DM1999 by operand into
LOAD A No., TM00 to TM31 TM00 to TM31 internal register or 3-140
#/$ #00000 to #00000 to inputs current value
constant, #65535 #65535 when T/C is specified
nnnn @LDA #TMxx $0000 to $0000 to 22.0 to 60.0 3 (12) as operand.
↑ LDA > @[FNC 23] $FFFF $FFFF
#TM00 to #TM00 to
#TM29 #TM29
0500 to 1915 0500 to 1915
2 nnnn STA R No., 2100 to 2915 2100 to 6915 Transfers content of
< STA > [FNC 42] C/T No., T000 to T063 T000 to T119 9.0 to 99.0 3 (5) internal register to
DM/TM C000 to C063 C000 to C119 location specified by
STORE A No., DM0000 to DM0000 to operand, or changes 3-140
#/$ DM0999 DM1999 preset value when T/
nnnn @STA constant, TM00 to TM29 TM00 to TM29 21.0 to 113.0 3 (12) C is specified as
↑ STA > @[FNC 42] #TMxx #TM00 to
#TM00 to operand.
#TM29 #TM29
nnnn CMP
< CMP > [FNC 04] DM0000 to DM0000 to 14.0 to 68.0 3 (5) Compares content of
DM0999 DM1999 internal register and
COMPARE value specified by 3-146
nnnn @CMP DM/TM TM00 to TM31 TM00 to TM31
↑ CMP > #00000 to #00000 to 26.0 to 82.0 3 (12) operand.
@[FNC 04] No.,
#/$ #65535 #65535
constant, $0000 to $0000 to Adds content of
nnnn ADD
< ADD > [FNC 00] #TMxx $FFFF $FFFF 13.0 to 65.0 3 (5) internal register and
#TM00 to #TM00 to value specified by
ADD 3-150
#TM29 #TM29 operand and inputs
nnnn @ADD
↑ ADD >
25.0 to 79.0 3 (12) result back to same
@[FNC 00]
register.
Subtracts value
nnnn SUB 15.0 to 68.0 3 (5) specified by operand
< SUB > [FNC 46] from content of
SUBTRACT register and inputs 3-150
nnnn @SUB
↑ SUB >
DM0000 to DM0000 to 27.0 to 82.0 3 (12) result back to same
@[FNC 46] DM0999 register.
DM1999
TM00 to TM31 TM00 to TM31 Multiplies content of
nnnn MUL #00000 to #00000 to 17.0 to 71.0 3 (5) internal register by
< MUL > [FNC 28] DM/TM #65535
No., #65535 value specified by
MULTIPLY $0000 to $0000 to 3-150
@MUL #/$ No., operand and inputs
nnnn $FFFF $FFFF
↑ MUL > @[FNC 28] #TMxx 29.0 to 85.0 3 (12) result back to same
#TM00 to #TM00 to register.
#TM29 #TM29
nnnn Divides content of
DIV 22.0 to 79.0 3 (5) internal register by
< DIV > [FNC 11]
value specified by
DIVIDE 3-150
operand and inputs
nnnn @DIV
34.0 to 93.0 3 (12) result back to same
↑ DIV > @[FNC 11]
register.
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand value Operand value Exec.time Function Page
Bytes
KV-10/16 KV-24/40/80 (µs)
nnnn ANDA ANDs each of 16 bits
<ANDA> 0000 to 2915 0000 to 6915 11.0 to 64.0 3 (5) of internal register and
[FNC 01]
DM0000 to DM0000 to that of value specified
AND A 3-159
DM0999 DM1999 by operand, and inputs
nnnn @ANDA
R No., TM00 to TM31 TM00 to TM31 23.0 to 78.0 3 (12) result back to same
↑ANDA> @[FNC 01]
DM/TM No., #00000 to #00000 to register.
#/$ No., #65535 #65535 ORs each of 16 bits of
nnnn ORA #TMxx $0000 to $0000 to
< ORA > 11.0 to 63.0 3 (5) internal register and
[FNC 31] $FFFF $FFFF
OR A that of value specified
#TM00 to #TM00 to 3-161
@ORA by operand, and
nnnn #TM29 #TM29 23.0 to 77.0 3 (12) inputs result back to
↑ ORA > @[FNC 31]
same register.
nnnn INC
< INC > 12.0 to 15.0 3 (5)
INCRE- [FNC 19] Adds 1 to content of
MENT data memory 3-172
MEMORY nnnn @INC 24.0 to 29.0 3 (12) specified by operand.
↑ INC > @[FNC 19]
DM0000 to DM0000 to
DM/TM No. DM0999 DM1999TM00
nnnn DEC
TM00 to TM29 to TM29 14.0 to 17.0 3 (5) Subtracts 1 from
DECRE- < DEC > [FNC 07]
MENT content of data
memory specified by 3-172
MEMORY nnnn @DEC
↑ DEC > @[FNC 07] 26.0 to 31.0 3 (12) operand.
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand value Operand value Exec.time Function Page
Bytes
KV-10/16 KV-24/40/80 (µs)
DMX
< DMX > [FNC 12] 28.0 to 30.0 1 (3) Converts position of
DEMULTI- highest order bit with 3-176
PLEXER 1 in internal register
@DMX
↑ DMX > @[FNC 12] 40.0 to 44.0 1 (10) into 4-bit data.
TBIN
< TBIN > [FNC 48] 18.0 to 20.0 1 (3) Converts content of
TRANSFER internal register (4-
digit BCD) into 16-bit 3-180
BIN @TBIN
↑ TBIN>
30.0 to 34.0 1 (10) binary data.
@[FNC 48]
RASC 1 (3)
<RASC> 12.0 to 14.0
REVERSE [FNC 32] Converts 2-digit ASCII
ASCII code into one byte 3-183
CONVERT @RASC data.
↑ RASC> 24.0 to 28.0 1 (10)
2 @[FNC 32]
Takes square root of 32-
ROOT 102.0 to
<ROOT> 1 (3) bit data (TM00: higher
[FNC 36] 103.0 order byte, internal
SQUARE 3-185
register: lower order
ROOT @ROOT 114.0 to
↑ ROOT> 1 (10) byte) and inputs result
@[FNC 36] 117.0 back to same register.
KV-300
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
nnnn:
DATA nnnn #/$ #0000 to #65535 0.60 to
MEMORY < DW > DW constant, $0000 to $FFFF 1.40 5 (11) Writes constant into 3-136
WRITE DMmmmm DM No. DMmmmm: data memory.
DM0000 to DM9999
n TMIN 5.10 to
< TMIN > [FNC 50] 1 (11) Converts trimmer
5.60
TRIMMER Trimmer 0, 1 rotation angle into 0 to
249 and inputs it into 3-138
SETTING No.
n @TMIN 2.00 to 1 (25) internal register.
↑ TMIN > @[FNC 50] 5.70
0000 to 0009
nnnn LDA 0500 to 17915 0.30 to 3 (12)
< LDA > [FNC 23] T000 to T249 28.00
R No., Inputs value specified
C000 to C249
C/T No., by operand into internal
LOAD A CTH0 to CTH1
DM/TM register or inputs 3-140
DM0000 to DM9999
No., current value when T/C
TM00 to TM31
@LDA #/$ is specified as operand.
nnnn #00000 to #65535 2.30 to 3 (26)
↑ LDA > @[FNC 23] constant, $0000 to $FFFF 30.00
#TMxx
#TM00 to #TM29
0500 to 1915
nnnn STA R No., 0.20 to 3 (12) Transfers content of
2100 to 17915
< STA > [FNC 42] C/T No., 30.00 internal register to
T000 to T249
DM/TM C000 to C249 location specified by
STORE A 3-140
No., CTC0 to CTC3 operand, or changes
@STA #/$ DM0000 to DM9999 preset value when T/C
nnnn 2.20 to
↑ STA > @[FNC 42] constant, TM00 to TM29 3 (26) is specified as operand.
32.00
#TMxx #TM00 to #TM29
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
nnnn CMP 9.20 to
< CMP > 3 (12) Compares content of
[FNC 04] 36.00 internal register and
COMPARE 3-146
nnnn value specified by
@CMP DM0000 to DM9999 11.20 to
↑ CMP > DM/TM 3 (26) operand.
@[FNC 04] TM00 to TM31 38.00
No.,
#/$ #00000 to #65535
nnnn ADD $0000 to $FFFF 7.70 to Adds content of internal
< ADD > constant, 3 (12)
[FNC 00] #TM00 to #TM29 35.00 register and value
ADD #TMxx
specified by operand 3-150
nnnn @ADD
↑ ADD >
9.70 to 3 (26) and inputs result back
@[FNC 00] 37.00 to same register.
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
#dd SRA
< SRA > 10.80 2 (22) Moves content of
SHIFT [FNC 41] internal register serially
RIGHT A right by value specified 3-166
#dd @SRA
↑ SRA > @[FNC 41] 12.80 2 (25) by operand.
#dd SLA
< SLA > [FNC 40] 10.80 2 (11) Moves content of
internal register serially
SHIFT left by value specified by 3-166
LEFT A #dd @SLA
↑ SLA > 12.80 2 (25) operand.
@[FNC 40]
# constant #01 to #16
Moves content of
#dd RRA
< RRA > [FNC 37] 12.00 2 (11) internal register serially
ROTATE right, allowing each bit
RIGHT A that leaves right end to 3-169
#dd @RRA
@[FNC 37] 14.00 2 (25) enter carry bit and then
↑ RRA > leftmost bit.
#dd RLA Moves content of
< RLA > [FNC 35] 12.00 2 (11) internal register serially
ROTATE left, allowing each bit
LEFT A that leaves left end to 3-169
#dd @RLA
↑ RLA > @[FNC 35] 14.00 2 (25) enter carry bit and then
rightmost bit.
COM
< COM > [FNC 05] 6.10 1 (9)
COMPLE- Inverts content of each
MENT bit in internal register. 3-171
@COM
↑ COM > 8.10 1 (23)
2 @[FNC 05]
nnnn INC
< INC > [FNC 19] 7.70 3 (12)
Adds 1 to content of
INCREMENT data memory specified 3-172
MEMORY nnnn @INC by operand.
↑ INC > @[FNC 19] 9.70 3 (26)
DM/TM DM0000 to DM9999
nnnn DEC No. TM00 to TM29
< DEC > [FNC 07] 7.70 3 (12)
Subtracts 1 from content
DECREMENT of data memory 3-172
MEMORY @DEC
nnnn
9.70 3 (26) specified by operand.
↑ DEC > @[FNC 07]
#n MPX
< MPX > [FNC 27] 7.30 1 (11) Converts 4-bit data
MULTI- (specified by operand)
# constant #0 to #3 3-176
PLEXER of internal register into
#n @MPX
9.30 1 (25) 16- bit data.
↑ MPX > @[FNC 27]
DMX
< DMX > [FNC 12] 6.70 1 (9) Converts position of
DEMULTI-
highest order bit with 1 3-176
PLEXER
@DMX in internal register into
↑ DMX > 8.70 1 (23) 4-bit data.
@[FNC 12]
KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
KV-300
2 KV-300
Instruction Symbol Mnemonic Operand Exec.time Function Page
Operand value Bytes
(µs)
INTERRUPT DI Disables execution
< DI > 3.20 1 (9) 3-193
DISABLED [FNC 08] of interrupt.
SET / RES
2.4 Instruction Details
0001 0500
RES
• Example
Coding
• Timing diagram
Line No. Instruction Operand
• Description 0000 LD 0000
0001 SET 0500 Coding
Perform programming 0002 LD 0001
Shows the
using the given example
12
0003 OUB 0500
Description coding for
to gain experience. • Output relay 0500 remains ON after input relay 0000 turns OFF. Output relay
0500 turns OFF when input relay 0001 turns ON. the given
• 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
example.
a timer or counter is used as an operand.
2 0001 #00100 0001 0002 #00100
C000 C000
00000 0000
0002 C000
RES
Note: The SET and RES instructions can be entered in any order. Note, however,
Note that priority is given to the instruction that is entered last.
Describes the notes In the above example, when both 0000 and 0001 are ON, RES has priority over
SET, causing 0500 to remain OFF.
for the instruction. Tips
Differences between SET/RES and KEEP
Basically , SET/RES and KEEP (➮ p. 3-57 and p. 3-71) serve the same purpose.
Tips • SET and RES can be used separately. Therefore, RES can be placed before
SET.
Describes hands-on Another instruction may be placed between SET and RES.
• KEEP needs only three lines of program, therefore saving memory space when
techniques for efficient used a number of times.
Operand Operands
NEW KV KV-300 KV-10/16 KV-24/40/80
Shows operands (element 0500 to 1915 0500 to 1915 0500 to 1915 0500 to 1915
2009 2009 2009 2009
Nos.) that can be used for 2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915
T000 to T249 T000 to T249 T000 to T063 T000 to T119
the instruction. C000 to C249 C000 to C249 C000 to C063 C000 to C119
CTH0 to CTH1 (RES only)
CTC0 to CTC3 (RES only)
switch to PROGRAM.
* The above page is created for explanation purposes only.
This page may be different from the actual page.
nnnn
LD: Load LD
7 : Connects N.O. contact to bus.
LDB nnnn
LDB: Load Bar 4 : Connects N.C. contact to bus.
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.
Description 12
• LD and LDB instructions are used to connect a contact to the bus.
• LD and LDB instructions are also used to separate program blocks when ANL or
ORL instruction is used.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915
T000 to T249 0500 to 17915 T000 to T063 T000 to T119
C000 to C249 T000 to T249 C000 to C063 C000 to C119
CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
CTC0 to CTC3
Key operation
Example: LD C014
LD
7
LDB
Operand ENT
R-SRCH ( L D CTR SET LDB
7 (C ) 1 4
ENT
R-SRCH )
4
Example
0000 0001 0500
0502
0004 0503
Coding
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 OUT 0500
0003 LD 0002
0004 ANB 0003
2 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
• As many contacts as desired can be connected in series provided these contacts
are used in the same program.
• As OUT 0503 shown in the above example, when an AND or ANB instruction is
used immediately after an OUT instruction to connect the other relay via a
contact (0004 in the example), the AND or ANB can be used as many times as
desired, provided the program syntax is correct.
• The following two circuits operate in the same manner, but the coding for these
circuits are different.
0500 0500
Coding Coding
Operand
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915
T000 to T249 0500 to 17915 T000 to T063 T000 to T119
C000 to C249 T000 to T249 C000 to C063 C000 to C119
CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
Key operation
Example: AND T012
AND
8
ANB
Operand ENT
R-SRCH ( AND TMR SET ANL
8 (T) 1 2
ENT
R-SRCH )
5
12
Example
0000 0003 0500
0001
0002
0004
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OR 0000
0002 ORB 0002
0003 AND 0003
0004 OR 0004
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.
Note: Output circuits (except for and ) 0000 0500
cannot be included in the parallel connection.
Incorrect 0001 0501
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 6915 0000 to 0009 0000 to 2915 0000 to 6915
T000 to T119 0500 to 17915 T000 to T063 T000 to T119
C000 to C119 T000 to T249 C000 to C063 C000 to C119
CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
CTC0 to CTC3
Key operation
Example: OR T018
OR
9
ORB
Operand ENT
R-SRCH ( O R TMR SET AND
9 (T ) 1 8
ENT
R-SRCH )
6
Example
0000 0001 0500
0002 0003
ANL
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OR 0002
0002 LD 0001
0003 OR 0003
0004 ANL
0005 OUT 0500
Description 12
0000
and Block B 0003 . The ANL instruction is used to connect two or more blocks in
series.
Operands
Key operation
ANL ENT
2 R-SRCH
• 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
2 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.
ORL
Connects in parallel blocks made of one or
ORL: Or Load 3 : more contacts.
Example
0000 0001 0050
0002 0003
ORL
Coding
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 LD 0002
0003 AMD 0003
0004 ORL
0005 OUT 0500
Description
0000 0001
The above example shows a parallel connection of Block A 12
0002 0003
and Block B . The ORL instruction is used to connect two or more blocks in
parallel.
Operands
Key operation
ORL ENT
3 R-SRCH
2 • 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).
nnnn
OUT: Out OUT
: Outputs ON/OFF status of input to relay coil.
A
OUB nnnn
OUB: Out Bar B : Outputs inverted ON/OFF status of input to
relay coil.
Example
0000 0500
0501
Coding
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, 12
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 0500 to 1915 0500 to 1915 0500 to 1915
2009 2009 2009 2009
2300 to 17915 2300 to 17915 2300 to 2915 2300 to 6915
Key operation
OUT Operand ENT OUB Operand ENT
A R-SRCH B R-SRCH
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.
2 0001 #00100 0001 0002 #00100
C000 C000
00000 0000
0002 C000
RES
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.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
0500 to 1915 0500 to 1915 0500 to 1915 0500 to 1915
2009 2009 2009 2009
2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915
T000 to T249 T000 to T249 T000 to T063 T000 to T119
C000 to C249 C000 to C249 C000 to C063 C000 to C119
CTH0 to CTH1 (RES only)
CTC0 to CTC3 (RES only)
Key operation
SET ENT RES ENT
1 Operand R-SRCH 0 Operand R-SRCH
Example
0000 #00010
T000 Preset value: 1 s
#00035
T001 Preset value: 3.5 s
T000 0500
T001 0501
Coding
Line No. Instruction Operand
0000 LD 0000
0001 TMR 000 #00010*1
0002 TMR 001 #00035*2
0003 LD T000
0004 OUT 0500
0005 LD T001
*1 0.1 s x 10 = 1 s
0006 OUT 0501 *2 0.1 s x 35 = 3.5 s
12
Timing diagram (TMR000 #00010 and 0500 in the above example)
Scan
ON
Input 0000 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
No.: 000 to 249 No.: 000 to 249 No.: 000 to 063 No.: 000 to 119
Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
Key operation
TMR Operand Operand ENT
(T) (TMR No.) (Preset value) R-SRCH
Example
0000 #00010
T000
T
H
T000 0500
Coding
Description
• 0500 and 0501 turn ON 0.1-s after 0000 turns ON.
2 • TMH is a subtraction timer. When the current value reaches "#00000", the
contact of the timer No. turns ON.
• When input relay 0000 turns OFF, contact T000 turns OFF and the current value
of TMH000 is reset.
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
Key operations
LDB OR ENT Operand Operand ENT
FUN 4 9 R-SRCH (TMH No.) (Preset value) R-SRCH
Example
0000 #00100
T000
T
S
Preset value: 0.1 s
T000 0500
Coding
Line No. Instruction Operand
0000 LD 0000
0001 TMS 000 #00010*1
0002 LD T000
0003 OUT 0500 *1 0.001 s x 100 = 0.1 s
Description
• 0500 and 0501 turn ON 0.1-s after 0000 turns ON.
• TMS is a subtraction timer. When the current value reaches "#00000", the
12
contact of the timer No. turns ON.
• When input relay 0000 turns OFF, contact T000 turns OFF and the current value
of TMS000 is reset.
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
No.: 000 to 249 No.: 000 to 249 No.: 000 to 063 No.: 000 to 119
Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
Key operations
ANB SET ENT Operand Operand ENT
FUN 5 1 R-SRCH (TMS No.) (Preset value) R-SRCH
Timing diagram
ON
OFF
0000
ON ON
0500
2 sec. 2 sec.
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 TMR 000 #00020
2 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 T000 0500
Timing diagram
ON
OFF
0000
ON
0500
2 sec.
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 ANB T000
0003 OUT 0500
0004 ANB 0000
0005 TMR 000 #00020
■ 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.
T000 0500
Timing diagram
ON
OFF
0000
0500 ON
2s 1s
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.
0500
Timing diagram
ON
OFF
0000
ON ON ON
0500
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
CTR #ddddd
C: Counter (C) : Cxxx
nnnn
Sets a 16-bit up-counter.
Example
Reset input Preset value
Coding
Line No. Instruction Operand
0000 LDB 0001
0001 C 000 #00010 0000
0002 LD C000
0003 OUT 0500
0000 ON
0001
(Reset input)
Current value 9
10
8
of C000 6
7
5
4
3
2
#00010 1
C000 ON
0500
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 25°C 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 #00010
C000
0000
Details of counter
■ Extended ladder
• The counter for the KV Series supports the extended ladder method.
KV counter
0001 2007 #00010
C005
0000
• 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.
Coding
Line No. Instruction Operand
0000 LDB 0002
0001 C 002 #00300 0004
0002 CON
0003 AND C002
12
0004 OUT 0500
➮ "CON instruction" (p. 3-102)
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
No.: 000 to 249 No.: 000 to 249 No.: 000 to 063 No.: 000 to 119
Count input: Count input: Count input: Count input:
0000 to 17915 0000 to 0009, 0000 to 2915 0000 to 6915
0500 to 17915
Preset value: Preset value: Preset value: Preset value:
#00001 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
Key operation
Coding
0001 C001 #03600 Line No. Instruction Operand
C001
2006 0000 LDB 0001
C001 1000 0001 ANB C001
0002 C 001 #03600 2006
0001 #00600 0003 LD C001
C002
1000 0004 OUT 1000
0005 LDB 0001
0006 C 002 #00600 1000
2
■ Large capacity counter
Coding
0002 C000 #10000 Line No. Instruction Operand
C000
0000 0000 LDB 0002
C000 1000 0001 ANB C001
0002 C 001 #10000 0000
0002 #65535 0003 LD C000
C001
1000 0004 OUT 1000
0005 LDB 0002
0006 C 001 #65535 1000
■ Multi-level setting
Sets a multi-level counter using arithmetic instructions.
0001 #09999
C002
0000
2002 C002 #01000 2009 0500
LDA CMP
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0002 0010 MRD
0001 C 002 #09999 0000 0011 CMP #02000
0002 LD 2002 0012 CON
0003 LDA C002 0013 ANB 2009
0004 CON 0014 OUT 0501
0005 MPS 0015 MPP
0006 CMP #01000 0016 CMP #03000
0007 CON 0017 CON
0008 ANB 2009 0018 ANB 2009
0009 OUT 0500 0019 OUT 0502
0001 #09999
C000
0000
2002 C000 #00999 2011 0500
LDA CMP
Coding
Line No. Instruction Operand
0000 LDB 0001
0001 C 000 #09999 0000
0002 LD 2002
0003 LDA C000
0004 CON
0005 MPS
0006 CMP #00999
0007 CON
0008 ANB 2011
0009 OUT 0500
0010 MRD
0011 CMP #01999
0012 CON
0013 ANB 2011
0014 ANB 0500
0015 OUT 0501
0016 MPP
0017 CMP #02999
0018 CON
0019 ANB 2011
0020 ANB 0500
0021 ANB 0501
0022 OUT 0502
UDC xxx
UDC: Up-Down Counter FUN 5
ANB ANL
2 : UP
DW #ddddd
RES
Sets a 16-bit up-down-counter.
Example UP input
UDC 000
0001
UP
#00009 DOWN input
0002
DW
RESET input
0003
RES
C000 0500
Coding
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002
0002 LD 0003
0003 UDC 000 #00009
0004 LD C000
0005 OUT 0500
2
Timing diagram
9
8
7
6
5
4
2 3
Current value of C000 1 Carry Carry Time
ON ON
C000 OFF
ON
Input for up 0001 OFF
ON
OFF
Input for down 0002
Input for resetting ON
0003 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 25°C even when the KV is not in operation or is turned off.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
No.: 000 to 249 No.: 000 to 249 No.: 000 to 063 No.: 000 to 119
Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
Key operation
ANB ANL ENT Operand Operand ENT
FUN 5 2 R-SRCH (C No.) (Preset value) R-SRCH
0003
RES
UDC 001
C000 0001
UP BCD
#09999 High-order 4 digits
C000 0002
DW
0003
RES
Up-input 0001
Down-input 0002
Coding
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002 12
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
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.
SET RES nnnn Detects rising edge of input signal and turns
DIFU: Differentiate Up FUN 1 0 : DIFU
ON specified relay for 1st scan time only.
RES OR nnnn Detects falling edge of input signal and turns
DIFD: Differentiate Down: FUN 0 9 : DIFD
ON specified relay for 1st scan time only.
Example
0000 1000
DIFU
1001
DIFD
Coding
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1000
0002 DIFD 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 0500
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 1915
3000 to 9915 3000 to 6915 3000 to 6915
*7000 to 9915
* 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
SET RES ENT Operand ENT FUN RES OR ENT Operand ENT
FUN 1 0 R-SRCH (Relay No.) R-SRCH 0 9 R-SRCH (Relay No.) R-SRCH
Coding
0000 1000 Line No. Instruction Operand
DIFU
0000 LD 0000
1001 0001 DIFU 1000
DIFD
0002 DIFD 1001
1000 T001 0500 0003 LD 1000
0004 OR 0500
0500 #00010 0005 ANB T001
T001 0006 OUT 0500
1001 T002 0501 0007 TMR 001 #00010
0008 LD 1001
0501 #00010 0009 OR 0501
T002 0010 ANB T002
0011 OUT 0501
0012 TMR 002 #00010
Timing diagram
ON
OFF
0000
ON
OFF
12
1000
ON
OFF
1001
ON
0500
1s
ON
0501
1s
■ Alternating circuit
Every time input relay 0000 turns ON, output relay 0500 turns ON and OFF alter-
nately.
Coding
0000 1000 Line No. Instruction Operand
DIFU 0000 LD 0000
1000 0500 0500 0001 DIFU 1000
0002 LD 1000
0003 ANB 0500
1000 0500 0004 LDB 1000
0005 AND 0500
0006 ORL
0007 OUT 0500
Example
KEEP SET input
0001
SET
0500
0002
RES RESET input
Coding
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1000
0002 DIFD 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.
2 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).
➮ "MEMSW instruction" (p. 3-92)
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 Coding
MEMSW 1000 through 1915.
Line No. Instruction Operand
$0004
0000 MEMSW $0004
0001 KEEP 0001 LD 0001
SET 0002 LD 0002
1000
0002 0003 KEEP 1000
RES 0004 LD 1000
1000 0500 0005 OUT 0500
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
0500 to 1915 0500 to 1915 0500 to 1915 0500 to 1915
2009 2009 2009 2009
2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915
Key operation
ANL ANL ENT Operand ENT
FUN 2 2 R-SRCH (Relay No.) R-SRCH
• 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 PZ2-61
Gum Gum Gum
KEEP
0000 0001 0002 0003
SET Executes SET when all input relays
12
1000 0000 to 0003 are ON.
1001
RES
0000 1001
DIFD Detects presence/absence of chewing
gum packs all Down edge of 0000.
1001 1000 T001 0500
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0007 DIFD 1001
0001 AND 0001 0008 LD 1001
0002 AND 0002 0009 ANB 1000
0003 AND 0003 0010 OR 0500
0004 LD 1001 0011 ANB T001
0005 KEEP 1000 0012 OUT 0500
0006 LD 0000 0013 TMR 001 #00010
Timing diagram
ON
OFF
0000
ON
OFF
0001
ON
OFF
0002
ON
OFF
0003
ON
OFF ON ON
0500
1s
SFT
ORL O R D
SFT: Shift FUN 3 9 : CLK nnnn
RES mmmm
Sets a shift register.
Example
Data input
SFT
0001
Relay shift D
operation
1000 First relay No.
0002
CLK Clock
1002 Last relay No.
0003
RES RESET input
1002 0500
Coding
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002
0002 LD 0003
0003 SFT 1000 1002
2 0004 LD 1002
0005 OUT 0500
Timing diagram
0 OFF
1 ON
RESET input ON
1002 1001 1000 0001
0003 OFF Lost 0 0 1 1 A)
ON
Data input 1002 1001 1000 0001
0 1 1 1 B)
0001 OFF Lost
A B C D E F G
ON
Clock 1002 1001 1000 0001
0002 OFF Lost 1 1 1 1 C)
ON
1002 1001 1000 0001
ON ON Lost 1 1 1 1 D)
1000
1002 1001 1000 0001
ON ON Lost 1 1 0 0 E)
1001
1002 1001 1000 0001
ON ON Lost 1 0 0 1 F)
1002
1002 1001 1000 0001
ON ON Lost 0 0 1 1 G)
0500
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.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 1915
3000 to 6915 3000 to 6915 3000 to 6915
*7000 to 9915
* 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
ORL OR ENT Operand Operand ENT
FUN 3 9 R-SRCH (Relay No.) (Relay No.) R-SRCH
SFT Coding
1000
D Line No. Instruction Operand
1000 0000 LDB 1000
0000
CLK 0001 LD 0000
1000 0002 LD 2003
2003 0003 SFT 1000 1000
RES
0004 LD 1000
1000 0500 0005 OUT 0500 12
Timing diagram
ON
OFF
0000
0500 ON ON ON ON ON
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 Line No. Instruction Operand
D
0000 LD 2003
1000
2003 0001 LD 2003
CLK 0002 LD 0000
1915 0003 SFT 1000 1915
0000
RES
Coding
2 2008 1000
SET
Line No. Instruction Operand
0000 LD 2008
T001 #00010 0001 SET 1000
T001
0002 LDB T001
SFT
2003 0003 T001 #00010
D
0004 LD 2003
1000
T001 0005 LD T001
CLK
0006 LD 2003
1005
2003 0007 SFT 1000 1005
RES
0008 LD 1000
1000 0500 0009 OUT 0500
0010 LD 1001
1001 0501 0011 OUT 0501
0012 LD 1002
1002 0502 0013 OUT 0502
0014 LD 1003
1003 0503 0015 OUT 0503
0016 LD 1004
1004 0504 0017 OUT 0503
0018 LD 1005
1005 1000 0019 SET 1000
SET
Timing diagram
Scan
ON
0001 OFF
ON
0000 OFF
ON
1000 OFF
1001
ON
OFF
ON
12
1002 OFF
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
2 0003 SET 0500
0004 LD 0002
0005 SET 0501
0006 LD 0003
0007 RES 0500
0008 RES 0501
Timing diagram
ON
OFF
0000
ON ON ON
0001
ON ON ON
0002
5 ms 5 ms 15 ms
ON ON
0003
ON ON
0500
ON
0501
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.
➮ "1.4.3 Constant Scan Time Mode" (p. 3-25)
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.
Note 3: The HSP instruction must be specified when the INT instruction or high-
speed counter is used.
Note 4: When special utility relay 2813 and HSP instruction turn ON at the same
time, priority is given to the HSP instruction and the time constant is changed to 10
µs.
Note 5: Connect a non-contact input for the HSP instruction to prevent a contact
bounce from being entered.
Output device
Output device
Inputdevice
Inputdevice
Inputdevice
Program Program Program
execution execution execution
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 12
time as in 3).
Scan time < Input signal width < Normal time constant (10 ms ± 20%)
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
SET AND ENT Operand ENT
FUN 1 8 R-SRCH (Relay No.) R-SRCH
Coding
0001 HSP Line No. Instruction Operand
0000
1-s timer 0000 LD 0001
0000 #00010 0001 HSP 0000
T000
Turns ON
0002 LD 0000
0500 T000 0500 timer for 1s 0003 OR 0500
when 0500 0004 TMR 000 #00010
is ON.
0005 ANB T000
0006 OUT 0500
Timing diagram
Scan
ON
0000 OFF
ON
0001 OFF
0500 ON
1s
2 * To input a signal having pulse interval shorter than the scan time, use the inter-
rupt instruction.
➮ Refer to "Chapter 3 Interrupts" (p. 3-191).
INT
0000 Sets interrupt input at 0000.
2002 0500
SET Sets 0500 when 0000 turns ON.
RETI
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 END
0001 EI 0008 INT 0000
0002 SET 2813 0009 LD 2002
0003 LD 0500 0010 SET 0500
0004 T000 #00010 0011 RET1
0005 LD T000 0012 ENDH
0006 RES 0500
MC: Master Control ANL LDB MC Selects ON/OFF status of relay coils, timers,
FUN 2 4 : or counters set before MCR instruction.
MCR: Master Control ANL ANB MCR
FUN 2 5 : Used in pairs with MC instruction to end the
Reset execution of MC instruction.
Example
0000 MC
0001 0500
0501
MCR
Coding
Line No. Instruction Operand
0000 LD 0000
0001 MC
0002 LD 0001
0003 OUT 0500
0004 OUB 0501
0005 MCR 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
OUT and OUB Corresponding relay is OFF
TMR, TMH, and TMS Timer is reset
C, SFT, KEEP, SET, RES, and CTH Previous status is retained
Other instructions such as TMIN Instruction is not executed.
MCR STE
MCR MCR
Operands
Key operation
ANL LDB ENT ENT ANL ANB ENT ENT
FUN 2 4 R-SRCH R-SRCH
FUN 2 5 R-SRCH R-SRCH
0003 0500
MCR
Note: The scan time is not shortened even if the input relay of the MC instruction is
2 OFF.
Output relays 0500 within and outside of the MC-MCR instructions form a double
coil as shown below. ➮ "Double coil" (p. 3-65)
0003 0500
This relay is ignored.
0001 MC
0002 0500
The last relay has priority.
MCR
Timing diagram
Scan
ON
0000 OFF
ON
0001 OFF
ON
0002 OFF
ON
0003 OFF
0500 ON ON ON
0501 ON ON ON
Coding
0502 ON ON ON
Line No. Instruction Operand
0000 LD 0000
0001 OUT 1000
0002 CON
0003 OUB 1001
0000 1000 1001 0004 LD 0000
0001
0005 DIFU 1002
0000 1002 1002 1100 1101 1102 0006 CON
0002 DIFU RES RES RES
0007 AND 1002
1000 MC
0003 0008 RES 1100
0009 CON
1100 1200 #00010 T000 1101
0004 STG T000 JMP 0010
0011
RES
CON
1101
12
1101 1201 #00020 T001 1102
0005 STG T001 JMP 0012 RES 1102
1102 1202 #00030 T002 1100 0013 LD 1000
0006 STG T002 JMP 0014 MC
MCR 0015 STG 1100
0007 0016 OUT 1200
1001 MC 0017 CON
0008
0018 TMR 000 #00010
0001 1203 0019 CON
0009
0020 AND T000
0002 1204 0021 JMP 1101
0010
0022 STG 1101
0003 1205
0011 0023 OUT 1201
0024 CON
MCR
0012 0025 TMR 001 #00020
0026 CON
1200 0500
0013 0027 AND T001
1203
0028 JMP 1102
0014 0029 STG 1102
1201 0501 0030 OUT 1202
0015 0031 CON
1204 0032 TMR 002 #00030
0016
0033 CON
1202 0502 0034 AND T002
0017
0035 JMP 1100
1205 0036 MCR
0018
0037 LD 1001
END 0038 MC
0019
0039 LD 0001
ENDH
0020 0040 OUT 1203
0041 LD 0002
0042 OUT 1204
0043 LD 0003
0044 OUT 1205
0045 MCR
0046 LD 1200
0047 OR 1203
0048 OUT 0500
0049 LD 1201
0050 OR 1204
0051 OUT 0501
0052 LD 1202
0053 OR 1204
0054 OUT 0502
0055 END
0056 ENDH
Memory Switch
FUN 2 6 : $nnnn Sets memory switches.
Key operation
ANL ORB ENT Operand ENT
FUN 2 6 R-SRCH 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 func-
2 tion of the switch is specified by turning a certain bit ON or OFF.
SW4 SW3 SW2 SW1
MEMSW
3 2 1 0 3 2 1 0 3 2 1 0 3 2 1 0 $3800
0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0
SW4 SW3 SW2 SW1
Switch
No. Function of switch ON OFF
0 Cancels error when power is ON. Retains error. Cancels error and
starts operation.
1 Action when "Memory error" occurs at Loads memory Does not load
startup (due to data memory, counter from EEPROM memory from
value, or retained content being erased). EEPROM
2 Uses latch function of internal utility relays Uses latch Doesn't use
1000 through 1915. function. latch function.
3 Uses latch function of internal utility relays Uses latch Doesn't use
3000 through 3915. function. latch function.
0 Uses latch function of internal utility relays Uses latch Doesn't use
4000 through 4915. function. latch function.
1 Uses latch function of internal utility relays Uses latch Doesn't use
5000 through 5915. function. latch function.
2 Uses latch function of internal utility relays Uses latch Doesn't use
6000 through 6915. function. latch function.
3 Not used. — —
0 Not used. — —
1 Clears DM0000 to DM0999 at power-on. Clears DM. Retains DM.
2 Clears DM1000 to DM1899 at power-on. Clears DM. Retains DM.
3 Switches between 24- and 16-bit compara- 24-bit 16-bit
tors for CTH0.
0 Switches between 24- and 16-bit compara- 24-bit 16-bit
tors for CTH1.
1 Clears values of counter, CTH, and CTC. Clears values. Retains values.
2 Write-protects program in KV PLC. Write-protects Doesn't write-
program. protect program.
3 Read-protects program in KV PLC. Read-protects Doesn't read-
program. protect program.
Details of MEMSW
■ Setting memory switches
Specify a hexadecimal number for each switch No.
Tips
• The data entered for the memory switch is set into the KV PLC when the pro-
gram 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
.
Description
To use internal utility MEMSW
To clear a DM when MEMSW
relays 1000 through $0004 operation is started. $0E00
1915 as latch relays.
END END
END: End DM : Indicates end of each routine of program.
ENDH
ENDH: End Hi ENDH
TM : Indicates end of entire program.
Description
• END and ENDH instructions must be used at the end of a program.
• A subroutine or interrupt program can be written between END and ENDH.
• When not using either subroutine or interrupt programs, write ENDH immediately
after END.
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 ENT ENDH ENT
DM R-SRCH TM R-SRCH
Example
0000 0001
ON
1000 W-ON
1000 0500
0002 0003
OFF
1001
W-OFF
1001 0501
Coding
Line No. Instruction Operand
0000 LD 0000
0001 W-ON 0001 1000
0002 LD 1000
0003 OUT 0500
2 0004 LD 0002
0005 W-OFF 0003 1001
0006 LD 1001
0007 OUT 0501
Timing chart
• W-ON
ON
OFF
0000
ON
OFF
0001
1000 ON ON
0500
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
OFF
0002 ON
OFF
0003
1001 ON ON
0501
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.
Description
W-ON
Input operand
Same
0001 operation
0000 0001 0000 1000
ON
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
Same
0002 0003 operation 0003 0002 1001
OFF
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 dupli-
cated in a program.
12
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
nnnn: nnnn: nnnn: nnnn:
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915
T000 to T249 0500 to 17915 T000 to T063 T000 to T119
C000 to C249 T000 to T249 C000 to C063 C000 to C119
CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
mmmm: CTC0 to CTC3 mmmm: mmmm:
1000 to 1915 mmmm: 1000 to 1915 1000 to 1915
3000 to 9915 1000 to 1915 3000 to 6915
3000 to 6915
*7000 to 9915
* 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
F ENT
First operand Second operand
(nnnn) (mmmm) R-SRCH
W-OFF
Li
Example
0000 0001
1000
W-UE
1000 0500
0002 0003
1001
W-DE
1001 0501
Coding
Timing chart
● W-UE
ON
OFF
0000
ON
OFF
0001
1000 ON
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
OFF
0002
ON
OFF
0003
1001 ON
0501
• 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.
Description
W-UE
Input operand 0001 1002
Same DIFU
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
Input operand 0003 1003
Same DIFD
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). 12
Note 3: Output operand relay Nos. for W-UE/W-DE instructions cannot be dupli-
cated in a program.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
nnnn: nnnn: nnnn: nnnn:
0000 to 17915 0000 to 0009 0000 to 6915 T000 to T119
T000 to T249 00500 to 17915 0000 to 2915 C000 to C119
C000 to C249 T000 to T249 T000 to T063 CTC0 to CTC3
CTC0 to CTC3 C000 to C249 CTC0 to CTC3 mmmm:
mmmm: CTC0 to CTC3 mmmm: 1000 to 1915
1000 to 1915 mmmm: 1000 to 1915 3000 to 6915
3000 to 9915 1000 to 1915
3000 to 6915
*7000 to 9915
* 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
E
First operand Second operand ENT
(nnnn) (mmmm) R-SRCH
W-DE
Lo
0000 0001 Output relay 0100 turns ON when both input relays
ON
1000 0000 and 0001 turn ON in any order.
0001
Output relay 1001 turns ON only when input relay
1001 0000 turns ON before input relay 0001.
0100 0500
1001 0501
ON
OFF
0000
ON
OFF
0001
1000
0500 ON ON
(W-ON)
1001
0501 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.
Output relay 0500 turns OFF when input relay 0000 is OFF.
Coding
0000 0001
Line No. Instruction Operand
1000
1000 0002 0000 LD 0000
1001 0001 W-UE 0001 1000
1001 0003 0002 LD 1000
1002 0003 W-UE 0002 1001
1002 0500
0004 LD 1001
0005 W-UE 0003 1002
0006 LD 1002
0007 OUT 0500
Timing diagram
Scan
ON
0000 OFF
ON
0001 OFF
0002
ON
OFF
12
ON
0003 OFF
0500 ON
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
ON
0000 OFF
ON
0001 OFF
0500 ON
0501 ON
Example
0000 0500 0501 0502 0503
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OUT 0500
0002 CON
0003 OUT 0501
0004 CON
0005 OUT 0502
0006 CON
0007 OUT 0503
Description
• When input relay 0000 turns ON, 0500, 0501, 0502, and 0503 turn ON.
2 • 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
RES ORB ENT ENT
FUN 0 6 R-SRCH R-SRCH
Example
0000 MPS 0001 0500
0002 0501
MRD
0003 0502
MPP
Coding
Line No. Instruction Operand
0000 LD 0000
0001 MPS
0002 AND 0001
0003 OUT 0500
0004 MRD
0005 AND 0002
12
0006 OUT 0501
0007 MPP
0008 AND 0003
0009 OUT 0502
Description
• When input relay 0000 is ON:
0500 turns ON as soon as 0001 turns ON.
0501 turns ON as soon as 0002 turns ON.
0502 turns ON as soon as 0003 turns ON.
• The MPS instruction is used at the start of an output branch.
• The MRD instruction is used to connect an output branch.
• The MPP instruction is used at the end of an output branch.
• When the KV IncrediWare (DOS)/LADDER BUILDER for KV programming
support software is used, the MPS, MRD, and MPP instructions are automatically
converted into mnemonics and entered in the ladder diagram.
MPP
ch
MPS/MRD/MPP applications
MPS, MRD, and MPP instructions are used as follows:
MPP
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0002 0007 OUT 0501
0001 AND 0003 0008 MRD
0002 MPS 0009 AND 0007
0003 AND 0004 0010 OUT 0502
0004 OUT 0500 0011 MPP
0005 MRD 0012 AND 0008
0006 AND 0006 0013 OUT 0503
2
MPP
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0009 MPP
0001 MPS 0010 AND 0004
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
MPP 0502
MPP 0503
MPP 0504
MPP
Coding
Line No. Instruction Operand
0000 LD 0000
0001 MPS
0002 AND 0001
0003 MPS
0004 AND 0002
0005 MPS
0006 AND 0003
0007 MPS 12
0008 AND 0004
0009 OUT 0500
0010 MPP
0011 OUT 0501
0012 MPP
0013 OUT 0502
0014 MPP
0015 OUT 0503
0016 MPP
0017 OUT 0504
nnnn
STG: Stage LDB LDB
FUN 4 4 : STG Executes instructions in STG block when operand relay is ON.
nnnn
When transition condition relay is ON, turns OFF relay of current
JMP: Jump ANL SET
FUN 2 1 : JMP stage and transfers execution to stage specified by operand.
ENDS: End Stage When transition condition relay is ON, turns OFF relay
SET LDB
FUN 1 4 : ENDS
of current stage.
Example
2008 1000
SET Initial setting
0003 1000
JMP
1003
JMP
1003 0502 0004
4) STG 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
Note 1: The following table shows the status of each instruction between STG and
JMP/ENDS when STG operand relay turns OFF.
Instruction Function
Relay for OUT instruction Turned OFF.
Relay for OUB instruction Turned ON.
TMR, TMH, TMS, Reset.
C (counter) instructions
SET, RES instructions Current status is retained.
Other instructions Not executed.
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 1915
3000 to 9915 3000 to 6915
*7000 to 9915
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
LDB LDB ENT Operand ENT
FUN 4 4 R-SRCH (nnnn) R-SRCH
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
NO Start
SW ON?
2 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:
I/O assignment
Lamp 1
KV
0000 0500
Start SW
Lamp 2
0501
Lamp 3
0502
COM COM
■ Sequence program
Assign the relays to execute the five processes on the previous page as follows:
1 Wait until the start switch is turned ON.: Input relay 0000
2 Turn on lamp 1 for 1 second.: Output relay 0500
3 Turn on lamp 2 for 3 second.: Output relay 0501
4 Turn on lamp 3 for 5 second.: Output relay 0502
5 Turn on lamps 1, 2, and 3 simultaneously: Output relays 0500, 0501, and 0502
for 7 seconds.
The following is the ladder diagram for the I/O assignments above, and is written
with and without STG instructions.
#00070
T003
1100
1002 0502
1102
2008 1001
SET 1001 turns ON at the start of operation.
1001 0000 0500 #00010 T000 1002 0500 turns ON for 1 second when input
STG T000 JMP
0000 turns ON. Then, 1002 turns ON.
1002 0501 #00030 T001 1003
STG T001 JMP 0501 turns ON for 3 seconds when
1002 turns ON. Then, 1003 turns ON.
1003 0502 #00050 T002 1004
STG T002 JMP 0502 turns ON for 5 seconds when 1003
turns ON. Then, 1004 turns ON.
1004 0500 0501 0502
STG
0500, 0501, and 0502 turn ON for 7
seconds when 1004 turns ON.
#00070 T003 1001
T003 JMP The process is repeated from the
beginning when T003 turns ON.
Description
When using the W-UE instruction in a program with STG instructions on the previ-
ous 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).
➮ "W-UE instruction" (p. 3-98)
Tips
Resetting STG instructions (in the above example)
2 Use the SFT instruction to turn OFF all STG instructions in an emergency.
SFT
2003
D
2003
1000 STG start relay
CLK
Reset input 1004 STG end relay
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.
➮ "SFT instruction" (p. 3-82)
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.
Interlock
Double coil
A double coil can be used for an STG instruction.
1000 0500 0001 1100 1001
STG ON JMP
1100
1001 0501 0002 1101 1002
STG ON JMP
1101
1002 0500 0003 1102 1003
STG ON JMP
1102
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. 12
1000 0500 0000 1001
STG SET JMP
STG operand
When the STG operand relay remains ON, 0500 does not turn OFF even if 0001
turns ON.
0000 1000
SET
Use a differentiation type instruction for the condition of the first STG instruction.
0000 1100 1100 1000
DIFU SET
JMP operand
Unlike the STG operand relay, the JMP operand relay No. can be duplicated in a
program.
1000 0500 0001 1001
STG JMP
1002
JMP
3000 0501
Coding
Note: The double coils in different STG instruction blocks operate properly. How-
ever, when several STG instructions turn ON simultaneously, priority is given to the
one programmed last.
■ Conditional branching
When input relay 0000 (start SW) turns ON, output relay 0500 turns ON. Then, as
programmed for conditional branching, output relay 0501 turns on for 1 second
when 0001 turns ON, and 0502 turns ON for 2 seconds when 0002 turns ON. After
each operation is completed, the program returns to the conditional branch and
repeats the same steps.
0002 1002
JMP
Coding
12
Line No. Instruction 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 000 #00010
0018 CON
0018 AND T000
0020 JMP 1000
0021 STG 1002
0022 OUT 0502
0023 CON
0024 TMR 001 #00020
0025 CON
0026 AND T001
0027 JMP 1000
Example
0000 1000
STP
1000
0001 0500
STE
Coding
Line No. Instruction Operand
0000 LD 0000
0001 OUT 1000
0002 STP 1000
0003 LD 0001
0004 OUT 0500
0005 STE
2
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.
• The program step specified with
STP-STE instructions are ex- STP
1000
ecuted when the STP operand When 1000 is OFF,
A A is not executed.
relay is ON. When the operand
relay is OFF, the program 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:
T000 0500
1000 #00050
T000 Timer Jump
T000 1000 remains
RES ON.
STE
Timer is reset.
T000 1000
RES
T000 0500
Timer Jump 12
1000 #00050 remains
T000
ON.
STE
0002 1002
JMP
STP instruction
Use the STP instruction for process progression without branches.
0000 1000
SET
STP
1000
0001 0500
STE
STP
1001
0004 0501
STE
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915
T000 to T249 0500 to 6915 T000 to T063 T000 to T119
C000 to C249 *7000 to 9915 C000 to C063 C000 to C119
CTC0 to CTC3 T000 to T249 CTC0 to CTC3 CTC0 to CTC3
C000 to C249
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
LDB ANB ENT Operand ENT
FUN 4 5 R-SRCH (nnnn) R-SRCH
Coding
2
0000 1000 1000 1001 Line No. Instruction Operand
DIFU SET
0000 LD 0000
STP
1001 0001 DIFU 1000
T000 1001
0002 CON
RES 0003 AND 1000
T000 0500 0004 SET 1001
0005 STP 1001
1001 #00020
T000 0006 LD T000
T000 1002 0007 RES 1001
SET
0008 LDB T000
STE 0009 OUT 0500
0010 LD 1001
STP
1002 0011 TMR 000 #00020
T001 1002 0012 LD T000
RES
0013 SET 1002
T001 0501 0014 STE
0015 STP 1002
1002 #00030
T001 0016 LD T001
STE 0017 RES 1002
0018 LDB T001
END 0019 OUT 0501
0020 LD 1002
ENDH
0021 TMR 001 #00030
0022 STE
0023 END
0024 ENDH
The double coils in different STP blocks operate properly.
ITVL
PLS
DMnnnn
ITVL Measures pulse-to-pulse interval or pulse
ITVL: Interval Timer #TM : PAUSE
mmmm
width in specified mode.
RES
0000 ITVL
PLS
0001
DM0000 Beginning of workpiece data table
PAUSE "Measurement Pause" input
0002
1000 First flag relay
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.
Key operation
ITVL First operand Second operand ENT
#TM (nnnn) (mmmm) R-SRCH
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 succes-
sive relays.
Note: Do not use the 16 data memories and 4 relays specified with the ITVL instruc-
tion for any other purpose.
Data memory
■ Relay assignment
Relay
Relay +0 MAX error Turns ON and remains ON for one scan time when
measured value exceeds Max preset value.
+1
MIN error Turns ON and remains On for one scan time when
measured value goes below Min preset value.
Every
+2 measurements Turns ON at completion of every measurement and
completion remains ON for one scan time.
Measurements
+3 completion for Turns ON for one scan time at completion of the
mean calculation specified No. of measurements for mean value
calculation, then remains ON for one scan time.
■ Mode setting
Write the desired mode No. into the first data memory.
0 10 m sec 1 10 m sec
4 1 sec 5 1 sec
Example
Write "#0006" to obtain the average of the contents of DM0006.
Mode No. DM No. Description
Measure the contents of DM0000 and obtain the
10000 DM0000
average.
Measure the contents of DM0001 and obtain the
10001 DM0001
average.
• • • 12
• • •
10005 DM0005 Measure the contents of DM0005 and obtain the
average.
0006 Measure the contents of DM0006 and obtain the
10006 DM0006
average.
0007 10007 DM0007 Measure the contents of DM0007 and obtain the
average.
• • • •
• • • •
1999 11999 DM1999 Measure the contents of DM1999 and obtain the
average.
2000 to 9999 12000 or more Not provided Cannot be used.
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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0013 LDA #00010
0001 LDA #00000 0014 CON
0002 CON 0015 STA DM0003
0003 STA DM0000 0016 LD 0000
0004 LD 2008 0017 LD 0001
0005 LDA #00051 0018 LD 0002
0006 CON 0019 ITVL DM0000 1000
0007 STA DM0001 0020 LD 1000
0008 LD 2008 0021 OR 1001
0009 LDA #00049 0022 OR 0500
0010 CON 0023 ANB T000
0011 STA DM0002 0024 OUT 0500
0012 LD 2008 0025 TMR 000 #00030
Timing diagram
ON
0000 OFF
500ms 400ms 600ms
1000 ON
1 scan
1001 ON
1 scan
0500 ON ON
3 sec. 3 sec.
ITVL
2003
PLS
DM0000
0001 Pauses measurement when input relay 0001 turns ON.
PAUSE
Resets measurement when input relay 0002 turns ON.
1000
0002
RES 12
1000 0500
0500 turns ON when measured value exceeds max. setting value.
1001 0501
0501 turns ON when measured value is below min. value.
Coding
nn
RES RES
CALL: Subroutine Call FUN 0 0 : Executes subroutine specified by operand.
CALL
Example
0000 00
CALL
END
SBN
00
RET
ENDH
Coding
Line No. Instruction Operand
0000 : :
: : :
2 : LD 0000
: CALL 00
: : :
: END :
: SBN 00
: : :
: RET :
: ENDH :
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 speci-
fied 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 instruc-
tion has been encountered, program execution returns to the instruction immedi-
ately following the CALL instruction.
Operand
CALL 00 to 99
SBN 00 to 99
RET —
Key operations
RES ORL
FUN 0 3
ENT Operand ENT
R-SRCH R-SRCH
ORL AND
FUN 3 8
ORL ORL ENT ENT
FUN 3 3 R-SRCH R-SRCH
Application of subroutine
Program A)
2008 00
CALL
Normal scan
Program B)
END
SBN
00
Subroutine program
Subroutine
RET
ENDH
Program A) Program A)
12
0000 00 0000 00
CALL CALL Subroutine program
Program B) Program B)
0001 00
CALL
Program
END
SBN
01
Subroutine program
RET
SBN
00
0000 01
CALL
Call
RET
ENDH
0001 0500
Program
END
SBN
00
Subroutine program
RET
INT
0000
0002 00
CALL
Call
RETI
ENDH
FOR
SET ORB
FOR: Repeat Start FUN 1 6 : nnnn Executes program between FOR and NEXT
NEXT
by number of times specified by operand.
ANL OR
NEXT: Repeat End FUN 2 9 : Represents end of repetition.
Example
2008 00
CALL
END
SBN
00
NEXT
RET
12
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0107 FOR #00050
0001 CALL 00 0108 LD 2002
: : 0109 STA #TM02
0099 END 0110 CON
0100 SBN 00 0111 INC TM02
0101 LD 2002 0112 NEXT
0102 LDA #00100 0113 RET
0103 CON :
0104 STA TM02 :
0105 CON :
0106 LDA #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 initializa-
tion is completed when the TM02 value becomes "50 + 1" between the FOR and
NEXT instructions.
➮ "Indirect addressing" (p. 3-127)
• 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.
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
#0000 to #65535 DM0000 to DM1984 #00000 to #65535 #00001 to #65535
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999
TM02 to TM28 TM00 to TM29 TM00 to TM29 TM00 to TM29
Key operation
SET ORB ENT Operand ENT
FUN 1 6 R-SRCH R-SRCH
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.
Example
When TM02 value is "0000", "#TM02" represents DM0000.
When TM02 value is "10000", "#TM02" represents 0000 (relay).
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.
DM0199
• Comparison between a program with normal addressing and one with indirect
addressing.
ENDH ENDH
The contents of DM0000 are transferred The first No. of the source DM block is specified
to DM0100. (DM0000).
The contents of DM0001 are transferred The first No. of the destination DM block is specified
to DM0101. (DM0100).
The contents of DM0002 are transferred The contents of the DM indirectly addressed by
▲
•
The contents of DM0099 are transferred Add "1" to both "TM02" and "TM03" to increment
to DM0199. the Nos. of the source and destination DMs by one.
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.
When the ladder program on line 3) is repeated 100 times, the contents of the
specified DM block are transferred.
SBN
00
ENDH
2 Coding
HKEY
Reads hexadecimal key data on time-
HKEY: 16-Key Input FUN 1
SET LD
7 : nnnn
mmmm
sharing basis and outputs these data to
special utility relays 2900 to 2915.
0005 HKEY
0000
0500
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
4 5 6 7
Pressing two or more keys
8 9 A B simultaneously is OK.
(With diode)
C D E F
• 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 corre-
sponding special utility relay (2900 to 2915).
Relay No. 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915
Hex key 0 1 2 3 4 5 6 7 8 9 A B C D E F
• 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:
Note 4: When two or more keys are pressed simultaneously even once during the
scan while relay 2814 is ON, relays 2900 through 2915 keep the current status as
soon as relay 2815 turns ON.
Note 5: The HKEY instruction does not properly operate if the scan time is longer
than 200 ms.
Note 6: When the expansion I/O module is used as an operand, the fetch may fail
unless the scan time is fixed to 2 ms or longer.
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 0500 to 00000 to 00500 to 0000 to 0500 to
0415 0915 00009 00503 0415 0915
10000 to 10500 to
10415 10915
: :
17000 to 17500 to
17415 17915
Key operation
SET LD ENT Input relay Output relay ENT
FUN 1 7 R-SRCH R-SRCH
Coding
2002 0001 #09999 C000 0600 Line No. Instruction Operand
C000
0000 0000 LD 2002
0005 HKEY
0104 0001 ANB 0001
0512 0002 C 000 #09999 0000
2815 2900 C000
LDA TBIN STA 0003 CON
0004 AND C000
END
0005 OUT 0600
0006 LD 0005
ENDH
0007 HKEY 0104 0512
0008 LD 2815
0009 LDA 2900
0010 CON
0011 TBIN
0012 CON
0013 STA C000
0014 END
0015 ENDH
• As soon as 0005 turns ON, the preset value is replaced with the new preset
value specified by the digital switches.
➮ "TBIN instruction" (p. 3-180), "LDA, STA instructions" (p. 3-140)
• 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.
Diode
1 2 4 8
+ COM 0104 0105 0106 0107
24 KV
VDC - COM 0512 0513 0514 0515
2002 HKEY
0000
0500
2815 2900 2010 $03FF TM05 2010 TM05 TM06
LDA ANDA CMP STA DMX STA
2815 2900
LDA
2010 $03FF
ANDA
TM05
CMP
2010 TM05
STA 12
DM0000 #04 TM06 DM0000
LDA SLA STA STA
ENDH
Coding
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.
LDA instruction
TMIN
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
CMP MPX Con-
ADD DMX
SUB TBCD
stant
Internal register MUL TBIN
temporary memories
Data memories,
DIV ASC
STA direction
ANDA
ORA
EORA
RASC
12
SRA
SLA
Preset T/C Data memory, Data memory accessed RRA
Relay No value. 5. temporary in indirect addressing via RLA
COM
memory temporary memory 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 rewrit-
ten each time when an instruction is executed.
Note 3: The internal register cannot be monitored.
DW nnnn
DW: Data Memory Write : DW
DMmmmm
Directly writes constant into data memory.
Example
First operand
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.
Description
• Values are directly written into data memories, without using the internal register.
Operand
Note: The contents of the internal register and the arithmetic flag do not change
even after the DW instruction is executed.
Tips
• The DW instruction can be used to reset the contents of data memories.
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 First operand Second operand ENT
reraly R-SRCH
Arithmetic flag
2009, 2010, 2011 No change
2012 No change
Example
Differentiation type instruction Every-scan type instruction
Description
• Arithmetic instructions have two instruction types: differentiation type and every-
scan 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
Every-scan type instruction Differentiation type instruction
ON ON
0000 OFF 0000 OFF
Note:
In the top program, an INC instruction is
0000 DM0000 executed every scan time, incrementing
INC the contents of DM0000 by one, while
input relay 0000 is ON.
Operands
ANB RES n
TMIN: Trimmer In FUN 5 0 : TMIN Inputs numerical value specified by digital
trimmer of access window (0 to 65535) to
@ ANB RES n
@TMIN: Trimmer Setting #,$ FUN 5 0 : TMIN internal register.
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 T000
TMIN STA
0000 #00010 T000 0500
T000
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. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0005 TMR 000 #65535
0001 TMIN 0 0006 CON
0002 CON 0007 AND T000
0003 STA T000 0008 OUT 0500
0004 LD 0000
2 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.
• Timer/counter preset
value
Internal • Relay ch No.
TMIN STA
register
• Data memory
• Temporary memory
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 0
Key operation
FUN
ANB RES ENT Operand ENT
@ 5 0 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 No change
2010 Turns ON when "0" is entered by the TMIN instruction. Turns
OFF at other times.
2011, 2012 No change
0000 #00010
T000
Coding
0000 #00010
T000
0001 #00010
T001
0002 #00010
T002
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0012 OUT 0500
0001 TMIN 0 0013 LD 0001
0002 CON 0014 OR 0501
0003 STA T000 0015 TMR 001 #00010
0004 CON 0016 ANB T001
0005 STA T001 0017 OUT 0501
0006 CON 0018 LD 0002
0007 STA T002 0019 OR 0502
0008 LD 0000 0020 TMR 002 #00010
0009 OR 0500 0021 ANB T002
0010 TMR 000 #00010 0022 OUT 0502
0011 ANB T000
In the above example, T000, T001, and T002 have the same setting value.
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 Input Storage Transfer Destination
Internal register
T/C current T XXX
2
value C XXX Data memory DM XXXX
LDA STA 6
Data memory DM XXXX Temporary memory TM XX
3 Temporary memory
TM XX
4 Relay No. Relay No. XXXX Relay No. Relay No. XXXX 7
(Data type: operand) (Data type: operand)
➮ "Internal Register" (p. 3-126)
Operands
2 Visual KV KV-300 KV-10/16 KV-24/40/80
LDA STA LDA STA LDA STA LDA STA
0000 to 0500 to 0000 to 0000 to 0000 to
17915 1915 0009 2915 6915
T000 to 2100 to 0500 to 0500 to T000 to 0500 to T000 to 0500 to
T249 17915 17915 1915 T063 1915 T119 1915
(Current
value)
C000 T000 to T000 to 2100 to C000 to 2100 to C000 to 2100 to
to 249 T249 T249 17915 C063 2915 C119 6915
(Current (Preset
value) value)
CTH0 to C000 C000 to T000 to CTH0 to T000 to CTH0 to T000 to
CTH1 to C249 C249 T249 CTH1 T063 CTH1 T119
(Preset
value)
DM0000 to CTC0 to CTH0 to C000 to DM0000 to C000 to DM0000 to C000 to
DM1999 CTC3 CTH1 C249 DM0999 C063 DM1999 C119
TM00 to DM0000 to DM0000 to CTC0 to TM00 to CTC0 to TM00 to CTC0 to
TM31 DM1999 DM9999 CTC3 TM31 CTC3 TM31 CTC3
#00000 to TM00 TM00 to DM0000 to #00000 to DM0000 to #00000 to DM0000 to
#65535 to TM29 TM31 DM9999 #65535 DM0999 #65535 DM1999
$0000 to #TM00 to #00000 to TM00 to $0000 to TM00 to $0000 to TM00 to
$FFFF #TM29 #65535 TM29 $FFFF TM29 $FFFF TM29
#TM00 to $0000 to #TM00 to #TM00 to #TM00 to #TM00 to #TM00 to
#TM29 $FFFF #TM29 #TM29 #TM29 #TM29 #TM29
#TM00 to
#TM29
Key operation
FUN
ANL ORL ENT ENT
2 3 R-SRCH
Operand R-SRCH
@ FUN
#,$
FUN
LDB ANL ENT Operand ENT
@ 4 2 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 No change
2010 Turns ON when the contents of the internal register is "0" after
"LDA #00000" is executed. Turns OFF at other times.
2011 No change
2012 Turns ON when the DM or relay indirectly addressed with #TM is
out of range.
➮ "Indirect addressing" (p. 3-127)
0002 #09999 C001 0500 When C001 current value equals to its preset value,
C001
0001 0500 turns ON.
Coding
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 speci-
fied 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.
Coding
Line No. Instruction Operand
0000 LDB 0001
0001 C 010 #099999 0000
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.
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 speci-
fied 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".
Coding
Line No. Instruction Operand
0000 LD 2002
0001 LDA 0000
0002 CON
0003 STA 0600
Description
Input (Internal register) Output
1 : ON
(KV basic unit) 16-bit (KV-E16T(P))
0 : OFF
000 ON 0000 1 D0 0600 ON 00
001 ON 0001 1 D1 0601 ON 01
002 ON 0002 1 D2 0602 ON 02
003 ON 0003 1 D3 0603 ON 03
004 OFF 0004 0 D4 0604 OFF 04
005 OFF 0005 0000 0 D5 0600 0605 OFF 05 12
006 OFF 0006 <LDA> 0 D6 <STA> 0606 OFF 06
007 OFF 0007 0 D7 0607 OFF 07 Out-
Input
008 ON 0008 1 D8 0608 ON 08 put
009 ON 0009 1 D9 0609 ON 09
010 ON 0010 1 D10 0610 ON 10
011 ON 0011 1 D11 0611 ON 11
012 OFF 0012 0 D12 0612 OFF 12
013 OFF 0013 0 D13 0613 OFF 13
014 OFF 0014 0 D14 0614 OFF 14
015 OFF 0015 0 D15 0615 OFF 15
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.
➮ "1.3 Device Configuration" (p. 3-5)
• 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.
Note 3: When an STA instruction is executed while the setting value of a counter or
a timer is smaller than the current value, the current value is changed to be the
setting value.
Unloading
timing
The OK/NG judgment and unloading timings can be used in asynchronous pro-
grams.
0000 1000 1000 0001 $1111 DM0000
DIFU LDA STA
OK/NG judgment "$1111" is transferred to
timing OK/NG judgment DM0000.
0001 $5555 DM0000
LDA STA
"$5555" is transferred to DM0000.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0035 STA DM0003
0001 DIFU 1000 0036 CON
0002 CON 0037 LDA $0000
0003 AND 1000 0038 CON
0004 MPS 0039 STA DM0002
0005 AND 0001 0040 LD 2002
0006 LDA $1111 0041 LDA DM0002
0007 CON 0042 CON
0008 STA DM0000 0043 CMP $0000
0009 MPP 0044 CON
0010 ANB 0001 0045 AND 2010
0011 LDA $5555 0046 LDA DM0001
0012 CON 0047 CON
0013 STA DM0000 0048 STA DM0002
0014 LD 2002 0049 CON
0015 LDA DM0004 0050 LDA $0000
0016 CON 0051 CON
0017 CMP $0000 0052 STA DM0001
0018 CON 0053 LD 2002
0019 AND 2010 0054 LDA DM0001
0020 LDA DM0003 0055 CON
0021 CON 0056 CMP $0000
0022 STA DM0004 0057 CON
0023 CON 0058 AND 2010
0024 LDA $0000 0059 LDA DM0000
0025 CON 0060 CON
0026 STA DM0003 0061 STA DM0001
0027 LD 0002 0062 CON
0028 LDA DM0003 0063 LDA $0000
0029 CON 0064 CON
0030 CMP $0000 0065 STA DM0000
0031 CON 0066 LD 0002
0032 AND 2010 0067 @LDA $0000
0033 LDA DM0002 0068 CON
0034 CON 0069 @STA DM0004
CMP instruction compares the contents of the internal register with the value speci-
fied by the operand, and turns ON/OFF the special utility relays (2009, 2010, 2011)
according to the result of comparison.
2009 2010 2011
(Internal register) < (Operand) ON OFF OFF
(Internal register) = (Operand) OFF ON OFF
(Internal register) > (Operand) OFF OFF ON
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
Operands
Visual KV KV-300 KV-10/16 KV-24/40/80
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
RES LDB ENT Operand ENT
@ 0 4 R-SRCH R-SRCH
#,$ FUN
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.
➮ "Indirect addressing" (p. 3-127)
Description 12
• 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 2009
LDA CMP
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 b
LDA CMP
2010 0501
DM0000=#01000
2011 0502
DM0000>#01000
Coding
0001 #09999
C001
0000
2002 C001 #01000 2011 0500
LDA CMP C001≤#01000
Coding
0500 turns ON when the current value of C000 is smaller than the CMP setting
value.
0501 turns ON when the current value of C000 is equal to or greater than the CMP
setting value.
2002 0 DM0000
TMIN STA Sets range of TMIN from 0 to 100.
0001 #09999
C000
00000
2002 C000 DM0000 2009 0500
LDA CMP
2009 0501
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0011 C 000 #09999 0000
0001 TMIN 0 0012 LD 02002
0002 CON 0013 LDA C000
0003 ADD #00001 0014 CON
0004 CON 0015 CMP DM0000
0005 MUL #00004 0016 MPS
0006 CON 0017 AND 2009
0007 DIV #00010 0018 OUT 0500
0008 CON 0019 MPP
0009 STA DM0000 0020 ANB 2009
0010 LDB 0001 0021 OUT 0501
ADD, SUB, MUL, and DIV allow arithmetic instructions between the contents of
internal register and the value specified by the operand.
Decimal (#XXXXX)
Constants
ADD
Internal register
Internal register
Hexadecimal ($XXXX)
Operand
SUB
Data memories
2 DIV
TM00 to TM31
#TM00 to #TM29
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
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
RES RES ENT Operand ENT
@ 0 0 R-SRCH R-SRCH
#,$ FUN
FUN
LDB ORB ENT Operand ENT
@ 4 6 R-SRCH R-SRCH
#,$ FUN
FUN
ANL AND ENT Operand ENT
@ 2 8 R-SRCH R-SRCH
#,$ FUN
FUN
SET SET ENT Operand ENT
@ 1 1 R-SRCH R-SRCH
#,$ FUN
ADD (Addition)
2002 DM0000 #00100 DM0001
LDA ADD STA
Coding
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 ADD #00100
0004 CON
0005 STA 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
12
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 2009 Input back internal register Result
utility relay
Tips
Solution when operation result overflows 16 bits
Arithmetic flag
2009 Turns ON when the result of an ADD operation exceeds the range of 16 bits
($FFFF). Turns OFF at other times.
2010 Turns ON when the contents of the internal register is "0" after an ADD
operation. Turns OFF at other times.
2011 No change
2012 The DM or relay indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
Coding
SUB (Subtraction)
2002 DM0000 #00100 DM0001
LDA SUB STA
Coding
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. 12
Special utility relay 2009 turns ON.
Operand - 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
Underflow 1
2's complement is stored.
2009
Note 2: To convert the complement into an antilogarithm, add the following opera-
tion:
Inverted bit of complement + 1 = Antilogarithm
Tips
Solution when operation result is a negative value
2002 DM0000 DM0001 2009 DM0002
LDA SUB STA (Stores positive value)
Absolute value
2009 #0001 DM0003
COM ADD STA (Stores negative value) is stored.
Arithmetic flag
2009 Turns ON when the result of a SUB operation is negative. Turns OFF at
other times.
2010 Turns ON when the contents of the internal register is "0" after a SUB
operation. Turns OFF at other times.
2011 Turns ON when the result of a SUB operation is positive. Turns OFF at other
times.
2012 The DM or relay indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
1000 0500
1001
Coding
MUL (Multiplication)
2002 DM0000 #00100 DM0001
LDA MUL STA
Coding
Description
• The MUL instruction multiplies the contents of the internal register by the oper-
and 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 #00100→DM0001 (#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, 12
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
0 0 0 1 F F F F
Tips
Solution when operation result overflows 16 bits
2002 DM0000 DM0001 DM0002 TM00 DM0003
LDA MUL STA LDA STA
Arithmetic flag
2009 Turns ON when the result of a MUL operation exceeds 16 bits. Turns OFF at
other times.
2010 Turns ON when all 32 bits are "0" after a MUL operation. Turns OFF at other
times.
2011 No change
2012 The DM or relay indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
0001 #09999
C001
0000
2002 C001 DM0000 DM0100 TM00 DM0101
LDA MUL STA LDA STA
Coding
DIV (Division)
2002 DM0001 TM00 DM0000 #00100 DM0002 TM00 DM0003 TM01 DM0004
LDA STA LDA DIV STA LDA STA LDA STA
Coding
Arithmetic flag
2009 No change
2010 Turns ON when all 32 bits are "0" after a DIV operation. Turns OFF at other
times.
2011 No change
2012 Turns ON when the divisor of a DIV operation is "0" or the DM or relay
indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
Description
• 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.
Quotient
Example
DM0001 DM0000
High-order 16 bits Low-order 16 bits
#00100
12
DM0003 DM0002 DM0004
High-order 16 bits Low-order 16 bits Remainder (16 bits)
Quotient
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
Quotient
Coding
Example
0000 DM0000 $00FF DM0001
LDA ANDA STA
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.
12
• 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".
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Operand ($F0F0)
Only when both bits of the
$00FF These values are ANDed for internal register and the
ANDA each bit to obtain logical product. operand are "1", will the logical
Internal ($F0F0)
product be "1".
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
register
The result is transferred DM0001
to 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
Arithmetic flag
2009 No change
2010 Turns ON when the internal register is "0" after an ANDA operation.
Turns OFF at other times.
2011 No change
2012 The DM or relay indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
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.
0004 #00300
C004
0005
2002 0100 $000F C004
LDA ANDA TBIN STA
Coding
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 ORA $00FF
0004 CON
0005 STA 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.
12
• The contents of the internal register are transferred to DM0001.
• The following shows the case when DM0000 is "$F0F0".
$00FF These values are ORed for Only when both bits of the
ORA each bit to obtain logical sum. internal register and the
Internal
operand are "0", will the logical
1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 ($F0FF) sum be "0".
register
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
ORL SET ENT Operand ENT
@ 3 1 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 No change
2010 Turns ON when the internal register is "0" after an ORA operation. Turns
OFF at other times.
2011 No change
2012 The DM or relay indirectly addressed with #TM is out of range.
➮ "Indirect addressing" (p. 3-127)
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 $000F DM0000 0200
LDA ANDA STA LDA
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 #00099
C000 Sets C000.
0001
2002 0500 $FF00 DM0000
LDA ANDA STA Writes data of 0008 to 0015 into DM0000.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0009 LDA C000
0001 C 001 #00099 0001 0010 CON
0002 LD 2002 0011 TBCD
0003 LDA 0500 0012 CON
0004 CON 0013 ANDA $00FF
0005 ANDA $FF00 0014 LD 2002
0006 CON 0015 ORA DM0000
0007 STA DM0000 0016 CON
0008 LD 2002 0017 STA 0500
Example
0000 DM0000 $00FF DM0001
LDA EORA STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 EORA $00FF
0004 CON
0005 STA 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
2 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 EOR (Exclusive OR)
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 DM0000 ($F0F0) truth table (Result)
$00FF These values are EORed for each Only when the bits of the
EORA bit to obtain exclusive OR value. internal register and the
Internal operand have different values,
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 register ($F00F) will the exclusive logical sum
be "1".
The result is trans-
DM0001
ferred to 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
SET ANB ENT Operand ENT
@ 1 5 R-SRCH R-SRCH
#,$ FUN
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.
➮ "Indirect addressing" (p. 3-127)
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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 ANDA $00FF
0001 LDA $00AA 0008 CON
0002 CON 0009 EORA DM0000
0003 STA DM0000 0010 CON
0004 LD 2002 0011 AND 2010
0005 LDA 0100 0012 OUT 0500
0006 CON
$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
When 2010 is ON, the two values match. Judges match between the operand and the
When 2010 is OFF, the two values do not match. data of 0100 to 0107.
Example
0000 DM0000 #05 DM0001
LDA SRA STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 SRA #05
0004 CON
0005 STA DM0001
2 0006 LD 0001
0007 LDA DM0010
0008 CON
0009 SLA #10
0010 CON
0011 STA DM0011
Operands
#01 to #16
Key operation
FUN
LDB SET ENT Operand ENT
@ 4 1 R-SRCH R-SRCH
#,$ FUN
FUN
LDB RES ENT Operand ENT
@ 4 0 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 Turns ON when "1" enters 2009 after an SRA/SLA operation. Turns OFF at
other times.
2010 Turns ON when the internal register is "0" after an SRA/SLA operation.
Turns OFF at other times.
2011 No change
2012 No change
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.
Carry
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 2009
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
0
Carry
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 2009
0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1 0
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
0
Carry
2009 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
1 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.
0001 #09999
C004
0000
2002 #12 DM0000 Shifts the value of internal register to right by 12 bits and writes it
SRA STA
into DM0000.
2 2002 0000 $000F
LDA ANDA Sends the data of 0000 to 0003 to internal register.
2002 #04 DM0000 Shifts the data of internal register to left by 4 bits, ORs the internal
SLA ORA
register data and the data of DM0000, and sends the ORed data to
the internal register.
2002 C001
TBIN STA Converts the data of internal register to BIN data and writes it into
C001.
Coding
Line No. Instruction Operand
0000 LD 0001
0001 C 001 #00099 0000
0002 LD 2002
0003 LDA 0100
0004 CON
0005 ANDA $F000
0006 LD 2002
0007 SRA #12
0008 CON
0009 STA DM0000
0010 LD 2002
0011 LDA 0000
0012 CON
0013 ANDA $000F
0014 LD 2002
0015 SLA #04
0016 CON
0017 ORA DM0000
0018 LD 2002
0019 TBIN
0020 CON
0021 STA C001
ORL LD #dd
RRA: Rotate Right A FUN 3 7 : RRA Rotates contents of internal register and
#dd
carry (2009) clockwise by operand value.
@ ORL LD
:
@RRA: Rotate Right A #,$ FUN 3 7 RRA
Example
0000 DM0000 #01 DM0001
LDA RRA STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 RRA #01
0004 CON
0005 STA DM0001
0006 LD 0001 12
0007 LDA DM0010
0008 CON
0009 RLA #04
0010 CON
0011 STA DM0011
Operands
#01 to #16
Key operation
FUN
ORL LD ENT Operand ENT
@ 3 7 R-SRCH R-SRCH
#,$ FUN
FUN
ORL ANB ENT Operand ENT
@ 3 5 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 Turns ON when "1" enters 2009 after an RRA/RLA operation. Turns
OFF at other times.
2010 Turns ON when the internal register is "0" after an RRA/RLA operation.
Turns OFF at other times.
2011, 2012 No change
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.
Use @RRA, a differentiation type instruction, to execute the instruction only once
when input relay 0000 turns ON.
Carry
2009 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0
Carry
2009 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0
Carry
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 2009
2 1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 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.
2002 0000
LDA Writes the data of 0000 to 0015 into internal register.
FOR
#00016 Executes FOR-NEXT instruction 16 times.
Coding
RES ANB
COM: Complement FUN 0 5 : COM
Inverts contents of each bit in internal
@COM: (Bit inversion) @ RES ANB
: register.
#,$ FUN 0
COM
5
Example
0000 DM0000 DM0001
LDA COM STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 @LDA DM0000
0002 CON
0003 @COM
0004 CON
0005 @STA 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". 12
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
DM0001 1 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 = $A0A0
Note:
0000 DM0000 DM0001
LDA COM 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
RES ANB ENT ENT
@ 0 5 R-SRCH R-SRCH
#,$ FUN
Arithmetic flag
2009 No change
2010 Turns ON when the internal register is "0" after a COM operation. Turns
OFF at other times.
2011 No change
2012 No change
nnnn
INC: Increment Memory FUN 1
SET OR
9 : INC
Adds 1 to contents of data memory
@ SET OR nnnn specified by operand.
@INC: Increment Memory #,$ FUN 1 9 : INC
RES LD nnnn
DEC: Decrement Memory FUN 0 7 : DEC Subtracts 1 from contents of data
nnnn memory specified by operand.
@DEC: Decrement Memory @
#,$ FUN
RES LD
0 7 : DEC
DM0001
DEC
Coding
Line No. Instruction Operand
0000 LD 0000
0001 @INC DM0000
0002 @DEC 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
2 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 Contents of data memory specified by operand
0 0 0 1 1 is added.
+
0 0 0 1 1 is subtracted.
–
Operands
Key operation
FUN
SET OR ENT ENT
1 9 R-SRCH
Operand R-SRCH
@ FUN
#,$
FUN
RES LD ENT ENT
0 7 R-SRCH
Operand R-SRCH
@ FUN
#,$
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 opera-
tion. 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 0000 DM0000
INC INC
Tips 12
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
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0005 @INC 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
■ Total count 1
Writes the total count of 4 lines (0000 to 0003) into DM0000.
Reset input relay is 0005.
0000 DM0000
INC Increments DM0000 by 1 at UP edge of input relay 0000.
0001 DM0000
INC Increments DM0000 by 1 at UP edge of input relay 0001.
0002 DM0000
INC Increments DM0000 by 1 at UP edge of input relay 0002.
0003 DM0000
INC Increments DM0000 by 1 at UP edge of input relay 0003.
0005 #00000
DW Clears DM0000 to #00000 when 0005 turns ON.
DM0000
Coding
Line No. Instruction Operand
0000 LD 2008
0001 LDA #00000
0002 CON
0003 STA DM0000
2 0004 LD 0000
0005 @INC DM0000
0006 LD 0001
0007 @INC DM0000
0008 LD 0002
0009 @INC DM0000
0010 LD 0003
0011 @INC DM0000
0012 LD 0005
0013 DW #00000 DM0000
■ Total count 2
Counts the number of boxes transferred on 5 production lines. Produces output
when the number becomes 100 or more.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0011 DW #00000 DM0000
0001 @INC DM0000 0012 LD 2002
0002 LD 0001 0013 LDA DM0000
0003 @INC DM0000 0014 CON
0004 LD 0002 0015 CMP #00100
0005 @INC DM0000 0016 CON
0006 LD 0003 0017 ANB 2009
0007 @INC DM0000 0018 OUT 0500
0008 LD 0004 0019 END
0009 @INC DM0000 0020 ENDH
0010 LD 0005
■ 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.
#09999 C004
STA
DM0004 0003
INC
DM0000
12
C004 LDA STA INC
0003
#09999 C005 DM0005 0004 DM0000
C005 LDA STA INC
0004
2002 DM0001 DM0002 DM0003 DM0004 DM0005 DM0000 0005 $0000
LDA ADD ADD ADD ADD STA DW
DM0000
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 simulta-
neously, duplicated inputs are ignored.
Use the appropriate program according to your application.
1) 2)
Example
0000 0000 #1 1000
LDA MPX STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA 0000
0002 CON
0003 MPX #1
0004 CON
0005 STA 1000
2 0006 LD 0001
0007 LDA 0100
0008 CON
0009 DMX
0010 CON
0011 STA DM0000
Operands
#0 to #3
Key operation
FUN
SET OR ENT Operand ENT
@ 1 9 R-SRCH R-SRCH
#,$ FUN
FUN
RES LD ENT Operand ENT
@ 0 7 R-SRCH R-SRCH
#,$ FUN
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.
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 #0 Operand
1 0 1 0 Internal register
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 1 0 1 1 0 0 1 0 1 0 0 0 1 0 0
F E D C B A 9 8 7 6 5 4 3 2 1 0 Enter the number of the most
significant bit with "1".
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
0 to F
The value is converted into a hexadecimal number.
The DMX instruction is disabled when all bits in the internal register are OFF. In
such a case, special utility relay 2012 turns ON.
When the digital switch shows "8", output 0508 turns ON, therefore, lamp 8 lights.
■ DMX instruction
Connect sensors 0 to 15 to input relays 0000 through 0015.
Connect output relays 0500 through 0503 to the one-digit data of a BIN indicator.
The sensors which are currently ON are shown by the BIN indicator.
* Assume that several sensors do not turn on simultaneously.
2002 0000
LDA DMX Converts the most significant bit of 16-bit data (0000 to
0015) to 4-bit BIN data and sends it to internal register.
2002 $00FF 0500
TBCD ANDA STA Converts internal register data to BCD data, executes an
ANDA instruction, and outputs the data to 0500 to 0507.
Coding
7-segment configuration
a
f b
g a : 0600 b : 0601 c : 0607
d : 0603 c : 0604 f : 0605
g : 0606
e c
d
1008 $007F
LDA
0600
STA 8
12
1009 $006F 0600
LDA STA 9
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB C000 0024 LD 1004
0001 C 000 #00009 0000 0025 LDA $0066
0002 CON 0026 CON
0003 LDA C000 0027 STA 0600
0004 CON 0028 LD 1005
0005 MPX #0 0029 LDA $006D
0006 CON 0030 CON
0007 STA 1000 0031 STA 0600
0008 LD 1000 0032 LD 1006
0009 LDA $003F 0033 LDA $007D
0010 CON 0034 CON
0011 STA 0600 0035 STA 0600
0012 LD 1001 0036 LD 1007
0013 LDA $0006 0037 LDA $0007
0014 CON 0038 CON
0015 STA 0600 0039 STA 0600
0016 LD 1002 0040 LD 1008
0017 LDA $005B 0041 LDA $007F
0018 CON 0042 CON
0019 STA 0600 0043 STA 0600
0020 LD 1003 0044 LD 1009
0021 LDA $004F 0045 LDA $006F
0022 CON 0046 CON
0023 STA 0600 0047 STA 0600
Example
0000 DM0000 DM0001
LDA TBCD STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 @TBCD
0004 CON
0005 @STA DM0001
2 0006 LD 0001
0007 LDA DM0010
0008 CON
0009 @TBIN
0010 CON
0011 @STA DM0011
Operands
Key operation
FUN
LDB LD ENT ENT
@ 4 7 R-SRCH R-SRCH
#,$ FUN
FUN
LDB AND ENT ENT
@ 4 8 R-SRCH R-SRCH
#,$ FUN
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.
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 con-
verted 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
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.
0001 #09999
C001 Sets C001.
0000
2002 C001 0700
LDA TBCD STA Converts current value of C001 into BCD data,
and outputs it to 0700 to 0715.
Coding
Line No. Instruction Operand
0000 LDB 0001
0001 C 001 #00009 0000
0002 LD 2002
0003 LDA C001
0004 CON
0005 TBCD
0006 CON
0007 STA 0700
Display
0600 to 0615 0500 to 0515
High-order 4 digits Low-order 4 digits
DM0101 0600
LDA TBCD STA
Coding
2 Line No.
0000
Instruction
LD
Operand
2002
Line No.
0010
Instruction
CON
Operand
Coding
Line No. Instruction Operand
0000 LD 2002
0001 LDA 0400
0002 CON
0003 TBIN
0004 CON
0005 STA C001
0006 LDB 0001
0007 C 001 #09999 0000
RES ANL
ASC: ASCII Convert FUN 0 2 : ASC
Converts contents of lower order byte
@ RES ANL of internal register into 2-digit ASCII
@ASC: ASCII Convert #,$ FUN 0 2 : ASC
code.
ORL ANL
RASC: Reverse ASCII Convert FUN 3 2 : RASC Converts 2-digit ASCII into byte data
representing 2-digit hex number.
@ ORL ANL
:
@RASC: Reverse ASCII Convert #,$ FUN 3 2 RASC
Example
0000 DM0000 DM0001
LDA ASC STA
Coding
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0000
0002 CON
0003 @ASC
0004 CON
0005 @STA DM0001
0006 LD 0001 12
0007 LDA DM0010
0008 CON
0009 @RASC
0010 CON
0011 @STA DM0011
Operands
Key operation
FUN
RES ANL ENT ENT
@ 0 2 R-SRCH R-SRCH
#,$ FUN
FUN
ORL ANL ENT ENT
@ 3 2 R-SRCH R-SRCH
#,$ FUN
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.
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 numeri-
cal 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
A 5
4 1 3 5
0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 1
0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1
3 6 4 3
2 6 C
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.)
ROOT: Square Root ORL ORB Takes square root of 32-bit data (TM00:
FUN 3 6 : ROOT
higher order byte, internal register: lower
@ROOT: Square Root @ ORL ORB order byte), and inputs result back to same
#,$ FUN 3 6 : ROOT
register.
Example
0000 DM0001 TM00 DM0000 DM0100
LDA STA LDA ROOT STA
Coding
Operands
Key operation
FUN
ORL ORB ENT ENT
@ 3 6 R-SRCH R-SRCH
#,$ FUN
A B 0500 C E B 0500
A
E
C D A E D
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 B 0500 A B 0500
C E 0500 C E
4. The circuit shown below left cannot be programmed. Modify it as shown on the
right.
A B C 0500 B C A 0500
D E D E
F F E
5. The circuit shown below left cannot be programmed. Modify it as shown on the
right.
A B 0500 C D B 0500
C D A
E 0501 C E 0501
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
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
0500
2 4. Make sure that illegal short-circuits are not generated in parallel connections.
0500
A B C
A B C 0500
D 0501
D 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.
Example
a)
Coding for normal input
Normal 0000 #00020 Line No. Instruction Operand
input T000
0000 LD 0000
0000
0500 T000 0500 0001 OR 0500
0002 TMR 00 #00020
(Input ON time: 10 ms min.) 0003 ANB T000
0004 OUT 0500
ENDH
Operands
0000 to 0003
CTC0 to CTC3
Key operation
SET ORL
EI: Interrupt Enabled FUN 1 3 EI
Enables execution of interrupt.
Visual KV
Series
Example 1000
EI
1000
DI
Coding
Line No. Instruction Operand
0000 LD 0000
0001 EI
• •
• •
• •
0021 LDB 1000
0022 DI
• •
• •
• •
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. 13
• Once an EI instruction is executed, an interrupt is enabled until a DI instruction is
executed.
• Any interrupt is disabled when the Visual KV Series starts operation.
• The DI instruction disables execution of an interrupt. Use this instruction to
temporarily disable an interrupt.
• The EI instruction enables execution of an interrupt. Use this instruction to
release an interrupt that was disabled by a DI instruction.
• To execute another interrupt during execution of the previous interrupt, include EI
instruction in this first interrupt. EI-DI instruction set can be nested to four levels.
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 ex-
ecuted, the stored INT CTC is deleted.
Operands
Key operation
RES AND
FUN 0 8 ENT ENT
R-SRCH R-SRCH
SET ORL
FUN 1 3
Chapter 3 Interrupts
3-193
Outline
Normally, a PLC processes a ladder sequence program by repeating the steps of
input processing, program execution, and output processing. Therefore, signals
which are shorter than the scan time cannot be received.
When the interrupt processing function is used, a process can be executed at the
instant of the interrupt, independent of the scan time.
When any interrupt occurs, the Visual KV series suspends the currently executed
program and executes the interrupt program in accordance with the interrupt factor.
When the interrupt program completes, the Visual KV resumes execution of the
suspended program.
➮ For more about scan time, refer to "1.1.2 Scan Time" (p. 3-3).
Input
processing
Direct input *
Interrupt input
(0000 to 0015)
Scan Program
3 time execution
Interrupt
processing
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 (KV-
10xx: 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. 3-
23).
2002
EI
2008 #00000 2813
EI DW SET or
DM1940 2002 HSP
0000
Visual KV
Series
Interrupt by an external input
This interrupt is executed by input relays 0000 through 0003. Use the special utility
relay to specify the polarity of the interrupt factor to a rising or falling edge.
CAUTION Use SET-RES instructions to turn the special utility relays ON/OFF.
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 high-
speed counter is automatically transferred to DM1928 through DM1935 when an
interrupt occurs.
External interrupt factor Description
Value of CTH0 is written to DM1928 (low-order bits)
Occurrence of INT0
and DM1929 (high-order bits)
Value of CTH0 is written to DM1930 (low-order bits)
Occurrence of INT1
and DM1931 (high-order bits)
Value of CTH1 is written to DM1932 (low-order bits)
Occurrence of INT2
and DM1933 (high-order bits)
Value of CTH1 is written to DM1934 (low-order bits)
Occurrence of INT3
and DM1935 (high-order bits)
Chapter 3 Interrupts
3-195
specified with special utility relays 2402 through 2405 and 2410 through
2413.
Note 1: While one interrupt is being executed, other interrupts are disabled. (Multi-
level interrupts are possible by placing an EI instruction within an interrupt routine.)
Note 2: When other interrupts occur during execution of an interrupt, other interrupts
are stored up to 8 levels deep. The stored interrupts are executed after completion
of the previous interrupt, according to the priority order. However, an interrupt which
uses the same device as a previous interrupt cannot be stored.
END
INT
0000
ENDH
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 inter-
rupt programs.
Visual KV
3.3.1 Direct Input
Series
The direct input function is used during interrupt processing. Direct input allows the
KV PLC to fetch the input status of the input relays during execution of the interrupt
program.
Direct input is available only with input relays 0000 through 0015 (KV-10xx: 0000-
0005, 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
13
0005 1000
SET
RETI
ENDH
2008
EI
2002 HSP
0000
HSP
0001
END
INT
0000
2002 0500
SET
RETI
INT
0001
2002 0501
SET
RETI
ENDH
Chapter 3 Interrupts
3-197
■ Outline
Converts the short pulses which are input by interrupt processing into pulses of a
constant width and then outputs them.
Scan
ON
Input 0000
OFF
ON
Output 0500 ON ON ON
OFF
1 sec. 1 sec. 1 sec.
■ 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.
3 • Output relay 0500 turns ON for 1 second from the rising edge of input relay 0000.
2008
EI When power is turned on, an EI
0001
instruction enables interrupts.
2002 HSP
0002 0000 Sets the input time constant of
input 0000 to 10 µs.
0500 #00010 T0000 0500
0003 T000 RES
Turns ON output 0500 for 1
END second and then turns it OFF.
0004
INT
0005 0002
When input 0000 turns
2002 0500 ON, output 0500 turns ON.
0006 SET
RETI
0007
ENDH
0008
Visual KV
Series
Scan
ON
Input 0004
OFF
ON
Input 0000
OFF
ON
Output 0500 ON
OFF
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.
INT
0007 CTC0 Executes an interrupt when the
input value of CTH0 reaches
2002 0500 "10000". Turns ON output 0500.
0008 SET
RETI
0009
ENDH
0010
Chapter 3 Interrupts
3-199
ON
Sensor input 0000
OFF
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
3 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).
END
0004
INT
0005 0000 • Turns ON input 0000 to execute an
interrupt.
2403 DM1928 TM02 KEEP
0006 LDA STA SET First, an interrupt is executed at the
2403 rising edge of input 0000. The
2403 DM1928 TM02 DM0000
0007 LDA SUB STA RES current value of CTH0 stored in
DM1928 is written to TM02. Turns
RETI ON special utility relay 2403 to
0008 change the interrupt polarity to the
falling edge.
ENDH
0009 Next, an interrupt is executed at the
falling edge of input 0000. The
value stored in TM02 is subtracted
from the current value of CTH0
stored in DM1928, and the
obtained ON width of input 0000 is
written to DM0000. Turns OFF
special utility relay 2403 to change
the interrupt polarity to the rising
edge.
Visual KV
Series
ON
Sensor 1 input 0002
OFF
ON
Sensor 2 input 0003
OFF
Visual KV
Sensor 1
Sensor 2
■ Ladder diagram 13
• 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).
2002 CTH1
0004 2200 • CTH1 counts the pulses using
a 1-µs internal clock.
END
0005
INT
0006 0002 • When INT2 is executed, the
current value of CTH1 is
RETI automatically transferred to
0007 DM1932 and DM1933 (Input
capture).
INT
0008 0003 • When INT3 is executed, the
current value of CTH1 is
2002 DM1934 DM1932 DM0000 automatically transferred to
0009 LDA SUB STA DM1934 and DM1935 (Input
capture).
RETI
0010 Subtracts the input capture
value of INT2 from that of INT3
ENDH to obtain the time it takes for
0011 the target to pass between two
points and then writes it to
DM0000.
Chapter 3 Interrupts
3-201
1. KV-300/Visual KV only
Example 2. Visual KV only
2008 HSP
0004
1)
2008 2103 CTH0
SET RES
#60000
3) CTC0
4
CTC0 0500
4) SET
Coding
Operands
CTH0: 0004
2100 to 2102
CTH1: 0005
0500
Visual KV
2200 to 2202
Series
CTC0 to 3: Preset value
#00001 to #65535
Key operation
RES
0 ENT
CTH Clock input
R-SRCH
SET
1
Preset ENT
CTC Operand value 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.
14
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.
Internal clocks* 16-bit high-speed Input capture device Special utility relay
2100 (1.0 µs) counter DM1928, DM1929(INT0) 2103 to 2114
2101 (10.0 µs) CTH0 DM1930, DM1931(INT1)
2102 (100.0 µs)
Control circuit 0500
External input high-speed high-speed
Phase A 0004 counter counter
0004/0006 comparator comparator INT CTC0
4 Phase B(0006)
CTC0 CTC1 INT CTC1
Internal clocks* 16-bit high-speed Input capture device Special utility relay
2200 (1.0 µs)
counter DM1932, DM1933(INT2) 2203 to 2214
2201 (10.0 µs) CTH1 DM1934, DM1935(INT3)
2202 (100.0µs)
0501
Internal connection
for external clock Control circuit
0500
Phase A high-speed high-speed
Phase B 0005 External input counter counter
0005/0007 comparator comparator INT CTC2
(0007)
CTC2 CTC3 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.
Visual KV
2102* Internal clock used only for CTH0 (100 µs)
Series
2103 Automatically clears CTH0 when comparator CTC0 turns ON. ON: Yes OFF: No
Disables/enables direct output from 0500 when comparator CTC0 ON: Disable
2104
turns ON. OFF: Enable
2105 Turns OFF direct output from 0500 when comparator CTC0 turns ON. ON: Yes OFF: No
2106 Turns ON direct output from 0500 when comparator CTC0 turns ON. ON: Yes OFF: No
Reverses ON/OFF status of output from 0500 each time comparator
2107 ON: Yes OFF: No
CTC0 turns ON.
Disables/enables direct output from 0500 when comparator CTC1 ON: Disable
2108
turns ON. OFF: Enable
2109 Turns OFF direct output from 0500 when comparator CTC1 turns ON. ON: Yes OFF: No
2110 Turns ON direct output from 0500 when comparator CTC1 turns ON. ON: Yes OFF: No
Reverses ON/OFF status of output from 0500 each time comparator
2111 ON: Yes OFF: No
CTC1 turns ON.
2112 Automatically clears CTH0 when comparator CTC1 turns ON. ON: Yes OFF: No
2113 Selects multiplication mode for CTH0.
OFF/OFF: No multiplication (1 pulse) ON/OFF: x2 OFF/ON: x4
2114 ON/ON: 2 pulses
* Read-only relay.
Multiplication No multiplication
x2 x4 2 pulses
mode (1 pulse)
2113 OFF ON OFF ON
2114 OFF OFF ON ON
Multiplication No multiplication
x2 x4 2 pulses
mode (1 pulse)
2213 OFF ON OFF ON
2214 OFF OFF ON ON
■ Data memory
DM No. Description
DM1900/DM1901 Current value of 24-bit CTH0 (low-order bits/high-order bits) is read.
DM1902/DM1903 Current value of 24-bit CTH1 (low-order bits/high-order bits) is read.
DM1904/DM1905 Current value of 24-bit CTC0 (low-order bits/high-order bits) is read.
DM1906/DM1907 Current value of 24-bit CTC1 (low-order bits/high-order bits) is read.
DM1908/DM1909 Current value of 24-bit CTC2 (low-order bits/high-order bits) is read.
DM1910/DM1911 Current value of 24-bit CTC3 (low-order bits/high-order bits) is read.
DM1912/DM1913 Current value of 24-bit CTH0 (low-order bits/high-order bits) is written.
DM1914/DM1915 Current value of 24-bit CTH1 (low-order bits/high-order bits) is written.
DM1916/DM1917 Preset value of 24-bit CTC0 (low-order bits/high-order bits) is written.
DM1918/DM1919 Preset value of 24-bit CTC1 (low-order bits/high-order bits) is written.
DM1920/DM1921 Preset value of 24-bit CTC2 (low-order bits/high-order bits) is written.
DM1922/DM1923 Preset value of 24-bit CTC3 (low-order bits/high-order bits) is written.
DM1924/DM1925 Preset value of CTH0 (low-order bits/high-order bits) is written.
DM1926/DM1927 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 16-
bit 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.
Visual KV
stant must be set to 10 µs with the HSP instruction or with special utility relay 2813.
Series
(Pulses with a maximum frequency of 30 kHz can be counted.)
Note 4: When using input 0004 as an operand, use input 0006 (KV-10xx: 0000) for
phase B input. Therefore, do not use input 0006 (KV-10xx: 0000) other than for the
high-speed counter.
Note 5: When selecting no multiplication mode, and you do not want to use input
0006 (KV-10xx: 0000) as phase B input, turn ON special utility relay 2407.
Note 6: When using input 0005 as an operand, use input 0007 (KV-10xx: 0001) for
phase B input. Therefore, do not use input 0007 (KV-10xx: 0000) other than for the
high-speed counter.
Note 7: When selecting no multiplication mode, and you do not want to use input
0007 (KV-10xx: 0001) as phase B input, turn ON special utility relay 2415.
Note 8: When using the high-speed counter internal connection relay 0500, only
single-phase input is available. In this case, external input relays 0005 and 0007 for
CTH1 can be used as normal input relays.
Note 9: When using phase differential input, 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.
Note 10: The current value of the high-speed counter is stored with a built-in,
electrical double-layer capacitor for more than two months at 25°C (KV-10xx: more
than 20 days). The value can also be stored in EEPROM.
➮ "3.5 System Mode" (p.1-94).
14
High-speed counter comparators
• 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 High-speed counter Preset value Direct
Interrupts
counter comparator range output
CTH0 CTC0, CTC1 0500 INT CTC0, INT CTC1
#1 to 65535
CTH1 CTC2, CTC3 0501 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.
tion.
Series
Visual KV
Series
specified with special utility relays.
➮ Refer to "4.4.1 24-bit High-speed Counter" (p. 3-221) when using the 24-bit high-speed counter.
High-speed
High-speed Special utility
counter Setting of special utility relay
counter relay
comparator
CTC0 2104 Turns output relay 0500 ON/OFF. OFF: Yes ON: No
CTH0
CTC1 2108 Turns output relay 0500 ON/OFF. OFF: Yes ON: No
CTC2 2204 Turns output relay 0501 ON/OFF. OFF: Yes ON: No
CTH1
CTC3 2208 Turns output relay 0501 ON/OFF. OFF: Yes ON: No
Three types of internal clocks are provided: 1 µs, 10 µs, and 100 µs.
Series
x2 ON OFF — ON OFF —
Phase differential
input
x4 OFF ON — OFF ON —
2-pulse method
ON ON — ON ON —
(Phase A: count up, phase B: count down)
4 ■ 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).
0004 OFF
(Phase B) ON
0006 OFF
(Counter value)
CTH0 0 1 2 3 2 1 0
(Phase A) ON
0004 OFF
(Phase B) ON
0006 OFF
(Counter value)
CTH0 0 1 2 3 4 5 6
Phase B input can be ignored by turning ON special utility relay 2407 (for CTH0) or
2415 (for CTH1).
Visual KV
(Phase B) ON
Series
0006 OFF
(Counter value)
CTH0
0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0
(Phase B) ON
0006 OFF
(Counter value)
CTH0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 5 4 3 2 1 0
(Counter value)
CTH1 0 1 2 3 4 5 6
CTC0 2103 When special utility relays 2103 and 2112 are
turned ON, the current CTH0 value is reset as
CTH0
soon as it matches the CTC0 or CTC1 preset
CTC1 2112 value.
CTC2 2203 When special utility relays 2203 and 2212 are
turned ON, the current CTH1 value is reset as
CTH1
soon as it matches the CTC2 or CTC3 preset
CTC3 2212 value.
Note: Do not specify the same values for CTC0 and 1 (2 and 3) to automatically
reset the counter with both comparators.
Scan
CTH
4 CTH = CTC
CTH is reset when CTH value equals CTC value.
CTH
* CTH is reset by the output process of the scan which executes the RES CTH
instruction.
Scan
Input-enable relay
for CTH instruction
CTH
* CTH is reset at execution of the CTH instruction during the scan after the input-
enable relay turns OFF.
Visual KV
or 2408 and 2409 (for CTH1) as follows.
Series
This reset operation is independent of the scan time.
High-speed
Relay No. Status Relay No. Status Operation
counter
OFF OFF Disables external reset operation.
Resets counter at rising edge of input
ON OFF
0008 (KV-10xx: 0002).
CTH0 2400 2401 Resets counter at falling edge of input
OFF ON
0008 (KV-10xx: 0002).
Resets counter when input 0008
ON ON
(KV-10xx: 0002) is ON.
OFF OFF Disables external reset operation.
Resets counter at rising edge of input
ON OFF
0009 (KV-10xx: 0003).
CTH1 2408 2409 Resets counter at falling edge of input
OFF ON
0009 (KV-10xx: 0003).
Resets counter when input 0009
ON ON
(KV-10xx: 0003) is ON.
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
DM1924 (low-order bits), DM1925 (high-order bits) Preset value for CTH0
DM1926 (low-order bits), DM1927 (high-order bits) Preset value for CTH1
Note 1: The preset function is available only with the external reset input. The CTH
value is reset to "0" with other resetting methods.
Note 2: Use the SET, RES instruction pair to set the special utility relays.
Note 3: When 16-bit high-speed counter is used, write the preset values into
DM1924 and DM1926 only.
Input-enable relay
0001 CTH0
0004
• 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 al-
ready 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.
Response frequency
The Visual KV Series provides a response frequency of 30 kHz.
Visual KV
is greater than that of 0004 and 0006 when 0004 and 0006 count "60000".
Series
Initial setting
2008 2113 2114 2213 2214 CTH0 SET 2113
EI SET RES SET RES RES Setting for CTH0
RES 2114
2002 HSP SET 2213
Setting for CTH1
0004 RES 2214
HSP
0005
HSP
0006 Sets input time constant of inputs 0004,
0005, 0006, and 0007 to 10 µs.
HSP
0007
0000 CTH0
0004 Phase differential input to inputs 0004 and
0006
#60000
CTC0 Specifies preset value of CTC0 to "#60000".
CTH1
0005 Phase differential input to inputs 0005 and
0007
END
INT
CTC0
2009 0500
SET Compares current value of CTH1 with
ENDH
2002 HSP
0005
0001 CTH1
0005
2002 CTH1 DM0000 2009 0500
LDA CMP
Cording
Cording
2008 2203 CTH1 Line No. Instruction Operand
SET RES
0000 LD 2008
2002 HSP 0001 SET 2203
0005
4 0002 CON
2002 CTH1
0003 RES CTH
0005
0004 LD 2002
#60000
CTC2 0005 HSP 0005
0006 LD 2002
CTC2 0502 #00030 T001 CTC2
T001 RES 0007 CTH1 0005
0008 CTC2 #60000
0009 LD CTC2
0010 OUT 0502
0011 CON
0012 TMR 001 #00030
0013 CON
0015 AND T001
0016 RES CTC2
Visual KV
output 0500, and stops counting at CTH0.
Series
• Input relay 0008 is used as an external reset.
0500 CTH0
0004
#60000
CTC0
END
INT
CTC0
2002 0500
SET
RETI
ENDH
Cording
Line No. Instruction Operand Line No. Instruction Operand 14
0000 LD 2008 0016 HSP 0006
0001 EI 0017 HSP 0008
0002 CON 0018 LDB 0500
0003 SET 2103 0019 CTH 0 0004
0004 CON 0020 CTC 0 #60000
0005 SET 2113 0021 LD 2002
0006 CON 0022 LDA CTH0
0007 RES 2114 0023 CON
0008 CON 0024 STA DM0000
0009 SET 2400 0025 END
0010 CON 0026 INT CTC0
0011 RES 2401 0027 LD 2002
0012 CON 0028 SET 0500
0013 RES CTH0 0029 RETI
0014 LD 2002 0030 ENDH
0015 HSP 0004
● 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.
➡
Note : External reset input 0008 is set with hardware. Programming is not necessary
except for setting the external reset enable relays (2400 to ON and 2401 to OFF).
2002 HSP
0004
HSP
0006
HSP
0008
0000 CTH0
0004
2002 #00000 TM00 CTH0 #00002 0600
LDA STA LDA DIV TBCD STA
END
ENDH
Cording
● 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.
➡
Note : The external reset input 0008 is set with hardware. Programming is not
necessary except for setting the external reset enable relay (2400 to ON).
Visual KV
Series
4.4.1 24-bit High-speed Counter
Normally, the high-speed counter operates with 16 bits. You can operate the counter
with 24 bits (0 to 16777215) using special utility relays.
Set the 24-bit operation with the MEMSW instruction.
➮ "MEMSW instruction" (p. 3-92)
Write areas
DM No. Description DM No. Description
Low-order bits of current Low-order bits of preset
DM1912 DM1918
CTH0 value CTC1 value
High-order bits of current High-order bits of preset
DM1913 DM1919
CTH0 value CTC1 value
Low-order bits of current Low-order bits of preset
DM1914 DM1920
CTH1 value CTC2 value
High-order bits of current High-order bits of preset
DM1915 DM1921
CTH1 value CTC2 value
Low-order bits of preset Low-order bits of preset
DM1916 DM1922
CTC0 value CTC3 value
High-order bits of preset High-order bits of preset
DM1917 DM1923
CTC0 value CTC3 value
The high-speed counter and high-speed counter comparator update the contents of
the read area of data memory each scan time.
At the start of an interrupt routine, the current value is updated. The contents of the
write area of data memory is updated with the data write operation.
➮ "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)
Visual KV
Series
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.
2. Change the preset value of CTC. (See the notes on the next page.)
4 • With the Access Window
Call CTC in device mode and change the value.
• With the "KV IncrediWare (DOS)" programming support software
Change the preset value of CTC with the "Edit Device CTC" [F2] option.
• With the "LADDER BUILDER for KV" programming support software
Change the preset value of CTC in the dialog box.
• With the KV-P3E(01) handheld programmer
Change the preset value of CTC with the "TIMER COUNTER SETTING
CHANGE" function.
➮ 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).
Visual KV
following procedure.
Series
1. Write the desired current value into data memory.
Write the desired current value to the CTH current value write areas DM1912
through DM1915.
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 in-
14
struction.
MEMSW
0001 $0800 1)
2002 CTH0
0004 0004 4)
#65535
0005 CTC0 5)
ENDH
0008
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
4 counter comparator (CTC0) and sets the value with the STA CTC0 instruction.
3) Sets the input time constant of input relay 0004 to 10 µs.
4) Counts pulses at input relay 0004 with high-speed counter CTH0.
5) Defines a dummy high-speed counter comparator.
6) Reads the current value of CTH0 into data memory DM0000 (low-order bits) and
DM0001 (high-order bits) each scan time.
Visual KV
■ Operation of the ring counter function
Series
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).
When CTH0 is used Set "upper limit value + 1" to CTC1. Turn ON 2406.
14
When CTH1 is used Set "upper limit value + 1" to CTC3. Turn ON 2414.
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 Does not turn ON.
CTH
0 1 2 97 98 99 0 1 2 2 1 0 99 98 97
0 9999
2002 CTH0
0004 0004 3)
#10000
0005 CTC1 4)
END
0007
4 0008
INT
CTC1
2002 0500
0009 SET 6)
RETI
0010
ENDH
0011
1) When the power is turned on, an EI instruction enables interrupts. Sets high-
speed 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.
Visual KV
Series
0 99999
MEMSW
0001 $0800 1)
2002 CTH0
0006 0004 5)
#65535
0007 CTC1 6)
0008
0500 #00010
T000
T000 0500
RES 7)
14
END
0009
INT
0010 CTC1
8)
2002 0500
0011 SET
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 high-
speed counter CTH0 in double (x2) multiplication mode, CTH0 as a ring counter,
and high-speed counter automatic reset function at counting up. Resets the high-
speed 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.
The internal clock of the high-speed counter is automatically set to 1 µs. Pulses with
duty ratio of 1:1 are output at the preset frequency obtained with the calculation
"1,000,000/2/Output frequency".
The KV performs the following operations after each scan time during the specified
frequency pulse output function.
• 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.
4 ON
OFF
Data memory
DM No. Description
DM1936 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.
Visual KV
• If an unacceptable frequency is specified, special utility relay 2307 (error relay)
Series
turns ON. Special utility relay 2306 is turned OFF and pulse output is stopped.
2002 0 DM1936 14
0002 TMIN STA 2)
2307 0500
0003 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.
speed with a start-up speed of 16 Hz and an acceleration speed of 100 Hz/100 ms.
2011 01
0006 CALL
2307 0500
0007 6)
0008 END
SBN
0009 00 7)
4 RET
0012
SBN 8)
0013 01
RET
0016
ENDH
0017
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 subrou-
tine 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".
Visual KV
Series
input) is ignored.
Data memory
DM No. Description
DM1404 Measurement cycle (ms) of frequency counter [1 to 1000]
■ 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.
14
Frequency (Hz) = (100,000 x Pulse count)/Elapsed time (Unit: 10 µs)
■ 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.
2002 HSP
0002 0004 2)
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.
2002 HSP
0002 0004 2)
2307 0500
0004 4)
END
0005
ENDH
0006
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.
Visual KV
■ Devices used with the cam switch function
Series
Special utility relays
Relay No. Description
2314 Start relay
2315 Error relay
2715 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.
In-operation
relay
2715
Cam switch
Stopped Executed Stopped
function
▲ ▲
: Operation with the ladder program.
▲ ▲
: Operation automatically executed by the Visual KV.
Description: When start relay 2314 is turned ON, the Visual KV automatically turns OFF
start relay 2314 and turns ON in-operation relay 2715 to activate the cam
switch function. 14
When in-operation relay 2715 is turned OFF, the cam switch function is
stopped.
DM1468/DM1469 Angle at which 32nd relay turns ON/OFF (Unit: 0.1 deg.)
(0 to 65534)
DM1470 Reserved for system use
tion. If 360 is written in DM1401, and 60 is written in DM1406, the 1st relay is turned
Series
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.
4 Example 0500, 0600: Acceptable, 0501, 0610: Unacceptable
5. Specify the preset value at which the second relay turns ON into DM1408.
6. Specify the preset value at which the second relay turns OFF into DM1409.
7. Repeat steps 3 through 6 as many times as the number of relays to be used (32
relays max.).
8. Turn ON special utility relay 2314.
Visual KV
This relay automatically turns OFF when the cam switch function is activated.
Series
9. Turn OFF special utility relay 2715 to stop the operation.
Note 1: When the cam switch function is used, 32 relays from the relay No. speci-
fied with DM1400 is occupied for the function regardless of whether they are used or
not. As a result, these relays cannot be used for any other purpose.
Note 2: To use the cam switch mode, 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 3: When any improper value is set in data memory, the setting error occurs
and special utility relay 2315 turns ON.
Note 4: CTH0 and the frequency counter function cannot be used while the cam
switch function is being used.
Note 5: The cam switch function cannot be used when CTH0 is used in the ladder
program.
Note 6: Special utility relays concerning CHT0, CTC0/1, and the frequency counter
function cannot be used.
Note 7: The scan time is extended by a maximum of 16 ms when the cam switch
function is activated.
Note 8: The in-operation relay of the cam switch function (2715) remains ON even
when the mode is changed or the power is turned OFF.
Note 9: Use the END instruction to change relays or turn them ON/OFF.
Note 10: When the encoder is ON in cam switch mode while the KV is OFF, the
14
count may be shifted for the time between the start-up and phase Z input.
Note 11: The encoder count is stopped in cam switch mode while the Visual KV is
OFF. (While the Visual KV is ON, the count is continued even in PROGRAM mode.)
Note 12: When a value of 360° or more is specified as the preset angle for the cam
switch function, the value is converted into one within the range of 0 to 360° before
the control.
Example: When 500° is specified, it is converted to 140°.
HSP
0004 0006 4)
HSP
0005 0008 5)
END
0008
ENDH
0009
4 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° 90° DM1407
DM1413
120° DM1412
150° DM1412
Timing Diagram
DM1406 DM1407
ON
1st relay 0600 OFF
DM1408 DM1409
2nd relay 0601 ON
OFF
DM1410 DM1411
3rd relay 0602 ON
OFF
DM1412 DM1413
4th relay 0603 ON
OFF
This section describes the outline and setting method for direct clock pulse output.
Visual KV
4.6.1 Outline of Direct Clock Pulse Output
Series
Using the high-speed counter (CTH) and high-speed counter comparator (CTC), the
KV PLC can output clock pulses directly through output relays 0500 and/or 0501
without any delays caused by the scan time.
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 com-
parator (CTC).
The period of the clock pulse (frequency) can be changed with the program within
the following ranges.
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 14
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 High-
speed 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.
By using two high-speed counter comparators, you can change only the pulse width
Series
while keeping the pulse period constant, or change only the pulse period while
keeping the pulse width constant.
The following examples illustrate how the pulse width and period can be selected
with the high-speed counter comparator.
ON
OFF
Pulse width
Pulse period
Use the following calculation to obtain the pulse period from the frequency:
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 re-
sponse 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.)
Visual KV
■ Pulse period
Series
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
ON
OFF Pulse
width
Pulse period
OFF Pulse
width
Pulse period
Special utility relay (internal clock) Period Range of CTC preset value
14
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 high-
speed 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.
High-speed Special
Operation when CTH0 (current value)
counter utility
reaches CTC (preset value)
comparator relay
Automatically clears current value of
2103 ON: Yes OFF: No
CTH0
Visual KV
ON: OFF:
Series
CTC0 2105 Turns OFF direct output through 0500. ON: Yes OFF: No
ON: OFF:
2108 Disables/enables control of 0500.
Disable Enable
2109 Turns OFF direct output through 0500. ON: Yes OFF: No
CTC1 211 Turns ON direct output through 0500. 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.
CTC0 CTC0
CTC1
ON ON ON ON ON ON
Visual KV
disable the direct output.
Series
Operation of output relay 0501 when special utility relays are ON/OFF
High-speed Special Operation when CTH0 (current value)
counter
comparator utility relay reaches CTC (preset value)
Automatically clears current value
2203 of CTH1 ON: Yes OFF: No
Note: If two or more relays of special utility relays 2204 through 2207 or 2208
through 2211 are turned ON, priority is given to the relay with the smaller number.
CTC2 CTC2
CTC3
ON ON ON ON ON ON
■ Example
Count value
2008 2103 2104 2105 2106 2107 CTH0
0001 SET RES RES RES SET RES
CTC0
2002 CTH0
0002 2101
#00050
0003 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.
Cording
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0008 CON
0001 SET 2103 0009 SET 2107
0002 CON 0010 CON
Visual KV
0003 RES 2104 0011 RES CTH0
Series
0004 CON 0012 LD 2002
0005 RES 2105 0013 CTH 0 2101
0006 CON 0014 CTC 0 #00050
0007 RES 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.
■ Example
Series
Count value
2008 2203 2204 2205 2206 2207 CTH1
0001 SET RES RES RES SET RES
CTC2
2002 CTH1
0002 2201
#00050
0003 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. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0008 CON
0001 SET 2203 0009 SET 2207
0002 CON 0010 CON
0003 RES 2204 0011 RES CTH1
4 0004 CON 0012 LD 2002
0005 RES 2205 0013 CTH 1 2201
0006 CON 0014 CTC 2 #00050
0007 RES 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.
Visual KV
This section describes a programming example that will output a clock pulse with
Series
variable ON/OFF ratio from output relay 0500 by using the high-speed counter
(CTH0) and high-speed counter comparator (CTC0 and CTC1).
Obtain the preset values of CTC0 and CTC1 by substituting 200 µs for the pulse
width, 500 µs for the pulse period, and 10 µs for the internal clock (special utility
relay 2101).
In this case, the preset value of CTC1 is "20", and that of CTC0 is "50". 14
Refer to the following table for the CTC preset values with other internal clocks.
Special utility relay Internal clock CTC0 preset value CTC1 preset value
2100 1.0 µs 500 200
2101 10.0 µs 50 20
2102 100.0µs 5 2
■ Example
Count value
2008 2103 2104 2105 2106 2107
0001 SET RES RES SET RES
#00020
0005 CTC1
• 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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0013 CON
0001 MPS 0014 SET 2109
0002 SET 2103 0015 CON
Visual KV
Series
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.
4 • 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.
• 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.3-
212).
To output a clock pulse of 500 µ s (2 kHz)-period and 200 µ s-width from output relay 0501
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).
Visual KV
■ Special utility relay setting
Series
Set the special utility relay (2203 through 2212) according to the following table.
Obtain the preset values of CTC2 and CTC3 by substituting 200 µs for the pulse
width, 500 µs for the pulse period, and 10 µs for the internal clock (special utility
relay 2201).
In this case, the preset value of CTC3 is "20", and that of CTC2 is "50".
Refer to the following table for the CTC preset values with other internal clocks.
Special utility relay Internal clock CTC2 preset value CTC3 preset value 14
2200 1.0 µs 500 200
2201 10.0 µs 50 20
2202 100.0 µs 5 2
■ Example
Count value
2008 2203 2204 2206 2207
0001 SET RES SET RES
#00020
0005 CTC3
• 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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0012 SET 2209
0001 MPS 0013 CON
0002 SET 2203 0014 RES 2210
Visual KV
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.
4
When SET-RES instructions are used When KEEP instruction is used
• 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.
Visual KV
10000 pulses are output.
Series
■ Special utility relay, internal clock, and CTC settings
Set the special utility relay according to the following table.
Relay No. Setting Relay No. Setting
2103 ON 2108 OFF
2104 OFF 2109 ON
2105 OFF 2110 OFF
2106 ON 2111 OFF
2107 OFF 2112 OFF
Specify the internal clock and CTC0/CTC1 preset values according to the following
table.
Special utility relay Internal clock CTC0 preset value CTC1 preset value
2100 1.0 µs 500 200
2101 10.0 µs 50 20
2102 100.0 µs 5 2
■ Example
2008 2103 2104 2105 2106 2107
0001 EI SET RES SET SET RES
0000
DM1940
1000 1000 2105
14
0004 DIFU RES
2002 CTH0
0005 2101
#00050
0006 CTC0
#00020
0007 CTC1
2002 CTH1
0008 0500
#10000
0009 CTC2
END
0010
INT
0011 CTC2
2002 2105
0012 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.
• 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
Visual KV
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0024 SET 2203
0001 EI 0025 CON
0002 CON 0026 DW #00000 DM1940
0003 MPS 0027 CON
0004 SET 2103 0028 SET 2813
0005 CON 0029 CON
0006 RES 2104 0030 RES CTH1
0007 CON 0031 LD 0000
0008 SET 2105 0032 DIFU 1000
0009 CON 0033 CON
0010 SET 2106 0034 AND 1000
0011 CON 0035 RES 2105
0012 RES 2107 0036 LD 2002
0013 MRD 0037 CTH 0 2101
0014 RES 2108 0038 CTC 0 #00050
0015 CON 0039 CTC 1 #00020
0016 SET 2109 0040 LD 2002
0017 CON 0041 CTH 1 0500
0018 RES 2110 0042 CTC 2 #10000
4 0019 CON 0043 END
0020 RES 2111 0044 INT CTC2
0021 CON 0045 LD 2002
0022 RES CTH0 0046 SET 2105
0023 MPP 0047 RET1
0048 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 2103 2104 2105 2106 2107 2008 $0268 2100 CTH0 2203 2813 CTH1
EI SET RES SET SET RES EI LDA STA RES SET SET RES
• LDA $0268
When LDA $0268 is executed, the value specified by the operand is written into
the internal register as follows.
[0] [2] [6] [8]
Internal register
0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0
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 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0
Visual KV
y
Series
nc
tpu e
sto erge
ou vers
t
rt
Em
Re
Sta
p
24 VDC
–
+
Stepping motor driver
Twisted-pair cable
+
– CW (Pulse)
COM 0001 0003
0000 0002
+
KV – CCW (Rotation
0500 0502 direction)
COM 0501 0503
5 VDC
– + FG Stepping motor
■ Setting parameters
Specify values in the range from 153 Hz to
DM0000: fH [Hz] (Running frequency)
➞ 50000 Hz. The fH value must be greater
DM0001: fL [Hz] (Start-up frequency) than the fL value.
DM0002: Acceleration rate [Hz/10 ms] ➞ (fH - fL) / (Acceleration time / 10 ms)
DM0003: No. of pulses for positioning ➞ Must be 65534 pulses or less.
Note 1: A smaller acceleration rate allows smoother control but extends the accel- 14
eration 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
Acceleration for positioning
rate (DM0003)
(DM0002)
L 10ms
(DM0001) (Acceleration
change period)
0 Time (ms)
Acceleration Constant Deceleration
time speed time time
■ Example
Specifies high-speed
0001 counters and comparators
2002 #00010 #65535 CTH0
0002 CTC1 CTC0 2100
• CTC0 generates a clock pulse.
#65535 #65535 CTH1
0003 CTC2 CTC3 0500 • CTH1 counts the number of
Visual KV
0001 0502
0009 • Sets reverse output.
0013
Calculation routine for
CTC0, CTC2, and DM0011
SBN
0014
• Specifies the CTC0 preset value.
02
CTC0 preset value =
2002 #01000 #10000 DM0012 #00005 #00010 CTC0 DM0010 1 ÷ DM0012 x 103 x 103
0015 LDA MUL DIV ADD DIV STA STA
RET
0025
INT
0038 • Clock pulse output is stopped when
CTC3
the No. of pulses equals the CTC3
2002 2105 preset value.
0039 SET
RETI
0040
ENDH
0041
This chapter describes ramp-up/down control of stepping motors and servo motors.
The Visual KV Series can directly output clock pulses not affected by the scan time
to output relay 0502.
If the frequency, the number of output pulses, and the acceleration time of the clock
pulses have been preliminarily set to data memories, the Visual KV Series automati-
cally performs ramp-up/down control.
The ramp-up/down control output function offers ramp-up/down timing charts of the
startup frequency, operating frequency, acceleration time, and deceleration time as
shown below.
The output frequency can be set within the range of 200 to 50,000 Hz.
Operating
frequency
DM1481
Startup
frequency
DM1480
Time (ms)
5 Acceleration
time DM1482
Deceleration
time DM1482
Clock pulse
Rotation direction
Lo: CW
0502 Hi: CCW
Stepping motor
NEW KV 0503 Servo motor
Motor driver
Visual KV
Series
ing control.
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). 15
Set value error code (DM1486)
If there is an error in the preset parameters when starting operation, a corresponding
error code (11 to 17) is automatically written to DM1486.
Note: If the startup frequency is the same as the operating frequency, the timing
Visual KV
Operating (startup)
frequency
Operating frequency
Acceleration/deceleration time
5
Number of output pulses (DM1484 and DM1485)
Set the angle of rotation (movement quantity) in positioning control as the number of
pulses. The Visual KV Series outputs as many clock pulses as the set value.
If the number of output pulses is larger than 65,535, divide it into the upper 16-bit
value and the lower 16-bit value using the following equation.
The minimum value is 2, and maximum value is 4,294,967,295.
Note 1: When the set number of pulses is too small and the target value cannot be
achieved, triangular control is performed as shown below.
Operating frequency
Startup frequency
0
Visual KV
Series
Special utility
R/W* Function Description
relay No.
Performs deceleration at rising edge, then stops
2308 W Stop
operation.
Remains ON while pulses are output.
R Run
2309 Stops operation immediately when being reset in an
W RESET
interrupt program.
2310 W Start Starts up operation at rising edge.
* R: Read W: Write
■ Operation chart
ing ramp-up/down control using the positioning control function of the Visual KV
Series.
p
rt
Sto
Em
Sta
24 VDC
–
+ Stepping motor driver
5 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.
Visual KV
When start switch 0000 is set to ON, output 0502 starts to output 100,000 pulses
Series
with a startup frequency of 500 Hz, operating frequency of 10 kHz, and acceleration/
deceleration time of 3 seconds.
When input 0001 is set to ON, pulse output is decelerated and stopped.
When input 0002 is set to ON, pulse output is immediately stopped.
Speed (Hz)
1000
500
■ Program example
2008 Permit interrupts when operation is
0001 EI started (so that emergency stop
operations are available).
2002 HSP
0002 0002 Set the input time constant of input
0002 to 10 µs.
0000 #00500 #10000 #03000 #00001 #34464 2310
0003 DW DW DW DW DW Set each parameter, and start pulse
DM1480 DM1481 DM1482 DM1485 DM1484 output at the same time.
0001 2308
0004 Decelerate and stop pulse output.
END
0005
INT
15
0006 0002 Perform emergency stop processing
by using an interrupt program.
2002 2309
0007 RES
RETI
0008
ENDH
0009
Speed (Hz)
CW direction CCW direction
Visual KV
1000
Series
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
END
0006
ENDH
0007
Visual KV
return movements. This type of operation is suitable for, for example, a job where
Series
workpieces to be supplied are located in one position and a moving body picks up
the workpieces and positions them little by little at a certain interval.
Speed (Hz)
5000
0 Coordinate (pulses)
Point 1: 10,000
500 Point 2: 12,000
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. After-
wards, 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
0016 When operation has completed, output 500 remains ON for 3 seconds.
ENDH
0019
Range detected by
zero point sensor
Visual KV
Series
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
0002
Zero point sensor: 0003 Start signal: 0000 Pulse output: 0502
Rotation direction: 0503
2008
0004 EI
2002 HSP
0005 0003
0009 When the zero point sensor turns ON, moves at low speed in the CW direction.
1006 2309 2308 #00200 #10200 #00500 #00000 #65535 2413 0503
0010 RES DW DW DW DW DW SET SET
DM1480 DM1481 DM1482 DM1485 DM1484
1005 2309 1007 1007 2310
0011 DIFU
1006
0012
END
0013
Detects the rising/falling edge of the zero point sensor (003), stops, and
0014
then changes direction.
INT
0015 0003
RETI
0018
ENDH
0019
Speed (Hz)
10000
Visual KV
7000
Series
5000
500
0 250000 320000 460000 Coordinate
(pulses)
Wait Wait
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 Ladder for automatic operation (continuous operation with wait status)
0002 Start signal: 0000 Pulse output: 0508 Rotation direction: 0503
0007
Moves to point 2 at speed of 5 kHz. Acceleration/deceleration time: 1 second
Moving quantity: 70,000 pulses
1001 2309 1400 0001 1301
0008 STG
1400 1301 15
0009
0011
Moves to point 3 at speed of 7 kHz. Acceleration/deceleration time: 1 second
0013
ENDH
0018
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
0001 Pulse motor application circuit (with zero point sensor, forward
limit switch, and backward limit switch)
0002 Specifications
0004 Manual switch: Forward = 0008, backward = 0009 Zero point switch:
0005 0007
0006
2008 1200
0008 RES EI
2002 HSP
0009 0000
HSP
0010 0002
Visual KV
0018 Move forward.
Settings for forward
Series
1205 0503 #00300 #03000 #00250 #00000 #03500 1300 1200 movement
0019 SET DW DW DW DW DW DIFU SET
DM1480 DM1481 DM1482 DM1485 DM1484 • Startup frequency: 300 Hz
• Operating frequency: 3 kHz
0020 Trigger end of forward movement • Acceleration time: 250 ms
• Number of output pulses:
1200 2309 1201 2309 1202 1203
0021 ON OFF DIFU 3,500
1201 1202 Settings for backward
0022 While moving backward at low speed, return to zero point. movement
• Drive frequency: 500 Hz
1203 0503 #00500 #00500 #00000 #00000 #65535 1301 1200 • Operating frequency: 500 Hz
0023 RES DW DW DW DW DW DIFU RES
DM1480 DM1481 DM1482 DM1485 DM1484 • Acceleration time: 0 ms
• Number of output pulses:
0024 Start up motor. 65,535
1300 0006 2310
0025 Give instructions to start up
and decelerate/stop the
1301 0004
0026 motor.
1103
0027
1506 2308
0028
0004 0008
0031
1105
0032
0035
2008 1400
SET 15
2308 1408 1408 1401 1402 1403 1400
0036 DIFU RES RES RES SET
END
0051
RETI
0055
ENDH
0056
Input processing
KV-300
KV-10/80
t
rup Processing of
inter
direct inputs
Scan time
of
ion
rat (00000 to 00005)
ne
Ge
Routine program Interrupt routine
execution Re execution
tu
at rns
the to
po sus Processing of
int pe
of nd direct outputs
su ed
sp pr (00500 to 00503)
en og
sio ram
n.
Output processing
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 sus-
pended to immediately execute the interrupt routine.
6 During execution of interrupt routine, input signals shorter than one scan time can be
received by the PLC.
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.
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-300
KV-10/80
Note 1: During execution of one interrupt routine, execution of other interrupt rou-
tines 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.
Interrupt routine
2008 2813
EI SET
END
INT
XXXXX
RETI
ENDH
16
• Execute EI to enable interrupt.
• Be sure to insert INT between END and ENDH.
• Be sure to shorten the input time constant by using HSP or by turning ON special
utility relay 2813.
Direct output
2008 2813
EI SET
END
INT
0000
2002 0500
( SET )
RETI
KV-300
INT
KV-10/80
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 2813
SET
1000 0500
END
6 INT
0000
0005 1000
RETI
ENDH
Note 1: Be sure to turn ON special utility relay 2813 to shorten the input time
constant.
Note 2: Input status read using direct input function is valid only in the interrupt
routine. Be sure to insert an internal utility relay after the direct input relay.
Key operations
KV-300
FNC
KV-10/80
1 3
Operand
Example
1000
EI
1000
DI
Coding
Line No. Instruction Operand
0000 LD 1000
0001 EI
: :
0021 LDB 1000
0022 DI
: :
Description 16
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 instruc-
tion.
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.
Key Operations
FNC ANL RES ENT Operand ENT
2 0 R-SRCH R-SRCH
KV-300
3 4 R-SRCH 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 #00020
Input for T000
routine
program 0500 T000 0500
0000
(b) 2008
2813
Input for
interrupt EI SET
routine 1000 #00020
0000 T000
0500 T000 0500
END
6
INT
0000
2002 1000
RETI
ENDH
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.
Example 2
KV-300
KV-10/80
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 Executes interrupts at falling edge of Executes interrupts at rising edge of
input pulse to 0003. input pulse to 0003.
END
INT
3 0003
2206 TM30
LDA
TM02
STA
KEEP
SET (a)
16
2206
4 2206 TM30 TM02 DM0000
LDA SUB STA RES (b)
RETI
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0014 CON
0001 EI 0015 STA TM02
0002 CON 0016 CON
0003 LDA $0000 0017 LD 2206
0004 CON 0018 LDA TM30
0005 STA 2200 0019 CON
0006 CON 0020 SUB TM02
0007 STA DM0000 0021 CON
0008 LD 2002 0022 STA DM0000
0009 CTH 1 2200 0023 CON
0010 END 0024 KEEP 2206
0011 INT 0003 0025 RETI
0012 LDB 2206 0026 ENDH
0013 LDA TM30
■ 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.
• The value of DM0000 is reset to "0".
• Turning ON special utility relay 2813 changes the input time constant to 10 µs.
• 1.0-µs internal clock pulses are counted using CTH1.
• INT instruction with 0003 as the operand allows interrupts to be executed.
KV-300
KV-10/80
• 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 2203 CTH1 #05000 2813
1 EI SET RES CTC2 SET
2002 CTH1
2 0005
0000 0501
3 RES
END
6 INT
CTC2
4
2002 0501
5 SET
RETI
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0010 LD 2002
0001 EI 0011 CTH 1 0005
0002 CON 0012 LD 0000
0003 SET 2203 0013 RES 0501
0004 CON 0014 END
0005 RES CTH1 0015 INT CTC2
0006 CON 0016 LD 2002
0007 CTC 2 #05000 0017 SET 0501
0008 CON 0018 RETI
0009 SET 2813 0019 ENDH
■ Initial setting
• When the operation is started, EI instruction enables interrupts.
• Turning ON special utility relay 2203 allows CTC2 to reset the CTH1 current
value to 0.
• The CTH1 current value is reset to 0.
• The CTC2 preset value is set to 5000.
• Turning ON special utility relay 2813 changes the input time constant to 10 µs.
• Pulses input to 0005 are counted using CTH1.
• When input 0000 turns ON, output 0501 is reset.
KV-300
KV-10/80
• INT CTC2 is used to execute the interrupt. (Interrupt routine is executed when
the CTH1 current value and CTC2 preset value are equal.)
• Immediate output to 0501 is performed.
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
0008 (RESET)
KV-300
KV-10/80
0: UP edge 1: DOWN edge
2207 Reverse output (toggle) level
1: ON 0: OFF
2208 Direct output to 0501 Direct output level to 0501 through comparator
1: Disable 0: Enable CTC3 (any one of these is ON)
2209 Turns OFF output to 0501.
1: Yes 0: No
2210 Turns ON output to 0501.
1: Yes 0: No
2211 Reverses output (toggle) to 0501.
1: Yes 0: No
2212 When comparator CTC3 is ON, automatically clears CTH1.
1: Yes 0: No
2213 Uses CTH1 in magnification mode.
1: Yes 0: No
2214 Selection of magnification mode for CTH1
1: x 4 0: x 2
2215 Enables external reset for CTH1.
1: Yes 0: No
3. Special utility relays of 2112, 2113, 2114, 2115, 2212, 2213, 2214, and 2215
are not available.
6 High-speed
counter
High-speed
counter
Range of
setting value
Output Interrupt
comparator
CTH0 CTC0 0 TO 65535 0500 INT CTC0
CTC1 INT CTC1
CTH1 CTC2 0501 INT CTC2
CTC3 INT CTC3
* KV-10/80 : 10 kHz
KV-300
The KV PLC can output clock pulses through 0500 and/or 0501 without any delays
KV-10/80
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.
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
CTH current value (count value)
0500 ON
0501
OFF
ON/OFF of output relay 0500/0501 depends on the setting of the special utility
CAUTION relay. ➮ Refer to page 3-281.
• Change CTC0 preset value to change the pulse width and period.
6 Pulse period
The pulse width determined as above is used to pulses generated from the
CAUTION
KV-300 CPU.
Pulses are output through the output circuit. The pulse width varies depend-
ing on the response delay from the output circuit and influence of the con-
nected load. Before setting the pulse width, you should measure the actual
waveform using an oscilloscope. (Use pulses with variable pulse width.)
• To obtain the pulse cycle from frequency, use the following expression:
Pulse cycle (µs) = 1000 ÷ Frequency (kHz)
KV-300
2104 Disables output to 0500.
KV-10/80
2105 Outputs OFF to 0500
2106 Outputs ON to 0500.
2107 Inverts output to 0500.
CTC1 2112 Automatically clears current value of CTH0.
2108 Disables output to 0500.
2109 Outputs OFF to 0500
2110 Outputs ON to 0500.
2111 Inverts output to 0500.
■ 16-bit high-speed counter (CTH1) and special utility relays (2203 to 2205,
2208 to 2212)
By setting the special utility relays 2204 to 2205 and 2208 to 2212 at startup or
changing these relays during generation of clock pulse, you can select ON/OFF of
output relay 0501 as listed below.
These special utility relays also allow you to set the pulse cycle
Pulse status at CTH1 (current value) = CTC (preset value)
Comparator No. Relay No. Pulse status at ON.
CTC2 2203 Automatically clears current value of CTH0.
2204 Disables output to 0501.
2205 Outputs OFF to 0501
KV-300
KV-10/80
ON
OFF
KV-300
Pulse
KV-10/80
width
Pulse cycle
ON
OFF
Pulse
width
Pulse cycle
• When setting 2100 or 2200 for the operand of High-speed counter CTH, set
CAUTION 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. 16
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.
➮ * Refer to page 3-276.
Special utility relays 2103 to 2112 are set as shown on the right table.
KV-10/80
The program can be simplified using reverse output (toggle) for pulse with 1:1 ON/
OFF ratio.
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 OFF
2106 OFF 2110 OFF
2107 ON 2111 OFF
Programming example
2008 2103 2104 2105 2106 2107 CTH0
CTH0 value
0001 SET RES RES RES SET RES
CTC0
2002
CTH0
0002 2101
ON
#00050
0003 OFF
CTC0
• 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.
➮ * Refer to page 3-276.
Coding
Line No. Instruction Operand
0000 LD 2008
0001 SET 2103
0002 CON
0003 RES 2104
0004 CON
0005 RES 2105
0006 CON
0007 RES 2106
KV-300
0008 CON
KV-10/80
0009 SET 2107
0010 CON
0011 RES 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/
CAUTION 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
2201 10.0 µs 50
2202 100.0 µs 5
Programming example
2008 2203 2204 2205 2207 CTH1 CTH1 value
0001 SET SET RES SET RES CTC2
2002
CTH1
0002 2201 ON
#00050 OFF
0003 CTC2
• 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.
6
Coding
Line No. Instruction Operand
0000 LD 2008
0001 SET 2203
0002 CON
0003 SET 2204
0004 CON
0005 RES 2205
0006 CON
0007 SET 2207
0008 CON
0009 RES CTH1
0010 LD 2002
0011 CTH 1 2201
0012 CTC 2 #00050
When start/stop of clock pulse is controlled by the input relay which enables/
CAUTION 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.
SET/RES Instructions KEEP Instructions
KV-300
KV-10/80
0000 2204 0000
KEEP
SET SET
2204
0000 2204 0000
RES RES
Programming example
2008 2103 2104 2105 2106 2107
0001 SET RES RES SET RES
CTH0 value
2108 2109 2110 2111 CTH0
0002 CTC0
RES SET RES RES RES
2002 CTC1
CTH0
0003 ON
2101
OFF
#00050
0004 CTC0
#00020
0005 CTC1
• The status of output 0500 is set by turning ON one of the relays 2104 to 2107
KV-300
KV-10/80
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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0013 CON
0001 MPS 0014 SET 2109
0002 SET 2103 0015 CON
0003 CON 0016 RES 2110
0004 RES 2104 0017 CON
0005 CON 0018 RES 2111
0006 RES 2105 0019 CON
0007 CON 0020 RES CTH0
0008 SET 2106 0021 LD 2002
0009 CON 0022 CTH 0 2101
0010 RES 2107 0023 CTC 0 #00050
0011 MPP 0024 CTC 1 #00020
6 0012 RES 2108
When start/stop of clock pulse is controlled by the input relay which enables/
CAUTION 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
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.
■ When outputting clock pulse with cycle 500 µs (2 kHz) and pulse width 200
µs from 0501
This program example shows how to output clock pulse with variable ON/OFF ratio
from 0501, through High-speed counter CTH1 and High-speed counter comparator
CTC2 and CTC3.
KV-300
KV-10/80
2205 ON 2209 ON
2206 OFF 2210 OFF
2207 OFF 2211 OFF
Programming example
16
2008 2203 2204 2205 2207
0001 SET SET SET RES CTH1 value
2208 2209 2210 2211 CTH1 CTC2
0002 RES SET RES RES RES CTC3
2002
CTH1 ON
0003 2201 OFF
#00050
0004 CTC2
#00020
0005 CTC3
• 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.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0012 SET 2209
0001 MPS 0013 CON
0002 SET 2203 0014 RES 2210
0003 CON 0015 CON
0004 SET 2204 0016 RES 2211
0005 CON 0017 CON
0006 SET 2205 0018 RES CTH1
0007 CON 0019 LD 2002
0008 RES 2207 0020 CTH 1 2201
KV-300
When start/stop of clock pulse is controlled by the input relay which enables/
CAUTION 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
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.
Programming example
2008 2103 2104 2105 2106 2107
0001 EI SET RES SET SET RES
2108 2109 2110 2111 CTH0
0002 RES SET RES RES RES
2203 2813 CTH1
0003 SET SET RES
0000 1000 1000 2105
0004 DIFU RES
2002
CTH0
0005 2101
#00050
0006 CTC0
#00020
KV-300
KV-10/80
0007 CTC1
2002
CTH1
0008 0500
#10000
0009 CTC2
END
0010
INT
0011 CTC2
2002 2105
0012 SET
RET1
0013
ENDH
0014
• 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.
• Enables interrupt using the EI instruction.
Stops clock pulse using interrupt program (INT CTC2) when the current value of 16
High-speed counter CTH1 reaches the setting value of high-speed counter
comparator CTC2 (when 10000 pulses are output).
• 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 com-
parator CTC2.
• Turns ON input relay 0000 to start clock pulse output.
To restart clock pulse output after once stopped, turns ON input relay 0000
again.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0024 SET 2203
0001 EI 0025 CON
0002 CON 0026 SET 2813
0003 MPS 0027 CON
0004 SET 2103 0028 RES CTH1
0005 CON 0029 LD 0000
0006 RES 2104 0030 DIFU 1000
0007 CON 0031 CON
KV-300
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.
6 2008
EI
2103
SET
2104
RES
2105
SET
2106
SET
2107
RES
2008
EI
$0268 $2100
LDA STA
CTH0
RES
2203
SET
2813
SET
CTH1
RES
2108 2109 2110 2111 CTH0
RES SET RES RES RES
2203 2813 CTH1
SET SET RES
• LDA $0268
When LDA $0268 is executed, the following data is input to the internal register.
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.
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Special utility
relays 21** 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0
Connection example
The following chart shows an operation example when the KV-300 CPU is con-
nected 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".
ers
rt
ve
KV-300
Sta
KV-10/80
Re
–
KV-300 24 VDC Stepping motor driver
+
Frequency (Hz)
fH
(DM0000) Positioning
pulse total
Acceleration count
rate (DM0003)
(DM0002)
fL 10 ms
(DM0001) Acceleration
change time
0 Time (ms)
Acceleration time Constant
rate time
Deceleration time 16
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.
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.
Programming exmaple
0001 0502
0009 ( ) Reverse output
0003 2105
0011 (SET)
END
0012
SBN
0019 01
SBN
0023 03
RET
0025
INT
0027 CTC2
0028 SPEED-UP
KV-300
KV-10/80
2011 DM0003 DM0011
ON. When the current frequency
CTC2 DM0011
0031 LDA SUB STA STA
reaches fH, stops acceleration and
sets the deceleration pulse count.
1201 1200
0032 (RES )
0033 SPEED-UP
1200 DM0012 DM0002 DM0012 DM0001 2011 02
0034 LDA SUB STA CMP CALL Subtracts the acceleration rate from
2011 02
the current frequency to change
#65535 CTC2
0035 CALL LDA STA
frequency whenever CTC2 turns
ON while acceleration flag 1200 is
RETI OFF. When the current frequency
0036 reaches fL, stops deceleration and
initializes the settings.
0037 INTERRUPT FOR PULSE STOP
INT
When pulse count of clock pulses
0038 CTC3
equals the setting value of CTC3,
2002 2105 stops clock pulse output.
0039 (SET )
RETI
0040
ENDH
0041
16
Frequency (Hz)
Operation
Start
Output pulse count
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 Rotation direction
0500
0501 Lo : CW
Hi : CCW
0502
0503 Stepping motor
/servo motor
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.
DMNo. Parameter Allowable setting range
DM9407 Set value error code Code 11 to 17 or FFFF (-1)
is entered when error occurs
KV-300
KV-10/80
X-axis DM9408 0500 Start frequency (Hz) 153 to 50000
(0500) DM9409 0500 Run frequency (Hz) 153 to 50000
DM9410 0500 Acceleration/deceleration 0 to 4096
time (ms)
DM9411 0500 Output pulse count 0 to 65535
(high-order 16 bits)
DM9412 0500 Output pulse count 0 to 65535
(low-order 16 bits)
Y-axis DM9413 0501 Start frequency (Hz) 153 to 50000
(0501) DM9414 0501 Run frequency (Hz) 153 to 50000
DM9415 0501 Acceleration/deceleration 0 to 4096
time (ms)
DM9416 0501 Output pulse count 0 to 65535
(high-order 16 bits)
DM9417 0501 Output pulse count 0 to 65535
(low-order 16 bits)
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) [ms] = (acceleration time [ms] + 199) ÷ 200 x 4
or
Pulse change cycle (∆t) [ms] = 1000 ÷ (run frequency [Hz] ÷ 1000)
Run
Start ∆t
Note: When the start frequency equals the run frequency, the system operates as
shown in the following chart.
Preset frequency
0
Here, the acceleration/deceleration time is ignored. The output count should be less
than 65535.
KV-300
KV-10/80
■ Output pulse count
Sets the positioning control rotation angle (moving distance) with the pulse count.
The KV-300 CPU outputs as many clock pulses as specified. If the output pulse
count is greater than 65535, set the pulse count separately for high-order 16 bits
and low-order 16 bits based on the following expressions.
Note: When the specified output pulse count is insufficient and does not reach the
target value, the KV-300 CPU performs triangular control.
Run frequency
Start frequency
0
Procedure
When the positioning control function is used, the KV-300 CPU controls start, stop,
16
and emergency stop by turning ON/OFF the utility relays. The table below shows the
operations and assigned utility relays.
DM9409
DM9408: Start frequency (Hz)
DM9409: Run frequency (Hz)
DM9408 DM9411 DM9410: Acceleration time (ms)
DM9412 DM9411: Output pulse count
0 (high-order 16 bits)
DM9410 DM9410
DM9412: Output pulse count
(low-order 16 bits)
When 2310 turns ON, clock pulse is output.
2310 (rising [UP] edge is detected.)
(START) 2309 is ON during clock pulse output. When
KV-300
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; other-
wise, 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.
p
e
rt
Sto
Em
Sta
–
24 VDC
+
KV-300 Stepping motor driver
0500 7
0501 8
0502 9 Stepping motor
0503 10 24 VDC
COM 20
– +
FG
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.
Enables interrupt when starting operation.
2008
0001 This is required to allow emergency stop
EI
operation.
0002 #01000 #05000 #03000 #00001 #34464 2310
0002 DW DW DW DW DW Sets parameters and simultaneously
0001 DM9408 DM9409 DM9410 DM9411 DM9412 2308 starts pulse.
0003 Decelerates and stops pulse.
KV-300
KV-10/80
END
0004
INT Executes emergency stop sequence with
0005 0000
interrupt progaram.
2002 2309
0006 RES
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).
Program example
0002 SPECIFICATION
0006
* * * * * * * * * * * * * * * * * * * * * * * * * * ORIGIN * * * * * * * * * * * * * * * * * * * * * * * * * * * *
For forward operation, the following
0015
parameters are set:
Start frequency: 300 Hz,
0016 LIMIT SWITCHES Run frequency: 3 kHz,
0007 1205 Acceleration/decekeratuib time: 250 ms,
0017 DIFU Output pulse count: 3500.
1103
0027
1506 2308
0028
KV-300
0030
KV-10/80
0004 0008
0031
1105
0032
2008 1400
0035 (SET)
1503 1506
0048 ( )
1504
0049
1505
0050
END
0051
INT
0053 0002
RETI
0055
ENDH
0056
Communications parameters
Duplex Full
Synchronization Start/stop
Data format ASCII
Baud rate 9,600 bps
Data length 8 bits
Parity check Even
Stop bit length 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.
7 Communication port B
Communication port A
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 desig- Device designated
KV nated as modem KV as terminal
SD 3 2 SD SD 3 2 SD
RD 5 3 RD RD 5 3 RD
SG 4 7 SG SG 4 7 SG
4 RS 4 RS
Connection Connection
5 CS 5 CS
cable 6 DR cable 6 DR
(Reverse: 20 ER (Straight: 20 ER
1 2 3 4 5 6
OP-96607) OP-26487)
Pin assignment for 25-pin D-sub 25-pin D-sub
the KV connector connector
(OP-26485) (OP-26485)
Recommended pin assignments for the RS-232C communication cable are shown
below. When connecting the KV-300 CPU, use only the connecting cable supplied.
KV-300 DCE KV-300 DTE
SD 3 2 SD SD 3 2 SD
RD 5 3 RD RD 5 3 RD
4 RS 4 RS
5 CS 5 CS
6 DR 6 DR
20 ER 20 ER
23 45 SG 4 7 SG SG 4 7 SG
SD 3 2
RD 5 3
4
SG 4 5
6
Modular 7
Connector 8
9-pin D-sub connector
17
Note 1: 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, 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.
■ Command/response format
"Command" and "response" in communications between the KV and a personal
computer are defined as follows:
When a personal computer transmits a command to the KV Series basic unit, the KV
sends back a response to the personal computer.
When creating a program to control the KV using a personal computer, create it so
that the response is checked before the next command is transmitted.
Command format
Use the following format to transmit commands from the personal computer to the
KV. [CR] is a delimiter. The KV ignores [LF] and recognizes the next character after
[LF] as the next command.
Command C
R
Or Command C L
R 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 C L
R F
17
ddddd_ddddd_00000_00000
dddddd= 00000 to 65535 (in decimal)
Digital trimmer RD_AT ↑ ↑
Reads preset values of trimmer 0 and 1.
(Trimmer 0) (Trimmer 1)
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
PLC’s EEPROM.
➮ Contact Keyence if you need to change it frequently.
■ Reading counter
Reads the contact ON/OFF status, or the current and preset values of the specified
counter/up-down counter.
Command: RD_Cnnn
Counter No.
Response: f,ddddd,ddddd
[Preset value of the counter (00000 to 65535: in
decimal)]
[Current value of the counter (00000 to 65535: in
decimal)]
0: Contact is OFF., 1: Contact is ON.
■ Reading timer
Reads the contact ON/OFF status, or the current and preset values of the specified
timer.
Command: RD_Tnnn
7 Timer No.
Response: f,ddddd,ddddd
Preset value of timer (00000 to 65535: in decimal)
Current value of timer (00000 to 65535: in decimal)
0: Contact is OFF., 1: Contact is ON.
■ Reading DM
Reads the contents of the specified data memory.
Command: RD_DMnnnn
Data memory No.
Response: ddddd
Data in the specified data memory. (00000 to
65535: in decimal)
■ Reading TM
Reads the contents of the specified temporary data memory.
Command: RD_TMnn
Temporary data memory No. (00 to 31)
Response: ddddd
Data in the specified temporary data memory.
(00000 to 65535: in decimal)
■ Writing current value of counter
Changes the current value of the specified counter or up-down counter.
Command: WR_Cnn_ddddd
New current value (00000 to 65535: in decimal)
Counter No.
Response: OK
■ Writing current value of timer
Changes the current value of the specified timer.
Command: WR_Tnnn_ddddd
New current value (00000 to 65535: in decimal)
Timer No.
Response: OK
■ Writing current value of high-speed counter CTH
Changes the current value of the specified high-speed counter CTH.
Command: WR_CTHn_ddddd
New current value (00000 to 65535: in decimal)
High-speed counter No.
Response: OK
■ Writing preset value of counter
Changes the preset value of the specified counter or up-down counter.
17
Command: WS_Cnnn_ddddd
New preset value (00000 to 65535: in decimal)
Counter No.
Response: OK
Note: Executing this command changes the program in the KV. The program in EEPROM is
automatically updated the next time the KV is turned ON.
Note: Visual KV Series: Executing this command changes the program in the KV. The
program in EEPROM is automatically 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 PLC’s EEPROM.
➮ Contact Keyence if you need to change it frequently.
■ Writing into DM
Writes data into the specified data memory.
Command: WR_DMnnnn_ddddd
New current value (00000 to 65535: in decimal)
Data memory No.
Response: OK
■ Writing into TM
Writes data into the specified temporary data memory. TM30 and TM31 are read-
only memories, so values cannot be written to them.
Command: WR_TMnn_ddddd
New current value (00000 to 65535: in decimal)
Temporary data memory No. (00 to 29)
Response: OK
■ Forcing relay ON
Forces the contact of the specified relay to ON.
Command: ST_nnnnn
Relay No.
Response: OK
Note 1: Input relays cannot be forced ON/OFF. (Except when special utility relay
2301 is ON.)
Note 2: "_" in commands and responses represents a space.
Response
Description Cause Remedy
code
E0 Relay No. • Undefined relay, counter, • Specify a number that is
error timer, DM, CTH, or CTC defined in the KV being
number was specified. used.
• Counter, timer, CTH, or • Check a program, and
CTC number, unused in a specify a number used in
program was specified. the program.
E3 Base unit Hardware error was detected Turn off the power for the KV, 17
fault in a KV base unit. and then turn it on again. If
the cause of the error is not
removed, the KV may be
faulty. Contact your nearest
KEYENCE office.
E5 Base unit "M1" was transmitted before Clear the error message from
error cleaning an error message the KV, and remove the cause
from the KV. of the error.
‘
‘Language Microsoft BASIC Version 7.0
‘
‘ *****I/OAddress (RS-232C Port-1)*****
‘Port-1&H3F*
‘Port-2&H2F*
‘
PortCtrl%=&H3FB’COM1
Port1Modem%=&H3FC’MODEMCtrl
PortBpsLow%=&H3F8’BitrateLow
PortBpsHigh%=&H3F9’BitrateHigh
‘*****ControlCode*****
Port1CtrlCode1%=&H5B’Break&8bitEven1Stopbit
Port1CtrlCode2%=&H1B’8bitEven1Stopbit
‘*****InitializesRS-232C***** Note: No parity check is specified due to the
OPEN"COM1:9600,N,8,1"FORRANDOMAS#1' limitations of the version of BASIC being used.
‘*****RS-232CPortInit*****
OUTPortCtrl %,Port1CtrlCode1%’Start transmitting a break signal
SLEEP1’wait 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%,linectrl’DLAB=ON
‘’’’’’’’’’’
‘’’’’’’’’’’OUTPortBpsLow%,12’SetBitRate(9600BPS)
‘’’’’’’’’’’OUTPortBpsHigh%,0'
‘’’’’’’’’’’
‘’’’’’’’’’’linectrl=linectrlAND&H7F’DLAB=OFF
‘’’’’’’’’’’OUTPortCtrl%,linectrl
‘’’’’’’’’’’’
‘’’’’’’’’’’’*****CtrlLine*****
‘’’’’’’’’’’OUTPort1Modem%,&HB’RTS,DTRON !!
‘’’’’’’’’’’’
‘’’’’’’’’’’’*****DebugPrint*****
‘’’’’’’’’’’status=INP(&H3FE):PRINT"ModemStatus2";status
‘’’’’’’’’’’status=INP(&H3FD):PRINT"LineStatus2";status
‘-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
‘*********************************************************
17
‘*****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.
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
1st DM
Data memory (Byte count of data) 2nd DM 3rd DM 4th DM 100th DM
15 00
Bits in 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1
data memory
High-order 8 bits (00) Low-order 8 bits (ASCII code)
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" program-
ming 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
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.
15 00
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" program-
ming 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
END
0012
ENDH
0013
High-order 4 bits
0 1 2 3 4 5 6 7 8 9
0
1
2
3
4
5
Low-order 4 bits
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.
8.1 List
Instruction Program title Reference
Page
TMR, TMH, TMS [Timers] One-shot circuit 3-326
Off-delay circuit 3-326
On-delay circuit 3-327
Flicker circuit 3-327
C [Counter] Accumulator timer 3-327
Large capacity counter 3-328
Multi-level Up/Down counter 3-328
Counter multi-level setting 3-328
DIFU, DIFD One-shot circuit 3-329
KEEP Detection of packs on conveyor 3-329
SFT Alternating circuit 3-330
Repeat shift circuit 3-331
Asynchronous shift register 3-331
Resetting internal utility relays 3-332
HSP High-speed fetching of input data 3-332
MC-MCR Emergency stop circuit 3-333
W-UE Input sequence check 3-334
Fork lift truck IN/OUT judgement 3-334
STG-JMP Enabling double coil 3-335
Conditional branching 3-335
STP-STE Process progression 3-336
ITVL Pulse interval measurement 3-336
Fetching data from KV-AN6 3-337
CTH [High-speed counter] High-speed counter multi-level setting 3-338
High-speed counter current value clear 3-339
Input of phase differential signal 3-339
SBN [Sub-routine] DM shift 3-340
FOR-NEXT Transfer of a block of DM data 3-341
HKEY Fetching 16-key input 3-342
TMIN [Analog timer] Changing timer setting value 3-343
18
8.2 Details
8.2.1 Reference Program Examples
Basic Instructions
Applications of TMR, TMH, and TMS Instructions ➮ Refer to p. 3-67 to p. 3-71.
■ One-shot circuit
When input relay 0000 turns ON, output relay 0500 turns ON and remains ON for a
specified time.
Timing diagram
0000
0500 2s 2s
■ 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
8 0500 2s
■ 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
■ Flicker circuit
Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
Timing diagram
0000 1s 1s
0500
2s 2s
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 8500
LDA TBCD STA Low-order
4 digits
C001 8600
LDA TBCD STA High-order
4 digits
Ladder diagram Coding
0001 UDC000
Line No. Instruction Operand
UP BCD:
0002 #09999 Low-order 0000 LD 0001
4 digits
DW 0001 LD 0002
0003 0002 LD 0003
RES
0003 UDC 000 #09999
C000 0001 UDC001 0004 LD C000
UP BCD:
High-order 0005 AND 0001
C000 0002 #09999
4 digits 0006 LD C000
8 DW
0007 AND 0002
0003
RES 0008 LD 0003
0009 UDC 001 #09999
Ladder diagram
0001 #09999
C000
0000
2002 C000 #00999 2011 0500
LDA CMP 00000 to
00999
#01999 2011 0500 0501
CMP 01000 to
01999
#02999 2011 0500 0501 0512
02000 to
CMP
02999
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0012 CON
0001 C 000 #09999 0000 0013 ANB 2011
0002 LD 2002 0014 ANB 0500
0003 LDA C000 0015 OUT 0501
0004 CON 0016 MPP
0005 MPS 0017 CMP #02999
0006 CMP #00999 0018 CON
0007 CON 0019 ANB 2011
0008 ANB 2011 0020 ANB 0500
0009 OUT 0500 0021 ANB 0501
0010 MRD 0022 OUT 0502
0011 CMP #01999
Timing diagram
0000
1000
1001
0500 1S
0501 1S
Ladder diagram Coding
0000 1000 Line No. Instruction Operand
DIFU 0000 LD 0000
1001 0001 DIFU 1000
DIFD 0002 DIFD 1001
1000 T001 0500 0003 LD 1000
0004 OR 0500
0500 #00010
0005 ANB T001
T001
0006 OUT 0500
1001 T002 0501
0007 TMR 001 #00010
0008 LD 1001
0501 #00010
T002 0009 OR 0501 18
0010 ANB T002
➮ Refer to p. 3-78. 0011 OUT 0501
0012 TMR 002 #00010
ON OFF ON
ES Series
Gum Gum
Gum Gum Gum
Gum Gum Gum
PZ2-61
Timing diagram
0000
0001
0002
0003
0500 1s
Ladder diagram
0000 0001 0002 0003 KEEP
Excecutes SET when
SE T all input relays 0000 to
1000 0003 are ON.
1001
RES
0000 1001 Detects presence/absence
DIFD of chewing gum packs at
DOWN edge of 0000.
1001 1000 T001 0500
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. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0007 DIFD 1001
0001 AND 0001 0008 LD 1001
0002 AND 0002 0009 ANB 1000
0003 AND 0003 0010 OR 0500
0004 LD 1001 0011 ANB T001
0005 KEEP 1000 0012 OUT 0500
0006 LD 0000 0013 TMR 001 #00010
➮ Refer to p. 3-80.
Timing diagram
0000
0500
Timing diagram
0001
0000
1000
1001 18
1002
.
.
.
Ladder diagram Coding
0000 1100 Line No. Instruction Operand
DIFU
0000 LD 0000
1100 1000
SET 0001 DIFU 1100
2003 SFT 0002 LD 1100
D
1000 0003 SET 100
0001
CLK 0004 LD 2003
0002 1010 0005 LD 0001
RES
0006 LD 0002
0007 SFT 1000 1010
Timing diagram
0000
0001
0500 1s
* To input a signal having pulse interval shorter than the scan time, use the inter-
8 rupt instruction. ➮ Refer to p. 3-192.
RET I
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 END
0001 EI 0008 INT 0000
0002 SET 2813 0009 LD 2002
0003 LD 0500 0010 SET 0500
0004 T000 #00010 0011 RETI
0005 LD T000 0012 ENDH
0006 RES 0500
➮ Refer to p. 3-86.
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
Timing diagram
0000
0001
0500
0501
8
Ladder diagram Coding
Ladder diagram
0000 1100 1100 1000
DIFU SET Turns ON 1000 when input relay 0000 turns ON.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0016 CON
0001 DIFU 1100 0017 TMR 001 #00020
0002 CON 0018 CON
0003 AND 1100 0019 AND T001
0004 SET 1000 0020 JMP 1002
0005 STG 1000 0021 STG 1002
0006 OUT 0500 0022 OUT 0500
0007 CON 0023 CON
0008 TMR 000 #00010 0024 OUT 0501
0009 CON 0025 CON
0010 AND T000 0026 OUT 0502
0011 JMP 1001 0027 CON
0012 STG 1001 0028 TMR 002 #00030
0013 OUT 0500 0029 CON
0014 CON 0030 AND T002
0015 OUT 0501 0031 JMP 1000
Ladder diagram
0000 1100 1100 1000
DIFU SET
1000 0500 0001 1001
STG JMP
0002 1002
JMP
1001 0501 #00010 T000 1000
STG T000 JMP
1002 0502 #00020 T001 1000
STG T001 JMP
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0014 OUT 0501
0001 DIFU 1100 0015 CON
0002 CON 0016 TMR 000 #00010
0003 AND 1100 0017 CON
0004 SET 1000 0018 AND T000
0005 STG 1000 0019 JMP 1000
0006 OUT 0500 0020 STG 1002
0007 MPS 0021 OUT 0502
0008 AND 0001 0022 CON
0009 JMP 1001 0023 TMR 001 #00020
0010 MPP 0024 CON
0011 AND 0002 0025 AND T001
0012 JMP 1002 0026 JMP 1000
0013 STG 1001
STP
0008 LDB T000
0008 1002
0009 OUT 0500
T001 1002
0009 RES 0010 LD 1001
T001 0501 0011 TMR 000 #00020
0010
1002 #00030
0012 LD T000
0011 T001 0013 SET 1002
8 0012
STE
0014 STE
END 0015 STP 1002
0013
0016 LD T001
ENDH
0014 0017 RES 1002
0018 LDB T001
0019 OUT 0501
0020 LD 1002
* The double coil operates normally 0021 TMR 001 #00030
across different STP instructions. 0022 STE
➮ Refer to p. 3-114. 0023 END
0024 ENDH
ON
OFF 500ms
Ladder diagram
2008 #00001 DM0000
LDA STA Sets mode 1 in DM0000.
1002 DM0007 DM0100 0500 Writes the average measurement value into
LDA STA RES DM0100 and resets 0500 after every time a
measurement is completed.
1000 0500
SET Turns On output relay 0500 when the pulse
interval is not within the range from 490 to 510
mm.
1001
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0015 STA DM0003
0001 LDA #00001 0016 LD 0000
0002 CON 0017 LD 0001 18
0003 STA DM0000 0018 LD 0002
0004 LD 2008 0019 ITVL DM0000 1000
0005 LDA #00051 0020 LD 1002
0006 CON 0021 LDA DM0007
0007 STA DM0001 0022 CON
0008 LD 2008 0023 STA DM0100
0009 LDA #00049 0024 CON
0010 CON 0025 RES 0500
0011 STA DM0002 0026 LD 1000
0012 LD 2008 0027 OR 1001
0013 LDA #00010 0028 SET 0500
0014 CON
Ladder diagram
2008 2813 2103 2113 2114 2115 CTH0
EI SET SET SET RES SET RES Initial settings*Note
0500 CTH0
00004
#60000
2002 CTH0 DM0000 CTC0
18
LDA STA
END
INT
CTC0
2002 0500
SET
RETI
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0014 LDB 0500
0001 EI 0015 CTH 1 0004
0002 CON 0016 CTC 0 #60000
0003 SET 2813 0017 LD 2002
0004 CON 0018 LDA CTH0
0005 SET 2103 0019 CON
0006 CON 0020 STA DM0000
0007 SET 2113 0021 END
0008 CON 0022 INT CTC0
0009 RES 2114 0023 LD 2002
0010 CON 0024 SET 0500
0011 SET 2115 0025 RETI
0012 CON 0026 ENDH
0013 RES CTH0
Ladder diagram
0000 1000 1000 #00010 TM02 #00030 TM03 00 Shifts data from
DIFU LDA STA LDA STA CALL DM0010 to DM0030.
Synchoronous Designates the Designates the
signal shift start shift end
DM No. (DM0010). DM No. (DM0030). END
SBN
00
2002 TM03 #00001 TM04 TM02 TM05
LDA ADD STA SUB STA
Shift level FOR
8 TM05
2002 TM03 TM04 #TM03 #TM04
DEC DEC LDA STA The program lines which
Uses the indirect addressing execute the data shift
function to designate DM Nos. are groped as the subroutine.
NEXT
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0021 CON
0001 DIFU 1000 0022 SUB TM02
0002 CON 0023 CON
0003 AND 1000 0024 STA TM05
0004 LDA #00010 0025 FOR TM05
0005 CON 0026 LD 2002
0006 STA TM02 0027 DEC TM03
0007 CON 0028 CON
0008 LDA #00030 0029 DEC TM04
0009 CON 0030 CON
0010 STA TM03 0031 LDA #TM03
0011 CON 0032 CON
0012 CALL 00 0033 STA #TM04
0013 END 0034 NEXT
0014 SBN 00 0035 LD 2002
0015 LD 2002 0036 LDA #00000
0016 LDA TM03 0037 CON
0017 CON 0038 STA #TM02
0018 ADD #00001 0039 RET
0019 CON 0040 ENDH
0020 STA 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.
DM0199
➮ Refer to p. 3-125.
Ladder diagram
2008 2814
SET
2002 HKEY KEY IN
0000
0500
2815 2900 2010 $03FF TM05 2010 TM05 TM06
LDA ANDA CMP STA DMX STA
2815 2900 2010 $03FF TM05 2010 TM05
LDA ANDA CMP STA
ENDH
Coding
Line No. Instruction Operand Line No. Instruction Operand
8 0000 LD 2008 0021 AND 2010
0001 SET 2814 0022 ANDA $03FF
0002 LD 2002 0023 CON
0003 HKEY 0000 0500 0024 CMP TM05
0004 LD 2815 0025 CON
0005 LDA 2900 0026 ANB 2010
0006 CON 0027 STA TM05
0007 ANB 2010 0028 CON
0008 ANDA $03FF 0029 LDA DM0000
0009 CON 0030 CON
0010 CMP TM05 0031 SLA #04
0011 CON 0032 CON
0012 ANB 2010 0033 ORA TM06
0013 STA TM05 0034 CON
0014 CON 0035 STA DM0000
0015 DMX 0036 LD 2815
0016 CON 0037 AND 2915
0017 STA TM06 0038 DW #0000 DM0000
0018 LD 2815 0039 END
0019 LDA 2900 0040 ENDH
0020 CON
➮ Refer to p. 3-131.
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).
DM0001
DM0003
DM0004
Unloading timing
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 pro-
grams.
Ladder diagram
0000 1000 1000 0001 $1111 DM0000
DIFU LDA STA
Transfers $1111 to DM0000.
OK/NG judgement timing OK/NG judgement
0001 $5555 DM0000
LDA STA
Transfers $5555 to DM0000.
2002 DM0004 $0000 2010 DM0003 DM0004 $0000 DM0003
LDA CMP LDA STA LDA STA
2002 DM0003 $0000 2010 DM0002 DM0003 $0000 DM0002
LDA CMP LDA STA LDA STA Compares the DM value to $0000.
If it is equal to $0000, transfers the
2002 DM0002 $0000 2010 DM0001 DM0002 $0000 DM0001 value of the previous DM No. and
then writes $0000 into the current DM No.
LDA CMP LDA STA LDA STA
2002 DM0001 $0000 2010 DM0000 DM0001 $0000 DM0000
LDA CMP LDA STA LDA STA
0002 $0000 DM0004
LDA STA
Unloading timing Transfers $0000 to DM at unloading timing.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0035 STA DM0003
0001 DIFU 1000 0036 CON
0002 CON 0037 LDA $0000
0003 AND 1000 0038 CON
0004 MPS 0039 STA DM0002
0005 AND 0001 0040 LD 2002
0006 LDA $1111 0041 LDA DM0002
0007 CON 0042 CON
0008 STA DM0000 0043 CMP $0000
0009 MPP 0044 CON
0010 ANB 0001 0045 AND 2010
0011 LDA $5555 0046 LDA DM0001
8 0012 CON 0047 CON
0013 STA DM0000 0048 STA DM0002
0014 LD 2002 0049 CON
0015 LDA DM0004 0050 LDA $0000
0016 CON 0051 CON
0017 CMP $0000 0052 STA DM0001
0018 CON 0053 LD 2002
0019 AND 2010 0054 LDA DM0001
0020 LDA DM0003 0055 CON
0021 CON 0056 CMP $0000
0022 STA DM0004 0057 CON
0023 CON 0058 AND 2010
0024 LDA $0000 0059 LDA DM0000
0025 CON 0060 CON
0026 STA DM0003 0061 STA DM0001
0027 LD 2002 0062 CON
0028 LDA DM0003 0063 LDA $0000
0029 CON 0064 CON
0030 CMP $0000 0065 STA DM0000
0031 CON 0066 LD 0002
0032 AND 2010 0067 @LDA $0000
0033 LDA DM0002 0068 CON
0034 CON 0069 @STA DM0004
Ladder diagram
0001 #09999
C001
0000
2002 C001 #01000 2011 0500
LDA CMP C001 ≤ #1000
2002 C001 #02000 2009 0501
LDA CMP C001 ≥ #02000
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0008 OUT 0500
0001 C 001 #09999 0000 0009 LD 2002
0002 LD 2002 0010 LDA C001
0003 LDA C001 0011 CON
0004 CON 0012 CMP #02000
0005 CMP #01000 0013 CON
0006 CON 0014 ANB 2009
0007 ANB 2011 0015 OUT 0501
Ladder diagram
2002 0 #00001 #00004 #00010 DM0000
Sets the TMIN setting
TMIN ADD MUL DIV STA range from 0 to 100.
0001 #09999
C000
00000
2002 C000 DM0000 2009 0500
LDA CMP
2009 0501
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0011 C 000 #09999 0000
0001 TMIN 0 0012 LD 02002
0002 CON 0013 LDA C000
0003 ADD #00001 0014 CON
0004 CON 0015 CMP DM0000
0005 MUL #00004 0016 MPS
0006 CON 0017 AND 2009
8 0007 DIV #00010 0018 OUT 0500
0008 CON 0019 MPP
0009 STA DM0000 0020 ANB 2009
0010 LDB 0001 0021 OUT 0501
■ 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
Ladder diagram
0001 #09999
C000
0000
2002 C000 #00999 2011 0500
LDA CMP C000 ≤ 00999
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0012 CON
0001 C 000 #09999 0000 0013 ANB 2011
0002 LD 2002 0014 ANB 0500
0003 LDA C000 0015 OUT 0501
0004 CON 0016 MPP
0005 MPS 0017 CMP #02999
0006 CMP #00999 0018 CON
0007 CON 0019 ANB 2011
0008 ANB 2011 0020 ANB 0500
0009 OUT 0500 0021 ANB 0501
0010 MRD 0022 OUT 0502
0011 CMP #01999
➮ Refer to p. 3-146.
Ladder diagram
2002 7000 DM0000
LDA TBIN STA Converts BCD input value to BIN.
2002 C001 DM0000 DM0100
18
LDA ADD STA Adds converted BIN value to the current value of
C001 and writes the sum into DM0100.
0001 #09999
C001
0000
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0007 LDA C001
0001 LDA 7000 0008 CON
0002 CON 0009 ADD DM0000
0003 TBIN 0010 CON
0004 CON 0011 STA DM0100
0005 STA DM0000 0012 LDB 0001
0006 LD 2002 0013 C 001 #09999 0000
■ Total count
Writes total count of counters C001 to C003 into DM0100. The total count must be
within 65535.
Ladder diagram
0000 #09999 C001 DM0001
C001 LDA STA Writes C001 current value into DM0001.
0001
0000 #09999 C002 DM0002
C002 LDA STA Writes C002 current value into DM0002.
0002
0000 #09999 C003 DM0003
C003 LDA STA Writes C003 current value into DM0003.
0003
2002 DM0001 DM0002 DM0003 DM0100
LDA ADD ADD STA Writes total count (DM0001 + CM0002 + DM0003) into
DM100.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0013 C 003 #09999 0003
0001 C 001 #09999 0001 0014 CON
0002 CON 0015 LDA C003
0003 LDA C001 0016 CON
0004 CON 0017 STA DM0003
0005 STA DM0001 0018 LD 2002
0006 LDB 0000 0019 LDA DM0001
0007 C 002 #09999 0002 0020 CON
0008 CON 0021 ADD DM0002
0009 LDA C002 0022 CON
0010 CON 0023 ADD DM0003
0011 STA DM0002 0024 CON
0012 LDB 0000 0025 STA DM0100
➮ Refer to p. 3-150.
Ladder diagram
8 2002 DM0000 DM0001 2009 #0005 2009 1000
LDA SUB CMP
2009 DM0001 DM0000 #0005 2009 1001
LDA SUB CMP
1000 0500
1001
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0012 LDA DM0001
0001 LDA DM0000 0013 CON
0002 CON 0014 SUB DM0000
0003 SUB DM0001 0015 CON
0004 MPS 0016 CMP #00005
0005 ANB 2009 0017 CON
0006 CMP #00005 0018 ANB 2009
0007 CON 0019 OUT 1001
0008 ANB 2009 0020 LD 1000
0009 OUT 1000 0021 OR 1001
0010 MPP 0022 OUT 0500
0011 AND 2009
➮ Refer to p. 3-150.
Ladder diagram
0000 #09999 C001 DM0001
Writes the C001 current
C001 LDA STA value into DM0001.
00001
0000 #09999 C002 DM0002
Writes the C002 current
C002 LDA STA value into DM0002.
00002
0000 #09999 C003 DM0003
Writes the C003 current
C003 LDA STA value into DM0003.
00003
2002 DM0001
LDA
DM0002 DM0003
ADD ADD DM0001 DM0002 DM0003
18
2002 #00003 07500 ÷3 → Output to 07500
DIV TBCD STA to 07515 in 4-digit BCD.
Coding
Ladder diagram
2002 0000 $000F
Fetches data of 0000 to 0015 and retains data of 0000
LDA ANDA
to 0003 only.
2002 C000
TBIN STA Converts data to BIN and writes it into C000.
7000 #09999
C000 Sets C000.
7001
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0005 TBIN
0001 LDA 0000 0006 CON
0002 CON 0007 STA C000
0003 ANDA $000F 0008 LDB 7000
0004 LD 2002 0009 C 000 #09999 7001
Ladder diagram
2002 7000 $00FF C000
LDA ANDA TBIN STA Converts data of 7000 to 7007 to BIN and
writes it into C000.
2002 7000 $FF00 #08 T001
LDA ANDA SRA TBIN STA Shifts data to right by 8 bits, converts it to
BIN, and writes it into T001.
0001 #09999
C000 Sets C000.
0000
0001 #09999
T001 Sets T001.
Coding
8
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0011 ANDA $FF00
0001 LDA 7000 0012 CON
0002 CON 0013 SRA #08
0003 ANDA $00FF 0014 CON
0004 CON 0015 TBIN
0005 TBIN 0016 CON
0006 CON 0017 STA T001
0007 STA C000 0018 LDB 0001
0008 LD 2002 0019 C 000 #09999 0000
0009 LDA 7000 0020 LDB 0001
0010 CON 0021 T 001 #09999
➮ Refer to p. 3-159.
Ladder diagram
0000 #00099
C000 Sets C000.
0001
2002 7500 $FF00 DM0000
LDA ANDA STA Writes data of 7008 to 7015 into DM0000.
2002 C000 $00FF Converts the current value of C000 to BCD and
LDA TBCD ANDA retains the low-order 2 digits of BCD in the
internal register.
2002 DM0000 7500 ORs the data in the internal register and the
ORA STA DM0000 data and sends the ORed data to 7500
to 7515.
Coding
Ladder diagram
0000 #00099
C001
0001
2002 7000 $000F DM0000
18
LDA ANDA STA
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0000 0010 CON
0001 C 001 #00099 0001 0011 ANDA $000F
0002 LD 2002 0012 LD 2002
0003 LDA 7000 0013 SLA #04
0004 CON 0014 CON
0005 ANDA $000F 0015 ORA DM0000
0006 CON 0016 CON
0007 STA DM0000 0017 TBIN
0008 LD 2002 0018 CON
0009 LDA 8000 0019 STA C001
➮ Refer to p. 3-161.
Judges match between the operand and the data of 7000 to 7015.
When 2010 is ON, the two values match.
When 2010 is OFF, the two values do not match.
➮ Refer to p. 3-164.
Ladder diagram
0001 #00099
C001 Sets C001.
0000
2002 7000 $F000 Sends the data of 7012 to 7015 to internal
LDA ANDA register.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0001 0011 LDA 8000
0001 C 001 #00099 0000 0012 CON
0002 LD 2002 0013 ANDA $000F
0003 LDA 7000 0014 LD 2002
0004 CON 0015 SLA #04
0005 ANDA $F000 0016 CON
0006 LD 2002 0017 ORA DM0000
0007 SRA #12 0018 LD 2002
0008 CON 0019 TBIN
0009 STA DM0000 0020 CON
0010 LD 2002 0021 STA C001
➮ Refer to p. 3-166.
Ladder diagram
2002 7000
LDA Writes the data of 7000 to
7015 into internal register.
FOR
#00016 Executes FOR-NEXT instruction for 16 times.
2002 #01 2009 TM10
RRA INC Shifts the data including carry (2009) to right,
and increments TM10 by 1 when 2009 is ON.
NEXT
2002 TM10 DM0000 #00000 TM10 Writes the TM10 data into DM0000, and then writes
LDA STA LDA STA #00000 to TM10.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0009 LD 2002
0001 LDA 7000 0010 LDA TM10
0002 FOR #00016 0011 CON
0003 LD 02002 0012 STA DM0000 18
0004 RRA #01 0013 CON
0005 CON 0014 LDA #00000
0006 AND 2009 0015 CON
0007 INC TM10 0016 STA TM10
0008 NEXT
➮ Refer to p. 3-169.
Ladder diagram
2008 #00000 DM0000
LDA STA Sets #00000 to DM0000 at startup.
0000 DM0000
INC Increments DM0000 by 1 at UP
edge of input relay 0000.
0001 DM0000
INC
Increments DM0000 by 1 at UP
edge of input relay 0001.
0002 DM0000
INC Increments DM0000 by 1 at UP
edge of input relay 0002.
0003 DM0000
INC Increments DM0000 by 1 at UP
edge of input relay 0003.
0005 #00000
DW Clears DM0000 to #00000 when
DM0000 0005 turns ON.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0007 @INC DM0000
0001 LDA #00000 0008 LD 0002
0002 CON 0009 @INC DM0000
0003 STA DM0000 0010 LD 0003
0004 LD 0000 0011 @INC DM0000
0005 @INC DM0000 0012 LD 0005
0006 LD 0001 0013 DW #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
2008 #00000 DM0000
LDA STA Sets #00000 to DM0000 at startup.
0000 DM0000
Increments DM0000 by 1 at UP edge
INC
of input relay 0000.
0001 DM0000
Decrements DM0000 by 1 at UP edge
8 DEC
of input relay 0001.
0005 #00000
DW Clears DM0000 to #00000 when 0005
turns ON.
DM0000
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0005 @INC 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
➮ Refer to p. 3-172.
Ladder diagram
2002 07000 Converts the most significant bit of 16-bit data
LDA DMX (7000 to 7015) to 4-bit BIN data and sends it to
internal register.
2002 $00FF 8000 Converts internal register data to BCD data,
TBCD ANDA STA executes ANDA instruction, and outputs the data
to 8000 to 8015.
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0005 TBCD
0001 LDA 7000 0006 CON
0002 CON 0007 ANDA $00FF
0003 DMX 0008 CON
0004 LD 2002 0009 STA 8000
➮ Refer to p. 3-176.
Ladder diagram
0001 #09999
C001
0000
2002 C001 7500
LDA TBCD STA
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0004 CON
8 0001 C 001 #09999 0000 0005 TBCD
0002 LD 2002 0006 CON
0003 LDA C001 0007 STA 7500
(Display)
Ladder diagram
DM0101 8500
LDA TBCD STA
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0010 CON
0001 LDA DM0000 0011 TBCD
0002 CON 0012 CON
0003 MUL DM0001 0013 STA 750
0004 CON 0014 CON
0005 DIV #10000 0015 LDA DM0101
0006 CON 0016 CON
0007 STA DM0101 0017 TBCD
0008 CON 0018 CON
0009 LDA TM01 0019 STA 8500
➮ Refer to p. 3-180.
Ladder diagram
Coding
width
Pulse output setting with the high-speed counter
Direct clock pulse, setting item for 3-238
comparator
E
Expansion unit, checking operation of Connection information for expansion units 1-75
Expansion unit, connecting Connecting Visual KV Series expansion units 1-71
Expansion unit, maximum number to be connected to Number of connectable units 1-73
Expansion unit, setting its height flush with AC-type basic unit Expansion unit spacer 1-66
External output, disabling Output prohibition function 3-26
F
Forcing input ON/OFF without switch Input refresh disabled function 3-26
Frequency counter function, setting item for Devices used with the frequency counter 3-231
High-speed counter, increasing measurement range of 24-bit high-speed counter 3-221
High-speed counter, measuring frequency with Frequency counter function 3-231
High-speed counter, outputting pulses using Direct Clock Pulse Output 3-237
Reading the current value of the high-speed
High-speed counter, reading current value of 3-211
counter
High-speed counter, resetting the value to other than "0" Preset function 3-215
3-360 Index
Index 3-361
3-362 Index
MPX/@MPX: Multiplexer ...................................... 3-176 System Configuration (Memory Card) ..................... 1-196
MRD: Read ............................................................ 3-103 System specifications [Visual KV Series] ................ 1-382
MUL/@MUL: Multiply ........................................... 3-150 System specifications [KV-300 Series] ................... 1-392
N T
NEXT: Repeat End ................................................ 3-125 TBCD/@TBCD: Transfer BCD ............................. 3-180
Non-procedure mode [KV-L2] ................................. 1-292 TBIN/@TBIN: Transfer BIN .................................. 3-180
NOP: No Operation ................................................ 3-94 Temporary Memory ...................................... 2-172, 2-176
Timers and Counters ............................................... 2-169
TMH: 0.01-s Timer .................................................. 3-68
O
TMIN: Trimmer In .................................................. 3-138
OR: Or ..................................................................... 3-60 @TMIN: Trimmer Setting ..................................... 3-138
ORA/@ORA: Or A ................................................. 3-161 TMR: 0.1-s Timer .................................................... 3-67
ORB: Or Bar ............................................................ 3-60 TMS: 1-ms Timer .................................................... 3-69
ORL: Or Load .......................................................... 3-63 Transmitting text data .......................................... 3-319
OUB: Out Bar .......................................................... 3-65 Troubleshooting ...................................................... 1-372
OUT: Out ................................................................. 3-65
Output Relays ......................................................... 3-10 U
UDC: Up-Down Counter ......................................... 3-76
P
Peripheral equipments ............................................ 1-176 W
Port1/Port2 [KV-L2] ................................................. 1-245
Positionning control ............................................ 3-296 W-DE: Wait Down Edge ......................................... 3-98
Programming examples ...................................... 3-324 W-OFF: Wait OFF ................................................... 3-96
W-ON: Wait ON ....................................................... 3-96
W-UE: Wait Up Edge .............................................. 3-98
R
RASC/@RASC: Reverse ASCII Convert ............. 3-183 X
Receiving text data .............................................. 3-318
Relay/Memory/Memory Switch Lists ....................... 2-167 @xxxx: Differentiation ......................................... 3-137
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
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
3-364 Index
Index 3-365
3-366 Index
• When the KV Series PLC is used in combination with other instruments, func-
tions 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) 3-367
Visual KV Series
96M0366
INDEX
1 2 3
Installation Support Programming
1. Configuration and Software 1. Programming
3
Specifications 1. Introduction 2. Instructions
User’s Manual
Programming
2. System Installation
2. Editor 3. Interrupts
3. Access Window
3. Simulator 4. High-speed Counters
4. KV-D20 Operator
Interface Panel 4. Monitor 5. Positioning Control Visual KV Series
5. Appendices 6. Interrupts, High-speed
5. KV-10/80 Hardware
Counters, Positioning
6. Handheld Program-
mer
Control 3
7. Serial Communication
Programming
User’s Manual
7. KV-L2 Serial Interface
8. Programming
Module
Examples
8. KV-AN6 Analog I/O
Module
9. KV-AD4/DA4 Analog
I/O Unit
10. Troubleshooting
11. Appendices
KEYENCE CORPORATION
1-3-14, Higashi-Nakajima, Higashi-Yodogawa-ku, Osaka, 533-8555, Japan PHONE: +81-6-6379-2211