The limit is 40mA output from the pin, but I'm pulsing out at 50% duty so the average voltage would be 5 x 50% = 2.5v. This changes the calculation for the external resistor... or does it?
That is, should we use average volts for this calculation, or max voltage pulse?
It depends on the load and goal. LED, motor and other consumers have a different relationship between duty cycle and voltage, current or power.
IMO an external (current limiting) resistor should be chosen for maximum current at 100%. Reduced duty cycle has different effects on different load types.
A stable DC voltage requires an (RC) low pass filter. In this case the resistor value depends on C and the impedance of the following stage.
For the Arduino Uno/Mega/Nano/Leonardo, the maximum current is 40 mA.
It can not give more current, even if there is only a 1µs pulse per year.
In theory the chip gets damaged at 40.001 mA.
However, it is better to keep 20mA as maximum, because at 40 mA the voltage drops. It is no longer 5V.
If you want to replace your board with a newer board that can do only 8mA, then you are in trouble. Can you add a transistor or mosfet or driver for 40mA ?
The real maximum output current can be between 50 and 60mA per pin, and the chip might still work (or not). But that is beyond the datasheet.
It is possible to tie a whole Port of 8 pins together and then change all the pins at the same time. That can drive 6 * 40mA = 240mA (6 instead of 8, because the Uno has 6 available pins for PortB and PortC and 8 pins for PortD). So you can make a H-Bridge with PortB and PortC to drive a motor that has a stall current of 240mA.
It will work, but I wonder for how long
All –
I'm not looking to take more than 40mA, I'm looking at 30mA max. If I use a DMM and measure the voltage on the pin I have 2.38v output (not sure why it's not exactly 2.5v, perhaps bad soldering). I'm pulsing out through the pin at 50% duty cycle. So the average voltage output on the pin is 2.38v. Let's say I want 30mA output from the arduino pin to turn on a semiconductor to a decent level. If I 'presumed' the pin output was 5v and calculated the resistor between them I would end up with half the current I need for the semiconductor. If I calculate my resistor on the average voltage I end up with the correct current to my semiconductor (which is acting as a switch). Many components will have a max continuous current and also a pulsed current max. It seems everyone is agreed with the 40mA limit from the Pro Mini pin but is this continuous, or pulsed? I'm presuming the pulsed max is higher and the semiconductor is turning on nicely and all is working fine.. for now.
@Koepel - thanks for the idea of using the pins in parallel for greater output, that's something I might experiment with.
If the datasheet says 40mA, then it is 40mA. No matter if that is continuous or only a short pulse. As I wrote, the real (short circuit) maximum current is between 50mA and 60mA, regardless if that is continuous or a pulse.
It is not a single transistor or mosfet that can be pushed to its maximum. There is a whole circuit inside the chip. There is, for example, also a maximum current for the VCC and GND.
Your question: Is continuous output current the same as pulsed ?
My answer: It does not work that way.
O no, what have I done
Use the registers to write 0xFF and 0x00 to the output registers. I have an example somewhere, but I can not find it. [UPDATE] Found it: WholePORT.ino - Wokwi ESP32, STM32, Arduino Simulator
Did you know that when the AREF pin is internally set to DEFAULT, then it can give enough current to turn on a led (use a led + resistor of course). By selecting the internal 1.1V, the led turns off. Don't try that, it is not in the datasheet.
@ koepel With respect, the 'tech specs' (https://docs.arduino.cc/retired/boards/arduino-pro-mini#tech-specs) say 40mA DC and this is not necessarily the same thing as pulsed DC. Is there an actual datasheet somewhere? It depends on the internal component(s) that are at risk as to whether continuous or pulsed current is a factor. Example would be a resistor. Let's say the main concern is it's power dissipation. This will differs in regards to DC vs. pulsed DC. If we are protecting internal resistors as the 'first line' of defence behind the arduino pin then there would likely be a difference between pulsed and constant current specs. I'm not meaning to be argumentative but I would like to find more information on what internal components we are considering - or an actual statement regarding pulsed DC - to say "it doesn't work like that" still leaves me with these questions.
Regarding tying the Ports together for output.. thanks for clarifying. Is this a trick for the Uno only is it something for the Pro Mini too?
Guys, maybe I'm not communicating clearly. I can calculate dropping resistors, that's not a problem. It's the basis for the voltage element of the calculation that I have questions form the start of this post. Average current, and average voltage have different effects on different types of components.
Here's a hypothesis: the tech spec uses 40mA max direct current just to keep it simple because the first line components behind the pin (resistors probably) have a power dissipation capability of 5v @ 40mA, ie, 0.2 watts. After that they are burned out and expose other components behind them. Therefore using average volts and average amps is just fine because the limit we are dealing with is power dissipation in a resistor. This is just theoretical but can be settled if we had more details on the internal circuit.
Components usually have a rating for DC and pulses, usually the pulsed rating is much higher. If your PWM frequency is low, it would be equivalent to DC. l drive some leds with very high current, but with very short pulses at 1% duty cycle, no problem.
You're dreaming. The pin connects to GND and Vcc by MOSFETs. See Pin Driver Strength in the ATmega data sheets. Then you'll see that the voltage drop, and dissipated heat, increases with temperature in a positive feedback loop. For the effect on nearby components a detailed (3D) layout of the chip is required and a good circuit simulator that also can handle temperature distribution in a chip executing some specific program.
You may come closer to your figures if you overload output pins until they burn out, then test the next chip with reduced load for longer time, and try to find a relationship between output current and chip lifetime.
All the data sheet curves stop at 20mA I/O pin current and the data sheet specifically states that testing is done at 20mA and that higher currents don’t come with any guarantees and in fact may over stress the part.
You could email/call Microchip and ask them what the pulsed current rating is if they have one. Or you can keep waving your hands in speculation.
Another solution, as has been recommended is to buffer the output with a logic level MOSFET to get the current you want. You could consider an optocoupler with a higher current transfer ratio as well.
Bottom line is, it’s your chip. Treat it however you like and it will reward you in its own fashion.