Continue to Site

# USB battery charger with programmable current

#### Sioux12

##### Newbie level 4
Hello!

I hope this topic fits to this Forum (otherwise, any suggestion about the right place to post it would be welcome).

I am a newbie and I would like to design (and possibly realize) a battery charger with a programmable current: ideally, the desired current should be selected from a range of discrete values. I wonder if this can be accomplished (for example) through the GPIO output pin(s) of a development board, wired to control the transistor(s) actually providing the current to the battery.

Some constraints:
- I would like to use USB as power line;
- consequently, the range of currents I would like to cover is from 0 A to about 3 or 4 A; the voltage should be fixed at 5 V;
- for now, my target battery is the one of a mobile phone, but I would ideally like to build a device which is able to charge any battery which can be charged through USB.

My knowledge about batteries and chargers is very poor. After some research, I found out that there are specific chargers for specific types of batteries. There are also Integrated Circuits providing a range of different currents to the batteries, but I've never found a range so wide as I ideally would like to have. Is there something that would fit to this case?

Moreover, I have a "principle" question: can this programmable charger current be obtained by a single transistor, simply controlling the base voltage (in the case of a BJT) or gate voltage (in the case of a MOSFET)? Or some other strategies are recommended? And why?

For example, in the Integrated Circuits I found (like LTC4077) the variable current is set using a (variable?) resistor ("The charge current is set by connecting a resistor, RIUSB, to ground"). Also in this message a voltage divider is mentioned. But doesn't this imply a waste of power?

Bye,

Hugh

voltage should be fixed at 5 V;
- for now, my target battery is the one of a mobile phone
Instructions usually advise to use the charger that came with the device. We're taking a chance when we use amateur means to charge batteries.

What's the recommended range for your mobile phone battery? I guess 3.7 to 4.2V (but you should measure to make sure). Here's a simple circuit that uses a plain diode to drop 0.6V from a 5V supply.

Suppose the battery starts at 3.7V, then it admits 22mA charge current. This amount goes down automatically as the battery rises over 4V.

After several hours the battery could reach 4.2V. In that event the charge current is small (3 mA). We can surmise it barely affects the battery. Of course you ought to research further and keep track of battery temperature as well as a host of other parameters to make sure.

Instructions usually advise to use the charger that came with the device. We're taking a chance when we use amateur means to charge batteries.
Yes, of course. I try to rephrase my goal (it was probably not well explained).
I don't want to replace an optimized factory charger, which best fits for some specific battery.
As far as I know (but correct me if this is wrong), the life of a battery (in particular, a Lithium-ion one) is extended if it is charged with lower currents. On the other hard, higher currents of course reduce the overall charge time.
I would like to build a device which is able, according to my needs, to provide both the scenarios, through a programmable current.

What's the recommended range for your mobile phone battery? I guess 3.7 to 4.2V (but you should measure to make sure). Here's a simple circuit that uses a plain diode to drop 0.6V from a 5V supply.

So far, I did not make any measurement through a multimeter. However, there is an app that monitors some battery parameters. Hoping that it provides enough accurate values, the higher voltage I saw is 4.3 V (charged at 88 %).
Also, the mobile phone itself seems to tweak the current provided to the battery during the charge, so that its value is always optimized. This way, probably my charger could be less "smart" than I thought, as it just must provide a fixed current, set by the user:
- when a fast charge is needed, I can set its current to a high value (3 A, for example), then the mobile phone will grab it according to the battery needs;
- when a slow charge can be tolerated, I can set the current to a lower value;
- in an intermediate situation, I can set the current to some value between 0.5 A and 3 A.
The key fact is that I would like to be able to set the current provided by the charger: then, it will be the maximum available current. The phone will adapt it, according to a precise schedule depending mostly on the battery charge percentage.
This also would make my charger independent from the specific phone and battery.

View attachment 184617

Suppose the battery starts at 3.7V, then it admits 22mA charge current. This amount goes down automatically as the battery rises over 4V.

After several hours the battery could reach 4.2V. In that event the charge current is small (3 mA). We can surmise it barely affects the battery. Of course you ought to research further and keep track of battery temperature as well as a host of other parameters to make sure.
These aspects (which are all very important) are probably monitored by the phone itself. Trying to rebuild such adjustments is out of my capabilities.

My initial doubt was, however, about a slightly different problem: in general, how can the output current of a device (whose purpose, if relevant, is to charge batteries) be set in a custom way? Is this achievable through a microcontroller setting its GPIO pins as command to the output transistor terminals? Or through the GPIO pins setting a resistance? Why?

Last edited:

This simple transistor circuit delivers an adjustable voltage to a device. Since you specify there's a stable USB supply, it makes it possible to adjust a desired maximum.

0.3A seems a reasonable maximum of Amperes you can draw from a computer without going through a process called enumeration. Caution is advised if you try to increase the current by eliminating or changing the 15 ohm resistor.