IR emitter/detector pair behaving badly
mpark
Posts: 1,305
I am trying to use an infrared emitter and detector I got from Radio Shack (part 276-142) as an electric eye, just to detect when an object passes between them.
The emitter is hooked up to 3.3V through a 100 ohm resistor.
The detector is connected between P9 on the Prop and ground. There's a 5k pot between P9 and 3.3V.
The emitter and detector are pointed toward each other.
I run a simple loop like
As I adjust the pot the output goes from 1111... to 101100... to 00000. When I put my hand between the emitter and the detector, the output is 11111... So far, so good.
Now, if I add snd.start(15) before the loop (snd being a "NS_sound_drv_052_11khz_16bit" obj), the loop prints 11111... whether my hand is in the way or not. I have to readjust the pot to get it back to 000000...
Why should starting the sound driver change what I see on P9?
The emitter is hooked up to 3.3V through a 100 ohm resistor.
The detector is connected between P9 on the Prop and ground. There's a 5k pot between P9 and 3.3V.
The emitter and detector are pointed toward each other.
I run a simple loop like
repeat debug.dec( ina[noparse][[/noparse]9] )
As I adjust the pot the output goes from 1111... to 101100... to 00000. When I put my hand between the emitter and the detector, the output is 11111... So far, so good.
Now, if I add snd.start(15) before the loop (snd being a "NS_sound_drv_052_11khz_16bit" obj), the loop prints 11111... whether my hand is in the way or not. I have to readjust the pot to get it back to 000000...
Why should starting the sound driver change what I see on P9?
Comments
-Phil
I also have the tv driver going. I'm just using the protoboard's power supply.
Without the sound driver, I measure 1.2V at P9. With the sound driver, it jumps to 1.6V. Earlier I thought it was up to 1.7 or 1.8 but something changed (maybe the ambient light?). Anyway, I don't understand what's happening. Help!
I just went through this with my coil winder. I was using the same emitter detector from Radio Shack. I would suggest you may need some hysteresis. Try a timer 555 and use it as a Schmitt trigger on the detector (3.3->10k->detector->ground, input to 555 is between 10k->detector). Cured all my problems.
-Parsko
Post Edited (parsko) : 2/22/2009 10:03:50 PM GMT
This may be a long shot, but if your power supply on the 3.3V side is marginal, perhaps running an extra cog can cause it to droop.
Trying loading your prop even more (as a stress test) or toughing up the supply. I ran my pairs off the 5 V supply, and put a voltage divider on the emitter output to connect the detector at a safe running voltage swing for the prop input terminal.
Cheers!
Paul Rowntree
·
Paul -- I don't see the 3.3V supply dropping significantly with the sound cog running but maybe I'll throw a few more cogs at it and see what happens.
PJ -- I think you're doing something a lot more advanced than the brain-dead electric eye I'm trying to make.
Is the IRED too far removed physically to drive it from the Propeller? If not, I have an idea...
-Phil
All ideas welcome!
This would make it insensitive to ambient light, temperature, and Vdd variations. You will have to experiment with the component values, but they shouldn't be critical. Both resistors in the input voltage divider should be the same, though, probably 22K or higher. A cap around 0.1uF should be fine. The pullup on the phototransistor needn't be a pot, since the input voltage threshold level is fixed and set on the other side of the cap.
From a programming standpoint, what you want to do is toggle the IRED rapidly on and off at around 10KHz. Not too fast, or the phototransistor won't keep up. (If it still doesn't keep up, there's another trick to help speed it up, but we'll cross that bridge when we get to it.) This can be done in your program or by a counter output. After each toggle, wait a couple microseconds, then add one to a counter if the detector input agrees with the toggle output; zero, if not. Do this maybe 64 times. Then, see if the the count was at least 48, say. If so, the beam was not broken. When the beam is broken, the count should be around 32 — half the number of toggles.
-Phil
_
I simply had a pin watching the state of the output from misc. circuits I was trying (I really wanted to make my own Schmitt trigger). In the end, I kept noticing that my "odometer" would increase in count WAY faster than it should, at times. This ended up being where the threshold of the pin was (~1.65V). Around this level, this "runaway" counting would occur.
I ended up adding a 555 in Schmitt mode, seen here:
www.kpsec.freeuk.com/555timer.htm
bottom of the page.
It worked like a charm. Prior to this, I would get erratic behavior. Ambient lights on and around my desk were messing with my handmade circuits (they would work brilliantly when I "shaded" them).
I used a 330ohm resistor for my IR emmitter. I also noticed that they had to be pointed pretty good at one another. You may have a problem with your 1 foot distance. It may make your life easier to use the "official' IR reciever, which is designed to work more robustly, should you not get this all going. That one can be found here:
www.parallax.com/Store/Sensors/ColorLight/tabid/175/CategoryID/50/List/0/Level/a/ProductID/177/Default.aspx?SortField=ProductName%2cProductName
Does that sound like your problem?
-Parsko
-Parsko
It must be connected through a RC filter.
Read Sharp IR detector datasheets which indicate the importance of this filter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
I've given up trying to figure out why turning on the sound driver changed the voltage at P9. There were too many other weird things going on, all of which disappeared as soon as I attached a scope. That's just unfair.
But I finally got around to trying Parsko's 555 Schmitt trigger suggestion and it worked! I now have a reliable electric eye. So, thanks, Parsko and everyone else who replied.