Electronics‎ > ‎Power‎ > ‎

USB Battery Charger

This is a slow rate battery charger for Ni-Mh and Ni-Cd cells designed to operate with 5V @500mA provided by any standard USB port. This is the type of charger you plug it in and forget about it. I personally have this charger built with 4 individual cell slots, plugged in 24/7 and I use it to charge batteries for low power devices (i.e. wireless mouse/keyboard) which require a battery swap once a couple a weeks or even a month. Slow rate chargers take up to 10 hours to charge a cell.

Principle of operation

The principle of operation is very simple and it involves two trigger levels: a low level one ( the starting voltage) and a high level one (the cut-off voltage). When a Ni-Mh or a Ni-Cd cell is connected to the charger with an open circuit voltage less than the low level trigger voltage, the charger is switched on sinking ~150 mA into the cell. As the battery gets charged more and more it will start to oppose resistivity to the injected reverse current and as a result the voltage across the cell will rise. When the voltage across the cell reaches the high level trigger, the charger is switched off and it doesn't start again until the voltage across the cell drops below the low level trigger.

Trigger levels

The trigger levels are very important because they determine when the charger starts and most importantly when it stops.

Ni-Mh and Ni-Cd batteries should never get under 0.8 - 0.9 V or they may get damaged, so setting the low level trigger at 1.1 - 1.2 V should be just fine.

The tricky one is the high level trigger, because not all cells behave the same and you don't want to set the level too high and overcharge, but you also don't want to set it too low and stop before the battery is fully charged. Although it is pretty much safe to overcharge at 0.1C (0.1C = 1/10 of the cell capacity, so if the cell capacity is 1300 mAh, 0.1C would be 130 mA), it's desirable to stop when fully charged. There is a great article at Texas Instruments about battery charging.

Generally, both Ni-Mh and Ni-Cd cells will reach 1.48 - 1.5 V when they are charged and are injected with 0.1C, but may vary depending on the battery chemistry and construction, from 1.45 V up to 1.55 V. Also if you charge a battery at way under 0.1C, the voltage across the cell may never reach 1.5 V, because the chemical reaction inside the battery will overcome the injected current, which won't oppose electrical resistivity, which in turn will result in a low voltage across the cell. So if you put a cell with a capacity of 2600 mAh in this charger it may never stop unless you drop the high level trigger or increase the current, so try to aim for that 0.1C charging rate.


First of all, this schematic could have been greatly reduced in size and number of components if modern chips were to be used, but instead I chose to use simple components that are very common. Plus, using general purpose components gives you a better understanding of how things actually work and greater flexibility, than using a single dedicated IC with a transistor.

The schematic has 3 main modules:

  • a 2.5 V voltage reference source
  • a comparator with hysteresis
  • and a constant current source

The voltage reference source is provided by a TL431 adjustable shunt regulator, which is then further lowered with a voltage divider (R10 + R14 + R9). R14 is a multiturn trimmer giving fine adjustment for the low and high level trigger voltages.

The comparator is the popular LM393 with a bit of positive feedback through R11 to get hysteresis between the output and the input. The lower R11 gets, the higher the hysteresis will be. The output of LM393 is an open collector one so a pull-up resistor (R13) is used. This output is then used to switch on/off the current source by pulling up/down the base of the Q1 transistor trough Q4.

The constant current source is a very simple configuration formed by two PNP transistors and a resistor (Q1, Q2 and R6).
To understand how it works, assume Q1's base has just been pulled down through Q4 and R15 by the comparator. As a result current starts to rush through Q1's emitter, which will also go through R6. As the voltage across R6 approaches VBE of Q2, Q2 turns on starting to conduct current through R15, pulling up Q1's base, which will make Q1 conduct less current through R6 and load. This is a negative feedback loop that keeps the voltage across R6 equal to VBE of Q2.
The current is basically limited at

where VBE,Q2 is typically 0.6 - 0.7 V, depending on the junction temperature and collector current of Q2.

If you plan to increase the current, make sure you check in the datasheet if Q1 can take that collector current and can dissipate enough power (IC * VCE). Also make sure you can provide enough base current through R15, which means the voltage across R15 must not exceed

where Ilimit is the charging current, VCE saturation of Q4 is at most 400 mV and hFE for 2n3906 is minimum 30 - 100 depending on Ilimit. Check hFE graph in Q1's datasheet. A R15 value too small will cause higher current through Q2 collector required to pull up Q1 base, so that Ilimit*R6 doesn't exceed VBE of Q2.

You can also replace Q1 PNP transistor with a low VGS(th) P-MOS transistor which takes no gate current, so the value of R15 doesn't affect Ilimit. A few examples of P-MOS transistors with a VGS(th) > -0.8 V are: BSH205-207, IRLML6401, Si2305. You may have to put multiple transistors in parallel in order to safely dissipate the power VDS*ID. When you use multiple transistors in parallel the dissipated power is evenly split between each other.

Below is a simulation of the charger with a cell that is fully charged, showing the current source switched off and the low level trigger voltage (1.23 V).

With the tool bellow you can determine the low level trigger voltage and the high level trigger voltage at different values for the feedback resistor R11, assuming R10, R14, R9, R13 and R7 are same values as in the schematic. You can also fine tune the multiturn 5KΩ trimmer R14.