Maker Pro
Maker Pro

Why is my LM317 current limiter circuit not working?

Noob here, but attempting to build a current limiter with a LM317 for use with a power supply to give constant current.

I have placed an extra potentiometer (the white one) to simulate changing load conditions - but when I adjust it, I am getting changing amperage - which if the LM317 was working correctly, I'm pretty sure it should not.

What am I doing wrong?
circuit1.jpg circuit2.jpg circuit3.jpg circuit4.jpg LM317 current limiter.jpeg
 

Harald Kapp

Moderator
Moderator
but when I adjust it, I am getting changing amperage - which if the LM317 was working correctly, I'm pretty sure it should not.
You may be pretty sure but you are wrong.
The LM317 is a constant voltage regulator. As such it tries to maintain the voltage between the out-pin and the adj-pin at 1.25 V. In the typical constant current circuit such as you use, this means the voltage drop across R1 + R2 is 1.25 V (at least within the limits of the regulator acc. to the datasheet). Thus current through R1 + R2 and consequently through the load is
Iout = 1.25 V / (R1 + R2)
You see immediately that changing R2 changes the current.
For simulating various load conditions you need to place the potentiometer instead of the load, outside the regulator loop.
upload_2021-7-9_8-22-33.png

But be aware: 1.25 V / R1 = 1.25 V / 12.5 Ω = 0.1 A. This current through a 2 kΩ potentiometer would require a voltage of V = 2 kΩ × 0.1 A = 200 V !
Your circuit can supply max. 35.75 V (40 V - 3 V drop across the LM317 - 1.25 V across R1). The max. resistance value of the potentiometer is therefore 35.75 V / 0.1 A = 357.5 Ω. For higher resistance values the current can no longer be regulated and will drop below 0.1 A.
Also the max. power dissipation of the potentiometer is P = I² × R = 0,01 A² × 357.5 Ω = 3.575 W. Your tiny trimmer pot is not up to that power dissipation.

See e.g. here for a more detailed explanation.
 
