Pages: [1] 2   Go Down
Author Topic: Open Drain  (Read 4131 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 50
Posts: 1717
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley The Output definition is very confusing.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley 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.  smiley-wink

 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
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 637
Posts: 34599
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley 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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley 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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Can't he just use INPUT/LOW as high impedance, and switch to OUTPUT/LOW to sink current?
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

That's what is needed if the internal pullup resistor is to be unconnected.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley 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?

Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 506
Posts: 19120
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Excellent, thank you for all of your help.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Add a 3rd state, D9 as input with pullup enabled.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1] 2   Go Up
Jump to: