Adding Digital Current Control to LM317 PSU - Page 1
Forum section: electronics / projects

author: electrode
author_rank: Regular Contributor
timestamp: December 02, 2017, 01:27:25 am
content: Hi all,(Sorry for yet another LM317 thread...)I have an old linear PSU I made 10 or 15 years ago from an Electronics Australia design. I thought it would be fun to add current limiting from a microcontroller (arduino) through a DAC. However, I'm having trouble simulating the PSU in LTSpice. Voltage and current regulation sorta work, but I can't get it to supply more than about 800 mA of current (please see attached pic). I'm using the LM317 model providedhere.I've also tried removing all the CC circuitry and used a low load resistor with a reasonably high set voltage, and still cannot get the output to reach 1 A.I was also going to use the arduino's PWM to provide a negative voltage reference to get the regulator down to 0V, but I removed the negative reference from my sim to check if it was causing problems (don't think it was).Am I doing something obviously stupid here?Thanks for any advice.

author: David Hess
author_rank: Super Contributor
timestamp: December 02, 2017, 04:29:47 am
content: Your schematic would be easier to read if it wasn't the size of a big postage stamp.Q1 is adding uncontrolled gain within the current control loop making frequency compensation difficult to impossible. Instead, replace it with a diode so U3 can pull the adjustment pin down directly with a gain of 1. If you must use Q1, then configure it with shunt feedback and a diode as described.Using separate instrumentation amplifier U2 to create a ground referenced signal adds delay within the current control loop making frequency compensation more difficult. Instead, use U2 to level shift the ground reverenced control voltage to the positive supply so U3 can do high side current sensing directly.Note that if U4 takes feedback from the output of the 317, then errors contributed by the 317 will be removed.

author: electrode
author_rank: Regular Contributor
timestamp: December 02, 2017, 07:34:55 am
content: Thanks for the reply.Quote from: David Hess on December 02, 2017, 04:29:47 amToo big or too small? The image file is a retina screenshot – 2772 x 1398 pixels! Even cropped to just the schematic, it's a sizeable 1364x478. Don't tell me you just squinted at the thumbnail instead of clicking to enlarge it or opening it in a new window/tab?Quote from: David Hess on December 02, 2017, 04:29:47 amSorry – I may not have been clear. In the steady-state configuration I showed, none of that current control stuff was even doing anything, and the result is the same if I cut it all out of the circuit (see attached): 813 mA.Quote from: David Hess on December 02, 2017, 04:29:47 amGood suggestion. changing the feedback path as described increases the current output to 943 mA.Any further ideas?

author: Kleinstein
author_rank: Super Contributor
timestamp: December 02, 2017, 08:56:14 am
content: I don't think it is a good idea to get the supply of the OP(s) from the output voltage.Adding current regulation to the LM317 is rather difficult, if there is not resistance in the output side of the circuit.Besides the points noted by David Hess, the 10 µF capacitor at the com pin of the LM317 to GND is a bad idea. It is OK if there is no external fast regulation going on, but not if external regulation is needed.This capacitor can already cause trouble for the OP regulating the voltage.It is a good Idea to crop the the pictures to the important part or at least use a suitable zoom in LTspice to have less unused frame around. Not many have a screen good for 2772 x 1398 pixels.

author: prasimix
author_rank: Unknown
timestamp: December 02, 2017, 09:20:23 am
content: Another good idea is to spend some extra time and attach .asc and related .lib file that people who are asking to assist can open it, check results or even directly make a change and post a new version back.

author: electrode
author_rank: Regular Contributor
timestamp: December 02, 2017, 09:47:53 am
content: Quote from: Kleinstein on December 02, 2017, 08:56:14 amPerhaps not. I just copied Dave's uSupply design/knew it would be fine for simulation, as it's a clean power source.Quote from: Kleinstein on December 02, 2017, 08:56:14 amAs in, resistance between output and adjust? Or load resistance?Quote from: Kleinstein on December 02, 2017, 08:56:14 amAlso fair point, thanks. Again, just trying to work out why something suss is up with even slow or steady-state conditions. Either way, I set that cap to 0.1uF and the output is the same (but do expect faster responses now).Quote from: Kleinstein on December 02, 2017, 08:56:14 amI just did it that way to show the simulation output alongside. Note a screen that big isn't required – just the ability to zoom an image (pinching, ctrl+/-, cmd+/-, view menu, etc.).Quote from: prasimix on December 02, 2017, 09:20:23 amGood point. I have uploaded them here:https://www.dropbox.com/sh/5sqdcirqmwaerls/AAAS9cm4qoFE_zt6cf4dCxLNa?dl=0

