User manual
Robotics experiment with PIC microcontroller l 63
4. Wait the required acquisition time.
5. Start conversion by setting the GO/DONE bit in ADCON0 register.
6. Wait for ADC conversion to complete by one of the following:
l Polling the GO/DONE bit
l Waiting for the ADC interrupt (interrupts enabled)
7. Read ADC Result. The result data will store in ADRESH and ADRESL register.
8. Clear the ADC interrupt flag (required if interrupt is enabled).
5.6 GP2D120 : 4 to 30cm. Infrared distance sensor
One of the special sensors in robotics is the Infrared Distance sensor. Some people
call it the IR Ranger. With the GP2D120 module, it adds the distance measuring and Ob-
stacle detection using infrared light feature to your robot. Your Robo-PICA robot can
avoid obstacles without having to make any physical contact.
5.6.1 GP2D120 features
l Uses Infrared light reflection to measure range
l Can measure a range from 4 to 30 cm.
l 4. 5 to 5 V power supply and 33mA electric current
l The output voltage range is 0.4 to 2.4V when supplied by +5V
Infrared LED transmitter Infrared Receiver
GND
Vout Vcc
/2 ,
4 8 12 16 20 24 28 320
0
0.4
0.8
1.2
1.6
2.0
2.4
2.8
Output voltage (V)
Distance (cm)
Figure 5-1 : GP2D120 pin assignment, operation and characteristic curve
1st measure 2nd measure
Not stable
1st out
p
ut 2nd out
p
ut n out
p
ut
n measure
38.3±9.6 ms
5 ms
Measurement
Vout
Su
pp
l
y
* Use Kodak R-27 gray-white
paper. The white side has a
90% reflection rate, made
from a material that reflects
light for range measurement.