What is an "open drain" ?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2007
    Posts
    67

    Default What is an "open drain" ?

    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!

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    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.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  4. #4
    Join Date
    Aug 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    Oct 2005
    Location
    Pinckney, Michigan
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    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.
    Last edited by J. Mark Wolf; - 12th September 2007 at 01:21.

  6. #6
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    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=118956013 6">

    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!
    Attached Images Attached Images  
    Last edited by RussMartin; - 12th September 2007 at 06:52.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  7. #7
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    Join Date
    Jan 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: What is an "open drain" ?

    thanq sir...

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts