Sunteți pe pagina 1din 55

Super-small Programmable Logic Controller

with Built-in Display

Visual KV Series
Advanced
Programming Course
Contents
VOL.1 Counting total number of products ...................................................................... 4
Example: Totaling the number of products on multiple production lines

VOL.2 Shift register ........................................................................................................... 6


Example: Ejecting rejects

VOL.3 BCD data output (to BCD display) ........................................................................ 8


Example: Indicating the number of products

VOL.4 Setting of multi-level output with high-speed counter ..................................... 10


Example: Cutting a sheet of cloth to specified length

VOL.5 BCD data input (4 digits) ..................................................................................... 12


Example: Inputting BCD data with a digital switch

VOL.6 BCD data input (2 digits) ..................................................................................... 14


Example: Inputting BCD data from the digital switch

VOL.7 Measurement of high-speed pulse period ......................................................... 16


Example: Checking rotation pulse period of engine

VOL.8 Phase differential input ........................................................................................ 18


Example: Input from rotary encoder

VOL.9 Position control using a stepping motor ........................................................... 20


Example: Stop/counterclockwise rotation of a stepping motor at a specified number of pulses

VOL.10 The specified frequency pulse output function ................................................. 22


Example: Speed control of a pulse motor with the specified frequency pulse output function

VOL.11 Word shifting ......................................................................................................... 24


Example: Storing the stop duration of equipment in memory as history

VOL.12 Fine adjustment with a digital trimmer ............................................................... 26


Example: Fine adjustment of the air discharge time of a parts feeder

VOL.13 Receiving multiple pulses and outputting them as a batch ............................. 28


Example: Displaying total number of products travelling on multiple lines on a counter

VOL.14 Converting high speed pulses into low speed pulses ...................................... 30
Example: Converting pulse frequency

VOL.15 Bit counting (Bit checking) .................................................................................. 32


Example: Checking how many error detection signals are input to input relays of channel

2
VOL.16 Shift register simulation in an asynchronous production line ......................... 34
Example: Ejecting rejects without a constant synchronous signal

VOL.17 Emergency stop circuit ........................................................................................ 36


Example: Emergency stop for cutting work

VOL.18 Selection of operation mode ............................................................................... 38


Example: Selecting fully-automatic or individual operation mode

VOL.19 Step-progress operation (sequential control) ................................................... 40


Example: Step progress of material handling machine

VOL.20 Frequency counter function ................................................................................ 42


Example: Counting the number of rotations using the frequency counter

VOL.21 Sorting ................................................................................................................... 44


Example: Sorting machines in the ascending order of production

VOL.22 High-speed interrupt input function ................................................................... 46


Example: Measurement of passing time between two points using high-speed interrupt input

VOL.23 Synchronous control function ............................................................................ 48


Example: Synchronous control of a pulse motor

VOL.24 High-speed counter .............................................................................................. 50


Example: Multi-step comparator operation with high-speed counter

3
VOL. 1 Counting total number of products
Example Totaling the number of products on multiple production lines

Outline
The number of products travelling on each of 5 lines is 0000
counted simultaneously. When the total number of products
0001
on the 5 lines reaches 100 the KV outputs.
An FS Series fiberoptic sensor counts the number of 0002
products on each line. When the total number equals the
preset value, the KV outputs. 0003

0004

Line 1
Products counted 0 1 2 3 4 5 6 7, 8

Line 2

Line 3 Input 0000: Counting products on line 1


Input 0001: Counting products on line 2
Input relay 0002: Counting products on line 3
Line 4 Input relay 0003: Counting products on line 4
Input relay 0004: Counting products on line 5
Input relay 0005: Resetting

Line 5
Output relay 0500: Comparator output

Visual KV Series

FS Series Fiberoptic Sensor

■ Programming Technique
The following 2 instructions can be used for counting.
(1) Counter instruction
(2) Increment Memory instruction
The programs created using instruction (1) and (2) are as follows:

Using instruction (1) Using instruction (2)


0005 #09999 C001 DM0001 0000 DM0000
C001 LDA STA INC
0000
#09999 C002 DM0002 0001 DM0000
C002 LDA STA INC
0001
#09999 C003 DM0003 0002 DM0000
C003 LDA STA INC
0002
#09999 C004 DM0004 0003 DM0000
C004 LDA STA INC
0003
#09999 C005 DM0005 0004 DM0000
C005 LDA STA INC
0004
2002 DM0001 DM0002 DM0003 DM0004 DM0005 DM0000 0005 $0000
LDA ADD ADD ADD ADD STA DW
DM0000

For the same control as shown here, using instruction (2) simplifies programming.

Time and labor for debugging is saved.


To obtain comparator output, the CMP instruction can be used.

4
VOL. 1 Counting total number of products
Programming Example
0000 DM0000
0001 INC When Input 0000 (line 1) turns ON, DM0000 is
incremented by 1.
0001 DM0000
0002 INC When Input 0001 (line 2) turns ON, DM0000 is
incremented by 1.
0002 DM0000
0003 INC When input relay 0002 (line 3) turns ON, DM0000 is
incremented by 1.
0003 DM0000
0004 INC When input relay 0003 (line 4) turns ON, DM0000 is
incremented by 1.
0004 DM0000
0005 INC When input relay 0004 (line 5) turns ON, DM0000 is
incremented by 1.
0005 $0000
0006 DW When input relay 0005 (reset input) turns ON, DM0000 is
DM0000 reset to 0.
2002 DM0000 #00100 2009 0500
0007 LDA CMP When DM0000 equals 100 or more, output relay 500 turns
END ON.
0008 When the reset input (0005) turns ON, output 0500 turns
OFF.
ENDH
0009

Set the input time constant to 10 µs using HSP instruction when the line speed is very high.

Tips ORing Differentiation instructions


• Compare the following 2 programs.

(1) 0000 DM0000 (2) 0000 DM0000


INC INC

0001 DM0000 0001


INC

0002 DM0000 0002


INC

0003 DM0000 0003


INC

0004 DM0000 0004


INC

In program (1), counting is performed for each input even when input relays 0000 to 0004
turn ON simultaneously.
In program (2), simultaneous inputs are ignored when input relays 0000 to 0004 turn ON
simultaneously.

Referring to the above, program according to your purpose.

5
VOL. 2 Shift register
Example Ejecting rejects

Outline
At position 1, the fiberoptic sensor checks whether the workpiece is acceptable or not. If the workpiece is rejected,
it is ejected at position 5.
When the detection position is different from the ejection position as shown in the figure, using the Shift instruction
is convenient.

Detecting rejects
Sensor Input 0001 Compressed air ejection
0500
Position 1 Position 2 Position 3 Position 4 Position 5

Clock input
Sensor Input 0002
Detection position Ejection position
Cam

■ Programming Technique
The SHIFT instruction allows the sensor reject input to turn ON each specified internal utility relay sequentially.
Each utility relay turns ON synchronously when the reject reaches a specific stage on the conveyor. This reject will
be ejected from the conveyor when the eject output and final utility relay turn ON.

0002
(Clock input)
0000
(Detection of rejects)
1000

1001

1002

1003

1004

0500

1 sec
(Ejection output)
Position of reject Position 1 Position 2 Position 3 Position 4 Position 5

Each time the clock input sensor is activated, a workpiece travels from position 1 to 5 sequentially. Acceptance or
rejection values for the workpieces in position 1 to 5 are stored in internal relays 1000 to 1004, with a reject being
ejected, using compressed air, in position 5.

6
VOL. 2 Shift register
Programming Example
0001 1100 1100 1000
0001 DIFU SET Internal Input relay 1000 is turned ON by a signal from
the fiberoptic sensor when it detects a reject.
2003 SFT
0002 D Each time clock input relay 0002 turns ON, acceptance
1000 or rejection of workpieces in position 1 to 5 is stored in
0002 internal relays 1000 to 1004.
0003 CLK

2003 1004
0004 RES

1004 0002 #00010


0005 T000 A one-shot ejection signal is sent.

0500 T000 0500


0006

Tips Using shift register


There are 2 ways to input data into the shift register:

0002
(Clock input)
(1) 0001 SFT
D 0001
1000 (Detection of rejects)
0002
CLK 1000
2003 1004
RES 1001

1002

In circuit 1 shown above, reject detection signals cannot be transferred to the internal register
if the reject detection output relay is not turned ON while the clock input pulse is ON (if they
are not synchronized).
Then, program as follows:

0002
(2) 0001 1100 1100 1000
DIFU SET 0001
2003 SFT
D
1000
0002 1000
CLK 1001
2003 1004
RES 1002

In circuit 2 shown above, the reject detection signal is guaranteed to be sent to the internal
register.

➮ For details, refer to the KV User’s Manual.

7
VOL. 3 BCD data output (to BCD display)
Example Indicating the number of products

Outline
The number of products is counted by the internal counter of the KV, and the number is indicated on the BCD
display.

Without using an externally-mounted counter, the internal counter of the KV can indicate the count result on the
external BCD display. This enables centralized control of the system by the KV.

Count input
PZ2 Series
Visual KV Series BCD display

■ Programming Technique
1. TBCD instruction: In the KV, data is in binary format to convert binary data into BCD data.
2. STA instruction: Use this instruction to transfer BCD data obtained by the TBCD instruction to external equip-
ment.

4-digit BCD display connection diagram and programming example are shown below.

Type I: 4-digit individual input

4th digit 3rd digit 2nd digit 1st digit

1 2 4 8 1 2 4 8 1 2 4 8 1 2 4 8

4th-digit BCD data 3rd-digit BCD data 2nd-digit BCD data 1st-digit BCD data
(512 to 515) (508 to 511) (504 to 507) (500 to 503)

Connect the output of the KV to each input of the 4 digits of the BCD display.

Programming Example (Using the KV-40)

C000 #00100
0001 C000 Counter (count input: 0000, preset value: 100)
0000
2002 C000 0500
0002 LDA TBCD STA The value of the internal counter is converted into BCD data and is
output to the display.

Though 16 outputs from the KV are required, program length can be decreased.

8
VOL. 3 BCD data output (to BCD display)
Type II: Digit designation input

4th digit 3rd digit 2nd digit 1st digit

1 2 4 8
4th digit 3rd digit 2nd digit 1st digit
BCD data of each digit
(0500 to 0503)
Each-digit designation
(0504 to 0507)
Data of 1st to 4th digits is indicated sequentially in a high speed cycle.

Programming Example (The ladder program may vary depending on the KV model to be used.)
2008 1000 The start relay of the Shift instruction is turned ON when operation
0001 SET
begins.
C000 #00100
0002 C000 Counter (count input: 0000, preset value: 100)
0000
T001 #00050
0003 T
S 001 50-ms clock pulses are output. (Display updating)
2003 SFT
0004 D Internal relays 1000 to 1008 are turned ON sequentially.
1000
T001 (BCD display updating)
0005 CLK

