Digital IR sensor module construction and operation

 

Usually, for small functions and detecting any obstacles or object, IR sensors are frequently used in Robotics because they are very cheap.  In this article, we will discuss how to make an IR sensor pair and discuss its working.  For this, firstly we need an IR LED and an IR reciever or photo diode.

light-emitting diode (LED) is a two-lead semiconductor light source that resembles a basic pn-junction diode, except that an LED also emits light. When an LED's anode lead has a voltage that is more positive than its cathode lead by at least the LED's forward voltage drop, current flows. Electrons are able to recombine with holes within the device, releasing energy in the form of photons. This effect is called electroluminescence, and the color of the light (corresponding to the energy of the photon) is determined by the energyband gap of the semiconductor.

 


Infrared (IR) light is electromagnetic radiation with longer wavelengths than those of visible light, extending from the nominal red edge of the visible spectrum at 700 nanometers (nm) to 1 mm. This range of wavelengths corresponds to a frequency range of approximately 430 THzdown to 300 GHz.[1] Most of the thermal radiation emitted by objects near room temperature is infrared. So, IR LEDs are those LEDs which emmit the light ways in this range.Next comes the Photodiode or IR reciever. This also looks similar to IR LED but it has a property where it recieves the light, instead of transmitting and change its resistance on IR light. (which is noted by a circuit formed with it). You can observe the impact of light on photo diode in the figure.

 

We need a basic phenomena to make this LED works. We create a pair of both IR LED and photodiode or IR reciever parallel to each other as shown.

You can clearly see that,  IR LED is sending the light and its get reflected by object, which is recieved by IR reciever LED. And in case, when there is no IR getting reflected due to absence of any object, there is no IR light recieved by photo diode.

Now, there are some points to study about the reliabilty of this sensor module packaging like this. You must be thinking that there are other IR elements in ambient light. 

For example: light of SUN, its has very high IR element or IR wavelengths. 

My friends, you are right! This is the one of the main and very bad disadvantage of IR sensor functioning that it does not work in Sun light or any type of hot places. AND sometimes in normal room light, this setting gets disturbed.

You Must be thinking that then why i am here to tell you about this sensor. Here is my answer to you.

Normally, These sensors are  used inside room (best in dark rooms). For example: robots working in dark rooms have these sensors. But if there is a way to get the work done by this sensor pair in ambient light. For that, we send the IR light at a very frequency and our emiter polls for the same frequency IR light. Obviously, it recieves all IR lights comming to it, but it will then only consider the object from where it gets the same IR light frequency.By frequence, i means simple squre waves of ON/OFF cycle.

If its still not clear then, you can take example of HEARING and LISTENING. 

But for sake of simplicity, i will not add that part into this article because thats a logic implementation either through software in any microcontroller or any logic device. I might write another article for this implementation but lets, concentrate on sensor module itself.

Electronic circuit


Now, lets see how can we use the resistance change of photo diode for processing in any microcontroller, whenever there is an object in front of the sensor module. In this circuit diagram, you can firstly see that IR LED is light up by 5v potential difference and series resistance of 270 ohm. So here i am making IR LED emit the light continously in the direction parallel to IR reciever but you can extend this by giving a suare pulse to emitter instead of constant supply. Next, look at the parallel circuit to IR Emitter. Here, there is a much higher resistance in series and both photo diode and series resistance are connected accross the same supply( you can take any refference voltage accorss it, but common the grounds).

But how this setup impacing the output point in the middle of series resistance and photo diode. Well, this is nothing but the potential drop accross the high series resistor. in case the resistance of Q1 is very low (due to any object reflecting the IR light on it), it allows more current through its branch. This results in more current accross the 10k resistor R2. Now voltage drop accross any resistor is directly proportional to the current accorss it (by Ohms law V = IR).

Now what we concluded is that resistive value of  Q1 is inversely proportional to light comming on it and voltage drop accross R2 is also inversly proprotional to resistance of  Q1. Therefore we know that whenever there is any object (means more light is fallying on IR reciever Q1) then we get higher voltage drop by R2 and therefore recieves less voltage in the output.

Hence, OUTPUT VOLTAGE is directly proportional to amount of IR light getting reflected on reciever, that is inversly proportional to distance of object from sensor.

So if we decrease distanc, voltage will increase.

This is a analog IR sensor module made by us, which gives us variable voltage depending on different distant objects and also with density and colour of that object because light coloured objects reflect the most IR light falling on them and on other hand, dark objects absorves the light.

 

Digitalization of sensor module


To make this sensor module digital, we have to make its output into a decision that is Yes(1) or No(0). In advance cases, we can use some logic devices or even small microcontrollers to give more binary or Hexa outputs for more than two decisions. But, that we will discuss in some other article. In this article, my main aim is to tell you about sensor module digitalization process, and will try to make it as simple as possible.