Thank you for this reply - I will have to go through the second part of it more deeply tomorrow ( I'm a noob haha, learning here)

As for the first part however, I have indeed placed my (second) potentiometer outside the regulator loop for simulating load conditions - you will see it is the white pot in the image.
But as you say with the power dissipation maybe that is the issue. Will try to wrap my head around that tomorrow, thank you!
edit- perhaps if my small pot is insufficient for simulating changing load conditions, I could go pick up a handful of 9v batteries and try changing the power supply voltage instead?
 
ok I guess it looks like you are choosing 12.5 Ohms for the R1 resistor inside the regulator loop- in the circuit I photo'd it is the red (2kOhm max) pot, set to 41 Ohms - I did not change this pot while doing the previous test, only the white 1k Ohm pot outside the loop. Still too low I guess, as that comes out to 61 V required per your equation - I will try changing the pot inside the regulator loop to 200 Ohms, as that looks like it would come out to 12.5 V required (I am using a 19.5 V laptop charger)
But what I don't understand is why for that equation you say "This current through a 2 kΩ potentiometer" - neither pot is set to 2k Ohms, so why do I have to multiply my amperage by that figure?

"The max. resistance value of the potentiometer is therefore 35.75 V / 0.1 A = 357.5 Ω" here are you referring to the pot outside the regulator loop?
 

Harald Kapp

Moderator
Moderator
It might help if you showed a diagram of your actual circuit, not something different from your circuit, don't you agree?
I'm not going to analyze the photos to find out what your circuit looks like.
Follow the link in my first answer to learn how the LM317 can be used as a constant current source.
 

bertus

Moderator
Hello,

Is this the set-up you are using?
bokeb LM317_constant_current_regulator.png

I assume R1 is 12.5 Ohms and VR1 is a 2 kOhm pot set to 41 Ohms.
The current will be about 1.25 V / (12.5 + 41)Ohm = 23.4 mA
The maximum output resitor will be (19.5-3-1.25) V / 23.4 mA = 651 Ohms.
The power developed in the output resistor will be (23.4 X 23.4) X 651 = 360 mW
As the pot looks like a 250 mW version, it will likely burn down.

Bertus
 
@Harald Kapp
Yes, sorry, the circuit as it stands is exactly as the one you edited from my original. Also the same as what bertus posted, except minus the R1, just have the 2 kOhm .25W pot inside the regulator loop.
Thank you for that link, clearly super relevant. I will read through that shortly.

@bertus
Yes that diagram is accurate, minus only that I have not placed a R1 yet.

Thank you very much for these calculations, this is helping clear up my understanding.
The numbers I think are correct for the originally posted circuit, minus the 12.5 Ohm R1- so...
Current Out = 1.25 V / 41 Ohm = 30.5 mA
Maximum Output Resistor = (19.5-3-1.25) V / 30.5 mA = 500 Ohms
Power in Output Resistor = (30.5 mA)^2 X 500 Ohms = 465 mW
You are correct, the output pot is 1kOhm 250 mW

so to figure what I should set VR1 to -
let's set Power in Output Resistor = 200mW = (1.25 V / VR1)^2 X (15.25 V / (1.25 V / VR1))
I get VR1 = 95 Ohms

I will build this now.
 
sorry for the delay here @bertus , I burnt the living crap out of my fingertips placing a resistor into a live circuit. Learning experiences, I guess.
Building the circuit with 95 Ohms of series resistors inside the LM317 loop now.

edit-
Ok so now I have built the circuit just about exactly as @Harald Kapp drew it, except that R1 is 3 resistors in series totalling 95 Ohms, and that between R2 and ground I have placed my ammeter in series.
Voltage In = 19.5 V
R1 = 95 Ohm resistor
R2 = 1k Ohm .25 W pot
still getting the same result: adjusting R2 does indeed adjust the amperage read - a range from 18 - 210 mA. I will note that this amperage adjustment changed across the spectrum of adjusting R2 - there was no range within either end of the pot where the current would stay steady.
Importantly (for me) I noticed after removing R2 that it was indeed getting hot. I suppose this means it was exceeding its power dissipation capability?
I thought by the previous calculations, by setting R1 to 95 Ohms, the maximum power in the Output Resistor (R2 here) would be 200 mW - within the bounds of the pot's 250 mW capability?
But I am still learning all of this, especially the power and power dissipation part, so perhaps I am not understanding something correctly here.

Skipping the comprehension step for the moment, I am considering the options of running and getting a heftier potentiometer, or (and saving an entire daytrip for me) buying 3 9v batteries and trying swapping out my power supply voltage to simulate variations in the Load instead.

Would that work?

lm317 test config.png
 
Last edited:
Below is the LTspice simulation of the circuit with the load going from 5Ω to 1kΩ.
Note that the current (green trace) is quite constant at about 13.2mA (1.25V / 95Ω) independent of the load resistance, while the output voltage (yellow trace) increases as the load resistance (horizontal axis) increases to keep the current constant.

The maximum load dissipation (red trace) is 173mW.

If your circuit doesn't do that, then there a serious problem with your connections.
Double-check all the connections, especially the LM317 pin connections.

buying 3 9v batteries and trying swapping out my power supply voltage to simulate variations in the Load instead.

Would that work?
No.
Changing the power supply voltage does not simulate variations in the load resistance.
Why do you think it would?

upload_2021-7-10_0-18-29.png
 
Last edited:

bertus

Moderator
Hello,

As @crutschow said, check the pins of the LM317:
LM317_pinout.png

It looks like you changed Vin and ADJ.

Also have a look at the used wires.
They are stranded wires, wich can split and cause shorts.
For a beadboard, you can better use solid core wires.

Bertus
 
Hello,

As @crutschow said, check the pins of the LM317:
View attachment 52301

It looks like you changed Vin and ADJ.

Also have a look at the used wires.
They are stranded wires, wich can split and cause shorts.
For a beadboard, you can better use solid core wires.

Bertus
Ok I've switched to some solid copper wires. They're tiny, but they seem to be working.

I'm now pretty sure I have the pins right.
I failed to mention this also, but in my original circuit I had actually placed the R2 pot in between the hot side of my power supply and the Vin leg of the LM317 (I think that placement makes no difference here?). So in that first image of the breadboard, the left leg of the LM317 is receiving the hot side of my power supply.

Last night while I was playing with this, I removed the resistors between Vout and ADJ... and discovered that the circuit was still live (I had replaced R2 with an LED). This means that the current was flowing solely through Vin and ADJ.. with Vout connected to nothing. I measured 11 V across Vin and ADJ.
Is that how this thing is supposed to work? I swapped out the LM317 with a 2nd one I have, same configuration, circuit was still live.

Below is the LTspice simulation of the circuit with the load going from 5Ω to 1kΩ.
Note that the current (green trace) is quite constant at about 13.2mA (1.25V / 95Ω) independent of the load resistance, while the output voltage (yellow trace) increases as the load resistance (horizontal axis) increases to keep the current constant.

The maximum load dissipation (red trace) is 173mW.

If your circuit doesn't do that, then there a serious problem with your connections.
Double-check all the connections, especially the LM317 pin connections.

No.
Changing the power supply voltage does not simulate variations in the load resistance.
Why do you think it would?

View attachment 52300
Thanks very much for running that simulation, thats not a tool that's in my wheelhouse.
So with the power disspation of the load-simulator-pot, and the LM317 pins eliminated as potential problems, it must be the wires or somehow the breadboard?

As for the batteries, you're right, I shouldn't have implied that changing the input voltage would simulate changing resistance in the load. What I meant to ask is if changing the input voltage would test whether the LM317 is creating a constant current, the same way changing a simulated load resistance would do. But with you confirming that with enough resistance in R1, my .25W potentiometer should handle the power dissipation just fine, then this seems like a moot point now.

I rebuilt the circuit just now, still getting the same problem. The current changes in a uniform logarithmic fashion across the range of the R2 (load-simulator-pot). No plateau of constant current in any range.
I'm also noticing that the LM317 is getting very hot.
See images attached
The black then green cable is the hot line of my power supply.
R1 is a 1k pot, set to 990 ohms during the test.
R2 is a 1k .25W pot
I'm reading about 10 mA when R2 is minimized and 200 mA when R2 is maximized.
limiter 2.0 1.jpglimiter 2.0 2.jpglm317 test config.png
 
Last edited:
Alright, I'm headed tomorrow to pick up some more LM317 s if I can.
If replacing the LM317 does not solve the issue, I will try rebuilding the circuit with alligator clip wires, no breadboard.
Will post back tomorrow night or Tuesday.
 
Sorry for the delay, ran to the city yesterday to get multiples of all new components, got around to rebuilding it with these today.

This new circuit is everything new except the 19.5v power supply, the breadboard, and the multimeter. Wires, LM317(T)'s , resistors, and pots all new.

R1 is a 980 Ohm resistor.
R2 is a 2k pot with a 19 ohm minimum.

Hooked everything up.

Similar(ish) results:
17.4 volts across R1.
between 50 and 60 milliamps between R2 and ground with R2 at 19 ohms. 0.9 volts across R2, 17.5 volts across R1.
between 40 and 50 milliamps between R2 and ground with R2 at 94 ohms. 4.5 volts across R2, 14 volts across R1.

Again tested with 2 (new) LM317(T)'s , basically same results.

I am starting to wonder if possibly my supply store I have been buying from just has a whole batch of bad LM317's. This is a developing country. I may run and buy some more from a few other component stores I know of.

I will now rebuild this circuit with alligator-clip-wires in place of the breadboard. ((Edit: Built it without the breadboard, still all the same results.)) If I still get the same results, the only problem source I can imagine besides the LM317's is my power supply. In that case, maybe I go buy some 9v batteries for testing purposes?limiter 3.0 .jpg lm317 test config.png
 
Last edited:
I found another store today and bought another couple LM317's from them. Have 5 from the original store I was buying from as well.

I discovered that with Vin at 19.5V, R1 at 980 Ohms and R2 at 22 Ohms, 1 of the original 5 and both of the new ones were reading 30mA between Adjust and R2, whereas the rest were reading 60mA between Adjust and R2.

So I ran a more thorough test on these 3 (calling these LM317-1/2/3) plus 1 of the ones reading 60mA (LM317-o):
How much Voltage across R1, how much Voltage across R2, and how much current between the LM317 Adjust pin and power supply ground (unfortunately had to read with a 10mA-resolution instrument, the finer circuit is fried), with:
Vin at 19.5V, R1 at 980 Ohms, and with R2 at 22, 100, and 218 Ohms. No potentiometers this time, all regular resistors.

LM317-1 with R2 at 22 Ohms: R1 17.7V , R2 0.8V , 30mA between Adj and ground
LM317-1 with R2 at 100 Ohms: R1 15.5V , R2 3.0V , 30mA between Adj and ground
LM317-1 with R2 at 218 Ohms: R1 12.7V , R2 5.8V , 20mA between Adj and ground

LM317-2 with R2 at 22 Ohms: R1 17.7V , R2 0.8V , 30mA between Adj and ground
LM317-2 with R2 at 100 Ohms: R1 15.5V , R2 3.0V , 30mA between Adj and ground
LM317-2 with R2 at 218 Ohms: R1 12.7V , R2 5.8V , 20mA between Adj and ground

LM317-3 with R2 at 22 Ohms: R1 17.7V , R2 0.8V , 30mA between Adj and ground
LM317-3 with R2 at 100 Ohms: R1 15.5V , R2 3.0V , 30mA between Adj and ground
LM317-3 with R2 at 218 Ohms: R1 12.7V , R2 5.8V , 20mA between Adj and ground

for reference, re-measured the LM317 from last night:
LM317-o with R2 at 22 Ohms: R1 17.2V , R2 1.2V , 60mA between Adj and ground
LM317-o with R2 at 100 Ohms: R1 13.6V , R2 4.9V , 40-50mA between Adj and ground
LM317-o with R2 at 218 Ohms: R1 10.3V , R2 8.2V , 40mA between Adj and ground

conclusion- these 3 LM317's that read I(out) 30mA with low R2, already start reading I(out) 20mA with an R2 set to just 218 Ohms. Shouldn't this circuit be able to maintain the I(out) with R2 having a good bit more resistance than that?

Would there be any point in swapping my power supply for a few 9V batteries... do you think it's possible my issue is somehow my power supply? All I know about it is that it says 19.5V DC out on the back, and my multimeter(s) read 19.6V across hot and ground. Other than that could it be the electricity running to my developing-nation-abode somehow?

Would love any further input. @bertus @crutschow @Harald Kapp
 
To update, I have discovered after swapping my power supply to 3 9v batteries in series, that the issue was something with my power supply - or perhaps the electricity at my house.

Now I'm trying to figure out what this is so I can fix it.
 
Top