How does an inverter or UPS work?

When the power cuts out and the fans keep turning, a box in the corner is quietly turning a battery's DC back into 230 V AC. A home inverter is a battery, a charger and an inverter in one box.

When the power cuts out and the fans keep turning, a box in the corner is quietly turning a battery's DC back into 230 V AC. Take a home inverter and a computer UPS apart in 3D, and watch the switch happen in milliseconds.

UPSClearOpened 14 Jul 202615 min to playFree · no sign-up

In 60 seconds

  1. Store it now, give it back later

    A home inverter is a battery, a charger and an inverter in one box. While the mains is on it fills a 12 V battery; in a power cut it turns that battery's energy back into 230 V AC for your fans and lights. A computer UPS is the same idea, shrunk down.

  2. AC into DC: four diodes and a capacitor

    Mains in India swings between +325 V and −325 V fifty times a second. A transformer steps it down, a bridge of four diodes flips the backwards half of each wave, and a capacitor smooths the bumps. The charger then fills the battery in stages: bulk, about 14.4 V absorption, then about 13.5 V float.

  3. DC into AC: four switches and a transformer

    Four MOSFET switches in an H-bridge connect the battery one way round, then the other, 50 times a second. Pure sine inverters switch thousands of times a second in pulses of changing width and filter them smooth. A transformer with about 19 times more turns lifts 12 V to 230 V, and the current drops by the same factor.

  4. Switching over in milliseconds

    An offline UPS lets mains straight through and clicks a relay over to its inverter when the mains fails, in about 5 to 15 ms. A PC survives the gap on the capacitor inside its power supply. An online UPS runs from its inverter all the time, so there is no gap at all.

  5. How long the backup lasts

    12 V × 150 Ah is 1,800 Wh, but only about 80% is usable, the inverter loses about 15%, and draining a battery fast gives less capacity (Peukert's law). Two ordinary fans, four LED bulbs, a TV and a router run for about three and a half hours; with BLDC fans, nearly six.

  6. Inside the battery

    Six lead-acid cells of about 2.1 V make 12.6 V. Discharging turns both plates into lead sulfate and weakens the acid, so a hydrometer reading shows the charge. Charging splits a little water, so it needs distilled water topped up. LiFePO₄ batteries use four 3.2 V cells, weigh about a third as much and last thousands of cycles.

Laws at work here

The history

225 years from a stack of metal discs in Italy to the battery box that keeps India's fans turning when the power goes out.

Read the full history
  1. 1800The first battery
  2. 1888A motor for alternating current
  3. 1947The transistor
  4. 1969A silent UPS for a computer
  5. 1998From cable TV to inverters

The full explanation

UPSClear, chapter by chapter

Chapter 1

Inside a home inverter and a UPS

A battery, a charger and an inverter: store electricity now, give it back in a power cut.

When the power goes out and the fans keep turning, thank the box in the corner. A home inverter has a simple job: store electricity while the mains is on, and give it back when it goes off.

It can't store electricity as it comes from the wall. Mains is AC: it flips direction 50 times a second. A battery only takes DC, which flows one way. So the box turns AC into DC to charge the battery (the charger), and DC back into AC to run your home (the inverter).

Inside you'll find a heavy transformer (most of the weight), a row of MOSFET switches on a heatsink, a control board that watches the mains, a change-over relay that clicks when the power goes, and a small fan. In many home inverters the same switches and transformer do both jobs: run one way they charge, run the other way they invert.

The tall battery is a 12 V lead-acid tubular type, about 150 Ah and over 50 kg. A computer UPS is the same idea shrunk down, with a small 12 V, 7 Ah battery inside.

Try “Inside an inverter” in the interactive model →

Chapter 2

Turning AC into DC

Four diodes flip the backwards half of every wave, and a capacitor smooths the bumps.

Mains electricity is AC. In India it swings between +325 V and −325 V fifty times a second (we call it 230 V, which is its average "strength", the RMS value). A battery is DC: a steady 12 V, always the same way round. To charge it, the charger has three jobs.

1. Step down. A transformer turns 230 V into about 15 V AC.

2. Rectify. Four diodes, one-way valves for current, are wired in a diamond called a bridge rectifier. Whichever way the AC pushes, two of them steer the current out of the same end. The backwards half of every wave is flipped forwards: now it's bumpy DC, 100 bumps a second.

3. Smooth. A big capacitor fills up at each bump and tops up the gaps, like a water tank under a dripping tap. The bigger it is, the smaller the leftover ripple.

Then a control circuit charges the battery in stages: bulk (a steady current, about 15 A), absorption (held at about 14.4 V while the current tapers off), then float (about 13.5 V, just enough to keep it full).

Try “AC into DC” in the interactive model →

Chapter 3

Turning DC back into AC

Four switches flip the battery back and forth, and a transformer lifts 12 V to 230 V.

A battery pushes current one way only. To make AC, the inverter uses four fast electronic switches called MOSFETs, wired in a square called an H-bridge. Switch on the top-left and bottom-right pair, and current flows through the transformer one way. Switch on the other pair, and it flows the other way. Do that 50 times a second and you have AC.

Flipping hard gives a square wave. Fans hum and some gadgets dislike it. Pausing between flips gives a modified sine, a bit closer. A pure sine inverter switches thousands of times a second, making pulses that are wide at the top of the wave and thin near zero (PWM), then smooths them with a coil and a capacitor into a clean sine wave, just like the mains.

The transformer lifts 12 V to 230 V: its high-voltage coil has about 19 times as many turns. Energy can't be made from nothing, so the current goes down 19 times. Power is volts × amps: 230 V × 1.3 A on one side needs 12 V × about 29 A on the other, plus losses.

Try “DC into AC” in the interactive model →

Chapter 4

Power cut! Switching in milliseconds

How fast the backup takes over decides whether your computer notices.

Most UPSes for computers are offline (standby): while the mains is fine, your PC runs straight off it through a relay. The UPS watches the wave. When it disappears, it starts its inverter and the relay clicks over. That takes about 5 to 15 milliseconds. A home inverter in UPS mode does the same in about 10 ms.

A line-interactive UPS keeps its inverter ready and also evens out high and low mains voltage, so it switches in 2 to 4 ms. An online (double-conversion) UPS never switches at all: it turns mains into DC and back into AC all the time, so a cut changes nothing. That costs some energy, which is why it is used for servers and hospitals.

Why can a PC survive even 10 ms of nothing? Its power supply has a big capacitor charged to about 380 V. It keeps the computer running for a few milliseconds on its own: the hold-up time. The ATX design guide asks for about 17 ms at full load. A cheap supply with a small capacitor may not make it.

Try “Power cut!” in the interactive model →

Chapter 5

How long will the backup last?

Battery energy divided by what you switch on, with a few real-world catches.

A battery's label gives its voltage and its amp-hours (Ah). Multiply them for the energy inside: 12 V × 150 Ah = 1,800 watt-hours. Run 180 W of fans and lights and you might hope for 10 hours. You'll get far less, for three reasons.

1. You can't use it all. Draining a lead-acid battery flat shortens its life, so the inverter cuts off with about 20% left: 80% usable. 2. The inverter isn't perfect. About 15% turns to heat, and it needs a few watts just to stay on. 3. Fast draining wastes capacity. The 150 Ah is measured over 20 hours. Pull current faster and less comes out: Peukert's law.

Inverters are sold in VA (volt-amps), not watts. Fans, TVs and chargers don't draw current perfectly in step with the voltage, so a load needs a bit more VA than W. The ratio is the power factor. A 900 VA inverter can run about 720 W.

The cheapest way to stretch your backup? Swap old 75 W fans for 30 W BLDC fans. With fans and lights alone, that more than doubles it.

Try “How long will it last?” in the interactive model →

Chapter 6

Inside the battery

Lead, lead dioxide and acid: a chemical reaction you can run forwards and backwards.

An inverter battery is six cells in a row. Each has lead plates (grey, negative) and lead dioxide plates (brown, positive) standing in dilute sulfuric acid. Each cell makes about 2.1 V, and six in series make 12.6 V.

As it gives out current, both kinds of plate soak up sulfate from the acid and turn into lead sulfate. The acid gets weaker and more watery: Pb + PbO₂ + 2 H₂SO₄ → 2 PbSO₄ + 2 H₂O. Charging drives the reaction backwards. That's why you can check the charge with a hydrometer: strong acid is denser. A reading of about 1.26 is full; about 1.12 is flat.

Charging also splits a little water into hydrogen and oxygen, so the level drops. Top it up with distilled water only, never acid or tap water. Tubular batteries hold the positive paste in little fabric tubes, so it can't flake off. They last about 1,200 to 1,500 deep cycles, far more than flat plates.

LiFePO₄ (lithium iron phosphate) batteries use 3.2 V cells, four in series. They weigh about a third as much, need no water, can be used more deeply and last several thousand cycles. They cost more up front.

Try “Inside the battery” in the interactive model →

Test yourself

Frequently asked

Why does an inverter need a charger as well?

A battery can only be filled with DC, and mains is AC. The charger turns mains AC into DC so the battery can store it.

What is the heaviest part inside a home inverter?

The transformer. Its iron core and copper coils make it the heavy lump in the box.

In a power cut, which way does energy flow?

Battery → inverter → your fans and lights. The battery’s DC is turned back into AC for your home.

What does a bridge rectifier do?

Turns both halves of an AC wave into current flowing one way. Four diodes steer the current so it always leaves by the same terminal.

Mains in India is called 230 V. What is its peak voltage?

About 325 V. 230 V is the RMS value. A sine wave peaks √2 times higher: about 325 V.

Why does the charger switch to a lower "float" voltage when the battery is full?

To keep it full without overcharging and boiling off its water. Holding a full lead-acid battery at 14.4 V would split its water into gas. About 13.5 V just tops it up.

How does an H-bridge make AC from a battery?

It connects the battery one way round, then the other, over and over. Swapping which pair of switches is on reverses the current through the load.

A transformer steps 12 V up to 230 V. What happens to the current?

It goes down about 19 times. Power in ≈ power out. Nineteen times the voltage means about a nineteenth of the current.

How does a pure sine inverter make its smooth wave?

By switching thousands of times a second in pulses of changing width, then filtering. PWM pulses average out to a sine, and a coil and capacitor smooth away the switching.

An offline UPS takes about 10 ms to switch over. Why does the PC usually not notice?

The power supply’s capacitor keeps it running for longer than that. A good power supply rides through about 16 ms or more on its capacitor: its hold-up time.

Which UPS type has no switchover gap at all?

Online (double conversion). It always runs your load from its inverter, so a cut only changes where the DC comes from.

What is the click you hear when a UPS takes over?

A relay switching the output over to the inverter. An electromagnet pulls the relay’s contact from the mains side to the inverter side.

A 12 V, 150 Ah battery holds about how much energy?

1,800 Wh. Volts × amp-hours = watt-hours: 12 × 150 = 1,800 Wh.

Why does a heavy load give less backup than simple maths says?

Draining faster wastes some capacity (Peukert) and the inverter loses energy as heat. Faster drain means less usable capacity, and 10–20% is lost in the inverter.

An inverter is rated 900 VA. Why not 900 W?

Many loads draw a little more current than their watts suggest, so VA is the honest limit. Power factor below 1 means more volt-amps than watts. At 0.8, 900 VA is about 720 W.

Why does a lead-acid battery need topping up with distilled water?

Charging splits some water into hydrogen and oxygen gas. Near the end of charging, a little water is split into gas and bubbles away. Only water is lost, so only water goes back.

A hydrometer reads 1.13. What does that tell you?

The battery is nearly flat. As it discharges, sulfate leaves the acid for the plates, so the acid gets less dense.

How many LiFePO₄ cells make a 12 V battery?

4. Each cell is about 3.2 V, so four in series make 12.8 V.

Words worth knowing

AC and DC
Alternating current keeps reversing, 50 times a second in India; direct current flows one way, like a battery's.
Rectifier
A circuit, usually four diodes in a bridge, that turns AC into current flowing one way.
Inverter
A circuit that turns DC into AC by switching a battery's connection back and forth.
H-bridge
Four switches that can connect a load either way round to a battery.
PWM
Pulse-width modulation: fast on-off pulses whose changing widths average out to a smooth wave.
Transformer
Two coils on an iron core that step AC voltage up or down; the current changes the other way.
Transfer time
The gap between the mains failing and the backup taking over: about 10 ms for an offline UPS, zero for an online one.
Amp-hour
How much charge a battery holds. Volts × amp-hours gives the energy in watt-hours.
Specific gravity
The density of a lead-acid battery's acid compared with water: about 1.26 when full, 1.12 when flat.

Fork it. Teach with it.

This box is plain HTML, CSS and JavaScript, with no build step and no accounts. Run it yourself and it sends nothing anywhere. The code is MIT. The words, images and videos are CC BY 4.0, so you can reuse them anywhere if you credit “Glassbox, glassbox.how/e/upsclear”.

git clone https://github.com/bdeeps/upsclear.git

Built with three.js (MIT), Geist, Instrument Serif (SIL OFL 1.1).

←→ previous / next box · / search

Would you like to see the full page, with the interactive model?