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.

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.

19 thoughts on “Parts: Digital proximity sensor (Sharp GP2Y0D02)”

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.

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.

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