Thursday, 15 November 2012

Interfacing GP2D12 with PIC 15


The GP2D12 is an analog infrared proximity sensor. It can be used to detect obstacles. This sensor has a LED that emits infrared light. Infrared light has the interesting property that it bounces on obstacles. On the front of the sensor, beside the LED that emits the infrareds, there is a photodiode that is sensible to infrared light. It will vary the output voltage based on the amount of infrared light that bounces back to the sensor. Roughly speaking, the more infrared light it sees, the closer is the object and the higher the output voltage generated by the photodiode.

If the voltage output is connected to a microcontroller with analog to digital conversion capability (such as a PIC16F877 microcontroller), it is possible to translate this voltage to a numerical value. This value can be used to determine whether or not there are obstacles close to the sensor and how far these obstacles are.

The GP2D12 circuit shows how to interface a PIC16F877 microcontroller to a Sharp GP2D12 sensor.

Note that in this example, it is assumed that the sensor is tucked in ten centimeters within the robot. This is necessary because the voltage output curve climbs for the first ten centimeters and then drops (see chart below), which means that there is a range of voltage values that account for two different distances. By placing the sensor inside the robot, we avoid this ambiguity in sensor reading.

Analog Output Voltage vs Detection Distance

The GP2D12 outputs a non-linear analog voltage corresponding to the distance of the reflective object. The sensor can measure in the range from 10-80 cm. The voltage is approximately 2.4V at 10cm and at 0.52 at 60cm. The sensor draws about 34mA. The maximum is stated to be 50mA.

No comments:

Post a Comment