Till now we have an analog output that is varying with the input IR light. To make it digital, we first need to know the refference voltage (which is in our case same 5 volt) and  caliberated voltage which will corresponds to critical point of change of decision from 1 to 0 or 0 to 1. For that, we need to things more.

1. LM393 comparator IC 

2. Potentiometers (for electronic data needed for caliberating sensors)

 

Caliberation of sensor module


Now, lets proceed and find out that what exactly is the caliberation. For that, we should study in more depth about the pattern of voltage which will come out using a particular environmen, IR LEDs and sometimes moisture in air and so on. I highly recommend you to check your analog sensor with a multimeter for better physical intuation of sensor working. Below is the video by me to show how a sensor module works. In this video, you will see a sensor module made on an universal PCB by me.

 

 

To know the importance of caliberation and why it is done, lets take a simple case where we want to detect the white and black coloured object at same distance. As you already know that with white object we will have nearly full voltage because maximum IR LED will be transmitted. But how nearly will depend on the distance of white object from sensor, but we are not concerned about it. Mainly, we know that in all cases value of white object will always be greater than black one.

So lets suppose, with a particular distance and most importantly at a given ambient light condition,  white object gives value ( or corresponding value of ADC to) 4.4 volt and black object gives 3.5volt. Now the decision point can be near 4 volt.

But the main need of caliberating these sensors comes when there is a much distance between object and sensor (it decreases sensitivity of sensor for colours) and there is much IR light already present in the room in ambient light. For example: in this case: VOUT for black will be 4.2 volt and for white it will be 4.6v. So basically, whenever there is less difference between two object data due to such conditions, caliberating become mandatory.

Now caliberating of sensor is not difficult though. To caliberate it, you need to generate the artifical data which will out put the voltage corresponding to the voltage required for decision transition. LIKE, in above example we take 4.2 and 4.6 and takes there mean value, which is 4.4v. To get this value, we use same circuit as above but we use a Potentiometer instead of IR reciever. As in diagram, you can see that by potentiometer we can set the value exactly to 4.4v output.

LM393 IC


As we have already made sensor module and its caliberated artificial eletcronic data by potentiometer circuit, we now need a device or IC which will compare the two value on give the digital decision 0 or 1. That can be any gate, logical device, microcontroller, your PC, but we are using LM393 comparator IC for that.

Lets, first get a brief knowledge about the usage of this IC. This IC has two caparating unit in it. we can compare 2 voltage and can give output 0/1 according to them. Lets have aview ofn pin description of this IC.

A comparator(electronic such as an LM393) works by sampling two input pins and turns on an output when there is ether a difference or similarity of the inputs. it depends on how the comparator is used in the design. Say you have a reference voltage on the "inverting"( - ) pin of 5 volts. And you have the "non-inverting" ( + ) connected to measure a voltage.

when the voltage on the Non-inverting side equals the inverting voltage. the Output pin will turn on. Usually the Output Pin is open and will switch to ground once the comparator is activated. Remember since most all comparators have open-collector outputs, you will need topull-up the pin to the source voltage through a resistor to see the switching action. To make the put act differently, (instead of switching to ground when active) all you need to do is exchange(swap) the input pins.

Here you can see that, there is a pull connected to (one of the output) out2 of the comparator, so that you can see the LED glowing (if connected to the out2 of the comparator IC) Or you can also trigger some other hardware relay. But in the most case, we uses this signal for microcontroller input pin or directly into drivers like L293D.

 

Circuit on BreadBoard for testing


I always recommen to students to make these small circuit on breadboard for studying rather than directly making or purchasing PCBs. This always makes conceptt much more clear as you can at any time connect or unconnect any wire and play with it to understand it even better.

Here, you can see all the connections are made between potentiometer, LM393 comparator and sensor module (in this case, i have used my sensor module PCB but you should make the sensor on the bread board or on universal PCB as in above video). For the connection, there are very less to do.

Just you have to connect the output of sensor module to 3rd pin(+int1) of comparator IC (longest wire in image) and to pin2 -IN1, you have to connect the voltage output comming from potentiometer circuit. Connect the OUT1 with pull up resistance (as shown above for OUT2) and also to a LED to see if you got a 1 or 0. 

After that, give power(5v) to the circuit, with common ground to all devices connected. Use my 7805 IC blog to know how to make a power circuit from a big source to 5 volt.

 

 

So this is your digital sensor module ready and working. To get more idea, check out the video of this sensor module on breadboard working. We have made this sensor in such a way that in future we can use this with many powerful microcontrollers and in very large level projects.

 

PCB design for LM393 and sensor module


If you have understood everything about this article and now you know how a digital sensor works and want to use it in your project, then its better to make a PCB for all of them, like i did. Here are the images of LM393 IC board and sensor module. If you want to make your own and want to know how you can make, then you can learn by clicking on LM393 board PCB and IR sensor module PCB. You will learn there about the designing software and all the components required for soldering. Here is also a sample screenshot of design of this comparator board.