# Lithium-ion battery charger using LM317

I have come across the following circuit in a datasheet for a battery charger:

I have also seen a similar use of the charging circuit for use as a lithium-ion battery charger, e.g. here.

But is this circuit implementation actually suitable for a lithium-ion battery? (I know the 6 V circuit would require the voltage output of the LM317 (R1 and R2) to be set depending on the attached lithium-ion battery voltage.)

I have read that lithium-ion batteries need the following in order to charge safely and correctly (assuming the battery is not below its discharge condition, in which case trickle charging is required first):

1. Constant Current (CC)
2. Constant Voltage (CV)

The constant-current stage requires the battery to be charged to its max. (fully charged) voltage with a fixed current. The max. charge voltage is set by R1 and R2 in the top picture. R3 and the BJT act as a current control.

The constant voltage stage requires the battery to be maintained at its max. (fully charged) voltage, whilst the output current is steadily dropped. The battery is deemed "charged" when the output current is below a very small current limit, which is specific to the lithium battery. This stage initiates when the voltage across R3 gets close to around 0.6 V: the BJT starts to turn on, which shorts the adjust pin and drops the LM317 output voltage until it is stable at around 1.25 V, which then reduces the output current to the battery.

Questions:

• Does R3 affect the LM317 output voltage as it's in series with R2?

• How do the BJT and resistor precisely work in this setup? Won't the battery initially try and draw as much current as it can, meaning 0.6 V would develop across R3 before the battery is sufficiently charged to transition into the CV stage?

• Wouldn't the 0.6 V developed across R3 mean that the potential "seen" by the battery is approx 6.3 V? (6.9 V LM317 output, subtract 0.6 V). Wouldn't this be insufficient to charge the battery fully?

• When the BJT turns on, the voltage output of the LM317 will drop to 1.25 V as the adjust pin is shorted (which bypasses the resistors). Surely this is not suitable for the CV stage of charging, as the potential drops to way below the battery charging voltage. How is current output to the battery affected during this voltage drop?

• Is the BJT even required for the CV stage? If just the resistor was used to limit the current, wouldn't the current to the battery decrease as it reaches full charge anyway?

• "is this circuit implementation actually suitable for a lithium battery?" - depends on how good you need it to be. Charging batteries is a complex field (esp for non-nimh and lead-acid types). However, I have made a 'emergency' charger to just top up some batteries on the go with a LM317 in constant-current configuration, but when using it we have a voltage meter verifying we don't exceed cell voltages. The question is: Do you just want to use an LM317, or do you want to make a good charger? There are integrated charger ICs that do a lot of the heavy lifting for you. Commented Jun 4, 2020 at 10:56
• An LM317 isn't suitable. Lithium batteries require careful monitoring whilst charging. There are a wide range of suitable IC's and pre-assembled PCBs available. Commented Jun 4, 2020 at 12:39
• The LM317 is like one of those great athletes of yesteryear. You can appreciate it for how good it was back then. But it is no longer competitive. Truth be told it is no longer suitable for anything, mainly because of the high dropout voltage. All of the circuits and app notes and whatnot are wonderful for learning, however. Commented Jun 4, 2020 at 16:53

Does R3 affect the LM317 output voltage as it's in series with R2?

If the battery is not connected (or, equivalently, if there is only a negligible current through the battery), the circuit operates as a constant voltage source with an output voltage of $$\V_{0}=V_{ref}\cdot \left( 1 + \frac{R_2+R_3}{R_1}\right) + I_{Adj}\cdot (R_2+R_3)\$$. Since $$\R_3\$$ is typically much smaller than $$\R_2\$$, $$\R_3\$$ has only a negligible influence on $$\V_0\$$. On the other hand, if a battery is connected, as long as the battery voltage is lower than $$\V_0\$$, the circuit works as a constant current source and the current through the battery will be approximately $$\\frac{0.6V}{R_3}\$$. In this case, the voltage across the battery will automatically be adjusted such that the current remains constant. Once the battery voltage reaches $$\V_0\$$, the current can no longer be kept constant. In this case, the voltage across the battery will be constant, namely $$\V_0\$$, independent on the current that flows through the battery.

How does the BJT and resistor precisely work in this setup? Won't the battery initially try and draw as much current as it can, meaning 0.6v would develop across R3 before the battery is sufficiently charged to transition into the CV stage?

Yes, the battery will try to draw as much current as it can, but it will not succeed, because the higher the current through the battery, the higher the voltage across $$\R_3\$$. When this voltage reaches 0.6V, the transistor starts to conduct and the output voltage of the regulator will decrease. Therefore, the current through the battery is automatically limited to approximately $$\\frac{0.6V}{R_3}\$$.

Wouldn't the 0.6V developed across R3 mean that the potential "seen" by the battery is approx 6.3V? (6.9V LM317 output subtract 0.6V). Wouldn't this be insufficient to charge the battery fully?

