Professional Documents
Culture Documents
Contact Us
Back
VOL. 22
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
INPUT 0002
ON
OFF
Sensor 1
Sensor 2
INPUT 0003
Visual KV Series
ON
OFF
Sensor 2
Passing time (s)
Programming Technique
Point 1: Measure the passing time with the internal clock of the KV.
Use the KVs 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
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)
Internal clock
(1 s)
DM1932
No. of clock
counts
DM1934
Top
Back
Contact Us
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
EI
2410
RES
2411
RES
2412
RES
2002
2413
RES
HSP
0002
HSP
0003
2002
CTH1
2200
END
INT
0002
RETI
INT
0003
DM1934
LDA
DM1932
SUB
DM0000
STA
#00001
LDA
#01000
MUL
DM0000
DIV
DM0010
STA
(1)
(2)
2002
RETI
ENDH
Tips
#00100
MUL
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).