Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to make an infrared proximity measurement device.

I want it to be in the range of 10cm or 4" (maybe 15 cm?). The frequency I use is 10 KHz. Here is the circuit I used, except that I have used 1 nF capacitors and resistors that suits them for band-passing 10 KHz. I have used LM358A for the OP-AMP and I don't know the part ID of my IR diode.

To increase the sensitivity and remove the offset, I added a difference amplifier with a gain of 10 using the other OP-AMP inside the LM358A. I've used a potentiometer to set the voltage to be subtracted from the out of below circuit.

It works! With a reasonable linearity. However, the voltage levels change with the day light intensity.

Is there any way to make this device immune to the daylight using an LDR? I've tried to connect the LDR in parallel with the offset removing potentiometer, however, as obvious, that didn't give good, logical results. I do not have any IR filters and it is really expensive to get them from Farnell or such in Turkey.


From here.


Here is my schematic:

My Schematic

share|improve this question
You mention an offset removing potentiometer but I don't see it in your schematic? – JonnyBoats Jan 11 '12 at 11:23
@JonnyBoats Sorry I rushed. I am drawing it, I will add. – abdullah kahraman Jan 11 '12 at 11:24
abdullah: In the original schematic the + input to the op-amp is tied to 2.5 V via a pullup resistor but I don't see that in your revised schematic. Was that an oversight? – JonnyBoats Jan 11 '12 at 12:03
@JonnyBoats I don't understand you; it is connected via R8? – abdullah kahraman Jan 11 '12 at 12:51
It is really easy to get phototransistors / photodiodes in a black package that filters the IR, instead of the PD15-22C you are using. – joeforker Jan 11 '12 at 22:13

I don't think that using the signal of an LDR can do much because the circuit already has some kind of ambient light suppression: it's the high pass filter at capacitor C8.

I agree with MikeJ-UK that the signal probably is saturated by ambient light.

If you just want to get the proximity sensor working with more ambient light I'd suggest to put an IR filter in front of the detector.

If this is too easy (or you also have a lot of ambient IR light, e.g. because the sun is shining at the detector):
You have to solve the problem of the signal being totally jammed by the ambient light.

Lets suppose the photocurrent caused by the signal is some micro amps or less and the ambient light gives you already some 0.1mA there is only a very very small signal voltage at the input voltage divider (D1/R10). The more current (caused by ambient light) is flowing in the voltage divider, the smaller your singal will be.

Just increasing the amplification doesn't help, because the noise will be amplified too and I think you come into regions where signal-to-noise ratio is what you have to take care about.

So instead of having a voltage divider at the detector a better approach would be to utilize a transimpedance amplifier:
enter image description here

Its output voltage is linear to the photo current. So this will give you at least constant signal level, no matter how much ambient light you have (see also this article about this problem by Bob Pease).

Of course this is only true within limits: if your amplifier is jammed, you can't do much.

So the amplification before bandpass filtering must not be too large. But if you make your bandpass filter narrow enough you can do huge amplification afterwards (like in radio receivers).

share|improve this answer
This is a good answer, in daylight, you modulate, use IR filters and still get beaten by the shot noise of the Sun's DC. I would add a positive bias to the diode above and put a cap between the cathode and the opamp. – Frank Jan 12 '12 at 7:21
@Frank: What you propose would turn the circuit back into what it was before.... with all its problems. – Curd Jan 13 '12 at 20:53

You want to extract the amplitude of a known frequency from you diode signal. That can as you have already tried be done with a very narrow band pass filter, however there are limits. Another option is to use a lock-in amplifier. They can be many orders of magnitude better than analog band pass filters.

A lock-in amplifier basically multiplies your input signal with a reference signal of the desired frequency. The output is then low-pass filtered. In this process all frequency components that don't match the reference don't generate any significant DC output as values of different periods compensate each other destructively.

I tried to find some good illustrations and found a LabView app note and a brief functional description.

Software approach: Microcontroller

Ready to use chip: AD630 (there must be cheaper ones)

share|improve this answer
You are mocking with me, right? As I know, lock-in amplifiers are the ones that are used in rubidium oscillators? – abdullah kahraman Jan 13 '12 at 8:18
I am sorry that I was so brief, I have edited my answer. – Chris Jan 14 '12 at 3:46
+1 Very good idea! I was also thinking about lock-in amplifier but didn't mention it, because I thought it might be to far from the existing circuit. It would be a very interesting project (some years ago I made an electronic compass using lock-in amplification). – Curd Jan 18 '12 at 17:50

Well, although the ideas in here seems quite elegant.. well, if you can-t make it simple it might not be right. Oli Glaser had maybe the best idea here, even I have tried it myself before. you have to switch off the IR LED to sample ambient light, and then turn it on again to sample your reading, by subtracting those measures you will get the correct measure. There are going to be few inconveniences due to the saturation levels of the photo transistor, but is the best you can get out of it. IR cap filters are not really recommended if you have a low power LED.

share|improve this answer

I suspect the input is saturating. At high ambient light levels with the diode passing near to 100uA there will be no bias left. Try reducing the 50k resistor.

share|improve this answer
Nope, doesn't help. I've replaced it (was 47K) with 39K and 33K and 56K. It decreased the sensitivity to IR, too. – abdullah kahraman Jan 11 '12 at 13:04

Looking at the sunlight spectrum on Wikipedia, there is a dip at 940nm due to absorption of IR by water vapor in the atmosphere.

Using a IR source and sensor operating at 940nm will greatly reduce the ambient light pick-up.

The RPR220 is one, which has a 800nm and 940nm version.

share|improve this answer
Your answer would be better if it included a link to the page on Wikipedia that you are looking at, or the spectrum were inserted into your post as an image. – Nick Alexeev Apr 26 '15 at 18:56

If you are feeding the signal into a microcontroller, then you could maybe use a calibration routine to adjust for the ambient light.

For example if you read the level when nothing is being transmitted, you can subtract this value from the "ON" reading to get the difference caused by your IR emitter.
Something like this should help. You could do similar with an LDR in the opamp feedback to adjust the gain, but it would be trickier to get right.

Another thing might be to have a sharper bandpass filter (e.g. stagger 2 or 3 stages) so only the modulated frequency is "seen".

share|improve this answer

I would go along with Oli Glaser's suggestion of using a microcontroller, but I'd suggest a couple of circuit changes as well:

  1. I would suggest adding a second ADC input to the microcontroller to sense the DC level from the photodiode. My guess would be that the sensitivity of the photodiode is non-linear. If your AC input has 100x the gain of the DC input, then compute the combined value of the inputs (100x the DC value the AC value) and perform some transformation (or interpolate using a lookup table) to get a linearized value.
  2. There may be some benefit to adding an analog bandpass filter but removing the demodulator. Have the processor sample the input at 40KHz. Use four rolling-average filters (first linearized sample to filter 0, next to filter 1, then 2, 3, 0, 1, 2, 3, etc.) and compute the AC signal level as (f2-f0)*(f2-f0)+(f3-f1)*(f3-f1). This approach will offer much better noise immunity than a peak detector.
share|improve this answer

I've seen a few variants of IR preamp circuits to control the diode bias to avoid saturation with , for example This Elmos device and This very old IR preamp SL480 I've used a circuit based on the first example for an outdoor proximity sensor and it worked very well.

share|improve this answer

A mechincal solution is also possible, a "snoot" which is a tube that protects the reciever from most of the ambient light.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.