Let's Make Robots!

sensible discussion on "open collector circuit" for sensor

Just found this on hackaday:

" ... 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.
Open collector outputs are useful when several sensors need to share the same microcontroller pin. ..." (my emphasis)


More in the article about a sharp IR proximity sensor, with video and this circuit diagram.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Yes you can connect more then one open collector output device to a single input to save pins but you loose the ability to determine which sensor is registering. The only real advantage is if you need multiple sensors to measure over an area greater than one alone can cover in which case there are cheaper / better ways such as mounting the sensor on a servo.

If you need to connect several analog devices to a single input due to lack of analog inputs then a cmos bi-lateral switch is a much better choice. They are cheap, easy to use and designed for analog signal.

Latency would be a good reason for having multiple sensors cover an area as opposed to a panned single sensor. Several of the Sharp sensors take about 40 ms for each reading, about 25 per second. My new favorite little sensor panning servo takes about 120 ms to cover 60 degrees. So if I used 3 Sharps, I could get an area reading in 40 ms compared to taking 120 ms to cover the same area. It gets a little worse when realizing that the sensor has to be panned back to recheck the side again 240 ms later.

So why is this bad? Well, if you have a robot that can travel around 150 cm per second, that 80 cm detection range of the GP20Y0D02YK means that there is less than half a second to react to a detection, at best. If a servo has panned the sensor to the other side at just the wrong time, that half second can be cut down to a quarter second (using the 240 ms above). Adding other little bits in there like inertia and skidding shows a good chance of the robot probably hitting what was hoped to dodge if using panned sensors, but maybe having just enough edge to get around an obstacle if several static sensors are used. As you implied though in knowing "which sensor is registering", there needs to be at least 2 side areas of coverage, maybe 2 sensors per side so the robot can be programmed which way to dodge.

Another possible reason might be efficiency. If wanting to build an endurance robot, running as long as possible on battery power, possibly augmented with photovoltaics, then running 3 Sharps at 33 mA each for 100 mA total, compared to 1 Sharp panned by a 100 mA servo for a total of 133 mA, there might be a slight advantage for multiple sensors. If I were going for efficiency though, sonars would be a much better choice. This is not so great a gain here, so may not be worth worrying about.

Pretty cool to see the bilateral switch, good chip that could come in handy sometime.

interesting.. How does one make it switch? By an output?

The line called "output" is attached to the micro controller's ADC input pin.

When several of these sensors are connected to the same ADC pin, the MCU would register the highest value of all connected sensors. In this case the sensor that registers the nearest object.


The GP2Y0D02 is a digital sensor, not an analog, so would go to an IO pin, not an ADC pin. They are pulled up, as in the diagram and article, and switches low when something is reflected closer than 80 cm, floating to be pulled up when nothing is detected. You could use it on an ADC pin, but you'd never get a value other than ground or 5 volts.

I'm not aware of an analog output sensor that is open collecterr, and not sure it would be possible.

But how is the "multiple sensors on one pin" still an improvement?

The pin would go high when one of the sensor registers an object nearer than 80 cm?

The last paragraph of the article :

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

Most of the Sharps have a narrow beam of detection, on the order of a 5 to 15 degree spread. If you have a wide robot, one side or the other or even the middle might overlook an obstacle. So you could have 3 (or more) sensors connected to a single IO pin, to detect "Obstacle Ahead" without all three overloading fighting each other since they all are open collector. 1 or 2 or all 3 could have a hit, and the micro pin would have the same low, and none of the of the sensor would be trying to pull high since they  can't being open collector.

Damage would occur with active outputs, where one tried to output a high, while another tried to go to ground, causing a direct short that one or both of the 2 sensors would lose and be fried.