Offline
Newbie
Karma: 0
Posts: 38
|
 |
« on: February 03, 2013, 04:54:23 pm » |
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
Sr. Member
Karma: 9
Posts: 331
|
 |
« Reply #1 on: February 03, 2013, 06:09:15 pm » |
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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #2 on: February 03, 2013, 06:14:26 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #3 on: February 03, 2013, 06:25:55 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25517
Solder is electric glue
|
 |
« Reply #4 on: February 03, 2013, 06:29:04 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #5 on: February 03, 2013, 06:31:30 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #6 on: February 03, 2013, 07:37:44 pm » |
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
Brattain Member
Karma: 249
Posts: 16540
Available for Design & Build services
|
 |
« Reply #7 on: February 03, 2013, 08:59:34 pm » |
"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
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #8 on: February 03, 2013, 09:14:26 pm » |
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?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #9 on: February 03, 2013, 09:22:47 pm » |
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. 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
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #10 on: February 03, 2013, 09:26:51 pm » |
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
Brattain Member
Karma: 249
Posts: 16540
Available for Design & Build services
|
 |
« Reply #11 on: February 03, 2013, 09:29:44 pm » |
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
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13896
Lua rocks!
|
 |
« Reply #12 on: February 03, 2013, 09:43:46 pm » |
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: 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
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #13 on: February 03, 2013, 09:46:00 pm » |
Excellent, thank you for all of your help.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 249
Posts: 16540
Available for Design & Build services
|
 |
« Reply #14 on: February 03, 2013, 09:57:57 pm » |
Add a 3rd state, D9 as input with pullup enabled.
|
|
|
|
|
Logged
|
|
|
|
|
|