Question about pot in LM317 circuit - Page 1
Forum section: electronics / beginners

author: OilsFan
author_rank: Regular Contributor
timestamp: January 22, 2016, 10:25:59 am
content: So I've built up this basic LM317 circuit to drive three LED's. I want to be able to dim them with a pot so I have used a 2K Linear pot on the adjust. It all works fine BUT the LED's go from off to full bright in the first half turn of the pot. How do you make the range of the pot more useful? As in I want the LED's to be their dimmest when the pot is all the way to the left and not achieve their full brightness till the pot is turned all the way right. If you see what I mean. Is it a function of the pot value or should I try a different taper? Thanks

author: sleemanj
author_rank: Super Contributor
timestamp: January 22, 2016, 10:37:36 am
content: You could try putting a resistor eitherabove or below the potin series or parallel (probably this) wih the pot (which is configured as a variable resistor). Experiment with values, 1/2 the value of the pot maybe.But know that human vision isn't linear, you might have more luck with an audio-taper pot.

author: bookaboo
author_rank: Frequent Contributor
timestamp: January 22, 2016, 11:44:57 am
content: Perhaps use a logarithmic pot?

author: MrSlack
author_rank: Frequent Contributor
timestamp: January 22, 2016, 11:50:37 am
content: Set the LM317 up as a current source rather than a voltage source. LEDs need variable current, not variable voltage to control brightness. See LM317 datasheet on how to do this.Info here on the idea:http://www.ae5d.com/led-1.htmlNote lack of series resistors if you're using a current source. A series resistor is a basically a bad current source. An LM317 is a better one!Your circuit is a voltage source (the LM317) and one current source per LED. You can just use the LM317 to do both.

author: mikerj
author_rank: Super Contributor
timestamp: January 22, 2016, 11:59:34 am
content: What voltage are you applying at J1? With a 2kpot and R1=220 ohms, you will get a maximum of 1.25*(1+2000/220) = 12.6 volts at the LM317T output, but only if the input voltage is high enough (i.e. 12.6v plus about 2v dropout for the regulator).If the input voltage is lower than this, then it would explain why the brightness stops increasing halfway through the pots range. You need to set the total resistance of the potentiometer so that when set to maximum resistance the LM317T is still in regulation.

author: Zero999
author_rank: Super Contributor
timestamp: January 22, 2016, 12:05:59 pm
content: What's the supply voltage?Using the LM317 as a current source is a good idea but it costs an extra 1.25V in voltage drop.The output voltage of the LM317 needs to vary from just below the minimum forward voltage to one which will drive the LEDs at a current which will give the required voltage.Plenty of web based calculators can be found for bother the LED resistor and LM317.

author: Chalcogenide
author_rank: Regular Contributor
timestamp: January 22, 2016, 12:08:32 pm
content: If you set up the LM317 as a current source I would still put a small (maybe 1/10th of what you are using now) series resistor with each LED to avoid current mismatch between the LEDs. Depending on the voltage supply you may also be able to wire the LEDs in series and reduce the power dissipation on the regulator (for blue LEDs, 3.5V each +2.5V for the LM317 = 13V min).You won't be able to completely turn the LEDs off unless you also add a shunt resistor from regulator to ground that allow the quiescent current of the regulator to flow allowing the voltage across the LEDs to be lower than the forward voltage. In case or the 3 LEDs in parallel, a 10k should do the job, for the LEDs in series you can probably increase it to 47k, but you should experiment.

author: Ian.M
author_rank: Super Contributor
timestamp: January 22, 2016, 12:37:38 pm
content: You might be better off with a 555 timer based PWM circuit. e.g.:Use a CMOS 555, and don't exceed 80% of the max discharge pin rating (typically 100mA). Therefore if you need to drive more or higher current LEDs, use an external N channel MOSFET, with its gate driven from OUT, source to ground and drain sinking the LED current. You may find the duty cycle cant go low enough to totally extinguish the LEDs. Unfortunately that's the price of simplicity.

author: bookaboo
author_rank: Frequent Contributor
timestamp: January 22, 2016, 05:05:27 pm
content: Yes Ian's right, some sort of PWM will be much more efficient than a 317.

author: Zero999
author_rank: Super Contributor
timestamp: January 22, 2016, 08:47:26 pm
content: Quote from: bookaboo on January 22, 2016, 05:05:27 pmPWM may be more convenient but it's certainly not more efficient than simply adjusting the current. If anything, reducing the current is the most efficient way to dim an LED because the efficiency of LEDs is higher at lower currents.

author: KL27x
author_rank: Super Contributor
timestamp: January 22, 2016, 09:01:31 pm
content: The voltage output is changing completely linearly, the way it is. You didn't specify what kind of LEDs you are using.Typical indicator LEDs get pretty bright from a mA up to about full brightness at 5-10mA. After that you can run as much current as you want and you're just shortening the life. They won't get much brighter. So everything important to your eye is going to happen between around 3-5 Volt.Before you go tearing down your circuit and trying pwm or current limiting, first you could try this:Goal:Make the entire range of the pot move the voltage from 2.5V to 4.5-5V, rather than 1.25V to 12V.Halfass: change R1 to 1k or so. Add a 1k resistor in series with the 2k pot. The brightness will still not be linear and it never will be, even with a log a rith mic (I can't spell) pot (which would help). But this will increase the brightness resolution of the pot, for starters. All the really big changes happen at the knee of the resistor, where the supply voltage passes the VFD of the LED, which is probably around 3V. So you want to progressively hone in on this area. (And when you get there, you can reduce the series resistors of your LED, even).I agree that PMW will be "more efficient" in the sense that it will be most linear to the human eye, regarding brightness. (It will not be more power efficient; but that is obviously not the goal for your circuit - I hope.) But with what you already have, you can still try this something simple.Once you have tuned the resistor ladder optimally, you will see how well supply voltage adjustment can control LED brightness. You can probably improve, as said, with PWM. Current limiting won't be all that much better, and may be pretty similar, in fact. But you can't really compare until you use a voltage adjust circuit that is reasonably decent.Even the PWM circuit won't be linear as far as the eye is concerned. The big changes will happen in the lower half of the duty cycle, and near full duty cycle you won't see much difference. In fact, I think the best would be PWM with a logarithmic* pot.*wherever I say logarithmic pot, I may actually mean an anti/reverse-logarhithmic pot. For a PWM circuit like Ian posted, it doesn't matter. If you get the wrong one, just reverse the logic of the output with a transistor. Or even more simple, just power the LED from the other leg.

author: Ian.M
author_rank: Super Contributor
timestamp: January 22, 2016, 09:14:22 pm
content: I *NEVER* claimed that PWM would be more efficient for this case. However if you can rearrange the LEDs to put them in series, with a single current limiting resistor recalculated for 3*Vf , the efficiency of either the PWM or a modified LM317 dimmer can be improved by a factor of three. For the series LEDs, I.d stick a 6.8V Zener between the pot and ground to lift the minimum output voltage of the regulator to about 9V to better match the LED If vs Vf curve. Of course that does mean you need a 15V or so supply to have enough headroom for the LM317 to regulate.

author: KL27x
author_rank: Super Contributor
timestamp: January 22, 2016, 09:19:17 pm
content: I know. I'm just adding for clarity of the OP, because of bookaboo's comment and the subsequent reply.

author: OilsFan
author_rank: Regular Contributor
timestamp: January 22, 2016, 09:20:23 pm
content: Wow thanks guys lots of great information here!To answer some questions input voltage is 9v. LEDs are water clear super bright blue. I want them bright enough to be seen out doors but then dimmable when you use the device indoors. I did investigate running the LM317 in constant current configuration but that seems to be only good for driving LED's in series and what is not shown here is that those LED's will actually be switched in and out of circuit as indicators for various switches. I don't see how I could use constant current that way but this is the beginners forum!I actually like the PWM idea a lot but this device I am working on is an audio switching circuit and I'm afraid any PWM frequency within the human hearing range is going to cause noise in the audio line. What are your thoughts on that? I would post my full schematic but I haven't gotten around to drawing it all in Diptrace yet. Still learning that too.BTW the device is a 1 input switcher to route an audio signal to one of three outputs and uses a some optos to prevent switching noise.