2003 1008
0006 RES

1008 1000
0007 SET
Internal relays 1000 to 1008 are sequential and repeatedly turned
ON/OFF.
1000 C000 DM0000 $000F 0500
0008 LDA TBCD STA ANDA STA Units digit data in the internal register is output through 0500.
1002 DM0000 #04 $000F 0500
0009 LDA SRA ANDA STA Tens digit in the internal register is output through 0500.
1004 DM0000 #08 $000F 0500
0010 LDA SRA ANDA STA Hundreds digit data in the internal register is output through 0500.
1006 DM0000 #12 $000F 0500
0011 LDA SRA ANDA STA Thousands digit data in the internal register is output through 0500.
1001 0504
0012 Digit designation of 1st digit (units digit) is output through 0504.
1003 0505
0013 Digit designation of 2nd digit (tens digit) is output through 0505.
1005 0506
0014 Digit designation of 3rd digit (hundreds digit) is output through 0506.
1007 0507
0015 Digit designation of 4th digit (thousands digit) is output through 0507.

Though longer programming is required, only 8 outputs from the KV are required.

The KV-D20 Operator Interface Panel is convenient for displaying several values.
7 6
5 4
3 2
1 0

9
Setting of multi-level output with
VOL. 4 high-speed counter
Example Cutting a sheet of cloth to specified length

Outline
By using pulses fed from the encoder, the KV controls winding speed of a sheet of cloth to cut the cloth to the
specified length.
High speed pulses from the encoder are entered to the high-speed counter of the KV. Output signals are issued
respectively to decrease winding speed, to stop winding and for overrunning alarm, the preset values (the number
of pulses) are previously input into the data memory of the KV.

Cutter

Rotary encoder

Winding process

Cutting
Decrease in Stop of
Start of winding
winding speed winding

Overrunning Alarm

Input the preset value for each point.

■ Programming Technique
For this control, 3 values (the number of pulses) must be preset respectively to decrease winding speed, stop
winding, and alarm overrunning. Preset the number of pulses of the high-speed counter to 3 levels using the CMP
instruction.

2002 CTH0 DM0000 2009 0500


LDA CMP Signal for decreasing winding speed

DM0001 2009 0501


CMP Signal for stopping winding
DM0002 2009 0502
CMP Alarm for overrunning

➮ For details on the instructions, refer to the KV Users Manual.

10
VOL. 4 Setting of multi-level output with high-speed counter
Programming Example
2008 #01000 #01500 #02000 When the power is turned ON, preset the initial values for decelera-
0001 DW DW DW tion point, stop point, and overrunning point respectively to 1000,
DM0000 DM0001 DM0002 1500, and 2000.
2113 2114
0002 SET RES CTH0 is set to the double multiplication mode.

2002 HSP
0003 0004
The input time constants of inputs 0004 and 0006 are changed to
10 µs.
HSP
0004 0006

0001 CTH0 The pulses from the encoder are received with high-speed counter
0005 0004
CTH0 through inputs 0004 and 0006.
2002 CTH0 DM0000 2009 0500 When the number of pulses from the encoder exceeds the preset
0006 LDA CMP
value for the deceleration point in DM0000, output is sent through
output relay 0500.
DM0001 2009 0501
0007 CMP When the number of pulses from the encoder exceeds the preset value
for stop point in DM0001, output is sent through output relay 0501.
DM0002 2009 0502
0008 CMP When the number of pulses from the encoder exceeds the preset
value for overrunning point in DM0002, output is sent through output
relay 0502.

Tips CMP instruction


1. To obtain comparator output using the CMP instruction, create an expanded ladder
diagram program. This makes it easier to understand sequential processing flow.

Conventional ladder diagram Expanded ladder diagram


2002 CTH0 2002 CTH0 DM0000 2009 0500
LDA LDA CMP
DM0000 From
CMP
2009 0500 encoder DM0001 2009 0501
CMP
2002 DM0000
CMP
2009 0501 DM0002 2009 0502
CMP
2002 DM0002
CMP
2009 0502

There are a large number of lines, There are few lines, making it easier to
making it difficult to understand the flow. understand the flow.

2. When or is used as compar ison condition:


When the value in the internal register is smaller than the operand value, internal relay
2009
2009 2009 turns ON. By applying this, program as , the desired condition
(value in the internal register oper and value) can be set.

* The same process can be used for comparison condition .

11
VOL. 5 BCD data input (4 digits)
Example Inputting BCD data with a digital switch

Outline
The preset value for the KVs counter is input using an external digital switch.

– – – –

1 2 3 4
+ + + +

4-digit BCD digital switch Visual KV Series

■ Programming Technique
To input 4-digit BCD data, it is convenient to use the HKEY instruction.

Advantage: To input 4-digit BCD data, 16 input terminals are normally required. With the HKEY instruction,
however, only 4 inputs and 4 outputs are required.

DC +
24 V DC COM 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012 0013 0014 0015
24V –

Digital
switch

100 101 102 103

DC + COM 0000 0001 0002 0003


24 V DC
24V – COM 0500 0501 0502 0503

Digital
switch

100 101 102 103


Diode

4-digit BCD data is stored in special utility relays 2900 to 2915.

Example of utility relay status: When the BCD data is 1234:


2 9 1 5 2 9 1 4 2 9 1 3 2 9 1 2 2 9 1 1 2 9 1 0 2 9 0 9 2 9 0 8 2 9 0 7 2 9 0 6 2 9 0 5 2 9 0 4 2 9 0 3 2 9 0 2 2 9 0 1 2 9 0 0
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
103 102 101 100

“1” “2” “3” “4”

12
VOL. 5 BCD data input (4 digits)
Programming Example
To set the preset value of counter C000 using a 4-digit digital switch:

C000 #09999
C000 Input to counter C000 is received through input
0001
0004 0004.

0005 HKEY
0002 0000 When input 0005 is turned ON, the preset value of
0500 the digital switch is determined.

2815 2900 C000


0003 LDA TBIN STA 4-digit BCD data from the digital switch is read
from special utility relays 2900 to 2915, and
converted into a binary number, which is used as
the preset value of counter C000.

Tips If the HKEY instruction is not used, the above programming example is written in ladder
diagram notation as follows. You soon discover how simple programming can be using HKEY.
2002 HSP
0000
HSP The time constant is set to 10 µs using the HSP
0001
instruction, and data is received through inputs
HSP
0002 0000 to 0003.
HSP
0003
0005 1000 1000 1001
DIFU SET
T001 #00020
T
S 001

2003 SFT
D
1001 Output relays 0500 to 0503 are turned ON
T001
CLK sequentially and the equivalent data for each digit
2003 1009 is sent to the special utility relays.
RES
1001 0500

1003 0501

1005 0502

1007 0503 Obtaining the preset value from the digital switch
When 0500 is ON: Receiving 100 data to store in
0500 0000 $000F DM0001
LDA ANDA STA DM0000
0501 0000 $000F #04 DM0002 When 0501 is ON: Receiving 101 data to store in
LDA ANDA SLA STA
0502 0000 $000F #08 DM0003
DM0001
LDA ANDA SLA STA When 0502 is ON: Receiving 102 data to store in
0503 0000 $000F
ANDA
#12
SLA
DM0004
STA
DM0002
LDA
1009 DM0001 DM0002 DM0003 DM0004 C000
When 0503 is ON: Receiving 103 data to store in
ORA TBIN STA
LDA ORA ORA DM0003
C000 #09999
C000 Combine each digit and convert the result into
0004
binary data. This data is used as the preset value
of the counter.
Using the HKEY instruction shortens programming to only 3 lines.

13
VOL. 6 BCD data input (2 digits)
Example Inputting BCD data from the digital switch

Outline
The product type No. is input to the KV using the external digital switch. At this time, the ANDA instruction ignores
input data from the operation switch or sensor.

– –

3 4
+ +
2-digit BCD digital switch Visual KV Series

■ Programming Technique
To input 2-digit BCD data, it is convenient to use the LDA instruction.

When 2-digit BCD data is entered to inputs 0000 to 0007 of the KV-40 Series:

+
DC
24 V DC
24V COM 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 0010 0011 0012

Digital
switch Operation switch, sensor, etc.

100 101

When the LDA instruction is used, the ON/OFF status of inputs 0000 to 0015 are received normally. When sensors
or operation switches are connected to inputs 0008 to 0015, therefore, their ON/OFF status is entered as BCD
data.
Use the ANDA instruction to ignore the ON/OFF status of inputs 0008 to 0015.

ON/OFF status of sensor or operation switch BCD data “3” BCD data “4”

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
Input 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0

$OOFF 0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
ANDA 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0

BCD data “0” BCD data “0” BCD data “3” BCD data “4”

As shown above, only 2-digit BCD data can be received, regardless of whether these sensors or operation switches
turn ON/OF.

14
VOL. 6 BCD data input (2 digits)
Programming Example
2002 0000 $00FF DM0000 The ON/OFF status of inputs 0000 to 0015 is received,
0001 LDA ANDA STA but only the data from inputs 0000 to 0007 is selected
and entered into data memory DM0000.

Tips 1. ANDA instruction


In the above programming example, $00FF is specified as the operand for the ANDA
instruction to ignore the ON/OFF status of inputs 0008 to 0015.
Referring to the above programming, specify the operand as follows to receive 1-digit data
or 3-digit data.

2002 0000 $000F DM0000


To receive 1-digit BCD data: LDA ANDA STA

2002 0000 $0FFF DM0000


LDA ANDA STA
To receive 3-digit BCD data:

2. 2-digit BCD data


Example: When inputs 0004 to 0007 cannot be used because the high-speed counter of
the KV-40 is used, receive 2-digit BCD data through inputs 0000 to 0003 and
0008 to 0011. At this time, use the SLA instruction and ORA instruction conven-
iently.

2002 0008 $000F #04 DM0001


LDA ANDA SLA STA Tens digit of BCD data is stored in DM0001.
(*1)
0000 $000F DM0002
LDA ANDA STA Units digit of BCD data is stored in DM0002.
DM0001 DM0002 DM0000
LDA ORA TBIN STA Tens and units digits are stored in DM0000.
(*2)

Used for high-speed counter.


+
24 V DC COM 0000 0001 0002 0003 0004 0005 0008 0009 0010 0011
– – –

Digital switch 3 4
+ +
100 101
Set value = 34

In (*1) and (*2) shown above, contents in the internal register are changed as follows:

0015 0014 0013 0012 0011 0010 0009 0008


– – – – 0 0 1 1 Input
0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000 $000F
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 ANDA
(*1)
0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000 Internal register
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 #04
SLA
0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 Tens digit of BCD data
0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
(*2) 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 DM0002
ORA
0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0010 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0

15
Measurement of high-speed pulse
VOL. 7 period
Example Checking rotation pulse period of engine
Outline
The sensor detects the mark on the jig for the engine and emits a pulse each rotation. Using these pulses, the
pulse period during engine rotation at high speed is measured.

