You are on page 1of 12

all-in-one PLC

KV Nano Application Guide


Vol. 7

KV Nano Built-in High-Speed Counter Function


Simple setup is complete in just a few steps!

Points
1. The Wizard function simplifies the setup.
2. Cost and space reduction due to no need for expansion units.
3. Up to 100 kHz (50 kHz phase-contrast) x 4 ch.
System Overview............................................................................

Encoder input Motor control

Operation Contents........................................................................
The encoder pulses are counted with the KV Nano built-in high-speed counter and then the workpiece
length and feed rate are calculated from the pulse count or the number of rotations.
When using a comparator of the high-speed counter, the timing at which the current value of the high-
speed counter exactly reaches the setting value can be used as an interrupt cause.

ONE POINT
• Using a dedicated instruction (RCNT) allows the number of rotations to be measured easily.
• The KV-Nano Series is equipped with a high-speed counter that has up to 4 channels.

KV-N14xx KV-N24xx KV-N40xx KV-N60xx KV-NC32T

No. of CH 2 2 3 4 3

2
Application examples of the high-speed counter

Measurement of workpiece length and feed rate in Measurement of workpiece length and feed rate for a
electric wire production winding machine

Measurement of workpiece transit time Rotation control of an index table

Tablet counting Connector pin counting

3
Preparation for Wiring...................................................................
Prepare and connect the required devices.
1. KV-N14/24/40/60xx or KV-NC32T x 1 unit
2. Encoder (open collector method)
* The KV Nano Series does not support line driver output encoders.

Wiring..................................................................................................

Device assignment table related to the count input


External input KV-N14xx KV-N24xx KV-N40xx KV-N60xx KV-NC32T
Phase A R004 R004 R008 R008 R010
CTH0 Phase B R005 R005 R009 R009 R011
Phase Z R002 R010 R104 R104 R007
Phase A R006 R006 R010 R010 R012
CTH1 Phase B R007 R007 R011 R011 R013
Phase Z R003 R011 R105 R105 R008
Phase A R012 R012 R014
CTH2 Phase B R013 R013 R015
Phase Z R106 R106 R009
Phase A R014
CTH3 Phase B R015
Phase Z R107

Wiring example for the KV-NC32T built-in KV-NC32T


input terminals input

Check the manual for wiring of other channels and the terminal block type.

4
How to Set the High-Speed Counter.......................................
Start KV STUDIO (Ver. 7.1 or later) to create a new project.
([KV-NC32] is selected as the supported model in this document.)

1. Select [Tools] > [CPU high-speed counter setup wizard] from the menu.
Select the high-speed counter channel to be used from the options displayed on the window.

* The number of channels differs according to the model.

2. Select the operation mode for the high-speed counter.

Preset count Enable accu count Enable count

5
3. Set the input mode for the high-speed counter.
Select the count input mode and input time constant.

ONE POINT
The high-speed counter function can be used as a high-precision timer in up to 50 ns units
when the internal clock input is selected.

4. Set the counting parameters.


Set the “Count range”, “Count mode” and “Initial value setting” parameters.

Linear counter : Counts encoder pulses in the range specified in the count range. The overflow
detection relay is turned on when the current value exceeds the range.
Ring counter : Counts encoder pulses in the range between the upper and lower limit values.
The overflow detection relay is not turned on even when the current value
exceeds the range.

6
5. Set the comparator consistent operation parameters.
Set the “Operations for consistency” and the “Initial value” parameters.

Uncheck the box when a


comparator is not used.

* The KV-Nano Series uses the fixed output relays when a comparator becomes consistent.
CTH No. 0 1 2 3
Output relay R500 R501 R502 R503

6. Specify the module name to be output and confirm the high-speed counter settings.

* Click Finish. A ladder


programme is then
automatically created for
the high-speed counter.

7
Sample Programming...................................................................
This sample programme counts the workpiece length.
When a workpiece is detected (R000 is turned on), the high-speed counter is reset and encoder pulse
counting starts. The workpiece length will be calculated by the count at which R000 is turned off.

