Documente Academic
Documente Profesional
Documente Cultură
Distance Measurement
using Infrared
with a new proximity sensor module
In the form of the GP2D02, Sharp have produced a sensor which, with
the aid of a microcontroller, can provide reasonably accurate measure-
ments of distances in the range 10 to 80 cm.
Control circuit
circuit The sensor is available in various alterna-
4 VOUT
Light detector tive versions. Here we will just mention the
GP2D05, which has the facility for setting a
LED drive threshold distance to the target object using
circuit 2 VIN a potentiometer. This device operates with-
(Control
IR LED signal out an external clock and requires only a trig-
input)
Reflective VCC ger signal to initiate a measurement cycle.
object
This simplifies the electronics, but does not
020010- 11 allow us to measure actual distances.
Although the GP2D02 is specified for a
Figure 1. Internal circuit block diagram of the Sharp GP2D02. supply voltage of 4.4 V to 7 V, the voltage at
the Vin pin should not be allowed to exceed
3 V. As can be seen from the circuit diagram
distance 2 object in Figure 5, this can be prevented by fitting
a protection diode. In the example circuit the
distance to the target object is measured con-
tinuously. The measured value from the
distance 1 GP2D02 is shown as a three-digit decimal
value on the display. In addition, pin P1.2 of
microcontroller IC1 is connected to a buzzer
(with integrated oscillator) which is turned
on when an object comes closer than a dis-
tance set via P2.0 and P2.1. The settings are
Sender
as follows:
PSD
P2.0 P2.1 Threshold value
H H > 219
displacement L H > 209
020010 - 12 H L > 199
L L > 179
Figure 2. Measuring distance by triangulation. Pins P2.0 and P2.1 are fitted with internal
pull-up resistors, so for a threshold value of
219 no external connections are necessary. Of
interesting parts of the curve are the case the output value starts to rise course, the switched output could be used to
regions below about 10 cm and with decreasing distance, which can operate a relay (with flyback diode!) in order
above around 80 cm. In the former confuse subsequent processing cir- to switch other equipment. P1.2 is an active-
low open drain output.
output
Thanks to its architecture and simple pro-
gramming, the Philips microcontroller is ideal
100
for this system. It includes 2 k of ROM,
128 bytes of RAM, two 16 bit timer/counters
50
0
0 20 40 60 80 100
distance [cm] 020010 - 14
+5V
Bz1
C1
100µ 16V
15
LD1
VOUT 2 1
P1.7 P0.0 D0 BL CLR
IC2 D1 3 20 Display
P1.6 IC1 P0.1 D1
VIN 4 19
GP2DO2 P1.5 P0.2 D2
1N4148 8 18
P1.4 P0.3 D3
9 87LPC762 17
P1.3 P0.4 D4
along with other internal circuitry which is 10 16
P1.2 P0.5 D5
not used in this application. It is worth not- 11
P1.1 P0.6
14
D6 A0 A1 WR
ing that the (RC) clock oscillator and the reset 12
P1.0 P0.7
13