Electronic – Sinking 80 mA with a microcontroller without any driver circuit


I was wondering since a micro controller can sink 20 mA on each pin, if I can make 4 pin ports low by software, and just connect the positive side of the load to Vcc, is this a reliable methodology for driving larger loads? Would the only thing to worry and pray about is that the machine cycle is fast enough to handle the fluctuations of setting all the pins at the same time? Am I on the right track?

Best Answer

It should work just fine, but You need to keep in mind a few things.

  1. Max VCC or Max GND current. There is a maximum current that the microcontroller can support through its VCC or GND pin.
  2. Max Port current. An individual port has a maximum current as well.
  3. Pin ESR. A GPIO Output will have a voltage drop (or rise) based on how much current is going through it. Typically, the recommended max current through the pin is for a given output voltage compared to VCC or GND.

enter image description here
Ex: The MSP430G2xxx family Voltage Output Low will rise 1 Volt from Gnd, at ~30mA.

If your load is within these specs, which your 80mA load example should be for ATMega micro controllers, then the other concern is preventing shorts.

You need to ensure that you change the entire Port at once, instead of one pin at a time. If you change only one pin at a time, from Low to High or High to Low, then you can create a dead short between the pins, blowing one or more of them. Depending on the default state of the pins when starting up, before your code can set them, this may not be avoidable without extra parts. Also try to keep it isolated to a single port, as it will be difficult to change multiple ports at the same time, and voltage differences between ports may hurt.

Typically, having series resistors on the pins will help. These resistors will end up in parallel with each pin as well, which helps regulate the current between them.

Assuming you want the 80 mA load equally on 4 pins, then that's 4 extra parts, as protection. At that point, you may as well just go with a single transistor + resistor pair.

With careful coding, you should not need these, and parallel gpio will work fine as current sinks.

Open Collector outputs, which can only pull low, do not have issues with shorts, but should still be changed at the same time. Not changing them at the same time can lead to the current though just a single output, which will cause issues if there is no current limiter. A typical microcontroller GPIO is not Open Collector, but you can mimic it by only switching between Output Low and High-Impedance Input mode.