FS Series

Visual KV Series

■ Programming Technique
Step 1: The rotation pulse period is obtained by counting the number of internal clock
pulses emitted by the KV.
To obtain the rotation pulse period, internal clock pulses (example: 100µs period) emitted during each rotation pulse
period are counted using the high-speed counter.

Pulse period

Rotation pulse

Internal clock
pulse (100 µs)
Internal clock pulse count

Rotation pulse period = internal clock pulse period: 100 µs x clock pulse count

Step 2: Use the INT instruction for programming the first step operation.
Rotation pulses are received by the KV through input 0003, and the pulse period is measured using the Interrupt
instruction.
INT
0003

When an interrupt is executed, the current value of the high-speed counter is automatically transferred to the data
memory (DM1934) at the rising edge of the pulse received at input 0003.

When this function is used, the clock pulse count equals the difference between the value of the high-speed coun-
ter obtained at the rising edge of the first rotation pulse and that of the second rotation pulse.
Pulse period
Rotation pulse

Internal clock
pulse (100 µs)
DM1934(1) DM1934(2)

Clock pulse count = DM1934 (2) - DM1934 (1)

16
VOL. 7 Measurement of high-speed pulse period
Programming Example An interrupt is declared, and initialization is
2008 #00000 2200 DM0000 DM0001 DM0002 1000 2412 2413 performed. The interrupt polarity of input
0001 EI LDA STA STA STA STA RES RES RES 0003 is set to the rising edge.
2002 HSP Input time constant for input 0003 is set to
0002 0003 10 µs.
2002 CTH1 Internal clock pulses (100 µs) of the KV are
0003 2202 input into high-speed counter CTH1, and
2002 DM0001 #00100 #10000 DM0002 counted.
0004 LDA MUL DIV STA The rotation pulse period measured is
entered into DM0002 in milliseconds.
END
0005

INT The rotation pulses are received using the


0006 0003
INT instruction.
1000 DM1934 DM0000 DM0001
0007 LDA SUB STA The difference between the current value
2002 DM1934 DM0000
of CTH1 obtained at the rising edge of the
0008 LDA STA first rotation pulse and that obtained at the
rising edge of the second rotation pulse is
2002 1000
0009 SET entered into DM0001.

RETI
0010

ENDH
0011

Note: Since the countable range of CTH1 is 00000 to 65535 in the above program example, measurable
rotation pulse period is between approx. 100 µs and approx. 6553 ms.

Tips Higher accuracy for this measurement can be obtained by using special utility relay 2200 or
2201 which enables the use of the 1 µs or 10 µs internal clock pulse of the KV. The countable
ranges are as follows.
• 1 µs: Approx. 1 µs to approx. 65 ms
• 10 µs: Approx. 10 µs to approx. 655 ms
When the clock pulses exceeds 65535 (maximum countable value by CTH1), use CTH0.
Then, up to 56 minutes (approx.) can be measured accurately.
Example:
1. Count internal clock pulses (100 µs) at the rising edge of the rotation pulse using CTH0,
and set the preset value to 50.
2. When the CHT0 count exceeds 50 (preset value), a direct clock pulse (period: 10 ms) is
output through output relay 500.
3. The rotation pulse period can be obtained by counting the number of direct clock pulses
emitted between the rising edge of the first rotation pulse and that of the second.
Rotation pulse Pulse period

Internal clock
pulse (100 µs)

100 µs

50 50 50
Direct clock
pulse 10 ms

17
VOL. 8 Phase differential input
Example Example: Input from rotary encoder

Outline

Phase A

Phase B

Rotary encoder Visual KV Series

■ Programming Technique
When using the phase differential input, set the high-speed counter to the double or quadruple multiplication mode.
CTH0 Phase A: Input 0004 Phase B: Input 0006
CTH1 Phase A: Input 0005 Phase B: Input 0007

Special utility relay setting for phase differential input


CTH0 CTH1
2113 2114 2213 2214
Double mode ON OFF ON OFF
Quadruple mode OFF ON OFF ON

Phase differential input in double multiplication mode


(2113: ON, 2114: OFF)
1 2 3 4
ON
Phase A
OFF
ON
Phase B OFF

Counter value
0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0

Phase differential input in quadruple multiplication mode


(2113: OFF, 2114: ON)
1 2 3 4
ON 1 2 3 4
Phase A OFF
ON
Phase B OFF

Counter value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

18
VOL. 8 Phase differential input
Programming Example (In double multiplication mode)
Pulses up to 30-kHz frequency can be input.

2008 2113 2114


0001 SET RES High-speed counter CTH0 is set to the double
mode.
2002 HSP
0002 The input time constants of inputs 0004 and
0004 0006 are set to 10 µs.
HSP
0003
0006
2002 CTH0
0004 The pulses from the encoder are counted with
0004
high-speed counter CTH0.
0000 CTH0
0005 RES Turning ON input 0000 resets high-speed
counter CTH0.

Tips To use 24-bit high-speed counter


The 24-bit high-speed counter can be used to count the pulses from the encoder by
setting the special utility relays. It allows reliable counting of the pulses that cannot be
counted with the 16-bit high-speed counter.

Setting method
Specify the 24-bit high-speed counter with the MEMSW instruction.
To set high-speed counter CTH0 To set high-speed counter CTH1
MEMSW MEMSW
$0800 $1000

The counter value is read at every scan and is stored in the following data memories.
DM1900: Low-order bits of current CTH0 value
DM1901: High-order bits of current CTH0 value
DM1902: Low-order bits of current CTH1 value
DM1903: High-order bits of current CTH1 value

By using the KV-D20 operator interface panel, you can display the current value of the 24-
bit high-speed counter in real time.

19
VOL. 9 Position control using a stepping motor
Example Stop/counterclockwise rotation of a stepping motor at a specified number of pulses

Outline
➮ For wiring, refer to “11.3 Examples of Using the Positioning Control
Operating procedure
Function” on page 652 in the Visual KV Series User’s Manual.
Input 0000: ON

Clockwise rotation
for 1000 pulses

Input 0001: ON

Clockwise rotation
for 2000 pulses

Input 0002: ON Visual KV Series


Counterclockwise
rotation for 3000 Stepping motor and motor driver
pulses (Return to the
starting position)

■ Programming Technique
For positioning control, set each parameter in the specified data memory in advance.
Turning on the special utility relay starts the operation. The KV Series starts ramp up/down control automatically.
Pulses are output from output 0502.
The output frequency can be specified within the range of 200 Hz to 50 kHz.
Number of output DM1485 and DM 1484
Frequency (Hz)
pulses (pulses) Upper digit Lower digit

Operating frequency
DM1481

Startup frequency
DM1480

Acceleration Deceleration
time DM1482 time DM1482

Parameter setting
Data memory Setting contents Setting range
DM1480 Ramp-up/down control startup frequency (Hz) 200 to 50,000
DM1481 Ramp-up/down control operating frequency (Hz) 200 to 50,000 (value larger than startup frequency)
DM1482 Ramp-up/down control acceleration/deceleration time (ms) 0 to 4000
DM1484 Number of output pulses (lower 16 bits) 0 to 65,535 (2 or more when DM1485 is 0)
DM1485 Number of output pulses (upper 16 bits) 0 to 65535

Control relays
Special utility relay No. Description
2308 Performs deceleration at rising edge, then stops operation.
2309 Remains ON while pulses are output. Stops operation immediately when being reset in an interrupt program.
2310 Starts up operation at rising edge.
➮ Refer to “12.3 Positioning Control” on page 690 in the Visual KV Series User’s Manual for details.

20
VOL. 9 Position control using a stepping motor
Programming Example
2008 2412 2413 The interrupt for emergency-stop opera-
0001 RES RES EI
tion is enabled.
2002 HSP The input time constant for input 0003
0002 0003
(emergency stop) is set to10 µs.
0000 0503 #00500 #05000 #00200 #01000 #00000 1000
0003 RES DW DW DW DW DW The parameters for clockwise rotation for
DM1480 DM1481 DM1482 DM1484 DM1485 1000 pulses are set.
0001 0503 #00500 #05000 #00200 #02000 #00000 1001
0004 RES DW DW DW DW DW The parameters for clockwise rotation for
DM1480 DM1481 DM1482 DM1484 DM1485 2000 pulses are set.
0002 0503 #00500 #05000 #00200 #03000 #00000 1002
0005 SET DW DW DW DW DW The parameters for counterclockwise
DM1480 DM1481 DM1482 DM1484 DM1485 rotation for 3000 pulses are set.
1000 2310
0006 When each parameter is set, pulse output
is started.
1001
0007

1002
0008

0004 2308
0009 The operation is slowed down and
stopped.
END
0010

INT
0011 0003 The interrupt program for emergency stop
is executed.
2002 2309
0012 RES

RETI
0013

ENDH
0014

Tips Slow-down stop and emergency stop


Turn ON relay 2308 for the slow-down stop operation.

0004 2308

Reset relay 2309 in the interrupt program for the emergency-stop operation.
INT
0003

2002 2309
RES

RETI

21
The specified frequency pulse output
VOL. 10 function
Example Speed control of a pulse motor with the specified frequency pulse output function

Outline
Use the specified frequency pulse output function to control the speed of a pulse motor.
Turning on input 0000 starts the operation. The operation is slowed down and stopped when input 0001 turns on.
The operation frequency is set in DM0000.

Visual KV Series Pulse motor and motor driver

50kHZ

30kHZ
20kHZ
Applications: Tension adjustment of hoop material, Time 5kHZ
adjustment for sheet material remaining in OHZ OHZ
the processing bath

■ Programming Technique
The Visual KV Series features the specified frequency pulse output function as standard. This function is convenient
especially for the applications above. When the specified frequency pulse output function is set, the pulses of the
frequency (Hz) specified in DM1936 is produced from output 0501. Turning ON special utility relay 2306 starts the
pulse output. Turning OFF special utility relay 2306 stops the pulse output.

Device used for specified frequency pulse output


Special utility relays
Relay No. Description
Use specified frequency pulse output. ON: Yes, OFF: No Function
2306
is forced OFF when error relay 2307 turns ON.
Error flag for specified frequency pulse output function.
2307
(When turned ON, the pulse output is turned OFF.)

Data memory
DM No. Description
DM1936 Preset value for specified frequency pulse output is written. (16 to 50000 [Units: Hz])

Pulse duty ratio: fixed to 50% ON

OFF

The ratio between ON and OFF time is 1:1.

The frequency is increased/decreased by 100 Hz and updated every 20 ms in the program.


The current speed is compared with the preset speed. If the current speed is less than preset speed, the current
speed is increased. If the current speed is more than the preset speed, the current speed is decreased.