Note that the battery is connected between the output of the voltage regulator and the base of the transistor, thus the voltage across $$\R_3\$$ has no influence on the battery voltage. The voltage regulator makes sure that the voltage across the battery will not exceed $$\V_0\$$.

When the BJT turns on, the voltage output of the LM317 will drop to 1.25V as the adjust pin is shorted (which bypasses the resistors). Surely this is not suitable for the CV stage of charging as the potential drops to way below the battery charging voltage? How is current output to the battery affected during this voltage drop?

The transistor will not conduct completely. The control loop ensures that the current through the transistor is just large enough to maintain a constant current. During charging with a constant current, the voltage of the battery will slowly increase. Once it reaches $$\V_{0}\$$ the current can no longer be kept constant and the voltage will remain at $$\V_{0}\$$.

However When charging lithium batteries, switching from CC to CV must take place at a precisely defined voltage. Therefore, $$\R_2\$$ should be made adjustable in order to set $$\V_0\$$ to the required level. This circuit is interesting to analyze and it might be a cheap solution, but there a integrated circuits that do a better job.

The simulation (using a rather crude battery model) shows the relationship between battery voltage (green) and current through the battery (blue). The constant current source does not show ideal behaviour.

• In what way is the CC mode non-ideal? Commented May 29, 2022 at 6:55

While I can't fault Hufi's answer that directly addresses the specific questions asked, I'm not sure it explains the theory of operation of the circuit in a way that someone new to this kind of circuit can easily grasp. Once you understand the theory of operation of the circuit, you can answer those questions yourself.

Probably the most important thing to keep in mind when analyzing this circuit is that the LM317 works kinda like a variable resistance that varies so as to regulate the output pin to be 1.25V higher than the adjust pin. When using it as a voltage regulator, we typically set the voltage at the adjust pin using a voltage divider across the output, but we can control the voltage at the adjust pin however we want and the LM317 will still work to keep the output pin about 1.25V higher than the voltage at the adjust pin.

The other thing that's handy to notice is that the output voltage - ie. the voltage across the battery being charged - is the voltage across the $$\240\Omega / 1.1k\$$ voltage divider. $$\R_{3}\$$ is not across the battery so if the transistor is off, the adjust pin is just set by the battery terminal voltage across the $$\240\Omega / 1.1k\$$ voltage divider. $$\R_{3}\$$ doesn't really matter in analyzing the LM317 as a voltage regulator in this circuit so long as the input voltage is enough to drive whatever current we expect through the LM317, the battery and $$\R_{3}\$$.

Consider what happens if the transistor is completely off - effectively open circuit. We have a typical LM317 voltage regulator circuit with the battery as the load and a voltage divider to set the output voltage. We know that the LM317 will act to keep 1.25V across the $$\240\Omega\$$ resistor, so the voltage across the entire voltage divider and hence across the battery is: $$V_{bat} = \frac{1.1k+240}{240} \times 1.25 = \frac{1340}{240} \times 1.25 \approx 6.97V$$ Let's call that 7V.

Now let's look at what $$\R_{3}\$$ and the transistor do when we connect a battery that needs to be charged. To keep the numbers nice and round, I'm going to use $$\R_{3}=0.6\Omega\$$ and assume that the transistor needs about $$\0.6V\$$ across the base-emitter junction to start conducting.

It's also important to understand how a battery behaves when being charged. A battery in a low state of charge will have a lower terminal voltage and that voltage will rise as the state of charge increases. The terminal voltage will also rise depending on how much current we're forcing into the battery. If the transistor wasn't there, the current going into the battery would rise to the point where the terminal voltage equals about 7V. For the purpose of discussion, let's say that at the battery's current state of charge, 7V is enough to force about 3A of charge current into the battery. If we had 7V across the battery terminals, that 3A has to go through $$\R_{3}\$$, which means the voltage across $$\R_{3}\$$ would be about 1.8V. But this is also the base-emitter voltage of our transistor, so it must be turned on hard - effectively saturated and pulling the adjust pin down to about 0.6V. But this would mean that the LM317 output would only be around 1.85V (ie. 0.6V + 1.25V) and that's not enough to push any current into the battery, let alone 3A of charge current. Clearly we have a contradiction here so this can't be happening.

What we actually have here is another negative feedback loop formed by the LM317, the transistor, $$\R_{3}\$$ and the battery. What happens is that as the current through the battery rises, the voltage across $$\R_{3}\$$ rises. When the voltage across $$\R_{3}\$$ reaches 0.6V, it's enough to bias the transistor on and it starts to conduct. It can't turn on hard because that would shut off the charger output as we saw above. Instead we end up in a balancing act where the charge current through the battery ends up being just enough to turn the transistor on just enough to pull down the charger output voltage so that the charge current is just enough to keep the transistor turned on just a little bit... and round and round the loop we go. Since the transistor needs about 0.6V across the base-emitter junction to start conducting and I said that I would use $$\R_{3}=0.6\Omega\$$ this means that the charge current will be held constant at about 1A. If it tries to go slightly higher than that the transistor turns on more, forcing the LM317 to pull down the charge voltage and the charge current falls back to 1A. If the charge current falls slightly below 1A the transistor starts to turn off, allowing the LM317 to increase the charge voltage and correct the output current back up toward 1A again.

