Sei sulla pagina 1di 6

IR SENSOR

IR sensors would definitely be one of the most easy to operate upon


What questions this document addresses? Detailed explanation of how IR modules can be prepared at minimum cost. Concept of developing your own customized IR module for varying applications. End to end working circuit diagram for using a typical IR module. Troubleshooting an IR sensor module. Infra red sensors are in the form of diodes with 2 terminals. Here onwards, we will use Tx to refer to a transmitter and Rx to refer to a receiver diode. This is how a typical Tx/Rx looks like:

Upon careful observation, you will notice that amongst the two legs, one has a much wider base within the diode. That is normally the cathode (negative) whereas the leg having a smaller base would be the anode (positive terminal). Operation: When the Tx is forward biased, it begins emitting infra red. Since its not in visible spectrum, you will not be able to see it through nakedeyes but you will be able to view it through an ordinary cell phone camera

A typical transmitter circuit. The resistance R1 in the above circuit can vary. It should not be a very high value (~ 1Kohm) as then the current flowing through the diode would be very less and hence the intensity of emitted IR would be lesser. By increasing the current flowing in the circuit, you can increase the effective distance of your IR sensor. However, there are drawbacks of reducing the resistance. Firstly, it would increase the current consumption of your circuit and hence drain the battery (one of the few precious resources for any embedded system) faster. Secondly, increasing the current might destroy the Tx. So, the final choice should be a calculated trade off between these various factors. You can also modulate the IR to achieve better distance and immunity.The receiver diode has a very high resistance, typically of the order of mega Ohms when IR is not incident upon it. However, when IR is incident upon it, the resistance decreases sharply to the order of a few kilo Ohms or even lesser. This feature forms the basis of using IR as a sensor. You will need to connect a resistance of the order of a few mega Ohm in series with the Rx. Then tap the output voltage at the point of connectivity of these two resistors. A complete Tx-Rx circuit is given below.

A Tx-Rx pair circuitry. Remember, the value of R2 can vary depending upon the Rx diode you are working with. You are advised to first check the resistance of Rx diode with no IR incident upon it and then select the value of R2 for decent performance.

Case1: when no IR is incident upon the Rx Rx would be of the order of mega ohms and hence the output voltage would be around 2.6v 3v depending upon your choice of R2 and the Rx. Case2: when IR is incident upon the Rx The resistance of Rx will sharply fall and hence the output voltage would be around 1.8v - 1.5v depending upon your choice of Rx and R2. Once you obtain a neat difference between the output voltages in case1 and case2, your sensor is ready. How to use this IR sensor? So far, we had just prepared the sensor. Now, we will see 2 different methods of using this in your machine. Method1: The output voltage is in the form of analog voltage. You would need to convert it into digital format so that whenever IR is incident upon the Rx, the final conditioned output voltage is a logic high (binary 1) and whenever IR is not incident upon the Rx, the conditioned output voltage should be a logic low (binary 0). You can use a comparator IC to serve this purpose. A comparator IC compares 2 input voltages using an op-amp and gives a logic high or a logic low as the final output. LM324 is one such comparator. Lets see how it can be used here:

Pin diagram of LM324 It has 4 separate channels meaning it can compare 4 pairs of voltages. For a single IR sensor, only one channel is enough. Here we would be using pin 1,2 and 3 for our sensor. Input voltage at pin2 > input voltage at pin3 ; Output1=> logic 0 Input voltage at pin2 logic 1

Connect the output of our sensor circuit to pin2 of this IC. Generate 2v from a potential divider circuit of multiple resistance and feed that 2v to pin3 of the IC. Therefore, Vin at pin3 = 2v (constant).

Case1: when IR is not incident upon the Rx. When the IR Tx is above a black line, the black line will absorb all the IR and will not reflect an appreciable amount of IR for the Rx to receive. If you are making an obstacle avoiding robot, then when there is no obstacle in front of the IR Tx, Rx will not receive back the transmitted IR. However, when an obstacle comes in front of the Tx, it will reflect the IR incident upon it and hence Rx will receive the IR. when IR is not incident upon the Rx. In this case, the output voltage of the sensor = 2.5v. Hence the input voltage at pin2 =2.5v. Input voltage at pin2 > input voltage at pin3 ; Output1=> logic 0

Case2: when IR is incident upon the Rx, the output voltage of the sensor = 1.8v. Hence the input voltage at pin2 =1.8v. Input voltage at pin2 logic 1

Now you can easily use the digital logic level outputs to drive any logic circuit as well as couple it with a microcontroller to decide the future course of action. Method2: Using ADC to convert the analog output voltage from sensor into a digital format. This is a little tedious way of implementing the similar logic but can give you great granular control over the distance/range of your IR sensor. You can use the built in ADC channels of a microcontroller also. The program section in the tutorial of robosense covers the program required to use the adc channels of a microcontroller as well as program for implementing a simple line follower or obstacle avoiding robot. Troubleshooting: What happens if you are in the middle of a crucial competition and suddenly your robot begins to malfunction? The once reliable IR sensor seems to have ditched you just when its needed the most. Being sound in quickly troubleshooting a IR sensor circuit is as crucial as developing the sensor itself. Here are some of the recommended steps you can adopt to troubleshoot your sensor circuit: Step1: first check if the Tx is glowing or not. You will not be able to view IR through naked eyes but a typical cell phone camera should be a good useful tool here.

Snap taken from a cell phone camera. Step2: Once you have verified that the IR TX are working fine, check if the output at the receiver side is showing correct expected voltages when IR is incident upon it and when it is absent. Step3: if the Tx and Rx are behaving correctly, please check the LM324 comparator and check if it is giving correct outputs in different scenarios.

Potrebbero piacerti anche