Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: boylesg on December 11, 2013, 05:13:51 PM

Title: PWM IR LED/Phototransistor electronic 'eye'
Post by: boylesg on December 11, 2013, 05:13:51 PM
Gidday folks - new to the forum.

Assuming I am OK with setting up a 555 bases PWM (53kHz) to run a few IR LEDs and that I can get an unmodulated IR LED and phototransistor to drive a red LED as an indicator as you pass your hand over the phototransistor.

What is the best way to go about demodulating a 50kHz IR signal coming from the phototransistor.

I have tried a high pass filter with a 4 x 1n5891 rectifier and a smoothing capacitor to convert the signal back to an analog voltage level but the high pass filter seems to reduce the voltage level down to millivolts.

I have tried a class A amplifier with a min frequency of 30kHz, but the 50kHz signal can't seem to pass the 220pF coupling capacitors that 'Transistor Amp' (class A amplifier design software) computes. I specified 50k for both input and output impedance - I suppose I am not specifying the correct impedance for the 50kHz signal.

I am assuming that the pulse heights generated by the phototransistor will be proportional to the pulse heights of the IR coming from the PWM'ed IR LEDs. What I want to do at the photo transistor is to fill in the gaps in the pulses to generate an analog voltage level, but reject an DC voltage levels coming from the phototransistor due to ambient IR.

Does any one know of a good website that explains in detail how to do this sort of thing?

Some else on another website has suggested a bandpass filter. Although I understand what one is and how in theory to arrange one on a breadboard, I need specific worked examples with a square wave in order to gain a decent understanding. I have found numerous examples but not this sort of specific application.

It is very difficult to piece together how to achieve this this from tit bits of info from general electronics web pages and from examples of unrelated applications of IR modulation

Can anyone point me in the direction of a good web page?
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: waltr on December 11, 2013, 07:56:55 PM
Use a large series cap to couple the PWM pulses but remove the DC bias (high pass with a very low frequency cut-off). Then a low pass filter to remove the pulses.
You may need an op-amp as a buffer after the series cap. Just remember that the signal will go positive and negative so the op-amp requires both a positive and negative power supplies.

A good reference on the circuit you are asking about is in the ARRL's Amateur Radio Handbook.

To figure out if the different parts of the circuit is working require an O'scope. Almost any O'scope will do ok with 50kHz.

Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: jwatte on December 11, 2013, 08:57:00 PM
Also, 50k Ohms as impedance is very high for output impedance. You want maybe 1k as output impedance, or better (50 Ohm is something to shoot for.)

Ideally, you build an active notch filter for separating 50 kHz signals, using an opamp or two. After that, you can use a low-pass and a Schmitt trigger (perhaps also a comparator to boost the signal) to clean it up.

I would not use a transistor amplifier at all; rather I'd use an opamp with say 100x gain (so 5 MHz gain*bandwidth product) and bias it down to filter out ambient. An automatic gain circuit could make this more robust to changes in ambient lighting, but perhaps you're not wanting to go quite that far :-)

Active bandpass (peak) filter design: http://www.electronics-tutorials.ws/filter/filter_7.html (http://www.electronics-tutorials.ws/filter/filter_7.html)

Of course, a different option is to use a fast comparator, and a small MCU, and do all the signal detection/processing in the digital domain. But perhaps that's cheating :-)
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: boylesg on December 12, 2013, 01:58:09 AM
Use a large series cap to couple the PWM pulses but remove the DC bias (high pass with a very low frequency cut-off). Then a low pass filter to remove the pulses.
You may need an op-amp as a buffer after the series cap. Just remember that the signal will go positive and negative so the op-amp requires both a positive and negative power supplies.

A good reference on the circuit you are asking about is in the ARRL's Amateur Radio Handbook.

To figure out if the different parts of the circuit is working require an O'scope. Almost any O'scope will do ok with 50kHz.


I noticed that if I arbitrarily replaced the 100pF cap (I think it was) with a 100nF then the 50 odd kHz PWM signal seemed to pass through, according to my multimeter that has frequency on it.

So perhaps I could also try a class A amplifier, as specified by 'TransistorAmp', that has a 100nF coupling cap on the input. I will have to fiddle with the input imedance until I figure out the right value to get a 100nF coupling cap.

If a low pass filter is designed to allow through all signal frequencies over a chosen threshold and attenuate all signal frequencies below that threshold, then what exactly is a high pass filter meant to do? I am not so sure I understand entirely after watching a youtube tutorial on low pass filter design.
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: waltr on December 12, 2013, 07:15:41 AM
A low pass filter attenuates higher frequencies and lets pass lower frequencies.
A high pass filter does just the opposite, attenuates lower frequencies (including DC) and lets pass higher frequencies.
"threshold" indicates a Voltage level so is the wrong term to use when referring to filters.
Also, no real filter is perfect so when the frequency changes from the 'pass band' into the 'stop band' the attenuation increases.

Do some web searches On these types of filters. Wikipedia has some good info. Study the frequency response plots to see the effect a filter has on the amplitude on different frequencies.
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: johnwarfin on December 12, 2013, 12:19:20 PM
What is the best way to go about demodulating a 50kHz IR signal coming from the phototransistor.

imo the best part for this is 3pin TL1838 ir receiver. about a dime on ebay and half that on aliexpress. they do an excellent job of demodulation, sensitive and very resistant to noise. much better than any diy ckt and cost less than a phototransistor.
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: waltr on December 12, 2013, 03:20:17 PM
the  TL1838 ir receiver is to demodulator 38kHz IR not 50kHz.

If the OP can change the modulator frequency to 38kHz then the  TL1838 ir receiver should work well.
Title: Re: PWM IR LED/Phototransistor electronic 'eye'
Post by: johnwarfin on December 13, 2013, 03:24:18 PM
op talks about 53hz and then 50hz so there seems to be some wiggle room there. im not sure what so magical about either but the 1838 does work at 50khz. just slightly less sensitive.

personally id use an mcu like tiny13. much cheaper and 1/10th the parts count. but maybe op wants to do this the hard way as a learning experience. 555 and all those other components will certainly serve that purpose.