As the battery state of charge increases, the battery terminal voltage will slowly rise. All the while the feedback loop we talked about will keep pushing the charger output voltage up to keep the charge current at 1A. This continues until the battery terminals have 7V across them. Once that happens, the charger output voltage cannot go any higher. Why not? Because of the voltage divider across the battery. The voltage between the adjust and output pins of the LM317 is the voltage across that $$\240\Omega\$$ resistor. If the transistor is off, this is given by: $$V_{240\Omega} = \frac{240}{240+1.1k}V_{bat}=\frac{240}{1340}V_{bat}\approx0.18V_{bat}$$ If $$\V_{bat}=7V\$$ then $$\V_{240\Omega}\$$ is about 1.253V. We're already a little higher than the 1.25V that the LM317's internal feedback is trying to maintain, so it will act to lower the output terminal voltage a little to bring it back into regulation.

Why did I suggest this with the transistor turned off? Because if the transistor is drawing any current at all, that increases the current through the $$\240\Omega\$$ resistor, increasing the voltage between the LM317's adjust and output pins. This makes the voltage regulation problem worse and drives the LM317 to lower the output voltage even more, so we just can't go above 7V at the output.

At this point, the battery state of charge has increased enough that 7V is no longer enough to push 1A of charge current into the battery. So the current starts falling below 1A. Since the LM317 can't push the voltage any higher, the voltage across $$\R_{3}\$$ and the transistor's base-emitter junction falls below 0.6V and the transistor turns off. We're now back at a standard LM317 voltage regulator circuit. As a voltage regulator, it holds the charger output voltage at 7V for the remainder of the charge cycle while the charge current continues to fall as the battery state of charge increases.

This is how CCCV chargers work. They're basically just a power supply that operates to a maximum voltage and current limit with the output rising to whichever of those limits is hit first and that's all this circuit does. They often have additional smarts built in to keep track of the state of charge and shut off the charging at some point - or perhaps other things. But at their core, they're just some kind of power supply with a current and voltage limit. For this particular circuit, the voltage limit is set by the voltage divider across the battery and the current limit is set by $$\R_{3}\$$. $$\R_{3}\$$ will probably be selected within the range of about $$\0.4\Omega\$$ to about $$\6\Omega\$$, depending on what maximum charge current is desired.

Is this suitable for lithium based battery chemistries? With appropriate resistors it could perform the CCCV function of a lithium battery charger, but at a minimum it should also include something to detect the end of charge condition and ideally a number of other protection features. You can buy specialized lithium battery charging ICs that integrate all the functions you need in one package. This makes something like this comparatively impractical but in a pinch could be designed to provide the CCCV function for lithium based chemistries. As shown in the schematic, this looks like it was designed for a 3-cell lead acid battery, as they have a nominal cell voltage of about 2V per cell, so 6V for a 3-cell battery. They also typically use a charge voltage of about 2.4V per cell, or around 7.2V for a 3-cell battery. This is pretty close to what the above resistor divider values give you and the caption does say it's for a 6V battery charger. If you were trying to charge lithium based cells, you'd need to check the datasheet for your cells and use resistors to set the voltage and current limits accordingly. Lead-acid batteries are much more forgiving to abuse during charging. Lithium based chemistries... not so much. If abused enough, they can sometimes catch fire and/or explode. If in doubt, you would want to err on the lower side for the maximum charge voltage. Using a lower CV will mean ending on a lower SOC, but also less likely to cause the cell to fail in some way due to overcharging.

• If the circuit keeps floating batteries indefinitely instead of stopping charging when expected, the circuit is unfit for lithium charging. If you say otherwise, people will try it, forget it left on and the batteries may burst into fire and burn down a house. The lithium battery will also not have 100% SoC when voltage over it reaches the CV value, it will still charge even if voltage reaches the CV phase. Commented Apr 6, 2023 at 4:39
• I'm not sure what you're getting at with respect to CV. I didn't say it's at 100% SOC when you reach CV. I said it continues to charge at CV and the charge current will decrease as SOC increases. Are you talking about designing for a lower CV? I wasn't suggesting you simply stop when you reach CV. I was suggesting that you could design for a lower CV to be on the safe side of any uncertainty and avoid applying too high of a voltage to the cells. The end of charge condition wouldn't change. Commented Apr 6, 2023 at 21:49