🔬 The principle

What it means: a battery is a fuel tank for charge. Its capacity (mAh) says how much charge it holds; its voltage says how hard that charge is pushed. Multiply the two and you get energy (Wh) — the currency that actually buys you metres of driving. A "2000 mAh" pack at 7.4 V holds twice the energy of the same pack at 3.7 V.

Why it matters: robot designers must answer one question before anything else: will the battery last the mission? Divide stored charge by the current your motors drink and you get the runtime — but only if you leave a safety reserve, because running a LiPo flat destroys it, and because real packs sag under load.

How it works: ① the motors draw current I, so the state of charge (SoC) drains steadily — at 60× time acceleration you can watch an hour of driving in a minute; ② the cell voltage falls as the SoC empties (an educational straight line — real LiPos also dive steeply at the ends); ③ the current through the pack's internal resistance Rint burns I·Rint volts inside the battery, so the robot sees a sagging terminal voltage Vt = Voc − I·Rint; ④ the robot's speed is proportional to its voltage, so it visibly slows as the pack empties; ⑤ the energy meter integrates power over time: E = ∫Vt·I dt.

Where you see it in real engineering

Drone flight-time calculations, EV range estimates ("kWh per 100 km"), phone battery percentages, and RC-car run timers are all this same bookkeeping. Racing drone pilots size packs by "C-rate" — how many times the capacity can be safely pulled as current.

🧮 The maths

Estored = Vnom · (Q/1000) ,    trun = (Q/1000) / I ,    Voc = n·(3.0 + 1.2·SoC) ,    Vt = Voc − I·Rint ,    P = Vt·I ,    E = ∫P dt
Q — pack capacity (mAh) · Vnom — nominal pack voltage = n × 3.7 V · n — number of series cells (1S/2S/3S) · I — load current (A) · trun — full-charge runtime (h) · SoC — state of charge, 1 = full, 0 = flat · Voc — open-circuit (no-load) voltage (V) · Rint — pack internal resistance (Ω) · Vt — terminal voltage at the robot (V) · P — electrical power (W) · E — energy delivered (Wh) · drain rate: SoC falls I/((Q/1000)·3600) per second
Worked example: a 7.4 V 2000 mAh pack stores E = 7.4 × 2 = 14.8 Wh. Driving at 10 W (about Vt ≈ 8 V at 1.25 A): trun = 2 Ah / 1.25 A = 1.6 h. With 1.0 A load: 2.0 h exactly — set Q = 2000 and I = 1.0 and the runtime tile reads 2:00.

Assumptions & limitations: the open-circuit voltage is a straight line from 3.0 V to 4.2 V per cell — real LiPo curves are much flatter in the middle and dive steeply near 20% and 100%; no temperature effects; no Peukert effect (capacity does not shrink at high current); no ageing or capacity fade; Rint constant; motor speed simply proportional to terminal voltage (no load-torque model). The sim runs at 60× real time (1 real second = 1 sim minute). This simulation is an educational approximation of a real LiPo pack under load — real packs need a low-voltage cutoff around 3.3 V/cell, which is why engineers plan a reserve.

🕹 Simulation workspace

Controls

Start begins the discharge; Pause freezes the robot mid-mission (no current, no sag); Restart re-runs the same mission from a full pack; Reset restores every default. Sliders can be changed while driving — the graphs show the effect instantly.

Live measurements

State of charge—
Terminal voltage Vt—
Load current—
Power drawn—
Energy delivered—
Remaining runtime—
Ready
Tiles are computed from the live battery state every frame — nothing here is a fixed number. Before Start there is no current, so Vt = Voc: sag only appears under load.
charge level > 50% charge 20–50% charge < 20% (reserve zone) robot — speed follows terminal voltage

📈 Graphs

Voltage vs mission time. The blue line is what the robot actually receives; the gap below the grey open-circuit line is the sag I·Rint — burn it while the motors are on, get it back the instant they stop.
State of charge vs mission time. A steady current drains a straight line. The amber marker is the 90-minute mission goal; the red line is the 20% reserve you must keep for the battery's own good.

🧪 Guided experiments

🏆 Engineering challenges

🌍 Real-world applications

🚁 DronesFlight time = usable capacity ÷ hover current. Pilots land at 20% SoC with the timer started at take-off — exactly the reserve rule this sim's challenge asks for.
🚗 Electric vehiclesRange = stored kWh ÷ consumption (Wh/km). Cold weather and speed both raise the current — and sag eats the last percents fast.
📱 Phones & laptopsThe percentage you see is a SoC estimate; the "1% lasts forever" trick happens because the curve flattens near empty — a gentler version of the LiPo knee.
🏎️ RC racingPacks are rated in C-rate: a 5000 mAh 25C pack can supply 25 × 5 = 125 A. Pull more and the sag collapses the voltage — the car feels gutless at full throttle.
🔧 Try it with hardware — Arduino UNO R4 + batteryPower the board from a 2S LiPo through a voltage divider on an analog input, log Vt every second over USB, and plot discharge vs time. Compare the sag when you add a buzzer or servo load.
⚙️ Try it with hardware — ESP32 + USB power meterPut a cheap inline USB meter on a robot's supply, read volts and amps mid-run, and compute the real Wh used. Compare with the nameplate mAh × voltage — then explain the difference (sag, converter losses, Peukert).

✅ Check your understanding

📌 What you discovered

➡ Engineering takeaway: size the pack for the mission plus its reserve, then check the sag — because the performance your robot actually delivers is Vt, not the label on the pack.