PDA

View Full Version : What is an "open drain" ?



kevj
- 11th September 2007, 09:20
I see the note about a certain pin being an "open drain" in the data sheet. What does this mean? Does this only have to do with using comparators?

I'd like to use this pin to just read a simple TTL (+5v or 0v) input just like I'd do with any other pin. Does this "open drain" mean it'll behave strange? Also, what if I want to use it as an output and drive something like an LED?

Thanks!

Jerson
- 11th September 2007, 09:36
An open drain output does exactly what it says. Think of an open drain(not electronics). It can only sink people/things. In a controller, an open drain can only sink current. It will not source current. So, if you want to drive an LED, you got to have it sinking current into the pin. When the pin is in input mode, there may not be any obvious difference; however, you need to check the datasheet for the particular device you are using to be sure.

RussMartin
- 11th September 2007, 17:28
I don't know which device you have, but . . .

If you put a pull-up resistor (try 10K or 22K) on the open-drain pin, normally that allows it to work just like any other pin, whether input or output.

"Open drain" is the MOSFET equivalent of "open collector" for a BJT.

kevj
- 12th September 2007, 00:35
Hmmm..... well, thanks for the responses but unfortunately I didn't understand either of them (except for the "I believe button" of adding a pull-up per Russ), but I still don't understand what's happening that would be effected by placing the pull-up.

Maybe a better question is "how is it different than the other standard I/O pins". I'm not even sure how to ask the question.

So it "drains" current I guess - from where and to where? If I put a voltate on that pin, say 3v with no resistance, will it "drain" through the PIC and out the Vss pin? Could I theoretically cook the PIC that way?

When I use a normal I/O to power an LED, it should be "draining" current from inside the PIC to that pin and down the wire to the load, so I don't know why a normal I/O wouldn't also be considered an "open drain" in this case.

Still confused.

J. Mark Wolf
- 12th September 2007, 00:53
An open-drain can only drive a signal low (sink current). It cannot drive a signal high (source current).

If you ever need an open-drain pin to go high, you must have a pull-up resistor connected between the open drain pin and a voltage. This resistor is what would give you the high voltage at the open drain pin.

Think of it his way, if you want to light an LED with an open drai pin, the anode of the LED must be tied to say, +5 volts, through a series resistor, and then you can drive the cathode of this LED low (lighting the LED) with an open-drain pin. This is called "sinking" current.

You cannot, however, tie the cathode of the LED to ground through a series resistor, and drive the anode of the LED with the open drain pin. That would be called "sourcing" current, and an open-drain pin cannot do this.

RussMartin
- 12th September 2007, 02:29
Let me see if I can make it clearer. Forget all the technical terms like "drain" and "sink" and "source". Just think of switches:

<IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2010&stc=1&d=1189560136">

The top pair of switches are like an "open drain" or "open collector". When the switch is open, nothing can happen. When the switch is closed, whatever is connected to it is connected to ground. The "open circuit" end of the switch can give you either an open circuit (when open) or a connection to ground (when closed).

The bottom pair of switches show the effect of a "pull-up resistor". Now, when the switch is open, the voltage at "A" is 5 volts. When the switch is closed, the voltage at "A" is 0 volts. The switch can give you either 5 volts (when open) or a connection to ground (when closed).

Hope this helps!

ErnieM
- 12th September 2007, 20:56
I'd like to use this pin to just read a simple TTL (+5v or 0v) input just like I'd do with any other pin. Does this "open drain" mean it'll behave strange?

OK, open drain has to do only when a pin is used as an output. When you want to use the pin as an input then you are fine, the pin works completely the same as any other input pin.


Also, what if I want to use it as an output and drive something like an LED?

It can work as an output, but only as a switch to ground (as Russ's pic correctly shows). If you connect your LED from + power thru an appropriate resistor then to the open drain pin all will work fine.

krishnakanth
- 17th January 2013, 06:06
thanq sir...