Electronics > Beginners

PWM for LM317 - how to increase resolution?

<< < (6/9) > >>

Zero999:
ogden,
I did the original LM317 schematic many years ago, when I was at school, using a child's simulation program called Crocodile Clips, which didn't even have an LM317, so I added it in MS Paint. I did the recent modifications for the PWM, using KolourPaint. The potential divider schematics were either done using the copy and pasted symbols from the other schematics, in KolourPaint or MS Paint, depending on whether I was using a Linux or Windows PC at the time and I can't remember which. Nowadays I do most of my schematics with LTSpice, but I occasionally still use MS/KolourPaint

Seekonk,
Yes a buck converter is a good idea. The switch could also be directly controlled by the MCU, but I agree, it's better to use a proper SMPS IC.

joeyjoejoe,
Are you still interested? If so, I'll add the information about using the online calculator to get standard values and more on PWM filtering, although I don't think ripple is a big problem for a battery charger.

joeyjoejoe:
Hey Hero! I'm all good - I think the ripple I have is no issue for a battery charger.

So for R2, I kept the same value. So I have

R1 = 7k6
R2 = 2k4
R3 = 933ohm

I was just gonna find something close enough as it doesn't have to be bang on.

Zero999:
All right, so you want  3.5v to 4.7V from 0V to 5V.

The potential divider needs to scale 5V to 4.7V-3.5V = 1.2V

VOUT = VIN*R2/(R1+R2) = 5*2400/(7600+2400) = 1.2V

Good, you've got that bit right. Now let's look at the LM317. The voltage needs to be set to 3.5V.


VOUT = VREF*(1+R2/R1)

R1 is the value of R3 in the new circuit, which is 933Ohm

And R2 is equal to the value of R1 and R2 in parallel in the new circuit.

R2 = (7600*2400)/(7600+2400) = 1824
VOUT = 1.25*(1+1824/933) = 3.69V

That's quite a bit off. Let's look at how to calculate R1 in the original LM317 circuit.

VOUT = VREF*(1+R2/R1)

Rearrange to make R1 the subject:
R1 = R2* VREF/(VOUT- VREF)
R1 = 1824*1.25/(3.5-1.25) = 1013.33

Back to the new circuit:

R1 = 7.6k
R2 = 2.4k
R3 = 1.01333k

Now we have the ratio of the three resistor values, we can now look at choosing standard E24 or E96 values to match them. For that we can use an on-line calculator. Unfortunately the calculators, I could find are designed for three values are aimed at potential dividers, but they can still be used for this circuit, with a little arithmetic.

Imagine all the resistors are connected up in series: It would also make a potential divider.

The total value would be:
RTOTAL = 7.6k+2.4k+1.01333k = 11.01333k

Now if we applied 11.01333V to the potential divider.


The voltage across each resistor would be equal to its value in kOhms so:

V1 = 11.01333V
V3 = 1.01333V
V2 = 2.4+1.01333 = 3.41333V

Here's where the calculator website comes in. If the above voltages are entered into the three resistor potential divider section, it will generate the nearest combination of standard resistor values which will give us as close to the desired resistor ratio as possible.
http://sim.okawa-denshi.jp/en/teikokeisan.htm

For E24 values it gives:
R1=5.1kΩ
R2=1.6kΩ
R3=680Ω
Which is probably near enough.

E96 values gives:
R1=3.09kΩ
R2=976Ω
R3=412Ω
Which is quite likely more precise than the LM317 so is a bit overkill.

Here's another potential divider tool which only works with two resistors, but can be handy for determining the ratio of R1 and R1: see the results in the "ideal values" section.
https://www.random-science-tools.com/electronics/divider.htm

Exercise for the reader: put the above values back into the original formulas and see how they match to the desired values.

Zero999:
Here's a spreadsheet which calculates the values of R1, R2 and R3.

joeyjoejoe:
I might need some guidance on filtering.

I'm not sure what I was doing before, but now I'm getting 200mV ripple. The issue is this is throwing off the ADC in reading the voltage output of the regulator. I'm going to take a look at your earlier post and split up R1 and see if that gets things under control.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod