Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
Manual
-
CONTENTS
[★★] indicates the level of importance.
-1- KV0475E_C
-
-2- KV0475E_C
-
Appendix
Installing the USB Driver [★★★] P127
Useful Functions Categorized by Situation [★] P129
-3- KV0475E_C
-
Chapter1
Hardware setting
-4- KV0475E_C
-
1. Appearance
The KV-5500/5000/3000 Series’ CPU has a built-in input/output and is equipped with a liquid crystal display, as
shown in the photo below.
CPU UNIT
Ethernet/EIP port
USB port
EXPANSION UNIT
The hyper access windows and the direct access switches appear in either green or red.
When the hyper access windows appear in red, it indicates some sort of error status (or stop mode), so the
error must be eliminated.
When the direct access switches are red and the hyper access windows are green, an error has occurred in
the unit only. The CPU is still operating.
-5- KV0475E_C
-
2 Size
3 Unit Configuration
You can connect a maximum of 48 units.
(Maximum of 16 units side by side and a maximum of 3 levels high)
-6- KV0475E_C
-
4 Installation
A 24V supply terminal is located at the bottom of the CPU. You do not need a dedicated power supply unit for the
KV-5500. (KV-U7)
Battery life is 5 years at +25°C. The life will be shortened if the battery is used at higher temperatures.
If [CPU Error No83] is displayed in the access window, you must replace the internal lithium battery immediately.
If a battery error occurs, CR2306 turns ON.
Data can be retained for at least 1 week (at normal temperature) after a battery error occurs.
-7- KV0475E_C
-
5 Device Memory
[DEFAULT FORMAT]
Default
Item Specification Range
Format
Input relay R
Output relay R Total 16000 points 1 bit R000 to R99915
Internal auxiliary relay R
Link relay B 16384 points 1 bit B0 to B3FFF
Internal auxiliary relay MR 16000 points 1 bit MR000 to MR99915
Latch relay LR 16000 points 1 bit LR000 to LR99915
Control relay CR 640 points 1 bit CR000 to CR3915
Timer T 4000 points 32 bits T0 to T3999
Counter C 4000 points 32 bits C0 to C3999
Data memory DM 65535 points 16 bits DM0 to DM65534
Extended data memory EM 65535 points 1 bit EM0 to EM65534
Current bank mode FM FM0 to FM32767 x 4 Bank
File register Consecutive 131072 points16 bits
ZF ZF0 to ZF131071
number mode
Link register W 16384 points 16 bits W0 to W3FFF
Temporary memory TM 512 points 16 bits TM0 to TM511
High-speed counter CTH 2 points 32 bits CTH0 to CTH1
High-speed counter comparator CTC 4 points 32 bits CTC0 to CTC3
Index register Z 12 points 32 bits Z01 to Z12
Control memory CM 6000 points 16 bits CM0 to CM5999
[Bit Device]
R10000
Channel Bit
DM0 0 0 0 0 and so on
The number is assigned serially.
-8- KV0475E_C
-
[XYM FORMAT]
On the KV-5500, you can switch the device memory to XYM mode.
Display
Item Specification Range
By XYM
Input relay X X0000 to X999F
Output relay Y Total 16000 points 1 bit Y0000 to Y999F
Internal auxiliary relay R R00000 to R99915
Link relay B 16384 points 1 bit B0000 to B3FFF
Internal auxiliary relay M 16000 points 1 bit M00000 to M15999
Latch relay L 16000 points 1 bit L00000 to L15999
Control relay CR 640 points 1 bit CR0000 to CR3915
Timer T 4000 points 32 bits T0 to T3999
Counter C 4000 points 32 bits C0 to C3999
Data memory D 65535 points 16 bits D0 to D65534
Extended data memory E 65535 points 1 bit E0 to E65534
Current bank mode F F0 to F32767 x 4 Bank
File register Consecutive 131072 points16 bits
ZF ZF0 to ZF131071
number mode
Link register W 16384 points 16 bits W0 to W3FFF
Temporary memory TM 512 points 16 bits TM0 to TM511
High-speed counter CTH 2 points 32 bits CTH0 to CTH1
High-speed counter comparator CTC 4 points 32 bits CTC0 to CTC3
Index register Z 12 points 32 bits Z01 to Z12
Control memory CM 6000 points 16 bits CM0 to CM5999
-9- KV0475E_C
-
Chapter2
Software setting
- 10 - KV0475E_C
-
Starting KV STUDIO
1 On the desktop, double click on the icon to start "KV STUDIO".
Initial screen
Creating a project
A project is a management program that collects ladder programs, unit setting information, comments and other
information.
Other procedure Select "File (F)" -> "New project (N)" from the menu.
- 11 - KV0475E_C
-
4 The "New project" dialog box appears. Enter the information for the project to be created.
Enter a comment to be
displayed in the access
window.
See the column field for
details. Enter a comment for the project to be created.
This is not required but recommended.
If one or more units to be added to a PLC you are using are already determined, click the "Yes" button.
Once the "Unit Editor" is started, you need to set the unit configuration you use.
If one or more units to be added to a PLC you are using are not yet determined, click the "No" button. (The
unit configuration setting can be done later.)
If a PLC that one or more units are already added to is able to communicate with KV STUDIO Ver. 6 (PC),
click "Read unit setting" to read the unit setting information from PLC.
Unit Editor
STEP4
- 12 - KV0475E_C
-
KV-U7
KV-5000
KV-AD40
KV-U7 : Power supply unit
KV-5000 : CPU unit
KV-AD40 : A/D convert unit
5 From the "Select unit" tab, drag and drop a unit to be connected to the CPU.
The units that are actually used in the project are displayed next to each other.
- 13 - KV0475E_C
-
When a message box appears to confirm whether to auto-assign relay/DM, click the “OK” button.
Relay/DM numbers are automatically assigned, and numbers appear on the units in the unit configuration
area.
Tip Click the appropriate icon on the toolbar to change the unit display.
Each click toggles between box/bitmap display of the unit.
- 14 - KV0475E_C
-
I/O assignment/other settings
Manual assignment
The device numbers that are assigned to each unit should be set to any number of your choice.
Double click on the connected unit, and then Relay setting should
change the device number from the "Setup unit be set to channel
(2)" tab. numbers, not to
device numbers.
If the assigned numbers contain errors, error messages appear in the message area.
If there is an error, the project cannot be transferred to PLC.
- 15 - KV0475E_C
-
7 Set up the added units.
Set up the added units other than the unit relay/DM.
Click the setting value of an item that can be charged. (Grayed out items cannot be set up)
If a pull-down menu appears, select the setting item from the menu. If a pull-down menu does
not appear, enter your setting directly.
An asterisk (*) at the end of the setting value indicates that the setting is a default setting.
- 16 - KV0475E_C
-
* Skip any CH that you don't want to use.
The numbers for input output relay can be set in the range of R1000 to R99900, and the numbers for data
memory in the range of DM0 to DM65534.
In the initial setting, the relay numbers have been batch assigned from R30000 (300ch) and DM
numbers from DM10000.
You can set the Unit Editor so that numbers are separately assigned to relay numbers by specifying them
respectively to the input unit, the output unit, and the special unit.
Once the units are configured, the overall width, height, depth,
weight and current consumption of the units a linked
connection are calculated automatically and then displayed.
- 17 - KV0475E_C
-
Item Description
“Batch chg (O)…” Batch-changes shortcut keys to Default format, GPPQ format,
GPPA format and CX format.
Shortcut key “Read (R)…” Reads saved setup files (*.key) for shortcut keys.
create “Save (S)…” Saves the settings of customized shortcut keys.
“Initialize (I)” Returns shortcut key settings to their defaults.
“Reg/delete keys (A)…” Registers/deletes shortcut keys.
3 Select the appropriate key format and click the "OK" button.
- 18 - KV0475E_C
-
”Default format”
”XYM format”
* Setting the XYM format may result in some parts being left unchanged.
For details, please refer to pages 6 and 7.
- 19 - KV0475E_C
-
The function that automatically adapts to I/O
After one or more ladder programs are created, and if you want to change the device
numbers of the connected units, the device numbers in the ladder programs are
automatically converted to the new numbers by changing the settings of the device
numbers with the Unit Editor.
Use the Unit Editor to change the device numbers assigned to the units.
Once you're finished, return to the Ladder Editor to make sure that the device numbers have changed automatically.
A list of the devices that have been automatically converted appears in the Output window.
- 20 - KV0475E_C
-
2 Select "Detail".
- 21 - KV0475E_C
-
4 Select "Reg".
Check the appropriate unit to be registered, and select "Reg".
5 Comments for the devices uniquely controlled by the special unit are registered automatically.
- 22 - KV0475E_C
-
3) Completed
- 23 - KV0475E_C
-
Entering commands
Many different ways of entering commands are supported.
- 24 - KV0475E_C
-
Performing a reverse lookup of device numbers from device comments -RT EDIT-
Enter a device comment to perform a reverse lookup of device numbers.
- 25 - KV0475E_C
-
Expanded ladder mode
Multiple out coils can be entered in a rung.
OR circuits, which are regularly used for programming, help to reduce the number of rungs.
If you are not familiar with OR circuits, uncheck the "Expanded ladder mode".
Select the "Edit" "Edit mode" "Expanded ladder mode" to uncheck the Expanded ladder mode.
Select an unknown command on the Editor, and then simply press key. The correct page of
the INSTRUCTION HELP opens.
- 26 - KV0475E_C
-
Shortcuts
Shortcut key list
Select "Help (H)" "Shortcut key list (K)" from the menu. The shortcut key list (PDF), which is useful when entering/editing ladder
programs, appears.
The Shortcut key list is included in the Appendices section of the “KV STUDIO User's Manual”.
- 27 - KV0475E_C
-
Entering mnemonics
You can also use a mnemonic language to enter ladder programs. Mnemonic programs created with a text editor (including Notepad)
can be copied and pasted.
Select "Edit" "List edit" from the menu to open the "List edit" window.
Other procedure
- 28 - KV0475E_C
-
Programming considerations
This section describes some considerations specific to programming.
(1) Timer
The timers for KV-5000/3000 are all 32-bit timers.
The settings can be specified in the range of Unsigned 32 bit (0 to 4294967295).
The unit of measure for timers, which is specified by a command, is not dependent on timer
numbers.
T 100ms
TH 10ms
TS 1ms
TU 10μs
A timer uses a subtract method. When the setting is 0, it is instantaneously ON.
The current values/contacts, updated when the T/TH/TS command is run, are more precise
and sophisticated than those updated when a batch process is executed by the END
processing.
Note) Two (2) words are occupied when the timer's setting is done with one or more
devices.
(2) Counters
The counters for KV-5000/3000 are all 32-bit counters.
The settings can be specified in the range of Unsigned 32 bit (0 to 4294967295).
There are two types of counters. One is counted by power rail, and the other reset by power
rail, either one of which is selectable.
- 29 - KV0475E_C
-
- 30 - KV0475E_C
-
Software layout
Various windows/dialog boxes, which are set to floating by default, can be docked to the main window of the KV
STUDIO.
Docking Navigator
Displayed when the mouse cursor is held on the Ladder Editing window.
Docked to the up/down, left/right position of the Ladder Editing window
when the mouse cursor is dropped onto these marks.
Appears when the mouse cursor is held on the workspace or the output
window.
Docked to the up/down, left/right position of the Docking target window
when the mouse cursor is dropped onto these marks.
Appears as a tab on the Docking target window when dropped onto the
center of the Docking Navigator.
- 31 - KV0475E_C
-
Docking assist
The docking position appears in a grid form on the image when the docking window or the dialog box is held on the
Docking Navigator.
The docking is
completed
- 32 - KV0475E_C
-
Auto-hide function
The ladder editing pane area becomes narrower when many windows and dialog boxes are displayed to create
ladder programs.
The Auto-hide function helps to only display the workspace, the output window or the watch window as necessary,
keeping the ladder editing pane as wider as possible.
Ladder editing pane
Workspace
Device comment
edit window
Output window
Output window
Click the PIN icon located on the top right corner of the up/down and left/right workspace, output window, or watch
window so that tabs appear.
A tabbed window or dialog box will be expanded by simply holding the mouse cursor over it.
Icon Description
- 33 - KV0475E_C
-
The KV STUDIO allows you to use an "ON/OFF delay circuit", a "One-shot circuit", or "Alternate circuit" which is often used as a timer.
The KV STUDIO allows you to use the Script language to describe ladder programs. Script-specific functions (command), like ABS
function, are available.
- 34 - KV0475E_C
-
Writing programs
Created ladder programs are written to the "KV-5000" that is connected to a PC.
Make sure that the "KV-5000's behavior selector switch" is set to the RUN mode position.
RUN 側に
Set in RUN
します。
mode
position
Select "Monitor/Simulator (N)" "Transfer to PLC -> Monitor mode (C)" from the menu.
Other procedure
Select "Transfer to PLC Monitor mode (C)…" to convert the target/transfer ladder programs to machine codes.
- 35 - KV0475E_C
-
Item Description
Items for which a checkbox has been selected are transferred to PLC.
Transfer items (I) Additionally, the detailed information of the selected item is displayed in the
transfer item information area on the right side of the dialog box.
Transfer item info The contents displayed may vary with different transfer items selected.
Only the item name is displayed for items for which detailed settings are not
display area necessary.
“Select all (S)” Selects the checkbox of all transferred items.
“Cancel all (D)” Deselects the checkbox of all transferred items.
Clear module/macro in If this checkbox is selected, the module/macro written into PLC is cleared before
PLC (Q) transfer, and then the project is transferred.
Transfer in If this radio button is selected, PLC is temporarily switched to the PROGRAM
PROGRAM mode (P) mode, and then the project is transferred.
If this radio button is selected, the project is transferred in RUN state.
Transfer in RUN mode
When the program is transferred in RUN state, some contents of the "Unit setting
(R)
info" and the "CPU system setting" cannot be transferred.
If the "Transfer program" dialog box appears, it means that the writing is ready to start.
Check the transfer item, and then click the "Execute" button to transfer the program.
- 36 - KV0475E_C
-
The following message appears in the "Output window".
The contents of each error appear in the "Output window". Refer to them to modify the program.
Module name
Line number
Column number
Error contents
For which an error
occurred, are shown.
In addition, click the error message in the "Output window" so that the cursor moves to the head of the appropriate
rung from the "Ladder Editing window".
The cursor moves to
the ladder rung that
shows the error
message.
Tip Even if there are two or more errors in the program, or even if the whole module is not correct, all the
errors appear in the "Output window" so that the cursor can easily jump to each error.
- 37 - KV0475E_C
-
Disabling of rungs
Save project as
Save a ladder program on the PC.
- 38 - KV0475E_C
-
Chapter3
Software debugging
- 39 - KV0475E_C
-
Debugging procedure
This chapter explains the general debugging procedure.
- 40 - KV0475E_C
-
* ”Read from PLC ->Monitor mode”…This option reads the program and then activates monitor mode.
“Read from PLC”…This option only reads the program.
【Execute】をクリックします。
- 41 - KV0475E_C
-
Mode Switching
When you access the PLC from a PC, you can switch between several modes.
When programming on the desktop, use the Editor and Simulator modes.
When debugging a program, use Monitor mode and Online Editor.
main unit.
- 42 - KV0475E_C
-
Instructions for
Input Output
timer, etc.
ON
OFF
- 43 - KV0475E_C
-
- 44 - KV0475E_C
-
[Registration monitor]
Registration monitor is for registering any device, and displaying and changing the current values of registered
devices. This monitor comes in handy for batch-checking different types of devices.
* To add a device to Registration monitor, select the device you want to add and drag it to Registration
monitor.
- 45 - KV0475E_C
-
3) To view a created monitor, click “Monitor/Simulator” and then “Custom Monitor”. The created file
opens.
- 46 - KV0475E_C
-
[Unit monitor]
Unit monitor is a monitor window that is optimized for each expansion unit. Unlike Registration monitor and Batch
monitor, relay and DM values can be viewed easily thanks to the dedicated window for expansion units.
Note Unit monitor can be selected from the menu only in Monitor or Online editor.
- 47 - KV0475E_C
-
KV-AD40 unit monitor KV-C32XC unit monitor
KV-L20V unit monitor
- 48 - KV0475E_C
-
Device search ( + )
Search for the location of R515 from the device numbers.
- 49 - KV0475E_C
-
3 Place the cursor on contact R15000 (1st cell in 50th line) to jump from contact to coil.
The instruction words that correspond to the contact/coil jump are as follows:
Contact instructions : LD, LDB, LDP, LDF, LDPB, LDFB, STP, STG instructions
Output instructions : OUT, OUB, SET, RES, KEEP, DIFU, DIFD, ONDL, OFDL, SHOT,
FLIK, ALT, TMR, TMS, TMH, C, CTH, RFSX, RFSY, SFT, JMP, W-ON, W-OFF,
W-UE, W-DE, FRSTM, FRLDM, PMOV, BSR, BSL, RCOM, CTC instructions
Tip If there are duplicate coils, the search is conducted in sequence from the currently selected cursor line.
Each time the key is pressed, the focus shifts to the next coil.
Select an output instruction (coil) and press to move the cursor to the corresponding contact.
Tip If there are multiple corresponding contact instructions, the search is conducted in sequence from the
currently selected cursor line. Each time the key is pressed, the focus shifts to the next contact.
- 50 - KV0475E_C
-
Place the cursor on contact R15000 (1st cell in 50th line) and press the key.
Use the same procedure to check the cause of output of each contact until you reach contact R10003 in the 7th
line of the ladder program.
4 Repeat the same procedure and press the key on a contact (execution condition).
- 51 - KV0475E_C
-
[Other searches]
Cross reference ( )
Clicking the Space key while the cursor is placed on a contact shows you where and with
what instruction words the contact is being used.
You can also sort contacts according to the sequence in which they appear or by
instruction words.
Select “Tool”“Option”“Setup edit/key”, and then click the “Start up direct entry by ESC key” check box.
- 52 - KV0475E_C
-
- 53 - KV0475E_C
-
5 Register forced set for R10003, register forced reset for MR2002, and switch OUT MR3000 to ON.
Select “Forced set/reset register (X)”→“Set register (S)” from the menu that appears by right-clicking contact
R10003.
Likewise, click “Reset register (R)” for MR3001.
You can also register forced set/reset from the “Forced set/reset register” dialog box.
From the menu, select “Debug (D)”“Forced set/reset register (X)”.
- 54 - KV0475E_C
-
Derivation monitor
Derivation monitor monitors the rising and falling count for the specified bit device.
You can monitor up to 4 devices. “Debug”“Derivation monitor”
- 55 - KV0475E_C
-
Tip Real time chart monitor records changes in bit devices and word devices.
Scanning of the PLC does not stop even if trigger conditions are met on Real time chart monitor.
Other procedure
- 56 - KV0475E_C
-
2 In the “Transfer program” dialog box, click “Execute”.
Click the “Execute” button without changing any of the transfer items.
In RUN mode, a dialog box is displayed to confirm overwriting.
Click “Yes”.
When program transfer is completed, KV STUDIO switches to Monitor mode.
With the 5th and 6th lines of the “KnightRider” module selected, right-click to display the menu and open
Registration monitor.
Current mode
Registration monitor
3 From the “Registration monitor” dialog box, start “Real time chart monitor”.
Select “Real time chart monitor (H)” from the menu that appears by right-clicking in the “Registration monitor”
dialog box.
Real time chart monitor starts.
Other procedure You can also start Real time chart monitor from the menu that appears by right-clicking
in the ladder edit window, from the KV STUDIO toolbar or the icon on
Real time
chart monitor
the desktop.
- 57 - KV0475E_C
-
Tip Adding a contiguous device
Confirm that the cells (blank cells) below the registration device R500
in the Devices list are selected, and press on the keyboard.
Other procedure Select “Increment registration (I)” from the menu that
appears by right-clicking the device to be incrementally
registered.
Tip You can also register a device in Real time chart monitor by selecting
the device to be registered from the ladder editing window and
dragging & dropping it.
You can register a total of 24 devices in Real time chart monitor: 16 bit
devices and 8 word devices.
Other procedure
From the Real time chart monitor
menu, select
“Communicate (C)” “Start
tracing (S)”.
•
- 58 - KV0475E_C
-
5 Stop monitoring (tracing).
Other procedure
From the Real time chart monitor menu,
select
“Communication (C)” “Stop tracing (E)”.
- 59 - KV0475E_C
-
Measuring a waveform
Use the cursor to measure a sampled (traced) waveform.
2 Select cursor A and click the position where you want to start measuring the waveform.
Fine adjustments will be made in the next step, so position cursor A by clicking near the measurement start
position.
Cursor
You can also adjust the position by dragging the cursor with the mouse.
When the mouse pointer is placed over the cursor, the cursor changes to .
You can then adjust the position by dragging the cursor.
You can even zoom in/zoom out the grid.
Zoom in/zoom out horizontal grid: (horizontal zoom in) / (horizontal zoom out)
Zoom in/zoom out vertical grid: (vertical zoom in) / (vertical zoom out)
If this happens, clicking the icons in the toolbar automatically adjusts the display position of the cursor so that it appears in the
center of the display area.
- 60 - KV0475E_C
-
4 Select cursor B and click the measurement end position.
As with cursor A, click near the end position and then finely adjust it.
Cursor A Cursor B
Displays the positions (assuming data starts at 0) Displays the distance (sampling count)
and date/time of cursors A and B. and time (ms) between cursors A and B.
- 61 - KV0475E_C
-
- 62 - KV0475E_C
-
Tip
- 63 - KV0475E_C
-
Break function
The KV-5000/3000 has various functions that support debugging. A break is a function that momentarily stops the
KV-5000/3000 at the desired step, enabling status confirmation at intermediate steps and during ladder execution,
which has conventionally been difficult to perform.
You can use the break function only during monitoring/simulation.
Device break
A device break invokes a break when there is a change in status of the specified bit device or depending on the
value of a word device.
At any one time, you can set up to 1 condition for monitoring, and up to 16 conditions for simulation.
From the menu, select “Debug (D)”“Setup device break (B)” and set the conditions for implementing a break in
the “Setup device break” dialog box that appears.
Other procedure From the right-click menu, select “Setup device break (K)”.
Click the icon.
Example Transfer the sample project “Seminer03_Device_break” to the PLC and switch it to the
monitor status. (Set the PLC to RUN status.)
*For details on the monitor procedure, see P.31 of this text.
The current values of the devices DM2800 to DM2808 displayed in the Registration monitor window
change in the range 0 to 15.
Change in the
range 0 to 15
- 64 - KV0475E_C
-
Next, set the device break conditions.
DM2810 is a device that increments the current value once every 2 seconds, so add a condition to
cause a device break to be invoked when the current value of DM2810 reaches 50.
In the “Setup device break” dialog box, click the “OK” (or “Apply”) button.
When the current value of DM2810 reaches 50, a device break is invoked and scanning stops.
indicates the
ladder line where the indicates the step
scan stopped where the scan
stopped
- 65 - KV0475E_C
-
To resume a scan, delete the break conditions from the “Setup device break” dialog box and then click the RUN
icon .
After a break occurs, the icons (Execute 1 step), (Execute 1 scan), and (Execute 1 block)
become available.
To delete a break point, double-click .
After registering CR2012 (calculation error), click the “OK” or “Apply” button to cause the break conditions to take
effect.
Setting “MR000” to ON in the “Registration monitor” window causes a calculation error break to be invoked.
- 66 - KV0475E_C
-
Line break
You can activate the break function at any location (step) in a ladder program.
Unlike a device break, scanning always stops at a specified break point.
You can specify a maximum of 4 break points at any locations within a mnemonic list.
- 67 - KV0475E_C
-
When an error occurs on KV-5500/5000/3000 and is indicated on the access window, the error remains on
the access window even if you eliminate the cause of the error. (The same applies even if the power is
momentarily turned OFF.)
If the indicated error is minor, you can resolve it by pressing a switch on the CPU.
(A prerequisite is that the error must have been resolved.)
To reset an error display by momentarily turning OFF/ON the unit, select “View”“CPU system setting” from
the KV STUDIO menu. Then, in “Operation during error” check “Eliminate CPU error when power ON”.
- 68 - KV0475E_C
-
In KV STUDIO, select “View”. In “CPU system setting”, select “System setting”. Then, in “Operation
during error”, change CPU operation when a calculation error or unit error occurs to “Continue (ignore)”.
- 69 - KV0475E_C
-
You can use the access window to monitor and set up any unit by pressing the direct access switch on any
expansion unit or special unit such as an I/O unit connected to the CPU.
To return the window for an expansion unit or special unit to the original window, press the direct access switch of
the unit currently displayed on the access window again.
Device mode
This mode enables you to monitor and change the values of the PLC device.
- 70 - KV0475E_C
-
[Error monitor]
The Error monitor enables you to check the error status and log of the PLC.
“Debug”“Error monitor”
- 71 - KV0475E_C
-
[PLC verification/synchronization]
This function verifies the data in a PC against the data stored in the PLC.
Verifying a program
Process the checked items by clicking “Verify”, “Write to PLC”, or “Read from PLC”.
Verification results
- 72 - KV0475E_C
-
Chapter4
Advanced programming
- 73 - KV0475E_C
-
Modules
Conventional PLC executed one program per project, but the KV-5000/3000 operates several programs per project.
The KV-5000/3000 does not execute an entire program at each scan, as was the case with conventional programs.
Instead, by managing a split program as independent parts (modules), it can execute just the program required in
circumstances.
Before you start programming, split the entire program into modules according to types that you have determined
beforehand.
Once you have completed each individual module, create a program that controls the timing at which the modules
will be started and stopped.
- 74 - KV0475E_C
-
[Types of modules]
Every-scan module
The every-scan module is a module that is executed at every scan when the KV-5000/3000 is in RUN mode.
One every-scan module is automatically created when a new project is created.
A project requires at least one every-scan module.
Initialize module
The initialize module is a module that is executed only at the first scan when the KV-5000/3000 starts
operating (when the power is turned on and PROG switches to RUN). (This module cannot be started at the
second or subsequent scans.)
This module is used for initializing each unit or function.
Standby module
The standby module is a module that does not execute until a start instruction (MDSTRT instruction) is
executed by another module.
After module startup (after the MDSTRT instruction is executed), this module is executed at every scan,
similar to the every-scan module. It continues operating until a stop instruction (MDSTOP instruction) is
executed.
Fixed period module
The program within a fixed period module is executed at a previously specified period and separately from
the usual scans. You can use only 1 fixed period module per project.
Similar to an interrupt program, fixed period execution is permitted/prohibited by the EI/DI.
Set the period (0.2 to 6000ms), etc., in “CPU system settings”.
- 75 - KV0475E_C
-
Verifying startup/stop of a module that uses the sample project
“Seminar04_Module_switch”
Switch operation (modules) using an external input such as switches or indicators.
In cases where work of various types is conveyed along a single line, operation must be changed for each type of
work. This can be accommodated by determining the type of work immediately beforehand and switching the
program for each type. If a type is added, the program can be changed easily by adding a module.
Check the module execution order using the seminar project “Seminar04_Module_switch”.
- 76 - KV0475E_C
-
Description of a module control (every-scan module) ladder program
The following shows a ladder program with the module name “process switchover”.
Instructions operate by a rising or falling edge. An active module remains active until the stop
instruction is executed, and a stopped (standby) module remains stopped until a start instruction is executed.
However, start/stop cannot be controlled for an initialize module.
System device
The module within a ladder indicates the active bits of a module. When a module with the contact name
“_module-name” is active, the contact is ON.
Apart from “Active bits”, the system device contains a “bit that turns ON only one scan at start of
module/macro execution (@CR2008)” and a “bit that turns OFF only one scan at start of module/macro
execution (@CR2007)”.
* For details on the system device, refer to “Module system device” (page 3-105)” in the
“KV-5000/3000 Series User’s Manual”.
- 77 - KV0475E_C
-
Procedure for checking operation of “Seminar04_Module_switch”
When SWITCH (R000) is turned ON, the LED for R500 to R515 switch.
10 In the “Monitor” tab of Workspace, check the modules that are currently active.
Select the “Monitor” tab in Workspace.
- 78 - KV0475E_C
-
11 Turn Switch 0 from OFF to ON, and verify that the module’s startup status changes.
The flashing of the I/O monitor lamps beside the access window enables you to check differences in the
operations of each module.
Switch 0 Switch 0
OFFON OFFON
- 79 - KV0475E_C
-
Bookmark function
The bookmark function treats a line comment as a “bookmark”. It is useful for modules that contain a large number of ladder lines or
when you want to create a program without splitting it into modules.
MODULE
BOOKMARK
- 80 - KV0475E_C
-
Local device
A local device is a device that can be used independently in a module or macro. Since it is treated as a separate
device, even if it uses the same device number in multiple modules or macros, it eliminates the need to manage
assignment of devices used in modules and macros.
To use a device as a local device, simply add “@” to the beginning of the device’s name.
Simply add @
The characters
are a different
color
- 81 - KV0475E_C
-
- 82 - KV0475E_C
-
Verifying operation of local timers using “Seminar05_Local_device”
1 Transfer the sample project “Seminar05_Local_device” to the PLC and switch to monitor
mode. (Switch the PLC to RUN status.) Check the operating status of each timer using Registration
monitor. In the Registration monitor window, register the local timer and the global device
R500 for the module name “Operation start complete”.
- 83 - KV0475E_C
-
Timechart
Watch window
Using watch window makes it easy to display a device’s current values.
However, use the Registration monitor window if you want to display
different module/macro devices at the same time or several windows.
To display the watch window, from the right-click menu, select
“Display/hide watch window (M)”.
For details of how to use watch window, see page 101.
- 84 - KV0475E_C
-
▪▪▪
▪▪▪
R30000 to R40000
No assignment required No assignment required No assignment required ▪▪▪ DM10000 to DM20000
Thus, compared with programming that uses conventional global devices only, there is virtually no need for the
burdensome process of mapping devices, thanks to the use of “split programming” and “local devices”. In
addition, “re-use of ladder programs” and “joint programming by several engineers”, previously difficult to
implement, are now possible.
- 85 - KV0475E_C
-
If a unit device in the modules and macros to be copied & pasted is being used,, the device must be replaced.
If you copy & paste the “Step control” module of the seminar sample project “Seminar 03A_Save library 1”, the “Replace devices
assigned to unit” dialog box is displayed.
By registering highly versatile modules into the module library, you can easily use them any number of times. The
module library is a library managed by KV STUDIO. It is not project-dependent, so the contents registered in the
module library differ from PC to PC.
- 86 - KV0475E_C
-
KV-AD 40
KV-5000/3000
KV-U7
Inspection station
Unit configuration
KV-C6 4XC
KV-C6 4 TC
KV-AD 40
KV-AD 40
KV- MC2 0V
KV-5000/3000
KV-U7
Measuring station
Inspection station
The project that borrows the module contains two AD convert units. One is used as an inspection
station, and the other is used as a measuring station. When a module is borrowed, the device
numbers assigned to units also change, so the device numbers of units at the registration destination
must be changed (replaced). If you use the module library, KV STUDIO automatically evaluates the
differences between the unit configuration at the registration source and the unit configuration at the
registration destination. The dialog box for replacing the device numbers is displayed, so replacing
unit numbers is easy (you simply have to select a unit number).
- 87 - KV0475E_C
-
Changing the device number assigned to a unit
If a unit device is being used in a module that is to be borrowed (that is registered in the module library), the
window shown below will always open. Select the appropriate unit from the pulldown menu.
The process shown above automatically replaces the unit device that was being used in the module with the
device number assigned to the selected unit.
- 88 - KV0475E_C
-
MACRO_A
KV-5000/3000 allows you to give any name to a ladder circuit that is repeatedly used within a project and register it as a macro.
Registering a ladder circuit as a macro makes it possible to use a user’s ladder program as an original instruction word, which facilitates
programming.
- 89 - KV0475E_C
-
With conventional programs that used subroutines, it was necessary to replace the device before a subroutine could
be used in a different program. Using a macro eliminates the need to replace the device.
In addition, a subroutine cannot contain any arguments (exchange of values between the main program and the
subroutine program), so it was necessary to set a device for accepting the values. However, macros can contain
arguments, so they can easily accept values.
- 90 - KV0475E_C
-
You can write a macro call instruction by simply selecting the “Macro” tab in Workspace and dragging & dropping a
registered macro.
Correct
The modification itself is not so If the same circuit is used many times, the same
difficult, but... correction must be repeated in all circuits.
Once a macro has been registered, simply correcting one of the macro’s ladder circuits corrects the same circuit in
all ladders.
Macro_A Macro_A
Correct
Macro_A
Macro_A Macro_A
Macro_A
Macro_A
- 91 - KV0475E_C
-
1) With the cursor on the target macro, right-click and then click “Module/macro property”.
- 92 - KV0475E_C
-
Module
Call
Argument settings
The macro program determines whether an argument specified when calling the macro is P (pass device) or V
(pass constant).
The devices and constants allocated to P and V are determined by the macro call instruction.
- 93 - KV0475E_C
-
STEP 1 : Extract processes and functions (planned to be) used several times within a program.
The macro is now ready for use. Use the macro’s exclusive instruction to call the macro.
Macro setup is
now complete
- 94 - KV0475E_C
-
STEP 2
Decide on the STEP 2 Decide on the macro type.
macro type.
Based on the details of operation, decide whether to select “Subroutine macro” or “Self-hold
macro” for the extracted processes and functions.
STEP 4
Create a
program.
STEP 5
Register the
arguments.
Other procedure Right-click in the “Ladder editing” window and select ”Edit
STEP 6 macro (M)”→”New macro (N)” from the menu that appears
Call the created Click the toolbar icon .
macro.
STEP 7
Check macro operation.
- 95 - KV0475E_C
-
Next, select a macro type.
STEP 1
Extract processes
and functions often
used in a program.
STEP 2
Select the macro type. Decide on the
macro type.
When you have entered all values, click the “OK” button.
The “Macro argument settings” dialog box is displayed. Close it.
STEP 3
The “Macro argument settings” dialog box is explained in STEP 5.
Create a
macro.
STEP 4
Create a
program.
STEP 5
Register the
arguments.
STEP 6
Call the created
A new subroutine macro*
macro.
with the name “Macro_A”
was created
STEP 7
* You can create a self-hold macro in the same way. Check macro operation.
For details on macro types, refer to “Macro types” (page 3-112) in the
“KV-5000/3000 User’s Manual”.
- 96 - KV0475E_C
-
STEP 3
Create a
macro.
Sample macro ladder program (subroutine)
Argument 1
STEP 4
Create a
program.
STEP 5
Register the You can enter P0 and
arguments. V0 in the same way as Argument 2
a normal device.
STEP 6
Call the created
macro.
STEP 7
Check macro operation.
- 97 - KV0475E_C
-
About macro arguments
Argument “P”
Specify P if the device itself is to be accepted. The value of the device passed as P can be rewritten within the macro, so P can be
used as the return value.
You can also pass table data to a macro by modifying the index of P.
Macro B
Argument pass
Main module
DM1000
・
・・・
・・
DM1001
・
・
Call DM1002
・・
・・
DM1003
・
・・・
・・
Return value
* Example of passing table data
Argument “V”
Use V if a constant or a value stored in a device is to be passed. A device passed as V directly passes the value stored in the device,
so the contents of the device cannot be rewritten.
Therefore, use V when setting a different device as an argument before and after execution of the macro would be a problem, or
when you want to use a constant as an argument.
Describing arguments
Specify P (P0 to P9) or V (V0 to V9) as a macro argument. You can specify a combined total of 10 P and V arguments.
Argument types
Argument type is determined according to the instruction word called within a macro or the suffix of the script. P0 indicates DM1000
Ladder program or DM1001 (32 bit
The argument type changes depending on the suffix of an instruction word described in the ladder.
Call
Script program
When a program is described using a script, the argument type changes if a suffix is given to P or V.
Call
- 98 - KV0475E_C
-
STEP 2
Decide on the Other procedure In the “Ladder editing” window, right-click and from the menu that
macro type. appears, select ”Edit macro (M)””Macro argument setting (Z)”.
Click the toolbar icon .
STEP 3
Create a
macro.
STEP 4
Create a
program.
This is the argument’s display sequence.
Describe arguments in this sequence
when writing a macro call instruction.
Select the display format
If there are several macros, select for arguments displayed
STEP 5
a macro for registering arguments. on the ladder editor.
Register the
arguments.
STEP 6
Call the created
macro.
This field indicates the
argument’s use status in the
macro. It shows “unused” if a
macro program was not created.
Give a title to the argument.
STEP 7
The name set here is displayed when
Check macro operation. the macro call instruction is described.
The argument title must not exceed 12
one-byte (6 two-byte) characters.
- 99 - KV0475E_C
-
UR/UM/UV is a unit relay/unit memory/unit number. It refers to the leading number of a unit device or the unit number assigned to an
additional unit.
For details on UR/UM/UV, refer to “3-9 Macros” in the ”KV-5000/3000 Series User’s Manual”, included in KV STUDIO.
To call: From the menu, select “Help (H)”→“CPU Unit User’s Manual (H)”.
- 100 - KV0475E_C
-
Adding a comment to a macro
A macro can be used in the same way as an original instruction word, but like a multipurpose instruction word, it does not have any
explanations or Help. To enhance the versatility of the macro, we recommend adding an explanation of an argument in the
argument’s operand explanation column or adding a simple explanation of macro operation as a comment.
Macro comments
Adding a comment to a macro dramatically improves its versatility and reusability. A macro comment is displayed in the macro
palette used when entering argument operands, and in the macro properties.
Other procedure Select a macro in Workspace and, from the menu, select “Modules/macros (M)”→”Module/macro
properties (H)”.
Enter a comment.
Right-click menu You could write a simple
explanation of operation
Other procedure Activate macro programs on the Ladder Editor. From the menu, select “Modules/macros (M)” →”Macro
argument setting (Z)”.
Right-click menu
Enter an explanation of
the operand
- 101 - KV0475E_C
-
STEP 3
Create a
macro.
STEP 5
Register the
Click the macro to be arguments.
called
STEP 6
Call the created
macro.
- 102 - KV0475E_C
-
STEP 3
Create a
macro.
STEP 5
Register the
arguments.
STEP 6
Call the created
macro.
STEP 7
Check macro operation.
- 103 - KV0475E_C
-
Chapter5
KV Script programming
- 104 - KV0475E_C
-
This section describes how to create the following box script.
R000
DM300 = DM100 + DM10100 + 1000
DM400 = (DM100 + DM10100 + 1000) / 2
Trigger
Operation description
Once Trigger(R000) is ON, the box script on the first rung is run.
In the box script, DM100 is set to a default value 100, DM200 is set to a default value 10,
and the operation result of DM100+DM200+1000 is stored in DM300.
Once Trigger(R000) is OFF, the box script on the second rung is run.
DM10100 is a variable analog resistance in the switch box.
The ON/OFF condition of the switch is used to check how the values of DM100, DM200, DM300, and
DM400 vary.
Point For scripts, arithmetic expressions with "+, -, *, /" can be used. Moreover, using scripts
enables you to describe arithmetic expressions more simply than ladder programs, as you
can assign values using "=".
Arithmetic operators, including the four arithmetic operators (+, -, *, /), are available for use with scripts.
Arithmetic operators
- 105 - KV0475E_C
-
- 106 - KV0475E_C
-
2 Describe execution conditions in the ladder editor, and click the cell for which the box script is to be
programmed.
Select "Script (S)" "Insert box script (B)" from the menu.
Tip
Select "Edit script (X)" "Insert box script (B)" from the right-click menu
- 107 - KV0475E_C
-
You can describe execution conditions after you finish creating the box script.
Now describe
execution Cond1
conditions.
- 108 - KV0475E_C
-
5 When you finish describing the script, convert the box script.
Select "Script (S)" "Convert all scripts (C)" from the menu.
Other procedure Select "Edit script (X)" -> "Convert all scripts (C)" from the right-click menu
If conversion is successfully
If conversion fails
A "script conversion error" appears.
An error message appears in the Output window.
- 109 - KV0475E_C
-
- 110 - KV0475E_C
-
Monitoring scripts
When all scripts are successfully converted, they should be transferred to "KV-5000" to be monitored.
Scripts are transferred following the same steps as the ones used to transfer regular ladder programs.
Select "Display/hide the watch window (M)" from the right-click menu to toggle display of the watch window.
Other procedure
Select "Monitor/Simulator (N)" -> "Display/hide the watch window (N)" from the menu
- 111 - KV0475E_C
-
The devices that are described in the selected script appear as registered in the Registration monitor window.
The used devices, etc., displayed when the script is expanded, do not appear in the Registration monitor window.
Switching the module macros will not close the Registration monitor window. You can also open more than one
window at a time.
- 112 - KV0475E_C
-
Expanding script programs to ladder programs may allow easier monitoring of behavior timing.
Expand this script as this script to a ladder program for monitoring.
- 113 - KV0475E_C
-
(1) Why?! The result of the operation is not correct. The result should be 66000...
If the following arithmetic expression is described, the expected result of the operation is not stored in DM0
Example) DM0 = 660 * 100................The result of the operation, ‘660×100, is stored in DM0
As the result of the operation implemented on the right side is 66000, which is out of the range of unsigned 16
bits (0 through 65535), "464" is stored in DM0 on the left side.
(2) Why?! Negative values cannot be stored in the result of the operation.
If the following arithmetic expression is described, overflow positive values (not negative values) are stored in
DM2.
Example) DM2 = 300 - 500 ................The result of the operation, ‘300 - 500, is stored in DM2
As the result of the operation implemented on the right side is -200, which is out of the range of unsigned 16
bits (0 through 65535), "65336" is stored in DM2 on the left side.
(3) Why?! The digits after the decimal point of the result of the operation are omitted,
aren't they?
If the following arithmetic expression is described, the value is stored in DM4 with the digits after the decimal
point truncated.
Example) DM4 = 123 * 1.05...............The result of the operation, ‘123 1.05, is stored in DM4
As the result of the operation implemented on the right side is 129.15, which is out of the range of unsigned 16
bits (0 through 65535), "129" is stored in DM4 on the left side.
The example 3 above will enable you to easily obtain the correct result of the operation if you
learn the rules of arithmetic expressions.
The rules of arithmetic expressions are explained in more detail in the following pages. Basically
you are supposed to understand the following three points:
1. Device types -> the range of values that the device handles
2. Operation type -> the range of values that the arithmetic expression can handle
3. Assignment type -> the rules applied when the device type on the right side is
different from that on the left side
- 114 - KV0475E_C
-
Suffix types
Suffix The range of values
Type
(Sample definition) that are handled
.U
16 bits unsigned data type 0 to 65535
(DM1000.U)
.S
16 bits signed data type -32768 to +32767
(DM1100.S)
.D
32 bits unsigned data type 0 to 4294967295
(DM1200.D)
.L
32 bits signed data type -2147483648 to +2147483647
(DM1300.L)
-3.4E38≤N≤ -1.4E-45
.F
Floating-point type (32 bits) N=0
(DM1400.F)
1.4E-45≤N≤3.4E38 (valid 7 digits)
.T
Text string type Text string (Within 1999 half-width characters)
(DM2000.T)
Bit type (Boolean-value)
.B
* If a word device .B is specified, only the 1, 0, ON, OFF, TRUE, FALSE
(DM3000.B)
least significant bit is handled.
Device .....A box that stores values
Suffix .......Size, type of the box
Specify a suffix (.D, .L, .F), which handles 32-bit type data, so that "device number・device number + 1" is
automatically handled.
Example) DM1200.D = 100...........A constant "100" is stored in "DM1200・DM1201".
DM1400.F = 1.25 ..........A constant "1.25" is stored in "DM1400・DM1401".
If a suffix (.T) that handles text strings is specified, the ensured range of the device varies depending on the length of
the text strings that are handled. A text string is separated at the point where NUL(00H) is detected.
Example) DM2000.T = "KEYENCE" Starting from a text string "KEYENCE", two characters (half-width) per word
are stored.
Note If values that are out of the range of the type, an overflow appears.
Example) DM1000.U = 65536 ······· A constant "0" is stored in "DM1000.U" (overflow).
DM1100.S = 65535········ A constant "-1" is stored in "DM1100.S" (overflow).
- 115 - KV0475E_C
-
About type declaration of a suffix
Declaring the type of the device at the head of a script program allows you to abbreviate a suffix.
Type
declaration Form Description
statement
In scripts, arithmetic expressions are handled as .L type (32 bits signed data). Therefore, computation elements should be type-converted
whenever doing a calculation that may handle the range other than .L (including a division calculation).
Example 1) DM1000.F = DM0.S / 3 .................."DM0.S/3" is calculated in the range of .L. If DM0.S is 10000, for example, +3333 (the
digits truncated after the decimal point of the result) is stored in DM1000.F.
Example 2) DM1002.F = FLOAT(DM0.S) /3.....DM0.S is converted to .F type by means of the FLOAT function, and then calculated in
the range of .F. If DM0.S is 10000, for example, 3333.333.... is stored in DM1002.F.
Example 3) DM1004.F = DM0.S /3.0 ................3 is handled as .F type and calculated in the range of .F by describing 3 as 3.0. If DM0.S
is 10000, for example, 3333.333.... is stored in DM1004.F.
- 116 - KV0475E_C
-
Computation types
The operation type of a computation expression varies depending on the suffix (type) of the device (constant) that is
described in the computation expression.
Computation types are separated into the following two general groups:
Tip If an arithmetic expression includes multiple arithmetic expressions, they are computed in the range
of .L until a computation element of .F appears.
Example) DM6100.F = (DM3300.L + 300) * 2 + (DM3310.L – 5000) * (DM3320.F + 50)
It is calculated in the range of .L until (DM3300.L + 300) * 2 + (DM3310.L - 5000), and after
that, it is calculated in the range of .F (operations within the parentheses are prioritized, in
an order from left to right).
Point
In a conventional ladder program that "multiplies the device by 1.25", the procedure described was "Multiply the
device by 125, and then divide the result by 100".
Using script programs allows you to directly describe an arithmetic expression, using constants (including a
decimal point).
Even if it is expected that the result of the operation should fall within the range of .L, the correct value (the expected value) may not be
obtained if it is out of the range of .L (-2147483648 through +2147483647) during the operation.
* If you want to carry out an operation that is out of the range of .L, use .F (valid numbers are 23 bits).
- 117 - KV0475E_C
-
Substitution types
A computation expression that is described in a script has the type that is defined by the result of the operation (on
the right side). However, it is possible that the type of the right side and the left side that is substituted are described
differently. In this case, he result type of the operation implemented on the right side is automatically converted to
that of the left side immediately before substituted into the left side.
Substituted
DM5000.L
Should be the same
type as the right side
= (123 + DM3100) × 1000
The result of the computation is of .L type
* If a floating type is included in the
computation expression (on the right
side), the result of the computation is
The left side The right side of .F type.
Example) DM5110.L = DM3100.L * 1.25 ...................... The result of the operation implemented on the right side
is of .F type, but when substituted, it is converted to .L
type, as the type of the left side is. L.
If DM3100.L = 12345: the result of the computation on the right, 12345 × 1.25 = 15431.25.
The digits after the decimal point of the result are truncated when
substituted
Substituted
DM5110.L
15431
= DM3100.L * 1.25
12345 × 1.25 = 15431.25
(.F -> the value converted (The result of the computation
to .L is stored) is a floating type)
If a type other than .L or .F is specified to the device on the left side that stores the result of the operation of the
arithmetic expression, the result type of the operation implemented on the right side is automatically converted to
that of the left side immediately before being substituted into the left side.
Example) DM5100.U = (DM3000.U + 300) * 20 ............ The result of the operation implemented on the right side
is of .L type, but the top 16 bits are truncated when
substituted since the type of the left side is .U.
DM3000.U = 40000: (40000+300) × 20 = 806000 on the right side. "19568" is stored in DM5100.U,
with the top 16 bits truncated.
- 118 - KV0475E_C
-
(1)-1 All the arithmetic expressions in the script are calculated in the range of .L type (32 bits signed data) *.
Arithmetic expressions
DM1000.L = 100 * DM10001.U ···················································the first rung
DM1010.U = 100 * DM10001.U····················································the second rung
R0000
Box script DM1000.L = 100 * DM10001.U
DM1010.U = 100 * DM10001.U
Operation description
The operation on the right side is implemented as .L type, and the result of the operation is also
of .L type. Therefore, the type of the device on the left side that stores the result of the operation
should be of .L type (the first rung).
Where, if a device of other than .L type is specified by the type of the left side, the precision may
be reduced (the second rung: .L type -> the precision of .U type is reduced).
However, even if a type other than .L is included in an element of the arithmetic expression,
operations will be implemented regardless of the suffix if the value during the operation or the
result value of the operation is expected to fall within the range of .L.
* Except where constants, including .F type data memory and decimal points, are included
(1)-2 Constants including decimal points can be described in arithmetic expressions in the script.
R0000
DM1100.F = DM10001.U * 1.23
Box script
Operation description If a decimal point is included in an element of the expression (on the right side), it is calculated
as .F type since a .F type device (or constant) appears*, and the result of the operation is also
of .F type (floating real number). Therefore, the type of the device on the left side that stores the
result of the operation should be of .F type.
Where, if a device of other than .F type is specified by the type of the left side, the digits after the
decimal point of the result are truncated, as .F type is converted to an integer before being
stored.
* In the program above, 5000-DM10000.U is calculated in the range of .L, and the result ×1.25 is
stored in the left side after .F type is calculated.
- 119 - KV0475E_C
-
(1)-3 The result of the operation implemented on the right side is always of ".L type (32 bits signed data" or ".F
type (floating real number)”. Where, if the type of the left side differs from that of the right side, the result
type of the operation implemented on the right side is automatically converted to that of the left side
immediately before being substituted into the left side.
Arithmetic expressions
DM1200.L = DM10001.U * 1.23························································· the first rung
DM1210.F = DM10001.U * 1.23 ························································ the second rung
R0000
Box script DM1200.L = DM10001.U * 1.23
DM1210.F = DM10001.U * 1.23
Arithmetic
trigger
Operation description The result of the arithmetic expression implemented on the right side is of .F type (floating real
number), since a constant with a decimal point is included in an element of the expression.
In the arithmetic expression on the first rung above, the result type of the operation (.F) is
automatically converted to .L type (with the digits after the decimal point truncated) before
substituted to the left side, as the type of the device (on the left side) that stores the result of the
operation is of .L type (32bits signed data).
On the second rung, the result of the operation is stored as .F type without being converted into
an integer.
Point If the type of the right side differs from that of the left side (which is of 16 bits type), the top
16 bits may be truncated.
The result of the operation may vary depending on how the expression is described.
- 120 - KV0475E_C
-
R0000
Box script DM1300.T = “ABC” + “XYZ” + CHR($0D)
DM1350.T = “abc” + STR ( DM10000.U ) + “xyz”
In the first rung, a text string "ABC" is concatenated with another string "XYZ", and a string
Operation description
constant with DM1300 is stored at the head of the string and "CR(0DH) at the end of the
string.
In the second rung, the value stored in DM10000 is first converted to a string and
concatenated with the text string "abc", before being concatenated with another string "xyz"
and DM1350 is stored at the head of the string.
"NUL(00H)" is automatically stored at the end of the text string.
The operation, DM1350.T = "abc" + STR (DM10000.U) + "xyz", stores text strings when
DM10000.U=2345, as shown below:
bit bit
15 “abc2345xyz” 0
High-order 4bit
Low –order 4bit
- 121 - KV0475E_C
-
(3)-1 Control structures are available to control the flow of a program. A control structure allows you to
describe a "conditional branch control statement" that will branch to specific actions determined by
whether a condition is satisfied or not.
Operation description Area scripts are of fixed scan execution types that do not require execution conditions (just like
box scripts).
If the switch box volume indicates that the value of DM10000 increases beyond 1000, the result
of the operation of "DM1420+100" is stored in DM1410, and R500 is turned ON. If the value of
DM10000 is equal or less than 1000, 0 is substituted into DM1400, and R500 is turned ON.
Point If the script is described with control structures, using area scripts may make its behavior
simpler to understand than using box scripts.
* For more information about area scripts, refer to the section, "2-3 Area scripts" of the "Script Programming
Manual".
Conditional branch statements
Control
Control contents
statements
(1) A control statement IF conditional expression A THEN
If the conditional expression A is true, then the
that executes the Process statement B
process statement B is executed.
process according to END IF
If the conditional expression A is false, no process
conditional
is executed.
expressions
(2) 2 branch control IF conditional expression A THEN
statements that Process statement B If the conditional expression A is true, then the
execute separate ELSE process statement B is executed.
processes according Process statement C If the conditional expression A is false, then the
IF statements to the conditional END IF process statement C is executed.
expressions
IF condition expression A THEN
(3) Multiple branch Process statement B If the conditional expression A is true, then the
control statements that ELSE IF conditional expression C process statement B is executed.
execute separate THEN If the conditional expression A is false, and the
processes according Process statement D conditional expression C is true, then the process
to more than 2 statement D is executed.
conditional If the conditional expressions A, C ... are false, no
expressions process is executed.
END IF
SELECT CASE the value to be
compared with
CASE condition A ・ if the condition A and the value to be compared
Process statement B are equal, then the process statement B is
Multiple branch control
CASE condition C executed. If the condition C and the value to be
statements that select
SELECT Process statement D compared are equal, then the process statement
processes to execute
statements D is executed.
according to
・ If the value to be compared with is not equal to
conditions the conditions A, C,..., then the process statement
CASE ELSE E is executed.
Process statement E
END SELECT
MC conditional expression A THEN ・ If the conditional expression A is true, then the
Control statements for Process statement B process statement B is executed.
MC statements MCR
the master control If the conditional expression A is false, then the
process statement B is executed OFF.
* For more information about conditional branch statements, refer to the section, "4-3 Control statements" of
the "Script Programming Manual".
- 122 - KV0475E_C
-
Arithmetic operators available for use with scripts
Various operators, including the four arithmetic operators (+, -, *, /), are available for use with scripts.
Arithmetic operators
Operator Operation Sample
^ Raising a number to a power DM500 = DM100 ^ 2
* Multiplies one numerical value with another (multiplication) DM502 = DM100 * 3
/ Divides one numerical value into another (division) DM504 = DM100 / 4
Divides one numerical value into another and returns only the DM506 = DM100 MOD 5
MOD
remainder
+ Sums two numerical value (addition) DM508 = DM100 + 6
- Subtracts one numerical value from another (subtraction) DM510 = DM100 - 7
Relational operators
Operator Operation Sample
< less than MR500 = DM100 < 10
<= less than or equal to (less-than-or-equal-to) MR501 = DM100 <= 20
> greater than MR502 = DM100 > 30
>= greater than or equal to (greater-than-or-equal-to) MR503 = DM100 >= 40
= equal (equivalent) MR504 = DM100 = 50
<> not equal (not equivalent) MR505 = DM100 <> 60
Logical operators
Operator Operation Sample
NOT Results the logical negative value of the operand MR600 = NOT R000
Results the logical multiplication of 2 devices
AND MR601 = R000 AND R001
(2 bit devices, 2 word devices)
Results the logical addition of 2 devices
OR MR602 = R000 OR R001
(2 bit devices, 2 word devices)
Results the exclusive OR of 2 devices
XOR MR603 = R000 XOR R001
(2 bit devices, 2 word devices)
List of script
functions
Tips on script
function forms
To insert the function at the cursor position on the Script Editor, select the function to be used, and then press the Enter key or double
click on the selected function. A hint for the script function format appears. Otherwise, press the F1 key while the function is
inserted in order to display the appropriate function help message.
- 123 - KV0475E_C
-
(3)-2 In control structures which can be described with scripts, "repetition control statements" are available as
well as conditional branch statements. Repetition control statements are useful when the same process
is repeated many times. However, they should be used carefully if a process takes a long time to
complete as they implement the process within one scan.
Operation description
Repeats until the value of Z01 is greater than 100.
Stores the value, in an order from DM4000, adding 5 to the analog input value each time.
Where, the repetition control is exited immediately if the sum total of the added values is greater
than 5000.
Point A FOR statement continues executing the repetition process statement until the last value (100
in the example) has been exceeded. In the Example, the repetition number of times is 101,
since "Z01=0 TO 100".
* For more information about repetition control statement, refer to the section, "4-3 Control statements" of
the "Script Programming Manual".
- 124 - KV0475E_C
-
(4) In ladder programs, only the index modification using index devices or index constants is available.
However, in script programs, there are various ways to use index modification.
Operation description Each value (on the right side of the expression) is stored in the modification location where
DM2000 is index modified with each value.
* For more information about index modification, refer to the section, "3-2 Index modification and indirect
assignment" of the "Script Programming Manual".127
- 125 - KV0475E_C
-
Appendix
- 126 - KV0475E_C
-
Connect the KV-5000/3000 to a PC running WindowsXP. You only need to install the USB driver for the
KV-5000/3000/1000/700 the first time you connect to a particular PC. The second and subsequent times you
connect, the USB driver is recognized automatically, so you need not install it.
The following pages explain the procedure to be used when you install the driver for the
KV-5000/3000/1000/700 onto Windows XP for the first time. When you install the USB driver for KV STUDIO,
the hardware must be detected.
- 127 - KV0475E_C
-
- 128 - KV0475E_C
-
In “Instruction/macro/pack pallet,” try a search using an instruction for another vendor’s PLC.
(6) How do I execute a batch-search for locations where the same device is used? P52
Press “Space” to jump to a list search. (Cross-reference))
- 129 - KV0475E_C
-
(7) How do I monitor I/O?
(11) How do I investigate the cause of errors that seldom occur? -/P56
In “Logging function”, clicking “Tracing setup” saves just the data immediately before and after
a failure to an SD card
In “Real time chart monitor,” clicking “Tracing setup” displays data immediately before and after
a failure as a waveform
- 130 - KV0475E_C
-
You can monitor ON/OFF at the scan period in “Monitor/Simulator”→“Real time chart monitor”
(14) What do I do if I can’t completely remember an instruction when adding a program? P25
Enter the first few letters that you can remember of the instruction.
The instructions that begin with those first few letters are listed.
- 131 - KV0475E_C
-
(15) How do I paste from the manual’s reference program? P28
Copy the mnemonics list next to the manual’s reference program, click “Edit”→“Edit list” and
paste the copied portion to batch-create programs.
Using “Logging function” enables you to collect the desired data at the desired timing onto a
multipurpose SD card. Its applications are infinite: automatically creating a daily report for a
single day, investigating failures, investigating the proportion of momentary stoppage time, etc.
(17) How do I skillfully convey on-site circumstances to another person (a machine manufacturer,
Keyence, etc.)?
You can also play back recordings using “KV STUDIO PLAYER.”
- 132 - KV0475E_C
www.keyence.com
Copyright (c) 2011 KEYENCE CORPORATION. All rights reserved. PLCSeminar-WW-OT-E 1111-1 600A26