Author Topic: ATmega328 controlled Power Supply?  (Read 14930 times)

0 Members and 1 Guest are viewing this topic.

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
ATmega328 controlled Power Supply?
« on: November 19, 2013, 04:00:19 am »
Hi everyone, first forum post

I 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
« Last Edit: October 01, 2014, 03:33:02 pm by Thane of Cawdor »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7549
  • Country: 00
  • +++ ATH1
Re: Arduino controlled Power Supply?
« Reply #1 on: November 19, 2013, 04:07:37 am »
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  >:D

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 7549
  • Country: 00
  • +++ ATH1
Re: Arduino controlled Power Supply?
« Reply #2 on: November 19, 2013, 04:50:33 am »
How else could I make a digital power supply which does not require the MCU to be in the voltage loop?

Watch 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.

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: ATmega328 controlled Power Supply?
« Reply #3 on: November 19, 2013, 06:03:16 am »
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 break  :palm:

Dave 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
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #4 on: November 19, 2013, 06:06:33 am »
However, as I dialled up the voltage using the potentiometer on the board, the feedback pin maintained a constant voltage.

That 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:

Also, what do you think about this simple way to control the output voltage LINK: http://new.linuxfocus.org/English/June2005/article379.shtml

That is the bullshit solution people just recommended against in their postings here. Rightfully.
« Last Edit: November 19, 2013, 06:08:05 am by Bored@Work »
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: ATmega328 controlled Power Supply?
« Reply #5 on: November 19, 2013, 06:28:19 am »
Thanks for sharing your knowledge  :-+

I 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.
 

alm

  • Guest
Re: ATmega328 controlled Power Supply?
« Reply #6 on: November 19, 2013, 08:19:23 am »
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.
 

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: ATmega328 controlled Power Supply?
« Reply #7 on: November 19, 2013, 08:35:19 am »
Thanks again!


So what do you think about driving the filtered PWM output into a LM2576 switching regulator? Any advice or ideas?
 

Offline shailesh3t

  • Regular Contributor
  • *
  • Posts: 50
  • Country: mu
Re: ATmega328 controlled Power Supply?
« Reply #8 on: November 19, 2013, 10:58:37 am »
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]
« Last Edit: November 19, 2013, 11:04:14 am by shailesh3t »
 

Offline quantumvolt

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: th
Re: ATmega328 controlled Power Supply?
« Reply #9 on: November 19, 2013, 11:00:45 am »
There are formulas that will get you started understanding PSUs with current-feedback or trim inputs in the datasheets of LTC2977 and LTC2974.

 

Offline quantumvolt

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: th
Re: ATmega328 controlled Power Supply?
« Reply #10 on: November 19, 2013, 12:01:59 pm »
Forget the chip. If you want to know what it does: Read the datasheet (I guess that is too much asked   :o) ...

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 ..
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #11 on: November 19, 2013, 12:07:26 pm »
Quote
Sadly, I cant find the schematic

There 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.

================================
https://dannyelectronics.wordpress.com/
 

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: ATmega328 controlled Power Supply?
« Reply #12 on: November 19, 2013, 12:12:14 pm »
Quote
After that, you can figure out ways to refine the system, for example by adding constant current capabilities, etc.

Would 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
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #13 on: November 19, 2013, 12:32:21 pm »
Quote
Would the software controlled current limiting work?

It can certainly be made to work - the solution can be either analog or digital.

You obviously will need a current sensor for that.
================================
https://dannyelectronics.wordpress.com/
 

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: ATmega328 controlled Power Supply?
« Reply #14 on: November 19, 2013, 12:36:52 pm »
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 :-//
 

Offline kizzap

  • Supporter
  • ****
  • Posts: 477
  • Country: au
Re: ATmega328 controlled Power Supply?
« Reply #15 on: November 19, 2013, 10:19:58 pm »
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 :-//

Both 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
<MatCat> The thing with aircraft is murphy loves to hang out with them
<Baljem> hey, you're the one who apparently pronounces FPGA 'fuhpugger'
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #16 on: November 19, 2013, 11:18:25 pm »
Quote
I would have liked a separate current limiting function that is done in hardware

I 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.
================================
https://dannyelectronics.wordpress.com/
 

Offline MaxPower

  • Newbie
  • Posts: 6
  • Country: au
Re: ATmega328 controlled Power Supply?
« Reply #17 on: November 24, 2013, 07:13:06 am »
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.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #18 on: November 24, 2013, 07:54:55 am »
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.

Bullshit, 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 it
http://www.maximintegrated.com/app-notes/index.mvp/id/5058


Or an Electronic Design article (however they got their math wrong, so I only link to the "complicated" schematic)



Or what about this 38 year old application note from Motorola? https://www.eevblog.com/forum/blog/eevblog-259-psu-rev-c-schematic-part-12/?action=dlattach;attach=22133
A 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.
« Last Edit: November 24, 2013, 07:56:38 am by Bored@Work »
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline quantumvolt

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: th
Re: ATmega328 controlled Power Supply?
« Reply #19 on: November 24, 2013, 12:44:50 pm »
I find it funny that we now have two pages of discussion, but no one could be arsed to do the few calculations.

Thanks 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 it  :scared:   http://www.linear.com/product/LTC2977. Click on "Datasheet"   :-DD
 

Offline quantumvolt

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: th
Re: ATmega328 controlled Power Supply?
« Reply #20 on: November 25, 2013, 06:18:00 pm »
There are formulas that will get you started understanding PSUs with current-feedback or trim inputs in the datasheets of LTC2977 and LTC2974.



I 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 ( ?:o?)) ... 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.
 

Offline asilva10

  • Contributor
  • Posts: 34
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #21 on: November 25, 2013, 07:12:21 pm »
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.
« Last Edit: November 25, 2013, 07:28:32 pm by asilva10 »
 

Offline quantumvolt

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: th
Re: ATmega328 controlled Power Supply?
« Reply #22 on: November 25, 2013, 10:22:01 pm »
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.

As 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/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: ATmega328 controlled Power Supply?
« Reply #23 on: November 26, 2013, 12:25:27 am »
Quote
build something like the supply below.

A 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, ....., :)

Quote
you don't have to do any math.

Another way to construct the same circuit is to use a R2R like ladder -> no more weird resistor values.

Quote
this thread is but air-ware

Agreed.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf