KV3000 Programming Tutorial
KV3000 Programming Tutorial
This tutorial is for people who are using a programmable logic controller
for the first time. It extracts frequently used commands from the User's
Manual and describes them accordingly.
In addition, it is possible to input commands to the KV-5000/3000
and do programming based on the explanations in this book.
However, if you want to try it without connecting to the
KV-5000/3000, please replace the R000 to R005 with MR000 to
MR005, etc. and perform the contacts' ON/OFF operation using
the ladder diagram software. (When operation is based on a
simulator, it can also be performed without changing the R000 to
R005.)
KEYENCE Corporation
Control System Division
Content
-1-
Chapter 1 What is the KV-5000/3000?
[What is KV-5000/3000?]
KV-5000/3000 is a programmable logic controller with a built-in CPU and memory.
It is a device that can conveniently and freely control external output devices (such as
indicator lights or cylinder shape coils) through the operation of various external input
devices (push buttons, limit switches, etc.) equipped on the control panel and
equipment.
From a PC with the dedicated ladder support software (KV STUDIO) installed,
programs can be written into the internal memory of the KV-5000/3000.
Memory
Switchover switch Digital indicator
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
-2-
[Control in FA]
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
Sequence Control
(Continuous) (To realize desired operationtate)
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
-3-
[What is Sequential Program Control?]
The flow of sequential program control will be explained by using a real-life example of
a piece of equipment.
Example
■ When playing a claw machine ■ When using a fully automatic
game in an arcade. washing machine.
⑤ Wash
⑥ Drain water
⑦ Dry
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
The PLC will verify the condition changes under the above-mentioned
sequential program control, and is responsible for performing control
tasks until the next process. It is referred to as a “programmable
controller".
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
[What is a PLC?]
"PLC" is short for "Programmable Logic Controller".
It means "a logic controller device that can be programmed". To put it simply, it is a
computer that is used in a factory.
-4-
[Functions of the KV-5000/3000]
The KV-5000/3000 Series are PLCs with high performance and high expansibility.
In this tutorial, we will only discuss the basic aspects of the controller. However, it can
also be used in the following controls, in order to deepen the understanding of the
KV-5000/3000 PLCs.
■ An example of the functions/expansibility of the KV-5000/3000 Series
Ethernet Pressure
Flowmeter sensor
●FL-net function
It is possible to realize a high speed/high
volume data connection to PLCs of various
manufacturers using the CPU unit. ● Positioning control
It is possible to control the motor used for
positioning. Possible to perform correct
FL-net
positioning control of the XY table etc.
(CPU unit also has a built-in positioning
function.)
-5-
Chapter 2 Programming of the KV-5000/3000
END
ENDH
+ -
First, verify the wiring diagram of units. This is the wiring diagram for a battery
and a switch that we have tested in previous physical experiments.
Actually, this switch may be a sensor or a limit switch, and the light may be a solenoid
valve, a motor, etc. In such a case, the actual unit wiring is relatively hard to view.
We can then put the "+" and "-" end of the battery on the left and right side
respectively, and represent the switch (PB) and the light (PL) using symbols,
then a easy-to-view sequential program diagram is completed. A sequential
program diagram is composed of graphs and symbols developed in order to
simplify the wiring diagram when performing relay sequential program control.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
-6-
[Programs of the KV-5000/3000]
A program of KV-5000/3000 is written using many commands.
These commands are composed of an instruction (symbol) and a device number
(element number), and are divided into basic commands, application commands,
arithmetic commands, etc.
Generally, basic commands can be used to write a program, and application
commands can be used to simplify a program or to perform more complicated control.
A device number (element number) refers to the number of an input relay, an
output relay, a timer, a counter, or an internal auxiliary relay, etc. It can freely
use any number within the number range in the KV-5000/3000 PLC.
R000 R500
Device no.
Instruction
(symbol)
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
For the range of device numbers that can be used, please refer to the
list of devices in section "1-3 Devices and Constants" in the
"KV-5000/3000/1000 Instruction Reference Manual".
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
-7-
[Structure of Devices of the KV-5000/3000]
The main devices of the KV-5000/3000 are divided into the following types.
Please verify according to each device.
◆Bit device◆
【Input relay】 R
The device used to load ON/OFF information from external equipment.
【Output relay】 R
The device used to output ON/OFF information from external equipment.
【Internal auxiliary relay】 MR
The device that can only be used inside a CPU
※ When a relay circuit is used and the same relay contact is used many
times in the circuit, sometimes multiple relays with the corresponding
number of times of use have to be used. Since the internal auxiliary relay
functions only on the program level, it completely eliminates the
complexity of the relay circuit, making circuit design easier.
【Control relay】 CR
The device used to control functions of the PLC or get its states.
※ The control relay has been assigned with special functions in advance
according to the device number.
【Timer】 T
1ms/10ms/100ms down timer and 10ms up/down timer
※ It is possible to assign settings respectively according to different devices.
The number of counts that can be used is 4000.
【Counter】 C
Up counter/up and down counter
※ It is possible to assign settings respectively according to different devices.
The number of counts that can be used is 4000.
In addition, there are also latching relay (LR), link relay (B), etc.
◆Word device◆
【Data memory】 DM
The device used to store digital data in the PLC. Data will be processed in
16-bit unit.
※ For example, it is used when performing arithmetic operation in the PLC.
The data stored in the data memory will be kept even if the PLC is turned
off.
【Control memory】 CM
The device used to control functions of the PLC or get its states.
※ The control memory has been assigned with special functions in advance according to
the device number.
In addition, there also expansion data memory (EM), file register (FM), link register (W)
and index register (Z), etc.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
Bit Only processes ON/OFF
Word Processes numerical value 1 word = 16 bit (to process
2 16 =65535)
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
-8-
[Startup of the Ladder Support Software "KV STUDIO"]
A ladder program is written through the dedicated ladder support software.
The ladder support software installed on the KV-5000/3000 Series PLCs is "KV
STUDIO".
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
① Double click the KV STUDIO icon on the desktop to start the KV STUDIO.
② After the title screen appears, the edit screen will be displayed.
Let’s try to write an actual ladder diagram.
-9-
[New Programming Method with Ladder Diagram and
Initial Setting of the Units]
Before writing a ladder program with KV STUDIO, set up the unit first.
Follow the instructions below.
・ If you select "Yes", the Unit Editor will be started, and you can perform initial setup for
the units in it.
・ If you select "No", the edit screen will be displayed. You can also start the Unit
Editor while editing the ladder program.
・ If you select "Read unit configuration", the unit configuration information will
be read from the KV-5000/3000. At this point, the PC (with KV STUDIO) should
be connected to the KV-5000/3000.
- 10 -
④ Start the Unit Editor.
Here, you can perform unit setup of the KV-5000/3000 Series PLC.
What is unit setup? To specify the units that need to be added to the
KV-5000/3000 and perform basic settings for the units
(the range and functions of the device number used).
The operation of unit addition is done by dragging/dropping
and connecting the CPU unit from the "Unit selection(1)" tag
on the right of the Unit Editor screen, and the added units
can be set up through the "Unit setting(2)" tag.
- 11 -
[Writing a Ladder Program ①(LD OUT)]
After the initial setting of the units is completed, an actual ladder program will be
written as follows.
■ Example 1:a program for LD+OUT
We will write a basic program first.
・ When R000 is ON, the light R500 will be ON (light up).
For the convenience of operation, program input can be done without many input
methods. The method used in this example is the "direct input method" in which
instructions are input directly using the keyboard.
In this case, move the green cursor on the KV STUDIO screen to the position where an
instruction is to be input (a cell), and input directly using the keyboard.
END and ENDH commands represent the end of the ladder program.
They have to be entered at the very end of the ladder program.
※ When writing a new module, the END/ENDH commands will be added
automatically at the end of the program.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
"A_0" is the short form for "LD_0". "LD" stands for "LOAD", and has the
same meaning as a-contact (normally open contact).
In addition, the OUT (output) command can also be abbreviated into "O_500".
Since they are commonly used commands, please memorize them through
unique input forms.
For the short input forms for other commands, please refer to the
"KV-5000/3000/1000 Command Reference Manual".
Attention ! _ refers to a space. It is actually blank.
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 12 -
What is the Relay Number (Device Number) of the Built-In
I/O of the KV-5000/3000?
A relay number (device number) refers to the number used to distinguish between the
input equipment (sensors or switches) and output equipment (lights or motors) that are
connected to the KV-5000/3000 or the expansion units.
Up to 16 input devices can be connected to KV-5000/3000 (R000-R015), and up
to 8 output devices can be connected (R500-R507).
Input/output connector
R000 R500
- 13 -
[Transfer and Monitoring of Ladder Programs]
After writing a program, please transfer it and verify its operation.
Transfer the completed ladder program to the KV-5000/3000 series PLC, and verify the
actual operation.
PC
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 14 -
③ The dialog box for confirming project
transfer appears. Click the "Execute"
button.
- 15 -
⑥ When the R000 of KV-5000/3000 is ON, the input R000 on the ladder diagram will
light up green, and the R500 will be ON (light up green).
R000 R500
■ Inserting a line
Move the cursor to the place
for inserting a line, and press
the "Shift+Enter" buttons to
insert a line.
R000 R500
■ Deleting a line
Move the cursor to the place
for deleting a line, and press
the "Shift+Delete" buttons to
delete a line.
- 16 -
■ Example 2: a program for LDB OUT
When the switch R001 is OFF, R501 will be ON.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
"B_0" is the short form for "LDB_0". "LDB" stands for "LOAD
BAR", and has the same meaning as b-contact (normally closed
contact).
Attention! _ refers to a space. It is actually blank.
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 17 -
[Writing Ladder Programs ③ (AND circuit)]
If a circuit is ON when both contacts are ON, then it is called an "AND" circuit.
Please write a ladder program and verify its operation.
Add a ladder program after operation of line insertion has been performed.
- 18 -
[Writing Ladder Programs ④ (OR circuit)]
If a circuit will be ON when one of the two contacts is ON, it is called an "OR" circuit.
Please write a ladder program and verify its operation.
After deleting the program that has been written up to now through the line
deletion operation, rewrite the ladder program.
■ Example 5: a program of an OR circuit (OR command)
When either switch R000 or switch R001 is ON, the light R500 will be ON.
- 19 -
[Writing Ladder Programs ⑤ (Self-hold circuit)]
If the output of a circuit will be ON continuously once the contact is ON, this circuit is
called a self-hold circuit.
Please write a ladder program and verify its operation.
After deleting the program that has been written up to now through the line
deletion operation, rewrite the ladder program.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 20 -
[Relationship between Control and Time]
Often, time has to be considered when performing controlling devices.
The function of adjusting time through control is called "Timer" function.
Example ① Verify a signal input error, and make buzzer sound after 1 second.
② Verify that a work-piece has arrived, and set the cylinder to ON after 1
second.
③ After the conveyor belt has verified passing of the workpiece, it will still
move for a certain time.
The timer commands of the KV-5000/3000 are divided into the following 3 types.
Command Symbol Mnemonics Function
#dddd Decrement delay in 0.1 s
Timer
XXX TMR unit
ON timer
#dddd Decrement delay in 0.01
High speed
TMH s unit
timer XXX ON timer
High speed 1ms #dddd Decrement delay in
timer XXX TMS 0.001 s unit
ON timer
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
In addition, KV-5000/3000 also has a built-in calendar timer.
Through this calendar timer, it is possible to realize control based on
"Year/Month/Day/Hour/Minute/Second/Week" system.
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 21 -
[Control Based Upon ON Delay Timer]
In the following section, we will describe the controls in which timers are used.
On Delay Timer・・・・The timer that makes the next operation (action) delay to ON.
To perform ON delay
Error lasts 1 s
Buzzer sounds
Buzzer sounds instantly
When there is no timer, or the error signal vibrates, the buzzer will sound for a short period.
When there is a timer, the buzzer will sound only after an error signal is actually detected to
prevent mis-operation.
- 22 -
[Application of the ON Delay Timer]
In this section, we will discuss the controls in which the timer functions of
KV-5000/3000 are flexibly used.
First, let us consider a control combined with an ON delay timer and a self-hold
function.
Conveyor belt starts moving ③ When the timer is ON, the output R500 of
KV-5000/3000 will be ON and self hold.
- 23 -
[Control Based Upon OFF Delay Timer]
Off Delay Timer a timer that enables a signal in ON state to perform OFF delay.
- 24 -
[Control Based Upon a One-Shot Timer]
One-Shot Timer A timer that generates a signal that will be ON for a certain time.
After the program is entered, please transfer the program and verify its
operation.
- 25 -
[Summary of Control Based Timers]
Do you understand control based timers?
The program charts of timers used as control centers are summed up below, so
be sure to remember them. They can help reduce the time required to write
programs.
In addition, an operation timing sequence is listed on the right of the ladder for easy
understanding. Please verify the actual operation according to the timing sequence.
ON delay timer
ON
R500
OFF
3s 0.5 s
ON
R500
OFF
3s
Single-shot
After R000 is ON, output R500 will
be ON, and will be OFF after 3
seconds.
ON
R000
OFF
ON
R500
OFF
3s 3s
- 26 -
[Flexible Use of Counters]
The KV-5000/3000 PLCs can perform counting.
The device that is used to count during control is called a counter.
Let’s analyze the controls in which a counter is used.
Example
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
Whereas timer command is always decrement operation, counter
command is always increment operation.
The reason is that a counter needs to realize overflow counting (i.e., it
will continue to count even if the setting value is reached).
☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆
- 27 -
[Control of Counters]
Let’s write a control program that uses a counter.
KV-5000/3000
(Reset)
(Output)
■ Timing sequence
R000
(Count)
R001
(Reset)
Setting 10
C0
(Current value)
C0
(Contact)
R500
(Output)
- 28 -
Please write a ladder program and verify its operation.
After deleting the program that has been written up to now through the line deletion
operation, rewrite the ladder program.
Setting value of
the counter
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- 29 -
The concepts of scan time and dual coil that are familiar to us will be described
here.
The ON/OFF state of the input will be loaded during input processing; during output
processing, the results of the program execution will be output collectively.
★☆★ The PLC with shorter scan time can write a program for a device that can
perform tasks faster ★☆★
After the above ladder program is executed, the output R500 will not be ON even if the
contact R000 or R001 is ON. Only when R002 is ON, will R500 be ON.
- 30 -
[Principle of a Dual Coil]
Here we describe the reason why execution of the verified program will cause the
operations shown in Example 13.
A ladder program will not output a result after each command execution.
・・・・①
・・・・②
・・・・③
・・・・④
★ Incorrect
① ② ③
④
As described above, the PLC will not output a result after each
command execution, instead it will output total results at the end of
the scan time. Obviously, to easier for a PLC with shorter scan time
to realize high speed control.
- 31 -
[Questions Summary]
Please consider the following issues after you have learned about circuits from this
tutorial.
Normal controls as shown below can be realized by combining the basic circuits
together.
■ Question
You are a responsible person for Production Technique in a food processing company.
In order to produce and sell new products for Christmas, it is necessary to rebuild the
production equipment.
Please try to write a program for realizing the following operation.
Example ①: Whether the produced chocolate products are good or defective needs
to be decided. After being detected by the decision sensor (R000), defective
products are to be pushed out using a 3-second push lever (R500).
- 32 -
[Answers to Questions]
Example ①
☆ The key point is to use a single-shot timer.
Example ②
☆ The key point is to perform a counter reset when the buzzer begins to sound
Setting
Sensor input
Reset signal Counter
Counter
5-second timer Self-hold circuit
- 33 -
Example ③
☆ The key point is to build a self-hold circuit through the signal of the counter.
Setting
Sensor input
Counter
Job completion
indicator light
Self-hold circuit
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
The commands that have the same functions as in the self-hold circuit
include KEEP and SET/RES commands, etc.
Please verify using the following reference ladder diagrams.
Please refer to Chapter 2 "Basic Commands" in the
KV-5000/3000/1000 Command Manual.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- 34 -
[Convenient Commands]
In order to make composing ladder diagrams easier, the KV-5000/3000 Series
PLCs are equipped with many convenient commands. Here we will describe
some of the commands.
Be sure to use them flexibly in subsequent programming.
The circuits described in this tutorial are frequently used circuits when building any control
schemes.
The KV-5000/3000 PLCs have added the most frequently used common circuits that
can be used for the ON delay or OFF delay ladder programs as new commands.
A circuit with multiple lines is changed into one command through new commands
(convenient commands), which reduces the time required for programming and
realizes efficient program operation.
The ON delay timer circuit we discussed on the last page is shown as follows.
The two-line program can be realized using one line in a convenient command.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
A convenient command also has advantages/disadvantages.
The advantages are: the program is simplified, time for
programming is reduced, and scan time is shorter. In addition, it
can be used without limit, since no timer number is required.
The disadvantages are: the timer unit is only 0.01 s, and the current value
cannot be displayed during monitoring, etc. (The normal timer can monitor
the decrement state.)
Please use normal commands and convenient commands flexibly
according to different conditions.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- 35 -
Example ② The OFF delay timer circuit
The two-line program can be realized through one line in a convenient command.
・ Blinking command
★ Be sure to try to using them in the program and verify their operation!
- 36 -
[Simulator Function]
Until now, switches and other devices have been used to verify operation after a
program is transferred to the KV-5000/3000 unit. However, when configuring a
device, the PLC unit is often connected to the device. Even if you want to
perform a program test (debugging), sometimes it is not possible to verify before
the device installation is finished.
In order to avoid this kind of debugging problem, the KV-5000/3000 is equipped with a
"simulator function" in the ladder support software "KV STUDIO", through which it is
possible to debug a program without transferring the ladder program to the unit.
Here, we will describe how to use the simulator.
It is possible to verify
operation of the program by
only using a PC.
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
- 37 -
① First, write the program as shown below.
This is the program written by using the ON delay timer through a common method,
in which convenient commands are used.
After the input R000 is ON, it is possible to verify that the normal command and the
convenient command have set output R500 and R501 to ON simultaneously.
Output R500
Output R501
③ Change to the simulator screen, and click the "Execute continuous scan" icon.
The ladder program will run on the PC.
- 38 -
④ On the simulator screen, double click a contact on the ladder program to switch
the input ON/OFF。
Try to double click the input R000. The input will be ON, and the timer will
begin to operate.
⑥ On the simulator screen, double click the contact on the ladder program again.
The input R000 will turn OFF, and the timer will reset.
- 39 -
MEMO
- 40 -
[End]
Were you able to understand and grasp the content in this tutorial?
If you have any questions about the content in this tutorial, please contact our
company's business office.
The personnel of each business office are ready to help you.
You are also welcome to purchase any of our products in the future.
※Model number, specifications, and other information are subject to change without notice
- 41 - 1094-1 600F63