Username: Password: Remember me

Home Sensors & Measurement

Infra-Red Proximity Sensor (I)

Based on a simple basic Idea, this proximity sensor, is easy to

build, easy to calibrate and still, it provides a detection rangeof 35 cm (range can change depending on the ambient lightintensity).

This sensor can be used for most indoor applications where no importantambient light is present. For simplicity, this sensor doesn't provide ambientlight immunity, but a more complicated, ambient light ignoring sensorshould be discussed in a coming article. However, this sensor can be usedto measure the speed of object moving at a very high speed, like in industryor in tachometers. In such applications, ambient light ignoring sensor,which rely on sending 40 Khz pulsed signals cannot be used because thereare time gaps between the pulses where the sensor is 'blind'...

The solution proposed doesn't contain any special components, like photo-diodes, photo-transistors, or IR receiver ICs,only a couple if IR leds, an Op amp, a transistor and a couple of resistors. In need, as the title says, a standard IR led isused for the purpose of detection. Due to that fact, the circuit is extremely simple, and any novice electronics hobbyistcan easily understand and build it.

Object Detection using IR light

It is the same principle in ALL Infra-Red proximity sensors. The basic idea is to send infra red light through IR-LEDs,which is then reflected by any object in front of the sensor.Then all you have to do is to pick-up the reflected IR light. Fordetecting the reflected IR light, we are going to use a veryoriginal technique: we are going to use another IR-LED, todetect the IR light that was emitted from another led of the exactsame type!This is an electrical property of Light Emitting Diodes (LEDs)which is the fact that a led Produce a voltage difference across itsleads when it is subjected to light. As if it was a photo-cell, butwith much lower output current. In other words, the voltagegenerated by the leds can't be - in any way - used to generateelectrical power from light, It can barely be detected. that's why asyou will notice in the

schematic, we are going to use a Op-Amp (operational Amplifier) to accurately detect very small voltage changes.

The electronic Circuit

Two different designs are proposed, each one of them is more suitable for different applications. The maindifference between the 2 designs is the way infra-red (IR) light is sent on the object. The receiver part of thecircuit is exactly the same in both designs.Note: Both the sender and the receiver are constructed on the same board. They are separated in the schematics forsimplification.

Design 1: Low range, Always ON

As the name implies, the sensor is always ON, meaning that the IR led is constantly emitting light. this design of thecircuit is suitable for counting objects, or counting revolutions of a rotating object, that may be of the order of 15,000rpm or much more. However this design is more power consuming and is not optimized for high ranges. in this design,range can be from 1 to 10 cm, depending on the ambient light conditions. As you can see the schematic is divided into 2 parts the sender and the receiver.

The sender is composed of an IR LED

(D2) in series with a 470 Ohm resistor, yielding a forward current of 7.5 mA.

The receiver part is more complicated,

the 2 resistors R5 and R6 form a voltage divider which provides 2.5V at the anode of the IR LED (here, this led will be used as a sensor). When IR light falls on the LED (D1), the voltage drop increases, the cathode's voltage of D1 may go as low as 1.4V or more, depending on the light intensity. This voltage drop can be

detected using an Op-Amp (operational Amplifier LM358). You will have to adjust the variable resistor (POT.) R8 sothe the voltage at the positive input of the Op-Amp (pin No. 5) would be somewhere near 1.6 Volt. if you understand thefunctioning of Op-Amps, you will notice that the output will go High when the volt at the cathode of D1 drops under1.6. So the output will be High when IR light is detected, which is the purpose of the receiver.

In case you're not familiar with op-amps, here is shortly and in a very simplified manner, what you need to know tounderstand how this sensor functions: The op-amp has 2 input, the +ve input, and the -ve input. If the +ve input'svoltage is higher than the -ve input's voltage, the output goes High (5v, given the supply voltage in the schematic),otherwise, if the +ve input's voltage is lower than the -ve input's voltage, then the output of the Op-Amp goes toLow (0V). It doesn't matter how big is the difference between the +ve and -ve inputs, even a 0.0001 volts difference willbe detected, and the the output will swing to 0v or 5v according to which input has a higher voltage.

Some applications of the 'low range Always ON' Design:

Notice how in both devices, the IR leds are encapsulated to protect them from ambient light. this kind of encapsulationwas totally sufficient to overcome all noise due to ambient light for indoor applications.

