Pulse Width Modulation (PWM) is a convenient place to start thinking about energy budgets because it happens fast enough for the numbers to make sense.

When you pulse-width sending power to a device, you turn the power on and off, usually rather fast, controlling how long the power is on, then off - the time can vary to produce the effect you want.

For reference, let’s take something easy, like using PWM to control the brightness of an LED. The operating principle is simple: when the LED has power, it lights up. When it doesn’t have power, the LED stays dark. Let’s say the LED uses 10mA when lit.

Let’s also say the PWM frequency is 1kHz (the circuit controlling the LED emits a pulse every millisecond) and that a pulse can have any width between 0ms (always off) and 1ms (always on).

It’s easy to find the current for those two cases: if the LED is always off, the current is 0mA. If the LED is always on, the current is 10mA.

And to set the stage for what’s coming, if 10 milliamps of current flows through an LED for 1 millisecond, it means 10 microcoulombs of charge have gone through the LED (10e-3C/s x 1e-3s = 10e-6C).

Flipping that around gives us the fundamental idea behind energy budgets: if 10 microcouloumbs of charge flow through a component in 1 millisecond, the average current through the component during that millisecond is 10mA.

## Changing the duty cycle

Now let’s make each pulse last 990 microseconds (a 99% duty cycle). The amount of charge that flows through the LED is only slightly less than it was for the always-on case:

`10e-3C/s x 990e-3s = 9.9e-6C`

Dividing the charge (9.9uC) by the total pulse width (1ms) give us the average charge during that time:

`9.9e-6C x 1e-3s = 9.9e-3C/s = 9.9mA`

So the average of 10mA at a 99% duty cycle is 9.9mA.

## Flipping it around

If we reverse the output values so the LED only gets current for 10 microseconds (a 1% duty cycle), we could imagine that LED getting the power the first LED didn’t use:

`10mA - 9.9mA = 0.1mA`

which matches the value we’d calculate the long way:

`10e-6C/s x 10e-3s = 100e-9C`

`100e-9C / 1e-3s = 100e-6C/s = 0.1mA`

## Some other values

Now that you’ve seen the calculations a few times, we can apply them to other duty cycles:

It makes sense to think a 50% duty cycle (500us on, 500us off) would have half the average current of the always-on value:

`10e-3C/s x 500e-6s = 5e-6C`

`5e-6C / 1e-3s = 5e-3C/s = 5mA`

and that a 27.5% duty cycle would have that fraction of the always-on case:

`10e-3C/s x 275e-6s = 2.75e-6C`

`2.75e-6C / 1e-3 = 2.75C/s = 2.75mA`

## Doing it the easy way

By now you’ve probably worked out that the average current for a duty cycle is just the total current times the duty cycle. You can rearrange the calculations to prove that’s true, but seeing the pattern empirically is almost as good.

Knowing why it works, and being able to derive the calculations from the definitions of current and charge, is better.

This guide was first published on Jun 12, 2019. It was last updated on May 29, 2019.