22
VOL. 10 The specified frequency pulse output function
Programming Example
The operation starts when input 0000 turns ON. The operation is slowed down and stopped when input 0001
turns ON. The output frequency is changed every time when input 0002 turns ON.
When the output frequency (Hz) is specified in DM0000, the operation is controlled at the start-up speed of 16
Hz and the acceleration of 100 Hz/20 ms.
0000 2306 1000 #00016 2306 1100 1200
The preset speed is set to “16” at the rising edge of input
1000
DIFU DW SET SET SET 0000. The specified frequency pulse output start relay is
DM1936 turned ON.
0001 1001 1001 1101
DIFU SET The operation is slowed down and stopped at the rising
1204 edge of input 0001 or at the end of the operation pattern.
When the slowdown-stop relay is turned ON, the preset
1101 #00016 DM0000 DM1936 2010 2306 1100 1101 1206
LDA STA CMP RES RES RES speed is set to 16 Hz. When the output frequency reaches
0002 1002 16 Hz, the operation is stopped.
DIFU
The output frequency is changed in the specified order at
2003 SFT the rising edge of the output frequency change input.
D
1200
1002
CLK
2008 1204
RES
1206

1200 1003 1003 #30000


DIFU DW The 1st frequency is set. (30 kHz)
DM0000
1201 1004 1004 #50000
DIFU DW The 2nd frequency is set. (50 kHz)
DM0000
1202 1005 1005 #05000
DIFU DW The 3rd frequency is set. (5 kHz)
DM0000
1203 1006 1006 #20000
DIFU DW The 4th frequency is set. (20 kHz)
DM0000
1100 T000 #00020
T
S 000 The 20-ms flicker circuit is activated during the pulse
T000 DM1936 DM0000 2009 00
output.
LDA CMP CALL The current speed is compared with the preset speed every
2011 01 20 ms. The current speed is accelerated (SBN00) when the
CALL preset speed is faster. The current speed is decelerated
2307 0500
(SBN01) when the preset speed is slower.
Output 0500 turns ON when a setting error occurs.
END

SBN
00 Acceleration process
2002 DM0000 DM1936 #00100 2011 TM02 DM1936 TM02 DM1936 When the difference between the current speed and preset
LDA SUB CMP STA LDA ADD STA
speed is less than “100,” the speed is accelerated by the
2011 DM1936 #00100 DM1936 difference. When the difference is “100” or more, the speed
LDA ADD STA
is accelerated by “100.”
RET

SBN
01 Deceleration process
2002 DM1936 DM0000 #00100 2011 TM02 DM1936 TM02 DM1936 When the difference between the current speed
LDA SUB CMP STA LDA SUB STA and preset speed is less than “100,” the speed
2011 DM1936 #00100 DM1936 is decelerated by the difference. When the
LDA SUB STA
difference is “100” or more, the speed is
RET
decelerated by “100.”
ENDH

23
VOL. 11 Word shifting
Example Storing the stop duration of equipment in memory as history

Outline
The stop duration of equipment is measured using the internal timer of the KV, and is stored into data memory
DM0000. When the equipment stops again, the previous stop duration is transferred to DM0001 and the current
stop duration is written into DM0000. The last 5 stop durations are stored.

Example:
When stop 1 (1 min), stop 2 (2 min and 28 sec), and stop 3 (51 sec) are input sequentially, the contents of each
data memory is changed, as follows, each time a new stop duration is input.
Stop 1 (1 min) Stop 2 (2 min and 28 sec) Stop 3 (51 sec)

DM0000: #00060 #00148 #00051

DM0001: #00060 #00148

DM0002 #00060

DM0004

■ Programming Technique
Use the FOR-NEXT instructions and indirect addressing of data memory.

Use the LDA instruction and STA instruction to shift words in the data memory. The content of each data memory is
transferred as follows:
(5) (4) (3) (2) (1)

DM0000 DM0001 DM0002 DM0003 DM0004


Latest stop duration (1): Content of DM0003 is transferred to DM0004.
(2): Content of DM0002 is transferred to DM0003.
(3): Content of DM0001 is transferred to DM0002.
(4): Content of DM0000 is transferred to DM0001.
(5): Latest stop duration is transferred to DM0000.

