DIY uC-based variable programmable switching power supply design - Page 1
Forum section: electronics / projects

author: T3STY
author_rank: Contributor
timestamp: September 12, 2014, 01:44:06 am
content: Hello everybody!I would like to have your opinion on an idea that came to my mind. I've been unable to find something similar on the internet so please excuse me if it's the worst thing someone could ever think of.I want to build a programmable, variable, switching power supply, that uses a micro controller device (I personally prefer PICs) to regulate the output voltage. Some control I/O buttons should be available as well as an LCD display. Obviously, if the PIC device has some USB/serial/I2C ports available, it might be used in conjunction with other devices or for PIC <-> PC communication.I have made a design layout of a buck/boost configuration, please have a look at the attachment. The idea is very basic for now, and I'd like to know if it can be done and/or why it will/won't work. Also, if the design is any good, do you think it could be used for an inverting configuration as well?

author: DanielS
author_rank: Frequent Contributor
timestamp: September 12, 2014, 02:24:59 am
content: I hope you are not expecting remotely good efficiency out of that design: what you have here is basically a shunt regulator with a 2nd order low-pass LC filter. The diode is unnecessary since current will always have a path through R3... R3's current will be either going to the load through the inductor or be shared between the transistor short to ground and the inductor.

author: mrflibble
author_rank: Super Contributor
timestamp: September 12, 2014, 09:40:44 am
content: Alternatively, you could get a working buck/boost converter on ebay for a couple dollars. Then to control it from your microcontroller you modify it slightly. Basically you do resistive summing at the FB pin of the converter in the same way you would for normal op amp circuits.That way you keep the loop nice and tight as per the ready-made-pcb, and you adjust the setpoint by varying the voltage on that resistor you just added to the FB node.In it's simplest form all you need is 2 resistors, 1 cap and a PWM output of your microcontroller. Well, and that buck/boost converter from ebay.The slightly better version would use an op amp in addition to the above.

author: T3STY
author_rank: Contributor
timestamp: September 12, 2014, 10:21:57 pm
content: So the idea is a total mess. OK, I'll check for other solutions.Thank you for your help

author: nuno
author_rank: Frequent Contributor
timestamp: September 13, 2014, 01:41:32 pm
content: It's totally doable, but you must revise the switch part of your schematics, that's not a buck-boost (nor a buck, nor a boost).http://en.wikipedia.org/wiki/Buck%E2%80%93boost_converter

author: T3STY
author_rank: Contributor
timestamp: September 13, 2014, 09:14:24 pm
content: Does any of you use a circuit simulator like Falstad? I have tried different simulations with manual switch and transistor switches, but I can't get to work any of them. Maybe can you help me with a reference (component values included) circuit?

author: Skimask
author_rank: Super Contributor
timestamp: September 13, 2014, 09:54:09 pm
content: Quote from: T3STY on September 13, 2014, 09:14:24 pmOr you could just open up one of the example circuits included with the software...

author: timb
author_rank: Super Contributor
timestamp: September 13, 2014, 11:39:19 pm
content: If you put that diode in series with the FET and inductor, it should work as a boost supply, albeit very inefficiently.Sent from my Smartphone

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: September 13, 2014, 11:48:04 pm
content: http://www.ebay.com/itm/DC-DC-60V-20A-1200W-programmable-Constant-Voltage-Current-Power-Supply-Module-/181108964187?pt=LH_DefaultDomain_0&hash=item2a2aef7b5b

author: T3STY
author_rank: Contributor
timestamp: September 14, 2014, 09:54:58 am
content: Quote from: Alex Eisenhut on September 13, 2014, 11:48:04 pm...yeah.. but it's 90$ and way more than I could ever need (3-20V, 2A).I have tried simulating the circuit schematics from wikipedia, I couldn't get any to work as expected. The boost config keeps "boosting", I got spikes of 500+V, while the buck configuration with a load resistor of 1K (parallel to the storage capacitor) just doesn't get higher than 4.7V with whatever component values. I think the simulator simply can't afford such (simple?) simulation.@Skimask: I had a look in the example files list but I couldn't find one of switching power supplies. Could you tell me which one is it?

author: nuno
author_rank: Frequent Contributor
timestamp: September 14, 2014, 11:54:37 am
content: This is a similar thing I did, but it's a buck converter.

author: Strada916
author_rank: Frequent Contributor
timestamp: September 14, 2014, 12:57:40 pm
content: Silicon chip did a hybrid 100W PSU. Not micro. Controled though. April this year if memory serves my right.

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: September 14, 2014, 01:09:14 pm
content: Quote from: T3STY on September 14, 2014, 09:54:58 amI see. But perhaps you can find a nice stand-alone power module and simply make the control panel for it.