Wheel Encoder Contact-Less tachometer

This is a simple wheel encoder based on the idea that This is a tachometer, that counts the revolutions perwhite stripes will reflect IR light, while black ones will minute of a rotating object, given that the object has aabsorb it. this will result in a series of electrical pulses as reflective stripe glued on it, that will pass in front of thethe wheel is rotating, providing the microcontroller with IR sensor for each and every revolution, giving a pulseprecious information that can be used to calculate per revolution. Again a microcontroller will have to bedisplacement, velocity or even acceleration. It is now used to 'understand' the data provided by the sensor andclear that this kind of sensor has to be Always ON, to display it. Many commercial contact-less tachometers,detect every single white stripe passing in front of it, to that are sold for more than $200 rely on this simpleachieve accurate results. idea! [Build your own one for less than $20 in this article...]

Design 2: High range, Pulsed IR

In this design, which is oriented to obstacle detection in robots, our primary target is to reach high ranges, from 25 to 35cm, depending on ambient light conditions. The range of the sensor is extended by increasing the current flowing in theled. This is a delicate task, as we need to send pulses of IR instead of constant IR emission.The duty cycle of the pulsesturning the LED ON and OFF have to be calculated with precision, so that the average current flowing into the LEDnever exceeds the LED's maximum DC current (or 10mA as a standard safe value).The duty cycle is the ratio between the ONduration of the pulse and the total period. Alow duty cycle will enable us to inject in theLED high instantaneous currents whileshutting it OFF for enough time to cooldown from the previous cycle.

Those 2 graphs shows the meaning of the

duty cycle, and the mathematical relationsbetween the ON time, the Total period, andthe average current.In the second graph, the average current inblue is exaggerated to be visible, but realcalculations would yield a much smalleraverage current.

Pulsed IR, Duty cycle, Average and Instantaneous current.

Now, hands on the circuit that will put all this theory into practice. The CTRL input in the figure, stands for Control,and this pin should be connected to the source of the low duty cycle pulses discussed above, whether it is amicrocontroller or an LM555 timer that generates the pulses.

The calculations yielded that a 10 ohm resistor is series with the LED D2, would cause a current of approximately 250mA to flow through the LED. A current this high, would destroy the LED if applied for a long period of time (somedozens of seconds), this is why we have to send low duty cycle pulses.

The first Op-amp will provide voltage buffer, to enable any kind of device to control the sensor, also, it will provide the 30mA base current required to drive the base of the transistor. The calculation of the the base resistor R3 depends on the type of transistor you use, thus on how much current you need on the base to drive the required collector current.

The receiver part of this schematic

functions in the exact same way as in the first design, refer to the first, 'ALLWAYS ON' design for a detailed description.

Software based ambient light detection.

When the sensor is controlled by a microcontroller to generate the low duty cycle pulses, you can benefit from the Highand Low pulses to be able to detect any false readings due to ambient light. This is done by recording 2 differentoutputs of the sensor, one of them during the ON pulse (the sensor is emitting infra red light) and the other during theOFF time. and compare the results.

The Idea is enlightened by this graph,

where in the first period, there is lowambient noise, so the microcontrollerrecords a "1" during the on cycle, meaningthat an object reflected the emitted IRLight, and then the microcontroller recordsa "0" meaning that during the OFF time, itdidn't receive anything, which is logicbecause the emitter LED was

OFF. But study the second period of the graph, where the sensor is put in a high ambient light environment. As you cansee, the the microcontroller records "1" in both conditions (OFF or ON). This means that we can't be sure whether thesensor reception was caused by an object that reflected the sent IR light, or it is simply receiving too much ambient light,and is giving "1" whether there is an obstacle or not.

The following table show the possible outcomes of this method.

Output recorded during: Software based deduction On pluse Off time 1 0 There is definitely an Obstacle in front of the sensor The sensor is saturated by ambient light, thus we can't know if 1 1 there is an obstacle There is definitely Nothing in front of the sensor, the way is 0 0 clear This reading is un logical, there is something wrong with the 0 1 sensor.

