ATmega328 controlled Power Supply? - Page 1
Forum section: electronics / projects

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 04:00:19 am
content: Hi everyone, first forum postI was trying out several circuits in order to have digital control of a power supply. The first method I tried was extremely non-linear (PWM output of the ATMega328 compared to the output voltage), and this made the programming v. difficult. It was done by using a number of transistors to amplify the voltage and current of the PMW or DAC to be able to vary the output voltage. Sadly, I cant find the schematic, I will post a link of where I found it soon.Basically, my program consists of a voltmeter, ammeter sketch along with 6 control buttons (Current +,-, Voltage +, -, etc.). I wanted to see whether I could feed in a voltage from the ATMega328 PWM output (filtered of course) to the feedback pin of a very popular switching regulator, the LM2576. So I proceeded to buy one of those cheap LM2576 DC-DC buck converter boards from eBay. However, as I dialled up the voltage using the potentiometer on the board, the feedback pin maintained a constant voltage.Thanks

author: BravoV
author_rank: Super Contributor
timestamp: November 19, 2013, 04:07:37 am
content: If I understand you correctly, are you planning to put the MCU into the role of regulating the voltage output ? aka MCU is in control of the voltage control loop ?Just forget it, you will get horrendous output regulation.Let alone that tiny under powered mcu, its even not easy to implement that at a beefy ARM >50Mhz mcu that has very efficient ISR mechanism, real fast ADC (MSPS rate), dedicated hardware PWM block and tight & mean watch"dog" timers

author: BravoV
author_rank: Super Contributor
timestamp: November 19, 2013, 04:50:33 am
content: Quote from: Thane of Cawdor on November 19, 2013, 04:25:04 amWatch Dave's video on uSupply series.The word digital in the power supply "usually" means the digital part takes part only like for the interfacing like UI or electronics interface such as USB/Ethernet etc, and also provides references like the voltage or current setting for the "analog" part to work/regulate with. NOT for controlling the power regulation loop.

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 06:03:16 am
content: I have watched the series many times over. Sadly however, the LT3080 is very hard for me to get and also on the pricey side knowing how many I will accidentally breakDave showed how to use an LM317 with PWM, would you recommend this method rather than the LM2567 way?Also, what do you think about this simple way to control the output voltage LINK:http://new.linuxfocus.org/English/June2005/article379.shtml

author: Bored@Work
author_rank: Super Contributor
timestamp: November 19, 2013, 06:06:33 am
content: Quote from: Thane of Cawdor on November 19, 2013, 04:00:19 amThat is whole idea of these regulators, SMPS or linear and thats what you pay for. They work pretty hard to keep the voltage at the feedback pin constant.You can control regulators with ground-referenced feedback by driving an additional current into the feedback node, offsetting the feedback loop a bit, which in turn requires the regulator to adjust the output voltage until the feedback voltage is again the desired constant voltage. Calculating the necessary feedback resistor combination and current is a nice exercise in using EE principles like Ohm's law and Kirchhoff's laws.You can control regulators with output (high side) referenced feedback (LM317, LM338, etc.) by adding a voltage between the feedback pin and ground. Calculation of that voltage is trivial.Edit:Quote from: Thane of Cawdor on November 19, 2013, 06:03:16 amThat is the bullshit solution people just recommended against in their postings here. Rightfully.

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 06:28:19 am
content: Thanks for sharing your knowledgeI finally understand why the voltage remains the same on that pin! Would you know of any websites that go in detail about the calculation of the current required for offsetting the feedback pin to a certain output voltage level?Also, why is that design that I linked in bad? I am too much of a beginner to be able to identify the flaws.

author: Unknown
author_rank: Unknown
timestamp: November 19, 2013, 08:19:23 am
content: The ADC of that design samples at about 10 kS/s. Last time I looked at the software it would change the output by one ADC LSB (0.1% of the output voltage, eg. 0.01 V for a 10 V maximum voltage) after every ADC sample, so changing from 0 V to 10 V would take 0.1 s. This is an age in electronics, and is in the same order of magnitude as it might take you to turn down a knob. Slewing 1 V would take 10 ms, while residual 120 Hz ripple, as you might expect from an unregulated wall wart, would go up and down every 8.3 ms. Let alone anything faster, like a load doing PWM. The base line is that bandwidth and slew rate absolutely sucks compared to even a 40 year old analog regulator, resulting in terrible noise rejection and transient response.You could probably improve it by sampling faster and using a more refined (eg. PID) control algorithm, but you'd have trouble getting the performance of even a lowly uA 741 or LM317. And it would certainly not be any simpler.

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 08:35:19 am
content: Thanks again!So what do you think about driving the filtered PWM output into a LM2576 switching regulator? Any advice or ideas?