author: poorchava
author_rank: Super Contributor
timestamp: September 14, 2014, 01:32:19 pm
content: In general switch mode supplies are not that easy to be made adjustable. Designing compensation circuit and control the software that will work well over the whole range of input and output voltages and currents is not an easy task.

author: nctnico
author_rank: Super Contributor
timestamp: September 14, 2014, 05:48:18 pm
content: True but if you start with the schematic of a proper step down converter circuit (without controller IC though) and add cycle-by-cycle current limiting in hardware using a current transformer, a comparator and flipflop you can mess a lot with software without blowing stuff up.

author: T3STY
author_rank: Contributor
timestamp: September 14, 2014, 07:14:17 pm
content: @nuno: nice schematic! I'll check it out and probably make a similar one for my purpose.Is there anything particular to consider for 0::+19V@2A buck configuration (20V @4.5A input) ?Also, I would like to design an inverting configuration as well for -19::0V@2A output (same 20V input) with common ground. Any drawbacks in doing that?

author: mrflibble
author_rank: Super Contributor
timestamp: September 15, 2014, 08:19:59 am
content: Quote from: T3STY on September 14, 2014, 09:54:58 amThat $90 seems a bit much. Plus I wonder how many of those 1200 MarketingWatts actually materialize in the form of sustained power.The ebay module + small modification I mentioned is more along the lines of this:http://www.ebay.com/itm/LM2596-Power-Supply-Output-1-23V-30V-DC-DC-Buck-Converter-Step-Down-Module-/141361451145That one is buck, and there are similarly priced boost converters as well. Those are so cheap that I just slap them in a project, tweak the pot to set the correct output voltage for that project and job done.And to make it uC controlled, see previous post. Solder resistor to the FB node, inject your set point voltage on other end of resistor and you are good to go. And generating that set point can be done by a uC pwm pin + RC filter. So all you need is 1 C + 2 R, a free pwm pin, and that ebay module.Mind you, that thing is NOT current limited. You only get voltage control. If you want current limit as well, then extra stuff is required. Mostly a sense resistor + LM324 + some more cheapo R's + C's. That's less than $2 total parts, including ebay module.And that does work continuously at your required 2 Amps. The inductor does get pretty hot at that current, or at least on the modules I have here. But they work fine for longer periods. Some I've used 8 hours on end per day, every day. And others for something like 100 hour stretches and no problems so far. All that to say that they will probably meet your current & voltage requirements.

author: timb
author_rank: Super Contributor
timestamp: September 15, 2014, 09:36:30 am
content: The C2000 does Digital Power brilliantly. But you really only need to use an an MCU for switching control when you're doing like a multiple node server power distribution supply where you'll be doing active PFC with full bridge switching and synchronous rectification.For your use it's overkill and you'll never get the efficiency you can get with an off the shelf SMPS IC from TI or whoever.If you want to vary the voltage/current, just use a DAC + OP Amp to vary the feedback voltage. Dead simple and reliable.Sent from my Smartphone

author: dannyf
author_rank: Super Contributor
timestamp: September 15, 2014, 09:39:13 am
content: QuoteFor an all digital solution, you need at least 100mips + fast adc. Some high-end dsPICs may work there. You can check of Freescale for their solutions - they are king of the hills here.A simpler way is an all-analog solution: use a pwm controller / smps chip and apply an analog signal to the feedback nod. The analog signal is generated by the pic, based on the output voltage.It is a lot easier to get it working.

author: mrflibble
author_rank: Super Contributor
timestamp: September 15, 2014, 10:22:31 am
content: Quote from: dannyf on September 15, 2014, 09:39:13 amIndeed. Freescale make some nice chips that are a good fit for this. One of (far too) many things on the todo list.Mind you, I would only do this as a pure learning experience. Not as a pragmatic route to getting an all digital controllable PSU.QuoteYup, seepreviouspost.

author: nctnico
author_rank: Super Contributor
timestamp: September 15, 2014, 01:22:44 pm
content: Quote from: dannyf on September 15, 2014, 09:39:13 amLooking at the basic equations of a step-down converter I know the above is nonsense. Output ripple is still dictated by the output capacitors. The only thing the controller has to do is adjust for variations in the input voltage. Current limiting is trickier but not unachievable (been there/done that).

