Battery charger: constant current, then constant voltage
A lithium-ion pack is charged in two stages. While the pack is low the charger pushes a fixed current (CC); when the pack voltage reaches its limit the charger holds that voltage (CV) and the current tapers away. Here you open a buck charger with two nested loops, read the hand-over on the scope, and change the current limit to see when it moves. About 10 minutes.
File › Open Example is a menu path and F5 a key.
The numbers on this page are checked by the tests of crates/engine/tests/tutorial_wpt_charger_mppt.rs, which run the same example. The pack is four cells with a capacity of 1 mAh, far smaller than any real pack: that makes the charge move in a fraction of a second instead of hours. For a real 4.5 Ah pack see tutorial 22. All parameters are illustrative.
1. Open the charger
Step 1 of 3 · about 1 minChoose File › Open Example › DC-DC › Battery charger, constant current then constant voltage.
A synchronous buck from 24 V charges four cells in series (B1, 15.3 V at 70 % charge). The inner loop makes the inductor current il follow a reference iref; the outer loop compares the filtered pack voltage with the target Vcv (16.6 V, 4.15 V a cell) and its PI gives iref, limited between 0 and Icc (5 A). While the pack is below the target the error is large and iref sits on its 5 A limit: constant current. Near the target the PI leaves the limit and the current falls: constant voltage.
2. Run it
Step 2 of 3 · about 1 minPress F5 (0.6 s). Read ibat and vbat on the scope:
- In the first 0.1 s the current is held at 5.00 A, the limit
Icc. - The current reference
irefleaves the limit at 150 ms: that is the hand-over from CC to CV. - In the last 50 ms the pack voltage is 16.61 V, held at the target, the current has tapered to 0.01 A, and the charge
sochas reached 95.6 %.
The current falls in CV because the pack's rest voltage keeps rising towards the target, so less and less current is needed to hold the terminal voltage.
3. Change the current limit
Step 3 of 3 · about 1 minUnder Circuit › Variables set Icc to 2.5 and run again. The held current is now 2.50 A, and since the pack climbs to the target at half the rate, the hand-over moves from 150 ms to 330 ms. The end of the run shows 16.60 V and 0.01 A, with the charge at 95.5 %: a lower limit charges more gently but takes longer to reach the same state.
Next: tutorial 26 charges a battery from a solar array, with the converter finding the array's best operating point. The manual lists every command used here.