author: Ian.M
author_rank: Super Contributor
timestamp: January 22, 2016, 09:46:33 pm
content: Its always the requirements you *DON'T* tell us about that cause the problems. To avoid audio frequency noise, use your 2K pot and reduce C1 to 22nF and you should be able to push the PWM frequency up to between about 23KHz and 27KHz, depending on the duty cycle (highest at 50%, lowest at 0% and 100%). If that's not good enough, try 15nF, and yes, the CMOS 555 PWM circuit will run from 9V.The only other potential problem is if the 9V supply has a lot of ripple as that could modulate the EMI radiated by the PWM circuit if its poorly laid out and/or poorly screened and if the EMI is rectified picked up on a high gain input circuit (e.g. a mic input) and rectified in a b-e junction in the preamp, you could get hum breakthrough on the audio.Why not breadboard it and see?N.B. *DON'T* use a bipolar 555 like the original NE555 as they suffer from severeshoot-throughand the resulting large current spikes are likely to cause massive amounts of EMI.

author: KL27x
author_rank: Super Contributor
timestamp: January 22, 2016, 09:50:46 pm
content: The really big advantage of PWM is that you can throw the brightness/current graph and the FVD:current graph, and the FVD:temperature graphs of the particular LED out the window. The PWM will control the amount of lumens very linearly. (But the human eye sees brightness logrhytmically, so add the right pot, and bob's your uncle.)But for your purposes, I am sure you can use voltage control and it will work quite satisfactorily, as long as all your LEDs are the same. As I said, try decreasing the range of your pot, so the full movement changes voltage just a little bit around the FVD of the LEDs.If you want to have different color LEDs, voltage control won't work very well, at all.Now that we know what you are doing, I would suggest you aim for the pot to change voltage from FVD-0.1V to FVD+0.5V and change your current limiting resistors to 50 ohms, using the formula that was posted to calculate your resistor ladder. The equation will be in the LM317 datasheet. V = R2/R1 +1.25V, or something like that.For a 2k pot, you would be looking at R1 of about ~ 4K and the series resistor with the pot around 7k. This would put R1 way higher than suggested (but it would still probably work just fine). It would be technically better (as in the voltage regulator output being more stable) if your pot was say in the 200R-500R range. But to drive a stable load like LEDs you probably wouldn't be able to tell the difference without an oscilloscope.

author: OilsFan
author_rank: Regular Contributor
timestamp: January 22, 2016, 10:25:47 pm
content: Quote from: Ian.M on January 22, 2016, 09:46:33 pmThank you. Looks like my local electronics place has CMOS 555 timers in stock. I will get some and try this out. Look forward to it.Quote from: KL27x on January 22, 2016, 09:50:46 pmI will investigate this option too. Thank you so much for the information. You guys have given me lots of information to play with.

author: KL27x
author_rank: Super Contributor
timestamp: January 22, 2016, 10:48:28 pm
content: BTW, forget what the current rating says in the LM317 datasheet. If Vin is 9V and Vout is 3V, you can derate that by a factor of ten, at least. E.g. don't expect to drive much more than a few LEDs with long term reliability. So unless you fancy opening the box and fixing it later, take precaution.If you can find the wattage dissipation for the device, use that, instead. Take your current draw in amps and multiply by 6V to get the heat production in watts. I would derate the max dissipation at least a few quadzillion fold, without a heatsink and/or a fan.A series resistor on the input of the device can dissipate some of that heat, taking that burden off the IC.The problem with these regulators is they don't die in a poof of smoke, right away. If they are overdriven, they will die 3-4 years later. A Dpak lm317 can't sustain a measly 15mA output with 15V differential, long term. A non heatsinked TO220 can't sustain 200mA with 15V differential. And you won't know it until several years have passed. At 6V differential, I would think you can drive 3 LEDs with a Dpak. I wouldn't even trust a TO92 to drive 1 LED with 6V differential. But then again, when I started out, I bought a lot of these types of ICs off eBay.

author: Zero999
author_rank: Super Contributor
timestamp: January 22, 2016, 11:00:48 pm
content: The problem with the LM317 is it will drop 2V to 3V which doesn't leave much room for the LEDs.Is it a regulated 9V supply or just a small battery?PWM is probably the best way to go. The CD40106 or 74C14 could be used to make a PWM circuit with the other gates acting as buffers to drive the LEDs.https://www.fairchildsemi.com/datasheets/CD/CD40106BC.pdfhttps://www.fairchildsemi.com/datasheets/MM/MM74C14.pdf

author: rdl
author_rank: Super Contributor
timestamp: January 23, 2016, 02:39:18 am
content: Why not just set the range of the LM317 so the low end is near the forward voltage of the LED and the high end is just below the voltage where the LED approaches its maximum current rating? All that's needed is the data sheet and a multimeter. Wouldn't fix any nonlinear brightness changes though.

author: edavid
author_rank: Super Contributor
timestamp: January 23, 2016, 06:46:28 am
content: Quote from: OilsFan on January 22, 2016, 10:25:59 amYour 2K pot value is too high.Quote from: KL27x on January 22, 2016, 09:01:31 pmThis is not correct. Modern LEDs don't saturate... brightness is proportional to current, up to the maximum.Quote from: Ian.M on January 22, 2016, 09:46:33 pmIn reality, it's not a big deal. If you add a 100-220uF bypass cap, you won't have any problems with a bipolar 555.Quote from: KL27x on January 22, 2016, 10:48:28 pmAlso not correct. They have built in thermal and safe area protection, so you can overload them indefinitely. (But if you're worried, just use a TO220 package.)

