Given a constant source of infrared and a constant dispersive surface reflectance, the amount of reflected radiance is proportional to the distance. As a result, by measuring the amount of reflected radiance, it is possible to compute the distance between the sensor and the reflecting surface.
Triangulation sensors, such as the Sharp GP2D12, measure distance based on triangulation of the reflection of a focused IR beam. The advantage of this type of sensors is that distance measuring does not depend on the reflectance of the surface, and it is fairly immune to noise. Furthermore, there is a curve to fit the return voltage to distance between the sensor and an object.
However, triangulation sensors have two major disadvantages. First, the accuracy drops very quickly as distance increases. Second, the response time is very long. While triangulation sensors are well suited to low speed or stationary applications, they easily and severely limit the top speed of a Micromouse robot.
Reflectance sensing can be much faster than triangulation sensors. However, a reflectance sensor must make some assumptions about the reflectance of a surface.
Reflectances sensors can be made very small and light, even compared to triangulation sensors. A receiver can be as small as the OSRAM SFH5410.
Infrared receivers intended for IR remote controls have demodulators already built-in. This is excellent for reducing the effect of noise. Infrared receivers are also binary devices, as they either detect a modulated IR beam, or not.
Due to the binary characteristics, Infrared receivers are great as proximity sensors (whether an object is within a certain distance). However, there are tricks to use infrared receivers as “analog” sensors.
The sensitivity of an infrared sensor changes predictably as the modulation frequency of the IR beam changes (away from the ideal). If the modulation of the IR beam is controled, then the threshold of detection can change. as a result, it is possible to modify the modulation frequency to zero-in to the exact amount of reflected infrared energy.
With one sensor, this can be done by binary search. First, assume the modulation is handled by the PWM mechanism (to control both the frequency and duty cycle). In this example, assume the main clock frequency is 16MHz, while the center modulation frequency is 40kHz. This implies a period of 400 cycles. With a prescaler of 2, each period has 200 timer increments. Assuming 43kHz is the highest frequency to use, each period has 186.05 timer increments. There are 15 possible frequencies, which requires 4 binary search stages.
Most receivers demodulates in 16 wave cycles. In this example, it takes 400us (microseconds). Combined with 400us of dead time before the next burst, each binary search stage requires 800us, or 0.8ms. Four binary search stages requires 3.2ms. This is still a very short amount of time compared to the 50ms of a triangulation sensor. Assuming a moderately fast robot moves at , 3.2ms translates to about 1mm!
One of the most crippling limitations of a reflectance sensor is its dependency on surface reflectance. This is the case if the direction of the infrared emitter is parallel to that of the infrared receiver.
Let us now consider the use of two receivers. One’s direction of parallel to that of the emitter and located close to the emitter. The other located at an offset from the emitter, and looking “sideways” at an angle to the reflection of the infrared beam. The ratio of recorded reflected infrared intensity, in this case, depends only on the distance of an object, and not the reflectance of the object. In other words, we just implemented a crude triangulation sensor using reflectance sensors.
One problem of this configuration, however, is that the binary search method does not handle both sensors. In the worst case, we need to conduct two separate binary searches, which results in a longer latency.
A potential alternative, however, is to sweep the frequency of modulation and record when each sensor starts to register a signal and when it loses the signals. This method is just as slow as the binary search method, however.
Some receivers only require a minimum of 6 waves to demodulate, which significantly reduces the amount of time needed for each binary search stage.
Thanks to some nifty chips, rolling your own demodulator is now easier. The TI OP380 and OP2380 is a package of a single rail transconductance op amp. It is designed to interface with photodiodes and amplify the tiny current to a much larger voltage swing. The output voltage can, then, be fed through a band-pass filter, and then filtered by a peak detector circuit. Because everything is under the control of a processor, the peak detector can be reset by software. To improve the response time of the peak detector, a full rectifier bridge may be used.
The advantage of a custom demodulator is that it can be sampled by an ADC. This means improved resolution (instead of 15 levels!) and response time (6 waves).
A band-pass filter is a composite of a low-pass filter and a high-pass filter.
Using a resistor in series with one of the signal lines and a capacity across the signal lines, a first order low-pass filter is implemented. The cut off frequency is .
A high-pass filter is the exact opposite, where the capacity is in series on one of the signal lines, and the resistor is across the signal lines. The cut off frequency is also .
A band pass filter is essentially a low-pass filter followed by a high-pass filter. However, in order not to have the filters interact with each other, it is conventional to use a follower opamp in between.
Although the cut off frequencies are determined by the resistor and capacity values, precision of these passive components become important for a precise control of the filter frequency. A digital pot can be used so that a controller can calibrate the resistor value automatically.
A peak detector follows a band-pass filter. A capacitor is used in-line to concert the output to an AC signal centered around zero. To reduce the number of periods necessary, a full wave rectifier is better than a half wave rectifier. There are single-rail opamp circuits that can do this without the typical loss (due to voltage drop) of a diode.
A reference design can be found at http://freecircuitdiagram.com/2008/09/15/single-supply-precise-full-wave-rectifier-using-ca3140-op-amp/.
Once the filtered wave is rectified, the output is fed to a diode that charges a capacitor. A low-side FET is used to discharge the capacitor through a resistor to reset the peak. If the “load” is low, the value of the capacity can be very small, which reduces the number of wave periods necessary to charge the capacitor.
The component count of a home brew demodulator is quite high.