Go Down

Topic: Open Drain (Read 4851 times) previous topic - next topic

Firefox

To put an Arduino Input/Output into Open Drain mode I assume I do the following.

Set the Pin as an Input

Send the Input HIGH to present a High Impedance at the Input

Send the Input LOW to Sink current

Can someone please confirm I have this right or otherwise.

MAS3

No.

Open drain means you have an output, so you'd need to set it up as such.
Setting it HIGH means it will put 5 volts to that pin.
Setting it LOW means it will connect it to GND (0 volts).
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Firefox

They (the electronics world) call it an Output!! but if you google Open Drain the explanation is that it can only Sink current or present a High Impedance so it cannot output anything. :) The Output definition is very confusing.

retrolefty


They (the electronics world) call it an Output!! but if you google Open Drain the explanation is that it can only Sink current or present a High Impedance so it cannot output anything. :) The Output definition is very confusing.


Open drain, like open collector outputs are used where the external circuitry determines what the HIGH output voltage needs to be and then the open drain output can turn it LOW by turning on and the output signal goes to ground. There is a real world place for open drain/open collector outputs Vs full push-pull output pins. Simply wiring an external pull-up resistor will convert a open drain/open collector output pin to a standard output that you seem more comfortable with.  ;)

One good example for the need of open drain output pins is the AVR chip's I2C clock and data pins when I2C is engaged. These two pins have to be able to switch from input or output mode to support bi-directional communications on these two pins, and they need to be open drain outputs so the external pull-up resistor can determine the logic voltage level to use with specific I2C chips.

Lefty

Grumpy_Mike


They (the electronics world) call it an Output!! but if you google Open Drain the explanation is that it can only Sink current or present a High Impedance so it cannot output anything. :) The Output definition is very confusing.

No it is not.

Sinking current IS an output. Just like sourcing current is an output.

There is no open drain or open collector configuration in an arduino. If you want one you have to use an external transistor or FET.

retrolefty



They (the electronics world) call it an Output!! but if you google Open Drain the explanation is that it can only Sink current or present a High Impedance so it cannot output anything. :) The Output definition is very confusing.

No it is not.

Sinking current IS an output. Just like sourcing current is an output.

There is no open drain or open collector configuration in an arduino. If you want one you have to use an external transistor or FET.


Well except if you enable the I2C hardware, then it's two signal pins will be open drain when in output mode.

Lefty

Nick Gammon

Can't he just use INPUT/LOW as high impedance, and switch to OUTPUT/LOW to sink current?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

"Can't he just use INPUT/LOW as high impedance"

That's what is needed if the internal pullup resistor is to be unconnected.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Firefox



They (the electronics world) call it an Output!! but if you google Open Drain the explanation is that it can only Sink current or present a High Impedance so it cannot output anything. :) The Output definition is very confusing.

No it is not.

Sinking current IS an output. Just like sourcing current is an output.

There is no open drain or open collector configuration in an arduino. If you want one you have to use an external transistor or FET.


It may not be confusing to you but it is to me.

Doesn't Sinking Current mean the current is going into the Pin?

If you I set the Arduino digital pin as an Input, and set it LOW, will it Sink Current?

If you I set the Arduino digital pin as an Input, and set it HIGH, will it present a HIGH Impedance?


Nick Gammon

Quote
If you I set the Arduino digital pin as an Input, and set it LOW, will it Sink Current?


No it won't. It will be high impedance.


Quote
If you I set the Arduino digital pin as an Input, and set it HIGH, will it present a HIGH Impedance?


It will be high impedance with an added approximately 50K pull-up resistor.

To sink current it has to be OUTPUT mode and LOW.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

Quote
Doesn't Sinking Current mean the current is going into the Pin?


Yes. If you have it output/low it will attempt to make that pin 0V, thus sinking any current going into it. It will succeed in comfortably sinking around 20 mA.

If it is output/high it will attempt to make that pin 5V, thus sourcing that current. It will succeed in comfortably sourcing around 20 mA.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

Arduino digital pin as an Input, and set it LOW, will NOT Sink Current. Its an input. Setting it low only disables the internal pullup resistor.  That will be the High Impedance state.

Arduino digital pin as an Input, and set it HIGH, will turn on the internal 20Kto 50K pullup resistor.  Pretty high impedance, but still capable of outputting some current (like 1/4 of a mA, not much, but enough to pull a switch high, or make a sensitive LED appear to be dimly on).
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Nick Gammon

Try this experiment with two LEDs:



One connects pin D8 to +5v. Thus for the LED to come on D8 has to sink current.
The other LED connects pin D9 to Gnd. Thus for the LED to come on D9 has to source current.

Run this sketch:

Code: [Select]
void setup ()
 {
 pinMode (8, OUTPUT);
 pinMode (9, OUTPUT);
 }  // end of setup

void loop ()
 {
 digitalWrite (8, LOW);
 digitalWrite (9, LOW);
 delay (500);
 digitalWrite (8, HIGH);
 digitalWrite (9, HIGH);
 delay (500);
 }  // end of loop
 


The sketch turns D8 and D9 on and off at the same time, but the LEDs blink alternately. The D8 LED lights up when D8 is LOW, and the D9 LED lights up when D9 is HIGH.

Both pins are output.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Firefox

Excellent, thank you for all of your help.

CrossRoads

Add a 3rd state, D9 as input with pullup enabled.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up