Indirect addressing of the data memory (format: #TMxx) can be performed using tempo-
rary data memory (such as TM10 and TM11).
Destination indirectly Destination indirectly
Word shifting Value of TM10 Value of TM10
addressed by #TM10 addressed by #TM11
(1) #00003 DM0003 #00004 DM0004
(2) #00002 DM0002 #00003 DM0003
(3) #00001 DM0001 #00002 DM0002
(4) #00000 DM0000 #00001 DM0001

When word shifting (1) is performed, for example, #00003 and #0004 are specified respectively for TM10 and TM11
to transfer data from #TM10 to #TM11 using the LDA instruction and STA instruction.

Word shifting of (1) to (4): Transfer from #TM10 to #TM11 is repeated using the FOR-NEXT instructions.

➮ To use the FOR-NEXT instructions in combination with indirect addressing of data memory, refer to examples 1 and 2 of
FOR-NEXT applications of the visual KV Series Users Manual, “Indirect addressing” on page 521.
24
VOL. 11 Word shifting
Programming Example
0000 1001 1000
0001 SET DIFD

1001 #65535
0002 T000 ON duration of input 0000 is stored into
temporary data memory TM05.
1000 T000 TM04 #65535 TM04 TM05 1001
0003 LDA STA LDA SUB STA RES

1000 00 At the rising edge of input to 0000, subroutine


0004 CALL
program is called.
END
0005

SBN Subroutine for executing word shifting


0006 00

2002 #00003 TM02 #00004 TM03 To execute word shifting (1) first, DM0003 and
0007 LDA STA LDA STA DM0004 are specified using TM02 and TM03.
FOR Program between FOR and NEXT is repeated
0008 #00004
4 times.
2002 #TM02 #TM03 TM02 TM03 Content of the data memory indirectly-
0009 LDA STA DEC DEC
addressed by TM02 is transferred to the data
NEXT memory indirectly-addressed by TM03. Then,
0010 the value of TM02 and that of TM03 are
2002 TM05 #TM03 decremented respectively by one, and data
0011 LDA STA memory No. for the next word shifting is
specified.
RET
0012
After execution of program between FOR
and NEXT is terminated, the latest stop
duration is transferred to the data memory
(DM0000) indirectly-addressed by TM03.

Tips If indirect addressing of data memory using temporary data memory is not used for the
above programming, program for word shifting (for which LDA instruction and STA instruction
are used) is shown below.
0000 1001 1000
SET DIFD
1001 #65535
T000
1000 T000 TM04 #65535 TM04 TM05 1001
LDA STA LDA SUB STA RES
1000 DM0003 DM0004
LDA STA Word shifting (1) is executed.
DM0002 DM0003
LDA STA Word shifting (2) is executed.
DM0001 DM0002
LDA STA Word shifting (3) is executed.
DM0000 DM0001
LDA STA Word shifting (4) is executed.
TM05 DM0000
LDA STA Word shifting (5) is executed.

Just change this value! FOR


#00004
If word shifting is executed 20
times using the LDA instruction When indirect addressing is used, what you have
and STA instruction, program to do is just to change the value of operand for the
becomes longer as frequency FOR instruction. The program does not become
of execution increases. longer.

25
VOL. 12 Fine adjustment with a digital trimmer
Example Fine adjustment of the air discharge time of a parts feeder
Outline
In a factory with several lines, defective products are discharged by air. The digital trimmer of the Visual KV Series
can be used to adjust the air discharge time for each line according to the size and interval of products.

The digital trimmer mode of the Access Window enables the adjustment of the air discharge without the handheld
programmer or an external input device.

Setting

Digital trimmer

Line 1
Defective product Visual KV Series
Line 2
input: 0003 Defective product Line 3
Air discharge: 0500 input: 0004 Defective product input: 0005
Air discharge: 0501 Air discharge: 0502

■ Programming Technique
Use the TMIN instruction to set the digital trimmer.
Store the preset value of the Visual KV series’ digital trimmer in the internal register. The value is set in the KV’s
internal timer as the air discharge time for each line.
Enter the preset value for each line by changing the preset input respectively.

Internal register Input 0000: When turned ON, it updates the


#00000 preset value of the timer for line 1.
to #65535 Input 0001: When turned ON, it updates the
preset value of the timer for line 2.
Input 0002: When turned ON, it updates the
preset value of the timer for line 3.
Digital trimmer

26
VOL. 12 Fine adjustment with a digital trimmer
Programming Example
0000 0001 0002 1000
0001
Interlock circuit of input relays 0000 to 0002
0000 0001 0002 1001 When 0000 turns ON, compressed air release
0002 time for line 1 is updated.
When 0001 turns ON, compressed air release
0000 0001 0002 1002
0003 time for line 2 is updated.
When 0002 turns ON, compressed air release
2002 0 1000 T000 time for line 3 is updated.
0004 TMIN STA
The preset values of the digital trimmer are
changed to the preset values of timers T000 to
1001 T001
0005 STA T002.
T000: Compressed air release time for line 1
1002 T002 T001: Compressed air release time for line 2
0006 STA T002: Compressed air release time for line 3
0003 #00080
0007 T
S 000 When input of detecting defective for line 1
(0003) turns ON, one-shot output is sent
0500 T000 0500 through 0500.
0008

0004 #00150
T
0009 S 001 When input of detecting defective for line 2
(0004) turns ON, one-shot output is sent
0501 T001 0501 through 0501.
0010

0005 #00230
0011 T
S 002 When input of detecting defective for line 3
(0005) turns ON, one-shot output is sent
0502 T002 0502 through 502.
0012

Tips To set the range for the digital trimmer adjustment, specify the upper limit
value in data memory.

Digital trimmer 0 Upper limit value: DM1938


Digital trimmer 1 Upper limit value: DM1939

Set the upper limit value by specifying it in the device mode of the Access Window or by
writing it in the program.

Example:
To set the range of 0 to 1000:

2008 #01000
DW
DM1938

27
Receiving multiple pulses and
VOL. 13 outputting them as a batch
Example Displaying total number of products travelling on multiple lines on a coun-

Outline
ter
The total number of products on all lines is counted. Then, the same number of pulses as counted products are
output to the RC Series high speed counter to display the total number on the counter.

Line 1

Pulse

Line 2
6 5 4
Line 3 RST 3 2 1

RC Series Counter
Line 4 Visual KV Series

Line 5

FS Series Fiberoptic Sensor

■ Programming Technique
Create an up-down counter using the INC instruction and DEC instruction.

• To count the total number of products on the line, the INC instruction is used.
➮ Refer to No. 1 “Counting total number of products”.

• Since the total count is stored in the data memory, the same number of pulses as the stored value are output to
the RC Series.

The CMP instruction checks


whether the value of the data memory is 0. This is repeated until the value of the
data memory is 0.

Each time a pulse is output, the value of


the data memory is decremented by one.

In the example from No.1 “Counting total number of products”, the data memory is used. When the temporary data
memory is used instead of the data memory, the value of the memory is reset to 0 automatically when power is
turned OFF.

Note 1: If the pulse period of the count input is very short, the RC’s display will not follow the flow of products.
Note 2: Use the KV with transistor or MOS-FET type outputs.

28
VOL. 13 Receiving multiple pulses and outputting them as a batch
Programming Example
2002 HSP
0001 0000

HSP
0002 0001 The time constant of input relays 0000 to 0004 is
set to 10 µs so that high speed inputs can be
HSP
0003 0002 received.
(If you use an input device that chatters, such as
HSP a limit switch, do not use the HSP instruction.)
0004 0003

HSP
0005 0004

0000 TM02
0006 INC

0001 TM02
0007 INC

0002 TM02 Each time one of input relays 0000 to 0004 turns
0008 INC ON, the value of temporary data memory TM02 is
incremented by one.
0003 TM02
0009 INC

0004 TM02
0010 INC

2002 TM02 #00000 2010 T000 #00010 When the value of temporary data memory TM02
0011 LDA CMP T
H 000 is not #00000, timer T000 cycles ON and OFF
each 0.1 sec.
T000 TM02 0500
0012 DEC Each time timer T000 turns ON, the value of
TM02 is decremented by one and output is sent
through 0500.

Tips To minimize the response delay of the counter display, the following cir-
cuit is recommended.
2002 TM02 #00000 2011 1000
LDA CMP

0500 1000 KEEP


SET
0500
0500
RES

0500 TM02
DEC

When this circuit is replaced with that on the 11th and 12th lines of the above program, 0500
turn ON every two scans. Accordingly, the RC counts once in two scans.

When the scan time is 0.3 ms, for example, the RC counts every 0.6 ms. Higher speed
response can be obtained by using the above circuit than by using the 1-ms timer.

29
Converting high speed pulses into
VOL. 14 low speed pulses
Example Converting pulse frequency
Outline
High speed pulses emitted from the high speed response fiberoptic sensor FS-M1H are converted into low speed
pulses, and the same number of low speed pulses are output to an electromagnetic counter or host controller.

Electromagnetic counter
Large host controller

Visual KV Series

Low speed pulse


High speed pulse

■ Programming Technique
The number of high speed pulses are counted using CTH0, and low speed pulses are output until the high speed
pulse count is the same as that of low speed pulses.

High speed pulses are counted using CTH0. Low speed pulses are uniformly output to control the internal timer.
The value of the temporary data memory is incremented by one each time a pulse is sent. The pulses continue to
be output until the value of the temporary data memory equals the count value of CTH0.

2002 CTH0 TM02 2010 T001 #00100 #00200


T T
LDA CMP S 000 S 001

T000 0500

T001 TM02
INC
TM02: Used for counting the number of low speed pulses

The width and period of pulses to be output through 0500 can be set as required using timers T000 and T001.

Pulse width =preset value of T001 - preset value of T000


Pulse period = preset value of T001

Note: Frequency of low speed pulses depends on error margin of timers T000 and T001.

➮ To count the number of cyclic outputs using the temporary data memory, refer to No. 13 “Receiving Multiple Pulses then
Outputting Them as A Batch”.

30
VOL. 14 Converting high speed pulses into low speed pulses
Programming Example
2008 #00000 2100 CTH0
0001 LDA STA When the operation is started, reset high-
RES
speed counter CTH0 to the initial setting.
2002 HSP
0002 0004 The input time constant for input 0004 is set
to 10 µs.
2002 CTH0
0003 0004 High speed pulses are input through 0004.
2002 CTH0 TM02 2010 T001 #00100 #00200
0004 LDA CMP T
S 000
T
S 001 Pulses whose width is 100 ms and whose
period is 200 ms are cyclic-output through
T000 0500
0005
0500 until the count value of high speed pulses
becomes same as that of low speed pulses.
T001 TM02
0006 INC Each time T001 turns ON, the value of TM02
is incremented by one.

Tips In the above program, up to 65,535 (maximum number that high speed counter can count)
high speed pulses can be converted into low speed pulses. (When 24 bit mode is used, the
maximum count is 16,777,215.) When more than 65,535 pulses need be counted, a pro-
gram should be created so that the following conditions are satisfied:
Overflow frequency of high speed pulses = overflow frequency of low
speed pulses
Count value of high speed pulses is same as that of low speed pulses
The programming example is shown below.
2008 CTH0 2103
0001 EI RES SET
2002 HSP
0002 0004
2002 #65535 CTH0
0003 CTC0 0004
2002 CTH0 TM02 2010 1000
0004 LDA CMP
TM10 TM03 2010 1001
0005 LDA CMP
Pulses whose width is 100 ms and whose period is
1000 T000 #00100 #00200 200 ms are cyclic-output through 0500 until the
T T
0006 S 000 S 001
count value of high speed pulses becomes same as
1001
0007 that of low speed pulses.
T000 0500
0008
T001 TM02 TM02 #65535 2010 #00000 TM02 TM03
0009 INC LDA CMP LDA STA INC When the value of TM02 exceeds 65,535 (overflow
END occurs), the overflow frequency is stored in TM03.
0010
INT
0011 CTC0
2002 TM10 When CTH0 counts up to 65,535 (overflow occurs),
0012 INC
the overflow frequency is stored in TM10.
RETI TM02: Used for counting the number of low speed
0013
pulses
ENDH
0014 TM03: Used for counting the overflow frequency of
low speed pulses
TM10: Used for counting the overflow frequency of
high speed pulses

Number of low speed pulses that are output:


Overflow frequency of high speed pulses x 65,535 + count value of high speed pulses.

31
VOL. 15 Bit counting (Bit checking)
Example Checking how many error detection signals are input to input relays of channel
Outline
The KV checks how many sensors for detecting errors (that are connected to input relays 0000 to 0015 of channel
0) are currently turned ON, allowing you to confirm the total number of errors.

Error
detection
input

0015001400130012001100100009000800070006000500040003000200010000
OFF ON OFF OFF OFF OFF ON OFF OFF ON OFF OFF OFF OFF OFF ON

Visual KV Series Four errors are detected.

■ Programming Technique
The KV checks whether each input relay is ON, and the number of relays that are ON are counted.

Use the RRA instruction to check the status of input relays.

Procedures
1. The status of the input relays of channel 0 are entered into the internal register using the LDA instruction.

2. Contents of the internal register are shifted right by one bit using the RRA instruction.

3. Contents of the rightmost bit is entered into special utility relay 2009. When the contents of 2009 is 1 (ON), 1 is
added to the number of errors.

The above operation is repeated 16 times (number of bits of channel 0).

0000 0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0 0 1 0 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0
LDA 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1
Repeated
16 times.
#01 0 0 1 5 0 0 1 4 0 0 1 3 0 0 1 2 0 0 1 1 0 0 1 0 0 0 0 9 0 0 0 8 0 0 0 7 0 0 0 6 0 0 0 5 0 0 0 4 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0 2009
RRA 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1

When content of 2009 is 1 (ON), 1 is added to the number of errors.


When content of 2009 is 0 (OFF), no action is performed.

The SRA instruction can be used in the same way.


➮ Refer to KV Series Users Manual, “Change in status of special utility relays by arithmetic instruction” on page 580 to 582.

32
VOL. 15 Bit counting (Bit checking)
Programming Example
2002 0000
0001 LDA
The ON/OFF status of the input relays of channel
0 are always entered into the internal register.
FOR
0002 #00016 16 bits of the internal register are checked.

2002 #01 2009 TM10 Bits are shifted right one by one each time the bit
0003 RRA INC of 2009 is checked, and the value of TM10 is
incremented by one when 2009 turns ON.
NEXT
0004
After the 16 bits are checked, the value of TM10 is
2002 TM10 DM0000 #00000 TM10
0005
transferred to DM0000 and the value of TM10 is
LDA STA LDA STA
reset to 0. The value entered into DM0000 is the
number of inputs that turns ON.

Tips When some of the input relays of channel 0 are used for purposes other than error detection,
the ON/OFF status of those input relays should not be subjected to bit checking.

Immediately after status of the input relays of channel 0 are read using the LDA instruc-
tion, fetch only status of the desired inputs using the ANDA instruction.

Example
When input 0006 is not used for error detection input:

2002 0000 $FFBF


0001 LDA ANDA

0000 0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
LDA 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1

$FFBF 0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
ANDA 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1

0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000
0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1

#01 0015 0014 0013 0012 0011 0010 0009 0008 0007 0006 0005 0004 0003 0002 0001 0000 2009
RRA 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1

As shown above, the status of error detection input relays only can be read, allowing the
number of errors to be counted.
When the input relays of another channel, in addition to channel 0, are also used for error
detection input, specify the desired channel for LDA and create the same program as the
above, then combine it with the above program.

➮ The number of error detection inputs can be counted using the INC instruction more easily than
using the C (Counter) instruction. For details, refer to No. 1 “Counting total number of products”.

33
Shift register simulation in an asyn-
VOL. 16 chronous production line
Example Ejecting rejects without a constant synchronous signal

Outline
When interval between workpieces on the production line varies, rejects are correctly ejected only by using sensors
for detecting rejects and for confirming a workpiece in the ejection position.

• Inputting clock pulses (synchronous signal) for a timing cam is not required.

Inspection process Ejection process


Even if interval between workpieces is not constant,
rejects can still be correctly ejected.
Sensor for Sensor for confirming
detecting rejects workpiece in ejection
INPUT 0001 position INPUT 0002

Box for
Sensor for synchronization
receiving
INPUT 0000
rejects

■ Programming Technique
Since the clock pulse input to control the position of a reject on the line is not used, the SFT instruction cannot be
used. ➮ Refer to No. 2 “Shift register”.

Then, use the data memory to eject rejects.


Information whether each workpiece is acceptable or not is stored sequentially into the data memory. When each
workpiece reaches the ejection position, the workpiece is accepted or ejected according to the stored information.

First-in first-out (FIFO) queuing is used to store and read data.

Reject detection input: 0001

DM0004 O K DM0004 Blank


When input from the
workpiece confirmation
DM0003 N G sensor at the ejection position
DM0003 O K
(0002) turns ON
DM0002 O K DM0002 N G

DM0001 O K DM0001 O K
Ejection

DM0000 N G DM0000 O K N G

34
VOL. 16 Shift register simulation in an asynchronous production line
Programming Example
2008 $FFFF DMOOO0 DMOOO1 DMOOO2 DMOOO3 DMOOO4
When power is turned ON, $FFFF is written into
0001 LDA STA STA STA STA STA DM0000 to DM0004. $FFFF assumes that content of
the data memories is blank.
0000 0001 $1111 DMOOO4
0002 LDA STA When input 0000 (input from sensor for synchroniza-
tion) turns ON, detection of rejects is performed (0001).
0001 $0000 DMOOO4 Acceptable workpiece: $0000 is entered into DM0004.
0003 LDA STA
Defective workpiece: $1111 is entered into DM0004.
0002 1001 1001 DM0000 $1111 2010 1000
0004 LDA CMP
When the workpiece in ejection position is defective
DIFU
($1111), output is sent through 1000.
$FFFF DM0000 After workpiece acceptability has been determined,
0005 LDA STA the contents of DM0000 is erased.
1000 #00010
0006 T000 When the workpiece is defective, a one-shot output is
sent through 0500.
0500 T000 0500
0007

2002 DM0000 $FFFF 2010 DM0001 DM0000 $FFFF


0008 LDA CMP LDA STA DW
DM0001
2002 DM0001 $FFFF 2010 DM0002 DM0001 $FFFF When the contents of DM0000 to DM0004 is
0009 LDA CMP LDA STA DW blank, the contents of each data memory is
DM0002
transferred to the previous data memory.
2002 DM0002 $FFFF 2010 DM0003 DM0002 $FFFF
0010 LDA CMP LDA STA DW
DM0003 Contents of data
2002 DM0003 $FFFF 2010 DM0004 DM0003 $FFFF $FFFF: No data (blank)
0011 LDA CMP LDA STA DW $0000: Acceptable
DM0004
$1111: Defective

Tips The important point is that the blank data is entered into the contents of
the data memory after a defective workpiece is ejected.

On the 8th to 11th lines of the above program, the contents of data memory DM0000 is
made blank after a reject is ejected. To perform the next ejection, the contents of the next
data memory (DM0001) must be transferred to DM0000. Blank data memory is expressed as
$FFFF, and the contents of data memories DM0001 to DM0004 is transferred sequentially to
the previous data memory to fill the data memory where $FFFF is written.

DM0003 N G N G N G

DM0002 O K O K Blank

DM0001 O K Blank O K

DM0000 Blank N G O K O K

By changing content of the data memory, product types can be differentiated.


In addition to acceptable ($0000) and defective ($1111), other information can be digitalized
and entered into the data memories. This allows differentiation between product types.

Example
Product type 1 ($0100), product type 2 ($0200), product type 3 ($0300), etc.

35
VOL. 17 Emergency stop circuit
Example Emergency stop for cutting work

Outline
An emergency stop is performed in the cutting process shown below.

Operation procedures
Emergency stop
Closing chuck
Emergency stop

Rotating workpiece

Advancing cutting
tool and machining
workpiece

Retreating Visual KV Series


cutting tool

Releasing chuck

■ Programming Technique
Use the MC-MCR instructions for performing an emergency stop.

Put the cutting program between the MC and MCR instructions and create the program so that the MC instruction
is set to OFF when an emergency stop signal is input. Then the cutting process, which was interrupted by an
emergency stop signal, is stored and can resume when the emergency stop is canceled.

Configure program as follows:


Emergency stop input

????? MC
????? ?????
????? ?????

????? ?????
SET ????? ?????
SET

????? ????? ?????


RST ????? ????? ?????
RES
MCR

Control circuit and emergency stop circuit can be programmed as 2 independent steps.

36
VOL. 17 Emergency stop circuit
Programming Example
0000 1000
When 0000 turns ON, STG 1000 turns ON and
0001 SET
the cutting operation starts.
0005 MC
When 0005 turns ON, an emergency stop is
0002 performed. (All outputs between MC and MCR
instructions are turned OFF.)
1000 0500 0001 1001 The chuck closes and execution is transferred to
0003 STG JMP STG 1001 when chuck confirmation input is set
0501 0502 0002
to ON.
1001 1002
0004 STG SET JMP The motor starts and the cutting tool advances.
When the cutting tool reaches the other end,
1002 #00030 T000 0501 0503 0003 1003 execution is transferred to STG 1002.
0005 STG T000 RES JMP The motor stops after 3 sec and the cutting tool
is retracted. When the cutting tool reaches its
1003 0504 0000 1000 origin, execution is transferred to STG 1003.
0006 STG JMP The chuck is released and the system waits for
a restart.
MCR
0007
0000: Start
0001: Confirming chuck closing
0002: Confirming advance end
0003: Confirming retreat end
* When operation resumes, after the emergency stop is canceled 0500: Closing chuck
(0005: OFF), all relays except for output relays* are reactivated in the 0501: Rotating motor
same status (ON/OFF) as before the emergency stop was performed. 0502: Advancing cutting tool
The timer, however, operates from its initial status. 0503: Retreating cutting tool
* Outputs are set to OFF when an emergency stop is performed.

Tips For users who need a complete reset when the emergency stop is per-
formed
To perform a complete reset when the emergency stop is performed, add the following step
to the above program as the 8th line.
0005
ENDS

By adding the above step, execution of all STG instructions is stopped. The above is effective
for resetting all relays when the STG instruction and JMP instruction are used in a sequential
process.

Even when processes other than a sequential process are controlled, the SFT instruction
can be used conveniently to reset all the specified internal relays.
2003 SFT
D
1000
2003
CLK

0005 1003
RES

➮ When input 0005 turns ON, internal relays 1000 to 1003 can be reset.

37
VOL. 18 Selection of operation mode
Example Selecting fully-automatic or individual operation mode

Outline

On a production line with multiple processing machines, the fully-automatic or individual operation mode is se-
lected. (fully-automatic operation mode allows workpieces to be transferred sequentially to each machine, while
individual operation mode allows each machine to be operated by pressing a pushbutton.)
ce

ce

ce
ng

ng

ng
pie

pie

pie
etti

etti

etti
or k

or k

or k
g1

g2

g3
iec g

rkp ing

iec g
es

es

es
wo firmin

wo firmin
gw

gw

gw
sin

sin

sin
m

Fully-
iec

Individual
nfir
ces

ces

ces
ctin

ctin

ctin
automatic
r kp

r kp
n

n
Co

Co

Co
Pro

Pro

Pro
Eje

Eje

Eje
wo

Processing Processing Processing


machine 1 machine 2 machine 3 Selector switch
0000

Pushbutton for
individual operation
0007 0008 0009

■ Programming Technique
Points are as follows:
1. Sequential processing is controlled.
2. Because one process is controlled using two inputs (fully-automatic and individual), a double-input coil is ap-
plied.

The STG instruction and JMP instruction are optimal for controlling the process shown
above.

For the STG instruction, one coil can be used as the output for 2 relays as shown below.

1000 0001 1001 0500


STG

1001 0002 1000 0500


STG

By programming internal relays 1000 and 1001 not to turn ON simultaneously, the ON/OFF of 0500 can be control-
led using the STG instruction for internal relays 1000 and 1001.

38
VOL. 18 Selection of operation mode
Programming Example
2008 0000 When power is turned ON, STG 1000 (fully-automatic operation
1000 mode) is selected when the input for the selector switch turns ON.
0001 SET
At this time, STG 1100 (individual operation mode) is selected
0000 1100 when the input for the selector switch turns OFF.
0002 SET
Fully-automatic operation mode
1000 0001 0500 0002 1001 Control of processing machine 1:
0003 STG JMP After confirmation of workpiece setting, processing, and
1201 confirmation of workpiece ejection are completed, execution is
0004 ENDS transferred to STG 1001 (processing machine 2).
1001 0003 0501 0004 The STG instruction for the fully-automatic operation mode is
1002
0005 canceled.
STG JMP
Control of processing machine 2:
1201 After confirmation of workpiece setting, processing, and
0006 ENDS confirmation of workpiece ejection are completed, execution is
1002 0005 0502 0006 1000 transferred to STG 1002 (processing machine 3).
0007 STG JMP The STG instruction for the fully-automatic operation mode is
1201 canceled.
0008 ENDS Control of processing machine 3:
After confirmation of workpiece setting, processing, and
1100 0007 0001 0500
confirmation of workpiece ejection are completed, execution is
0009 STG transferred to STG 1000 (processing machine 1).
0008 0003 0501
The STG instruction for the fully-automatic operation mode is
0010 canceled.
0009 0005 0502 Individual operation mode
0011 Control of processing machine 1: After workpiece setting is
1200 confirmed, each workpiece is processed by pressing the
0012 ENDS pushbutton switch.
0000 1200 1200 1000 Control of processing machine 2: After workpiece setting is
0013 SET confirmed, each workpiece is processed by pressing the
DIFU
pushbutton switch.
C000 1201 1201 1100 Control of processing machine 3: After workpiece setting is
0014 DIFU SET confirmed, each workpiece is processed by pressing the
pushbutton switch.
The STG instruction for the individual operation mode is
Description of terminals canceled.
0000: Mode selector switch
0001: Confirming workpiece setting (processing machine 1) The STG instruction for the individual operation mode is
0002: Confirming workpiece ejection (processing machine 1) canceled, and the fully-automatic operation mode is selected.
0003: Confirming workpiece setting (processing machine 2) The STG instruction for the fully-automatic operation mode is
0004: Confirming workpiece ejection (processing machine 2) canceled and the individual operation mode is selected.
0005: Confirming workpiece setting (processing machine 3)
0006: Confirming workpiece ejection (processing machine 3)
0007: Pushbutton switch for individual operation (processing machine 1)
0008: Pushbutton switch for individual operation (processing machine 2)
0009: Pushbutton switch for individual operation (processing machine 3)
0500: Processing output (processing machine 1)
0501: Processing output (processing machine 2)
0502: Processing output (processing machine 3)

Tips To repeat a cycle of fully-automatic operation several times, add the following step to the
above program as the 11th line of the program.
Example
To repeat a cycle of fully-automatic operation 5 times:
C000 #00005 C000
C000 ENDS
0006

The number of times that input 0006 turns on, indicating the completion of one cycle opera-
tion (completion of machine 3 process), is counted. When the count value reaches the
preset value, the entire process operation is terminated. (To restart operation, turn ON input
0000 again.)

39
Step-progress operation
VOL. 19 (sequential control)
Example Step progress of material handling machine

Outline
When the step-progress operation is specified, pressing the start button changes the operation process one by one.

Origin point

1. Lowering the arm Operation panel 7


4
Step
2. Clamping
8
Auto
Start 5
3. Raising the arm Stage 6

3
4. Forwarding the arm

5. Lowering the arm


2
1

6. Unclamping

7. Raising the arm


Parts feeder
8. Returning the arm

■ Programming Technique
W-UE (wait up edge) instruction is useful for step-progress operation.
When the W-UE instruction is used with the STG and JMP instructions, one start button allows the step-progress
operation (sequential control) of every process.

Start button: 0000

Start button
1001 0500 0000 1101 1002
With W-UE instruction: Simple STG JMP
1101
1002 0501 0000 1102 1003
STG JMP
1102
1003 0502 0000 1103 1004
STG JMP
1103

0000 1101
Without W-UE instruction: Complicated DIFU
1001 0500 1101 1002
STG JMP
0000 1102
DIFU
1002 0501 1102 1003
STG JMP
0000 1103
DIFU
1003 0502 1103 1004
STG JMP

When the STG and JMP instructions are used for the control of each process, the program can be created inde-
pendently. This allows for easy programming.

40
VOL. 19 Step-progress operation (sequential control)
Programming Example
0005 1000
0001 SET When 0005 turns ON, the step-progress operation
is enabled.
1000 0000 1100 1001
0002 STG JMP When 0000 turns ON, the arm is lowered.
1100
1001 0500 0000 1101 1002
0003 STG JMP When 0000 turns ON, the product is clamped.
1101
1002 0501 0000 1102 1003
0004 STG JMP When 0000 turns ON, the arm is raised.
1102
1003 0502 0000 1103 1004
0005 STG JMP When 0000 turns ON, the arm is forwarded.
1103
1004 0503 0000 1104 1005
0006 STG JMP When 0000 turns ON, the arm is lowered.
1104
1005 0501 0000 1105 1006
0007 STG JMP When 0000 turns ON, the product is unclamped.
1105
1006 0504 0000 1106 1007
0008 STG JMP When 0000 turns ON, the arm is raised.
1106
1007 0502 0000 1107 1008
0009 STG JMP When 0000 turns ON, the arm returns.
1107
1008 0505 0000 1108 1000
0010 STG JMP When 0000 turns ON, the arm goes back to the
1108 origin point.

0000: Start button 0501: Clamping 0504: Unclamping


0005: Step-progress operation setting 0502: Raising the arm 0505: Returning the arm
0500: Lowering the arm 0503: Forwarding the arm

Tips Save the internal relay by setting the step-progress operation using the W-
UE instruction.

Since the W-UE instruction does not allow for the duplication of the second operand, the
programming example above requires several internal relays.

However, the following program requires only the one point of an internal relay.
0005 1000
SET
2002 0000

1100
1000 1100 1100 1001
STG RES JMP
1001 0500 1100 1100 1002
STG RES JMP
1002 0501 1100 1100 1003 0000
STG RES JMP

????

The point is that the internal relay 1100 used for the W-UE
instruction resets itself.

41
VOL. 20 Frequency counter function
Example Counting the number of rotations using the frequency counter
Outline
With the frequency counter function, which the Visual KV Series features as standard, measure the time for the
output pulse of a rotating object received through input 0004 with the high-speed counter and convert it into a
frequency (Hz). The measured frequency is used for the calculation of the number of rotations (rpm).

Pulse

Proximity sensor

Visual KV Series

Applications: Detecting the reduction in the number of rotations of a magnet, detecting the reduction in the number
of rotations of an agitator, and measuring the frequency of a rotating object

■ Programming Technique
The frequency counter function of high-speed counter CTH0 enables the measurement of the frequency of 30 kHz
at maximum.
Input the pulses for the frequency measurement to 0004. (In this case, phase B input 0006 is ignored.)

Devices used for the frequency counter function


Special utility relay
2305: Enable/disable the frequency counter function ON: Enable, OFF: Disable
Data memories
DM1404: Measurement cycle of frequency count (1 to 9999 [ms])
DM1405: Result of frequency count (Hz)

Turning ON special utility relay 2305 starts the frequency counter function. The measurement result (Hz) is stored in
DM1405.
To set the interval of the frequency measurement (ms), specify the value larger than the scanning time in DM1404
in the unit of ms.
The number of rotations can be obtained from the measured frequency with the following calculation:

No. of rotations (rpm) = Frequency (Hz) x 60 (sec.) / (No. of pulses for one rotation)

Note: When setting the measurement cycle, limit the number of pulses that are input during one measurement
cycle within the range of 2 to 65535.
The frequency counter function and high-speed counter CTH0 cannot be used at the same time.

42
VOL.20 Frequency counter function
Programming Example
Count the number of rotations of the gear which requires 10 pulses for one rotation.
Count the frequency of the pulses received through input 0004 every second (1000 ms). Store the result in
DM0000 and store the calculated number of rotations in DM0001.

2008 #01000 DM1404 2305


LDA STA SET After the measurement cycle of the pulses is set to 1000 ms
2002
(1 sec.). The frequency counter start relay 2305 is turned ON.
HSP
0004 The input time constant for input 0004 is set to 10 µs.
2002 DM1405 DM0000
LDA STA The measured frequency (Hz) is stored in DM0000.

DM0000 #00060 #00010 DM0001


LDA MUL DIV STA The number of rotations (rpm) is calculated with the meas-
ured frequency and is stored in DM0001.
END

ENDH

Tips To obtain the signals of Hi, Go, and Lo using the number of rotations, use the COMPARE
(CMP) instruction in the program.

2002 DM0001 DM0010 2009 1000


LDA CMP DM0001 > DM0010: Lo output
2002 DM0011 2009 1001
CMP
DM0010 DM0001 < DM0011: Go output
2009 1002
DM0011 DM0001: Hi output

43
VOL. 21 Sorting
Example Sorting machines in the ascending order of production
Outline
In the production site with multiple-injection molding machines, the Visual KV Series counts the number of molded
products of each machine. The resulting with count can be used to determine the machine of low production.

<Before sorting> <After sorting>


Machine No. Count value

Machine 1 C001=#2500 DM0011=#0004: DM0001=#2100 Low

Machine 2 C002=#2200 DM0012=#0002: DM0002=#2200

Machine 3 C003=#2400 DM0013=#0005: DM0003=#2300

Machine 4 C004=#2100 DM0014=#0003: DM0004=#2400

Machine 5 C005=#2300 DM0015=#0001: DM0005=#2500 High

* This example uses 5 machines for simplification. This application is more effective with a greater number of
machines.

■ Programming Technique
Prepare data memories for each machine to register the machine No. and the count value. (Example: Machine 1:
DM0011 for machine No., DM0001 for count value)
The sorting uses these data memories.

The large/small comparison of all target data memories is repeated and the data memo-
ries are sorted.

Flow chart of large/small comparison

Start DM(*): DM0001 to DM0005

Compares the data of DM (*) with DM (*+1)

DM(*)>DM(*+1) DM(*)≤DM(*+1) (*+1)≤5

Switches the data and machine Nos. in DM Repeats the comparison until the data memory
(*) and DM (*+1). number (*+1) becomes the last number (0005).

(*+1)>5
Compares the new data in DM (*) with the
data in DM (*-1). Repeats the comparison
until the data memory number (*) becomes End
the initial number (0001).

It is convenient to use the indirect addressing with temporary data memory in order to specify the data memory
number (*).
44
VOL. 21 Sorting
Programming Example
0000 1001 1001 1000 03
0001 DIFU SET CALL
#00001 TM10 #00002 TM11 Sorting busy relay 1000 is set at the
0002 LDA STA LDA STA rising edge of 0000. The data memory
#00011 TM12 #00012 TM13 and temporary data memory are set to
0003 LDA STA LDA STA the initial settings.
1000 TM11 #00005 2011 00
0004 LDA CMP CALL If the value in TM11 is less than “5,” the
END subroutine of the sorting is called.
0005
SBN
0006 01 Subroutine for switching the count values.
1000 #TM10 TM20 #TM11 #TM10 TM20 #TM11
0007 LDA STA LDA STA LDA STA The data in DM0001 to DM0005 are
switched by using the indirect addressing.
RET
0008
SBN
0009 02 Subroutine for switching the machine
Nos.
2002 #TM12 TM20 #TM13 #TM12 TM20 #TM13
0010 LDA STA LDA STA LDA STA The data in DM0011 to DM0015 are
switched by using the indirect addressing.
RET
0011
SBN
0012 00 Subroutine for sorting
2002 #TM10 #TM11 2011 TM10 TM11 TM12 TM13 To sort values in ascending order, “1” is
0013 LDA CMP INC INC INC INC
added to the data memory No. (*) until
TM11 #00005 2011 1000 “*+1” exceeds the last number “5.” When
0014 LDA CMP RES it exceeds “5,” relay 1000 is reset and the
2011 01 02 operation finishes.
0015 CALL CALL To sort values other than in ascending
TM10 #00000 2010 TM10 TM11 order, the count values and the machine
0016 LDA CMP DEC DEC Nos. in data memories are switched. To
TM12 TM13 check the previous comparison, “1” is
0017 DEC DEC subtracted from the data memory No. (*)
until the number returns to the initial
RET number (0).
0018
SBN
0019 03 Subroutine for initial setting of sorting.
2002 C001 DM0001 C002 DM0002 C003 DM0003 C004 DM0004
0020 LDA STA LDA STA LDA STA LDA STA
The machine Nos. and count values are
C005 DM0005 #00001 #00002 #00003 #00004 #00005
LDA STA DW DW DW DW DW temporarily copied in data memories.
0021
DM0011 DM0012 DM0013 DM0014 DM0015
RET
0022
ENDH * The count inputs for C001 to C005
0023 should be prepared separately.

45
VOL. 22 High-speed interrupt input function
Example Measurement of passing time between two points using high-speed interrupt input
Outline
Measure the time during which the target passes two points A and B and calculate the passing speed.
The FS-M1H high-speed response photoelectric sensor is used as the sensor. The passing time is measured with
the internal clock of the high-speed counter in the unit of µs.

Sensor 1 ON
INPUT 0002 OFF
Sensor 1 Visual KV Series

Sensor 2 ON
INPUT 0003 OFF

Sensor 2
Passing time (µs)

Applications: Measurement of the swing speed of a golf club head.

■ Programming Technique
Point 1: Measure the passing time with the internal clock of the KV.
• Use the KV’s internal clock (1-µs cycle) and the high-speed counter to measure the passing time.

Passing
time
Sensor 1

Sensor 2

Internal clock
(1 µs) No. of clock
counts

(Passing time) = (Cycle of internal clock: 1 µs) x (No. of clock counts)

Point 2 The interrupt (INT) instruction is the best for the program.
• When the sensor detects the target, the interrupt is executed. Store the current value of the high-speed counter
in the data memory.
When the interrupt is executed, the current value of the high-speed counter is automatically stored in the data
memory (Input capture function).
By using this function, the passing time is obtained as the difference between the stored counter values of
sensor 1 and sensor 2.
Passing
time
Sensor 1
(Interrupt 0002)

Sensor 2
(Interrupt 0003) No. of pulses = xxxxx No. of pulses = yyyyy

Internal clock No. of clock


(1 µs) counts
DM1932 DM1934
(Value stored by the input capture of 0002) (Value stored by the input capture of 0003)

(Passing time) = [yyyyy (DM1934) - xxxxx (DM1932)] x (Cycle of internal clock: 1 µs)

46
VOL. 22 High-speed interrupt input function
Programming Example
• Measures the time from when input relay 0002 turns ON until input relay 0003 turn ON.
• The measured value is written to data memory DM0000 (Unit: µs).
• Writes the calculated speed into DM0010 (unit: m/ms).
(This program sets the distance between sensor 1 and sensor 2 to 1 m.)

2008 2410 2411 2412 2413 When power is turned on, an EL instruction enables
EI RES RES RES RES interrupts. Sets the interrupt polarity of inputs 0002 and
0003 to the rising edge.
2002 HSP
0002
Sets the input time constant of inputs 0002 and 0003 to
HSP 10 µs.
0003
2002 CTH1
2200 CTH1 counts the pulses using a 1-µs internal clock.

END

INT When INT0002 is executed, the current value of CTH1 is


0002 automatically transferred to DM1932 and DM1933 (Input
capture).
RETI

When INT0003 is executed, the current value of CTH1 is


INT
0003 automatically transferred to DM1934 and DM1935 (Input
capture).
2002 DM1934 DM1932 DM0000
LDA SUB STA Subtracts the input capture value of INT0002 from that
of INT0003 to obtain the time it takes for the target to
#00001 #01000 DM0000 DM0010 pass between two points and then writes it to DM0000.
LDA MUL DIV STA (Unit: 1µs)
(1) (2)
RETI
The passing speed is obtained through calculating (2)
the passing time and (1) the distance between the two
points (unit: m/ms). It is stored in DM0010.
ENDH

Tips Calculation of passing speed


The passing speed is calculated with the following expression:

Passing speed (m/ms) = ((1) Distance between two points [Unit: m]) / ((2) Passing time [Unit: ms])

In the program above, the passing time is measured in the unit of µs. Therefore, the meas-
ured value is multiplied by the factor of 1000 (2) to be converted into the value in the unit of
ms. The calculation uses 1 m (1) as the distance between the two points.

To set the distance between the two points in the unit of cm, multiply it by the factor of 100 as
the underlined section in the following program. The unit of speed is set to cm/ms.

#00100 #00100 #01000 DM0000 DM0010


LDA MUL MUL DIV STA

To convert the unit of time from µs to s (second), multiply values by the factor of 1,000,000
(execute 1,000x twice in a program).

47
VOL. 23 Synchronous control function
Example Synchronous control of a pulse motor
Outline
Synchronize and control the roller speed at the feeding side and the ejecting side of a device.
Control is easy when using the frequency counter function and specified frequency pulse output function featured
as standard with the Visual KV Series.
Pulse input

Pulse output

Application: Time adjustment for sheet material remaining in the processing bath.

■ Programming Technique
Use the frequency counter function of high-speed counter CTH0 to measure the frequency of the pulses (Hz) sent
through input 0004. Then, use the specified frequency pulse output function to output the pulse of the same fre-
quency as the measured input pulse from 0501.

(Frequency counter function) (Specified frequency pulse output function)


CTH0: high-speed counter (Measurement of 2306: Starts pulse output when turned ON.
Pulse input pulse period) DM1936: Frequency of output pulse Pulse output
0004 2305: Enables operation when turned ON. 0501
DM1404: Measurement timing
DM1405: Measured frequency Data
transfer
Frequency measurement Pulse output

The pulses are output after the frequency is changed according to the measurement result. The response is de-
layed by the length of the measurement.

Devices used with the frequency counter


Special utility relays
Relay No. Description
2305 Use frequency counter. ON: Yes, OFF: No
Data memory
DM No. Description
DM1404 Measurement cycle (ms) of frequency counter. (1 to 9999 [Units: ms])
DM1405 Result of frequency count (Hz) of frequency counter.
Devices used with the specified frequency pulse output
Special utility relays
Relay No. Description
Use specified frequency pulse output. ON: Yes, OFF: No Function
2306
is forced OFF when error relay 2307 turns ON.
Error flag for specified frequency pulse output function.
2307
(When turned ON, the pulse output is turned OFF.)
Data memory
DM No. Description
DM1936 Preset value for specified frequency pulse output is written. (16 to 50000 [Units: Hz])

48
VOL. 23 Synchronous control function
Programming Example
The frequency of the pulse sent through input 0004 is measured every 100 ms. Then, the pulses of the same
frequency are output from 0501. The pulse output is disabled when the measured frequency is less than 16 Hz.

2008 #00100 DM1404 2305


LDA STA SET The measurement cycle is set to 100 ms. The frequency counter
start relay (2305) turns ON.
2002 HSP
0004 The input time constant of input 0004 is set to 10 µs.

2002 2306 DM1405 DM1936


SET LDA STA The specified frequency pulse output start relay (2306) is turned
2307 0500
ON. The measured frequency (DM1405, Unit: Hz) is used as the
output frequency (DM1936, Unit: Hz).
Output 0500 turns ON when an error occurs in the setting of the
END specified frequency pulse output.

ENDH

Tips • The pulses of the frequency up to 30 kHz can be measured with the frequency counter
function.

• The pulses of the frequency up to 50 kHz can be output with the specified frequency
pulse output function. (Duty cycle of the pulses is 50%.)

• It is also possible to multiply the measured frequency by the factor of 2 or 1/2 for the
output.

Example
Output pulses of half frequency of the measured frequency. The pulse output is disabled
when the measured frequency is less than 16 Hz.
2002 2306 DM1405 #00002 DM1936
SET LDA DIV STA

49
VOL. 24 High-speed counter
Example Multi-step comparator operation with high-speed counter

Outline
By counting the pulses from the encoder, control the feeding amount of cloth and cut it at a specified length.
The high-speed counter is used to count the high-speed pulses from the encoder.
The number of pulses for the deceleration point, stopping point, and overrunning point are preset in data memories.

Start of winding
Cutting
machine Enter the preset
Film Decrease in value of the number
winding speed of pulses for each
point.

End of winding
Encoder

Pulley for
Cutting Overrunning
detection

Alarm

Application: Cutting products at a specified length

■ Programming Technique
This control requires three preset values of the number of pulses to determine deceleration, stopping, and
overrunning points.
The program of multi-step comparator operation can be simplified by using the multi-step comparator mode of the
high-speed counter’s cam switch function.
In the multi-step comparator mode, the value in DM1401 is compared with each preset value (DM 1406 to
DM1469). When the value in DM1401 is larger than the preset value, the corresponding relay is turned ON/OFF.
Up to 32 points can be set as the preset values.

High-speed counter CTH1 counts the pulses from the encoder received through inputs 0005 and 0007. The current
value of CTH1 is transferred to DM1401 as the value for comparison.
Set the preset values (comparator values) in DM1406 to DM1469 before the operation.
To enable the multi-step comparator operation, turn ON special utility relay 2314.
To stop the operation, turn OFF special utility relay 2715.

Devices used in multi-step comparator mode


Special utility relays
2314: Operation start relay (Operation starts when turned ON)
2315: Error relay (Turns ON during an error.)
2715: In-operation relay (Turns ON during operation.)
Data memories
DM1400: The initial No. of output relays
DM1401: The value to be compared. (0 to 65535)
DM1402: Enter “65535” in the multi-step comparator mode.
DM1406: Preset value to turn ON output relay “initial No. + 0” (0 to 65534)
DM1407: Preset value to turn OFF output relay “initial No. + 0” (0 to 65534)
DM1408: Preset value to turn ON output relay “initial No. + 1” (0 to 65534)
DM1409: Preset value to turn OFF output relay “initial No. + 1” (0 to 65534)
: :
DM1468: Preset value to turn ON output relay “initial No. + 31” (0 to 65534)
DM1469: Preset value to turn OFF output relay “initial No. + 31” (0 to 65534)

50
VOL. 24 High-speed counter
Programming Example
When input 0001 turns ON, the multi-step comparator mode is enabled.
When input 0002 turns ON, the multi-step comparator mode is disabled.
Outputs are assigned as follows:
Deceleration: 0500, Stopping: 0501, Overrunning: 0502

2008 2213 2214 CTH1


SET RES RES High-speed counter CTH1 is set to the double multiplication mode.

#00500 #65535
DW DW Relay 0500 is set as the initial relay to be used in the multi-step
DM1400 DM1402 comparator mode. The multi-step comparator mode is specified.
#10000 #15000 #20000
DW DW DW The positions where relays 0500 to 0502 turn ON/OFF are
DM1406 DM1408 DM1410 specified.
#11000 #16000 #21000
DW DW DW
DM1407 DM1409 DM1411
2002 HSP
0005 The input time constants for inputs 0005 and 0007 are set to 10 µs.
HSP
0007
2002 CTH1
0005
High-speed counter CTH1 counts the pulses from the encoder.
CTH1 DM1401 The current value of CTH1 is transferred to DM1401. This value is
LDA STA used for the comparison.
0000 1000 1000 2314
DIFU SET When input 0000 turns ON, the multi-step comparator mode is
0001 1001 2715 activated.
1001
DIFU RES When input 0001 turns ON, The multi-step comparator mode is
stopped.
END

ENDH

Tips The multi-step comparator mode compares values with the value stored in DM1401.
Therefore, not only the high-speed counter values but also the current values of a timer or
counter can be used for the multi-step comparator operation.

51
52
53
54
Visit our website for other Keyence products at

Specifications are subject to change without notice.

Boston Charlotte Cleveland Indianapolis Texas Northern California


Phone:781-453-2244 Phone:704-423-0070 Phone:216-464-7530 Phone:317-843-2616 Phone:972-733-6790 Phone:925-225-1550
Fax: 781-453-2255 Fax: 704-423-0066 Fax: 216-464-7540 Fax: 317-843-2647 Fax: 972-733-6791 Fax: 925-225-1440
New Jersey Nashville Columbus Chicago Denver Los Angeles
Phone:201-474-1480 Phone:615-986-0113 Phone:614-799-3400 Phone:847-969-0001 Phone:303-756-5242 Phone:562-552-9980
Fax: 201-474-1481 Fax: 615-986-0114 Fax: 614-799-3401 Fax: 847-969-0453 Fax: 303-756-8301 Fax: 562-552-9981
KEYENCE CORPORATION OF AMERICA
Pennsylvania Atlanta Cincinnati Minneapolis Phoenix
Corporate Office Phone:610-382-1310 Phone:770-951-1222 Phone:513-554-1227 Phone:952-924-9779 Phone:602-225-2400
50 Tice Blvd., Woodcliff Lake, NJ 07677 Fax: 610-382-1320 Fax: 770-951-1958 Fax: 513-554-1229 Fax: 952-249-9143 Fax: 602-225-2425
Phone:201-930-0100 Fax:201-930-0099 Virginia Tampa Michigan St. Louis Portland
E-mail:keyence@keyence.com Phone:804-327-9522 Phone:813-998-9886 Phone:734-591-9922 Phone:314-275-9174 Phone:503-699-0500
Fax: 804-327-9180 Fax: 813-998-9887 Fax: 734-591-1722 Fax: 314-275-9175 Fax: 503-699-8400

©KEYENCE CORPORATION,1999 NKV-KA-APC-1-0024 Printed in Japan

S-ar putea să vă placă și