Pages: [1]   Go Down
Author Topic: Digitally Controlling an LM317  (Read 4046 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to use the Arduino to run the brains of a digitally controlled power supply. I'm using an LM317 regulator as the heart of the system, but I am having trouble trying to control it without a physical potentionmeter.

My input voltage to the regulator is 20 volts. I am using a MAX548 8-bit digital to analog converter controlled by the Arduino to go from 0 to 5 volts. I'm taking the output of the MAX548 and feeding it into an LM324 op-amp with a gain of 4. The output of the op-amp is shifted so it ranges from 0 to 20 volts. I have tried taking the output of the op-amp and feeding it directly into the adjust pin of the LM317, along with a 240 ohm resistor connecting the output of the LM317 to the adjust pin, as shown in the data sheet. Using this configuration, interesting results are produced. The LM317 outputs about 12 volts as long as the value going into the DAC is ~< 135. Once it passes 135, the LM317 output voltage slowly rises as expected until it reaches ~18 volts (which is right where it should end, considering the voltage drop of the regulator).

What can I do to get the lower range working? Any other ideas on how I should approach controlling the lm317? I've tried using various different resistor values coming from the op-amp to the adjust pin, but that hasn't had any effect.
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe skip the DAC and op-amp thing, and get a digital pot (or two)?  Maxim has several, including I2C and SPI interfaces.  I seem to recall there's an Arduino tutorial on using a digital pot.

-j

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just for any other people searching for something later on, I resolved this issue. Turned out that I had the pinout of the lm317 wrong, much to my embarrassment and frustration. This set up works perfectly, it outputs ~2 volts to ~18 volts controlled via the arduino.

kg4wsv, I would have used a digital pot, but I couldn't find any that supported a high enough current running through it to drive the adjust pin at a high voltage.
Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I would have used a digital pot, but I couldn't find any that supported a high enough current
I didn't realize the currents on the digital pots were so small, but the first one I looked at (DS3502) showed max wiper current of 1 mA, and the LM317 data sheet shows a max Iadj current of 100 uA, so it looks like you're covered by a factor of 10 with that example.

Anyway, sounds like an interesting project - good luck!

-j

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This is pretty interesting. Would it be possible to do pwm to create an analog out on the arduino and then use that to control the lm317 ? This could be a nice little digital power supply. Any possibility of sharing you schematic ? Just want to see how you hooked everything up.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://kahrendt.googlepages.com/schematic.png

I threw together this schematic fairly quickly but I think it is all correct. The resistor values would have to change depending on your voltage input into the LM317. The LM324 can get a maximum output gain of VCC - 2 volts, so I set up the resistor to get a gain where 5 volts ends up to be 18 volts. The LM324 can be driven with ground and the +20 volt line, no need for a negative power supply at all.

This design gives two variable outputs from ~2.6 volts to ~18.5 volts. I'm working on finishing up a bench top power supply, just hammering out the bugs right now. I use a 4x4 keypad to adjust the voltages, LCD to present all the information, and using a few voltage dividers to read in the analog output to tie it all together.

You could use the PWM output to drive the op-amp, but then you have to bother with filtering out the waveform. I tried that initially and I didn't have very good luck with get a smooth output, which through off everything later on. I didn't put too much effort into it, and I must confess I know very little about the appropriate way of filtering it. I am using the DAC because it uses an internal R-2R ladder, so the output is constant. If you are more interested in going this route, here is a useful link: http://electronicdesign.com/Articles/ArticleID/13077/13077.html
It is basically the same principle, except using the PWM output.

The MAX548 is outdated as far as I can tell, I just had a few laying around. I'm sure maxim makes a very similar, current DAC that could be interfaced the same way. Really any DAC can be used, its just a relatively simple matter of communicating with the DAC correctly.
Logged

Pages: [1]   Go Up
Jump to: