KV-8000 Manual
KV-8000 Manual
Conventional programming
n]
operatio
[Manual
eration]
[Manual op
Duplication of addresses
Import
when reusing programs
P2-(3)
...
...
2
Programming using the KV-8000 Series
P3-(1)
(1) Readability is improved with programs divided into functions
[Error processing]
• Separating processes
for each module
[Manual operation]
improves readability
• Separating processes
[Automatic operation]
enables programming
[Initialisation processing] from multiple people
Modules
P3-(3) P3-(3)
• Corrections in one
Revised Function block C Function block C location are applied to
all locations
[Function block C] [Function block C]
[Module B] [Module B]
...
...
3
Step 1 Checking Device Compatibility
Compatible devices
The device and software versions indicated below support programs using variables.
• PLC
Device/software Version
KV-8000* CPU function Ver. 2.0 or later
KV STUDIO Ver. 11 or later
* Programming using variables is only usable with the KV-8000.
Refer to the KV-8000 User’s Manual for information on how to update the CPU function version.
4
Step 2 Standardising Programs
This example calculates the plane equation from three points on a target and then standardises a program to determine
whether the flatness of the inspection point does not exceed the reference value.
Processing flow
(1) S
ave the values from three measurement points and
the inspection point as target data.
(2) C
alculate the plane equation from the three
measurement points.
(3) C
alculate the distance between the inspection point
and the plane (flatness).
(4) D
etermine whether the calculated flatness exceeds the
reference value.
(5) S
ave the product data flatness and the judgement
result.
Creating the above process as a ladder program results in something similar to the following.
Calculation of
flatness
Data saving
The program includes difficult processing that makes it difficult to understand at a glance what is
happening. Program standardisation is presented on the next page.
5
Step 2 Standardising Programs
This section explains how to use variables through the creation of the following program.
2. For [Unit setting information], add units as necessary for the system configuration.
* To add a unit, click [Yes] in the [Confirm unit setting information] dialogue box.
6
Creating the program
1. Enter “MeasureStart” as the rising edge contact.
Select the first row of the circuit, enter “p MeasureStart”, and press Enter .
2. Right-click on “MeasureStart” entered above, and click [Register to global variable (2)] to register
the variable as a global variable.
The text colour changes when registering as a global variable.
If [Register to global variable] is not displayed in the context menu, the KV STUDIO version may be old,
! Note the selected PLC may not be the KV-8000, or the KV STUDIO project function version may not be 2.0.
4. After entering the above, use the procedure in step 2 to register the variable as a global variable.
7
Step 2 Standardising Programs
5. Enter “MeasureComp”.
Select the cell below “MeasureBusy”, type “T MeasureComp #30”, and press Enter .
* Connection lines can also be entered using Alt + Up/Down/Left/Right. Use Alt + Up/Down/Left/Right or the Delete key to clear
a connection line.
! Note Include the process details as a line comment to ensure easy standardisation during reuse.
Select the line where “MeasureStart” is entered, and press Ctrl + Enter .
A line comment will be inserted. Enter the processing details.
In this example, enter “Measurement Process”. Press Ctrl + Enter to confirm entry.
Including line comments improves the readability of the program.
Enter
“Measurement
Process”.
8
! Note Add comments to variables to increase visibility in the program.
Double-click [Variable] in the workspace to open the [Variable edit] window. The registered variables will
be displayed.
Enter “Start Measurement”, “Measuring”, and “Complete Measurement” in each of the Comment 1 fields.
Up to eight comments can be entered, making it possible to register translation comments as well.
* If no variables are displayed, the KV STUDIO project function version may not be 2.0.
■ After input
! Note Programs can also be created after setting the variables in the [Variable edit] window.
Point
9
Step 2 Standardising Programs
Point
Local variables
Local variables are handled in program-based units (in modules and function blocks). Variables defined as local
variables can be referenced only within the individual programs. Because such variables cannot be referenced from the
VT5 Series, users must register variables that need to be referenced as global variables.
Local variables are automatically allocated to the internal working area and cannot be allocated to devices.
Using local variables is recommended if there is no need to reference the variables from other
! Note programs, as this will help prevent conflicts.
Point
Data type
Type Description
BOOL Bit
TIMER Timer
COUNTER Counter
ARRAY Array
10
Point
Constant (CONST) c, c_
Point
Batch variable importing
Variables can be registered each time or as a batch.
With batch importing, variables are automatically registered as local variables
If the variables are used in a ladder program, the data type is set according to the suffix of the operand being used.
If the variables cannot be matched to the suffix, such as when using in KV Script, the variables are registered as UINT.
In the [Variable edit] window, select the [Local] tab and select the registered program. Perform [Read ladder (&Q)] to register
all items as local variables.
Right-click the registered local variable and select [Move to global variable (M)] to move to the
! Note global variable.
When performing batch registration, verify that no variables entered incorrectly have been
Caution imported. The same variable may be registered as another variable unintentionally and may
not work properly.
11
Step 2 Standardising Programs
This example shows how to create a structure called “PrdctInfo” for saving product information, and a structure called
“PntInfo” for saving coordinate information.
The variable “Product_A” can then be created using “PrdctInfo” as the data type, making it possible to use Product_A
as a structure-type variable.
12
3. The [Structure] window will be displayed.
PntInfo uses the X, Y, and Z coordinate information as the aggregated data type, so the member names and
data types should be set as follows.
X INT
Y INT
Z INT
■ After configuration
4. Double-click [Structure] in the workspace again, enter “PrdctInfo” under “Structure name (N)”,
and press [OK].
5. The [Structure] window will be opened. Set the member names and data types under “PrdctInfo”
(product name, serial number, measurement point, inspection point, flatness, and inspection result)
according to the following table.
13
Step 2 Standardising Programs
6. This section explains how to input measurement points (array-type structure variable).
Select “ARRAY” from the data type drop-down list.
7. The [Array size] dialogue box will be displayed. Select “PntInfo” from the data type drop-down list.
8. Set “3” as the array size to register three measurement points. Press [OK].
14
9. Double-click [Variable] in the workspace to open the [Variable edit] window, and create the variable
“Product_A”.
Because the variable “Product_A” includes the PntInfo-type array “MsrPnt” as a member, “Product_A.MsrPnt[0]”
can be specified.
In addition, because the PntInfo-type includes X, Y, and Z members, this type can be used in programs with
“Product_A.MsrPnt[0].X”.
This concludes configuration of structure-type variables.
Point
Array-type structures
An array defines a collection of variables of the same data type under a single name.
To set the data type when using an array, select ARRAY and specify the data type within.
Setting structure as the data type for an array makes it possible to define array-type structures.
Using array-type structures makes programming more efficient when using the same data structure for multiple axes.
When using an array in a program, include brackets at the end of the variable and set the number of elements.
Example: If the structure “PntInfo” is specified as an array in the data type, the area for saving the data from three
measurement points can be defined as follows.
Measurement point
Variable name Member name Data type MsrPnt[0] coordinates are
Product_A MsrPnt PntInfo[3]
X MsrPnt[1] stored in each
structure
Y X MsrPnt[2]
Z Y X
Z Y
Z
15
Step 2 Standardising Programs
The following example uses function block creation to obtain flatness from product data.
Function blocks are created according to the following procedure.
• Configuring argument settings Argument type, argument name, display format, and comment settings
16
Function block creation
Alternate procedure
From the menu, select [Program (M)] -> [Argument setting (Z)] -> [Function block (F)].
UpperLim IN REAL
■ After configuration
If the data type is a structure, the entire variable can be passed to the function block.
! Note When passing a structure-type variable to a function block, setting the argument type to IN-OUT
improves processing speed.
17
Step 2 Standardising Programs
Program creation
This section explains how to create a function block program. The description method is the same as for normal programs.
This example creates a program that calculates flatness using “MsrPnt” and “TstPnt” from the “PrdctInfo” argument.
When entering a structure-type variable, enter a period after the variable name to specify a member.
RT (Real-Time) Edit
Setting variable names and comments in advance enables RT (real-time) edit, which is displayed as
! Note a candidate during entry. RT (real-time) edit can also be used for commands and device entry.
Using only arguments and local variables for programs in a function block does not cause device
! Note conflicts, thereby improving reusability.
Point
Entering comments
KV Script treats character strings entered after a single quotation as a comment.
Equation wrapping
Equation wrapping is possible in KV Script by using underscores.
18
Arranging function blocks
1. Place the function block.
Drag and drop “FlatnessCheck” from “Function Block” in the workspace to the “Main” module.
Variable names can be used as instance names. Using instance names makes it possible to check the
! Note function block execution status by specifying “FlatnessCheck1.ENO”.
19
Step 2 Standardising Programs
4. Right-click on the function block, select [Register to global variable (2)], and register “UpperLim”
as a global variable.
6. From the menu, select [Monitor/Simulator (N)] -> [Transmit to PLC -> Monitor mode (C)] to transmit
the program to the KV-8000.
After transmitting the program, set the PLC to RUN mode.
Caution If the following message is displayed when transmitting the program, the KV-8000 system
program must be updated.
Refer to the KV-8000 User’s Manual for more information.
20
Point
Point
Point
Library registration
Created function blocks can be registered to a library.
Right-click on the function in the workspace and select [Register in the Library (U)].
Switch to the [Library] tab in the workspace.
The created function block will be registered as a user function block, making it possible to place the function block by
dragging and dropping.
21
Step 2 Standardising Programs
Point
IN-OUT Argument values cannot be referred to or changed with “(instance name).(argument name)”.
Unit Argument values cannot be referred to or changed with “(instance name).(argument name)”.
EN, ENO
En (ENable): T
ransmits the ON/OFF status of the function execution condition into the function block. Include “EN” within
the program inside the function block to use.
ENO (ENable Out): Including “(instance name).ENO” makes it possible to reference values from outside the program
inside the function block. This always turns ON while the function block is running and turns off when
the function block stops.
However, if a value is written by the program inside the function block, the written value is applied.
ENO
Instance B.ENO
22
Appendix
A calculation error will occur if the size of the structure variable in the transmission source is larger
Caution
than the size of the structure variable in the transmission destination.
• Using KV Script
Destination Source
Using KV Script makes it possible to transmit the data without determining the data size of the
! Note structure-type variable.
Caution A conversion error will occur with KV Script if the data type of the structure-type variable in the
transmission source is different from that in the transmission destination.
Variable search
1. From the menu, select [Edit (E)] -> [Search device (S)]. The [Search] window will be displayed.
Alternate procedure Ctrl + F
2. Enter a variable name in “Trgt (T)” and press [Search (F)] to search for a variable.
23
Appendix
Registration monitor
Variables can be registered in the registration monitor and monitored in the same way as devices.
1. From the menu, select [Monitor/Simulator (N)] -> [Registration monitor window (G)] to start
the registration monitor.
2. To register the variable, enter the variable name to be registered in the device column
! Note Alternate procedure Drag and drop the variables in the program.
ove the cursor to the green frame of the variable, and drag and drop the variable when
M
the following cursor is displayed.
! Note If only variables are registered for structure-type variables, the members will also be registered
automatically.
24
Real-time chart monitor
Variables can be graphed and displayed using the real-time chart monitor in the same way as devices.
1. From the KV STUDIO menu, select [Monitor/Simulator (N)] -> [Real-time chart monitor (N)].
2. From the real-time chart monitor menu, and click [View (V)] -> [Retrieve comment from KV STUDIO
(N)] to import variable information.
3. Click the device list in the real-time chart monitor to register the variables.
Point
25
Appendix
DM number Name
Leading No. + 000 A/D conversion data
26
4. Set “DM10300” as the “SAD_Unit1” allocation device.
• Ladder program
• KV Script
Point
27
SAFETY INFORMATION
Please visit: www.keyence.com Please read the instruction manual carefully in
order to safely operate any KEYENCE product.
The information in this publication is based on KEYENCE’s internal research/evaluation at the time of release and is subject to change without notice. WW11-1039
Company and product names mentioned in this catalogue are either trademarks or registered trademarks of their respective companies. Unauthorised reproduction of this catalogue is strictly prohibited.
Copyright © 2020 KEYENCE CORPORATION. All rights reserved. KVprogrammingintro-WW-TG-GB 2050-1 600X36