Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new

A lithium-ion charger has two jobs that look like one. It must not push more current into the cell than the cell is rated for, and it must not take the cell above its charge voltage. A constant-current, constant-voltage (CC-CV) charger does both with two control loops, one inside the other, and a single clamp between them. This article builds that controller on a buck converter, shows the moment it hands over from current to voltage, and then runs a real four-cell pack through a whole charge.

The cell sets the two numbers

Both numbers come from the cell's data sheet, not from the charger. For the Molicel INR-21700-P45B (E-One Moli Energy, Product Data Sheet, Model INR-21700-P45B, version 1.2, "Charge" rows):

  • charge voltage 4.2 V per cell,
  • standard charge current 4.5 A, with a standard charge time of 1.5 hours,
  • typical capacity 4500 mAh, and a typical DC impedance of 15 mΩ at 50 % charge.

For four cells in series the charger therefore holds at most 4.5 A and at most 16.8 V. The sheet gives no termination current; the charger designer chooses one. C/10 (0.45 A for this cell) is a common choice and is used below.

Two loops and a clamp

The power stage is a synchronous buck from 24 V. The control has two PI loops:

  1. The inner current loop makes the inductor current iLi_L follow a reference irefi_{ref}. A feedforward duty vbat/Vinv_{bat}/V_{in} does most of the work, so the PI only corrects. The plant from duty to current is about Vin/(sL)V_{in}/(sL), and the loop crosses over well below the switching frequency.
  2. The outer voltage loop compares the filtered pack voltage with the target VCVV_{CV} and gives irefi_{ref}.

The clamp is the whole trick: the output of the voltage PI is limited to 0≤iref≤ICC0 \le i_{ref} \le I_{CC}. While the pack is below its target, the voltage error is large and positive, the PI sits on its upper limit, and iref=ICCi_{ref} = I_{CC}: the charger is a current source. As the pack voltage approaches VCVV_{CV}, the error shrinks, the PI leaves the limit, and from then on it holds the voltage: the charger is a voltage source, and the current falls by itself.

Two details matter in practice:

  • Anti-windup. While the voltage PI sits on its limit, its integrator must stop integrating. Otherwise it winds up during the whole CC phase and the pack overshoots VCVV_{CV} at the handover. Voltecx's pi block holds its integrator so that its output stays between lo and hi.
  • Measure the voltage at the cell. The current through the pack's internal resistance R0R_0 raises the terminal voltage by I⋅R0I \cdot R_0. Regulating the terminal voltage is right (it is what the cell's limit refers to), but it means the CV phase starts early, while the cell's rest voltage is still ICCR0I_{CC} R_0 below the target.

The batteryCharger example in Voltecx: a synchronous buck from 24 V into a four-cell pack, with the voltage PI giving iref and the current PI and feedforward giving the duty.

The handover, simulated

The batteryCharger example uses this controller with ICC=5I_{CC} = 5 A and VCV=16.6V_{CV} = 16.6 V (4.15 V a cell) at 10 kHz. Its pack has a capacity of only 1 mAh, so a fraction of a second of simulated time shows the whole charge with every switching cycle; the controller's behaviour does not depend on the capacity, only the time scale does.

CC-CV charge of the batteryCharger example: the pack voltage (2 ms mean) rises to 16.6 V and holds; the pack current (2 ms mean) holds 5 A, then falls as the voltage loop leaves its limit; the state of charge rises from 70 % to about 96 %.

The simulation shows the three phases:

  • CC. The current holds 5.00 A while the pack voltage climbs. The current loop is fast enough that the 2 ms mean of ibati_{bat} sits on irefi_{ref}.
  • Handover. At 149 ms the mean current falls below 4.9 A: the voltage PI has left its clamp. The current turns down smoothly, without a step, because the integrator did not wind up. The 2 ms mean of the pack voltage goes 45 mV above 16.6 V before it settles: the 300 Hz filter in the voltage feedback lets the pack run a little ahead of what the loop sees. That is about 11 mV a cell; a slower filter or a lower target would trade it against ripple.
  • CV. The pack voltage holds 16.61 V and the current tapers. It is below 0.5 A, a tenth of ICCI_{CC}, at 233 ms, and under 10 mA at the end of the run, with the charge at 95.6 %.

In CV the current is set by the gap between the target and the cell's rest voltage, divided by the internal resistance. That gap closes as the cell fills, so the current decays roughly exponentially and never quite reaches zero.

A real pack over a real charge

A switching simulation of 1.5 hours at a 2 µs step would take billions of steps. The batteryChargerLongRun example puts four P45B cells (the data sheet's 4.5 Ah, 16.8 V, 4.5 A and 60 mΩ for the pack) behind the same controller, and simulation.batteryRun runs it on the converter's averaged model: short bursts until the current settles, then jumps of seconds to minutes in which only the battery's charge moves.

The four-cell Molicel P45B pack charged by the same controller over 90 minutes, on the averaged model: pack voltage, pack current with the 0.45 A (C/10) line, and state of charge.

The current holds 4.5 A for 45 minutes. It reaches C/10 at 54 minutes with the pack at 99.6 %, and at the end of the data sheet's 1.5 hours the pack is at 100.0 %. The last half percent after C/10 takes nearly as long again as the CV phase before it, which is why chargers stop at a termination current rather than waiting for zero.

The pack model keeps the battery part's default rest-voltage curve (illustrative, not from the data sheet) and no RC branch, because the sheet gives neither. The times above depend on that curve; the shape of the charge does not.

Checklist

  • Take VCVV_{CV} and ICCI_{CC} from the cell's data sheet, per cell, and multiply by the number in series. Leave margin for the tolerance of your voltage measurement: an error of 1 % is 42 mV a cell.
  • Clamp the voltage PI's output at ICCI_{CC} and stop its integrator while it is clamped.
  • Make the current loop at least five times faster than the voltage loop, so the voltage loop sees a current source.
  • Choose a termination current and say where it comes from: the data sheet, if it gives one, otherwise your own trade between charge time and capacity.
  • Add the protections the loops do not provide: a charge timer, a temperature window (most cells must not be charged below 0 °C), and a pre-charge at low current for a deeply discharged cell, all per the cell's data sheet.

Try it in Voltecx

  • Open the batteryCharger example and plot vbat, ibat, iref and soc. Change Icc or Vcv in the variables and run again.
  • Open batteryChargerLongRun and run simulation.batteryRun with tEnd 5400, or with stopCurrent 0.45 to stop at C/10.
  • The battery charger tutorial builds the charger step by step, and long battery runs explains the averaged run. The analyses page lists the measurements used here.