How fast it counts
The light sensor is the limit. On its 10 kΩ, the GK105A sheet's typical edges are about 100 µs rising and 130 µs falling, and slower at this board's lower LED current. The book trusts about 1,900 pulses a second: some 5,800 rpm on a 20-slot disc. The comparator and your board's interrupt are hundreds of times faster.
Three stages, one slow one
A pulse passes through three things on its way to your count: the light sensor, the comparator and your board's interrupt. The comparator answers in about 1.3 µs. An interrupt on any of the four boards runs in a few microseconds. The light sensor takes a hundred times longer.
Drag the rate up. At a few hundred pulses a second the sensor's voltage swings all the way from VCC to near 0 V and back between bars, and SIGNAL flips once per bar. As the rate climbs, each half of the pulse gets too short for the voltage to finish swinging, and it starts to wobble around the middle instead of crossing it cleanly.
Where the numbers come from
The GK105A sheet measures how long its output takes to swing, with the light switched on and off, against the load resistor. With 10 kΩ, this board's R11, its typical figures are about 100 µs to rise and 130 µs to fall. The book allows two of the slower edge for the pulse and two for the gap: a period of 520 µs, about 1,900 pulses a second.
That is a best case. The sheet measures with 20 mA through its LED; this board gives it 2 to 4 mA, and a phototransistor passing less current is slower. So treat 1,900 as a ceiling, not a promise, and the figure's drawing past it as illustrative.
In revolutions
1,900 pulses a second is about 5,800 rpm on a 20-slot disc, 29,000 on a 4-slot one, and far more than any hobby motor on one opening. A small gear motor's output shaft turns at a few hundred rpm, well inside it. The bare shaft of a small DC motor often turns at 10,000 rpm or more; put a disc with few openings on that.
When it does not work
The pulses are coming faster than the light sensor can swing between bars, so the comparator starts to miss them. Use a disc with fewer openings: the same shaft speed then makes fewer pulses a second.
In principle, yes: the sheet's edges are several times quicker with 1 kΩ than with 10 kΩ. But R11 is a surface-mount part on the board, and a smaller one needs more current from the sensor to cross half of VCC, which this board's LED current may not give. Fewer openings is the easy fix.
Much faster, and it counts with no interrupts at all, but it cannot make the block faster. At the rates this block can follow, attachInterrupt on any of the four boards keeps up easily.
The red LED first, then the wires, the slot and the sketch.
When the count is wrong →Edit this page — content/books/ir-speed-sensor/how-fast-it-counts.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Infrared Speed Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.