Electronic Design

# Lead-Acid Battery Charger Becomes A Subfunction In A Microcontroller

This design implements a charger for a lead-acid battery as a subfunction in a microcontroller whose main function can be any more complex task. Furthermore, the MCU gets its power from the same battery. The charging process is so slow and uses so little processor time that it doesn't jeopardize the MCU's primary task.

The goal of the circuit (Fig. 1) is to ensure an uninterruptible power supply. Depending on battery condition, there are three operating scenarios:

• the battery is charged
• the battery is discharged
• the battery is disconnected

In the first case, the MCU must monitor battery voltage and temperature, as well as control the power switch to maintain the optimal battery condition. In the second case, the battery voltage is too low to maintain MCU operation. With the MCU inactive, the power switch must be on. In the third case, the power switch must also be on. In this condition, the voltage on the MCU input is significantly higher than in the other cases. As a result, the MCU's input voltage can be used to recognize this condition.

The charger's schematic (Fig. 2) can be broken down into three sections:

• the voltage divider
• the temperature sensor
• the MOSFET driver and MOSFET

Also to be considered are MCU ports TEMP/AD0, VOLT/AD1, and STOP and the charging algorithm (implemented in the microcontroller).

The charging algorithm (see the code listing) provides two charging modes: full charging and standby. As the rectifier starts to deliver power, the algorithm goes into the full-charging mode.

In this mode, the circuit charges the battery to between 14.4 and 15 V, which is "full battery voltage" (FBV). The algorithm then goes to standby mode, which keeps the voltage between 13.5 and 13.8 V, or "standby voltage" (SBV). The digital oscilloscope printout in Figure 3 shows an example of this cycle.

The battery voltage through voltage-divider R5/R6 goes to the MCU's ADC input (VOLT/AD1). R5 and R6 should be temperature-stable devices.

Lead-acid battery manufacturers recommend including temperature correction in the charging process, since battery voltage changes with temperature at about 4 mV/°C/cell.1 Therefore, the charger incorporates a temperature sensor consisting of two diodes (D1 and D2) and one resistor (R4).

Voltage on these forward-biased diodes changes with temperature at about 2 mV/°C, so two diodes are used to double the voltage signal. This kind of temperature sensor can measure temperatures from about 20°C to 150°C.2 That's more than enough for this application. The sensor's output is connected to the MCU's ADC input (TEMP/AD0).

The MOSFET driver circuitry provides voltage gain and level shifting. When the battery is discharged, the driver turns on the MOSFET and starts battery charging. If the battery is disconnected, the MCU will detect a very high input voltage and keep the MOSFET on.

The charger circuit and control algorithm was implemented using an Atmel ATMega16 microcontroller and WinAvr GNU GCC compiler.3,4 With an 8-MHz clock rate, the algorithm's ChargerSubfunction takes approximately 2.1 ms with a repetition time of 5 to 10 seconds. Accordingly, the charger uses less than 0.00042% of the MCU's time.

Finally, we should mention that this charger also can be built as a stand-alone device.

References

1. D. Berndt, Maintenance-Free Batteries: Aqueous Electrolyte Lead-Acid, Nickel/Cadmium, Nickel/Metal Hydride, Research Studies Press; 3rd edition, Oct. 2003
2. Adel S. Sedra and Kenneth C. Smith, Microelectronic Circuits, Oxford University Press, USA; 5th edition, Nov. 27, 2003
3. www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
4. http://winavr.sourceforge.net