Introduction: Sinking Vs Sourcing Current in Arduino
In this Instructable we will look at the difference of sourcing and sinking current through an Arduino.
Supplies
Arduino Uno - http://s.click.aliexpress.com/e/bQBs0U9a
Resistors - http://s.click.aliexpress.com/e/ogMHBoc
Step 1: Sourcing Current
When working with an Arduino on a project and you need to control a digital output, they can have one of two states. The output can either be high, or low.
When the output is pushed high, the full supply voltage is applied to the pin and this can then be used to power an LED or turn a device on depending on the project. This configuration is called sourcing where the current source is the Arduino. This way the current exits the power source, enters the Arduino and then enters the load.
Step 2: Sinking Current
In the opposite situation when the output is pulled low, we can no longer source current but current can still flow through it. If we now connect the LED with its positive connection to the power source and connect the cathode to the Arduino pin that is pulled low, current will once again flow. This is called sinking where the current first flows through the load and it is then connected to ground via the digital pin on the Arduino.
Step 3: Comparison and Usage
In both ways, the same limitations will apply. The Arduino Uno has a maximum current limit of 40 mA but should not be handling more than half of that for extended periods of time. Both sourcing and sinking have exactly the same effect on the chip and can be used depending on the configuration and the requirements on the circuit.
From what I’ve seen, sourcing is more commonly used but if you have a project where you are sinking current, I would love to see it so let me know down in the comments. If you liked this Instructable then subscribe to my YouTube channel and follow me here on Instructables.
9 Comments
1 year ago on Step 3
IMO this article would be clearer if you labeled the circuit diagrams "sink" and "source". As it stands in the title graphic source is on the left and sink is on the right, but the text title is the opposite ("sink vs. source" - sink is on the left).
Also I would switch the color of the wires in one photo. When sinking current, it would make sense to have the wire to the output pin be black, since it's serving as a ground for the load.
Reply 1 year ago
Hey, thanks for the feedback. If I decide on updating the article I will include it.
2 years ago on Introduction
Hi, thanks for the info
nice to know about the sourcing or sinking capability.
I like to drive an analog meter with two PWM ports.
The analog indicator has a dial in the mid position and with positive current of 0.5mA I have full scale left. and with -0.5mA i have a full scale right.
So I use port 5 as a 'zero' at analog write 128 and drive port 6 from 0 to 255
so the max voltage is 2.5 + or - and with a 4k7 resistor I limit the current
The only thing I am still puzzling is that during start-up or fault conditions there can be 5V and thus double current when port 5 is 0 and port 6 is 255. this may damage the analog indicator.
Tips for protecting my analog indicator are welcome
regs
Hans
Reply 1 year ago
You can use a voltage divider as someone else suggested as follows: limit the voltage on both pins 5 and 6 to 2.5v. When you need 2.5v the indicator, pin6=255 and pin5=0. When you need -2.5v, pin6=0 and pin5=255. If your code has a 0-255 range for the signal, pin6=signal, pin5=255-signal.
Reply 2 years ago
Use a voltage divider with resistors and power the meter from that. That way you can work with the 5V at all times and your meter will be safe. Plus, the added resolution of the 5V will make the control more sensitive and precise.
Reply 2 years ago
OK thnx,
I am considering that, however with an added emitter follower, so that changes in the current through the analog indicators does not change the the 2.5Volt reference.
Reply 1 year ago
I don't see how adding a voltage divider helps. Pin 5 must be capable of producing 5v since your reference is 2.5v and your meter swings between -2.5 and 2.5. So even with the divider, if pin 5 is at zero and pin 6 is at 255, you'll still have a 5v swing. I suspect you're running into a problem because your pin initialization code isn't quite right. Set the reference voltage (pin 5) before setting the control voltage (pin 6). If you're still concerned about your software going haywire, you could use a zener on the control pin to prevent overvoltage.
1 year ago
When driving common anode LEDs (e.g. RGB LEDs), it is necessary to tie the cathodes to a current sink. The ULN chips are high current darlington chips that do this. Current sinking chips such as these are for more common and less expensive than their sourcing counterparts.
Reply 1 year ago
Thanks for sharing this!