User’s ManualVisual KV Series
3Programming
How this manual is organized:
The Visual KV Series User’s Manual is composed of 3 separatemanuals; 1-Installation, 2-Support Software, 3-Programming.Please read each manual relevant to your purpose.
96M0366
SupportSoftware
1. Introduction
2. Editor
3. Simulator
4. Monitor
5. Appendices
Programming1. Programming
2. Instructions
3. Interrupts
4. High-speed Counters
5. Positioning Control
6. Interrupts, High-speedCounters, PositioningControl
7. Serial Communication
8. ProgrammingExamples
INDEX
Installation1. Configuration and
Specifications
2. System Installation
3. Access Window
4. KV-D20 OperatorInterface Panel
5. KV-10/80 Hardware
6. Handheld Program-mer
7. KV-L2 Serial InterfaceModule
8. KV-AN6 Analog I/OModule
9. KV-AD4/DA4 AnalogI/O Unit
10. Troubleshooting
11. Appendices
1 2 3
A5WW1-MAN-0069
Copyright (c) 1999 KEYENCE CORPORATION. All rights reserved.084024E-3 0109-5 96M0366 Printed in Japan
Specifications are subject to change without notice.
AUSTRIAPhone: +43-2236-378266-0
BELGIUMPhone: +32 2 716 40 63
CHINAPhone: +86-21-68757500
CANADAPhone: +1-905-696-9970
CZECH REPUBLICPhone: +420 222 191 483
FRANCEPhone: +33 1 56 37 78 00
GERMANYPhone: +49-6102-36 89-0
HONG KONGPhone: +852-3104-1010
KOREAPhone: +82-31-642-1270
HUNGARYPhone: +36 14 748 313
ITALYPhone: +39-2-6688220
JAPANPhone: +81-6-6379-2211
MEXICOPhone: +52-81-8220-7900
NETHERLANDSPhone: +31 40 20 66 100
POLANDPhone: +48 71 36861 60
MALAYSIAPhone: +60-3-2092-2211
SINGAPOREPhone: +65-6392-1011
SLOVAKIAPhone: +421 2 5939 6461
SWITZERLANDPhone: +41 43 455 77 30
TAIWANPhone: +886-2-2718-8700
THAILANDPhone: +66-2-369-2777
UK & IRELANDPhone: +44-1908-696900
USA Phone: +1-201-930-0100
KEYENCE CORPORATION1-3-14, Higashi-Nakajima, Higashi-Yodogawa-ku, Osaka, 533-8555, Japan PHONE: +81-6-6379-2211
laun
aM
s’res
U
P
rogramm
ing
3
V
isual KV
Series
Safety PrecautionsThis instruction manual describes the operation and function of the KV Series PLC.Read this manual carefully to ensure safe use and maximum performance from yourKV Series PLC.
SymbolsThe following symbols alert you to important messages. Be sure to read thesemessages carefully.
Failure to follow instructions may lead to injury. (electricshock, burn, etc.)
Failure to follow instructions may lead to product damage.
Provides additional information on proper operation.
ConventionsThis manual describes the operation/function of all Keyence KV Series PLC.Note following conventions when you use.
General Precautions• At startup and during operation, be sure to monitor the functions and perfor-
mance of the KV Sereis PLC.
• We recommend that you take substantial safety measures to avoid any damagein the event a problem occurs.
• Do not open or modify the KV Series PLC or use it in any way other than de-scribed in the specifications.
• When the KV Series PLC is used in combination with other instruments, func-tions and performance may be degraded, depending on operating conditions andthe 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 veryfirst time you turn on the power supply to the Visual KV Series. Press any keyaround the display to cancel this message.The Visual KV Series shows this message when no program is loaded.
WARNING
CAUTION
Note:
(1)
Visual KV (Series) KV-10AR/AT/DR/DT KV-16AR/AT/DR/DTKV-10xx, 16xx, 24xx, 40xx KV-24AR/AT/DR/DT KV-40AR/AT/DR/DT
Conventional KV (Series) KV-10R(W)/T(W) KV-16R(W)/T(W)KV-300 (Series) KV-24R(W)/T(W) KV-40R(W)/T(W)KV-10/80 (Series) KV-80R(W)/T(W)
KV-300
3-367
WARRANTIES AND DISCLAIMERS: (1) KEYENCE warrants the Products to be free of defects in materials and workmanship for a period ofone (1) year from the date of shipment. If any models or samples were shown to Buyer, such models orsamples were used merely to illustrate the general type and quality of the Products and not to representthat the Products would necessarily conform to said models or samples. Any Products found to be defec-tive must be shipped to KEYENCE with all shipping costs paid by Buyer or offered to KEYENCE for in-spection and examination. Upon examination by KEYENCE, KEYENCE, at its sole option, will refund thepurchase price of, or repair or replace at no charge any Products found to be defective. This warrantydoes not apply to any defects resulting from any action of Buyer, including but not limited to improperinstallation, improper interfacing, improper repair, unauthorized modification, misapplication and mishan-dling, such as exposure to excessive current, heat, coldness, moisture, vibration or outdoors air. Compo-nents which wear are not warranted. (2) KEYENCE is pleased to offer suggestions on the use of its various Products. They are only sugges-tions, and it is Buyer’s responsibility to ascertain the fitness of the Products for Buyer’s intended use.KEYENCE will not be responsible for any damages that may result from the use of the Products. (3) The Products and any samples (“Products/Samples”) supplied to Buyer are not to be used internallyin humans, for human transportation, as safety devices or fail-safe systems, unless their written specifica-tions state otherwise. Should any Products/Samples be used in such a manner or misused in any way,KEYENCE assumes no responsibility, and additionally Buyer will indemnify KEYENCE and holdKEYENCE harmless from any liability or damage whatsoever arising out of any misuse of the Products/Samples. (4) OTHER THAN AS STATED HEREIN, THE PRODUCTS/SAMPLES ARE PROVIDED WITH NOOTHER WARRANTIES WHATSOEVER. ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES,INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR APARTICULAR PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EXPRESSLYDISCLAIMED. IN NO EVENT SHALL KEYENCE AND ITS AFFILIATED ENTITIES BE LIABLE TO ANYPERSON OR ENTITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSE-QUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RESULTING FROMLOSS OF USE, BUSINESS INTERRUPTION, LOSS OF INFORMATION, LOSS OR INACCURACY OFDATA, LOSS OF PROFITS, LOSS OF SAVINGS, THE COST OF PROCUREMENT OF SUBSTITUTEDGOODS, SERVICES OR TECHNOLOGIES, OR FOR ANY MATTER ARISING OUT OF OR IN CONNEC-TION WITH THE USE OR INABILITY TO USE THE PRODUCTS, EVEN IF KEYENCE OR ONE OF ITSAFFILIATED ENTITIES WAS ADVISED OF A POSSIBLE THIRD PARTY’S CLAIM FOR DAMAGES ORANY OTHER CLAIM AGAINST BUYER. In some jurisdictions, some of the foregoing warranty disclaimersor damage limitations may not apply.
BUYER’S TRANSFER OBLIGATIONS: If the Products/Samples purchased by Buyer are to be resold ordelivered to a third party, Buyer must provide such third party with a copy of this document, all specifica-tions, manuals, catalogs, leaflets and written information provided to Buyer pertaining to the Products/Samples.
Note to UserWhen using the Visual KV Series in the following conditions or environments, besure to use the Visual KV Series with sufficient margin regarding the rating andfunctions, take appropriate safety precautions such as fail-safe, and contact oursales 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 livesand properties and safety is especially requested.
Restriction on Acquiring the CE Marking Restriction to be compatible with EMC directives• When using a relay output type unit (whose model name ends with "R"), connect
spark killers having the appropriate withstand voltage against the load to theoutput terminals in parallel to contacts (because the unit discharges when a relaycontact becomes open and noise is generated). In our experiments, we use thefollowing models of spark killers.
XEB0101 0.1 µF-10 Ω manufactured by OKAYA DENKI SANGYO
The following 1-turn ferrite core is added to the AC power input circuit of the KV-40AR/T, the KV-24AR/T and to the DC power input circuit of the KV-40DR/T.
ZCAT3035-1330 manufactured by TDK
Note: The contents above do not by themselves ensure that the entire machinemanufactured in accordance with the above contents is compatible with EMCdirectives.
You must judge by yourself whether or not the entire machine is compatible withEMC directives because compatibility may change depending on the componentconfiguration, wiring and location inside of the machine.
Restriction on compatibility with low-voltage directives (IEC-1010-1)
• Use insulated type crimp-style terminals.
• For wiring materials, use lead wires whose sheath is 0.4 mm or more.
• The Visual KV Series is allowed to be installed in a vertical position only.(Spacers for expansion units are not available.)
• Be sure to use the Visual KV Series inside the control panel.
(2)96M0366
KVNKA Front_Pro.p65 09.10.9, 21:293
Features of the Visual KV Series Extremely small
The Visual KV Series is the smallest in the world among AC type PLCs equippedwith screw terminal blocks, and saves installation space.
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.
AC power built-in type newly addedAC power built-in type units are newly added. This type can be used in smallspaces where a switching power supply unit cannot be installed.
Excellent Access Window
An Access Window with two-color backlight is adopted in all models to facilitatechanging and monitoring of device data. Changing between RUN mode andPROGRAM mode, checking the error code when an error has occurred, etc. canbe performed in a Visual KV Series unit without the need for any handheldprogrammer.The analog trimmer, which has been popular in the conventional KV Series, isdigitized to enable more detail settings. [Digital trimmers]
User message setting function
In the Access Window, 256 different user messages can be displayed. Thisfunction can be used to give instructions on works on the production line, indicateabnormalities in the units, etc.
Program write in RUN modeLadder programs can be changed even while the system is running.
Equipped with two serial ports
Visual KV Series basic units are equipped with two serial ports to connect periph-eral units, improving the debug environment.(The KV-10xx is equipped with only one serial port.)
Easy Ramp-up/down control functionThe one-axis motor control function is offered separately from high-speedcounters so that feedback control is enabled.
Equipped with two 24-bit high-speed 30 kHz, two-phase counters
The Visual KV Series is equipped with two high-speed counters each with a two-point comparator output function that enables high-speed encoder input.
Specified frequency pulse output functionHigh-speed counters can function as pulse oscillators of 50 kHz maximum witheasy setting, without creating a complicated ladder program.
Frequency counter function
High-speed counters can function as frequency counters with easy setting,without creating complicated ladder programs.
Cam switch functionHigh-speed counters can function as cam switches with easy setting, withoutcreating complicated ladder programs.
(3)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM4
Interrupt functionThe Visual KV Series is equipped with four high-speed interrupt inputs of10 µs maximum.
Input time constant change function
The time constant can be set in 7 steps from 10 µs to 10 ms.
Double memory backup functionsIn addition to a conventional SRAM battery backup function, the Visual KV Seriesis also equipped with an EEPROM backup function.
Compatibility with Conventional KV Series Peripheral UnitsThe Visual KV Series functions as a high-end compatible model of the conventionalKV Series. Peripheral units of the conventional KV Series such as the ladder supportsoftware "KV IncrediWare (DOS)" and "LADDER BUILDER for KV" and thehandheld programmer KV-P3E(01) can be used since they are part of the Visual KVSeries.However, it should be noted that the contents have changed as follows.
• 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 basicunit.
• 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 thefront 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 100mA.
• Conventional KV Series expansion units are not available as expansion units forthe Visual KV Series.
• The channel setting switch is not provided for expansion units. Channels aredetermined in connection order.
• Scans in expansion I/O units are not synchronous with the scan time in Visual KVSeries basic units.
• Assignment of special utility relays has partially changed.
• Data memory device Nos. DM1000 to DM1999 are assigned as special datamemories.
(4)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM5
Cautions when using the previous version of ladder support softwarePay strict attention to the following items when using the ladder support software.
• When using the ladder support software "KV IncrediWare (DOS)" or "LADDERBUILDER for KV Ver. 1.0x", set the model to "KV-300".
• DM0 to DM1999 are only available.
When the ladder support software "LADDER BUILDER for KV Ver. 1.0x" isused, do not use the monitor’s Change All function. If the Change All functionis used, the basic unit may be damaged. Never use the Change All function.
Peripheral units and other units incompatible with the Visual KV SeriesPeripheral units in the conventional KV Series and other units shown below are notcompatible 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
Cautions when Using the Serial PortThe KV-16xx/24xx/40xx units are equipped with two RJ-11 modular connectors forserial communication.When using them, pay strict attention to the following contents:
• Programs can be transferred and monitored using either communication port A orB. However, never connect the ladder software and a handheld programmer tothe two ports at the same time.
• The KV-D20 operator interface panel can be connected to either communicationport A or B. However, only one KV-D20 unit can be connected to a single basicunit.
• Never leave both the KV-D20 operator interface panel and KV-P3E(01) handheldprogrammer on simultaneously for a long period of time.
CAUTION
(5)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM6
(6)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM7
(7)
How this manual is organizedThe Visual KV Series User’s Manual is composed of 3 separate manuals;1-Installation, 2-Support Software, 3-Programming. Please read each manualrelevant to your purpose.
1 InstallationChapter 1 Configuration and Specifications [Visual KV Series Only]
Describes the system configuration of the Visual KV Series, the names and functions ofeach part, and the specifications.
Chapter 2 System Installation [Visual KV Series Only]Describes the installation and connection of each Visual KV Series unit as well assystem maintenance.
Chapter 3 Access Window [Visual KV Series Only]Describes the Access Window used for changing and monitoring data.
Chapter 4 KV-D20 Operator Interface Panel [Visual KV Series Only]Describes the KV-D20 Operator Interface Panel used for changing, monitoring, anddisplaying the status of inside relays, timers, counters and data memories.
Chapter 5 KV-300, KV-10/80 Hardware [KV-300, KV-10/80 Series Only]Describes the hardware specifications and wirings for KV-300 and KV-10/80 Series.
Chapter 6 Handheld ProgrammerDescribes how to use the handheld programmer and memory card.
Chapter 7 KV-L2 Serial Interface Module [KV-300 Series Only]Describes the serial interface modules for KV-300 Series.
Chapter 8 KV-AN6 Analog I/O Module [KV-300 Series Only]Describes the optional Analog I/O module for KV-300 Series
Chapter 9 KV-AD4/DA4 Analog I/O Unit [KV-10/80 Series Only]Describes the optional Analog I/O unit for KV-10/80 Series.
Chapter 10 TroubleshootingThis chapter describes the error code list, countermeasures against problems, and errorindications for each unit.
AppendicesThe appendix includes a list of ladder program applications and the index.
2 Support SoftwareChapter 1 Introduction
Describes the items included in the package, the product outline, the method to connecta personal computer, the installation method, etc.
KVNKA Front_Pro.p65 08.3.11, 0:13 PM8
(8)
Chapter 2 EditorDescribes the operating procedures in Editor mode.
Chapter 3 SimulatorDescribes the operating procedures in Simulator mode.
Chapter 4 MonitorDescribes the operating procedures in Monitor mode.
AppendicesIncludes instructions list, devices list, sample program list and quick reference for keyoperation and shortcuts.
3 ProgrammingChapter 1 Programming
Describes basic knowledge including program creation procedures, device configuration,relay assignments, special functions to set and confirm Visual KV Series operations, aswell as the extended ladder diagrams. Understand the contents described here com-pletely at first before creating programs.
Chapter 2 InstructionsDescribes 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-speedcounters used in the application instruction.
Chapter 3 Interrupts [Visual KV Series Only]The interrupt processing function executes an interrupt program when an external inputor request from the high-speed counter comparator (interrupt factor) is encounteredduring KV operation.This chapter describes the types of interrupt factors as well as inputs and outputsencountered during interrupt processing.
Chapter 4 High-speed Counters [Visual KV Series Only]Describes high-speed counters and high-speed counter comparators, which allow high-speed pulse measurement and pulse output, independent of the scan time.
Chapter 5 Positioning Control [Visual KV Series Only]Describes ramp-up/down control of stepping motors and servo motors.
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.
Chapter 7 Serial CommunicationThe KV Series can be connected to an external device with an RS-232C interface toestablish communication.This chapter describes communications specifications, how to connect the KV Series toexternal devices, and how to perform communication.
Chapter 8 Programming ExamplesDescribes the typical programming examples for KV-10/80 Series. These programs canbe used for Visual KV Series. However, pay attention to the I/O addressing compatibilitybefore use.
KVNKA Front_Pro.p65 08.3.11, 0:13 PM9
(9)
Contents 3 Programming
Chapter 1 Programming
1.1 Before Creating Programs ..............................................................................3-21.1.1 Flow from Introduction to Operation ...................................................................3-21.1.2 Scan Time ...........................................................................................................3-3
Scan time .....................................................................................................3-3Input response time delay ............................................................................3-3
1.2 User Memory ....................................................................................................3-41.2.1 Program Capacity ...............................................................................................3-4
Maximum number of lines in a program .......................................................3-4Calculating the byte count used ...................................................................3-4
1.3 Device Configuration .......................................................................................3-51.3.1 Device List ..........................................................................................................3-5
Relay list ......................................................................................................3-5List of I/O relays in basic units .....................................................................3-5List of relays in expansion units ...................................................................3-6
1.3.2 Relay No. ............................................................................................................3-7Address No. .................................................................................................3-7Contact No. ..................................................................................................3-8Channel No. .................................................................................................3-8
1.3.3 Assigning Relay Nos. ..........................................................................................3-81.3.4 Input Relays ........................................................................................................3-9
Basic unit .....................................................................................................3-9Expansion unit ...........................................................................................3-10
1.3.5 Output Relays ...................................................................................................3-10Output operation time ................................................................................3-10
1.3.6 Internal Utility Relays ........................................................................................3-11Retentive function of internal utility relays ..................................................3-11
1.3.7 Special Utility Relays ........................................................................................3-12Description .................................................................................................3-12
1.3.8 Special Utility Relay List ...................................................................................3-14Special relays and arithmetic operation flags ............................................3-14Special utility relays for high-speed counter(0) ..........................................3-14Special utility relays for high-speed counter(1) ..........................................3-15Other special utility relays ..........................................................................3-15
1.3.9 Timers and Counters ........................................................................................3-18Timer/Counter list .......................................................................................3-18Description .................................................................................................3-18
1.3.10 Data Memories .................................................................................................3-191.3.11 Temporary Data Memory ..................................................................................3-211.3.12 Relay Nos. and Functions .................................................................................3-22
1.4 Special Functions ..........................................................................................3-231.4.1 Input Time Constant Change Function .............................................................3-23
Setting the input time constant for basic units using special utility relays ..3-231.4.2 Modifying the Input Relay Time Constant .........................................................3-24
Modification within the CPU .......................................................................3-241.4.3 Constant Scan Time Mode ...............................................................................3-251.4.4 Output Disabled Function .................................................................................3-261.4.5 Input Refresh Disabled Function ......................................................................3-261.4.6 Contact Comment Save Function .....................................................................3-271.4.7 Special Functions .............................................................................................3-28
Constant Scan Time Mode ........................................................................3-28Output Disabled Function ..........................................................................3-28Input Refresh Disabled Function ................................................................3-28
1.5 Extended Ladder Diagrams ..........................................................................3-291.5.1 Features of Extended Ladder Diagrams ...........................................................3-291.5.2 Advantages of Extended Ladder Diagrams ......................................................3-301.5.3 Example of an Extended Ladder Diagram ........................................................3-31
KVNKA Front_Pro.p65 08.3.11, 0:13 PM10
(10)
Chapter 2 Instructions
2.1 Instruction List [Visual KV Series] ..............................................................3-342.1.1 Basic Instructions ..............................................................................................3-342.1.2 Application Instructions .....................................................................................3-362.1.3 Arithmetic Instructions ......................................................................................3-382.1.4 Interrupt Instructions .........................................................................................3-412.1.5 Function No. List (Alphabetical order) ..............................................................3-41
2.2 Instruction List [KV-300 Series, KV-10/80] .................................................3-422.2.1 Basic Instructions ..............................................................................................3-422.2.2 Application Instructions .....................................................................................3-452.2.3 Arithmetic Instructions ......................................................................................3-482.2.4 Interrupt Instructions .........................................................................................3-54
2.3 Convention Details ........................................................................................3-55
2.4 Instruction Details ..........................................................................................3-562.4.1 Basic Instructions ..............................................................................................3-562.4.2 Application Instructions .....................................................................................3-952.4.3 Arithmetic Instructions ....................................................................................3-134
2.5 Programming Notes .....................................................................................3-189
Chapter 3 Interrupts Visual KV
3.1 Interrupt Instructions ...................................................................................3-192
3.2 Interrupt Processing ....................................................................................3-1943.2.1 Interrupt Processing ........................................................................................3-1943.2.2 Types of Interrupts ..........................................................................................3-1953.2.3 Interrupt Priority ..............................................................................................3-1963.2.4 Interrupt Program ............................................................................................3-196
3.3 Direct Input/Output ......................................................................................3-1973.3.1 Direct Input .....................................................................................................3-1973.3.2 Direct Output ...................................................................................................3-197
3.4 Applications of Interrupt Programs ...........................................................3-1983.4.1 Interrupt with a Signal Converter ....................................................................3-1983.4.2 Interrupt with a High-speed Counter ...............................................................3-1993.4.3 Measuring the ON Time of High-speed Pulses ..............................................3-2003.4.4 Measuring the Period in which a Target Passes between Two Points ...........3-201
Chapter 4 High-speed Counters Visual KV
4.1 High-speed Counter Instructions ...............................................................3-204
4.2 Outline of High-speed Counters .................................................................3-2064.2.1 High-speed Counters and High-speed Counter Comparators ........................ 3-206
Structure of high-speed counters and high-speed counter comparators .3-206Specifications of high-speed counters .....................................................3-208High-speed counter comparators .............................................................3-209
4.2.2 Internal Clock for High-speed Counters ..........................................................3-210
4.3 Setting and Operation of High-speed Counters ........................................3-2114.3.1 Reading the Current Value of the High-speed Counter .................................. 3-2114.3.2 Preset Value of the High-speed Counter Comparator ....................................3-2114.3.3 Comparator Output .........................................................................................3-2114.3.4 Count Input Method ........................................................................................3-2124.3.5 Resetting the High-speed Counter .................................................................3-2144.3.6 Differences with the CTH Instruction between the
Conventional and Visual KV Series ................................................................3-2164.3.7 Applications of High-speed Counters .............................................................3-217
4.4 Extended Functions of High-speed Counters ...........................................3-2214.4.1 24-bit High-speed Counter ..............................................................................3-2214.4.2 Changing the Current Value of a 24-bit High-speed Counter .........................3-2234.4.3 Application Example of 24-bit High-speed Counter (single-phase input) .......3-2244.4.4 Ring Counter Function ....................................................................................3-2254.4.5 Applications of Ring Counters ........................................................................3-226
4.5 Special Functions Using High-speed Counters ........................................3-228
KVNKA Front_Pro.p65 08.3.11, 0:13 PM11
(11)
4.5.1 Specified Frequency Pulse Output Function ..................................................3-2284.5.2 Applications of the Specified Frequency Pulse Output ...................................3-2294.5.3 Frequency Counter Function ..........................................................................3-2314.5.4 Applications of Frequency Counters ...............................................................3-2324.5.5 Cam Switch Function ......................................................................................3-233
Cam switch mode ....................................................................................3-233Multi-step comparator mode ....................................................................3-234Setting method .........................................................................................3-234
4.5.6 Application of the Cam Switch (Cam Switch Mode) ....................................... 3-236
4.6 Direct Clock Pulse Output ...........................................................................3-2374.6.1 Outline of Direct Clock Pulse Output ..............................................................3-2374.6.2 Pulse Output Setting with the High-speed Counter Comparator ....................3-238
Changing the pulse period and width .......................................................3-238Calculating the pulse period and comparator preset value ......................3-239Operation with special utility relays ..........................................................3-239
4.7 Examples of Direct Clock Pulse Output ....................................................3-2424.7.1 Example of Outputting a Pulse with 1:1 ON/OFF Ratio .................................. 3-2424.7.2 Example of Outputting a Pulse with Variable ON/OFF Ratio .......................... 3-2454.7.3 Example of Stopping the Pulse Output at a Specified Pulse Count ...............3-2494.7.4 Application of Direct Clock Pulse Output (Ramp-up/down control) ................3-251
Chapter 5 Positioning Control Visual KV
5.1 Outline of Positioning Control ....................................................................3-2545.1.1 Ramp-up/down Control ...................................................................................3-254
5.2 Parameter Setting and Operating Procedures ..........................................3-2555.2.1 Parameter Setting Procedure .........................................................................3-2555.2.2 Operating Procedure ......................................................................................3-257
5.3 Examples of Using the Positioning Control Function ..............................3-2585.3.1 Connection Example .......................................................................................3-2585.3.2 Tips .................................................................................................................3-2585.3.3 Application Examples of the Positioning Control Function ............................. 3-259
Chapter 6 Interrupts, High-speed Counters,Positioning Control KV-300, KV-10/80
6.1 Interrupt Instructions ...................................................................................3-2686.1.1 Description of Interrupts ..................................................................................3-268
Input processing for routine program and interrupt routine ......................3-268Types of interrupt .....................................................................................3-268Interrupt priority ........................................................................................3-269Interrupt routine ........................................................................................3-269Direct output .............................................................................................3-270Direct input ...............................................................................................3-270
6.1.2 Interrupt Instructions .......................................................................................3-271
6.2 Direct Clock Pulse ........................................................................................3-2766.2.1 Output of Direct Clock Pulse ...........................................................................3-276
Outline of High-Speed Counters ..............................................................3-276Outline of Pulse Output ............................................................................3-279Examples of Pulse Output .......................................................................3-284
6.3 Positioning Control ......................................................................................3-2966.3.1 Positioning Control (Ramp-up/down Control) .................................................3-296
Outline of positioning control ....................................................................3-296Setting and application of parameters .....................................................3-297Examples of stepping motor control .........................................................3-300
Chapter 7 Serial Communication
7.1 Communications Specifications ................................................................3-3067.1.1 Communications Specification ........................................................................3-3067.1.2 Connection with the KV Unit ...........................................................................3-3067.1.3 Connecting the KV-300 CPU to a Personal Computer ...................................3-307
7.2 Serial Communication .................................................................................3-3087.2.1 Command Transmission Procedure ...............................................................3-308
KVNKA Front_Pro.p65 08.3.11, 0:13 PM12
(12)
7.2.2 Format of Commands/Responses ..................................................................3-3097.2.3 Communication Command/Response List .....................................................3-3107.2.4 Setting Communication Commands and Responses to Commands .............. 3-3117.2.5 Other Response Codes ..................................................................................3-3157.2.6 Error Code List ................................................................................................3-3167.2.7 Example Program ...........................................................................................3-317
7.3 Loading Text Data ........................................................................................3-3187.3.1 Receiving Text Data .......................................................................................3-3187.3.2 Transmitting Text Data ...................................................................................3-3197.3.3 Sample Program .............................................................................................3-320
7.4 ASCII Code List ............................................................................................3-321
Chapter 8 Programming Examples
8.1 List .........................................................................................................3-324
8.2 Details .........................................................................................................3-3268.2.1 Reference Program Examples ........................................................................3-326
Basic Instructions .....................................................................................3-326Application Instructions ............................................................................3-334Arithmetic Instructions ..............................................................................3-343
WARRANTIES AND DISCLAIMERS 3-367
1 Installation
Chapter 1 Configuration and Specifications Visual KV
1.1 System Configuration ......................................................................................1-21.1.1 System Configuration .........................................................................................1-2
1.2 Specifications ...................................................................................................1-41.2.1 General Specifications ........................................................................................1-41.2.2 AC Power Specifications ....................................................................................1-5
Visual KV Series operation at power interruption ........................................1-51.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-81.3.1 Model of a Basic Unit ..........................................................................................1-81.3.2 Common I/O Specifications ................................................................................1-8
1.4 KV-10AR/AT(P)/DR/DT(P) (10-I/O Basic Unit) .............................................1-101.4.1 Part Names and Functions ...............................................................................1-101.4.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................1-11
KV-10AR/DR (Relay output type) ..............................................................1-11KV-10AT(P)/DT(P) (Transistor output type) ...............................................1-13
1.4.3 AC Power Input (KV-10AR/AT(P)) ....................................................................1-141.4.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-151.4.5 Dimensions .......................................................................................................1-16
1.5 KV-16AR/AT(P)/DR/DT(P) (16-I/O Basic Unit) .............................................1-171.5.1 Part Names and Functions ...............................................................................1-171.5.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................1-18
KV-16AR/DR (Relay output type) ..............................................................1-18KV-16AT(P)/DT(P) (Transistor output type) ...............................................1-20
1.5.3 AC Power Input (KV-16AR/AT(P)) ....................................................................1-211.5.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-221.5.5 Dimensions .......................................................................................................1-23
1.6 KV-24AR/AT(P)/DR/DT(P) (24-I/O Basic Unit) .............................................1-241.6.1 Part Names and Functions ...............................................................................1-241.6.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................1-25
KV-24AR/DR (Relay output type) ..............................................................1-25KV-24AT(P)/DT(P) (Transistor output type) ...............................................1-27
1.6.3 AC Power Input (KV-24AR/AT(P)) ....................................................................1-281.6.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-291.6.5 Dimensions .......................................................................................................1-30
1.7 KV-40AR/AT(P)/DR/DT(P) (40-I/O Basic Unit) ..............................................1-31
KVNKA Front_Pro.p65 08.3.11, 0:13 PM13
(13)
1.7.1 Part Names and Functions ...............................................................................1-311.7.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................1-32
KV-40AR/DR (Relay output type) ..............................................................1-32KV-40AT(P)/DT(P) (Transistor output type) ...............................................1-34
1.7.3 AC Power Input (KV-40AR/AT(P)) ....................................................................1-351.7.4 Relationship between Continuous Simultaneous ON Ratio and Ambient Temperature 1-361.7.5 Dimensions .......................................................................................................1-37
1.8 KV-E4X/E8X/E16X (Expansion Input Unit) ..................................................1-381.8.1 Part Names and Functions ...............................................................................1-381.8.2 Input Specifications ...........................................................................................1-381.8.3 Terminal Layout Drawings and Input Circuit Diagrams ....................................1-39
KV-E4X (4-I/O expansion input unit) ..........................................................1-39KV-E8X (8-I/O expansion input unit) ..........................................................1-40KV-E16X (16-I/O expansion input unit) ......................................................1-41
1.8.4 Dimensions .......................................................................................................1-42
1.9 KV-E4R/E4T/E8R/E8T(P)/E16R/E16T(P) (Expansion Output Unit) .............1-431.9.1 Part Names and Functions ...............................................................................1-431.9.2 Output Specifications ........................................................................................1-43
KV-E4R/E8R/E16R (Relay output type) .....................................................1-44KV-E4T/E8T(P)/E16T(P) [Transistor output type (NPN/PNP)] ..................1-44
1.9.3 Terminal Layout Drawings and Input Circuit Diagrams ....................................1-45KV-E4R [4-I/O expansion output unit (relay output type)] ..........................1-45KV-E4T [4-I/O expansion output unit transistor output type)] ....................1-46KV-E8R [8-I/O expansion output unit (relay output type)] ..........................1-47KV-E8T(P) [8-I/O expansion output unit (transistor output type)] ..............1-48KV-E16R [16-I/O expansion output unit (relay output type)] ......................1-49KV-E16T(P) [16-I/O expansion input unit (transistor output)] ....................1-50
1.9.4 Dimensions .......................................................................................................1-51
1.10 KV-E4XR/E4XT(P) (Expansion I/O Unit) .......................................................1-521.10.1 Part Names and Functions ...............................................................................1-521.10.2 Input Specifications ...........................................................................................1-531.10.3 Output Specifications ........................................................................................1-53
KV-E4XR (Relay output type) ....................................................................1-53KV-E4XT(P) (Transistor output type) .........................................................1-53
1.10.4 Terminal Layout Drawings and Input Circuit Diagrams ....................................1-54KV-E4XR (Relay output type) ....................................................................1-54KV-E4XT(P) (Transistor output type) .........................................................1-56
1.10.5 Dimensions .......................................................................................................1-58
1.11 KV-D20 (Operator Interface Panel) ...............................................................1-591.11.1 Part Names and Functions ...............................................................................1-591.11.2 General Specifications ......................................................................................1-601.11.3 Functional Specifications ..................................................................................1-601.11.4 Dimensions .......................................................................................................1-61
Chapter 2 System Installation Visual KV
2.1 Installation Environment ...............................................................................1-642.1.1 Installation Environment ...................................................................................1-642.1.2 Installation Position ...........................................................................................1-652.1.3 Installation Procedure .......................................................................................1-66
Expansion unit spacer ................................................................................1-662.1.4 Cautions on Wiring for Each Unit ......................................................................1-67
Wiring procedures for basic units ...............................................................1-67Cautions on wiring for I/O units ..................................................................1-68Terminal .....................................................................................................1-68Cautions on grounding ...............................................................................1-69
2.1.5 Contact Protection ............................................................................................1-69
2.2 Connecting Visual KV Series Expansion Units ..........................................1-702.2.1 Visual KV Series Expansion Units ....................................................................1-702.2.2 Connecting Visual KV Series Expansion Units .................................................1-71
Connection methods ..................................................................................1-72Number of connectable units .....................................................................1-73
2.2.3 Confirming the Connection Settings of Expansion Units ..................................1-74Expansion unit relay list .............................................................................1-74Connection information for expansion units ...............................................1-75Input time constant for expansion units .....................................................1-76
KVNKA Front_Pro.p65 08.3.11, 0:13 PM14
(14)
Clearing the input value when disconnecting .............................................1-762.2.4 Transferring I/O Information between Expansion Units and the Basic Unit ......1-77
When inputting ...........................................................................................1-77In the case of output ..................................................................................1-77
2.3 Inspection and Maintenance .........................................................................1-782.3.1 Inspection .........................................................................................................1-782.3.2 Maintenance .....................................................................................................1-78
Chapter 3 Access Window Visual KV
3.1 Overview of the Access Window ..................................................................1-803.1.1 What is the Access Window .............................................................................1-803.1.2 Access Window Use Examples ........................................................................1-80
3.2 Basic Operating Procedures .........................................................................1-813.2.1 Operation Mode ................................................................................................1-813.2.2 Access Window Modes .....................................................................................1-813.2.3 Part Names and Functions of the Access Window ...........................................1-823.2.4 Selecting Modes and Setting/Resetting Key Lock ............................................1-823.2.5 Turbo Function ..................................................................................................1-83
3.3 Digital Trimmer Mode ....................................................................................1-843.3.1 Function and Operating Procedure ...................................................................1-84
Key operation and screen display ..............................................................1-84Function and operating procedure .............................................................1-84
3.4 Device Mode ...................................................................................................1-873.4.1 Function and Operating Procedure ...................................................................1-87
Devices that can be displayed and changed .............................................1-87Key operation and screen display ..............................................................1-87Selecting the device and displaying the current value/set value ................1-88Changing a numeric value .........................................................................1-89Holding the setting .....................................................................................1-91
3.4.2 Screen Display for Each Device Type ..............................................................1-91Data memory (DM) ....................................................................................1-91Temporary data memory (TM) ...................................................................1-91Timer/counter (T/C) ....................................................................................1-92High-speed counter comparator (CTC) ......................................................1-92Trimmer (TRM) ..........................................................................................1-93Relay (RLY) ...............................................................................................1-93
3.5 System Mode ..................................................................................................1-943.5.1 Function and Operating Procedure ...................................................................1-94
Key operation and screen display ..............................................................1-94LOAD mode and SAVE mode ....................................................................1-96Display in LOAD/SAVE mode ....................................................................1-96
3.6 Message Display ............................................................................................1-973.6.1 Error Messages and Error Status .....................................................................1-973.6.2 User Messages .................................................................................................1-97
How to use the user messages ..................................................................1-98
Chapter 4 KV-D20 Operator Interface Panel Visual KV
4.1 Before Operation ..........................................................................................1-1004.1.1 Checking Package Contents ..........................................................................1-1004.1.2 Part Names and Functions .............................................................................1-1014.1.3 Details about the KV-D20 ...............................................................................1-102
General specifications ..............................................................................1-102Functional specifications ..........................................................................1-102Dimensions ..............................................................................................1-103
4.1.4 Installation and Environment ..........................................................................1-104Use environment ......................................................................................1-104Panel mounting ........................................................................................1-105
4.1.5 Inspection and Maintenance ...........................................................................1-106Inspection .................................................................................................1-106Maintenance ............................................................................................1-106
4.2 Overview and Operation ..............................................................................1-1074.2.1 Use Examples for the KV-D20 ........................................................................1-107
KVNKA Front_Pro.p65 08.3.11, 0:13 PM15
(15)
4.2.2 Connection with the KV Series .......................................................................1-108Connection ...............................................................................................1-108Precautions ..............................................................................................1-108
4.2.3 Overview of the KV-D20 .................................................................................1-109Switching the display mode .....................................................................1-109Overview of each display mode ...............................................................1-110Assignment of relays/DM .........................................................................1-111Other functions .........................................................................................1-112Precautions about screen change function ..............................................1-115
4.2.4 Operator Mode ................................................................................................1-117Screen selection in operator mode ..........................................................1-117Operator screen .......................................................................................1-118Direct access screen ................................................................................1-126KV-I/O monitor screen .............................................................................1-127Switch comment screen ...........................................................................1-128Lamp comment screen ............................................................................1-128Screen change permission in operator mode ..........................................1-129
4.2.5 Device Mode ...................................................................................................1-130Device mode ............................................................................................1-130Operation example for device mode ........................................................1-132
4.2.6 System Mode ..................................................................................................1-134System mode ...........................................................................................1-134
4.3 Examples of Ladder Programs ...................................................................1-1354.3.1 Basic Ladder Programs ..................................................................................1-135
Before creating ladder programs .............................................................1-135Basic ladder programs .............................................................................1-136
4.3.2 Examples of Ladder Programs .......................................................................1-143Example of displaying user messages .....................................................1-143Example of displaying messages with titles .............................................1-145Example of position control ......................................................................1-146Example of frequency counter .................................................................1-149Example of 24-bit high-speed counter .....................................................1-152Example of cam switch function ...............................................................1-154
4.4 Appendix .......................................................................................................1-1584.4.1 Troubleshooting ..............................................................................................1-1584.4.2 Available Character List ..................................................................................1-1624.4.3 Comment Draft Sheet .....................................................................................1-163
Chapter 5 KV-300, KV-10/80 Hardware KV-300, KV-10/80
5.1 System Configuration ..................................................................................1-1665.1.1 KV-300 ............................................................................................................1-1665.1.2 KV-10/80 .........................................................................................................1-167
5.2 Module/Unit Specifications .........................................................................1-1685.2.1 Wiring: KV-U4 Power Supply Module .............................................................1-168
Parts and functions ..................................................................................1-1685.2.2 Wiring: KV-U5 DC Power Distribution Module ................................................1-169
Parts and functions ..................................................................................1-1695.2.3 Wiring: KV-300 CPU .......................................................................................1-170
Parts and functions ..................................................................................1-1705.2.4 Wiring: KV-C16X/C32X Connector Input Module ...........................................1-171
Parts and functions ..................................................................................1-1715.2.5 Wiring: KV-C32T/B16R/B16S Connector Output Module ............................... 1-172
Parts and functions ..................................................................................1-1725.2.6 Wiring: KV-R1A I/O Distribution Module .........................................................1-173
Parts and functions ..................................................................................1-1735.2.7 Wiring: KV-R8X/R16X/R8R/R16R/R8T/R16T I/O Terminal Modules .............1-174
Parts and functions ..................................................................................1-1745.2.8 Module Names and Functions ........................................................................1-1755.2.9 Peripheral Equipment Names and Functions .................................................1-176
5.3 Module/Unit Connections ............................................................................1-1785.3.1 Environmental Requirements .........................................................................1-1785.3.2 Installation Guidelines .....................................................................................1-1785.3.3 Assembling the System ..................................................................................1-179
Connecting modules ................................................................................1-1795.3.4 Mounting to the DIN Rail .................................................................................1-1805.3.5 Removing the Terminal Block .........................................................................1-181
KVNKA Front_Pro.p65 08.3.11, 0:13 PM16
(16)
5.3.6 Connecting the AC Power Supply Module and DC Power Distribution Module .... 1-182KV-U4 AC Power Supply Module ............................................................1-182KV-U5 DC Power Distribution Module .....................................................1-182
5.3.7 I/O Connectors ................................................................................................1-183KV-300 CPU ............................................................................................1-183KV-C16X/C32X ........................................................................................1-184KV-C32T/B16R/B16S ..............................................................................1-185KV-R8X/R16X/R8R/R16R/R8T/R16T ......................................................1-186
5.3.8 I/O Terminal Modules: Communication Cables and Power Distribution ......... 1-187Transmission distance by cable type .......................................................1-187Connection patterns .................................................................................1-187Incorrect wiring patterns ...........................................................................1-188Power distribution ....................................................................................1-188
5.3.9 Connector Assembly Instructions ...................................................................1-1895.3.10 KV-300 CPU I/O Indicators .............................................................................1-1915.3.11 KV-10/80 Expansion Units ..............................................................................1-1925.3.12 Mounting Environment ....................................................................................1-194
Chapter 6 Handheld Programmer
6.1 Using the Handheld Programmer ...............................................................1-1966.1.1 Outline of the Handheld Programmer .............................................................1-1966.1.2 Precautions .....................................................................................................1-198
6.2 Basic Operations .........................................................................................1-2006.2.1 Basic Programming Operation ........................................................................1-200
6.3 Functions ......................................................................................................1-216Function Nos. list .....................................................................................1-216ALL CLEAR ..............................................................................................1-217HANDHELD PROGRAMMER CLEAR.....................................................1-217COUNTER CLEAR ..................................................................................1-218HIGH-SPEED COUNTER CLEAR ...........................................................1-218ALL DATA MEMORY CLEAR ..................................................................1-219ALL LATCHING RELAYS RESET ...........................................................1-219PROGRAM SENT OR RECEIVED ..........................................................1-220OFFLINE EDITOR START ......................................................................1-221OFFLINE EDITOR STOP ........................................................................1-221TIMER/COUNTER CURRENT VALUE CHANGE ...................................1-222TIMER/COUNTER SETTING CHANGE ..................................................1-224RELAY ON/OFF .......................................................................................1-226WRITE INTO DATA MEMORY ................................................................1-227READ TRIMMER SETTING.....................................................................1-228SYNTAX CHECK .....................................................................................1-228PROGRAM CAPACITY CHECK ..............................................................1-229
6.4 Memory Card ................................................................................................1-2306.4.1 Functions [used with KV-P3E(01)] ..................................................................1-2306.4.2 Storage Capacity ............................................................................................1-230
CLEAR .....................................................................................................1-232NEW .........................................................................................................1-233ACCS .......................................................................................................1-234ACCS: SAVE ...........................................................................................1-235ACCS: LOAD ...........................................................................................1-236ACCS: VERIFY ........................................................................................1-236ACCS: DELETE .......................................................................................1-237
Chapter 7 KV-L2 Serial Interface Module KV-300
7.1 Outline .........................................................................................................1-2407.1.1 Features ..........................................................................................................1-240
7.2 Configuration ...............................................................................................1-2417.2.1 Parts and Functions ........................................................................................1-2417.2.2 System Configuration .....................................................................................1-2427.2.3 Outline of Operation Modes ............................................................................1-244
7.3 Installation ....................................................................................................1-2457.3.1 Setting the Operation Mode ............................................................................1-2457.3.2 Communications Protocols .............................................................................1-2477.3.3 Connector Wiring ............................................................................................1-248
KVNKA Front_Pro.p65 08.3.11, 0:13 PM17
(17)
7.3.4 Connecting to External Units ..........................................................................1-249Connecting to An External Display ..........................................................1-249Connecting to an IBM PC-AT Computer ..................................................1-249Connecting to the KV-10/16/24/40/80 ......................................................1-250Connecting KV-L2s ..................................................................................1-250
7.4 Software Setup .............................................................................................1-2527.4.1 Using KV Software [KV IncrediWare (DOS)] ..................................................1-252Starting KV IncrediWare (DOS) from the KV-L2 ........................................................1-252
7.5 KV Mode Programming ...............................................................................1-2537.5.1 Operating in KV Mode ....................................................................................1-253
Communications protocol ........................................................................1-2537.5.2 Serial Communications Procedure .................................................................1-255
Command transmission procedure ..........................................................1-255Command/response format .....................................................................1-256Communications commands and responses ...........................................1-256Communications commands ....................................................................1-257
7.5.3 Transmission and Reception of Text Data ......................................................1-262Assigning relay nos. and data memory address nos. ..............................1-262Transmitting Text Data .............................................................................1-264Receiving text data ..................................................................................1-265ASCII code/binary conversion function ....................................................1-266Example program.....................................................................................1-269
7.6 Display Interface Mode Programming .......................................................1-2707.6.1 Operating in Display Interface Mode ..............................................................1-270
Communications protocols .......................................................................1-270Communications control procedure .........................................................1-271
7.6.2 Command and Response Format ...................................................................1-2737.6.3 Commands and Responses ...........................................................................1-275
List of commands and responses ............................................................1-275Description of commands and responses ................................................1-277End codes ................................................................................................1-291
7.7 Non-procedure Mode Programming ..........................................................1-2927.7.1 Operating in Non-procedure Mode .................................................................1-292
Communications protocol ........................................................................1-292Connecting to the KV-L2 ..........................................................................1-293
7.7.2 Assignment of Relay Nos. and Data Memory Address Nos. .......................... 1-294Assigning relay nos. and data memory address nos. ..............................1-294
7.7.3 Transmitting Text Data ...................................................................................1-297Data transmission and internal data memory addresses .........................1-297
7.7.4 Receiving Text Data .......................................................................................1-298Format of received data and data memory addresses ............................1-298
7.7.5 ASCII code/Binary Conversion Function ........................................................1-300
7.8 Troubleshooting Guide ...............................................................................1-3047.8.1 Troubleshooting ..............................................................................................1-3047.8.2 Precautions .....................................................................................................1-305
7.9 Specifications ...............................................................................................1-3067.9.1 Specifications ..................................................................................................1-306
General specifications ..............................................................................1-306Communications protocol ........................................................................1-306RS-232C connector specifications ...........................................................1-306RS-422A terminal block specifications .....................................................1-306
7.9.2 Dimensions .....................................................................................................1-307
7.10 Command List ..............................................................................................1-3087.10.1 List of Commands and Responses .................................................................1-3087.10.2 List of Commands and Responses in Display Interface mode ....................... 1-309
Chapter 8 KV-AN6 Analog I/O Module KV-300
8.1 Outline .........................................................................................................1-312Features ...................................................................................................1-312
8.2 Configuration ...............................................................................................1-3138.2.1 Parts and Functions ........................................................................................1-3138.2.2 System Configuration .....................................................................................1-314
8.3 Installation ....................................................................................................1-3158.3.1 Terminal Nos. .................................................................................................1-315
KVNKA Front_Pro.p65 08.3.11, 0:13 PM18
(18)
8.3.2 Removing the Terminal Block .........................................................................1-3168.3.3 Example of Voltage I/O Wiring ........................................................................1-3178.3.4 Example of Current I/O Wiring ........................................................................1-3188.3.5 Setting I/O Ranges .........................................................................................1-319
8.4 Programming ................................................................................................1-3208.4.1 Input Characteristics (A/D) ..............................................................................1-3208.4.2 Calculating Input Data (A/D) ...........................................................................1-3218.4.3 Output Characteristics (D/A) ...........................................................................1-3228.4.4 Calculating Output Data (D/A) ........................................................................1-3238.4.5 Assigning Data Memory (DM) Addresses .......................................................1-3248.4.6 Reading Analog Input .....................................................................................1-3258.4.7 Measuring Analog Input Average ...................................................................1-3268.4.8 Writing Analog Output .....................................................................................1-3278.4.9 Converting Analog Input to Analog Output .....................................................1-328
8.5 KV-AN6 Appendices ....................................................................................1-3298.5.1 Troubleshooting ..............................................................................................1-3298.5.2 Precautions .....................................................................................................1-3308.5.3 Specifications ..................................................................................................1-331
Environmental specifications ...................................................................1-331System specifications ..............................................................................1-331
8.5.4 Dimensions .....................................................................................................1-332
Chapter 9 KV-AD4/DA4 Analog I/O Unit KV-10/80
9.1 Outline .........................................................................................................1-334Features ...................................................................................................1-334
9.2 Configuration ...............................................................................................1-3359.2.1 Part Names and Functions .............................................................................1-335
KV-AD4 ....................................................................................................1-335KV-DA4 ....................................................................................................1-336
9.2.2 Specifications ..................................................................................................1-337KV-AD4 ....................................................................................................1-337KV-DA4 ....................................................................................................1-339
9.2.3 System Configuration .....................................................................................1-341
9.3 Installation ....................................................................................................1-3429.3.1 Installation Procedure .....................................................................................1-3429.3.2 Checking the Installation Environment ...........................................................1-3439.3.3 Setting the KV-AD4 Input Mode ......................................................................1-344
Setting the input mode .............................................................................1-3449.3.4 Connecting External Instruments ....................................................................1-345
Wiring .......................................................................................................1-345Wiring diagrams .......................................................................................1-346
9.3.5 Connecting to the KV-10 to 80 ........................................................................1-3489.3.6 Maintenance ...................................................................................................1-349
Inspection and Cleaning ..........................................................................1-349
9.4 Programming ................................................................................................1-3509.4.1 Programming the KV-AD4 ..............................................................................1-350
A/D Conversion Mechanism ....................................................................1-350About Digital Data after A/D Conversion ..................................................1-351Calculating Voltage and Current Values from Digital Data ......................1-352
9.4.2 Programming the KV-DA4 ..............................................................................1-353D/A Conversion Mechanism ....................................................................1-353Converting Digital Data to Voltage or Current Values to be Output ......... 1-354Writing Digital Data to Data Memory for D/A Conversion ........................ 1-356
9.4.3 A/D and D/A Conversion Tables .....................................................................1-357Voltage Conversion Table ........................................................................1-357Current Conversion Table ........................................................................1-358
9.5 Programming Examples ..............................................................................1-359Calculating Analog Data Values from Digital Data ...................................1-359Writing Data to be Analog-output .............................................................1-361Outputting Analog Trimmer Values ..........................................................1-364Outputting Analog Input Data ...................................................................1-365Outputting Analog Input from a Pressure Sensor to an Air Valve ............1-366Setting the Minimum and Maximum Voltage Limits and Measuring theAverage Voltage ......................................................................................1-367
9.6 Troubleshooting ...........................................................................................1-370
KVNKA Front_Pro.p65 08.3.11, 0:13 PM19
(19)
Chapter 10 Troubleshooting
10.1 Error List .......................................................................................................1-37210.1.1 List of Error Codes in Basic Units ...................................................................1-37210.1.2 Error indication in Expansion Units .................................................................1-37410.1.3 Program Errors ...............................................................................................1-37510.1.4 Memory Card Errors and Other Errors ...........................................................1-376
10.2 Replacing Relays .........................................................................................1-377Replacement procedure ...........................................................................1-377
10.3 Troubleshooting ...........................................................................................1-37810.3.1 Troubleshooting List .......................................................................................1-378
10.4 Error Messages ............................................................................................1-380
Appendices
Appendix A. Specifications and Dimensions [Visual KV Series] ....................1-382A.1 System Specifications [Visual KV Series] .......................................................1-382
Hardware .................................................................................................1-382Software and Programming .....................................................................1-383AC power supply unit ...............................................................................1-384
A.2 Common I/O Specifications of Basic Units .....................................................1-384Input specifications ..................................................................................1-384Output specifications (relay output): KV-10AR/DR, KV-16AR/DR,KV-24AR/DR, and KV-40AR/DR ..............................................................1-385Output 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-385A.4 Dimensions .....................................................................................................1-389
Appendix B. Specifications and Dimensions [KV-300 Series] .........................1-392B.1 System Specifications [KV-300 Series] ..........................................................1-392
Hardware .................................................................................................1-392Software and Programming .....................................................................1-393AC Power supply module/DC power distribution module ........................ 1-394
B.2 Module Specifications .....................................................................................1-398KV-300 CPU ............................................................................................1-398KV-C16X/C32X Input Modules ................................................................1-399KV-C32T/B16R/B16S Output Modules ...................................................1-400KV-R8X/R16X I/O Terminal Modules .......................................................1-401KV-R8T/R16T/R8R/R16R I/O Terminal Modules .....................................1-402KV-R8T/R16T/R8R/R16R I/O Terminal Modules (RUN Output) .............. 1-403KV-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-408Voltage conversion table ..........................................................................1-408Current 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-31.2.1 Operating environment and system configuration ..............................................2-31.2.2 Features and functions of the Ladder Builder for KV ..........................................2-4
Features of the Ladder Builder for KV .........................................................2-4Functions of the Ladder Builder for KV ........................................................2-6
1.3 Before Programming .......................................................................................2-7Machines to be prepared .............................................................................2-7
1.3.1 Differences from the KV IncrediWare (DOS) ......................................................2-81.3.2 Differences from the Ladder Builder for KV Ver 1.0 ...........................................2-8
1.4 Installing the Software .....................................................................................2-9
KVNKA Front_Pro.p65 08.3.11, 0:13 PM20
(20)
1.4.1 Preparation for installation ..................................................................................2-91.4.2 Installation Procedure .......................................................................................2-10
Installation in Windows 95 .........................................................................2-10Installation in Windows 3.1 ........................................................................2-12
1.5 Cautions for Use ............................................................................................2-13
1.6 Basic Operations ...........................................................................................2-141.6.1 Program creation flow and available modes .....................................................2-141.6.2 Starting up and exiting from the software .........................................................2-161.6.3 Screen ..............................................................................................................2-181.6.4 Mouse operation and keyboard operation ........................................................2-211.6.5 Online Help .......................................................................................................2-23
Chapter 2 Editor KV-300
2.1 Outline of the Editor Functions ....................................................................2-262.1.1 Cautions for editing ladder programs ................................................................2-26
2.2 Edit Screen .....................................................................................................2-272.2.1 Name and function of each part of the screen ..................................................2-272.2.2 Ladder program window screen .......................................................................2-28
2.3 File Management ............................................................................................2-292.3.1 Creating a new file ............................................................................................2-292.3.2 Setting the automatic file read function .............................................................2-302.3.3 Setting automatic file save for the file ...............................................................2-312.3.4 Saving and reading files ...................................................................................2-322.3.5 Reading and saving a file in another format .....................................................2-332.3.6 Saving a ladder diagram in text format .............................................................2-362.3.7 Verifying files ....................................................................................................2-36
2.4 Entering/Deleting Symbols and Connection Lines ....................................2-372.4.1 Entering symbols ..............................................................................................2-372.4.2 Deleting symbols ..............................................................................................2-422.4.3 Entering contacts/coils directly .........................................................................2-422.4.4 Changing the device at the current cursor position ..........................................2-432.4.5 Entering/Deleting connection lines ...................................................................2-442.4.6 Canceling edit operations .................................................................................2-45
2.5 Entering Comments/Labels .........................................................................2-462.5.1 Editing comments/labels ...................................................................................2-462.5.2 Editing line comments .......................................................................................2-502.5.3 Changing ladder lines into comments ...............................................................2-51
2.6 Edit and Arrangement ..................................................................................2-522.6.1 Copy, move, and delete ....................................................................................2-522.6.2 Inserting and deleting lines ...............................................................................2-57
2.7 Jump, Search, and Replace .........................................................................2-582.7.1 Jump .................................................................................................................2-582.7.2 Searching for instruction words/operands ........................................................2-622.7.3 Searching for the device at the cursor position .................................................2-632.7.4 Replacing operands ..........................................................................................2-642.7.5 Converting a/b contacts ....................................................................................2-65
2.8 Editing the Mnemonic List ...........................................................................2-672.8.1 Displaying and terminating a mnemonic list .....................................................2-672.8.2 Copy, move, and delete ....................................................................................2-69
2.9 Displaying the Use Status .............................................................................2-702.9.1 Displaying a use status list ...............................................................................2-70
2.10 Setting the System .........................................................................................2-712.10.1 Setting the system ............................................................................................2-71
2.11 Entering and Developing Macros ................................................................2-722.11.1 Creating a macro file .........................................................................................2-722.11.2 Entering and developing macros ......................................................................2-74
2.12 Compilation ....................................................................................................2-752.12.1 Executing compilation .......................................................................................2-752.12.2 Error display ......................................................................................................2-762.12.3 Double coil check ..............................................................................................2-76
2.13 Printing Functions .........................................................................................2-77
KVNKA Front_Pro.p65 08.3.11, 0:13 PM21
2.13.1 Printing ..............................................................................................................2-772.13.2 Preview display .................................................................................................2-81
2.14 Changing the Display Color on the Screen .................................................2-822.14.1 Changing display colors on the screen .............................................................2-82
Chapter 3 Simulator
3.1 Outline of the Simulator Functions ..............................................................2-843.1.1 Outline of the functions .....................................................................................2-843.1.2 Restrictions in the simulator ..............................................................................2-84
3.2 Starting up and Exiting from the Simulator .................................................2-863.2.1 Operating procedure for startup and exit ..........................................................2-863.2.2 Name and function of each part of the screen ..................................................2-88
3.3 Ladder Monitor ...............................................................................................2-893.3.1 Outline of the ladder monitor ............................................................................2-893.3.2 Executing scans ................................................................................................2-893.3.3 Executing steps ..............................................................................................2-1013.3.4 Jump and search ............................................................................................2-1053.3.5 Stop/reset and device all clear ........................................................................2-108
3.4 Monitor All ....................................................................................................2-1093.4.1 Outline of monitor all .......................................................................................2-1093.4.2 Displaying, saving, and reading the monitor all window .................................2-1093.4.3 Monitor all window ..........................................................................................2-1133.4.4 Registering devices ........................................................................................2-1133.4.5 Selecting and changing devices .....................................................................2-116
3.5 Registration Monitor ....................................................................................2-1193.5.1 Outline of the registration monitor ...................................................................2-1193.5.2 Displaying, saving, and reading the registration monitor ................................2-1193.5.3 Registration monitor window ...........................................................................2-1223.5.4 Registering devices ........................................................................................2-1223.5.5 Selecting and changing devices .....................................................................2-1233.5.6 Manipulating timing charts ..............................................................................2-1283.5.7 Printing out the registration monitor ................................................................2-131
Chapter 4 Monitor
4.1 Outline of the Monitor Functions ...............................................................2-1344.1.1 Outline of the functions ...................................................................................2-1344.1.2 Restrictions in the monitor ..............................................................................2-1344.1.3 Precautions for communication ......................................................................2-135
4.2 Communicating with the PLC .....................................................................2-1364.2.1 Setting the PLC communication parameters ..................................................2-1364.2.2 Setting the comment transfer ..........................................................................2-138
4.3 Starting up and Exiting from the Monitor ..................................................2-1394.3.1 Operating procedures for startup and exit ......................................................2-1394.3.2 Name and function of each part of the screen ................................................2-143
4.4 Ladder Monitor .............................................................................................2-1444.4.1 Outline of the ladder monitor ..........................................................................2-1444.4.2 Displaying the ladder monitor window ............................................................2-1444.4.3 PLC error check ..............................................................................................2-1444.4.4 Starting the monitor ........................................................................................2-1454.4.5 Stopping the monitor .......................................................................................2-1454.4.6 Screen displayed while the monitor is running ...............................................2-1464.4.7 Setting the PLC operation mode .....................................................................2-147
4.5 Monitor All and Registration Monitor .........................................................2-1484.5.1 Functions of the monitor all window ................................................................2-1484.5.2 Functions of the registration monitor ..............................................................2-148
4.6 Monitor Function ..........................................................................................2-1494.6.1 Disabling the input refresh/Disabling the output .............................................2-1494.6.2 Changing the current values all at once .........................................................2-1504.6.3 Device all clear ...............................................................................................2-154
(21)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM22
Appendices
Appendix A Error Message List .........................................................................2-156A-1 System errors .................................................................................................2-156A-2 Memory errors ................................................................................................2-156A-3 File errors ........................................................................................................2-157A-4 Installation errors ............................................................................................2-157A-5 Errors that occur in the editor .........................................................................2-158A-6 Errors that occur in the monitor/simulator .......................................................2-159A-7 Communication errors (displayed in the monitor) ...........................................2-159A-8 PLC errors ......................................................................................................2-160A-9 Errors that occur during compilation ...............................................................2-161
Appendix B Instruction List ...............................................................................2-163B-1 Basic instructions ............................................................................................2-163B-2 Application instructions ...................................................................................2-164B-3 Arithmetic instructions .....................................................................................2-165B-4 Interrupt instructions .......................................................................................2-166
Appendix C Relay No. List ..................................................................................2-167C-1 Relays, timers, counters, and memory numbers for each model ...................2-167
Appendix D Special Utility Relay List ................................................................2-168D-1 Special relays and arithmetic operation flags .................................................2-168D-2 Special utility relays for high-speed counter (0) ..............................................2-168D-3 Special utility relays for high-speed counter (1) ..............................................2-169D-4 Other special utility relays ...............................................................................2-169D-5 Memory switches ............................................................................................2-172D-6 Special memory list .........................................................................................2-172
Appendix E Devices for KV-10R(W)/T(W) to 80R(W)/T(W), KV-300 ................2-174E-1 Special utility relays ........................................................................................2-174E-2 Memory switches ............................................................................................2-176E-3 Special memory list .........................................................................................2-176
Appendix F Sample Program List .....................................................................2-178F-1 Description of sample ladder programs ..........................................................2-178
Appendix G Quick Reference .............................................................................2-180G-1 Editor ..............................................................................................................2-180G-2 Simulator .........................................................................................................2-188G-3 Monitor ............................................................................................................2-195
Appendix H Notes for Programming .................................................................2-201H-1 Circuits that must be modified ........................................................................2-201H-2 Precautions for programming .........................................................................2-202H-3 Programs which cannot be decompiled ..........................................................2-203
Appendix I List of Files Used ............................................................................2-204
Appendix J Countermeasures for Frequent Communication Errors ............2-205
WARRANTIES AND DISCLAIMERS 2-215
(22)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM23
WARRANTIES AND DISCLAIMERSSee 3-367.
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 contactthe sales office listed at the end of this manual if you have any questions orcomments 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 ortrademarks of their respective owners.
(23)
KVNKA Front_Pro.p65 08.3.11, 0:13 PM24
Chapter 1Programming
This chapter describes basic knowledge including program creation procedures,device configuration, relay assignments, special functions to set and confirm VisualKV Series operations, as well as the extended ladder diagrams. Understand thecontents described here completely at first before creating programs. For a detailed description of instructions, refer to "2.4. Instruction Details" (p.3-56).
1.1 Before Creating Programs .......................................................... 3-21.1.1 Flow from Introduction to Operation ........................................................... 3-21.1.2 Scan Time .................................................................................................. 3-3
1.2 User Memory ................................................................................ 3-41.2.1 Program Capacity ...................................................................................... 3-4
1.3 Device Configuration ................................................................... 3-51.3.1 Device List .................................................................................................. 3-51.3.2 Relay No. ................................................................................................... 3-71.3.3 Assigning Relay Nos. ................................................................................. 3-81.3.4 Input Relays ............................................................................................... 3-91.3.5 Output Relays .......................................................................................... 3-101.3.6 Internal Utility Relays ............................................................................... 3-111.3.7 Special Utility Relays ................................................................................ 3-121.3.8 Special Utility Relay List ........................................................................... 3-141.3.9 Timers and Counters ................................................................................ 3-181.3.10 Data Memories ......................................................................................... 3-191.3.11 Temporary Data Memory ......................................................................... 3-211.3.12 Relay Nos. and Functions ........................................................................ 3-22
1.4 Special Functions ...................................................................... 3-231.4.1 Input Time Constant Change Function .................................................... 3-231.4.2 Modifying the Input Relay Time Constant ................................................ 3-241.4.3 Constant Scan Time Mode....................................................................... 3-251.4.4 Output Disabled Function ......................................................................... 3-261.4.5 Input Refresh Disabled Function .............................................................. 3-261.4.6 Contact Comment Save Function ............................................................ 3-271.4.7 Special Functions ..................................................................................... 3-28
1.5 Extended Ladder Diagrams ...................................................... 3-291.5.1 Features of Extended Ladder Diagrams .................................................. 3-291.5.2 Advantages of Extended Ladder Diagrams ............................................. 3-301.5.3 Example of an Extended Ladder Diagram ............................................... 3-31
KVNKA Chap 01P.p65 08.3.11, 11:49 AM1
1.1 Before Creating Programs
3-2
1
Chapter 1 Programming
1.1 Before Creating ProgramsThis section describes what you should know before creating programs and opera-tions for the Visual KV Series.
1.1.1 Flow from Introduction to OperationThis section describes an overview of program creation procedures, functions used,and setting items.In the example described below, a latch circuit is created as a program for the VisualKV Series.
Introduction
Examining contents of operationsFigure 1 shows a latch circuit which operates as follows.
Pushbutton switch PB1: ONPushbutton switch PB2: OFF
Pilot lamp (PL) turns on.
Pushbutton switch PB1: OFFPushbutton switch PB2: OFF
Pilot lamp (PL) remainslit even if PB1 turnsOFF.
Pushbutton switch PB1: OFFPushbutton switch PB2: ON
Pilot lamp (PL) goes outwhen PB2 is set to ON.
Time chartON
OFF
ON
OFF
PLON
OFF
PB1 contact
PB2 contact
Fig. 1PB1 = N.O. contact switchPB2 = N.C. contact switch
PB1 PB2
RL(Relay)
PL
Next, a program is created that will use the same operation as this circuit to control a PLC.
Program examinationCircuit 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
PL
RL
RL
RL
PB1 PB2Relay (coil)
Relay (contact)
Relay (contact)Pilot lamp
Table 1
I/O device Contact No.Pushbutton switch PB1 (N.O. contact) Input relay (0000)
Pushbutton switch PB2 (N.C. contact) Input relay (0001)
Relay RL Internal relay (1000)
Pilot lamp PL Output coil (0500)
Program creationEdit a program using the "LADDER BUILDER for KV" programming support software creation tool.
Ladder diagram
0500
1000
1000
1000
0000 0001*
Coding listLD 0000OR 1000AND 0001OUT 1000LD 1000OUT 0500END
* Enter "N.O. (AND X001)" to 0001 touse N.C. contact.
Transferring and confirming the programTransfer the created program to the Visual KV Series, perform a test run, and then confirm operationswith the actual devices.
Operation
KVNKA Chap 01P.p65 08.3.11, 11:49 AM2
1.1 Before Creating Programs
3-3
11
Chapter 1 Programming
1.1.2 Scan TimeScan time
The Visual KV Series repeatedly executes a ladder based on the sequence circuitas follows.
The duration of time required to perform one cycle is called the scan time (or cycletime). The scan time varies based on program size and the instructions used in theprogram.
Input response time delayIn addition to the I/O processing time, there is also an input time delay in the VisualKV Series caused by the scan time. The input time delay is generated because theinput status can only be read during the input processing time. If the input status ischanged after input processing, the changed contents can only be read during thenext scan time.
In the figure below, 1 and 2 can be read but 3 cannot be read.
Reference: The maximum and minimum values of the input response time are asfollows.
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 ifits 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).
Input processing Writes the ON/OFF status of all input terminals to the inputmemory before executing the program.
Program execution
Reads the ON/OFF status of each device (internal utility relay,timer, counter, etc.) based on the instructions, and performsarithmetic operations.Writes the arithmetic operation result to the output memory.
Output processing Outputs the contents of the output memory to output terminals.
ON
OFF
1 2 3Input signal
Read Read
Out
put p
roce
ssin
g
Inpu
t pro
cess
ing
Programexecution
Scan time
Out
put p
roce
ssin
g
Inpu
t pro
cess
ing
Programexecution
Scan time
Out
put p
roce
ssin
g
Inpu
t pro
cess
ing
Programexecution
Out
put p
roce
ssin
g
Inpu
t pro
cess
ing
Programexecution
Out
put p
roce
ssin
g
Inpu
t pro
cess
ing
KVNKA Chap 01P.p65 08.3.11, 11:49 AM3
1.2 User Memory
3-4
1
Chapter 1 Programming
1.2 User MemoryThis section describes the allowable size (capacity) of a program which can becreated in the Visual KV Series.
1.2.1 Program CapacityWhen a user program is created for the Visual KV Series, the maximum number ofsteps a program can contain using the mnemonic diagram varies based on the bytecount of the instructions used. The instruction byte count is determined individuallyfor each instruction. For more about byte counts for each instruction, refer to "2.1 Instruction List" (p.3-34).
Maximum number of lines in a programIn the KV-10xx/16xx, a program with approximately 2,000 steps can be written. Inthe KV-24xx/40xx, a program with approximately 4,000 steps can be written.
• Total byte count of the memory used by instructions ≤ 6,000 bytes / 12,000bytes
• Total byte count of the memory used by objects of instructions ≤ 12,000bytes / 24,000 bytes
* In the description above, a value on the left side indicates the byte count forthe KV-10xx/16xx, while a value on the right side indicates the byte count forthe KV-24xx/40xx.
* The memory occupied by objects indicates the memory required to execute aprogram when operation is started.
For example, the allowable number of steps to be written can be calculated from thememory 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 byobjects of a program exceeds the specified memory capacity, the program cannotbe written or executed.
Calculating the byte count usedThe byte count used in this program can be calculated as shown in the table below.
T0000500
0000
0500
#00020T000
Line No. Instruction Operand Byte count Number of objects
00000 LD 0000 3 5
00001 OR 0500 3 4
00002 TMR 000#00020 2 7
00003 ANB T000 3 8
00004 OUT 0500 3 8
Total 14 bytes 32 bytes
KVNKA Chap 01P.p65 08.3.11, 11:49 AM4
1.3 Device Configuration
3-5
11
Chapter 1 Programming
1.3 Device Configuration"Device" is a general name for relays, registers, etc. processed by instructions.This section describes the available devices in the Visual KV Series and theirgeneral use.
1.3.1 Device ListRelay list
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 2700to 2715 are held even when the operation mode is changed from PROGRAM toRUN or when the power is turned off.
Note 2: Internal utility relays can be held by setting the MEMSW instruction
List of I/O relays in basic units
.oNyaleR esulamroNdeeps-hgiH
)1(esu)2(esudeeps-hgiH skrameR
0000syalertupnItupnitceriD(
)aeradewolla
stupnitpurretnI3TNIot0TNI
noisrevniytiraloP()dewolla
serutpactupnI
deeps-hgihfoesahpBsanoitcnufyehTnisyalerytilitufonoitacificepshguorhtsretnuoc
.01-VK1000
2000 –
3000 –
4000
syalertupnI
deeps-hgiHtupni0retnuoc
deeps-hgiH0retnuoc esahpA
tupni
–
5000deeps-hgiH
tupni1retnuocdeeps-hgiH
1retnuoc–
6000
–
deeps-hgiH0retnuoc esahpB
tupni
–
7000deeps-hgiH
1retnuoc–
8000deeps-hgiH
0retnuoc teserPtupni
–
9000deeps-hgiH
1retnuoc–
5140ot0100 syalertupnI –
0050
syalertuptuOtuptuotceriD()aeradewolla
tuptuo0retnuocdeeps-hgiH stniop07
1050deeps-hgiH
1retnuoctuptuo
ycneuqerfdeificepStuptuoeslup
–
2050 tuptuolortnocnwod/pu-pmaR –
3050 – –
5190ot4050 syalertuptuO stniop67
5191ot0001 syalerytilitulanretnI stniop061
5182ot0002 syalerytilitulaicepS stniop441
5192ot0092 syalerytilitulaicepS aeraegarotsnoitamrofniYEKH
51971ot0003 syalerytilitulanretnI stniop441,2
Model KV-10xx KV-16xx KV-24xx KV-40xx
Basic input relays 0000 to 0005 0000 to 0009 0000 to 0015 0000 to 0107
Basic output relays 0500 to 0503 0500 to 0505 0500 to 0507 0500 to 0515
KVNKA Chap 01P.p65 08.3.11, 11:49 AM5
1.3 Device Configuration
3-6
1
Chapter 1 Programming
List of relays in expansion units Input units
Output units
I/O units
* 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.
noitcennoCredro
X4E-VK X8E-VK X61E-VK
42/61/01-VK 04-VK 42/61/01-VK 04-VK 42/61/01-VK 04-VKtupnits1
eludom301ot001 302ot002 701ot001 702ot002 511ot001 512ot002
tupnidn2eludom
302ot002 303ot003 702ot002 703ot003 512ot002 513ot003
tupnidr3eludom
303ot003 304ot004 703ot003 704ot004 513ot003 514ot004
tupniht4eludom
304ot004 704ot004 514ot004
noitcennoCredro
R/)P(T4E-VK R/)P(T8E-VK R/)P(T61E-VK
tuptuots1eludom
306ot006 706ot006 516ot006
tuptuodn2eludom
307ot007 707ot007 517ot007
tuptuodr3eludom
308ot008 708ot008 518ot008
tuptuoht4eludom
309ot009 709ot009 519ot009
noitcennoCredro
)P(T/RX4E-VK
syalertupnI syalertuptuO
42/61/01-VK 04-VK 42/61/01-VK 04-VKtupnits1
eludom 301ot001 302ot002
tupnidn2eludom 302ot002 303ot003
tupnidr3eludom 303ot003 304ot004
tupniht4eludom 304ot004
tuptuots1eludom 306ot006 306ot006
tuptuodn2eludom 307ot007 307ot007
tuptuodr3eludom 308ot008 308ot008
tuptuoht4eludom 309ot009 309ot009
KVNKA Chap 01P.p65 08.3.11, 11:49 AM6
1.3 Device Configuration
3-7
11
Chapter 1 Programming
1.3.2 Relay No.The relay No. configuration is shown below.
Address No.Address Nos. are assigned to basic units, input expansion units, output expansionunits, and I/O expansion units. Zero to 4 are assigned to input units, while 5 to 9 areassigned to output units. Address Nos. assigned in a unit vary based on the numberof I/O terminals and the connection position of the unit.
* 2 to 4 in KV-40xx
Address No. assignment procedure
• The address No. is represented as a number 0 to 9.• Address Nos. 0 to 4 are provided for inputs, while address Nos. 5 to 9 are pro-
vided for outputs.
1 2 5 1 5Channel No.
Contact No.(00 to 15)
Address No.(Input: 0 to 4, output: 5 to 9)
Model Address Nos.
KV-10xx 0, 5
Basic unitsKV-16xx 0, 5
KV-24xx 0, 5
KV-40xx 0, 1, 5
kV-E4X 1 to 4*
Input expansion units KV-E8X 1 to 4*
KV-E16X 1 to 4*
KV-E4R/E4T(P) 6 to 9
Output expansion units KV-E8R/E8T(P) 6 to 9
KV-E16R/E16T(P) 6 to 9
I/O expansion units KV-E4XR/E4XT(P) 1 to 4*, 6 to 9
KVNKA Chap 01P.p65 08.3.11, 11:49 AM7
1.3 Device Configuration
3-8
1
Chapter 1 Programming
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 to0 and its address No. is increased by 1.
Example
In the KV-40AR, with 40 terminals (24 input and 16 output terminals), addressNo. 0 is assigned to input terminal Nos. 1 to 16 and address No. 1 is assigned toinput terminal Nos. 17 to 24
Channel No.The channel No. is the higher order digit in the contact No.
1.3.3 Assigning Relay Nos.When assigning relay Nos., the unit No. is based on the connection position of theunit, and the address No. is determined based on the unit type and I/O contacts.
With the connections above, the relay Nos. for each unit are assigned as shown inthe table below.
a) KV-16ARBasic unitInput: 10 pointsOutput: 6 points
b) KV-E4X InputexpansionunitInput: 4 points
c) KV-E8R Outputexpansion unitOutput: 8 points
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)
KVNKA Chap 01P.p65 08.3.11, 11:49 AM8
1.3 Device Configuration
3-9
11
Chapter 1 Programming
1.3.4 Input RelaysInput relays receive ON/OFF signals sent from external input equipment.
Note 1: Input relays function as contacts in programs. They cannot be used as relaycoils (outputs).
Note 2: There is no restriction of the contact type (N.O. or N.C.) used, the order therelay 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 thefollowing settings.
• When the HSP instruction is used: 10 µs ±20%
• While special utility relay 2813 remains ON, the time constant can be changed in7 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%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 ChangeFunction" (p.3-23).
Hardware input (independent of scan time)• High-speed counter
When the time constant is set to 10 µs using the HSP instruction or data memoryDM1940 (only while special utility relay 2813 remains ON), the maximum inputresponse of input relays 0004 and 0005 of CTH0 and CTH1 becomes 30 kHz.
• INT instruction: 0000 to 0003This instruction can receive any signal without regard to the scan time as far asthe signal ON time is longer than the input time constant.
"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 bespecified 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 becomeseffective at the rising edge of special utility relay 2813. To change the input timeconstant, first change data memory DM1940, then set special utility relay 2813 toOFF 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 sametime, priority is given to the HSP instruction.
Note 5: Only when a high-speed counter input or INT instruction is given, availableinput signals do not depend on the scan time.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM9
1.3 Device Configuration
3-10
1
Chapter 1 Programming
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.
* Not available with the KV-40xx
1.3.5 Output RelaysOutput relays output the program execution results to the outside. There are twotypes of outputs, relay and transistor.
Note 1: Output 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 therelay Nos. are used, or the number of relays used.
Output operation time• Transistor output
OFF ON: 50 µs or less (10 µs or less in 500 to 502)ON OFF: 250 µs or less (10 µs or less in 500 to 502, 100 µs or less for other
outputs in the basic unit)
• Relay outputOFF ON: 10 ms or lessON OFF: 10 ms or less
Note 1: When programming direct clock pulses, output relays 0500 and 0501 areused to output pulses in a transistor-type output unit.
Note 2: When the ramp-up/down control function is used, output relay 0502 outputspositioning 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 relay0501 outputs pulses in a transistor-type output unit. "4.5.1 Specified Frequency Pulse Output Function" (p.3-228)
ytilitulaicepS.oNyaler
noitcnuF
*9062tinunoisnapxetupnifotnatsnocemittupnI
5110ot0010.soNyalerhtiw01:NO,sm01:FFO µs
0162tinunoisnapxetupnifotnatsnocemittupnI
5120ot0020.soNyalerhtiw01:NO,sm01:FFO µs
1162tinunoisnapxetupnifotnatsnocemittupnI
5130ot0030.soNyalerhtiw01:NO,sm01:FFO µs
2162tinunoisnapxetupnifotnatsnocemittupnI
5140ot0040.soNyalerhtiw01:NO,sm01:FFO µs
epyttuptuorotsisnarT epyttuptuoyaleR
)P(TD/)P(TA01-VK )P(TD/)P(TA61-VK RD/RA01-VK RD/RA61-VK
)P(TD/)P(TA42-VK )P(TD/)P(TA04-VK RD/RA42-VK RD/RA04-VK
T4E-VK )P(T8E-VK R4E-VK R8E-VK
)P(T61E-VK )P(TX4E-VK R61E-VK RX4E-VK
KVNKA Chap 01P.p65 08.3.11, 11:49 AM10
1.3 Device Configuration
3-11
11
Chapter 1 Programming
1.3.6 Internal Utility RelaysIn a relay circuit, when one relay contact is used twice or more inside the circuit, amulti-pole relay with the same number of poles as the number used may be needed.Internal utility relays function only in programs, and eliminate the complexity of relaycircuits to facilitate circuit design.
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 therelay Nos. are used, or the number of relays used.
Retentive function of internal utility relaysExcept for internal utility relays, all relays turn OFF when the operation mode ischanged or when operation is stopped via a power shutdown. When operation isrestarted, all relays remain OFF except relays whose input condition is ON. How-ever, internal utility relays can be set using the MEMSW (memory switch) whether ornot they are to be retained. (Internal utility relays 2700 to 2715, however, are alwaysretained.)
When an internal utility relay is set to be retained, its ON/OFF status is stored even ifthe power is turned off. By using the retained relay all clear function (FUN65), allrelays which are set to be retained can be set to OFF. For more about setting the memory switch, refer to "MEMSW instruction" (p.3-92).
Application example of a retentive function: Lift vertical movement controlInternal utility relays 1000 and 1001 are set to be retained.When the upper/lower limit switch turns ON, the direction of lift movement isinverted. Even if the power is turned off while the lift is moving up (or down), the liftcontinues to move up (or down) when the power is turned on again.
Note: The retentive function is effective only when internal utility relays retained bythe self-retentive circuit or the SET/SFT/KEEP instruction are also retained by thememory switch.
Internal utility relays are not retained in the program shown below.
(0000)
(0500)
(0501)
(0001)
0000 10000001
T000 05000501
T001 05010500
1000 #00010T000
0001 10010000
1001 #00010T001
END
ENDH
MEMSW$0004
Move-up
Upper limitswitch
Lower limitswitch
Move-down
0000 1001
KVNKA Chap 01P.p65 08.3.11, 11:49 AM11
1.3 Device Configuration
3-12
1
Chapter 1 Programming
1.3.7 Special Utility RelaysEach special utility relay has a unique function. By using special utility relays effec-tively, programs can be simplified and program control improved.
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, butcannot be used as outputs.
For more about relays dedicated for reading, refer to "1.3.8 Special Utility Relay List" (p.3-14).
DescriptionRelay 2002: Always ONBy setting an output relay to ON using relay 2002, the output relay can be used as a"running indicator output".
Relay 2003: Always OFF.Opposite that of relay 2002, use relay 2003 where it is not required to be turned on.For example, when using only the up function of an up/down counter, use relay 2003in the DW (down) input.
Relays 2004, 2005 and 2006: Clock pulse
For each relay, the time ratio is "ON:OFF = 1:1". (Accordingly, the ON time of relay2005 is 0.05 sec/pulse.)However, because these relays depend on the scan time, error as much as the scantime is generated.
• By combining an output relay, an "intermittent output" can be made.• By using relay 2006 as input for a counter, the counter can be used as a long-
term timer.
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 foran initial reset at the start of operation.After one scan, this relay remains ON.
2002
00000LDA
DM0000STA
2002
HSP0100
Set the input time constant of relay 0100 to 10 µs.Transfer the ON/OFF status data of channel 0000 to DM0000.
C000
1000 #03600
2006C000
1000
1000 turns ON at every hour.
1000 #00100
0000C005
2007
When operation is started, this relay returnsthe current value of C005 to 0.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM12
1.3 Device Configuration
3-13
11
Chapter 1 Programming
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.
Relay 2813: Sets the input time constant of the CPU.While relay 2813 remains ON, the input time constant of a basic unit can be setusing the value of DM1940.
When operation is started, this relay sets all internalutility relays used by the SFT instruction to OFF.
0000
1000
SFTD
CLK
RES2008
1100
1100
#00000LDA
DM0000STA
2008
When operation is started, this relay returns the currentvalue of DM0000 to 0.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM13
1.3 Device Configuration
3-14
1
Chapter 1 Programming
1.3.8 Special Utility Relay ListSpecial relays and arithmetic operation flags
"1.3.7 Special Utility Relays" (p.3-12)
* Read-only relay.
Special utility relays for high-speed counter(0)
"Chapter 4. High-Speed Counters" (p.3-203)
* Read-only relay.
Note: Never use special utility relays that are not shown above.
.oNyaleR noitcnuF
*0012 1(0HTCrofylnodesukcolclanretnI µ )s*1012 01(0HTCrofylnodesukcolclanretnI µ )s*2012 001(0HTCrofylnodesukcolclanretnI µ )s
3012 0CTCrotarapmocnehw0HTCforaelccitamotuA.NOsnrut
deraelC:NOderaelctoN:FFO
4012 nehw0050ottuptuotceridstimrep/stibihorP.NOsnrut0CTCrotarapmoc
detibihorP:NOdettimreP:FFO
5012 rotarapmocnehwFFOottessi0050ottuptuotceriD.NOsnrut0CTC
FFOotteS:NOFFOottestoN:FFO
6012 rotarapmocnehwNOottessi0050ottuptuotceriD.NOsnrut0CTC
NOotteS:NONOottestoN:FFO
7012 hcaedesreversi0050ottuptuofosutatsFFO/NO.NOsnrut0CTCrotarapmocemit
desreveR:NOdesrevertoN:FFO
8012 nehw0050ottuptuotceridstimrep/stibihorP.NOsnrut1CTCrotarapmoc
detibihorP:NOdettimreP:FFO
9012 rotarapmocnehwFFOottessi0050ottuptuotceriD.NOsnrut1CTC
FFOotteS:NOFFOottestoN:FFO
0112 rotarapmocnehwNOottessi0050ottuptuotceriD.NOsnrut1CTC
NOotteS:NONOottestoN:FF
1112 hcaedesreversi0050ottuptuofosutatsFFO/NO.NOsnrut1CTCrotarapmocemit
desreveR:NOdesrevertoN:FFO
2112 1CTCrotarapmocnehw0HTCforaelccitamotuA.NOsnrut
deraelC:NOderaelctoN:FFO
3112 .0HTCrotarapmocrofedomnoitacilpitlumstceleSNOFFONOFFO
seslup2:NO4x:NO2x:FFOeslup1:FFO4112
noitacilpitluMedom
eslup1 2x 4x seslup2
3112 FFO NO FFO NO
4112 FFO FFO NO NO
.oNyaleR noitcnuF
*2002 .NOsyawlA
*3002 .FFOsyawlA
*4002 )%05:elcycytud(eslupkcolcs-10.0
*5002 )%05:elcycytud(eslupkcolcs-1.0
*6002 )%05:elcycytud(eslupkcolcs-0.1
*7002 .putratsretfanacstsrifgnirudFFOsniameR
*8002 .putratsretfanacstsrifgnirudNOsniameR
*9002nanehwroevitagensinoitarepocitemhtirafotlusernehwNOsnruT
.detarenegsiwolfrevo
*0102 .0sinoitarepocitemhtirafotlusernehwNOsnruT
*1102 .evitisopsinoitarepocitemhtirafotlusernehwNOsnruT
*2102 .rorrenasetarenegnoitarepocitemhtirananehwNOsnruT
KVNKA Chap 01P.p65 08.3.11, 11:49 AM14
1.3 Device Configuration
3-15
11
Chapter 1 Programming
Special utility relays for high-speed counter(1)
"Chapter 4. High-Speed Counters" (p.3-203)
* Read-only relay.
Note: Never use special utility relays that are not shown above.
Other special utility relays
.oNyaleR noitcnuF
*0022 1(1HTCrofylnodesukcolclanretnI µ )s*1022 01(1HTCrofylnodesukcolclanretnI µ )s*2022 001(1HTCrofylnodesukcolclanretnI µ )s
3022 2CTCrotarapmocnehw1HTCforaelccitamotuA.NOsnrut
deraelC:NOderaelctoN:FFO
4022 nehw1050ottuptuotceridstimrep/stibihorP.NOsnrut2CTCrotarapmoc
detibihorP:NOdettimreP:FFO
5022 rotarapmocnehwFFOottessi1050ottuptuotceriD.NOsnrut2CTC
FFOotteS:NOFFOottestoN:FFO
6022 rotarapmocnehwNOottessi1050ottuptuotceriD.NOsnrut2CTC
NOotteS:NONOottestoN:FFO
7022 hcaedesreversi1050ottuptuofosutatsFFO/NO.NOsnrut2CTCrotarapmocemit
desreveR:NOdesrevertoN:FFO
8022 nehw1050ottuptuotceridstimrep/stibihorP.NOsnrut3CTCrotarapmoc
detibihorP:NOdettimreP:FFO
9022 rotarapmocnehwFFOottessi1050ottuptuotceriD.NOsnrut3CTC
FFOotteS:NOFFOottestoN:FFO
0122 rotarapmocnehwNOottessi1050ottuptuotceriD.NOsnrut3CTC
NOotteS:NONOottestoN:FFO
1122 hcaedesreversi1050ottuptuofosutatsFFO/NO.NOsnrut3CTCrotarapmocemit
desreveR:NOdesrevertoN:FFO
2122 3CTCrotarapmocnehw1HTCforaelccitamotuA.NOsnrut
deraelC:NOderaelctoN:FFO
3122 .1HTCrotarapmocrofedomnoitacilpitlumstceleSNOFFONOFFO
seslup2:NO4x:NO2x:FFOeslup1:FFO4122
noitacilpitluMedom
eslup1 2x 4x seslup2
3122 FFO NO FFO NO
4122 FFO FFO NO NO
.oNyaleR noitcnuF
0032 delbasidstuptuolanretxE)5190ot0050stuptuo(
delbasiD:NOdelbasidtoN:FFO
1032 delbasidstupnihserferlanretxE)5140ot0000stupni(
delbasiD:NOdelbasidtoN:FFO
3032 edomemitnacstnatsnoC)92MTnieulavteserpetirw(
delbanE:NOdelbasiD:FFO
4032 sdeecxeemitnacsnehwnacsenorofNOsniameR.emitnacstnatsnocteserp
5032 .noitareporetnuocycneuqerfrofgalftratS
6032 tuptuoeslupycneuqerfdeificepSdelbanE:NO
delbasiD:FFO7032 tuptuoeslupycneuqerfdeificepsrofgalfrorrE8032 .NOdenrutnehwrevirdrotomspotS
9032 nirevirdrotomspotS.noitareponisirevirdrotomnehwNOsnruT.noitcurtsnitpurretniybFFOdenrutnehwseicnegreme
0132 .)egdegnisirtanoitceted(NOdenrutnehwrevirdrotomstratS4132 .noitarepohctiwsmacrofgalftratS5132 .noitarepohctiwsmacnisruccororrenanehwNOsnruT
* Read-only relay.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM15
1.3 Device Configuration
3-16
1
Chapter 1 Programming
.oNyaleR noitcnuF
0042 langislanretxe0HTCfognimiTFFO teserplanretxE FFO
egdegnillaftANO
egdegnisirtANO
leveL1042 FFO desuton NO FFO NO
2042 TNIfoytiraloptpurretnIFFO
egdegnisirtAFFO
egdegnillaftANO
egdegnisirtANO
segdehtobtA3042 FFO NO FFO NO
4042 1TNIfoytiraloptpurretnIFFO
egdegnisirtAFFO
egdegnillaftANO
egdegnisirtANO
segdehtobtA5042 FFO NO FFO NO
6042 retnuocgnirsates0HTC teS:NO testoN:FFO
7042.edomnoitacilpitlumonottessi0HTCnehwtupniBesahperongI
.putnuocsyawladnatupniBesahperongI:NO.laususatupniBesahpesU:FFO
8042 teserplanretxe1HTCfognimiTFFO teserplanretxE FFO
egdegnillaftANO
egdegnisirtANO
leveL9042 FFO desuton NO FFO NO
0142 2TNIfoytiraloptpurretnIFFO
egdegnisirtAFFO
egdegnillaftANO
egdegnisirtANO
segdehtobtA1142 FFO NO FFO NO
2142 3TNIfoytiraloptpurretnIFFO
egdegnisirtAFFO
egdegnillaftANO
egdegnisirtANO
segdehtobtA3142 FFO NO FFO NO
4142 retnuocgnirsates1HTC teS:NO testoN:FFO
5142.edomnoitacilpitlumonottessi1HTCnehwtupniBesahperongI
.putnuocsyawladnatupniBesahperongI:NO.laususaBesahpesU:FFO
0052 .dengissasilenapecafretnirotarepo02D-VKno]1F[hctiwsdezimotsuC1052 .dengissasilenapecafretnirotarepo02D-VKno]2F[hctiwsdezimotsuC2052 .dengissasilenapecafretnirotarepo02D-VKno]3F[hctiwsdezimotsuC3052 .dengissasilenapecafretnirotarepo02D-VKno]4F[hctiwsdezimotsuC
4052silenapecafretnirotarepo02D-VKno1pmalrotacidnidezimotsuC
.dengissa
5052silenapecafretnirotarepo02D-VKno2pmalrotacidnidezimotsuC
.dengissa
6052silenapecafretnirotarepo02D-VKno3pmalrotacidnidezimotsuC
.dengissa
7052silenapecafretnirotarepo02D-VKno4pmalrotacidnidezimotsuC
.dengissa
8052rotareponeewtebegnahcstimreP02D-VKfoedomeciveddnaedom
.lenapecafretnirotarepodettimreP:NO
toN:FFOdettimrep
9052ecafretnirotarepo02D-VKehtstimreP
rotareponeewtebdetfihsebotlenap.edommetsysdnaedom
dettimreP:NOO toN:FF
dettimrep
0152ehtrofegaugnalyalpsidehtseificepS
lenapecafretnirotarepo02D-VKesenapaJ:NO hsilgnE:FFO
1152rotarepo02D-VKehtrofpeebehtsteS
lenapecafretnipeebesU:NO peeboN:FFO
2152 metsysrofdevreseR3152 metsysrofdevreseR
5152fostnetnoc(egassemresuasyalpsiD
wodniWsseccAehtni)0591MDyalpsiD:NO
egassemtonoD:FFO
egassemyalpsid
KVNKA Chap 01P.p65 08.3.11, 11:49 AM16
1.3 Device Configuration
3-17
11
Chapter 1 Programming
Note: Never use special utility relays that are not shown above.
.oNyaleR noitcnuF
9062yalerhtiwtinunoisnapxetupnifotnatsnocemittupnI
5110ot0010.soNsm01:FFO
01:NO µs
0162yalerhtiwtinunoisnapxetupnifotnatsnocemittupnI
5120ot0020.soNsm01:FFO
01:NO µs
1162yalerhtiwtinunoisnapxetupnifotnatsnocemittupnI
5130ot0030.soNsm01:FFO
01:NO µs
2162yalerhtiwtinunoisnapxetupnifotnatsnocemittupnI
5140ot0040.soNsm01:FFO
01:NO µs
3162 tcennocsidnoisnapxetatupnifogniraelCderaelC:FFO
deraelctoN:NO
2172lamroN:FFOrorretcennocsiD
tinudetcennocninoitcennocsiD:NO
derotssiaerasihTehtnehwneve
siedomnoitarepomorfdegnahc
,NURotMARGORPsirewopehtnehwro
tuohtiw(ffodenrutehtybdetceffagnieb.)noitcurtsniWSMEM
tonsiaerasihTehtfinevederaelc
raelCllAyalerytilitu.detavitcasinoitcnufsiaerasiht,revewoH
llAnanehwderaelcdetucexesiraelC
agniretsigertuohtiw.margorp
4172tiucricnoitcerroctupnideeps-hgihfoesU
desutoN:FFOdesU:NO
5172 .noitareponisihctiwsmacelihwNO
0082 .)gnidneselihwNOsniamer(AtropnoitacinummocotdneslangiskaerB
1082ylnognirudNOsniamerdna,AtropnoitacinummocmorfatadtxetsevieceR
.atadtxetgniviecerelihwnacs1
2082ylnognirudNOsniameR.rorreecnatpeccaatadtxetAtropnoitacinummoC3082yalerro1082yalerrehtieelihwdeviecersiatadtxetnehwNOnacs1
.NOsi
3082rorreevieceratadtxetAtropnoitacinummoC
.sruccororreevieceratadtxetanehwnacs1ylnognirudNOsniameR4082 ).gnidnesgnirudNOsniamer(tratsdnesatadtxetAtropnoitacinummoC5082 .)gnidneselihwNOsniamer(BtropnoitacinummocotdneslangiskaerB
60821ylnognirudNOsniamerdna,atadtxetBtropnoitacinummocsevieceR
.atadtxetgniviecerelihwnacs
7082.rorreecnatpeccaatadtxetBtropnoitacinummoC
elihwdeviecergniebsiatadtxetnehwNOnacs1ylnognirudNOsniameR.NOsi8082yalerro6082yaler
8082rorreevieceratadtxetBtropnoitacinummoC
.sruccororreevieceratadtxetanehwnacs1ylnognirudNOsniameR9082 ).gnidnesgnirudNOsniamer(tratsdnesatadtxetBtropnoitacinummoC2182 .yrettabpukcabhtiwsruccoytilamronbananehwNOsnruT
3182
ybdesustupnitpecxe(eludomcisabnistupnillaottnatsnocemittupnisteS.)noitcurtsniPSH
.sm01ottnatsnocemittupnisteS:FFO.tnatsnocemittupnisenimretedneht,0491MDniderotseulavotsrefeR:NO
4182 .detibihorperasyekelpitluM:noitcurtsniYEKH5182 .dehsinifsinacS:noitcurtsniYEKH
5192ot0092 .aeraegarotsnoitamrofniYEKH
KVNKA Chap 01P.p65 08.3.11, 11:49 AM17
1.3 Device Configuration
3-18
1
Chapter 1 Programming
1.3.9 Timers and CountersTimers and counters can be set in a program, and their outputs can be used ascontacts elsewhere in the program. [There is no restriction on the contact type (N.O.or N.C.) and the order of use.]A same number can be assigned to only one timer or counter. For example, T005and C005 cannot be used in the same program.
Timer/Counter list
Description Timers• When 0.1-s timers (TMR) and high-speed 0.001-s timers (TMS) are used as
contacts, the "Tnnn" No. is used for both types. However, the form for setting isdifferent. "TMRnnn#ddddd" is used for 0.1-s timers, "TMHnnn#ddddd" is used forhigh-speed 0.01-s timers, and "TMSnnn#ddddd" is used for high-speed 1-mstimers (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 becomeequivalent 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/downcounters.
• In one program, different numbers must be assigned to each of the counters andup/down counters.
• Even when operation is stopped, each counter stores whatever value it has atthat 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).
High-speed counters and high-speed counter comparators
The Visual KV Se ries is equipped with two high-speed counters (CTH0 and CTH1)and four high-speed counter comparators (CTC0, CTC1, CTC2, and CTC3) with a30-kHz input response speed (frequency), two phases, and size of 16 or 24 bits.
Note: When a high-speed counter or high-speed counter comparator will be used asa 24-bit device, a set value is required to be stored in a data memory using theMEMSW instruction.
For details about high-speed counters and high-speed counter comparators, refer to "Chapter 4 High-speed Counters" (p.3-203).
emaN tcatnoClioC
)noitcurtsni(rebmuN
remiT
)remits-1.0(remiT
942Tot000T
942ot000RMT
latotni052
remitdeeps-hgiH)remits-10.0(
942ot000HMT
remitsm-1deeps-hgiH)remits-100.0(
942ot000SMT
retnuoCretnuoC
942Cot000C942ot000C
retnuocnwod/pU 942ot000CDU
KVNKA Chap 01P.p65 08.3.11, 11:49 AM18
1.3 Device Configuration
3-19
11
Chapter 1 Programming
1.3.10 Data MemoriesData memories store various types of data.Data memories are not usually used in a program that consists of contacts, coils,timers, and counters. When arithmetic instructions are used, however, data memo-ries can be used to store data for arithmetic operations as well as the results ofarithmetic operations.
.oNMD noitpircseD
999MDot0MD )resuybdesuebnac(deificepstoN
9901MDot0001MD AtropeviecertxeT
9911MDot0011MD AtropdnestxeT
9921MDot0021MD BtropeviecertxeT
9931MDot0031MD BtropdnestxeT
0041MD .oNyalertuptuotsrifehT:noitcnufhctiwsmaC
1041MD rotarapmocpets-itlumnieulavnosirapmoC:noitcnufhctiwsmaCedom
2041MD tupnitnempiuqefoelcycenofotnuocesluP:noitcnufhctiwsmaC0HTCot
3041MD )resuybdesuebnac(deificepstoN
4041MD )sm(elcyctnemerusaeM
5041MD )zH(tnuocycneuqerffotluseR
7041MD/6041MD yalertuptuohcihwtaelgnafoeulavteS:noitcnufhctiwsmaCFFO/NOsnrut
9041MD/8041MD:
9641MD/8641MD
1+yalertuptuohcihwtaelgnafoeulavteS:noitcnufhctiwsmaCFFO/NOsnrut
:13+yalertuptuohcihwtaelgnafoeulavteS:noitcnufhctiwsmaC
FFO/NOsnrut
0741MD )resuybdesuebtonnac(metsysybdevreseR
9741MDot1741MD )resuybdesuebnac(deificepstoN
0841MD ot002()zH(ycneuqerfputratS:noitcnuflortnocnwod/pu-pmaR)000,05
1841MD ot002()zH(ycneuqerfgnitarepO:noitcnuflortnocnwod/pu-pmaR)000,05
2841MD )sm(emitnoitareleccA:noitcnuflortnocnwod/pu-pmaR)000,4ot0(
3841MD )resuybdesuebnac(deificepstoN
4841MD )tigidrewol(tnuocesluptuptuO:noitcnuflortnocnwod/pu-pmaR)535,56ot0(
5841MD )tigidreppu(tnuocesluptuptuO:noitcnuflortnocnwod/pu-pmaR)535,56ot0(
6841MD )71ot11(edocrorrE:noitcnuflortnocnwod/pu-pmaR
9941MDot7841MD )resuybdesuebnac(deificepstoN
9651MDot5651MD )resuybdesuebnac(deificepstoN
9751MDdna8751MD )resuybdesuebnac(deificepstoN
9951MDot0851MD .oNecivedyalpsiD:lenapecafretnirotarepO02D-VK
9961MDot4661MD )resuybdesuebnac(deificepstoN
5761MDot0761MD )resuybdesuebtonnac(metsysybdevreseR
6761MD gnittesnoissimreptfihsneercS:lenapecafretnirotarepO02D-VKedomrotareponi
KVNKA Chap 01P.p65 08.3.11, 11:49 AM19
1.3 Device Configuration
3-20
1
Chapter 1 Programming
* Read-only relay.
Note 1: 16-bit binary data is stored in each of the data memories as for internalregisters.
Note 2: The data stored in data memories is held even when the power is turned offor when the All Clear function is executed. The backup time is 20 days or more inthe KV-10xx, and 2 months or more in other models.
Note 3: DM1000 to DM1999 are assigned as special data memories.
.oNMD noitpircseD
9761MDot7761MDecafretnirotarepo02D-VKehtrofedomsseccatceridrofaerA
lenap
9961MDot0861MD setubirttaecivedyalpsiD:lenapecafretnirotarepO02D-VK
9971MDot4671MD )resuybdesuebnac(deificepstoN
9081MDot6081MD )resuybdesuebnac(deificepstoN
9981MDot6281MD )resuybdesuebnac(deificepstoN
*1091MD/0091MD )tigidreppu/tigidrewol(0HTCmorfdaereulavtib-42
*3091MD/2091MD )tigidreppu/tigidrewol(1HTCmorfdaereulavtib-42
*5091MD/4091MD )tigidreppu/tigidrewol(0CTCmorfdaereulavtib-42
*7091MD/6091MD )tigidreppu/tigidrewol(1CTCmorfdaereulavtib-42
*9091MD/8091MD )tigidreppu/tigidrewol(2CTCmorfdaereulavtib-42
*1191MD/0191MD )tigidreppu/tigidrewol(3CTCmorfdaereulavtib-42
3191MD/2191MD )tigidreppu/tigidrewol(0HTCotnettirweulavtnerructib-42
5191MD/4191MD )tigidreppu/tigidrewol(1HTCotnettirweulavtnerructib-42
7191MD/6191MD )tigidreppu/tigidrewol(0CTCotnettirweulavtnerructib-42
9191MD/8191MD )tigidreppu/tigidrewol(1CTCotnettirweulavtnerructib-42
1291MD/0291MD )tigidreppu/tigidrewol(2CTCotnettirweulavtnerructib-42
3291MD/2291MD )tigidreppu/tigidrewol(3CTCotnettirweulavtnerructib-42
5291MD/4291MD )tigidreppu/tigidrewol(tupniteserp0HTC
7291MD/6291MD )tigidreppu/tigidrewol(tupniteserp1HTC
*9291MD/8291MD )tigidreppu/tigidrewol(detarenegsi0TNInehwerutpactupnI
*1391MD/0391MD )tigidreppu/tigidrewol(detarenegsi1TNInehwerutpactupnI
*3391MD/2391MD )tigidreppu/tigidrewol(detarenegsi2TNInehwerutpactupnI
*5391MD/4391MD )tigidreppu/tigidrewol(detarenegsi3TNInehwerutpactupnI
6391MD )zH(ycneuqerfteS:noitcnuftuptuoeslupycneuqerfdeificepS
7391MD noitamrofninoitcennoctinunoisnapxeO/I
8391MD eulavtimilreppU:0.oNremmirtlatigiD
9391MD eulavtimilreppU:1.oNremmirtlatigiD
0491MD
gnittestnatsnocemittupnI01:0 µ 02:1s µ 005:2s µs
sm01:6sm5:5sm5.2:4sm1:3.tesebtonnaceulavrehtoynA
3491MDot1491MD )resuybdesuebtonnac(metsysybdevreseR
4491MDnoisividnehwnacs1otnidetrevnocsnoitcurtsniforebmuN
demrofrepsinoisrevnoc
9491MDot5491MD )resuybdesuebnac(deificepstoN
0591MD )552ot0(yalpsidrorrewodniwsseccA
9991MDot1591MD )resuybdesuebnac(deificepstoN
KVNKA Chap 01P.p65 08.3.11, 11:49 AM20
1.3 Device Configuration
3-21
11
Chapter 1 Programming
1.3.11 Temporary Data MemoryThese data memories are used for temporary storage. When arithmetic instructionsare used, temporary data memories can be used to temporarily store the data forarithmetic operations as well as the results of arithmetic operations.
Attribute R: Read W: Write
* Both R and W are enabled when special functions are not used.
Note 1: Temporary data memories are initialized when the power is turned on.
Note 2: TM20, TM30, and TM31 are read-only, so cannot be used for writing.However, TM28 can be used for both reading and writing if special functions are notused.
Note 3: TM00 and TM01 are used by the MUL and DIV instructions. Never use themfor any other purpose.
.oNMT egasU etubirttA
00MT )LUM/VID(snoitarepocitemhtirarofdesU W/R
10MT )VID(snoitarepocitemhtirarofdesU W/R
72MTot20MT )resuybdesuebnac(deificepstoN W/R
82MTelihweulavtesdnoyeb)sm1:eludom(emitnacsserotS
.demrofrepsinoitarepoemitnacstnatsnoc*R
92MTemitnacstnatsnocfo)sm1:eludom(eulavtesserotS
noitarepoW/R
03MT .nevigsinoitpurretni3TNInehweulav0CTCserotS *R
13MT01yrevefoeulavnaem(emitnacsderusaemserotS
.)sm1.0:eludom()snacsR
KVNKA Chap 01P.p65 08.3.11, 11:49 AM21
1.3 Device Configuration
3-22
1
Chapter 1 Programming
1.3.12 Relay Nos. and FunctionsAssignment of Relay Nos.The components of a relay no. are shown below.
Unit Nos.
Unit nos. are assigned to units within the KV-300 system, with the unit connected tothe right of the KV-300 CPU (see the figure below) assigned as no. 7. The CPU isassigned 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.
0 7 5 1 5
Address No.
Channel No. Relay No. (00 to 15)
Module No. (07 to 17)Input (0 to 4) Output (5 to 9)
Power supply unit CPU
0 7 8 9 16 17
Unit Address No.
KV-300 CPU CPU 0, 5
KV-C16X 16-input unit 0
KV-C32X 32-input unit 0. 1
KV-B16R 16-output unit 5
KV-B16S 16-output unit 5
KV-C32T 32-output unit 5, 6
KV-R8X 8-input terminal unit 0 to 4 *
KV-R16X 16-input terminal unit
KV-R8R 8-output terminal unit 5 to 9 *
KV-R16R 16-output terminal unit
KV-R8T 8-output terminal unit
KV-R16T 16-output terminal unit
KVNKA Chap 01P.p65 08.3.11, 11:49 AM22
1.4 Special Functions
3-23
11
Chapter 1 Programming
1.4 Special FunctionsThis section describes special functions to set and confirm operations on the VisualKV Series, and useful functions for program debugging and adjustment of externalequipment.
1.4.1 Input Time Constant Change FunctionThe input time constant can be changed when a signal is read from an input contact.When connecting external equipment which has no contact in which chattering suchas transistor outputs does not occur, and inputting pulses of short width, the inputtime constant change function can be used to decrease the input time constant.
Setting the input time constant for basic units using special utility relaysThe input time constant for a basic unit can be changed using data memory DM1940and special utility relay 2813.Though the input time constant is usually 10 ms, it can be changed to a value thatcorresponds to the number stored in DM1940 by setting special utility relay 2813 toON.If the HSP instruction and special utility relay 2813 are used at the same time,priority is given to the HSP instruction and the number stored in DM1940 is ignored.
Special utility relay 2813OFF: Sets the input time constant to 10 ms.ON: Refers to the number stored in DM1940, then determines the input time
constant.
Note 1: Be sure to set the input time constant to 10 µs when using the 30-kHz high-speedcounter 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 therising edge of special utility relay 2813.
To change the input time constant, first change data memory DM1940, then set special utilityrelay to OFF and ON again. Or change the operation mode of the KV basic unit fromPROGRAM 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 timeconstant 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 equipmentwithout 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 thanthe scan time may not be received even if the input time constant is set to a small value.
0491MDniderotsrebmuN tnatsnocemittupnI0 01 µs1 02 µs2 005 µs3 sm14 sm5.25 sm56 sm01
eromro7 dewollatoN
KVNKA Chap 01P.p65 08.3.11, 11:49 AM23
1.4 Special Functions
3-24
1
Chapter 1 Programming
1.4.2 Modifying the Input Relay Time Constant Modifying with External Switches
KV-C32X/C16X KV-R16X/R8X
As shown in above figures, an external switch can be used to select the input timeconstant only on the KV-C32X/C16X Connector Input Units and KV-R16X/R8X I/OTerminal Units.
In the following table, white represents the switch position.
Note: Connect a solid-state contact output device when the input time constant isset to 1 ms for 25 µs. Connection of a contact output device may result in contactbounce.
Modification within the CPUThe input time constant for KV-300 CPU input relay nos. 0000 to 0009 can bemodified in the program.
Note 1: When using the 30 kHz high-speed counter input, turn ON special utilityrelay 2813.
Note 2: When special utility relay 2813 is ON, the input time constant of input relays0000 to 0009 is set to 10 µs ±20%.
Note 3: The input time constant remains 10 ms ±20% if the HSP instruction is usedwhen special utility relay 2813 is ON.
Note 4: When the input time constant is set to 10 µs or 25 µs, a solid-state outputdevice must be connected. Connection of a contact output device may result incontact bounce.
5V24V 10 ms0 ms1 ms
43
2
10
1 ms0 ms 10 ms
Input time constant selection switch
Input time constant KV-C32X/C16X KV-R16X/R8X
25 µs ±20%
1 ms ±20%
10 ms ±20%
0ms 1ms 10ms
0ms 1ms 10ms
0ms 1ms 10ms
0ms 1ms 10ms
0ms 1ms 10ms
0ms 1ms 10ms
Input time constant Setting
10 µs ±20% Turn ON special utility relay 2813 (0000 to 0009).
25 µs ±20% Use the HSP instruction.
10 ms ±20% Default
KV-300 PLC Only
KVNKA Chap 01P.p65 08.3.11, 11:49 AM24
1.4 Special Functions
3-25
11
Chapter 1 Programming
1.4.3 Constant Scan Time ModeThis function executes a program while keeping the scan time at a constant valuewhich usually changes based on the processing contents. This section describeshow to set this function.
Though the scan time changes usually depending on the processing contents, it canbe kept at a constant value by using this function. This function can be used toacquire data from external equipment at a constant time interval.The set value should be longer than the maximum scan time because the scan timeis kept at a constant value until the end of processing.
Setting procedureSet 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.
Note 1: Be sure to set the constant scan time value so it is larger than the actualscan time.
Note 2: If the actual scan time exceeds the set scan time, special utility relay 2304turns 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. Ifa value larger than 200 ms is input, it will be treated as 200 ms.
2008 2303SET
TM29STA
#00020LDA
KVNKA Chap 01P.p65 08.3.11, 11:49 AM25
1.4 Special Functions
3-26
1
Chapter 1 Programming
1.4.4 Output Disabled FunctionThis function disables outputs from each unit in RUN mode without regard to theprogram used. By disabling external outputs, the program can be debugged whileexternal equipment is connected, even when output of signals to the externalequipment is not desired.
Setting procedureWhen special utility relay 2300 turns ON, all outputs from all output relays (0500 to0915) to the outside are cleared after 1 scan is finished.However, the display in the Access Window and the output indicator lamps are notcleared.
Setting example
By setting/resetting special utility relay 2300 using the Access Window, the "KVIncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,or the KV-P3E(01) handheld programmer, the external output prohibition functioncan be used.External outputs are prohibited while input 0000 is ON. External outputs are permit-ted, though, while input 0000 is OFF.
For more about operating procedures, refer to the "Chapter 6. Handheld Programmer" (p.1-195).
1.4.5 Input Refresh Disabled FunctionThis function disables the update of inputs from each unit triggered by input signalsfrom external equipment.By disabling external input refresh, inputs from each unit can be set to ON/OFF inmonitor status without mechanical operations to enable a program check.
Setting procedure
When special utility relay 2301 turns ON, input refresh (read of input relays) for allinput 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 "KVIncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,or the KV-P3E(01) handheld programmer.
Setting exampleBy setting/resetting special utility relay 2301 using the Access Window, the "KVIncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software,or the KV-P3E(01) handheld programmer, the external input refresh prohibitionfunction can be used.External input refresh is prohibited while input 0000 is ON. External input refresh ispermitted, though, while input 0000 is OFF.
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 settingspecial 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.
0000 2300
0000 2301
KVNKA Chap 01P.p65 08.3.11, 11:49 AM26
1.5 Extended Ladder Diagrams
3-27
11
Chapter 1 Programming
1.4.6 Contact Comment Save Function• This function transfers contact comments to the Visual KV Series using the "KV
IncrediWare (DOS)" or "LADDER BUILDER for KV" programming supportsoftware.
• The Visual KV Series can store not only programs but also comments registeredto each contact using the "KV IncrediWare (DOS)" or "LADDER BUILDER forKV" programming support software.A program may not be easy to understand if only device Nos. are used. Byregistering comments to the contacts, the program can be easily debugged andmore efficiently maintained.
• The number of contact comments that can be transferred is up to 1,000 for bothnormal transfer and compression transfer.
• The KV-D20 operator interface panel includes the contact comment displayfunction.
For more about operating procedures, refer to "2.5 Entering Comments/Labels" (p.1-46) and "4.2.2Setting the comment transfer" (p.2-138).
Note 1: Line comments cannot be stored.
Note 2: The KV-P3E(01) handheld programmer cannot read or write contact com-ments.
Note 3: The KV-D20 operator interface panel cannot display contact commentswhich have been compressed and transferred.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM27
1.4 Special Functions
3-28
1
Chapter 1 Programming
1.4.7 Special FunctionsConstant Scan Time Mode
In this mode, operation can take place according to a preset scan time (in ms).
SettingWrite the desired scan time into TM29 (temporary data memory), then turn onspecial utility relay No. 2303. The scan time can also be written into TM31. Specify ascan 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 actualscan time. Otherwise, special utility relay 2304 turns on during every scan to disableconstant scan time mode.
Note 2: If the scan time exceeds the set value, special utility relay no. 2304 turns onduring the next scan.
Output Disabled FunctionDuring checking of a program, this function clears output from output relays regard-less of the program currently running.
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 specialutility relay No. 2300 from the monitor display. To execute FORCED RESET or RESET, refer to "Chapter 6 Handheld Programmer" (p.1-195).
Input Refresh Disabled FunctionSet this function if it is desired to turn ON/OFF input relays from the monitor displaywithout activating the machine when checking a program.
SettingTurn ON special utility relay No. 2301 to skip input refresh (reading from inputrelays). Input relays can then be turned ON/OFF with the KV-P3E(01) or with KVIncrediWare (DOS) on the monitor display.
Example
Set input relay No. 0000 to ON to disable input refresh; set to OFF to enable inputrefresh.
Note: If input refresh is disabled, it is not enabled until input relay No. 0000 is turnedon from the handheld programmer.
LDA STA SET
02008 #00200 TM29 2303
0000 2301
KV-300 PLC only
KVNKA Chap 01P.p65 08.3.11, 11:49 AM28
1.5 Extended Ladder Diagrams
3-29
11
Chapter 1 Programming
1.5 Extended Ladder DiagramsThis section describes KEYENCE’s unique extended ladder diagram.
1.5.1 Features of Extended Ladder DiagramsThe extended ladder diagram is a programming method developed to reduceproblems related to design, testing, operation, and maintenance of programs.In a conventional ladder diagram, output instructions can be written only on the rightside of a ladder diagram. On the other hand, in an extended ladder diagram, outputinstructions can be written anywhere except on the left. As the result, the programsshown below can be written.
Mixture of input and output circuitsConventional ladder diagram Extended ladder diagram
Connection of two or more instructions on one lineConventional ladder diagram Extended ladder diagram
Branch from output coilConventional ladder diagram Extended ladder diagram
Only input circuitscan be written.
Only outputcircuits canbe written.
Only inputcircuits canbeassembled.
Both inputcircuits andoutput circuitscan beassembled.
Only outputcircuits canbeassembled.
Instructions can be written only from theleft end to the right end on one line.
Many instructions can be connected.
There is only a single line, so the ladderdiagram is easier to understand.
Branches can be made only from inputcontacts.
Three lines are required.
Branches can also be made from outputcoils.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM29
1.5 Extended Ladder Diagrams
3-30
1
Chapter 1 Programming
2010
20102002
2010 0502
0501
0500#01000CMP
DM0000LDA
#02000CMP
#03000CMP
2002 DM0000LDA
#01000CMP
2002
2010
#02000CMP
0500
0501
2002
2010
#03000CMP
2010 0502
In a conventional ladder diagram, operationsperformed by the program cannot be easilyunderstood. In an extended ladder diagram,operations performed by the program can beunderstood at a glance.
When the start switch (0000) is set to ON, a lamp (0500) is lit andtimer 0 is activated.
0000 1100
T000
T001
0500
0501
0502 0000
1000STG
1001STG
#00030T000
#00020T001
1002STG
1001JMP
1002JMP
ENDS
1100DIFU
1000SET
When timer 0 turns ON three seconds later, the lamp goes out, abuzzer (0501) is sounded, and timer 1 is activated.
When timer 1 turns ON two seconds later, the buzzer is stoppedand the motor (0502) starts to rotate.
When the start switch (0000) is set to OFF, the motor is stoppedand all operations are reset.
0000
T002
T001
T000
1000
0500 0501
0501
0500
0500
0000
1000
T002
1001
T000
T001
T002
1001
0501
1002
T000
1002
T001
1003
1001
1003
1002
1003
#00010T000
1000DIFU
1001STG
1001JMP
1003JMP
1002JMP
#00030T002
#00020T001
#00010T000
1000DIFU
1002STG
1003STG
#00020T001
1003
#00030T002
1001SET
By using an extended ladder diagram as shownabove, the program can be executed in thesequence of the processing to be performed. Soeven a person who uses a relay sequence for thefirst time can understand the processing contents.By combining the STG instruction, double coilscan also be used.
1.5.2 Advantages of Extended Ladder DiagramsThe number of lines in a ladder diagram can be reduced.Because both output instructions and input instructions can be written side by side,the number of program lines can be reduced.As the result, the contents of the program can be seen at a glance.
Example
When DM0000 stores 1000, 0500 turns ON.2000, 0501 turns ON.3000, 0502 turns ON.
Conventional ladder diagram Extended ladder diagram
Processing sequence is clear.Ladder symbols can be laid out in processing sequence, so the program flow iseasier 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 issounded for two seconds, and then the motor starts to rotate.
Conventional ladder diagram Extended ladder diagram
KVNKA Chap 01P.p65 08.3.11, 11:49 AM30
1.5 Extended Ladder Diagrams
3-31
11
Chapter 1 Programming
0501
05000000
LD 0000OUT 0500OUT 0501
LD 0000OUT 0500CONOUT 0501
050105000000
The CON instruction for connection is added.(The scan time is not affected.)
At the rising edge of input0001, 1002 turns ON.
0001
1000
1002 0000
0002
1000
1001
1003 1000 1001
1001 0500
1003DIFU
1002DIFU
05000000 10000001
1000
10010002
1001
At the rising edge of input1003, 1002 turns ON.
If input 0000 is ON, 1000turns ON.
If 1000 is ON, 1001 turns ON.
When 1001 turns ON, output 0500turns ON.
Input 0000turns ON.
Input 0001turns ON.
Input 0002turns ON.
Output 0500turns ON.
Note: When an extended ladder diagram is used, the number of lines in ladderdiagram may be reduced. However, this may not necessarily reduce the number ofmnemonics in the program.
Conventional ladder diagram Extended ladder diagram
1.5.3 Example of an Extended Ladder Diagram Using W-UE
Only when inputs are given in the order "0000 0001 0002", output 0500 turnsON.
Conventional ladder diagram Extended ladder diagram
Because the program can be written in only one line when an extended adderdiagram is used, it is easier to look at and understand compared with a programwritten using a conventional ladder diagram.
KVNKA Chap 01P.p65 08.3.11, 11:49 AM31
1.5 Extended Ladder Diagrams
3-32
1
Chapter 1 Programming
KVNKA Chap 01P.p65 08.3.11, 11:49 AM32
Chapter 2Instructions
Describes the concrete usage of instructions in the KV Series.Refer to "Chapter 3 Interrupts" on page 3-191 for details of interrupt instructions.Refer to "Chapter 4 High-speed counters" on page 3-203 for details of the high-speed counters used in the application instruction.
2.1 Instruction List [Visual KV Series] ....................................... 3-342.1.1 Basic Instructions ................................................................................. 3-342.1.2 Application Instructions ........................................................................ 3-362.1.3 Arithmetic Instructions .......................................................................... 3-382.1.4 Interrupt Instructions ............................................................................ 3-412.1.5 Function No. List (Alphabetical order) .................................................. 3-41
2.2 Instruction List [KV-300 Series, KV-10/80] .......................... 3-422.2.1 Basic Instructions ................................................................................. 3-422.2.2 Application Instructions ........................................................................ 3-452.2.3 Arithmetic Instructions .......................................................................... 3-482.2.4 Interrupt Instructions ............................................................................ 3-54
2.3 Convention Details .................................................................3-55
2.4 Instruction Details ..................................................................3-562.4.1 Basic Instructions ................................................................................. 3-562.4.2 Application Instructions ........................................................................ 3-952.4.3 Arithmetic Instructions .......................................................................... 3-134
2.5 Programming Notes ...............................................................3-189
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:51 AM33
2.1 Instruction List Visual KV Series
3-34
2
Chapter 2 Instructions
2.1 Instruction ListThe KV Series uses 80 instructions.The instructions are divided into four categories according to their functions: basicinstructions, application instructions, arithmetic instructions, and interrupt instruc-tions.The following is an overview of applications and functions. For details, refer to therespective description pages for each instruction.
2.1.1 Basic Instructions
Visual KV Series
LOAD LD
R No.T/C No.
LOAD BAR LDB
AND AND
AND BAR ANB
OR OR
OR BAR ORB
AND LOAD ANL
OR LOAD ORL
OUT OUT
R No.
OUT BAR OUB
SET SET
RESET RES
0.1-sTIMER TMR T No.,
# presetvalue0.01-s
TIMERTMH
(FUN49)
0000 to 17915T000 to T249C000 to C249CTC0 to CTC3
0500 to 19152009
2300 to 17915
0500 to 19152009
2300 to 17915T000 to T249C000 to C249
0500 to 19152009
2100 to 17915T000 to T249C000 to C249CTH0 to CTH1CTC0 to CTC3
000 to 249#00000 to
#65535
0.7 to 1.6
0.7 to 1.6
0.7 to 0.9
0.7 to 0.9
0.7 to 0.9
0.7 to 0.9
0.8
0.8
1.5
1.5
1.9 to 12.8
1.9 to 20.5
12.0 to 17.8
12.0 to 17.8
3 (12)
3 (12)
3 (8)
3 (8)
3 (8)
3 (8)
1 (4)
1 (4)
3 (12)
3 (12)
3 (14)
3 (14)
2 (6)
2 (6)
Connects N.O. contact to bus.
Connects N.C. contact to bus.
Connects N.O. contact inseries with previous contact.
Connects N.C. contact inseries with previous contact.
Connects N.O. contact inparallel with previous contact.
Connects N.C. contact inparallel with previous contact.
Connects in series blocksmade of one or morecontacts.Connects in parallel blocksmade of one or morecontacts.
Outputs input ON/OFF statusto R coil.
Outputs inverted input ON/OFF status to R coil.
Forces relay ON and holdsthis status when input is ON.
Forces R/T/C OFF when inputis ON.
16-bit on-delay T that countsdown in 0.1-s decrements.
16-bit on-delay T that countsdown in 0.01-s decrements.
3-57
3-57
3-58
3-58
3-60
3-60
3-61
3-63
3-65
3-65
3-66
3-66
3-67
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
R No.T/C No.
nnnn
nnnn
nnnn
nnnn
nnnn
nnnn
nnnn
nnnn
nnnnSET
nnnnRES
#ddddd
Txxx
#ddddd
TxxxTH
3-68
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM34
Visual KV Series
3-35
12
Chapter 2 Instructions
2.1 Instruction List
• 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:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
1-msTIMER
TMS(FUN51)
COUNTER C# preset value,C No., counter
input R
UP-DOWNCOUNTER
UDC(FUN52)
C No.,# preset value
#00000 to#65535
000 to 2490000 to 17915
000 to 249#00000 to#65535
12.0 to 17.8
12.0 to 17.8
13.0 to 24.0
2 (7)
4 (7)
2 (10)
16-bit on-delay T thatcounts down in 1-msdecrements.
Sets 16-bit up-counter.
Sets a 16-bit up-downcounter.
000 to 249#0000 to #65535
3-72
3-76
3-69
DIFFEREN-TIATE UP
DIFU(FUN10)
R No.DIFFEREN-
TIATEDOWN
DIFD(FUN09)
KEEP KEEP(FUN22)
R No.
SHIFT SFT(FUN39)
nnnn: 1st RNo. mmmm:Last R No.
HIGHSPEED
HSP(FUN18) R No.
MASTERCONTROL
MC(FUN24)
MASTERCONTROL
RESET
MCR(FUN25)
MEMORYSWITCH
MEMSW(FUN26) $ constant
NOPNOP
(FUN30)
END END
END HI ENDH
1000 to 19153000 to 9915
0500 to 19152009
2100 to 17915
1000 to 19153000 to 9915
(KV-10)0000 to 0005
(KV-16)0000 to 0009
(KV-24)0000 to 0015
(KV-40)0000 to 0107
$ 0000 to$ FFFF
11.2 to 13.2
10.0 to 12.8
8.2 to 19.8
(*)
3.8 to 9.4
0.2
0.2
––
––
––
––
3 (10)
3 (10)
3 (11)
5 (15)
3 (8)
1 (4)
1 (0)
3 (0)
1 (0)
1 (1)
1 (0)
Turns ON R for 1 scantime at rising edge ofinput.Turns ON R for 1 scantime at falling edge ofinput.Turns ON R and holds thisstatus when SET input is ON.Turns OFF R when RESETinput is ON.
Sets shift register.
Reduces input relay timeconstant to 10 µs forhigher input response.
Selects ON/OFF status ofR coils, Ts, or Cs.
Represents end of MC.
Sets memory switches.
Performs no operation.
Indicates end of eachroutine of program.
Indicates end of entireprogram.
3-78
3-78
3-80
3-82
3-86
3-89
3-89
T No.,# preset value
3-94
3-94
3-94
#dddddTxxxT
S
#ddddd
nnnnCxxx
UDC xxx#ddddd
UPDWRES
nnnnDIFU
nnnn
DIFD
KEEP
SETRES
nnnn
SFTnnnn
mmmm
DCLKRES
HSPnnnn
MC
MCR
MEMSW$xxxx
END
ENDH
3-92
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM35
2.1 Instruction List Visual KV Series
3-36
2
Chapter 2 Instructions
• Number of bytes represents the memory capacity required for each instruction.• Number in ( ) represents the memory capacity required for object code of each
instruction.• All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F
2.1.2 Application Instructions
Instruction Symbol Mnemonic Operand Operand value FunctionExec.time
(µs) Bytes Page
WAIT ON
WAIT OFF
WAIT UPEDGE
WAITDOWNEDGE
CONNECT
PUSH
READ
POP
W-ON
W-OFF
W-UE
W-DE
CON(FUN 06)
MPS
MRD
MPP
nnnn:R, T, CNos.
mmmm:R No.R No.
17915T000 to T249C000 to C249CTC0 to CTC3
mmmm:1000 to 19153000 to 99151000 to 1915
10.4 to 12.6
13.6 to 18.5
13.6 to 18.5
6.8 to 5.3
3.2
6.8
10.5 to 13.0
5 (12)
5 (12)
5 (12)
1 (0)
1 (4)
1 (4)
1 (4)
R (output operand [mmmm])when R, T, or C (input operand[nnnn]) is ON.
Turns ON R (output operand[mmmm]) at falling edge of R, T,or C (input operand [nnnn]).Represents series connectionof output instruction togetherwith another instruction.
Stores input status andarithmetic flag.
Reads input status andarithmetic flag stored withPUSH.
3-96
3-96
3-98
3-98
3-102
STEP
STEP END
STP(FUN 45)
STE(FUN 43)
R No.nnnn:
0000 to
0500 to 9915T000 to T249C000 to C249CTC0 to CTC3
11.2 to 13.4
2.5
5 (12)
3 (10)
1 (0)
Reads & clears input statusand arithmetic flag storedwith PUSH.
Is used with STEP to makeprogram step.
STAGE
JUMP
ENDSTAGE
STG(FUN 44)
JMP(FUN 21)
ENDS(FUN 14)
R, T, CNos.
3000 to 99150000 to 0009
4.5 to 12.5
4.3 to 7.5
3 (10)
3 (8)
1 (4)
Turns ON
Turns ON R (output operand[mmmm]) when R, T, or C (inputoperand [nnnn]) is OFF.Turns ON R (output operand[mmmm]) at rising edge of R, T,or C (input operand [nnnn]).
Executes instructions in STGblock when R (operand) is ON.
When input is ON, turns R ofcurrent stage OFF and movesto stage specified by operand.
Turns current stage OFF andnext stage ON when input isON.
Executes program betweenSTP & STE when R (oper-and) is ON.
3-103
3-103
3-106
3-106
3-106
3-114
3-114
nnnnON
mmmm
nnnnOFF
mmmm
nnnn
mmmm
nnnn
mmmm
nnnn
STG
nnnn
JMP
ENDS
STPnnnn
STE
3-103
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM36
Visual KV Series
3-37
12
Chapter 2 Instructions
2.1 Instruction List
• Number of bytes represents the memory capacity required for each instruction.• Number in ( ) represents the memory capacity required for object code of each
instruction.• All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
INTERVALTIMER
16-BITCOUNTER
16-BITCOUNTERCOMPARA-
TOR
16-BITCOUNTER
16-BITCOUNTERCOMPARA-
TOR
SUBROUTINECALL
ITVL
CTH
CTC
CALL(FUN 03)
SBN(FUN 38)
RET(FUN 33)
DMnnnn:DM No.mmmm: RNo.
Count inputR
n:Comparator
No.ddddd:
# presetvalue
n:Comparator
No.ddddd:# preset
value
SubroutineNo.
DMnnnn:DM0000 toDM1985mmmm:
1000 to 19123000 to 9912
0004210021012102
n: 0,1ddddd: #00001
to #65535
00050500220022012202
20.0 to 80.0
14.4
2.3 to 3.5
5.4 to 6.5
4.3
5 (10)
4 (6)
2 (6)
4 (6)
2 (6)
2 (8)
Measures pulse-to-pulseinterval & pulse width inspecified mode.
16-bit (0 to 65535) up-down counter for clockpulses with input responsefrequency of 30 kHz.
Hardware-based comparatorbetween preset & currentvalues of high-speed counter(CTH0). This comparator isturned ON when thesevalues are equal.
Executes subroutinespecified by operand.
Represents beginning ofsubroutine specified byoperand.
Represents end ofsubroutine.
3-117
3-204
3-204
3-204
REPEATSTART
REPEAT END
16-KEY INPUT
FOR(FUN 16)
NEXT(FUN 29)
HKEY(FUN 17)
# constant,DM No.TMxx
nnnn:Input Rmmmm:Output R
#00000 to#65535
DM0000 toDM1999
TM00 to TM29
nnnn:0000 to 415
mmmm:0500 to 915
12.0 to18.0
0.5
22.1 to180.0
3 (20)
1 (4)
5 (10)
Executes programbetween FOR & NEXTfor number of timesspecified by operand.
Represents end ofrepetition.
Reads 16-key data bytime-sharing and outputsthese data into specialutility Rs 2900 to 2915.
3-125
3-125
SUBROUTINEENTRY
SUBROUTINERETURN
CTH
CTC
Count inputR
SubroutineNo.
n: 2,3ddddd: #00001
to #65535
00 to 99
00 to 99
14.4
2.3 to 3.5
2 (4)
1 (4)
16-bit (0 to 65535) up-down counter for clockpulses with inputresponse frequency of 30kHz.
Hardware-based comparatorbetween preset & currentvalues of high-speed counter(CTH1). This comparator isturned ON when thesevalues are equal.
3-204
3-122
3-122
3-131
ITVLPLSDMnnnnPAUSEmmmmRES
CTH0nnnn
CTCn#ddddd
CTH1nnnn
CTCn#ddddd
CALLnn
SBNnn
RET
FORnnnn
HKEYnnnn
mmmm
NEXT
3-122
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM37
2.1 Instruction List Visual KV Series
3-38
2
Chapter 2 Instructions
• Number of bytes represents the memory capacity required for each instruction.• Number in ( ) represents the memory capacity required for object code of each
instruction.
2.1.3 Arithmetic Instructions
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
DATAMEMORY
WRITE
TRIMMERSETTING
LOAD A
STORE A
COMPARE
ADD
SUBTRACT
MULTIPLY
DW
TMIN(FUN 50)
@TMIN@(FUN 50)
LDA(FUN 23)
@LDA@(FUN 23)
STA(FUN 42)
@STA@(FUN 42)
CMP(FUN 04)
@CMP@(FUN 04)
ADD(FUN00)
@ADD@(FUN 00)
SUB(FUN 46)
@SUB@(FUN 46)
MUL(FUN 28)
@MUL@(FUN28)
nnnn:#/$ constantDMmmmm:
DM No.
Trimmer No.
R No.,C/T No.,DM No,TM xx,
#/$ constant,#TMxx
R No.,C/T No.,DM No.,TM xx,#TMxx
DM/TM No.TMxx,
#/$ constant,#TMxx
nnnn:#0000 to#65535$0000 to$FFFF
DMmmmm:DM0000 toDM1999
0 to 1
0000 to 17915T000 to T249C000 to C249CTH0 to CTH1
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to $FFFF
#TM00 to#TM29
0500 to 19152100 to 17915T000 to T249C000 to C249
CTH0 toCTC3
DM0000 toDM1999
TM00 to TM29#TM00 to#TM29
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
8.0
8.9
20.9
6.4 to 14.0
18.4 to 26.0
6.6 to 28.5
18.0 to 40.5
10.8 to 35.6
22.8 to 47.6
9.4 to 34.2
21.4 to 46.2
10.8 to 35.6
22.8 to 47.6
14.4 to 38.1
26.4 to 50.1
5 (8)
1 (6)
1 (16)
3 (8)
3 (18)
3 (8)
3 (18)
3 (6)
3 (16)
3 (6)
3 (16)
3 (6)
3 (16)
3 (6)
3 (16)
Writes constant into datamemory.
Inputs value set byaccess window’s digitaltrimmer (0 to 65535) tointernal register.
Inputs value specified byoperand into internalregister or inputs currentvalue when T/C isspecified as operand.
Transfers content ofinternal register tolocation specified byoperand, or changespreset value when T/C isspecified as operand.
Compares content ofinternal register andvalue specified byoperand.
Adds content of internalregister and valuespecified by operand andinputs result back tosame register.
Subtracts value specifiedby operand from contentof register and inputsresult back to sameregister.
Multiplies content ofinternal register by valuespecified by operand andinputs result back tosame register.
3-136
3-138
3-140
3-140
3-150
3-150
nnnn
DMmmmmDW
n TMIN
n TMIN
nnnnLDA
nnnnLDA
nnnnSTA
nnnnSTA
nnnnCMP
nnnnCMP
nnnnADD
nnnnADD
nnnnSUB
nnnnSUB
nnnnMUL
nnnnMUL
3-150
3-146
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM38
Visual KV Series
3-39
12
Chapter 2 Instructions
2.1 Instruction List
• 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:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F
@DIV@(FUN 11)
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
DIVIDE
DIV(FUN 11)
17.4 to 43.3
29.4 to 55.3
3 (6)
3 (16)
Divides content of internalregister by value specifiedby operand and inputsresult back to sameregister.
R No.,DM No.,TM xx,
#/$ constant,#TMxx
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
AND A
OR A
EXCLUSIVEOR A
SHIFTRIGHT A
SHIFT LEFTA
ROTATERIGHT A
ROTATELEFT A
ANDA(FUN 01)
@ANDA@(FUN 01)
ORA(FNC 31)
@ORA@(FUN 31)
EORA(FUN 15)
@EORA@(FUN 15)
SRA(FNC 41)
@SRA@(FUN 41)
SLA(FNC 40)
@SLA@(FUN 40)
RRA(FUN 37)
@RRA@(FUN 37)
RLA(FUN 35)
@RLA@(FUN 35)
R No.,DM No.,TM xx,
#/$ constant,#TMxx
R No.,DM No.,TM xx,
#/$ constant,#TMxx
# constant
0000 to 17915DM0000 to
DM1999TM00 to TM31
#00000 to#65535
$0000 to$FFFF
#TM00 to#TM29
0000 to 17915DM0000 to
DM1999TM00 to TM31
#00000 to#65535
$0000 to$FFFF
#TM00 to#TM29
8.2 to 33.1
20.2 to 45.1
8.2 to 33.1
20.2 to 45.1
8.2 to 33.1
20.2 to 45.1
9.3 to 27.6
21.3 to 39.6
9.2 to 27.6
21.2 to 39.6
10.3 to 28.6
22.3 to 40.6
10.3 to 28.6
22.3 to 40.6
3 (8)
3 (18)
3 (8)
3 (18)
3 (8)
3 (18)
2 (6)
2 (16)
2 (6)
2 (16)
2 (6)
2 (16)
2 (6)
2 (16)
ANDs each of 16 bits ofinternal register and thatof value specified byoperand, and inputs resultback to same register.
ORs each of 16 bits ofinternal register and thatof value specified byoperand, and inputs resultback to same register.
EXCLUSIVE-ORs each of16 bits of internal registerand that of value specifiedby operand, and inputsresult back to sameregister.
Moves content of internalregister serially left byvalue specified byoperand.
Rotates contents ofinternal register and carrybit (2009) clockwise byoperand value.
Rotates contents ofinternal register and carrybit (2009) counterclock-wise by operand value.
Moves content of internalregister serially right byvalue specified byoperand.
3-159
3-161
3-164
3-166
#01 to #16
3-166
3-169
nnnnDIV
nnnnDIV
nnnnANDA
nnnnANDA
nnnnORA
nnnnORA
nnnnEORA
nnnnEORA
#ddSRA
#ddSRA
#ddSLA
#ddSLA
#ddRRA
#ddRRA
#ddRLA
#ddRLA
3-169
3-150
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:52 AM39
2.1 Instruction List Visual KV Series
3-40
2
Chapter 2 Instructions
• Number of bytes represents the memory capacity required for each instruction.• Number in ( ) represents the memory capacity required for object code of each
instruction.• All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F (OUTPUT)
Converts content ofinternal register (4-digitBCD) into 16-bit binarydata.
Converts content ofinternal register (16-bitbinary) into 4-digit BCDdata.
DEMULTI-PLEXER
TRANSFERBCD
TRANSFERBIN
ASCIICONVERT
REVERSEASCII
CONVERT
SQUAREROOT
DMX(FUN 12)
@DMX@(FUN 12)
TBCD(FUN 47)
@TBCD@(FUN 47)
TBIN(FUN 48)
@TBIN@(FUN 48)
ASC(FUN 02)
@ASC@(FUN 02)
RASC(FUN 32)
@RASC@(FUN 32)
ROOT(FUN 36)
@ROOT@(FUN 36)
22.6
34.6
5.6
17.6
9.6
21.6
9.7
21.7
9.3
21.3
95.7 1 (4)
1 (4)
1 (14)
1 (4)
1 (14)
1 (14)
1 (4)
1 (14)
1 (4)
1 (14)
1 (4)
1 (14)
Converts position ofhighest order bit with 1 ininternal register into 4-bitdata.
Converts content of lowerorder 8 bytes of internalregister into 2-digit ASCIIcode.
Converts 2-digit ASCIIcode of internal registerinto 2-digit numericalvalue.
Takes square root of 32-bit data (TM00: higherorder byte, internalregister: lower order byte)and inputs result back tosame register.
3-176
3-180
3-180
3-183
3-183
Instruction Symbol Mnemonic Operand Operandvalue
Function Exec.time(µs) Bytes Page
COMPLE-MENT
INCREMENTMEMORY
DECRE-MENT
MEMORY
MULTI-PLEXER
COM(FUN 05)
@COM@(FUN 05)
INC(FNC 19)
@INC@(FUN 19)
DEC(FNC 07)
@DEC@(FUN 07)
MPX(FUN 27)
@MPX@(FUN 27)
DM/TM No.
DM/TM No.
DM0000 toDM1999TM00 to
TM29
5.6
17.6
9.8
21.8
10.4
22.4
10.1
22.1
1 (4)
1 (14)
3 (6)
3 (16)
3 (6)
3 (16)
1 (6)
1 (16)
Inverts content of each bitin internal register.
Adds 1 to content of datamemory specified byoperand.
Subtracts 1 from contentof data memory specifiedby operand.
Converts 4-bit data(specified by operand) ofinternal register into 16-bitdata.
3-171
3-172
3-172
# constant
DM0000 toDM1999TM00 to
TM29
#0 to #3
COM
COM
nnnnINC
nnnnINC
nnnnDEC
nnnnDEC
#nMPX
#nMPX
DMX
DMX
TBCD
TBCD
TBIN
TBIN
ASC
ASC
RASC
RASC
ROOT
ROOT
3-185
3-176
107.7
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM40
Visual KV Series
3-41
12
Chapter 2 Instructions
2.1 Instruction List
• Number of bytes represents the memory capacity required for each instruction.• Number in ( ) represents the memory capacity required for object code of each
instruction.• All operand values are shown in normal notation. The corresponding relay
numbers in X-Y-M notation are shown below:
Normal notation X-Y-M notation0000 to 0415 X000 to X04F0500 to 0915 Y050 to Y09F1000 to 6915 M1000 to M69157000 to 17915 X700 to X174F or Y750 to Y179F
2.1.5 Function No. List (Alphabetical order)The following list shows the function Nos. used to enter instructions with the KV-P3E(01) handheld programmer. Refer to "Chapter 6 Handheld Programmer" on page 1-195 for details.
Reference: To find function No. assigned to desired function:1. Press the [FUN] key.2. When the cursor appears at the position where the function No. is to be entered,
press the ON or OFF key and scroll the functions and assigned Nos. to find thedesired function.
2.1.4 Interrupt Instructions
Instruction Symbol Mnemonic Operand Operand value Function Exec.time(µs) Bytes Page
INTERRUPTDISABLED
INTERRUPTENABLED
INTERRUPT
RETURNINTERRUPT
DI(FUN 08)
EI(FUN 13)
INT(FUN 20)
RETI(FUN 34)
R No.
ComparatorNo.
000 to 003
CTC0 toCTC3
2.2
4.0
60.0 to90.0
60.0 to90.0
18.0 to22.0
1 (12)
1 (10)
1 (8)
1 (4)
Disables execution ofinterrupt.
Enables execution ofinterrupt.
Executes interruptinstructions between INTand RETI at rising/fallingedge of input relays 0000through 0003.
Used with comparatorsCTC0 to CTC3 andexecutes instructionsbetween INT and RETI.
Represents end ofinterrupt.
3-193
3-193
3-192
3-1921 (8)
3-192
DI
EI
INTnnnn
INTCTCn
RETI
.oNnoitcnuF noitcurtsnI
00 DDA
10 ADNA
20 CSA
30 LLAC
40 PMC
50 MOC
60 NOC
70 CED
80 ID
90 DFID
01 UFID
11 VID
21 XMD
.oNnoitcnuF noitcurtsnI
62 WSMEM
72 XPM
82 LUM
92 TXEN
03 PON
13 ARO
23 CSAR
33 TER
43 1TER
53 ALR
63 TOOR
73 ARR
83 NBS
.oNnoitcnuF noitcurtsnI
31 IE
41 SDNE
51 AROE
61 ROF
71 YEKH
81 PSH
91 CNI
02 TNI
12 PMJ
22 PEEK
32 ADL
42 CM
52 RCM
.oNnoitcnuF noitcurtsnI
93 TFS
04 ALS
14 ARS
24 ATS
34 ETS
44 GTS
54 PTS
64 BUS
74 DCBT
84 NIBT
94 HMT
05 NIMT
15 SMT
25 CDU
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM41
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-42
2
Chapter 2 Instructions
2.2 Instruction List• 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.
2.2.1 Basic InstructionsKV-10/16/24/40/80
KV-300 Series, KV-10/80
nnnnLOAD
nnnn
nnnn
nnnn
nnnn
nnnn
nnnn
nnnn
(SET)nnnn
LD
R No.T/C No.
LOAD BAR LDB
AND AND
AND BAR ANB
OR OR
OR BAR ORB
AND LOAD ANL
OR LOAD ORL
OUT OUT
R No.
OUT BAR OUB
SET SET
RESET RES
0.1-s TIMER TMR
T No.,# preset
value
0.01-sTIMER
TMH(FNC49)
1-ms TIMERTMS
(FNC51)
COUNTER C
# presetvalue, C
No., clocksource R
UP-DOWNCOUNTER
UDC(FNC52)
C No.,# preset
value
0000 to 2915T000 to T063C000 to C063CTC0 to CTC3
0500 to 19152009
2300 to 2915
0500 to 19152009
2100 to 2915T000 to T063C000 to C063
0500 to 19152009
2100 to 2915T000 to T063C000 to C063CTH0 to CTH1CTC0 to CTC3
(RES)nnnn
#ddddd
T xxx
#dddddxxxH
#dddddxxxS
nnnn
#dddddC xxx
UDCxxx#dddddUP
DWRES
000 to 063#00000 to#65535
#00000 to65535
000 to 0630000 to 6915
000 to 063#00000 to
#65535
0000 to 6915T000 to T119C000 to C119CTC0 to CTC3
0500 to 19152009
2300 to 6915
0500 to 19152009
2100 to 6915T000 to T119C000 to C119
0500 to 19152009
2100 to 6915T000 to T119C000 to C119CTH0 to CTH1CTC0 to CTC3
000 to 119#00000 to#65535
#00000 to#65535
000 to 1190000 to 6915
000 to 119#00000 to
#65535
1.5 to 2.5
2.1 to 3.5
1.5 to 2.5
2.7 to 4.5
1.5 to 2.5
2.7 to 4.5
1.0 to 1.4
1.0 to 1.4
5.2 to 8.4
6.4 to 10.4
3.1 to 23.0
3.1 to 24.0
17.0 to 22.0
17.0 to 22.0
17.0 to 22.0
19.0 to 21.0
21.0 to 26.0
3 (4)
3 (6)
3 (4)
3 (8)
3 (4)
3 (8)
1 (2)
1 (2)
3 (13)
3 (17)
3 (8)
3 (8)
2 (5)
2 (5)
2 (5)
4 (7)
2 (5)
Connects N.O. contactto bus.
Connects N.C. contactto bus.
Connects N.O. contactin series with previouscontact.Connects N.C. contactin series with previouscontact.Connects N.O. contactin parallel with previouscontact.Connects N.C. contactin parallel with previouscontact.Connects in seriesblocks made of one ormore contacts.Connects in parallelblocks made of one ormore contacts.Outputs input ON/OFFstatus to R coil.Outputs inverted input
ON/OFF status to Rcoil.
Forces R ON and holdsthis status when input isON.
Forces R/T/C OFFwhen input is ON.
16-bit on-delay T thatcounts down in 0.1-sdecrements.16-bit on-delay T thatcounts down in 0.01-sdecrements.16-bit on-delay T thatcounts down in 1-msdecrements.
Sets 16-bit up-counter.
Sets a 16-bit up-downcounter.
Page
3-57
3-57
3-58
3-58
3-60
3-60
3-61
3-63
3-65
3-65
3-66
3-66
3-67
3-68
3-69
3-72
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction
3-76
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM42
KV-300 Series, KV-10/80
3-43
12
Chapter 2 Instructions
2.2 Instruction List
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs)
BytesFunction Page
LOADnnnn
nnnn
nnnn
nnnn
nnnn
nnnn
LOAD BAR
AND
AND BAR
OR
OR BAR
AND LOAD
OR LOAD
LD
LDB
AND
ANB
OR
ORB
ANL
ORL
R No.T/C No.
0000 to 00090500 to 17915T000 to T249C000 to C249CTC0 to CTC3
0.15 to 0.70
0.15 to 0.90
0.15 to 0.50
0.15 to 0.80
0.15 to 0.50
0.15 to 0.80
0.55
0.55
3 (5)
3 (7)
3 (4)
3 (8)
3 (4)
3 (8)
1 (3)
1 (3)
Connects N.O. contactto bus.
Connects N.C. contactto bus.
Connects N.O. contactin series with previouscontact.Connects N.C. contactin series with previouscontact.Connects N.O. contactin parallel withprevious contact.Connects N.C. contactin parallel withprevious contact.Connects in seriesblocks made of one ormore contacts.Connects in parallelblocks made of one ormore contacts.
3-57
3-57
3-58
3-58
3-60
3-60
3-61
3-63
KV-300
nnnnDIFU
nnnnDIFD
KEEPSETRES
nnnn
SFTDCLKRES
nnnn
mmmm
MC
HSPnnnn
MCR
$xxxxMEMSW
$xxxx
END
ENDH
DIFFEREN-TIATE UP
DIFU(FNC10)
R No.DIFFEREN-
TIATEDOWN
DIFD(FNC09)
KEEPKEEP
(FNC22)R No.
SHIFT SFT(FNC39)
R No.1st& last R
Nos.
HIGHSPEED
HSP(FNC18) R No.
MASTERCONTROL
MC(FNC24)
MASTERCONTROL
RESET
MCR(FNC25)
MEMORYSWITCH
MEMSW(FNC26)
$ constant
NOP NOP(FNC30)
END END
END HI ENDH
1000 to 1915
0500 to 19152009
2100 to 2915
1000 to 1915
(KV-10)0000 to 0005
(KV-16)0000 to 0009
$ 0000 to $ FFFF
1000 to 19153000 to 6915
0500 to 19152009
2100 to 69151000 to
19153000 to6915
(KV-24)0000 to 0015
(KV-40)0000 to 0107
11.0 to 13.0
11.0 to 13.0
9.0 to 26.0
(*)
8.0 to 9.0
1.8 to 3.2
0.6 to 1.0
––
––
––
––
3 (5)
3 (5)
3 (5)
5 (7)
3 (4)
1 (7)
1 (2)
3 (0)
1 (0)
1 (3)
1 (0)
Turns ON R for 1scan time at risingedge of input.
Turns ON R for 1scan time at fallingedge of input.Turns ON R andholds this status whenSET input is ON.
Turns OFF R whenRESET input is ON.
Sets shift register.
Reduces input relay timeconstant to 25 ms forhigher input response.Selects ON/OFFstatus of R coils, Ts,or Cs.
Represents end of MC.Sets memory switches.
Performs no opera-tion.
Indicates end of eachroutine of program.
Indicates end of entireprogram.
3-78
3-78
3-80
3-82
3-86
3-89
3-89
3-92
3-94
3-94
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
3-94
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM43
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-44
2
Chapter 2 Instructions
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
OUT
OUT BAR
nnnn
nnnn
(SET)nnnn
(RES)nnnn
#ddddd
T xxx
#dddddxxxH
#dddddxxxS
nnnn
#dddddC xxx
UDCxxx#dddddUP
DWRES
nnnnDIFU
nnnnDIFD
KEEPSETRES
nnnn
SFTDCLKRES
nnnn
mmmm
HSPnnnn
MC
MCR
$xxxxMEMSW
$xxxx
END
ENDH
SET
RESET
0.1-s TIMER
0.01-s TIMER
1-ms TIMER
COUNTER
UP-DOWNCOUNTER
DIFFEREN-TIATE UP
DIFFEREN-TIATE DOWN
KEEP
SHIFT
HIGHSPEED
MASTERCONTROL
MASTERCONTROLRESET
MEMORYSWITCH
NOP
END
OUT
OUB
SET
RES
TMR
TMH(FNC49)
TMS(FNC51)
C
UDC(FNC52)
DIFUFNC10)
DIFD(FNC09)
KEEP(FNC22)
SFT(FNC39)
HSP(FNC18)
MC(FNC24)
MCR(FNC25)
MEMSW(FNC26)
NOP(FNC30)
END HI
END
ENDH
R No.
T No.,# presetvalue
# presetvalue, CNo., clocksource R
C No.,# presetvalue
R No.
R No.
1st &last RNos.
R No.
$ constant
0500 to 19152009
2300 to 17915
0500 to 19152009
2100 to 17915T000 to T249C000 to C249
0500 to 19152009
2100 to 17915T000 to T249C000 to C249CTH0 to CTH1CTC0 to CTC3
000 to 249#00000 to 65535
#00000 to #65535000 to 249
0000 to 00090500 to 17915
000 to 249#00000 to #65535
1000 to 19153000 to 6915
(*) 7000 to 9915
0500 to 19152009
2100 to 179151000 to 19153000 to 6915
(*) 7000 to 9915
0000 to 0009
$0000 to $FFFF
0.20 to 0.56
0.50 to 1.20
0.20 to 5.70
0.50 to 4.40
5.60 to 10.40
5.60 to 10.40
5.60 to 10.40
7.60 to 9.45
8.00 to 11.60
6.70
6.70
6.10 to 7.90
6.40 to 8.20
4.66 to 4.92
0.20
—
—
—
0.95
—
3 (8)
3 (11)
3 (12)
3 (12)
2 (7)
2 (7)
2 (7)
4 (7)
2 (10)
3 (10)
3 (10)
3 (11)
5 (15)
3 (8)
1 (4)
1 (0)
3 (0)
1 (0)
1 (1)
1 (0)
Outputs input ON/OFFstatus to R coil.
Outputs inverted inputON/OFF status to Rcoil.
Forces R ON and holdsthis status when inputis ON.
Forces R/T/C OFFwhen input is ON.
16-bit on-delay T thatcounts down in 0.1-sdecrements.16-bit on-delay T thatcounts down in 0.01-sdecrements.16-bit on-delay T thatcounts down in 1-msdecrements.
Sets 16-bit up-counter.
Sets a 16-bit up-downcounter.
Turns ON R for 1 scantime at rising edge ofinput.Turns ON R for 1 scantime at falling edge ofinput.Turns ON R and holdsthis status when SETinput is ON.
Turns OFF R whenRESET input is ON.
Sets shift register.
Reduces input relay timeconstant to 25 ms forhigher input response.
Selects ON/OFF statusof R coils, Ts, or Cs.
Represents end of MC.Sets memory switches.
Performs no operation.
Indicates end of eachroutine of program.
Indicates end of entireprogram.
3-65
3-65
3-66
3-66
3-67
3-68
3-69
3-72
3-76
3-78
3-78
3-80
3-82
3-86
3-89
3-89
3-92
3-94
3-94
Note: 14.0 + 3.0 x (n) to 17.0 + 3.0 x (n) (n represents number of times the originaldata is generated.)
3-94
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM44
KV-300 Series, KV-10/80
3-45
12
Chapter 2 Instructions
2.2 Instruction List
2.2.2 Application InstructionsKV-10/16/24/40/80
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs) Bytes
Function Page
WAIT ON
WAIT OFF
WAIT UPEDGE
WAIT DOWNEDGE
CONNECT
PUSH
READ
POP
STAGE
JUMP
ENDSTAGE
STEP
STEP END
INTERVALTIMER
8-BITCOUNTER
8-BITCOUNTERCOMPARA-
TOR
16-BITCOUNTER
16-BITCOUNTERCOMPARA-
TOR
SUBROU-TINE CALL
SUBROU-TINE ENTRY
SUBROU-TINE
RETURN
W-ONnnnnON
mmmm
W-OFFnnnnOFF
mmmm
W-UE
W-D
CON[FNC 06]
MPS
MRD
MPP
STG[FNC 44]
JMP[FNC 21]
ENDS[FNC 14]
STP[FNC 45]
STE[FNC 43]
ITVL
CTH
CTC
CTH
CTC
CALL[FNC 03]
SBN[FNC 38]
RET[FNC 33]
nnnn:R,T, or C
No.
R No.
R, T, CNos.
DM & RNo.
Clocksource Rs
n:Comparator
No.ddddd: #
preset value
Clocksource Rs
n: Compara-tor No.
ddddd: #preset value
Subrou-tine No.
Subrou-tine No.
nnnn↑
mmmm
nnnn↓
mmmm
nnnnSTG
nnnnJMP
ENDS
STPnnnn
STE
ITVLPLS
PAUSERES
nnnnmmmm
DM
nnnnCTH0
#ddddd
CTCn
nnnnCTH1
#ddddd
CTCn
nn
CALL
nnSBN
RET
nnnn:0000 to 2915T000 to T063C000 to C063CTC0 to CTC3
mmmm:1000 to 1915
1000 to 1915
0000 to 2915T000 to T063C000 to C063CTC0 to CTC3
DM0000 toDM0985
1000 to 1912
00042100 to 2102
n: 0,1ddddd: #00000 to #00255
00052200 to 2202
n: 2,3ddddd: #00000 to #65535
00 to 99
00 to 99
nnnn:0000 to 6915T000 to T119C000 to C119CTC0 to CTC3
mmmm:1000 to 19153000 to 6915
1000 to 19153000 to 6915
0000 to 6915T000 to T119C000 to C119CTC0 to CTC3
DM0000 toDM1985
1000 to 19123000 to 6912
11.0 to13.0
11.0 to13.0
14.0 to18.0
14.0 to18.0
0.4 to0.6
11.0 to14.0
8.0 to10.0
10.0 to12.0
11.0 to14.0
10.0 to13.0
7.0 to9.0
3.7 to5.3
0.00
29.0 to79.0
9.0 to39.0
3.0 to 4.0
8.0 to48.0
3.0 to 4.0
8.0 to10.0
0.00
4.6 to 6.2
5 (7)
5 (7)
5 (7)
5 (7)
301
1 (3)
1 (3)
1 (3)
3 (7)
3 (5)
1 (3)
3 (7)
1 (0)
5 (7)
4 (4)
2 (5)
4 (4)
2 (5)
2 (6)
2 (0)
1 (5)
Turns ON R (2nd operand[mmmm]) when R, T, or C (1stoperand [nnnn]) turns ON.
When R, T, or C (1st operand[nnnn]) turns OFF, R (2ndoperand [mmmm]) turns ON.R (2nd operand [mmmm])turns ON at rising edge of R, T,or C (1st operand [nnnn]).
R (2nd operand [mmmm])turns ON at falling edge of R,T, or C (1st operand [nnnn]).
Represents series connectionof output instruction togetherwith another instruction.
Stores input status andarithmetic flag.
Reads input status andarithmetic flag stored withPUSH.Reads & clears input statusand arithmetic flag stored withPUSH.Executes instructions betweenSTG & JMP when R(operand) is ON.
Turns current stage OFF andnext stage ON when input isON.
Turns current stage OFF wheninput is ON.
Executes program betweenSTP & STE when R (operand)is ON.
Is used with STEP to makeprogram step.
Measures pulse-to-pulseinterval & pulse width inspecified mode.
8-bit (0 to255) up-counter forclock pulses with inputresponse frequency of 10 kHz.Hardware-based comparatorbetween preset & currentvalues of high speed counter.This comparator is turned ONwhen these values are equal.16-bit (0 to 65535) up-counterfor clock pulses with inputresponse frequency of 10 kHz.Hardware-based comparatorbetween preset & currentvalues of high speed counter.This comparator is turned ONwhen these values are equal.
Executes subroutine specifiedby operand.
Represents beginning ofsubroutine specified byoperand.
Represents end of subroutine.
3-96
3-96
3-98
3-98
3-102
3-103
3-103
3-103
3-106
3-106
3-106
3-114
3-114
3-117
3-277
3-277
3-204
3-204
3-122
3-122
3-122
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM45
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-46
2
Chapter 2 Instructions
KV-300KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
WAIT ONnnnnON
mmmm
nnnnOFF
mmmm
nnnn↑
mmmm
nnnn↓
mmmm
nnnnSTG
nnnnJMP
ENDS
STPnnnn
STE
ITVLPLS
PAUSERES
nnnnmmmm
DM
nnnnCTH0
WAIT OFF
WAIT UPEDGE
WAIT DOWNEDGE
CONNECT
PUSH
READ
POP
STAGE
JUMP
ENDSTAGE
STEP
STEP END
INTERVALTIMER
16-BITCOUNTER
W-ON
W-OFF
W-UE
W-DE
CON[FNC 06]
MPS
MRD
MPP
STG[FNC 44]
JMP[FNC 21]
ENDS[FNC 14]
STP[FNC 45]
STE[FNC 43]
ITVL
CTH
nnnn:R,T, orC No.
R No.
R, T,C Nos.
DM & R No.
Clocksource Rs
nnnn:0000 to 00090500 to 17915T000 to T249C000 to C249CTC0 to CTC3
mmmm:1000 to 19153000 to 6915
(*)7000 to 9915
1000 to 19153000 to 6915
(*)7000 to 9915
0000 to 00090500 to 6915
(*)7000 to 9915T000 to T249C000 to C249CTC0 to CTC3
DMnnnn:DM0000 to DM9985
mmmm:1000 to 19123000 to 6912
(*)7000 to 9912
0004210021012102
5.00 to 6.10
5.00 to 6.10
6.10 to 7.50
6.10 to 7.50
—
1.30
2.70
1.40
5.60 to 6.50
3.80 to 6.00
—
1.30
—
13.80 to17.30
3.85
5 (9)
5 (9)
5 (10)
5 (10)
1 (0)
1 (9)
1 (18)
1 (9)
3 (10)
3 (7)
1 (0)
3 (9)
1 (0)
5 (11)
4 (7)
Turns ON R (2nd operand[mmmm]) when R, T, or C (1stoperand [nnnn]) turns ON.
When R, T, or C (1st operand[nnnn]) turns OFF, R (2ndoperand [mmmm]) turns ON.R (2nd operand [mmmm])turns ON at rising edge of R,T, or C (1st operand [nnnn]).R (2nd operand [mmmm])turns ON at falling edge of R,T, or C (1st operand [nnnn]).
Represents series connectionof output instruction togetherwith another instruction.
Stores input status andarithmetic flag.
Reads input status andarithmetic flag stored withPUSH.
Reads & clears input statusand arithmetic flag storedwith PUSH.Executes instructionsbetween STG & JMP when R(operand) is ON.
Turns current stage OFF andnext stage ON when input isON.
Turns current stage OFFwhen input is ON.
Executes program betweenSTP & STE when R(operand) is ON.
Is used with STEP to makeprogram step.
Measures pulse-to-pulseinterval & pulse width inspecified mode.
16-bit (0 to 65535) up-counterfor clock pulses with inputresponse frequency of 30kHz.
3-96
3-96
3-98
3-98
3-102
3-103
3-103
3-103
3-106
3-106
3-106
3-114
3-114
3-117
3-204
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
REPEATSTART
REPEATEND
16-KEYINPUT
FOR[FNC 16]
NEXT[FNC 29]
HKEY[FNC 17]
# constant,DM No.
I/O R
nnnnFOR
NEXT
nnnnmmmm
HKEY
#00000 to#65535
DM0000 toDM0999
TM00 to TM29
nnnn:0000 to 000910000 to 10415
:17000 to 17415
mmmm:10500 to 10915:
17500 to 17915
#00000 to#65535
DM0000 toDM1999
TM00 to TM29
5.0 to 20.0
1.7 to 2.3
71 to 370
3 (15)
1 (3)
5 (7)
Executes programbetween FOR & NEXTfor number of timesspecified by operand.
Represents end ofrepetition.
Reads 16-key data bytime-sharing andoutputs these data intospecial utility Rs 2900to 2915.
3-125
3-125
3-131
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM46
KV-300 Series, KV-10/80
3-47
12
Chapter 2 Instructions
2.2 Instruction List
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
16-BITCOUNTERCOMPARA-
TOR
16-BITCOUNTER
16-BITCOUNTERCOMPARA-
TOR
SUBROU-TINE CALL
SUBROU-TINE ENTRY
SUBROU-TINE
RETURN
REPEATSTART
REPEATEND
16-KEYINPUT
CTC
CTH
CTC
SBN[FNC 38]
RET[FNC 33]
FOR[FNC 16]
NEXT [FNC 29]
HKEY[FNC 17]
CALL [FNC 03]
#ddddd
CTCn
nnnnCTH1
#ddddd
CTCn
nn
CALL
nnSBN
RET
nnnnFOR
NEXT
nnnnmmmm
HKEY
n:Comparator
No.ddddd: #
preset value
Clocksource Rs
n:Comparator
No.ddddd: #
preset value
SubroutineNo.
SubroutineNo.
# constant,DM No.
I/O R
n: 0, 1ddddd:
#00000 to #65535
0005220022012202
n: 2, 3ddddd:
#00000 to #65535
00 to 99
00 to 99
#00000 to #65535DM0000 to DM9999
TM00 to TM29
nnnn:0000 to 000910000 to 10415
:17000 to 17415
mmmm:0500 to 050310500 to 10915
:17500 to 17915
—
3.85
—
3.16
—
1.15 to 1.45
1.55
—
16.50
2 (0)
4 (7)
2 (0)
2 (17)
2 (0)
1 (6)
3 (19)
1 (0)
5 (9)
Hardware-based comparatorbetween preset & currentvalues of high speed counter.This comparator is turned ONwhen these values are equal.
16-bit (0 to 65535) up-counter for clock pulses withinput response frequency of30 kHz.
Hardware-based comparatorbetween preset & currentvalues of high speed counter.This comparator is turned ONwhen these values are equal.
Executes subroutinespecified by operand.
Represents beginning ofsubroutine specified byoperand.
Represents end ofsubroutine.
Executes program betweenFOR & NEXT for number oftimes specified by operand.
Represents end of repetition.
Reads 16-key data by time-sharing and outputs thesedata into special utility Rs2900 to 2915.
3-204
3-204
3-204
3-122
3-122
3-122
3-125
3-125
3-131
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM47
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-48
2
Chapter 2 Instructions
2.2.3 Arithmetic InstructionsKV-10/16/24/40/80
KV-10/16/24/40/80 Instruction Symbol Mnemonic Operand Operand value
KV-10/16Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
DATAMEMORY
WRITE
TRIMMERSETTING
LOAD A
STORE A
COMPARE
ADD
SUBTRACT
MULTIPLY
DIVIDE
DW
TMIN[FNC 50]
@TMIN@[FNC 50]
LDA[FNC 23]
@LDA@[FNC 23]
STA[FNC 42]
@STA@[FNC 42]
CMP[FNC 04]
@CMP@[FNC 04]
ADD[FNC 00]
@ADD@[FNC 00]
SUB[FNC 46]
@SUB@[FNC 46]
MUL[FNC 28]
@MUL@[FNC 28]
DIV[FNC 11]
@DIV@[FNC 11]
#/$constant,DM No.
TrimmerNo.
R No.,C/T No.,DM/TM
No.,#/$
constant,#TMxx
R No.,C/T No.,DM/TM
No.,#/$
constant,#TMxx
DM/TMNo.,#/$
constant,#TMxx
DM/TMNo.,
#/$ No.,#TMxx
#00000 to#65535$0000 to$FFFF
DM0000 toDM0999
0
0000 to 2915T000 to T063C000 to C063CTH0 to CTH1
DM0000 toDM0999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
0500 to 19152100 to 2915T000 to T063C000 to C063
DM0000 toDM0999
TM00 to TM29#TM00 to#TM29
DM0000 toDM0999
TM00 to TM31#00000 to#65535$0000 to$FFFF
#TM00 to#TM29
DM0000 toDM0999
TM00 to TM31#00000 to#65535$0000 to$FFFF
#TM00 to#TM29
#0000 to#65535$0000 to$FFFF
DM0000 toDM1999
0 to 1
0000 to 6915T000 to T119C000 to C119CTH0 to CTH1
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
0500 to 19152100 to 6915T000 to T119C000 to C119
DM0000 toDM1999
TM00 to TM29#TM00 to#TM29
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
DM0000 toDM1999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
3.6 to 6.0
13.0 to 15.0
25.0 to 29.0
10.0 to 46.0
22.0 to 60.0
9.0 to 99.0
21.0 to 113.0
14.0 to 68.0
26.0 to 82.0
13.0 to 65.0
25.0 to 79.0
15.0 to 68.0
27.0 to 82.0
17.0 to 71.0
29.0 to 85.0
22.0 to 79.0
34.0 to 93.0
5 (6)
1 (4)
1 (11)
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
Writes constant intodata memory.
Converts trimmerrotation angle into 0to 249 and inputs itinto internal register.
Inputs value specifiedby operand intointernal register orinputs current valuewhen T/C is specifiedas operand.
Transfers content ofinternal register tolocation specified byoperand, or changespreset value when T/C is specified asoperand.
Compares content ofinternal register andvalue specified byoperand.
Adds content ofinternal register andvalue specified byoperand and inputsresult back to sameregister.Subtracts valuespecified by operandfrom content ofregister and inputsresult back to sameregister.
Multiplies content ofinternal register byvalue specified byoperand and inputsresult back to sameregister.
Divides content ofinternal register byvalue specified byoperand and inputsresult back to sameregister.
3-136
3-138
3-140
3-140
3-146
3-150
3-150
3-150
3-150
< DW >DMmmmm
nnnn
< TMIN >n
↑ TMIN >n
< LDA >nnnn
↑ LDA >nnnn
< STA >nnnn
↑ STA >nnnn
< CMP >nnnn
↑ CMP >nnnn
< ADD >nnnn
↑ ADD >nnnn
< SUB >nnnn
↑ SUB >nnnn
< MUL >nnnn
↑ MUL >nnnn
< DIV >nnnn
↑ DIV >nnnn
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM48
KV-300 Series, KV-10/80
3-49
12
Chapter 2 Instructions
2.2 Instruction List
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
AND A
OR A
EXCLU-SIVEOR A
SHIFTRIGHT A
SHIFTLEFT A
ROTATERIGHT A
ROTATELEFT A
COMPLE-MENT
INCRE-MENT
MEMORY
DECRE-MENT
MEMORY
MULTI-PLEXER
ANDA[FNC 01]
@ANDA@[FNC 01]
ORA[FNC 31]
@ORA@[FNC 31]
EORA[FNC 15]
@EORA@[FNC 15]
SRA[FNC 41]
@SRA@[FNC 41]
SLA[FNC 40]
@SLA@[FNC 40]
RRA[FNC 37]
@RRA@[FNC 37]
RLA[FNC 35]
@RLA@[FNC 35]
COM[FNC 05]
@COM@[FNC 05]
INC[FNC 19]
@INC@[FNC 19]
DEC[FNC 07]
@DEC@[FNC 07]
MPX[FNC 27]
@MPX@[FNC 27]
R No.,DM/TM No.,
#/$ No.,#TMxx
R No.,DM/TM No.,
#/$ No.,#TMxx
# constant
DM/TM No.
# constant
0000 to 2915DM0000 toDM0999
TM00 to TM31#00000 to#65535$0000 to$FFFF
#TM00 to#TM29
0000 to 2915DM0000 toDM0999
TM00 to TM31#00000 to
#65535$0000 to$FFFF
#TM00 to#TM29
#01 to #16
DM0000 toDM0999
TM00 to TM29
#0 to #3
0000 to 6915DM0000 to
DM1999TM00 to TM31
#00000 to#65535
$0000 to$FFFF
#TM00 to#TM29
0000 to 6915DM0000 to
DM1999TM00 to TM31
#00000 to#65535
$0000 to$FFFF
#TM00 to#TM29
DM0000 toDM1999TM00
to TM29
11.0 to 64.0
23.0 to 78.0
11.0 to 63.0
23.0 to 77.0
10.0 to 63.0
22.0 to 77.0
11.0 to 28.0
23.0 to 42.0
10.0 to 28.0
22.0 to 42.0
12.0 to 30.0
24.0 to 44.0
12.0 to 29.0
24.0 to 43.0
5.0 to 6.0
17.0 to 20.0
12.0 to 15.0
24.0 to 29.0
14.0 to 17.0
26.0 to 31.0
24.0 to 25.0
36.0 to 39.0
3 (5)
3 (12)
3 (5)
3 (12)
3 (5)
3 (12)
2 (4)
2 (11)
2 (4)
2 (11)
2 (4)
2 (11)
2 (4)
2 (11)
1 (3)
1 (10)
3 (5)
3 (12)
3 (5)
3 (12)
1 (4)
1 (11)
ANDs each of 16 bitsof internal register andthat of value specifiedby operand, and inputsresult back to sameregister.
ORs each of 16 bits ofinternal register andthat of value specifiedby operand, andinputs result back tosame register.
EXCLUSIVE-ORseach of 16 bits ofinternal register andthat of valuespecified by operand,and inputs resultback to sameregister.
Moves content ofinternal registerserially left by valuespecified by operand.
Moves content ofinternal register seriallyright, allowing each bitthat leaves right end toenter carry bit and thenleftmost bit.
Moves content ofinternal register seriallyleft, allowing each bitthat leaves left end toenter carry bit and thenrightmost bit.
Inverts content ofeach bit in internalregister.
Adds 1 to content ofdata memoryspecified by operand.
Subtracts 1 fromcontent of datamemory specified byoperand.
Converts 4-bit data(specified byoperand) of internalregister into 16bitdata.
Moves content ofinternal registerserially right byvalue specified byoperand.
3-159
3-161
3-164
3-166
3-166
3-169
3-169
3-171
3-172
3-172
<ANDA>nnnn
↑ANDA>nnnn
< ORA >nnnn
↑ ORA >nnnn
<EORA>nnnn
↑EORA>nnnn
< SRA >#dd
↑ SRA >#dd
< SLA >#dd
↑ SLA >#dd
< RRA >#dd
↑ RRA >#dd
< RLA >#dd
↑ RLA >#dd
< COM >
↑ COM >
< INC >nnnn
↑ INC >nnnn
< DEC >nnnn
↑ DEC >nnnn
< MPX >#n
↑ MPX >#n
3-176
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM49
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-50
2
Chapter 2 Instructions
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs)
BytesFunction Page
KV-300
DATAMEMORY
WRITE
TRIMMERSETTING
LOAD A
STORE A
DW
TMIN [FNC 50]
@TMIN@[FNC 50]
LDA[FNC 23]
@LDA@[FNC 23]
STA[FNC 42]
@STA@[FNC 42]
#/$constant,DM No.
TrimmerNo.
R No.,C/T No.,DM/TM
No.,#/$
constant,#TMxx
R No.,C/T No.,DM/TM
No.,#/$
constant,#TMxx
nnnn:#0000 to #65535$0000 to $FFFF
DMmmmm:DM0000 to DM9999
0, 1
0000 to 00090500 to 17915T000 to T249C000 to C249CTH0 to CTH1
DM0000 to DM9999TM00 to TM31
#00000 to #65535$0000 to $FFFF#TM00 to #TM29
0500 to 19152100 to 17915T000 to T249C000 to C249CTC0 to CTC3
DM0000 to DM9999TM00 to TM29
#TM00 to #TM29
0.60 to1.40
5.10 to5.60
2.00 to5.70
0.30 to28.00
2.30 to30.00
0.20 to30.00
2.20 to32.00
5 (11)
1 (11)
1 (25)
3 (12)
3 (26)
3 (12)
3 (26)
Writes constant intodata memory.
Converts trimmerrotation angle into 0 to249 and inputs it intointernal register.
Inputs value specifiedby operand into internalregister or inputscurrent value when T/Cis specified as operand.
Transfers content ofinternal register tolocation specified byoperand, or changespreset value when T/Cis specified as operand.
3-136
3-138
3-140
3-140
< DW >DMmmmm
nnnn
< TMIN >n
↑ TMIN >n
< LDA >nnnn
↑ LDA >nnnn
< STA >nnnn
↑ STA >nnnn
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
DEMULTI-PLEXER
TRANSFERBCD
TRANSFERBIN
ASCIICONVERT
REVERSEASCII
CONVERT
SQUAREROOT
DMX[FNC 12]
@DMX@[FNC 12]
TBCD[FNC 47]
@TBCD@[FNC 47]
TBIN[FNC 48]
@TBIN@[FNC 48]
ASC[FNC 02]
@ASC@[FNC 02]
RASC[FNC 32]
@RASC@[FNC 32]
ROOT[FNC 36]
@ROOT@[FNC 36]
28.0 to 30.0
40.0 to 44.0
19.0 to 21.0
31.0 to 35.0
18.0 to 20.0
30.0 to 34.0
8.0
20.0 to 22.0
12.0 to 14.0
24.0 to 28.0
102.0 to103.0
114.0 to117.0
1 (3)
1 (10)
1 (3)
1 (10)
1 (3)
1 (10)
1 (3)
1 (10)
1 (3)
1 (10)
1 (3)
1 (10)
Converts position ofhighest order bit with1 in internal registerinto 4-bit data.
Converts content ofinternal register (16-bit binary) into 4-digitBCD data.
Converts content ofinternal register (4-digit BCD) into 16-bitbinary data.
Converts content oflower order byte ofinternal register into2-digit ASCII code.
Converts 2-digit ASCIIcode into one bytedata.
Takes square root of 32-bit data (TM00: higherorder byte, internalregister: lower orderbyte) and inputs resultback to same register.
3-176
3-180
3-180
3-183
3-183
3-185
< DMX >
↑ DMX >
<TBCD>
↑ TBCD>
< TBIN >
↑ TBIN>
< ASC >
↑ ASC >
<RASC>
↑ RASC>
<ROOT>
↑ ROOT>
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM50
KV-300 Series, KV-10/80
3-51
12
Chapter 2 Instructions
2.2 Instruction List
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
COMPARE
ADD
SUBTRACT
MULTIPLY
DIVIDE
AND A
OR A
EXCLUSIVEOR A
CMP[FNC 04]
@CMP@[FNC 04]
ADD[FNC 00]
@ADD@[FNC 00]
SUB[FNC 46]
@SUB@[FNC 46]
MUL [FNC 28]
@MUL@[FNC 28]
DIV[FNC 11]
@DIV@[FNC 11]
ANDA[FNC 01]
@ANDA@[FNC 01]
ORA [FNC 31]
@ORA@[FNC 31]
EORA[FNC 15]
@EORA@[FNC 15]
DM/TMNo.,#/$
constant,#TMxx
DM/TMNo.,
#/$ No.,#TMxx
R No.,DM/TM
No.,#/$ No.,#TMxx
R No.,DM/TM
No.,#/$ No.,#TMxx
DM0000 to DM9999TM00 to TM31
#00000 to #65535$0000 to $FFFF#TM00 to #TM29
DM0000 to DM9999TM00 to TM31
#00000 to #65535$0000 to $FFFF#TM00 to #TM29
0000 to 00090500 to 17915
DM0000 to DM9999TM00 to TM31
#00000 to #65535$0000 to $FFFF#TM00 to #TM29
0000 to 00090500 to 17915
DM0000 to DM9999TM00 toTM31
#00000 to #65535$0000 to $FFFF#TM00 to #TM29
9.20 to36.00
11.20 to38.00
7.70 to35.00
9.70 to37.00
8.40 to35.00
10.40 to37.00
9.80 to37.00
11.80 to39.00
13.70 to41.00
15.70 to42.00
6.90 to33.00
8.90 to35.00
6.90 to33.00
8.90 to35.00
6.90 to33.00
8.9 to35.00
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
3 (12)
3 (26)
Compares content ofinternal register andvalue specified byoperand.
Adds content of internalregister and valuespecified by operandand inputs result backto same register.
Subtracts valuespecified by operandfrom content of registerand inputs result backto same register.
Multiplies content ofinternal register byvalue specified byoperand and inputsresult back to sameregister.
Divides content ofinternal register byvalue specified byoperand and inputsresult back to sameregister.ANDs each of 16 bits ofinternal register and thatof value specified byoperand, and inputsresult back to sameregister.ORs each of 16 bits ofinternal register andthat of value specifiedby operand, and inputsresult back to sameregister.
EXCLUSIVE-ORs eachof 16 bits of internalregister and that of valuespecified by operand,and inputs result back tosame register.
3-146
3-150
3-150
3-150
3-150
3-159
3-161
< CMP >nnnn
↑ CMP >nnnn
< ADD >nnnn
↑ ADD >nnnn
< SUB >nnnn
↑ SUB >nnnn
< MUL >nnnn
↑ MUL >nnnn
< DIV >nnnn
↑ DIV >nnnn
<ANDA>nnnn
↑ANDA>nnnn
< ORA >nnnn
↑ ORA >nnnn
<EORA>nnnn
↑EORA>nnnn
3-164
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM51
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-52
2
Chapter 2 Instructions
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
SHIFTRIGHT A
SHIFTLEFT A
ROTATERIGHT A
ROTATELEFT A
COMPLE-MENT
INCREMENTMEMORY
DECREMENTMEMORY
MULTI-PLEXER
DEMULTI-PLEXER
SRA [FNC 41]
@SRA@[FNC 41]
SLA[FNC 40]
@SLA@[FNC 40]
RRA [FNC 37]
@RRA@[FNC 37]
RLA [FNC 35]
@RLA@[FNC 35]
COM [FNC 05]
@COM@[FNC 05]
INC[FNC 19]
@INC@[FNC 19]
DEC[FNC 07]
@DEC@[FNC 07]
MPX [FNC 27]
@MPX@[FNC 27]
DMX [FNC 12]
@DMX@[FNC 12]
# constant
DM/TMNo.
# constant
#01 to #16
DM0000 to DM9999TM00 to TM29
#0 to #3
10.80
12.80
10.80
12.80
12.00
14.00
12.00
14.00
6.10
8.10
7.70
9.70
7.70
9.70
7.30
9.30
6.70
8.70
2 (22)
2 (25)
2 (11)
2 (25)
2 (11)
2 (25)
2 (11)
2 (25)
1 (9)
1 (23)
3 (12)
3 (26)
3 (12)
3 (26)
1 (11)
1 (25)
1 (9)
1 (23)
Moves content ofinternal register seriallyright by value specifiedby operand.
Moves content ofinternal register seriallyleft by value specified byoperand.
Moves content ofinternal register seriallyright, allowing each bitthat leaves right end toenter carry bit and thenleftmost bit.
Moves content ofinternal register seriallyleft, allowing each bitthat leaves left end toenter carry bit and thenrightmost bit.
Inverts content of eachbit in internal register.
Adds 1 to content ofdata memory specifiedby operand.
Subtracts 1 from contentof data memoryspecified by operand.
Converts 4-bit data(specified by operand)of internal register into16- bit data.
Converts position ofhighest order bit with 1in internal register into4-bit data.
3-166
3-166
3-169
3-169
3-171
3-172
3-172
3-176
3-176
< SRA >#dd
↑ SRA >#dd
< SLA >#dd
↑ SLA >#dd
< RRA >#dd
↑ RRA >#dd
< RLA >#dd
↑ RLA >#dd
< COM >
↑ COM >
< INC >nnnn
↑ INC >nnnn
< DEC >nnnn
↑ DEC >nnnn
< MPX >#n
↑ MPX >#n
< DMX >
↑ DMX >
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM52
KV-300 Series, KV-10/80
3-53
12
Chapter 2 Instructions
2.2 Instruction List
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs) Bytes
Function Page
TRANSFERBCD
TRANSFERBIN
ASCIICONVERT
REVERSEASCII
CONVERT
SQUAREROOT
TBCD[FNC 47]
@TBCD@[FNC 47]
TBIN[FNC 48]
@TBIN@[FNC 48]
ASC [FNC 02]
@ASC@[FNC 02]
RASC[FNC 32]
@RASC@[FNC 32]
ROOT[FNC 36]
@ROOT@[FNC 36]
13.20
15.20
14.00
16.00
8.50
10.50
6.80
8.80
77.70
79.70
1 (9)
1 (23)
1 (9)
1 (23)
1 (9)
1 (23)
1 (9)
1 (23)
1 (9)
1 (23)
Converts content ofinternal register (16-bitbinary) into 4-digit BCDdata.
Converts content ofinternal register (4-digitBCD) into 16-bit binarydata.
Converts content oflower order byte ofinternal register into 2-digit ASCII code.
Converts 2-digit ASCIIcode into one byte data.
Takes square root of 32-bit data (TM00: higherorder byte, internalregister: lower orderbyte) and inputs resultback to same register.
3-180
3-180
3-183
3-183
<TBCD>
↑ TBCD>
< TBIN >
↑ TBIN>
< ASC >
↑ ASC >
<RASC>
↑ RASC>
<ROOT>
↑ ROOT>
3-185
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM53
KV-300 Series, KV-10/802.2 Instruction List KV-300 Series,
3-54
2
Chapter 2 Instructions
2.2.4 Interrupt InstructionsKV-10/16/24/40/80
KV-300
Instruction Symbol Mnemonic Operand Operand value Exec.time(µs)
Bytes Function Page
INTERRUPTDISABLED
INTERRUPTENABLED
INTERRUPT
RETURNINTERRUPT
DI[FNC 08]
EI[FNC 13]
INT[FNC 20]
RETI[FNC 34]
R No.
ComparatorNo.
000 to 003
CTC0 to CTC3
3.20
5.80
40.00 to80.00
40.00 to80.00
60 to 100
1 (9)
1 (0)
1 (0)
1 (0)
1 (0)
Disables executionof interrupt.
Enables executionof interrupt.
Executes instructionsbetween INT andRETI at rising edgeof any of input 000 to003 or at falling edgeof 003.
Used with compara-tors CTC0 to CTC3and executesinstructions betweenINT and RETI.
Represents end ofinterrupt.
3-193
3-193
3-192
3-192
3-192
< DI >
< EI >
INTnnn
INTCTCn
RETI
KV-300
KV-10/16/24/40/80
Instruction Symbol Mnemonic Operand Operand valueKV-10/16
Operand valueKV-24/40/80
Exec.time(µs)
BytesFunction Page
INTERRUPTDISABLED
INTERRUPTENABLED
INTERRUPT
RETURNINTERRUPT
DI[FNC 08]
EI[FNC 13]
INT[FNC 20]
RETI[FNC 34]
R No.
ComparatorNo.
000 to 003
CTC0 to CTC3
3.0 to 4.6
3.0 to 4.6
35.0 to 48.0
35.0 to48.8
20.0 to23.0
1 (4)
1 (4)
1 (8)
1 (3)
Disables executionof interrupt.
Enables executionof interrupt.
Executes instruc-tions between INTand RETI at risingedge of any of input000 to 003 or atfalling edge of 003.
Used with compara-tors CTC0 to CTC3and executesinstructions betweenINT and RETI.
Represents end ofinterrupt.
3-193
3-193
3-192
3-192
3-192
< DI >
< EI >
INTnnn
INTCTCn
RETI
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM54
2.3 Convention Details
3-55
12
Chapter 2 Instructions
2.3 Convention DetailsIn this chapter, each instruction is described as follows:
2.4 Instruction Details
3-66
2
Chapter 2 Instructions
Example
Coding
Description
• Output relay 0500 remains ON after input relay 0000 turns OFF. Output relay0500 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.
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 overSET, causing 0500 to remain OFF.
Tips
Differences between SET/RES and KEEP
Basically , SET/RES and KEEP ( p. 3-57 and p. 3-71) serve the same purpose.• SET and RES can be used separately. Therefore, RES can be placed before
SET.Another instruction may be placed between SET and RES.
• KEEP needs only three lines of program, therefore saving memory space whenused a number of times.
Operands
Key operation
SET: Set
RES: Reset
Turns ON specified relay when input is ONand enables this relay to remain ON.
Turns OFF specified relay, timer, or counterwhen input is ON.
SET1
RES0
nnnnRES
nnnnSET
0000
0001
0500SET
0500RES
Line No. Instruction Operand
0000 LD 0000
0001 SET 0500
0002 LD 0001
0003 OUB 0500
0001 00020001
0002 C000RES
#00100
00000C000
#00100
0000C000
0000
0001 0500SET
0500RES
0000
0001RES
KEEP
0500SETLD 0000
RES 0500
LD 0001SET 0500
LD 0000LD 0001KEEP 0500
SET1
RES0Operand ENT
R-SRCH Operand ENTR-SRCH
:
:
SET / RES
NEW KV KV-300 KV-10/16 KV-24/40/80
0500 to 1915 0500 to 1915 0500 to 1915 0500 to 19152009 2009 2009 2009
2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915T000 to T249 T000 to T249 T000 to T063 T000 to T119C000 to C249 C000 to C249 C000 to C063 C000 to C119
CTH0 to CTH1 (RES only)CTC0 to CTC3 (RES only)
InstructionDescribes the nameand brief function ofthe instruction.
Instruction keyRepresents the key orfunction No. for entry.
Ladder symbolRepresents the formof the instruction on aladder diagram.
MnemonicRepresents the instruc-tion in ladder language.
• Example• Timing diagram• DescriptionPerform programmingusing the given exampleto gain experience.
NoteDescribes the notesfor the instruction.
TipsDescribes hands-ontechniques for efficientprogramming.
OperandShows operands (elementNos.) that can be used forthe instruction.
Key operationDescribes the basic keyoperations on the handheldprogrammer. Set the modeswitch to PROGRAM.
CodingShows thecoding forthe givenexample.
* The above page is created for explanation purposes only.This page may be different from the actual page.
KVNKA Chap 02_1&2&3P.p65 08.3.11, 11:53 AM55
2.4 Instruction Details
3-56
2
Chapter 2 Instructions
2.4 Instruction Details
2.4.1 Basic InstructionsThis section describes the basic instructions used for programming. You can createcomplete programs with only these basic instructions.
Instruction Mnemonic Reference page
Load LD 3-57
Load Bar LDB 3-57
And AND 3-58
And Bar ANB 3-58
OR: Or OR 3-60
ORB: Or Bar ORB 3-60
ANL: And Load ANL 3-61
Or Load ORL 3-63
OUT: Out OUT 3-65
OUB: Out Bar OUB 3-65
SET: Set SET 3-66
RES: Reset RES 3-66
TMR: 0.1-s Timer TMR 3-67
TMH: 0.01-s Timer TMH (FUN49) 3-68
TMS: 1-ms Timer TMS (FUN51) 3-69
C: Counter C 3-72
UDC: Up-Down Counter UDC (FUN52) 3-76
DIFU: Differentiate Up DIFU (FUN10) 3-78
DIFD: Differentiate Down DIFD (FUN09) 3-78
KEEP: Keep KEEP (FUN22) 3-80
SFT: Shift SFT (FUN39) 3-82
HSP: High Speed HSP (FUN18) 3-86
MC: Master Control MC (FUN24) 3-89
MCR: Master Control Reset MCR (FUN25) 3-89
MEMSW: Memory Switch MEMSW (FUN26) 3-92
NOP: No Operation NOP 3-94
END: End END 3-94
ENDH: End Hi END 3-94
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM56
2.4 Instruction Details
12
3-57Chapter 2 Instructions
Example
Coding
When input relay 0000 turns ON, output relay 0500 turns ON.When input relay 0001 turns OFF, output relay 0501 turns ON.
Description
• 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
Key operation
Example: LD C014
LD: Load
LDB: Load Bar
Connects N.O. contact to bus.
Connects N.C. contact to bus.
LD7
LDB4
nnnn
nnnn
0000 0500
0001 0501
Line No. Instruction Operand
0000 LD 0000
0001 OUT 0500
0002 LDB 0001
0003 OUT 0501
( )LD7
Operand ENTR-SRCH
ENTR-SRCH
LD7LDB
4
LDB4
CTR(C)
SET1
:
:
LD / LDB
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915T000 to T249 0500 to 17915 T000 to T063 T000 to T119C000 to C249 T000 to T249 C000 to C063 C000 to C119CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3CTC0 to CTC3
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM57
2.4 Instruction Details
3-58
2
Chapter 2 Instructions
AND: And
ANB: And Bar
Connects N.O. contact in series withprevious contact.
Connects N.C. contact in series withprevious contact.
AND8
ANB5
nnnn
nnnn
Example
Coding
To turn ON 0503, 0002 must be ON, 0003 OFF, and 0004 ON at the same time. TheAND 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 contactsare used in the same program.
• As OUT 0503 shown in the above example, when an AND or ANB instruction isused immediately after an OUT instruction to connect the other relay via acontact (0004 in the example), the AND or ANB can be used as many times asdesired, provided the program syntax is correct.
• The following two circuits operate in the same manner, but the coding for thesecircuits are different.
Coding Coding
0000 0500
0002
0001
0004
0003 0501
0502
0503
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 OUT 0500
0003 LD 0002
0004 ANB 0003
0005 OUT 0501
0006 OUT 0502
0007 AND 0004
0008 OUT 0503
0000 0001 0501
0500
Line No. Instruction Operand
0000 LD 0000
0001 OUT 0500
0002 AND 0001
0003 OUT 0501
Line No. Instruction Operand
0000 LD 0000
0001 MPS
0002 AND 0001
0003 OUT 0501
0004 MPP
0005 OUT 0500
0000 0001 0501
0500
:
:
AND / ANB
"MPS instruction" (p. 3-103) "MPP instruction" (p. 3-103)
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM58
2.4 Instruction Details
12
3-59Chapter 2 Instructions
Operand
Key operationExample: AND T012
( )SET1
TMR(T)
AND8 AND
8ANB5
ANL2Operand ENT
R-SRCHENTR-SRCH
AND / ANB
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915T000 to T249 0500 to 17915 T000 to T063 T000 to T119C000 to C249 T000 to T249 C000 to C063 C000 to C119CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM59
2.4 Instruction Details
3-60
2
Chapter 2 Instructions
OR: Or
ORB: Or Bar
Connects N.O. contact in parallel withprevious contact.
Connects N.C. contact in parallel withprevious contact.
Example
Coding
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 forthese instructions with contacts on the previous line. An LD or LDB instruction isused together with the OR and ORB instructions.
• As many contacts as desired can be connected in parallel provided they are usedin the same program.
Note: Output circuits (except for and )cannot be included in the parallel connection.
Operands
Key operationExample: OR T018
OR9
ORB6
nnnn
nnnn
0000 0003 0500
0004
0002
0001
Line No. Instruction Operand
0000 LD 0000
0001 OR 0000
0002 ORB 0002
0003 AND 0003
0004 OR 0004
0005 OUT 0500
( )SET1
TMR(T)
AND8
OR9
OR9
ORB6
Operand ENTR-SRCH
ENTR-SRCH
:
:
OR / ORB
0000 0500
05010001
To turn ON 0500,
0000 must be ON or
0001 ON or
0002 OFF.
0003 must be ON, and
or,
0004 must be ON.
Incorrect
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 6915 0000 to 0009 0000 to 2915 0000 to 6915T000 to T119 0500 to 17915 T000 to T063 T000 to T119C000 to C119 T000 to T249 C000 to C063 C000 to C119CTC0 to CTC3 C000 to C249 CTC0 to CTC3 CTC0 to CTC3
CTC0 to CTC3
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM60
2.4 Instruction Details
12
3-61Chapter 2 Instructions
Example
Coding
Description
The above example shows a serial connection between Block A 0000
0002
and Block B 0001
0003 . The ANL instruction is used to connect two or more blocks in
series.
Operands
Key operation
ANL: And LoadConnects in series blocks made of one ormore contacts.
ANL2
0000 0001 0500
00030002
ANL
Line No. Instruction Operand
0000 LD 0000
0001 OR 0002
0002 LD 0001
0003 OR 0003
0004 ANL
0005 OUT 0500
:
ANL
ANL2
ENTR-SRCH
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM61
2.4 Instruction Details
3-62
2
Chapter 2 Instructions
ANL
0000 0002 0500
0003 00050001
0004
Line No. Instruction Operand
0000 LD 0000
0001 OR 0001
0002 LD 0002
0003 OR 0003
0004 ANL
0005 LD 0004
0006 OR 0005
0007 ANL
0008 OUT 0500
Line No. Instruction Operand
0000 LD 0000
0001 OR 0001
0002 LD 0002
0003 OR 0003
0004 LD 0004
0005 OR 0005
0006 ANL
0007 ANL
0008 OUT 0500
Applications of ANL Instruction
Coding (1) Coding (2)
• The ANL instruction can be used as many times as desired. Note, however, thatin example (2) above, ANL is entered one less time than the number of blocks tobe 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.
Note: "LOGIC ERROR" is displayed on the programmer when ANL is used 9 ormore times in example (2).
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM62
2.4 Instruction Details
12
3-63Chapter 2 Instructions
Example
Coding
Description
The above example shows a parallel connection of Block A 0000 0001
and Block B 0002 0003
. The ORL instruction is used to connect two or more blocks in
parallel.
Operands
Key operation
ORL: Or LoadConnects in parallel blocks made of one ormore contacts.
ORL3
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 LD 0002
0003 AMD 0003
0004 ORL
0005 OUT 0500
0000 0001 0050
00030002 ORL
ORL3
ENTR-SRCH
:
ORL
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM63
2.4 Instruction Details
3-64
2
Chapter 2 Instructions
Applications of ORL Instruction
Coding (1) Coding (2)
• The ORL instruction can be used as many times as desired. Note, however, thatin example (2) above, ORL is entered one less time than the number of blocks tobe 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 timesor more in example (2).
0000 0001 0500
00030002
00050004
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 LD 0002
0003 AND 0003
0004 ORL
0005 LD 0004
0006 AND 0005
0007 ORL
0008 OUT 0500
Line No. Instruction Operand
0000 LD 0000
0001 AND 0001
0002 LD 0002
0003 AND 0003
0004 LD 0004
0005 AND 0005
0006 ORL
0007 ORL
0008 OUT 0500
Block
Block
Block
ORL
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM64
2.4 Instruction Details
12
3-65Chapter 2 Instructions
Example
Coding
Description
• When input relay 0000 turn ON, output relay 0500 turns ON and output relay0501 turns OFF.
• The OUT and OUB instructions are used to drive relay coils for output relays,internal utility relays, and latch relays. These instructions are not used for inputrelays, timers, counters, or data memories.
Note: Double coilWhen one output relay receives input from two or more OUT or OUB instructions,priority is given to the instruction that is entered last.
When 0001 is OFF, 0500 does not turn ON even if 0000 turns ON.
Operands
Key operation
OUT: Out
OUB: Out Bar
Outputs ON/OFF status of input to relay coil.
Outputs inverted ON/OFF status of input torelay coil.
OUTA
OUBB
nnnn
nnnn
0000 0500
0501
Line No. Instruction Operand
0000 LD 0000
0001 OUT 0500
0002 OUB 0501
OUTA Operand ENT
R-SRCHOUB
B Operand ENTR-SRCH
:
:
OUT / OUB
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 1915 0500 to 1915 0500 to 1915 0500 to 19152009 2009 2009 2009
2300 to 17915 2300 to 17915 2300 to 2915 2300 to 6915
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM65
2.4 Instruction Details
3-66
2
Chapter 2 Instructions
Example
Coding
Description
• Output relay 0500 remains ON after input relay 0000 turns OFF. Output relay0500 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.
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 overSET, 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 whenused a number of times.
Operands
Key operation
SET: Set
RES: Reset
Turns ON specified relay when input is ONand enables this relay to remain ON.
Turns OFF specified relay, timer, or counterwhen input is ON.
SET1
RES0
nnnnRES
nnnnSET
0000
0001
0500SET
0500RES
Line No. Instruction Operand
0000 LD 0000
0001 SET 0500
0002 LD 0001
0003 OUB 0500
0001 00020001
0002 C000RES
#00100
00000C000
#00100
0000C000
0000
0001 0500SET
0500RES
0000
0001RES
KEEP
0500SETLD 0000
RES 0500
LD 0001SET 0500
LD 0000LD 0001KEEP 0500
SET1
RES0Operand ENT
R-SRCH Operand ENTR-SRCH
:
:
SET / RES
Visual KV KV-300 KV-10/16 KV-24/40/80
0500 to 1915 0500 to 1915 0500 to 1915 0500 to 19152009 2009 2009 2009
2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915T000 to T249 T000 to T249 T000 to T063 T000 to T119C000 to C249 C000 to C249 C000 to C063 C000 to C119
CTH0 to CTH1 (RES only)CTC0 to CTC3 (RES only)
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM66
2.4 Instruction Details
12
3-67Chapter 2 Instructions
Example
Coding
Timing diagram (TMR000 #00010 and 0500 in the above example)
• 0500 and 0501 turn ON 1 second and 3.5 seconds respectively after 0000 turnsON.
• 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 thecurrent values of TMR000 and TMR001 are reset.
Note 1: The TMR number cannot be the same as any other TMS, TMH, TMR, C, or UDCinstructions in the same program.Note 2: The current value of TMR is not retained but is reset to the preset value if a powerfailure occurs or if power is turned OFF.
Tips
• When the number specified by TMR is used as a contact (T000 in the aboveexample), this contact can be used as many times as desired. It can also beused as both N.O. and N.C. contacts.
• Timer accuracy = 0.1 sec. + (1 scan time) (max.)
Operands
Key operation
TMR: 0.1-s TimerSets a 16-bit on-delay timer that countsdown in 0.1-s decrements.
*1 0.1 s x 10 = 1 s*2 0.1 s x 35 = 3.5 s
TMR(T)
#ddddd
Txxx
0000
T000
T001
0500
0501
#00010
T000
#00035
T001
Preset value: 1 s
Preset value: 3.5 s
Line No. Instruction Operand0000 LD 00000001 TMR 000 #00010*1
0002 TMR 001 #00035*2
0003 LD T0000004 OUT 05000005 LD T0010006 OUT 0501
OFF
ON
ON
#00010
#00000
Output 0500
Scan
Input 0000
Currentvalue of
TMR000
TMR(T)
Operand(TMR No.)
Operand(Preset value)
ENTR-SRCH
:
TMR
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 119Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
KVNKA Chap 02_4aP.p65 08.3.11, 11:57 AM67
2.4 Instruction Details
3-68
2
Chapter 2 Instructions
Example
Coding
Description
• 0500 and 0501 turn ON 0.1-s after 0000 turns ON.• 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, orUDC instructions in the same program.
Note 2: The current value of TMH is not retained but is reset to the preset value ifpower failure occurs or if power is turned OFF.
• When the number specified by TMH is used as a contact (T000 in the aboveexample), this contact can be used as many times as desired. It can also beused as both N.O. and N.C. contacts.
• Timer accuracy = 0.01 sec. + (1 scan time) (max.)
Operand
Key operations
TMH: 0.01-s TimerSets a 16-bit on-delay timer thatcounts down in 0.01-s decrements.
*1 0.01 s x 10 = 0.1 s
LDB4
OR9FUN
#dddddTxxxTH
0000
T000 0500
#00010
T000TH
Line No. Instruction Operand
0000 LD 0000
0001 TMH 000 #00010*1
0002 LD T000
0003 OUT 0500
FUN LDB4
OR9
Operand(Preset value)
Operand(TMH No.)
ENTR-SRCH
ENTR-SRCH
:
TMH
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 119Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM68
2.4 Instruction Details
12
3-69Chapter 2 Instructions
Example
Coding
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
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, orUDC instructions in the same program.
Note 2: The current value of TMS is not retained but is reset to the preset value ifpower failure occurs or if power is turned OFF.
• When the number specified by TMS is used as a contact (T000 in the aboveexample), this contact can be used as many times as desired. It can also beused as both N.O. and N.C. contacts.
• Timer accuracy = 0.001 sec. + (1 scan time) (max.)
Operand
Key operations
TMS: 1-ms Timer Sets a 16-bit on-delay timer thatcounts down in 0.01 ms decrements.
*1 0.001 s x 100 = 0.1 s
SET1
ANB5FUN
#ddddd
TxxxT
S
0000
T000 0500
#00100
T000TS Preset value: 0.1 s
Line No. Instruction Operand
0000 LD 0000
0001 TMS 000 #00010*1
0002 LD T000
0003 OUT 0500
SET1
ANB5FUN ENT
R-SRCHENTR-SRCH
Operand(Preset value)
Operand(TMS No.)
:
TMS
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 119Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM69
2.4 Instruction Details
3-70
2
Chapter 2 Instructions
Applications of TMR instruction One-shot circuit
When input relay 0000 turns ON, output relay 0500 turns ON and remains ON for aspecified time.
Timing diagram
Coding
Off-delay circuit
When input relay 0000 turns ON, output relay 0500 turns ON. 0500 turns OFF in aspecified time after 0000 turns OFF.
Timing diagram
Coding
0000
T0000500 0500
#00020
T000
OFF
ON
ONON
0000
0500
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 TMR 000 #00020
0003 ANB T000
0004 OUT 0500
0000 T000
00000500
0500
#00020
T000
OFF
ON
ON
0000
0500
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 ANB T000
0003 OUT 0500
0004 ANB 0000
0005 TMR 000 #00020
2 sec.
2 sec.
2 sec. 2 sec.
2 sec.
TMR
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM70
2.4 Instruction Details
12
3-71Chapter 2 Instructions
On-delay circuitOutput 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
Coding
Flicker circuit
Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
Timing diagram
Coding
0000
T000 0500
#00020T000
OFF
ON
ON
0000
0500
Line No. Instruction Operand
0000 LD 0000
0001 TMR 000 #00020
0002 LD T000
0003 OUT 0500
0000 T001
T000
0500
#00020T000
#00010T001
2 sec.
2 sec.
1 sec.
OFF
ON
ON ON
0000
0500 ON
Line No. Instruction Operand
0000 LD 0000
0001 ANB T001
0002 TMR 000 #00020
0003 LD T000
0004 AMR 001 #00010
0005 OUT 0500
2 s 1 s
2 s 1 s 2 s 1 s 2 s 1 s
TMR
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM71
2.4 Instruction Details
3-72
2
Chapter 2 Instructions
0001
0000
#00010C000
Example
Coding
Timing diagram (C000#00010 and 0500 in the above example)
Description
• The counter performs one counting at the rising edge of clock pulse. When thecurrent 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 resetto "00000".
• Since C is software counter which is set on the program, the response speeddepends on the scan time.
Note 1: When a reset input is provided using an a (N.O.) contact, the currentcounter value is reset at power-off.
Note 2: The C number cannot be the same as any other TMS, TMH, TMR, C, orUDC instructions in the same program.
Note 3: The current C value is stored more than two months (KV-10xx: More than20 days) at 25°C even when the KV is not in operation or is turned off.
TipsBy entering relay 2007 (which can turn the counter OFF for only the first scan timewhen the operation is started) using an 'a' (N.O.) contact in series as the input relayfor resetting counter, you can reset the current C value whenever the operation isstarted.
C: Counter Sets a 16-bit up-counter.#ddddd
nnnnCxxxCTR
(C)
0001
C000 05000000
#00010C000
Line No. Instruction Operand
0000 LDB 0001
0001 C 000 #00010 0000
0002 LD C000
0003 OUT 0500
ON
#00010 1 2 3 4 5 6 7 8 9 10
C0000500
OFF
ON
:
Reset input Preset value
Counter No.
Count input
0000(Count input)
0001(Reset input)
Current valueof C000
C
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM72
2.4 Instruction Details
12
3-73Chapter 2 Instructions
Details of counter
Extended ladder
• The counter for the KV Series supports the extended ladder method.
• The extended ladder allows you to connect contacts or output coils after thecounter in series, reducing the number of ladder program lines.
In the following example, the counter starts counting when counter input relay 0004turns ON. When the current counter value reaches "300", output relay 0500 turnsON.
Coding
"CON instruction" (p. 3-102)
For details of the extended ladder, refer to "1.5 Extended Ladder Diagrams"(p.3-29).
Operands
Key operation
0002 C002 0500
0004
#00300C002
Line No. Instruction Operand
0000 LDB 0002
0001 C 002 #00300 0004
0002 CON
0003 AND C002
0004 OUT 0500
0001 2007
0000
#00010C005
C
CTR(C)
Operand(Counter No.)
Operand(Preset value)
Operand(Count input)
ENTR-SRCH
KV counter
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 119Count input: Count input: Count input: Count input:
0000 to 17915 0000 to 0009, 0000 to 2915 0000 to 69150500 to 17915
Preset value: Preset value: Preset value: Preset value:#00001 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM73
2.4 Instruction Details
3-74
2
Chapter 2 Instructions
0001
20090000
#09999C002
2002 0500#01000CMP
2009 0501#02000CMP
2009 0502#03000CMP
C002LDA
Applications of C (counter) instruction Long-duration timer
Sets a long-duration timer by combining a timer and a counter.Output 0500 turns ON in 1 hour.
Coding
"1.3.7 Special Utility Relays" (p. 3-12)
Accumulator timer (Remains ON in case of power failure)
Coding
Large capacity counter
Coding
Multi-level setting
Sets a multi-level counter using arithmetic instructions.
Outputs in 3 different levels according to the current counter value.
Current counter value• 1000 or more 0500 turns ON.• 2000 or more 0501 turns ON.• 3000 or more 0502 turns ON. "2.4.3 Arithmetic Instructions" (p. 3-134)
0000
2006
#03600C002
C002 0500
Special utility relay(1-second clock)
Line No. Instruction Operand0000 LDB 00000001 C 002 #03600 20060002 LD C0020003 OUT 0500
0001 C001
2006
#03600C001
0001
1000
#00600C002
C001 1000
Line No. Instruction Operand0000 LDB 00010001 ANB C0010002 C 001 #03600 20060003 LD C0010004 OUT 10000005 LDB 00010006 C 002 #00600 1000
0002 C000
0000
#10000C000
0002
1000
#65535C001
C000 1000
Line No. Instruction Operand0000 LDB 00020001 ANB C0010002 C 001 #10000 00000003 LD C0000004 OUT 10000005 LDB 00020006 C 001 #65535 1000
C
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM74
2.4 Instruction Details
12
3-75Chapter 2 Instructions
Coding
Counter multi-level setting
Outputs in 3 different levels according to the counter current value.
Current counter value• 00000 to 00999 0500 turns ON.• 01000 to 01999 0501 turns ON.• 02000 to 02999 0502 turns ON.
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0002 0010 MRD0001 C 002 #09999 0000 0011 CMP #020000002 LD 2002 0012 CON0003 LDA C002 0013 ANB 20090004 CON 0014 OUT 05010005 MPS 0015 MPP0006 CMP #01000 0016 CMP #030000007 CON 0017 CON0008 ANB 2009 0018 ANB 20090009 OUT 0500 0019 OUT 0502
C
0001
20110000
#09999C000
2002 0500#00999CMP
2011 0501#01999CMP
2011
0500
0500 0501 0502#02999CMP
C000LDA
Line No. Instruction Operand0000 LDB 00010001 C 000 #09999 00000002 LD 20020003 LDA C0000004 CON0005 MPS0006 CMP #009990007 CON0008 ANB 20110009 OUT 05000010 MRD0011 CMP #019990012 CON0013 ANB 20110014 ANB 05000015 OUT 05010016 MPP0017 CMP #029990018 CON0019 ANB 20110020 ANB 05000021 ANB 05010022 OUT 0502
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM75
2.4 Instruction Details
3-76
2
Chapter 2 Instructions
Example
Coding
Timing diagram
• When UP input relay (0001) turns ON, the current value of the counter isincremented by one. When DOWN input relay (0002) turns ON, the current valueis 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, orUDC instructions in the same program.
Note 2: The current UDC value is stored more than two months (KV-10xx: Morethan 20 days) at 25°C even when the KV is not in operation or is turned off.
Operands
Key operation
UDC: Up-Down Counter Sets a 16-bit up-down-counter.UDC xxx
#dddddUPDWRES
ANB5
ANL2FUN
0001
0002
0003
C000 0500
UDC 000
UP #00009
DW
RES
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002
0002 LD 0003
0003 UDC 000 #00009
0004 LD C000
0005 OUT 0500
12 3 4 5 6 7 8 9
OFF
ON
OFF
ON
OFF
ON
OFF
ON
ANB5
ANL2FUN Operand
(Preset value)Operand
(C No.)ENTR-SRCH
ENTR-SRCH
UP input
DOWN input
RESET input
Current value of C000Carry TimeCarry
ON
C000
Input for up 0001
Input for down 0002Input for resetting0003
:
UDC
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 119Preset value: Preset value: Preset value: Preset value:
#00000 to #65535 #00000 to #65535 #00000 to #65535 #00000 to #65535
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM76
2.4 Instruction Details
12
3-77Chapter 2 Instructions
Application of UDC instruction Multi-level UP/DOWN counter
UP/DOWN counter which allows a count setting value up to 99,990,000.
Coding
The example below outputs the high-order 4 digits of 8-digit BCD to UDC001 andthe low-order 4 digits of 8-digit BCD to UDC000.
Low-order 4 digits
0001
0002
0003
UDC 000
UP #09999
DW
RES
C000
C000
0001
0002
0003
UDC 001
UP #09999
DW
RES
00010002
BCD
BCDHigh-order 4 digits
Line No. Instruction Operand
0000 LD 0001
0001 LD 0002
0002 LD 0003
0003 UDC 000 #09999
0004 LD C000
0005 AND 0001
0006 LD C000
0007 AND 0002
0008 LD 0003
0009 UDC 001 #09999
0004 C000LDA TBCD
0500STA
C001LDA TBCD
0600STA
Up-inputDown-input
Low-order4 digits
High-order4 digits
UDC
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM77
2.4 Instruction Details
3-78
2
Chapter 2 Instructions
Example
Coding
Timing diagram (0000, 1000, and 1001 in the above example)
• The DIFU instruction turns ON the relay specified by the operand for only the 1stscan time at the rising edge of input signal (0000).
• The DIFD instruction turns ON the relay specified by the operand for only the 1stscan time at the falling edge of input signal (0000).
Note 1: Any DIFU/DIFD operand relay No. cannot be duplicated in a program.
Note 2: When an expanded ladder is used, the DIFU instruction in example a)operates without any problems. However, with the DIFD instruction in example b),output relay 0500 does not turn ON because 1000 turns ON at the next scan afterthe falling edge of input relay 0000 though input relay 0000 is already OFF. In thiscase, change the ladder diagram as in example c).
Operands
* Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or I/Oterminal module ports can be used for internal utility relays.
Key operation
DIFU: Differentiate Up
DIFD: Differentiate Down:
Detects rising edge of input signal and turnsON specified relay for 1st scan time only.
Detects falling edge of input signal and turnsON specified relay for 1st scan time only.
nnnn
DIFD
nnnn
DIFUSET
1RES
0
RES0
FUN
FUN OR9
0000
1000DIFU
1001DIFD
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1000
0002 DIFD 1001
ON
ON
0000
1000
1001
OFF
ON
0000 1000
1000DIFU
0500 0000 1000
1000DIFD
1000DIFD
0500
0000
1000 0500
a) 0500 turns ON for one scan at the rising edgeof input relay 0000.
c) 0500 turns ON for one scan at thefalling edge of input relay 0000.
b) 0500 does not turn ON for one scan atthe falling edge of input relay 0000.
SET1
RES0
RES0FUNFUN OR
9Operand(Relay No.)
Operand(Relay No.)
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
:
:
ON for 1st scan time only
ON for 1st scan time only
DIFU / DIFD
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 19153000 to 9915 3000 to 6915 3000 to 6915
*7000 to 9915
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM78
2.4 Instruction Details
12
3-79Chapter 2 Instructions
Application of DIFU, DIFD instructions One-shot circuit using the differentiate instruction
When input relay 0000 turns ON/OFF, output relay 0500 and 0501 turns ON one-shot (1 second).
Coding
Timing diagram
Alternating circuit
Every time input relay 0000 turns ON, output relay 0500 turns ON and OFF alter-nately.
Coding
0000
1000 T001
0500
1001 T002
0501
0500
1000DIFU
1001DIFD
#00010T001
0501
#00010T002
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 DIFD 10010003 LD 10000004 OR 05000005 ANB T0010006 OUT 05000007 TMR 001 #000100008 LD 10010009 OR 05010010 ANB T0020011 OUT 05010012 TMR 002 #00010
ON
ON
0000
1000
1001
0500
0501
OFFON
OFFON
OFFON
0000
1000DIFU
1000
1000
0500
0500 0500
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 LD 10000003 ANB 05000004 LDB 10000005 AND 05000006 ORL0007 OUT 0500
1 s
1 s
DIFU / DIFD
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM79
2.4 Instruction Details
3-80
2
Chapter 2 Instructions
ANL2
ANL2FUN Operand
(Relay No.)ENTR-SRCH
ENTR-SRCH
Example
Coding
Description
• When SET input relay No. 0001 is ON and RESET input relay No. 0002 is OFF,0500 turns ON.
• When RES input (0002) is ON, output relay 0500 turns OFF.• When both 0001 and 0002 are OFF, the previous status is retained.
Note 1: When 0500 used for KEEP instruction in the above example is changed toOUT instruction ( ), it forms a double coil. In such a case, priority is given to theinstruction 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.
TipsInternal utility relay latching function
The ON/OFF status of an internal utility relay immediately before power-off can bestored 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 relaysettings can be stored while the power is off.
Coding
Operands
Key operation
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 DIFD 1001
KEEP: Keep
Turns ON specified relay when SET inputrelay turns ON and enables this relay toremain ON. And, turns OFF specified relaywhen RESET input relay turns ON.
OR9
ORL3FUN
KEEP
SETRES
nnnn
0001
0002
KEEP
SET 0500
RESRES RESET input
SET input
0001
0002
1000
KEEP
MEMSW
SET 1000
$0004
RESRES
0500
Stores the status ofinternal utility relays1000 through 1915.
Line No. Instruction Operand0000 MEMSW $00040001 LD 00010002 LD 00020003 KEEP 10000004 LD 10000005 OUT 0500
:
KEEP
0500
Visual KV KV-300 KV-10/16 KV-24/40/80
0500 to 1915 0500 to 1915 0500 to 1915 0500 to 19152009 2009 2009 2009
2100 to 17915 2100 to 17915 2100 to 2915 2100 to 6915
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM80
2.4 Instruction Details
12
3-81Chapter 2 Instructions
Application of KEEP instruction Detection of chewing gum packs
Detects chewing gum packs over the carton using the proximity switch ES series(0001 to 0003). If the switch detects that one or more packs of chewing gum aremissing, output relay 0500 turns ON for 1 s.The timing clock is generated from the visible beam photoelectric switch PZ2 (0000).
• Executes SET when all input relays 0000 to 0003 are ON.• Detects presence/absence of chewing gum packs at DOWN edge of 0000.• Outputs 1-s one-shot pulse from output relay 0500 when 1000 is OFF.
Coding
Timing diagram
Reflector R-2
ES
PZ2-61
ESON
GumGumGum
GumGum
GumGumGum
OFF ON
0000
1001
0000 1001DIFD
#00010T001
1001 1000 T001
0500
0001 0002 0003KEEP
SET 1000
RESRES
0500
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0007 DIFD 10010001 AND 0001 0008 LD 10010002 AND 0002 0009 ANB 10000003 AND 0003 0010 OR 05000004 LD 1001 0011 ANB T0010005 KEEP 1000 0012 OUT 05000006 LD 0000 0013 TMR 001 #00010
0000
0001
0002
0003
0500
OFF
ON
OFF
ON
OFF
ON
OFF
ON
OFF
ONON ON
Executes SET when all input relays0000 to 0003 are ON.
Detects presence/absence of chewinggum packs all Down edge of 0000.
Outputs 1-s one-shot plus from outputrelay 0500 when 1000 is OFF.
1 s
KEEP
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM81
2.4 Instruction Details
3-82
2
Chapter 2 Instructions
SFT: Shift Sets a shift register.
Example
Coding
Timing diagram
Description
• First relay No. 1000 turns ON (OFF) when the data input relay is ON (OFF) at therising edge of the clock pulse.
• Clock pulse A) shifts the ON status of input relay 0001 to relay 1000, and shiftsthe 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 relay1000.
• When the RESET input relay turns ON, all the relays (from the first one to the lastone) turn OFF.
• Several SFT instructions can be used in a program.
Note: No SFT operand relay No. can be duplicated in a program.
SFTnnnn
mmmm
DCLKRES
OR9
ORL3FUN
0001
0002
0003
1002 0500
SFT
D 1000
CLK 1002
RES
Line No. Instruction Operand0000 LD 00010001 LD 00020002 LD 00030003 SFT 1000 10020004 LD 10020005 OUT 0500
0500
1002
1001
1000
0002 OFF
ON
0001
0003
OFF
ON
OFF
ON
ON
ON ON
ON ON
1002 1001 1000 0001
0 OFF1 ON
0 0 1 1 A)
ON ON
ON ON
1002 1001 1000 0001
0 1 1 1 B)
1002 1001 1000 0001
1 1 1 1 C)
1002 1001 1000 0001
1 1 1 1 D)
1002 1001 1000 0001
1 1 0 0 E)
1002 1001 1000 0001
1 0 0 1 F)
1002 1001 1000 0001
0 0 1 1 G)
A B C D E F G
RESET input
Data input
First relay No.
Clock
Last relay No.
RESET input
Data input
Clock
:
SFT
Relay shiftoperation
Lost
Lost
Lost
Lost
Lost
Lost
Lost
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM82
2.4 Instruction Details
12
3-83Chapter 2 Instructions
Operands
* Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or remote I/Ounit ports can be used for internal utility relays.
Key operation
Applications of SFT instruction Alternating circuitEvery time input relay No. 0000 turns ON, 0500 turns alternately ON and OFF.
Coding
Timing diagram
Reference: Alternating circuit can be configured without SFT instruction.The following circuit does the same operation as the circuit above. "DIFU instruction" (p. 3-78)
Coding
1000
0000
2003
1000 0500
SFT
D 1000
CLK 1000
RES
Line No. Instruction Operand0000 LDB 10000001 LD 00000002 LD 20030003 SFT 1000 10000004 LD 10000005 OUT 0500
ONOFF
ON ON ON ON ON
0000
0500
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 LD 10000003 ANB 05000004 LDB 10000005 AND 05000006 ORL0007 OUT 0500
SFT
FUN OR9
ORL3
Operand(Relay No.)
Operand(Relay No.)
ENTR-SRCH
ENTR-SRCH
0000
1000DIFU
1000
1000
0500
0500 0500
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 19153000 to 6915 3000 to 6915 3000 to 6915
*7000 to 9915
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM83
2.4 Instruction Details
3-84
2
Chapter 2 Instructions
Line No. Instruction Operand0000 LD 2008
0001 SET 1000
0002 LDB T001
0003 T001 #00010
0004 LD 2003
0005 LD T001
0006 LD 2003
0007 SFT 1000 1005
0008 LD 1000
0009 OUT 0500
0010 LD 1001
0011 OUT 0501
0012 LD 1002
0013 OUT 0502
0014 LD 1003
0015 OUT 0503
0016 LD 1004
0017 OUT 0503
0018 LD 1005
0019 SET 1000
Resetting internal utility relaysWhen input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915turn OFF.
SFT instruction can be substituted for RES instruction. This application can be usedto reset many relays at one time.(All relays 3000 through 9915 can also be turned OFF at one time.)
Coding
Repeat shift circuitTurns ON every output for a second sequentially. Sets 1000 to 2008 (ON for 1stscan only at startup) and shifts outputs from 0500 to 0504 every second at T001.When 1005 turns ON, 1000 is set and the same sequence as above repeats.
Coding
2003
2003
0000
SFT
D 1000
CLK 1915
RES
Line No. Instruction Operand0000 LD 20030001 LD 20030002 LD 00000003 SFT 1000 1915
2003
T001
2008
T001
2003
SFT
D 1000
CLK 1005
RES
1000
1001
1002
1003
1004
1005
#00010T001
1000SET
0500
0501
0502
0503
0504
1000SET
SFT
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM84
2.4 Instruction Details
12
3-85Chapter 2 Instructions
Asynchronous shift registerTurns ON input relay 0002 to reset the shift register (1000 to 1010) when the datainput to 0000 does not synchronize with the clock input to 0001.
Coding
Timing diagram
2003
0001
0002
SFT
D 1000
CLK 1010
RES
1100
0000 1100DIFU
1000SET
Line No. Instruction Operand0000 LD 00000001 DIFU 11000002 LD 11000003 SET 10000004 LD 20030005 LD 00010006 LD 00020007 SFT 1000 1010
ONOFF
ONOFF
ONOFF
ONOFF
ONOFF
1001
0000
0001
1002
1000
Scan
SFT
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM85
2.4 Instruction Details
3-86
2
Chapter 2 Instructions
HSP: High Speed Shortens time constant of specified inputrelay to 10 µs to increase input response.
SET1
AND8FUN
HSPnnnn
0000 HSP0001
0001 0500SET
0002 0501SET
0003 0500RES
0501RES
Example
Coding
Timing diagram
Description
• When enable input 0000 turns ON, the time constant of input 0001 (specified byHSP) changes from 10 ms to 10 µs.
• When enable input relay 0000 is ON and the scan time is 1 ms, and when theON time ( ) of input relays 0001 and 0002 is 5 ms, output relay 0500 turns ONbut 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 2612with 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.
Enable input
Line No. Instruction Operand
0000 LD 0000
0001 HSP 0001
0002 LD 0001
0003 SET 0500
0004 LD 0002
0005 SET 0501
0006 LD 0003
0007 RES 0500
0008 RES 0501
ON ON ON
ON
0000
0002
0001
0003
0500
0501
ON ON
ONON
ON ON
ON
OFFON
5 ms 5 ms 15 ms
:
HSP
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM86
2.4 Instruction Details
12
3-87Chapter 2 Instructions
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 sametime, 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 contactbounce from being entered.
Details of HSP Instruction
This section describes the operation of the HSP instruction.
Input signal width
Even if the input signal width is shorter than the scan time, the signal can be fetchedwhen it turns ON during input process as in 1). However, it cannot be fetched whenit 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 scantime as in 3).
Scan time < Input signal width < Normal time constant (10 ms ± 20%)
Switching the input time constant of expansion units
Expansion input unit Expansion I/O unitKV-E4X KV-E4XT(P)KV-E8X KV-E4XRKV-E16X
The input time constant of an expansion unit is initially set to 10 ms.It can be changed to 10 µs by creating a ladder program or by using the AccessWindow, the LADDER BUILDER for KV programming support software, or with theKV-P3E(01) handheld programmer.
Change the values of special utility relays 2609 to 2612.
Operands
Key operation
HSP
OFF
ON1) 2) 3)
Scan time
Out
put d
evic
e
Programexecution
Programexecution
Programexecution
Scan time Scan time
Inpu
tdev
ice
Out
put d
evic
e
Out
put d
evic
e
Inpu
tdev
ice
Inpu
tdev
ice
Special utility relay Description2609 Input time constant of 1st unit. OFF: 10 ms, ON: 10 µs
2610 Input time constant of 2nd unit. OFF: 10 ms, ON: 10 µs
2611 Input time constant of 3rd unit. OFF: 10 ms, ON: 10 µs
2612 Input time constant of 4th unit. OFF: 10 ms, ON: 10 µs
FUN SET1
AND8
Operand(Relay No.)
ENTR-SRCH
ENTR-SRCH
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
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM87
2.4 Instruction Details
3-88
2
Chapter 2 Instructions
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0007 END0001 EI 0008 INT 00000002 SET 2813 0009 LD 20020003 LD 0500 0010 SET 05000004 T000 #00010 0011 RET10005 LD T000 0012 ENDH0006 RES 0500
Applications of HSP Instruction High-speed fetching of input data
When the input signal at 0000 has pulses of 5-ms interval and 2-ms scan time andinput relay 0001 is ON, fetches data from input relay 0000 at high speed and outputs1-s one-shot pulse from output relay 0500.
Coding
Timing diagram
* 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).
When using the interrupt instruction
Coding
0001 HSP0000
0000
0500 T000 0500
#00010T000
Line No. Instruction Operand0000 LD 00010001 HSP 00000002 LD 00000003 OR 05000004 TMR 000 #000100005 ANB T0000006 OUT 0500
ONOFF
ONOFF
0500
0000
0001
ON
2813SET
EI
#00010T000
2008
0500
T000
END
RETI
ENDH
INT
0500RES
2002 0500SET
0000
Turn ON for 1st scan only at startup.
Input time constant 10 µs
Turns ONtimer for 1swhen 0500is ON.
Resets 0500 when T000 turns ON.
Sets 0500 when 0000 turns ON.
Interrupt enabledInitial settings
Sets interrupt input at 0000.
1-s timer
Scan
1 s
Turn ON for 1stscan only at startup.
HSP
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM88
2.4 Instruction Details
12
3-89Chapter 2 Instructions
MC: Master ControlMCR: Master Control
Reset
Selects ON/OFF status of relay coils, timers,or counters set before MCR instruction.
Used in pairs with MC instruction to end theexecution of MC instruction.
LDB4
ANB5
ANL2
ANL2
MCR
MC FUN
FUN
0000 MC
MCR
0001 0500
0501
Example
Coding
Description
• When 0000 is OFF, both 0500 and 0501 do not turn ON, even if 0001 is turnedON.
• When 0000 is ON, 0500 turns ON and 0501 turns OFF as soon as 0001 is turnedON.
• 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:
Note: MC-MCR instructions cannot be used in the following configuration.1. Nesting 2. Improper combination with STP-STE
instructions
"STP, STE instructions" (p. 3-114)
Operands
Key operation
Line No. Instruction Operand0000 LD 00000001 MC0002 LD 00010003 OUT 05000004 OUB 05010005 MCR
MC
MC
MCR
MCR
STPx x x x
MC
STE
MCR
FUN FUNLDB4
ANB5
ANL2
ANL2
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
:
:
MC / MCR
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.
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM89
2.4 Instruction Details
3-90
2
Chapter 2 Instructions
Details of MC-MCR Instructions
Position of MC-MCR instructions
MC-MCR instructions can be used in the following positions.
Making an input condition
The input condition for an MC instruction can be made as shown below:
Note: The scan time is not shortened even if the input relay of the MC instruction isOFF.
Output relays 0500 within and outside of the MC-MCR instructions form a doublecoil as shown below. "Double coil" (p. 3-65)
In this case, priority is given to the instruction that is entered last.
1. MC-MCR instructions canbe placed before or afterSTP-STE instructions.
This relay is ignored.
MC
STPx x x x
STE
MCR
STPx x x x
MC
MCR
STE
STPx x x x
STE
MC
MCR
2. MC-MCR instructions canbe placed between STPand STE instructions.
3. STP-STE instructions canbe placed between MCand MCR instructions.
0000 0001 0002 MC
MCR
0003 0500
MC
0003
0001
0500
MCR
0002 0500The last relay has priority.
MC / MCR
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM90
2.4 Instruction Details
12
3-91Chapter 2 Instructions
Application of MC-MCR Instruction Emergency stop circuit
When input relay 0000 is ON, 0500 turns ON for 1 s, then 0501 turns ON for 2 s,and then 0502 turns ON for 3 s, repeatedly.Once input relay 0000 turns OFF, 0500 turns ON when 0001 is ON, 0501 turns ONwhen 0002 is ON, and 0502 turns ON when 0003 is ON.
Timing diagram
CodingON ON
ON
ON
ON
ONON
ON ON
0003
0501
0001
0502
0000
Scan
0500
0002
ONOFFONOFFONOFFONOFF
1102RES
1101RES
1100RES
00000001
0020
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
MC
MCR
MCR
END
ENDH
10011000
0001 1203
1200
1203
0500
1201
1204
0501
1202
1205
0502
0002 1204
0003 1205
1200
0000
T000
1000
MC1001
1002DIFU1002
T000#00010
STG1100
JMP1101
1201 T001T001
#00020STG1101
JMP1102
1202 T002T002
#00030STG1102
JMP1100
MC / MCR
Line No. Instruction Operand0000 LD 00000001 OUT 10000002 CON0003 OUB 10010004 LD 00000005 DIFU 10020006 CON0007 AND 10020008 RES 11000009 CON0010 RES 11010011 CON0012 RES 11020013 LD 10000014 MC0015 STG 11000016 OUT 12000017 CON0018 TMR 000 #000100019 CON0020 AND T0000021 JMP 11010022 STG 11010023 OUT 12010024 CON0025 TMR 001 #000200026 CON0027 AND T0010028 JMP 11020029 STG 11020030 OUT 12020031 CON0032 TMR 002 #000300033 CON0034 AND T0020035 JMP 11000036 MCR0037 LD 10010038 MC0039 LD 00010040 OUT 12030041 LD 00020042 OUT 12040043 LD 00030044 OUT 12050045 MCR0046 LD 12000047 OR 12030048 OUT 05000049 LD 12010050 OR 12040051 OUT 05010052 LD 12020053 OR 12040054 OUT 05020055 END0056 ENDH
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM91
2.4 Instruction Details
3-92
2
Chapter 2 Instructions
FUN ANL2
ORB6 OperandENT
R-SRCHENTR-SRCH
Key operation
Operands
$0000 to $FFFF
Example
Coding
• 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-tion of the switch is specified by turning a certain bit ON or OFF.
MEMSW:Memory Switch
Sets memory switches.FUNMEMSW
$nnnnANL2
ORB6
0 0 1 1
3 2 1 0
1 0 0 0
3 2 1 0
0 0 0 0
3 2 1 0
0 0 0 0
3 2 1 0
SW4 SW3 SW2 SW1 MEMSW$3800
SW1SW2SW3SW4
Cancels error andstarts operation.
Loads memoryfrom EEPROM
Does not loadmemory fromEEPROM
Uses latchfunction.
Doesn't uselatch function.
Uses latchfunction.Uses latchfunction.
Uses latchfunction.
Uses latchfunction.
Doesn't uselatch function.
Doesn't uselatch function.
Doesn't uselatch function.
Doesn't uselatch function.
—
Clears DM.
—
24-bit 16-bit
Retains DM.
:
MEMSW
MEMSW$3800
Line No. Instruction Operand
0000 MEMSW $3800
Write-protectsprogram.
Doesn't write-protect program.
Clears values. Retains values.
24-bit 16-bit
Read-protectsprogram.
Doesn't read-protect program.
SwitchNo. OFFFunction of switch ON
Retains error.0 Cancels error when power is ON.
1 Action when "Memory error" occurs atstartup (due to data memory, countervalue, or retained content being erased).
2 Uses latch function of internal utility relays1000 through 1915.
3 Uses latch function of internal utility relays3000 through 3915.
0 Uses latch function of internal utility relays4000 through 4915.
1 Uses latch function of internal utility relays5000 through 5915.
2 Uses latch function of internal utility relays6000 through 6915.
3 Not used.
0 Not used.
1 Clears DM0000 to DM0999 at power-on.
2 Clears DM1000 to DM1899 at power-on.
3 Switches between 24- and 16-bit compara-tors for CTH0.
0 Switches between 24- and 16-bit compara-tors for CTH1.
1 Clears values of counter, CTH, and CTC.
2 Write-protects program in KV PLC.
3 Read-protects program in KV PLC.
— —
Clears DM. Retains DM.
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM92
2.4 Instruction Details
12
3-93Chapter 2 Instructions
(8)
23
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
(4)
22
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
(2)
21
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
(1)
20
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0 0 0 0
3 2 1 0
0
0 0 1 0
3 2 1 0
2
0 1 1 0
3 2 1 0
6
1 0 0 1
3 2 1 0
9
SW4 SW3 SW2 SW1
MEMSW$0269
Retains all errors when power is ON.Retains utility relays 3000 through 3999.
(Switch No.)
(Example)
Hexadecimalnumber
Clears DM0000 to DM0999when power is ON.
Retains Internal utility relay5000 through 5999 and 6000through 6999.
MEMSW
Note 1: When a read-protected program is transferred into the KV PLC it cannotbe read or modified from this PLC. Before read-protecting a program, be sure tocreate a backup copy of the program.
Note 2: When a 24-bit high-speed counter comparator is used, the ladder programwhich specifies the numerical values of a 24-bit CTC is required before starting thehigh-speed counter.
Note 3: The value of MEMSW can be changed even during operation. However,the new operation is not actually performed. The change is effective only after theKV is turned off or stopped once and then restarted.
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 executingthe transfer regardless of the message, press .
Description
Hexadeci-mal number
To use internal utilityrelays 1000 through1915 as latch relays.
To clear a counter whenoperation is started.
To use a 24-bit high-speed counter CTH1.
To clear a DM whenoperation is started.
To read-protect aprogram.
To use a 24-bit high-speed counter CTH0.
MEMSW$0004
MEMSW$0E00
MEMSW$8000
MEMSW$2000
MEMSW$0800
MEMSW$1000
ENTR-SRCH
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM93
2.4 Instruction Details
3-94
2
Chapter 2 Instructions
NOP: No Operation Performs no operation.
END: End
ENDH: End Hi
Indicates end of each routine of program.
Indicates end of entire program.
Normal program
RES0
ORL3FUN
ENDDM
ENDHTM
END
ENDH
END
ENDH
ENDH
END
Subroutine programInterrupt program
Normal program
ENDDM
ENDHTM
ENTR-SRCH
ENTR-SRCH
:
:
:
NOP END / ENDH
When ALL CLEAR [FNC60] or HANDHELD PROGRAMMER CLEAR (P3E CLEAR)[FNC61] is executed to delete the program, NOP appears on all lines of the deletedprogram.NOP is not written by the KV IncrediWare (DOS)/LADDER BUILDER for KV pro-gramming support software.
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.
Note: When a program does not have END or ENDH, "ENTER END", "ENTERENDH" or "LOGIC ERROR" occurs when the program is converted or transferred.
Operands
Key operation
KVNKA Chap 02_4aP.p65 08.3.11, 11:58 AM94
2.4 Instruction Details
12
3-95Chapter 2 Instructions
Instruction Mnemonic Reference page
W-ON: Wait ON W-ON 3-96
W-OFF: Wait OFF W-OFF 3-96
W-UE: Wait Up Edge W-UE 3-98
W-DE: Wait Down Edge W-DE 3-98
CON: Connect CON (FUN06) 3-102
MPS: Push MPS 3-103
MRD: Read MRD 3-103
MPP: Pop MPP 3-103
STG: Stage STG (FUN44) 3-106
JMP: Jump JMP (FUN21) 3-106
ENDS: End Stage END (FUN14) 3-106
STP: Step STP (FUN45) 3-114
STE: Step End STE (FUN43) 3-114
ITVL: Interval Timer ITVL 3-117
16-bit high-speed counter CTH 3-204
16-bit high-speed counter comparator CTC 3-204
16-bit high-speed counter CTH 3-204
16-bit high-speed counter comparator CTC 3-204
CALL: Subroutine Call CALL (FUN03) 3-122
SBN: Subroutine Entry SBN (FUN38) 3-122
RET: Subroutine Return RET (FUN33) 3-122
FOR: Repeat Start FOR (FUN16) 3-125
NEXT: Repeat End NEXT (FUN29) 3-125
HKEY: 16 Key input HKEY (FUN17) 3-131
2.4.2 Application InstructionsApplication instructions are used for batch processing of input signals. Data istransmitted to specified memory locations or changed into different formats. More-over, parts of a program can be repeated or skipped with the instruction.
KVNKA Chap 02_4bP.p65 08.3.11, 11:59 AM95
2.4 Instruction Details
3-96
2
Chapter 2 Instructions
Example
Coding
Timing chart
• W-ON
When input relay 0000 is ON, output relay 0500 turns ON as soon as input operand0001 turns ON. 0500 remains ON until 0000 turns OFF.
• W-OFF
When input relay 0002 is ON, output relay 0501 turns ON as soon as input operand0003 turns OFF. 0501 remains ON until 0002 turns OFF.
W-ON: Wait ONW-OFF: Wait OFF
Turn ON second operand relay when firstoperand relay contact turns ON.
Turns ON second operand relay when firstoperand relay contact turns OFF.
Line No. Instruction Operand
0000 LD 0000
0001 W-ON 0001 1000
0002 LD 1000
0003 OUT 0500
0004 LD 0002
0005 W-OFF 0003 1001
0006 LD 1001
0007 OUT 0501
nnnnOFF
mmmm
nnnnON
mmmm
W-ONF
W-OFFL i
0000
1000 0500
0001ON
1000
0002
1001 0501
0003OFF
1001
W-ON
W-OFF
ON
0000
0001
10000500
OFF
ON
OFF
ON
ON
ON
0002
0003
10010501
OFF
ON
OFF
ON
ON
:
:
W-ON / W-OFF
KVNKA Chap 02_4bP.p65 08.3.11, 11:59 AM96
2.4 Instruction Details
12
3-97Chapter 2 Instructions
Description
W-ON
• When input relay 0000 is ON, output operand 1000 turns ON as soon as thecontact of input operand 0001 turns ON.
W-OFF
• When input relay 0002 is ON, output operand 1001 turns ON as soon as thecontact of input operand 0003 turns OFF.
Note: Output operand relay Nos. for W-ON/W-OFF instructions cannot be dupli-cated in a program.
Operands
* Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion orremote I/O unit ports can be used for internal utility relays.
Key operation
0002 0003
1001
00020003OFF
1001
1001
0000 0001
1000
00000001ON
1000
1000
Sameoperation
Input operand
Output operand
W-ONF
W-OFFL i
First operand(nnnn)
Second operand(mmmm)
ENTR-SRCH
Sameoperation
Input operand
Output operand
W-ON / W-OFF
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 6915T000 to T249 0500 to 17915 T000 to T063 T000 to T119C000 to C249 T000 to T249 C000 to C063 C000 to C119CTC0 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 19153000 to 9915 1000 to 1915 3000 to 6915
3000 to 6915*7000 to 9915
KVNKA Chap 02_4bP.p65 08.3.11, 11:59 AM97
2.4 Instruction Details
3-98
2
Chapter 2 Instructions
Example
Coding
Timing chart W-UE
• When input relay 0000 is ON, output relay 0500 turns ON at rising edge of firstoperand relay 0001.
• As soon as input relay 0000 turns OFF, output relay 0500 turns OFF.
W-DE
• When input relay 0002 is ON, output relay 0501 turns ON at falling edge of firstoperand relay 0003.
• As soon as input relay 0002 turns OFF, output relay 0501 turns OFF.
W-UE: Wait Up EdgeW-DE: Wait Down Edge
Turns ON second operand relay at risingedge of first operand relay contact.
Turns ON second operand relay at fallingedge of first operand relay contact.
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 LD 1000
0003 OUT 0500
0004 LD 0002
0005 W-DE 0003 1001
0006 LD 1001
0007 OUT 0501
nnnn
mmmm
nnnn
mmmm
W-UEE
W-DEL o
0000
1000 0500
0001
1000
0002
1001 0501
0003
1001
W-UE
W-DE
ON
0000
0001
10000500
OFF
ON
OFF
ON
ON
0002
0003
10010501
OFF
ON
OFFON
:
:
W-UE / W-DE
KVNKA Chap 02_4bP.p65 08.3.11, 11:59 AM98
2.4 Instruction Details
12
3-99Chapter 2 Instructions
Description
W-UE
• When input relay 0000 is ON, the output operand turns ON at the rising edge ofthe input operand.
W-DE
• When input relay 0002 is ON, the output operand turns ON at the falling edge ofthe input operand.
Note 1: If the input operand is already ON before input relay 0000 turns ON, theoutput operand does not turn ON.
Note 2: The W-UE/W-DE instruction must be used in subroutine programs that areexecuted every scan time (because rising and falling edges cannot be recognized).
Note 3: Output operand relay Nos. for W-UE/W-DE instructions cannot be dupli-cated in a program.
Operands
* Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion orremote I/O unit ports can be used for internal utility relays.
Key operation
0000 1002
0001
1000
00000001
1000
1000
1002DIFUSame
operation
Input operand
Output operand
0002 1003
1001
00020003
1001
1001
0003 1003DIFDSame
operation
Input operand
Output operand
W-UEE
W-DEL o
First operand(nnnn)
Second operand(mmmm)
ENTR-SRCH
W-UE / W-DE
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 T119T000 to T249 00500 to 17915 0000 to 2915 C000 to C119C000 to C249 T000 to T249 T000 to T063 CTC0 to CTC3CTC0 to CTC3 C000 to C249 CTC0 to CTC3 mmmm:
mmmm: CTC0 to CTC3 mmmm: 1000 to 19151000 to 1915 mmmm: 1000 to 1915 3000 to 69153000 to 9915 1000 to 1915
3000 to 6915*7000 to 9915
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM99
2.4 Instruction Details
3-100
2
Chapter 2 Instructions
Details of W-ON and W-UE InstructionsA combination of W-ON, W-OFF, W-UE, and W-DE instructions is much moreeffective when used in programs controlling sequential operation where the comple-tion of one operational step starts the next step.This section describes minute differences in the operation of these instructions.
Difference between W-ON and W-UE
W-ON: Output relay 0500 turns ON when both input relays 0000 and 0001 turnON in any order.
W-UE: Output relay 0501 turns ON only when input relay 0000 turns ON beforeinput relay 0001.
Note: An input operand relay No. for these instructions can be duplicated in aprogram, but output operand relay Nos. cannot be duplicated.
As shown above, W-UE requires a certain order for turning ON relays 0000 and0001, but W-ON does not. Therefore, W-UE is suitable for circuits to be executed atevery input; W-ON is suitable for circuits that go on to the next operation when acertain condition is satisfied.
The operation of W-OFF and W-DE instructions are same as above by the operationwhich turns relays OFF.
Output relay 0100 turns ON when both input relays0000 and 0001 turn ON in any order.
Output relay 1001 turns ON only when input relay0000 turns ON before input relay 0001.
0000
0100 0500
0001ON
10000001
1001
1001 0501
ON
0000
0001
(W-ON)
(W-UE)
10000500
10010501
OFF
ON
OFF
ON
ON
ON
W-UE / W-DE
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM100
2.4 Instruction Details
12
3-101Chapter 2 Instructions
Application of W-UE Instruction Input sequence check
Output relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and0003 turn ON in this sequence.
Output relay 0500 turns OFF when input relay 0000 is OFF.
Coding
Timing diagram
Fork lift truck IN/OUT judgementChecks the input sequence. Output relay 0500 turns ON when input relay 0000 turnsON and then 0001 turns ON. Output relay 0501 turns ON when input relay 0001turns ON and then 0000 turns ON.
Coding
Timing diagram
0000
0500
0001
10001000 0002
10011001 0003
10021002
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 LD 1000
0003 W-UE 0002 1001
0004 LD 1001
0005 W-UE 0003 1002
0006 LD 1002
0007 OUT 0500
ON
ONOFF
ONOFF
ONOFF
ONOFF0003
0001
0000
0500
0002
0000 0500
0501
1001
10000001
1000
10010000
1001
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
ON
ONOFF
ONOFF
0500
0000
0501
0001
ON
Scan
Leave warehouse
Enter warehouse
Scan
W-UE
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM101
2.4 Instruction Details
3-102
2
Chapter 2 Instructions
Example
Coding
Description
• When input relay 0000 turns ON, 0500, 0501, 0502, and 0503 turn ON.• When input relay 0000 turns OFF, 0500, 0501, 0502, and 0503 turn OFF.• The CON instruction is used to connect instructions after output instructions
when the extended ladder is used.• When the LADDER BUILDER for KV programming support software is used, the
CON instruction is automatically converted into a mnemonic and entered in theladder 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
CON: ConnectRepresents series connection of outputinstruction with another instruction.
RES0
ORB6FUN
0000 0503050205010500
CON CON CON
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
RES0
ORB6FUN ENT
R-SRCHENTR-SRCH
:
CON
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM102
2.4 Instruction Details
12
3-103Chapter 2 Instructions
Example
Coding
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 automaticallyconverted into mnemonics and entered in the ladder diagram.
Note 1: Limit the number of MPS instructions to 8 or less in a circuit.
Note 2: An MPS instruction must have a corresponding MPP instruction. Thismeans that the same number of MPS and MPP instructions must be used in aprogram. An MPS or MPP instruction without a corresponding MPP or MPS instruc-tion results in a logic error.
Operands
Key operation
MPS: Push
MRD: Read
MPP: Pop
Stores current input and arithmetic flagstatus.
Reads input and arithmetic flag statusstored with PUSH.
Reads and clears input and arithmetic flagstatus stored with PUSH.
Line No. Instruction Operand
0000 LD 0000
0001 MPS
0002 AND 0001
0003 OUT 0500
0004 MRD
0005 AND 0002
0006 OUT 0501
0007 MPP
0008 AND 0003
0009 OUT 0502
MPSC
MRDD
MPPc h
0000
0501
0500
0001
0002
0003 0502
MRD
MPP
MPS
MPSC
MRDD
MPPch
ENTR-SRCH
:
:
:
MPS / MRD / MPP
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM103
2.4 Instruction Details
3-104
2
Chapter 2 Instructions
MPS/MRD/MPP applicationsMPS, MRD, and MPP instructions are used as follows:
Coding
Coding
Start of branch0002 0003 0004 0500
0006 0501
0007 0502
0008 0503
MPS
MRD
MRD
MPP
Connection of branch
End of branch
Connection of branch
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
0000 0001
0004
0002 0500
0003 0501
0005 0502
0006 0503
MPS
MPS
MPS
MPP
MPP
MPP
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
MPS / MRD / MPP
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM104
2.4 Instruction Details
12
3-105Chapter 2 Instructions
Coding
0000 0001 0002 0003 0004 0500
0501
0502
0503
0504
MPS MPS MPS MPS
MPP
MPP
MPP
MPP
Line No. Instruction Operand
0000 LD 0000
0001 MPS
0002 AND 0001
0003 MPS
0004 AND 0002
0005 MPS
0006 AND 0003
0007 MPS
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
MPS / MRD / MPP
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM105
2.4 Instruction Details
3-106
2
Chapter 2 Instructions
Example
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 STG1000and 1003.
4) 0502 turns ON. The process finishes when transition condition relay 0004 turnsON.
Coding
STG: Stage
JMP: Jump
ENDS: End Stage
Executes instructions in STG block when operand relay is ON.
When transition condition relay is ON, turns OFF relay of currentstage and transfers execution to stage specified by operand.
When transition condition relay is ON, turns OFF relayof current stage.
ENDS
nnnn
JMP
nnnn
STGLDB
4
LDB4
LDB4
SET1
SET1
ANL2
FUN
FUN
FUN
Initial setting2008
0000
0500
1001JMP
1000STG
0001 1002JMP
1001STG
0502 0004 ENDS
1003STG
0501 0002 1001JMP
1002STG
0003 1000JMP
1003JMP
1000SET
1)
2)
3)
4)
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0013 MPS
0001 SET 1000 0014 AND 0002
0002 STG 1000 0015 JMP 1001
0003 AND 0000 0016 MPP
0004 JMP 1001 0017 AND 0003
0005 STG 1001 0018 JMP 1000
0006 OUT 0500 0019 JMP 1003
0007 CON 0020 STG 1003
0008 AND 0001 0021 OUT 0502
0009 JMP 1002 0022 CON
0010 STG 1002 0023 AND 0004
0011 OUT 0501 0024 ENDS
0012 CON
:
:
:
STG / JMP / ENDS
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM106
2.4 Instruction Details
12
3-107Chapter 2 Instructions
Note 1: The following table shows the status of each instruction between STG andJMP/ENDS when STG operand relay turns OFF.
Note 2: STG/JMP/ENDS operand relay Nos. cannot be duplicated in a program.
Note 3: The STG instruction must be used in combination with the JMP or ENDSinstruction.
Note 4: The following instructions are not properly executed between STG and JMP/ENDS instructions:
DIFU, DIFD, KEEP, UDC, SFT, FOR, NEXT, andDifferentiation type instruction (@xxx)
Operands
* Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion orremote I/O unit ports can be used for internal utility relays.
Key operation
FUN
FUN ANL2
FUN
LDB4
LDB4
LDB4
SET1
SET1
Operand(nnnn)
Operand(nnnn)
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
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.
STG / JMP / ENDS
Visual KV KV-300 KV-10/16 KV-24/40/80
1000 to 1915 1000 to 1915 1000 to 1915 1000 to 19153000 to 9915 3000 to 6915
*7000 to 9915
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM107
2.4 Instruction Details
3-108
2
Chapter 2 Instructions
Details of STG instruction STG instruction
The STG instruction is suitable for sequential step-by-step processing.The whole process is divided into several operational steps, and one program isassigned to each step.The process to turn on several lamps sequentially can be divided into the followingfive steps:
1) Wait until the start switch is turned ON.2) Turn on lamp 1 for 1 second.3) Turn on lamp 2 for 3 second.4) Turn on lamp 3 for 5 second.5) Turn on lamps 1, 2, and 3 simultaneously for 7 seconds.
These five steps are sequentially performed in order as shown in the flowchartbelow.If a ladder program is written for such sequential processing without any STGinstructions, the resulting program may be complicated and difficult to review byothers.
I/O assignmentsAssign the input and output of the Visual KV Series as follows:
1) Start switch: Turned on when 0000 turns ON.2) Lamp 1: Lights when 0500 turns ON.3) Lamp 2: Lights when 0501 turns ON.4) Lamp 3: Lights when 0502 turns ON.
NO
YES
Start
StartSW ON?
Turn on lamp 1for 1 second.
Turn on lamp 2for 3 second.
Turn on lamp 3for 5 second.
Turn on lamps 1, 2,and 3 simultaneouslyfor 7 seconds.
Sequential processing
0000 0500
KV
COM COM0502
0501
Lamp 3
I/O assignment
Start SW
Lamp 1
Lamp 2
STG
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM108
2.4 Instruction Details
12
3-109Chapter 2 Instructions
Sequence programAssign the relays to execute the five processes on the previous page as follows:
1 Wait until the start switch is turned ON.: Input relay 00002 Turn on lamp 1 for 1 second.: Output relay 05003 Turn on lamp 2 for 3 second.: Output relay 05014 Turn on lamp 3 for 5 second.: Output relay 05025 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 writtenwith and without STG instructions.
• Without STG instruction
• With STG instruction
0000 T000
#00010T000
1000SET
1000
T000 T001 1001
1000
#00030T001
1001
T001
T003
T002 1002
T002 T003 1100
1101
1102
#00050T002
#00070T003
1002
1100
1100
05001000
1101
05011001
1102
05021002
2008
0000 T0001001STG
1002JMP
#00010T000
0500
T0011002STG
1003JMP
#00030T001
0501
T0021003STG
1004JMP
#00050T002
T003 1001JMP
#00070T003
0502
1004STG
0500 0501 0502
1001SET
OR circuit is required becausedouble coil cannot be used.
1000 (0500) turns ON for 1 secondwhen input 0000 turns ON.
1001 (0501) turns ON for 3 secondswhen T000 turns ON.
1002 (0502) turns ON for 5 secondswhen T001 turns ON.
1100 (0500), 1101(0501), and 1102 (0502)turn ON for 7 secondswhen T002 turns ON.
The process is repeated from thebeginning when T003 turns ON.
The process is repeated from thebeginning when T003 turns ON.
1001 turns ON at the start of operation.
0500 turns ON for 1 second when input0000 turns ON. Then, 1002 turns ON.0501 turns ON for 3 seconds when1002 turns ON. Then, 1003 turns ON.0502 turns ON for 5 seconds when 1003turns ON. Then, 1004 turns ON.
0500, 0501, and 0502 turn ON for 7seconds when 1004 turns ON.
STG
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM109
2.4 Instruction Details
3-110
2
Chapter 2 Instructions
Process progression with Wait instruction
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 stageevery time when start switch 0000 turns ON (process progression). "W-UE instruction" (p. 3-98)
Tips
Resetting STG instructions (in the above example)
Use the SFT instruction to turn OFF all STG instructions in an emergency.
Enter the initial setting process depending on the program. The above examplecannot 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.
2008
1100
0500
1001JMP
1000STG
1002JMP
1001STG
0501 1003JMP
1002STG
0502
0500 0501 0502
1003STG
1004STG
1004JMP
1000SET
0000
1100
1104 1000JMP
0000
1104
1101
1102
1103
0000
11010000
11020000
1103
2003
2003
SFT
D 1000
CLK 1004
RES
1000SET Initial setting
Reset input
STG start relay
Reset input
STG end relay
STG
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM110
2.4 Instruction Details
12
3-111Chapter 2 Instructions
Cautions for using STG instructionInterlock
When an STG instruction moves to another stage, the previous and next stages turnON simultaneously only for one scan. Provide an interlock circuit for the outputwhich may be dangerous when turned ON in such occasions (e.g., motor's normal/reverse rotation).
Double coilA double coil can be used for an STG instruction.
Note: When STG 1000 and 1002 turn ON simultaneously, priority is given to outputrelay 0500 of STG 1002, which is entered last.
Retaining outputUse the SET instruction to retain output.
When no JMP is usedWhen no JMP instruction is used, the STG instruction does not turn OFF even if0001 turns ON. Be sure to use JMP after STG.
STG operandWhen the STG operand relay remains ON, 0500 does not turn OFF even if 0001turns ON.
Use a differentiation type instruction for the condition of the first STG instruction.
Double coil
0001
0501
0500
1001JMP
1000STG
1002JMP
1001STG
0002
0501
0500
1100
0501
0500
1001JMP
1000STG
1002JMP
1001STG
1101
0001ON
11000002ON
11010500 1003
JMP1002STG
11020003ON
1102
0000
1001
1002
JMP1000STG
JMP
1001STG
0001
0500SET
0501SET
00011000STG
0500 0501
0001
0000
1000STG
1001JMP
0500
1000SET
0001
11000000
1000STG
1100DIFU
1001JMP
0500
1000SET
Interlock
STG
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM111
2.4 Instruction Details
3-112
2
Chapter 2 Instructions
JMP operandUnlike the STG operand relay, the JMP operand relay No. can be duplicated in aprogram.
DIFU/DIFD instructions in an STG block
The operand relay for an STG instruction cannot be used as the input operand relayfor a DIFU or DIFD instruction.
Application of STG and JMP instructions Enabling a double coilWhen start SW 0000 is pressed, the following output operation is repeated:Output relay 0500 turns ON for 1 second.
Output relays 0500 and 0501 turn ON for 2 seconds.Output relays 0500, 0501, and 0502 turn ON for 3 seconds.
Coding
00021001STG
1002JMP
0501
00011000STG
1001JMP
1002JMP
0500
0501
0001
3000
1000STG
3000DIFU
1001JMP
0500
1100
T000 1001JMP
1100DIFU
#00010T000
05001000STG
T001 1002JMP
#00020T001
050105001001STG
T002 1000JMP
#00030T002
0502050105001002STG
1000SET
0000
Outputs 0500, 0501, and 0502 turn ON for3 seconds.
1000 turns ON at the rising edge of input 0000.
Output 0500 turns ON for 1 second.
Outputs 0500 and 0501 turn ON for 2 seconds.
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
STG / JMP
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM112
2.4 Instruction Details
12
3-113Chapter 2 Instructions
Note: The double coils in different STG instruction blocks operate properly. How-ever, when several STG instructions turn ON simultaneously, priority is given to theone programmed last.
Conditional branchingWhen input relay 0000 (start SW) turns ON, output relay 0500 turns ON. Then, asprogrammed for conditional branching, output relay 0501 turns on for 1 secondwhen 0001 turns ON, and 0502 turns ON for 2 seconds when 0002 turns ON. Aftereach operation is completed, the program returns to the conditional branch andrepeats the same steps.
Coding
1100
0001 1001JMP
1100DIFU
1000STG
0002 1002JMP
0500
T000 1000JMP
#00010T000
05011001STG
T001 1000JMP
#00020T001
05021002STG
1000SET
0000
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
STG / JMP
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM113
2.4 Instruction Details
3-114
2
Chapter 2 Instructions
When 1000 is OFF,steps 1) through 3) arenot executed.
1000STP
STP1001
STE
STE
1)
2)
3)
4)
Example
Coding
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 and0500 are ON, 0500 remains ON after 0001 turns OFF.
• The program step specified withSTP-STE instructions are ex-ecuted when the STP operandrelay is ON. When the operandrelay is OFF, the programexecution jumps to STE instruc-tion. (Fig 1).
• STP-STE instructions can benested up to 8 levels deep asshown in Fig. 2. When 1000 isOFF, steps 1) through 3) are notexecuted. Control jumps to theSTE instruction just above step4), then step 4) is executed.When 1000 and 1001 are ON,steps 1) through 3) are executedin that order. When 1000 is ONand 1001 is OFF, steps 1), 3),and 4) are executed in thatorder, while step 2) is left unex-ecuted.
Note 1: STP/STE operand relay Nos. cannot be duplicated in a program.Note 2: When an STP operand turns OFF during program execution between STPand STE instructions, the state of the instructions between STP and STE are re-tained.Note 3: The scan time is not affected by any instructions between STP and STEwhich are not executed.
STP: StepSTE: Step End
Executes instructions between STP andSTE when operand relay is ON.
Used with STP to make a program step.
When 1000 is OFF,A is not executed.
LDB4
LDB4
ANB5
ORL3
STE
STPnnnnFUN
FUN
STP1000
STE
0001 0500
0000 1000
Line No. Instruction Operand
0000 LD 0000
0001 OUT 1000
0002 STP 1000
0003 LD 0001
0004 OUT 0500
0005 STE
1000STP
STE
A
B
:
:
Fig. 1
Fig. 2
STP / STE
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM114
2.4 Instruction Details
12
3-115Chapter 2 Instructions
Tips
Operation when STP turns OFF
Using a timer in an STP blockWhen a timer is used in a program defined with an STP instruction, the operation isas follows:
a) 1000 is reset immediately when thetimer turns ON. The STE instruction isstarted with the timer remaining ON.
b) 1000 is not reset immediately when thetimer turns ON but is reset at the nextscan. The timer is reset before the STEinstruction is started.
Usage of STG and STP instructions
STG instructionUse the STG instruction for process progression with branches.
STP instructionUse the STP instruction for process progression without branches.
Tim
er is reset.
0000
T000
1000SET
1000
T000 1000RES
0500
#00050T000
STP1000
STE
a)
JumpTimerremains
ON.
Scan
0000
T000
1000SET
T000
1000
1000RES
0500
#00050T000
STP1000
STE
b)
JumpTimerremains
ON.
Scan
STP / STE
0000
ENDS
ENDS
1002
JMP
1001
JMP
1000
STG
1001
STG
1002
STG
0001
0002
0003
0004
0500
0501
0502
1000SET
0000
0002
1000SET
0001
0003
0004
1000RES
1001SET
0500
1002SET
1001RES
STE
STP1001
STP1000
0501
STE
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM115
2.4 Instruction Details
3-116
2
Chapter 2 Instructions
0000 1000
T000
1001SET
T000
1001
T000
1001RES
0500
0501
1002RES
STE
STE
END
ENDH
STP1002
STP1001
1002SET
1000DIFU
#00020T000
1002
T001
T001
#00030T001
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 CON0003 AND 10000004 SET 10010005 STP 10010006 LD T0000007 RES 10010008 LDB T0000009 OUT 05000010 LD 10010011 TMR 000 #000200012 LD T0000013 SET 10020014 STE0015 STP 10020016 LD T0010017 RES 10020018 LDB T0010019 OUT 05010020 LD 10020021 TMR 001 #000300022 STE0023 END0024 ENDH
Operands
* Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or remote I/Ounit ports can be used for internal utility relays.
Key operation
Application of STP and STE instructions Process progressionWhen input relay 0000 turns ON, output relay 0500 turns ON for 2 seconds, thenoutput relay 0501 turns ON for 3 seconds automatically.
Coding
The double coils in different STP blocks operate properly.
STP / STE
FUN
FUN
LDB4
LDB4
ANB5
ORL3
Operand(nnnn)
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915T000 to T249 0500 to 6915 T000 to T063 T000 to T119C000 to C249 *7000 to 9915 C000 to C063 C000 to C119CTC0 to CTC3 T000 to T249 CTC0 to CTC3 CTC0 to CTC3
C000 to C249CTC0 to CTC3
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM116
2.4 Instruction Details
12
3-117Chapter 2 Instructions
Example
Coding
Operation in the above example
Measures pulse-to-pulse interval or pulse width for input relay 0000.
ITVL instruction has two functions:• Measures pulse-to-pulse interval (cycle) or pulse width. (Minimum unit: 10 ms)• Obtains the average of the contents of data memory.
Each input has the following functions:• PLS
Executes measurement. In data memory measurement, however, PLS input isdisabled in modes 0006 to 1999. Values are fetched only at the scan when PLSinput is ON in modes 10000 to 11999.The measured value is written into the specified data memory (DM).
In the above example, the measured value of input relay 0000 iswritten into DM0004 (DM0000 + 4 addresses).
• PAUSEPauses the measurement when turned ON.
• RESInitializes 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.
Note: ITVL operand relay Nos. cannot be duplicated in a program.
Operands
* Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or remote I/Ounit ports can be used for internal utility relays.
Key operation
ITVL: Interval Timer Measures pulse-to-pulse interval or pulsewidth in specified mode.
ITVLPLSDMnnnnPAUSEmmmmRES
ITVL#TM
0000
0001
0002
PLS
DM0000
PAUSE
1000
RES
ITVL
"Reset" input
"Pulse" input
Beginning of workpiece data table"Measurement Pause" inputFirst flag relay
ITVL#TM
First operand(nnnn)
Second operand(mmmm)
ENTR-SRCH
Line No. Instruction Operand
0000 LD 0000
0001 LD 0001
0002 LD 0002
0003 ITVL DM0000 1000
:
ITVL
Visual KV KV-300 KV-10/16 KV-24/40/80
Data table No.: Data table No.: DM0000 to DM0985 DM0000 to DM1985DM0000 to DM1984 DM0000 to DM9985 1000 to 1912 1000 to 1912
1000 to 1912 Flag relay No.: 3000 to 6912Flag relay No.: 1000 to 19123000 to 9912 3000 to 9912
*7000 to 9915
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM117
2.4 Instruction Details
3-118
2
Chapter 2 Instructions
Setting procedure
The ITVL instruction reserves 16 data memories: 1 specified data memory and 15successive 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 (DM) assignment• Set the initial setting data to the first four data memories.
Data memory
ModeDM XX + 00
01
02
03
04
05
06
07
08
09
10
11 to 12
MAX value
MIN value
Measured value
MAX measured value
MIN measured value
Mean
Preset No.ofmeasurements
No.of measurementsperformed*
Higher digits*
Lower digits*
Work memory
MAX errorRelay +0
+1
+2
+3
MIN error
Everymeasurements
completion
Measurementscompletion for
mean calculation
Used for computing measured values, Max.measured values, Min. measured values, meanvalues, and accumulating totals. (Cannot be used)
Specifies measurement mode (0 to 5).
Presets highest value in measurementrange.Presets lowest value in measurementrange.Specifies number of measurements formean calculation (1 to 65535).Stores current measured value.
Stores Max. measured value.
Stores Min. measured value.
Stores mean value.
Stores number of times measurementsactually performed.
Stores higher 16 bits of accumulatingtotal of measurements. (#00000 to#65535) ($0000 to $FFFF)
Initialsettingis to bespecifiedby user.
Stores lower 16 bits of accumulatingtotal of measurements. (#00000 to#65535)($0000 to $FFFF)
Turns ON and remains ON for one scan time whenmeasured value exceeds Max preset value.
Turns ON and remains On for one scan time whenmeasured value goes below Min preset value.
Turns ON at completion of every measurement andremains ON for one scan time.
Turns ON for one scan time at completion of thespecified No. of measurements for mean valuecalculation, then remains ON for one scan time.
Relay assignmentRelay
Note 1: When 0 (zero) is specified as the number of measurements, mean valuecalculation will not be performed. In this case, the number of measurements will beaccumulated until RES input turns ON, which may cause overflow.
Note 2: Data in the No. of measurements, Higher digits, and Lower digits are resetwhen the No. of measurements performed reaches the preset No. of measurements.
Note 3: Once ITVL instruction is defined in MC-MCR block, the measurementprocess pauses when the block is not executed.
Note 4: For programs containing subroutines, interrupts, steps, or stages, ITVLinstructions must be defined so that they are executed unconditionally for every scantime.
ITVL
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM118
2.4 Instruction Details
12
3-119Chapter 2 Instructions
Mode settingWrite the desired mode No. into the first data memory.
Mode for pulse measurement
Mode for DM measurementWrite the desired mode No. into the specified data memory.
Example
Write "#0006" to obtain the average of the contents of DM0006.
Note 1: When the mode No. is set to 10000 through 11999, values are fetched atthe 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. Becareful when specifying data memory for the ITVL instruction. Refer to "1.3.10 Data Memories" (p. 3-19) for data memory assignments.
ModePulse-to-pulse
interval Unit Mode Pulse width Unit
10 m sec
100 m sec
1 sec
10 m sec
100 m sec
1 sec
Mode No. DM No. Description
10000 DM0000Measure the contents of DM0000 and obtain theaverage.
10001 DM0001Measure the contents of DM0001 and obtain theaverage.
• • •• • •
10005 DM0005 Measure the contents of DM0005 and obtain theaverage.
000610006 DM0006
Measure the contents of DM0006 and obtain theaverage.
0007 10007 DM0007 Measure the contents of DM0007 and obtain theaverage.
• • • •• • • •
1999 11999 DM1999 Measure the contents of DM1999 and obtain theaverage.
2000 to 9999 12000 or more Not provided Cannot be used.
Pulse-to-pulse interval measurement Pulse width measurement
0 1
2 3
4 5
ITVL
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM119
2.4 Instruction Details
3-120
2
Chapter 2 Instructions
ON
0500
1000
0000500ms 400ms 600ms
1001
ONOFF
ON
ON ON
1 scan
3 sec. 3 sec.
1 scan
Application of ITVL instructionThis section describes examples of pulse interval measurement.
Pulse interval measurement
Turns ON output relay 0500 for 3 seconds when the pulse interval is not within therange of 490 to 510 ms.
Coding
Timing diagram
2008
2008
2008
2008
0000
0001
0002
T0001000
1001
0500
#00000LDA
DM0000STA
#00051LDA
DM0001STA
#00049LDA
DM0002STA
#00010LDA
DM0003STA
PLS
DM0000
PAUSE
1000
RES
ITVL
0500
#00030T000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0013 LDA #000100001 LDA #00000 0014 CON0002 CON 0015 STA DM00030003 STA DM0000 0016 LD 00000004 LD 2008 0017 LD 00010005 LDA #00051 0018 LD 00020006 CON 0019 ITVL DM0000 10000007 STA DM0001 0020 LD 10000008 LD 2008 0021 OR 10010009 LDA #00049 0022 OR 05000010 CON 0023 ANB T0000011 STA DM0002 0024 OUT 05000012 LD 2008 0025 TMR 000 #00030
1001 turns ON for one scan when measured valueis below min. setting value (490 ms).
Sets mode 0 (Unit:10 ms).
Sets max. setting value of measurement range to 510 ms.
Sets min. setting value of measurement range to 490 ms.
Sets number of averaging measurements to 10.
Measures pulse interval when input relay 0000 turns ON.
Pauses measurement while input relay 0001 turns ON.
Resets measurement when input relay 0002 turns ON.
1000 turns ON for one scan when measuredvalue exceeds max. setting value (510 ms).
ITVL
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM120
2.4 Instruction Details
12
3-121Chapter 2 Instructions
ITVL
A/D data measurement
Turns ON output relay 0500 when the analog input from the KL-4AD to DM1600(range: 1 to 5 V) exceeds +3 V. Turns ON output relay 0501 when the input is below+2 V. Writes the average into DM0100.Refer to the "KL-4AD/KL-2AD User’s Manual" for data memory settings for the KL-4AD.
Coding
2008
2008
2008
2008
2003
0001
0002
1000
#01600LDA
DM0000STA
#02000LDA
DM0001STA
#01000LDA
DM0002STA
#00100LDA
DM0003STA
PLS
DM0000
PAUSE
1000
RES
ITVL
1001
1003 DM0100STA
DM0007LDA
0500
0501
Writes average into DM0100 every 100 measurement.
Measures contents of DM1600.
Sets max. setting value to +3 V (2000).
Sets min. setting value to +2 V (1000).
Sets number of averaging measurements to 100.
Pauses measurement when input relay 0001 turns ON.Resets measurement when input relay 0002 turns ON.
0500 turns ON when measured value exceeds max. setting value.
0501 turns ON when measured value is below min. value.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0014 CON
0001 LDA #01600 0015 STA DM0003
0002 CON 0016 LD 2003
0003 STA DM0000 0017 LD 0001
0004 LD 2008 0018 LD 0002
0005 LDA #02000 0019 ITVL DM0000 1000
0006 CON 0020 LD 1000
0007 STA DM0001 0021 OUT 0500
0008 LD 2008 0022 LD 1001
0009 LDA #01000 0023 OUT 0501
0010 CON 0024 LD 1003
0011 STA DM0002 0025 LDA DM0007
0012 LD 2008 0026 STA DM0100
0013 LDA #00100
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM121
2.4 Instruction Details
3-122
2
Chapter 2 Instructions
Example
Coding
Description
• When input relay 0000 turns ON, the subroutine specified by SBN00 and RET isexecuted. 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
Key operations
CALL: Subroutine CallSBN: Subroutine EntryRET: Subroutine Return
Executes subroutine specified by operand.
Represents beginning of subroutine speci-fied by operand.
Represents end of subroutine.
RES0
RES0
AND8
ORL3
ORL3
ORL3
FUN
FUN
FUNRET
SBNnn
CALLnn
Line No. Instruction Operand0000 : :
: : :: LD 0000: CALL 00: : :: END :: SBN 00: : :: RET :: ENDH :
0000 00CALL
END
SBN00
RET
ENDH
RES0
AND8
ORL3
ORL3
ORL3
ORL3
FUN
FUN
FUN
OperandENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
:
:
:
CALL / SBN / RET
CALL 00 to 99
SBN 00 to 99
RET —
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM122
2.4 Instruction Details
12
3-123Chapter 2 Instructions
Application of subroutine
When CALL00 is encountered during normal scan execution, the subroutine isexecuted. At the completion of this subroutine, program execution returns to pro-gram at B) immediately following CALL00. Then, the normal scan is continued untilan END instruction is encountered.
With no CALL instruction With CALL instruction
Nesting structure of a subroutine• Subroutine instructions can be nested up to 4 levels deep.• A subroutine which is called from another subroutine should be defined before
the call.
00
CALL
0000
A)
B)
00
CALL
SBN00
2008
ENDH
RET
END
B)
A)
Subroutine program
Normal scan
Subroutine
Program
Program
Program
Program
00
CALL
0000
B)
A)Program
Program
Subroutine program
00
CALL
SBN01
0001
01
CALL
0000
SBN00
ENDH
RET
RET
END
Call
Program
Subroutine program
CALL / SBN / RET
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM123
2.4 Instruction Details
3-124
2
Chapter 2 Instructions
Calling a subroutine from an interrupt program• Subroutines can be called from interrupt programs.• A subroutine which is called from an interrupt program should be defined before
the call.
Note 1: Subroutine Nos. for SBN instructions cannot be duplicated in a program.(It can be duplicated for CALL instructions.)
Note 2: When a subroutine is executed, the scan time is extended by the timeneeded for subroutine execution.
Note 3: The following instructions cannot be used in subroutines:STG, JMP, ENDS, INT, RETI, and MEMSW
Note 4: The following instructions can be used only in subroutines which are ex-ecuted every scan time:
TMR, TMH, TMS, C, SFT, UDC, DIFU, DIFD, W-UE, W-DE, HKEY, ITVL,and Differentiation type instruction (@xxx)
SBN00
0001
00
CALL
0002
INT0000
ENDH
RET
RETI
END
0500
Call
Program
Subroutine program
CALL / SBN / RET
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM124
2.4 Instruction Details
12
3-125Chapter 2 Instructions
Example
Coding
Description
Use FOR-NEXT instructions in a subroutine program (between SBN and RET) toinitialize 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 andNEXT instructions. "Indirect addressing" (p. 3-127)
• The FOR instruction takes either of the following two types of operands: thenumber of repetitions or the location (DM No.) of the data memory containing thenumber 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.
FOR: Repeat Start
NEXT: Repeat End
Executes program between FOR and NEXTby number of times specified by operand.
Represents end of repetition.
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
FUN
FUN
SET1
ANL2
OR9
ORB6
NEXT
FORnnnn
Specify the first DM No.
Specify the number of DMs to beinitialized.
2008
#00100LDA
2002
2002
00CALL
END
SBN00
#00050FOR
NEXT
RET
ENDH
TM02STA
#00000LDA
#TM02STA
TM02INC
(DM100)
:
:
FOR / NEXT
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM125
2.4 Instruction Details
3-126
2
Chapter 2 Instructions
Tips
Note 1: The FOR-NEXT instruction pair repeats the program for a specified timeperiod 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 FORand 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 shortenthe ladder program.
• The FOR-NEXT instruction set can be nested up to 8 levels deep. Nine or morenested levels will result in a FOR-NEXT error.
• After repeating FOR-NEXT 3) five times, program execution transfers to theinstructions following the NEXT instruction.
• FOR-NEXT 2) is repeated twice while FOR-NEXT 3) is executed once.Thus, FOR-NEXT 2) is executed 10 times.
• FOR-NEXT 1) is repeated 5 times while FOR-NEXT 2) is executed once.Thus, FOR-NEXT 1) is executed up to 50 (5 x 2 x 5) times.
Operands
Key operation
NEXT
NEXT
NEXT
FOR#05
FOR#02
FOR#05
1) 2) 3)
FOR / NEXT
FUN
FUN
SET1
ANL2
OR9
ORB6 OperandENT
R-SRCHENTR-SRCH
ENTR-SRCH
ENTR-SRCH
Visual KV KV-300 KV-10/16 KV-24/40/80
#0000 to #65535 DM0000 to DM1984 #00000 to #65535 #00001 to #65535DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999
TM02 to TM28 TM00 to TM29 TM00 to TM29 TM00 to TM29
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM126
2.4 Instruction Details
12
3-127Chapter 2 Instructions
Indirect addressing Indirect addressing
Indirect addressing is used to so you don't have to use fixed data memories or relayNos. when the contents of data memory or a relay is stored in internal registers, orwhen the contents of the internal memory is stored in data memory or a relay.
Method for indirect addressing• Specify the operand for instructions as "#TMxx". The contents of "TMxx" is
considered to be the specification No. (indirect addressing).
Example
When TM02 value is "0000", "#TM02" represents DM0000.When TM02 value is "10000", "#TM02" represents 0000 (relay).
• Any of "02" through "29" can be specified for "xx".• Specify the desired decimal number for "xx".• Numbers "0000" through "1999" specify DM0000 through DM1999 (data
memory).Numbers "10000" through "27915" specify 0000 through 17915 (relay).
Example: LDA #TM15
This is the same operation whether "LDA DM0020" or "LDA 1000" is specified. Thespecified data memory or relay can be changed as desired by changing the value ofTM15.
Example: STA #TM02
This is the same operation whether "STA DM0000" or "STA 3000" is specified. Thespecified data memory or relay can be changed as desired by changing the value ofTM02.
Range of DM and relay Nos. that can be specified by "TMxx"
Instructions which can use indirect addressing:
Specify "#TMxx" as an operand relay.LDA, @LDA, STA, @STA, CMP, @CMP, ADD, @ADD, SUB, @SUB, MUL, @MUL,DIV, @DIV, ANDA, @ANDA, ORA, @ORA, EORA, @EORA
Note 1: "2000" to "9999" cannot be used as a TMxx value.
Note 2: If there is no data memory or relay corresponding to the number specifiedwith "#TMxx", special utility relay 2012 turns ON.
TM15 value Data entered into internal register
20 DM0020
11000 1000 to 1015
TM02 value Specified destination
00 DM0000
13000 3000 to 3015
TMxx value DM/relay
0000 to 1999 DM0000 to DM1999
2000 to 9999 Cannot be used.
10000 to 27915 0000 to 17915
FOR / NEXT
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM127
2.4 Instruction Details
3-128
2
Chapter 2 Instructions
Data memory block transfer
• Comparison between a program with normal addressing and one with indirectaddressing.
Program with normal addressing Program with indirect addressing
0000
1000
1000
1000
1000
DM0000LDA
DM0100STA
DM0001LDA
DM0101STA
DM0002LDA
DM0102STA
DM0003LDA
DM0103STA
1000 DM0098LDA
DM0198STA
1000 DM0099LDA
DM0199STA
1000
DIFU
END
ENDH
0000
1000
2002 #00000LDA
TM02STA
#00100LDA
TM03STA
2002 #TM02LDA
#TM03STA
TM02INC
TM03INC
SBN0 0
FOR#0100
NEXT
RET
ENDH
END
1000DIFU
00CALL
1)
2)
3)
4)
The contents of DM0000 are transferredto DM0100.The contents of DM0001 are transferredto DM0101.The contents of DM0002 are transferredto DM0102.
•••••
The contents of DM0099 are transferredto DM0199.
DM0000
DM0099
DM0100
DM0199
••••••••••••
The block of 100 data istransferred.
The contents of DM0000 aretransferred to DM0100.
The contents of DM0099 aretransferred to DM0199.
Transfer ablock ofdata.
Program stepsare reduced byone-eighth.
No. of datamemory to betransferred.
The first No. of the source DM block is specified(DM0000).The first No. of the destination DM block is specified(DM0100).The contents of the DM indirectly addressed by"#TM02" is transferred to the internal register.
The contents of the internal register are transferredto the DM indirectly addressed by "#TM03".
Add "1" to both "TM02" and "TM03" to incrementthe Nos. of the source and destination DMs by one.
FOR / NEXT
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM128
2.4 Instruction Details
12
3-129Chapter 2 Instructions
Description
• On line 1), "TM02" is assigned to the first No. of the source 0000 and "TM03" isassigned 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 DM0100to DM0199.
• The ladder program on line 3) is executed 100 times in one scan.
1st operation: TM02 value: 0000, TM03 value: 0100
2nd operation: TM02 value: 00001, TM03 value: 0101
100th operation: TM02 value: 0099, TM03 value: 0199
When the ladder program on line 3) is repeated 100 times, the contents of thespecified DM block are transferred.
This operation is repeated.
2002 #TM02LDA
#TM03STA
TM02INC
TM03INC
2002 #TM02LDA
#TM03STA
TM02INC
TM03INC
2002 #TM02LDA
#TM03STA
TM02INC
TM03INC
••
••
Add "1" to thecurrent value of"TM03".
DM0000 isindirectlyaddressed.
DM0100 isindirectlyaddressed.
Add "1" to thecurrent value of"TM02".
Add "1" to thecurrent value of"TM03".
DM0001 isindirectlyaddressed.
DM0101 isindirectlyaddressed.
Add "1" to thecurrent value of"TM02".
Add "1" to thecurrent valueof "TM03".
DM0099 isindirectlyaddressed.
DM0199 isindirectlyaddressed.
Add "1" to thecurrent valueof "TM02".
FOR / NEXT
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM129
2.4 Instruction Details
3-130
2
Chapter 2 Instructions
Application of SBN-RET and FOR-NEXT instructions Data memory shift
Shifts the contents of the current data memory (DM) to the next DM at the risingedge of the synchronous (timing) signal. As the number of DMs to be shifted in-creases, the required scan time becomes longer.
Coding
0000 1000
2002
#00010LDA
TM03LDA
TM04STA
TM02SUB
TM05STA
#00001ADD
2002 TM03DEC
#TM03LDA
#TM04STA
TM04DEC
TM02STA
#00030 TM03LDA STA
00CALL
1000DIFU
END
NEXT
SBN00
FOR
2002 #00000LDA
#TM02STA
RET
TM05
ENDH
Synchronoussignal
Shift start DMNo. (DM0010)is designated.
Shift end DMNo. (DM0030)is designated.
Shift level
Indirect addressing is usedto designate DM Nos.
Program lines which executedata shift are grouped as asubroutine.
Data is shifted from DM0010 toDM0030.
Shift start DM No. is cleared to"#00000" after data is shifted.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 0000 0020 STA TM04
0001 DIFU 1000 0021 CON
0002 CON 0022 SUB TM02
0003 AND 1000 0023 CON
0004 LDA #00010 0024 STA TM05
0005 CON 0025 FOR TM05
0006 STA TM02 0026 LD 2002
0007 CON 0027 DEC TM03
0008 LDA #00030 0028 CON
0009 CON 0029 DEC TM04
0010 STA TM03 0030 CON
0011 CON 0031 LDA #TM03
0012 CALL 00 0032 CON
0013 END 0033 STA #TM04
0014 SBN 00 0034 NEXT
0015 LD 2002 0035 LD 2002
0016 LDA TM03 0036 LDA #00000
0017 CON 0037 CON
0018 ADD #00001 0038 STA #TM02
0019 CON 0039 RET
0040 ENDH
FOR / NEXT
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM130
2.4 Instruction Details
12
3-131Chapter 2 Instructions
HKEY: 16-Key InputReads hexadecimal key data on time-sharing basis and outputs these data tospecial utility relays 2900 to 2915.
FUN SET1
LD7
HKEYnnnn
mmmm
0005 HKEY00000500
Input relay
Output relay
Line No. Instruction Operand
0000 LD 0005
0001 HKEY 0000 0500
COM24VDC
+
-
000 001KV
002 003
0COM 500 501 502 503
4
8
C
1
5
9
D
2
6
A
E
3
7
B
F
Pressing two or more keyssimultaneously is OK.(With diode)
Pressing two or more keyssimultaneously is invalid.
:
ON: Key input read operation hascompleted.
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
ON: Pressing two or more keyssimultaneously is not valid.
R: Reading W: Writing
Example
Coding
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.
• The HKEY instruction employs four input relays and four output relays from thespecified number.
• Inputs are processed on a time-sharing basis, so that input processing requires 8scan 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).
• The special utility relay status indicates whether two or more keys can bepressed simultaneously or whether a key input read operation has completed, asshown in the following table:
Note 1: An HKEY instruction can be defined only once in a program.
Note 2: The HKEY instruction turns output relays ON/OFF every scan time. Connectthe device with transistor output.
Note 3: If the scan time is shorter than 8 ms, set the input time constant smallerthan the scan time.
Relay No. 2814 R/W 2815 R
Status
HKEY
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM131
2.4 Instruction Details
3-132
2
Chapter 2 Instructions
2002 0001 C000
2815
0005
#09999C0000000
HKEY01040512
ENDH
END
2900LDA TBIN
C000STA
0600
HKEY
FUN SET1
LD7 Output relayInput relay ENT
R-SRCHENTR-SRCH
Note 4: When two or more keys are pressed simultaneously even once during thescan while relay 2814 is ON, relays 2900 through 2915 keep the current status assoon as relay 2815 turns ON.
Note 5: The HKEY instruction does not properly operate if the scan time is longerthan 200 ms.
Note 6: When the expansion I/O module is used as an operand, the fetch may failunless the scan time is fixed to 2 ms or longer.
Operands
Key operation
Application of HKEY instruction Changing the preset value of internal counters using a BCD digital switch
Coding
• As soon as 0005 turns ON, the preset value is replaced with the new presetvalue 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 followingdiagram: (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.
Line No. Instruction Operand0000 LD 20020001 ANB 00010002 C 000 #09999 00000003 CON0004 AND C0000005 OUT 06000006 LD 00050007 HKEY 0104 05120008 LD 28150009 LDA 29000010 CON0011 TBIN0012 CON0013 STA C0000014 END0015 ENDH
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 to10415 10915
: :17000 to 17500 to
17415 17915
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM132
2.4 Instruction Details
12
3-133Chapter 2 Instructions
COM24VDC
+
-
0104 0105KV
0106 01071
100 101 102 103
2 4 8
COM 0512 0513 0514 0515
BCD Digital switch
Diode
2815
2002
2008
2010 20102900LDA
$03FFANDA
TM05CMP
TM05CMP
TM05STA
TM06STADMX
2815
2815 2915
2010 2010
DM0000STA
#00000
DM0000DW
TM06STA
#04SLA
DM0000LDA
2900LDA
$03FFANDA
TM05STA
END
ENDH
2814SET
HKEY
05000000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0020 CON0001 SET 2814 0021 AND 20100002 LD 2002 0022 ANDA $03FF0003 HKEY 0000 0500 0023 CON0004 LD 2815 0024 CMP TM050005 LDA 2900 0025 CON0006 CON 0026 ANB 20100007 ANB 2010 0027 STA TM050008 ANDA $03FF 0028 CON0009 CON 0029 LDA DM00000010 CMP TM05 0030 CON0011 CON 0031 SLA #040012 ANB 2010 0032 CON0013 STA TM05 0033 ORA TM060014 CON 0034 CON0015 DMX 0035 STA DM00000016 CON 0036 LD 28150017 STA TM06 0037 AND 29150018 LD 2815 0038 DW #0000 DM00000019 LDA 2900 0039 END
0040 ENDH
HKEY
Fetching 16-key input
Writes the following 16-key input value into DM0000 as 4-digit BCD.Pressing the [F] key clears the input value.
Coding
KVNKA Chap 02_4bP.p65 08.3.11, 0:00 PM133
2.4 Instruction Details
3-134
2
Chapter 2 Instructions
2.4.3 Arithmetic InstructionsArithmetic instructions handle data as integers to perform arithmetic, comparative, orlogical operations.
Instruction Mnemonic Reference page
DW: Data Memory Write DW 3-136
Trimmer In TMIN (FUN50), @TMIN @(FUN50) 3-138
LDA/@LDA: Load A LDA (FUN23), @LDA@ (FUN23) 3-140
STA/@STA: Store A STA (FUN42), @STA@ (FUN42) 3-140
CMP/@CMP: Compare CMP (FUN04), @CMP @(FUN04) 3-146
ADD/@ADD: Add ADD (FUN00), @ADD @(FUN00) 3-150
SUB/@SUB: Subtract SUB (FUN46), @SUB @(FUN46) 3-150
MUL/@MUL: Multiply MUL (FUN28),@ MUL @(FUN28) 3-150
DIV/@DIV: Divide DIV (FUN11), @DIV @(FUN11) 3-150
ANDA/@ANDA: And A ANDA (FUN01), @ANDA @(FUN01) 3-159
ORA/@ORA: Or A ORA (FUN31), @ORA @(FUN31) 3-161
EORA/@EORA: Exclusive Or A EORA (FUN15), @EORA@ (FUN15) 3-164
SRA/@SRA: Shift Right A SRA (FUN41), @SRA @(FUN41) 3-166
SLA/@SLA: Shift left A SLA (FUN40), @SLA @(FUN40) 3-166
RRA/@RRA: Rotate Right A RRA (FUN37), @RRA@ (FUN37) 3-169
RLA/@RLA: Rotate Left A RLA (FUN35), @RLA @(FUN35) 3-169
COM/@COM: Complement COM (FUN05), @COM @(FUN05) 3-171
INC/@INC: Increment Memory INC (FUN19), @INC @(FUN19) 3-172
DEC/@DEC: Decrement Memory DEC (FUN07), @DEC@ (FUN07) 3-172
MPX/@MPX: Multiplexer MPX (FUN27), @MPX@(FUN27) 3-176
DMX/@DMX: Demultiplexer DMX (FUN12), @DMX @(FUN12) 3-176
TBCD/@TBCD: Transfer BCD TBCD (FUN47), @TBCD @(FUN47) 3-180
TBIN/@TBIN: Transfer BIN TBIN (FUN48), @TBIN @(FUN48) 3-180
ASC/@ASC: ASCII Convert ASC (FUN02), @ASC @(FUN02) 3-183
RASC/@RASC: Reverse ASCII Convert RASC (FUN32), @RASC @(FUN32) 3-183
ROOT/@ROOT: Square Root ROOT (FUN36), @ROOT @(FUN36) 3-185
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM134
2.4 Instruction Details
12
3-135Chapter 2 Instructions
Internal registerKV executes all arithmetic instructions (i.e. data exchange) by using an internalregister, 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 forstoring ON-OFF status data (1-0 status data). The internal register is required whenthe 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 oroperates.
Arithmetic instructions executed using internal register
1. ON-OFF status of the specified relay and 15 successive relays is stored into theresister.
2. Current T/C value (decimal value = #*****) is automatically converted into abinary value and input to the internal register.
3. Constant (decimal value = #*****, hexadecimal value = $****) is automaticallyconverted 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 #65535Hexadecimal $0000 to $FFFFThe constants can be entered by using @
#, $ and the corresponding alphanumerickeys.(Pressing @
#, $ once allows you to enter decimal values, and pressing twice to enterhexadecimal values.)
5. The contents of the internal register (binary) is automatically converted into adecimal 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 datamemories. Although the data memories can store data when the power is beingOFF, 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.
CMP MPXADD DMXSUB TBCDMUL TBINDIV ASCANDA RASCORAEORASRASLARRARLACOMINCDEC
TMIND15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
(Arithmetic instructions executed as binary code.)
Relay No.1. Current T/Cvalue. 2.
Constant 3. 4.
(decimal,hexadecimal)
Data memory,temporarymemory
Data memory accessedin indirect addressing viatemporary memory
LDA instruction
Internal register
STA direction
Relay NoPreset T/Cvalue. 5.
Data memory,temporarymemory
Data m
emories,
temporary m
emories
Data memory accessedin indirect addressing viatemporary memory
Con-stant
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM135
2.4 Instruction Details
3-136
2
Chapter 2 Instructions
Example
Coding
• 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.
Note: The contents of the internal register and the arithmetic flag do not changeeven after the DW instruction is executed.
Tips
• The DW instruction can be used to reset the contents of data memories.
Operands
Key operation
Arithmetic flag
2009, 2010, 2011 No change2012 No change
DW: Data Memory Write Directly writes constant into data memory.DW nnnn
DMmmmmDW
2008 #00050
DM0001DW
$0018
DM0000DW
Line No. Instruction Operand
0000 LD 2008
0001 DW $0018 DM0000
0002 CON
0003 DW #00050 DM0001
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
2008 #00000
DM0001DW
#00000
DM0000DW
DWreraly First operand Second operand ENT
R-SRCH
:
First operand
Second operand
Operand
Data memory
DW
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 DMmmmmDM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM136
2.4 Instruction Details
12
3-137Chapter 2 Instructions
Example
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 inputrelay 0000.
• The every-scan type instruction is executed every scan time while input relay0000 is ON.
Timing diagram
• Instructions with the DIFFERENTIATION function are as follows:LDA, SAT, CMP, ADD, SUB, MUL, DIV, ANDA, ORA, EORA, SRA, SLA, RRA,RLA, COM, INC, DEC, MPX, DMX, TBCD, TBIN, ASC, RASC, ROOT
Note:In the top program, an INC instruction isexecuted every scan time, incrementingthe contents of DM0000 by one, whileinput relay 0000 is ON.
In the middle program, an INC instruc-tion is executed and the contents ofDM0000 is incremented only when inputrelay 0000 is turned from OFF to ON.
The bottom program uses theevery-scan type instruction whichperforms the same operation as thedifferentiation type instruction.
Operands
Key operation
@xxxx: DifferentiationExecutes instruction only at rising edge ofinput to input relay.
@#,$ FUN xxxx
0000 0000 DM0000INC
DM0000INC
Every-scan type instructionDifferentiation type instruction
ONOFF0000
INC
ONOFF0000
INC
Executed only once at the risingedge of input relay 0000.
Differentiation type instruction
Executed StoppedStopped Stopped
Every-scan type instruction
Stopped
0000 DM0000INC
0000 DM0000INC
0000 1000 DM0000INC
1000DIFU
@#,$ FUN Function No. ENT
R-SRCH
:
@xxxx
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM137
2.4 Instruction Details
3-138
2
Chapter 2 Instructions
T000 preset value can be changed with trimmer as follows (#00000 to #65535):
Coding
Description
The TMIN instruction transfers the value of the KV series’ digital trimmer (0 to65535) 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 ofthe destination can be changed without modifying the program.
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 operationprocedures for the digital trimmer of the Access Window.
Operands
Key operation
Arithmetic flag
2009 No change2010 Turns ON when "0" is entered by the TMIN instruction. Turns
OFF at other times.2011, 2012 No change
TMIN: Trimmer In
@TMIN: Trimmer Setting
Inputs numerical value specified by digitaltrimmer of access window (0 to 65535) tointernal register.@
#,$
FUN
FUN RES0
ANB5
RES0
ANB5
n TMIN
n TMIN
Inputs trimmer rotation angle of 0 to internal register.
Transfers contents of internal register to timer T000for use as preset value.
Turns ON output 0500 when current value ofT000 reaches "#00000".
Timer T000 operates as ON-delay timer when 0000 is ON.
02002TMIN
T000STA
#000100000 T000 0500T000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0005 TMR 000 #655350001 TMIN 0 0006 CON0002 CON 0007 AND T0000003 STA T000 0008 OUT 05000004 LD 0000
STATMIN
Digital trimmervalue of accesswindow [0 to 65535]
Internalregister
DestinationTransferNumeric data
0 to 65535Input
• Timer/counter presetvalue
• Relay ch No.• Data memory• Temporary memory
@#,$ FUN
FUNRES
0ANB
5ENTR-SRCH
ENTR-SRCH
Operand
:
:
TMIN / @TMIN
Visual KV KV-300/24/40/80 KV-10/16
0, 1 0, 1 0
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM138
2.4 Instruction Details
12
3-139Chapter 2 Instructions
Applications of TMIN (Analog timer) instruction Changing the timer setting value
Uses the digital trimmer (TMIN0) to change the setting value of a timer (0 to 6553.5sec.).
Coding
Changing setting values for multiple timersUses the digital trimmer (TMIN0) to change setting values for multiple timers (0 to6553.5 sec.).
Coding
In the above example, T000, T001, and T002 have the same setting value.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0005 OR 05000001 TMIN 0 0006 TMR 000 #000100002 CON 0007 ANB T0000003 STA T000 0008 OUT 05000004 LD 0000
0TMIN
T000STA
2002
0000
0500 0500T000
#00010T000
0TMIN
T000STA
T001STA
T002STA
#00010T000
2002
0000
0500T000
#00010T001
0001
0501T001
0500
0501
#00010T002
0002
0502T0020502
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0012 OUT 05000001 TMIN 0 0013 LD 00010002 CON 0014 OR 05010003 STA T000 0015 TMR 001 #000100004 CON 0016 ANB T0010005 STA T001 0017 OUT 05010006 CON 0018 LD 00020007 STA T002 0019 OR 05020008 LD 0000 0020 TMR 002 #000100009 OR 0500 0021 ANB T0020010 TMR 000 #00010 0022 OUT 05020011 ANB T000
TMIN / @TMIN
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM139
2.4 Instruction Details
3-140
2
Chapter 2 Instructions
The LDA instruction inputs each data item to the internal register.The STA instruction transfers the contents of the internal register to the specifieddestination.
"Internal Register" (p. 3-126)
Operands
Key operation
LDA: Load A
@LDA: Load A
STA: Store A
@STA: Store A
Inputs value specified by operand to internalregister.
Transfers contents of internal register todestination specified by operand.
@#,$
FUN
FUN
@#,$
FUN
FUN
LDB4
ANL2
ORL3
ORL3
LDB4
ANL2
ORL3
ORL3
nnnnSTA
nnnnSTA
nnnnLDA
nnnnLDA
@#,$ FUN
FUN
@#,$ FUN
FUNORL
3
LDB4
ANL2
ANL2
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
(#XXXXX)($XXXXX)
T XXXC XXX
DM XXXXTM XX
XXXX
1
2
3
T XXXC XXX
DM XXXXTM XX
XXXX
5
6
74
LDA STA
Constant DecimalHexadecimal
T/C currentvalue
Data memoryTemporary memory
Relay No. Relay No.
Storage Transfer Destination
Inte
rnal
reg
iste
r
T/C presetvalue
Data memoryTemporary memory
Relay No.
InputSource
(Data type: operand)
Relay No.
(Data type: operand)
LDA / @LDA / STA @STA
Visual KV KV-300 KV-10/16 KV-24/40/80LDA STA LDA STA LDA STA LDA STA
0000 to 0500 to 0000 to 0000 to 0000 to17915 1915 0009 2915 6915
T000 to 2100 to 0500 to 0500 to T000 to 0500 to T000 to 0500 toT249 17915 17915 1915 T063 1915 T119 1915
(Currentvalue)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 (Presetvalue) 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
(Presetvalue)
DM0000 to CTC0 to CTH0 to C000 to DM0000 to C000 to DM0000 to C000 to DM1999 CTC3 CTH1 C249 DM0999 C063 DM1999 C119TM00 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
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM140
2.4 Instruction Details
12
3-141Chapter 2 Instructions
Arithmetic flag
2009 No change2010 Turns ON when the contents of the internal register is "0" after
"LDA #00000" is executed. Turns OFF at other times.2011 No change2012 Turns ON when the DM or relay indirectly addressed with #TM is
out of range. "Indirect addressing" (p. 3-127)
Application of LDA and STA instructions Changing the counter setting value
Coding
Description
• In step a), contents of DM00100 is transferred to C001 via the internal register foruse as the C001 preset value, when 0000 is ON.
• In step b) , contents of #00200 is transferred to C001 via the internal register foruse as the C001 preset value, when 0002 is OFF.
• Although the C001 preset value is #09999 in the above example, any valueexcept #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 thepreset value, the current value will be changed to the preset value.Note 2: Do not specify "#00000" as the setting value for C001.
When 0000 is ON, #00100 is transferred as C001preset value.
When 0000 is OFF, #00200 is transferred as C001preset value.
When C001 current value equals to its preset value,0500 turns ON.
0000
C001 0500
b)
#00100LDA
C001STA
0000
0002
#00200LDA
C001STA
#09999C0010001
a)
Line No. Instruction Operand
0000 LD 0000
0001 LDA #00100
0002 CON
0003 STA C001
0004 LDB 0000
0005 LDA #00200
0006 CON
0007 STA C001
0008 LD 0002
0009 C 001 #09999 0001
0010 CON
0011 AND C001
0012 OUT 0500
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM141
2.4 Instruction Details
3-142
2
Chapter 2 Instructions
Transferring the current counter value to data memory (DM)
Coding
Description
In step a), the C010 current value is transferred via the internal register and storedinto DM0000, throughout the operation.
Transferring the contents of data memory as a setting value for a timer
Coding
Description
• In step a), contents of DM0010 is transferred to T002 via the internal register foruse as the T002 preset value, when 0002 is ON.
• In step b), contents of DM0011 is transferred to T002 via the internal register foruse as the T002 preset value, when 0002 is OFF.
• Although the preset value of T002 is #00010 in the above example, any valueexcept #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 valuesafter 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 thepreset value, the current value will be changed to the preset value.Note 2: Do not change the setting value of T002 to "#00000".
The C010 current value is transferred to DM0000.
0001
2002 C010LDA
DM0000STA
#09999C0100000
a)
Line No. Instruction Operand
0000 LDB 0001
0001 C 010 #099999 0000
0002 LD 2002
0003 LDA C010
0004 CON
0005 STA DM0000
0002
T002 0500
b)
DM0010LDA
T002STA
0002
0003
DM0011LDA
T002STA
#00010T002
a)
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
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM142
2.4 Instruction Details
12
3-143Chapter 2 Instructions
Outputting the input (ON/OFF status) of a basic unit directly to an expan-sion output unit
The ON/OFF status of a KV series basic unit is output to a KV-E16T(P) unit con-nected next to the basic unit.
Coding
Description
• The LDA instruction transfers the input (ON/OFF status) of the KV basic unit tothe 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 arefetched by the LDA instruction.
Note 2: Relays 0000 through 0415 are assigned as input relays, and 0500 through0915 are assigned as output relays. "1.3 Device Configuration" (p. 3-5)
2002 0000LDA
0600STA
Line No. Instruction Operand
0000 LD 2002
0001 LDA 0000
0002 CON
0003 STA 0600
1 : ON0 : OFF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
00
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
000
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
ON
ON
ON
ON
OFF
OFF
OFF
OFF
ON
ON
ON
ON
OFF
OFF
OFF
OFF
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
ON
ON
ON
ON
OFF
OFF
OFF
OFF
ON
ON
ON
ON
OFF
OFF
OFF
OFF
0600<STA>
0000<LDA>
Out-put
Input (KV basic unit)
(Internal register) 16-bit
Binary number
Output (KV-E16T(P))
Input
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM143
2.4 Instruction Details
3-144
2
Chapter 2 Instructions
When a BCD (2-digit) digital switch is connected to inputs 0000 through0007 and a toggle switch is connected to inputs 0008 through 0015
a) Use the value of the digital switch (2 digits) as the setting value of a counter(C001).
b) The current value of the counter (C001) is output to 0500 to 0515 using BCDoutput.
Coding
Description
• In example a), the LDA instruction reads the ON/OFF status of input relays 0000through 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, butcannot read the setting value.
Note 2: An STA instruction can change the setting value of a counter or a timer, butcannot change the current value.
(C001)<59>
20+ 21+ 23+ 24+ 25= 1 + 2 + 8 + 16 + 32 = 59
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
C001<STA>
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
<TBIN>
1
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
$00FF<ANDA>
1
0
0
1
1
0
1
0
0
1
1
1
0
0
0
0
ON
OFF
OFF
ON
ON
OFF
ON
OFF
OFF
ON
ON
ON
OFF
OFF
OFF
OFF
000
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
07000<LDA>
(Decimalnumber)
Digital switch
Reset inputProximitySW input
SW input
Internal register
Countersettingvalue
ON/OFFstatus istrans-ferred tointernalregister.
Only low-order 2digits isused.
BCDdata isconvertedinto binarydata.
Data istransferredas settingvalue ofcounter.
0008
0010 0000LDA
$00FFANDA TBIN
C001STA
#09999C0010009
0011 C001LDA TBCD
0500STAb)
a)
Line No. Instruction Operand0000 LDB 00080001 C 001 #09999 00090002 LD 00100003 LDA 00000004 CON0005 ANDA $00FF0006 CON0007 TBIN0008 CON0009 STA C0010010 LD 00110011 LDA C0010012 CON0013 TBCD0014 CON0015 STA 0500
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM144
2.4 Instruction Details
12
3-145Chapter 2 Instructions
Note 3: When an STA instruction is executed while the setting value of a counter ora timer is smaller than the current value, the current value is changed to be thesetting value.
First-in first-out (FIFO)
The data once fetched is written into DM0004,DM0003, …, to DM0000 in this order. At theunloading timing, data is fetched fromDM0004 and the contents of DM are shiftedto the next DM.
The OK/NG judgment and unloading timings can be used in asynchronous pro-grams.
Coding
DM0000
DM0001
DM0002
DM0003
DM0004
Unloadingtiming
OK/NGjudgment
Datashift
0000 1000 0001
DM0004LDA
$1111LDA
DM0000STA
$0000CMP
DM0003LDA
DM0004STA
$0000LDA
DM0003STA
1000
0001 $5555LDA
DM0000STA
DIFU
2002 2010
DM0003LDA
$0000CMP
DM0002LDA
DM0003STA
$0000LDA
DM0002STA
2002 2010
DM0002LDA
$0000CMP
DM0001LDA
DM0002STA
$0000LDA
DM0001STA
2002 2010
DM0001LDA
$0000CMP
DM0000LDA
DM0001STA
$0000LDA
DM0000STA
2002
$0000 DM0004STA
0002
2010
LDA
Contents of DM is compared with "$0000".When two values match, contents of oneprevious DM is transferred, then "$0000" istransferred to DM.
"$0000" is transferred to DMat unloading timing.
OK/NG judgmenttiming OK/NG judgment
"$1111" is transferred toDM0000.
"$5555" is transferred to DM0000.
Unloadingtiming
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 CON0003 AND 10000004 MPS0005 AND 00010006 LDA $11110007 CON0008 STA DM00000009 MPP0010 ANB 00010011 LDA $55550012 CON0013 STA DM00000014 LD 20020015 LDA DM00040016 CON0017 CMP $00000018 CON0019 AND 20100020 LDA DM00030021 CON0022 STA DM00040023 CON0024 LDA $00000025 CON0026 STA DM00030027 LD 00020028 LDA DM00030029 CON0030 CMP $00000031 CON0032 AND 20100033 LDA DM00020034 CON
Line No. Instruction Operand0035 STA DM00030036 CON0037 LDA $00000038 CON0039 STA DM00020040 LD 20020041 LDA DM00020042 CON0043 CMP $00000044 CON0045 AND 20100046 LDA DM00010047 CON0048 STA DM00020049 CON0050 LDA $00000051 CON0052 STA DM00010053 LD 20020054 LDA DM00010055 CON0056 CMP $00000057 CON0058 AND 20100059 LDA DM00000060 CON0061 STA DM00010062 CON0063 LDA $00000064 CON0065 STA DM00000066 LD 00020067 @LDA $00000068 CON0069 @STA DM0004
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM145
2.4 Instruction Details
3-146
2
Chapter 2 Instructions
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.
Comparing the current value of the counter and CMP value
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
CMP: Compare
@CMP: Compare
Compares contents of internal register withvalue specified by operand.@
#,$
FUN
FUN
LDB4
RES0
LDB4
RES0
nnnnCMP
nnnnCMP
2009 2010 2011
(Internal register) < (Operand) ON OFF OFF
(Internal register) = (Operand) OFF ON OFF
(Internal register) > (Operand) OFF OFF ON
0001
C001LDA
#01000CMP
0500
#09999
0003 C001
2) (=)
1) (<)
3) (>)
4) (≥)
2002
C001LDA
#02000CMP
2002
2009
05012010
05022011
05032009
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0012 OUT 0501
0001 C 001 #099999 0003 0013 MPP
0002 LD 2002 0014 AND 2011
0003 LDA C001 0015 OUT 0502
0004 CON 0016 LD 2002
0005 CMP #01000 0017 LDA C001
0006 CON 0018 CON
0007 MPS 0019 CMP #02000
0008 AND 2009 0020 CON
0009 OUT 0500 0021 ANB 2009
0010 MRD 0022 OUT 0503
0011 AND 2010
:
:
CMP / @CMP
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM146
2.4 Instruction Details
12
3-147Chapter 2 Instructions
Operands
Key operation
Arithmetic flag
2009 Turns ON when the result of the CMP operation is negative. Turns OFF atother times.
2010 Turns ON when the result of the CMP operation is "0". Turns OFF at othertimes.
2011 Turns ON when the result of the CMP operation is positive. Turns OFF atother times.
2012 The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p. 3-127)
Description
• As shown in the above example, the CMP instruction is used by connecting thespecial utility relay (2009 to 2011) immediately after the instruction.
• The operation of the CMP instruction varies depending on the contents of theinternal register.
Note: Special utility relays 2009 to 2011 are used as arithmetic flags. The functionvaries depending on the execution of other arithmetic instructions.
Tips
An operand is compared with the internal register using the following program.
When the internal register is assumed as "a" and the operand is "b" such as , thestatuses of the special utility relays are as follows:
@#,$ FUN
FUNLDB
4RES
0ENTR-SRCH
ENTR-SRCH
Operand
#00999CMP
DM0000LDA
2009
aLDA CMP
b
2009a < b, a ≤ b, a = b, a ≥ b, a > b
2011 2010 2009 2011
CMP / @CMP
Visual KV KV-300 KV-10/16 KV-24/40/80
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999TM00 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
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM147
2.4 Instruction Details
3-148
2
Chapter 2 Instructions
2009
2010
2011
2002
0502
0501
0500DM0000<#01000
DM0000=#01000
DM0000>#01000
DM0000LDA
#01000CMP
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0007 MRD0001 LDA DM0000 0008 AND 20100002 CON 0009 OUT 05010003 CMP #01000 0010 MPP0004 MPS 0011 AND 20110005 AND 2009 0012 OUT 05020006 OUT 0500
Application of CMP instruction Multi-level counter
Coding
DescriptionThe following outputs are provided according to the current value of the counter.
(Current value) (Output)0000 to 0999 0500 turns ON.1000 to 1999 0501 turns ON.2000 to 2999 0502 turns ON.
When comparing values with no specific range
Turns ON 0500 when the DM0000 value is smaller than the CMP value.Turns ON 0501 when the DM0000 value is equal to the CMP value.Turns ON 0502 when the DM0000 value is greater than the CMP value.
Coding
0001
C000LDA
#00999CMP
#01999CMP
#02999CMP
0500
#09999
0000C000
2002 2011
05012011
05022011
0500
0500 0501
Line No. Instruction Operand0000 LDB 00010001 C 000 #099999
00000002 LD 20020003 LDA C0000004 CON0005 MPS0006 CMP #009990007 CON0008 ANB 20110009 OUT 05000010 MRD0011 CMP #019990012 CON0013 ANB 20110014 ANB 05000015 OUT 05010016 MPP0017 CMP #029990018 CON0019 ANB 20110020 ANB 05000021 ANB 05010022 OUT 0502
CMP / @CMP
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM148
2.4 Instruction Details
12
3-149Chapter 2 Instructions
Setting the upper/lower limitTurns ON 0500 when the C001 value is 1000 or less.Turns ON 0501 when the C001 value is 2000 or more.
Coding
Changing the CMP setting value
Compares the current value of counter C000 with the CMP setting value. The settingvalue of the CMP instruction is specified with the digital trimmer (TMIN0). Thefollowing example changes the setting value to the range from "0" through "100".The upper limit of the digital trimmer is set to "100".
0500 turns ON when the current value of C000 is smaller than the CMP settingvalue.0501 turns ON when the current value of C000 is equal to or greater than the CMPsetting value.
Coding
2011
2009
0001
2002
2002
C001≤#01000
C001≥#02000
C001LDA
C001LDA
#01000CMP
#02000CMP
0500
0501
#09999
0000 C001
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0001 0008 OUT 05000001 C 001 #09999 0000 0009 LD 20020002 LD 2002 0010 LDA C0010003 LDA C001 0011 CON0004 CON 0012 CMP #020000005 CMP #01000 0013 CON0006 CON 0014 ANB 20090007 ANB 2011 0015 OUT 0501
Sets range of TMIN from 0 to 100.
2009
2009
0001
2002
2002
C000LDA
DM0000CMP
DM0000STA
0TMIN
0500
0501
#09999
00000C000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0011 C 000 #09999 00000001 TMIN 0 0012 LD 020020002 CON 0013 LDA C0000003 ADD #00001 0014 CON0004 CON 0015 CMP DM00000005 MUL #00004 0016 MPS0006 CON 0017 AND 20090007 DIV #00010 0018 OUT 05000008 CON 0019 MPP0009 STA DM0000 0020 ANB 20090010 LDB 0001 0021 OUT 0501
CMP / @CMP
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM149
2.4 Instruction Details
3-150
2
Chapter 2 Instructions
ADD, SUB, MUL, and DIV allow arithmetic instructions between the contents ofinternal register and the value specified by the operand.
Note: Arithmetic instructions use binary numbers (BIN). Therefore, the contents ofthe internal register used for the arithmetic instruction must be BIN data. Use theTBIN instruction to convert BCD data into BIN data.
Operands
Key operation
ADD: Add
@ADD: Add
SUB: Subtract
@SUB: Subtract
MUL: Multiply
@MUL: Multiply
DIV: Divide
@DIV: Divide
Adds value specified by operand to contents ofinternal register, and inputs result back to sameinternal register.@
#,$
FUN
FUN
@#,$
FUN
FUN
@#,$
FUN
FUN
@#,$
FUN
FUN
LDB4
SET1
SET1
RES0
RES0
AND8
ANL2
ORB6
LDB4
SET1
SET1
RES0
RES0
AND8
ANL2
ORB6
nnnnDIV
nnnnDIV
nnnnMUL
nnnnMUL
nnnnSUB
nnnnSUB
nnnnADD
nnnnADD
ADD
SUB
MUL
DIV
(#XXXXX)
($XXXX)
DM0000 to DM1999TM00 to TM31#TM00 to #TM29
@#,$
FUN
FUN
@#,$ FUN
FUN
@#,$
FUN
FUN
@#,$
FUN
FUN
LDB4
SET1
SET1
RES0
RES0
ANL2
ORB6
AND8
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
Inte
rnal
reg
iste
r
Ope
rand
Cons
tant
sD
ata
mem
orie
s
Hexadecimal
ResultArithmetic operation
Decimal
Inte
rnal
reg
iste
r
:
:
:
:
:
:
:
:
Subtracts value specified by operand fromcontents of internal register, and inputs resultsback to same register.
Multiplies contents of internal register by valuespecified by operand, and inputs result back tosame register.
Divides contents of internal register by valuespecified by operand, and inputs result back tosame register.
ADD / @ADD / SUB / @SUB / MUL / @MUL / DIV / @DIV
Visual KV KV-300 KV-10/16 KV-24/40/80
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999TM00 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
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM150
2.4 Instruction Details
12
3-151Chapter 2 Instructions
ADD (Addition)
Coding
Description
• The ADD instruction adds the operand value to the contents of the internalregister and inputs the result back to the internal register.
• In the above example, "#00100" is added to the contents of DM0000 and theresult is stored in DM0001.
• When the contents of DM0000 is "#00100", for example, "#00200" is stored inDM0001.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 theinternal 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.
Tips
Solution when operation result overflows 16 bits
DM0000 + DM0001 = DM0003 (High-order 16 bits), DM0002 (Low-order 16 bits)DM0000 and DM0001 must be 16 bits or less.
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 ADDoperation. Turns OFF at other times.
2011 No change2012 The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p. 3-127)
DM0000LDA
#00100ADD
DM0001STA
2002
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 ADD #00100
0004 CON
0005 STA DM0001
Example:Internal register 1
1
= $FFFF1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0+ = $00020 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 = $0001
2009
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Operand
Overflow
Specialutility relay
Input back internal register Result
DM0000LDA
DM0001ADD
DM0002STA
#00000LDA
DM0003STA
DM0002STA
#00001LDA
DM0003STA
2002 2009
2009
ADD / @ADD
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM151
2.4 Instruction Details
3-152
2
Chapter 2 Instructions
Application of ADD instruction Total count
Writes the total count of counters C001 to C003 into DM0100. The total count mustbe within #65535.
Coding
Writes C001 current value into DM0001.C001LDA
DM0001STA
0000
C002LDA
DM0002STA
0000
C003LDA
DM0003STA
0000
DM0002ADD
DM0001LDA
DM0003ADD
DM0100STA
2002
#09999C003
#09999C0010001
0002
#09999C002
0003
Writes C002 current value into DM0002.
Writes C003 current value into DM0003.
Writes total count (DM0001 + DM0002 +DM0003) into DM100.
Line No. Instruction Operand
0000 LDB 0001
0001 C 010 #099999 0000
0002 CON
0003 LDA C001
0004 CON
0005 STA DM0001
0006 LDB 0000
0007 C 002 #099999 0002
0008 CON
0009 LDA C002
0010 CON
0011 STA DM0002
0012 LDB 0000
0013 C 003 #099999 0003
0014 CON
0015 LDA C003
0016 CON
0017 STA DM0003
0018 LD 2002
0019 LDA DM0001
0020 CON
0021 ADD DM0002
0022 CON
0023 ADD DM0003
0024 CON
0025 STA DM0100
ADD / @ADD
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM152
2.4 Instruction Details
12
3-153Chapter 2 Instructions
SUB (Subtraction)
Coding
Description
• The SUB instruction subtracts the operand value from the contents of the internalregister and inputs the result back into the internal register.
• In the above example, "#00100" is subtracted from the contents of DM0000 andthe result is stored in DM0001.
• When the contents of DM0000 is "#00150", for example, "#00050" is stored inDM0001.DM0000 (#00150) – #00100 DM0001 (#00050)
Note 1: When the operation result is a negative value (-), the 2's complement valueis also stored in the internal register.Special utility relay 2009 turns ON.
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
When DM0000 is "#10" and DM0001 is "#30", "#20" is stored in DM0003.
Arithmetic flag
2009 Turns ON when the result of a SUB operation is negative. Turns OFF atother times.
2010 Turns ON when the contents of the internal register is "0" after a SUBoperation. Turns OFF at other times.
2011 Turns ON when the result of a SUB operation is positive. Turns OFF at othertimes.
2012 The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p. 3-127)
DM0000LDA
#00100SUB
DM0001STA
2002
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 SUB #00100
0004 CON
0005 STA DM0001
0
1
= $00010 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1- = $FFFF1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 = $00020 0 0 0 0 0 0 0 0 0 0 0 0 1 0
20092's complement is stored.
Internal register
Operand
Underflow
DM0000LDA
DM0001SUB
DM0002STA
COM#0001ADD
DM0003STA
2002 2009
2009
DM0000 - DM0001 =
(Stores positive value)
(Stores negative value)
Absolute valueis stored.
Positive value DM0002
Negative value DM0003
SUB / @SUB
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM153
2.4 Instruction Details
3-154
2
Chapter 2 Instructions
Application of SUB instruction Comparing absolute values
Compares the DM0000 value to the DM0001 value and turns ON 0500 when thedifference between the two absolute values is greater than 5.
Coding
2002 20092009DM0000LDA
DM0001SUB
#0005CMP
1001
1000
2009 DM0001LDA
DM0000SUB
1000
2009#00005CMP
1001
0500
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 SUB DM0001
0004 MPS
0005 ANB 2009
0006 CMP #00005
0007 CON
0008 ANB 2009
0009 OUT 1000
0010 MPP
0011 AND 2009
0012 LDA DM0001
0013 CON
0014 SUB DM0000
0015 CON
0016 CMP #00005
0017 CON
0018 ANB 2009
0019 OUT 1001
0020 LD 1000
0021 OR 1001
0022 OUT 0500
SUB / @SUB
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM154
2.4 Instruction Details
12
3-155Chapter 2 Instructions
MUL (Multiplication)
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" andthe result is stored in DM0001.
• When the contents of DM0000 is "#00200", for example, "#20000" is stored inDM0001.DM0000 (#00200) x #00100→DM0001 (#20000)
Note 1: An overflow occurs when the operation result exceeds 16 bits (#65535). Insuch a case, only the data of the low-order 16 bits are stored in the internal register,and the overflow data of the high-order 16 bits is stored in TM00. (The data of thehigh-order 16 bits is always stored in TM00.)
Note 2: When an overflow occurs, special utility relay 2009 turns ON.
Tips
Solution when operation result overflows 16 bits
DM0000 x DM0001 = DM0003 (High-order 16 bits) – DM0002 (Low-order 16 bits)The operation result must be 32 bits or less.
Arithmetic flag
2009 Turns ON when the result of a MUL operation exceeds 16 bits. Turns OFF atother times.
2010 Turns ON when all 32 bits are "0" after a MUL operation. Turns OFF at othertimes.
2011 No change2012 The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p. 3-127)
DM0000LDA
#00100MUL
DM0001STA
2002
Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 MUL #00100
0004 CON
0005 STA DM0001
F
(TM00)
F F F
0 0 0 2
F F F F0 0 0 1
(Internal register)
Internal register
Operand Hexadecimal number
2002 DM0000LDA
DM0001MUL
DM0002STA
TM00LDA
DM0003STA
MUL / @MUL
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM155
2.4 Instruction Details
3-156
2
Chapter 2 Instructions
2002 DM0001LDA
TM00STA
DM0000LDA
#00100DIV
DM0002STA
TM00LDA
DM0003STA
TM01LDA
DM0004STA
Line No. Instruction Operand0000 LD 20020001 LDA DM00010002 CON0003 STA TM000004 CON0005 LDA DM00000006 CON0007 DIV #001000008 CON0009 STA DM00020010 CON0011 LDA TM000012 CON0013 STA DM00030014 CON0015 LDA TM010016 CON0017 STA DM0004
Application of MUL instruction Multiplying the counter current value by the DM value
Multiplies the counter current value by the DM0000 value and writes the high-order16 bits of the product into DM0101 and low-order 16 bits of the product intoDM0100.
Coding
DIV (Division)
Coding
0001
C001LDA
DM0000MUL
DM0100STA
TM00LDA
DM0101STA
2002
#09999
0000C001
Line No. Instruction Operand0000 LDB 00010001 C 001 #099999 00000002 LD 20020003 LDA C0010004 CON0005 MUL DM00000006 CON0007 STA DM01000008 CON0009 LDA TM000010 CON0011 STA DM0101
High-order Low-order Low-order High-order Remainder
MUL / @MUL / DIV / @DIV
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM156
2.4 Instruction Details
12
3-157Chapter 2 Instructions
Arithmetic flag
2009 No change2010 Turns ON when all 32 bits are "0" after a DIV operation. Turns OFF at other
times.2011 No change2012 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 16bits 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 thesame internal register. The remainder is stored in TM01.
Note 1: When data of 16 bits or less is divided by the operand value, the contents ofTM00 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 alsoused for the operation.
Tips
Solution when data of 16 bits or less is divided
TM00
TM00 TM01
DM0000DM0001
DM0002DM0003 DM0004
#00100
Quotient
Example
Low-order 16 bits
Remainder (16 bits)
Internal register Operand
High-order 16 bits
Internal register
Remainder (16 bits)Low-order 16 bitsHigh-order 16 bits
Low-order 16 bitsHigh-order 16 bits
Low-order 16 bitsHigh-order 16 bits
Quotient
02002 #00000LDA
TM00STA
DM0000LDA
DM0001DIV
DM0002STA
TM01LDA
DM0003STA
TM00 • DM0000 = TM00 • DM0002 ••• DM0003High-order16 bits
Quotient
RemainderLow-order16 bits
High-order16 bits
Low-order16 bits
DIV / @DIV
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM157
2.4 Instruction Details
3-158
2
Chapter 2 Instructions
Application of DIV instruction Total count average
Outputs the average of 3 counter values in 4-digit BCD.(C001 + C002 + C003) ÷ 3 BCD output valueThe BCD value is output to 500 to 515.
Coding
C001LDA
DM0001STA
0000
C002LDA
DM0002STA
0000
C003LDA
DM0003STA
0000
DM0001LDA
DM0002ADD
DM0003ADD
2002
#09999C0030003
#09999C001
#099990001
0002C002
(DM0001+DM0002+DM0003)
TM00STA
#00000LDA
2002
#00003DIV TBCD
0500STA
2002÷ 3 Output to 0500 to 0515 in 4-digit BCD.
Writes the C001 current value into DM0001.
Writes the C002 current value into DM0002.
Writes the C003 current value into DM0003.
Line No. Instruction Operand
0000 LDB 0000
0001 C 001 #099999 0001
0002 CON
0003 LDA C001
0004 CON
0005 STA DM0001
0006 LDB 0000
0007 C 002 #099999 0002
0008 CON
0009 LDA C002
0010 CON
0011 STA DM0002
0012 LDB 0000
0013 C 003 #099999 0003
0014 CON
0015 LDA C003
0016 CON
0017 STA DM0003
0018 LD 2002
0019 LDA DM0001
0020 CON
0021 ADD DM0002
0022 CON
0023 ADD DM0003
0024 LD 2002
0025 DIV #0003
0026 CON
0027 TBCD
0028 CON
0029 STA 500
DIV / @DIV
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM158
2.4 Instruction Details
12
3-159Chapter 2 Instructions
Example
Coding
Description
• The contents of DM0000 are transferred to the internal register when input relay0000 is ON.
• The contents of the internal register (DM0000) and the value specified by theoperand ($00FF) are ANDed for each bit and the result (logical product) is inputback to the same register.
• When the operation result is "0", special utility relay 2010 turns ON.• The contents of the internal register are transferred to DM0001.• The following shows the case when DM0000 is "$F0F0".
Operands
Key operation
ANDA:
@ANDA:
ANDs contents of internal register andvalue specified by operand for each of16 bits, and inputs result back to sameregister.
AND A(Logical product) @
#,$
FUN
FUN SET1
RES0
SET1
RES0
nnnnANDA
nnnnANDA
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 ANDA $00FF0004 CON0005 STA DM0001
0000 DM0000LDA
$00FFANDA
DM0001STA
(DM0000) ^ ($00FF) = (DM0001)Logical product
Contents of DM0000are transferred to theinternal register.
1
AND
1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0
DM0000LDA
$00FFANDA
DM0001STA
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Only when both bits of theinternal register and theoperand are "1", will the logicalproduct be "1".
@#,$ FUN
FUNSET
1RES
0ENTR-SRCH
ENTR-SRCH
Operand
These values are ANDed foreach bit to obtain logical product.
The result is transferredto DM0001.
Internalregister
Operand ($F0F0)
Internalregister
AND (Logical product)truth table (Result)
:
:
DM0000 ($F0F0)
($F0F0)
($F0F0)
DM0001 ($00F0)
Internal Operand Internalregister register
1 1 11 0 00 1 00 0 0
ANDA / @ANDA
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 17915 0000 to 2915 0000 to 6915DM0000 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
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM159
2.4 Instruction Details
3-160
2
Chapter 2 Instructions
Arithmetic flag
2009 No change2010 Turns ON when the internal register is "0" after an ANDA operation.
Turns OFF at other times.2011 No change2012 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 0100to 0103, while ignoring other inputsOnly one-digit data of the BCD digital switch is transferred as the setting value of thefetching counter (C004).Other inputs (0104 to 0115) are ignored.
Application of ANDA instruction
Fetch input data separatelySets the low-order 2 digits of the BCD digital switch (7000 to 7007) to counter C000and the high-order 2 digits (7008 to 7015) to timer T001.
Coding
0004
2002
#00300C0040005
0100LDA
$000FANDA TBIN
C004STA
7000LDA
$00FFANDA TBIN
C000STA
2002
TBIN#08SRA
$FF00ANDA
7000LDA
T001STA
2002
0001
0001
#09999C0000000
#09999T001
Line No. Instruction Operand0000 LD 20020001 LDA 70000002 CON0003 ANDA $00FF0004 CON0005 TBIN0006 CON0007 STA C0000008 LD 20020009 LDA 70000010 CON0011 ANDA $FF000012 CON0013 SRA #080014 CON0015 TBIN0016 CON0017 STA T0010018 LDB 00010019 C 000 #09999 00000020 LDB 00010021 T 001 #09999
Converts data of 7000 to 7007 to BIN andwrites it into C000.
Shifts data to right by 8 bits, converts it to BIN,and writes it into T001.
Sets C000.
Sets T001.
ANDA / @ANDA
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM160
2.4 Instruction Details
12
3-161Chapter 2 Instructions
Example
Coding
Description
• The contents of DM0000 are transferred to the internal register when input relay0000 is ON.
• The contents of the internal register (DM0000) and the value specified by theoperand ($00FF) are ORed for each bit and the result (logical sum) is input backto the same register.
• When the operation result is "0", special utility relay 2010 turns ON.• The contents of the internal register are transferred to DM0001.• The following shows the case when DM0000 is "$F0F0".
Operands
Key operation
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 ORA $00FF0004 CON0005 STA DM0001
ORA:
@ORA:
ORs contents of internal register and valuespecified by operand for each of 16 bits,and inputs result back to same register.
Or A(Logical sum) @
#,$
FUN
FUN SET1
ORL3
SET1
ORL3
nnnnORA
nnnnORA
1
OR
1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1
1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1
DM0000LDA
$00FFORA
DM0001STA
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Contents of DM0000 aretransferred to the internalregister.
Only when both bits of theinternal register and theoperand are "0", will the logicalsum be "0".
These values are ORed foreach bit to obtain logical sum.
The result is transferredto DM0001.
Internalregister
Operand ($00FF)
Internalregister
OR (Logical sum)truth table (Result)
@#,$ FUN
FUNSET
1ORL
3ENTR-SRCH
ENTR-SRCH
Operand
0000 DM0000LDA
$00FFORA
DM0001STA
(DM0000) U ($00FF) = (DM0001)
Logical sum
:
:
DM000 ($F0F0)
($F0F0)
($F0FF)
InternalOperand
Internalregister register
1 1 1
1 0 1
0 1 1
0 0 0
ORA / @ORA
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 0000 to 0009 0000 to 2915 0000 to 6915DM0000 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
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM161
2.4 Instruction Details
3-162
2
Chapter 2 Instructions
0000
TBCDC000LDA
0500STA
DM0000ORA
$00FFANDA
$FF00ANDA
0500LDA
DM0000STA
2002
2002
2002
#00099C0000001
Sets C000.
Writes data of 0008 to 0015 into DM0000.
ORs the data in the internal register and the DM0000data and sends the ORed data to 0500 to 0515.
2002 0100LDA
$000FANDA
DM0000STA
0200LDA
$000FANDA
#04SLA
DM0000ORA
C004STA
#00300
C0040005
TBIN
0004
Converts the current value of C000 to BCD and retainsthe low-order 2 digits of BCD in the internal register.
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0000 0009 LDA C0000001 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
ORA / @ORA
Arithmetic flag
2009 No change2010 Turns ON when the internal register is "0" after an ORA operation. Turns
OFF at other times.2011 No change2012 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 0100to 0103 for the first digit and 0200 to 0203 for the second digit) separatelyFetches the two-digit data of the BCD digital switch, which are separated into thefirst digit (0100 to 0103) and the second digit (0200 to 0203), and transfers thevalues as the setting value of a counter (C004).
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 datato output relays 0500 to 0507.However, retain ON/OFF of 0508 to 0515 which are loaded.
Coding
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM162
2.4 Instruction Details
12
3-163Chapter 2 Instructions
0000
ANDA0100LDA
DM0000ORA TBIN
C001STA
#04SLA
$000F
$000F
ANDA0000LDA
DM0000STA
2002
2002
2002
#00099C0000001
Line No. Instruction Operand
0000 LDB 0001
0001 C 001 #00099 0001
0002 LD 2002
0003 LDA 0000
0004 CON
0005 ANDA $000F
0006 CON
0007 STA DM0000
0008 LD 2002
0009 LDA 0100
0010 CON
0011 ANDA $000F
0012 LD 2002
0013 SLA #04
0014 CON
0015 ORA DM0000
0016 CON
0017 TBIN
0018 CON
0019 STA C001
Sets C001.
Writes data of 7000 to 7003 into DM0000.
Writes data of 8000 to 8003 into internal regis-ter.
ORA / @ORA
Separate input of 2-digit BCDFetches only 2 digits of the BCD digital switch (0000 to 0003 for the 1st digit, 0100to 0103 for the 2nd digit) and sets it as the counter value.
Coding
ORs content of internal register which is shiftedto left by four bits and data of 7000 to 7003,converts ORed data into BIN, and write it intoC001.
KVNKA Chap 02_4cP.p65 08.3.11, 0:02 PM163
2.4 Instruction Details
3-164
2
Chapter 2 Instructions
Example
Coding
Description
• The contents of DM0000 is transferred to the internal register when input relay0000 is ON.
• The contents of the internal register (DM0000) and the value specified by theoperand ($00FF) are EORed (exclusive OR) for each bit and the result is inputback 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".
Operands
Key operation
EORA:@EORA:
EXCLUSIVE ORs contents of internalregister and operand for each of 16 bits,and inputs result back to same register.
Exclusive Or A(Exclusivelogical sum)
@#,$
FUN
FUN SET1
ANB5
SET1
ANB5
nnnnEORA
nnnnEORA
0000 DM0000LDA
$00FFEORA
DM0001STA
(DM0000) ($00FF) = (DM0001)UExclusivelogical sum
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 EORA $00FF0004 CON0005 STA DM0001
1
EORA
1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
DM0000LDA
$00FFEORA
DM0001STA
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Contents of DM0000 aretransferred to the internalregister.
Only when the bits of theinternal register and theoperand have different values,will the exclusive logical sumbe "1".
These values are EORed for eachbit to obtain exclusive OR value.
The result is trans-ferred to DM0001.
Internalregister
Operand ($00FF)
Internalregister
EOR (Exclusive OR)truth table (Result)
:
:
@#,$ FUN
FUNSET
1ANB
5ENTR-SRCH
ENTR-SRCH
Operand
Internal Internalregister register
1 1 0
1 0 1
0 1 1
0 0 0
DM0000 ($F0F0)
($F0F0)
($F00F)
DM0000 ($F00F)
EORA / @EORA
Visual KV KV-300 KV-10/16 KV-24/40/80
0000 to 17915 00000 to 0009 0000 to 2915 0000 to 6915DM0000 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
Operand
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM164
2.4 Instruction Details
12
3-165Chapter 2 Instructions
Arithmetic flag
2009 No change2010 Turns ON when the internal register is "0" after an EORA operation. Turns
OFF at other times.2011 No change2012 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 aconstant ($0F0F)
When the values match, special internal relay 2010 turns ON and output relay 0500turns 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 through0011 are ON.
Application of EORA instruction
Judgment of matching data
Turns ON 0500 when the ON/OFF statuses of input relays 0100 to 0107 match theDM0000 setting value.
Coding
When 2010 is ON, the two values match.When 2010 is OFF, the two values do not match.
2002 2010 0500$0F0FEORA
0000LDA
STA$00AA DM0000LDA
$00FFANDA
0100LDA
DM0000EORA
2008
2002 2010 0500
1
ANDA
0100 to 01150 1 1 1 0 1 1 1 0 1 1 1 0 1 1
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1
0 DM00000 0 0 0 0 0 0 1 0 1 0 1 0 1 0
0
$BBBB
$00FF
$00BB
$00AA
$0011 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
EORA
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Operand
Internal register
Internal register 2010 is OFF. When thevalue of internal register is 0000, 2010 turns ON.
Judges match between the operand and thedata of 0100 to 0107.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0007 ANDA $00FF0001 LDA $00AA 0008 CON0002 CON 0009 EORA DM00000003 STA DM0000 0010 CON0004 LD 2002 0011 AND 20100005 LDA 0100 0012 OUT 05000006 CON
EORA / @EORA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM165
2.4 Instruction Details
3-166
2
Chapter 2 Instructions
Example
Coding
Operands
#01 to #16
Key operation
Arithmetic flag
2009 Turns ON when "1" enters 2009 after an SRA/SLA operation. Turns OFF atother times.
2010 Turns ON when the internal register is "0" after an SRA/SLA operation.Turns OFF at other times.
2011 No change2012 No change
SRA: Shift Right A@SRA: Shift Right ASLA: Shift Left A@SLA: Shift Left A
Moves contents of internal registerserially right by value specified by oper-and.
Moves contents of internal registerserially left by value specified by operand.
@#,$
FUN
FUN
@#,$
FUN
FUN
LDB4
LDB4
SET1
RES0
LDB4
LDB4
SET1
RES0
#ddSRA
#ddSRA
#ddSLA
#ddSLA
0000 DM0000LDA
#05SRA
DM0001STA
0001 DM0010LDA
#10SLA
DM0011STA
Line No. Instruction Operand0000 LD 0000
0001 LDA DM0000
0002 CON
0003 SRA #05
0004 CON
0005 STA DM0001
0006 LD 0001
0007 LDA DM0010
0008 CON
0009 SLA #10
0010 CON
0011 STA DM0011
:
::
:
@#,$ FUN
FUN
@#,$ FUN
FUNLDB
4
LDB4
SET1
RES0
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
SRA / @SRA / SLA / @SLA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM166
2.4 Instruction Details
12
3-167Chapter 2 Instructions
Description
• Operations using the SRA instruction
When input relay 0000 is ON, the contents of DM0000 are transferred to the internalregister and shifted serially right by the operand value (5). The operation result iswritten 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) everyscan time while input relay 0000 is ON.Use @SRA, a differentiation type instruction, to execute the instruction only oncewhen input relay 0000 turns ON.
• Operation using the SLA instruction
When input relay 0001 is ON, the contents of DM0000 are transferred to the internalregister and shifted serially left by the operand value (10). The operation result iswritten into DM0011. The contents of D15 are shifted to carry bit 2009.In the above example, the contents shift to the left by the operand value (10) everyscan time while input relay 0001 is ON.Use @SLA, a differentiation type instruction, to execute the instruction only oncewhen input relay 0001 turns ON.
Note: Special utility relay 2009 may turn ON in accordance with the operationresults; however, it changes immediately when another operation is executed.
Carry
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 00
2009
0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1 0
2009
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Carry
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 00
2009
1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 01
2009
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Carry
Carry
SRA / @SRA / SLA / @SLA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM167
2.4 Instruction Details
3-168
2
Chapter 2 Instructions
Application of SRA/SLA instructions Fetching four-digit data of the BCD digital switch (inputs 0004 through 0011
for low-order 2 digits and 0100 through 0107 for high-order 2 digits) totransfer them as a counter setting value
Separate input of BCDFetches only 2 digits of the BCD digital switch (0112 to 0115 for the 1st digit, 0000 to0003 for the 2nd digit) and sets it as the counter value.
Coding
2002 0000LDA
$0FF0ANDA
#04SRA
DM0000STA
0100LDA
$00FFANDA
#08SLA
DM0000ORA
C004STA
0001 #09999
C0040000
Line No. Instruction Operand0000 LD 00010001 C 001 #00099 00000002 LD 20020003 LDA 01000004 CON0005 ANDA $F0000006 LD 20020007 SRA #120008 CON0009 STA DM00000010 LD 20020011 LDA 00000012 CON0013 ANDA $000F0014 LD 20020015 SLA #040016 CON0017 ORA DM00000018 LD 20020019 TBIN0020 CON0021 STA C001
0001
STA#12SRA
$000FANDA
0000LDA
$F000
DM0000
ANDA0100LDA
2002
2002
2002
#00099C0010000
DM0000ORA
#04SLA
2002
C001STATBIN
2002Converts the data of internal register to BIN data and writes it intoC001.
Sets C001.
Sends the data of 0112 to 0115 to internal register.
Shifts the value of internal register to right by 12 bits and writes itinto DM0000.
Sends the data of 0000 to 0003 to internal register.
Shifts the data of internal register to left by 4 bits, ORs the internalregister data and the data of DM0000, and sends the ORed data tothe internal register.
SRA / @SRA / SLA / @SLA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM168
2.4 Instruction Details
12
3-169Chapter 2 Instructions
Example
Coding
Operands
#01 to #16
Key operation
Arithmetic flag
2009 Turns ON when "1" enters 2009 after an RRA/RLA operation. TurnsOFF 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 instructionWhen input relay 0000 is ON, the contents of DM0000 are transferred to the internalregister. The contents of the internal register and carry (2009) are rotated clockwiseby the operand value.In the above example, the contents are rotated clockwise every scan time whileinput relay 0000 is ON.
RRA: Rotate Right A
@RRA: Rotate Right A
RLA: Rotate Left A
@RLA: Rotate Left A
Rotates contents of internal register andcarry (2009) clockwise by operand value.
Rotates contents of internal register andcarry (2009) counterclockwise by operandvalue.
@#,$
FUN
FUN
@#,$
FUN
FUN
LD7
ANB5
ORL3
ORL3
LD7
ANB5
ORL3
ORL3
#ddRRA
#ddRRA
#ddRLA
#ddRLA
0000 DM0000LDA
#01RRA
DM0001STA
0001 DM0010LDA
#04RLA
DM0011STA
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 RRA #010004 CON0005 STA DM00010006 LD 00010007 LDA DM00100008 CON0009 RLA #040010 CON0011 STA DM0011
@#,$ FUN
FUN
@#,$ FUN
FUNLD7
ANB5
ORL3
ORL3
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
:
:
:
:
RRA / @RRA / RLA / @RLA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM169
2.4 Instruction Details
3-170
2
Chapter 2 Instructions
Writes the TM10 data into DM0000, and then writes#00000 to TM10.
#01RRA
2002
2002 2009
TM10STA
#00000DM0000TM10LDALDA
TM10INC
0000LDA
STA2002
NEXT
FOR#00016
Writes the data of 0000 to 0015 into internal register.
Executes FOR-NEXT instruction 16 times.
Shifts the data including carry (2009) to right, andincrements TM10 by 1 when 2009 is ON.
Use @RRA, a differentiation type instruction, to execute the instruction only oncewhen input relay 0000 turns ON.
• Operation using the RLA instructionWhen input relay 0001 is ON, the contents of DM0000 are transferred to the internalregister. The contents of the internal register and carry (2009) are rotated counter-clockwise by the operand value.In the example above, the contents are rotated counterclockwise every scan timewhile input relay 0001 is ON.Use @RLA, a differentiation type instruction, to execute the instruction only oncewhen input relay 0001 turns ON.
Note: Special utility relay 2009 may turn ON in accordance with the operationresults; however, it changes immediately when another operation is executed.
Application of RRA/RLA instructions Error input count
Writes the number of error detection sensors, which are connected to input relays(0000 to 0015) and turn ON, into DM0000.
Coding
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 00
2009
0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 00
2009
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Carry
Carry
1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 0
2009
1 0 0 0 1 1 1 0 0 1 0 0 0 1 1 0 0
2009
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Carry
Carry
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0009 LD 2002
0001 LDA 0000 0010 LDA TM10
0002 FOR #00016 0011 CON
0003 LD 02002 0012 STA DM0000
0004 RRA #01 0013 CON
0005 CON 0014 LDA #00000
0006 AND 2009 0015 CON
0007 INC TM10 0016 STA TM10
0008 NEXT
SRA / @SRA / SLA / @SLA
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM170
2.4 Instruction Details
12
3-171Chapter 2 Instructions
Example
Coding
Description
• Each time input relay 0000 turns from OFF to ON, the contents of DM0000 aretransferred to the internal register. The COM instruction inverts the status of eachbit 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".
Note:
When an every-scan type COM instruction is used, the status of bits are invertedevery scan time while input relay 0000 is ON.
Use @COM, a differentiation type instruction, to execute the instruction only oncewhen input relay 0000 turns ON, as shown in the example.
Operands
Key operation
Arithmetic flag
2009 No change2010 Turns ON when the internal register is "0" after a COM operation. Turns
OFF at other times.2011 No change2012 No change
COM:@COM:
Inverts contents of each bit in internalregister.@
#,$
FUN
FUN
RES0
ANB5
RES0
ANB5
COM
COM
Complement(Bit inversion)
0000COM
DM0001STA
DM0000LDA
Line No. Instruction Operand0000 LD 00000001 @LDA DM00000002 CON0003 @COM0004 CON0005 @STA DM0001
0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1
DM0001
DM0000 = $5F5F
= $A0A01 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
COM instructionBit inversion
0000 DM0000LDA COM
DM0001STA
@#,$
FUN
FUN
RES0
ANB5
ENTR-SRCH
ENTR-SRCH
:
:
COM / @COM
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM171
2.4 Instruction Details
3-172
2
Chapter 2 Instructions
Example
Coding
DescriptionOperation using the @INC instructionEvery time input relay 0000 turns ON, "1" is added to the contents of the datamemory specified by the operand. The result is then input back to the same datamemory. (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", theresult of the addition is "#00000" so that special utility relay 2009 turns ON.
Operation using the @DEC instructionEvery time input relay 0000 turns ON, "1" is subtracted from the contents of the datamemory specified by the operand. The result is then input back to the same datamemory. (In the above example, "1" is subtracted from the contents of DM0001.DM0001 - 1 DM0001) When the data memory specified by the operand is"#00001", the result of the subtraction is "#00000" so that special utility relay 2010turns ON.When the specified data memory is "00000", the result of the subtraction is "#65535($FFFF)" so that special utility relay 2009 turns ON.
Operands
INC: Increment Memory
@INC: Increment Memory
DEC: Decrement Memory
@DEC: Decrement Memory
Adds 1 to contents of data memoryspecified by operand.
Subtracts 1 from contents of datamemory specified by operand.
@#,$
FUN
FUN
@#,$
FUN
FUN
LD7
SET1
SET1
RES0
LD7
RES0
OR9
OR9
nnnnINC
nnnnINC
nnnnDEC
nnnnDEC
0000 DM0000INC
DM0001DEC
Line No. Instruction Operand0000 LD 00000001 @INC DM00000002 @DEC DM0001
Contents of data memory specified by operand
Contents of data memory specified by operand
1 is subtracted.
Contents of data memory specified by operand
Contents of data memory specified by operand
1 is added.
0 0 1 0
@
0 0 0 1+
0 0 1 1
0 0 1 1
@
0 0 0 1–
0 0 1 0
:
:
:
:
INC instruction
DEC instruction
INC / @INC / DEC / @DEC
Visual KV KV-300 KV-10/16 KV-24/40/80
DM0000 to DM1999 DM0000 to DM9999 DM0000 to DM0999 DM0000 to DM1999TM00 to TM29 TM00 to TM29 TM00 to TM29 TM00 to TM29
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM172
2.4 Instruction Details
12
3-173Chapter 2 Instructions
Key operation
Arithmetic flag
2009 Turns ON when the result is "0" after an INC operation, or when theresult is "$FFFF (#65535)" after DEC operation. Turns OFF at othertimes.
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 instructiononly once when input relay 0000 turns ON, as shown in the example.
Tips
When using DM0000 as an UP/DOWN counterPerforms an UP count (addition) when input relay 0000 turns ON.Performs a DOWN count (subtraction) when input relay 0001 turns ON.
Applications of INC/DEC instructions UP/DOWN count
Performs an UP count when input relay 0000 turns ON.Performs a DOWN count when input relay 0001 turns ON.Writes the count value into DM0000.Reset input relay is 0005.
Coding
0000 DM0000INC
0001 DM0000DEC
#00000LDA
2008
0000
DM0000STA
0005 #00000DW
DM0000INC
0001 DM0000DEC
DM0000
0000 DM0000INC
0000 DM0000INC
Clears DM0000 to #00000 when 0005turns ON.
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UP edgeof input relay 0000.
Decrements DM0000 by 1 at UP edgeof input relay 0001.
@#,$ FUN
FUN
@#,$ FUN
FUNSET
1OR9
LD7
RES0
ENTR-SRCH
ENTR-SRCH Operand
ENTR-SRCH
ENTR-SRCH Operand
Line No. Instruction Operand Line No. Instruction Operand0000 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
INC / @INC / DEC / @DEC
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM173
2.4 Instruction Details
3-174
2
Chapter 2 Instructions
Total count 1Writes the total count of 4 lines (0000 to 0003) into DM0000.Reset input relay is 0005.
Coding
Total count 2
Counts the number of boxes transferred on 5 production lines. Produces outputwhen the number becomes 100 or more.
#00000LDA
2008
0000
DM0000STA
0005 #00000DW
DM0000INC
0001 DM0000INC
0002 DM0000INC
0003 DM0000INC
DM0000Clears DM0000 to #00000 when 0005 turns ON.
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UP edge of input relay 0000.
Increments DM0000 by 1 at UP edge of input relay 0001.
Increments DM0000 by 1 at UP edge of input relay 0002.
Increments DM0000 by 1 at UP edge of input relay 0003.
Line No. Instruction Operand0000 LD 20080001 LDA #000000002 CON0003 STA DM00000004 LD 00000005 @INC DM00000006 LD 00010007 @INC DM00000008 LD 00020009 @INC DM00000010 LD 00030011 @INC DM00000012 LD 00050013 DW #00000 DM0000
0000
0005
2002
$0000DW
DM0000INC
0001 DM0000INC
0002 DM0000INC
0003 DM0000INC
0004 DM0000INC
DM000005002009#00100DM0000
CMPLDA Turns output relay 0500 ON when valueof DM0000 is 100 or more.
Increments DM0000 by 1 at UP edge ofinput relay 0000.
Increments DM0000 by 1 at UP edge ofinput relay 0001.
Increments DM0000 by 1 at UP edge ofinput relay 0002.
Increments DM0000 by 1 at UP edge ofinput relay 0003.
Increments DM0000 by 1 at UP edge ofinput relay 0004.
Clears DM0000 when input relay 0005turns ON.
INC / @INC / DEC / @DEC
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM174
2.4 Instruction Details
12
3-175Chapter 2 Instructions
Coding
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.
As the example of the INC instruction shows, using different instructions sometimessimplifies 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 instructionCompare the following two programs.With program 1), input relays 0000 through 0004 are individually counted even whenthey 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.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0011 DW #00000 DM00000001 @INC DM0000 0012 LD 20020002 LD 0001 0013 LDA DM00000003 @INC DM0000 0014 CON0004 LD 0002 0015 CMP #001000005 @INC DM0000 0016 CON0006 LD 0003 0017 ANB 20090007 @INC DM0000 0018 OUT 05000008 LD 0004 0019 END0009 @INC DM0000 0020 ENDH0010 LD 0005
0005 DM0001STA
C001LDA
#09999
0000C001
DM0002STA
C002LDA
#09999
0001C002
DM0003STA
C003LDA
#09999
0002C003
DM0004STA
C004LDA
#09999
0003C004
DM0005STA
C005LDA
#09999
0004C005
DM0000STA
DM0005ADD
DM0004ADD
DM0003ADD
DM0002ADD
DM0001LDA
2002 $0000DW
0005
0000
0001
0002
0003
0004
DM0000INC
DM0000INC
DM0000INC
DM0000INC
DM0000INC
DM0000
Programming with the INC instructionwith data memory
Programming with the C instruction
0000 DM0000INC
0001 DM0000INC
0002 DM0000INC
0003 DM0000INC
0004 DM0000INC
0000 DM0000INC
0001
0002
0003
0004
1) 2)
INC / @INC / DEC / @DEC
KVNKA Chap 02_4dP.p65 08.3.11, 0:03 PM175
2.4 Instruction Details
3-176
2
Chapter 2 Instructions
Example
Coding
Operands
#0 to #3
Key operation
Arithmetic flag
2009, 2010, 2011 No change2012 Turns ON when no bit is ON after a DMX operation (the result is
"0"). Turns OFF at other times.
MPX:
@MPX:
DMX:
@DMX:
Converts 4-bit data of internalregister into 16-bit data. The 4-bitdata to be converted is specified asoperand.
@#,$
FUN
FUN
@#,$
FUN
FUN
LD7
LD7
SET1
ANL2
SET1
ANL2
ANL2
ANL2
#nMPX
#nMPX
DMX
DMX
Multiplexer
(4-to-16 decoder),
Demultiplexer
(16-to-4 encoder)
0000 0000LDA
#1MPX
1000STA
0001 0100LDA DMX
DM0000STA
Line No. Instruction Operand0000 LD 00000001 LDA 00000002 CON0003 MPX #10004 CON0005 STA 10000006 LD 00010007 LDA 01000008 CON0009 DMX0010 CON0011 STA DM0000
@#,$ FUN
FUN
@#,$ FUN
FUNSET
1OR9
LD7
RES0
ENTR-SRCH
ENTR-SRCH
Operand
ENTR-SRCH
ENTR-SRCH
Operand
:
:
:
: Converts position of most signifi-cant bit with 1 in internal registerinto 4-bit data.
MPX / @MPX / DMX / @DMX
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM176
2.4 Instruction Details
12
3-177Chapter 2 Instructions
Description
Operation with the MPX instruction
When input relay 0000 is ON, the ON/OFF status of input relays 0000 through 0015is transferred to the internal register. The section of the internal register specified bythe operand (input relays 0004 through 007: 4 bits) is converted into a hexadecimalnumber (0 to F). Only the bit at the position specified by the hexadecimal number isset to "1" and other bits are set to "0". The resulting ON/OFF status is input back tothe 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.
Operation with the DMX instruction
When input relay 0001 is ON, the ON/OFF status of input relays 0100 through 0115is sent to the internal register. Within the 16-bit data of the internal register, thenumber corresponding to the position of the most significant bit with "1" (0 to F) isconverted into 4-bit data and input back to the internal register. The contents of theinternal register are then transferred to DM0000.In the example, when input relay 0114 turns ON, "E" is input to DM0000.
The DMX instruction is disabled when all bits in the internal register are OFF. Insuch a case, special utility relay 2012 turns ON.
Application of MPX and DMX instructions MPX instructionConnect the one-digit data of a BIN digital switch to input relays 0004 through 0007.Connect output relays 0500 through 0515 to lamps 0 to 15.An operator turns on the lamp corresponding to the digital switch using binarynumbers.
When the digital switch shows "8", output 0508 turns ON, therefore, lamp 8 lights.
1 0 1 0
#3 #2 #1
A
#0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
F E D C B A 9 8 7 6 5 4 3 2 1 0
No. represented by the section of theinternal register specified by operand
Operand
Internal register
Internal register
0 to F
0 1 0 1 1 0 0 1 0 1 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
F E D C B A 9 8 7 6 5 4 3 2 1 0
The value is converted into a hexadecimal number.
Most significant bit with "1"
Enter the number of the mostsignificant bit with "1".
2002 0000LDA
#1MPX
0500STA
MPX / @MPX / DMX / @DMX
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM177
2.4 Instruction Details
3-178
2
Chapter 2 Instructions
a
d
gf b
a : 0600 b : 0601 c : 0607
d : 0603 c : 0604 f : 0605
g : 0606e c
DMX instructionConnect 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.
When sensor 8 is ON, the indicator shows "8".
Output of error input No. in BCD
Outputs the error sensor No. from input relay 0000 to 0015 to output relays 0500 to0507 in 2-digit BCD.
Coding
Display of 7-segment LEDDisplays the current value of counter C007 to the 7-segment LED.Outputs from 0600 to 0615.
7-segment configuration
2002 0000LDA DMX
0500STA
Line No. Instruction Operand0000 LD 20020001 LDA 00000002 CON0003 DMX0004 LD 20020005 TBCD0006 CON0007 ANDA $00FF0008 CON0009 STA 0500
0000LDA
2002
2002
DMX
TBCD$00FFANDA
0500STA Converts internal register data to BCD data, executes an
ANDA instruction, and outputs the data to 0500 to 0507.
Converts the most significant bit of 16-bit data (0000 to0015) to 4-bit BIN data and sends it to internal register.
MPX / @MPX / DMX / @DMX
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM178
2.4 Instruction Details
12
3-179Chapter 2 Instructions
C000LDA
#0MPX
C000 #00009C0000000
1000STA
$003FLDA
0600STA
10000
$0006LDA
0600STA
10011
$005BLDA
0600STA
10022
$004FLDA
0600STA
10033
$0066LDA
0600STA
10044
$006DLDA
0600STA
10055
$007DLDA
0600STA
0600STA
10066
$0007LDA
10077
$007FLDA
0600STA
10088
$006FLDA
0600STA
10099
Converts the counter value to 16-bitdata using the MPX instruction.
7-segment display
Auto-resetcounter
Sends internal register data tooutput relays starting from 0600.
Line No. Instruction Operand Line No. Instruction Operand0000 LDB C000 0024 LD 10040001 C 000 #00009 0000 0025 LDA $00660002 CON 0026 CON0003 LDA C000 0027 STA 06000004 CON 0028 LD 10050005 MPX #0 0029 LDA $006D0006 CON 0030 CON0007 STA 1000 0031 STA 06000008 LD 1000 0032 LD 10060009 LDA $003F 0033 LDA $007D0010 CON 0034 CON0011 STA 0600 0035 STA 06000012 LD 1001 0036 LD 10070013 LDA $0006 0037 LDA $00070014 CON 0038 CON0015 STA 0600 0039 STA 06000016 LD 1002 0040 LD 10080017 LDA $005B 0041 LDA $007F0018 CON 0042 CON0019 STA 0600 0043 STA 06000020 LD 1003 0044 LD 10090021 LDA $004F 0045 LDA $006F0022 CON 0046 CON0023 STA 0600 0047 STA 0600
Coding
MPX / @MPX / DMX / @DMX
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM179
2.4 Instruction Details
3-180
2
Chapter 2 Instructions
Example
Coding
Operands
Key operation
Arithmetic flag
2009, 2010, 2011 No change2012 Turns ON when the contents of the internal register are greater
than "$270F (#09999)" before TBCD operation, or when thecontents of the internal register are not BCD data before theTBIN operation (In these cases, the TBCD or TBIN instructionwill not be executed.). Turns OFF at other times.
TBCD: Transfer BCD
@TBCD: Transfer BCD
TBIN: Transfer BIN
@TBIN: Transfer BIN
Converts contents of internal register(16-bit binary) into 4-digit BCD data.
Converts contents of internal register(4-bit binary) into 16-digit BCD data.
@#,$
FUN
FUN
@#,$
FUN
FUN
LD7
LDB4
LDB4
AND8
LD7
LDB4
LDB4
AND8
TBCD
TBCD
TBIN
TBIN
TBCD
TBIN
0000
0001
DM0000LDA
DM0001STA
DM0010LDA
DM0011STA
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 @TBCD0004 CON0005 @STA DM00010006 LD 00010007 LDA DM00100008 CON0009 @TBIN0010 CON0011 @STA DM0011
@#,$ FUN
FUN
@#,$ FUN
FUNLD7
LDB4
LDB4
AND8
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
:
:
:
:
TBCD / @TBCD / TBIN / @TBIN
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM180
2.4 Instruction Details
12
3-181Chapter 2 Instructions
Description
Operation using the TBCD instruction
When input relay 0000 turns ON, the contents of DM0000 are transferred to theinternal 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 thentransferred to DM0001.
Operation using the TBIN instruction
When input relay 0001 turns ON, the contents of DM0010 are transferred to theinternal register. The contents of the internal register (4-digit BCD data) are con-verted into 16-bit binary data, which is input back to the internal register, and thentransferred to DM0011.
Note 1: The TBCD instruction can only convert data up to "#09999". When theconversion of data of "#10000" or greater is attempted, special utility relay 2012turns ON and the conversion is disabled.
Note 2: When the data in the internal register is not BCD data, special utility relay2012 turns ON and the TBIN instruction is disabled.
Applications of TBCD instruction Output of 4-digit BCD dataOutputs the current value of counter C001 to 0700 to 0715 in 4-digit BCD data.
Coding
Data is converted into BCD of "0" through "9999".
Data is converted into binary number of "0" through "9999".
103
(0)102
(0)101
(2)100
(4)
0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
216 20
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
(5)103
(5)
102(5)101
(5)100
0 0 0 1 0 1 0 1 1 0 1 1 0 0 1 1
0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1
8 4 2 1 8 4 2 1 8 4 2 1 8 4 2 1
D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
0001
2002 C001LDA
0700STATBCD
#09999
C0010000
Converts current value of C001 into BCD data,and outputs it to 0700 to 0715.
Sets C001.
Line No. Instruction Operand0000 LDB 00010001 C 001 #00009 00000002 LD 20020003 LDA C0010004 CON0005 TBCD0006 CON0007 STA 0700
TBCD / @TBCD / TBIN / @TBIN
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM181
2.4 Instruction Details
3-182
2
Chapter 2 Instructions
0400LDA
C001STA
2002
0001
TBIN
#09999C0010000
Line No. Instruction Operand0000 LD 20020001 LDA 04000002 CON0003 TBIN0004 CON0005 STA C0010006 LDB 00010007 C 001 #09999 0000
Converts data of 0400 to 0415 to BIN data and writesinto C001.
Sets C001
Output of 8-digit BCD dataOutputs the calculated product of DM0000 x DM0001 (0 to 99999999) in BCD of 8digits at maximum as below:
High-order 4-digit BCD data To 0600 to 0615Low-order 4-digit BCD data To 0500 to 0515
Coding
Application of TBIN instruction Input of 4-digit BCD dataSets 4 digits of the BCD digital switch (0400 to 0415) as the counter C001 value.
Coding
DM0000LDA
DM0001MUL
DM0101STA
#10000DIV
TM01LDA TBCD
0500STA
2002
DM0101LDA TBCD
0600STA
TM00DM0000 x DM0001 =
TM00
0600 to 0615 0500 to 0515
... TM01
÷ #10000
=
Display
Internal registerHigh-order 4 digits Low-order 4 digits
High-order 4 digits
Internal register
Internal register
TM00
Low-order 4 digits Remainder
High-order 4 digits Low-order 4 digits
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0010 CON0001 LDA DM0000 0011 TBCD0002 CON 0012 CON0003 MUL DM0001 0013 STA 05000004 CON 0014 CON0005 DIV #10000 0015 LDA DM01010006 CON 0016 CON0007 STA DM0101 0017 TBCD0008 CON 0018 CON0009 LDA TM01 0019 STA 0600
TBCD / @TBCD / TBIN / @TBIN
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM182
2.4 Instruction Details
12
3-183Chapter 2 Instructions
Example
Coding
Operands
Key operation
Arithmetic flag2009, 2010, 2011 No change
2012 Turns ON when the high- and low-order 8-bit value is not withinthe range of "$30" to "$39" and "$41" to "$46", respectively,before the RASC instruction is executed (In this case, the RASCinstruction will not be executed.). Turns OFF at other times.
ASC: ASCII Convert
@ASC: ASCII Convert
RASC: Reverse ASCII Convert
@RASC: Reverse ASCII Convert
Converts contents of lower order byteof internal register into 2-digit ASCIIcode.
Converts 2-digit ASCII into byte datarepresenting 2-digit hex number.
@#,$
FUN
FUN
ORL3
ORL3
@#,$
FUN
FUN
RES0
ANL2
ANL2
ANL2
RES0
ANL2 ASC
ASC
RASC
RASC
ASC
RASC
0000
0001
DM0000LDA
DM0001STA
DM0010LDA
DM0011STA
Line No. Instruction Operand0000 LD 00000001 LDA DM00000002 CON0003 @ASC0004 CON0005 @STA DM00010006 LD 00010007 LDA DM00100008 CON0009 @RASC0010 CON0011 @STA DM0011
ORL3@
#,$ FUN
FUN
@#,$ FUN
FUNRES
0
ANL2
ANL2
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ASC / @ASC / RASC / @RASC
:
:
:
:
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM183
2.4 Instruction Details
3-184
2
Chapter 2 Instructions
Hex number Bit configuration Code Bit configuration
0 0 0 0 0 $30 0 0 1 1 0 0 0 0
1 0 0 0 1 $31 0 0 1 1 0 0 0 1
2 0 0 1 0 $32 0 0 1 1 0 0 1 0
3 0 0 1 1 $33 0 0 1 1 0 0 1 1
4 0 1 0 0 $34 0 0 1 1 0 1 0 0
5 0 1 0 1 $35 0 0 1 1 0 1 0 1
6 0 1 1 0 $36 0 0 1 1 0 1 1 0
7 0 1 1 1 $37 0 0 1 1 0 1 1 1
8 1 0 0 0 $38 0 0 1 1 1 0 0 0
9 1 0 0 1 $39 0 0 1 1 1 0 0 1
A 1 0 1 0 $41 0 1 0 0 0 0 0 1
B 1 0 1 1 $42 0 1 0 0 0 0 1 0
C 1 1 0 0 $43 0 1 0 0 0 0 1 1
D 1 1 0 1 $44 0 1 0 0 0 1 0 0
E 1 1 1 0 $45 0 1 0 0 0 1 0 1
F 1 1 1 1 $46 0 1 0 0 0 1 1 0
Description
Operation using the ASC instruction
When input relay 0000 turns ON, the contents of DM0000 are transferred to theinternal 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 theinternal register, and then transferred to DM0001.
Operation using the RASC instruction
When input relay 0001 turns ON, the contents of DM0010 are transferred to theinternal register. The contents of the internal register (2-digit ASCII code) is con-verted into a low-order 8-bit, 2-digit numeric value. This 2-digit numeric value is inputback to the internal register, then transferred to DM0011..
The value is converted only when the high- and low-order 8-bit value of the internalregister is within the range of "$30" to "$39" and "$41" to "$46", respectively, beforethe conversion. (When either of the high- or low-order 8-bit value is not within therange, the conversion is disabled. In this case, special utility relay 2012 turns ON.)
Example of conversion between hex and ASCII numbers
1 0 1 0 0 1 0 1
0 1 0 0 0 0 0 1 0 0 1 1 0 1
4 1 3 5
A 5
0 1
0 0 0 0 0 0 0 0 0 1 1 0 1 1
4 33 6
6 C
0 0
0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 1
ASC / @ASC / RASC / @RASC
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM184
2.4 Instruction Details
12
3-185Chapter 2 Instructions
Example
Coding
Description
• The ROOT instruction takes the square root of 32-bit data (binary number) ofwhich the high-order 16 bits are contained in DM0001 and low-order 16 bits arecontained in DM0000, and then input the result to DM0100.
• The figures to the right the decimal point of the obtained square root are omitted,and the result is input back to the same register.
• When the result is 0, special utility relay No. 2010 turns ON.• The ROOT instruction takes the square root of a 32-bit numerical value. In this
case, the high-order 16 bits are contained in TM00, and the low-order 16 bits arecontained in the internal register.
Operands
Key operation
ROOT: Square Root
@ROOT: Square Root
Takes square root of 32-bit data (TM00:higher order byte, internal register: lowerorder byte), and inputs result back to sameregister.
ROOT
ROOT
ORB6
ORL3
ORB6
ORL3
@#,$
FUN
FUN
ROOT0000 TM00
STADM0001
LDADM0000
LDADM0100
STA
Line No. Instruction Operand
0000 LD 0000
0001 LDA DM0001
0002 CON
0003 STA TM00
0004 CON
0005 LDA DM0000
0006 CON
0007 ROOT
0008 CON
0009 STA DM0100
T M 0 0 Internal register Internal register
Higher order 16 bits Lower order 16 bits
ORL3
ORB6@
#,$
FUN
FUN
ENTR-SRCH
ENTR-SRCH
:
:
ROOT / @ROOT
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM185
2.4 Instruction Details
3-186
2
Chapter 2 Instructions
Change in status of special utility relays (arithmetic flags) by arithmeticinstructions (1/3)
Instruction Mnemonic Operand A < 0 A = 0 A > 0 Error2009 2010 2011 2012
DATAMEMORY DW $,# constant — — — —WRITE 3-136
Relay No. — 5 — —
LOAD A LDA Timer/counter No. — 5 — —
3-140 [FUN23] Data memory No. — 5 — —
$,# constant — 5 — —
# TM — 5 — H
Relay No. — — — —
STORE A STA Timer/counter No. — — — —
3-140 [FUN42] Data memory No. — — — —
# TM — — — H
COMPARECMP
Data memory No. 1 2 3 —
3-146[FUN04]
$,# constant 1 2 3 —
# TM 1 2 3 H
ADDADD
Data memory No. 4 5 — —
3-150[FUN00]
$,# constant 4 5 — —
# TM 4 5 — H
SUBTRACTSUB
Data memory No. 6 5 7 —
3-150[FUN46]
$,# constant 6 5 7 —
# TM 6 5 7 H
MULTIPLYMUL
Data memory No. I 8 — —
3-150[FUN28]
$,# constant I 8 — —
# TM I 8 — H
DIVIDEDIV
Data memory No. — 8 — 9
3-150[FUN11]
$,# constant — 8 — 9
# TM — 8 — H9
AND AANDA
Data memory No. — 5 — —
3-159[FUN01]
$,# constant — 5 — —
# TM — 5 — H
—: No change in arithmetic flagRefer to the description of each instruction for details of the operating conditions of the flag.
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM186
2.4 Instruction Details
12
3-187Chapter 2 Instructions
Change in status of special utility relays (arithmetic flags) by arithmeticinstructions (2/3)
Instruction Mnemonic Operand A < 0 A = 0 A > 0 Error2009 2010 2011 2012
OR AORA
Data memory No. — 5 — —
3-161[FUN31]
$,# constant — 5 — —
# TM — 5 — H
EXCLUSIVEEORA
Data memory No. — 5 — —
OR A[FUN15]
$,# constant — 5 — —
3-164 # TM — 5 — H
SHIFTSRA
Number of shifts 0 5 — —RIGHT A
[FUN41] 3-166
SHIFTSLA
Number of shift 0 5 — —LEFT A
[FUN40] 3-166
ROTATERRA
Number of rotations 0 5 — —RIGHT A
[FUN37] 3-169
ROTATERLA
Number of rotations 0 5 — —LEFT A
[FUN40] 3-169
COMPLE-COM
— 5 — —MENT
[FUN05] 3-171
INCREMENTINC
Data memory No. A 5 — —MEMORY
[FUN19] 3-172
DECRE-MENT DEC Data memory No. B 5 — —MEMORY [FUN07] 3-172
MULTI-MPX
Digit No. — — — —PLEXER
[FUN27] 3-176
DEMULTI-DMX
— — — C
PLEXER[FUN12]
3-176
TRANSFERTBCD
— — — D
BCD[FUN47]
3-180
TRANSFERTBIN
— — — E
BIN[FUN48]
3-180
ASCIIASC
— — — —CONVERT
[FUN02] 3-183
REVERSEASCII RASC — — — F
CONVERT [FUN32] 3-183
SQUAREROOT
— 5 — —ROOT
[FUN36] 3-185
TRIMMERTMIN
— G — —SETTING
[FUN50] 3-138
—: No change in arithmetic flagRefer to the description of each instruction for details of the operating conditions of the flag.
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM187
2.4 Instruction Details
3-188
2
Chapter 2 Instructions
Change in status of special utility relays (arithmetic flags) by arithmeticinstructions (3/3)
1 When the result of COMPARE is negative, the relay turns ON. When the result isnot negative, the relay remains OFF.
2 When the result of COMPARE is "0", the relay turns ON. When the result is not"0", the relay remains OFF.
3 When the result of COMPARE is positive, the relay turns ON. When the result isnot positive, the relay remains OFF.
4 When the result of the arithmetic operation exceeds the 16-bit range ($FFFF),the relay turns ON. When the result is within the 16-bit range, the relay remainsOFF.
5 When, as a result of the arithmetic operation, the data in the internal register is"0", the relay turns ON. When the data is not "0", the relay remains OFF.
6 When the result of the arithmetic operation is negative, the relay turns ON.When the result is not negative, the relay remains OFF.
7 When the result of the arithmetic operation is positive, the relay turns ON.When the result is not positive, the relay remains OFF.
8 When, as a result of the arithmetic operation, all of the 32 bits are "0", the relayturns ON. When any of them is not "0", the relay remains OFF.
9 When the divisor is "0", in the division, the relay turns ON. In this case, DIVIDE isnot executed.
0 When, as a result of SHIFT or ROTATE, "1" is entered into 2009, it turns ON.When "1" is not entered, it remains OFF.
A When as a result of INCREMENT MEMORY, the data of the data memory is "0",the relay turns ON. When the data is not "0", the relay remains OFF.
B When as a result of DECREMENT MEMORY, the data of the data memoryEXCEEDS 16 BIT RANGE ($FFFF), the relay turns ON. When the data is withinthe 16-bit range, the relay remains OFF.
C When there is no "ON" bit in the internal register at execution ofDEMULTIPLEXER, the relay turns ON. (In this case, "0" is entered in the internalregister.) When there is a "ON" bit(s), the relay remains OFF.
D When the data in the internal register exceeds $270F (#09999) at execution ofTRANSFER BCD, the relay turns ON. (In this case, TRANSFER BCD is notexecuted.) When the data does not exceed $270F, the relay remains OFF.
E When the data in the internal register is not BCD data at execution of TRANS-FER BIN, the relay turns ON. (In this case, TRANSFER BIN is not executed.)When the data is BCD, the relay remains OFF.
F When the higher-order byte or lower-order byte in the internal register is respec-tively not within the range of $30 through $39, or the range of $41 through $46 atexecution of REVERSE ASCII CONVERT, the relay turns ON. (In this case,REVERSE ASCII CONVERT is not executed.)When the value is within the range, the relay remains OFF.
G When the input value for TRIMMER SETTING is "0", the relay turns ON.When the value is not "0", the relay remains OFF.
H During indirect addressing, there is no data memory or relay by the numberspecified by "TMxx".
I When the result of the arithmetic operation exceeds the 16-bit range, the relayturns ON. When the result is within the 16-bit range, the relay remains OFF.
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM188
2.5 Programming Notes
12
3-189Chapter 2 Instructions
2.5 Programming NotesThis section describes important points and precautions for creating ladder pro-grams.
Circuits that must be modified
1. The circuit shown below left cannot be programmed. Modify it as shown on theright.
2. Output is disabled in 0500 in the circuit shown below left. By modifying it asshown on the right, output of one scan only is disabled.
3. If the same coil is used in two positions, the latter position has priority and thecoil in the former position is ignored.
4. The circuit shown below left cannot be programmed. Modify it as shown on theright.
5. The circuit shown below left cannot be programmed. Modify it as shown on theright.
C D
A B 0500
E
A E
C E 0500
A
D
B
C
1000
A 1000
0500
A 1000 0500
A 1000
E
A
C
B 0500
0500
A B 0500
C E
A B C
D E
F
0500 B C
D E
A
E
0500
F
A B 0500
0501
C D
E
C D
E
A
B 0500
0501C
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM189
2.5 Programming Notes
3-190
2
Chapter 2 Instructions
0500
2002 #0010T000
0500
#0010T000
A B D E E0500
C
A B
0500
C
D
B C 0500
0501
A
B C
0500
A
A B D 0500
D 0501
Programming precautions1. 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 internalutility relay, a 'b' contact of an unused special utility relay, or a special utility relay2002 (always ON) as a dummy.
2. A contact cannot be connected to an output line.
3. Make sure that every contact/coil is located on a path from a bus to an outputline. Make sure that there are no unconnected portions.
4. Make sure that illegal short-circuits are not generated in parallel connections.
5. Circuits including output coils cannot be connected in parallel.
However, parallel connection is enabled when each circuit in parallel connectionis connected to an output line.
6 . When the following program is entered with the programming support softwareand sent to the KV, and then read from the KV with the software, reading isdisabled due to a "Reverse Compilation Error".When a return is included in parallel connection in a ladder program, adecompilation (reverse compilation) error is generated as shown below.To prevent this error, change the ladder diagram to eliminate the return, orseparate the parallel connection.
KVNKA Chap 02_4dP.p65 08.3.11, 0:04 PM190
Chapter 3Interrupts
The interrupt processing function executes an interrupt program when an externalinput or request from the high-speed counter comparator (interrupt factor) is encoun-tered during KV operation.This chapter describes the types of interrupt factors as well as inputs and outputsencountered during interrupt processing.
For KV-10/80 Series, see Chapter 6.
3.1 Interrupt Instructions ...................................................................... 3-192
3.2 Interrupt Processing ....................................................................... 3-1943.2.1 Interrupt Processing ............................................................................... 3-1943.2.2 Types of Interrupts ................................................................................. 3-1953.2.3 Interrupt Priority ...................................................................................... 3-1963.2.4 Interrupt Program ................................................................................... 3-196
3.3 Direct Input/Output .......................................................................... 3-1973.3.1 Direct Input ............................................................................................. 3-1973.3.2 Direct Output .......................................................................................... 3-197
3.4 Applications of Interrupt Programs ............................................ 3-1983.4.1 Interrupt with a Signal Converter ............................................................ 3-1983.4.2 Interrupt with a High-speed Counter ...................................................... 3-1993.4.3 Measuring the ON Time of High-speed Pulses ...................................... 3-2003.4.4 Measuring the Period in which a Target Passes between
Two Points ............................................................................................. 3-201
Visu
al K
VSe
ries
KVNKA Chap 03.p65 08.3.11, 0:05 PM191
3.1 Interrupt Instructions
3-192
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
FUN
FUN LDB4
RES0
ENTOperand
R-SRCHENTR-SRCH
ENTR-SRCH
ENTR-SRCH
ANL2
ORL3
3.1 Interrupt InstructionsThis section describes the INT, RETI, DI, and EI instructions used for interruptprocessing.
INT: Interrupt
RETI: Return Interrupt
Executes interrupt between INT and RETIinstructions at rising or falling edge of inputspecified by operand.
Represents termination of interrupts.
FUN
FUN LDB4
RES0
ANL2
ORL3
RETI
INTnnnn
0500
0000
T000 0500
#00020T000
a)
0000
Normalinput
Example
Coding for normal input
Coding for interrupt input
Description
• Example a) shows a normal input and is used when input relay 0000 turns ONlonger than the input time constant (10 ms).
• Example b) is used when input relay 0000 turns ON shorter than the scan time.
Operands
0000 to 0003CTC0 to CTC3
Key operation
(Input ON time: 10 µs min.)
(Input ON time: 10 ms min.)
Interruptinput
Line No. Instruction Operand0000 LD 00000001 OR 05000002 TMR 00 #000200003 ANB T0000004 OUT 0500
Line No. Instruction Operand0000 LD 20080001 EI0002 LD 20020003 HSP 00000004 LD 10000005 OR 05000006 TMR 000 #000200007 OUT 05000008 LD T00009 RES 10000010 END0011 INT 00000012 LD 20020013 OUT 10000014 RETI0015 ENDH
1000
0500
#00020T000
1000
2002
b)
0000
2008EI
END
INT0000
HSP0000
RETI
ENDH
2002
T0 1000(RES)
KVNKA Chap 03.p65 08.3.11, 0:05 PM192
3.1 Interrupt Instructions
3-193
Visu
al K
VSe
ries
13
Chapter 3 Interrupts
DI: Interrupt Disabled
EI: Interrupt Enabled
Disables execution of interrupt.
Enables execution of interrupt.
Example
Coding
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.• 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 disabledperiod), the disabled interrupt is stored (to 8 levels max.). The stored interrupt isexecuted 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
FUN
FUN
RES0
ORL3
DI
EISET1
AND8
1000EI
DI1000
FUN
FUN SET1
RES0
AND8
ORL3
ENTR-SRCH
ENTR-SRCH
Line No. Instruction Operand0000 LD 00000001 EI
• •• •• •
0021 LDB 10000022 DI
• •• •• •
KVNKA Chap 03.p65 08.3.11, 0:05 PM193
3.2 Interrupt Processing
3-194
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
2008SET or
2813EI
#00000DW
DM1940
2002
2002
EI
HSP0000
(0000 to 0015)
(0500 to 0503)
3.2 Interrupt ProcessingThis section describes interrupt processing.
3.2.1 Interrupt ProcessingOutline
Normally, a PLC processes a ladder sequence program by repeating the steps ofinput processing, program execution, and output processing. Therefore, signalswhich are shorter than the scan time cannot be received.When the interrupt processing function is used, a process can be executed at theinstant of the interrupt, independent of the scan time.When any interrupt occurs, the Visual KV series suspends the currently executedprogram and executes the interrupt program in accordance with the interrupt factor.When the interrupt program completes, the Visual KV resumes execution of thesuspended program. For more about scan time, refer to "1.1.2 Scan Time" (p. 3-3).
Direct input/output
The direct input/output functions are used during interrupt processing. Direct inputallows 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 relays0500 through 0503 during execution of the interrupt program.No special setting is required to use the direct input/output functions. The functionscan be used only by using the devices assigned for direct input/output within theinterrupt program.
Executing interrupts
The INT (Interrupt) instruction is used to execute an interrupt. Since an interrupt isdisabled 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 constantshould be set shorter by using the HSP instruction (to 10 µs) or by specifying thedesired 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).
Direct output
Inputprocessing
Programexecution
Outputprocessing
Scantime
Interrupt input
Return to the nextline of the interrupt.
Interruptprocessing
Direct input *
KVNKA Chap 03.p65 08.3.11, 0:05 PM194
3.2 Interrupt Processing
3-195
Visu
al K
VSe
ries
13
Chapter 3 Interrupts
3.2.2 Types of InterruptsInterrupts can be divided into two types: an interrupt by an external input, and aninterrupt by the high-speed counter comparator. This section describes both of theseinterrupt types.
Interrupt by an external inputThis interrupt is executed by input relays 0000 through 0003. Use the special utilityrelay to specify the polarity of the interrupt factor to a rising or falling edge.
Interrupt by the high-speed counter comparator
This interrupt is executed when the current value of the high-speed counter (CTH)matches the preset value of the high-speed counter comparator (CTC).
Polarity setting for interrupts by an external input
Turn ON the appropriate special utility relay to specify the interrupt factor to a risingor falling edge.The interrupt polarity can be changed as follows by setting special utility relays2402/2403 (INT0), 2404/2405 (INT1), 2410/2411 (INT2), and 2412/2413 (INT3).
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 afunction which writes the value of the high-speed counter into the data memorywhen an interrupt occurs. Without any particular settings, the value of the high-speed counter is automatically transferred to DM1928 through DM1935 when aninterrupt occurs.
CAUTION
tpurretnIepyt
yaleR.oN
sutatSyaleR.oN
sutatS noitpircseD
0TNI 2042
FFO
3042
FFO.egdegnisirtasruccotpurretnI
NO FFO
FFO NO .egdegnillaftasruccotpurretnI
NO NO .segdegnillafdnagnisirhtobtasruccotpurretnI
1TNI 4042
FFO
5042
FFO.egdegnisirtasruccotpurretnI
NO FFO
FFO NO .egdegnillaftasruccotpurretnI
NO NO .segdegnillafdnagnisirhtobtasruccotpurretnI
2TNI 0142
FFO
1142
FFO.egdegnisirtasruccotpurretnI
NO FFO
FFO NO .egdegnillaftasruccotpurretnI
NO NO .segdegnillafdnagnisirhtobtasruccotpurretnI
3TNI 2142
FFO
3142
FFO.egdegnisirtasruccotpurretnI
NO FFO
FFO NO .egdegnillaftasruccotpurretnI
NO NO .segdegnillafdnagnisirhtobtasruccotpurretnI
rotcaftpurretnilanretxE noitpircseD
0TNIfoecnerruccO)stibredro-wol(8291MDotnettirwsi0HTCfoeulaV
)stibredro-hgih(9291MDdna
1TNIfoecnerruccO)stibredro-wol(0391MDotnettirwsi0HTCfoeulaV
)stibredro-hgih(1391MDdna
2TNIfoecnerruccO)stibredro-wol(2391MDotnettirwsi1HTCfoeulaV
)stibredro-hgih(3391MDdna
3TNIfoecnerruccO)stibredro-wol(4391MDotnettirwsi1HTCfoeulaV
)stibredro-hgih(5391MDdna
KVNKA Chap 03.p65 08.3.11, 0:05 PM195
3.2 Interrupt Processing
3-196
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
• Use SET-RES instructions to turn the special utility relays ON/OFF.• The input capture function stores the high-order bit data only when the 24-
bit high-speed counter is used. The data is undefined when the 16-bit high-speed counter is used.
"4.4.1 24-bit High-speed Counter" (p. 3-221)
• Timing of the input capture execution depends on the input polarity settingspecified with special utility relays 2402 through 2405 and 2410 through2413.
3.2.3 Interrupt PriorityWhen many interrupts occur sequentially, priority is given to the interrupt whichoccurs earlier.When two or more interrupts occur simultaneously, priority is given in the order of0000, 0001, 0002, 0003, CTC2, CTC3, CTC0, and CTC1.
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 interruptsare stored up to 8 levels deep. The stored interrupts are executed after completionof the previous interrupt, according to the priority order. However, an interrupt whichuses the same device as a previous interrupt cannot be stored.
3.2.4 Interrupt ProgramThe interrupt program is a program which is executed by an interrupt. It is necessaryto execute an EI (Interrupt enabled) instruction before executing an interrupt pro-gram.To temporarily disable an interrupt, execute a DI (Interrupt disabled) instruction.When an interrupt is disabled, subsequent interrupts are not executed but storeduntil the next EI instruction. "EI instruction", "DI instruction" (p. 3-193)
Example of an interrupt program
Note 1: To shorten the input time constant, use the HSP instruction (to 10 µs) orspecify 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 ConstantChange Function" (p. 3-23).
Note 3: Use SET-RES instructions instead of OUT-OUTB instructions within inter-rupt programs.
The following instructions cannot be used within interrupt programs:TMR, TMH, TMS, DIFU, DIFD, W-ON, W-OFF, W-UE, W-DE, STG, JMP, ENDS,HKEY, ITVL, @xxxx (differentiation type instructions), C, UDC, SFT
CAUTION
2008EI
HSP0000
END
RETI
ENDH
INT0000
An interrupt program is not executed unless an EI instruction is executed.
Set the input time constant shorter by using the HSP instruction(to 10 µs) or by turning ON special utility relay 2813.
Write the interrupt program between the END and ENDHinstructions.
KVNKA Chap 03.p65 08.3.11, 0:05 PM196
3.3 Direct Input/Output
3-197
Visu
al K
VSe
ries
13
Chapter 3 Interrupts
2002
2008
END
INT0000
1000
0005
RETI
ENDH
0500
HSP0000
HSP0005
EI
1000SET
2002
2008EI
END
INT0000
HSP0001
HSP0000
2002
RETI
INT0001
2002
RETI
ENDH
0500SET
0501SET
3.3 Direct Input/OutputThis section describes direct input and output.
3.3.1 Direct InputThe 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 interruptprogram.
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 byturning ON special utility relay 2813.
• The direct input data is effective only within the interrupt program so that theinternal utility relay must be provided.
3.3.2 Direct OutputDirect output allows the Visual KV PLC to output the ON/OFF status of output relaysduring execution of the interrupt program. Direct output is available only with outputrelays 0500 through 0503.
• Direct output is not affected by the scan time.
KVNKA Chap 03.p65 08.3.11, 0:05 PM197
3.4 Applications of Interrupt Programs
3-198
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
0001
0002
0003
0004
0005
0006
0007
0008
2008EI
2002
2002
T00000500
HSP0000
END
INT0002
RETI
ENDH
#00010T000
0500RES
0500SET
3.4 Applications of Interrupt ProgramsThis section presents program examples of interrupt processing.
3.4.1 Interrupt with a Signal Converter OutlineConverts the short pulses which are input by interrupt processing into pulses of aconstant width and then outputs them.
Ladder diagram• Converts the short pulses input from input relay 0000 into pulses of 1-second ON
width and then outputs them from output relay 0500.• Output relay 0500 turns ON for 1 second from the rising edge of input relay 0000.
OFF
ON
OFF
ON
ONONON
1 sec.
Scan
Input 0000
Output 0500
1 sec. 1 sec.
When input 0000 turnsON, output 0500 turns ON.
When power is turned on, an EIinstruction enables interrupts.
Sets the input time constant ofinput 0000 to 10 µs.
Turns ON output 0500 for 1second and then turns it OFF.
KVNKA Chap 03.p65 08.3.11, 0:05 PM198
3.4 Applications of Interrupt Programs
3-199
Visu
al K
VSe
ries
13
Chapter 3 Interrupts
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
2008EI
2002 HSP0004
2002 CTH00004
# 10000CTC0
CTH0RES
0500SET
2103SET
2002
0500RES
0000
END
INTCTC0
RETI
ENDH
3.4.2 Interrupt with a High-speed Counter Outline
Uses the input value of a high-speed counter from one input relay and the ON/OFFstatus of another input relay to control the ON/OFF status of an output relay.
Example: Filling control for medicine (tablets)
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.
Sensor
When power is turned on, an EIinstruction enables interrupts.Sets automatic reset of CTH0.Resets current value of CTH0.
ON
OFF
ON
OFF
ON
OFF
ON
Output 0500
Scan
Input 0004
Input 0000
Sets an input time constant ofinput 0004 to 10 µs.
Turns OFF output 0500 wheninput 0000 turns ON.
Executes an interrupt when theinput value of CTH0 reaches"10000". Turns ON output 0500.
Specifies CTH0 as the high-speed counter for input 0004 andsets "10000" as the preset valueof CTC0.
Visual KV
KVNKA Chap 03.p65 08.3.11, 0:05 PM199
3.4 Applications of Interrupt Programs
3-200
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
0001
0002
0003
0004
0005
0006
0007
0008
0009
2008EI
2002 HSP0000
2002 CTH02100
2403
END
INT0000
RETI
ENDH
KEEP
2403
RES
SETTM02STA
DM1928LDA
DM0000STA
TM02SUB
DM1928LDA
2403
3.4.3 Measuring the ON Time of High-speed Pulses OutlineMeasures the pulse width of the pulse input to an input relay.
Example: Measurement of workpiece length
Ladder diagram• Special utility relay 2100 is turned ON to measure the pulse width using 1-µs
units.• The values when input relay 0000 is ON is written into temporary data memory
TM02, and the values when input relay 0000 is OFF is written into data memoryDM1912. The pulse width can be obtained by subtracting the value of TM02 fromthe value of DM1912.
• The obtained value is written into data memory DM0000 (Unit: µs).
• Turns ON input 0000 to execute aninterrupt.
First, an interrupt is executed at therising edge of input 0000. Thecurrent value of CTH0 stored inDM1928 is written to TM02. TurnsON special utility relay 2403 tochange the interrupt polarity to thefalling edge.
Next, an interrupt is executed at thefalling edge of input 0000. Thevalue stored in TM02 is subtractedfrom the current value of CTH0stored in DM1928, and theobtained ON width of input 0000 iswritten to DM0000. Turns OFFspecial utility relay 2403 to changethe interrupt polarity to the risingedge.
• When power is turned ON, an EIinstruction enables interrupts.
• Sets an input time constant ofinput 0000 to 10 µs.
• CTH0 counts pulses with a 1-µsinternal clock.
OFF
ONSensor input 0000
Pulse width (µs)
Visual KV
Sensor
KVNKA Chap 03.p65 08.3.11, 0:05 PM200
3.4 Applications of Interrupt Programs
3-201
Visu
al K
VSe
ries
13
Chapter 3 Interrupts
3.4.4 Measuring the Period in which a Target Passes betweenTwo Points
Outline
Measures the period in which two input relays turn ON.
Example: Measurement of tact time
Ladder diagram• Measures the time from when input relay 0002 turns ON until input relay 0003
turn ON.• The measured value is written to data memory DM0000 (Unit: µs).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
2008EI
2002 HSP0002
HSP0003
2002 CTH12200
2411RES
2412RES
2413RES
2410RES
END
INT0002
RETI
RETI
ENDH
INT0003
DM0000STA
DM1932SUB
DM1934LDA
2002
• When power is turned on, anEI instruction enables inter-rupts. Sets the interrupt polarityof inputs 0002 and 0003 to therising edge.
• Sets the input time constant ofinputs 0002 and 0003 to 10 µs.
• CTH1 counts the pulses usinga 1-µs internal clock.
• When INT2 is executed, thecurrent value of CTH1 isautomatically transferred toDM1932 and DM1933 (Inputcapture).
• When INT3 is executed, thecurrent value of CTH1 isautomatically transferred toDM1934 and DM1935 (Inputcapture).Subtracts the input capturevalue of INT2 from that of INT3to obtain the time it takes forthe target to pass between twopoints and then writes it toDM0000.
OFF
ON
OFF
ON
Sensor 1 input 0002
Sensor 2 input 0003
Passing time (µs)
Sensor 1
Sensor 2
Visual KV
KVNKA Chap 03.p65 08.3.11, 0:05 PM201
3.4 Applications of Interrupt Programs
3-202
Visu
al K
VSe
ries
3
Chapter 3 Interrupts
KVNKA Chap 03.p65 08.3.11, 0:05 PM202
Chapter 4High-speed Counters
This chapter describes high-speed counters and high-speed counter comparators,which allow high-speed pulse measurement and pulse output, independent of thescan time.
For KV-10/80 Series, see Chapter 6.
4.1 High-speed Counter Instructions ................................................ 3-204
4.2 Outline of High-speed Counters .................................................. 3-2064.2.1 High-speed Counters and High-speed Counter Comparators ............... 3-2064.2.2 Internal Clock for High-speed Counters ................................................. 3-210
4.3 Setting and Operation of High-speed Counters ...................... 3-2114.3.1 Reading the Current Value of the High-speed Counter ......................... 3-2114.3.2 Preset Value of the High-speed Counter Comparator ........................... 3-2114.3.3 Comparator Output ................................................................................ 3-2114.3.4 Count Input Method................................................................................ 3-2124.3.5 Resetting the High-speed Counter ......................................................... 3-2144.3.6 Differences with the CTH Instruction between the
Conventional and Visual KV Series ....................................................... 3-2164.3.7 Applications of High-speed Counters ..................................................... 3-217
4.4 Expanded Functions of High-speed Counters ......................... 3-2214.4.1 24-bit High-speed Counter ..................................................................... 3-2214.4.2 Changing the Current Value of a 24-bit High-speed Counter ................ 3-2234.4.3 Application Example of 24-bit High-speed Counter (single-phase input) 3-2244.4.4 Ring Counter Function ........................................................................... 3-2254.4.5 Applications of Ring Counters ................................................................ 3-226
4.5 Special Functions Using High-speed Counters ...................... 3-2284.5.1 Specified Frequency Pulse Output Function .......................................... 3-2284.5.2 Applications of the Specified Frequency Pulse Output .......................... 3-2294.5.3 Frequency Counter Function .................................................................. 3-2314.5.4 Applications of Frequency Counters ...................................................... 3-2324.5.5 Cam Switch Function ............................................................................. 3-2334.5.6 Application of the Cam Switch ............................................................... 3-236
4.6 Direct Clock Pulse Output ............................................................. 3-2374.6.1 Outline of Direct Clock Pulse Output ...................................................... 3-2374.6.2 Pulse Output Setting with the High-speed Counter Comparator ............ 3-238
4.7 Examples of Direct Clock Pulse Output .................................... 3-2424.7.1 Example of Outputting a Pulse with 1:1 ON/OFF Ratio ......................... 3-2424.7.2 Example of Outputting a Pulse with Variable ON/OFF Ratio ................. 3-2454.7.3 Example of Stopping the Pulse Output at a Specified Pulse Count ....... 3-2494.7.4 Application of Direct Clock Pulse Output (Ramp-up/down control) ........ 3-251
Visu
al K
VSe
ries
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM203
4.1 High-speed Counter Instructions
3-204
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
CTH0: 16-Bit High-speed counter
CTH1: 16-Bit High-speed counter
CTC: High-speedcounter comparator
• 16-bit (0 to 65535) up/down counters forclock pulses with a 30-kHz input 1.
response frequency.• Can be changed to 24-bit (0 to 16777215)
counters with the MEMSW instruction. 2.
• Enables 30 kHz, two-phase input throughtwo channels.1.
• Hardware-based comparator between thepreset value and current value of thehigh-speed counter.
• The current value can be changed to apreset value by external input.
SET1
CTC
CTH
CTH
RES0
CTH1nnnn
CTCn#ddddd
CTH0nnnn
2008
0000
CTH0RES
0500SET
2103SET
CTC0RES
2008
0500RES
CTC0
0500 T000
#60000CTC0
#00030T000
CTH00004
HSP0004
1)
2)
3)
4)
5)
Input-enable relay
4.1 High-speed Counter InstructionsThis section describes the CTH0, CTH1, and CTC instructions, which are used forhigh-speed counters.
Count input
Example
Coding
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0009 LD CTC0
0001 HSP 0004 0010 SET 0500
0002 LD 2008 0011 LD 0500
0003 SET 2103 0012 TMR 000 #00030
0004 CON 0013 AND T000
0005 RES CTH0 0014 RES CTC0
0006 LD 0000 0015 CON
0007 CTH0 0004 0016 RES 0500
0008 CTC0 #6000
:
:
:
1. KV-300/Visual KV only2. Visual KV only
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM204
4.1 High-speed Counter Instructions
3-205
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Operands
CTH0: 00042100 to 2102
CTH1: 000505002200 to 2202
CTC0 to 3: Preset value#00001 to #65535
Key operation
Description
1) Initializes the setting when power is turned on.• The HSP instruction sets the input time constant of input relay 0004 to 10 µs.• The current value of CTH0 is reset as soon as it matches the preset value of
CTC0 when special utility relay 2103 is ON.2) The counting is disabled when input relay 0000 is OFF. Counting starts (at 0004)
when input relay 0000 turns ON.3) Sets "60000" as the preset value of the high-speed counter comparator.4) When the current value of CTH0 reaches "60000", output relay 0500 turns ON
and the current value is reset.5) Turns OFF both CTC0 and 0500 for three seconds after output relay 0500 turns
ON.
Tips
Unlike software-based counters, the high-speed counter is a hardware-based,program-independent counter. It achieves an input response frequency of 30 kHzwithout being affected by the scan time.
• Input relays 0004 and 0005 can independently count the pulses with a 30 kHzinput 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 inputand input from 0007 as phase B input (KV-10xx: 0001).
Note: When phase differential input is used, pulses with a maximum frequency of 30kHz can be counted, provided the pulses have a duty ratio of 1:1 (50%) and phasedifference of 90°. Inputting pulses with an irregular duty ratio or phase difference willdecrease the allowable input frequency.
SET1
RES0
CTC
CTH
Operand
Clock input
Preset value
ENTR-SRCH
ENTR-SRCH
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM205
4.2 Outline of High-speed Counters
3-206
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.2 Outline of High-speed CountersThis section describes the outline and specifications for high-speed counters andhigh-speed counter comparators featured with the Visual KV Series.
4.2.1 High-speed Counters and High-speed Counter Compara-tors
The high-speed counter is a hardware-based counter that can count high-speedpulses that cannot be counted by counters written in main routines (C or UDC).(Pulses with a maximum frequency of 30 kHz can be counted.). *High-speed counter comparators are hardware-based comparators that comparetheir preset value with the current value of one of the a high-speed counters.Both counters and comparators perform processing with hardware rather thansoftware programs, enabling high-speed performance independent of the scan time.
Structure of high-speed counters and high-speed counter comparatorsThe Visual KV PLC has two high-speed counters, each equipped with two high-speed counter comparators and dedicated internal clocks.
Block diagram of high-speed counters
1. With the KV-10xx, the external input relay for CTH0 is 0004 (phase A)/0000(phase B), and for CTH1 is 0005 (phase A)/0001 (phase B).
2. With the KV-10xx, the preset input relay for CTH0 is 0002, and for CTH1 is 0003.
For KV-10/80 user'sMax. response frequency: 10 kHz* 2100 0.8 µs
2101 6.4 µs2102 102.4 µs2200 0.4 µs2201 0.8 µs2202 3.2 µs
CTC2
CTH1
CTC3
DM1932, DM1933(INT2)DM1934, DM1935(INT3)
2203 to 2214
INT CTC2INT CTC3
2200 (1.0 µs)2201 (10.0 µs)2202 (100.0µs)
0500
0005/0007
CTC0
CTH0
CTC1
DM1928, DM1929(INT0)DM1930, DM1931(INT1)
2103 to 2114
INT CTC0INT CTC1
2100 (1.0 µs)2101 (10.0 µs)2102 (100.0 µs)
0004/0006
0005(0007)
0004(0006)
0008 (RESET) 2.
0009 (RESET) 2.
0500
0501
Phase APhase B
Internal clocks*
External input
16-bit high-speedcounter
high-speedcountercomparator
high-speedcountercomparator
Input capture device Special utility relay
Control circuit
Input capture deviceInternal clocks*
External input
16-bit high-speedcounter
high-speedcountercomparator
high-speedcountercomparator
Special utility relay
Control circuit
Phase APhase B
Internal connectionfor external clock
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM206
4.2 Outline of High-speed Counters
3-207
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
List of special utility relays for high-speed counter CTH0
* Read-only relay.
List of special utility relays for high-speed counter CTH1
* Read-only relay.
yaleR.oN noitcnuF
*0012 1(0HTCrofylnodesukcolclanretnI µ )s
*1012 01(0HTCrofylnodesukcolclanretnI µ )s
*2012 001(0HTCrofylnodesukcolclanretnI µ )s3012 .NOsnrut0CTCrotarapmocnehw0HTCsraelcyllacitamotuA oN:FFOseY:NO
40120CTCrotarapmocnehw0050morftuptuotceridselbane/selbasiD
.NOsnrutelbasiD:NOelbanE:FFO
5012 .NOsnrut0CTCrotarapmocnehw0050morftuptuotceridFFOsnruT oN:FFOseY:NO6012 .NOsnrut0CTCrotarapmocnehw0050morftuptuotceridNOsnruT oN:FFOseY:NO
7012rotarapmocemithcae0050morftuptuofosutatsFFO/NOsesreveR
.NOsnrut0CTCoN:FFOseY:NO
80121CTCrotarapmocnehw0050morftuptuotceridselbane/selbasiD
.NOsnrutelbasiD:NOelbanE:FFO
9012 .NOsnrut1CTCrotarapmocnehw0050morftuptuotceridFFOsnruT oN:FFOseY:NO
0112 .NOsnrut1CTCrotarapmocnehw0050morftuptuotceridNOsnruT oN:FFOseY:NO
1112rotarapmocemithcae0050morftuptuofosutatsFFO/NOsesreveR
.NOsnrut1CTCoN:FFOseY:NO
2112 .NOsnrut1CTCrotarapmocnehw0HTCsraelcyllacitamotuA oN:FFOseY:NO
3112 .0HTCrofedomnoitacilpitlumstceleS4x:NO/FFO2x:FFO/NO)eslup1(noitacilpitlumoN:FFO/FFO
seslup2:NO/NO4112
noitacilpitluMedom
noitacilpitlumoN)eslup1(
2x 4x seslup2
3112 FFO NO FFO NO4112 FFO FFO NO NO
yaleR.oN noitcnuF
*0022 1(1HTCrofylnodesukcolclanretnI µ )s
*1022 01(1HTCrofylnodesukcolclanretnI µ )s
*2022 001(1HTCrofylnodesukcolclanretnI µ )s3022 .NOsnrut2CTCrotarapmocnehw1HTCsraelcyllacitamotuA oN:FFOseY:NO
40222CTCrotarapmocnehw1050morftuptuotceridselbane/selbasiD
.NOsnrutelbasiD:NOelbanE:FFO
5022 .NOsnrut2CTCrotarapmocnehw1050morftuptuotceridFFOsnruT oN:FFOseY:NO6022 .NOsnrut2CTCrotarapmocnehw1050morftuptuotceridNOsnruT oN:FFOseY:NO
7022rotarapmocemithcae1050morftuptuofosutatsFFO/NOsesreveR
.NOsnrut2CTCoN:FFOseY:NO
80223CTCrotarapmocnehw1050morftuptuotceridselbane/selbasiD
.NOsnrutelbasiD:NOelbanE:FFO
9022 .NOsnrut3CTCrotarapmocnehw1050morftuptuotceridFFOsnruT oN:FFOseY:NO
0122 .NOsnrut3CTCrotarapmocnehw1050morftuptuotceridNOsnruT oN:FFOseY:NO
1122rotarapmocemithcae1050morftuptuofosutatsFFO/NOsesreveR
.NOsnrut3CTCoN:FFOseY:NO
2122 .NOsnrut3CTCrotarapmocnehw1HTCsraelcyllacitamotuA oN:FFOseY:NO3122 .1HTCrofedomnoitacilpitlumstceleS
seslup2:NO/NO4x:NO/FFO2x:FFO/NO)eslup1(noitacilpitlumoN:FFO/FFO4122
noitacilpitluMedom
noitacilpitlumoN)eslup1(
2x 4x seslup2
3122 FFO NO FFO NO4122 FFO FFO NO NO
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM207
4.2 Outline of High-speed Counters
3-208
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
Other special utility relays
Data memory
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 turnedoff or "ALL DATA MEMORY CLEAR" is executed. It is stored more than 20 dayswith the KV-10xx, and more than two months with other models.
Specifications of high-speed counters• The high-speed counter is a hardware-based up/down counter that counts from 0
to 65535 with an auto-reset function.
• The following operands can be specified for count inputs.
• High-speed counters CTH0 and CTH1 store current values only.
• When input relays 0004 and 0005 are selected as operands, they can be used ashigh-speed counters with a response frequency of 30 kHz.
• When special utility relays 2100 through 2102 and 2200 through 2202 are se-lected as operands, the high-speed counters can be used as high-speed timers.
• When relay 0500 is selected as an operand for CTH1, CTH1 can count the clockpulses produced by CTH0.
• CTH0 and CTH1 can be used as 24-bit high-speed counters when the MEMSWinstruction is set.
"MEMSW instruction" (p. 3-92), "4.4.1 24-bit High-speed Counter" (p. 3-221), "4.3.4 Count InputMethod" (p. 3-212), "When using comparator output from other counters as count input" (p. 3-213).
yaleR.oN noitcnuF
0042 langislanretxeybeulavteserpot0HTCfoeulavtnerrucsegnahCleveL:NO/NOegdegnillaftA:NO/FFOegdegnisirtA:FFO/NOdesutoN:FFO/FFO1042
6042 oN:FFOseY:NO.retnuocgnirsa0HTCsteS
7042.0HTCrofdesusiedomnoitacilpitlumonnehwtupniBesahpserongI
.laususatupniBesahpesU:FFO.putnuocsyawladnatupniBesahperongI:NO
8042 langislanretxeybeulavteserpot1HTCfoeulavtnerrucsegnahCleveL:NO/NOegdegnillaftA:NO/FFOegdegnisirtA:FFO/NOdesutoN:FFO/FFO9042
4142 oN:FFOseY:NO.retnuocgnirsa1HTCsteS
5142.1HTCrofdesusiedomnoitacilpitlumonnehwtupniBesahpserongI
.laususatupniBesahpesU:FFO.putnuocsyawladnatupniBesahperongI:NO
.oNMD noitpircseD
1091MD/0091MD .daersi)stibredro-hgih/stibredro-wol(0HTCtib-42foeulavtnerruC
3091MD/2091MD .daersi)stibredro-hgih/stibredro-wol(1HTCtib-42foeulavtnerruC
5091MD/4091MD .daersi)stibredro-hgih/stibredro-wol(0CTCtib-42foeulavtnerruC7091MD/6091MD .daersi)stibredro-hgih/stibredro-wol(1CTCtib-42foeulavtnerruC9091MD/8091MD .daersi)stibredro-hgih/stibredro-wol(2CTCtib-42foeulavtnerruC1191MD/0191MD .daersi)stibredro-hgih/stibredro-wol(3CTCtib-42foeulavtnerruC3191MD/2191MD .nettirwsi)stibredro-hgih/stibredro-wol(0HTCtib-42foeulavtnerruC
5191MD/4191MD .nettirwsi)stibredro-hgih/stibredro-wol(1HTCtib-42foeulavtnerruC
7191MD/6191MD .nettirwsi)stibredro-hgih/stibredro-wol(0CTCtib-42foeulavteserP
9191MD/8191MD .nettirwsi)stibredro-hgih/stibredro-wol(1CTCtib-42foeulavteserP
1291MD/0291MD .nettirwsi)stibredro-hgih/stibredro-wol(2CTCtib-42foeulavteserP3291MD/2291MD .nettirwsi)stibredro-hgih/stibredro-wol(3CTCtib-42foeulavteserP5291MD/4291MD .nettirwsi)stibredro-hgih/stibredro-wol(0HTCfoeulavteserP7291MD/6291MD .nettirwsi)stibredro-hgih/stibredro-wol(1HTCfoeulavteserP
retnuocdeeps-hgiH dnarepO egnartnemerusaeM
0HTC 4000,2012ot001253556ot00000#
1HTC 0050,5000,2022ot0022
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM208
4.2 Outline of High-speed Counters
3-209
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Note 1: CTH instructions cannot be duplicated in a program. A maximum of twocounters, CTH0 and CTH1, can be used in one program.
Note 2: The operands for a high-speed counter cannot be changed during programexecution.
Note 3: When using a high-speed counter with external inputs, the input time con-stant must be set to 10 µs with the HSP instruction or with special utility relay 2813.(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) forphase B input. Therefore, do not use input 0006 (KV-10xx: 0000) other than for thehigh-speed counter.
Note 5: When selecting no multiplication mode, and you do not want to use input0006 (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) forphase B input. Therefore, do not use input 0007 (KV-10xx: 0000) other than for thehigh-speed counter.
Note 7: When selecting no multiplication mode, and you do not want to use input0007 (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, onlysingle-phase input is available. In this case, external input relays 0005 and 0007 forCTH1 can be used as normal input relays.
Note 9: When using phase differential input, pulses with a maximum frequency of 30kHz can be counted, provided the pulses have a duty ratio of 1:1 (50%) and phasedifference of 90°. Inputting pulses with an irregular duty ratio or phase difference willdecrease 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: morethan 20 days). The value can also be stored in EEPROM.
"3.5 System Mode" (p.1-94).
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. Setspecial utility relays (2103 to 2112, 2203 to 2212) to change the ON/OFF statusof output relays 0500 and 0501.
• The following table shows the relationship between the high-speed counters andhigh-speed counter comparators.
Note 1: Once the high-speed counter comparator turns ON, it remains ON until aRES instruction is encountered.Note 2: When a high-speed counter comparator is used as an interrupt, the interruptis executed as soon as the current value of the high-speed counter reaches thepreset value of the comparator. At the same time, the contact for the high-speedcounter comparator automatically turns OFF.Note 3: CTC2 or CTC3 cannot be used as comparators for CTH0; CTC0 or CTC1cannot be used as comparators for CTH1.Note 4: Do not specify "#00000" as the preset value for CTC0 through CTC3.
deeps-hgiHretnuoc
retnuocdeeps-hgiHrotarapmoc
eulavteserPegnar
tceriDtuptuo
stpurretnI
0HTC 1CTC,0CTC53556ot1#
0050 1CTCTNI,0CTCTNI1HTC 3CTC,2CTC 1050 3CTCTNI,2CTCTNI
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM209
4.2 Outline of High-speed Counters
3-210
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.2.2 Internal Clock for High-speed Counters• Each high-speed counter (CTH) is equipped with a dedicated internal clock.• To use the internal clock, specify the appropriate relay No. as an operand for the
CTH instruction.• The internal clock or external pulses cannot be changed during program execu-
tion.• Each clock has the following count period:
High-speed counter internal clock error• Absolute error: ± 200 ppm• Temperature coefficient: 00• Relative error between CTH0 and CTH1: ± 0
retnuocdeeps-hgiH 0HTC 1HTC doireP
.oNyaleR0012 0022 0.1 µs
1012 1022 0.01 µs2012 2022 0.001 µs
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM210
4.3 Setting and Operation of High-speed Counters
3-211
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
retnuocdeeps-hgiH eulavtnerruC
0HTC53556ot0
1HTC
retnuocdeeps-hgiHretnuocdeeps-hgiH
rotarapmoc
0HTC0CTC
1CTC
1HTC2CTC3CTC
deeps-hgiHretnuoc
deeps-hgiHretnuoc
rotarapmoc
ytilitulaicepSyaler
yalerytilitulaicepsfognitteS
0HTC0CTC 4012 oN:NOseY:FFO.FFO/NO0050yalertuptuosnruT
1CTC 8012 oN:NOseY:FFO.FFO/NO0050yalertuptuosnruT
1HTC2CTC 4022 oN:NOseY:FFO.FFO/NO1050yalertuptuosnruT
3CTC 8022 oN:NOseY:FFO.FFO/NO1050yalertuptuosnruT
4.3 Setting and Operation of High-speedCounters
The high-speed counters and high-speed counter comparators operate using dataspecified with special utility relays.
4.3.1 Reading the Current Value of the High-speed CounterThe current value of a high-speed counter is normally written as 16-bit data (0 to65535).The range of the current value for high-speed counters is as follows:
Refer to "4.4.1 24-bit High-speed Counter" (p. 3-221) when using the 24-bit high-speed counter.
4.3.2 Preset Value of the High-speed Counter ComparatorThe preset value of a high-speed counter comparator is written as 16-bit data (0 to65535).The relationship between high-speed counters and high-speed counter comparatorsis as follows:
Refer to "4.4.1 24-bit High-speed Counter" (p. 3-221) when using the 24-bit high-speed counter.
4.3.3 Comparator OutputThe high-speed counter comparator provides the comparator output function, whichturns ON outputs as soon as the comparator turns ON, without being affected by thescan time.Comparator output is controlled by setting special utility relays. The relationshipsamong the high-speed counters, high-speed counter comparators, and special utilityrelays are as follows:
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM211
4.3 Setting and Operation of High-speed Counters
3-212
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.3.4 Count Input MethodSelect the input source for the high-speed counter.
When using an internal clock as input
Three types of internal clocks are provided: 1 µs, 10 µs, and 100 µs.Set the desired internal clock with a special utility relay.
When using external inputs as count inputs
Set special utility relays as follows:
Operation mode
The counting method can be selected from the following when external inputs areused.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).
Types of operation modes
No multiplication mode (single-phase input)Counts up at the rising edge of phase A while phase B is OFF.Counts down at the rising edge of phase A while phase B is ON.
• With direction judgement (Special utility relay 2407: OFF)
• Without direction judgement (Special utility relay 2407: ON)
Phase B input can be ignored by turning ON special utility relay 2407 (for CTH0) or2415 (for CTH1).
0006
0004
CTH0 0 1 2 3 2 1 0
OFF
ON
OFF
ON
(Counter value)
(Phase A)
(Phase B)
edomnoitarepO0HTC 1HTC
3112 4112 7042 3122 4122 5142
noitacilpitlumoNesahp-elgnis(
)tupni
tnemegdujnoitceridhtiWtupniBesahpnehwputnuoC(nwodtnuoc,FFOsi]7000[6000
)NOnehw
FFO FFO FFO FFO FFO FFO
tnemegdujnoitceridtuohtiWgnirongiybputnuocsyawlA(
)]7000[6000tupniBesahpFFO FFO NO FFO FFO NO
laitnereffidesahPtupni
2x NO FFO — NO FFO —
4x FFO NO — FFO NO —
dohtemeslup-2)nwodtnuoc:Besahp,putnuoc:AesahP(
NO NO — NO NO —
tupni)1HTC(0050 — — — — — —
0006
0004
CTH0 0 1 2 3 4 5 6
OFF
ON
OFF
ON
(Counter value)
(Phase A)
(Phase B)
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM212
4.3 Setting and Operation of High-speed Counters
3-213
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Double (x2) mode: Counts up/down based on the phase differencebetween two-phase pulse inputs (phase A andphase B).
Quadruple (x4) mode: Counts up/down based on the phase differencebetween two-phase pulse inputs (phase A andphase B).
2-pulse method mode: Counts up at the rising edge of phase A andcounts down at the rising edge of phase B.
Count up: Rising edge of phase ACount down: Rising edge of phase B
Note 1: Use SET-RES instructions to set the special utility relays.
Note 2: When using phase differential input, pulses with a maximum frequency of 30kHz can be counted, provided the pulses have a duty ratio of 1:1 (50%) and phasedifference of 90°. Inputting pulses with an irregular duty ratio or phase difference willdecrease the allowable input frequency.
When using comparator output from other counters as count input
When relay 0500 is specified as the operand for CTH1, the pulses produced byCTH0 can be directly output from 0500 to CTH1.In this case, input relays 0005 (phase A) and 0007 (phase B) for CTH1 can be usedas normal input relays.
3 2 1 07 6 5 4
0006
0004
CTH00 1 2 3 4 5 6 7 8
OFF
ON
OFF
ON
7 6 5 4 3 2 1 015 14 13 12 11 10 9 8
0006
0004
CTH00 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
OFF
ON
OFF
ON
0006
0004
CTH0
0 1 2 3 4 5 6 5 4 3 2 1 0
OFF
ON
OFF
ON
(Counter value)
(Phase A)
(Phase B)
(Counter value)
(Phase A)
(Phase B)
(Counter value)
(Phase A)
(Phase B)
0500
CTH1 0 1 2 3 4 5 6
OFF
ON
(Counter value)
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM213
4.3 Setting and Operation of High-speed Counters
3-214
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.3.5 Resetting the High-speed CounterReset is an operation used to set the current value of a high-speed counter to "0".Four types of reset operations are available: reset with input-enable relay, reset withexternal input, reset automatically after counting up, and reset with the RES CTHinstruction.
Automatic reset after counting up
Resets the counter value as soon as the preset value matches the current value(CTC = CTH).This reset operation is independent of the scan time.
Note: Do not specify the same values for CTC0 and 1 (2 and 3) to automaticallyreset the counter with both comparators.
Reset with the RES CTH instruction
Resets the counter by writing a RES CTH instruction to the program.This reset operation is dependent on the scan time.
* CTH is reset by the output process of the scan which executes the RES CTHinstruction.
Reset with the input-enable relay
Resets the counter at execution of CTH instruction during the scan after the input-enable relay is turned OFF.This reset operation is dependent on the scan time.
* CTH is reset at execution of the CTH instruction during the scan after the input-enable relay turns OFF.
CTH
Scan
Execution of CTH instruction
Input-enable relayfor CTH instruction
deeps-hgiHretnuoc
deeps-hgiHretnuoc
rotarapmoc.oNyaleR noitarepO
0HTC0CTC 3012 era2112dna3012syalerytilitulaicepsnehW
satesersieulav0HTCtnerruceht,NOdenrutteserp1CTCro0CTCehtsehctamtisanoos
.eulav1CTC 2112
1HTC2CTC 3022 era2122dna3022syalerytilitulaicepsnehW
satesersieulav1HTCtnerruceht,NOdenrutteserp3CTCro2CTCehtsehctamtisanoos
.eulav3CTC 2122
CTH
CTH = CTC
CTH is reset when CTH value equals CTC value.
Scan
CTH
Execution of RES CTH instruction
Scan
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM214
4.3 Setting and Operation of High-speed Counters
3-215
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Reset with external input
Resets the counter at the instant the external reset input relay turns ON.The external reset is assigned to input relay 0008 (KV-10xx: 0002) for CTH0, andinput relay 0009 (KV-10xx: 0003) for CTH1.The timing of the reset can be changed by setting relays 2400 and 2401 (for CTH0)or 2408 and 2409 (for CTH1) as follows.This reset operation is independent of the scan time.
* 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 externalreset 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) or2408 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:
Use the STA or DW instruction to write data to the data memory.
Note 1: The preset function is available only with the external reset input. The CTHvalue 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 intoDM1924 and DM1926 only.
Scan
Externalreset input
CTH
deeps-hgiHretnuoc
.oNyaleR sutatS .oNyaleR sutatS noitarepO
0HTC 0042
FFO
1042
FFO .noitarepoteserlanretxeselbasiD
NO FFOtupnifoegdegnisirtaretnuocsteseR
.)2000:xx01-VK(8000
FFO NOtupnifoegdegnillaftaretnuocsteseR
.)2000:xx01-VK(8000
NO NO8000tupninehwretnuocsteseR
.NOsi)2000:xx01-VK(
1HTC 8042
FFO
9042
FFO .noitarepoteserlanretxeselbasiD
NO FFOtupnifoegdegnisirtaretnuocsteseR
.)3000:xx01-VK(9000
FFO NOtupnifoegdegnillaftaretnuocsteseR
.)3000:xx01-VK(9000
NO NO9000tupninehwretnuocsteseR
.NOsi)3000:xx01-VK(
.oNMD noitpircseD
)stibredro-hgih(5291MD,)stibredro-wol(4291MD 0HTCrofeulavteserP
)stibredro-hgih(7291MD,)stibredro-wol(6291MD 1HTCrofeulavteserP
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM215
4.3 Setting and Operation of High-speed Counters
3-216
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.3.6 Differences with the CTH Instruction between theConventional and Visual KV Series
The Visual KV Series has some different high-speed counter operations from theconventional KV Series [KV-10/16/24/80R(W)/T(W)].
Input-enable relay
• With the conventional KV Series, the current value of the high-speed counter isreset 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 aresult, 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 atthe falling edge of the input-enable relay, so that the counter does not continuecounting.
High-speed counter (CTH)
• The conventional KV Series includes high-speed counter CTH0, which is an 8-bitcounter. The period of the internal clock is different from that in the new KVSeries.
• The Visual KV Series allows you to reset a high-speed counter with externalinputs. Its high-speed counter CTH0 is a 16-bit counter (can also be used as 24-bit counter).
• With the Visual KV Series, when using the high-speed counter, the input timeconstant must be set shorter by using the HSP instruction or by turning ONspecial utility relay 2813.
Phase differential inputThe Visual KV Series allows phase differential input for the high-speed counter.
Response frequency
The Visual KV Series provides a response frequency of 30 kHz.
High-speed counter comparator• The high-speed counter comparator turns ON the contact when its preset value
matches the current value of the high-speed counter. Consequently, the contactmay turn ON during the scan time.Be careful when using the contact for one comparator in several points in aprogram.
Special utility relay
A portion of the special utility relay assignment is different from that of the conven-tional KV Series.
0001 CTH00004
Count inputInput-enable relay
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM216
4.3 Setting and Operation of High-speed Counters
3-217
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
2008
2002
0000
2214RES
2213SET
2114RES
2113SETEI
#60000
CTC0
CTH0RES
0500RES
CTH00004
CTH10005
HSP0005
HSP0006
HSP0004
HSP0007
INTCTC0
2002 2009
2009
2002
ENDH
RETI
END
0500SET
CTH0RES
CTH1RES
CTH1LDA
#60000CMP
4.3.7 Applications of High-speed CountersComparing encoder values
Uses two encoders to input phase differential signals to input relays 0004 and 0006,and 0005 and 0007. Turns ON output relay 0500 if the count value of 0005 and 0007is greater than that of 0004 and 0006 when 0004 and 0006 count "60000".
Compares current value of CTH1 with"#60000". Turns ON 0500 when value isgreater than "#60000". Turns OFF 0500when value is smaller.
Initial settingSET 2113RES 2114SET 2213RES 2214
Setting for CTH0
Setting for CTH1
Sets input time constant of inputs 0004,0005, 0006, and 0007 to 10 µs.
Phase differential input to inputs 0004 and0006
Specifies preset value of CTC0 to "#60000".
Phase differential input to inputs 0005 and0007
Setting multi-level high-speed counters
Sets the preset value of the high-speed counter comparator for the high-speedcounter for input relay 0005 as follows:
#01000 DM0000#02000 DM0001#03000 DM0002
When the current counter value reaches one of the preset values, the respectiveoutput turns ON as follows:
DM0000 0500 turns ON.DM0001 0501 turns ON.DM0002 0502 turns ON.
DM0000STA
#01000LDA
#02000LDA
DM0001STA
DM0000CMP
CTH1LDA
DM0001CMP
DM0002CMP
#03000LDA
DM0002STA
2008
0001
2009
2009
2009
2002
CTH10005
2002 HSP0005
0500
0501
0502
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM217
4.3 Setting and Operation of High-speed Counters
3-218
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
2203SET
CTH1RES
CTC2RES
CTC2 T001
2008
2002
#60000 CTC2
CTH10005
2002 HSP0005
0502 #00030T001
Clearing the current value of the high-speed counter
Counts pulses at input relay 0005. When the current value reaches the preset value"60000", clears the current value of high-speed counter CTH1 and turns ON outputrelay 0502 for 3 seconds.
Cording
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0015 CTH1 00050001 LDA #01000 0016 LD 20020002 CON 0017 LDA CTH10003 STA DM0000 0018 MPS0004 CON 0019 CMP DM00000005 LDA #02000 0020 ANB 20090006 CON 0021 OUT 05000007 STA DM0001 0022 MRD0008 CON 0023 CMP DM0010009 LDA #03000 0024 ANB 20090010 CON 0025 OUT 05010011 STA DM0002 0026 MPP0012 LD 2002 0027 CMP DM00020013 HSP 0005 0028 ANB 20090014 LDB 0001 0029 OUT 0502
Line No. Instruction Operand
0000 LD 2008
0001 SET 2203
0002 CON
0003 RES CTH
0004 LD 2002
0005 HSP 0005
0006 LD 2002
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
Cording
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM218
4.3 Setting and Operation of High-speed Counters
3-219
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Phase differential input
• Inputs phase differential signals from input relays 0004 and 0006 and countspulses at CTH0.
• The count value is written to DM0000.• When the current value of CTH0 reaches "60000", clears the value, turns ON
output 0500, and stops counting at CTH0.• Input relay 0008 is used as an external reset.
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 and turn OFF 2401 to enable the external reset.
The counter is reset at the rising edge of input 0008.
Note : External reset input 0008 is set with hardware. Programming is not necessaryexcept for setting the external reset enable relays (2400 to ON and 2401 to OFF).
2103SETEI
2113SET
2114RES
2401RES
CTH0RES
0500
2008
0500
2002
CTH00004
2002
END
INTCTC0
RETI
ENDH
#60000CTC0
2002 HSP0004
HSP0006
HSP0008
CTH0LDA
DM0000STA
SET
2400SET Initial setting
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0016 HSP 00060001 EI 0017 HSP 00080002 CON 0018 LDB 05000003 SET 2103 0019 CTH 0 00040004 CON 0020 CTC 0 #600000005 SET 2113 0021 LD 20020006 CON 0022 LDA CTH00007 RES 2114 0023 CON0008 CON 0024 STA DM00000009 SET 2400 0025 END0010 CON 0026 INT CTC00011 RES 2401 0027 LD 20020012 CON 0028 SET 05000013 RES CTH0 0029 RETI0014 LD 2002 0030 ENDH0015 HSP 0004
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM219
4.3 Setting and Operation of High-speed Counters
3-220
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
Fetching counts from encoder
Uses the double (x2) multiplication mode to fetch phase differential input from theencoder.The fetched data is output as BCD data. Phase differential input: 0004, 0006 BCDoutput: 0600 to 0615 (4 digits)
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.
The counter is reset at the rising edge of input 0008.
Note : The external reset input 0008 is set with hardware. Programming is notnecessary except for setting the external reset enable relay (2400 to ON).
2103SET
2113SET
2114RES
CTH0RES
2400SET
2008
CTH0LDA
TM00STA
#00002DIVLDA TBCD
0600STA
2002 #00000
0000 CTH00004
2002 HSP0004
HSP0006
HSP0008
END
ENDH
Initial setting
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2008 0015 CTH 0 0004
0001 SET 2103 0016 LD 2002
0002 CON 0017 LDA #0000
0003 SET 2113 0018 CON
0004 CON 0019 STA TM00
0005 RES 2114 0020 CON
0006 CON 0021 LDA CTH0
0007 RES CTH0 0022 CON
0008 CON 0023 DIV #00002
0009 SET 2400 0024 CON
0010 LD 2002 0025 TBCD
0011 HSP 0004 0026 CON
0012 HSP 0006 0027 STA 0600
0013 HSP 0008 0028 END
0014 LD 0000 0029 ENDH
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM220
4.4 Expanded Functions of High-speed Counters
3-221
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.4 Extended Functions of High-speedCounters
This section describes the 24-bit high-speed counter and ring counter functions.
4.4.1 24-bit High-speed CounterNormally, the high-speed counter operates with 16 bits. You can operate the counterwith 24 bits (0 to 16777215) using special utility relays.Set the 24-bit operation with the MEMSW instruction. "MEMSW instruction" (p. 3-92)
MEMSW instruction: SW3
MEMSW instruction: SW4
The following data memories are used for 24-bit operation.Read areas
Write areas
.oN hctiwsfonoitcnuF NO FFO
3retnuoctib-61/tib-42gnitteS
0HTCrofrotarapmoctib-42 tib-61
.oNMD noitpircseD .oNMD noitpircseD
0091MDtnerrucfostibredro-woL
eulav0HTC6091MD
teserpfostibredro-woLeulav1CTC
1091MDtnerrucfostibredro-hgiH
eulav0HTC7091MD
teserpfostibredro-hgiHeulav1CTC
2091MDtnerrucfostibredro-woL
eulav1HTC8091MD
teserpfostibredro-woLeulav2CTC
3091MDtnerrucfostibredro-hgiH
eulav1HTC9091MD
teserpfostibredro-hgiHeulav2CTC
4091MD0CTCteserpfostibredro-woL
eulav0191MD
teserpfostibredro-woLeulav3CTC
5091MDteserpfostibredro-hgiH
eulav0CTC1191MD
teserpfostibredro-hgiHeulav3CTC
.oN hctiwsfonoitcnuF NO FFO
0retnuoctib-61/tib-42gnitteS
1HTCrofrotarapmoctib-42 tib-61
.oNMD noitpircseD .oNMD noitpircseD
2191MDtnerrucfostibredro-woL
eulav0HTC8191MD
teserpfostibredro-woLeulav1CTC
3191MDtnerrucfostibredro-hgiH
eulav0HTC9191MD
teserpfostibredro-hgiHeulav1CTC
4191MDtnerrucfostibredro-woL
eulav1HTC0291MD
teserpfostibredro-woLeulav2CTC
5191MDtnerrucfostibredro-hgiH
eulav1HTC1291MD
teserpfostibredro-hgiHeulav2CTC
6191MDteserpfostibredro-woL
eulav0CTC2291MD
teserpfostibredro-woLeulav3CTC
7191MDteserpfostibredro-hgiH
eulav0CTC3291MD
teserpfostibredro-hgiHeulav3CTC
Visual KV Series Only
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM221
4.4 Expanded Functions of High-speed Counters
3-222
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
The high-speed counter and high-speed counter comparator update the contents ofthe read area of data memory each scan time.At the start of an interrupt routine, the current value is updated. The contents of thewrite 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)
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 iseffective when the Visual KV is in RUN mode.You must change the program to change between 16-bit and 24-bit settings.
Setting the 24-bit high-speed counter comparator
To specify the preset value for the 24-bit high-speed counter comparator, write thevalue into the write area DM1916 to DM1923 and execute the STA and CTC instruc-tions to specify or change the preset value.When the setting or change is properly performed, the CTC read areas DM1904through DM1911 are updated with the new values after one scan.
Changing the preset valueChange the preset value for the 24-bit high-speed counter comparator using theAccess Window, programming support software, handheld programmer, or operatorpanel with the following procedure.
1. Write the desired preset value into data memory.
Write the desired preset value to the CTC preset value write areas DM1916through DM1923.
2. Change the preset value of CTC. (See the notes on the next page.)• With the Access Window
Call CTC in device mode and change the value.
• With the "KV IncrediWare (DOS)" programming support softwareChange the preset value of CTC with the "Edit Device CTC" [F2] option.
• With the "LADDER BUILDER for KV" programming support softwareChange the preset value of CTC in the dialog box.
• With the KV-P3E(01) handheld programmerChange the preset value of CTC with the "TIMER COUNTER SETTINGCHANGE" function.
For more about detailed operation, refer to "Chapter 3 Access Window" (p. 1-79), "Chapter 6Handheld 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 suchas STA CTC0, the value entered as an operand is ignored but the value written inDM1916 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-speedcounter comparator preset value (DM1916 through DM1923) before executing thechange operation (e.g., STA instruction).
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM222
4.4 Expanded Functions of High-speed Counters
3-223
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.4.2 Changing the Current Value of a 24-bit High-speedCounter
Change the current value of the 24-bit high-speed counter with the Access Window,programming support software, handheld programmer, or operator panel with thefollowing procedure.
1. Write the desired current value into data memory.
Write the desired current value to the CTH current value write areas DM1912through DM1915.
2. Change the current value of CTH. (See notes below.)• With the Access Window
Call CTH in device mode and change the value.
• With the "KV IncrediWare (DOS)" programming support softwareChange the preset value of CTH with the "Edit Device CTH" [F2] option.
• With the "LADDER BUILDER for KV" programming support softwareChange the preset value of CTH in the dialog box.
• With the KV-P3E(01) handheld programmerChange the preset value of CTH with the "TIMER COUNTER CURRENT VALUECHANGE" function.
For more about detailed operation, refer to "Chapter 3 Access Window" (p.1-79), "Chapter 6Handheld Programmer" (p.1-195) and "Chapter 2 Instructions" (p.3-33).
Note 1: The current value of the high-speed counter cannot be changed in theladder program.
Note 2: DM1900 to DM1923, the data memories for 24-bit high-speed counters, canbe used only when a 24-bit high-speed counter is specified with the MEMSW in-struction.
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM223
4.4 Expanded Functions of High-speed Counters
3-224
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.4.3 Application Example of 24-bit High-speed Counter(single-phase input)
The following is a ladder program using a 24-bit high-speed counter and high-speedcounter comparator with a preset value of "1000000".
1) Sets CTH0 as the 24-bit high-speed counter with the MEWSW instruction. (Turnon 3 of SW3.)
2) When power is turned on, writes the preset value "1000000" of the high-speedcounter 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) andDM0001 (high-order bits) each scan time.
2008 CTH0RES
0008
CTC0STA
DM1916STA
#16960LDA
DM1917STA
#00015LDA
2002 DM0000STA
DM1900LDA
DM0001STA
DM1901LDA
2002
0002
0001
HSP0004
2002
0003
0004CTH00004
0006
END0007
0005
ENDH
#65535CTC0
2)
1)
3)
4)
5)
6)
MEMSW$0800
Low-order 16 bits ofcurrent value of high-speed counter
High-order 16 bits ofhigh-speed countercomparator
Low-order 16 bits ofhigh-speed countercomparator
Writes preset value ofhigh-speed countercomparator
High-order 16 bits ofcurrent value of high-speed counter
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM224
4.4 Expanded Functions of High-speed Counters
3-225
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.4.4 Ring Counter FunctionNormally, the counter reads "#65535 ($FFFF)" by counting down from "0" by one.The ring counter function is an additional function of the automatic clear function. Itreads "preset value - 1" when it counts down from "0" by one.
Operation of the ring counter function
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 specialutility relay 2112 (for CTH0) or 2212 (for CTH1).
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 upoperations, but is disabled in counting down operations.
Example: When CTC = 100
0 65535
0 CTC1 -1
( CTC3 -1)
65535
Not used
Normal counter
Ring counter
CTH
0 1 2 97 98 99 0 1 2
CTC
9798992 1 0
Countup
Countdown Turns ON.
Does not turn ON.
retnuocdeeps-hgiH rotarapmocretnuocdeeps-hgiH yalerytilitulaicepS
desusi0HTCnehW .1CTCot"1+eulavtimilreppu"teS .6042NOnruT
desusi1HTCnehW .3CTCot"1+eulavtimilreppu"teS .4142NOnruT
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM225
4.4 Expanded Functions of High-speed Counters
3-226
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
0 9999
2008
0003
0005
CTH0RES
0007
EI2406SET
2112SET
2114RES
2113SET
2002
0001
HSP00040002
END
0006
INTCTC1
0010
0011
RETI
0009
ENDH
#00010T000
1)
0500RES 5)
2)HSP0006
2002 CTH000040004
0500 T000
3)
0500SET 6)
2002
0008
#10000CTC1 4)
Sets high-speed counter indouble (x2) multiplication mode.
Sets ringcounter.
Automatic resetof high-speedcounter
4.4.5 Applications of Ring CountersWhen using a 16-bit high-speed counter
The following is a ladder program that uses the ring counter of a 16-bit high-speedcounter with the preset value of "10000".
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 thehigh-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.
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM226
4.4 Expanded Functions of High-speed Counters
3-227
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
0 99999
0013
2008
0004
0006
CTH0RES
0008
EI2406SET
2114RES
2113SET
2002
0002
#00001LDA
DM1919STA
#34464LDA
DM1918STA
CTC1STA
HSP0004
0003
0012
END
0007
INTCTC1
0011
RETI
0010
ENDH
#00010T000
2)
1)
3)
0500RES
6)
HSP0006
2002 CTH00004
0005
0500 T000
4)
0500SET
2002
0009
7)
#65535CTC1
5)
8)
2112SET
0001MEMSW
$0800
Writes presetvalue of high-speed countercomparator.
Sets high-speedcounter in double (x2)multiplication mode.
Sets ringcounter.
Automatic reset ofhigh-speed counter
High-order 16bits of high-speed countercomparator
Low-order 16bits of high-speed countercomparator
When using a 24-bit high-speed counter
The following is a ladder program that uses the ring counter of a 24-bit high-speedcounter with the preset value of "100000".
1) Sets CTH0 as a 24-bit high-speed counter using the MEMSW instruction (Turnon 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) forthe 24-bit high-speed counter (CTH0). Sets the preset value with the STA CTC0instruction.
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.
KVNKA Chap 04_1.p65 08.3.11, 0:06 PM227
4.5 Special Functions Using High-speed Counters
3-228
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
OFF
ON
4.5 Special Functions Using High-speedCounters
This section describes the specified frequency pulse output function, frequencycounter function, and cam switch function.
4.5.1 Specified Frequency Pulse Output FunctionWith high-speed counter CTH1, output pulses from output relay 0501 with thefrequency (Hz) specified in data memory DM1936. To activate this function, write thedesired value into DM1936 and turn ON special utility relay 2306.
The internal clock of the high-speed counter is automatically set to 1 µs. Pulses withduty 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 specifiedfrequency 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 dutyPulse duty is the ratio of the pulse widths between ON time and OFF time. A pulseduty of 50% means that the pulse widths between ON time and OFF time are thesame, as follows.
The ratio between ON and OFF time is 1:1.
Device used for specified frequency pulse outputSpecial utility relays
Data memory
.oNyaleR noitpircseD
6032noitcnuFoN:FFO,seY:NO.tuptuoeslupycneuqerfdeificepsesU
.NOsnrut7032yalerrorrenehwFFOdecrofsi
7032.noitcnuftuptuoeslupycneuqerfdeificepsrofgalfrorrE
.00005ot61nahtrehtosi6391MDfostnetnocnehwNOsnruT
.oNMD noitpircseD
6391MD .nettirwsituptuoeslupycneuqerfdeificepsrofeulavteserP
Visual KV Series Only
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM228
4.5 Special Functions Using High-speed Counters
3-229
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Setting method• Set the desired output frequency (Hz) into DM1936. The available range is 16 Hz
to 50 kHz (16 to 50000).• Pulses are output when special utility relay 2306 is ON. The output is stopped
when the relay is turned OFF.• If an unacceptable frequency is specified, special utility relay 2307 (error relay)
turns ON. Special utility relay 2306 is turned OFF and pulse output is stopped.
Note 1: The available minimum frequency specified in DM1936 is 16 Hz.Note 2: The output is stopped when a value of 15 or less is specified in DM1936.
Note 3: Starts and stops of pulse output or frequency changes are executed aftereach scan.
Note 4: It takes a maximum of 200 µs from when the output command is issued untilpulses are output.
Note 5: CTH1 and special utility relays 2200 through 2215 cannot be used when thespecified frequency pulse output function is used.
4.5.2 Applications of the Specified Frequency Pulse Output Program using a digital trimmerThe following ladder program illustrates how to use a digital trimmer to output pulsesat a desired frequency (16 Hz to 10 kHz).Pulse output is stopped when the value of the digital trimmer decreases to 15 orless.
1) Sets the upper limit of the digital trimmer to "10000" and turns ON special utilityrelay 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.
2008
0003
0005
#10000LDA
DM1938STA
0TMIN
DM1936STA
2002
0001
2307
0002
END
ENDH
0004
0500
2306SET 1)
2)
3)
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM229
4.5 Special Functions Using High-speed Counters
3-230
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
Program for speed controlThe following ladder program illustrates speed control using the specified frequencypulse output function.Control is started when input relay 0000 turns ON. The operation is slowed downand then stopped when input relay 0001 turns ON.By specifying the speed (Hz) in data memory DM0000, the program controls thespeed with a start-up speed of 16 Hz and an acceleration speed of 100 Hz/100 ms.
1) Sets "16" as the preset speed at the rising edge of input relay 0000. Turns ONspecial utility relay 2306 to start the specified frequency pulse output. Then, turnsON 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 thepreset 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 differenceis "100" or more, the speed is accelerated by "100".
8) Deceleration process. When the current speed is faster than the preset speed byless than "100", the speed is decelerated by the difference. When the differenceis "100" or more, the speed is decelerated by "100".
0003
0005
TM02ADD
#00016LDA
DM1936LDA
DM0000CMP
DM0000STA
DM1936CMP
DM1936STA
TM02STA
DM1936LDA
0001
2010
2307
0002
0006
END
SBN00
SBN01
RET
0004
0500
1000DIFU
0000 1000 1100SET
1001DIFU
#00100T 000S
0001 1001 1101SET
1101
DM0000LDA
DM1936SUB
#00100CMP
2011
#00100ADD
DM1936STA
DM1936LDA
2011
2002
TM02SUB
DM1936STA
TM02STA
DM1936LDA
RET
ENDH
DM1936LDA
DM0000SUB
#00100CMP
2011
#00100SUB
DM1936STA
DM1936LDA
2011
2002
1100
00CALL
T000
0007
0008
0011
0013
0009
0010
0014
0012
0015
0016
0017
2009
01CALL
2011
T000
1101RES
1100RES
2306RES
2306SET 1)
2)
3)
4)
5)
6)
7)
8)
#00016LDA
DM1936STA
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM230
4.5 Special Functions Using High-speed Counters
3-231
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.5.3 Frequency Counter FunctionHigh-speed counter CTH0 is used. Write the interval (ms) of frequency measure-ment into data memory DM1404 and turn ON special utility relay 2305. The mea-surement result (Hz) is written into DM1405.Input relay 0004 is for pulse input (single-phase input). Input relay 0006 (phase Binput) is ignored.
Devices used with the frequency counterSpecial utility relays
Data memory
Operation flow1. 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 datamemory. The frequency is calculated from the count value and written into datamemory.
2. When the time specified with DM1404 elapses from the last measurement, thecurrent value of CTH0 is fetched and divided by the elapsed time (Unit: 10 µs).The frequency is obtained with the following calculation.
Frequency (Hz) = (100,000 x Pulse count)/Elapsed time (Unit: 10 µs)
3. The calculation result (Hz) is written into DM1405.
Setting method1. 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 thanthe 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 µswith the HSP instruction or the special utility relay. (A maximum frequency of 30 kHzcan 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 specifiedwith 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 periodis 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 ladderprogram.
Note 6: Special utility relays concerning CTH0, CTC0/1, and the cam switch cannotbe used.
Note 7: CTH0 and the cam switch function cannot be used when the frequencycounter is used.
.oNyaleR noitpircseD
5032 oN:FFO,seY:NO.retnuocycneuqerfesU
.oNMD noitpircseD
4041MD ]0001ot1[retnuocycneuqerffo)sm(elcyctnemerusaeM
5041MD retnuocycneuqerffo)zH(tnuocycneuqerffotluseR
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM231
4.5 Special Functions Using High-speed Counters
3-232
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.5.4 Applications of Frequency CountersProgram for basic operation of the frequency counterStores the frequency of pulses at input relay 0004 to DM0000 every second (1000ms). (Unit: Hz)
1) Sets the counting period to "1000 ms (1 second)" and turns ON special utilityrelay 2305 to start the frequency counter function.
2) Sets the input time constant for input relay 0004 to 10 µs.3) Stores the measured frequency (Hz) into data memory DM0000.
Program for synchronous controlThe following ladder program illustrates synchronous control using the frequencycounter and pulse output functions.Measures the frequency of pulses at input relay 0004 every 100 ms and outputspulses of the same frequency from output relay 0501.
1) Sets the counting period to "100 ms" and turns ON special utility relays 2305 and2306 to start the frequency counter and the specified frequency pulse outputfunctions.
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.
00012008
0003
2002
2002
0004
0002
#01000LDA
DM1404STA
END
0005ENDH
2305SET
DM1405LDA
DM0000STA
HSP0004
1)
2)
3)
00012008
0003
2002
2002
0004
0002
#00100LDA
DM1404STA
2307
END0005
0006ENDH
2305SET
2306SET
DM1405LDA
DM1936STA
HSP0004
0500
1)
2)
3)
4)
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM232
4.5 Special Functions Using High-speed Counters
3-233
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.5.5 Cam Switch FunctionThe cam switch function has two modes: cam switch mode, which simulates camoperation; and multi-step comparator mode, which compares the value written inDM1401 with multiple values.
Devices used with the cam switch functionSpecial utility relays
The preset value in the data memory is registered at the rising edge of the startrelay. When the preset value is changed, turn OFF special utility relay 2314 onceand then turn it ON again to register the new value.
Timing diagram of cam switch 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 OFFstart relay 2314 and turns ON in-operation relay 2715 to activate the camswitch function.When in-operation relay 2715 is turned OFF, the cam switch function isstopped.
Cam switch modeSimulates a cam operation.Connect an encoder to CTH0 to count pulses in double multiplication mode.CTH0 uses input relays 0004 (phase A), 0006 (phase B) (KV-10xx: 0000), and 0008(phase Z) (KV-10xx: 0002).Relays are turned ON/OFF when the pulse count reaches the specified angle.The cam switch function controls a maximum of 32 successive relays. Specify relayNos. with the data memory (DM1400). Each relay is turned ON/OFF once everyrotation. To turn relays ON/OFF several times in one rotation, use the OR instructionin the ladder program.
Devices used in cam switch modeData memory
.oNyaleR noitpircseD4132 yalertratS5132 yalerrorrE5172 yalernoitarepo-nI
.oNMD noitpircseD
0041MD0091nahtrehtoseulaV(syalertuptuofosserddalaitiniserotS
.).00erastigidowttsalesohw0092hguorht
2041MDotdetcennocecivedehtfonoitatorenorofsrebmuneslupehteciwT
)43556ot1(0HTC
7041MD/6041MD).ged1.0:tinU(FFO/NOsnrutyalertuptuotsrifhcihwtaelgnA
)43556ot0(
9041MD/8041MD•••
9641MD/8641MD
).ged1.0:tinU(FFO/NOsnrutyalerdnoceshcihwtaelgnA)43556ot0(
•••
).ged1.0:tinU(FFO/NOsnrutyalerdn23hcihwtaelgnA)43556ot0(
0741MD esumetsysrofdevreseR
2715
2314
Executed
Start relay
In-operationrelay
Cam switchfunction
Stopped Stopped
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM233
4.5 Special Functions Using High-speed Counters
3-234
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
Multi-step comparator modeEven a single phase incoder can be used by changing a part of the cam switchfunction.To activate the multi-step comparator mode, write the value to be compared intodata memory DM1401 to replace the CTH0 value. This value determines the resolu-tion. If 360 is written in DM1401, and 60 is written in DM1406, the 1st relay is turnedON at 60/360 i.e. 60°.
Devices used in multi-step comparator mode
Data memory
Setting method In cam switch mode
1. Write the initial number of output relays to be used into DM1400.
Be sure to write the initial relay number of each channel.Example 0500, 0600: Acceptable, 0501, 0610: Unacceptable
2. Write the number of pulses in two pulse-periods of the encoder connected toCTH0 into DM1402. (Twice the number of pulses for one rotation.)
3. Specify the angle at which the first relay turns ON (Unit: 0.1 deg.) intoDM1406. Use units of 0.1 deg. to specify the preset angle for the cam switchmode. (Write the value of [Desired angle x 10] into data memory.)
4. Specify the angle at which the first relay turns OFF (Unit: 0.1 deg.) intoDM1407.
5. Specify the angle at which the second relay turns ON (Unit: 0.1 deg.) intoDM1408.
6. Specify the angle at which the second relay turns OFF (Unit: 0.1 deg.) intoDM1409.
7. Repeat steps 3 through 6 as many times as the number of relays to be used (32relays max.).
8. Turn ON special utility relay 2314.This relay automatically turns OFF when the cam switch function is activated.
9. Turn OFF special utility relay 2715 to stop the operation.
In multi-step comparator mode1. Write the initial number of output relays to be used into DM1400.
Be sure to write the initial relay number of each channel.Example 0500, 0600: Acceptable, 0501, 0610: Unacceptable
2. Write the value to be compared into DM1401, and write "65535" into DM1402.
3. Specify the preset value at which the first relay turns ON into DM1406.
4. Specify the preset value at which the first relay turns OFF into DM1407.
.oNMD noitpircseD
0041MD0091nahtrehtoseulaV(syalertuptuofosserddalaitiniserotS
.).00erastigidowttsalesohw0092hguorht
1041MD )43556ot0(derapmoceboteulaV
2041MD .edomrotarapmocegats-itlumesuot"53556"retnE
7041MD/6041MD )43556ot0(FFO/NOsnrutyalertuptuotsrifhcihwtaeulavteserP
9041MD/8041MD•••
9641MD/8641MD
)43556ot0(FFO/NOsnrutyalerdnoceshcihwtaeulavteserP•••
)43556ot0(FFO/NOsnrutyalerdn23hcihwtaeulavteserP
0741MD esumetsysrofdevreseR
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM234
4.5 Special Functions Using High-speed Counters
3-235
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
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 (32relays max.).
8. Turn ON special utility relay 2314.This relay automatically turns OFF when the cam switch function is activated.
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 ornot. 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 theHSP instruction or the special utility relay. (A maximum frequency of 30 kHz can bemeasured.)
Note 3: When any improper value is set in data memory, the setting error occursand special utility relay 2315 turns ON.
Note 4: CTH0 and the frequency counter function cannot be used while the camswitch function is being used.
Note 5: The cam switch function cannot be used when CTH0 is used in the ladderprogram.
Note 6: Special utility relays concerning CHT0, CTC0/1, and the frequency counterfunction cannot be used.
Note 7: The scan time is extended by a maximum of 16 ms when the cam switchfunction is activated.
Note 8: The in-operation relay of the cam switch function (2715) remains ON evenwhen 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, thecount 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 isOFF. (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 camswitch function, the value is converted into one within the range of 0 to 360° beforethe control.
Example: When 500° is specified, it is converted to 140°.
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM235
4.5 Special Functions Using High-speed Counters
3-236
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.5.6 Application of the Cam Switch (Cam Switch Mode)The following ladder program illustrates the basic setting of the cam switch function.Connect the encoder with a resolution of 360 pulses.Use output relays 0600 through 0603.Output relay 0600: Turns ON within the range 30° to 90°Output relay 0601: Turns ON within the range 45° to 80°Output relay 0602: Turns ON within the range 70° to 150°Output relay 0603: Turns ON within the range 120° to 270°
1) Sets "0600", which is the initial number of relays used for the cam switch function, toDM1400 and sets twice the number of pulses for one encoder rotation (360 x 2 = 720) toDM1402.
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.
#00720LDA
DM1402STA
#00600LDA
DM1400STA
2008
2002
0001
0000
HSP0004
HSP0006
HSP0008
ENDH
END
0001
0002
0005
0007
0003
0004
0008
0006
0009
#02700DW
DM1413
#01200DW
DM1412
#01500DW
DM1411
#00700DW
DM1410
#00800DW
DM1409
#00450DW
DM1408
#00900DW
DM1407
#00300DW
DM1406
1000
1001DIFU
1000DIFU
1001
2314SET
2715RES
1)
2)
5)
3)
6)
4)
7)
3600(360°)
30° DM1406
45° DM1408
70° DM1410
80° DM1409
90° DM1407
120° DM1412
150° DM1412
90 180 270 3600
ONOFF
ONOFF
ONOFF
ONOFF
Timing Diagram
Rotation (°)
1st relay 0600
2nd relay 0601
3rd relay 0602
4th relay 0603
DM1406 DM1407
DM1408 DM1409
DM1410 DM1411
DM1412 DM1413
270° DM1413
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM236
4.6 Direct Clock Pulse Output
3-237
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.6 Direct Clock Pulse OutputThis section describes the outline and setting method for direct clock pulse output.
4.6.1 Outline of Direct Clock Pulse OutputUsing the high-speed counter (CTH) and high-speed counter comparator (CTC), theKV PLC can output clock pulses directly through output relays 0500 and/or 0501without any delays caused by the scan time.
The period (frequency) and width of the pulses are determined by the period of theinternal 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 withinthe following ranges.
Pulses of the internal clock are counted with the high-speed counter (CTH). Whenthe number of current pulses reaches the preset value of the high-speed countercomparator (CTC), the ON/OFF status of output relays 0500 and/or 0501 is toggledto output direct clock pulses.
Count value
Note 1: The operation of output relays 0500 and 0501 are determined by setting thespecial 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 thesame 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 duringdirect clock pulse output.
CTC
ONON
tuptuO kcolclanretnI )ycneuqerF(doirepeslupfoegnaR
0050
0.1(0012 µ )s 02 µ )zH51(sm5.56ot)zHk05(s
0.01(1012 µ )s 02 µ )zH5.1(sm3.556ot)zHk05(s
0.001(2012 µ )s 002 µ )zH51.0(sm5.3556ot)zHk5(s
1050
0.1(0022 µ )s 02 µ )zH51(sm5.56ot)zHk05(s
0.01(1022 µ )s 02 µ )zH5.1(sm3.556ot)zHk05(s
0.001(2022 µ )s 002 µ )zH51.0(sm5.3556ot)zHk5(s
Visual KV Series Only
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM237
4.6 Direct Clock Pulse Output
3-238
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
4.6.2 Pulse Output Setting with the High-speed CounterComparator
Changing the pulse period and widthBy using two high-speed counter comparators, you can change only the pulse widthwhile keeping the pulse period constant, or change only the pulse period whilekeeping the pulse width constant.The following examples illustrate how the pulse width and period can be selectedwith the high-speed counter comparator.
ON-OFF ratio of 1:1
Pulse width (µs) = CTC0 preset value x internal clock (µs)
Pulse period (µs) = CTC0 preset value x 2 x internal clock (µs)
Use the following calculation to obtain the pulse period from the frequency:
Pulse period (µs) = 1,000,000/Frequency (Hz)
Example: To output 10-kHz pulsesPulse period = 1,000,000 ÷ 10,000 = 100 µsPreset value for CTC0 = 10 ÷ 2 ÷ 1 = 50
Variable pulse widthThe period and width of the pulse can be changed by changing the preset values ofCTC0 and CTC1.
Pulse width (µs) = CTC1 preset value x internal clock (µs)
Pulse period (µs) = CTC0 preset value x internal clock (µs)
• Change CTC1 preset value to change the pulse width.• Change CTC0 preset value to change the pulse period.
Note: The pulse width determined above is the pulse width produced inside theVisual 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 todetermine the pulse width after monitoring the actual output waveform with anoscilloscope. (Monitor the pulses of variable pulse width.)
OFF
ON
Pulse period
ON/OFF status is set by special utility relays.
Pulse width
OFF
ON
Pulse period
ON/OFF status is set by special utility relays.
Pulsewidth
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM238
4.6 Direct Clock Pulse Output
3-239
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Calculating the pulse period and comparator preset valueThe Visual KV PLC can output a maximum clock pulse of 50 kHz.Use the following calculations to obtain the pulse period and preset value of thehigh-speed counter comparator used to output the clock pulse.
Pulse period
Pulse period (µs) = 1,000,000 ÷ Frequency (Hz)
CTC preset value for pulses with 1:1 ON/OFF ratio (using one comparator)CTC preset value = Pulse period (µs) ÷ Internal clock (µs) ÷ 2
CTC preset value for pulses with variable pulse widthCTC preset value for pulse width = Pulse width (µs) ÷ Internal clock (µs)CTC preset value for pulse period = Pulse period (µs) ÷ Internal clock (µs)
Range of CTC preset value with the internal clock
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 improperwhen 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 withan oscilloscope.
Note 3: When CTC0 and CTC1, or CTC2 and CTC3, are used to output the clockpulse, do not specify the same value for the preset values of CTC0 and CTC1, or ofCTC2 and CTC3.
Operation with special utility relays Operation with special utility relays for high-speed counter CTH0The following table shows the ON/OFF status of output relay 0500 which can bechanged by setting special utility relays (2103 through 2112) at the start of opera-tion, or by changing them during clock pulse output.You can set desired values for the pulse period and pulse width, and can enable ordisable the direct output.Operation of output relay 0500 when special utility relays are ON/OFF
OFF
ON
Pulsewidth
Pulse period
OFF
ON
Pulsewidth
Pulse period
)kcolclanretni(yalerytilitulaicepS doireP eulavteserpCTCfoegnaR
0012 0022 0.1 µs 53556ot01
1012 1022 0.01 µs 53556ot1
2012 2022 0.001 µs 53556ot1
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM239
4.6 Direct Clock Pulse Output
3-240
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
CTC0
ONON
CTC1CTC0
ON ON ON ON
sgnittesyalerytilitulaicepS
NO3012 FFO8012
FFO4012 FFO9012
FFO5012 FFO0112
FFO6012 FFO1112
NO7012 FFO2112
sgnittesyalerytilitulaicepS
NO3012 FFO8012
FFO4012 NO9012
FFO5012 FFO0112
NO6012 FFO1112
FFO7012 FFO2112
Setting the special utility relayThe special utility relay must be set to output the clock pulse. Set the relays in thefollowing manner.• Only one relay for each group can be turned ON from relays 2104 through 2107
and 2108 through 2111.• Use the SET-RES pair or STA instruction to turn relays 2103 through 2112 ON/
OFF.• Turning OFF relays 2104 or 2108 enables control of output relay 0500.• To change the pulse width, be sure to first turn ON relays 2103 or 2112 to auto-
matically clear the current value of CTH0. You cannot change the pulse periodunless you turn ON relays 2103 or 2112.
• Turning ON/OFF relay 2105 stops/outputs the clock pulse.
Note: If two or more relays of special utility relays 2104 through 2107 or 2108through 2111 are turned ON, priority is given to the relay with the smaller number.
Operation of output 0500 by setting special utility relaysOutputting a pulse with 1:1 ON/OFF ratio Outputting a pulse with variable pulse width
Count value Count value
deeps-hgiHretnuoc
rotarapmoc
laicepSytilituyaler
)eulavtnerruc(0HTCnehwnoitarepO)eulavteserp(CTCsehcaer
0CTC
3012foeulavtnerrucsraelcyllacitamotuA
0HTCseY:NO oN:FFO
4012 .0050folortnocselbane/selbasiD:NO
elbasiD:FFO
elbanE
5012 .0050hguorhttuptuotceridFFOsnruT seY:NO oN:FFO
6012 .0050hguorhttuptuotceridNOsnruT seY:NO oN:FFO
7012 .0050fosutatsFFO/NOsesreveR seY:NO oN:FFO
1CTC
8012 .0050folortnocselbane/selbasiD:NO
elbasiD:FFO
elbanE
9012 .0050hguorhttuptuotceridFFOsnruT seY:NO oN:FFO
112 .0050hguorhttuptuotceridNOsnruT seY:NO oN:FFO
1112 .0050fosutatsFFO/NOsesreveR seY:NO oN:FFO
2112foeulavtnerrucsraelcyllacitamotuA
0HTCseY:NO oN:FFO
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM240
4.6 Direct Clock Pulse Output
3-241
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
Operation with special utility relays for high-speed counter CTH1The following table shows the ON/OFF status of output relay 0501 which can bechanged by setting special utility relays (2203 through 2212) at the start of opera-tion, or by changing them during clock pulse output.You can set desired values for the pulse period and pulse width, and can enable ordisable the direct output.Operation of output relay 0501 when special utility relays are ON/OFF
Setting the special utility relay
The special utility relay must be set to output the clock pulse. Set the relays in thefollowing manner.• Only one relay for each group can be turned ON from relays 2204 through 2207
and 2208 through 2211.• Use the SET-RES pair or STA instruction to turn relays 2203 through 2212 ON/
OFF.• Turning OFF relays 2204 or 2208 enables control of output relay 0501.• To change the pulse width, be sure to first turn ON relays 2203 or 2212 to auto-
matically clear the current value of CTH1. You cannot change the pulse periodunless you turn ON relays 2203 or 2212.
• Turning ON/OFF relay 2205 stops/outputs the clock pulse.
Note: If two or more relays of special utility relays 2204 through 2207 or 2208through 2211 are turned ON, priority is given to the relay with the smaller number.
Operation of output 0501 by setting special utility relaysOutputting a pulse with 1:1 ON/OFF ratio Outputting a pulse with variable pulse width
Count value Count value
deeps-hgiHretnuoc
rotarapmoc
laicepSyalerytilitu
)eulavtnerruc(0HTCnehwnoitarepO)eulavteserp(CTCsehcaer
2CTC
3022 eulavtnerrucsraelcyllacitamotuA1HTCfo seY:NO oN:FFO
4022 .1050folortnocselbane/selbasiD :NOelbasiD
:FFOelbanE
5022 hguorhttuptuotceridFFOsnruT.1050 seY:NO oN:FFO
6022 hguorhttuptuotceridNOsnruT.1050 seY:NO oN:FFO
7022 .1050fosutatsFFO/NOsesreveR seY:NO oN:FFO
3CTC
8022 .1050folortnocselbane/selbasiD :NOelbasiD
:FFOelbanE
9022 hguorhttuptuotceridFFOsnruT.1050 seY:NO oN:FFO
0122 hguorhttuptuotceridNOsnruT.1050 seY:NO oN:FFO
1122 .1050fosutatsFFO/NOsesreveR seY:NO oN:FFO
2122 eulavtnerrucsraelcyllacitamotuA1HTCfo seY:NO oN:FFO
CTC2
ONON
CTC3
CTC2
ON ON ON ON
sgnittesyalerytilitulaicepS
NO3022 NO8022
FFO4022 FFO9022
FFO5022 FFO0122
FFO6022 FFO1122
NO7022 FFO2122
sgnittesyalerytilitulaicepS
NO3022 FFO8022
FFO4022 NO9022
FFO5022 FFO0122
NO6022 FFO1122
FFO7022 FFO2122
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM241
4.7 Examples of Direct Clock Pulse Output
3-242
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
CTC0
ONON
4.7 Examples of Direct Clock Pulse OutputThis section describes programming examples of the direct clock pulse output.
4.7.1 Example of Outputting a Pulse with 1:1 ON/OFF RatioTo output a clock pulse of 1 ms (1 kHz)-period from output relay 0500
This section describes a programming example that will output a clock pulse with 1:1ON/OFF ratio from output relay 0500 by using the high-speed counter (CTH0) andhigh-speed counter comparator (CTC0).
Special utility relay setting
Set the special utility relay (2103 through 2112) according to the following table.When outputting a pulse with 1:1 ON/OFF ratio, you can simplify the program byusing the reverse (toggle) output (2107: ON).
Internal clock and CTC0 preset value
Specify the internal clock and calculate the preset value of CTC0 for the clock.
CTC0 preset value = Pulse period (µs) ÷ Internal clock (µs) ÷ 2
Obtain the preset value of CTC0 by substituting 1 ms for the pulse period and 10 µsfor the internal clock (special utility relay 2101).In this case, the preset value of CTC0 is "50".Refer to the following table for the preset value of CTC0 with other internal clocks.
ExampleCount value
• 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 toreverse 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 theclock pulse.
.oNyaleR gnitteS
3012 NO
4012 FFO
5012 FFO
6012 FFO
7012 NO
yalerytilitulaicepS kcolclanretnI eulavteserp0CTC
0012 0.1 µs 005
1012 0.01 µs 05
2012 0.001 µs 5
2103SET
2104RES
2105RES
2106RES
2107SET
CTH0RES
2008
2002
#00050CTC0
CTH02101
0001
0002
0003
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM242
4.7 Examples of Direct Clock Pulse Output
3-243
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
0000
0000 2105RES
2105SET
0000
0000RES
KEEP
2105SET
Cording
Note :When the input enable relay for the high-speed counter is used to start/stopthe clock pulse, the response is delayed by a maximum of one scan when outputstarts. Moreover, if the response is delayed by one scan when output stops, theclock pulse stops but the output may remain ON.
Tips
• Use special utility relay 2105 to control (enable/disable) the clock pulse output byexternal 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 asstops.
• When either of the following programs is added to the example on the previouspage, the clock pulse is output from 0500 only when 0000 is ON.
When SET-RES instructions are used When KEEP instruction is used
To output a clock pulse of 1 ms (1 kHz)-period from output relay 0501
This section describes a programming example that will output a clock pulse with 1:1ON/OFF ratio from output relay 0501 by using the high-speed counter (CTH1) andhigh-speed counter comparator (CTC2).
Special utility relay setting
Set the special utility relay (2203 through 2212) according to the following table.When outputting a pulse with 1:1 ON/OFF ratio, you can simplify the program byusing the reverse (toggle) output (2207: ON).
Internal clock and CTC2 preset valueSpecify the internal clock and calculate the preset value of CTC2 for the clock.
CTC2 preset value = Pulse period (µs) ÷ Internal clock (µs) ÷ 2
Obtain the preset value of CTC2 by substituting 1 ms for the pulse period and 10 µsfor the internal clock (special utility relay 2201).In this case, the preset value of CTC2 is "50".Refer to the following table for the CTC2 preset value with other internal clocks.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0008 CON0001 SET 2103 0009 SET 21070002 CON 0010 CON0003 RES 2104 0011 RES CTH00004 CON 0012 LD 20020005 RES 2105 0013 CTH 0 21010006 CON 0014 CTC 0 #000500007 RES 2106
.oNyaleR gnitteS
3022 NO
4022 FFO
5022 FFO
6022 FFO
7022 NO
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM243
4.7 Examples of Direct Clock Pulse Output
3-244
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
ExampleCount value
• 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 toreverse 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 theCTC2 preset value is repeated.
• The RES CTH1 instruction resets the CTH1 current value when operation starts. Thisensures 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 theclock pulse.
Coding
Note :When the input enable relay for the high-speed counter is used to start/stopthe clock pulse, the response is delayed by a maximum of one scan when outputstarts. Moreover, if the response is delayed by one scan when output stops, theclock pulse stops but the output may remain ON.
Tips• Use special utility relay 2205 to control (enable/disable) the clock pulse output by
external inputs.• Use the SET-RES pair or KEEP instruction to turn special utility relay 2205 ON/
OFF.• With this setting, the clock pulse is always turned OFF when it starts as well as
stops.• When either of the following programs is added to the example on the previous
page, the clock pulse is output from 0501 only when 0000 is ON.
When SET-RES instructions are used When KEEP instruction is used
0000
0000 2205RES
2205SET
0000
0000RES
KEEP
2205SET
CTC2
ONON
yalerytilitulaicepS kcolclanretnI eulavteserp2CTC
0022 0.1 µs 005
1022 0.01 µs 05
2022 0.001 µs 5
2203SET
2204RES
2205RES
2206RES
CTH1RES
2008
2002
#00050CTC2
CTH12201
0001
0002
0003
2207SET
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0008 CON0001 SET 2203 0009 SET 22070002 CON 0010 CON0003 RES 2204 0011 RES CTH10004 CON 0012 LD 20020005 RES 2205 0013 CTH 1 22010006 CON 0014 CTC 2 #000500007 RES 2206
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM244
4.7 Examples of Direct Clock Pulse Output
3-245
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
2103SET
2104RES
2105RES
2106SET
2107RES
2108RES
2109SET
2110RES
2111RES
CTH0RES
2008
2002
#00050CTC0
#00020CTC1
CTH02101
0001
0002
0003
0004
0005
CTC0CTC1
ON ON ON ON
4.7.2 Example of Outputting a Pulse with Variable ON/OFFRatio
To output a clock pulse of 500 µs (2 kHz)-period and 200 µs-width from output relay 0500
This section describes a programming example that will output a clock pulse withvariable ON/OFF ratio from output relay 0500 by using the high-speed counter(CTH0) and high-speed counter comparator (CTC0 and CTC1).
Special utility relay settingSet the special utility relay (2103 through 2112) according to the following table.
Internal clock and CTC0/CTC1 preset values
Specify the internal clock and calculate the preset values of CTC0 and CTC1 for theclock.
CTC1 preset value = Pulse width (µs) ÷ Internal clock (µs)CTC0 preset value = Pulse period (µs) ÷ Internal clock (µs)
Obtain the preset values of CTC0 and CTC1 by substituting 200 µs for the pulsewidth, 500 µs for the pulse period, and 10 µs for the internal clock (special utilityrelay 2101).In this case, the preset value of CTC1 is "20", and that of CTC0 is "50".Refer to the following table for the CTC preset values with other internal clocks.
ExampleCount value
• Sets the pulse output from output relay 0500 with special utility relays 2104 through 2107and 2108 through 2111.In this example, turns OFF 2104 to enable direct output from 0500. Turns ON 2106 to turnON the output from 0500 when the CTH0 value reaches the CTC0 value, and turns ON2109 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. Thisensures 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 theclock pulse.
.oNyaleR gnitteS .oNyaleR gnitteS
3012 NO 8012 FFO
4012 FFO 9012 NO
5012 FFO 0112 FFO
6012 NO 1112 FFO
7012 FFO 2112 FFO
yalerytilitulaicepS kcolclanretnI eulavteserp0CTC eulavteserp1CTC
0012 0.1 µs 005 002
1012 0.01 µs 05 02
2012 0.001 µs 5 2
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM245
4.7 Examples of Direct Clock Pulse Output
3-246
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
0000
0000 2105RES
2105SET
0000
0000RES
KEEP
2105SET
Coding
Note 1: When the input enable relay for the high-speed counter is used to start/stopthe clock pulse, the response is delayed by a maximum of one scan when outputstarts. 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 byexternal 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 asstops.
• When either of the following program is added to the example on the previouspage, the clock pulse is output from 0500 only when 0000 is ON.
When SET-RES instructions are used When KEEP instruction is used
• You can change the period (frequency) of the clock pulse by changing the CTC0preset 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).
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 RES 2106 0021 LD 2002
0009 CON 0022 CTH 0 2101
0010 RES 2107 0023 CTC 0 #00050
0011 MPP 0024 CTC 1 #00020
0012 RES 2108
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM246
4.7 Examples of Direct Clock Pulse Output
3-247
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
2203SET
2204RES
2206SET
2207RES
2208RES
2209SET
2210RES
2211RES
CTH1RES
2008
2002
#00050CTC2
#00020CTC3
CTH12201
0001
0002
0003
0004
0005
CTC2CTC3
ON ON ON ON
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 withvariable ON/OFF ratio from output relay 0501 by using the high-speed counter(CTH1) and high-speed counter comparator (CTC2 and CTC3).
Special utility relay setting
Set the special utility relay (2203 through 2212) according to the following table.
Internal clock and CTC2/CTC3 preset valuesSpecify the internal clock and calculate the preset values of CTC2 and CTC3 for theclock.
CTC2 preset value = Pulse width (µs) ÷ Internal clock (µs)CTC3 preset value = Pulse period (µs) ÷ Internal clock (µs)
Obtain the preset values of CTC2 and CTC3 by substituting 200 µs for the pulsewidth, 500 µs for the pulse period, and 10 µs for the internal clock (special utilityrelay 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.
ExampleCount value
• Sets the pulse output from output relay 0501 with special utility relays 2204 through 2207and 2208 through 2211.In this example, turns OFF 2204 to enable direct output from 0501. Turns ON 2206 to turnON the output from 0501 when the CTH1 value reaches the CTC2 value and turns ON2209 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. Thisensures 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 theclock pulse.
.oNyaleR gnitteS .oNyaleR gnitteS
3022 NO 8022 NO
4022 FFO 9022 FFO
5022 FFO 0122 FFO
6022 NO 1122 FFO
7022 FFO 2122 FFO
yalerytilitulaicepS kcolclanretnI eulavteserp2CTC eulavteserp3CTC
0022 0.1 µs 005 002
1022 0.01 µs 05 02
2022 0.001 µs 5 2
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM247
4.7 Examples of Direct Clock Pulse Output
3-248
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
0000
0000 2205RES
2205SET
0000
0000RES
KEEP
2205SET
Coding
Note :When the input enable relay for the high-speed counter is used to start/stopthe clock pulse, the response is delayed by a maximum of one scan when outputstarts. The response is also delayed by a maximum of one scan when the outputstops.
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 asstops.
• When either of the following programs is added to the example on the previouspage, the clock pulse is output from 0501 only when 0000 is ON.
When SET-RES instructions are used When KEEP instruction is used
• You can change the period (frequency) of the clock pulse by changing CTC2preset value using LDA and STA instructions.To change the period of the clock pulse, refer to "4.3.4 Count Input Method" onpage 3-212.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0012 SET 22090001 MPS 0013 CON0002 SET 2203 0014 RES 22100003 CON 0015 CON0004 RES 2204 0016 RES 22110005 CON 0017 CON0006 SET 2205 0018 RES CTH10007 CON 0019 LD 20020008 RES 2207 0020 CTH 1 22010009 MPP 0021 CTC 2 #000500010 RES 2208 0022 CTC 3 #000200011 CON
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM248
4.7 Examples of Direct Clock Pulse Output
3-249
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
2109SET
2110RES
2111RES
CTH0RES
2105RES
2105SET
2203SET
2813SET
CTH1RES
2002
#00050CTC0
1000DIFU
#00020CTC1
CTH02101
0002
2104RES
2105SET
2106SET
2107RES
2108RES
2103SETEI
2008
1000
0001
0003
0005
20020012
2002
#10000CTC2
CTH105000008
END0010
RETI0013
ENDH0014
INTCTC20011
00000004
0006
0009
0007
#00000DW
DM1940
4.7.3 Example of Stopping the Pulse Output at a SpecifiedPulse Count
This section describes a programming example that will output a clock pulse of 500µs (2 kHz)-period and 200 µs-width from output relay 0500 and then stop it after10000 pulses are output.
Special utility relay, internal clock, and CTC settings
Set the special utility relay according to the following table.
Specify the internal clock and CTC0/CTC1 preset values according to the followingtable.
Example
• Sets the pulse output from output relay 0500 with special utility relays 2104 through 2107and 2108 through 2111.In this example, turns OFF 2104 to enable direct output from 0500. Turns ON 2106 to turnON the output from 0500 when the CTH0 value reaches the CTC0 value and turns ON2109 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. Thisensures 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 valuereaches 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. Thisforces the operation to repeat by the specified pulses (10000).
• Relay 2813 must be turned ON when counting pulses with CTH1.
.oNyaleR gnitteS .oNyaleR gnitteS3012 NO 8012 FFO4012 FFO 9012 NO5012 FFO 0112 FFO6012 NO 1112 FFO7012 FFO 2112 FFO
yalerytilitulaicepS kcolclanretnI eulavteserp0CTC eulavteserp1CTC0012 0.1 µs 005 0021012 0.01 µs 05 022012 0.001 µs 5 2
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM249
4.7 Examples of Direct Clock Pulse Output
3-250
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
• The input enable relay for CTH0 must be ON all the time when CTH0 is used to output theclock pulse.
• The input enable relay for CTH1 must be ON all the time when CTH1 is used to count theclock pulse.
• Specifies the internal clock (2101) as the clock input for CTH0. Specifies 0500 as theclock input for CTH1. With this setting, CTH0 is used to output the clock pulse, and CTH1is used to count the clock pulse.
• Specifies the number of clock pulses to the CTC2 preset value.• The clock pulse output starts when input 0000 is turned ON.
To restart the clock pulse output after it stops, turn ON input 0000 again.
Coding
TipsSpecial utility relays 2103 through 2111 can be turned ON/OFF by using the LDAand STA instructions instead of the SET-RES instructions.The example program below can be changed as follows by using the LDA and STAinstructions. The number of lines and steps can be reduced.
• LDA $0268When LDA $0268 is executed, the value specified by the operand is written intothe internal register as follows.
When STA 2100 is executed, the value in the internal register is assigned tospecial utility relays 2100 through 2115.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0024 SET 22030001 EI 0025 CON0002 CON 0026 DW #00000 DM19400003 MPS 0027 CON0004 SET 2103 0028 SET 28130005 CON 0029 CON0006 RES 2104 0030 RES CTH10007 CON 0031 LD 00000008 SET 2105 0032 DIFU 10000009 CON 0033 CON0010 SET 2106 0034 AND 10000011 CON 0035 RES 21050012 RES 2107 0036 LD 20020013 MRD 0037 CTH 0 21010014 RES 2108 0038 CTC 0 #000500015 CON 0039 CTC 1 #000200016 SET 2109 0040 LD 20020017 CON 0041 CTH 1 05000018 RES 2110 0042 CTC 2 #100000019 CON 0043 END0020 RES 2111 0044 INT CTC20021 CON 0045 LD 20020022 RES CTH0 0046 SET 21050023 MPP 0047 RET1
0048 ENDH
0 0
[0] [2] [6] [8]
0 0 0 0 1 0 0 1 1 0 1 0 0 0Internal register
0
15xx 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 0 0 0 0 1 0 0 1 1 0 1 0 0 0Special utilityrelay 21xx
2109SET
2110RES
2111RES
CTH0RES
2203SET
2813SET
CTH1RES
2104RES
2105SET
2106SET
2107RES
2108RES
2103SETEI
2008 2100STA
CTH0RES
2203SET
2813SET
CTH1RES
$0268LDAEI
2008
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM250
4.7 Examples of Direct Clock Pulse Output
3-251
Visu
al K
VSe
ries
14
Chapter 4 High-speed Counters
4.7.4 Application of Direct Clock Pulse Output(Ramp-up/down control)
The following ramp-up/down control is available by setting four parameters (DM0000to DM0003)
Setting parameters
DM0000: fH [Hz] (Running frequency)DM0001: fL [Hz] (Start-up frequency)DM0002: Acceleration rate [Hz/10 ms]DM0003: No. of pulses for positioning
Note 1: A smaller acceleration rate allows smoother control but extends the accel-eration time.Note 2: Be sure to turn OFF input 0007 (phase B input).
OperationIn 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 shownbelow. Control is stopped when the pulse count reaches "4000".Pressing the start switch restarts the operation. The operation is reversed whilereverse switch 0001 is ON.
Connection exampleThe above diagram shows a connection example between the KV PLC and astepping 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".
CW
KV
24 VDC
FG
–+–+
–+
5 VDC
+–
CCW0002
00010000
05020500
COM 0003
0501COM 0503
Stepping motor
Star
tR
ever
seou
tput
Emer
genc
yst
op
Stepping motor driver
Twisted-pair cable
(Pulse)
(Rotationdirection)
Specify values in the range from 153 Hz to50000 Hz. The fH value must be greaterthan the fL value.
(fH - fL) / (Acceleration time / 10 ms) Must be 65534 pulses or less.
L(DM0001)
H(DM0000)
10ms
(DM0003)(DM0002)
0
Frequency (Hz)
Accelerationrate
(Accelerationchange period)
Total pulsesfor positioning
Accelerationtime
Constantspeed time
Time (ms)
Decelerationtime
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM251
4.7 Examples of Direct Clock Pulse Output
3-252
Visu
al K
VSe
ries
4
Chapter 4 High-speed Counters
Interrupt routine foracceleration/deceleration
Acceleration process
Deceleration process
Interrupt for pulse stop
• Clock pulse output is stopped whenthe No. of pulses equals the CTC3preset value.
• Acceleration ratio is added to thecurrent frequency to change it eachtime CTC2 turns ON whileacceleration flag 1200 is ON.Acceleration stops when thecurrent frequency reaches fH. SetsNo. of pulses for the decelerationpoint.
• Acceleration ratio is subtractedfrom the current frequency tochange it each time CTC2 turnsON while acceleration flag 1200 isON. Deceleration stops when thecurrent frequency reaches fL. Thesetting is initialized.
#08000DW
#00700DW
$0268LDA
#01000LDA
#10000MUL
DM0012DIV
#00005ADD
#00010DIV
CTC0STA
DM0010STA
2100STA
1200SET
CTH1RES
CTH0RES EI
2105RES
#00400DW
#04000
DM0000 DM0001 DM0002 DM0003DW
2813SET
2105SET
2002
2008
0003
0001
2002
0000 1001
#00010CTC1
1001DIFU
#65535CTC0
CTH02100
0003 2105SET
#65535CTC2
#65535CTC3
01CALL
02CALL
CTH10500
END
RET
SBN01
RET
SBN03
RET
DM0003LDA
CTC3STA
#00002DIV
DM0004STA
DM0001LDA
DM0012STA
#00000
DM0011DW
2002
DM0012LDA
#00100DIV
DM0011ADD
DM0004CMP
2002
#00010LDA
#10000MUL
DM0010DIV
#00005ADD
#00010DIV
DM0011ADD
CTC2STA
DM0011STA
SBN02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0502
DM0012LDA
DM0002ADD
DM0011STA
2105SET
CTC2STA
DM0011SUB
DM0003LDA
DM0012STA
DM0000CMP
1200 2011
2011
1200RES
#65535LDA
CTC2STA
1201
INTCTC2
RETI
INTCTC3
RETI
ENDH
03CALL
DM0012LDA
DM0002SUB
DM0012STA
DM0001CMP
1200
2002
2011 02CALL
2011 02CALL
2011
2011
02CALL
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
1201
Specifies high-speedcounters and comparators
Starts positioning
Emergency stop
Calculation routine forCTC0, CTC2, and DM0011
Initialization routine
Triangle drive check routine
• CTC0 generates a clock pulse.
• CTH1 counts the number ofclock pulses.CTC0:Pulse periodCTC1: Pulse widthCTC2:Frequency change pointCTC3:Total No. of pulses for positioning
• Sets parameters (DM0000 toDM0003).
• Sets reverse output.
• Sets emergency stop.
• Specifies the CTC2 presetvalue.DM0010: Pulse period T (µs)DM0011: No. of accumulated pulsesDM0012: Current frequency (Hz)1200: Acceleration flag
• Specifies the CTC0 preset value.CTC0 preset value = 1 ÷ DM0012 x 103 x 103
Example
KVNKA Chap 04_2.p65 08.3.11, 0:08 PM252
Chapter 5Positioning Control
This chapter describes ramp-up/down control of stepping motors and servo motors.
For KV-10/80 Series, see Chapter 6.
5.1 Outline of Positioning Control ..................................................... 3-2545.1.1 Ramp-up/down Control .......................................................................... 3-254
5.2 Parameter Setting and Operating Procedures ......................... 3-2555.2.1 Parameter Setting Procedure ................................................................. 3-2555.2.2 Operating Procedure .............................................................................. 3-257
5.3 Examples of Using the Positioning Control Function ........... 3-2585.3.1 Connection Example .............................................................................. 3-2585.3.2 Tips ........................................................................................................ 3-2585.3.3 Application Examples of the Positioning Control Function ..................... 3-259
Visual KV Series Only
Visu
al K
VSe
ries
KVNKA Chap 05.p65 08.3.11, 0:09 PM253
5.1 Outline of Positioning Control
3-254
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control
5.1 Outline of Positioning ControlThis section describes the outline of positioning control.
5.1.1 Ramp-up/down ControlThe Visual KV Series can directly output clock pulses not affected by the scan timeto output relay 0502.
If the frequency, the number of output pulses, and the acceleration time of the clockpulses 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 thestartup frequency, operating frequency, acceleration time, and deceleration time asshown below.
The output frequency can be set within the range of 200 to 50,000 Hz.
By using the ramp-up/down control output function, ramp-up/down control of step-ping motors and AC servo motors (pulse input types) is possible.
Frequency (Hz)Number of outputpulses (pulses)
DM1485 and DM1484
OperatingfrequencyDM1481
Upper digit Lower digit
StartupfrequencyDM1480
Accelerationtime DM1482
Decelerationtime DM1482
Time (ms)
NEW KV
Lo: CWHi: CCW0502
0503
Clock pulse
Rotation direction
Motor driver
Stepping motorServo motor
KVNKA Chap 05.p65 08.3.11, 0:09 PM254
5.2 Parameter Setting and Operating Procedures
3-255
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control
5.2 Parameter Setting and OperatingProcedures
This section describes the parameter setting and operating procedures for position-ing control.
5.2.1 Parameter Setting ProcedurePreliminarily set each parameter for positioning control to a corresponding datamemory. To operate, special utility relays must be set. For more about special utility relays, refer to "5.2.2 Operating Procedure" (p. 3-257).
The table below shows the relationship between parameters and data memories.
Data memories for ramp-up/down control
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).
Set value error code (DM1486)
If there is an error in the preset parameters when starting operation, a correspondingerror code (11 to 17) is automatically written to DM1486.
Startup frequency (Hz) (DM1480)
Set the frequency (speed) of the motor at startup in positioning control so that motorrotations start up smoothly.At the set frequency, the Visual KV Series will output clock pulses.
yromemataD stnetnocgnitteS egnargnitteS
0841MD putratslortnocnwod/pu-pmaR)zH(ycneuqerf
000,05ot002
1841MD gnitarepolortnocnwod/pu-pmaR)zH(ycneuqerf
000,05ot002)ycneuqerfputratsnahtregraleulav(
2841MDlortnocnwod/pu-pmaR
emitnoitareleced/noitarelecca)sm(
0004ot0
4841MD sesluptuptuoforebmuN)stib61rewol(
535,56ot0)0si5841MDnehweromro2(
5841MD sesluptuptuoforebmuN)stib61reppu(
535,56ot0
6841MD edocrorreeulavteS-dnopserroca,sruccororrenanehW
.derotssi71ot11edocrorregni
edoC noitpircseD serusaemretnuoC
11 nahtrellamssieulavycneuqerfputratS.egnargnitteselbawolla
gnittesnihtiwycneuqerfgnitratsteS.)000,05ot002(egnar
21 rellamssieulavycneuqerfgnitarepO.egnargnitteselbawollanaht
gnittesnihtiwycneuqerfgnitarepoteS.)000,05ot002(egnar
31 sieulavycneuqerf)putratsro(gnitarepO.egnargnitteselbawollanahtregral
ycneuqerf)putratsro(gnitarepoteS.)000,05ot002(egnargnittesnihtiw
41 nahtregralsieulavycneuqerfputratS.eulavycneuqerfgnitarepo
putratstahtosyletairporppamehtteSgnitareponahtrellamssiycneuqerf
.ycneuqerf51 regralsiemitnoitareleced/noitareleccA
.egnargnitteselbawollanahtnihtiwemitnoitareleced/noitareleccateS
.)000,4ot0(egnargnittes61 rorremetsyS .eciffoselasruotcatnoC
71 nihtiwtuptuoseslupforebmuNootsiemitnoitareleced/noitarelecca
.llams
ro2otsesluptuptuoforebmunteS.erom
KVNKA Chap 05.p65 08.3.11, 0:09 PM255
5.2 Parameter Setting and Operating Procedures
3-256
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control
Operating frequency (Hz) (DM1481)
Set the frequency (speed) of the motor during operation in positioning control.At the set frequency, the Visual KV Series will output clock pulses.
Note: If the startup frequency is the same as the operating frequency, the timingchart becomes as shown below.
In this case, the acceleration/deceleration time is ignored.
Acceleration/deceleration time (ms) (DM1482)
Set the time to accelerate from the starting frequency to the operating frequencyafter operation is started.When operation is stopped, the deceleration time is equivalent to the accelerationtime.In the set time, the Visual KV Series varies the clock pulse frequency from thestartup frequency to the operating frequency (in the case of acceleration time).The clock pulse frequency change cycle within the acceleration time is fixed to 5 ms.
Number of output pulses (DM1484 and DM1485)
Set the angle of rotation (movement quantity) in positioning control as the number ofpulses. 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-bitvalue and the lower 16-bit value using the following equation.The minimum value is 2, and maximum value is 4,294,967,295.
(Number of output pulses) ÷ 65,536 = A (answer) . . . B (remainder)A = Number of output pulses (upper 16-bit) DM1485B = Number of output pulses (upper 16-bit) DM1484
Note 1: When the set number of pulses is too small and the target value cannot beachieved, triangular control is performed as shown below.
Note 2: The current value of pulse output cannot be obtained.
0
Operating (startup)frequency
5ms
Operating frequency
Startup frequency
Acceleration/deceleration time
0
Operating frequency
Startup frequency
KVNKA Chap 05.p65 08.3.11, 0:09 PM256
5.2 Parameter Setting and Operating Procedures
3-257
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control
5.2.2 Operating ProcedureIn positioning control, operation is started up, stopped normally, and stopped inemergencies by the ON/OFF status of special utility relays.The table below shows the relationship between operations and the special utilityrelays used.
* R: Read W: Write
Operation chart
Note 1: If there is no error in the parameter setting when special utility relay 2310turns ON at startup of the clock pulses, special utility relay 2309 turns ON and clockpulses are output.
Note 2: If there is an error in the parameter setting, special utility relay 2309 doesnot turn ON but a corresponding error code is written to DM1486.
Confirm the error code, and change the erroneously set parameter.
Note 3: By setting special utility relay 2309 to OFF in an interrupt program, clockpulses can be immediately stopped.
Note 4: Rising of special utility relay 2310, falling of special utility relay 2309, andrising of special utility relay 2308 are performed by end processing and RETI.(Special utility relay 2309 turns ON at that time.)
Note 5: It takes a maximum of 10 ms from when special utility relay 2310 turns ONuntil pulses are output.
Note 6: Even if special utility relay 2310 is set to ON while special utility relay 2308or 2309 is ON, it is ignored.
Note 7: When pulse output has finished, special utility relay 2309 is immediately setto OFF (without regard to the scan time).
ytilitulaicepS.oNyaler
*W/R noitcnuF noitpircseD
8032 W potSspotsneht,egdegnisirtanoitarelecedsmrofreP
.noitarepo
9032 RW
nuRTESER
.tuptuoeraseslupelihwNOsniameRnanitesergniebnehwyletaidemminoitarepospotS
.margorptpurretni
0132 W tratS .egdegnisirtanoitarepopustratS
DM1480: Startup frequency (Hz)DM1481: Operating frequency (Hz)DM1482: Acceleration time (ms)DM1485: Number of output pulses (upper 16 bits)DM1484: Number of output pulses (lower 16 bits)
DM1481
DM1480
2310(START)
2309(RUN)
2308(STOP)
0
DM1485DM1484
DM1482 DM1482
When relay 2310 turns ON, clock pulses areoutput (detection at rising edge).
While clock pulses are output, relay 2309remains ON. While clock pulses are notoutput, relay 2309 remains OFF.
When relay 2308 turns ON, clock pulses aredecelerated and stopped (detection at risingedge).
KVNKA Chap 05.p65 08.3.11, 0:09 PM257
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control3-258
5.3 Examples of Using the PositioningControl Function
This section describes examples of connecting a stepping motor driver and perform-ing ramp-up/down control using the positioning control function of the Visual KVSeries.
5.3.1 Connection ExampleConnect the Visual KV Series and stepping motor driver as shown below.This example is only for reference. For details, refer to the instruction manual for thestepping motor driver.Set the pulse input type of the stepping motor driver to "1 pulse input type".
• When using a 24 VDC power supply, be sure to use the outputs with current limitingresistors (R500, R501, and R502) or use the normal outputs with external current limitingresistors.
5.3.2 TipsWhen 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.
CW
Visual KV
24 VDC
FG
–+–+
+
–
5 VDC*
+–
CCW0002
00010000
R0502
COM
COM R0503
Em
erge
ncy
stop
Sto
pS
tart
Stepping motor driver
Twisted pair cable
(pulse)
(rotationdirection)
Stepping motor
KVNKA Chap 05.p65 08.3.11, 0:09 PM258
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control 3-259
5.3.3 Application Examples of the Positioning ControlFunction
Ladder example of ramp-up/down control
When start switch 0000 is set to ON, output 0502 starts to output 100,000 pulseswith 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.
Program example
0 100000
500
1000
Speed (Hz)
Coordinate (pulses)
Permit interrupts when operation isstarted (so that emergency stopoperations are available).
2008
2002
EI0001
0002
0003
0004
0005
0006
0007
0008
0009
#34464DW
#00001DW
#03000DW
#10000DW
#00500
DM1484DM1485DM1482DM1481DM1480DW
0000
2309RES
2310
0001 2308
RETI
ENDH
END
INT0002
HSP0002
2002
Set the input time constant of input0002 to 10 µs.
Set each parameter, and start pulseoutput at the same time.
Decelerate and stop pulse output.
Perform emergency stop processingby using an interrupt program.
KVNKA Chap 05.p65 08.3.11, 0:09 PM259
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control3-260
Ladder example of the jog operation
The jog operation is performed.
• 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
1000
500
Speed (Hz)CW direction CCW direction
Coordinate (pulses)
Input 0000(CW direction)
Input 0001(CCW direction)
1000DIFU
0000 0001
#65535DW
#65535DW
#01000DW
#02000DW
#00500
DM1484DM1485DM1482DM1481DM1480DW
1000
1100
1001
0503SET
2310
2308
END
ENDH
0001 23090000
1001DIFU
1100DIFU
0503RES
0000 23090001
0001
0002
0003
0004
0005
0006
0007
KVNKA Chap 05.p65 08.3.11, 0:09 PM260
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control 3-261
Ladder example of automatic operation (palletizing operation)
A palletizing operation is automatically performed.The machine moves to a target coordinate, then returns to the start position. Next,the machine moves to a position further away than the target coordinate, then againreturns to the start position. Such an operation is realized using repetitious andreturn movements. This type of operation is suitable for, for example, a job whereworkpieces to be supplied are located in one position and a moving body picks upthe workpieces and positions them little by little at a certain interval.
When start signal 0000 is set to ON, a moving body moves to point 1, returns to thestart 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, output05000 remains ON for 3 seconds, and then the operation is finished.
Program example
5000
0
5000
500
500
Speed (Hz)
Point 3: 14,000
Point 1: 10,000 Coordinate (pulses)Point 2: 12,000
#00000DW
#03000DW
#05000DW
#00500DW
DM1485DM1482DM1481DM1480
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
1000SET
0000
#10000
DM1484DW
2310 1001JMP
1000STG
0503SET
#12000
DM1484DW
2310 1003JMP
1002STG
0503SET
1100 2310 1002JMP
1001STG
2309
1100
1102 2310 1004JMP
1003STG
0503RES
2309
1102
1104 2310 1006JMP
1005STG
0503RES
2309
1104
11012309
1101
2310 1005JMP
1004STG
0503SET
11032309
1103
12012309
1201
12002309
1200
12032309
1203
12022309
1202
12042309
1204
END
ENDH
0500 #00030T000
T0001105ENDS
1006STG
2309
1105
#14000
DM1484DW
0503RES
Ladder for automatic operation
Point 1: 10,000 Point 2: 12,000 Point 3: 14,000
Moves to point 1.
Returns from point 1.
Moves to point 2.
Returns from point 2
Moves to point 3.
Returns from point 3.
When operation has completed, output 500 remains ON for 3 seconds.
KVNKA Chap 05.p65 08.3.11, 0:09 PM261
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control3-262
Ladder example of a return to the zero point
A return to the zero point is performed.
When start signal 0000 turns ON, the machine moves at a high speed in the CCWdirection. When the zero point sensor turns ON, the machine decelerates, moves ata low speed in the CW direction, then stops in the position at which the zero pointsensor turns OFF (at the end of the CW direction).
Program example
Range detected byzero point sensor
Low speedForced stop
Start
Decelerationand stop High-speed
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
2008
2002
EI
1005SET
HSP0003
#65535DW
#00000DW
#00500DW
#10000DW
#00500
DM1484DM1485DM1482DM1481DM1480DW
0503RES
2413RES
1006RES
2309RES
1000DIFU
0000 1000 2309
1007DIFU
1005 10072309
0503SET
2413SET
#65535DW
#00000DW
#00500DW
#10200DW
#00200
DM1484DM1485DM1482DM1481DM1480DW
1006
1006
2309
2310
1006
END
INT0003
1005RES
1006SET
2308SET
1005
RETI
ENDH
2308RES
Return to zero point
Zero point sensor: 0003 Start signal: 0000 Pulse output: 0502Rotation direction: 0503
Initial setting
Moves at high speed in the CCW direction.
When the zero point sensor turns ON, moves at low speed in the CW direction.
Detects the rising/falling edge of the zero point sensor (003), stops, andthen changes direction.
KVNKA Chap 05.p65 08.3.11, 0:09 PM262
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control 3-263
Ladder example of an automatic operation (continuous operation with wait status)
In automatic operation, wait status is realized at each point.
When start signal 0000 turns ON, the machine moves to point 1 and stops there. Atthe rising edge of wait status reset switch 1, the machine automatically moves topoint 2 and stops there. At the rising edge of waiting status reset switch 1, themachine automatically moves to point 3. When the machine reaches point 3, output0500 remains ON for 3 seconds and the operation is finished.
Program example
0 250000 460000320000
5005000
100007000
Speed (Hz)
Wait Wait
Coordinate(pulses)
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
1000SET
0000
1400
#00500
DM1480DW
#01000
DM1481DW
#01000
DM1482DW
#00003
DM1485DW
#53392
DM1484DW
2310 1001JMP
#05000
DM1481DW
#01000
DM1482DW
#00001
DM1485DW
#04464
DM1484DW
2310 1002JMP
1000STG
0503SET
0503SET
#07000
DM1481DW
0503SET
1001STG
2309
1400
13010001
1301
1401
#01000
DM1482DW
#00002
DM1485DW
#08928
DM1484DW
0500
2310 1003JMP
#00030T000
1002STG
2309
1401
1303
T000
0001
1303
1305ENDS
1003STG
2309
1305END
ENDH
13002309
1300
13022309
1302
13042309
1304
Ladder for automatic operation (continuous operation with wait status)
Start signal: 0000 Pulse output: 0508 Rotation direction: 0503
Wait reset switch: 0001
Moves to point 1 at speed of 10 kHz. Acceleration/deceleration time: 1 secondMoving quantity: 250,000 pulses
Moves to point 2 at speed of 5 kHz. Acceleration/deceleration time: 1 secondMoving quantity: 70,000 pulses
Moves to point 3 at speed of 7 kHz. Acceleration/deceleration time: 1 second
Moving quantity: 140,000 pulsesWhen operation has completed, output 500 remains ON for 3 seconds.
KVNKA Chap 05.p65 08.3.11, 0:09 PM263
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control3-264
2008EI
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
1100DIFU
1101DIFU
#00000DW
#00001DW
#00100DW
#04000DW
#00600
DM1484DM1485DM1482DM1481DM1480DW
1200RES
0503RES
0008 0009
0008
2309 0006
1103DIFU
1105DIFU
0503SET
0009
1100
0008 0009
2309 0004
1101
2002 HSP0000
HSP0002
Ladder example of a pulse motor application circuit
This is a program example which offers control using both automatic and manualoperations.In automatic operation, when input 000 is set to ON, the following operation isperformed.
In manual operation, the machine moves forward while input 0008 is ON, and movesbackward while input 0009 is ON. When input 0007 is set to ON, the machinereturns to the zero point.Output 0502 outputs pulses. The rotation direction is changed by an ON/OFF of0503.This machine is equipped with a zero-point sensor (0002), a forward limit switch(0006), and a backward limit switch (0004).
Program example
0 15000 17500
300
15000
2000
8000
Speed (Hz)
Coordinate(pulses)
Pulse motor application circuit (with zero point sensor, forwardlimit switch, and backward limit switch)
Set the startup frequency,operating frequency, andacceleration/decelerationtime for manual operation.
• Startup frequency: 600 Hz• Operating frequency: 4 kHz• Acceleration/
deceleration: 100 ms• Number of output pulses:
65,536
Specifications
Pulse output: 0502 Rotation direction: 0503Forward limit switch: 0006 Backward limit switch: 0004
Manual switch: Forward = 0008, backward = 0009 Zero point switch:
0007
Automatic operation start: 0000
Resets interrupt permission & zero point detection flag.Manual switch (0008: Forward, 0009: Backward)
KVNKA Chap 05.p65 08.3.11, 0:09 PM264
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
15
Chapter 5 Positioning Control 3-265
2309
1405
2310
2308
2008 1400SET
1205DIFU
0007
#03500DW
#00000DW
#00250DW
#03000DW
#00300
DM1484DM1485DM1482DM1481DM1480DW
1300DIFU
1205
0006
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
1203DIFU
#65535DW
#00000DW
#00000DW
#00500DW
#00500
DM1484DM1485DM1482DM1481DM1480DW
0503SET
1200SET
1200
1301DIFU
0503RES
1200RES
1203
1408DIFU
1402RES
1403RES
1400SET
1401RES
2308
1400STG
1401STG
#00010T001
1500DIFU
1401JMP
1402JMP
0000
1408
1300
1301 0004
1506 2308
1103
1407RES
T001 1405
2309
1406
1402STG
#00005T002
1501DIFU
1403JMP
1405RES
T002 1406
2309
1407
1403STG
#00005T003
1502DIFU
1400JMP
1406RES
T003 1407
00090006
0004 0008
1105
2309ON
1201
1201 12022309OFF1202
2308 2309
Return to zero point
Limit switch
Move forward.
Trigger end of forward movement
While moving backward at low speed, return to zero point.
Start up motor.
Decelerate and stop (in manual/automatic operation).
Automatic operation
Trigger for stage instruction
Automatic start (while 0000 is ON)
When motor operation has finished, moves stage forward.
In a zero-point-returnoperation, the machinemoves forward once, andthen backward. When thezero point limit switch(0002) turns ON, themachine stops.Settings for forwardmovement• Startup frequency: 300 Hz• Operating frequency: 3 kHz• Acceleration time: 250 ms• Number of output pulses:
3,500Settings for backwardmovement• Drive frequency: 500 Hz• Operating frequency: 500 Hz• Acceleration time: 0 ms• Number of output pulses:
65,535
Create each operationprogram using the STGinstruction, and let eachprogram be executed inturn.
Give instructions to start upand decelerate/stop themotor.
KVNKA Chap 05.p65 08.3.11, 0:09 PM265
5.3 Examples of Using the Positioning Control Function
Visu
al K
VSe
ries
5
Chapter 5 Positioning Control3-266
2309RES
#17500DW
#00000DW
#00250DW
#15000DW
#00300
DM1484DM1485DM1482DM1481DM1480DW
1505DIFU
0503RES
1502
1200 0008 0009 0000
15061503
END
RETI
ENDH
INT0002
1504
1505
#15000DW
#00000DW
#00150DW
#08000DW
#00300
DM1484DM1485DM1482DM1481DM1480DW
1503DIFU
0503SET
1500
#02500DW
#00000DW
#00250DW
#02000DW
#00300
DM1484DM1485DM1482DM1481DM1480DW
1504DIFU
0503SET
1501
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
Set automatic operation parameters.Set parameters for auto-matic operation.1. Startup frequency: 300 Hz
Operating frequency: 8 kHzAcceleration time: 150 msNumber of output pulses:15,000
2. Startup frequency: 300 HzOperating frequency: 2 kHzAcceleration time: 250 msNumber of output pulses:25000
3. Startup frequency: 300 HzOperating frequency: 15 kHzAcceleration time: 250 msNumber of output pulses:17,500
Start up motor.
Interrupt for instantaneous stop (to return to zero point)Stop pulse output at thezero point by using aninterrupt program.
KVNKA Chap 05.p65 08.3.11, 0:09 PM266
Chapter 6Interrupts, High-speed Counters,Positioning Control
This chapter describes ramp-up/down control of stepping motors and servo motors.
6.1 Interrupt Instructions .............................................................. 3-2686.1.1 Description of Interrupts ......................................................................... 3-2686.1.2 Interrupt Instructions .............................................................................. 3-271
6.2 Direct Clock Pulse ................................................................... 3-2766.2.1 Output of Direct Clock Pulse .................................................................. 3-276
6.3 Positioning Control ................................................................. 3-2966.3.1 Positioning Control (Ramp-up/down Control) ......................................... 3-296
KV-300, KV-10/80 Series Only
KV-3
00KV
-10/
80
KVNKA Chap 06.p65 08.3.11, 0:10 PM267
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-268
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.1 Interrupt Instructions
6.1.1 Description of InterruptsInput processing for routine program and interrupt routine
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 ONspecial utility relay 2813, input signals can be received only if they are longer thanthe 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.
During execution of interrupt routine, input signals shorter than one scan time can bereceived by the PLC.
Note: To execute INT (interrupt initiation instruction), execute EI first to enableinterrupt, then use HSP (time constant: 25 µs) or turn ON special utility relay 2813(time constant: 10 µs) to reduce the input time constant.
Types of interrupt
Interrupt by CTC can be generated when the CTC preset value and CTH currentvalue are equal.
A signal received through any of inputs 0000 to 0003 can generate an interrupt.
Input processing
Output processing
Routine program execution
Interrupt routineexecution
(00000 to 00005)
(00500 to 00503)
Sca
n tim
e
Generation of in
terrupt
Returns to suspended program
at the point of suspension.
Processing of direct inputs
Processing of direct outputs
2008 EI
2813 SET or
2002
HSP0000
EI
2002
Fig. 1
High speed counter comparators CTC0, CTC1, CTC2, CTC3
Input relays 0000, 0001, 0002, 0003
(rising/falling edge selectable)
→
KVNKA Chap 06.p65 08.3.11, 0:10 PM268
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-269
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Interrupt priorityIf two or more interrupts are generated at different timings, interrupt routines areexecuted in the order that interrupts are generated.If two or more interrupts are generated simultaneously, interrupt routines areexecuted 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.
Note 1: During execution of one interrupt routine, execution of other interrupt rou-tines is inhibited. (One interrupt routine can be executed inside another interruptroutine 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 interruptroutine in the order that they are generated. Note that generation of up to 8 levels ofinterrupt nesting or up to 8 individual interrupts can be stored during execution ofinterrupt routine. However, generation of an interrupt is ignored if generation of thesame interrupt has already been stored.
Interrupt routine
• 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.
Instructions that cannot be used in the INT-RETI blockTMR, TMH, TMS, DIFU, DIFD, W-ON, W-OFF, W-UE, W-DE, STG, JMP, ENDS,HKEY, ITVL, @xxxx (instruction), C, UDC, SFT
2008 EI
2813 SET
END
INTXXXXX
RETI
ENDH
KVNKA Chap 06.p65 08.3.11, 0:10 PM269
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-270
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Direct output
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, and0503 to be output during execution of interrupt routine.This function allows immediate ON/OFF status output without delay caused by scantime.
Note: Be sure to turn ON special utility relay 2813 to shorten the input time constant.
Direct input
Direct input is enabled only through input relays 0000 to 0005.This function allows ON/OFF status of any of input relays 0000 to 0005 to be inputduring execution of interrupt routine.
Note 1: Be sure to turn ON special utility relay 2813 to shorten the input timeconstant.
Note 2: Input status read using direct input function is valid only in the interruptroutine. Be sure to insert an internal utility relay after the direct input relay.
2008
EI
2813 SET
END
INT0000
0500
( SET )
RETI
INT0001
ENDH
0500( SET )
2002
2002
2008 2813 SET
END
RETI
ENDH
05001000
INT 0000
10000005
KVNKA Chap 06.p65 08.3.11, 0:10 PM270
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-271
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.1.2 Interrupt Instructions
DI: Interrupt Disabled Disables execution of interrupt.
EI: Interrupt Enabled Enables execution of interrupt.
Key operations
Operand
Example
Coding
Description
When 1000 is ON, execution of interrupt is enabled. When 1000 is OFF, executionof 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 temporarilydisable interrupt.EI instruction enables the execution of interrupt. Use this instruction to releaseinterrupt disabled by DI instruction.During execution of an interrupt, any other interrupt is disabled.To execute anotherinterrupt during execution of the previous interrupt, include EI instruction in this firstinterrupt. Interrupts can be nested up to 8 levels by executing EI in each interruptroutine.
Note 1: Generation of up to 8 levels of interrupt nesting or up to 8 individual inter-rupts can be stored while interrupt is disabled. These interrupts are executed after EIhas been executed.
Note 2: Generation of INT CTC is erased from the storage when RES CTC isexecuted.
: DIAND8FNC RES
0
: EISET1FNC ORL
3
ORL3
AND8 ENT
R-SRCH
RES0FNC
SET1FNC
ENTR-SRCH
1000EI
1000DI
Line No. Instruction Operand
0000 LD 1000
0001 EI
: :
0021 LDB 1000
0022 DI
: :
DI / EI
KVNKA Chap 06.p65 08.3.11, 0:10 PM271
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-272
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT: Interrupt
RETI: Return Interrupt
Key Operations
Operand
0000 to 0003CTC0 to CTC3
Example 1
Input pulse width shorter than one scan time (eg. one-shot circuit)
Program (a) can be used when input 0000 remains ON longer than the input time constant (8to 12 ms).Program (b) is used when input 0000 remains ON shorter than one scan time.
Routine program coding
: nnnnINT
FNC RES0
ANL2
:RETI
ORL3FNC LDB
4
ENTR-SRCH
RES0
LDB4
ENTR-SRCH
Operand ENTR-SRCH
ENTR-SRCHFNC
FNC
ANL2
ORL3
0000(a)
0000
(Input remains ON for 1 ms or more.)
2008
EI2813SET
0500 0500
#00020 T000
T000
0500 0500
#00020 T000
T000
1000
END
INT0000
RETI
ENDH
10002002
(Input remains ON for 10 µs or more.)
(b)
0000
Input for routine program
Input forinterruptroutine
Executes interrupt between INT and RETIinstructions at rising edge of input specifiedby operand. When 0003 is specified byoperand, the rising or falling edge can beselected for execution of interrupts.
Represents termination of interrupts.
Line No. Instruction Operand
0000 LD 0000
0001 OR 0500
0002 TMR 000 #00020
0003 ANB T000
0004 OUT 0500
INT / RETI
KVNKA Chap 06.p65 08.3.11, 0:10 PM272
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-273
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Interrupt routine coding
Example 2
Features of INT0003
Upon generation of interrupt by INT0003, the CTH1 current value is automaticallytransferred to TM30.Interrupt generated by any of INT0000 to INT0002 is executed at the rising edge ofthe input signal. Interrupt generated by INT0003 can be executed either at the risingor falling edge of the input signal.
In the example program below, pulse width of input 0003 is measured.
Coding
0003Pulse width
ONOFF
2206(OFF) 2206(ON) 2008
1 EI$0000LDA
2200STA
DM0000STA
2002
2206
2206
TM30LDA
TM02STA
TM30LDA
TM02SUB
DM0000STA
CTH12200
END
INT0003
KEEPSET2206
RES
RETI
ENDH
2
3
4
(a)
(b)
Relay No. ON OFF
2206 Executes interrupts at falling edge of Executes interrupts at rising edge ofinput pulse to 0003. input pulse to 0003.
INT / RETI
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0008 OUT 05000001 EI 0009 END0002 CON 0010 INT 00000003 SET 2813 0011 LD 20020004 LD 1000 0012 OUT 10000005 OR 0500 0013 RETI0006 TMR 000 #00020 0014 ENDH0007 ANB T000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0014 CON0001 EI 0015 STA TM020002 CON 0016 CON0003 LDA $0000 0017 LD 22060004 CON 0018 LDA TM300005 STA 2200 0019 CON0006 CON 0020 SUB TM020007 STA DM0000 0021 CON0008 LD 2002 0022 STA DM00000009 CTH 1 2200 0023 CON0010 END 0024 KEEP 22060011 INT 0003 0025 RETI0012 LDB 2206 0026 ENDH0013 LDA TM30
KVNKA Chap 06.p65 08.3.11, 0:10 PM273
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-274
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT / RETI
2008
1 EI2203
2002
2002
CTH10005
END
INTCTC2
RETI
2
4
0000
5
3
CTH1 #05000CTC2 SET
2813
0501
0501
SET RES
SET
RES
ENDH
Initial setting• When the operation is started, EI instruction enables interrupts.
• Special utility relays No. 2200 through 2215 are turned OFF. Turning OFF 2203disables 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.
• When interrupt is generated for the first time, 2206 is OFF. Therefore, program inrung (a) is executed. Then, KEEP turns 2206 ON.
• When interrupt is generated for the second time, 2206 is ON. Therefore, programin 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 pulsesreaches 5,000.
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0010 LD 20020001 EI 0011 CTH 1 00050002 CON 0012 LD 00000003 SET 2203 0013 RES 05010004 CON 0014 END0005 RES CTH1 0015 INT CTC20006 CON 0016 LD 20020007 CTC 2 #05000 0017 SET 05010008 CON 0018 RETI0009 SET 2813 0019 ENDH
KVNKA Chap 06.p65 08.3.11, 0:10 PM274
6.1 Interrupt Instructions
KV-3
00KV
-10/
80
3-275
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
INT / RETI
Initial setting• When the operation is started, EI instruction enables interrupts.
• Turning ON special utility relay 2203 allows CTC2 to reset the CTH1 currentvalue 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.
• INT CTC2 is used to execute the interrupt. (Interrupt routine is executed whenthe 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 INTinstructions.
KVNKA Chap 06.p65 08.3.11, 0:10 PM275
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-276
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Internal clocks2200(1.0 µs)2201(10.0 µs)2202(100.0 µs)External pulse0005/00070500
Internal clocks2100(1.0 µs)2101(10.0 µs)2102(100.0 µs)External pulse0004/0006
Special utility relay(2103 to 2115)
Special utility relay(2203 to 2215)
INT CTC0INT CTC1
INT CTC2INT CTC3
TM30
Phase A 0004Phase B (0006)
0009 (RESET)
0500
0501
0008 (RESET)
Phase A 0005Phase B (0007)
Control circuit
Control circuit
16-bit high-speed counterCTH0
16-bit high- speed counterCTH1
High-speed counter comparatorCTC0, CTC1
High-speed counter comparatorCTC2, CTC3
6.2 Direct Clock Pulse
6.2.1 Output of Direct Clock PulseOutline of High-Speed Counters
Basic Architecture
The KV-300 CPU has two 16-bit (CTH0, CTH1) double-phase counter, eachequipped with two high-speed counter comparators (CTC0, 1, 2, 3). These counterscan be used as a stepping motor controller or are used to measure pulse width.
Block diagram of high-speed counters
Lists of special utility relays for high-speed countersUtility relays for high-speed counter CTH0
2100 Internal clock (1.0 µs) for CTH0
2101 Internal clock (10.0 µs) for CTH0
2102 Internal clock (100.0 µs) for CTH0
2103 When comparator CTC0 is ON, automatically clears CTH0.1: Yes 0: No
2104 Direct output to 0500 Direct output level to 0500 through comparator1: Disable 0: Enable CTC1 (any one of these is ON)
2105 Turns OFF output to 0500.1: Yes 0: No
2106 Turns ON output to 0500.1: Yes 0: No
2107 Reverses output (toggle) to 0500.1: Yes 0: No
2108 Direct output to 0500 Direct output level to 0500 through comparator1: Disable 0: Enable CTC1 (any one of these is ON)
2109 Turns OFF output to 0500.1: Yes 0: No
2110 Turns ON output to 0500.1: Yes 0: No
2111 Reverses output to 0500 (toggle).1: Yes 0: No
2112 When comparator CTC1 is ON, automatically clears CTH0.1: Yes 0: No
2113 Uses CTH0 in magnification mode.1: Yes 0: No
2114 Selection of magnification mode for CTH01: x 4 0: x 2
2115 Enables external reset for CTH0.1: Yes 0: No
KVNKA Chap 06.p65 08.3.11, 0:10 PM276
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-277
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Utility relays for high-speed counter CTH1
2200 Internal clock (1.0 µs) for CTH1
2201 Internal clock (10.0 µs) for CTH1
2202 Internal clock (100.0 µs) for CTH1
2203 When comparator CTC2 is ON, automatically clears CTH1.1: Yes 0: No
2204 Direct output to 0501 through comparator CTC21: Enable 0: Disable
2205 Direct output level to 0501 through comparator CTC21: ON 0: OFF
2206 Selection of INT3 edge0: UP edge 1: DOWN edge
2207 Reverse output (toggle) level1: ON 0: OFF
2208 Direct output to 0501 Direct output level to 0501 through comparator1: 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 CTH11: x 4 0: x 2
2215 Enables external reset for CTH1.1: Yes 0: No
For KV-10/80 users
1. KV-10/80 has one 8-bit (CTH0) and one 16-bit (CTH1) single phase counter.
2. Internal clocks are as follows:
3. Special utility relays of 2112, 2113, 2114, 2115, 2212, 2213, 2214, and 2215are not available.
2100 0.8 µs 2200 0.4 µs
2101 6.4 µs 2201 0.8 µs
2102 102.4 µs 2202 3.2 µs
KVNKA Chap 06.p65 08.3.11, 0:10 PM277
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-278
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
High-speed counter and counter comparatorsHigh-speed counter (CTH1)CTH1 is a 16-bit hardware counter that counts from 0 to 65535.
• You can specify the operands listed in the table below as the count input.• You can specify one operand from the table below.• Operand cannot be modified externally during execution of the program.• When the external pulse (0004, 0005) is selected, CTH1 is used as a High-speed
counter with a response frequency of 30 kHz.*• When one of the internal clocks (2100 to 2102, 2200 to 2202) is selected, CTH1
is used as a High-speed timer.• When the external pulse 0500 is selected as input to CTH1, CTH1 can count
direct clock pulses generated by CTH0.
* KV-10/80: 10 kHz
High-speed counter comparator (CTC)
High-speed counter comparators (CTC) is used only for High-speed counters (CTH).When the current value of CTH reaches the preset value of one of the comparators(CTC), the comparator turns ON.At the contact of High-speed counter comparator (CTC), the level of output (0500,0501) can be changed (directly output) through hardware or an interrupt can begenerated. To change the level of output 0500 and 0501, set the desired value (ON/OFF) to special utility relays 2103 to 2112, 2203 to 2205, and 2207 to 2212.
The High-speed counters correspond to the High-speed counter comparators asshown in the table below.
Internal Clocks for CTH0 and CTH1
• Each High-speed counter (CTH) has its own internal clock.• The desired clock can be selected by specifying the relay No. as operand for
CTH instruction.• You cannot change the internal clock or external pulse during execution of the
program.• Each clock has the following period:
High-speed counter CTH0 CTH1
Operand 2100 22002101 22012102 22020004 0005
0500
Countable range 0 to 65535
High-speed High-speed Range of Output Interruptcounter counter setting value
comparator
CTH0 CTC0 0 TO 65535 0500 INT CTC0
CTC1 INT CTC1
CTH1 CTC2 0501 INT CTC2
CTC3 INT CTC3
High-speed counter CTH0 CTH1 Period
Relay No. 2100 2200 1.0 µs
2101 2201 10.0 µs
2102 2202 100.0 µs
KVNKA Chap 06.p65 08.3.11, 0:10 PM278
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-279
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
• You cannot change operands of the high-speed counters (CTH) duringexecution of the program. The input time constant of the high-speedcounters is usually set to 25 ms. (The HSP instruction is not required.)
• High-speed pulses can be counted at up to 30 kHz through external inputs(0004 to 0007) by turning ON special utility relay 2813. (Internal pulses canbe counted at up to 50 kHz by turning ON 2813.)*
* KV-10/80 : 10 kHz
Outline of Pulse OutputThe KV PLC can output clock pulses through 0500 and/or 0501 without any delayscaused by scan time. (Through CPU only)Direct clock pulses, used with the high-speed counters, are applicable for varioustypes 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 withinthe allowable range as shown in the table below.
Outline of pulse output
Direct clock pulses are output through 0500 and/or 0501 according to the settings onthe special utility relays when the number of internal clock pulses counted by thehigh-speed counter reaches the preset value of the comparator.
Output example
ON/OFF of output relay 0500/0501 depends on the setting of the special utilityrelay. Refer to page 3-281.
For KV-10/80 users
CAUTION
Output Internal clock Range of pulse cycle (frequency)
0500 2100 20 µs (50 kHz) to 65.5 ms (15 Hz)
2101 20 µs (50 kHz) to 655.3 ms (1.5 Hz)
2102 200 µs (5 kHz) to 6553.5 ms (0.1 Hz)
0501 2200 20 µs (50 kHz) to 65.5 ms (15 Hz)
2201 20 µs (50 kHz) to 655.3 ms (1.5 Hz)
2202 200 µs (5 kHz) to 6553.5 ms (0.1 Hz)
CTH current value (count value)
CTC preset value
ON
OFF
05000501
CAUTION
Model Output Range of pulse cycle
KV-10, 16, 24, 40 500 500 ms to 52.2 ms(2 kHz to 19 Hz)
501 666 ms to 419.4 ms(1.5 kHz to 2.4 Hz)
KV-80 500 50 ms to 52.2 ms(20 kHz to 19 Hz)
501 666 ms to 419.4 ms(1.5 kHz to 2.4 Hz)
KVNKA Chap 06.p65 08.3.11, 0:10 PM279
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-280
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Pulse period and width
Period and width of the pulse is determined by the period of the internal clock (CTH)used and the preset value of the comparator (CTC).When two counter comparators are used, only the pulse width can be changed whilea constant period is maintained.The following examples illustrate how pulse width and period can be selected:
ON/OFF ratio of 1:1
Pulse width (ms) = CTC0 preset value x internal clock (ms)Pulse period (ms) = CTC0 preset value x 2 x internal clock (ms)
• ON/OFF ratio of pulse is 1:1.• Change CTC0 preset value to change the pulse width and period.
Variable pulse width
ON/OFF status is set by special utility relays.Pulse width (ms) = CTC1 preset value x internal clock (ms)Pulse period (ms) = CTC0 preset value x internal clock (ms)
• Change CTC1 preset value to change the pulse width.• Change CTC0 preset value to change the pulse period.
The pulse width determined as above is used to pulses generated from theKV-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 actualwaveform 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)
ON
OFFPulse width
Pulse period
ON/OFF status is set special utility relays
ON
OFF
Pulse period
ON/ OFF status is set by special utility relays
Pulse width
CAUTION
KVNKA Chap 06.p65 08.3.11, 0:10 PM280
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-281
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
CTH0 value
ONOFF
CTC0
CTH0 value
ONOFF
CTC0CTC1
Special utility relay settings and output statuses
16-bit high-speed counter (CTH0) and special utility relays (2103 to 2112)
By setting the special utility relays 2104 to 2112 at startup or changing these relaysduring generation of clock pulse, you can select ON/OFF of output relay 0500 aslisted below.These special utility relays also allow you to set the pulse cycle and pulse widthand enable or disable the direct output.
• Special utility relay must be ON when clock pulse is generated.
• Only one of relays 2104 to 2107 and one of relays 2108 to 2111 can beturned ON. When two or more of the relays among each group are ON,priority is given to the relay with the smallest No.
• Turning OFF special utility relays 2104 and 2108 enable direct output.Because these relays are factory-set to ON, be sure to set them to OFF.
• ON/OFF status of special utility relays 2104 to 2112 is set using SET andRES instructions or STA instruction.
• Be sure to turn the special utility relay 2103 or 2112 ON to change thepulse width. Turn ON 2103 or 2112 to change the pulse cycle.
• Turn OFF 2105 to start clock pulse output. Turn ON 2105 to stop pulseoutput.
• When special utility relays 2104 and 2108 are turned ON while the directclock pulses are being output, the status of the output relay 0500 is outputand the pulses will be stopped.
Timing diagram of 0500 with special utility relay settings• ON-OFF ratio of 1:1 • Variable pulse width
Settings of special utility relays Settings of special utility relays
CAUTION
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 OFF
2106 OFF 2110 OFF
2107 ON 2111 OFF
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
Pulse status at CTH0 (current value) = CTC (preset value)
Comparator No. Relay No. Pulse status at ON.
CTC0 2103 Automatically clears current value of CTH0.
2104 Disables output to 0500.
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.
KVNKA Chap 06.p65 08.3.11, 0:10 PM281
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-282
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
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 orchanging these relays during generation of clock pulse, you can select ON/OFF ofoutput relay 0501 as listed below.These special utility relays also allow you to set the pulse cycle
• Special utility relay must be ON when clock pulse is generated.
• Only one of relays 2208 to 2211 can be turned ON. When two or more of therelays among each group are ON, priority is given to the relay with thesmallest No.
• Turning ON special utility relay 2204 and turning OFF special utility relay2208 enable direct output.
• ON/OFF status of special utility relays 2204 to 2212 is set using SET andRES instructions or STA instruction.
• Be sure to turn the special utility relay 2203 or 2212 ON to change the pulsewidth.
• Turn ON 2203 or 2212 to change the pulse cycle.Turn OFF 2205 to start clock pulse output. Turn ON 2205 to stop pulseoutput.
• When special utility relays 2204 and 2208 are turned ON while the directclock pulses are being output, the status of the output relay 0501 which isused in the program is output and the pulses will be stopped.
Timing diagram of 0501 with special utility relay settings• Variable pulse width • ON-OFF ratio of 1:1
Settings of special utility relays Settings of special utility relays
CTH1 value
ONOFF
CTC2
CTH1 value
ONOFF
CTC2CTC3
CAUTION
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 OFF 2209 OFF
2206 OFF 2210 OFF
2207 ON 2211 OFF
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 ON 2209 ON
2206 OFF 2210 OFF
2207 OFF 2211 OFF
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
2207 Inverts output to 0501.
CTC3 2212 Automatically clears current value of CTH0.
2208 Disables output to 0501.
2209 Outputs OFF to 0501
2210 Outputs ON to 0501.
2211 Inverts output to 0501.
KVNKA Chap 06.p65 08.3.11, 0:10 PM282
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-283
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Calculating the pulse cycle and comparator setting value
The KV-300 CPU supports clock pulse output at maximum frequency of 50 kHz.Obtain the pulse cycle for clock pulse output and comparator setting value from thefollowing expressions:• Pulse cycle
Pulse cycle (µs) = 1000 ÷ Frequency (kHz)• For pulse with 1:1 ON/OFF ratio (using one comparator)
CTC setting value = Pulse cycle (µs) ÷ Internal clock (µs) ÷ 2
• For pulse with variable pulse width (using two comparators)CTC setting value for pulse width = Pulse width (µs) ÷ Internal clock (µs)CTC setting value for pulse cycle = Pulse cycle (µs) ÷ Internal clock (µs)
Range of CTC setting based on internal clock
• When setting 2100 or 2200 for the operand of High-speed counter CTH, set10 or greater value to CTC. Otherwise, clock pulse is not correctly output.
• The pulse width varies depending on the influence of the connected load.Before setting the pulse width, you should measure the actual waveformusing 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 settingthe same value, clock pulse is output at the double clock cycle.
* Refer to page 3-276.
ON
OFFPulse width
Pulse cycle
ON
OFFPulse width
Pulse cycle
CAUTION
Special utility relay (Internal clock) Cycle * CTC setting range
2100 2200 1.0 µs 10 to 65535
2101 2201 10.0 µs 1 to 65535
2102 2202 100.0 µs 1 to 65535
KVNKA Chap 06.p65 08.3.11, 0:10 PM283
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-284
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Examples of Pulse OutputThe following sample explains how to program the pulse output.
Example of clock pulse with 1:1 ON/OFF ratio
When outputting clock pulse with cycle 1 ms (1 kHz) from 0500
This program example shows how to output clock pulse with 1:1 ON/OFF ratio from0500, through High-speed counter CTH0 and High-speed counter comparatorCTC0.
Setting special utility relaysSpecial utility relays 2103 to 2112 are set as shown on the right table.The program can be simplified using reverse output (toggle) for pulse with 1:1 ON/OFF ratio.
Values set to the internal clock and CTC0After the internal clock is determined, the CTC0 setting value is calculated from thefollowing expression.
CTC0 setting value = Pulse cycle (µs) ÷ Internal clock (µs) ÷ 2Assign 1 ms to pulse cycle and 10 µs (2101: special utility relay) to internal clockand calculate the CTC0 setting value.The calculated result is "50".CTC0 values calculated based on other internal clocks are listed below for yourreference.
Programming example
• The status of output 0500 is set by turning ON one of the relays 2104 to 2107 atthe beginning of the program. In Example, output of direct clock pulses to 0500 isenabled, 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. Theprogram 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 directclock 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.
Special utility relay Internal clock* CTC0 value
2100 1.0 µs 500
2101 10.0 µs 50
2102 100.0 µs 5
2008
SET
2103 2104 2105 2106 2107
2002
0001
0002
0003
CTH0
2101
RES RES RES SET RES
CTH0
CTC0#00050
CTH0 value
ONOFF
CTC0
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
KVNKA Chap 06.p65 08.3.11, 0:10 PM284
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-285
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2105
0000
SET
2105
RES
0000
21050000
SET
RES
KEEP
KEEP InstructionsSET/RES Instructions
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
0008 CON
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/disables the high-speed counter, response relay of up to 1 scan is generatedat start. Also, the same response relay is generated at stop, which may stopclock 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 ofdirect clock pulses using one of the external clocks. Use SET and RES instructionstogether or only KEEP instruction to turn ON/OFF this relay.The diagram below can be added to the sample diagram so that direct clock pulsesare output through 0500 only when 0000 is ON.
CAUTION
When outputting clock pulse with cycle 1 ms (1 kHz) from 0501
This program example shows how to output clock pulse with 1:1 ON/OFF ratio from0501, through high-speed counter CTH1 and high-speed counter comparator CTC2.
Setting special utility relaysSpecial utility relays 2203 to 2212 are set as shown on the right table.The program can be simplified using reverse output (toggle) for pulse with 1:1 ON/OFF ratio.
Relay No. Setting Relay No. Setting
2203 ON 2212 OFF
2204 OFF 2208 OFF
2205 OFF 2209 OFF
2206 OFF 2210 OFF
2207 ON 2211 OFF
KVNKA Chap 06.p65 08.3.11, 0:10 PM285
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-286
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Values set to the internal clock and CTC2After the internal clock is determined, the CTC2 setting value is calculated from thefollowing expression.
CTC2 setting value = Pulse cycle (µs) ÷ Internal clock (µs) ÷ 2Assign 1 ms to pulse cycle and 10 µs (2201: special utility relay) to internal clockand calculate the CTC2 setting value.The calculated result is "50".CTC2 values calculated based on other internal clocks are listed below for yourreference.
* Refer to page 3-276.
Programming example
• The status of output 0501 is set by turning ON one of the relays 2204 to 2207 atthe beginning of the program. In Example, output of direct clock pulses to 0501 isenabled, 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. Theprogram 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 directclock pulses of specified width to be output starting from the 1st pulse.
• Input relay which enables CTH1 remains ON during clock pulse output.
Coding
Special utility relay Internal clock* CTC0 value
2200 1.0 µs 500
2201 10.0 µs 50
2202 100.0 µs 5
2008
SET
2203 2204 2205 2207
2002
0001
0002
0003
CTH1
2201
SET RES SET RES
CTH1
CTC2#00050
CTH1 value
ONOFF
CTC2
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
KVNKA Chap 06.p65 08.3.11, 0:10 PM286
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-287
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2204
0000
SET
2204
RES
0000
22040000
SET
RES
KEEP
KEEP InstructionsSET/RES Instructions
When start/stop of clock pulse is controlled by the input relay which enables/disables the high-speed counter, response relay of up to 1 scan is generatedat start. Also, the same response relay is generated at stop, which may stopclock 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 ofdirect clock pulses using one of the external clocks. Use SET and RES instructionstogether or only KEEP instruction to turn ON/OFF this relay.The diagram below can be added to the sample diagram so that direct clock pulsesare output through 0501 only when 0000 is ON.
CAUTION
Example of clock pulse with variable ON/OFF ratio
When outputting clock pulse with cycle 500 µs (2 kHz) and pulse width200 µs from 0500
This program example shows how to output clock pulse varies ON/OFF ratio from0500, through high-speed counter CTH0 and high-speed counter comparatorCTC0 and CTC1.
Setting special utility relays
Special utility relays 2103 to 2112 are set as shown in the table below.
Values set to the internal clock, CTC0 and CTC1
After the internal clock is determined, the CTC0 and CTC1 setting value is calcu-lated from the following expression.CTC1 setting value = Pulse width (µs) ÷ Internal clock (µs)CTC0 setting value = Pulse cycle (µs) ÷ Internal clock (µs)Assign 200 µs to pulse width, 500 µs to pulse cycle and 10 µs (2101: special utilityrelay) to internal clock and calculate the CTC0 and CTC1 setting value.The calculated results of CTC1 and CTC0 are "20" and "50", respectively.Values calculated based on other internal clocks are listed below for your reference.
Special utility relay Internal clock* CTC0 value CTC1 value
2100 1.0 µs 500 200
2101 10.0 µs 50 20
2102 100.0 µs 5 2
* Refer to page 3-276.
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
KVNKA Chap 06.p65 08.3.11, 0:10 PM287
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-288
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
When start/stop of clock pulse is controlled by the input relay which enables/disables the high-speed counter, response relay of up to 1 scan is generatedat start. Also, the same response relay is generated at stop, which may stopclock 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 ofdirect clock pulses using one of the external clocks. Use SET and RES instructionstogether or only KEEP instruction to turn ON/OFF this relay.The diagram below can be added to the sample diagram so that direct clock pulsesare output through 0500 only when 0000 is ON.
By overwriting the setting value of high-speed counter comparator CTC0 using theLDA and STA instructions, you can change the clock pulse cycle (frequency). Refer to "Example of pulse output "on page 3-293.
CAUTION
Programming example
2008
SET2103 2104 2105 2106
2002
0001
0002
0003 2101
RES RES SET RES
CTH0
CTC0#00050
0004
0005
RES2108 2109 2110 2111 CTH0
SET RES RES RES
2107
CTC1#00020
CTH0 value
ONOFF
CTC0CTC1
• The status of output 0500 is set by turning ON one of the relays 2104 to 2107and 2108 to 2111 at the beginning of the program. In Example, output of directclock pulses to 0500 is enabled, and the status of output 0500 is turned ON atCTC0 and is turned OFF at CTC1.
• Turns ON special utility relay 2103 and specifies to clear CTH0 using CTC0. Theprogram 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 Operand0000 LD 2008 0013 CON0001 MPS 0014 SET 21090002 SET 2103 0015 CON0003 CON 0016 RES 21100004 RES 2104 0017 CON0005 CON 0018 RES 21110006 RES 2105 0019 CON0007 CON 0020 RES CTH00008 SET 2106 0021 LD 20020009 CON 0022 CTH 0 21010010 RES 2107 0023 CTC 0 #000500011 MPP 0024 CTC 1 #000200012 RES 2108
0000 2105
0000
SET
2105
RES
0000
21050000
SET
RES
KEEP
KEEP InstructionsSET/RES Instructions
KVNKA Chap 06.p65 08.3.11, 0:10 PM288
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-289
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
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 ratiofrom 0501, through High-speed counter CTH1 and High-speed counter comparatorCTC2 and CTC3.
Setting special utility relaysSpecial utility relays 2203 to 2212 are set as shown on the right table.
Relay No. Setting Relay No. Setting
2203 ON 2212 OFF
2204 ON 2208 OFF
2205 ON 2209 ON
2206 OFF 2210 OFF
2207 OFF 2211 OFF
Values set to the internal clock and CTC2 and CTC3After the internal clock is determined, the CTC2 and CTC3 setting value is calcu-lated from the following expression.CTC3 setting value = Pulse width (µs) ÷ Internal clock (µs)CTC2 setting value = Pulse cycle (µs) ÷ Internal clock (µs)Assign 200 µs to pulse width, 500 µs to pulse cycle and 10 µs (2201: special utilityrelay) to internal clock and calculate the CTC2 and CTC3 setting value.The calculated results of CTC3 and CTC2 are "20" and "50", respectively.Values calculated based on other internal clocks are listed below for your refer-ence.
Special utility relay Internal clock* CTC2 value CTC3 value
2100 1.0 µs 500 200
2101 10.0 µs 50 20
2102 100.0 µs 5 2
*Refer to page 3-276.
Programming example
2008
SET2203 2204 2205
2002
0001
0002
0003 2201
SET SET RES
CTH1
CTC2#00050
0004
0005
RES2208 2209 2210 2211 CTH1
SET RES RES RES
2207
CTC3#00020
CTH1 value
ONOFF
CTC2CTC3
• The status of output 0501 is set by turning ON one of the relays 2204 to 2207and 2208 to 2211 at the beginning of the program. In Example, output of directclock pulses to 0501 is enabled, and the status of output 0501 is turned ON atCTC2 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 toCTC2.
• Input relay which enables CTH1 remains ON during clock pulse output.
KVNKA Chap 06.p65 08.3.11, 0:10 PM289
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-290
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0000 2204
0000
SET
2204
RES
0000
22040000
SET
RES
KEEP
KEEP InstructionsSET/RES Instructions
Relay No. Setting Relay No. Setting
2103 ON 2112 OFF
2104 OFF 2108 OFF
2105 OFF 2109 ON
2106 ON 2110 OFF
2107 OFF 2111 OFF
Special utility relay Internal clock* CTC0 value CTC1 value
2100 1.0 µs 500 200
2101 10.0 µs 50 20
2102 100.0 µs 5 2
When start/stop of clock pulse is controlled by the input relay which enables/disables the high-speed counter, response relay of up to 1 scan is generatedat start. Also, the same response relay is generated at stop, which may stopclock pulse output while the output relay is still ON.
This controls the clock pulse so that it always starts and stops when 2205 turnsOFF.
Turn ON/OFF special utility relay 2205 as required to enable or disable output ofdirect clock pulses using one of the external clocks. Use SET and RES instructionstogether or only KEEP instruction to turn ON/OFF this relay.The diagram below can be added to the sample diagram so that direct clock pulsesare output through 0501 only when 0000 is ON.
By overwriting the setting value of high-speed counter comparator CTC2 using theLDA 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 isoutput from 0500 at cycle of 500 µs (2 kHz) after reaching the pulse count value of10000.
Setting special utility relay, internal clock, and CTCSettings of the special utility relays, internal clock, CTC0, and CTC1 are listedbelow.
CAUTION
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0012 SET 22090001 MPS 0013 CON0002 SET 2203 0014 RES 22100003 CON 0015 CON0004 SET 2204 0016 RES 22110005 CON 0017 CON0006 SET 2205 0018 RES CTH10007 CON 0019 LD 20020008 RES 2207 0020 CTH 1 22010009 MPP 0021 CTC 2 #000500010 RES 2208 0022 CTC 3 #000200011 CON
*Refer to page 3-276.
KVNKA Chap 06.p65 08.3.11, 0:10 PM290
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-291
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Programming example
2008
SET2103 2104 2105 2106
2002
0001
0002
0003
2101
RES SET SET RES
CTH0
CTC0#00050
0004
0005
RES2108 2109 2110 2111 CTH0
SET RES RES RES
2107
CTC1#00020
END
INTCTC2
2002SET2105
RET1
ENDH
SET2203 2813
SET
2105RES
CTH1RES
EI
0000 1000DIFU
1000
0006
00072002
0500CTH1
CTC2#10000
0008
0009
0010
0011
0012
0013
0014
• Sets pulse output to 0500 using special utility relays 2104 to 2107 and 2108 to2111.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 outputwith 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 ofHigh-speed counter CTH1 reaches the setting value of high-speed countercomparator CTC2 (when 10000 pulses are output).
• Turns ON special utility relay 2203 to clear CTH1 using CTC2. This allowsprogram 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 usedfor 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 0000again.
KVNKA Chap 06.p65 08.3.11, 0:10 PM291
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-292
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
2008
SET2103 2104 2105 2106
RES SET SET RES
RES2108 2109 2110 2111 CTH0
SET RES RES RES
2107
SET2203 2813
SETCTH1RES
EI
2008 2203 2813RES SET SET RES
CTH1EI LDA STA
$0268 $2100 CTH0
0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0Internal register
[0] [2] [6] [8]
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0Special utility relays 21**
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
0008 SET 2105 0032 AND 1000
0009 CON 0033 RES 2105
0010 SET 2106 0034 LD 2002
0011 CON 0035 CTH 0 2101
0012 RES 2107 0036 CTC 0 #00050
0013 MRD 0037 CTC 1 #00020
0014 RES 2108 0038 LD 2002
0015 CON 0039 CTH 1 0500
0016 SET 2109 0040 CTC 2 #10000
0017 CON 0041 END
0018 RES 2110 0042 INT CTC2
0019 CON 0043 LD 2002
0020 RES 2111 0044 SET 2105
0021 CON 0045 RETI
0022 RES CTH0 0046 ENDH
0023 MPP
Special utility relays 2103 to 2111 can be set to turn ON or OFF using LDA and STAinstructions as well as SET and RES instructions. Example below illustrates howone program can be made shorter using LDA and STA instructions.
• LDA $0268
When LDA $0268 is executed, the following data is input to the internal register.
Internal registerWhen STA 2100 is executed, the data in the internal register is assigned to 16special utility relays starting from 2100 to 2115.
Thus, 2103, 2105, 2106, and 2109 are ON.
KVNKA Chap 06.p65 08.3.11, 0:10 PM292
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-293
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
COM00000001
0500050105020503
1112
789
10COM 20
24 VDC–
+KV-300
FG
Twisted pair cable
CW (pulse)
CCW (rotating direction)
Stepping motor driver
Stepping motor
Star
t
Rev
erse
24 VDC
– +
0
fH(DM0000)
fL(DM0001)
Frequency (Hz)
Acceleration rate
(DM0002)
10 msAcceleration change time
Positioning pulse total count (DM0003)
Acceleration time Constant rate time
Deceleration timeTime (ms)
CAUTION
Example of pulse output (Ramp-up/down control)
The following example performs ramp-up/down control as shown below by setting 4parameters (DM0000 to DM0003).
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 instructionmanual for details.Set the pulse input mode of the stepping motor driver to "1 pulse input mode".
Setting parametersDM0000: fH [Hz] (Run frequency) 153 Hz to 50000 Hz fH must be greater thanfL.DM0001: fH [Hz] (Start frequency)DM0002: Acceleration rate [Hz/10 ms] (fH-fL) ÷ (Acceleration time ÷ 10 ms)DM0003: Positioning pulse count 65534 pulses max.
• Although smoother trapezoidal control can be obtained by setting a smalleracceleration rate, the acceleration time is extended.
• Be sure to turn OFF input relay 0007 (phase B input).
Operation
This program sets the parameters as below:DM0000 = 8000 [Hz], DM0001 = 700 [Hz], DM0002 = 400 [Hz/10 ms], DM0003 =4000 pulsesThe program performs trapezoidal control as shown above when start switch 0000 ispressed, and stops control when pulse count reaches 4000.The program restarts operation by re-pressing the start switch. It performs reverseoperation while reverse switch 0001 is ON.
KVNKA Chap 06.p65 08.3.11, 0:10 PM293
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-294
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
2002
INITIAL SETUP FOR HIGH-SPEED COUNTER/COMPARATOR
#00010CTC1
#65535CTC0
CTH02100
#65535CTC2
#65535CTC3
CTH10500
2008 #08000DW
DM0000
#00700DW
DM0001
#00400DW
DM0002
#04000DW
DM0003
(SET ) (SET )2813 2105
STARTS POSITIONING
0003 0000 1001 DIFU
1001
$0268LDA
2100STA
01 CALL (SET ) (RES )
1200 CTH1(RES )
CTH0(RES )EI2105
0001( )0502
EMERGENCY STOP
0003(SET)2105
END
CTC0,CTC2,DM0011, CALCULATION SUBROUTINE
SBN02
2002 #01000LDA
#10000MUL
DM0012DIV
#00005ADD
#00010DIV
CTC0STA
DM0010STA
#00010LDA
#10000MUL
DM0010DIV
#00005ADD
#00010DIV
DM0011ADD
CTC2STA
DM0011STA
INITIALIZING SUBROUTINE
RET
SBN01
DM0003LDA
CTC3STA
#00002DIV
DM0004STA
DM0001LDA
DM0012STA
#00000DW
DM0011
2002 02 CALL
RAMP UP/DOWN CHECK ROUTINE
SBN03
RET
DM0012LDA
#00100DIV
DM0011ADD
DM0004CMP
2002
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
Generates clock pulse through high-speed counter CTH0.
Counts clock pulese through high-speed counter CTH1.• CTC0: Pulse cycle
CTC1: Pulse width• CTC2: Frequency change point
CTC3: Positioning pulse totalcount
Sets parameters (DM0000 toDM0003).
Reverse output
Emergency stopSets CTC0.Setting value of CTC0 = 1 ÷ DM0012 x 103 x 103 ÷ 6.4
Sets CTC2.• DM0010: Pulse cycle T (µs) x 10• DM0011: Accumulated pulse count• DM0012: Current frequency f [Hz]• 1200: Acceleration flag
Programming exmaple
KVNKA Chap 06.p65 08.3.11, 0:10 PM294
6.2 High-speed Counters
KV-3
00KV
-10/
80
3-295
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
RET
0025
INTERRUPT ROUTINE FOR SPEED-UP/SLOW-DOWN
INTCTC2
SPEED-UP
DM0012LDA
DM0002ADD
DM0012STA
DM0000CMP
1200 2011 03 CALL
2011 02 CALL
2011( )1201
2011 DM0003LDA
DM0011SUB
CTC2STA
DM0011STA
1201(RES )1200
SPEED-UP
DM0012LDA
DM0002SUB
DM0012STA
DM0001CMP
1200 2011 02 CALL
2011 02 CALL
#65535LDA
CTC2STA
RETI
RETI
ENDH
INTERRUPT FOR PULSE STOP
INTCTC3
2002(SET )2105
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
Adds the acceleration rate to thecurrent frequency to changefrequency whenever CTC2 turnsON while acceleration flag 1200 isON. When the current frequencyreaches fH, stops acceleration andsets the deceleration pulse count.
Subtracts the acceleration rate fromthe current frequency to changefrequency whenever CTC2 turnsON while acceleration flag 1200 isOFF. When the current frequencyreaches fL, stops deceleration andinitializes the settings.
When pulse count of clock pulsesequals the setting value of CTC3,stops clock pulse output.
KVNKA Chap 06.p65 08.3.11, 0:10 PM295
6.3 Positioning Control
KV-3
00KV
-10/
80
3-296
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
6.3 Positioning Control
6.3.1 Positioning Control (Ramp-up/down Control)Outline of positioning control
The KV-300 CPU outputs clock pulses, independent of scan time, directly throughoutput relay 0500 or 0501. When the clock pulse frequency, output pulse count, andacceleration/deceleration time are set to the data memory addresses in advance,the KV-300 CPU automatically performs ramp-up/down control. Output frequencycan be set within the range of 153 Hz to 50000 Hz.
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 controlparameters.
Acceleration time Deceleration time Time (ms)
Frequency (Hz)
Operation
StartOutput pulse count
Stepping motor/servo motor
Motor driver
Clock pulse
Rotation direction
Lo : CWHi : CCW
KV-300
05000501
05020503
KVNKA Chap 06.p65 08.3.11, 0:10 PM296
6.3 Positioning Control
KV-3
00KV
-10/
80
3-297
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Run
Start
Acceleration/ deceleration time
∆t
Setting and application of parametersThis section describes how to set and apply parameters for positioning control.
Setting parameters
Set the parameters to the assigned data memory addresses. To operate thepositioning control function, the special utility relays must be set. Refer to page 3-299.
The following table shows the parameters and assigned DM Nos.
Note: Refer to the following expression to determine the output pulse count.
Output pulse count < (65535 x pulse change cycle [ms]) ÷ (1000 x run frequency[Hz])
Pulse change cycle (∆t)
The pulse change cycle is the cycle in which the output clock pulse frequency ischanged for acceleration or deceleration. The pulse change cycle is obtained fromone of the following expressions, whichever produces the smaller solution. However,when the start pulse is less than 500 Hz, the pulse change cycle becomes 14 ms ormore.
Pulse change cycle (∆t) [ms] = (acceleration time [ms] + 199) ÷ 200 x 4orPulse change cycle (∆t) [ms] = 1000 ÷ (run frequency [Hz] ÷ 1000)
DMNo. Parameter Allowable setting range
DM9407 Set value error code Code 11 to 17 or FFFF (-1)is entered when error occurs
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 4096time (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 4096time (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)
KVNKA Chap 06.p65 08.3.11, 0:10 PM297
6.3 Positioning Control
KV-3
00KV
-10/
80
3-298
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Set value error code
Automatically writes an error code (11 to 17) into DM9407 when a parameter settingerror is found at startup.
Corrective action for error code 16
Error code 16 is issued when the output pulse count during acceleration/decelera-tion time exceeds other values calculated from the preset parameters.To recover from the error, the following corrective actions are available.• Change the run frequency and/ or the acceleration/ deceleration time according
to the following expression.
Corrective action for error code FFFF (-1)• Reduce run frequency and start frequency.• Reduce accelleration/ deccelleration time.
Start frequency (Hz)Sets a start frequency (speed) to start the motor rotation smoothly during positioningcontrol.
The KV-300 CPU outputs clock pulses at the specified frequency.
Run frequency (Hz)
Sets the motor frequency (speed) during positioning control. The KV-300 CPUoutputs clock pulses at the specified frequency.
Note: When the start frequency equals the run frequency, the system operates asshown in the following chart.
Here, the acceleration/deceleration time is ignored. The output count should be lessthan 65535.
0
Preset frequency
Code Error description Corrective action
11 Start frequency is below allowable Adjust start frequency to within allow-range. able range (153 to 50000).
12 Run frequency is below allowable Adjust run frequency to within allow-range. able range (153 to 50000).
13 Run/start frequency exceeds allow- Adjust run/start frequency to withinable range. allowable range (153 to 50000).
14 Start frequency is greater than run Reduce start frequency to less thanfrequency. run frequency.
15 Acceleration/deceleration time Adjust acceleration/deceleration timeexceeds allowable range. to within allowable range (0 to 4096).
16 Too many pulses are output during Change the parameters.acceleration/deceleration time.
17 Too few pulses are output during Set 2 or more as value for outputacceleration/deceleration time. pulse count.
FFFF Other calculation error Change the parameters.
65535Run frequency
x Pulse change cycle x 655351000
KVNKA Chap 06.p65 08.3.11, 0:10 PM298
6.3 Positioning Control
KV-3
00KV
-10/
80
3-299
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
Acceleration/deceleration time (ms)
Sets the time required when the start frequency accelerates to the run frequency atstartup. In the same manner, sets the deceleration time required at stop. The KV-300 CPU controls the clock pulse frequency from the start frequency to the runfrequency within the specified time. The pulse change cycle within the accelerationtime is obtained from one of the following expressions, whichever produces thesmaller solution. However, the pulse change cycle when the start pulse is less than500 Hz becomes 14 ms or more.
Pulse change cycle (∆t) ms = (acceleration time ms + 199) ÷ 200 x 4orPulse change cycle (∆t) ms = 1000 ÷ (run frequency Hz ÷ 1000)
Output pulse countSets 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 pulsecount is greater than 65535, set the pulse count separately for high-order 16 bitsand low-order 16 bits based on the following expressions.
(Output pulse count) ÷ 65536 = A (solution) … B (remainder)
A = Output pulse count (high-order 16 bits)B = Output pulse count (low-order 16 bits)
Note: When the specified output pulse count is insufficient and does not reach thetarget value, the KV-300 CPU performs triangular control.
The current pulse output value cannot be checked.
Procedure
When the positioning control function is used, the KV-300 CPU controls start, stop,and emergency stop by turning ON/OFF the utility relays. The table below shows theoperations and assigned utility relays.
0
Run frequency
Start frequency
Relay No. R/W Function Description
0500 0501
2308 2311 W STOP Decelerates at rising (UP) edge and stops.
2309 2312 R RUN Turns ON during pulse output.W RESET Immediately stops when turning ON during
interrupt program.
2310 2313 W START Starts at rising (UP) edge.
KVNKA Chap 06.p65 08.3.11, 0:10 PM299
6.3 Positioning Control
KV-3
00KV
-10/
80
3-300
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
DM9409
DM9408
0
DM9411DM9412
DM9410DM9410
2310(START)
2309(RUN)
2308(STOP)
COM000000010002
0500050105020503
111212
78910
COM 20
24 VDC–
+KV-300
+–+–
FG
24 VDC
– +
Twisted pair cableCW (pulse)
CCW (rotation direction)
Stepping motor driver
Stepping motor
Em
erge
ncy
stop
Sto
pS
tart
Operation chart (when 0500 is used)
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 settingsare correct.
Note 2: If a parameter setting for the X-axis or Y-axis is incorrect, 2309 (2312) doesnot turn ON and an error code is written into DM9407. Check the error code andadjust the parameter setting.
Note 3: By resetting 2309 (2312) within the interrupt program, you can stop theclock 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 isextended by 10 µs to 20 µs in the pulse change cycle. Test the clock pulse output onthe KV-300 system before using it in practical applications.
Examples of stepping motor control Connection example
The following reference example shows how to connect the KV-300 CPU to astepping motor driver. Refer to the stepping motor driver instruction manual fordetails.Set the pulse input mode for the stepping motor driver to "Pulse input mode 1".
DM9408: Start frequency (Hz)DM9409: Run frequency (Hz)DM9410: Acceleration time (ms)DM9411: Output pulse count
(high-order 16 bits)DM9412: Output pulse count
(low-order 16 bits)
When 2310 turns ON, clock pulse is output.(rising [UP] edge is detected.)2309 is ON during clock pulse output. Whenpulse output is stopped, 2309 turns OFF.When turning ON 2308, clock pulsedecelerates and stops (rising [UP] edge isdetected.)
KVNKA Chap 06.p65 08.3.11, 0:10 PM300
6.3 Positioning Control
KV-3
00KV
-10/
80
3-301
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
15000 17500
80002000300
0
15000
Ramp-up/down control
When start switch 0002 is turned ON, 0500 outputs 100000 pulses under thefollowing 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, pulseoutput is immediately stopped.
Application example of stepping motor control
Assume a program that can be controlled both automatically and manually.In automatic mode, the system runs as shown in the chart below after 0000 is turnedON.
In manual mode, the system goes forward while 0008 is ON and rearward while0009 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), andrearward end limit (0004).
0002DW DW DW DW DW
2008EI
#01000 #05000 #03000 #00001 #34464 2310
0001 2308
END
INT0000
2002RES2309
RET1
ENDH
DM9408 DM9409 DM9410 DM9411 DM9412
0001
0002
0003
0004
0005
0006
0007
0008
Enables interrupt when starting operation.This is required to allow emergency stopoperation.
Sets parameters and simultaneouslystarts pulse.Decelerates and stops pulse.
Executes emergency stop sequence withinterrupt progaram.
KVNKA Chap 06.p65 08.3.11, 0:10 PM301
6.3 Positioning Control
KV-3
00KV
-10/
80
3-302
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
STEPPING MOTOR CONTROL PROGRAM (ORIGIN, FORWARD, REVERSE LIMITS)
SPECIFICATION
PULUSE OUT==500 FOR/REV=502 ORIGIN=0002 FOR/END=0006 FOR/END=0004
MANUAL SW: FORWARD=0008 REVERSE=0009 ORIGIN SW=0007
AUTO OPERATION START=0000
ENABLES INTERRUPT & RESETS ORIGIN POSITIONING FRAG
MANUAL SWITCHES: FORWARD=0008 REVERSE=0009
LIMIT SWITCHES
FORWARD IN ADVANCE
STOP FORWARDING
POSITIONING ORIGIN WHILE REVERSING SLOWLY
* * * * * * * * * * * * * * * * * * * * * * * * * * ORIGIN * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2008 1200(RES) < EI >
0008 0009 2309 00060502(SET) DIFU
1100
0009 0008 2309 00040502(RES) DIFU
1101
1100
1101
< DW > < DW > < DW > < DW > < DW >1103DIFU
#00600
DM9408
#04000
DM9409
#00100
DM9410
#00001
DM9411
#00000
DM9412
0008 0009 1105DIFU
0007 1205DIFU
1205< DW > < DW > < DW > < DW > < DW >
1300DIFU
#00300
DM9408
#03000
DM9409
#00250
DM9410
#00000
DM9411
#03500
DM9412
0502(SET)
1200(SET)
1203< DW > < DW > < DW > < DW > < DW >
1301DIFU
#00500
DM9408
#05000
DM9409
#00000
DM9410
#00001
DM9411
#00000
DM9412
0502(RES)
1200(RES)
1203DIFU
1200 1201 12022309ON
2309OFF
1201 1202
Program example
Sets start frequency, run frequency,and acceleration/deceleration time.Start frequency: 600 HzRun frequency: 4 kHzAcceleration/deceleration time:100 msOutput pulse count: 65536
To return to the origin, first goesforward and then rearward. Stopswhen origin limit (0002) turns ON.
For forward operation, the followingparameters are set:Start frequency: 300 Hz,Run frequency: 3 kHz,Acceleration/decekeratuib time: 250 ms,Output pulse count: 3500.
For rearward operation, the followingparameters are set:Start frequency: 50 HzRun frequency: 500 HzAcceleration/deceleration time: 0 msOutput pulse count: 65536
KVNKA Chap 06.p65 08.3.11, 0:10 PM302
6.3 Positioning Control
KV-3
00KV
-10/
80
3-303
16
Chapter 6 Interrupts, High-speed Counters, Positioning Control
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
SLOW DOWN & STOP (MANUAL/AUTO)
MOVES TO NEXT STAGE AFTER MOTOR STOPS
STARTS MOTOR
* * * * * * * * * * * * * * * * * * * * * * * * AUTO OPERATION CH0 * * * * * * * * * * * * * * * * * * * *
2008 1400(SET)
2308 1401(RES)
T003
1502
2309
1407
< DW > < DW > < DW > < DW > < DW >#00300
DM9408
#15000
DM9409
#00250
DM9410
#00000
DM9411
#17500
DM9412
0502(RES)
1505DIFU
1501< DW > < DW > < DW > < DW > < DW >#00300
DM9408
#02000
DM9409
#00250
DM9410
#00000
DM9411
#02500
DM9412
0502(SET)
1504DIFU
1500< DW > < DW > < DW > < DW > < DW >#00300
DM9408
#08000
DM9409
#00150
DM9410
#00000
DM9411
#15000
DM9412
0502(SET)
1503DIFU
AUTO OPERATION PARAMETER SET
1400JMP
1502DIFU
1403STG
1406(RES)
#00005T003
1407
T002 2309
1406
1403JMP
1501DIFU
1402STG
1405(RES)
#00005T002
1406
T001 2309
1405
1402JMP
1500DIFU
1401STG
1407(RES)
#00010T001
1405
0000 1401JMP
1400STG
1300 0006 2310( )
1301 0004
1103
1506 2308
0006 0009 2308( )
0004 0008
1105
DIFU1408 1402
(RES)1403(RES)
1408
STAGE INSTRUCTION START
AUTO START (OPERATES DURING 0000 IS TURNED ON)
1400(SET)
0024 STARTS MOTOR
0048
0049
0050
0051
0052
0053
0054
INTERRUPT FOR EMERGENCY STOP (POSITIONING ORIGIN)
1503 1506( )
1504
1505
2309( RES )
1200 0008
END
0055
0056ENDH
RETI
0009 0000
INT0002
Instructs motor start and acceleration/deceleration stop.
Creates each of the operation programswith the STG instruction and makes theprograms ready in the specified order.
Sets the parameters for automatic mode.(1) Start frequency: 300 HzRun frequency: 8 kHzAcceleration/deceleration time: 150 msOutput pulse count: 15000(2) Start frequency: 300 HzRun frequency: 2 kHzAcceleration/deceleration time: 250 msOutput pulse count: 2500(3) Start frequency: 300 HzRun frequency: 15 kHzAcceleration/deceleration time: 250 msOutput pulse count: 17500
Stops pulse at the origin with the interruptprogram.
KVNKA Chap 06.p65 08.3.11, 0:10 PM303
6.3 Positioning Control
KV-3
00KV
-10/
80
3-304
6
Chapter 6 Interrupts, High-speed Counters, Positioning Control
KVNKA Chap 06.p65 08.3.11, 0:10 PM304
Chapter 7Serial Communication
The KV Series can be connected to an external device with an RS-232C interfaceto establish communication.This chapter describes communications specifications, how to connect the KVSeries to external devices, and how to perform communication.
7.1 Communications Specifications ............................................ 3-3067.1.1 Communications Specification ............................................................... 3-3067.1.2 Connection with the KV Unit .................................................................. 3-3067.1.3 Connecting the KV-300 CPU to a Personal Computer .......................... 3-307
7.2 Serial Communication ............................................................. 3-3087.2.1 Command Transmission Procedure ....................................................... 3-3087.2.2 Format of Commands/Responses ......................................................... 3-3097.2.3 Communication Command/Response List ............................................. 3-3107.2.4 Setting Communication Commands and Responses to Commands ..... 3-3117.2.5 Other Response Codes .......................................................................... 3-3157.2.6 Error Code List ....................................................................................... 3-3167.2.7 Example Program .................................................................................. 3-317
7.3 Loading Text Data .................................................................... 3-3187.3.1 Receiving Text Data ............................................................................... 3-3187.3.2 Transmitting Text Data ........................................................................... 3-3197.3.3 Sample Program .................................................................................... 3-320
7.4 ASCII Code List ........................................................................ 3-321
KVNKA Chap 07.p65 08.3.11, 0:11 PM305
7.1 Communications Specifications
3-306
7
Chapter 7 Serial Communication
7.1 Communications SpecificationsThis section describes the specifications for the RS-232C interface and the connec-tion between the KV and external devices.
7.1.1 Communications SpecificationThe communications specification of the KV is summarized in the table. Set thecommunications parameters of the personal computer by referring to the table.
Communications parameters
Note 1: Be sure to specify the same communication parameters for the KV and anyexternal devices to be connected. Communication will fail if different parameters areused.Note 2: Refer to the instruction manual supplied with each device when settingcommunications parameters on the device.
7.1.2 Connection with the KV UnitUse the special connection cable (Straight cable: OP-26487, Reverse cable: OP-96607) and a 25-pin D-sub connector (OP-26485) to connect the KV to the RS-232Cconnector of the external device.
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 thespecial connection cable to connect the KV with each device.
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
External device with RS-232C connector
Communication port ACommunication port B
25-pin D-subconnector
(OP-26485)
Pin assignment forthe KV
KV
Connectioncable
(Reverse:OP-96607)
Device desig-nated as modem
25-pin D-subconnector
(OP-26485)
KV
Connectioncable
(Straight:OP-26487)
Device designatedas terminal
SD 3RD 5SG 4
23
45620
7
SDRD
RSCSDRER
SG
SD 3RD 5SG 4
23
45620
7
SDRD
RSCSDRER
SG
2 31 4 5 6
KV
KVNKA Chap 07.p65 08.3.11, 0:11 PM306
7.1 Communications Specifications
3-307
17
Chapter 7 Serial Communication
7.1.3 Connecting the KV-300 CPU to a Personal ComputerConnect the KV-300 CPU to the RS-232C port of the personal computer with thesupplied connecting cable (OP-226486/OP-26487).
Recommended pin assignments for the RS-232C communication cable are shownbelow. When connecting the KV-300 CPU, use only the connecting cable supplied.
Standard cable (OP-26486 + OP-26487)
KV-300
Connecting cableStandard cable:OP-26486
9-pin D-SUB femaleconnector: OP-26487 Personal computer with an
RS-232C port
KV-30035
4
23456
207
SDRD
SG
SDRDRSCSDRERSG
35
4
23456207
SDRD
SG
SDRDRSCSDRERSG5432
Pin assignments forthe KV-300 CPU
DCE KV-300 DTE
35
4
2345678
SDRD
SG
ModularConnector
9-pin D-sub connector
KVNKA Chap 07.p65 08.3.11, 0:11 PM307
7.2 Serial Communication
3-308
7
Chapter 7 Serial Communication
7.2 Serial CommunicationWhen the KV is connected to a personal computer, the current value or preset valueof timers/counters or contents of data memories in the KV can be loaded to andmodified on the computer.
7.2.1 Command Transmission ProcedureCommands are transmitted from a personal computer to the KV base unit as follows:
Transmitting a break signal
A break signal is used to initialize the communication buffer and baud rate setting ofthe KV. It is necessary to transmit a break signal of 100 ms or longer to the KVbefore starting communication. Another break signal is unnecessary once thecommunication is established.A break signal must have the waveform shown below.
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, besure 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 thecommunication program. After that, restart communication between the KV and thepersonal computer.Note 3: Be sure to stop the communication for 10 ms or longer after transmitting abreak signal.
10 ms or longer
Transmits a command
Transmits communicationsstart command (CR)
Initialize the communication buffer andbaud rate setting of the KV.
Start communications with the KV.
Transmit a command which instructs theKV to perform the required operation.
Transmits communicationsend command (CQ)
End communications with the KV.
Receive and check the response to thetransmitted command.
Transmits a break signal
Receiving a response
100 ms or longer+V
-VSD
KVNKA Chap 07.p65 08.3.11, 0:11 PM308
7.2 Serial Communication
3-309
17
Chapter 7 Serial Communication
Command/response format
"Command" and "response" in communications between the KV and a personalcomputer are defined as follows:
Command: Message transmitted from personal computer to KV
Response: Answer to the command (message from KV to personal computer)
When a personal computer transmits a command to the KV Series basic unit, the KVsends back a response to the personal computer.When creating a program to control the KV using a personal computer, create it sothat the response is checked before the next command is transmitted.
7.2.2 Format of Commands/ResponsesThe formats of commands and responses are as follows:
Command formatUse the following format to transmit commands from the personal computer to theKV. [CR] is a delimiter. The KV ignores [LF] and recognizes the next character after[LF] as the next command.
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 personalcomputer can process the response in this format.
Command
Response
Or
CR
CR LFCommand
CR LF
KVNKA Chap 07.p65 08.3.11, 0:11 PM309
7.2 Serial Communication
3-310
7
Chapter 7 Serial Communication
7.2.3 Communication Command/Response ListThe following list shows the commands and responses used in serial communica-tion. "_" in the list represents a space.
noitcnuF dnammoC esnopseR noitpircseD
.noitacinummocstratS RC CC
.noitacinummocsdnE QC FC
.edomsegnahC nM KO edomMARGORP:0=nedomNUR:1
.rorresraelC RE KO
.rorreCLPskcehC E? dd )rorreoN:00(edocrorrE=dd
.edomCLPtnerrucskcehC M? f edomMARGORP:0=fedomNUR:1
retnuoC nnnC_DR
ddddd,ddddd,f↑↑
)eulavteserP()eulavtnerruC(
NOtcatnoC:1,FFOtcatnoC:0=f)lamicedni(53556ot00000=dddddd
.oNretnuoC=nnn/n
deeps-hgiHHTCretnuoc nHTC_DR
deeps-hgiHretnuoc
CTCrotarapmocnCTC_DR
sdaeR remiT nnnT_DRddddd,ddddd,f
↑↑)eulavteserP()eulavtnerruC(
NOtcatnoC:1FFOtcatnoC:0=f)lamicedni(53556ot00000=dddddd
.oNremiT=nnn
remmirtlatigiD TA_DR00000_00000_ddddd_ddddd
↑↑)1remmirT()0remmirT(
)lamicedni(53556ot00000=dddddd.1dna0remmirtfoseulavteserpsdaeR
tcatnocyaleR nnnnn_DR f NOtcatnoC:1,FFOtcatnoC:0=f
yromemataD nnnnMD_DRddddd )lamicedni(53556ot00000=dddddd
.oNMD=nnnnatadyraropmeTyromem nnMT_DR
tnerrucretnuoCeulav ddddd_nnnC_RW
KO retnuoc/remiT=nnn/n)lamicedni(53556ot00000=dddddd.oN
tnerrucremiTeulav ddddd_nnnT_RW
tnerrucHTCeulav ddddd_nHTC_RW
setirW teserpretnuoCeulav .2 ddddd_nnnC_SW
KO retnuoc/remiT=nnn/n)lamicedni(53556ot00000=dddddd.oN
teserpremiTeulav .2 ddddd_nnnT_SW
teserpCTCeulav .2 ddddd_nCTC_SW
yromemataD ddddd_nnnnMD_RWKO )lamicedni(53556ot00000=dddddd
.oNMD=nnnn,nnatadyraropmeTyromem ddddd_nnMT_RW
yaleR nnnnn_TS
KO .oNyaleR=nnnn.oNretnuoc/remiT=nnnNOsecroF tcatnocretnuoC nnnC_TS
tcatnocremiT nnnT_TS
yaleR nnnnn_SR
KO.oNyaleR=nnnn
.oNretnuoc/remiT=nnn.oNCTC=n
tcatnocretnuoC nnnC_SR
FFOsecroF tcatnocremiT nnnT_SR
deeps-hgiHretnuoc
CTCrotarapmoctcatnoc
nCTC_SR
Note 1: Temporary data memories TM28, TM30, and TM31 are read-only. Values cannot be written intothese 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", theladder 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 thePLC’s EEPROM.
Contact Keyence if you need to change it frequently.
KVNKA Chap 07.p65 08.3.11, 0:11 PM310
7.2 Serial Communication
3-311
17
Chapter 7 Serial Communication
7.2.4 Setting Communication Commands and Responses toCommands
This section describes the command settings and responses when a command isproperly processed."_" represents a space.Refer to "7.2.5 Other Response Codes" (p. 3-315) for responses under abnormalconditions.
Communications start commandTransmit a communications start command to start communication with the KV.Other commands can be transmitted after the proper response is sent back from theKV.
Note: Other commands cannot be used unless a [CR] (communications start)command is transmitted first.
Starts communications between the KV and a personal computer.
Command: CRResponse: CC
Communications end commandEnds communications between the KV and a personal computer.
Command: CQResponse: CF
Mode change commandSelects the mode between PROGRAM and RUN.
Command: Mn [n=0; PROGRAM mode, n=1; RUN mode]Response: OK
Error clear commandClears error messages on KV.
Command: ERResponse: OK
Checking KV PLC errorChecks errors or faults in the KV. The description of the error is indicated with theerror code. "7.2.6 Error Code List" (p. 3-316).
Command: ?EResponse: dd
Error code (2- or 3-digit number)
Checking current mode
The KV responds with 0 or 1 indicating a current mode.
Command: ?MResponse: f
0: PROGRAM mode 1: RUN mode
KVNKA Chap 07.p65 08.3.11, 0:11 PM311
7.2 Serial Communication
3-312
7
Chapter 7 Serial Communication
Reading counter
Reads the contact ON/OFF status, or the current and preset values of the specifiedcounter/up-down counter.
Command: RD_CnnnCounter No.
Response: f,ddddd,ddddd[Preset value of the counter (00000 to 65535: indecimal)][Current value of the counter (00000 to 65535: indecimal)]0: Contact is OFF., 1: Contact is ON.
Reading high-speed counter CTH
Reads the contact ON/OFF status, or the current and preset values of the specifiedhigh-speed counter CTH.
Command: RD_CTHnHigh-speed counter No. (0 or 1)
Response: f,ddddd,dddddPreset value of CTH (00000 to 65535: in decimal)Current value of CTH (00000 to 65535: in decimal)0: Contact is OFF., 1: Contact is ON.
Reading high-speed counter comparator CTC
Reads the contact ON/OFF status, or the current and preset values of the specifiedhigh-speed counter comparator CTC.
Command: RD_CTCnHigh-speed counter comparator No.
Response: f,ddddd,dddddPreset value of CTC (00000 to 65535: in decimal)Current value of CTC (00000 to 65535: in decimal)0: Contact is OFF., 1: Contact is ON.
Reading timerReads the contact ON/OFF status, or the current and preset values of the specifiedtimer.
Command: RD_TnnnTimer No.
Response: f,ddddd,dddddPreset 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 digital trimmerReads the preset values of the digital trimmers.
Command: RD_ATResponse: ddddd_ddddd_00000_00000
Value of trimmer 1 (00000 to 65535: in decimal)Value of trimmer 0 (00000 to 65535: in decimal)
Reading relay contactReads the contact ON/OFF status of the specified relay.
Command: RD_nnnnRelay No.
Response: f0: Contact is OFF., 1: Contact is ON.
KVNKA Chap 07.p65 08.3.11, 0:11 PM312
7.2 Serial Communication
3-313
17
Chapter 7 Serial Communication
Reading DMReads the contents of the specified data memory.
Command: RD_DMnnnnData memory No.
Response: dddddData in the specified data memory. (00000 to65535: in decimal)
Reading TMReads the contents of the specified temporary data memory.
Command: RD_TMnnTemporary data memory No. (00 to 31)
Response: dddddData 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_dddddNew current value (00000 to 65535: in decimal)Counter No.
Response: OK
Writing current value of timerChanges the current value of the specified timer.
Command: WR_Tnnn_dddddNew current value (00000 to 65535: in decimal)Timer No.
Response: OK
Writing current value of high-speed counter CTHChanges the current value of the specified high-speed counter CTH.
Command: WR_CTHn_dddddNew 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.
Command: WS_Cnnn_dddddNew 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 isautomatically updated the next time the KV is turned ON.
Writing preset value of timerChanges the preset value of the specified timer.
Command: WS_Tnnn_dddddNew preset value (00000 to 65535: in decimal)Timer No.
Response: OK
Note: Visual KV Series: Executing this command changes the program in the KV. Theprogram in EEPROM is automatically updated the next time the KVis turned ON.
KV-300, 10/80 Series: The "WS" command changes the content of the programstored in the PLC’s EEPROM.
Contact Keyence if you need to change it frequently.
KVNKA Chap 07.p65 08.3.11, 0:11 PM313
7.2 Serial Communication
3-314
7
Chapter 7 Serial Communication
Writing preset value of high-speed counter comparator CTCChanges the preset value of the specified high-speed counter comparator CTC.
Command: WS_CTCn_dddddNew preset value (00000 to 65535: in decimal)High-speed counter comparator No.
Response: OK
Writing into DM
Writes data into the specified data memory.
Command: WR_DMnnnn_dddddNew 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_dddddNew 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_nnnnnRelay No.
Response: OK
Forcing counter contact ON
Forces the contact of the specified counter to ON.
Command: ST_CnnnCounter No.
Response: OK
Forcing timer contact ON
Forces the contact of the specified timer to ON.
Command: ST_TnnnTimer No.
Response: OK
Forcing relay OFF
Forces the contact of the specified relay to OFF.
Command: RS_nnnnnRelay No.
Response: OK
Forcing counter contact OFF
Forces the contact of the specified counter to OFF.
Command: RS_CnnnCounter No.
Response: OK
Forcing timer contact OFF
Forces the contact of the specified timer to OFF.
Command: RS_TnnnTimer No.
Response: OK
KVNKA Chap 07.p65 08.3.11, 0:11 PM314
7.2 Serial Communication
3-315
17
Chapter 7 Serial Communication
Forcing CTC contact OFFForces the contact of the specified high-speed counter comparator to OFF.
Command: RS_CTCnHigh-speed counter comparator No.
Response: OK
Note 1: Input relays cannot be forced ON/OFF. (Except when special utility relay2301 is ON.)Note 2: "_" in commands and responses represents a space.
7.2.5 Other Response CodesIf the command from a computer is an unspecified one, or an error occurs in the KV,the KV sends back an appropriate response code for the status.
Base uniterror
Responsecode
Description Cause Remedy
• Undefined relay, counter,timer, DM, CTH, or CTCnumber was specified.
• Counter, timer, CTH, orCTC number, unused in aprogram was specified.
• Specify a number that isdefined in the KV beingused.
• Check a program, andspecify a number used inthe program.
• Undefined command wastransmitted.
• Incorrect command wasspecified.
• Command other than "CR"was transmitted before thecommunications path wasestablished.
• Check a command.
• Transmit "CR" to startcommunications, and thentransmit a command.
E0
E1
E2
E3
E4
E5
Relay No.error
Commanderror
Programunregistered
Base unitfault
Write-protected
When the KV has no programstored, "M1" was transmittedor reading of timer/countercontent was attempted.
• Register a program into theKV.
• Check a program andspecify the number used inthe program.
Hardware error was detectedin a KV base unit.
Turn off the power for the KV,and then turn it on again. Ifthe cause of the error is notremoved, the KV may befaulty. Contact your nearestKEYENCE office.
Attempt was made to changethe preset value of a counter,timer, or CTC in a write-protected program.
Write-enable the program,and change the preset value.
"M1" was transmitted beforecleaning an error messagefrom the KV.
Clear the error message fromthe KV, and remove the causeof the error.
KVNKA Chap 07.p65 08.3.11, 0:11 PM315
7.2 Serial Communication
3-316
7
Chapter 7 Serial Communication
Subroutines are nested to four levelsor more.
FOR/NEXT instructions are nested toeight levels or more.
Five levels or more of interruptsoccurred simultaneously.
MPS/MPP instructions are nested toeight levels or more.
Content in RAM was erased. All datain data memory and current values ofcounters in the KV were cleared.
Scan time exceeds 300 ms.
Attempt was made to operate a KVbase unit which has no programsstored.
Hardware error was detected in a KVbase unit.
Error code Description Cause Remedy
00 No error
10 CALL nest error
11 FOR nest error
12 INT nest error
13 MPS nest error
20 Memory error
30 Scan timer error
40 NO PROGRAM
50 SND/RTN failure
51 Division by zero
52 Address error
53 Invalid instruction
54 Watchdog timer error
7.2.6 Error Code ListWhen a "Checking KV PLC error" command (?E) is transmitted, the KV sends backthe error code. The following list shows the description, cause, and remedy for eacherror code.
These errors may occur when aprogram is executed.
Check the program while payingparticular attention to usage ofsubroutines and the INT instruction,and restore the program accordingly.
Turn the KV off once and turn it on.Register data from the beginning.
Check the program again.• Be sure that there is no excessive
repetition using the FOR/NEXT loop.• Be sure that an interrupt is not
executed at a higher rate.
Write a program into KV.
Turn off the power for the KV, andthen turn it on again. If the cause ofthe error is not removed, the KV maybe faulty. Contact your nearestKEYENCE office.
KVNKA Chap 07.p65 08.3.11, 0:11 PM316
7.2 Serial Communication
3-317
17
Chapter 7 Serial Communication
7.2.7 Example ProgramTypical program for communications between the KV and a personal computer (ForIBM PC-AT & compatible computers using BASIC)
‘‘Language Microsoft BASIC Version 7.0‘‘ *****I/OAddress (RS-232C Port-1)*****‘Port-1&H3F*‘Port-2&H2F*‘PortCtrl%=&H3FB’COM1Port1Modem%=&H3FC’MODEMCtrlPortBpsLow%=&H3F8’BitrateLowPortBpsHigh%=&H3F9’BitrateHigh‘*****ControlCode*****Port1CtrlCode1%=&H5B’Break&8bitEven1StopbitPort1CtrlCode2%=&H1B’8bitEven1Stopbit‘*****InitializesRS-232C*****OPEN"COM1:9600,N,8,1"FORRANDOMAS#1'‘*****RS-232CPortInit*****OUTPortCtrl %,Port1CtrlCode1%’Start transmitting a break signalSLEEP1’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‘-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-‘*********************************************************‘*****Transmitting a command/receiving a response*****‘*********************************************************a$=""WHILEa $>"END"PRINT"Command>>":INPUTa$PRINT#1,a $b$=""LINEINPUT#1,b$PRINT"RsP[";b$;"]"PRINTWENDPRINT"GoodBy!!"CLOSE#1
END
Note: No parity check is specified due to thelimitations of the version of BASIC being used.
• Change value in "SLEEP" timer according to your personal computer’s clockfrequency so that value I exceeds 100 ms.
• Set the baud rate of your personal computer to 9600 bits/s.• Enter END to terminate programming.
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.
KVNKA Chap 07.p65 08.3.11, 0:11 PM317
7.3 Loading Text Data
3-318
7
Chapter 7 Serial Communication
7.3 Loading Text DataThe KV can be connected to equipment having an RS-232C port to load consecutivetext data (less than 100 bytes) as a batch into its data memories.Loaded data can be modified and incorporated into a program.
7.3.1 Receiving Text DataThe KV can write up to 100 bytes of text data sandwiched between STX and ETX,into internal data memories (DM1000 to DM1099 with communication port A,DM1200 to DM1299 with communication port B), one byte per data memory inASCII code.
Communications data formatNote that each text data must include STX (02H) in the 1st byte followed by the text(100 bytes max.) and end with ETX (03H) in the last byte as shown below.
Internal data memoryThe KV writes received text data into its data memories (DM1000 to DM1099 withcommunication port A, DM1200 to 1299 with communication port B), one byte perdata memory in ASCII code.
The KV writes "00" into the high-order 8 bits and text data in ASCII code into thelow-order 8 bits of the data memory.
Note: The KV-10xx includes only communication port A.
Special utility relay operationThree special utility relays assigned for each channel turn on for one scan toindicate that text data has been received or that data reception has failed.
STX
1st byte Last byte
Text data (less than 100 bytes) ETX
Low-order 8 bits (ASCII code)
Received data
Byte count of data
Data 1 Data 2 Data 3 Data 99
1st DM(Byte count of data)Data memory 2nd DM 3rd DM 4th DM 100th DM
Bits indata memory
High-order 8 bits (00)
ataDyromem
WENVK
ATROP 0001MD 1001MD 2001MD 8901MDot3001MD 9901MD
BTROP 0021MD 1021MD 2021MD 8921MDot3021MD 9921MD
003-VK08/01-VK 0029MD 1029MD 2029MD 8929MDot3029MD 9929MD
.oNataD tnuocetyB 1ataD 2ataD 89ataDot3ataD 99ataD
STX
0
15 00
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1
ETX
KVNKA Chap 07.p65 08.3.11, 0:11 PM318
7.3 Loading Text Data
3-319
17
Chapter 7 Serial Communication
Note 1: Be sure to transmit a break signal for the first serial communication with apersonal computer after the KV-P3E(01) handheld programmer is connected to theKV, 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 transmita break signal, turn the KV OFF once to initialize the communication setting. The KVwill 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, thereceived data is not written into the data memory. In this case, special utility relay2802 (2807)*2 turns ON for one scan.
Note 4: When parity errors or other errors occur during text data reception, thereceived data is not written into the data memory. In this case, special utility relays2802 (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
7.3.2 Transmitting Text DataThe KV transmits text data written into its data memories (DM1100 to DM1199 forcommunication port A, DM1300 to DM1399 for communication port B), one byte perdata memory in ASCII code.
Transmission data format and internal data memoriesWhen transmitting data from the KV, write the data into the data memory in thefollowing format.
The KV writes "00" into the high-order 8 bits and text data in ASCII code into thelow-order 8 bits of the data memory.
Note: The KV-10xx includes only communication port A.
Data 99
Data memory bits
High-order 8 bits (00) Low-order 8 bits (ASCII code)
Data memory 1st DM(Byte count of data) 2nd DM 3rd DM 4th DM 100th DM
Transmitted data Data 1 Data 2 Data 3
.oNyaleR)ATROP(
.oNyaleR)BTROP(
.oNyaleR)08/01/003-VK( noitpircseD
1082 6082 4082 atadtxetnehwnacsenorofNOsnruT.deviecerneebsah
2082 7082 5082atadtxetnehwnacsenorofNOsnruT
,NOsi1082elihwdeviecerneebsah.NOsi3082nehwro
3082 8082 6082 atadtxetnehwnacsenorofNOsnruT.deliafsahnoitpecer
ataDyromem
ATROP 0011MD 1011MD 2011MD 8911MDot3011MD 9911MD
BTROP 0031MD 1031MD 2031MD 8931MDot3031MD 9931MD
/003-VK08/01 0039MD 1039MD 2039MD 8939MDot3039MD 9939MD
.oNataD tnuocetyB 1ataD 2ataD 89ataDot3ataD 99ataD
0
15 00
0 0 0 0 0 0 0 0 0 1 1 0 0 0 1
KVNKA Chap 07.p65 08.3.11, 0:11 PM319
7.3 Loading Text Data
3-320
7
Chapter 7 Serial Communication
T000
T0012803
0500
2801
2800
0000
2008
1001
2800
0500
DM1007LDA
DM1006LDA
DM1005LDA
DM1004LDA
DM1003LDA
DM1002LDA
DM1001LDA
DM1000LDA
1001DIFU
#00010T000
#00030T001
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
2804SET
END
ENDH
#00009DW
DM1100
$0002DW
DM1101
$004BDW
DM1102
$0045DW
DM1103
$0059DW
DM1104
$004EDW
DM1106
$0043DW
DM1107
$0045DW
DM1108
$0003DW
DM1109
$0045DW
DM1105STX K E Y E
N C E ETX
Turns ON output relay 0500for 3 seconds whenreception error occurs.
Sends break signal (1 sec.).
One scan ON
Break signal
Transmits text data ("STX KEYENCE ETX").
Transmissionstart relay No. of
transmitteddata
Trans-missionrelayReceives text data.
Reception relay No. ofreceived data.
Receiveddata
Reception error
When power is turned ON,transmits a break signal forone second during the firstscan.
Transmits text data wheninput relay 0000 turns ON.
Receives text data.Received
dataReceived
dataReceived
dataReceived
dataReceived
dataReceived data
Special utility relay operationTwo special utility relays are assigned for each channel for data transmission. Textdata or a break signal is transmitted when the respective relay is turned ON/OFF.
Note 1: Be sure to transmit a break signal for the first serial communication with apersonal computer after the KV-P3E(01) handheld programmer is connected to theKV, 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 transmita 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 beeninitialized.
Note 2: Turn ON special utility relay 2804 (2809) (SET 2804 [2809])*1 to transmit textdata. 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 breaksignal. The communication program of the destination KV is initialized after a breaksignal has been transmitted.
*1: 2807 with KV-300/10/80 *2: 2803 with KV-300/10/80
7.3.3 Sample ProgramThe following is the sample program to transmit/receive text data using communica-tion port A on the KV basic unit.
Data to be transmitted: KEYENCETransmission header: STXTransmission delimiter: ETXLength of received data: Fixed to 7 bytes
.oNyaleR)AtroP(
.oNyaleR)BtroP(
.oNyaleR)08/01/003-VK( noitpircseD
4082 9082 7082 .atadtxetgnittimsnartspots/stratSpotS:FFO,tratS:NO
0082 5082 3082 .langiskaerbgnittimsnartspots/stratSpotS:FFO,tratS:NO
KVNKA Chap 07.p65 08.3.11, 0:11 PM320
7.4 ASCII Code List
3-321
17
Chapter 7 Serial Communication
0
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
1 2 3 4 5 6 7 8 9
High-order 4 bits
Low
-ord
er 4
bits
7.4 ASCII Code ListThe following are the ASCII code characters used for data transmission.
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 forcontrol purposes.
KVNKA Chap 07.p65 08.3.11, 0:11 PM321
7.4 ASCII Code List
3-322
7
Chapter 7 Serial Communication
KVNKA Chap 07.p65 08.3.11, 0:11 PM322
Chapter 8Programming Examples
This chapter describes the typical programming examples for KV-300, KV-10/80Series. These programs can be used for Visual KV Series. However, pay attentionto the I/O addressing compatibility before use.
8.1 List ....................................................................................................... 3-324
8.2 Details ................................................................................................. 3-3268.2.1 Reference Program Examples ............................................................... 3-326
KVNKA Chap 08.p65 08.3.11, 0:12 PM323
8.1 List
3-324
8
Chapter 8 Programming Examples
8.1 List
Instruction Program title ReferencePage
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
Changing setting values of multiple timers 3-343
LDA/STA First-in first-out (FIFO) 3-343
Changing the counter setting value 3-345
Changing the timer setting value 3-345
CMP Comparing values with no specific range 3-345
Setting the upper/lower limit 3-345
Changing the CMP setting value 3-346
Multi-level comparator 3-346
ADD Adding BCD and BIN(binary) values 3-347
Total count 3-348
SUB Comparison of absolute values 3-348
MUL Multiplying the counter current value by DM value 3-349
DIV Total count average 3-349
ANDA BCD (1-digit) input 3-350
Fetches input data separately 3-350
ORA Output of 2-digit BCD data 3-351
Separate input of 2-digit BCD 3-351
KVNKA Chap 08.p65 08.3.11, 0:12 PM324
8.1 List
3-325
18
Chapter 8 Programming Examples
Instruction Program title ReferencePage
EORA Judgement of matcing data 3-352
SRA/SLA Separate input of BCD 3-352
RRA/RLA Error input count 3-353
INC/DEC Total count 3-353
Up/Down count 3-354
MPX Display of 7-segment LED 3-355
DMX Output of error input No. in BCD 3-356
TBCD Output of 4-digit BCD data 3-356
Output of 8-digit BCD data 3-356
TBIN Output of 4-digit BCD data 3-357
KVNKA Chap 08.p65 08.3.11, 0:12 PM325
8.2 Details
3-326
8
Chapter 8 Programming Examples
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 aspecified time.
Timing diagram
Ladder diagram Coding
Off-delay circuitWhen input relay 0000 turns ON, output relay 0500 turns ON. 0500 turns OFF in aspecified time after 0000 turns OFF.
Timing diagram
Ladder diagram Coding
0500
0000
2s 2s
0000 #00020
T000
T000 005000500
2-s timer
0500
0000
2s
0000
#00020
T000
0500
000000500
2-s timer
T000
Line No. Instruction Operand0000 LD 00000001 OR 05000002 TMR 000#000200003 ANB T0000004 OUT 0500
Line No. Instruction Operand0000 LD 00000001 OR 05000002 ANB T0000003 OUT 05000004 ANB 00000005 TMR 000 #00020
KVNKA Chap 08.p65 08.3.11, 0:12 PM326
8.2 Details
3-327
18
Chapter 8 Programming Examples
On-delay circuitOutput 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
Ladder diagram Coding
Flicker circuitOutput relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
Timing diagram
Ladder diagram Coding
Accumulator timer (Remains ON in case of power failure)
Counts special utility relay 2006 (1-s clock pulse) for 3600 s at C001 and inputs thecount value to C002. Accumulates the count for 10000 hours and retains the currentcount value even when power failure occurs or power is OFF.Input relay 0000Reset relay 0001(Resolution is 1 s at 2006.)
Ladder diagram Coding
0500
0000
2s 1s
0000 #00020
T000
0500T000
2-s timer
0500
0000
2s
1s 1s
2s
0000 #00020T000
T000
2-s timer
0500
#00010T001
T001
1-s timer
Line No. Instruction Operand0000 LD 00000001 TMR 000 #000200002 LD T0000003 OUT 0500
Line No. Instruction Operand
0000 LD 0000
0001 ANB T001
0002 TMR 000 #00020
0003 LD T000
0004 TMR 001 #00010
0005 OUT 0500
0000 #03600C001
C001
3600-s counterC001
1-s pulse
0001 #10000C002
10000-s counter
1000
1000
2006
Line No. Instruction Operand
0000 LD 0000
0001 ANB C001
0002 C 001 #03600 2006
0003 LD C001
0004 OUT 1000
0005 LDB 0001
0006 C 002 #10000 1000
KVNKA Chap 08.p65 08.3.11, 0:12 PM327
8.2 Details
3-328
8
Chapter 8 Programming Examples
0001 #09999C000
2002 0500#0099900000 to00999
LDAC000
CMP
0501
0512
2011
#01999CMP
2011 0500
#02999CMP
2011 0500 0501
0000
01000 to 01999
02000 to 02999
0004Low-order4 digits
High-order4 digits
STATBCDLDAC000 8500
STATBCDLDAC001 8600
Large capacity counterAccumulates 1 count to C001 for every 10000 counts by C000. This example cancount up to 655350000.Count input relay 0000Reset relay 0001
Ladder diagram Coding
Multi-level UP/DOWN counterUP/DOWN counter which allows the count setting value up to 99,990,000.• UP input relay: 0001• DOWN input relay: 0002• Reset input relay: 0003
The example below outputs the high-order 4 digits of 8-digit BCD to UDC001 andthe low-order 4 digits of 8-digit BCD to UDC000.
Ladder diagram Coding
Counter multi-level settingOutputs in 3 different levels according to the counter current value.• 00000 to 00999 —> 0500 turns ON.• 01000 to 01999 —> 0501 turns ON.• 02000 to 02999 —> 0502 turns ON.
Ladder diagram
#10000C000
C000
0001 C000
0001 #65535C001
1000
1000
0000
Line No. Instruction Operand
0000 LDB 0001
0001 ANB C000
0002 C 000 #10000 0000
0003 LD C000
0004 OUT 1000
0005 LDB 0001
0006 C 001 #65535 1000
Line No. Instruction Operand
0000 LD 00010001 LD 00020002 LD 00030003 UDC 000 #099990004 LD C0000005 AND 00010006 LD C0000007 AND 00020008 LD 00030009 UDC 001 #09999
0001
#09999UP
UDC000
0002
0003
C000
C000
0003
0002
0001
DW
RES
#09999UP
UDC001
DW
RES
BCD: Low-order 4 digits
BCD:High-order 4 digits
KVNKA Chap 08.p65 08.3.11, 0:12 PM328
8.2 Details
3-329
18
Chapter 8 Programming Examples
Coding
Application of DIFU, DIFD Instructions
One-shot circuit using differentiate instructionWhen input relay 0000 turns ON/OFF, output relay 0500 and 0501 turns ON one-shot (1 second).
Timing diagram
Ladder diagram Coding
Refer to p. 3-78.
Application of KEEP instruction
Detection of chewing gum packsDetects chewing gum packs over the carton using the proximity switch ES Series(0001 to 0003). If the switch detects that one or more packs of chewing gum aremissing, output relay 0500 turns ON for 1 s.The timing clock is generated from the visible beam photoelectric switch PZ2 (0000).
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0001 0012 CON0001 C 000 #09999 0000 0013 ANB 20110002 LD 2002 0014 ANB 05000003 LDA C000 0015 OUT 05010004 CON 0016 MPP0005 MPS 0017 CMP #029990006 CMP #00999 0018 CON0007 CON 0019 ANB 20110008 ANB 2011 0020 ANB 05000009 OUT 0500 0021 ANB 05010010 MRD 0022 OUT 05020011 CMP #01999
1000
0000
1S
1001
0500
0501 1S
1001 0501
0501 #00010T002
T002
0000 1000DIFU
1001DIFD
1000 0500
0500 #00010T001
T001
Line No. Instruction Operand0000 LD 00000001 DIFU 10000002 DIFD 10010003 LD 10000004 OR 05000005 ANB T0010006 OUT 05000007 TMR 001 #000100008 LD 10010009 OR 05010010 ANB T0020011 OUT 05010012 TMR 002 #00010
Gum
Reflector (R-2)
Proximity Switch ES Series
ON OFF ON
PZ2-61
Chewing
gum pack
Chewing
gum pack
Gum
Gum
Gum
Gum
Gum
Gum
Gum
ES Series
KVNKA Chap 08.p65 08.3.11, 0:12 PM329
8.2 Details
3-330
8
Chapter 8 Programming Examples
Timing diagram
Ladder diagram
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
Refer to p. 3-80.
Applications of SFT instruction
Alternating circuit
Every time input relay No. 0000 turns ON, 0500 turns alternately ON and OFF.
Timing diagram
Ladder diagram Coding
Refer to p. 3-82.
0000
1s
0001
0002
0003
0500
0000
1000SETKEEP
1001RES
0000 1001DIFD
1001 0500
0500 #00010T001
T001
0001 0002 0003
1000
Excecutes 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.
0000
0500
1000
1000D
SFT
0000
2003
1000
CLK
RES
0500
1000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0007 DIFD 10010001 AND 0001 0008 LD 10010002 AND 0002 0009 ANB 10000003 AND 0003 0010 OR 05000004 LD 1001 0011 ANB T0010005 KEEP 1000 0012 OUT 05000006 LD 0000 0013 TMR 001 #00010
Line No. Instruction Operand
0000 LDB 1000
0001 LD 0000
0002 LD 2003
0003 SFT 1000 1000
0004 LD 1000
0005 OUT 0500
KVNKA Chap 08.p65 08.3.11, 0:12 PM330
8.2 Details
3-331
18
Chapter 8 Programming Examples
Repeat shift circuitTurns ON every output for a second sequentially. Sets 1000 to 2008 (ON for 1stscan only at startup) and shifts outputs from 7500 to 7504 every second at T001.When 1005 turns ON, 1000 is set and the same sequence as above repeats.
Ladder diagram Coding
Synchronous shift registerTurns ON input relay 0002 to reset the shift register (1000 to 1010) when the datainput to 0000 does not synchronize with the clock input to 0001.
Timing diagram
Ladder diagram Coding
2008
T001
2003
T001
2003
1000D
SFT
1000
1001
1002
CLK
RES
7502
1005
1003 7503
#00010T001
7500
7501
1004 7504
1005 1000
SET1000
SET
0000
0001
1000
1001
1002 ...
Line No. Instruction Operand0000 LD 20080001 SET 10000002 LDB T0010003 T001 #000100004 LD 20030005 LD T0010006 LD 20030007 SFT 1000 10050008 LD 10000009 OUT 75000010 LD 1001
0011 OUT 7501
0012 LD 1002
0013 OUT 7502
0014 LD 1003
0015 OUT 7503
0016 LD 1004
0017 OUT 7504
0018 LD 1005
0019 SET 1000
0000
1100
2003
0001
0002
1000D
SFT
CLK
RES1010
1100DIFU
SET1000
Line No. Instruction Operand
0000 LD 0000
0001 DIFU 1100
0002 LD 1100
0003 SET 100
0004 LD 2003
0005 LD 0001
0006 LD 0002
0007 SFT 1000 1010
KVNKA Chap 08.p65 08.3.11, 0:12 PM331
8.2 Details
3-332
8
Chapter 8 Programming Examples
2008Turn ON for 1st scan only at startup.
2813SET
EI
0500 #00010T000
T000RES
0000
2002SET
0500
0500
Interrupt enabled
Input time constant 10µs
Turns ON timer for 1s when 0500 is ON.
Resets 0500 when T000 turns ON.
Sets interrupt input at 0000.
Sets 0500 when 0000 turns ON.
END
INT
RETI
ENDH
Initial settings
Resetting internal utility relaysWhen input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915turn OFF.SFT instruction can be substituted for RES instruction. This application can be usedto reset many relays at one time.
Ladder diagram Coding
Applications of HSP instruction
High-speed fetching of input data
When the input signal at 0000 has pulses of 5-ms interval and input relay 0001 isON, fetches data from input relay 0000 at high speed and outputs 1-s one-shotpulse from output relay 0500.
Timing diagram
Ladder diagram Coding
* To input a signal having pulse interval shorter than the scan time, use the inter-rupt instruction. Refer to p. 3-192.
When using the interrupt instructionLadder diagram
2003
2003
0000
1000D
SFT
CLK
RES1915
0001
0000
0500 1s
0001
0000
0500
#00010T000
1-s timer
0500 T000
Outputs 1-s one-shot pulse from output relay0500.
0000HSP
Line No. Instruction Operand0000 LD 2003
0001 LD 2003
0002 LD 0000
0003 SFT 1000 1915
Line No. Instruction Operand0000 LD 00010001 HSP 00000002 LD 00000003 OR 05000004 TMR 000 #000100005 ANB T0000006 OUT 0500
KVNKA Chap 08.p65 08.3.11, 0:12 PM332
8.2 Details
3-333
18
Chapter 8 Programming Examples
Coding
Refer to p. 3-86.
Application of MC-MCR instruction
Emergency stop circuit
When input relay 0000 is ON, 0500 turns ON for 1 s, then 0501 turns ON for 2 s,and then 0502 turns ON for 3 s, repeatedly.Once input relay 0000 turns OFF, 0500 turns ON when 0001 is ON, 0501 turns ONwhen 0002 is ON, and 0502 turns ON when 0003 is ON.
Timing diagram Coding
Ladder diagram
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0007 END0001 EI 0008 INT 00000002 SET 2813 0009 LD 20020003 LD 0500 0010 SET 05000004 T000 #00010 0011 RETI0005 LD T000 0012 ENDH0006 RES 0500
0000
0001
0002
0500
0501
0502
0003
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0015
0014
0016
0017
0018
0019
0020
0000
0000
1000
SET RES RES1100 1101 1102
DIFU1002 1002
STG1100 1200 #00010 T000
JMP1101
T000
MC
STG1101 1201 #00020 T001
JMP1102
T001
STG1102 1202 #00030 T002
JMP1100
T002
MCR
MC1001
0001
0002
0003
MCR
1203
1204
1205
1200
1203
0500
1201
1204
1202
1205
0501
0502
END
ENDH
1000 1001
Line No. Instruction Operand0000 LD 00000001 OUT 10000002 CON0003 OUB 10010004 LD 00000005 DIFU 10020006 CON0007 AND 10020008 SET 11000009 CON0010 RES 11010011 CON0012 RES 11020013 LD 10000014 MC0015 STG 11000016 OUT 12000017 CON0018 TMR 000 #000100019 CON0020 AND T0000021 JMP 11010022 STG 11010023 OUT 12010024 CON0025 TMR 001 #000200026 CON0027 AND T0010028 JMP 11020029 STG 11020030 OUT 12020031 CON0032 TMR 002 #000300033 CON0034 AND T0020035 JMP 11000036 MCR0037 LD 10010038 MC0039 LD 00010040 OUT 12030041 LD 00020042 OUT 12040043 LD 00030044 OUT 12050045 MCR0046 LD 12000047 OR 12030048 OUT 05000049 LD 12010050 OR 12040051 OUT 05010052 LD 12020053 OR 12050054 OUT 05020055 END0056 ENDH
KVNKA Chap 08.p65 08.3.11, 0:12 PM333
8.2 Details
3-334
8
Chapter 8 Programming Examples
0000
0001
0500
0501
0000
0001
0002
0003
0500
0000
1000 0002
1001 0003
0001
1002 0500
1000
1001
1002
Application Instructions
Application of W-UE instruction
Input sequence checkOutput relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and0003 turn ON in this sequence.Output relay 0500 turns OFF when input relay 0000 is OFF.
Timing diagram
Ladder diagram Coding
Fork lift truck IN/OUT judgement
Checks the input sequence. Output relay 0500 turns ON when input relay 0000 turnsON and then 0001 turns ON. Output relay 0501 turns ON when input relay 0001turns ON and then 0000 turns ON.
Timing diagram
Ladder diagram Coding
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 LD 1000
0003 W-UE 0002 1001
0004 LD 1001
0005 W-UE 0003 1002
0006 LD 1002
0007 OUT 0500
0000 0001
1000
1000 0500
0001 0000
1001
1001 0501
Leave warehouse
Enter warehouse
Line No. Instruction Operand
0000 LD 0000
0001 W-UE 0001 1000
0002 CON
0003 AND 1000
0004 OUT 0500
0005 LD 0001
0006 W-UE 0000 1001
0007 CON
0008 AND 1001
0009 OUT 0501
KVNKA Chap 08.p65 08.3.11, 0:12 PM334
8.2 Details
3-335
18
Chapter 8 Programming Examples
Application of STG-JMP instruction
Enabling double coil
When start SW 0000 is pressed, output relay 0500 turns ON for 1 s, then outputrelays 0500 and 0501 turn ON for 2 s, and then output relays 0500, 0501, and 0502turn ON for 3 s. The above sequence repeats.
Ladder diagram
Coding
The double coil operates normally through different STG instructions. Ifdifferent STG instructions turn ON simultaneously, the latter programmedinstruction has the priority.
Conditional branching
When input relay 0000 (start SW) turns ON, output relay 0500 turns ON. Then, asprogrammed for conditional branching, output 0501 turns ON for 1 s when 0001turns ON or 0502 turns ON for 2 s when 0002 turns ON. After either one of theprocesses is completed, the program returns to the conditional branching andrepeats the same steps.
Ladder diagram
0000
1001JMP
SET10001100
DIFU1100
1000STG
T000#00010T000
1002JMP
1001STG
T001#00020T001
1000JMP
1002STG
T002#00030T002
0500
0501
050205010500
0500
Turns ON 1000 when input relay 0000 turns ON.
Output relay 0500 turns ON for 1 s.
Output relays 0500 and 0501 turn ON for 2 s.
Output relays 0500, 0501 and 0502 turn ON for 3 s.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0016 CON0001 DIFU 1100 0017 TMR 001 #000200002 CON 0018 CON0003 AND 1100 0019 AND T0010004 SET 1000 0020 JMP 10020005 STG 1000 0021 STG 10020006 OUT 0500 0022 OUT 05000007 CON 0023 CON0008 TMR 000 #00010 0024 OUT 05010009 CON 0025 CON0010 AND T000 0026 OUT 05020011 JMP 1001 0027 CON0012 STG 1001 0028 TMR 002 #000300013 OUT 0500 0029 CON0014 CON 0030 AND T0020015 OUT 0501 0031 JMP 1000
CAUTION
0000
1001JMP
SET10001100
DIFU1100
1000STG
0001
1002JMP
0002
1000JMP
1001STG
T000#00010T000
0500
0501
1000JMP
1002STG
T001#00020T001
0502
KVNKA Chap 08.p65 08.3.11, 0:12 PM335
8.2 Details
3-336
8
Chapter 8 Programming Examples
Application of STP-STE instruction
Process progressionWhen input relay 0000 turns ON, output relay 0500 automatically turns ON for 2 s,and then 0501 turns ON for 3 s.
Ladder diagram Coding
* The double coil operates normallyacross different STP instructions.
Refer to p. 3-114.
Application of ITVL instruction
Pulse interval measurementMeasures the pulse interval of input relay 0000 and writes the measured data intoDM0100 (in units of 10 ms).• Mode No. 1 (DM0000)• MAX. setting value 51 (DM0001)• MIN. setting value 49 (DM0002)• Average number of measurements 10 (DM0003)
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0014 OUT 05010001 DIFU 1100 0015 CON0002 CON 0016 TMR 000 #000100003 AND 1100 0017 CON0004 SET 1000 0018 AND T0000005 STG 1000 0019 JMP 10000006 OUT 0500 0020 STG 10020007 MPS 0021 OUT 05020008 AND 0001 0022 CON0009 JMP 1001 0023 TMR 001 #000200010 MPP 0024 CON0011 AND 0002 0025 AND T0010012 JMP 1002 0026 JMP 10000013 STG 1001
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0000
SET1001
DIFU1000 1000
STE
T001 0501
END
ENDH
SET1002T000
1001
STE
STP
T000
1001T000
#00020
0500
RES1001T000
STP1002
RES1002T001
1002T001
#00030
Line No. Instruction Operand
0000 LD 00000001 DIFU 10000002 CON0003 AND 10000004 SET 10010005 STP 10010006 LD T0000007 RES 10010008 LDB T0000009 OUT 05000010 LD 10010011 TMR 000 #000200012 LD T0000013 SET 10020014 STE0015 STP 10020016 LD T0010017 RES 10020018 LDB T0010019 OUT 05010020 LD 10020021 TMR 001 #000300022 STE0023 END0024 ENDH
KVNKA Chap 08.p65 08.3.11, 0:12 PM336
8.2 Details
3-337
18
Chapter 8 Programming Examples
ONOFF 500ms
Measure the pulse interval
Reset input relay 0002Output relay 0500 turns ONwhen the pulse interval is not within the range from 490 to 510 mm.
Ladder diagram
Coding
2008
0000
0001
0002
DM0000PLS
ITVL
PAUSE
RES1000
1000 0500
STADM0000
SET
LDA#00001
2008STA
DM0001LDA
#00051
2008STA
DM0002LDA
#00049
2008STA
DM0003LDA
#00010
1002RES0500
STADM0100
1001
LDADM0007
Sets mode 1 in DM0000.
Sets MAX. setting value (510 ms) in DM0001.
Sets MIN. setting value (490 ms) in DM0002.
Sets the average number of measurements (10) inDM0003.
Measures the pulse interval when input relay 0000turns ON.
Pauses measurement when input relay 0001 turnsON.
Resets measurement when input relay 0002 turnsON.
Writes the average measurement value intoDM0100 and resets 0500 after every time ameasurement is completed.
Turns On output relay 0500 when the pulseinterval is not within the range from 490 to 510mm.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0015 STA DM00030001 LDA #00001 0016 LD 00000002 CON 0017 LD 00010003 STA DM0000 0018 LD 00020004 LD 2008 0019 ITVL DM0000 10000005 LDA #00051 0020 LD 10020006 CON 0021 LDA DM00070007 STA DM0001 0022 CON0008 LD 2008 0023 STA DM01000009 LDA #00049 0024 CON0010 CON 0025 RES 05000011 STA DM0002 0026 LD 10000012 LD 2008 0027 OR 10010013 LDA #00010 0028 SET 05000014 CON
Fetching data from the KV-AN6 (For KV-300 PLC only)
Fetches data from Ch 1 of the KV-AN6. Writes this data value into DM0100.• Mode No. 9000 (DM0000) from Ch 1 of KV-AN6• MAX. setting value 2000 (DM0001)• MIN. setting value 00900 (DM0002)• Average number of measurements 10 (DM0003)Reset input relay 0002
KVNKA Chap 08.p65 08.3.11, 0:12 PM337
8.2 Details
3-338
8
Chapter 8 Programming Examples
2008
2003
0001
0002
DM0000PLS
ITVL
PAUSE
RES1000
STADM0000
LDA#09000
2008STA
DM0001LDA
#02000
2008STA
DM0002LDA
#00900
2008STA
DM0003LDA
#00010
1003STA
DM0100LDA
DM0007
2008STA
DM0002LDA
#03000
0001
2002CMP
DM0000LDA
CTH1
STADM0001
LDA#02000
STADM0000
LDA#01000
SET2813
CTH100005
2009 0500
CMPDM0001 2009 0501
CMPDM0002 2009 0502
Ladder diagram Coding
Refer to p. 3-117.
Applications of High-speed counter
High-speed counter multi-level settingSets the high speed counter comparator value of the input relay 0005 as below:• #0100 DM0000• #0200 DM0001• #0300 DM0002
When a comparator value is greater than the setting value:• DM0000 0500 turns ON.• DM0001 0501 turns ON.• DM0002 0502 turns ON.
Ladder diagram Coding
Line No. Instruction Operand0000 LD 20080001 LDA #090000002 CON0003 STA DM00000004 LD 20080005 LDA #020000006 CON0007 STA DM00010008 LD 20080009 LDA #009000010 CON0011 STA DM00020012 LD 20080013 LDA #000100014 CON0015 STA DM00030016 LD 20030017 LD 00010018 LD 00020019 ITVL DM0000 10000020 LD 10030021 LDA DM00070022 CON0023 STA DM0100
Line No. Instruction Operand0000 LD 20080001 SET 28130002 CON0003 LDA #010000004 CON0005 STA DM00000006 CON0007 LDA #020000008 CON0009 STA DM00010010 CON0011 LDA #030000012 CON0013 STA DM00020014 LDB 00010015 CTH1 00050016 LD 20020017 LDA CTH10018 MPS0019 CMP DM00000020 ANB 20090021 OUT 05000022 MRD0023 CMP DM00010024 ANB 20090025 OUT 05010026 MPP0027 CMP DM00020028 ANB 20090029 OUT 0502
KVNKA Chap 08.p65 08.3.11, 0:12 PM338
8.2 Details
3-339
18
Chapter 8 Programming Examples
2008
2002 CTH10005
RESCTH1
SET2203
SET2813
#60000CTC2
CTC2RES0502
RESCTC2T0010502 #00030
T001
High-speed counter current value clearCounts pulses at input relay 0005. When the count value reaches setting value60000, clears the current value of high speed counter CTH1 and turns ON outputrelay 0502 for 3 s.
Ladder diagram Coding
Input of phase differential signal
Inputs phase differential signals to input relays 0004 and 0006 and counts pulses atCTH0.Writes the count value into DM0000.When high speed counter CTH0 reaches 60000, clears the current value of CTH0,sets output relay 0500, and stops fetching count value to CTH0.Sets 0008 as external reset.
Ladder diagram
Note: Initial settings for special utility relays
• Sets input time constant of input relays 0000 to 0009 to 10 µs when 2813 turnsON.
• Clears the current value of CTH0 when 2103 turns ON and CTC0 is ON.• Sets CTH0 in the X 2 mode when 2113 is ON and 2114 is OFF.• Enables external reset (input relay 0008) when 2115 turns ON.
Line No. Instruction Operand0000 LD 20080001 SET 28130002 CON0003 SET 22030004 CON0005 RES CTH10006 LD 20020007 CTH1 00050008 CTC2 #600000009 LD CTC20010 OUT 05020011 CON0012 TMR 001 #000300013 CON0015 AND T0010016 RES CTC20017 CON0018 RES 0502
2008RES
CTH0SET2115
0500RES2114
SET2113
SET2103
SET2813
EI
CTH000004#60000CTC02002
STADM0000
LDACTH0
END
INTCTC0
2002SET0500
RETI
ENDH
Initial settings*Note
KVNKA Chap 08.p65 08.3.11, 0:12 PM339
8.2 Details
3-340
8
Chapter 8 Programming Examples
0000STA
TM03LDA
#00030STA
TM02LDA
#00010
END
00CALL
2002
NEXT
RET
ENDH
SBN00
2002STA
TM05SUB
TM02STA
TM04ADD
#00001LDA
TM03
FORTM05
2002STA
#TM04LDA
#TM03DECTM04
DECTM03
STA#TM02
LDA#00000
1000DIFU
1000 Shifts data from DM0010 to DM0030.
Designates the shift start DM No. (DM0010).
Designates the shift end DM No. (DM0030).
Uses the indirect addressing function to designate DM Nos.
Clears the start DM to #0000 after the data is shifted.
The program lines which execute the data shift are groped as the subroutine.
Shift level
Synchoronous signal
External reset 0008 is predetermined on hardware even if you do not specify inthe program. However, you have to set external reset enable relay 2115 to ON.
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0014 LDB 05000001 EI 0015 CTH 1 00040002 CON 0016 CTC 0 #600000003 SET 2813 0017 LD 20020004 CON 0018 LDA CTH00005 SET 2103 0019 CON0006 CON 0020 STA DM00000007 SET 2113 0021 END0008 CON 0022 INT CTC00009 RES 2114 0023 LD 20020010 CON 0024 SET 05000011 SET 2115 0025 RETI0012 CON 0026 ENDH0013 RES CTH0
Application of Subroutine CALL
DM shift
Shifts the data from current DM to the next DM at UP edge of the synchronoussignal (timing).As the number of DMs to be shifted increases, the required scan time becomeslonger.
Ladder diagram
CAUTION
KVNKA Chap 08.p65 08.3.11, 0:12 PM340
8.2 Details
3-341
18
Chapter 8 Programming Examples
Coding
Refer to p. 3-122.
Application of FOR-NEXT
Transfer of a block of DM data
Uses the indirect addressing function to transfer a block of data from DM0000 -DM0099 to DM0100 - DM0199.
Ladder diagram Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0021 CON0001 DIFU 1000 0022 SUB TM020002 CON 0023 CON0003 AND 1000 0024 STA TM050004 LDA #00010 0025 FOR TM050005 CON 0026 LD 20020006 STA TM02 0027 DEC TM030007 CON 0028 CON0008 LDA #00030 0029 DEC TM040009 CON 0030 CON0010 STA TM03 0031 LDA #TM030011 CON 0032 CON0012 CALL 00 0033 STA #TM040013 END 0034 NEXT0014 SBN 00 0035 LD 20020015 LD 2002 0036 LDA #000000016 LDA TM03 0037 CON0017 CON 0038 STA #TM020018 ADD #00001 0039 RET0019 CON 0040 ENDH0020 STA TM04
Refer to p. 3-125.
FOR
NEXT
RET
SBN01
2002STA
TMO3LDA
#00100STA
TMO2LDA
#0000
2002INC
TM03INC
TM02STA
#TM03LDA
#TM02
#00100
1st DM No. of transfer source
1st DM No. of transfer destination
Number of DMs to be Transferred.
Line No. Instruction Operand0000 SBN 010010 LD 20020001 LD 20020011 LDA #TM020002 LDA #00000012 CON0003 CON0013 STA #TM030004 STA TM020014 CON0005 CON0015 INC TM020006 LDA #001000016 CON0007 CON0017 INC TM030008 STA TM030018 NEXT0009 FOR #001000019 RET
DM0000
DM0099
DM0100
DM0199
Transfer a block of data
Data memory
KVNKA Chap 08.p65 08.3.11, 0:12 PM341
8.2 Details
3-342
8
Chapter 8 Programming Examples
2008SET2814
2815
END
ENDH
HKEY0000
STADM0000
ORATM06
SLA#04
LDADM0000
DW#00000
2815DMXSTA
TM05CMPTM05
ANDA$03FF2010
0500
LDA2900
KEY IN
Input value (BCD)
2010STA
TM06
2002
2815STA
TM05CMPTM05
ANDA$03FF2010
LDA2900 2010
2915
DM0000
Input value (BCD)
24 VDC COM 000 001 002 003
COM 500 501 502 503KV
0 1 2 3
4 5 6 7
8 9 A B
C D E F
Application of HKEY instruction
Fetching 16-key input
Writes the following 16-key input value into DM0000 in 4-digit BCD.Pressing the keys in the lower line clear the input numerical value.Wires the 16-key input terminals using 4 outputs and 4 inputs as shown below.
Ladder diagram
Coding
Refer to p. 3-131.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0021 AND 20100001 SET 2814 0022 ANDA $03FF0002 LD 2002 0023 CON0003 HKEY 0000 0500 0024 CMP TM050004 LD 2815 0025 CON0005 LDA 2900 0026 ANB 20100006 CON 0027 STA TM050007 ANB 2010 0028 CON0008 ANDA $03FF 0029 LDA DM00000009 CON 0030 CON0010 CMP TM05 0031 SLA #040011 CON 0032 CON0012 ANB 2010 0033 ORA TM060013 STA TM05 0034 CON0014 CON 0035 STA DM00000015 DMX 0036 LD 28150016 CON 0037 AND 29150017 STA TM06 0038 DW #0000 DM00000018 LD 2815 0039 END0019 LDA 2900 0040 ENDH0020 CON
KVNKA Chap 08.p65 08.3.11, 0:12 PM342
8.2 Details
3-343
18
Chapter 8 Programming Examples
2002
0000
0500
#00010T000
0500 T000
STAT000
TMIN0
2002
0000
0500
#00010T000
0500 T000
STAT002
STAT001
STAT000
TMIN0
0001
0501
#00010T001
0501 T001
0002
0502
#00010T002
0502 T002
Arithmetic Instructions
Applications of TMIN (Analog timer) instruction
Changing timer setting valueUses analog timer (TMIN0) to change the timer setting value (0 to 24.9 s).
Ladder diagram Coding
Changing setting values of multiple timersUses analog timer (TMIN0) to change setting values of multiple timers (0 to 24.9 s).
Ladder diagram Coding
* In the above example, T000, T001,and T002 have the same setting value.
Refer to p. 3-138.
Applications of LDA/STA instruction
First-in first-out (FIFO)DM data flow
Line No. Instruction Operand0000 LD 20020001 TMIN 00002 CON0003 STA T0000004 LD 00000005 OR 05000006 TMR 000 #000100007 ANB T0000008 OUT 0500
Line No. Instruction Operand0000 LD 20020001 TMIN 00002 CON0003 STA T0000004 CON0005 STA T0010006 CON0007 STA T0020008 LD 00000010 TMR 000 #000100011 ANB T0000012 OUT 05000013 LD 00010014 OR 05010015 TMR 001 #000100016 ANB T0010017 OUT 05010018 LD 00020019 OR 05020020 TMR 002 #000100009 OR 05000021 ANB T0020022 OUT 0502
D M 0 0 0 2
D M 0 0 0 0
D M 0 0 0 1
D M 0 0 0 3
D M 0 0 0 4
Data shift
OK/NG judgement
Unloading timing
KVNKA Chap 08.p65 08.3.11, 0:12 PM343
8.2 Details
3-344
8
Chapter 8 Programming Examples
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0000 0035 STA DM00030001 DIFU 1000 0036 CON0002 CON 0037 LDA $00000003 AND 1000 0038 CON0004 MPS 0039 STA DM00020005 AND 0001 0040 LD 20020006 LDA $1111 0041 LDA DM00020007 CON 0042 CON0008 STA DM0000 0043 CMP $00000009 MPP 0044 CON0010 ANB 0001 0045 AND 20100011 LDA $5555 0046 LDA DM00010012 CON 0047 CON0013 STA DM0000 0048 STA DM00020014 LD 2002 0049 CON0015 LDA DM0004 0050 LDA $00000016 CON 0051 CON0017 CMP $0000 0052 STA DM00010018 CON 0053 LD 20020019 AND 2010 0054 LDA DM00010020 LDA DM0003 0055 CON0021 CON 0056 CMP $00000022 STA DM0004 0057 CON0023 CON 0058 AND 20100024 LDA $0000 0059 LDA DM00000025 CON 0060 CON0026 STA DM0003 0061 STA DM00010027 LD 2002 0062 CON0028 LDA DM0003 0063 LDA $00000029 CON 0064 CON0030 CMP $0000 0065 STA DM00000031 CON 0066 LD 00020032 AND 2010 0067 @LDA $00000033 LDA DM0002 0068 CON0034 CON 0069 @STA DM0004
The data once fetched is written into DM0004, DM0003, ..., DM0000 in this order. Atthe unloading timing, unload the data from DM0004 and shifts the data value to thenext DM.
The ON/NG judgement and unloading timings can be used in asynchronous pro-grams.
Ladder diagram
Coding
2002LDA$0000
STADM0004
LDADM0003
CMP$0000 2010
LDADM0004
STADM0003
0000LDA
$11111000 0001STA
DM00001000DIFU
Transfers $1111 to DM0000.
LDA$55550001
STADM0000
Transfers $5555 to DM0000.
OK/NG judgementOK/NG judgement timing
2002LDA$0000
STADM0003
LDADM0002
CMP$0000 2010
LDADM0003
STADM0002
2002LDA$0000
STADM0002
LDADM0001
CMP$0000 2010
LDADM0002
STADM0001
2002LDA$0000
STADM0001
LDADM0000
CMP$0000 2010
LDADM0001
STADM0000
0002LDA
$0000STA
DM0004
Unloading timing Transfers $0000 to DM at unloading timing.
Compares the DM value to $0000. If it is equal to $0000, transfers the value of the previous DM No. and then writes $0000 into the current DM No.
KVNKA Chap 08.p65 08.3.11, 0:12 PM344
8.2 Details
3-345
18
Chapter 8 Programming Examples
2002
0005 #9999C000
STAC000
LDADM0000
0001
Changing the counter setting valueSets the setting value of counter C000 to DM0000. Reset input is 0005.
Ladder diagram Coding
Changing the timer setting value
Sets the setting value of timer T000 to DM0000. Reset input is 0005.
Ladder diagram Coding
Refer to p. 3-140.
Application of CMP (compare) instruction
When comparing values with no specific rangeTurns ON 0500 when the DM0000 value is smaller than the CMP value.Turns ON 0501 when the DM0000 value is equal to the CMP value.Turns ON 0502 when the DM0000 value is greater than the CMP value.
Ladder diagram Coding
Setting the upper/lower limit
Turns ON 0500 when the C001 value is 1000 or less.Turns ON 0501 when the C001 value is 2000 or more.
Ladder diagram
Line No. Instruction Operand0000 LD 2002
0001 LDA DM0000
0002 CON
0003 STA C000
0004 LDB 0005
0005 C 000 #9999 0001
2002
0005 #9999T000
STAT000
LDADM0000 Line No. Instruction Operand
0000 LD 2002
0001 LDA DM0000
0002 CON
0003 STA T000
0004 LDB 0005
0005 T 0000 #9999
2002
05022011
CMP
#01000
LDA
DM000 05002009
DM0000 <#01000
DM0000 =#01000
DM0000 >#01000
05012010
Line No. Instruction Operand0000 LD 2002
0001 LDA DM0000
0002 CON
0003 CMP #01000
0004 MPS
0005 AND 2009
0006 OUT 0500
0007 MRD
0008 AND 2010
0009 OUT 0501
0010 MPP
0011 AND 2011
0012 OUT 0502
2002
0001 #09999C001
CMP
#02000
LDA
C001 05012009
C001≤#1000
C001≥#02000
2002
CMP
#01000
LDA
C001 050020110000
KVNKA Chap 08.p65 08.3.11, 0:12 PM345
8.2 Details
3-346
8
Chapter 8 Programming Examples
2002
05012009
CMP
DM0000
LDA
C000 05002009
2002DIV
#00010MUL
#00004ADD
#00001TMIN
0
0001 #09999C00000000
STADM0000
Sets the TMIN setting range from 0 to 100.
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0001 0008 OUT 05000001 C 001 #09999 0000 0009 LD 20020002 LD 2002 0010 LDA C0010003 LDA C001 0011 CON0004 CON 0012 CMP #020000005 CMP #01000 0013 CON0006 CON 0014 ANB 20090007 ANB 2011 0015 OUT 0501
Changing the CMP setting value
Compares the current value of C000 to the CMP setting value. Sets the CMP settingvalue to analog timer TMIN0.The following example changes the setting value within the range from 0 to 100.Turns ON 0500 when the C000 value is smaller than the CMP setting value.Turns ON 0501 when the C000 value is greater than the CMP setting value.
Ladder diagram
Coding
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 0001Counter input relay 0000
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0011 C 000 #09999 00000001 TMIN 0 0012 LD 020020002 CON 0013 LDA C0000003 ADD #00001 0014 CON0004 CON 0015 CMP DM00000005 MUL #00004 0016 MPS0006 CON 0017 AND 20090007 DIV #00010 0018 OUT 05000008 CON 0019 MPP0009 STA DM0000 0020 ANB 20090010 LDB 0001 0021 OUT 0501
KVNKA Chap 08.p65 08.3.11, 0:12 PM346
8.2 Details
3-347
18
Chapter 8 Programming Examples
0001 #09999C000
2002 0500#00999C000 ≤ 00999LDA
C000CMP
0501
0502
2011
#01999CMP
2011 0500
#02999CMP
2011 0500 0501
0000
00999 < C000 ≤ 01999
01999 < C000 ≤ 02999
Ladder diagram
Coding
Refer to p. 3-146.
Application of ADD instruction
Adding BCD and BIN values
Adds a 4-digit BCD input value (7000 to 7015) to the counter current value andwrites the sum into DM0100.
Ladder diagram
Coding
2002
0001 #09999C001
ADD
DM0000
LDA
C001
2002
TBINLDA
7000
0000
STA
DM0100
STA
DM0000Converts BCD input value to BIN.
Adds converted BIN value to the current value ofC001 and writes the sum into DM0100.
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0001 0012 CON0001 C 000 #09999 0000 0013 ANB 20110002 LD 2002 0014 ANB 05000003 LDA C000 0015 OUT 05010004 CON 0016 MPP0005 MPS 0017 CMP #029990006 CMP #00999 0018 CON0007 CON 0019 ANB 20110008 ANB 2011 0020 ANB 05000009 OUT 0500 0021 ANB 05010010 MRD 0022 OUT 05020011 CMP #01999
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0007 LDA C0010001 LDA 7000 0008 CON0002 CON 0009 ADD DM00000003 TBIN 0010 CON0004 CON 0011 STA DM01000005 STA DM0000 0012 LDB 00010006 LD 2002 0013 C 001 #09999 0000
KVNKA Chap 08.p65 08.3.11, 0:12 PM347
8.2 Details
3-348
8
Chapter 8 Programming Examples
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0012 LDA DM00010001 LDA DM0000 0013 CON0002 CON 0014 SUB DM00000003 SUB DM0001 0015 CON0004 MPS 0016 CMP #000050005 ANB 2009 0017 CON0006 CMP #00005 0018 ANB 20090007 CON 0019 OUT 10010008 ANB 2009 0020 LD 10000009 OUT 1000 0021 OR 10010010 MPP 0022 OUT 05000011 AND 2009
0000LDAC001
STADM0001#09999
C0010001
0000LDAC002
STADM0002#09999
C0020002
0000LDAC003
STADM0003#09999
C0030003
2002ADD
DM0002LDA
DM0001STA
DM0100ADD
DM0003
2002CMP
#00052009LDA
DM0000SUB
DM0001 10002009
CMP#0005
SUBDM0000
LDADM00012009 10012009
1000 0500
1001
Total countWrites total count of counters C001 to C003 into DM0100. The total count must bewithin 65535.
Ladder diagram
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0000 0013 C 003 #09999 00030001 C 001 #09999 0001 0014 CON0002 CON 0015 LDA C0030003 LDA C001 0016 CON0004 CON 0017 STA DM00030005 STA DM0001 0018 LD 20020006 LDB 0000 0019 LDA DM00010007 C 002 #09999 0002 0020 CON0008 CON 0021 ADD DM00020009 LDA C002 0022 CON0010 CON 0023 ADD DM00030011 STA DM0002 0024 CON0012 LDB 0000 0025 STA DM0100
Writes C001 current value into DM0001.
Writes C002 current value into DM0002.
Writes C003 current value into DM0003.
Writes total count (DM0001 + CM0002 + DM0003) intoDM100.
Refer to p. 3-150.
Application of SUB instruction
Comparison of absolute values
Compares the DM0000 value to the DM0001 value and turns ON 0500 when thedifference of the two absolute values is greater than 5.
Ladder diagram
Coding
Refer to p. 3-150.
KVNKA Chap 08.p65 08.3.11, 0:12 PM348
8.2 Details
3-349
18
Chapter 8 Programming Examples
2002LDATM00
STADM0100
MULDM0000
LDAC001
0001 #09999C0010000
STADM0101
#09999
00001C001
0000STA
DM0001LDA
C001
2002
DM0001 DM0002 DM0003
÷3 → Output to 07500 to 07515 in 4-digit BCD.
2002
#09999C002
0000STA
DM0002LDA
C002
#09999C003
0000STA
DM0003LDA
C003
ADDLDADM0001
ADDDM0003
TBCDDIV#00003
STA07500
00002
00003DM0002
Writes the C001 current value into DM0001.
Writes the C002 current value into DM0002.
Writes the C003 current value into DM0003.
Application of MUL instruction
Multiplying the counter current value by DM value
Multiplies the counter current value by the DM0000 value and writes the high-order16 bits of the product into DM0101 and low-order 16 bits of the product intoDM0100.
Ladder diagram Coding
Refer to p. 3-150.
Application of DIV instruction
Total count average
Outputs the average of 3 counter values in 4-digit BCD.(C001 + C002 + C003) ÷ 3 → BCD output valueThe BCD value is output to 7500 to 7515.
Ladder diagram
Coding
Line No. Instruction Operand0000 LDB 00010001 C 001 #09999 00000002 LD 20020003 LDA C0010005 MUL DM00000004 CON0006 CON0007 STA DM01000008 CON0009 LDA TM000010 CON0011 STA DM0101
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0000 0015 LDA C0030001 C 001 #09999 0001 0016 CON0002 CON 0017 STA DM00030003 LDA C001 0018 LD 20020004 CON 0019 LDA DM00010005 STA DM0001 0020 CON0006 LDB 0000 0021 ADD DM00020007 C 002 #09999 0002 0022 CON0008 CON 0023 ADD DM00030009 LDA C002 0024 LD 20020010 CON 0025 DIV #000030011 STA DM0002 0026 CON0012 LDB 0000 0027 TBCD0013 C 003 #09999 0003 0028 CON0014 CON 0029 STA 7500
Refer to p. 3-150.
KVNKA Chap 08.p65 08.3.11, 0:12 PM349
8.2 Details
3-350
8
Chapter 8 Programming Examples
Refer to p. 3-159.
Line No. Instruction Operand Line No. Instruction Operand0000 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
Application of ANDA instruction
BCD (1-digit) input
Sets a 1-digit BCD value, which is input to 0000 to 0003, in C000.
Ladder diagram
Coding
Fetches input data separatelySets the low-order 2 digits of the BCD digital switch (7000 to 7007) to counter C000and the high-order 2 digits to timer T001.
Ladder diagram
Coding
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0005 TBIN0001 LDA 0000 0006 CON0002 CON 0007 STA C0000003 ANDA $000F 0008 LDB 70000004 LD 2002 0009 C 000 #09999 7001
2002ANDA$000F
LDA0000
2002STAC000
TBIN
#09999C000
7000
7001
Fetches data of 0000 to 0015 and retains data of 0000to 0003 only.
Converts data to BIN and writes it into C000.
Sets C000.
2002
2002LDA
#09999C000
0001
0000
7000ANDA$FF00
TBIN#08
SRA STAT001
LDA7000
ANDA$00FF
STAC000
TBIN
#09999T001
0001
Converts data of 7000 to 7007 to BIN andwrites it into C000.
Shifts data to right by 8 bits, converts it toBIN, and writes it into T001.
Sets C000.
Sets T001.
KVNKA Chap 08.p65 08.3.11, 0:12 PM350
8.2 Details
3-351
18
Chapter 8 Programming Examples
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 datato output relays 7500 to 7507.However, retain ON/OFF of 7508 to 7515 which are loaded.
Ladder diagram
Coding
Separate input of 2-digit BCD
Fetches only 2 digits of the BCD digital switch (7000 to 7003 for the 1st digit, 8000 to8003 for the 2nd digit) and sets it as the counter value.
Ladder diagram
Coding
Refer to p. 3-161.
#00099
0001C000
0000
2002
2002STA
DM0000ANDA$FF00
2002ANDA$00FF
TBCD
STAORADM0000 7500
LDA7500
LDAC000
Sets C000.
Writes data of 7008 to 7015 into DM0000.
ORs the data in the internal register and theDM0000 data and sends the ORed data to 7500to 7515.
Converts the current value of C000 to BCD andretains the low-order 2 digits of BCD in theinternal register.
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0000 0009 LDA C0000001 C 000 #00099 0001 0010 CON0002 LD 2002 0011 TBCD0003 LDA 7500 0012 CON0004 CON 0013 ANDA $00FF0005 ANDA $FF00 0014 LD 20020006 CON 0015 ORA DM00000007 STA DM0000 0016 CON0008 LD 2002 0017 STA 7500
#00099
0001C001
0000
2002
2002STA
DM0000ANDA$000F
2002ANDA$000F
LDA7000
LDA8000
SLA#04
ORADM0000
STAC001
TBIN
Line No. Instruction Operand Line No. Instruction Operand0000 LDB 0000 0010 CON0001 C 001 #00099 0001 0011 ANDA $000F0002 LD 2002 0012 LD 20020003 LDA 7000 0013 SLA #040004 CON 0014 CON0005 ANDA $000F 0015 ORA DM00000006 CON 0016 CON0007 STA DM0000 0017 TBIN0008 LD 2002 0018 CON0009 LDA 8000 0019 STA C001
KVNKA Chap 08.p65 08.3.11, 0:12 PM351
8.2 Details
3-352
8
Chapter 8 Programming Examples
1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1D15D14D13D12D11D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1
0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
ANDA
EORA
$BBBB
$00FF
$00BB
$00AA
$0011
7000 to 7015
Operand
Internal register
DM0000
Internal register → 2010 is OFF. When the value of internal register is 0000, 2010 turns ON.
Judges match between the operand and the data of 7000 to 7015.
#00099
0000C001
0001
2002
2002ANDA$F000
2002STA
ANDALDA08000
DM0000
LDA7000
SRA#12
2002
2002ORA
STATBINC001
SLA#04
$000F
DM0000
Sets C001.
Sends the data of 7012 to 7015 to internalregister.
Shifts the value of internal register to right by12 bits and writes it into DM0000.
Sends the data of 8000 to 8003 to internalregister.
Shifts the data of internal register to left by 4bits, ORs the internal register data and thedata of DM0000, and sends the ORed data tointernal register.
Converts the data of internal register to BINdata and writes it into C001.
2008
2002LDA7000
ANDA$00FF DM0000
EORA
LDA$00AA
STADM0000
2010 0500
Application of EORA instruction
Judgement of matching data
Turns ON 0500 (“OK” output) when the ON/OFF statuses of input relays 7000 to7007 match the DM0000 setting value.
Ladder diagram Coding
For easy comprehension, the following data is set temporarily.
When 2010 is ON, the two values match.When 2010 is OFF, the two values do not match. Refer to p. 3-164.
Application of SRA/SLA instructions
Separate input of BCDFetches only 2 digits of the BCD digital switch (7012 to 7015 for the 1st digit, 8000 to8003 for the 2nd digit) and sets it as the counter value.
Ladder diagram
Line No. Instruction Operand0000 LD 20080001 LDA $00AA0002 CON0003 STA DM00000004 LD 20020005 LDA 70000006 CON0007 ANDA $00FF0008 CON0009 EORA DM00000010 CON0011 AND 20100012 OUT 0500
KVNKA Chap 08.p65 08.3.11, 0:12 PM352
8.2 Details
3-353
18
Chapter 8 Programming Examples
Coding
Refer to p. 3-166.
Application of RRA/RLA instructions
Error input count
Writes the number of error detection sensors, which are connected to input relays(7000 to 7015) and turn ON, into DM0000.
Ladder diagram
Coding
Refer to p. 3-169.
Applications of INC/DEC instructions
Total countWrites the total count of 4 lines (0000 to 0003) into DM0000.Reset input relay is 0005.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 0001 0011 LDA 80000001 C 001 #00099 0000 0012 CON0002 LD 2002 0013 ANDA $000F0003 LDA 7000 0014 LD 20020004 CON 0015 SLA #040005 ANDA $F000 0016 CON0006 LD 2002 0017 ORA DM00000007 SRA #12 0018 LD 20020008 CON 0019 TBIN0009 STA DM0000 0020 CON0010 LD 2002 0021 STA C001
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0009 LD 20020001 LDA 7000 0010 LDA TM100002 FOR #00016 0011 CON0003 LD 02002 0012 STA DM00000004 RRA #01 0013 CON0005 CON 0014 LDA #000000006 AND 2009 0015 CON0007 INC TM10 0016 STA TM100008 NEXT
Writes the TM10 data into DM0000, and then writes#00000 to TM10.
2002
RRA#01
INCTM10
LDA7000
#00016
2002
LDATM10
LDADM0000
STA STATM102002
2009
#00000
NEXT
FOR
Writes the data of 7000 to7015 into internal register.
Executes FOR-NEXT instruction for 16 times.
Shifts the data including carry (2009) to right,and increments TM10 by 1 when 2009 is ON.
KVNKA Chap 08.p65 08.3.11, 0:12 PM353
8.2 Details
3-354
8
Chapter 8 Programming Examples
2008STA
DM0000LDA
#00000
0000INC
DM0000
0005DW
#00000
0001DEC
DM0000
DM0000
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UP edgeof input relay 0000.
Decrements DM0000 by 1 at UP edgeof input relay 0001.
Clears DM0000 to #00000 when 0005turns ON.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0005 @INC DM00000001 LDA #00000 0006 LD 00010002 CON 0007 @DEC DM00000003 STA DM0000 0008 LD 00050004 LD 0000 0009 DW #00000 DM0000
Ladder diagram
Coding
UP/DOWN countPerforms 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
Coding
Refer to p. 3-172.
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2008 0007 @INC DM00000001 LDA #00000 0008 LD 00020002 CON 0009 @INC DM00000003 STA DM0000 0010 LD 00030004 LD 0000 0011 @INC DM00000005 @INC DM0000 0012 LD 00050006 LD 0001 0013 DW #00000 DM0000
2008STA
DM0000LDA
#00000
0000INC
DM0000
0003INC
DM0000
0005DW
#00000
0001INC
DM0000
0002INC
DM0000
DM0000
Sets #00000 to DM0000 at startup.
Increments DM0000 by 1 at UPedge of input relay 0000.
Increments DM0000 by 1 at UPedge of input relay 0001.
Increments DM0000 by 1 at UPedge of input relay 0002.
Increments DM0000 by 1 at UPedge of input relay 0003.
Clears DM0000 to #00000 when0005 turns ON.
KVNKA Chap 08.p65 08.3.11, 0:12 PM354
8.2 Details
3-355
18
Chapter 8 Programming Examples
a
f b
e c
g
d
a. 7500
b. 7501
c. 7502
d. 7503
e. 7504
f. 7505
g. 7506
Application of MPX instruction
Display of 7-segment LED
Displays the current value of counter C000 to the 7-segment LED.Outputs from 7500 to 7571.Connection of 7 segmentsConnect each of 7 segments to output relays as shown below:
Ladder diagram Coding
1000
1004
1005
1006
STA7500
LDA$003F
1001STA7500
LDA$0006
1002STA7500
LDA$005B
1003STA7500
LDA$004F
1007STA7500
LDA$0007
C000 #00009C000 STA
1000MPX#0
LDAC000
0000
Converts the counter value to 16-bit data using the MPX instruction.Auto reset counter
STA7500
LDA$0066
STA7500
LDA$006D
STA7500
LDA$007D
Sends internal register data to output relays starting from 7500.
1008STA7500
LDA$007F
1009STA7500
LDA$006F
0
1
2
3
4
5
6
7
8
9
7-segment display
Line No. Instruction Operand0000 LDB C0000024 LD 10040001 C 000 #00009 00000025 LDA $00660002 CON0026 CON0003 LDA C0000027 STA 75000004 CON0028 LD 10050005 MPX #00029 LDA $006D0006 CON0030 CON0007 STA 10000031 STA 75000008 LD 10000032 LD 10060009 LDA $003F0033 LDA $007D0010 CON0034 CON0011 STA 75000035 STA 75000012 LD 10010036 LD 10070013 LDA $00060037 LDA $00070014 CON0038 CON0015 STA 75000039 STA 75000016 LD 10020040 LD 10080017 LDA $005B0041 LDA $007F0018 CON0042 CON0019 STA 75000043 STA 75000020 LD 10030044 LD 10090021 LDA $004F0045 LDA $006F0022 CON0046 CON0023 STA 75000047 STA 7500
Refer to p. 3-176.
KVNKA Chap 08.p65 08.3.11, 0:12 PM355
8.2 Details
3-356
8
Chapter 8 Programming Examples
2002DMXLDA
07000
2002ANDATBCD$00FF
STA8000
STA7500
TBCDLDA
0001 #09999C001
2002 C001
0000
Converts the most significant bit of 16-bit data(7000 to 7015) to 4-bit BIN data and sends it tointernal register.Converts internal register data to BCD data,executes ANDA instruction, and outputs the datato 8000 to 8015.
Line No. Instruction Operand Line No. Instruction Operand
0000 LDB 0001 0004 CON
0001 C 001 #09999 0000 0005 TBCD
0002 LD 2002 0006 CON
0003 LDA C001 0007 STA 7500
DM0000 x DM0001 = TM00 Internal register
DM00 Internal register ÷ #10000 = TM00 Internal register --- TM01
(High-order 4 digits) (Low-order 4 digits)
(High-order 4 digits) (Low-order 4 digits) (Remainder)
8500 to 8515 7500 to 7515
(Display)
(High-order 4 digits) (Low-order 4 digits)
Application of DMX instruction
Output of error input No. in BCD
Outputs the error sensor No. from input relay 7000 to 7015 to output relays 8500 to8507 in 2-digit BCD.
Ladder diagram
Coding
Refer to p. 3-176.
Applications of TBCD instruction
Output of 4-digit BCD data
Outputs the current value of counter C001 to 7500 to 7515 in 4-digit BCD data.
Ladder diagram
Coding
Output of 8-digit BCD dataOutputs the calculated product of DM0000 x DM0001 (0 to 99999999) in BCD of 8digits at maximum as below:
High-order 4-digit BCD data To 8500 to 8515Low-order 4-digit BCD data To 7500 to 7515
Line No. Instruction Operand Line No. Instruction Operand0000 LD 2002 0005 TBCD0001 LDA 7000 0006 CON0002 CON 0007 ANDA $00FF0003 DMX 0008 CON0004 LD 2002 0009 STA 8000
KVNKA Chap 08.p65 08.3.11, 0:12 PM356
8.2 Details
3-357
18
Chapter 8 Programming Examples
MULLDA2002
LDASTADIV TBCD STADM0000 DM0001 #10000 DM0101 TM01 7500
LDA TBCD STADM0101 8500
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
2002TBINLDA
7000STAC001
#09999
0000C001
0001
Converts data of 7000 to 7015 to BINdata and writes it into C001.
Sets C001.
Line No. Instruction Operand Line No. Instruction Operand
0000 LD 2002 0004 CON
0001 LDA 7000 0005 STA C001
0002 CON 0006 LDB 0001
0003 TBIN 0007 C 001 #09999 0000
Ladder diagram
Coding
Refer to p. 3-180.
Application of TBIN instruction
Output of 4-digit BCD data
Sets 4 digits of the BCD digital switch (7000 to 7015) as the counter C001 value.
Ladder diagram
Coding
Refer to p. 3-183.
KVNKA Chap 08.p65 08.3.11, 0:12 PM357
8.2 Details
3-358
8
Chapter 8 Programming Examples
KVNKA Chap 08.p65 08.3.11, 0:12 PM358
Index
KVNKA Index_Pro.p65 08.3.11, 0:14 PM359
Inde
x
Index3-360
Index — For Visual KV User’s OnlyThe following is the index with some descriptions for your reference.
Index — For Visual KV User’s Only
esopruP eltiT egaP
A
nieulavecivedgnignahc,wodniWsseccA edomeciveD 78-1
nisedomgnignahc,wodniWsseccA kcolyekgnitteser/gnittesdnasedomgnitceleS 28-1
nisnoitceridgniyalpsid,wodniWsseccA segassemresU 79-1
nisrorregniyalpsid,wodniWsseccA sutatsrorrednasegassemrorrE 79-1
niyalpsidrorre,wodniWsseccA tsiLrorrE 273-1
nideepsnoitcelesecivedgnisaercni,wodniWsseccA noitcnufobruT 38-1
fosnoitcnufsemantrap,wodniwsseccA wodniWsseccAehtfosnoitcnufdnasemantraP 28-1
dnaNURneewtebCLPVKehtgnihctiws,wodniWsseccAnisedom)pots(MARGORP
edoMmetsyS 49-1
niremmirtlatigidgnisu,wodniWsseccA edoMremmirTlatigiD 48-1
tuobagninrael,snoitcurtsninoitacilppA snoitcurtsninoitacilppA 63-3
tuobagninrael,snoitcurtsnicitemhtirA snoitcurtsnicitemhtirA 83-3
B
tuobagninrael,snoitcurtsnicisaB snoitcurtsnicisaB 43-3
C
rofmetignittes,noitcnufhctiwsmaC noitcnufhctiwsmacrofdesueciveD 332-3
saVKgnisu,hctiwsmaC noitcnufhctiwsmaC 332-3
gniriuqca,gnikramEC gnikramECehtgniriuqcanonoitcirtseR )2(
retupmoclanosrepdnaVKneewtebnoissimsnartdnammoC tsilesnopser/dnammocnoitacinummoC 013-3
gnirudsruccororrenehw,noissimsnartdnammoC tsiledocrorrE 613-3
fosnoitacificeps,tropnoitacinummoC noitacificepSsnoitacinummoC 603-3
CLPVKotmehtgnittimsnart,stnemmoctcatnoC noitcnufevastnemmoctcatnoC 72-3
gnitcetorp,stcatnoC noitcetorptcatnoC 96-1
htiwsecnereffid,seiresVKlanoitnevnoC stinularehpirepVKlanoitnevnochtiwytilibitapmoC )4(
noitpmusnoctnerruC snoitacificepslareneG 4-1
D
otdengissasnoitcnuf,yromemataD seiromemataD 91-3
foeniltuo,eslupkcolctceriD tuptuoeslupkcolctceridfoeniltuO 732-3
oitarFFO/NO1:1htiwseslupgnittuptuo,eslupkcolctceriDgnisu
1:1fooitarFFO/NO 832-3
eslupelbairavhtiwseslupgnittuptuo,eslupkcolctceriDhtdiw
htdiweslupelbairaV 832-3
rofmetignittes,eslupkcolctceriDretnuocdeeps-hgihehthtiwgnittestuptuoesluP
rotarapmoc832-3
E
fonoitarepognikcehc,tinunoisnapxE stinunoisnapxerofnoitamrofninoitcennoC 57-1
gnitcennoc,tinunoisnapxE stinunoisnapxeseireSVKlausiVgnitcennoC 17-1
otdetcennocebotrebmunmumixam,tinunoisnapxE stinuelbatcennocforebmuN 37-1
tinucisabepyt-CAhtiwhsulfthgiehstignittes,tinunoisnapxE recapstinunoisnapxE 66-1
gnilbasid,tuptuolanretxE noitcnufnoitibihorptuptuO 62-3
F
hctiwstuohtiwFFO/NOtupnignicroF noitcnufdelbasidhserfertupnI 62-3
rofmetignittes,noitcnufretnuocycneuqerF retnuocycneuqerfehthtiwdesuseciveD 132-3
foegnartnemerusaemgnisaercni,retnuocdeeps-hgiH retnuocdeeps-hgihtib-42 122-3
htiwycneuqerfgnirusaem,retnuocdeeps-hgiH noitcnufretnuocycneuqerF 132-3
gnisuseslupgnittuptuo,retnuocdeeps-hgiH tuptuOesluPkcolCtceriD 732-3
foeulavtnerrucgnidaer,retnuocdeeps-hgiHdeeps-hgihehtfoeulavtnerrucehtgnidaeR
retnuoc112-3
"0"nahtrehtooteulavehtgnitteser,retnuocdeeps-hgiH noitcnufteserP 512-3
KVNKA Index_Pro.p65 08.3.11, 0:14 PM360
Inde
x
Index 3-361
esopruP eltiT egaP
"0"oteulavehtgnitteser,retnuocdeeps-hgiH retnuocdeeps-hgihehtgnitteseR 412-3
rofecruostupnignitceles,retnuocdeeps-hgiH dohtemtupnitnuoC 212-3
fosnoitacificeps,retnuocdeeps-hgiH sretnuocdeeps-hgihfosnoitacificepS 802-3
foeulavteserpehtgniyficeps,retnuocdeeps-hgiHretnuocdeeps-hgihehtfoeulavteserP
rotarapmoc112-3
retnuocgnirsa,gnisu,retnuocdeeps-hgiH noitcnufretnuocgniR 522-3
I
gnignahc,tinucisabfotnatsnocemittupnI noitcnufegnahctnatsnocemittupnI 32-3
gnittes,tinunoisnapxefotnatsnocemittupnI stinunoisnapxeroftnatsnocemittupnI 67-1
fotnednepednisutatsyalergnittuptuo,noitcurtsnitpurretnIemitnacs
tuptuO/tupnItceriD 791-3
tuobagninrael,snoitcurtsnitpurretnI noitcurtsnitpurretnI 14-3
nihtiwdesuebtonnactahtsnoitcurtsni,smargorptpurretnI desuebtonnactahtsnoitcurtsnI 691-3
ybretnuocdeeps-hgihfoeulavtnerrucgnidaer,tpurretnI erutpactupnI 591-3
rofnoitidnoctupnignittes,tpurretnI tupnilanretxenaybstpurretnirofgnittesytiraloP 591-3
detucexeerastpurretnilarevesnehw:tpurretnI ytiroirptpurretnI 691-3
K
gnisu,VKrofREDLIUBREDDAL/)SOD(eraWidercnIVKreddalfonoisrevsuoiverpehtgnisunehwsnoituaC
erawtfostroppus)5(
gnisusnoitcurtsnigniretne,)10(E3P-VK )redrolacitebahpla(tsil.oNnoitcnuF 14-3
htiwelbaliavasnoitcnuf,)10(E3P-VK tsil.soNnoitcnuF 612-1
gnitarepo,)10(E3P-VK noitarepognimmargorpcisaB 002-1
M
foyticapac,dracyromeM yticapacegarotS 032-1
foyrettabgnicalper,dracyromeM yrettabecalperoT 832-1
gnitucexe,MDfonoitareporotarapmocpets-itluM edomrotarapmocpets-itluM 432-3
O
VKmorftuptuognilbasid,tuptuO noitcnufdelbasidtuptuO 62-3
P
VKfognitnuomlenaP lenapaotyltceridtinuagnihcattA 66-1
morfatadgniviecer,retupmoclanosreP atadtxetgnivieceR 813-3
otVKmorfatadgnittimsnart,retupmoclanosreP atadtxetgnittimsnarT 913-3
fonoitaluclac,yticapacmargorP desutnuocetybehtgnitaluclaC 4-3
tuobagninrael,yticapacmargorP yticapacmargorP 4-3
dracyromemotnignivas,smargorP ])10(E3P-VKhtiwdesu[snoitcnuF 032-1
gnivird,rotomesluP erudecorpgnittesretemaraP 552-3
ycneuqerfderisedtatuptuoesluP noitcnuftuptuoeslupycneuqerfdeificepS 822-3
tinucisabotdengissa.soNyaleR tsilyaleR 5-3
tinunoisnapxeotdengissa.soNyaleR stinunoisnapxenisyalerfotsiL 6-3
gningissa,.soNyaleR .soNyalergningissA 8-3
S
MORotniMD/retnuocfoeulavtnerrucgnivaS sedomEVASdnaDAOL 69-1
emitnacS emitnacS 3-3
VKotgnitcennoc,secivedrehtorosrosneS stinucisabrofserudecorpgniriW 76-1
citemhtiranehw,fosutatsniegnahc,syalerytilitulaicepSdesusinoitcurtsni
syalerytilitulaicepsfosutatsniegnahCsnoitcurtsnicitemhtirayb)sgalfcitemhtira(
681-3
otdengissasnoitcnuf,syalerytilitulaicepS tsilyalerytilitulaicepS 68-3
rofmetignittes,noitcnuftuptuoeslupycneuqerfdeificepS tuptuoeslupycneuqerfdeificepsrofdesueciveD 822-3
T
otdengissasnoitcnuf,yromematadyraropmeT yromematadyraropmeT 12-3
forebmunmumixam,sretnuoc/sremiT tsilretnuoC/remiT 81-3
Index — For Visual KV User’s Only
KVNKA Index_Pro.p65 08.3.11, 0:14 PM361
Inde
x
Index3-362
AA/D converter ........................... 1-312 [AN6], 1-334 [AD4]A/D conversion table ................ 1-408 [AN6], 1-357 [AD4]ADD/@ADD: Add .................................................. 3-150AND: And ................................................................ 3-58ANB: And Bar ......................................................... 3-58ANDA/@ANDA: And A ......................................... 3-159ANL: And Load ....................................................... 3-61Application Instructions ...................... 3-36, 3-45, 3-95Arithmetic Instructions ...................... 3-38, 3-48, 3-134ASC/@ASC: ASCII Convert ................................ 3-183Assignment of Data Memory ................................. 3-19Assignment of I/O relay numbers ......................... 3-22
BBasic Instructions ................................ 3-34, 3-42, 3-56Baud rate......................................... 2-136, 1-247 [KV-L2]Break signal .......................................................... 3-308
CC: Counter .............................................................. 3-72CALL: Subroutine Call ......................................... 3-122CMP/@CMP: Compare ......................................... 3-146COM/@COM: Complement .................................. 3-171Commands [Serial communication] ................... 3-310Communications ....................................... 2-135, 3-306CON: Connect ....................................................... 3-102Connector wiring ....................................................... 1-72CTC: Counter Comparator .................................. 3-204CTH1: 16-Bit Counters ......................................... 3-204
DData Memory ........................................................... 3-19D/A converter ........................... 1-312 [AN6], 1-334 [AD4]D/A conversion table ................ 1-408 [AN6], 1-357 [DA4]DEC/@DEC: Decrement Memory ........................ 3-172DI: Interrupt Disabled ........................................... 3-193DIFD: Differentiate Down ....................................... 3-78DIFU: Differentiate Up ........................................... 3-78Dimensions ............................................................. 1-404DIN rail (mounting) .................................................. 1-180Direct Clock Pulse ................................................ 3-276Display Interface Mode [KV-L2] .............................. 1-244DIV/@DIV: Divide .................................................. 3-150DMX/@DMX: Demultiplexer ................................. 3-176DW: Data Memory Write ...................................... 3-136
EEI: Interrupt Enabled ............................................ 3-193END: End ................................................................. 3-94ENDH: End Hi ......................................................... 3-94ENDS: End Stage ................................................. 3-106Environment requirements ........................................ 1-64EORA/@EORA: Exclusive Or A .......................... 3-164Error code list .......................................................... 1-372Extended Ladder Diagrams ................................... 3-29
Index — For KV-300, KV-10/80 User’s Only
Index — For KV-300, KV-10/80 User’s Only
FFOR: Repeat Start ................................................ 3-125
HHigh-Speed Counters .......................................... 3-276HKEY: 16 Key Input .............................................. 3-131HSP: High Speed .................................................... 3-86
IINC/@INC: Increment Memory ............................ 3-172Indirect Addressing of Data Memory or Relay .. 3-127Input Relays .............................................................. 3-9Instruction List .............................................. 3-34, 3-42INT: Interrupt ........................................................ 3-192Interface [RS-232C] .............................................. 3-306Internal register .................................................... 3-135Internal Utility Relays ............................................. 3-11Internal Clocks for CTH0 and CTH1 ................... 3-278Interrupt Instructions ........................................... 3-268I/O distribution ......................................................... 1-187ITVL: Interval Timer .............................................. 3-117
JJMP: Jump ............................................................ 3-106
KKEEP: Keep ............................................................ 3-80KV-10/16/24/40/80 ............................ 1-167, 1-175, 1-177KV-300 ......................................................... 1-166, 1-170KV-AD4 ................................................................... 1-334KV-AN6 ................................................................... 1-312KV-B16R/B16S/C32T.............................................. 1-172KV-C16X/C32X ....................................................... 1-171KV-DA4 ................................................................... 1-334KV-L2 ...................................................................... 1-240KV-R1A/R16X/R16R/R16T/R8X/R8R/R8T .. 1-173, 1-174KV-U4/U5 ..................................................... 1-168, 1-169KV mode [KV-L2] .................................................... 1-253
LLD: Load .................................................................. 3-57LDA/@LDA: Load A .............................................. 3-140LDB: Load Bar ........................................................ 3-57
MMacros ...................................................................... 2-72MC: Master Control ................................................ 3-89MCR: Master Control Reset ................................... 3-89Memory Card .......................................................... 1-230MEMSW: Memory Switch ...................................... 3-92Module names......................................................... 1-175Mounting Environment .............................................. 1-64MPP: Pop .............................................................. 3-103MPS: Push ............................................................ 3-103
KVNKA Index_Pro.p65 08.3.11, 0:14 PM362
Inde
x
Index 3-363
MPX/@MPX: Multiplexer ...................................... 3-176MRD: Read ............................................................ 3-103MUL/@MUL: Multiply ........................................... 3-150
NNEXT: Repeat End ................................................ 3-125Non-procedure mode [KV-L2] ................................. 1-292NOP: No Operation ................................................ 3-94
OOR: Or ..................................................................... 3-60ORA/@ORA: Or A ................................................. 3-161ORB: Or Bar ............................................................ 3-60ORL: Or Load .......................................................... 3-63OUB: Out Bar .......................................................... 3-65OUT: Out ................................................................. 3-65Output Relays ......................................................... 3-10
PPeripheral equipments ............................................ 1-176Port1/Port2 [KV-L2] ................................................. 1-245Positionning control ............................................ 3-296Programming examples ...................................... 3-324
RRASC/@RASC: Reverse ASCII Convert ............. 3-183Receiving text data .............................................. 3-318Relay/Memory/Memory Switch Lists ....................... 2-167Relay/Memory Nos. ................................................. 2-167Relay No. List .......................................................... 2-167Relay Nos. and Functions ....................................... 2-167RES: Reset .............................................................. 3-66RET: Subroutine Return ...................................... 3-122RETI: Return Interrupt ......................................... 3-192RLA/@RLA: Rotate Left A ................................... 3-169ROOT/@ROOT: Square Root .............................. 3-185RRA/@RRA: Rotate Right .................................... 3-169RS-232C cable connection .................................. 3-307RS-232C Protocol ................................................. 3-306RS-422A [KV-L2] ..................................................... 1-248
SSBN: Subroutine Entry ........................................ 3-122Serial Communication ......................................... 3-306SET: Set .................................................................. 3-66SFT: Shift ................................................................ 3-82SLA/@SLA: Shift Left A ....................................... 3-166Special Utility Relays............................................... 2-174SRA/@SRA: Shift Right A .................................... 3-166STA/@STA: Store A ............................................. 3-140Station No. [KV-L2] ................................................. 1-246STE: Step End ...................................................... 3-114STG: Stage ............................................................ 3-106STP: Step .............................................................. 3-114SUB/@SUB: Subtract ........................................... 3-150System configuration............................................... 1-166
Index — For KV-300, KV-10/80 User’s Only
System Configuration (Memory Card) ..................... 1-196System specifications [Visual KV Series] ................ 1-382System specifications [KV-300 Series] ................... 1-392
TTBCD/@TBCD: Transfer BCD ............................. 3-180TBIN/@TBIN: Transfer BIN .................................. 3-180Temporary Memory ...................................... 2-172, 2-176Timers and Counters ............................................... 2-169TMH: 0.01-s Timer .................................................. 3-68TMIN: Trimmer In .................................................. 3-138@TMIN: Trimmer Setting ..................................... 3-138TMR: 0.1-s Timer .................................................... 3-67TMS: 1-ms Timer .................................................... 3-69Transmitting text data .......................................... 3-319Troubleshooting ...................................................... 1-372
UUDC: Up-Down Counter ......................................... 3-76
WW-DE: Wait Down Edge ......................................... 3-98W-OFF: Wait OFF ................................................... 3-96W-ON: Wait ON ....................................................... 3-96W-UE: Wait Up Edge .............................................. 3-98
X@xxxx: Differentiation ......................................... 3-137
KVNKA Index_Pro.p65 08.3.11, 0:14 PM363
Inde
x
Index3-364
AACCS ...................................................................... 1-234ALL CLEAR [FNC60] [P3E]..................................... 1-217ALL DATA MEMORY CLEAR (DM ALL CLEAR): [FNC64] [P3E]...................... 1-219ALL LATCHING RELAYS RESET (L-RELAY ALL RST): [FNC65] [P3E] ................... 1-219
BBreak signal .......................................................... 3-308
CCLEAR [P3E] .......................................................... 1-232Comments (Relay comment, Line comment) ............ 2-46Compile ..................................................................... 2-75Converting N.O./N.C. ................................................ 2-65Copy, move and delete ............................................. 2-69COUNTER CLEAR (CTR CLEAR): [FNC62] [P3E] 1-218Customizing KV-LADDER , Defining Environment Strings................................ 2-19Copy, move and delete operation ............................. 2-52
DData Communications between KV and Personal Computer .................................... 3-306Display mode ........................................................... 2-19Double coil check ...................................................... 2-76
EEdit screen ................................................................ 2-27Entering symbols....................................................... 2-37Environment requirements .......................................... 2-3Error message list ................................................... 2-156
HHANDHELD PROGRAMMER CLEAR (P3E CLEAR): [FNC61] .............................................................. 1-217Handheld Programmer KV-P3E .............................. 1-196HIGH-SPEED COUNTER CLEAR (HIGH SPEED CTR CLR): [FNC63] [P3E] .......... 1-218
IInstalling Ladder Builder.............................................. 2-9
JJump ......................................................................... 2-58
LLadder Monitor ........................................................ 2-134Ladder Simulator ....................................................... 2-84Line comment........................................................... 2-46
MMacros ...................................................................... 2-72Memory Card [P3E] ................................................. 1-230Monitor Mode .......................................................... 2-134Monitor screen ........................................................ 2-143MOVE CURSOR [P3E] ........................................... 1-202
Index — Software/P3E (handheld programmer)MULTI-MONITOR [P3E] ......................................... 1-212
OOFFLINE EDITOR START (OFFLINE EDITOR): [FNC67] [P3E] .................................................... 1-221OFFLINE EDITOR STOP (QUIT OFF-L EDIT): [FNC68] [P3E] .................................................... 1-221ON/OFF MONITOR [P3E] ....................................... 1-215
PPrinter Setting, Defining Environment Strings .......... 2-77Printing examples...................................................... 2-81PROGRAM CAPACITY CHECK (PROGRAM SIZE): [FNC75] [P3E] .................................................... 1-229PROGRAM SENT OR RECEIVED (COMMUNICATION—): [FNC66] [P3E] ............. 1-220
QQuitting software ....................................................... 2-16
RREAD TRIMMER SETTING (TRIMMER MONITOR): [FNC73] [P3E] .................................................... 1-228Registration of cursor position and jump to registered position ................................... 2-59RELAY ON/OFF (FORCED SET/RESET): [FNC71] [P3E] .................................................... 1-226Replacing relays........................................................ 2-64RS-232C cable connection ......................................... 2-7RS-232C Protocol ....................................................... 2-3
SSCAN TIME MONITOR [P3E] ................................. 1-212SCROLL [P3E] ........................................................ 1-202Search ....................................................................... 2-58Searching Program [P3E] ....................................... 1-207Selecting display mode ............................................. 2-19Setting print range ..................................................... 2-77Simulator Mode ......................................................... 2-84Simulator screen ....................................................... 2-86Starting and quitting software ................................... 2-16Starting edit mode .................................................... 2-29Starting the Monitor Function .................................. 2-139Starting the Simulator ................................................ 2-86SYNTAX CHECK (PROGRAM CHECK): [FNC74] [P3E] .................................................... 1-228
TTemporary Memory ................................................ 3-21Time Chart Monitor ................................................. 2-157Time Chart Viewer ....................................... 2-148, 2-167TIMER/COUNTER SETTING CHANGE (CHG: T/C SET-V): [FNC70] [P3E] .................... 1-224TIMER/COUNTER CURRENT VALUE CHANGE (CHG: T/C CURT-V): [FNC69] [P3E] ................. 1-222
WWRITE INTO DATA MEMORY (DM WRITE): [FNC72] [P3E] .................................................... 1-227
Index — Software/P3E (handheld programmer)
KVNKA Index_Pro.p65 08.3.11, 0:14 PM364
Inde
x
Index 3-365
KVNKA Index_Pro.p65 08.3.11, 0:14 PM365
Inde
x
Index3-366
KVNKA Index_Pro.p65 08.3.11, 0:14 PM366
Safety PrecautionsThis instruction manual describes the operation and function of the KV Series PLC.Read this manual carefully to ensure safe use and maximum performance from yourKV Series PLC.
SymbolsThe following symbols alert you to important messages. Be sure to read thesemessages carefully.
Failure to follow instructions may lead to injury. (electricshock, burn, etc.)
Failure to follow instructions may lead to product damage.
Provides additional information on proper operation.
ConventionsThis manual describes the operation/function of all Keyence KV Series PLC.Note following conventions when you use.
General Precautions• At startup and during operation, be sure to monitor the functions and perfor-
mance of the KV Sereis PLC.
• We recommend that you take substantial safety measures to avoid any damagein the event a problem occurs.
• Do not open or modify the KV Series PLC or use it in any way other than de-scribed in the specifications.
• When the KV Series PLC is used in combination with other instruments, func-tions and performance may be degraded, depending on operating conditions andthe 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 veryfirst time you turn on the power supply to the Visual KV Series. Press any keyaround the display to cancel this message.The Visual KV Series shows this message when no program is loaded.
WARNING
CAUTION
Note:
(1)
Visual KV (Series) KV-10AR/AT/DR/DT KV-16AR/AT/DR/DTKV-10xx, 16xx, 24xx, 40xx KV-24AR/AT/DR/DT KV-40AR/AT/DR/DT
Conventional KV (Series) KV-10R(W)/T(W) KV-16R(W)/T(W)KV-300 (Series) KV-24R(W)/T(W) KV-40R(W)/T(W)KV-10/80 (Series) KV-80R(W)/T(W)
KV-300
3-367
WARRANTIES AND DISCLAIMERS: (1) KEYENCE warrants the Products to be free of defects in materials and workmanship for a period ofone (1) year from the date of shipment. If any models or samples were shown to Buyer, such models orsamples were used merely to illustrate the general type and quality of the Products and not to representthat the Products would necessarily conform to said models or samples. Any Products found to be defec-tive must be shipped to KEYENCE with all shipping costs paid by Buyer or offered to KEYENCE for in-spection and examination. Upon examination by KEYENCE, KEYENCE, at its sole option, will refund thepurchase price of, or repair or replace at no charge any Products found to be defective. This warrantydoes not apply to any defects resulting from any action of Buyer, including but not limited to improperinstallation, improper interfacing, improper repair, unauthorized modification, misapplication and mishan-dling, such as exposure to excessive current, heat, coldness, moisture, vibration or outdoors air. Compo-nents which wear are not warranted. (2) KEYENCE is pleased to offer suggestions on the use of its various Products. They are only sugges-tions, and it is Buyer’s responsibility to ascertain the fitness of the Products for Buyer’s intended use.KEYENCE will not be responsible for any damages that may result from the use of the Products. (3) The Products and any samples (“Products/Samples”) supplied to Buyer are not to be used internallyin humans, for human transportation, as safety devices or fail-safe systems, unless their written specifica-tions state otherwise. Should any Products/Samples be used in such a manner or misused in any way,KEYENCE assumes no responsibility, and additionally Buyer will indemnify KEYENCE and holdKEYENCE harmless from any liability or damage whatsoever arising out of any misuse of the Products/Samples. (4) OTHER THAN AS STATED HEREIN, THE PRODUCTS/SAMPLES ARE PROVIDED WITH NOOTHER WARRANTIES WHATSOEVER. ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES,INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR APARTICULAR PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS, ARE EXPRESSLYDISCLAIMED. IN NO EVENT SHALL KEYENCE AND ITS AFFILIATED ENTITIES BE LIABLE TO ANYPERSON OR ENTITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL OR CONSE-QUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, ANY DAMAGES RESULTING FROMLOSS OF USE, BUSINESS INTERRUPTION, LOSS OF INFORMATION, LOSS OR INACCURACY OFDATA, LOSS OF PROFITS, LOSS OF SAVINGS, THE COST OF PROCUREMENT OF SUBSTITUTEDGOODS, SERVICES OR TECHNOLOGIES, OR FOR ANY MATTER ARISING OUT OF OR IN CONNEC-TION WITH THE USE OR INABILITY TO USE THE PRODUCTS, EVEN IF KEYENCE OR ONE OF ITSAFFILIATED ENTITIES WAS ADVISED OF A POSSIBLE THIRD PARTY’S CLAIM FOR DAMAGES ORANY OTHER CLAIM AGAINST BUYER. In some jurisdictions, some of the foregoing warranty disclaimersor damage limitations may not apply.
BUYER’S TRANSFER OBLIGATIONS: If the Products/Samples purchased by Buyer are to be resold ordelivered to a third party, Buyer must provide such third party with a copy of this document, all specifica-tions, manuals, catalogs, leaflets and written information provided to Buyer pertaining to the Products/Samples.
User’s ManualVisual KV Series
3Programming
How this manual is organized:
The Visual KV Series User’s Manual is composed of 3 separatemanuals; 1-Installation, 2-Support Software, 3-Programming.Please read each manual relevant to your purpose.
96M0366
SupportSoftware
1. Introduction
2. Editor
3. Simulator
4. Monitor
5. Appendices
Programming1. Programming
2. Instructions
3. Interrupts
4. High-speed Counters
5. Positioning Control
6. Interrupts, High-speedCounters, PositioningControl
7. Serial Communication
8. ProgrammingExamples
INDEX
Installation1. Configuration and
Specifications
2. System Installation
3. Access Window
4. KV-D20 OperatorInterface Panel
5. KV-10/80 Hardware
6. Handheld Program-mer
7. KV-L2 Serial InterfaceModule
8. KV-AN6 Analog I/OModule
9. KV-AD4/DA4 AnalogI/O Unit
10. Troubleshooting
11. Appendices
1 2 3
A5WW1-MAN-0069
Copyright (c) 1999 KEYENCE CORPORATION. All rights reserved.084024E-3 0109-5 96M0366 Printed in Japan
Specifications are subject to change without notice.
AUSTRIAPhone: +43-2236-378266-0
BELGIUMPhone: +32 2 716 40 63
CHINAPhone: +86-21-68757500
CANADAPhone: +1-905-696-9970
CZECH REPUBLICPhone: +420 222 191 483
FRANCEPhone: +33 1 56 37 78 00
GERMANYPhone: +49-6102-36 89-0
HONG KONGPhone: +852-3104-1010
KOREAPhone: +82-31-642-1270
HUNGARYPhone: +36 14 748 313
ITALYPhone: +39-2-6688220
JAPANPhone: +81-6-6379-2211
MEXICOPhone: +52-81-8220-7900
NETHERLANDSPhone: +31 40 20 66 100
POLANDPhone: +48 71 36861 60
MALAYSIAPhone: +60-3-2092-2211
SINGAPOREPhone: +65-6392-1011
SLOVAKIAPhone: +421 2 5939 6461
SWITZERLANDPhone: +41 43 455 77 30
TAIWANPhone: +886-2-2718-8700
THAILANDPhone: +66-2-369-2777
UK & IRELANDPhone: +44-1908-696900
USA Phone: +1-201-930-0100
KEYENCE CORPORATION1-3-14, Higashi-Nakajima, Higashi-Yodogawa-ku, Osaka, 533-8555, Japan PHONE: +81-6-6379-2211
laun
aM
s’res
U
P
rogramm
ing
3
V
isual KV
Series
Recommended