Advanced sensors for line following
From STAB Resources
Sensors for line following
Aim:To differentiate between Black/White on ground. This can be done by transmitting a light of a particular color and measuring the reflected light. IR Leds are used to transmit IR Light. Photodiode is used to detect the intensity of the reflected light. The intensity will vary with the reflecting surface. Black part will have low reflection while the white surface will be highly reflective.
Diodes are devices which conduct in forward bias and do not conduct in the reverse Bias. But there is a small current (~ few uA) in the reverse bias. However if we shine light on the Photodiode, the reverse current increases in proportion to the light shining on the diode. We can measure this by passing the current through a high resistance so that we can measure the output in terms of voltage. Magnitude of photo current depends on: • Intensity of incoming light: Photodiode is more responsive to light in reverse bias.
From the above discussions, we understand that a photocurrent flows through a reverse biased photo diode that depends on incoming luminance. We will use the simplest method and convert current into voltage by using resistor. Vout = iR which is directly proportional to light intensity. Sensor works perfectly if, 1)There are no sudden changes in intensity. 2)A decent amount of light is always incident on the sensor.
Why above conditions?
• The depletion region in the p-‐n junction behaves like a parallel plate capacitor of sorts. • Reverse biasing the diode increases this capacitance. So, now we have a capacitor across whose terminals the voltage changes whenever the incident intensity changes on the photodiode. We know that voltages across capacitor cannot change abruptly i.e. it needs time to charge/discharge to a given value. Also,this charging time depends on the value of the capacitance and resistance R in series with it.
Why condition 1 is necessary?
If there is a sudden increase/decrease in intensity for a short period of time , Vout will probably not show it as the sudden change may have had a duration shorter than the charging time of the capacitor.
Why condition 2 is required?
Since current i is very low (~uA),we use a suitable large resistor R to obtain a good voltage variation. But this adds to the response time of the sensor by increasing the ‘RC’ constant of the circuit. Also, large resistances have random Johnson-‐Nyquist noise which leads to bad SNR (signal to noise ratio) That’s why we need to maintain good luminance on the sensor otherwise noise will dominate due to the large resistance.
Worst case scenario
The worst performance of this sensor comes when it is used in high speed line following, where there are frequent and large changes in intensity as the bot quickly moves on and off on a line that changes direction quickly and abruptly, and there is lot of ambient light around. The response time depends on C, but C is a function of change in potential difference across the photo diode i.e. C = f (Vcc – iR), but i depends on the incident illumination, thus response time also depends upon incident illumination. Another major flaw is that this sensor assumes that no current is consumed when Vout is measured as otherwise Vout! = iR due to loading effect. Hence a current buffer comparator must be used before measuring Vout. Suggestion: Design a better sensor instead of bothering with so many trade-‐offs.
Slightly sophisticated sensors
We solve the problem of fixing a reverse biased voltage first. We use Opamps to maintain constant reverse bias voltage across the photodiode. This also ensures that there is no error introduced while sampling the input signal (In the previous case you will have to draw small current to measure voltage across the resistance and this will affect the circuit).
What are Opamps? To state it very briefly in our context, they are black box with two properties: 1) They ensure Input Voltage is same at both terminals. 2) Input Current in both terminals is zero. This is a very crude way of describing opamps. For better description and details we advise you to look at the Opamps (Analog) tutorial or wiki/google for it. Opamp has a large no of modes for various applications and we will be using it in what is called as negative feedback mode.
Set V+(non--inverting) of the opamp to a fixed voltage Vi. V--(Pin 2) also has voltage Vi by property 1. Reverse bias voltage across the photo--diode is Vd=Vcc--Vi in this case. Therefore, the photo--diode now has a fixed reverse bias across it. Vout =Vi-- iR (Property 2 says no current goes through input terminals) Vi--iR>0 (To prevent saturation) So we need to ensure that iR<Vi at all times. i is proportional to the incident light incident. Hence we have to select R suitably. If we choose a very low value for R the range we get will be too low. Hence an optimum value needs to be decided. The value of R has to be decided by testing for best results. LM324 is a quad Opamp.
Hence it can be used to make 4 analog sensors. We will be using: Vcc+: 5V Vcc-=0V Vi=3.3V(This is available on the arduino board.) Vd=Vcc--Vi=1.7V which gives reasonably good performance.
Now, we have a deterministic and reasonably well--behaved sensor in our hands.