Digitally selected power supply, or, I'm not quite as clever as I thought I was. - Page 1
Forum section: electronics / projects

author: poodyp
author_rank: Regular Contributor
timestamp: August 07, 2011, 02:14:23 am
content: I thought I'd try to add simple digital selection to a simple LM317 power supply I made using a PIC. I started by making a DAC using PWM and a two stage RC low pass filter, then feeding that into an op-amp to scale the 0-5v from the PIC to 0-12v, then fed that into adj pin on the LM317.The problem I discovered is that the output won't go below ~3v. My guess at what's happening is that when the output from the op-amp is too low, the output of the 317 is feeding itself because there's no path to ground. Is there some way I can fix this? Or is my design flawed?Thanks.

author: Bored@Work
author_rank: Super Contributor
timestamp: August 07, 2011, 08:31:56 am
content: You need to drive the ADJ pin of a 317 to -1.25V (yes, that is a minus) to get 0V output. This requires that your op-amp has a negative supply, and the op-amp biased that it generates -1.25V output when the input from the PWM DAC is 0V. Do you have a negative supply? Do you have the op-amp biased?If not, the best you can get with a single-supply is +1.25V output. This requires that the single-supply op-amp can go down to close to 0V. And that requires a rail-to-rail op-amp. Do you use a rail-to-rail op-amp?If you get +3 V output it means your op-amp is driving the ADJ pin down to +1.75 V only. Measure that. Especially without the 317 connected. Further, do some math. The current the op-amp needs to sink is dictated by the resistor you selected for the OUT - ADJ resistor of the 317. The typical values for this resistor result in 5 mA or 10 mA current the op-amp has to sink. Check in the datasheet of your op-amp if yours can sink so much current. If not, you can increase the resistor to around 1200 Ohm, but then need to make sure that you connect a load that ensures the 317's required minimum load is met.

author: poodyp
author_rank: Regular Contributor
timestamp: August 08, 2011, 10:17:38 pm
content: So I did some more testing. I wasn't thinking and didn't realize the op-amp had to sink the current, not source it. I'm using an LM324 and while it can source 20-30ma, it can only sink 8ma. I was using a 120ohm resistor so I swapped it out for a 1k and put the 120 between Vout and gnd, Vout dropped to 1.2v.I only used the LM324 because that's the only op-amp I have on hand. What are some good generic op-amps I can keep around just to have on hand?Thanks for the help.

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 09, 2011, 04:01:16 am
content: Replace the LM317 with a MOSFET and change the circuit accordingly. Or use a charge pump (run from one side of the transformer secondary) to get a negative voltage for the opamp.

author: Zero999
author_rank: Super Contributor
timestamp: August 09, 2011, 05:16:20 pm
content: If the LM317 is replaced with a MOSFET, you'd loose the overcurrent and thermal protedtion and you'll need the gate voltage to be 5V above the output voltage (assuming it's a logic level device).It's possible to use the LM324, if it has a negative supply. Increasing the R1 may cause the output voltage to rise at no load.

author: poodyp
author_rank: Regular Contributor
timestamp: August 10, 2011, 04:18:42 am
content: I did want to keep the regulation and protection features of the 317, as it is much smarter than I am when it comes to that stuff.Does the LM324 needs a negative voltage to be able to get 0Vout? I'd be happy with the 1.25 minimum of the LM317, not sure yet what I'd need anything lower than that for, yet, so I think I can skip it. I tried increasing R1 then adding resistors to load the regulator, but then they'll burn at higher voltages. I think the easiest method is to get an op-amp that can sink the 10mA required.Anyway the wall-wart I was using seems to have died for no reason, so I'll have to shelve this until I get around to getting a replacement.Thanks all.

author: Zero999
author_rank: Super Contributor
timestamp: August 10, 2011, 04:45:11 pm
content: The answers to many of your questions are on the datasheet.http://www.national.com/ds/LM/LM124.pdfPage 5: Output current: SinkPage 8: Graph: 00929944: Output Characteristics: Current SinkingYou won't be able to get 1.25V minimum because you won't be able to find an op-amp which can happily sink 10mA with an output voltage of <10mV, at least not cheaply. I think the best solution is to power the op-amp from a negative power supply, that way you can easily go down to 0V. It's fairly easy to generate a negative supply: using a couple of diodes and capacitors to form a voltage doubler run from the AC coming from the transformer, or if you're running it off DC, you can generate a squarewave from a PIC output.

author: poodyp
author_rank: Regular Contributor
timestamp: August 11, 2011, 07:20:59 am
content: Oh duh, 0.05mA at 0.1Vout... not going to work much. So negative voltage it is. I could even bias the output to generate -1.25Vout and kill two birds with one stone, right?Edit: Something likethiswould work, yes?I suppose while I'm at it an output relay would be good to make sure everything's stable so I don't fry something with 15 volts.

author: Zero999
author_rank: Super Contributor
timestamp: August 11, 2011, 07:34:06 pm
content: Yes, the 555 is one way of doing it but is pretty silly in your case as you already have a microcontroller capable of generating a squarewave. All you need to do is omit the 555 and associated components, connect the I/O input to C3 annode and program the MCU to generate a 2kHz squarewave.Here's another way of doing it. T1, D1 and C1 are the existing transformer, filter capacitor and bridge rectifier in your circuit. In your case D2 could be replaced with a 5V zener, as 9V plus the voltage across C1 may be too high for the LM324.

author: poodyp
author_rank: Regular Contributor
timestamp: August 17, 2011, 09:21:41 pm
content: So I went out and got a new transformer to replace the brick I was using that died (Must've been a lot of heat in there, the cap was totally dead)). I decided on a 9+9V 2A, as 9 volts is fine for now, I'm only doing logic level stuff, but I can also opt for 18V later on if I need it.I have the two halves of the secondaries together, with the center tap as ground. On my multimeter I seem to be getting 15.7V which seems high. Loading it with a 150ohms the voltage only drops to about 14.99V. Peak to peak should only be ~12V, but after the loss in the diodes it should be less, right? Everything seems to be working fine.Also, quick side question: I have a SPST switch that's rated for 120VAC, but has an indicator lamp that's rated for 12VDC. If I want to switch the mains properly, I need to be able to cut off both lines, right? And in order to use the lamp I'll have to switch the ground and use 12V, or switch the output and use ground, right?Hopefully everything I need will get here soon. Thanks.