High-speed counter settings


Channel : CTH0 Operation mode : Enable count
Input mode : External input (Phase diff. (quad edge eval)) Input time constant : 10 µs
R000
Count range : Unsigned 32-bit Count mode : Linear counter
Comparator : Disabled Count permit condition : Internal relay (CR4212)

CTH0 count

[Ladder programme]

The programme permits counting to start when a workpiece is detected.

The workpiece length is


calculated based on
1 pulse = 3 mm and the
result is stored in DM0.

[Built-in function monitor]


Select [Monitor/Simulator] > [Built-in Function Monitor] from the menu.

The current value of


the high-speed
counter can be
confirmed on the
Built-in Function
Monitor.

When the workpiece detection signal and the count need to be monitored simultaneously,
select [Monitor/Simulator] > [Registration monitor window] from the menu.

Register devices in
advance to make
debugging even easier.

8
Sample Programming...................................................................
The sample programme uses a combination of the high-speed counter and the interrupt processing for
cutting wire materials.

When MR000 is turned on, the programme starts motor speed control to feed the wire
material. The high-speed counter 0 (CTH0) counts the length of the fed wire material.
When the count reaches the CTC0 setting value (set length to be cut), the stop sensor
input is turned on. The interrupt processing stops the motor control to perform cutting.
The motor stops when MR002 is turned on.
After an operation time passes, the programme resumes the motor speed control and
repeats the operation described above.
Encoder

[Operation contents]

The stop sensor input is turned on when the current value of the
counter exactly reaches the CTC0 setting value (length to be cut).

Speed

MR000

Time

Travel after stop Cutting is being


sensor input performed

Operation time Operation time Operation time


setting value setting value setting value
(DM0) (DM0) (DM0)

[Device specifications]
Device Device Comment Device Device Comment

MR000 Operation start R010 CTH0 Phase A *

MR001 Cutting signal R011 CTH0 Phase B *

MR002 Operation stop R007 CTH0 Phase Z *

DM0 Operation time setting value (10 ms units)

* [KV-NC32T] is selected as the supported model in this document.


Refer to the device assignment table (page 4) when the terminal block type is used.

9
[High-speed counter settings] [How to execute interrupt processing]

Channel : CTH0

Operation mode : Up/down count


Main programme routine
Input mode : External input (Phase diff. The EI instruction is required
to execute the interrupt
(quad edge eval)) programme.
Input time constant : 10 µs

Count range : Unsigned 32-bit


Interrupt programme
Count mode : Linear counter Enter the interrupt programme
between [END] and [ENDH].
Comparator : Enabled

CTC0 default value : 100000

ONE POINT
The KV Nano responds to the interrupt within 100 μs.

[Positioning control setting]


Select [Tool] > [CPU positioning parameter setting] from the menu.

Select “Enabled” for the stop sensor setting and set the travel after stop
sensor input. When zero is set, feeding stops immediately after the stop
sensor input is turned on. When a value between 1 and 65535 is set, feeding
stops after traveling the set number of pulses.

Select “CR8015” for the


stop sensor input. Set
other parameters
according to the usage
conditions.

10
[Ladder programme example]
* This diagram omits the high-speed counter programme that is created automatically.

When the power is turned on, the interrupt is permitted,


automatic reset is configured for the CTH0 high-speed
counter, and the reset is executed.

The axis 1 speed control starts when MR000 is


turned on.

The operation stops when the stop


sensor input is turned on and then the
cutting signal (MR001) is turned on.

After the time set for DM0 (in 10 ms units)


passes, the axis 1 speed control resumes.

The axis 1 speed control stops when MR002 is turned on.

The interrupt processing starts when CTC0 reaches the setting value.

When the count reaches 100,000 pulses, the axis 1 stop sensor input is turned on.

11
www.keyence.com

Copyright (c) 2013 KEYENCE CORPORATION. All rights reserved. KVN7-WW-AG-GB 1103-1 E 600D05

You might also like