Portable battery-powered applications sometimes also permit operation from the power grid. If so, the application must choose the appropriate available power source—the grid or the battery. If the battery is rechargeable, the system also requires a charging circuit.
Instead of employing a dedicated charge controller for the backup-power controller, designers can choose the more economical option of using an inexpensive eight-pin microcontroller, available from many manufacturers, as a charge controller for a variety of charging algorithms and battery chemistries. An added advantage of this approach is that if the intended application uses a microcontroller, the same device can implement the charging algorithm, provided that the application has a few I/O lines and code space available.
For our design, we chose an Atmel AVR Tiny13, which works over a wide supply voltage range from 1.8 to 5.5 V (Fig. 1). The controller monitors a 9-V nickel-cadmium (NiCd) rechargeable battery. If its voltage drops below 9.6 V, the controller detects—through transistor Q3—whether or not grid power is available. If available, the controller starts a batterycharging cycle. The charging circuit employs pulse-width modulation (PWM), with the PWM duty cycle inversely proportional to the battery voltage. So, as the battery gets charged, the PWM duty cycle is proportionally reduced.
The battery charges through transistor Q2 and transistor Q1. A logic 1 at Q2’s base turns on the transistor, which then turns on Q1 and starts the charging current. When the battery voltage reaches 9.8 V, the charging cycle is terminated.
While the battery is charging, indicator LED D1 is turned on. If the grid power is available, LED D2 also turns on. The microcontroller is operated at the lowest clock frequency possible on the Tiny13—128 kHz—in order to minimize the power consumption.
The charging algorithm can be modified for lithium or nickelmetal- hydride (NiMH) batteries. When you use these types of batteries, which require constant-current charging, Q1 can be replaced with a suitable current source. If required, battery temperature can also be monitored. The Tiny13 has additional analog-to-digital inputs available. A suitable temperature sensor, such as a thermistor, that’s placed in thermal contact with the battery can monitor the temperature. Thus, the controller can modify the charging process appropriately.
The control program for the Tiny13 was implemented in C using the AVRGCC compiler under a Windows operating system. The AVRGCC is available for Linux as well. Figure 2 illustrates the flow diagram for the control program. For the code listing, click here.