Energy budgets are especially useful when you have circuits with parts running at different voltages: one that takes power from a 3.7V LiPo but has some pieces running at 3.3V while others take 5V from a PowerBoost, for instance.

As a matter of fact, battery life for that kind of circuit can change depending on how you make the power connections. We'll get to that in a bit, but first let's take a look at switching converters like the Adafruit PowerBoost.

## DC-to-DC converters

Switching converters get their name from the fact that they literally open and close switches to change one voltage to another. The switches are connected to an inductor, and the magic happens as energy moves into and out of the inductor's magnetic field.

Over the long term, all switching converters are constant-power devices: you have to send 1W into an ideal switching converter to get 1W out of it. The input can be 303mA @ 3.3V and the output can be 200mA @ 5V, or vice versa. As long as the voltage and current multiply to the same amount of power on both sides, the math works.

No real switching converter is perfect though, so you have to send more power in than you get out. The PowerBoost is at least 90% efficient, for instance, so it's safe to assume 1.11W of input will guarantee 1W of output.

Over the short term, switching converters are constant-energy devices that use PWM, doing the same amount of work in each part of the duty cycle.

To use the PowerBoost as an example, let's say we have a circuit that needs 100mA @ 5V.

The PowerBoost starts by closing the switch that connects the 3.7V LiPo to the inductor, and lets power flow in for 15 microseconds. During that time, the average current is about 250mA (trust me.. I've already run the numbers).

If we multiply the voltage, current, and time we get 13.9uJ of work, and about 95% of the energy from that work gets stored in the inductor's magnetic field:

Input 95% stored |
3.7V - |
250mA - |
15us - |
13.9uJ 13.2uJ |

Then the PowerBoost opens the switch to the LiPo and closes the output switch for 10us. The same 250mA average current flows out, with about 95% of the energy stored in the inductor's magnetic field (12.5uJ) pushing it.

If we divide that 12.5uJ of energy by 10us of time and 250mA of current, we get an output voltage of 5V:

Input 95% stored 95% released Output |
3.7V - - 5V |
250mA - - 250mA |
15us - - 10us |
13.9uJ 13.2uJ 12.5uJ 12.5uJ |

*(the 95% stored and released energy values are sleight of hand, by the way. I said the PowerBoost is at least 90% efficient, and the square root of 0.90 is about 0.95. Applying the same scaling factor twice gives the correct result while helping to show where the energy losses occur)*

The input and output currents are both examples of PWM, so we can use what we learned about that to calculate the average currents:

The 250mA input current only flows for 15us per cycle, for a total of 3.75uC of charge. Each PWM cycle lasts 25us, and if we divide 3.75uC by 25us, we get an amortized input current of 150mA.

The 250mA output current only flows for 10us per cycle, for a total of 2.5uC of charge. Dividing that by the 25us cycle time gives us an amortized output current of 100mA.

If we amortize the work done during the input and output phases, we get 556mW of input power and 500mW of output power:

Input 95% stored 95% released Output |
3.7V - - 5V |
250mA - - 250mA |
15us - - 10us |
3.75uC - - 2.5uC |
13.9uJ 13.2uJ 12.5uJ 12.5uJ |
150mA - - 100mA |
556mW - - 500mW |

The actual conversion is done by moving the same amount of energy in different amounts of time. The amortized values of the duty cycles make the same average current through the inductor, and slightly decreasing energy, look like different voltages and currents at the input and output.

You can use the same calculations in circuits that use step-up or step-down converters of any value.

## Now about those connections..

If you're building a hybrid 3.3V/5V circuit that gets its power from a PowerBoost, it's natural to ask whether you should connect the 3.3V side directly to the LiPo or to use the 5V supply.

Let's run the numbers, assuming the 3.3V circuit wants 100mA:

If we take power directly from the LiPo, the 3.3V circuit burns off an average of 0.4V in its voltage regulator, for a power loss of 0.4V x 0.1A = 40mW.

If we use the 5V supply, the PowerBoost has to draw an average of 150mA from the LiPo, and will lose up to 10% of that during the boost process. Using the numbers above, 1.4uJ/25us = 56mW of loss getting the 3.7V up to 5V.

Then the 3.3V circuit's regulator has to burn off the excess 1.7V, which produces 1.7V x 0.1A = 170mW of loss. Adding that to the 56mW lost in the PowerBoost gives us a total of 226mW loss.

Using the PowerBoost's 5V output to run a 3.3V circuit wastes more than 4x as much energy as running the 3.3V circuit directly from the LiPo.