Parts: Digital proximity sensor (Sharp GP2Y0D02)

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.

Comments

  1. Andrew says:

    I love these parts tutorials/discussions. Keep ‘em coming!

  2. cde says:

    LadyAda was able to modify one of these digital sensors into it’s analog counterparts, so instead of an on/off toggle if something is in the way, it will output a voltage proportional to the distance of the object in the way.

    http://www.ladyada.net/rant/2008/10/quick-tip-analog-signal-from-a-digital-distance-sensor/

  3. chris says:

    You’re efforts are appreciated ian

    also, thanks for the link cde

  4. I also like the Parts sections, just need more money to try myself. I was all excited about this one until I saw the price tag…

  5. andrew says:

    love the parts!

  6. Alan says:

    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.

  7. Ian Lesnet says:

    @cde

    Interesting link. We also have the true analog version, we’ll demonstrate it soon.

  8. Grovenstien says:

    Um wasn’t a device like this attached to a roland 808 type thingy and used like a theramin?

    Wooa oo woo aa woooh!

    Im sure i played with one in a mind altered state!

  9. fractalrock says:

    Neat stuff, thanks for the info and video.

  10. horsedung says:

    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..

  11. Robotatron says:

    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.

  12. EdZ says:

    Not quite as cheap as ultrasound proximity detectors can be, but far more reliable (jingling your keys will seriously screw with ultrasonic transducers).

  13. Jules says:

    I think this kind of sensor need to be integrate to roomba washer / cleaner instead of hitting a wall and make very noisy sound for my neighbors.

    Jules

    http://www.openprox.info

  14. dielectric says:

    @edz: good to know about the jingling keys if I have to defend myself against killer robots. They usually have ultrasonics, right?

  15. Andrew says:

    Is the sensory really that slow or is that just the multimeter?

  16. Ian Lesnet says:

    From datasheet (page 1):

    Typical response time: 39 ms

  17. jimmys says:

    @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.

  18. Wwhat says:

    hah I have the exact same super cheap multimeter, I feel better now (although it’s not the only one I have)

  19. adair says:

    Ola gostaria de saber , com teste sensores no dka3
    Tem alguma dica ai pra mim .
    abraço adair miranda.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 93,799 other followers