Electrical – use a current control buck converter to charge a battery

batteriesbattery-chargingbuckchargercharging

As shown below, could I use a microcontroller to charge the Li-ion battery? I'm unsure if I'll run into issues with the voltages on the ADC. I've done this exact setup before with a generic load, I'm unfamiliar with batteries though.

schematic

simulate this circuit – Schematic created using CircuitLab

Best Answer

Generally, yes, you can build a switch-mode power supply using a microcontroller.

It'll certainly be more work than just buying a dedicated controller IC, though, and your digital control scheme must take software reliability risks into account.

Here, these risks are increased: if your MCU software fails for some reason, or the MCU doesn't properly power on, there's a realistic chance the MOSFET will stay "on", and that'll quickly render the inductor effectively a short, delivering as much current as your 12V can source into the battery. Lithium batteries, under these circumstances, will heat up, produce gas, bulge and tend to explode. No fun. Considering that, I'd very much recommend using dedicated third-party LiIon charge controllers that integrate all the switch driving (often even the switching mosfet), sensing and overtemperature and -current protection you need.

That being said:

No, this is not an appropriate LiIon charger circuit; Lithium batteries want to be charged by a controlled current, not using a controlled voltage (the voltage is usually used to check the charging state). Your ADC just checks the voltage across the battery, not the current flowing into it. Thus, this can't be a safe charger.

Again, a dedicated LiIon charger IC has an "understanding" of the state the Lithium cell is in. It will charge at a limitable rate, and it will slow down and stop when the cell has reached a certain state. Such chips are typically not very expensive.