# How to calculate size of filter capacitor for microcontroller that has changing loads on its 5V supply

How do I calculate the size of a filter capacitor to reduce the ripple when I have a microcontroller on the same regulated power supply as a high current load like an LCD strip or a motor controller? (I'm aware of the need to use flyback diodes on inductive loads.)

If I'm building a power supply that rectifies AC and filters it, there are lots of articles out there that describe how to calculate the size of the filter capacitor, e.g.: https://makingcircuits.com/blog/calculate-filter-capacitor-smoothing-ripple/

The formula for that is C = I / 2 x f x Vpp, where I is the load current, f is the AC frequency (usually 50 Hz or 60 Hz, and Vpp is the allowable ripple.

All the searches I've done lead me to articles about filtering ripple on AC power supplies.

However, I'm not trying to smooth ripple from a rectified AC supply. I'm trying to smooth out variations in an already regulated 5V supply as the load to the supply changes.

Say, for example, I have a regulated 2A 5V supply that's driving a 1.5A LED array AND an Arduino-based system that draws ≈200mA. I am feeding the 5V from the supply into the Arduino, and also using it to drive the LED array. I'm under the 2A limit of the regulated supply, with a little "wiggle room", but concerned that as the LED array turns on and off, it will cause droops and spikes in the regulated 5V supply as the power supply lags slightly in adjusting the output voltage for changes in load.

Assume the Arduino can tolerate ±0.5V on it's 5V supply. I imagine the LED array's load spikes are going to be nearly instantaneous, like switching on and off a resistive load. (Assume the 5V supply is a typical switching supply. I don't know how to estimate its max voltage variation under changing load, or recovery time, and need help with that bit.)

How do I calculate the rating of a filter capacitor to put on the 5V rail that feeds the Arduino to smooth its input voltage as the load to the power supply changes?

• Without going into many details, if you are designing the PCB, you could scatter some decoupling caps near the local feed to the Arduino and the LED strip. Usually values of 0.1uF, 0.01uF work well. That way, for sudden current demands, the decoupling caps, will source the current, at least for those short intervals of time, until the main supply catches up.
– Big6
Jul 7 '19 at 15:23
• It will be highly dependent on the characteristics of the switching regulator. How well does it respond to transients (related to loop bandwidth)? For a low-cost regulator, this data isn't usually in the datasheet, you may need to measure it yourself. For a hobbyist, create a worst case current variation, add bulk capacitance until you get the voltage variation that you can live with, add 50% or 100% to the cap value for margin. Jul 7 '19 at 15:52
• If you want 1Amp load to cause 1 volt sag in the capacitor voltage, over 1 second, you need 1 Farad. Jul 7 '19 at 16:14

Here is a first order calculation, ignoring cap ESR and other secondary effects. And assuming that your switching regulator is already chosen, and it is a budget off-the-shelf module. If you are doing a rigorous design from scratch, use Sunnyskyguy's answer.

$$\ v = \frac 1 C \int i dt \$$

If i is a step from one constant current to another, we can simplify:

$$\ \Delta V = \frac{I_{step} \Delta T}{C} \$$

Solving for C:

$$\ C = \frac{I_{step} \Delta T}{\Delta V} \$$

I is the current step, delta V is the allowable voltage sag. Delta T is the regulator recovery time from a step current change, i.e. how long the cap needs to hold-up the voltage until the regulator closed-loop recovers.

Example: I = 1.5 A, delta V = 0.5 V, delta T = 1 mS

The regulator dynamic recovery time is usually not going to be included in a budget regulator data sheet. And if it is, it may be specified another way. 1 mS is a wild guess, you need to measure it by applying a step current change and looking at the voltage with a scope.

C = 1.5 * 0.001 / 0.5 = 3000 uF

A Rubycon YXJ 3300 uF, 16 V, has an impedance of 0.032 ohms, this is small, but not quite negligible for this application. 1.5 A * 0.032 ohms will add another 48 mV to the sag.

And remember, this is an approximation, we don't know what is inside the switching regulator, it already has capacitance included, most likely small compared to 3300 uF if it is a modern high frequency converter.

Load regulation error is defined by design as the drop in voltage for rise in current. The current is defined as the rise in current for drop in resistance.

Thus the load regulation error becomes a ratio of source impedance to load impedance x 100%. ( for both static and dynamic loads to avoid excessive (TBD) sag and spikes)

Since the regulator uses negative feedback sensing the output voltage, it’s effective ESR depends on the series resistance internally divided by the feedback gain. Each regulator has stability restrictions on load capacitance/reactance based on its internal design. This can be decoupled with a series L to a larger C when necessary but beware that this creates a high Q resonant circuit that must be kept away from dynamic loads being commutated at some frequency.

• when the loads are reactive or nonlinear, we must consider the ESR of all caps and the DCR of all inductors , motors and LEDs as smallest effective resistance to voltage changes with pulsed currents.
• thus bulk C to switched C loads have a C ratio and an ESR ratio that can affect load regulation error.
• high power LED’s may use current feedback or resistive forward drop that raises this load Rs or ESR impedance.
• motor loads and inductors generate a back EMF current with a voltage proportional to the current thru the reactor or the speed of the motor. (kV/RPM - I*DCR)
• Schottky power diodes return the flyback energy slower due to the L/ESR =Tau time constant but with lower loss, yet not as low as FETs acting as ideal diodes in a synchronous pulsed Load such as a full Power FET bridge for driving Motors.

• generally the RdsOn and ESR’s and DCR must be <1% of rated Load for high efficiency

• Motor DCRs are usually 10% of equiv rated Load resistance. e.g. 5V motor at 2A will draw 20A surge from large caps with an ESR <5% of Vdd or 250mV/ 20A= 125uOhms which is an expensive solution, so a bigger current regulator requires a smaller capacitor.

These are all hand waving arguments to help you define real specs and problems that are more easily solved, once all the unknowns , functional specs and I/O parameters are quantized for an interface spec for a given budget.

This design should also include a power loss and input&load regulation error budget. High f spikes ripple must only be measured using Cap coupled 50 Ohm coax. With test pins nearby for easy of probing and a 50 Ohm load on a BMC T connector or in the DSO option menu.

Then and only then can a perfect design follow.

• for unregulated inputs V , I use Tau= 8/f = RC for load V/I=R for 10% ripple but you must consider dropout and Vmin input requirements and f =100 or 120Hz after bridge.