Components positioning: The correct positioning of the sender LED, the receiver LED with regard to each other and to the Op-Amp can alsoincrease the performance of the sensor. First, we need to adjust the position of the sender LED with respect to thereceiver LED, in such a way they are as near as possible to each others , while preventing any IR light to be picked upby the receiver LED before it hit and object and returns back. The easiest way to do that is to put the sender(s) LED(s)from one side of the PCB, and the receiver LED from the other side, as shown in the 3D model below.

This 3D model shows the position of the LEDs. The green

plate is the PCB holding the electronic components of thesensor. you can notice that the receiver LED is positionedunder the PCB, this way, there wont be ambient light fallingdirectly on it, as ambient light usually comes from the top.

It is also clear that this way of positioning the LEDs prevent

the emitted IR light to be detected before hitting an eventualobstacle.

Another important issue about components positioning, is the distance between the receiver LED and the Op-Amp.which should be as small as possible. Generally speaking, the length of wires or PCB tracks before an amplifier shouldbe reduced, otherwise, the amplifier will amplify - along with the original signal - a lot of noise picked up form theelectromagnetic waves traveling the surrounding.

Here is an example PCB where the distance between the LED and the Op-Amp isshown. Sure this distance is not as critical as you may think, it can be up to 35mmwithout causing serious problems, but trying to reduce this distance will Always giveyou better results.

Actually, when I design the PCB, I start by placing the receiver LED and the Op-Amp, as near to each others as possible, then continue the rest of the design.

An example PCB construction

Here is an example construction of the PCB for the High Range, Pulsed IR proximity sensor.You can download here the project folder containing the schematic, the PCB design, and an example code for 8051microcontroller to send the low duty cycle pulses. In this design, the LM358 Op-Amp is moundedon the copper side, to save some space. The POT isthe potentiometer used to adjust sensitivity.

As explained before, the sender and receiver LEDs

are on both sides of the PCB.

Testing the High range Pulsed IR sensor

The last step, is to test the performance of the pulsed IR proximity sensor. To do this, I connected the sensor to a 89S52microcontroller, loaded with a program to generate pulses with a duty cycle of approximately 1.6. at a frequency of3Khz. LEDs are deigned to operate at very high frequencies, so you don't have to worry about the response time. Tomake sure your duty cycle calculations are correct, let the sensor running for a minute, and check with your fingers thetemperature of the IR sender LED. If its not hot, then everything is alright. On the other hand, if the LED is getting hot,to an extent that you can feel it, there is probably something wrong, you should then try to decrease the duty cycle, orincrease the series resistor, in order to decrease the average current flowing into the LED.

Then, you can start testing the range of the sensor, and experiment it in different ambient light conditions, but thepotentiometer may have to be adjusted carefully, to cope with ambient light.

In the example C code above, the final output of the sensor appears on the pin P2_3 of the microcontroller, as explainedbefore.

1. can i use this same circuit(design 1) for a line follower

2. i am using lm324 in place of lm358 and rest everything same...will it make any difference?? 3. y r u using such higher values as 470 ohm in sender circuit and 3k8 ohms in receiver circuit. can i use any lower value in place of these two values such as 100 ohms as a value of R7. 4. how we have to set tht 10K Pot......how can we measure the voltage....by a multimeter i guess?? 5. if i use an ir receiver diode in place of ir led in receiver circuit will it make any difference??

**pls rply its really urgent**

