Amongst other models, Sharp produces the GP2D02, a distance sensor intended for sanitary hand dryers. It uses a reflective measurement, using at least two wavelengts, red and supposedly infra-red. It achieves a 5% accuracy over a range of 10 to 80 cm (4'' to 32''), and is quite immune to differences in reflector material. It's easily interfaced to a microcontroller, as a two wire 8 bits serial interface is provided. Two more wires are used to carry power (+5V). The next diagram shows the timing of the interface. Direction is as follows: Clock signal, driven by the computer, data line, driven by the sensor.
Figure 1.1 Timing diagram for sharp gp2d02. |
The device outputs 8 bits data (bytes). Distance is reported as counts, ranging from 8 at 7.5 cm to approx 80 at 100 cm. The transfer function is not linear by nature, but quite so when squared:
Figure 1.2 Distance to counts characteristic. |
Figure 1.3 The same plot, but now squared. |