I2C uses open-drain pins. I did some googling and found out the reason is that open-drain/open-collector pins are bi-directional. What I don't understand is why are open-drain/open-collector terminals bi-directional? Can someone explain? Thank you very much.
Open Drain/Collector pins use the two logic levels FLOATING and LOW. You can connect a bunch of them to the same wire and as long as only one signals LOW at a time they can each control the wire separately. When all the outputs are FLOATING, the wire uses a pull-up resistor to bias the wire to HIGH. The result is a logical NAND of all the inputs: All FLOATING and wire is HIGH. Any one (or more) LOW and wire is LOW.
The Arduino's regular "Totem Pole" outputs will force the wire either HIGH or LOW. If two try to control the same wire and one is HIGH while the other is LOW they cause a short circuit and lots of heat.
To use an Arduino pin as "Open Drain" you just switch between OUTPUT LOW (LOW) and INPUT (FLOATING).
johnwasser:
Open Drain/Collector pins use the two logic levels FLOATING and LOW. You can connect a bunch of them to the same wire and as long as only one signals LOW at a time they can each control the wire separately. When all the outputs are FLOATING, the wire uses a pull-up resistor to bias the wire to HIGH. The result is a logical NAND of all the inputs: All FLOATING and wire is HIGH. Any one (or more) LOW and wire is LOW.The Arduino's regular "Totem Pole" outputs will force the wire either HIGH or LOW. If two try to control the same wire and one is HIGH while the other is LOW they cause a short circuit and lots of heat.
To use an Arduino pin as "Open Drain" you just switch between OUTPUT LOW (LOW) and INPUT (FLOATING).
Thanks. You are clearer than all the explanation I found on google.
as long as only one signals LOW at a time
furthermore, even if more than one signal is LOW at one time, this is not a circuit-damaging state. In fact, you get the logical "OR" function of all the connected signals - the bus state is LOW if A is low OR of B is LOW, OR if C is LOW, etc...
Actually you get the logical AND of all the connected lines.
Doesn't the and function require all three to be low? A & B & C?
Doc
The discussion of the Open Drain logic symbol can have two versions. AND with NOR are both logical ways to define the function of open drain and De Morgan's theorem shows how to convert them. The NOR symbol can have the first truth table while AND is defined in a second truth table:
0 = transistor not conducting as pulldown because gate of FET is grounded
1 = transistor conducting because gate voltage is 5
a,b gate inputs to NMOS/Resistor NOR
c output
abc NOR
001
010
100
110
abc AND
111
100
010
000
In other words, De Morganization inverted the inputs and output while converting form OR to AND logic gates. The - symbol is the inverted state
--
abc AND with inverted inputs
001
010
100
110
Conclusion
The logic that drives an open collector, multi-driver bus can select input inverters to result in AND logic or NOR logic. The question about, "Why are open-drain pins bi-directional?
This makes fuller use of the pins than unidirectional pins. The input direction has a CMOS gate circuit. The output direction has complicated logic that drives a single transistor to pull down the pin voltage to ground. The transistor is an n-channel MOSFET with its drain terminal pinned out to the IC package leads. There is no pullup in the IC. The output can only drive a '0' output bit. Any '1' bit cannot be set by the IC, an external resistor is used for the '1' output on the wire.
So the input and output directions are compatible to be used on an Arduino pin at the same time or at different times for input and different times for output for bi-directionality.