Posted by:svignes ['Quote ] Infra-Red proximity sensors PART 1h90on: 12 Oct2009 Can I use this sensor for line-tracking? And is it possible to get these kind of sensors as 8-cell arrays (similar to LED and LDRs) ? http://www.pololu.com/catalog/product/1134

Posted by:svignes ['Quote ] Infra-Red proximity sensors PART 1h90on: 12 Oct2009 Sir, I'm building a robot now and I would like to use line-tracking sensor which can detect white reflective tape on a black background. The distance from which it can sense the line needs to be approximately 3-5 cm (height of chassis from the ground). Is it advisable to use IR proximity sensors for this? I checked the line tracking sensors at http://www.ikalogic.com/tut_line_sens_algo.php. The speed at which it detects is important and hence I think IR proximity sensor is better than LED and LDRs. Most of the Line tracking sensors I found online have a very low sensing distance of 1-12 mm (like this one http://www.trossenrobotics.com/p/I2C-Li ... ensor.aspx). Can you please advice which one will be better for me to use? And is it possible to get a detailed description of "IR proximity sensor used for line-tracking" as it's mentioned for LED and LDR sensor? Thank you very much.

Posted by: ['Quote ] Re: Infra-Red proximity sensors PART 1

Quoting jaydu1904: thank you Sir, bt if I use those blue/black IR LEDs that i am getting here, will the circuit work properly or not?? Also I have another doubt, if I want to use a photo detector diode in the Receiver part of the circuit(instead of IR LED), will there be any changes in the circuit??(Because photo diode is connected in reverse bias)

thanks again...ikalogicon: 02 Oct2009 I am not quite sure of the result, I know it will work, but how good? i dont know. You have to try different configurations.Posted by:jaydu1 ['Quote ] Re: Infra-Red proximity sensors PART 1904on: 02Oct 2009 thank you Sir, bt if I use those blue/black IR LEDs that i am getting here, will the circuit work properly or not?? Also I have another doubt, if I want to use a photo detector diode in the Receiver part of the circuit(instead of IR LED), will there be any changes in the circuit??(Because photo diode is connected in reverse bias)

thanks again...

Posted by: ['Quote ] Re: Infra-Red proximity sensors PART 1

Quoting jaydu1904: hello Sir,

How an IR LED looks like??? Bcoz one that is shown in images here is transperant, whereas one i've got here is bluish black in colour. Are the same or will it make some difference?? I know it sounds a fullish kind of quetion bt still please let me know...ikalogicon: 02 Oct thanking you...2009

it is not a foolish question at all! on the contrary, when i was testing my IR sensors, i always got much better results with transparent IR leds than with opaque ones. I am however unable to give you a certain reason for that!

How an IR LED looks like??? Bcoz one that is shown in images here is transperant, whereas one i've got here is bluish black in colour. Are the same or will it make some difference?? I know it sounds a fullish kind of quetion bt still please let me know...

Postedby: ['Quote ] Infra-Red proximity sensors PART 1rafrusselon: 02 hello..could some one help me: I need a circuit of a sensor and their components using PIC16f84...thankyouMay for you time2009

Postedby: ['Quote ] Infra-Red proximity sensors PART 1sukruton: 15 hello sir.Apr i have finished making the ir sensor.2009 so do u need to add program with ir sensor zip file to microcontroller. as when u connect sensor the o/p isnt changing on display.? reply immediately.

Postedby: ['Quote ] Infra-Red proximity sensors PART 1sukruton: 12 hi,do we have to burn program given for ir sensor in microcontroller along with the code for the digitalApr tachometer.2009Posted by: ['Quote ] Infra-Red proximity sensors PART 1thejudge this is probably a noob question, but what's the amp rating for the different 5v inputs?on: also, is the on/off "switch" between the output label and ground?02Apr2009

Posted by: ['Quote ] Re: Infra-Red proximity sensors PART 1maksaon: 02Mar Quoting sumanfiem:2009 Quoting sumanfiem: Sir, I'm interested in having an IR Proximity detector circuit that gives an analog output and not digital...i.e, I want to know exactly how far is the bot from an obstacle. What changes would you suggest in your above circuit that would make this possible? Thank you

since op amp output will swing from 0 to 5v if it sense something, i think is hard to do but if u use ranger or sonar sensor u could do that, because apparently i use those method for my sumo robot. so the ranger will send signal and receive the signal back after that it will calculate it for u then i use adc to convert to digital as my input function.

Posted by:sumanf ['Quote ] Re: Infra-Red proximity sensors PART 1iemon: 28 Feb2009 Quoting sumanfiem: Sir, I'm interested in having an IR Proximity detector circuit that gives an analog output and not digital...i.e, I want to know exactly how far is the bot from an obstacle. What changes would you suggest in your above circuit that would make this possible? Thank you

You have to be a member to post replies.

Top of Form

../ir_prox_sensor Login

Username: Password: Remember me

Bottom of Form Register now! it only takes an instant. Forgot your password? Unless mentioned, all content is written and designed by Ibrahim Kamal, copying is prohibited and unethical

Home | Forums | contact | Check mail | About Ibrahim KAMAL

All content on this site is provided as is and without any guarantee of any kind. We cannot be held responsible for any errors, omissions, or damages arising out of use of information available on this web site.IMPORTANT COPYRIGHT NOTE: Electronics and Robotics Articles by IbrahimKAMAL are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.