author: KL27x
author_rank: Super Contributor
timestamp: January 23, 2016, 08:27:54 am
content: QuoteBurned out LM7805 and LM317 comprise 75% of the component replacement repairs I have had to make on my own DIY circuits. Worked fine for several years, never a thermal shutdown... then kaput. They say ST (or LT? Something well-known) on them, but maybe they are fake.Anyways, the good part of that is I have learned how to use series resistors with linear regulators where you want to drop a lot of V's.... just figure the max current of your load and use the biggest value resistor that will drop the excess voltage. If the regulator draws more current than you allowed for, the voltage will sag. But if you calculate wrong and get power errors, at least you can find that out today, rather than waiting 3+ years.

author: MrSlack
author_rank: Frequent Contributor
timestamp: January 23, 2016, 08:31:33 am
content: Genuine ones are very hard to break. You need a heatsink though or all bets are off.

author: Ian.M
author_rank: Super Contributor
timestamp: January 23, 2016, 10:04:23 am
content: Quote from: edavid on January 23, 2016, 06:46:28 am

author: Zero999
author_rank: Super Contributor
timestamp: January 23, 2016, 02:29:12 pm
content: Quote from: KL27x on January 23, 2016, 08:27:54 amI've had problems with LM317s blowing before too.It was on a battery charger regulator connected to some solar panels on a shed roof. I think it was most likely caused by a nearby lightning strike. After replacing it for the second time I connected a 15V zener diode between the input and output pins and haven't had any problems since.

author: Cliff Matthews
author_rank: Unknown
timestamp: January 23, 2016, 02:35:04 pm
content: I read most everyone's posts, but I didn't see explanation for the OP's "off to full full bright" results. The 317 requires a minimum operating current of 10mA, so the OP needs to provide a suitable load. I suspect once the LED's are biased on, he can get some dimming when turning back the pot?

author: TerminalJack505
author_rank: Super Contributor
timestamp: January 23, 2016, 04:30:22 pm
content: Here are some simulations that show the DC transfer characteristics of your original circuit as well as some changes you can make to improve it.Notice that the output voltage of the first circuit starts at 1.25V and reaches the maximum output voltage at about a half turn of the pot--50% of the pot isn't being utilized.The second circuit introduces R2, which sets a minimum output voltage. In this case, around 2.7V. Most blue LED's Vfis about 3.2V. The issue with the output reaching the maximum too quickly still hasn't been fixed.The third circuit changes the pot's value to 1k. The resistor in parallel effectively helps make it a little smaller than that, which helps stretch useful range of the pot a little. The output voltage reaches its maximum at 94%, instead of 86%.