author: Kleinstein
author_rank: Super Contributor
timestamp: December 02, 2017, 10:22:38 am
content: The capacitor at the com pin of the LM317 is a general problem - just making is a little smaller does not help much. Even 100 pF or maybe even 10 pF might be too much for the OP alone to work stable.Adjusting the voltage at the com pin of the LM317 sets the output voltage, with a very low output impedance. So in case of a low impedance load, only very little change in voltage is needed to get a large change in current. This makes current control difficult. To make it would one would need a resistor in series with the load so that the LM317 together with the resistor no longer makes a very low impedance source. However this means the LM317 can no longer do the voltage regulation on it's own, but need support by something like the OP to slowly compensate for the voltage lost at the resistor. So the LM317 is essentially degraded to a kind of transistor with internal protection.

author: electrode
author_rank: Regular Contributor
timestamp: December 02, 2017, 10:44:05 am
content: Ah, I see. That perhaps explains the relative dearth of available circuits doing what I had intended to do.By the way, the circuit I started with was one that a memberhere on the forumsremastered from an old design floating around on the internet (see attached). I moved the current sense circuitry to the input side to avoid the burden voltage incurred by using higher value resistance (in the hopes of more accuracy at lower current).It seems what I'm basically trying to do – make part of Dave's uSupply with an LM317 instead of an LT3080 – might be more trouble than it's worth. Maybe I should pull my LM317K off the back of my power supply and sell it for enough money to buy 20 LT3080s (see attachment 2).

author: Kleinstein
author_rank: Super Contributor
timestamp: December 02, 2017, 01:45:33 pm
content: There is no need and actual it is not such a good idea to make the shunt resistor very small. One can still compensate for most of the drop on the shunt, at least for the more critical slow part.Using the LT3080 instead of the LM317 would not help very much - it has most of the same drawbacks of the LM317, except for a smaller drop out voltage, and in addition the more critical output impedance of an LDO.The more logical choice would be going towards separate reference (need that for digital control anyway), regulation (OPs) and power stage (transistor) - the lm317 could be used to to replace the transistor.

author: David Hess
author_rank: Super Contributor
timestamp: December 02, 2017, 04:23:33 pm
content: Quote from: electrode on December 02, 2017, 07:34:55 amThe schematic is part of a larger image. The schematic itself is only about 1300x452.QuoteWe do not have enough information to tell what is going on in the simulation however the LM317 includes safe operating area protection which lowers the current limit at high input to output voltage differences. Assuming this is simulated, it may explain the low output current.QuoteThis is what I usually do for a general purpose fault protected bench power supply. The current and voltage control loops are external and use an external reference. The LM317 or other integrated regulator serves to drive the power pass transistors while providing them with fast backup current limiting, thermal protection, and safe operating area protection.

author: electrode
author_rank: Regular Contributor
timestamp: December 02, 2017, 09:03:19 pm
content: Quote from: David Hess on December 02, 2017, 04:23:33 pmI know. I mentioned that in the post you quoted:Quote from: electrode on December 02, 2017, 07:34:55 amIt's, in fact, nearlytwicethe pixel area of the 2nd circuit you postedhere, so I am sure it's big enough for you to read. What I gather now, however, is that you only view images scaled to the width of your window, and don't have a good workflow for zooming or resizing embedded images easily on the fly. I can crop and upload multiple for you in the future.Quote from: David Hess on December 02, 2017, 04:23:33 pmCertainly a possibility, but I tried a few input values over the range of >11V to 24V (expecting 10V out at 1A) and it didn't change much. I'm thinking either LM317s don't play nicely with this op amp configuration, or the model might be a bit suss.