Author Topic: LM317 control by PWM  (Read 9627 times)

0 Members and 1 Guest are viewing this topic.

Offline tzcTopic starter

  • Newbie
  • Posts: 8
  • Country: my
LM317 control by PWM
« on: February 01, 2019, 10:09:23 am »
I am trying to adjust the output of the LM317 by using PWM of microcontroller but I cant get the aspected result that I want ,even the output of the non inverting operation amplifier is wrong.
It is my schematic diagram is wrong?
please give some recommendation and suggestion.

Thanks.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: bj
Re: LM317 control by PWM
« Reply #1 on: February 01, 2019, 11:32:17 am »
What is the value of RV1?
What is your PWM frequency?
Here is something which may work: https://www.eevblog.com/forum/beginners/pwm-for-lm317-how-to-increase-resolution/msg1809224/#msg1809224
The R6/R7 in my schematics is the feedback from the output of the LM317.

What results you get?
« Last Edit: February 01, 2019, 11:44:17 am by imo »
Readers discretion is advised..
 
The following users thanked this post: tzc

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #2 on: February 01, 2019, 12:12:44 pm »
Why would one want to use a LM317 for this task? It is one of the worst choices, if there is an opamp available already.

Beef the opamp outputs with a suitable NPN transisotr and let the opamp deal with the regulation. Then just one NPN more to add current limiting.
 
The following users thanked this post: Amper, tzc

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #3 on: February 01, 2019, 01:52:14 pm »
What's the PWM voltage?

What's the desired output voltage range?
 
The following users thanked this post: tzc

Offline tzcTopic starter

  • Newbie
  • Posts: 8
  • Country: my
Re: LM317 control by PWM
« Reply #4 on: February 01, 2019, 03:42:08 pm »
What is the value of RV1?
What is your PWM frequency?
Here is something which may work: https://www.eevblog.com/forum/beginners/pwm-for-lm317-how-to-increase-resolution/msg1809224/#msg1809224
The R6/R7 in my schematics is the feedback from the output of the LM317.

What results you get?

Thanks for your reply
RV1=10Kohm
PWM frequency= 1KHz
PWM Voltage=0-5V peak-peak
« Last Edit: February 01, 2019, 03:43:46 pm by tzc »
 

Offline tzcTopic starter

  • Newbie
  • Posts: 8
  • Country: my
Re: LM317 control by PWM
« Reply #5 on: February 01, 2019, 03:45:47 pm »
What's the PWM voltage?

What's the desired output voltage range?

PWM voltage = 0-5V peak-peak
Output voltage range = 1.25V- 30V
Thanks
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: bj
Re: LM317 control by PWM
« Reply #6 on: February 01, 2019, 04:44:04 pm »
With the feedback resistors ratio RV1=5k/R3=1k and LM317's Input voltage >=32.5V you should get the output range.
Not sure -15V rail is necessary, I would use an LM358 (or similar) with single 32.5V source.
Mind the feedback divider is wired at the LM317 output - such the LM317 is inside the control loop.
You may leave your R4=240ohm there, hopefully the TL081 can handle 5mA output current (sink).
« Last Edit: February 01, 2019, 05:05:23 pm by imo »
Readers discretion is advised..
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17202
  • Country: us
  • DavidH
Re: LM317 control by PWM
« Reply #7 on: February 01, 2019, 05:32:30 pm »
Tzc, the circuit is not ideal but it should work.

Why would one want to use a LM317 for this task? It is one of the worst choices, if there is an opamp available already.

Beef the opamp outputs with a suitable NPN transisotr and let the opamp deal with the regulation. Then just one NPN more to add current limiting.

The advantage of using an LM317 instead of discrete transistors are:

1. The LM317 includes built in current limiting.
2. The LM317 includes built in thermal protection.
3. The LM317 includes built in safe operating area protection.
4. The LM317 only requires a constant drive current invariant of load which in this example is about 5 milliamps.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #8 on: February 01, 2019, 06:03:36 pm »
One can protect for over-current and SOA with a single transistor. Even implement a fold-back current limit.  I see zero reason for LM317.   Current drive argument is irrelevant,  the opamp does not care if 10uA or 10mA needs to be supplied.

Soft current limiting will be pain in the arse to add to the LM317. Can't do that with a single transistor in this single supply configuration.

 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15413
  • Country: fr
Re: LM317 control by PWM
« Reply #9 on: February 01, 2019, 06:21:25 pm »
First off - having to resort to a dual +/-15V supply to only generate a positive supply in the end is quite wasteful. Just chose a different opamp that can work on a single supply (with an output which can get close to ground).

Due to R4, the opamp will also have to sink significant current. Not sure the TL081 can.

Additionally, obviously you will never get a 30V output with a 15V input... ;D

(As a side note, when you say "I can't get the result I want", it's a bit vague, to be polite. Please be more specific as to what you notice about the behavior of your circuit.)

I would get rid of the -15V supply and select an appropriate opamp. An LM358 would kinda work, but it doesn't have nulling offset pins (if that matters, since you'd probably get only a few mV offset), and whereas its output can get down to almost ground, it won't get high enough - due to the current it will have to sink - to get your full output voltage range here IMO.

Your circuit should get you an output voltage close to: 1.25V + Vop (where Vop is the output voltage of the opamp) and with a maximum voltage of approx. between (Vin-2.5V) and (Vin-1.5V) (dropout voltage of the LM317) depending on the conditions (output current, temperature...) So take that into account. Your input supply voltage should thus be at least 32.5V if you want a 30V max output. Don't forget to use a good heatsink on the LM317. The opamp should also be able to take a 32.5V supply and sink enough current. With all that combined, a possible opamp would be the AD820 for instance. Many others will have a much reduced output voltage span due to the relatively high current they will have to sink here (~5 mA).

« Last Edit: February 01, 2019, 06:23:10 pm by SiliconWizard »
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: bj
Re: LM317 control by PWM
« Reply #10 on: February 01, 2019, 06:45:53 pm »
This is an LTspice rewrite of my LM317 PWM (see my link above).
How the output looks like when an R_LOAD is switched on/off, I=15mA/500mA, Vout=15V.
Still you may see some PWM feed-through at the output.
Simulation only.
Use at your own risk.. :)
« Last Edit: February 01, 2019, 07:45:20 pm by imo »
Readers discretion is advised..
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #11 on: February 01, 2019, 09:39:08 pm »
Not sure -15V rail is necessary, I would use an LM358 (or similar) with single 32.5V source.
I would get rid of the -15V supply and select an appropriate opamp. An LM358 would kinda work, but it doesn't have nulling offset pins (if that matters, since you'd probably get only a few mV offset), and whereas its output can get down to almost ground, it won't get high enough - due to the current it will have to sink - to get your full output voltage range here IMO.
You've got that backwards. The LM358 won't do without a negative supply because it can't sink enough current with a low enough saturation voltage for 1.25V out. The higher end of the voltage range is no problem.

I've done a quick search and there are no common, cheap op-amps, which can sink the minimum load current required by the LM317, with a low saturation voltage.

If a single supply is a requirement, then I'd add a current sink to the LM317's output and remove the resistor.

Here's how I'd do it. Q1 is a constant current sink which takes the LM317's minimum load.

U2 is configured as a Sallen-Key filter with a cut-off of 10Hz, a damping factor of 1.4 and a gain of 5.75. If a dual op-amp is being used, it might be better to separate the filter and gain stage, but I just wanted to demonstrate it can be done.

I cheated by using a calculator tool to select the component values, see the link below:
http://sim.okawa-denshi.jp/en/OPstool.php

« Last Edit: February 01, 2019, 09:41:05 pm by Zero999 »
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #12 on: February 01, 2019, 09:49:24 pm »
So yet another reasons why NOT to use a damn 317!

//also you sure it will be stable at gain of almost 6?  I have had bad trouble making sallen-key filters to not oscillate above gain of 3.
« Last Edit: February 01, 2019, 09:51:14 pm by Yansi »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #13 on: February 01, 2019, 11:09:06 pm »
Well I wouldn't agree with you about the LM317: the current limiting, thermal, safe operating area protection are very good reasons tio use it, in spite of the other minor inconveniences it causes.

