Ir detector assistance

I am in desperate need of help. I have over-promised to a group of cub scouts and now I am afraid I can’t deliver. I am working on a digital timer for a pinewood derby race that is scheduled for Wednesday evening and I need to solve this problem by then.

I am using the schematics provided by http://www.miscjunk.org/mj/pg_pdt.html to build the hardware. It is a Arduino Uno-base timer that feeds data back over a USB port. I thought everything was working great, but over the weekend in final prep, I discovered I am only getting about 3 inches of range between IR emitter and detector. I am using the emitter and detector set from Radio Shack. (276-0142 http://www.radioshack.com/product/index … Id=2049723)

After significant effort to debug the hardware, I think I have it narrowed down. The emitters are working as far as I can tell. The voltage and amperage on that circuit seems to be fine.

I believe the problem is the amperage on the detectors. Each detector is connected between a digital pin and ground on the Arduino. The power on that circuit is 4.4 V @ 0.2 mA according to my multimeter. The package for the detector says forward voltage should by 1.2V @ 1mA. (I am a bit surprised that the 4.4 volts haven’t burned out the detectors, but they have consistently worked as long as the emitter in within 3")

So my question is this: How do I drive the detectors at lower voltage but higher amps? Can I use a pin on the Arduino (I have 1 available pin/detector) to drive a transistor (MOSFET?) to switch the detector on a lower volt/higher amperage circuit? I believe this is possible, but I am in way over my head.

The Arduino has two always on power pins:

3.3V @ ~= 400mA

5.0V @ ~= 700mA

I am currently using the 5V pin to power my emitters as shown in the schematic referenced above. It runs through a 68ohm resistor, stepping the amperage down to about 70mA. That is also out-of-line with the spec on the package, which says it should be driven at 1.2V @ 100mA.

As I said, I am in way over my head and will need pretty explicit instructors on how to create a different circuit.

Thanks in advance!

David.

OK I see a problem here. Reading the comments on the RS page you linked to I find that RS has probably not sold you what you think that product is. The IR detector is most likely a photodiode and not the phototransistor your schematic calls for. That’s a big difference. The phototransistor will act like a switch on the Arduino’s digital input pin. When enough light is hitting it, the transistor should saturate and act like a closed switch and thus effectively apply a ground (logic low state) to that input pin. When the beam is broken the transistor “switch” will open allowing the input to float back to a logic high (assuming you have the pin configured as an input and the internal pullup resistor enabled). The transistor would allow whatever current is needed to flow so trying to drive it more is not your problem. The problem is that you most likely don’t have a photo transistor. What you should see (with a photo transistor) is a pretty clear difference in DC voltage at that pin when the beam is on vs when off (or blocked/broken). When the beam is on, the voltage should be <0.2V. When off it should be the Arduino supply voltage (or perhaps a few tenths less). If you’re seeing something between these 2 voltages you’re got a photodiode, which is less sensitive (hence your reduced range).

Given your timeframe you might risk wasting another $3 and buy [this item from RS. From the reviews I don’t see that it’s mislabeled like the detector is in the product you bought. Replacing the existing detector with this one might just make your system work as intended. If you had more time (or access to an SF retail outlet) I could make a better suggestion.](http://www.radioshack.com/product/index.jsp?productId=2049724)

I think it is actually a phototransistor. Looking at their tech specs:

Use this RadioShack infrared LED emitter and detector in your latest hobby project.

Emitter Specs (tinted package)

Reverse voltage: 5V

Cont. forward current: 150mA

Forward voltage: 1.3V typical, 1.7V max

Radiant power output: 13-15mW

Wavelength (peak emission): 950nm

Detector Specs (max)

VCEO (collector to emitter): 70V

VECO (emitter to collector): 5V

IC (collector current): 50mA

Total power dissipation : 150mW

Peak sensitivity wavelength: 850nm

Spectral bandwidth range: 620-980nm

Angle of half sensitivity: +/- 20°

Note that it appears to be a photo transistor. There are several possibilities as to the problem.

First, the designer is using the internal pullup resistors of the arduino. They are fairly weak. I’d suggest trying a 10K resistor between the anode and +5V. See the link below for more info about phototransistors. Also, make sure you have it wired in correctly. They will work when wired in backwards but with low sensitivity. To test, switch the LED on and off while measuring the voltage between the collector and gnd. You should see it go between 0 and something reasonably close to 5V (4.4 would be ok with those high resistance internal pull-ups)). It should be low when the light is one it and high when dark.

Second, the original design uses a bright white LED, not an IR one. I suspect that your’s just not bright enough. You could get a high power IR led. This RS one looks reasonable http://www.radioshack.com/product/index … Id=2062565. Note that the spec for the emitter you have says continuous forward current max is 150 mA (which is kind of high, imo) with that 68 ohm resistor, you are running about 50mA through it. Perhaps you need something smaller. You could put another 68 ohm resistor in parallel to double the current. Not sure that’s the best way to go about it but it might work in a pinch.

By the way, the designer’s emitter LED is being run well above the current from the specification.

Also, verify that your IR LED is working by viewing it through a camera (which is sensitive to IR).

So, your radio shack shopping list:

http://physlab.lums.edu.pk/images/1/10/ … ircuit.pdf is a good application note for understanding photodiodes and phototransistors. Fig 9 is what you should use for a PT.

Philba:
I think it is actually a phototransistor. Looking at their tech specs:

From what I could gather from the comments on the RS page, there seems to be 2 sets of emitter/detector pairs beng sold under the same SKU. One has a PT and the other a PD (at least some tests results indcate that). Obviously there’s no good way to tell up front what the OP has. So reverse the detector’s orientation and see if that helps and if not, buy a different detector, one that seems to really be a PT, and see if that works. With 50+ mA flowing through the emitter LED he should have better than 3" of range.

yeah, I saw the comments but I don’t see how a PD could work at all in that situation. One other possibility pointed out in the comments was that the part labels are reversed. Regardless of the actual situation, Radio Shack is not my go to store for exactly that reason - you never know what the heck you are getting. But hey, you have to love the blank stares you get when you ask them for something.

So the pressing question is how did the PWD go? Manual timing or did you get the timer to work?

I used to run the PWD in our pack. I upgraded the system to piezo film switches for the end detector. I found IR sensor gates to be to fussy and could be spoofed by flash photos.

Built our own track in the basement so my son could design and tune his car. Had the track available twice a week for kids to come it and test. My son tried dozens of experiments to find the sweet spot and had a car that went to the state championship and came home with a second place. Ahhhh the good old days of father/son bonding. Today its teaching him C++ over Christmas break. They grow up fast.

I posted both to this forum and to the Arduino forum very late on Monday night. I was so frustrated and frazzled, that I forgot about having posted here until after the derby was done. I got home, was reading my email and saw that I had responses on this thread.

Tuesday morning before work, I read a post on the Arduino thread lead me down the path of turning off the on-board pull-up resistor and wiring in a 470K ohm pull-up into my circuit. That seemed to give me much better range in my sunny living room and I continued to believe that I was working with IR detectors.

The fact that the Radio Shake packaging was wrong should have been obvious to me weeks back. In playing with things, I discovered that the “IR detectors” worked just as well with a high-brightness white LED as it did with an IR emitter. (Well, duh!) At that point, I made the assumption that the LED was producing light down into the IR range of the spectrum. My faith in Radio Shacks package labelling completely blinded me.

When I set up the track and timing system in our gym with high ceilings and poor fluorecent lighting, my timing sensors failed again. (Again, anothing sign that I was working with photo resistors, but I still didn’t catch on.) We ended up doing last minute surgery on the wooden mounting bridge with a hack saw, lowering them back down to 6". That got us through the races successfully.

I think the derby was successful and everyone had fun. With a timing rig in place, we were able to do a much better job of determining the fastest car. (We ran each car in each lane and then took the average time. That way nobody was disadvantaged by a slow lane on the track.) When the races were over, we discovered that the fastest two cars’ average times differed by less that 0.004 seconds. Never would have been able to determine the faster car without the timer.

If I were to revise what I have now, would you all advise replacing the photo transistors that I have in place now with true IR detectors? Or should I go the other way and replace the IR emitters with high-brightness white LEDs? and with either direction, can I pull out the 470K ohm pull-up resistors and revert to using the on-board pull ups?

Thanks for everyone’s input. It is nice to have an active, passionate and knowledgable community to fall back on when things aren’t going well. Hopefully, at some point in the future, I can pay it forward.

-David.

Glad it worked out well. I would keep phototransistors and do things to minimize incident light pollution. For example,. if the detectors are above the track, they will be more shielded. You can also put shrouds on them (think black tubes) to shield all but the LED’s light from them. it can be made to work. You discovered that ambient lighting can be a real wild card - fact of life with phototronics.

In general, I’d recommend you stay far away from radioshack for components. There are mail order places that are significantly cheaper. But more importantly, you can get reasonably believable specifications from actual datasheets. Your whole phototransistor/photodiode/emitter thing would have been a lot simpler to sort out when you know what you need and have. Jameco, mouser, digikey and others are great. I’d use radioshack only if I had to have it yesterday. Well, actually, I live about 15 miles from a Frys so I go there for immediate needs but other might not be so lucky.

I too am glad that it worked out. I would discourage the use of an optical gate. They are very fussy and easy to spoof. I would suggest piezo film switches like these:

http://search.digikey.com/us/en/product … -ND/279646

If you place these at the finish line as a car drives over them, they bend out of the way and generate a good strong signal. In fact you need to be a bit careful to lower the sensitivity as the bow wave from one car can trip the adjacent lanes!

What kind of timing resolution is desired for this ? Looking as what the OP posted it seems that 1 msec is not unreasonable. How fast are PWD cars going when they cross the finish line ? I might GUESS that 1 msec corresponds to less than 0.1" and that suggests some method of aligning / calibrating the gates to happen simultaneously (for a true tie finish) would be advisable.

From memory, the track is 32 feet long (4 lengths of plywood) minus a couple feet of roll out. A fast car takes about 3 seconds to run the course. In rough numbers that is 120 inches per second or 0.12" per millisecond. This is about 1/8 inch per millisecond. The OP indicated that 0.004 was the difference between the fastest cars. But that could just as easily have been 4 microseconds.

The issue is what accuracy to you need to be “fair”. I would suggest that a human eye could not tell the difference in arrival time of two cars in motion that are 4 inches apart on parallel tracks and only 1/8" apart. But it would be best if timing could be done to the tens of microseconds, then the error would be just a tad over a thousandths of an inch. No way anyone could think that unfair. (Also a good reason to install a solenoid starter!).

Adjustment/calibration of the light gates can be minimized by putting the receiver in the track and the illuminator above. If a small hole is drilled accurately and the sensor properly centered, then errors (from parallax, reflection, mal-placement, …) should be very small.

Again, my experience with photo gates is that they are fussy and can be spoofed. Each time you set up the track, you are playing with gains and thresholds on comparators to get the system stable. Do all that and then Dad fires of his DSLR with a 500W flash just as juniors car breaks the beam, all that light can sneak under the car and extends the finish time. Before we changed over to piezo, they put a one foot long tunnel at the finish line to shade the sensors. But then nobody could see the cars finish!

The piezo approach is interesting and worth taking a look at.

To make the opto approach more reliable, you could use a TV remote receiver. Basically, it’s looking for a carrier. With shielding and the carrier, you can be pretty confident that there won’t interference. They’re fairly inexpensive (less than a RS phototransistor). You need to drive the LED with the carrier frequency so it’s a bit more work. As I recall the receivers take a few cycles (4 runs in my mind). This family is really cheap - $1.12 from mouser http://www.mouser.com/catalog/specsheets/tsop21xx.pdf and looks like it takes 9 cycles max (3 min) to recognize the carrier. Using the 56Khz one, that’s a worst case of 160 microSeconds (9 cycles). It would plug right into the arduino pin in the current design. Generating the carrier for the leds is really easy in the arduino with a timer. Probably should use a transistor to drive multiple LEDs.