2. 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
3. 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
4. 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
s 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
5. 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
6. 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
s 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
7. 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
8. 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
s 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
9. 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
10. 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.
s 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
11. 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
12. 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
s 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
13. 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
14. 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
s 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
15. 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
16. 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
s 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
17. 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
18. VOL. 8 Phase differential input
Example Example: Input from rotary encoder
Outline
Phase A
Phase B
Rotary encoder Visual KV Series
s 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
19. 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
21. 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
22. 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
s 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
23. 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
24. 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
s 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
25. 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
26. 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
s 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
27. 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
28. 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
s 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
29. 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