Regarding the Salen-Key, you're probably right. I've not tried to design one with this much gain before. It would be a good idea to move the gain stage to after the filter.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17202
  • Country: us
  • DavidH
Re: LM317 control by PWM
« Reply #14 on: February 02, 2019, 12:22:12 am »
I've done a quick search and there are no common, cheap op-amps, which can sink the minimum load current required by the LM317, with a low saturation voltage.

If the saturation voltage matters, then a different circuit topology should be used.  The LM317 is not suitable for outputs below 1.25 volts unless a negative control voltage and a minimum load current with a negative compliance is available but often this restriction is acceptable.

For performance and precision reasons, the minimum load or quiescent current of the integrated regulation should be buffered from the output of the operational amplifier with a transistor and old designs which use the LM317 or other integrated regulator do this.

Both of these problems are solved if the minimum load current is provided without the resistor between the output and adjustment pin of the LM317 despite how convenient it was.  Now no buffering is required and the load current on the operational amplifier is stable and low allowing for low saturation voltages.  But to operate below 1.25 volts, this still requires a negative supply which might as well be used to remove the saturation requirements on the operational amplifier also.

One can protect for over-current and SOA with a single transistor. Even implement a fold-back current limit.

And thermal protection?  I really try to avoid adding discrete temperature sensors if I can avoid it.

It does not apply to this circuit but current boosted designs using the LM317 to drive a power transistor make the LM317 even more useful that just a current buffer because with a little attention to thermal resistance, the thermal protection of the LM317 can be extended to cover the power transistors.

Quote
I see zero reason for LM317.   Current drive argument is irrelevant,  the opamp does not care if 10uA or 10mA needs to be supplied.

Precision applications (which this is not yet) require the operational amplifier's output current to be controlled and even better, low.  This makes the LM317 with the minimum load current returned to another point especially useful for simplified precision power applications.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #15 on: February 02, 2019, 12:37:29 am »
This is not a precision circuit in any way shape or form, and if there was a requirement for the output to go from 0 to 30V. Adding a negative supply, or other hacks (the pre-load current sink) for it to work at least close to zero, is just to much fucking around for nothing, in my opinion.

A simple NPN darlington cascade would be more than adequate, with some form of fold-back current limiting circuit (still nothing more, than a TO220 power darlington and a small signal NPN to handle the current limiting).

Thermal protection being the most difficult difficult of these to implement (you've got me on that one), but a thermal cutoff switch (that mechanical one) would probably do more than enough in that case.

However PWM indicates a presence of an MCU, so simple temperature sensing is a matter of just an NTC and a couple of resistors. Not ideal, but simple and effective also.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15413
  • Country: fr
Re: LM317 control by PWM
« Reply #16 on: February 02, 2019, 03:27:45 am »
I would get rid of the -15V supply and select an appropriate opamp. An LM358 would kinda work, but it doesn't have nulling offset pins (if that matters, since you'd probably get only a few mV offset), and whereas its output can get down to almost ground, it won't get high enough - due to the current it will have to sink - to get your full output voltage range here IMO.
You've got that backwards. The LM358 won't do without a negative supply because it can't sink enough current with a low enough saturation voltage for 1.25V out. The higher end of the voltage range is no problem.

Well, yeah. The sink current (as opposed to source) is going to have the opposite effect. My bad.

That said, I think an LM358 can sink 5mA without much problem. Its output should be able to get as low as a few tens of mV, and I think it will still get further away than this from the positive rail on the other end. From its datasheet, it's given for a typical 8mA of max current sink. Would have to be tested, but simulation shows that the output can go as low as ~30mV for 5mA of current sink, and can't get higher than the positive rail minus ~1.2V, so there's still this asymetry (of course for higher currents, the output range would get shifted up). Looking at an LM317 datasheet, its reference voltage is specified between 1.2V and 1.3V, so a minimum of 50mV output for the opamp is not really going to make much of a difference actually. If the OP really wants 1.25V min voltage output to a few mV of accuracy, then clearly this topology is not for them. Given the proposed schematic and their questions, I doubt 50mV or 100mV from 1.25V will make any difference! But if it did, I guess an LM317 could go lower than its reference voltage by setting a negative voltage on its ADJ pin, but not 100% sure it would not cause issues. In this case, a slightly negative supply voltage (-15V would certainly not be needed) should allow to do this.

