We use cookies to provide our visitors with an optimal site experience. View our privacy notice and cookie notice to learn more about how we use cookies and how to manage your settings. By proceeding on our website you consent to the use of cookies.
If you are just starting out with electronics a term you may come across early on is “open drain”. It is very common in integrated circuits for output pins to be open drain. A datasheet for an IC will either state this for an output pin or show a functional circuit diagram with the output pin being internally connected to the otherwise “open drain” of an n-channel FET.
Open drain outputs require a pull-up resistor (R in the image above) for the output to be able to properly “output high”. The pull-up resistor is connected between the output pin and the output voltage (Vcc in the image above) that is desired for a high state. When the internal N-FET of the IC is off, R “pulls up” the output pin to Vcc and at that point only a very small amount of “leakage current” should flow through the N-FET transistor. When the internal N-FET of the IC is on, it “pulls down” the output pin to very nearly GND and the current flow is set by Ohm’s Law (I = Vcc/R).
The value of R should be large enough to limit current sufficiently so the output N-FET isn’t damaged (refer to IC datasheet ratings), but not so large such that it isn’t much smaller (generally orders of magnitude smaller) than the combination of any other impedances connected to the same output pin (usually just called “high impedance”). Similarly, Vcc must be within the datasheet given voltage ratings of the output pin.
I am a bit confused with regards to open-collector/ open-drain output pin.
I understand that:-
when the internal transistor is ON, the output would be LOW(0).
when the internal transistor is OFF, the output would be HIGH(1).
But what is my program supposed to write to the port bit ?
To get a LOW(0) output, should I make the bit’s value equal to 0 in the “code” or should I make it’s value 1. I mean, is it like we need to write the complement of the desired output value; 1 to get 0 and 0 to get 1?
Your question would be specific to the IC you are using. What is the part number of the IC you are talking about?
If you aren’t able to find the answer in the documentation for the specific part you are using, a very easy way to determine the answer would be to try writing each value to the “port bit” of the output pin you are attempting to toggle and physically measure the pin’s output state with a volt meter. Remember you would need a pull-up resistor correctly connected to the output in question, as explained in the original post topic.
An open-drain or open-collector output pin is driven by a single transistor, which pulls the pin to only one voltage (generally, to ground). When the output device is off, the pin is left floating (open, or hi-z). A common example is an n-channel transistor which pulls the signal to ground when the transistor is on or leaves it open when the transistor is off.
Open-drain refers to such a circuit implemented in FET technologies because the transistor’s drain terminal is connected to the output; open-collector means a bipolar transistor’s collector is performing the function.
When the transistor is off, the signal can be driven by another device or it can be pulled up or down by a resistor. The resistor prevents an undefined, floating state.