author: shailesh3t
author_rank: Regular Contributor
timestamp: November 19, 2013, 10:58:37 am
content: I have just bought a switch mode power supply (B3603 DC-DC Digital Control Step-down Module LM2596S 6V~40V to 0~36V 0-3A) for 17 US dollar where u have current and voltage control it works well, but i dont like the fact that u have to press switch to read the current or set voltage, prefer to have 2 rotary encoders to do the job and an LCD to show the values, am in the process of doing the modification, right now am still trying to figure out the pins to play with and have to write a program on an arduino to do so.[https://www.youtube.com/watch?v=S_KjmF1iI9w]

author: quantumvolt
author_rank: Frequent Contributor
timestamp: November 19, 2013, 11:00:45 am
content: There are formulas that will get you started understanding PSUs with current-feedback or trim inputs in the datasheets of LTC2977 and LTC2974.

author: quantumvolt
author_rank: Frequent Contributor
timestamp: November 19, 2013, 12:01:59 pm
content: Forget the chip. If you want to know what it does: Read the datasheet (I guess that is too much asked) ...You wrote:"Would you know of any websites that go in detail about the calculation of the current required for offsetting the feedback pin to a certain output voltage level?"Well - R30 does that into the junction of R10 and R20. Formulas for a task similar to yours are in the datasheets.My final advice: Buy a rotary knob China-volt-box from fleabay ..

author: dannyf
author_rank: Super Contributor
timestamp: November 19, 2013, 12:07:26 pm
content: QuoteThere are prtty much the same: all regulators have a feedback pin that regulates the output voltage. The regulator will try to maintain a constant voltage on that feedback pin by changing the voltage on the output pin. All you need to do is to attempt to impact the voltage on the feedback pin, in order to force the regulator to change the voltage on the output pin.So use your mcu to generate a voltage, and sum that voltage to the feedback pin via a resistor. Done. A big issue with such a system is that its stability is generally beyond most people's capability to assess, including many professional designers.After that, you can figure out ways to refine the system, for example by adding constant current capabilities, etc.

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 12:12:14 pm
content: QuoteWould the software controlled current limiting work? By that I mean, once the measured output current exceeds set current, the voltage is reduced to a level where the current is less than the set current.Thanks

author: dannyf
author_rank: Super Contributor
timestamp: November 19, 2013, 12:32:21 pm
content: QuoteIt can certainly be made to work - the solution can be either analog or digital.You obviously will need a current sensor for that.

author: Thane of Cawdor
author_rank: Regular Contributor
timestamp: November 19, 2013, 12:36:52 pm
content: Would that be the only viable solution to current limiting in this situation? I would have liked a separate current limiting function that is done in hardware

author: kizzap
author_rank: Unknown
timestamp: November 19, 2013, 10:19:58 pm
content: Quote from: Thane of Cawdor on November 19, 2013, 12:36:52 pmBoth are equally usable, as long as you know what you are doing. I'm personally designing around the hardware current limiting. The only thing I can think that might be an issue (I haven't looked into it at all) is the read time of the ADCs that you will need to use to measure the output voltage, and measured current.-kizzap

author: dannyf
author_rank: Super Contributor
timestamp: November 19, 2013, 11:18:25 pm
content: QuoteI am sure you could, as long as your mcu knows when the current limiter is kicking in. Otherwise, your current limiter is trying to decrease the output voltage while your mcu is trying to increase its output voltage.

author: MaxPower
author_rank: Newbie
timestamp: November 24, 2013, 07:13:06 am
content: You are not supposed to manipulate the output voltage of the converter by applying a control signal to the feedback pin. Feedback is part of the control loop and must be left alone. Do it at the cost of sacrificing performance and output regulation. The output voltage of LM2576 is adjusted by changing the feedback gain which is set by R1 and R2. The only way that you can manipulate the output voltage via a microcontroller is to use digital potentiometers instead of R1 and R2 in order to change the feedback gain and effectively change the output voltage.If you have ever modeled a switching converter, you would know that both output voltage and current can be expressed as a function of a control signal (I am referring to "control to output voltage" and "control to output current" transfer functions). That control signal is generated by the compensator and passed to the modulator with proper gain in order to adjust duty cycle and effectively the output voltage or current.In order to limit the output current of the converter effectively, you should be able to set a limit on the maximum control signal and duty cycle which means direct manipulation of the compensator and modulator. Since there is no direct access to the control logic of LM2576, therefore there is no direct way to limit its output current.If you want a switching converter with the flexibilities that you have mentioned, your best bet would be to build your own.

author: Bored@Work
author_rank: Super Contributor
timestamp: November 24, 2013, 07:54:55 am
content: Quote from: MaxPower on November 24, 2013, 07:13:06 amBullshit, this is simply wrong. Injecting an additional current (from a DAC) is all it takes. It has been done thousand times and simply works. Digital pots are a piece of crap and there is absolutely no point in using one here. All one needs to do is to run a few numbers and using Ohm's and Kirchhoff's laws.Maxim has an app note about ithttp://www.maximintegrated.com/app-notes/index.mvp/id/5058Or an Electronic Design article (however they got their math wrong, so I only link to the "complicated" schematic)Or what about this38 year oldapplication note from Motorola?https://www.eevblog.com/forum/blog/eevblog-259-psu-rev-c-schematic-part-12/?action=dlattach;attach=22133A DAC as current sink in the feedback.I find it funny that we now have two pages of discussion, but no one could be arsed to do the few calculations. Instead we have to hear bullshit about the need for digital pots.

author: quantumvolt
author_rank: Frequent Contributor
timestamp: November 24, 2013, 12:44:50 pm
content: Quote from: Bored@Work on November 24, 2013, 07:54:55 amThanks for the Maxim link. Very useful. If it wasn't for that link, I wouldn't waste my time posting here again.As I wrote in post #10 in this thread, a very instructive set of calculations of the feedback divider and DAC force resistor is pedagogically presented in the datasheet for LTC2977, but it seems that nobody RTFD. Or may be they need a link to find ithttp://www.linear.com/product/LTC2977. Click on "Datasheet"

author: quantumvolt
author_rank: Frequent Contributor
timestamp: November 25, 2013, 06:18:00 pm
content: Quote from: quantumvolt on November 19, 2013, 11:00:45 amI don't know how to get the message through to you. The very same 3 resistors between V_OUT, V_FB and V_DAC that you are asking for now (R1, R2 and R3), were given to you a (small) week ago (R10, R20 and R30 - see page 83 in the LTC2977 datasheet).And you can put in any voltage source you like at V_FB - a DAC, PWM, DigPot or a battery with a servo controlled pot (potensiometer-robot-supply ( ??)) ... A proper value for the resistor R30/R3 will limit the current. Your problem is to determine the values for the resistor triplet for your application. Unless you start to read, make some calculations and do some experimental research your chances are imo very small.

author: asilva10
author_rank: Contributor
timestamp: November 25, 2013, 07:12:21 pm
content: Any suggestion for a simpler alternative (single channel) to LTC2977 which has 8 channels?Like, would LTC2970 be enough for the mentioned project? In this case, it seems that we also need to add a DAC chip (? LTC3883).I also noticed that LTC3883 can do the job via I2C. However, there's a limitation on the range of the output voltage.

author: quantumvolt
author_rank: Frequent Contributor
timestamp: November 25, 2013, 10:22:01 pm
content: Quote from: asilva10 on November 25, 2013, 07:12:21 pmAs I wrote in an earlier post - FORGET LTC2977. It's a PMBus controller and is very overkill/unusable here. The question asked and my answer was about R10, R20 and R30 only. Please read TF thread.If you are not determined to use a switch mode unit, go to your bench and build something like the supply below. All you need is any uC/Arduino and a 3 pin regulator. When you have something working, a lot of people (including me) will tell you how to use a rotary knob / keyboard / DAC / PWM and implement current limiting (hardwired and software). Also - since the design is based on 'TRIM' instead of 'FB' (feedback), you don't have to do any math. But MAKE something - this thread is but air-ware ...http://www.electronics-lab.com/projects/power/020/

author: dannyf
author_rank: Super Contributor
timestamp: November 26, 2013, 12:25:27 am
content: QuoteA simpler (and better in my view) version of that is to get rid of the base resistors / leds + transistors and tie R10..14 directly to the port. At that point, you have THREE options for each pin:1) logic 0 activates the corresponding resistors and increases the output voltage;2) logic 1 also activates the corresponding resistors but decreases the output voltage;3) putting the pin to input, .....,QuoteAnother way to construct the same circuit is to use a R2R like ladder -> no more weird resistor values.QuoteAgreed.