2 3 Installation Support Software Programming 1. Configuration and Specifications 3. Access Window 4. KV-D20 Operator Interface Panel 5. KV-10/80 Hardware 1. Introduction 2. Instructions 2. Editor 3. Interrupts 3. Simulator 4. High-speed Counters 4. Monitor 5. Positioning Control 5. Appendices 6. Interrupts, High-speed Counters, Positioning Control 6. Handheld Programmer Programming 2. System Installation 1. Programming 7. Serial Communication 8. Programming Examples 8.
Safety Precautions WARRANTIES AND DISCLAIMERS: This instruction manual describes the operation and function of the KV Series PLC. Read this manual carefully to ensure safe use and maximum performance from your KV Series PLC. Symbols The following symbols alert you to important messages. Be sure to read these messages carefully. Failure to follow instructions may lead to injury. (electric WARNING shock, burn, etc.) CAUTION Note: Failure to follow instructions may lead to product damage.
Note to User When using the Visual KV Series in the following conditions or environments, be sure to use the Visual KV Series with sufficient margin regarding the rating and functions, take appropriate safety precautions such as fail-safe, and contact our sales personnel if any questions arise.
Features of the Visual KV Series ● Extremely small The Visual KV Series is the smallest in the world among AC type PLCs equipped with 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 added AC power built-in type units are newly added. This type can be used in small spaces where a switching power supply unit cannot be installed.
● Interrupt function The Visual KV Series is equipped with four high-speed interrupt inputs of 10 µs maximum. ● Input time constant change function The time constant can be set in 7 steps from 10 µs to 10 ms. ● Double memory backup functions In addition to a conventional SRAM battery backup function, the Visual KV Series is also equipped with an EEPROM backup function.
Cautions when using the previous version of ladder support software Pay strict attention to the following items when using the ladder support software. • • CAUTION When using the ladder support software "KV IncrediWare (DOS)" or "LADDER BUILDER for KV Ver. 1.0x", set the model to "KV-300". DM0 to DM1999 are only available. When the ladder support software "LADDER BUILDER for KV Ver. 1.0x" is used, do not use the monitor’s Change All function.
(6) KVNKA Front_Pro.p65 7 08.3.
How this manual is organized The Visual KV Series User’s Manual is composed of 3 separate manuals; 1-Installation, 2-Support Software, 3-Programming. Please read each manual relevant to your purpose. 1 Installation Chapter 1 Configuration and Specifications [Visual KV Series Only] Describes the system configuration of the Visual KV Series, the names and functions of each part, and the specifications.
Chapter 2 Editor Describes the operating procedures in Editor mode. Chapter 3 Simulator Describes the operating procedures in Simulator mode. Chapter 4 Monitor Describes the operating procedures in Monitor mode. Appendices Includes instructions list, devices list, sample program list and quick reference for key operation and shortcuts.
Contents 3 Programming Chapter 1 Programming 1.1 Before Creating Programs .............................................................................. 3-2 1.1.1 Flow from Introduction to Operation ................................................................... 3-2 1.1.2 Scan Time ........................................................................................................... 3-3 Scan time ....................................................................................................
Chapter 2 Chapter 3 Instructions 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 Instruction List [Visual KV Series] .............................................................. 3-34 Basic Instructions ..............................................................................................3-34 Application Instructions ..................................................................................... 3-36 Arithmetic Instructions ................................................................................
4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 Specified Frequency Pulse Output Function .................................................. 3-228 Applications of the Specified Frequency Pulse Output ................................... 3-229 Frequency Counter Function .......................................................................... 3-231 Applications of Frequency Counters ............................................................... 3-232 Cam Switch Function ......................................................
Chapter 8 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 Format of Commands/Responses .................................................................. 3-309 Communication Command/Response List ..................................................... 3-310 Setting Communication Commands and Responses to Commands .............. 3-311 Other Response Codes .................................................................................. 3-315 Error Code List ..............................................................
1.7.1 Part Names and Functions ............................................................................... 1-31 1.7.2 Terminal Layout Drawings and I/O Circuit Diagrams ........................................ 1-32 KV-40AR/DR (Relay output type) .............................................................. 1-32 KV-40AT(P)/DT(P) (Transistor output type) ............................................... 1-34 1.7.3 AC Power Input (KV-40AR/AT(P)) ...............................................................
Clearing the input value when disconnecting ............................................. 1-76 2.2.4 Transferring I/O Information between Expansion Units and the Basic Unit ...... 1-77 When inputting ........................................................................................... 1-77 In the case of output .................................................................................. 1-77 2.3 Inspection and Maintenance .........................................................................
4.2.2 Connection with the KV Series ....................................................................... 1-108 Connection ............................................................................................... 1-108 Precautions .............................................................................................. 1-108 4.2.3 Overview of the KV-D20 ................................................................................. 1-109 Switching the display mode ............................
5.3.6 Connecting the AC Power Supply Module and DC Power Distribution Module .... 1-182 KV-U4 AC Power Supply Module ............................................................ 1-182 KV-U5 DC Power Distribution Module ..................................................... 1-182 5.3.7 I/O Connectors ................................................................................................ 1-183 KV-300 CPU ............................................................................................
7.3.4 Connecting to External Units .......................................................................... 1-249 Connecting to An External Display .......................................................... 1-249 Connecting to an IBM PC-AT Computer .................................................. 1-249 Connecting to the KV-10/16/24/40/80 ...................................................... 1-250 Connecting KV-L2s ..................................................................................
8.3.2 8.3.3 8.3.4 8.3.5 Removing the Terminal Block ......................................................................... 1-316 Example of Voltage I/O Wiring ........................................................................ 1-317 Example of Current I/O Wiring ........................................................................ 1-318 Setting I/O Ranges ......................................................................................... 1-319 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.4.6 8.4.
Chapter 10 Troubleshooting 10.1 10.1.1 10.1.2 10.1.3 10.1.4 Error List ....................................................................................................... 1-372 List of Error Codes in Basic Units ................................................................... 1-372 Error indication in Expansion Units ................................................................. 1-374 Program Errors ...............................................................................................
1.4.1 Preparation for installation .................................................................................. 2-9 1.4.2 Installation Procedure ....................................................................................... 2-10 Installation in Windows 95 ......................................................................... 2-10 Installation in Windows 3.1 ........................................................................ 2-12 Chapter 2 1.5 Cautions for Use ......................
2.13.1 Printing ..............................................................................................................2-77 2.13.2 Preview display ................................................................................................. 2-81 2.14 Changing the Display Color on the Screen ................................................. 2-82 2.14.1 Changing display colors on the screen ............................................................. 2-82 Chapter 3 Simulator 3.
Appendices Appendix A Error Message List ......................................................................... 2-156 A-1 System errors ................................................................................................. 2-156 A-2 Memory errors ................................................................................................ 2-156 A-3 File errors ........................................................................................................
WARRANTIES AND DISCLAIMERS See 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 contact the sales office listed at the end of this manual if you have any questions or comments regarding this manual or if you find an error.
Chapter 1 Programming This chapter describes basic knowledge including program creation procedures, device configuration, relay assignments, special functions to set and confirm Visual KV Series operations, as well as the extended ladder diagrams. Understand the contents described here completely at first before creating programs. ➮ KVNKA Chap 01P.p65 For a detailed description of instructions, refer to "2.4. Instruction Details" (p.3-56). 1 1.1 Before Creating Programs ................................
1.1 Before Creating Programs 1.1 Before Creating Programs This section describes what you should know before creating programs and operations for the Visual KV Series. 1.1.1 Flow from Introduction to Operation This 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 Visual KV Series.
1.1 Before Creating Programs 1.1.2 Scan Time Scan time The Visual KV Series repeatedly executes a ladder based on the sequence circuit as follows. Writes the ON/OFF status of all input terminals to the input memory before executing the program. Input processing Program execution Output processing Reads the ON/OFF status of each device (internal utility relay, timer, counter, etc.) based on the instructions, and performs arithmetic operations. Writes the arithmetic operation result to the output memory.
1.2 User Memory 1.2 User Memory This section describes the allowable size (capacity) of a program which can be created in the Visual KV Series. 1.2.1 Program Capacity When a user program is created for the Visual KV Series, the maximum number of steps a program can contain using the mnemonic diagram varies based on the byte count of the instructions used. The instruction byte count is determined individually for each instruction. ➮ For more about byte counts for each instruction, refer to "2.
1.3 Device Configuration 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 their general use. 1.3.1 Device List Relay list Relay No. Normal use High-speed use (1) High-speed use (2) 0001 0002 Input relays (Direct input allowed area) Interrupt inputs INT0 to INT3 Remarks They function as B phase of high-speed counters through specification of utility relays in KV-10.
1.
1.3 Device Configuration 1.3.2 Relay No. The relay No. configuration is shown below. Channel No. 12515 Contact No. (00 to 15) Address No. (Input: 0 to 4, output: 5 to 9) Address No. Address Nos. are assigned to basic units, input expansion units, output expansion units, and I/O expansion units. Zero to 4 are assigned to input units, while 5 to 9 are assigned to output units. Address Nos. assigned in a unit vary based on the number of I/O terminals and the connection position of the unit.
1.3 Device Configuration 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 KVE16T(P), with 16 input terminals, the contact Nos. are 0 to 15. • In a unit with 16 or more terminals, the contact No. of the 17th terminal returns to 0 and its address No. is increased by 1.
1.3 Device Configuration 1.3.4 Input Relays Input relays receive ON/OFF signals sent from external input equipment. Note 1: Input relays function as contacts in programs. They cannot be used as relay coils (outputs). Note 2: There is no restriction of the contact type (N.O. or N.C.) used, the order the relay Nos. are used, or the number of relays used. Basic unit ■ Input relay time constant Though the time constant is usually 10 ms ±20%, it can be changed using the following settings.
1.3 Device Configuration Expansion unit ■ Input relay time constant By setting special utility relays 2609 to 2612 to ON, the time constant in input expansion units can be set to 10 µs. Special utility relay No. 2609* 2610 2611 2612 * Function Input time constant of input expansion with relay Nos. 0100 to 0115 Input time constant of input expansion with relay Nos. 0200 to 0215 Input time constant of input expansion with relay Nos. 0300 to 0315 Input time constant of input expansion with relay Nos.
1.3 Device Configuration 1.3.6 Internal Utility Relays In a relay circuit, when one relay contact is used twice or more inside the circuit, a multi-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 relay circuits 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.
1.3 Device Configuration 1.3.7 Special Utility Relays Each special utility relay has a unique function. By using special utility relays effectively, 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, but cannot be used as outputs. ➮ For more about relays dedicated for reading, refer to "1.3.8 Special Utility Relay List" (p.3-14).
1.3 Device Configuration Relay 2008: Remains ON during only one scan when operation is started. This relay can be used for an initial reset at the start of operation. After one scan, this relay remains OFF. 0000 1000 SFT D 1100 CLK 1100 2008 RES When operation is started, this relay sets all internal utility relays used by the SFT instruction to OFF. 2008 #00000 LDA DM0000 STA When operation is started, this relay returns the current value of DM0000 to 0.
1.3 Device Configuration 1.3.8 Special Utility Relay List Special relays and arithmetic operation flags ➮ "1.3.7 Special Utility Relays" (p.3-12) Relay No. 2002* 2003* Always OFF. 2004* 0.01-s clock pulse (duty cycle: 50%) 2005* 0.1-s clock pulse (duty cycle: 50%) 2006* 1.0-s clock pulse (duty cycle: 50%) 2007* Remains OFF during first scan after startup. 2008* Remains ON during first scan after startup. Turns ON when result of arithmetic operation is negative or when an overflow is generated.
1.3 Device Configuration Special utility relays for high-speed counter(1) ➮ "Chapter 4. High-Speed Counters" (p.3-203) Relay No. 2200* 2201* Internal clock used only for CTH1 (10 µs) 2202* Internal clock used only for CTH1 (100 µs) Automatic clear of CTH1 when comparator CTC2 turns ON. Prohibits/permits direct output to 0501 when comparator CTC2 turns ON. Direct output to 0501 is set to OFF when comparator CTC2 turns ON. Direct output to 0501 is set to ON when comparator CTC2 turns ON.
1.3 Device Configuration Relay No.
1.3 Device Configuration Relay No. 2609 2610 2611 2612 Function Input time constant of input expansion unit with relay Nos. 0100 to 0115 Input time constant of input expansion unit with relay Nos. 0200 to 0215 Input time constant of input expansion unit with relay Nos. 0300 to 0315 Input time constant of input expansion unit with relay Nos.
1.3 Device Configuration 1.3.9 Timers and Counters Timers and counters can be set in a program, and their outputs can be used as contacts 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, T005 and C005 cannot be used in the same program. Timer/Counter list Name Timer Counter Timer (0.1-s timer) High-speed timer (0.01-s timer) High-speed 1-ms timer (0.
1.3 Device Configuration 1.3.10 Data Memories Data 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 memories can be used to store data for arithmetic operations as well as the results of arithmetic operations. DM No.
1.3 Device Configuration DM No.
1.3 Device Configuration 1.3.11 Temporary Data Memory These data memories are used for temporary storage. When arithmetic instructions are used, temporary data memories can be used to temporarily store the data for arithmetic operations as well as the results of arithmetic operations. TM No.
1.3 Device Configuration 1.3.12 Relay Nos. and Functions Assignment of Relay Nos. The components of a relay no. are shown below. 0 7 5 1 5 Channel No. Relay No. (00 to 15) Module No. (07 to 17) Address No. Input (0 to 4) Output (5 to 9) ■ Unit Nos. Unit nos. are assigned to units within the KV-300 system, with the unit connected to the right of the KV-300 CPU (see the figure below) assigned as no. 7. The CPU is assigned as unit no. 0. 1 Power supply unit CPU 0 7 8 9 16 17 ■ Address Nos.
1.4 Special Functions 1.4 Special Functions This section describes special functions to set and confirm operations on the Visual KV Series, and useful functions for program debugging and adjustment of external equipment. 1.4.1 Input Time Constant Change Function The input time constant can be changed when a signal is read from an input contact.
1.4 Special Functions 1.4.2 Modifying the Input Relay Time Constant KV-300 PLC Only ■ Modifying with External Switches KV-C32X/C16X KV-R16X/R8X Input time constant selection switch 3 24V 4 1 ms 0 ms 10 ms 2 5V 0 ms 10 ms 1 ms 1 0 As shown in above figures, an external switch can be used to select the input time constant only on the KV-C32X/C16X Connector Input Units and KV-R16X/R8X I/O Terminal Units. 1 In the following table, white represents the switch position.
1.4 Special Functions 1.4.3 Constant Scan Time Mode This function executes a program while keeping the scan time at a constant value which usually changes based on the processing contents. This section describes how to set this function. Though the scan time changes usually depending on the processing contents, it can be kept at a constant value by using this function. This function can be used to acquire data from external equipment at a constant time interval.
1.4 Special Functions 1.4.4 Output Disabled Function This function disables outputs from each unit in RUN mode without regard to the program used. By disabling external outputs, the program can be debugged while external equipment is connected, even when output of signals to the external equipment is not desired. ■ Setting procedure When special utility relay 2300 turns ON, all outputs from all output relays (0500 to 0915) to the outside are cleared after 1 scan is finished.
1.5 Extended Ladder Diagrams 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 support software. • The Visual KV Series can store not only programs but also comments registered to each contact using the "KV IncrediWare (DOS)" or "LADDER BUILDER for KV" programming support software. A program may not be easy to understand if only device Nos. are used.
1.4 Special Functions 1.4.7 Special Functions KV-300 PLC only Constant Scan Time Mode In this mode, operation can take place according to a preset scan time (in ms). ■ Setting Write the desired scan time into TM29 (temporary data memory), then turn on special utility relay No. 2303. The scan time can also be written into TM31. Specify a scan time in increments of 10 ms (a value of less than 10 ms is invalid). Here, write a value into TM equivalent to 10 times the scan time.
1.5 Extended Ladder Diagrams 1.5 Extended Ladder Diagrams This section describes KEYENCE’s unique extended ladder diagram. 1.5.1 Features of Extended Ladder Diagrams The extended ladder diagram is a programming method developed to reduce problems related to design, testing, operation, and maintenance of programs. In a conventional ladder diagram, output instructions can be written only on the right side of a ladder diagram.
1.5 Extended Ladder Diagrams 1.5.2 Advantages of Extended Ladder Diagrams The 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.
1.5 Extended Ladder Diagrams Note: When an extended ladder diagram is used, the number of lines in ladder diagram may be reduced. However, this may not necessarily reduce the number of mnemonics in the program. Conventional ladder diagram 0000 Extended ladder diagram 0500 0000 0500 0501 0501 LD 0000 OUT 0500 OUT 0501 LD 0000 OUT 0500 CON OUT 0501 The CON instruction for connection is added. (The scan time is not affected.) 1.5.
1.5 Extended Ladder Diagrams 1 3-32 Chapter 1 Programming KVNKA Chap 01P.p65 32 08.3.
Chapter 2 Instructions Describes the concrete usage of instructions in the KV Series. Refer to "Chapter 3 Interrupts" on page 3-191 for details of interrupt instructions. Refer to "Chapter 4 High-speed counters" on page 3-203 for details of the highspeed counters used in the application instruction. KVNKA Chap 02_1&2&3P.p65 33 2.1 Instruction List [Visual KV Series] ....................................... 3-34 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 Basic Instructions ...........................................
Visual KV Series 2.1 Instruction List 2.1 Instruction List Visual KV Series The KV Series uses 80 instructions. The instructions are divided into four categories according to their functions: basic instructions, application instructions, arithmetic instructions, and interrupt instructions. The following is an overview of applications and functions. For details, refer to the respective description pages for each instruction. 2.1.
2.1 Instruction List Instruction Exec.time (µs) Bytes Page 12.0 to 17.8 2 (7) 3-69 12.0 to 17.8 4 (7) 3-72 13.0 to 24.0 2 (10) 3-76 3 (10) 3-78 3 (10) 3-78 3 (11) 3-80 (*) 5 (15) 3-82 Reduces input relay time constant to 10 µs for higher input response. 3.8 to 9.4 3 (8) 3-86 MC (FUN24) Selects ON/OFF status of R coils, Ts, or Cs. 0.2 1 (4) 3-89 MCR MCR (FUN25) Represents end of MC. 0.2 1 (0) 3-89 MEMSW $xxxx MEMSW (FUN26) Sets memory switches.
Visual KV Series 2.1 Instruction List 2.1.2 Application Instructions Instruction Symbol WAIT ON nnnn ON mmmm W-ON nnnn OFF mmmm W-OFF WAIT OFF WAIT UP EDGE WAIT DOWN EDGE nnnn W-UE mmmm nnnn CON (FUN 06) PUSH MPS READ MRD POP MPP nnnn STG nnnn JMP JMP (FUN 21) END STAGE ENDS ENDS (FUN 14) STP nnnn STP (FUN 45) STE STE (FUN 43) STEP END 17915 T000 to T249 C000 to C249 CTC0 to CTC3 mmmm: mmmm: 1000 to 1915 3000 to 9915 R No. 1000 to 1915 R No. nnnn: R, T, C Nos. • • • Exec.
2.1 Instruction List Instruction INTERVAL TIMER 16-BIT COUNTER 16-BIT COUNTER COMPARATOR 16-BIT COUNTER Symbol Mnemonic ITVL PLS DMnnnn PAUSE mmmm RES Exec.time (µs) Bytes Page 20.0 to 80.0 5 (10) 3-117 14.4 4 (6) 3-204 Hardware-based comparator between preset & current values of high-speed counter 2.3 to 3.5 (CTH0). This comparator is turned ON when these values are equal. 2 (6) 3-204 16-bit (0 to 65535) updown counter for clock pulses with input response frequency of 30 kHz. 14.
2.1 Instruction List Visual KV Series 2.1.3 Arithmetic Instructions Instruction DATA MEMORY WRITE TRIMMER SETTING Symbol Mnemonic nnnn DW DMmmmm DW n TMIN TMIN (FUN 50) n TMIN nnnn LDA LOAD A nnnn LDA Operand value nnnn: #/$ constant DMmmmm: DM No. nnnn: #0000 to #65535 $0000 to $FFFF DMmmmm: DM0000 to DM1999 Writes constant into data memory. Trimmer No. 0 to 1 Inputs value set by access window’s digital trimmer (0 to 65535) to internal register.
2.1 Instruction List Instruction Symbol nnnn DIV DIVIDE nnnn DIV nnnn ANDA AND A nnnn ANDA nnnn ORA OR A nnnn ORA nnnn EORA EXCLUSIVE OR A nnnn EORA SHIFT RIGHT A SHIFT LEFT A Mnemonic Operand DM0000 to DM1999 DIV TM00 to TM31 R No., (FUN 11) #00000 to DM No., #65535 TM xx, $0000 to #/$ constant, @DIV $FFFF #TMxx @(FUN 11) #TM00 to #TM29 ANDA (FUN 01) 0000 to 17915 DM0000 to DM1999 @ANDA R No., TM00 to TM31 @(FUN 01) DM No.
2.1 Instruction List Instruction Visual KV Series Symbol Mnemonic COM COM (FUN 05) COMPLEMENT INCREMENT MEMORY DECREMENT MEMORY MULTIPLEXER COM @COM @(FUN 05) nnnn INC INC (FNC 19) Operand @INC @(FUN 19) nnnn DEC DEC (FNC 07) DM/TM No.
2.1 Instruction List Visual KV Series 2.1.4 Interrupt Instructions Instruction Symbol Mnemonic Operand Exec.time (µs) Bytes Page 2.2 1 (12) 3-193 4.0 1 (10) 3-193 Executes interrupt instructions between INT and RETI at rising/falling edge of input relays 0000 through 0003. 60.0 to 90.0 1 (8) 3-192 Used with comparators CTC0 to CTC3 and executes instructions between INT and RETI. 60.0 to 90.0 1 (8) 3-192 Represents end of interrupt. 18.0 to 22.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List 2.2 Instruction List • • • KV-300 Series, KV-10/80 Number of bytes represents the memory capacity required for each instruction. Number in ( ) represents the memory capacity required for object code of each instruction. Abbreviations: R: Relay, T: Timer, C: Counter, #: Decimal, $: Hex. 2.2.1 Basic Instructions KV-10/16/24/40/80 Instruction Symbol KV-10/16/24/40/80 Mnemonic Operand Operand value Operand value Exec.
2.2 Instruction List Instruction DIFFERENTIATE UP DIFFERENTIATE DOWN Symbol nnnn DIFU nnnn DIFD KEEP KEEP SET RES nnnn SFT SHIFT D nnnn CLK RES mmmm HIGH SPEED HSP MASTER CONTROL MC MASTER CONTROL RESET MEMORY SWITCH nnnn MCR MEMSW $xxxx $xxxx NOP END END HI END ENDH KV-300 Series, KV-10/80 KV-10/16/24/40/80 Mnemonic Operand Operand value Operand value Exec.time Bytes KV-10/16 (µs) KV-24/40/80 DIFU (FNC10) R No. 1000 to 1915 1000 to 1915 3000 to 6915 KEEP (FNC22) R No.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List KV-300 Instruction Symbol Mnemonic Operand Operand value Exec.time Bytes (µs) 0500 to 1915 2009 2300 to 17915 0.20 to 0.56 nnnn OUT OUT nnnn OUB OUT BAR nnnn (SET) SET SET nnnn RESET RES (RES) 0.1-s TIMER #ddddd #ddddd H xxx TMH (FNC49) 1-ms TIMER #ddddd S xxx TMS (FNC51) COUNTER #ddddd C xxx nnnn UP-DOWN COUNTER UP #ddddd DW RES DIFFERENTIATE UP UDC xxx C T No., # preset value # preset value, C No.
2.2 Instruction List KV-300 Series, KV-10/80 2.2.2 Application Instructions KV-10/16/24/40/80 Instruction Symbol KV-10/16/24/40/80 Mnemonic Operand Operand value Operand value Exec.time Bytes (µs) KV-10/16 KV-24/40/80 nnnn ON mmmm W-ON WAIT OFF nnnn OFF mmmm W-OFF WAIT UP EDGE nnnn ↑ mmmm W-UE WAIT DOWN EDGE nnnn ↓ mmmm W-D WAIT ON nnnn: 0000 to 2915 T000 to T063 nnnn: C000 to C063 R,T, or C CTC0 to CTC3 No.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List Instruction Symbol Mnemonic Operand REPEAT START FOR nnnn FOR [FNC 16] REPEAT END NEXT NEXT [FNC 29] HKEY HKEY [FNC 17] nnnn mmmm 16-KEY INPUT # constant, DM No. I/O R KV-10/16/24/40/80 Operand value Operand value Exec.time Bytes KV-10/16 (µs) KV-24/40/80 Function Page #00000 to #00000 to #65535 #65535 DM0000 to 5.0 to 20.
2.2 Instruction List KV-300 Series, KV-10/80 KV-300 Instruction Symbol Mnemonic Operand Operand value Exec.time Bytes (µs) 16-BIT COUNTER COMPARATOR #ddddd CTCn CTC n: Comparator No. ddddd: # preset value n: 0, 1 ddddd: #00000 to #65535 16-BIT COUNTER CTH1 nnnn CTH Clock source Rs 0005 2200 2201 2202 3.85 CTC n: Comparator No. ddddd: # preset value n: 2, 3 ddddd: #00000 to #65535 — CALL Subroutine [FNC 03] No. 00 to 99 3.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List 2.2.3 Arithmetic Instructions KV-10/16/24/40/80 Instruction DATA MEMORY WRITE Symbol nnnn < DW > DMmmmm n < TMIN > TRIMMER SETTING n ↑ TMIN > nnnn < LDA > LOAD A nnnn ↑ LDA > 2 nnnn < STA > STORE A nnnn ↑ STA > nnnn < CMP > COMPARE nnnn ↑ CMP > nnnn < ADD > ADD nnnn ↑ ADD > nnnn < SUB > KV-10/16/24/40/80 Mnemonic Operand Operand value Operand value Exec.
2.2 Instruction List Instruction Symbol nnnn AND A nnnn ↑ANDA> nnnn < ORA > OR A nnnn ↑ ORA > 0000 to 2915 0000 to 6915 DM0000 to DM0000 to DM0999 DM1999 @ANDA R No., TM00 to TM31 TM00 to TM31 @[FNC 01] DM/TM No., #00000 to #00000 to #65535 #/$ No.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List Instruction Symbol < DMX > DMX [FNC 12] ↑ DMX > @DMX @[FNC 12] TBCD [FNC 47] ↑ TBCD> @TBCD @[FNC 47] < TBIN > TBIN [FNC 48] ↑ TBIN> @TBIN @[FNC 48] < ASC > ASC [FNC 02] ↑ ASC > @ASC @[FNC 02] RASC [FNC 32] ↑ RASC> @RASC @[FNC 32] ROOT [FNC 36] 102.0 to 103.0 ↑ ROOT> @ROOT @[FNC 36] 114.0 to 117.
2.2 Instruction List KV-300 Series, KV-10/80 KV-300 Instruction Symbol nnnn < CMP > Mnemonic Operand Operand value Exec.time Bytes (µs) 9.20 to 36.00 CMP [FNC 04] COMPARE nnnn ↑ CMP > nnnn < ADD > @CMP @[FNC 04] ADD [FNC 00] ADD nnnn ↑ ADD > nnnn < SUB > DM/TM No., #/$ constant, #TMxx DM0000 to DM9999 TM00 to TM31 #00000 to #65535 $0000 to $FFFF #TM00 to #TM29 nnnn nnnn < MUL > 8.40 to 35.00 @SUB @[FNC 46] 10.40 to 37.00 nnnn nnnn < DIV > @MUL @[FNC 28] DM/TM No., #/$ No.
KV-300 KV-300 Series, Series, KV-10/80 2.2 Instruction List KV-300 Instruction Symbol 10.80 #dd @SRA @[FNC 41] 12.80 SLA [FNC 40] 10.80 #dd < SLA > #dd ↑ SLA > @SLA @[FNC 40] 12.80 # constant ↑ RLA > @RLA @[FNC 35] 14.00 < COM > COM [FNC 05] 6.10 1 (9) ↑ COM > @COM @[FNC 05] 8.10 1 (23) INC [FNC 19] 7.70 3 (12) @INC @[FNC 19] 9.70 3 (26) 7.
2.2 Instruction List KV-300 Series, KV-10/80 KV-300 Instruction Mnemonic TBCD [FNC 47] 13.20 ↑ TBCD> @TBCD @[FNC 47] 15.20 < TBIN > TBIN [FNC 48] 14.00 ↑ TBIN> @TBIN @[FNC 48] 16.00 < ASC > ASC [FNC 02] 8.50 ↑ ASC > @ASC @[FNC 02] 10.50 RASC [FNC 32] 6.80 1 (9) 8.
2.2 Instruction List KV-300 KV-300 Series, Series, KV-10/80 2.2.4 Interrupt Instructions KV-10/16/24/40/80 Mnemonic Operand Function Page Symbol INTERRUPT DISABLED < DI > DI [FNC 08] 3.0 to 4.6 1 (4) Disables execution of interrupt. 3-193 INTERRUPT ENABLED < EI > EI [FNC 13] 3.0 to 4.6 1 (4) Enables execution of interrupt. 3-193 INT nnn R No. RETI 1 (8) Comparator No. INT CTCn RETURN INTERRUPT 35.0 to 48.
2.3 Convention Details 2.3 Convention Details In this chapter, each instruction is described as follows: Ladder symbol Represents the form of the instruction on a ladder diagram. Instruction key Represents the key or function No. for entry. Instruction Describes the name and brief function of the instruction. SET / RES 2.4 Instruction Details SET: Set Mnemonic Represents the instruction in ladder language.
2.4 Instruction Details 2.4 Instruction Details 2.4.1 Basic Instructions This section describes the basic instructions used for programming. You can create complete programs with only these basic instructions. Instruction Load 3-57 Load Bar LDB 3-57 And AND 3-58 And Bar ANB 3-58 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.
LD / LDB 2.4 Instruction Details LD LD: Load 7 LDB LDB: Load Bar 4 : nnnn : nnnn Connects N.O. contact to bus. Connects N.C. contact to bus. Example 0000 0500 0001 0501 Coding Line No. Instruction 0000 LD Operand 0000 0001 OUT 0500 0002 LDB 0001 0003 OUT 0501 When input relay 0000 turns ON, output relay 0500 turns ON. When input relay 0001 turns OFF, output relay 0501 turns ON. 12 Description • • LD and LDB instructions are used to connect a contact to the bus.
AND / ANB 2.4 Instruction Details AND: And AND : nnnn ANB: And Bar ANB : nnnn 8 5 Connects N.O. contact in series with previous contact. Connects N.C. contact in series with previous contact. Example 0000 0001 0500 0002 0003 0501 0502 0004 0503 Coding 2 Line No.
AND / ANB 2.4 Instruction Details Operand Visual KV KV-300 KV-10/16 KV-24/40/80 0000 to 17915 T000 to T249 C000 to C249 CTC0 to CTC3 0000 to 0009 0500 to 17915 T000 to T249 C000 to C249 0000 to 2915 T000 to T063 C000 to C063 CTC0 to CTC3 0000 to 6915 T000 to T119 C000 to C119 CTC0 to CTC3 Key operation Example: AND T012 AND 8 Operand ANB ENT R-SRCH ( AND TMR SET ANL 8 (T) 1 2 ENT R-SRCH ) 5 12 Chapter 2 Instructions KVNKA Chap 02_4aP.p65 59 08.3.
OR / ORB 2.4 Instruction Details OR: Or OR : nnnn ORB : nnnn 9 ORB: Or Bar 6 Connects N.O. contact in parallel with previous contact. Connects N.C. contact in parallel with previous contact. Example 0000 0003 0500 0001 0002 0004 Coding Line No. Instruction Operand 0000 LD 0000 0001 OR 0000 0002 ORB 0002 0003 AND 0003 0004 OR 0004 0005 OUT 0500 2 0000 must be ON or To turn ON 0500, 0003 must be ON, and 0001 ON or or, 0002 OFF. 0004 must be ON.
ANL 2.4 Instruction Details ANL: And Load ANL 2 Connects in series blocks made of one or more contacts. : Example 0000 0001 0002 0003 0500 ANL Coding Line No. Instruction Operand 0000 LD 0000 0001 OR 0002 0002 LD 0001 0003 OR 0003 0004 ANL 0005 OUT 0500 12 Description 0000 The above example shows a serial connection between Block A 0002 0001 and Block B series. 0003 .
ANL 2.4 Instruction Details Applications of ANL Instruction 0000 0002 0004 0001 0003 0005 0500 Coding (1) • 2 • Coding (2) Line No. Instruction Operand Line No.
ORL 2.4 Instruction Details ORL: Or Load ORL Connects in parallel blocks made of one or more contacts. : 3 Example 0000 0001 0002 0003 0050 ORL Coding Line No. Instruction Operand 0000 LD 0000 0001 AND 0001 0002 LD 0002 0003 AMD 0003 0004 ORL 0005 OUT 0500 Description The above example shows a parallel connection of Block A and Block B parallel. 0002 0003 0000 0001 12 .
ORL 2.4 Instruction Details Applications of ORL Instruction 0000 0001 Block 0002 0003 Block 0004 0005 Block 0500 Coding (1) 2 • • Coding (2) Line No. Instruction Operand Line No.
OUT / OUB 2.4 Instruction Details OUT: Out OUB: Out Bar OUT A OUB B : nnnn : nnnn Outputs ON/OFF status of input to relay coil. Outputs inverted ON/OFF status of input to relay coil. Example 0500 0000 0501 Coding Line No. Instruction 0000 LD Operand 0000 0001 OUT 0500 0002 OUB 0501 Description • When input relay 0000 turn ON, output relay 0500 turns ON and output relay 0501 turns OFF.
SET / RES 2.4 Instruction Details SET: Set SET : nnnn SET RES: Reset RES : nnnn RES 1 0 Example Turns ON specified relay when input is ON and enables this relay to remain ON. Turns OFF specified relay, timer, or counter when input is ON. 0000 0500 SET 0001 0500 RES Coding Line No. Instruction Operand 0000 LD 0000 0001 SET 0500 0002 LD 0001 0003 OUB 0500 Description • Output relay 0500 remains ON after input relay 0000 turns OFF.
TMR 2.4 Instruction Details TMR: 0.1-s Timer TMR ( T) Sets a 16-bit on-delay timer that counts down in 0.1-s decrements. #ddddd Txxx : Example 0000 #00010 T000 Preset value: 1 s #00035 T001 Preset value: 3.5 s T000 0500 T001 0501 Coding Line No. 0000 0001 0002 0003 0004 0005 0006 Instruction LD TMR TMR LD OUT LD OUT Operand 0000 000 #00010*1 001 #00035*2 T000 0500 T001 0501 *1 0.1 s x 10 = 1 s *2 0.1 s x 35 = 3.
TMH 2.4 Instruction Details TMH: 0.01-s Timer FUN LDB 4 OR 9 Sets a 16-bit on-delay timer that counts down in 0.01-s decrements. #ddddd T Txxx H : Example 0000 #00010 T T000 H T000 0500 Coding Line No. Instruction 0000 LD Operand 0000 0001 TMH 000 #00010*1 0002 LD T000 0003 OUT 0500 *1 0.01 s x 10 = 0.1 s Description • • 2 • 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.
TMS 2.4 Instruction Details TMS: 1-ms Timer ANB SET FUN 5 1 Sets a 16-bit on-delay timer that counts down in 0.01 ms decrements. #ddddd T Txxx S : Example 0000 #00100 T T000 S T000 0500 Preset value: 0.1 s Coding Line No. Instruction 0000 LD Operand 0000 0001 TMS 000 #00010*1 0002 LD T000 0003 OUT 0500 *1 0.001 s x 100 = 0.1 s Description • • • 0500 and 0501 turn ON 0.1-s after 0000 turns ON. TMS is a subtraction timer.
TMR 2.4 Instruction Details Applications of TMR instruction ■ One-shot circuit When input relay 0000 turns ON, output relay 0500 turns ON and remains ON for a specified time. #00020 T000 0000 T000 0500 2 sec. 0500 Timing diagram ON OFF 0000 ON ON 2 sec. 2 sec. 0500 Coding 2 Line No. Instruction 0000 LD Operand 0000 0001 OR 0500 0002 TMR 000 #00020 0003 ANB T000 0004 OUT 0500 ■ Off-delay circuit When input relay 0000 turns ON, output relay 0500 turns ON.
TMR 2.4 Instruction Details ■ On-delay circuit Output relay 0500 turns ON in a specified time after input relay 0000 turns ON. When input relay 0000 turns OFF, output relay 0500 also turns OFF. 0000 #00020 T000 T000 0500 2 sec. Timing diagram ON OFF 0000 ON 0500 1s 2s Coding Line No. Instruction 0000 LD Operand 0000 0001 TMR 000 #00020 0002 LD T000 0003 OUT 0500 12 ■ Flicker circuit Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
C 2.4 Instruction Details CTR (C) C: Counter #ddddd Cxxx nnnn : Sets a 16-bit up-counter. Example Reset input Preset value #00010 C000 0000 0500 Counter No. Line No.
C 2.4 Instruction Details Details of counter ■ Extended ladder • The counter for the KV Series supports the extended ladder method. KV counter 0001 • #00010 C005 0000 2007 The extended ladder allows you to connect contacts or output coils after the counter in series, reducing the number of ladder program lines. In the following example, the counter starts counting when counter input relay 0004 turns ON. When the current counter value reaches "300", output relay 0500 turns ON.
C 2.4 Instruction Details 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. Special utility relay (1-second clock) #03600 C002 2006 0500 0000 C002 Coding Line No. Instruction Operand 0000 LDB 0000 0001 C 002 #03600 2006 0002 LD C002 0003 OUT 0500 ➮ "1.3.7 Special Utility Relays" (p.
C 2.4 Instruction Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 Instruction LDB C LD LDA CON MPS CMP CON ANB OUT Operand 0002 002 #09999 0000 2002 C002 #01000 2009 0500 Line No.
UDC 2.4 Instruction Details UDC: Up-Down Counter : ANB ANL FUN 5 2 UDC xxx UP DW #ddddd RES Sets a 16-bit up-down-counter. Example UP input UDC 000 0001 UP DOWN input #00009 0002 DW RESET input 0003 RES 0500 C000 Coding Line No.
UDC 2.4 Instruction Details Application of UDC instruction ■ Multi-level UP/DOWN counter UP/DOWN counter which allows a count setting value up to 99,990,000. UDC 000 0001 UP #09999 BCD Low-order 4 digits 0002 DW 0003 RES C000 UDC 001 0001 UP #09999 C000 BCD High-order 4 digits 0002 DW 0003 RES Up-input 0001 Down-input 0002 Coding Line No.
DIFU / DIFD 2.4 Instruction Details SET RES : nnnn DIFU RES OR : nnnn DIFD DIFU: Differentiate Up FUN 1 DIFD: Differentiate Down: FUN 0 0 9 Detects rising edge of input signal and turns ON specified relay for 1st scan time only. Detects falling edge of input signal and turns ON specified relay for 1st scan time only. Example 1000 DIFU 0000 1001 DIFD Coding Line No.
DIFU / DIFD 2.4 Instruction Details 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 oneshot (1 second). Coding 1000 DIFU 0000 1001 DIFD 1000 0500 T001 #00010 T001 0500 1001 0501 T002 #00010 T002 0501 Line No.
KEEP 2.4 Instruction Details KEEP: Keep ORL O R FUN 3 : 9 Turns ON specified relay when SET input relay turns ON and enables this relay to remain ON. And, turns OFF specified relay when RESET input relay turns ON. KEEP SET nnnn RES Example KEEP 0001 SET input SET 0500 0002 RES RESET input Coding Line No. 0000 0001 0002 Instruction LD DIFU DIFD Operand 0000 1000 1001 Description • • • 2 When SET input relay No. 0001 is ON and RESET input relay No. 0002 is OFF, 0500 turns ON.
KEEP 2.4 Instruction Details 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 are missing, 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.
SFT 2.4 Instruction Details SFT: Shift ORL O R FUN 3 9 : SFT D nnnn CLK RES mmmm Sets a shift register. Example Data input SFT 0001 Relay shift operation D 1000 0002 First relay No. CLK Clock 1002 0003 Last relay No. RES RESET input 0500 1002 Coding Line No.
SFT 2.4 Instruction Details Operands * Visual KV KV-300 KV-10/16 KV-24/40/80 1000 to 1915 3000 to 6915 1000 to 1915 3000 to 6915 *7000 to 9915 1000 to 1915 1000 to 1915 3000 to 6915 Note that of I/O Nos. 7000 to 9915, those that are not assigned to expansion or remote I/O unit ports can be used for internal utility relays. Key operation FUN ORL OR 3 9 ENT Operand Operand ENT R-SRCH (Relay No.) (Relay No.
SFT 2.4 Instruction Details ■ Resetting internal utility relays When input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915 turn OFF. SFT instruction can be substituted for RES instruction. This application can be used to reset many relays at one time. (All relays 3000 through 9915 can also be turned OFF at one time.) Coding SFT 2003 D 1000 2003 CLK 1915 0000 Line No.
SFT 2.4 Instruction Details ■ Asynchronous shift register Turns ON input relay 0002 to reset the shift register (1000 to 1010) when the data input to 0000 does not synchronize with the clock input to 0001. 0000 1100 DIFU 1100 1000 SET SFT 2003 D 1000 0001 CLK 1010 0002 Coding Line No.
HSP 2.4 Instruction Details HSP: High Speed SET AND FUN 1 8 : Shortens time constant of specified input relay to 10 µs to increase input response. HSP nnnn Example Enable input 0000 HSP 0001 0001 0500 SET 0002 0501 SET 0003 0500 RES 0501 RES Coding 2 Line No.
HSP 2.4 Instruction Details Note 3: The HSP instruction must be specified when the INT instruction or highspeed counter is used. Note 4: When special utility relay 2813 and HSP instruction turn ON at the same time, priority is given to the HSP instruction and the time constant is changed to 10 µs. Note 5: Connect a non-contact input for the HSP instruction to prevent a contact bounce from being entered. Details of HSP Instruction This section describes the operation of the HSP instruction.
HSP 2.4 Instruction Details 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 and input relay 0001 is ON, fetches data from input relay 0000 at high speed and outputs 1-s one-shot pulse from output relay 0500. Coding HSP 0000 0001 1-s timer #00010 T000 0000 0500 0500 T000 Turns ON timer for 1s when 0500 is ON. Line No.
MC / MCR 2.4 Instruction Details MC: Master Control MCR: Master Control Reset ANL LDB : MC ANL ANB : MCR FUN 2 FUN 2 4 5 Selects ON/OFF status of relay coils, timers, or counters set before MCR instruction. Used in pairs with MC instruction to end the execution of MC instruction. Example 0000 MC 0001 0500 0501 MCR Coding Line No.
MC / MCR 2.4 Instruction Details Details of MC-MCR Instructions ■ Position of MC-MCR instructions MC-MCR instructions can be used in the following positions. 1. MC-MCR instructions can be placed before or after STP-STE instructions. 2. MC-MCR instructions can be placed between STP and STE instructions. 3. STP-STE instructions can be placed between MC and MCR instructions.
MC / MCR 2.4 Instruction Details 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 ON when 0002 is ON, and 0502 turns ON when 0003 is ON.
MEMSW 2.4 Instruction Details MEMSW: Memory Switch FUN ANL ORB 2 6 : MEMSW $nnnn Sets memory switches. Key operation FUN ANL 2 ORB 6 ENT R-SRCH Operand ENT R-SRCH Operands $0000 to $FFFF Example MEMSW $3800 Coding • Line No. Instruction Operand 0000 MEMSW $3800 Specify 3 of SW3 and 0 and 1 of SW4 to reset the values of DM1900 to DM1999, counter, up-down counter, CTH, and CTC when the operation is started. Description Switch Nos. and functions are as follows.
MEMSW 2.4 Instruction Details Note 1: When a read-protected program is transferred into the KV PLC it cannot be read or modified from this PLC. Before read-protecting a program, be sure to create a backup copy of the program. Note 2: When a 24-bit high-speed counter comparator is used, the ladder program which specifies the numerical values of a 24-bit CTC is required before starting the high-speed counter. Note 3: The value of MEMSW can be changed even during operation.
END / ENDH NOP 2.4 Instruction Details NOP: No Operation ORL RES FUN 3 0 : Performs no operation. When ALL CLEAR [FNC60] or HANDHELD PROGRAMMER CLEAR (P3E CLEAR) [FNC61] is executed to delete the program, NOP appears on all lines of the deleted program. NOP is not written by the KV IncrediWare (DOS)/LADDER BUILDER for KV programming support software. END DM END: End ENDH TM ENDH: End Hi END : Indicates end of each routine of program. ENDH : Indicates end of entire program.
2.4 Instruction Details 2.4.2 Application Instructions Application instructions are used for batch processing of input signals. Data is transmitted to specified memory locations or changed into different formats. Moreover, parts of a program can be repeated or skipped with the instruction.
W-ON / W-OFF 2.4 Instruction Details W-ON: Wait ON W-OFF: Wait OFF W-ON F : nnnn ON mmmm W-OFF Li : nnnn OFF mmmm Turn ON second operand relay when first operand relay contact turns ON. Turns ON second operand relay when first operand relay contact turns OFF. Example 0001 ON 1000 0500 0000 1000 0003 OFF 1001 0501 0002 1001 W-ON W-OFF Coding 2 Line No.
W-ON / W-OFF 2.4 Instruction Details Description W-ON Input operand 0000 Same operation 0001 ON 1000 0001 0000 1000 1000 Output operand • When input relay 0000 is ON, output operand 1000 turns ON as soon as the contact of input operand 0001 turns ON. W-OFF Input operand 0002 Same operation 0003 OFF 1001 0003 0002 1001 1001 Output operand • When input relay 0002 is ON, output operand 1001 turns ON as soon as the contact of input operand 0003 turns OFF. Note: Output operand relay Nos.
W-UE / W-DE 2.4 Instruction Details W-UE: Wait Up Edge W-DE: Wait Down Edge W-UE E : W-DE Lo : Turns ON second operand relay at rising edge of first operand relay contact. Turns ON second operand relay at falling edge of first operand relay contact. nnnn mmmm nnnn mmmm Example 0000 0001 1000 1000 0500 0002 0003 1001 1001 0501 W-UE W-DE Coding Line No.
W-UE / W-DE 2.4 Instruction Details Description W-UE 0000 Input operand Same operation 0001 1000 1002 DIFU 0001 1002 0000 1000 1000 Output operand • When input relay 0000 is ON, the output operand turns ON at the rising edge of the input operand. W-DE 0002 Input operand Same operation 0003 1001 1003 DIFD 0003 1003 0002 1001 1001 Output operand • When input relay 0002 is ON, the output operand turns ON at the falling edge of the input operand.
W-UE / W-DE 2.4 Instruction Details Details of W-ON and W-UE Instructions A combination of W-ON, W-OFF, W-UE, and W-DE instructions is much more effective when used in programs controlling sequential operation where the completion of one operational step starts the next step. This section describes minute differences in the operation of these instructions.
W-UE 2.4 Instruction Details Application of W-UE Instruction ■ Input sequence check Output relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and 0003 turn ON in this sequence. Output relay 0500 turns OFF when input relay 0000 is OFF. Coding 0000 0001 1000 1000 0002 Line No.
CON 2.4 Instruction Details CON: Connect RES ORB FUN 0 6 Represents series connection of output instruction with another instruction. : Example 0500 0000 0501 CON CON 0502 0503 CON Coding Line No. Instruction 0000 LD 0000 0001 OUT 0500 0002 CON 0003 OUT 0004 CON 0005 OUT 0006 CON 0007 OUT Operand 0501 0502 0503 Description • • • 2 • When input relay 0000 turns ON, 0500, 0501, 0502, and 0503 turn ON.
MPS / MRD / MPP 2.4 Instruction Details MPS: Push MPS C : MRD: Read MRD D : MPP: Pop MPP ch : Stores current input and arithmetic flag status. Reads input and arithmetic flag status stored with PUSH. Reads and clears input and arithmetic flag status stored with PUSH. Example 0000 MPS 0001 0500 0002 0501 0003 0502 MRD MPP Coding Line No.
MPS / MRD / MPP 2.4 Instruction Details MPS/MRD/MPP applications MPS, MRD, and MPP instructions are used as follows: 0002 0003 0004 0500 Start of branch 0006 MPS 0501 Connection of branch 0007 MRD 0502 Connection of branch 0008 MRD 0503 End of branch MPP Coding 2 Line No. Instruction Operand Line No.
MPS / MRD / MPP 2.4 Instruction Details 0000 MPS 0001 MPS 0002 MPS 0003 0004 0500 MPS 0501 MPP 0502 0503 MPP 0504 MPP MPP Coding Line No. Instruction Operand 0000 LD 0000 0001 MPS 0002 AND 0003 MPS 0004 AND 0005 MPS 0001 0002 0006 AND 0007 MPS 0008 AND 0004 0009 OUT 0500 0010 MPP 0011 OUT 0012 MPP 0013 OUT 0014 MPP 0015 OUT 0016 MPP 0017 OUT 0003 12 0501 0502 0503 0504 Chapter 2 Instructions KVNKA Chap 02_4bP.p65 105 08.3.
STG / JMP / ENDS 2.4 Instruction Details STG: Stage LDB LDB FUN 4 JMP: Jump : nnnn STG ANL SET : nnnn JMP SET LDB : ENDS FUN 2 ENDS: End Stage 4 FUN 1 1 4 Executes instructions in STG block when operand relay is ON. When transition condition relay is ON, turns OFF relay of current stage and transfers execution to stage specified by operand. When transition condition relay is ON, turns OFF relay of current stage.
STG / JMP / ENDS 2.4 Instruction Details Note 1: The following table shows the status of each instruction between STG and JMP/ENDS when STG operand relay turns OFF. Instruction Function Relay for OUT instruction Turned OFF. Relay for OUB instruction Turned ON. TMR, TMH, TMS, C (counter) instructions Reset. SET, RES instructions Current status is retained. Other instructions Not executed. Note 2: STG/JMP/ENDS operand relay Nos. cannot be duplicated in a program.
STG 2.4 Instruction Details 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 is assigned to each step. The process to turn on several lamps sequentially can be divided into the following five steps: 1) 2) 3) 4) 5) Wait until the start switch is turned ON. Turn on lamp 1 for 1 second. Turn on lamp 2 for 3 second. Turn on lamp 3 for 5 second.
STG 2.4 Instruction Details ■ Sequence program Assign the relays to execute the five processes on the previous page as follows: 1 2 3 4 5 Wait until the start switch is turned ON.: Turn on lamp 1 for 1 second.: Turn on lamp 2 for 3 second.: Turn on lamp 3 for 5 second.: Turn on lamps 1, 2, and 3 simultaneously: for 7 seconds.
STG 2.
STG 2.4 Instruction Details Cautions for using STG instruction Interlock When an STG instruction moves to another stage, the previous and next stages turn ON simultaneously only for one scan. Provide an interlock circuit for the output which may be dangerous when turned ON in such occasions (e.g., motor's normal/ reverse rotation). 1000 STG 0501 0500 0001 1001 JMP 1001 STG 0500 0501 0002 1002 JMP Interlock Double coil A double coil can be used for an STG instruction.
STG / JMP 2.4 Instruction Details JMP operand Unlike the STG operand relay, the JMP operand relay No. can be duplicated in a program. 1000 STG 0001 0500 1001 JMP 1002 JMP 1001 STG 0002 0501 1002 JMP DIFU/DIFD instructions in an STG block The operand relay for an STG instruction cannot be used as the input operand relay for a DIFU or DIFD instruction.
STG / JMP 2.4 Instruction Details Note: The double coils in different STG instruction blocks operate properly. However, when several STG instructions turn ON simultaneously, priority is given to the one programmed last. ■ Conditional branching When input relay 0000 (start SW) turns ON, output relay 0500 turns ON. Then, as programmed for conditional branching, output relay 0501 turns on for 1 second when 0001 turns ON, and 0502 turns ON for 2 seconds when 0002 turns ON.
STP / STE 2.4 Instruction Details LDB ANB : LDB ORL : FUN 4 STP: Step STE: Step End FUN 4 5 3 Executes instructions between STP and STE when operand relay is ON. STP nnnn STE Used with STP to make a program step. Example 1000 0000 STP 1000 0500 0001 STE Coding 2 Line No. Instruction 0000 LD Operand 0000 0001 OUT 1000 0002 STP 1000 0003 LD 0001 0004 OUT 0500 0005 STE Description • When 1000 is ON, 0500 turns ON/OFF as soon as 0001 turns ON/OFF.
STP / STE 2.4 Instruction Details Tips ■ Operation when STP turns OFF Using a timer in an STP block When a timer is used in a program defined with an STP instruction, the operation is as follows: a) 1000 is reset immediately when the timer turns ON. The STE instruction is started with the timer remaining ON. a) 0000 Scan 1000 SET STP 1000 T000 0500 1000 #00050 T000 T000 1000 RES Timer remains ON.
STP / STE 2.4 Instruction Details Operands * Visual KV KV-300 KV-10/16 KV-24/40/80 0000 to 17915 T000 to T249 C000 to C249 CTC0 to CTC3 0000 to 0009 0500 to 6915 *7000 to 9915 T000 to T249 C000 to C249 CTC0 to CTC3 0000 to 2915 T000 to T063 C000 to C063 CTC0 to CTC3 0000 to 6915 T000 to T119 C000 to C119 CTC0 to CTC3 Note that of I/O Nos.7000 to 9915, those that are not assigned to expansion or remote I/O unit ports can be used for internal utility relays.
ITVL 2.4 Instruction Details ITVL #TM ITVL: Interval Timer : ITVL PLS DMnnnn PAUSE mmmm RES Example Measures pulse-to-pulse interval or pulse width in specified mode. "Pulse" input ITVL PLS 0000 Beginning of workpiece data table "Measurement Pause" input First flag relay DM0000 0001 PAUSE 1000 0002 RES "Reset" input Coding Line No.
ITVL 2.4 Instruction Details Setting procedure The ITVL instruction reserves 16 data memories: 1 specified data memory and 15 successive data memories. It also reserves 4 relays: 1 specified relay and 3 successive relays. Note: Do not use the 16 data memories and 4 relays specified with the ITVL instruction for any other purpose. ■ Data memory (DM) assignment • Set the initial setting data to the first four data memories. Data memory DM XX + 00 01 Mode Specifies measurement mode (0 to 5).
ITVL 2.4 Instruction Details ■ Mode setting Write the desired mode No. into the first data memory. Mode for pulse measurement Pulse-to-pulse interval measurement Pulse-to-pulse Unit interval Mode Pulse width measurement Mode Pulse width Unit 0 10 m sec 1 10 m sec 2 100 m sec 3 100 m sec 4 1 sec 5 1 sec Mode for DM measurement Write the desired mode No. into the specified data memory. Example Write "#0006" to obtain the average of the contents of DM0006. Mode No. DM No.
ITVL 2.4 Instruction Details Application of ITVL instruction This 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 the range of 490 to 510 ms. 2008 #00000 DM0000 Sets mode 0 (Unit:10 ms). LDA STA 2008 #00051 DM0001 Sets max. setting value of measurement range to 510 ms. LDA STA 2008 #00049 DM0002 Sets min. setting value of measurement range to 490 ms.
ITVL 2.4 Instruction Details ■ 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 KL4AD. 2008 #01600 DM0000 LDA STA 2008 #02000 DM0001 Sets max. setting value to +3 V (2000). LDA STA 2008 #01000 DM0002 Sets min. setting value to +2 V (1000).
CALL / SBN / RET 2.4 Instruction Details RES RES CALL: Subroutine Call FUN 0 0 : AND SBN: Subroutine Entry FUN ORL 3 8 : RET: Subroutine Return ORL ORL FUN 3 3 nn CALL SBN nn RET : Executes subroutine specified by operand. Represents beginning of subroutine specified by operand. Represents end of subroutine. Example 0000 00 CALL END SBN 00 RET ENDH Coding Line No.
CALL / SBN / RET 2.4 Instruction Details Application of subroutine Program A) 00 CALL 2008 Normal scan Program B) END SBN 00 Subroutine program Subroutine RET ENDH When CALL00 is encountered during normal scan execution, the subroutine is executed. At the completion of this subroutine, program execution returns to program at B) immediately following CALL00. Then, the normal scan is continued until an END instruction is encountered.
CALL / SBN / RET 2.4 Instruction Details ■ 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. 0500 0001 Program END SBN 00 Subroutine program RET INT 0000 0002 00 CALL Call RETI ENDH Note 1: Subroutine Nos. for SBN instructions cannot be duplicated in a program. (It can be duplicated for CALL instructions.
FOR / NEXT 2.4 Instruction Details SET ORB FOR: Repeat Start FUN 1 ANL OR NEXT: Repeat End FUN 2 9 FOR nnnn : 6 NEXT : Executes program between FOR and NEXT by number of times specified by operand. Represents end of repetition. Example 2008 00 CALL END SBN 00 #00100 LDA 2002 TM02 STA Specify the first DM No.(DM100) Specify the number of DMs to be initialized. #TM02 2002 STA #00000 LDA FOR #00050 TM02 INC NEXT RET 12 ENDH Coding Line No. Instruction Operand Line No.
FOR / NEXT 2.4 Instruction Details Tips Note 1: The FOR-NEXT instruction pair repeats the program for a specified time period at each scan. It usually is used in steps or subroutines. Note 2: When a large number of loops or long programs are defined between FOR and NEXT instructions, the processing time for one scan may become too long, resulting in "Cycle time error". In such a case, reduce the number of loops or shorten the ladder program.
FOR / NEXT 2.4 Instruction Details Indirect addressing ■ Indirect addressing Indirect addressing is used to so you don't have to use fixed data memories or relay Nos. when the contents of data memory or a relay is stored in internal registers, or when the contents of the internal memory is stored in data memory or a relay. ■ Method for indirect addressing • Specify the operand for instructions as "#TMxx". The contents of "TMxx" is considered to be the specification No. (indirect addressing).
FOR / NEXT 2.4 Instruction Details ■ Data memory block transfer The contents of DM0000 are transferred to DM0100. DM0000 •••••• The block of 100 data is transferred. Transfer a block of data. DM0099 DM0100 The contents of DM0099 are transferred to DM0199. •••••• DM0199 • Comparison between a program with normal addressing and one with indirect addressing.
FOR / NEXT 2.4 Instruction Details Description • • • On line 1), "TM02" is assigned to the first No. of the source 0000 and "TM03" is assigned to the first No. of the destination 0100. This is the initial setting. On lines 2) to 4), the contents of DM0000 to DM0099 are transferred to DM0100 to DM0199. The ladder program on line 3) is executed 100 times in one scan. 1st operation: TM02 value: 0000, TM03 value: 0100 2002 #TM02 LDA #TM03 STA DM0000 is indirectly addressed.
FOR / NEXT 2.4 Instruction Details 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 rising edge of the synchronous (timing) signal. As the number of DMs to be shifted increases, the required scan time becomes longer. 0000 1000 DIFU Synchronous signal #00010 TM02 LDA STA Shift start DM No. (DM0010) is designated. 1000 #00030 TM03 LDA STA Shift end DM No. (DM0030) is designated.
HKEY 2.4 Instruction Details HKEY: 16-Key Input SET LD FUN 1 7 Reads hexadecimal key data on timesharing basis and outputs these data to special utility relays 2900 to 2915. HKEY nnnn mmmm : Input relay Example HKEY 0000 0500 0005 Output relay Coding Line No. Instruction 0000 LD Operand 0005 0001 HKEY 0000 0500 Description • • When input relay 0005 turns ON, the operand hexadecimal key data is read. HKEY instruction employs four inputs and four outputs arranged as shown below.
HKEY 2.4 Instruction Details Note 4: When two or more keys are pressed simultaneously even once during the scan while relay 2814 is ON, relays 2900 through 2915 keep the current status as soon as relay 2815 turns ON. Note 5: The HKEY instruction does not properly operate if the scan time is longer than 200 ms. Note 6: When the expansion I/O module is used as an operand, the fetch may fail unless the scan time is fixed to 2 ms or longer.
HKEY 2.4 Instruction Details 100 101 102 103 BCD Digital switch Diode 24 VDC + COM 1 0104 - COM 0512 2 0105 KV 0513 4 0106 8 0107 0514 0515 ■ 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.
2.4 Instruction Details 2.4.3 Arithmetic Instructions Arithmetic instructions handle data as integers to perform arithmetic, comparative, or logical operations.
2.4 Instruction Details Internal register KV executes all arithmetic instructions (i.e. data exchange) by using an internal register, in order to increase the processing speed. This section begins by describing details of the internal register. ■ Internal register An internal register stores 16-digit binary data. That is, the resister uses 16 bits for storing ON-OFF status data (1-0 status data). The internal register is required when the KV performs arithmetic operation.
DW 2.4 Instruction Details DW: Data Memory Write DW : nnnn DW DMmmmm Directly writes constant into data memory. Example First operand 2008 $0018 #00050 DW DW DM0000 DM0001 Second operand Coding Line No. Instruction 0000 LD Operand 2008 0001 DW $0018 DM0000 0002 CON 0003 DW #00050 DM0001 • When starting operation, $0018 is written into DM0000 and #00050 into DM0001. • Values are directly written into data memories, without using the internal register.
@xxxx 2.4 Instruction Details @ @xxxx: Differentiation : #,$ FUN xxxx Executes instruction only at rising edge of input to input relay. Example Every-scan type instruction Differentiation type instruction DM0000 INC 0000 DM0000 INC 0000 Description • • • Arithmetic instructions have two instruction types: differentiation type and everyscan type. The differentiation type instruction is executed only at the rising edge of input relay 0000.
TMIN / @TMIN 2.4 Instruction Details ANB RES TMIN: Trimmer In FUN 5 @ @TMIN: Trimmer Setting #,$ FUN 0 ANB RES 5 0 : n TMIN : n TMIN Inputs numerical value specified by digital trimmer of access window (0 to 65535) to internal register. T000 preset value can be changed with trimmer as follows (#00000 to #65535): Inputs trimmer rotation angle of 0 to internal register. Transfers contents of internal register to timer T000 for use as preset value.
TMIN / @TMIN 2.4 Instruction Details 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.5 sec.). 0 TMIN 2002 T000 STA #00010 T000 0000 T000 0500 0500 Coding Line No. 0000 0001 0002 0003 0004 Instruction LD TMIN CON STA LD Operand 2002 0 T000 0000 Line No.
LDA / @LDA / STA @STA 2.4 Instruction Details ANL ORL nnnn LDA ANL ORL @ 3 #,$ FUN 2 nnnn LDA LDB ORL nnnn STA FUN 2 LDA: Load A @LDA: Load A STA: Store A 3 FUN 4 @ @STA: Store A 3 #,$ FUN Transfers contents of internal register to destination specified by operand. nnnn STA LDB ORL 4 Inputs value specified by operand to internal register. 3 The LDA instruction inputs each data item to the internal register.
LDA / @LDA / STA @STA 2.4 Instruction Details Arithmetic flag 2009 2010 No change Turns ON when the contents of the internal register is "0" after "LDA #00000" is executed. Turns OFF at other times. No change Turns ON when the DM or relay indirectly addressed with #TM is out of range. 2011 2012 ➮ "Indirect addressing" (p.
LDA / @LDA / STA @STA 2.4 Instruction Details ■ Transferring the current counter value to data memory (DM) #09999 C010 0000 DM0000 STA 0001 2002 a) C010 LDA The C010 current value is transferred to DM0000. Coding Line No. Instruction 0000 LDB Operand 0001 0001 C 010 #099999 0000 0002 LD 2002 0003 LDA C010 0004 CON 0005 STA DM0000 Description In step a), the C010 current value is transferred via the internal register and stored into DM0000, throughout the operation.
LDA / @LDA / STA @STA 2.4 Instruction Details ■ Outputting the input (ON/OFF status) of a basic unit directly to an expansion output unit The ON/OFF status of a KV series basic unit is output to a KV-E16T(P) unit connected next to the basic unit. 0000 LDA 2002 0600 STA Coding Line No.
LDA / @LDA / STA @STA 2.4 Instruction Details ■ When a BCD (2-digit) digital switch is connected to inputs 0000 through 0007 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 BCD output. Coding 0008 a) 0010 0000 LDA 0011 C001 LDA b) 2 $00FF ANDA TBIN TBCD 0500 STA #09999 C001 0009 C001 STA Line No.
LDA / @LDA / STA @STA 2.4 Instruction Details Note 3: When an STA instruction is executed while the setting value of a counter or a timer is smaller than the current value, the current value is changed to be the setting value. ■ First-in first-out (FIFO) The data once fetched is written into DM0004, DM0003, …, to DM0000 in this order. At the unloading timing, data is fetched from DM0004 and the contents of DM are shifted to the next DM.
CMP / @CMP 2.4 Instruction Details RES LDB CMP: Compare FUN 0 @CMP: Compare 4 RES LDB @ #,$ FUN 0 4 : nnnn CMP : nnnn CMP Compares contents of internal register with value specified by operand. CMP instruction compares the contents of the internal register with the value specified by the operand, and turns ON/OFF the special utility relays (2009, 2010, 2011) according to the result of comparison.
CMP / @CMP 2.
CMP / @CMP 2.4 Instruction Details Application of CMP instruction ■ Multi-level counter Coding 0001 2002 C000 LDA #00999 CMP 2011 #01999 CMP 2011 0500 #02999 CMP 2011 0500 0501 #09999 C000 0000 0500 Line No.
CMP / @CMP 2.4 Instruction Details ■ Setting the upper/lower limit Turns ON 0500 when the C001 value is 1000 or less. Turns ON 0501 when the C001 value is 2000 or more. 0001 2002 2002 C001 LDA #01000 CMP 2011 C001 LDA #02000 CMP 2009 #09999 C001 0000 0500 C001≤#01000 0501 C001≥#02000 Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 Instruction Operand LDB 0001 C 001 #09999 0000 LD 2002 LDA C001 CON CMP #01000 CON ANB 2011 Line No.
ADD / @ADD / SUB / @SUB / MUL / @MUL / DIV / @DIV 2.4 Instruction Details RES RES ADD: Add FUN 0 @ADD: Add SUB: Subtract : LDB ORB : nnnn SUB LDB ORB @ #,$ FUN 4 6 : nnnn SUB ANL AND MUL: Multiply : nnnn MUL : nnnn MUL : nnnn DIV : nnnn DIV FUN 2 @ @MUL: Multiply #,$ FUN 6 8 ANL AND 2 8 SET SET DIV: Divide FUN 1 @ @DIV: Divide #,$ FUN 1 SET SET 1 1 Adds value specified by operand to contents of internal register, and inputs result back to same internal register.
ADD / @ADD 2.4 Instruction Details ADD (Addition) DM0000 #00100 DM0001 LDA ADD STA 2002 Coding Line No. Instruction 0000 LD 2002 0001 LDA DM0000 0002 CON 0003 ADD 0004 CON 0005 STA Operand #00100 DM0001 Description • • • The ADD instruction adds the operand value to the contents of the internal register and inputs the result back to the internal register. In the above example, "#00100" is added to the contents of DM0000 and the result is stored in DM0001.
ADD / @ADD 2.4 Instruction Details Application of ADD instruction ■ Total count Writes the total count of counters C001 to C003 into DM0100. The total count must be within #65535. 0000 #09999 C001 LDA C001 0001 0000 #09999 C002 LDA C002 0002 0000 #09999 C003 LDA C003 0003 2002 DM0001 DM0002 DM0003 LDA ADD ADD DM0001 STA Writes C001 current value into DM0001. DM0002 STA Writes C002 current value into DM0002. DM0003 STA Writes C003 current value into DM0003.
SUB / @SUB 2.4 Instruction Details SUB (Subtraction) 2002 DM0000 #00100 DM0001 LDA SUB STA Coding Line No. Instruction 0000 LD 2002 0001 LDA DM0000 0002 CON 0003 SUB 0004 CON 0005 STA Operand #00100 DM0001 Description • • • The SUB instruction subtracts the operand value from the contents of the internal register and inputs the result back into the internal register. In the above example, "#00100" is subtracted from the contents of DM0000 and the result is stored in DM0001.
SUB / @SUB 2.4 Instruction Details Application of SUB instruction ■ Comparing absolute values Compares the DM0000 value to the DM0001 value and turns ON 0500 when the difference between the two absolute values is greater than 5. 2002 DM0000 DM0001 LDA SUB 2009 #0005 CMP 2009 1000 2009 DM0001 DM0000 #00005 CMP LDA SUB 2009 1001 0500 1000 1001 Coding 2 3-154 Line No.
MUL / @MUL 2.4 Instruction Details MUL (Multiplication) 2002 DM0000 #00100 DM0001 LDA MUL STA Coding Line No. Instruction 0000 LD 2002 0001 LDA DM0000 0002 CON 0003 MUL 0004 CON 0005 STA Operand #00100 DM0001 Description • • • The MUL instruction multiplies the contents of the internal register by the operand value and inputs the result back to the internal register. In the above example, the contents of DM0000 are multiplied by "#00100" and the result is stored in DM0001.
MUL / @MUL / DIV / @DIV 2.4 Instruction Details 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-order 16 bits of the product into DM0101 and low-order 16 bits of the product into DM0100. 0001 C001 LDA 2002 DM0000 DM0100 MUL STA TM00 LDA #09999 C001 0000 DM0101 STA Coding Line No.
DIV / @DIV 2.4 Instruction Details Arithmetic flag 2009 2010 2011 2012 No change Turns ON when all 32 bits are "0" after a DIV operation. Turns OFF at other times. No change Turns ON when the divisor of a DIV operation is "0" or the DM or relay indirectly addressed with #TM is out of range. ➮ "Indirect addressing" (p. 3-127) • The 32-bit value (binary) consisting of the higher 16 bits from TM00 and lower 16 bits from the internal register is divided by the value specified by the operand.
DIV / @DIV 2.4 Instruction Details Application of DIV instruction ■ Total count average Outputs the average of 3 counter values in 4-digit BCD. (C001 + C002 + C003) ÷ 3 ➞ BCD output value The BCD value is output to 500 to 515. 0000 0000 0000 2002 C001 #09999 LDA C001 0001 C002 #09999 LDA C002 0002 C003 #09999 LDA C003 0003 DM0001 DM0002 LDA ADD 2002 2002 #00003 DIV DM0001 STA Writes the C001 current value into DM0001. DM0002 STA Writes the C002 current value into DM0002.
ANDA / @ANDA 2.4 Instruction Details ANDA: AND A @ANDA: (Logical product) RES SET FUN 0 1 @ #,$ FUN RES SET 0 1 : nnnn ANDA : nnnn ANDA ANDs contents of internal register and value specified by operand for each of 16 bits, and inputs result back to same register. Example 0000 DM0000 LDA $00FF ANDA DM0001 STA (DM0000) ^ ($00FF) = (DM0001) Logical product Coding Line No.
ANDA / @ANDA 2.4 Instruction Details Arithmetic flag 2009 2010 2011 2012 ➮ No change Turns ON when the internal register is "0" after an ANDA operation. Turns OFF at other times. No change The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p.
ORA / @ORA 2.4 Instruction Details ORL SET FUN 3 ORA: Or A @ORA: (Logical sum) Example 1 ORL SET @ #,$ FUN 3 1 0000 DM0000 LDA $00FF ORA : nnnn ORA : nnnn ORA ORs contents of internal register and value specified by operand for each of 16 bits, and inputs result back to same register. DM0001 STA (DM0000) U ($00FF) = (DM0001) Logical sum Coding Line No.
ORA / @ORA 2.4 Instruction Details Arithmetic flag 2009 2010 2011 2012 ➮ No change Turns ON when the internal register is "0" after an ORA operation. Turns OFF at other times. No change The DM or relay indirectly addressed with #TM is out of range. "Indirect addressing" (p.
ORA / @ORA 2.4 Instruction Details ■ Separate input of 2-digit BCD Fetches only 2 digits of the BCD digital switch (0000 to 0003 for the 1st digit, 0100 to 0103 for the 2nd digit) and sets it as the counter value. 0000 0000 LDA #00099 C000 0001 $000F DM0000 ANDA STA 2002 0100 LDA $000F ANDA 2002 #04 SLA DM0000 ORA 2002 Sets C001. Writes data of 7000 to 7003 into DM0000. Writes data of 8000 to 8003 into internal register.
EORA / @EORA 2.4 Instruction Details EORA: Exclusive Or A @EORA: (Exclusive logical sum) SET ANB FUN 1 5 SET ANB @ #,$ FUN 1 5 : nnnn EORA : nnnn EORA EXCLUSIVE ORs contents of internal register and operand for each of 16 bits, and inputs result back to same register. Example 0000 DM0000 LDA $00FF EORA DM0001 STA (DM0000) U ($00FF) = (DM0001) Exclusive logical sum Coding Line No.
EORA / @EORA 2.4 Instruction Details Arithmetic flag 2009 No change 2010 Turns ON when the internal register is "0" after an EORA operation. Turns OFF at other times. 2011 No change 2012 The DM or relay indirectly addressed with #TM is out of range. ➮ "Indirect addressing" (p. 3-127) Tips Turning output 0500 ON when inputs 0000 through 0015 have the same value as a constant ($0F0F) When the values match, special internal relay 2010 turns ON and output relay 0500 turns ON.
SRA / @SRA / SLA / @SLA 2.4 Instruction Details LDB SET FUN 4 SRA: Shift Right A @SRA: Shift Right A SLA: Shift Left A @SLA: Shift Left A @ #,$ FUN 1 LDB SET 4 1 : #dd SRA : #dd SRA #dd SLA LDB RES : LDB RES : FUN 4 0 FUN 4 @ #,$ Moves contents of internal register serially right by value specified by operand. 0 Moves contents of internal register serially left by value specified by operand.
SRA / @SRA / SLA / @SLA 2.4 Instruction Details Description • Operations using the SRA instruction When input relay 0000 is ON, the contents of DM0000 are transferred to the internal register and shifted serially right by the operand value (5). The operation result is written into DM0001. The contents of D0 are shifted to carry bit 2009. In the above example, the contents shift to the right by the operand value (5) every scan time while input relay 0000 is ON.
SRA / @SRA / SLA / @SLA 2.
RRA / @RRA / RLA / @RLA 2.4 Instruction Details : #dd RRA ORL LD @ #,$ FUN 3 7 : #dd RRA ORL ANB : #dd RLA : #dd RLA ORL LD RRA: Rotate Right A FUN 3 @RRA: Rotate Right A RLA: Rotate Left A FUN 3 @ @RLA: Rotate Left A #,$ FUN 7 5 ORL ANB 3 5 Rotates contents of internal register and carry (2009) clockwise by operand value. Rotates contents of internal register and carry (2009) counterclockwise by operand value.
SRA / @SRA / SLA / @SLA 2.4 Instruction Details Use @RRA, a differentiation type instruction, to execute the instruction only once when input relay 0000 turns ON. Carry 2009 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 Carry 2009 D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 • Operation using the RLA instruction When input relay 0001 is ON, the contents of DM0000 are transferred to the internal register.
COM / @COM 2.4 Instruction Details COM: Complement @COM: (Bit inversion) RES ANB : COM RES ANB @ #,$ FUN 0 5 : COM FUN 0 5 Inverts contents of each bit in internal register. Example DM0000 LDA 0000 COM DM0001 STA Coding Line No. 0000 0001 0002 0003 0004 0005 Instruction LD @LDA CON @COM CON @STA Operand 0000 DM0000 DM0001 Description • • • Each time input relay 0000 turns from OFF to ON, the contents of DM0000 are transferred to the internal register.
INC / @INC / DEC / @DEC 2.4 Instruction Details INC: Increment Memory @INC: Increment Memory DEC: Decrement Memory : nnnn INC SET OR @ #,$ FUN 1 9 : nnnn INC RES LD : nnnn DEC : nnnn DEC 9 FUN 0 @ @DEC: Decrement Memory Example SET OR FUN 1 #,$ FUN 7 RES LD 0 7 Adds 1 to contents of data memory specified by operand. Subtracts 1 from contents of data memory specified by operand. DM0000 INC 0000 DM0001 DEC Coding Line No.
INC / @INC / DEC / @DEC 2.4 Instruction Details Key operation FUN @ FUN #,$ FUN @ FUN #,$ SET OR 1 9 RES LD 0 7 ENT R-SRCH ENT R-SRCH Operand ENT Operand ENT R-SRCH R-SRCH Arithmetic flag 2009 Turns ON when the result is "0" after an INC operation, or when the result is "$FFFF (#65535)" after DEC operation. Turns OFF at other times. 2010 Turns ON when the internal register is "0" after an INC or DEC operation. Turns OFF at other times.
INC / @INC / DEC / @DEC 2.4 Instruction Details ■ Total count 1 Writes the total count of 4 lines (0000 to 0003) into DM0000. Reset input relay is 0005. 2008 #00000 DM0000 LDA STA Sets #00000 to DM0000 at startup. DM0000 INC Increments DM0000 by 1 at UP edge of input relay 0000. 0001 DM0000 INC Increments DM0000 by 1 at UP edge of input relay 0001. 0002 DM0000 INC Increments DM0000 by 1 at UP edge of input relay 0002. DM0000 INC Increments DM0000 by 1 at UP edge of input relay 0003.
INC / @INC / DEC / @DEC 2.4 Instruction Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 Instruction LD @INC LD @INC LD @INC LD @INC LD @INC LD Operand 0000 DM0000 0001 DM0000 0002 DM0000 0003 DM0000 0004 DM0000 0005 Line No.
MPX / @MPX / DMX / @DMX 2.4 Instruction Details MPX: #n MPX : #n MPX SET ANL : DMX SET ANL @ #,$ FUN 1 2 : DMX FUN 2 Demultiplexer 7 @ @MPX: (4-to-16 decoder), DMX: : ANL LD Multiplexer #,$ FUN ANL LD FUN 1 @DMX: (16-to-4 encoder) 2 7 2 Converts 4-bit data of internal register into 16-bit data. The 4-bit data to be converted is specified as operand. Converts position of most significant bit with 1 in internal register into 4-bit data.
MPX / @MPX / DMX / @DMX 2.4 Instruction Details Description Operation with the MPX instruction When input relay 0000 is ON, the ON/OFF status of input relays 0000 through 0015 is transferred to the internal register. The section of the internal register specified by the operand (input relays 0004 through 007: 4 bits) is converted into a hexadecimal number (0 to F). Only the bit at the position specified by the hexadecimal number is set to "1" and other bits are set to "0".
MPX / @MPX / DMX / @DMX 2.4 Instruction Details ■ DMX instruction Connect sensors 0 to 15 to input relays 0000 through 0015. Connect output relays 0500 through 0503 to the one-digit data of a BIN indicator. The sensors which are currently ON are shown by the BIN indicator. * Assume that several sensors do not turn on simultaneously. 2002 0000 LDA 0500 STA DMX When sensor 8 is ON, the indicator shows "8". ■ Output of error input No. in BCD Outputs the error sensor No.
MPX / @MPX / DMX / @DMX 2.4 Instruction Details Converts the counter value to 16-bit data using the MPX instruction. Auto-reset counter C000 #00009 C000 0000 C000 LDA #0 MPX 1000 STA Sends internal register data to output relays starting from 0600.
TBCD / @TBCD / TBIN / @TBIN 2.4 Instruction Details LDB LD TBCD: Transfer BCD FUN 4 @TBCD: Transfer BCD LDB LD 4 7 LDB AND TBIN: Transfer BIN FUN 4 @ @TBIN: Transfer BIN Example @ #,$ FUN 7 #,$ FUN 0000 0001 8 LDB AND 4 8 : TBCD : TBCD : TBIN : TBIN DM0000 LDA TBCD DM0001 STA DM0010 LDA TBIN DM0011 STA 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.
TBCD / @TBCD / TBIN / @TBIN 2.4 Instruction Details Description Operation using the TBCD instruction When input relay 0000 turns ON, the contents of DM0000 are transferred to the internal register. The contents of the internal register (16-bit binary data) are converted into 4-digit BCD data, which is input back to the internal register, and then transferred to DM0001. 216 20 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 Data is converted into BCD of "0" through "9999".
TBCD / @TBCD / TBIN / @TBIN 2.4 Instruction Details ■ Output of 8-digit BCD data Outputs the calculated product of DM0000 x DM0001 (0 to 99999999) in BCD of 8 digits at maximum as below: High-order 4-digit BCD data ➞ To 0600 to 0615 Low-order 4-digit BCD data ➞ To 0500 to 0515 DM0000 x DM0001 = Internal register TM00 High-order 4 digits Low-order 4 digits Internal register TM00 = ÷ #10000 ...
ASC / @ASC / RASC / @RASC 2.4 Instruction Details ASC: ASCII Convert RES ANL : ASC RES ANL @ #,$ FUN 0 2 : ASC ORL ANL : RASC ORL ANL @ #,$ FUN 3 2 : RASC FUN 0 @ASC: ASCII Convert RASC: Reverse ASCII Convert @RASC: Reverse ASCII Convert Example FUN 3 0000 0001 2 2 DM0000 LDA ASC DM0001 STA DM0010 LDA RASC DM0011 STA Converts contents of lower order byte of internal register into 2-digit ASCII code. Converts 2-digit ASCII into byte data representing 2-digit hex number.
ASC / @ASC / RASC / @RASC 2.4 Instruction Details Description Operation using the ASC instruction When input relay 0000 turns ON, the contents of DM0000 are transferred to the internal register. The contents of the internal register (low-order 8-bit, 2-digit numerical value) are converted into 2-digit ASCII code. This 2-digit code is input back to the internal register, and then transferred to DM0001.
ROOT / @ROOT 2.4 Instruction Details ROOT: Square Root ORL ORB FUN 3 6 @ @ROOT: Square Root #,$ FUN ORL ORB 3 6 : ROOT : ROOT Takes square root of 32-bit data (TM00: higher order byte, internal register: lower order byte), and inputs result back to same register. Example 0000 DM0001 LDA TM00 STA DM0000 LDA ROOT DM0100 STA Coding Line No.
2.4 Instruction Details Change in status of special utility relays (arithmetic flags) by arithmetic instructions (1/3) Instruction Mnemonic DATA MEMORY WRITE ➮ 3-136 DW A<0 2009 A=0 2010 A>0 2011 Error 2012 $,# constant — — — — — Relay No. — 5 — LOAD A LDA Timer/counter No. — 5 — — ➮ 3-140 [FUN23] Data memory No. — 5 — — $,# constant — 5 — — # TM — 5 — H Relay No. — — — — STA Timer/counter No. — — — — [FUN42] Data memory No.
2.
2.4 Instruction Details Change in status of special utility relays (arithmetic flags) by arithmetic instructions (3/3) 1 When the result of COMPARE is negative, the relay turns ON. When the result is not 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 is not positive, the relay remains OFF.
2.5 Programming Notes 2.5 Programming Notes This section describes important points and precautions for creating ladder programs. Circuits that must be modified 1. The circuit shown below left cannot be programmed. Modify it as shown on the right. A 0500 B E B E D 0500 A E C C D A C 2. Output is disabled in 0500 in the circuit shown below left. By modifying it as shown on the right, output of one scan only is disabled. A 1000 1000 A 0500 A 0500 1000 1000 12 3.
2.5 Programming Notes Programming precautions 1. A coil output or timer/counter cannot be connected directly from a bus. When an output coil or a timer/counter is required, insert a 'b' contact of an unused internal utility relay, a 'b' contact of an unused special utility relay, or a special utility relay 2002 (always ON) as a dummy. 0500 0500 2002 #0010 T000 #0010 T000 2. A contact cannot be connected to an output line. A B D E 0500 E C 3.
Visual KV Series Chapter 3 Interrupts The interrupt processing function executes an interrupt program when an external input or request from the high-speed counter comparator (interrupt factor) is encountered during KV operation. This chapter describes the types of interrupt factors as well as inputs and outputs encountered during interrupt processing. ➮ For KV-10/80 Series, see Chapter 6. KVNKA Chap 03.p65 3.1 Interrupt Instructions ......................................................................
3.1 Interrupt Instructions 3.1 Interrupt Instructions Visual KV Series This section describes the INT, RETI, DI, and EI instructions used for interrupt processing. INT: Interrupt FUN ANL RES INT nnnn RETI: Return Interrupt ORL LDB RETI FUN 2 3 0 Executes interrupt between INT and RETI instructions at rising or falling edge of input specified by operand. 4 Represents termination of interrupts. Example Coding for normal input a) 0000 Normal input 0000 #00020 T000 0500 T000 Line No.
3.1 Interrupt Instructions EI: Interrupt Enabled Example FUN RES AND DI Disables execution of interrupt. FUN SET ORL EI Enables execution of interrupt. 0 1 8 3 Visual KV Series DI: Interrupt Disabled 1000 EI 1000 DI Coding Line No. 0000 0001 • • • 0021 0022 • • • Instruction LD EI • • • LDB DI • • • Operand 0000 1000 Description • • • • • • • • When 1000 is ON, execution of interrupt is enabled. When 1000 is OFF, execution of interrupt is disabled.
3.2 Interrupt Processing 3.2 Interrupt Processing Visual KV Series This section describes interrupt processing. 3.2.1 Interrupt Processing Outline Normally, a PLC processes a ladder sequence program by repeating the steps of input processing, program execution, and output processing. Therefore, signals which are shorter than the scan time cannot be received. When the interrupt processing function is used, a process can be executed at the instant of the interrupt, independent of the scan time.
3.2 Interrupt Processing 3.2.2 Types of Interrupts Interrupt by an external input This interrupt is executed by input relays 0000 through 0003. Use the special utility relay to specify the polarity of the interrupt factor to a rising or falling edge. Visual KV Series Interrupts can be divided into two types: an interrupt by an external input, and an interrupt by the high-speed counter comparator. This section describes both of these interrupt types.
3.2 Interrupt Processing CAUTION • • 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 24bit high-speed counter is used. The data is undefined when the 16-bit highspeed counter is used. Visual KV Series ➮ "4.4.1 24-bit High-speed Counter" (p. 3-221) • Timing of the input capture execution depends on the input polarity setting specified with special utility relays 2402 through 2405 and 2410 through 2413. 3.2.
3.3 Direct Input/Output 3.3 Direct Input/Output 3.3.1 Direct Input The direct input function is used during interrupt processing. Direct input allows the KV PLC to fetch the input status of the input relays during execution of the interrupt program. Visual KV Series This section describes direct input and output. Direct input is available only with input relays 0000 through 0015 (KV-10xx: 00000005, KV-16xx: 0000-0009).
3.4 Applications of Interrupt Programs 3.4 Applications of Interrupt Programs Visual KV Series This section presents program examples of interrupt processing. 3.4.1 Interrupt with a Signal Converter ■ Outline Converts the short pulses which are input by interrupt processing into pulses of a constant width and then outputs them. Scan Input 0000 ON OFF ON Output 0500 ON ON ON 1 sec. 1 sec. 1 sec.
3.4 Applications of Interrupt Programs 3.4.2 Interrupt with a High-speed Counter Visual KV Series ■ Outline Uses the input value of a high-speed counter from one input relay and the ON/OFF status of another input relay to control the ON/OFF status of an output relay.
3.4 Applications of Interrupt Programs 3.4.3 Measuring the ON Time of High-speed Pulses Visual KV Series ■ Outline Measures the pulse width of the pulse input to an input relay. ON Sensor input 0000 OFF Pulse width (µs) Example: Measurement of workpiece length Sensor Visual KV ■ Ladder diagram • Special utility relay 2100 is turned ON to measure the pulse width using 1-µs units.
3.4 Applications of Interrupt Programs 3.4.4 Measuring the Period in which a Target Passes between Two Points Sensor 1 input 0002 Visual KV Series ■ Outline Measures the period in which two input relays turn ON. ON OFF Sensor 2 input 0003 ON OFF Passing time (µs) Example: Measurement of tact time Visual KV Sensor 1 Sensor 2 ■ Ladder diagram • Measures the time from when input relay 0002 turns ON until input relay 0003 turn ON. • The measured value is written to data memory DM0000 (Unit: µs).
Visual KV Series 3.4 Applications of Interrupt Programs 3 3-202 Chapter 3 Interrupts KVNKA Chap 03.p65 202 08.3.
Visual KV Series Chapter 4 High-speed Counters This chapter describes high-speed counters and high-speed counter comparators, which allow high-speed pulse measurement and pulse output, independent of the scan time. ➮ For KV-10/80 Series, see Chapter 6. KVNKA Chap 04_1.p65 4.1 High-speed Counter Instructions ................................................ 3-204 4.2 Outline of High-speed Counters .................................................. 3-206 4.2.1 4.2.
4.1 High-speed Counter Instructions 4.1 High-speed Counter Instructions Visual KV Series This section describes the CTH0, CTH1, and CTC instructions, which are used for high-speed counters. CTH0: 16-Bit Highspeed counter CTH RES : CTH0 nnnn CTH1: 16-Bit Highspeed counter CTH SET : CTH1 nnnn CTC: High-speed counter comparator CTC : #ddddd CTCn 0 1 • 16-bit (0 to 65535) up/down counters for clock pulses with a 30-kHz input 1. response frequency.
4.1 High-speed Counter Instructions CTH0: 0004 2100 to 2102 CTH1: 0005 0500 2200 to 2202 CTC0 to 3: Preset value #00001 to #65535 Visual KV Series Operands Key operation RES 0 CTH Clock input SET ENT R-SRCH 1 CTC Operand Preset value ENT R-SRCH Description 1) Initializes the setting when power is turned on. • The HSP instruction sets the input time constant of input relay 0004 to 10 µs.
4.2 Outline of High-speed Counters 4.2 Outline of High-speed Counters Visual KV Series This section describes the outline and specifications for high-speed counters and high-speed counter comparators featured with the Visual KV Series. 4.2.1 High-speed Counters and High-speed Counter Comparators The high-speed counter is a hardware-based counter that can count high-speed pulses that cannot be counted by counters written in main routines (C or UDC).
4.2 Outline of High-speed Counters ■ List of special utility relays for high-speed counter CTH0 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 Function Internal clock used only for CTH0 (1 µs) Internal clock used only for CTH0 (10 µs) Internal clock used only for CTH0 (100 µs) Automatically clears CTH0 when comparator CTC0 turns ON. Disables/enables direct output from 0500 when comparator CTC0 turns ON. Turns OFF direct output from 0500 when comparator CTC0 turns ON.
4.2 Outline of High-speed Counters ■ Other special utility relays Visual KV Series Relay Function No. 2400 Changes current value of CTH0 to preset value by external signal 2401 OFF/OFF: Not used ON/OFF: At rising edge OFF/ON: At falling edge ON/ON: Level 2406 Sets CTH0 as ring counter. ON: Yes OFF: No 2407 Ignores phase B input when no multiplication mode is used for CTH0. ON: Ignore phase B input and always count up. OFF: Use phase B input as usual.
Note 1: CTH instructions cannot be duplicated in a program. A maximum of two counters, CTH0 and CTH1, can be used in one program. Note 2: The operands for a high-speed counter cannot be changed during program execution. Note 3: When using a high-speed counter with external inputs, the input time constant 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.
4.2 Outline of High-speed Counters 4.2.2 Internal Clock for High-speed Counters • • Visual KV Series • • 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 execution. Each clock has the following count period: High-speed counter Relay No. CTH0 2100 2101 2102 CTH1 2200 2201 2202 Period 1.0 µs 10.0 µs 100.
4.3 Setting and Operation of High-speed Counters The high-speed counters and high-speed counter comparators operate using data specified with special utility relays. 4.3.1 Reading the Current Value of the High-speed Counter Visual KV Series 4.3 Setting and Operation of High-speed Counters The current value of a high-speed counter is normally written as 16-bit data (0 to 65535).
4.3 Setting and Operation of High-speed Counters 4.3.4 Count Input Method Select the input source for the high-speed counter. Visual KV Series 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.
4.3 Setting and Operation of High-speed Counters Double (x2) mode: (Phase B) 0006 ON OFF Visual KV Series (Phase A) 0004 Counts up/down based on the phase difference between two-phase pulse inputs (phase A and phase B). ON OFF (Counter value) CTH0 0 1 2 3 4 Quadruple (x4) mode: (Phase A) 0004 (Phase B) 0006 5 6 7 8 7 6 5 4 3 2 1 0 Counts up/down based on the phase difference between two-phase pulse inputs (phase A and phase B).
4.3 Setting and Operation of High-speed Counters Visual KV Series 4.3.5 Resetting the High-speed Counter Reset 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 with external input, reset automatically after counting up, and reset with the RES CTH instruction. Automatic reset after counting up Resets the counter value as soon as the preset value matches the current value (CTC = CTH).
4.3 Setting and Operation of High-speed Counters Resets the counter at the instant the external reset input relay turns ON. The external reset is assigned to input relay 0008 (KV-10xx: 0002) for CTH0, and input relay 0009 (KV-10xx: 0003) for CTH1. The timing of the reset can be changed by setting relays 2400 and 2401 (for CTH0) or 2408 and 2409 (for CTH1) as follows. This reset operation is independent of the scan time. High-speed counter CTH0 CTH1 Relay No. Status 2400 2408 Relay No.
4.3 Setting and Operation of High-speed Counters 4.3.6 Differences with the CTH Instruction between the Conventional and Visual KV Series Visual KV Series The Visual KV Series has some different high-speed counter operations from the conventional KV Series [KV-10/16/24/80R(W)/T(W)].
4.3 Setting and Operation of High-speed Counters 4.3.7 Applications of High-speed Counters 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 0007 is greater than that of 0004 and 0006 when 0004 and 0006 count "60000".
4.3 Setting and Operation of High-speed Counters Cording Visual KV Series Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 Instruction LD LDA CON STA CON LDA CON STA CON LDA CON STA LD HSP LDB Operand 2008 #01000 DM0000 #02000 DM0001 #03000 DM0002 2002 0005 0001 Line No.
4.3 Setting and Operation of High-speed Counters • • • • Inputs phase differential signals from input relays 0004 and 0006 and counts pulses at CTH0. The count value is written to DM0000. When the current value of CTH0 reaches "60000", clears the value, turns ON output 0500, and stops counting at CTH0. Input relay 0008 is used as an external reset.
4.3 Setting and Operation of High-speed Counters Fetching counts from encoder Visual KV Series Uses the double (x2) multiplication mode to fetch phase differential input from the encoder. The fetched data is output as BCD data.
4.4 Expanded Functions of High-speed Counters This section describes the 24-bit high-speed counter and ring counter functions. 4.4.1 24-bit High-speed Counter Normally, the high-speed counter operates with 16 bits. You can operate the counter with 24 bits (0 to 16777215) using special utility relays. Set the 24-bit operation with the MEMSW instruction. ➮ Visual KV Series 4.4 Extended Functions of High-speed Counters Visual KV Series Only "MEMSW instruction" (p. 3-92) MEMSW instruction: SW3 No.
4.4 Expanded Functions of High-speed Counters The high-speed counter and high-speed counter comparator update the contents of the read area of data memory each scan time. At the start of an interrupt routine, the current value is updated. The contents of the write area of data memory is updated with the data write operation. Visual KV Series ➮ "Setting the 24-bit high-speed counter comparator" (below) and "4.4.2 Changing the Current Value of a 24-bit High-speed Counter" (p.
4.4 Expanded Functions of High-speed Counters Change the current value of the 24-bit high-speed counter with the Access Window, programming support software, handheld programmer, or operator panel with the following procedure. 1. Write the desired current value into data memory. Write the desired current value to the CTH current value write areas DM1912 through DM1915. Visual KV Series 4.4.2 Changing the Current Value of a 24-bit High-speed Counter 2. Change the current value of CTH. (See notes below.
4.4 Expanded Functions of High-speed Counters 4.4.3 Application Example of 24-bit High-speed Counter (single-phase input) Visual KV Series The following is a ladder program using a 24-bit high-speed counter and high-speed counter comparator with a preset value of "1000000".
4.4 Expanded Functions of High-speed Counters 4.4.4 Ring Counter Function Visual KV Series Normally, the counter reads "#65535 ($FFFF)" by counting down from "0" by one. The ring counter function is an additional function of the automatic clear function. It reads "preset value - 1" when it counts down from "0" by one.
4.4 Expanded Functions of High-speed Counters 4.4.5 Applications of Ring Counters When using a 16-bit high-speed counter Visual KV Series The following is a ladder program that uses the ring counter of a 16-bit high-speed counter with the preset value of "10000". 0 0001 0002 9999 2008 EI 2113 SET 2114 RES 2406 SET Sets ring Sets high-speed counter in counter. double (x2) multiplication mode.
4.4 Expanded Functions of High-speed Counters When using a 24-bit high-speed counter 0 Visual KV Series The following is a ladder program that uses the ring counter of a 24-bit high-speed counter with the preset value of "100000". 99999 MEMSW $0800 0001 0002 2008 EI 2114 RES 2406 SET Sets high-speed counter in double (x2) multiplication mode. Sets ring counter.
4.5 Special Functions Using High-speed Counters Visual KV Series 4.5 Special Functions Using High-speed Counters Visual KV Series Only This section describes the specified frequency pulse output function, frequency counter function, and cam switch function. 4.5.1 Specified Frequency Pulse Output Function With high-speed counter CTH1, output pulses from output relay 0501 with the frequency (Hz) specified in data memory DM1936.
■ 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.
4.5 Special Functions Using High-speed Counters Visual KV Series ■ Program for speed control The following ladder program illustrates speed control using the specified frequency pulse output function. Control is started when input relay 0000 turns ON. The operation is slowed down and then stopped when input relay 0001 turns ON. By specifying the speed (Hz) in data memory DM0000, the program controls the speed with a start-up speed of 16 Hz and an acceleration speed of 100 Hz/100 ms.
4.5 Special Functions Using High-speed Counters High-speed counter CTH0 is used. Write the interval (ms) of frequency measurement into data memory DM1404 and turn ON special utility relay 2305. The measurement result (Hz) is written into DM1405. Input relay 0004 is for pulse input (single-phase input). Input relay 0006 (phase B input) is ignored. ■ Devices used with the frequency counter Special utility relays Relay No. 2305 Visual KV Series 4.5.
4.5 Special Functions Using High-speed Counters 4.5.4 Applications of Frequency Counters Visual KV Series Program for basic operation of the frequency counter Stores the frequency of pulses at input relay 0004 to DM0000 every second (1000 ms).
4.5 Special Functions Using High-speed Counters 4.5.5 Cam Switch Function Visual KV Series The cam switch function has two modes: cam switch mode, which simulates cam operation; and multi-step comparator mode, which compares the value written in DM1401 with multiple values. ■ Devices used with the cam switch function Special utility relays Relay No.
4.5 Special Functions Using High-speed Counters Multi-step comparator mode Visual KV Series Even a single phase incoder can be used by changing a part of the cam switch function. To activate the multi-step comparator mode, write the value to be compared into data memory DM1401 to replace the CTH0 value. This value determines the resolution. If 360 is written in DM1401, and 60 is written in DM1406, the 1st relay is turned ON at 60/360 i.e. 60°.
4.5 Special Functions Using 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. 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.
4.5 Special Functions Using High-speed Counters 4.5.6 Application of the Cam Switch (Cam Switch Mode) Visual KV Series The following ladder program illustrates the basic setting of the cam switch function. Connect the encoder with a resolution of 360 pulses. Use output relays 0600 through 0603.
4.6 Direct Clock Pulse Output 4.6 Direct Clock Pulse Output Visual KV Series Only 4.6.1 Outline of Direct Clock Pulse Output Using the high-speed counter (CTH) and high-speed counter comparator (CTC), the KV PLC can output clock pulses directly through output relays 0500 and/or 0501 without any delays caused by the scan time. Visual KV Series This section describes the outline and setting method for direct clock pulse output.
4.6 Direct Clock Pulse Output 4.6.2 Pulse Output Setting with the High-speed Counter Comparator Visual KV Series Changing the pulse period and width By using two high-speed counter comparators, you can change only the pulse width while keeping the pulse period constant, or change only the pulse period while keeping the pulse width constant. The following examples illustrate how the pulse width and period can be selected with the high-speed counter comparator.
4.6 Direct Clock Pulse Output Calculating the pulse period and comparator preset value ■ Pulse period Pulse period (µs) = 1,000,000 ÷ Frequency (Hz) ■ CTC preset value for pulses with 1:1 ON/OFF ratio (using one comparator) CTC preset value = Pulse period (µs) ÷ Internal clock (µs) ÷ 2 Visual KV Series The Visual KV PLC can output a maximum clock pulse of 50 kHz.
4.6 Direct Clock Pulse Output Visual KV Series High-speed counter comparator Special utility relay CTC0 CTC1 Operation when CTH0 (current value) reaches CTC (preset value) 2103 Automatically clears current value of CTH0 ON: Yes OFF: No 2104 Disables/enables control of 0500. ON: Disable OFF: Enable 2105 Turns OFF direct output through 0500. ON: Yes OFF: No 2106 Turns ON direct output through 0500. ON: Yes OFF: No 2107 Reverses ON/OFF status of 0500.
■ Operation with special utility relays for high-speed counter CTH1 The following table shows the ON/OFF status of output relay 0501 which can be changed by setting special utility relays (2203 through 2212) at the start of operation, or by changing them during clock pulse output. You can set desired values for the pulse period and pulse width, and can enable or disable the direct output.
4.7 Examples of Direct Clock Pulse Output 4.7 Examples of Direct Clock Pulse Output Visual KV Series This section describes programming examples of the direct clock pulse output. 4.7.1 Example of Outputting a Pulse with 1:1 ON/OFF Ratio To 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:1 ON/OFF ratio from output relay 0500 by using the high-speed counter (CTH0) and high-speed counter comparator (CTC0).
4.7 Examples of Direct Clock Pulse Output Cording Instruction LD SET CON RES CON RES CON RES Operand 2008 2103 2104 2105 Line No. 0008 0009 0010 0011 0012 0013 0014 Instruction CON SET CON RES LD CTH CTC Operand 2107 CTH0 2002 0 2101 0 #00050 Visual KV Series Line No. 0000 0001 0002 0003 0004 0005 0006 0007 2106 Note :When the input enable relay for the high-speed counter is used to start/stop the clock pulse, the response is delayed by a maximum of one scan when output starts.
Visual KV Series 4.7 Examples of Direct Clock Pulse Output Special utility relay Internal clock CTC2 preset value 2200 1.0 µs 500 2201 10.0 µs 50 2202 100.0 µs 5 ■ Example Count value 0001 2008 2203 SET 2204 RES 2205 RES 2206 RES 2207 SET CTH1 RES 0002 CTH1 2201 0003 #00050 CTC2 2002 • • • CTC2 ON ON Sets the pulse output from output relay 0501 with special utility relays 2204 through 2207.
4.7 Examples of Direct Clock Pulse Output 4.7.2 Example of Outputting a Pulse with Variable ON/OFF Ratio This section describes a programming example that will output a clock pulse with variable 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 setting Set the special utility relay (2103 through 2112) according to the following table. Relay No. Setting Relay No.
4.7 Examples of Direct Clock Pulse Output Visual KV Series Coding Line No. Instruction Operand Line No.
4.7 Examples of Direct Clock Pulse Output To output a clock pulse of 500 µ s (2 kHz)-period and 200 µ s-width from output relay 0501 ■ Special utility relay setting Set the special utility relay (2203 through 2212) according to the following table. Relay No. Setting Relay No.
4.7 Examples of Direct Clock Pulse Output Coding Visual KV Series Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 Instruction LD MPS SET CON RES CON SET CON RES MPP RES CON Operand 2008 2203 2204 2205 2207 2208 Line No.
4.7 Examples of Direct Clock Pulse Output This section describes a programming example that will output a clock pulse of 500 µs (2 kHz)-period and 200 µs-width from output relay 0500 and then stop it after 10000 pulses are output. ■ Special utility relay, internal clock, and CTC settings Set the special utility relay according to the following table. Relay No. 2103 2104 2105 2106 2107 Setting ON OFF OFF ON OFF Relay No. 2108 2109 2110 2111 2112 Visual KV Series 4.7.
4.7 Examples of Direct Clock Pulse Output • • Visual KV Series • • • The input enable relay for CTH0 must be ON all the time when CTH0 is used to output the clock pulse. The input enable relay for CTH1 must be ON all the time when CTH1 is used to count the clock pulse. Specifies the internal clock (2101) as the clock input for CTH0. Specifies 0500 as the clock input for CTH1. With this setting, CTH0 is used to output the clock pulse, and CTH1 is used to count the clock pulse.
4.7 Examples of Direct Clock Pulse Output Sta rt Re ou vers tpu e t Em sto erge p nc y The following ramp-up/down control is available by setting four parameters (DM0000 to DM0003) Visual KV Series 4.7.
4.7 Examples of Direct Clock Pulse Output ■ Example Specifies high-speed counters and comparators 0001 0002 2002 Visual KV Series 0003 #00010 CTC1 #65535 CTC0 CTH0 2100 #65535 CTC2 #65535 CTC3 CTH1 0500 0004 #08000 #00700 #00400 #04000 DW DW DW DW DM0000 DM0001 DM0002 DM0003 0005 Starts positioning 2008 0003 0000 0006 1001 DIFU 1001 2100 STA 01 CALL 2813 SET 2105 SET $0268 LDA • CTH1 counts the number of clock pulses.
Visual KV Series Chapter 5 Positioning Control Visual KV Series Only This chapter describes ramp-up/down control of stepping motors and servo motors. ➮ For KV-10/80 Series, see Chapter 6. 5.1 KVNKA Chap 05.p65 Outline of Positioning Control ..................................................... 3-254 5.1.1 Ramp-up/down Control .......................................................................... 3-254 5.2 Parameter Setting and Operating Procedures ......................... 3-255 5.2.1 5.2.
5.1 Outline of Positioning Control 5.1 Outline of Positioning Control Visual KV Series This section describes the outline of positioning control. 5.1.1 Ramp-up/down Control The Visual KV Series can directly output clock pulses not affected by the scan time to output relay 0502. If the frequency, the number of output pulses, and the acceleration time of the clock pulses have been preliminarily set to data memories, the Visual KV Series automatically performs ramp-up/down control.
5.2 Parameter Setting and Operating Procedures This section describes the parameter setting and operating procedures for positioning control. 5.2.1 Parameter Setting Procedure Visual KV Series 5.2 Parameter Setting and Operating Procedures Preliminarily set each parameter for positioning control to a corresponding data memory. To operate, special utility relays must be set. ➮ For more about special utility relays, refer to "5.2.2 Operating Procedure" (p. 3-257).
5.2 Parameter Setting and Operating Procedures 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. Visual KV Series Note: If the startup frequency is the same as the operating frequency, the timing chart becomes as shown below. Operating (startup) frequency 0 In this case, the acceleration/deceleration time is ignored.
5.2 Parameter Setting and Operating Procedures In positioning control, operation is started up, stopped normally, and stopped in emergencies by the ON/OFF status of special utility relays. The table below shows the relationship between operations and the special utility relays used. Special utility relay No. R/W* Function 2308 W Stop 2309 R W Run RESET 2310 W Start Description Performs deceleration at rising edge, then stops operation. Remains ON while pulses are output.
5.3 Examples of Using the Positioning Control Function Visual KV Series 5.3 Examples of Using the Positioning Control Function This section describes examples of connecting a stepping motor driver and performing ramp-up/down control using the positioning control function of the Visual KV Series. 5.3.1 Connection Example Sta rt p Sto 24 VDC Em erg enc ys top Connect the Visual KV Series and stepping motor driver as shown below. This example is only for reference.
5.3 Examples of Using the Positioning Control Function 5.3.3 Application Examples of the Positioning Control Function When start switch 0000 is set to ON, output 0502 starts to output 100,000 pulses with a startup frequency of 500 Hz, operating frequency of 10 kHz, and acceleration/ deceleration time of 3 seconds. When input 0001 is set to ON, pulse output is decelerated and stopped. When input 0002 is set to ON, pulse output is immediately stopped.
5.3 Examples of Using the Positioning Control Function Ladder example of the jog operation The jog operation is performed. Speed (Hz) CCW direction Visual KV Series CW direction 1000 500 Coordinate (pulses) Input 0000 (CW direction) Input 0001 (CCW direction) • While input 0000 is ON, the machine continues to move in the CW direction. When input 0000 turns OFF, the machine decelerates and stops. • While input 0001 is ON, the machine continues to move in the CCW direction.
5.3 Examples of Using the Positioning Control Function 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 again returns to the start position. Such an operation is realized using repetitious and return movements.
5.3 Examples of Using the Positioning Control Function Ladder example of a return to the zero point A return to the zero point is performed. Visual KV Series Range detected by zero point sensor Start Low speed Forced stop Deceleration and stop High-speed When start signal 0000 turns ON, the machine moves at a high speed in the CCW direction.
5.3 Examples of Using the Positioning Control Function Ladder example of an automatic operation (continuous operation with wait status) In automatic operation, wait status is realized at each point. 10000 7000 5000 500 0 250000 320000 Wait Wait 460000 Coordinate (pulses) Visual KV Series Speed (Hz) When start signal 0000 turns ON, the machine moves to point 1 and stops there. At the rising edge of wait status reset switch 1, the machine automatically moves to point 2 and stops there.
5.3 Examples of Using the Positioning Control Function Ladder example of a pulse motor application circuit Visual KV Series This is a program example which offers control using both automatic and manual operations. In automatic operation, when input 000 is set to ON, the following operation is performed. Speed (Hz) 8000 2000 300 0 15000 17500 Coordinate (pulses) 15000 In manual operation, the machine moves forward while input 0008 is ON, and moves backward while input 0009 is ON.
Return to zero point 0015 0016 Limit switch 0007 1205 DIFU 0017 0018 Move forward. 1205 0503 SET 0019 0020 #00300 #03000 #00250 #00000 #03500 DW DW DW DW DW DM1480 DM1481 DM1482 DM1485 DM1484 1300 DIFU 1200 SET Trigger end of forward movement 1200 0021 2309 ON 1201 1201 2309 OFF 1202 1202 1203 DIFU 1203 0503 RES #00500 #00500 #00000 #00000 #65535 DW DW DW DW DW DM1480 DM1481 DM1482 DM1485 DM1484 1301 DIFU 1200 RES 0024 Start up motor.
5.3 Examples of Using the Positioning Control Function Set parameters for automatic operation. 0043 Set automatic operation parameters.
KV-10/80 KV-300 Chapter 6 Interrupts, High-speed Counters, Positioning Control KV-300, KV-10/80 Series Only This chapter describes ramp-up/down control of stepping motors and servo motors. KVNKA Chap 06.p65 6.1 Interrupt Instructions .............................................................. 3-268 6.1.1 6.1.2 Description of Interrupts ......................................................................... 3-268 Interrupt Instructions .............................................................
6.1 Interrupt Instructions 6.1 Interrupt Instructions 6.1.1 Description of Interrupts Input processing for routine program and interrupt routine KV-10/80 KV-300 Input processing t Scan time rup Processing of direct inputs ter ion in of rat (00000 to 00005) ne Routine program execution Output processing Ge Interrupt routine execution Re tu at rns the to po sus int pe of nd su ed sp pr en og sio ram n. Processing of direct outputs (00500 to 00503) Fig.
6.1 Interrupt Instructions Interrupt priority If two or more interrupts are generated at different timings, interrupt routines are executed in the order that interrupts are generated. If two or more interrupts are generated simultaneously, interrupt routines are executed according to the priority shown below. CTC0 > CTC1 > CTC2 > CTC3 > 0000 > 0001 > 0002 > 0003 Note that the above priority differs from that for other KV PLCs (KV-10/16/24/40/ 80).
6.1 Interrupt Instructions Direct output 2813 SET 2008 EI END INT 0000 2002 0500 ( SET ) KV-300 RETI KV-10/80 INT 0001 2002 0500 ( SET ) ENDH Direct output is enabled only through output relays 0500, 0501, 0502, and 0503. This function allows ON/OFF status of any of output relays 0500, 0501, 0502, and 0503 to be output during execution of interrupt routine. This function allows immediate ON/OFF status output without delay caused by scan time.
DI / EI 6.1 Interrupt Instructions 6.1.2 Interrupt Instructions DI: Interrupt Disabled EI: Interrupt Enabled FNC RES AND 0 8 : DI Disables execution of interrupt. FNC SET 1 : EI Enables execution of interrupt. ORL 3 Key operations AND 8 FNC SET 1 ORL 3 ENT R-SRCH ENT R-SRCH KV-10/80 RES 0 KV-300 FNC Operand Example 1000 EI 1000 DI Coding Line No.
INT / RETI 6.1 Interrupt Instructions INT: Interrupt FNC ANL 2 RETI: Return Interrupt RES 0 : LDB FNC ORL 3 4 : INT nnnn RETI Executes interrupt between INT and RETI instructions at rising edge of input specified by operand. When 0003 is specified by operand, the rising or falling edge can be selected for execution of interrupts. Represents termination of interrupts.
INT / RETI 6.1 Interrupt Instructions Interrupt routine coding Operand 2008 Line No. 0008 0009 0010 0011 0012 0013 0014 2813 1000 0500 000 #00020 T000 Instruction OUT END INT LD OUT RETI ENDH Operand 0500 0000 2002 1000 Example 2 Features of INT0003 Upon generation of interrupt by INT0003, the CTH1 current value is automatically transferred to TM30. Interrupt generated by any of INT0000 to INT0002 is executed at the rising edge of the input signal.
INT / RETI 6.1 Interrupt Instructions KV-10/80 KV-300 ■ Initial setting • When the operation is started, EI instruction enables interrupts. • Special utility relays No. 2200 through 2215 are turned OFF. Turning OFF 2203 disables CTC2 from resetting the CTH1 current value to 0. • Turning OFF 2206 allows interrupt to be generated at the rising edge of INT0003. • The value of DM0000 is reset to "0". • Turning ON special utility relay 2813 changes the input time constant to 10 µs. • 1.
INT / RETI 6.1 Interrupt Instructions Turning ON special utility relay 2203 allows CTC2 to reset the CTH1 current value to 0. • The CTH1 current value is reset to 0. • The CTC2 preset value is set to 5000. • Turning ON special utility relay 2813 changes the input time constant to 10 µs. • Pulses input to 0005 are counted using CTH1. • When input 0000 turns ON, output 0501 is reset. • INT CTC2 is used to execute the interrupt.
6.2 High-speed Counters 6.2 Direct Clock Pulse 6.2.1 Output of Direct Clock Pulse Outline of High-Speed Counters Basic Architecture KV-10/80 KV-300 The KV-300 CPU has two 16-bit (CTH0, CTH1) double-phase counter, each equipped with two high-speed counter comparators (CTC0, 1, 2, 3). These counters can be used as a stepping motor controller or are used to measure pulse width. Block diagram of high-speed counters 0008 (RESET) Phase A 0004 Phase B (0006) Internal clocks 2100(1.0 µs) 2101(10.
6.2 High-speed Counters Utility relays for high-speed counter CTH1 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.
6.2 High-speed Counters ■ High-speed counter and counter comparators High-speed counter (CTH1) CTH1 is a 16-bit hardware counter that counts from 0 to 65535. • • • • • KV-10/80 KV-300 • You can specify the operands listed in the table below as the count input. You can specify one operand from the table below. Operand cannot be modified externally during execution of the program. When the external pulse (0004, 0005) is selected, CTH1 is used as a High-speed counter with a response frequency of 30 kHz.
6.2 High-speed Counters CAUTION • You cannot change operands of the high-speed counters (CTH) during execution of the program. The input time constant of the high-speed counters 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 can be counted at up to 50 kHz by turning ON 2813.
6.2 High-speed Counters 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 while a constant period is maintained.
6.2 High-speed Counters 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 relays during generation of clock pulse, you can select ON/OFF of output relay 0500 as listed below. These special utility relays also allow you to set the pulse cycle and pulse width and enable or disable the direct output.
6.2 High-speed Counters ■ 16-bit high-speed counter (CTH1) and special utility relays (2203 to 2205, 2208 to 2212) By setting the special utility relays 2204 to 2205 and 2208 to 2212 at startup or changing these relays during generation of clock pulse, you can select ON/OFF of output relay 0501 as listed below. These special utility relays also allow you to set the pulse cycle KV-10/80 KV-300 Pulse status at CTH1 (current value) = CTC (preset value) Comparator No. Relay No.
6.2 High-speed Counters Calculating the pulse cycle and comparator setting value The KV-300 CPU supports clock pulse output at maximum frequency of 50 kHz.
6.2 High-speed Counters Examples of Pulse Output The 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 from 0500, through High-speed counter CTH0 and High-speed counter comparator CTC0. KV-10/80 KV-300 Setting special utility relays Special utility relays 2103 to 2112 are set as shown on the right table.
6.2 High-speed Counters Coding CAUTION Line No. Instruction Operand 0000 LD 2008 0001 SET 2103 0002 CON CON 0005 RES 0006 CON 0007 RES 0008 CON 2104 2105 2106 0009 SET 0010 CON 0011 RES 0012 LD 2002 0013 CTH 0 2101 0014 CTC 0 #00050 KV-10/80 RES 0004 KV-300 0003 2107 CTH0 When start/stop of clock pulse is controlled by the input relay which enables/ disables the high-speed counter, response relay of up to 1 scan is generated at start.
6.2 High-speed Counters Special utility relay Internal clock* CTC0 value 2200 1.0 µs 500 2201 10.0 µs 50 2202 100.0 µs 5 KV-10/80 KV-300 Values set to the internal clock and CTC2 After the internal clock is determined, the CTC2 setting value is calculated from the following expression. CTC2 setting value = Pulse cycle (µs) ÷ Internal clock (µs) ÷ 2 Assign 1 ms to pulse cycle and 10 µs (2201: special utility relay) to internal clock and calculate the CTC2 setting value.
6.2 High-speed Counters CAUTION When start/stop of clock pulse is controlled by the input relay which enables/ disables the high-speed counter, response relay of up to 1 scan is generated at start. Also, the same response relay is generated at stop, which may stop clock pulse output while the output relay is still ON. This controls clock pulse so that it always starts and stops when 2204 turns OFF.
6.2 High-speed Counters Programming example 2008 0001 2103 SET 2104 RES 2105 RES 2106 SET 2107 RES 0002 2108 RES 2109 SET 2110 RES 2111 RES CTH0 RES 2002 CTH0 2101 #00050 CTC0 #00020 CTC1 0003 0004 0005 ON OFF • The status of output 0500 is set by turning ON one of the relays 2104 to 2107 and 2108 to 2111 at the beginning of the program. In Example, output of direct clock pulses to 0500 is enabled, and the status of output 0500 is turned ON at CTC0 and is turned OFF at CTC1.
6.2 High-speed Counters ■ When outputting clock pulse with cycle 500 µs (2 kHz) and pulse width 200 µs from 0501 This program example shows how to output clock pulse with variable ON/OFF ratio from 0501, through High-speed counter CTH1 and High-speed counter comparator CTC2 and CTC3. Setting special utility relays Special utility relays 2203 to 2212 are set as shown on the right table. Setting Relay No.
6.2 High-speed Counters Coding KV-10/80 KV-300 Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 CAUTION Instruction LD MPS SET CON SET CON SET CON RES MPP RES CON Operand 2008 Line No.
6.2 High-speed Counters Programming example 0002 0003 0000 0004 2002 0005 0006 0007 2002 0008 0009 2103 SET 2104 RES 2108 RES 2203 SET 2109 SET 2813 SET 2105 SET 2106 SET 2107 RES 2110 2111 RES RES CTH1 RES 1000 1000 DIFU CTH0 RES 2105 RES CTH0 2101 #00050 CTC0 #00020 CTC1 CTH1 0500 #10000 CTC2 END 0010 INT CTC2 0011 2002 0012 0013 0014 2105 SET RET1 ENDH • Sets pulse output to 0500 using special utility relays 2104 to 2107 and 2108 to 2111.
6.2 High-speed Counters KV-10/80 KV-300 Coding Line No. Instruction Operand Line No.
6.2 High-speed Counters Example of pulse output (Ramp-up/down control) The following example performs ramp-up/down control as shown below by setting 4 parameters (DM0000 to DM0003). – KV-10/80 24 VDC KV-300 rt Sta KV-300 Re ve rs e Connection example The following chart shows an operation example when the KV-300 CPU is connected to the stepping motor driver. See the stepping motor driver instruction manual for details. Set the pulse input mode of the stepping motor driver to "1 pulse input mode".
6.2 High-speed Counters Programming exmaple 0001 INITIAL SETUP FOR HIGH-SPEED COUNTER/COMPARATOR 2002 0002 #00010 CTC1 #65535 CTC0 CTH0 2100 0003 #65535 CTC2 #65535 CTC3 CTH1 0500 2008 KV-10/80 KV-300 0005 #00700 DW DM0001 #08000 DW DM0000 0004 #00400 DW DM0002 2813 2105 (SET ) (SET ) #04000 DW DM0003 STARTS POSITIONING 0003 0000 1001 DIFU 0006 Generates clock pulse through highspeed counter CTH0. Counts clock pulese through highspeed counter CTH1.
6.
6.3 Positioning Control 6.3 Positioning Control 6.3.1 Positioning Control (Ramp-up/down Control) Outline of positioning control KV-10/80 KV-300 The KV-300 CPU outputs clock pulses, independent of scan time, directly through output relay 0500 or 0501. When the clock pulse frequency, output pulse count, and acceleration/deceleration time are set to the data memory addresses in advance, the KV-300 CPU automatically performs ramp-up/down control.
6.3 Positioning Control Setting and application of parameters This section describes how to set and apply parameters for positioning control. Setting parameters Set the parameters to the assigned data memory addresses. To operate the positioning control function, the special utility relays must be set. ➮ Refer to page 3-299. The following table shows the parameters and assigned DM Nos.
6.3 Positioning Control ■ Set value error code Automatically writes an error code (11 to 17) into DM9407 when a parameter setting error is found at startup. KV-10/80 KV-300 Code Error description Corrective action 11 Start frequency is below allowable range. Adjust start frequency to within allowable range (153 to 50000). 12 Run frequency is below allowable range. Adjust run frequency to within allowable range (153 to 50000). 13 Run/start frequency exceeds allowable range.
6.3 Positioning Control ■ Output pulse count Sets the positioning control rotation angle (moving distance) with the pulse count. The KV-300 CPU outputs as many clock pulses as specified. If the output pulse count is greater than 65535, set the pulse count separately for high-order 16 bits and low-order 16 bits based on the following expressions.
6.3 Positioning Control ■ Operation chart (when 0500 is used) DM9409 DM9408 DM9411 DM9412 0 DM9410 DM9410 When 2310 turns ON, clock pulse is output. (rising [UP] edge is detected.) 2309 is ON during clock pulse output. When pulse output is stopped, 2309 turns OFF. When turning ON 2308, clock pulse decelerates and stops (rising [UP] edge is detected.
6.3 Positioning Control Ramp-up/down control When start switch 0002 is turned ON, 0500 outputs 100000 pulses under the following conditions: start frequency 1 kHz, run frequency 5 kHz, and acceleration/ deceleration time 3 s. Turn ON 0001 to decelerate and stop pulse output. When 0000 is turned ON, pulse output is immediately stopped. 0002 0002 0001 #01000 #05000 #03000 #00001 #34464 2310 DW DW DW DW DW DM9408 DM9409 DM9410 DM9411 DM9412 2308 0003 Enables interrupt when starting operation.
6.
6.3 Positioning Control 0024 STARTS MOTOR 1300 0006 1301 0004 2310 ( ) 0025 Instructs motor start and acceleration/ deceleration stop.
KV-10/80 KV-300 6.3 Positioning Control 6 3-304 Chapter 6 Interrupts, High-speed Counters, Positioning Control KVNKA Chap 06.p65 304 08.3.
Chapter 7 Serial Communication The KV Series can be connected to an external device with an RS-232C interface to establish communication. This chapter describes communications specifications, how to connect the KV Series to external devices, and how to perform communication. KVNKA Chap 07.p65 7.1 Communications Specifications ............................................ 3-306 7.1.1 7.1.2 7.1.3 Communications Specification ...............................................................
7.1 Communications Specifications 7.1 Communications Specifications This section describes the specifications for the RS-232C interface and the connection between the KV and external devices. 7.1.1 Communications Specification The communications specification of the KV is summarized in the table. Set the communications parameters of the personal computer by referring to the table.
7.1 Communications Specifications 7.1.3 Connecting the KV-300 CPU to a Personal Computer Connect the KV-300 CPU to the RS-232C port of the personal computer with the supplied connecting cable (OP-226486/OP-26487). 9-pin D-SUB female connector: OP-26487 Connecting cable Standard cable:OP-26486 Personal computer with an RS-232C port KV-300 Recommended pin assignments for the RS-232C communication cable are shown below. When connecting the KV-300 CPU, use only the connecting cable supplied.
7.2 Serial Communication 7.2 Serial Communication When the KV is connected to a personal computer, the current value or preset value of timers/counters or contents of data memories in the KV can be loaded to and modified on the computer. 7.2.1 Command Transmission Procedure Commands are transmitted from a personal computer to the KV base unit as follows: Transmits a break signal Initialize the communication buffer and baud rate setting of the KV.
7.2 Serial Communication ■ Command/response format "Command" and "response" in communications between the KV and a personal computer 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 KV sends back a response to the personal computer.
7.2 Serial Communication 7.2.3 Communication Command/Response List The following list shows the commands and responses used in serial communication. "_" in the list represents a space. Function Command Response Description Starts communication. CR CC Ends communication. CQ CF Changes mode. Mn OK Clears error. ER OK Checks PLC error. ?E dd dd= Error code (00: No error) Checks current PLC mode.
7.2 Serial Communication 7.2.4 Setting Communication Commands and Responses to Commands This section describes the command settings and responses when a command is properly processed. "_" represents a space. Refer to "7.2.5 Other Response Codes" (p. 3-315) for responses under abnormal conditions. ■ Communications start command Transmit a communications start command to start communication with the KV. Other commands can be transmitted after the proper response is sent back from the KV.
7.2 Serial Communication ■ Reading counter Reads the contact ON/OFF status, or the current and preset values of the specified counter/up-down counter. Command: RD_Cnnn Counter No. Response: f,ddddd,ddddd [Preset value of the counter (00000 to 65535: in decimal)] [Current value of the counter (00000 to 65535: in decimal)] 0: Contact is OFF., 1: Contact is ON. ■ Reading high-speed counter CTH Reads the contact ON/OFF status, or the current and preset values of the specified high-speed counter CTH.
7.2 Serial Communication ■ Reading DM Reads the contents of the specified data memory. Command: RD_DMnnnn Data memory No. Response: ddddd Data in the specified data memory. (00000 to 65535: in decimal) ■ Reading TM Reads the contents of the specified temporary data memory. Command: RD_TMnn Temporary data memory No. (00 to 31) Response: ddddd Data in the specified temporary data memory.
7.2 Serial Communication ■ Writing preset value of high-speed counter comparator CTC Changes the preset value of the specified high-speed counter comparator CTC. Command: WS_CTCn_ddddd New 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_ddddd New current value (00000 to 65535: in decimal) Data memory No. Response: OK ■ Writing into TM Writes data into the specified temporary data memory.
7.2 Serial Communication ■ Forcing CTC contact OFF Forces the contact of the specified high-speed counter comparator to OFF. Command: RS_CTCn High-speed counter comparator No. Response: OK Note 1: Input relays cannot be forced ON/OFF. (Except when special utility relay 2301 is ON.) Note 2: "_" in commands and responses represents a space. 7.2.
7.2 Serial Communication 7.2.6 Error Code List When a "Checking KV PLC error" command (?E) is transmitted, the KV sends back the error code. The following list shows the description, cause, and remedy for each error code. Error code Description Cause Remedy 00 No error 10 CALL nest error Subroutines are nested to four levels or more. 11 FOR nest error 12 INT nest error FOR/NEXT instructions are nested to Check the program while paying eight levels or more.
7.2 Serial Communication 7.2.7 Example Program Typical program for communications between the KV and a personal computer (For IBM PC-AT & compatible computers using BASIC) ‘ ‘Language Microsoft BASIC Version 7.
7.3 Loading Text Data 7.3 Loading Text Data The KV can be connected to equipment having an RS-232C port to load consecutive text data (less than 100 bytes) as a batch into its data memories. Loaded data can be modified and incorporated into a program. 7.3.
7.3 Loading Text Data Relay No. ( PO RT A) Relay No. ( PO RT B) Relay No. ( KV- 300/ 10/ 80) Descript ion 2801 2806 2804 Turns ON for one scan when text data has been received. 2802 2807 2805 Turns ON for one scan when text data has been received while 2801 is ON, or when 2803 is ON. 2803 2808 2806 Turns ON for one scan when text data reception has failed.
7.3 Loading Text Data Special utility relay operation Two special utility relays are assigned for each channel for data transmission. Text data or a break signal is transmitted when the respective relay is turned ON/OFF. Relay No. (Port A) Relay No. (Port B) Relay No. (KV-300/10/80) 2804 2809 2807 Starts/stops transmitting text data. ON: Start, OFF: Stop 2800 2805 2803 Starts/stops transmitting break signal.
7.4 ASCII Code List 7.4 ASCII Code List The following are the ASCII code characters used for data transmission. High-order 4 bits 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 Low-order 4 bits 5 6 7 8 9 A B C D 17 E F Characters in the shaded area can be used for data transmission with the KV. [STX], [ETX], [LF], and [CR] are used as data delimiters. Only use characters in the shaded area because the other characters are used for control purposes. Chapter 7 Serial Communication KVNKA Chap 07.p65 321 08.
7.4 ASCII Code List 7 3-322 Chapter 7 Serial Communication KVNKA Chap 07.p65 322 08.3.
Chapter 8 Programming Examples This chapter describes the typical programming examples for KV-300, KV-10/80 Series. These programs can be used for Visual KV Series. However, pay attention to the I/O addressing compatibility before use. KVNKA Chap 08.p65 8.1 List ....................................................................................................... 3-324 8.2 Details ................................................................................................. 3-326 8.2.
8.1 List 8.
8.1 List Instruction Program title Reference Page 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 Output of 4-digit BCD data 3-357 TBIN 18 Chapter 8 Programming Examples KVNKA Chap 08.p65 325 08.3.
8.2 Details 8.2 Details 8.2.1 Reference Program Examples Basic Instructions Applications of TMR, TMH, and TMS Instructions ➮ Refer to p. 3-67 to p. 3-71. ■ One-shot circuit When input relay 0000 turns ON, output relay 0500 turns ON and remains ON for a specified time. Timing diagram 0000 0500 2s 2s Ladder diagram Coding 2-s timer 0000 #00020 T000 0500 T000 00500 Line No.
8.2 Details ■ On-delay circuit Output relay 0500 turns ON in a specified time after input relay 0000 turns ON. When input relay 0000 turns OFF, output relay 0500 also turns OFF. Timing diagram 0000 0500 2s 1s Ladder diagram Coding 2-s timer 0000 #00020 T000 T000 0500 Line No. 0000 0001 0002 0003 Instruction LD TMR LD OUT Operand 0000 000 #00020 T000 0500 ■ Flicker circuit Output relay 0500 turns ON and OFF repeatedly while input relay 0000 is ON.
8.2 Details ■ Large capacity counter Accumulates 1 count to C001 for every 10000 counts by C000. This example can count up to 655350000. Count input relay 0000 Reset relay 0001 Ladder diagram 0001 Coding C000 #10000 C000 0000 1000 C000 0001 #65535 C001 1000 Line No.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 Instruction LDB C LD LDA CON MPS CMP CON ANB OUT MRD CMP Operand 0001 000 #09999 0000 2002 C000 #00999 2011 0500 Line No.
8.2 Details Timing diagram 0000 0001 0002 0003 0500 1s Ladder diagram 0000 0001 0002 0003 KEEP SE T 1000 Excecutes SET when all input relays 0000 to 0003 are ON. 1001 RES 0000 1001 DIFD 1001 1000 T001 0500 0500 #00010 T001 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. Executes SET when all input relays 0000 to 0003 are ON. Detects presence/absence of chewing gum packs at DOWN edge of 0000.
8.2 Details ■ Repeat shift circuit Turns ON every output for a second sequentially. Sets 1000 to 2008 (ON for 1st scan only at startup) and shifts outputs from 7500 to 7504 every second at T001. When 1005 turns ON, 1000 is set and the same sequence as above repeats. Ladder diagram Coding 1000 SET #00010 T001 2008 T001 SFT 2003 D 1000 T001 CLK 1000 1005 RES 7500 1001 7501 1002 7502 1003 7503 1004 7504 2003 1000 SET 1005 Line No.
8.2 Details ■ Resetting internal utility relays When input relay No. 0000 turns ON, all internal utility relays No. 1000 through 1915 turn OFF. SFT instruction can be substituted for RES instruction. This application can be used to reset many relays at one time. Ladder diagram Coding SFT 2003 D 1000 2003 CLK 1915 0000 RES Line No.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 Instruction LD EI SET LD T000 LD RES Operand 2008 2813 0500 #00010 T000 0500 Line No. 0007 0008 0009 0010 0011 0012 Instruction END INT LD SET RETI ENDH Operand 0000 2002 0500 ➮ Refer to p. 3-86. 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.
8.2 Details Application Instructions Application of W-UE instruction ■ Input sequence check Output relay 0500 turns ON when input relay 0000 is ON and input 0001, 0002, and 0003 turn ON in this sequence. Output relay 0500 turns OFF when input relay 0000 is OFF.
8.2 Details Application of STG-JMP instruction ■ Enabling double coil When start SW 0000 is pressed, output relay 0500 turns ON for 1 s, then output relays 0500 and 0501 turn ON for 2 s, and then output relays 0500, 0501, and 0502 turn ON for 3 s. The above sequence repeats. Ladder diagram 0000 1100 DIFU 1000 STG 0500 #00010 T000 T000 1001 JMP Output relay 0500 turns ON for 1 s. #00020 T001 T001 1002 JMP Output relays 0500 and 0501 turn ON for 2 s.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 Instruction LD DIFU CON AND SET STG OUT MPS AND JMP MPP AND JMP STG Operand 0000 1100 1100 1000 1000 0500 0001 1001 0002 1002 1001 Line No.
8.2 Details Reset input relay 0002 Output relay 0500 turns ON when the pulse interval is not within the range from 490 to 510 mm. Measure the pulse interval ON OFF 500ms Ladder diagram 2008 #00001 LDA DM0000 STA Sets mode 1 in DM0000. 2008 #00051 LDA DM0001 STA Sets MAX. setting value (510 ms) in DM0001. #00049 LDA DM0002 STA Sets MIN. setting value (490 ms) in DM0002.
8.2 Details Ladder diagram Coding 2008 #09000 LDA DM0000 STA 2008 #02000 LDA DM0001 STA 2008 #00900 LDA DM0002 STA 2008 #00010 LDA DM0003 STA ITVL PLS DM0000 2003 0001 PAUSE 1000 RES 0002 DM0007 LDA 1003 DM0100 STA ➮ Refer to p. 3-117. Line No.
8.2 Details ■ High-speed counter current value clear Counts pulses at input relay 0005. When the count value reaches setting value 60000, clears the current value of high speed counter CTH1 and turns ON output relay 0502 for 3 s. Ladder diagram Coding 2813 SET 2008 2203 SET 2002 CTH1 RES CTH1 0005 #60000 CTC2 0502 CTC2 #00030 T001 T001 CTC2 RES 0502 RES Line No.
8.2 Details CAUTION External reset 0008 is predetermined on hardware even if you do not specify in the program. However, you have to set external reset enable relay 2115 to ON. Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 Instruction LD EI CON SET CON SET CON SET CON RES CON SET CON RES Operand 2008 2813 2103 2113 2114 2115 Line No.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 Instruction LD DIFU CON AND LDA CON STA CON LDA CON STA CON CALL END SBN LD LDA CON ADD CON STA Operand 0000 1000 1000 #00010 TM02 #00030 TM03 00 00 2002 TM03 #00001 Line No.
8.2 Details 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.
8.2 Details Arithmetic Instructions Applications of TMIN (Analog timer) instruction ■ Changing timer setting value Uses analog timer (TMIN0) to change the timer setting value (0 to 24.9 s). Ladder diagram Coding 2002 0 TMIN Line No.
8.2 Details The data once fetched is written into DM0004, DM0003, ..., DM0000 in this order. At the unloading timing, unload the data from DM0004 and shifts the data value to the next DM. The ON/NG judgement and unloading timings can be used in asynchronous programs. Ladder diagram 0000 1000 DIFU 1000 OK/NG judgement timing 0001 $1111 LDA DM0000 STA Transfers $1111 to DM0000. OK/NG judgement 0001 $5555 LDA DM0000 STA Transfers $5555 to DM0000.
8.2 Details ■ Changing the counter setting value Sets the setting value of counter C000 to DM0000. Reset input is 0005. Ladder diagram 2002 Coding DM0000 LDA 0005 Line No. Instruction Operand 0000 LD 2002 0001 LDA DM0000 0002 CON 0003 STA C000 0004 LDB 0005 0005 C 000 #9999 0001 C000 STA #9999 C000 0001 ■ Changing the timer setting value Sets the setting value of timer T000 to DM0000. Reset input is 0005. Ladder diagram 2002 Coding DM0000 LDA 0005 Line No.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 Instruction LDB C LD LDA CON CMP CON ANB Operand 0001 001 #09999 0000 2002 C001 #01000 2011 Line No. 0008 0009 0010 0011 0012 0013 0014 0015 Instruction OUT LD LDA CON CMP CON ANB OUT Operand 0500 2002 C001 #02000 2009 0501 ■ Changing the CMP setting value Compares the current value of C000 to the CMP setting value. Sets the CMP setting value to analog timer TMIN0.
8.2 Details Ladder diagram 0001 #09999 C000 0000 2002 C000 LDA #00999 2011 CMP 0500 #01999 2011 0500 CMP 0501 C000 ≤ 00999 00999 < C000 ≤ 01999 #02999 2011 0500 0501 0502 01999 < C000 ≤ 02999 CMP Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 Instruction LDB C LD LDA CON MPS CMP CON ANB OUT MRD CMP Operand 0001 000 #09999 0000 2002 C000 #00999 2011 0500 Line No.
8.2 Details ■ Total count Writes total count of counters C001 to C003 into DM0100. The total count must be within 65535. Ladder diagram #09999 C001 C001 LDA 0001 #09999 C002 0000 C002 LDA 0002 #09999 C003 0000 C003 LDA 0003 2002 DM0001 DM0002 DM0003 LDA ADD ADD 0000 DM0001 STA Writes C001 current value into DM0001. DM0002 STA Writes C002 current value into DM0002. DM0003 STA Writes C003 current value into DM0003. DM0100 STA Writes total count (DM0001 + CM0002 + DM0003) into DM100. Coding Line No.
8.2 Details 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-order 16 bits of the product into DM0101 and low-order 16 bits of the product into DM0100. Ladder diagram Coding 0001 #09999 C001 0000 2002 C001 DM0000 DM0100 TM00 DM0101 LDA MUL STA LDA STA Line No.
8.2 Details 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 2002 0000 LDA $000F ANDA TBIN C000 STA 2002 Fetches data of 0000 to 0015 and retains data of 0000 to 0003 only. Converts data to BIN and writes it into C000. #09999 C000 7001 7000 Sets C000. Coding Line No. 0000 0001 0002 0003 0004 Instruction LD LDA CON ANDA LD Operand 2002 0000 $000F 2002 Line No.
8.2 Details Application of ORA instruction ■ Output of BCD 2-digit data Converts the current value of counter C000 to BCD and sends 2 digits of BCD data to output relays 7500 to 7507. However, retain ON/OFF of 7508 to 7515 which are loaded. Ladder diagram 7500 LDA #00099 C000 0001 $FF00 ANDA DM0000 STA C000 LDA TBCD $00FF ANDA DM0000 ORA 7500 STA 0000 2002 2002 2002 Sets C000. Writes data of 7008 to 7015 into DM0000.
8.2 Details Application of EORA instruction ■ Judgement of matching data Turns ON 0500 (“OK” output) when the ON/OFF statuses of input relays 7000 to 7007 match the DM0000 setting value. Ladder diagram 2008 2002 Coding $00AA DM0000 LDA STA $00FF ANDA 7000 LDA DM0000 2010 0500 EORA Line No.
8.2 Details Coding Line No. 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 Instruction LD C LD LDA CON ANDA LD SRA CON STA LD Operand 0001 001 #00099 0000 2002 7000 $F000 2002 #12 DM0000 2002 Line No. 0011 0012 0013 0014 0015 0016 0017 0018 0019 0020 0021 Instruction LDA CON ANDA LD SLA CON ORA LD TBIN CON STA Operand 8000 $000F 2002 #04 DM0000 2002 C001 ➮ Refer to p. 3-166.
8.2 Details Ladder diagram 2008 #00000 LDA DM0000 STA 0000 DM0000 INC 0001 DM0000 INC 0002 DM0000 INC 0003 DM0000 INC 0005 #00000 DW DM0000 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. Clears DM0000 to #00000 when 0005 turns ON. Coding Line No.
8.2 Details 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 segments Connect each of 7 segments to output relays as shown below: a a. 7500 f b. 7501 b c. 7502 g d. 7503 e e. 7504 c d f. 7505 g. 7506 Ladder diagram Auto reset counter C000 #00009 C000 0000 Coding Converts the counter value to 16-bit data using the MPX instruction.
8.2 Details 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 to 8507 in 2-digit BCD. Ladder diagram 2002 07000 LDA DMX TBCD $00FF ANDA 2002 Converts the most significant bit of 16-bit data (7000 to 7015) to 4-bit BIN data and sends it to internal register. Converts internal register data to BCD data, executes ANDA instruction, and outputs the data to 8000 to 8015. 8000 STA Coding Line No.
8.2 Details Ladder diagram 2002 DM0000 DM0001 LDA MUL DM0101 LDA TBCD #10000 DM0101 DIV STA TM01 LDA TBCD 7500 STA 8500 STA Coding Line No. Instruction Operand Line No. Instruction 0000 LD 2002 0010 CON 0001 LDA DM0000 0011 TBCD 0002 CON 0012 CON 0003 MUL 0004 CON 0005 DIV 0006 CON 0007 STA 0008 CON 0009 LDA DM0001 #10000 DM0101 TM01 0013 STA 0014 CON 0015 LDA 0016 CON 0017 TBCD 0018 CON 0019 STA Operand 750 DM0101 8500 ➮ Refer to p. 3-180.
8.2 Details 8 3-358 Chapter 8 Programming Examples KVNKA Chap 08.p65 358 08.3.
Index KVNKA Index_Pro.p65 359 08.3.
Index — For Visual KV User’s Only Index — For Visual KV User’s Only The following is the index with some descriptions for your reference.
Index — For Visual KV User’s Only Purpose High-speed counter, resetting the value to "0" Title Page Resetting the high-speed counter 3-214 High-speed counter, selecting input source for Count input method 3-212 High-speed counter, specifications of Specifications of high-speed counters 3-208 High-speed counter, specifying the preset value of Preset value of the high-speed counter comparator 3-211 High-speed counter, using, as ring counter Ring counter function 3-225 I Input time constant of
Index — For KV-300, KV-10/80 User’s Only Index — For KV-300, KV-10/80 User’s Only A F A/D converter ........................... 1-312 [AN6], 1-334 [AD4] A/D conversion table ................ 1-408 [AN6], 1-357 [AD4] ADD/@ADD: Add .................................................. 3-150 AND: And ................................................................ 3-58 ANB: And Bar ......................................................... 3-58 ANDA/@ANDA: And A .........................................
Index — For KV-300, KV-10/80 User’s Only MPX/@MPX: Multiplexer ...................................... 3-176 MRD: Read ............................................................ 3-103 MUL/@MUL: Multiply ........................................... 3-150 System Configuration (Memory Card) ..................... 1-196 System specifications [Visual KV Series] ................ 1-382 System specifications [KV-300 Series] ................... 1-392 T N NEXT: Repeat End ..........................................
Index — Software/P3E (handheld programmer) Index — Software/P3E (handheld programmer) MULTI-MONITOR [P3E] ......................................... 1-212 A ACCS ...................................................................... 1-234 ALL CLEAR [FNC60] [P3E] ..................................... 1-217 ALL DATA MEMORY CLEAR (DM ALL CLEAR): [FNC64] [P3E] ...................... 1-219 ALL LATCHING RELAYS RESET (L-RELAY ALL RST): [FNC65] [P3E] ................... 1-219 B Break signal ......................
Index Index KVNKA Index_Pro.p65 365 08.3.
Index 3-366 Index KVNKA Index_Pro.p65 366 08.3.
Safety Precautions WARRANTIES AND DISCLAIMERS: This instruction manual describes the operation and function of the KV Series PLC. Read this manual carefully to ensure safe use and maximum performance from your KV Series PLC. Symbols The following symbols alert you to important messages. Be sure to read these messages carefully. Failure to follow instructions may lead to injury. (electric WARNING shock, burn, etc.) CAUTION Note: Failure to follow instructions may lead to product damage.
2 3 Installation Support Software Programming 1. Configuration and Specifications 3. Access Window 4. KV-D20 Operator Interface Panel 5. KV-10/80 Hardware 1. Introduction 2. Instructions 2. Editor 3. Interrupts 3. Simulator 4. High-speed Counters 4. Monitor 5. Positioning Control 5. Appendices 6. Interrupts, High-speed Counters, Positioning Control 6. Handheld Programmer Programming 2. System Installation 1. Programming 7. Serial Communication 8. Programming Examples 8.