Parts: Digital Proximity Sensor (Sharp GP2Y0D02)

[youtube=http://www.youtube.com/watch?v=TqOzmGNBgJE]

The GP2Y0D02 is an infrared proximity sensor with a detection field that extends 80cm. This type of sensor can be used to build collision avoidance systems for robots. We’ll demonstrate this sensor using a single resistor and a multimeter.

2y0d02b

Sharp GP2Y0D02 fixed 80cm IR proximity detector (Digikey #425-2064-ND, $14.38). Datasheet (PDF).

The GP2Y0D02 requires a 5volt power supply (not shown). A 0.1uF bypass capacitor between power and ground (C1) is a good idea, but we didn’t use it in our demonstration. The open collector output (pin 1) pulls to ground when no object is detected, a 12K pull-up resistor (R1) holds the signal high when an object is detected.

In the demonstration we connected the output of the sensor to a multimeter. When nothing is in front of the sensor, the detector holds the output low (0.40volts). When we put a PCB in front of the sensor, the output changes to high-impedance and the pull-up resistor (R1) holds the signal high (5volts).

Why open collector?

An open collector output doesn’t toggle between high and ground, it toggles between ground and unconnected. The unconnected state, also called high impedance, exerts nothing on the output and allows the signal line to float. This is an undefined state for most microcontrollers that returns rapidly varying values, so we use a resistor (R1) to hold the signal high. The open collector output overcomes the small amount of current flowing through resistor to register the low state. Without this resistor, the output will never reach a proper high state.

Open collector outputs are useful when several sensors need to share the same microcontroller pin. Multiple sensors outputting high to the same microcontroller pin is generally considered a bad practice that can damage parts of a circuit. Multiple open collector outputs, however, can only switch to ground; a single resistor holds the signal high. In the case of multiple GP2Y0D02s, the signal will be high only when all connected sensors detect an object and switch to high impedance state.

Like this post? Check out the parts posts you may have missed.

19 thoughts on “Parts: Digital Proximity Sensor (Sharp GP2Y0D02)

  1. I love these sensors but I have not purchased any yet since the cost seems much higher than it should be. I would like to see these come down to the $3 or $4 price point. Nice work on breaking it down Ian.

  2. When you test the analogue version could you please please test how far and close you can register hand movement. I’ve found with other devices that hands return only about half as much IR as the white paper the manufacturers use, so I’d like to know if this is similar, worse)

    I’m planning a project using the analogue devices to detect hand wave gestures (three units placed in a line could detect wave right, wave left, wave top-left to bottom-right, middle stab etc!)

    Many thanks as always for great parts write ups..

  3. I used one of these and hooked it up to the head of a Roboquad or whatever, took control the motors and used it to give an image of what the robot could ‘see’, just converted it to analog and got the distance from the sensor to whatever the object was and moved the head in a grid like fashion to determine distance to objects between small degrees. I then sent the data back to my laptop and painted a grey-scale image of it. Only problem I had was since they were just normal DC motors the weight of the head after attachment with some brackets caused it to dip.

    It was pretty snazzy.

  4. @dielectric:

    Fella, don’t kid yourself. There are things you could try. Acid for his visual system, noise for his hearing. No matter what, he’ll always be one jump ahead of you!

    You haven’t got a chance.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.