author: T3STY
author_rank: Contributor
timestamp: September 15, 2014, 04:28:35 pm
content: Wow, soo much feedback from you guys, thank you very much!About all those uC units you're suggesting (C2000, dsPIC, ect.) they're overkill in my opinion. It's not like I need nanosecond control on the output. Most PIC devices are very low MIPS, but they include hardware features that can deliver high performance (like 32kHz PWM on 8MHz main PIC clock). Don't get me wrong, I'm not saying "PIC for evaarrrr"; I'm just saying a "normal" low-budget uC can handle this well enough.mrflibble's suggestion looks quite nice. I don't think it would require much work to get it to work with a uC. Do you think I could use two buck modules with one's positive connected to other's negative and get a dual power supply with a common ground (+15::0::-15)?Quote from: mrflibble on September 15, 2014, 10:22:31 amGot thatevb149 PSFB solution also looks nice, I don't care it requires 4 switches, but I wonder how big the transformer would become. I needed a switching power supply mainly because I needed to get as small as possible. I may consider using a PSFB solution, but I need the transformer to be low profile (not more than 3 cm height).

author: dannyf
author_rank: Super Contributor
timestamp: September 15, 2014, 04:43:52 pm
content: If you aren't looking for efficiency, use a comparator to drive a switch. One input is the output voltage and another is your target voltage.no mcu requiredas to pic based amps, google black roman.

author: mrflibble
author_rank: Super Contributor
timestamp: September 15, 2014, 10:33:25 pm
content: Quote from: T3STY on September 15, 2014, 04:28:35 pmThat's a two part question...1 - Can you generate a negative voltage supply using one of those cheapo ebay converters?2 - Can you generate both a positive and a negative voltage using only 1 input supply?1) yes you can. You will have to make 1 extra mod, because you have to slightly change the way the diode is connected. But it's no biggie.2) I vaguely recall the answer to be no. Not entirely sure, I'll have to consult my notes (read: find the bloody piece of paper). But if you have two floating input supplies (like oooh lets say, two of those 12 Volt wallwarts that you always have loads of) then you can use that to generate a dual +15 V / -15 V supply.Anyways, I'll see if I can find those pesky notes tomorrow.

author: T3STY
author_rank: Contributor
timestamp: September 16, 2014, 02:52:52 am
content: For note 2: if I have a big enough input voltage, say 30V, and I use a 1:0.5/0.5 (half split secondary) transformer or a resistor voltage divider, I could just split the input voltage in two and as such create +15::0::-15 before I use those SMPS modules. If I use a transformer there I could also use a 1:2 winding to create 30V (still split as 15+15) or so from a merely 16V input. Did I get this right?For note 1: I should convert a buck configuration into an inverting configuration. I don't think it's easy doable, and most inverting designs I seen on application notes of LM2576 (and similar) report that I could only go up to 700mA current, by far less than 2A. Also, I would not really get to use 2A, but I'd feel better to know I have the little extra just in case.EDITstill about note 2: the thought might be correct but I get a lot of current loss since output power must be equal to input power. Supposing I have 15V input at 4A and I want 30V output (half split, but still 30V total), then the output current is (15V*4A)/30V = 2A.Since I want to use 19V @3.5A power supplies that come with laptop PCs, it puts me down on using a transformer to double the output voltage... any ideas?

author: T3STY
author_rank: Contributor
timestamp: September 16, 2014, 11:38:13 pm
content: Quote from: evb149 on September 16, 2014, 05:06:47 amYeah, I thought of that right after I posted above... even using the switching modules directly from the main power supply, I could never go more than available.dumb question: can I use a linear transformer with DC instead of AC? I could only find examples of transformers used in AC and I have not much knowledge about.Also, do you have any good links about PSFB power supplies? I could understand the basic functioning from a few web pages, but I'd like to know more. However, at this point I'm more interested in using those simple buck converter modules since it requires less knowledge and sounds easier to put together.

author: timb
author_rank: Super Contributor
timestamp: September 17, 2014, 12:21:50 am
content: Running DC through a transformer will burn it up.Think about it, it's just a coil of thin wire that runs from + to -; what happens when you short out a battery or other DC power source? The reason AC doesn't burn it up is because the polarity is constantly changing.In a SMPS that uses a transformer instead of an inductor, they take AC in from the line, rectify it to HVDC and then use switching to turn it back into square-wave AC. After it goes through the transformer there will be either a diode or another switch to rectify it back to DC.Sent from my Smartphone

author: poorchava
author_rank: Super Contributor
timestamp: September 17, 2014, 06:14:19 am
content: Microchips has a PICs that integrate peripheral module called PSMC (programmable switch mode controller). I've never used it but it seems like a good first shot.