# Detecting a moderately-fast moving object from 1ft away

I have a small side project using Arduino (pro mini or nano) that would detect passing model race cars (and quadcopters) and counting how many times it passed through a selected location. I thought of using IR emitters and detectors (photodiode) to achieve this but I'm worried it might not be fast enough or it might miss some counts.

The setup would have a few (1 or 3) IR emitters on one side of the road and a detector on the opposite side, facing the emitters (or maybe the emitters on top, and detector on the bottom). They would be more or less 1 foot apart and the toys would pass in between (there is also an arch about 1ft and all of them should pass under the arch). I'm using these for the emitters and these for the detectors.

Only one car would pass through the track at any given time so there would be no issues arising from use of multiple cars.

The toys are about 4-5" length and width, and height of a quadcopter would be around 1-2".

Basically, just detect any brick-sized object passing through the arch.

Is there something I could do to guarantee a count and would IR even fit this type of application? Or should I use an alternative? If so, any suggestions?

As far as the speed, IR detectors are definitely fast enough with response time being of the order of ns or us (if you use more filtering). There are a couple of areas of concern:

1) The pattern is probably close to being omni-directional (I could not see the datasheet that would show this) so you may have issues with the signal bouncing off of the floor, other objects and would have to experiment a lot with thresholds.

2) It is likely that the signal would not increase/decrease monotonically as the car is passing by, so you would have to implement some sort of a debounce function to avoid multiple counts for the same event.

• Debounce logic taken care of – PNDA Sep 15 '15 at 2:04

I shone a laser onto a LDR (light dependent resistor) for this sort of situation a while back. The laser (you can buy them for \$1 or so on eBay) is highly directional, and quite powerful, so the difference between the laser hitting the resistor, or not, is substantial, and gives you a nice sharp cut-off.

• Be aware that black-plastic IR detectors won't detect a visible-red laser. The visible attenuation of the black plastic is phenomenal. Besides, specular reflection from moving cars could be eye-dangerous. – glen_geek Sep 28 '16 at 17:50
• In my test to which I refer, I was shining the LED onto a LDR (simple light-dependent resistor). That worked fine. I wouldn't expect an IR detector to detect a visible red laser beam. – Nick Gammon Oct 1 '16 at 6:17

IR detector speed is faster than necessary. But some other points must be considered....
(1) The beam-width of IR LEDs, and IR detectors are unknown. Since you can point your IR LED directly at the IR detector, it should be possible to minimize optical path loss. You would prefer to have narrow beam width for both.
(2) Those IR detectors could be raw diodes, or phototransistors. Both can yield acceptable car-passing output, but a raw diode needs a different amplifier circuit than a phototransistor. A phototransistor has internal gain that relieves some gain requirements of the external amplifier.
(3) Some method must be arranged to compensate for ambient light. Those photo-detectors will give some considerable output from room lights, and can change as shadows pass from people moving about. Attaching a hood or tube onto the photodetector can help reduce this effect, but not eliminate it.

Be not discouraged - this can be made workable. Consider hiding your photo-gate within the bridge (tunnel) where optical environment is better-controlled.
One method of dealing with a variable ambient-light environment is to use your microcontroller to modulate the IR LED on-to-off at a fast rate. Then the amplifier that boosts the IR-detector signal can be an AC amplifier which blocks a slowly-varying ambient background. Here's a possible measurement sequence...

turn LED off
Measure detector amplifier output
turn LED on
Measure detector amplifier output
Subtract two measured values.
Repeat


The subtracted result, if small, indicates a blocked optical path. Large changes from light-to-dark and dark-to-light are also available. Your microcontroller should be able to perform this sequence hundreds or even thousands of times each second.