Infrared Proximity Sensors

Application Note

By Vashishtha Kadchhud
Design Team 08
ECE 480, Spring 2007

A through beam works great in assembly lines and in close ranges. In this application note. A Retro-reflective is really durable and works well where there are harsh environment. The major categories of infrared sensor are retro-reflective sensors. we will be using the Sharp GP2D120 which is an Analog infrared sensor working on the diffuse principle. it can be an emitter and detector by itself operating at the same wavelength. 1 2 3 GP2D120 . Each of these sensors has its own advantage based on the application it is being used for. Introduction: Infrared sensors are available in various forms.Abstract: This paper discusses the implementation of a Sharp infrared proximity sensor to measure the distance of an object from the sensor. A diffuse reflective is useful where only partial light is reflected back. a emitter and detector housed in the same unit or a like a photoelectric sensor which works with reflective surfaces. This analog voltage can be translated into distance. The Infrared sensors are used along with a microprocessor with Analog to Digital Voltage conversion capability and clock to create a simple circuitry to measure distance. The Sharp GP2D120 measures analog voltage which when the transmitted beam is reflected back from the object. diffuse reflection sensor and Through Beam Sensors. This paper will elaborate on how the infrared proximity sensor is connected and communicates with the microprocessor and the software implemented based on the data provided for the sensors.

But operated at 5V .3 -0. 1uF Capacitor 10. Protoboard Rating Analog Output -0.3 to +7 V. while the bigger lens on the right is a detector. Microprocessor (PIC 18F4520) 3. Microchip MPLAB ICD 2 4.3 to Vcc 0. 40 MHz Clock Crystal 6. The pin layout for the sensor is essential while wiring it up. 5V Power Supply 8. 1pF Capacitor 11. Pin Layout for GP2D120: Pin Number Symbol 1 V0 2 GND 3 Vcc Hardware Requirement: 1. 10KΩ resistor 9. The LED on the left is an emitter. Sharp GP2D120 Sensor 2. Microchip MPLAB IDE 5.The picture above shows a Sharp GP2D120. Winford R11 Header 7.

The PIC provides us with 13 analog to digital conversion pins and in total 40 pins.Implementation: Wiring the Protoboard: The PIC18F4520 is used to do an analog to digital conversion of the voltage obtained from the infrared sensor. Wiring Diagram for Sharp GP2D120 IR Sensor . In this setup we will only be using one A to D conversion pin.

When we implement our code this will be taken into consideration. By operating on one side of the graph we can eliminate the other reading. A typical graph for the analog output voltage vs. This is done so we don’t get any errors in the reading.The output coming out of pin 3 of the Sharp GP2D120 sensor is wired to pin 2 on the PIC. This is done to prevent the sensor from absorbing all the current and the PIC seeing a big voltage drop. Pin 2 is an AN0 port which performs an A to D conversion at the user’s request. Software/Algorithm Implementation: The infrared sensors analog output voltage to distance from the object can be graphed. One of the important things to do is to wire the 1uF and 1 pF capacitors at the power bus and Vdd of the PIC.8 V we would have two distances that correspond to 0. . distance from the object GP2D120 looks like This is very valuable information in our setup. Say if we got our voltage as 0.8 V. The graph is almost linear for the first 4cms and then is exponentially decaying. we will try and operate in the exponentially decaying curve of the graph. preventing it from performing the functions.

distance=adc_result/2.height. //set VREF+ to VDD and VREF. double distance. } } . //perform ADC conversion while(BusyADC()).Code: #include <p18cxxx. //Set ADC to Pin 2 ConvertADC().) { SetChanADC(ADC_CH0).87.j.. 0).to GND (VSS) for(.h> #include <ADC. void main() { OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_12_TAD.conv. //open adc port for reading ADCON1 =0x00.ADC_CH0 & ADC_INT_OFF.h> #pragma config WDT=OFF long int count. int adc_result1. //get ADC result conv=adc_result1*(5/1024).R. //wait for result adc_result1 = ReadADC().

msu.html Information in regards to application of GP2D120 c.pdf Data sheet for PIC1854520 d.egr. The voltage converted by the PIC is checked against this reference table to determine the MPLAB and A to D conversion help . Conclusion: The application note covers the principle. A separate reference table needs to be created for each sensor since they have a small difference. A better way of determining the distance could be by using the line of best fit for the graph provided in the data sheet as compared to creating a reference table for each sensor. Recommendation: Calibrating every individual sensor is a time consuming and challenging task. how to program the PIC and implement a code to work with the sensor.microchip.html Data sheet for Sharp GP2D120 and information. implementation and application of the analog infrared sensor Sharp GP2D120. http://www. http://www. http://ww1.Calibration: In order to determine the distance of the object a reference table is created for the sensor based on the graph. It shows the basics of how to wire the sensor. This can be done in the coding. References: a. b.hobbyengineering.acroname.