# Computing stuff tied to the physical world

## Heat versus momentum

Now that we know that voltages need to match up: how can a voltage be changed ?

Let’s take the simplest example: say we have a power supply voltage of 5V and we want to make our circuit run at 3.3V. We’d like to “get rid” of 1.7V, somehow…

This is the domain of voltage “regulators”. The most common one is the linear regulator: it takes an input voltage, and throws away some part to get a fixed output voltage. Here is what it does, although the internal circuitry is actually completely different:

In this example, we have a known load of 1 kΩ and we’d like to run it at 3.3V – easy: if we set the adjustable resistor to 500 Ω, it’ll eat up one third of the incoming 5V, leaving ≈ 3.3V on its output pin.

The adjustable resistor is a simplification: in reality, regulators use a transistor to perform this task, plus a bit of extra circuitry to keep the output voltage constant even when the load changes. It does this by comparing the output voltage to an internal fixed voltage, and adjusting the transistor drive to always produce the desired 3.3V output level.

But the effect is the same as with a variable resistor: the excess power is dissipated, which is just another way of saying that the voltage x current is turned into heat.

Linear regulators are designed to waste energy!

If the input voltage is increased, the regulator will simply waste more energy. Powering this circuit from 9V or even 12V just makes the regulator get hotter (up to the point where safety mechanisms take over and cause the regulator to shut down and turn its output off).

Linear regulators are incredibly useful devices, but also awfully wasteful. Can we do better?

## Switching regulators

The answer is yes, by moving to switching regulators. To explain how they work, we need to take a few steps. The key idea is that we’ll turn a high voltage into a lower one by only connecting the power supply intermittently – on for a bit, off for a bit, in rapid succession.

Here are two circuits which explain the process:

Let’s look at the left one first: about 25% of the time, we connect power, the rest of the time we don’t. The diode eats up a little voltage, but basically just makes sure that power is not flowing back into the power supply while it’s off. The key trick here is the 10 µF capacitor, which acts as a tiny reservoir. It charges up when power is on, and then gradually discharges into the circuit when power is off. Here’s the result, cycling 10x per second:

The yellow line is the input voltage, the blue line is the output voltage. It’s not very constant, but as you can see, the average voltage is now 3.3V – there is no extra resistor in the circuit to dissipate energy, the power supply is simply off 75% of the time. No heat!

Here is the same circuit, but with an 80% duty cycle, i.e. power connected 80% of the time. As you can see, the capacitor still discharges, but it gets topped up a much larger part of the time. Now the average voltage is considerably higher – again without losses:

So by regulating the on/off duty cycle, we can adjust the output voltage. If the load needs more current, the discharge will go faster, so we’ll need to keep the power supply connected longer in each cycle.

The big problem with the above circuit is that the output is far from a constant 3.3V – it’s a big jumpy mess which merely averages out to 3.3V, but for say a µC which can take at most 3.6V as input, this circuit will not be good enough.

That’s where the second circuit above comes in. We replace the diode with an inductor, which is simply a coil of wire. You may know that a coil + a current = an electromagnet. Inductors don’t dissipate electrical energy, they convert it to/from magnetic energy.

The simplest analogy here is the flywheel: when giving a big yank on such a wheel, you convert your muscle energy into motion, which the wheel then “stores” by spinning. When you then try to stop it by grabbing the wheel, it’ll return the energy by “yanking your hand”, i.e. extra motion. You’ll need to apply an opposite force to make it stop.

A flywheel wants to keep doing what it’s doing. It opposes change. When at rest, it “takes” an effort to make it spin, and when spinning, it “gives” an effort to prevent being stopped.

Same for inductors and voltages. Put a voltage on an inductor, and it resists conducting the current – remove the voltage, and it wants to keep on delivering current. The analogy is that the flywheel’s momentum represents the magnetic field created within the inductor:

The yank on the flywheel is the ≈ 5V step up, which gradually tapers off as the energy is converted into magnetism. The sudden brake is the ≈ 5V drop as the magnetic field gets converted back into electrical energy. But as the input switching is being opposed, the output end of the inductor is “damped” by the reservoir effect of the capacitor.

The result is a fairly smooth 3.3V output voltage. Note that the duty cycle is almost exactly 66.6%, i.e. we’re drawing current from the power supply 2/3 of the time, converting the incoming 5V to 2/3 = 3.3V – no losses: excess energy is shuttling into magnetism and back!

The crazy bit is the input voltage swing, which is peaking between +7.24V and -1.26V, completely messing up the 0/5V power supply level. It’s harmless here, since the “supply” used for this experiment is a signal generator with a fixed internal resistance, but for real switching power supply designs all these spikes and energy transfers require great care.

We’ve accomplished something magical: turning one voltage into another, without heat.

Note that switching power supplies are converters, they can’t “make” energy – the laws of conservation of energy still hold. A perfect “switcher” can convert 5V @ 1A into 3.3V @ ≈ 1.5A or into 2.5V @ 2A (5W = 5W = 5W). Such switchers are called buck converters.

## Boost regulators

There are also boost converters which can turn an input voltage into a higher voltage, but again: no miracles. A perfect booster can turn 5V @ 1A into 10V @ 0.5A or 12V @ ≈ 0.4A.

Boost regulators use an inductor plus a diode to play tricks with those extra voltage swings you see in that last scope image. By singling out the peaks, an output can exceed its input:

(the above image comes from Wikipedia, as always a wonderful resource)

Again, the flywheel analogy helps to understand what’s going on:

• switch closed (briefly!) = current starts flowing
• switch open = current wants to continue flowing

The essential trick in this circuit is that when the switch opens, the energy release from the inductor (“inductive kick”) will add to the input voltage, pushing the output well above the input level. Just as a yo-yo can easily jump considerably higher than where it started from.

[Back to article index]