author: edavid
author_rank: Super Contributor
timestamp: January 23, 2016, 05:26:20 pm
content: Quote from: Cliff Matthews on January 23, 2016, 02:35:04 pmThat was not really what he said... it just wasn't using the full range of the adjustment pot.Quote10mA is worst case... in the OP's circuit, it would be more like 1mA (or less).

author: edavid
author_rank: Super Contributor
timestamp: January 23, 2016, 05:28:41 pm
content: Quote from: Ian.M on January 23, 2016, 10:04:23 amI don't think the OP is going into production. My point is that if you have a bipolar 555, it will work well enough... no need to hold up everything and buy a CMOS part.

author: Cliff Matthews
author_rank: Unknown
timestamp: January 23, 2016, 05:52:25 pm
content: Quote from: edavid on January 23, 2016, 05:26:20 pmDoesn't the 317 require passing 10ma just to establish the stability of its own internal circuits? (1.25Vref etc..)

author: edavid
author_rank: Super Contributor
timestamp: January 23, 2016, 06:16:08 pm
content: Quote from: Cliff Matthews on January 23, 2016, 05:52:25 pmNot under most conditions... here's the graph from the On Semi datasheet:

author: Zero999
author_rank: Super Contributor
timestamp: January 23, 2016, 06:43:46 pm
content: Quote from: edavid on January 23, 2016, 06:16:08 pmIt's not recommended to rely on the LM317 to only need 10mA though.

author: TerminalJack505
author_rank: Super Contributor
timestamp: January 23, 2016, 08:00:34 pm
content: Here are a couple more ideas. These circuits show ways to get a nonlinear output.The first one provides more sensitivity at the lower voltages/currents and the second gives more sensitivity at the higher voltages/currents.

author: Audioguru
author_rank: Super Contributor
timestamp: January 23, 2016, 08:08:22 pm
content: Quote from: Cliff Matthews on January 23, 2016, 02:35:04 pmThe LM317 needs to have a load of 10mA only when it has 40V across it and has maximum operating current.The voltage-setting resistors usually load it. When the resistor from the output to the ADJ terminal is 120 ohms then it draws a current from the output of 1.25V/120 ohms= 10.4mA then the LM317 is loaded enough so its output voltage will not rise if it has no other load.

author: edavid
author_rank: Super Contributor
timestamp: January 23, 2016, 08:24:12 pm
content: Quote from: Hero999 on January 23, 2016, 06:43:46 pm1. Of course it is, 10mA is the datasheet maximum spec2. OP is not going into production3. If the load was not sufficient, the symptom would be the LEDs being on with the adjustment pot turned off, which is not happening, so this is a non-issue

author: TerminalJack505
author_rank: Super Contributor
timestamp: January 23, 2016, 08:43:34 pm
content: Here's a more efficient version of circuit #5 that I posted above. It requires some non-E12 series resistor values, however. (The resistor values have basically been scaled-up to 2.5 times their previous values.)The other circuit requires 18 mA of current to drive the ADJ pin. This one requires about 7.5 mA. (Which should also provide enough of a minimum load for the LM317.)

author: OilsFan
author_rank: Regular Contributor
timestamp: January 23, 2016, 09:20:14 pm
content: OP here. Thanks guys, really good discussion I'm learning a lot. As someone commented I'm not going into production but rather making this device as a way to learn more about circuits overall. I do hope it works in the end though. So it occurred to me that I could have a dimmer on those bright LED's but I just couldn't figure out how to implement it. Lots of good ideas and thank you to TerminalJack505 for all the simulations. Really helpful.

author: Cliff Matthews
author_rank: Unknown
timestamp: January 23, 2016, 11:34:32 pm
content: Quote from: edavid on January 23, 2016, 05:26:20 pmOk my badI guess I translated into that from a 317 experience I had where the pot acted like a switch. Still, some circuits act weird without loads.