3 measuring the on time of high-speed pulses, Visual kv series – KEYENCE Visual KV Series User Manual
Page 224

3.4 Applications of Interrupt Programs
3-200
Visual KV
Series
3
Chapter 3 Interrupts
0001
0002
0003
0004
0005
0006
0007
0008
0009
2008
EI
2002
HSP
0000
2002
CTH0
2100
2403
END
INT
0000
RETI
ENDH
KEEP
2403
RES
SET
TM02
STA
DM1928
LDA
DM0000
STA
TM02
SUB
DM1928
LDA
2403
3.4.3
Measuring the ON Time of High-speed Pulses
■ Outline
Measures the pulse width of the pulse input to an input relay.
Example: Measurement of workpiece length
■ Ladder diagram
•
Special utility relay 2100 is turned ON to measure the pulse width using 1-µs
units.
•
The values when input relay 0000 is ON is written into temporary data memory
TM02, and the values when input relay 0000 is OFF is written into data memory
DM1912. The pulse width can be obtained by subtracting the value of TM02 from
the value of DM1912.
•
The obtained value is written into data memory DM0000 (Unit: µs).
• Turns ON input 0000 to execute an
interrupt.
First, an interrupt is executed at the
rising edge of input 0000. The
current value of CTH0 stored in
DM1928 is written to TM02. Turns
ON special utility relay 2403 to
change the interrupt polarity to the
falling edge.
Next, an interrupt is executed at the
falling edge of input 0000. The
value stored in TM02 is subtracted
from the current value of CTH0
stored in DM1928, and the
obtained ON width of input 0000 is
written to DM0000. Turns OFF
special utility relay 2403 to change
the interrupt polarity to the rising
edge.
• When power is turned ON, an EI
instruction enables interrupts.
• Sets an input time constant of
input 0000 to 10 µs.
• CTH0 counts pulses with a 1-µs
internal clock.
OFF
ON
Sensor input 0000
Pulse width (µs)
Visual KV
Sensor
KVNKA Chap 03.p65
08.3.11, 0:05 PM
200