(As to the higher end, there is a lot of headroom here actually, if the opamp is powered by the input voltage of the circuit, given that the LM317 has around 2.5V of dropout voltage and there is an extra 1.25V, so that's 3.75V of headroom. So yes the higher end shouldn't be a concern here anyway.)

The OP's schematic's idea was actually given here: https://www.edn.com/design/analog/4363990/Control-an-LM317T-with-a-PWM-signal
There are of course a lot of ways to do better, but as far as I've gotten it, the OP simply wanted something that "works" before going any further and chasing after a few mV... ::)
And in that case, it seems to just be a matter of using a more appropriate opamp than the TL081.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #17 on: February 02, 2019, 09:22:33 am »
I would get rid of the -15V supply and select an appropriate opamp. An LM358 would kinda work, but it doesn't have nulling offset pins (if that matters, since you'd probably get only a few mV offset), and whereas its output can get down to almost ground, it won't get high enough - due to the current it will have to sink - to get your full output voltage range here IMO.
You've got that backwards. The LM358 won't do without a negative supply because it can't sink enough current with a low enough saturation voltage for 1.25V out. The higher end of the voltage range is no problem.

Well, yeah. The sink current (as opposed to source) is going to have the opposite effect. My bad.

That said, I think an LM358 can sink 5mA without much problem. Its output should be able to get as low as a few tens of mV, and I think it will still get further away than this from the positive rail on the other end. From its datasheet, it's given for a typical 8mA of max current sink. Would have to be tested, but simulation shows that the output can go as low as ~30mV for 5mA of current sink, and can't get higher than the positive rail minus ~1.2V, so there's still this asymetry (of course for higher currents, the output range would get shifted up). Looking at an LM317 datasheet, its reference voltage is specified between 1.2V and 1.3V, so a minimum of 50mV output for the opamp is not really going to make much of a difference actually. If the OP really wants 1.25V min voltage output to a few mV of accuracy, then clearly this topology is not for them. Given the proposed schematic and their questions, I doubt 50mV or 100mV from 1.25V will make any difference! But if it did, I guess an LM317 could go lower than its reference voltage by setting a negative voltage on its ADJ pin, but not 100% sure it would not cause issues. In this case, a slightly negative supply voltage (-15V would certainly not be needed) should allow to do this.
The simulator you've used doesn't model the output stage correctly. Never rely on the manufacturer's SPICE models to accurately show things such as output voltage saturation, supply current and input common mode range. They're more often than not wrong. The only way to test this is to build it!

The LM358 doesn't have a proper single supply output stage. It has 50µA current sink, consisting of a current mirror, connected to an ordinary push-pull stage, with a PNP low side. As long as the output isn't sinking any more than 5µA, the saturation voltage will be fairly low and there's a huge ramp up, as the current exceeds 10µA.

This is all on the datasheet.
http://www.ti.com/lit/ds/symlink/lm158.pdf

In short, the LM358 is not designed to sink any current, with its output at the negative rail
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #18 on: February 02, 2019, 09:58:43 am »
Once more - using a NPN darlington output stage instead of 317 solves all of these hassles. Only current supplied, not needed to be sunk!
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #19 on: February 02, 2019, 12:38:50 pm »
Once more - using a NPN darlington output stage instead of 317 solves all of these hassles. Only current supplied, not needed to be sunk!
That's all well, until it overheats, resulting in magic smoke. It also will have a higher drop out voltage than the LM317, as the saturation voltage of the op-amp's output stage will add to Darlington pair.

Just use the LM317 and current sink, to provide the minimum load. It's not complicated.
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3540
  • Country: es
Re: LM317 control by PWM
« Reply #20 on: February 02, 2019, 01:16:34 pm »
If I understand how this IC works then a bias voltage like in the attached diagram should control the LM317 output voltage.  Then it is just a matter of filtering the PWM so that it results in a stable voltage. The two diodes help bring the output closer to zero but they can be omitted if not needed.

With R1 = R2 roughly Vout = - Vcontrol.

Increasing the value of R1 would make roughly Vout = -(R1 / R2) * Vcontrol

Maybe somebody can go over it and check.
« Last Edit: February 02, 2019, 01:57:25 pm by soldar »
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #21 on: February 02, 2019, 02:10:32 pm »
If I understand how this IC works then a bias voltage like in the attached diagram should control the LM317 output voltage.  Then it is just a matter of filtering the PWM so that it results in a stable voltage.
Yes, that's the general idea. The trouble with that configuration is the op-amp has to sink all of the current.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: LM317 control by PWM
« Reply #22 on: February 02, 2019, 02:23:43 pm »
Once more - using a NPN darlington output stage instead of 317 solves all of these hassles. Only current supplied, not needed to be sunk!
That's all well, until it overheats, resulting in magic smoke. It also will have a higher drop out voltage than the LM317, as the saturation voltage of the op-amp's output stage will add to Darlington pair.

Just use the LM317 and current sink, to provide the minimum load. It's not complicated.

Who cares about the Vdrop? Was not in the requirement list.

Why should it overheat?  Your LM317 will anyway, if you will not use enough heatsinking.

That is like saying your car is going to crash, because it is an older model without airbags. It is the same kind of logic.

//EDIT: Using a compound darlington the Vdrop becomes even smaller

//EDIT2: Wanted to compare the voltage drops, and ... wtf is this?
« Last Edit: February 02, 2019, 02:31:43 pm by Yansi »
 

Offline soldar

  • Super Contributor
  • ***
  • Posts: 3540
  • Country: es
Re: LM317 control by PWM
« Reply #23 on: February 02, 2019, 03:42:25 pm »
Yes, that's the general idea. The trouble with that configuration is the op-amp has to sink all of the current.
I am sorry but I don't understand. What op-amp? Are you referring to the LM317? In which case... yeah. Isn't that what it is supposed to do?

If you are referring to the voltage source I have included, then, no, it does not sink all the current. The main current returns via the common ground. The PWM signal is very small and can be generated using a 555 timer or anything else, completely independent of the rest of the system.

Maybe I am missing something.

I am not good enough with LTSpice yet but maybe someone can do it. I would start by just connecting R2 to a variable negative voltage. Then add the diodes. Then add LC filter and put a PWM signal there.
« Last Edit: February 02, 2019, 04:26:02 pm by soldar »
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: LM317 control by PWM
« Reply #24 on: February 02, 2019, 05:50:07 pm »
Once more - using a NPN darlington output stage instead of 317 solves all of these hassles. Only current supplied, not needed to be sunk!
That's all well, until it overheats, resulting in magic smoke. It also will have a higher drop out voltage than the LM317, as the saturation voltage of the op-amp's output stage will add to Darlington pair.

Just use the LM317 and current sink, to provide the minimum load. It's not complicated.

Who cares about the Vdrop? Was not in the requirement list.

Why should it overheat?  Your LM317 will anyway, if you will not use enough heatsinking.

That is like saying your car is going to crash, because it is an older model without airbags. It is the same kind of logic.

//EDIT: Using a compound darlington the Vdrop becomes even smaller

//EDIT2: Wanted to compare the voltage drops, and ... wtf is this?
1) Voltage drop is important because you won't be able to get 30V out, without exceeding the maximum voltage rating of the LM358.

2) Reading between the lines, it's probably for a bench power supply, so it will be abused and thermal protection is important.

3) Yes a compound transistor helps, but still no thermal protection.

4) An error.

Yes, that's the general idea. The trouble with that configuration is the op-amp has to sink all of the current.
I am sorry but I don't understand. What op-amp? Are you referring to the LM317? In which case... yeah. Isn't that what it is supposed to do?

If you are referring to the voltage source I have included, then, no, it does not sink all the current. The main current returns via the common ground. The PWM signal is very small and can be generated using a 555 timer or anything else, completely independent of the rest of the system.

Maybe I am missing something.

I am not good enough with LTSpice yet but maybe someone can do it. I would start by just connecting R2 to a variable negative voltage. Then add the diodes. Then add LC filter and put a PWM signal there.
I don't see how that circuit is supposed to convert 5V PWM into 1.25V to 30V.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf