Author Topic: Adding Digital Current Control to LM317 PSU  (Read 1628 times)

0 Members and 1 Guest are viewing this topic.

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Adding Digital Current Control to LM317 PSU
« on: December 02, 2017, 01:27:25 am »
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 provided here.

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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 10316
  • Country: us
  • DavidH
Re: Adding Digital Current Control to LM317 PSU
« Reply #1 on: December 02, 2017, 04:29:47 am »
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.
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Adding Digital Current Control to LM317 PSU
« Reply #2 on: December 02, 2017, 07:34:55 am »
Thanks for the reply.

Your schematic would be easier to read if it wasn't the size of a big postage stamp.
Too 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? ;)

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.

Sorry – 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.

Note that if U4 takes feedback from the output of the 317, then errors contributed by the 317 will be removed.

Good suggestion. changing the feedback path as described increases the current output to 943 mA.

Any further ideas?
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 6663
  • Country: de
Re: Adding Digital Current Control to LM317 PSU
« Reply #3 on: December 02, 2017, 08:56:14 am »
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.
 

Offline prasimix

  • Supporter
  • ****
  • Posts: 1366
  • Country: hr
    • EEZ
Re: Adding Digital Current Control to LM317 PSU
« Reply #4 on: December 02, 2017, 09:20:23 am »
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.

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Adding Digital Current Control to LM317 PSU
« Reply #5 on: December 02, 2017, 09:47:53 am »
I don't think it is a good idea to get the supply of the OP(s) from the output voltage.
Perhaps not. I just copied Dave's uSupply design/knew it would be fine for simulation, as it's a clean power source.

Adding current regulation to the LM317 is rather difficult, if there is not resistance in the output side of the circuit.
As in, resistance between output and adjust? Or load resistance?

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.
Also 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).

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.
I 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.).

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.
Good point. I have uploaded them here:
https://www.dropbox.com/sh/5sqdcirqmwaerls/AAAS9cm4qoFE_zt6cf4dCxLNa?dl=0
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 6663
  • Country: de
Re: Adding Digital Current Control to LM317 PSU
« Reply #6 on: December 02, 2017, 10:22:38 am »
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.
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Adding Digital Current Control to LM317 PSU
« Reply #7 on: December 02, 2017, 10:44:05 am »
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 member here on the forums remastered 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).  ;D
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 6663
  • Country: de
Re: Adding Digital Current Control to LM317 PSU
« Reply #8 on: December 02, 2017, 01:45:33 pm »
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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 10316
  • Country: us
  • DavidH
Re: Adding Digital Current Control to LM317 PSU
« Reply #9 on: December 02, 2017, 04:23:33 pm »
Your schematic would be easier to read if it wasn't the size of a big postage stamp.
Too 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? ;)

The schematic is part of a larger image.  The schematic itself is only about 1300x452.

Quote
Note that if U4 takes feedback from the output of the 317, then errors contributed by the 317 will be removed.

Good suggestion. changing the feedback path as described increases the current output to 943 mA.

We 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.

Quote
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.

This 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.
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Adding Digital Current Control to LM317 PSU
« Reply #10 on: December 02, 2017, 09:03:19 pm »
The schematic is part of a larger image.  The schematic itself is only about 1300x452.

I know. I mentioned that in the post you quoted:
Even cropped to just the schematic, it's a sizeable 1364x478

It's, in fact, nearly twice the pixel area of the 2nd circuit you posted here, 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.

We 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.
Certainly 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf