Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting an LM317 to a precision supply

Status
Not open for further replies.

Mosaic

Well-Known Member
Hi all:
I am doing a microcontroller project and I found myself needing an extra I/O pin. So I thought I'd do away with the precision Vref and make the 5Vdd a precision source.

Here is what i came up with, it simulates ok with a 500 Hz, +/- 50mA , switching drain while under a 500mA constant load. The simulator compares the regular LM317 vs the modified circuit with a precision reference control using an OPA driving an NPN as an active resistance.
I'd switch the 5V zener for a 0.5% LM4040-5V shunt in the actual circuit and increase R8 to about 1K to keep the Iz under 15mA.
The chart shows the green trace as the precision ref'd output. Note the switching load kicks in at 0.1 second.
This is my first crack at such a device so perhaps there are improvements that I am not seeing. The blue trace shows the effect of the switching load on the regular LM317 output on the right. Both circuits share the same load & primary supply for normalised data.
Screenshot_1.png
 
hi Mosiac,
The ADC in a PIC is ratiometric, which means the ADC counts will track any changes in Vdd, so if you use the PIC's internal Vdd as the Vref you dont need a precision supply
E
 
Even if you wanted to use the 317 to derive your Vdd, aren't the external Vref and opamp superfluous? The 317 has an internal Vref and provides typical line regulation of 0.01% per V and load regulation of 0.1% according to the datasheet.
 
Hi,

You seem to be saying that you need 0.5 percent accuracy on the reference voltage so i assume you will be using the A to D converter on the chip. The on chip ADC divides the reference voltage by N where N is something like 1024 for a 10 bit ADC, so that means that each bit value is worth 5/1024 volts. So if you had an external voltage on the ADC input that was 50/1024 volts you would see a count of 10 out of the ADC after the conversion was complete, at least in theory. So you want a reference that will maintain that 5/1024 volts per 'count' level to within 0.5 percent. And apparently you have a load that can change by 50ma while at the same time loading with a constant load of 500ma. So your load switches from 500ma to 550ma and you want to make sure the 'reference' voltage is stable.

Well the best approach is probably to just use a regular voltage regulator like the LM317 or better and filter the output with some capacitance, while at the same time making sure that in the code you never take a reading while the load is changing. Since the uC usually initiates any load changes this is usually possible. So wait until the reference voltage has a chance to settle before taking an ADC reading. That's the best way to do it anyway.
You can experiment a little to see if it makes much difference to sample after one instruction period, two instruction periods, etc. If you dont find any difference in readings then you're probably doing ok with it.

The LM317 isnt too bad on regulation. It's pretty good over temperature too, but if you need better then just add a reference diode to the circuit and that should get you to even better spec's. This way you dont have to go through any elaborate circuit design.

You can also look into oversampling or just averaging to get a more repeatable reading each time.
 
Good advice MrAl. From what i see happening in the sim. the LM317 0.5% load regulation spec appears to be an RMS spec; so since the 'noise' duty cycle is small the voltage gyrations can be comparatively large.

Do you see any problem with using the circuit I presented as a means to have relatively clean uC Vdd?

I will also oversample.

This site has some advanced precision regs built around the LM317..
https://tangentsoft.net/elec/opamp-linreg.html

EDIT: After doing a temperature range comparison, I am fairly convinced that the precision ref circuit is the way to go. Note the stable prec. ref'd green traces vs the spread out blue (normal LM317) traces over a 5C to 55C temp range.
tempcomp.png
 
Last edited:
Just a final note...by adding a 2 stage RC pi filter feeding the supply V to the shunt, the ripple caused by the switching is reduced to sub 100 uV on the 5Vdc regulated line, C4 reduced to 100uF. Also, the OPA Vcc is supplied by the 5V reg now, not the 'noisy' 12VDC. Lastly a 3:1 voltage divider is used instead of R9 to feed the transistor base, this permits the OPA output operating point to be about 2 volts, well away from any rail to rail issues.
 
Hi,

Doesnt look too bad actually.

Last thing to consider is the loop stability. See if it performs ok when you get the circuit built, looking for any oscillations. There's a slight chance the op amp might need compensation.

Since you are after such precision then yes the extra circuitry is probably worthwhile. The 317 temperature stability isnt as good as that and then there's always the aging factor.

One thing though, it sounds like you are now bootstrapping the op amp. So you'll want to double check the startup surge on the output of the LM317 to make sure it does not last too long. When power is first applied, the output might go up faster than the op amp can respond so there might be significant overshoot. Might not be, but a good thing to check because the op amps react slower when they have to go from the non linear mode to the linear mode.
 
Hi,

but a good thing to check because the op amps react slower when they have to go from the non linear mode to the linear mode.

Hola MrAl,

Could you please elaborate on the above? A little bit at lost on that.
 
Hi,

Yes. When the op amp is in the non linear mode that means it's inputs are not satisfied by the feedback so the output tries to ramp up or down to the required level in order to provide the right feedback, as it assumes that you have it in a circuit that allows this to work. The ramping time can be quite slow, for the LM358 as slow as 0.5 volts per microsecond, so there may be a couple microseconds where the output jumps up above the set point value (+5v in this case). It may work ok, but with the voltage divider on the output now that means the LM358 has to ramp up higher than 0.7 volts (transistor base emitter forward bias voltage drop). So it's something to check. If the output spikes up before it settles out to +5v then you know what is causing that, but if it doesnt then it could be ok.
 
Thanks MrAl!
 
Thanks MrAl!

Hi there,

You are certainly welcome :)

The main mechanism behind this behavior is the slew rate of the op amp just in case you are interested in looking into this a little more.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top