Author Topic: General Purpose Power Supply Design  (Read 151660 times)

0 Members and 1 Guest are viewing this topic.

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
General Purpose Power Supply Design
« on: March 20, 2012, 06:33:17 am »
This is a designed inspired by Dave's REV C PSU design, but it is opamp/transistor based rather then IC regulator based.

I did the design really as an exercise to see what could be done with some brilliant idea that Dave has used in his RevC power supply design. There are both benefits and negatives in using a LT3080 based supply, so this is just a different approach. I am pretty happy with the results.

First, just to put the design into context. I have designed a number of opamp-based supplies before, and usually you decide on the input voltages, the output voltage range, currents, etc and you then design a supply to suit those specs.

You then have to spend a lot of effort into stabilizing the control circuit - that is the hardest part of the design. Using the LT3080 bypasses any stability issues, but if you do an opamp designed, you are guaranteed to need compensation to get it unconditionally stable with all loads.

Now typically this design will only suit the set of specs the supply is designed for, and the moment you change the voltage ranges or input voltage, you have to change the values of components and then start from scratch with the stability compenstaion.

The ideas from Dave's supply that change all this are:

1. a low dropout design
2. single input supply
3. supply works to full specs with a wide range of input voltages
4. the regulation of the supply sets the output voltage to be the same as the opamp sense input (ie no voltage divider or voltage references involved in the supply regulation).

The result of #3 and #4 is the result is super flexible as you can feed the supply with whatever source supply voltage you like, and it will output whatever voltage you give it on the voltage control input. So a fully stabilized supply can be designed, and you can then make it output any voltages you like between about 0 and 30V without any change to the supply design at all. I do not have to redesign the control loop just because the voltage divider ratio has been changed.

I have never seen anyone produce a generic power supply board, so I decided to give it a try. I am hoping that it may be useful alternative to the many bad LM317 based supply design attempts.

The idea that really got me interested though was Dave's  Rev C addition of a pre-regulator so that the linear regulator never had to dissipate much heat. This is only possible if the supply can work fully with a very wide range if input source voltages and if it has a low dropout. Heatsinks and buckets of wasted energy have always gone hand in hand with linear supplies. Dave has done away with that.

I think people may not get how brilliant and revolutionary Dave's concept is. We are totally used to hand held meters, but we are still stuck to the idea that a power supply has to be anchored to a wall socket on the bench, and the idea that you do development on the bench, rather then the place the design is actually going to be used - whether that is on the roof, half way down a canyon, in the car, on a boat or wherever.

If a supply efficiently uses the energy in a lithium battery, the supply can easily last for days powering a typical modern low power circuit. Given that, why would you want a power cord at all? So a huge congratulations to Dave.

So on to my design.  Here were my design specs:

3V to 30V input source voltage range
1.5V dropout voltage
True regulation down to zero volts
1A output current with 0 to 1A current limit
High level of protection from loads.
Transient performance similar to the LT3080
No-load to full load output voltage regulation  better then 0.001% (Wiring and track resistance is the biggest problem)
Loads like a battery can be connected to the supply while the supply is off without causing any problems to the supply or the battery.
Design based on "garden' components - potential to make it very cheap.
Possibility of a wide range 1A supply using only board mounted devices and no heatsink

I will get onto the design in the next post. This design exercise is not to make something similar to Dave's supply. I have left out any attempt at this stage in a uCurrent type device, and I am only looking a very low cost high performance regulator that could be controlled by just plain potentiometers.

Richard.
 
The following users thanked this post: BravoV, LeoGray

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #1 on: March 20, 2012, 06:34:18 am »
Here is my initial design. If anyone is interested in using it, please feel free. I designed the compensation to be stable under all loads including huge pure capacitive loads, and I hope I got the numbers right. 



I have breadboarded it and it does work. The only change I had to to was to add capacitor C3 - without it, Q3 and Q1 had managed to form a very nice 108MHz sinewave oscillator - I was actually quite impressed by that. That actual power transistor I used was a MJE3055 - the TO220 version of the rather sluggish 2N3055 and I didn't think it was even possible to get it to generate a 108MHz sinewave.

The supply as drawn is for an output voltage range of 0 to 22volts with a 0 to 2.2 volts input. The current control regulates to 0 to 1A with a 0 to 1V input. The supply source should be at least 1.6 volts above the output voltage and 2.1 volts would give a small margin. My breadboard version actually regulated down to a 1V dropout voltage, but this is exceed the specs promised by the LM324.

MOSFET M1 on the output acts as a overvoltage clamp that will start to turn on between 25V and 30V, and it is also the reverse voltage clamp diode. Diode D10 prevents the regulator input pin of the LM324 going to -0.6 volts which is about the point you can get the IC to latch up. I didn't bother protecting the inputs of U3 from negative voltages. Tests seemed to indicate that with the 100K series resistance, you couldn't casue latch-up at -12V. and M1 will keep the negative voltages to -1 volts or less.

D5 stops a voltage on the output from damaging the regulator transistor. The last part of the protection is the LM324 itself - its inputs can be safely taken up to 32 Volts, and the MOSFET circuit will see that the inputs never get to 32 volts.

This supply does not need a bypass diode back to the input supply, so you could safely turn the supply off with a 12 or 24 volt battery on the supply output terminals.

I can talk more about component choices later, but as I said before, I see this as a design exercise, and there are things I would like to add. In particular, I would like to get rid of the 1K discharge resistor and replace it with an active circuit instead. Still thinking about the best way to implement that. Some kind of load discharge is needed, otherwise the regulator just cannot even regulate properly.

Richard.
 

alm

  • Guest
Re: General Purpose Power Supply Design
« Reply #2 on: March 20, 2012, 06:57:00 am »
Cool project! I think using a more complex circuit (both in design and in components) with cheaper and more readily available components might be the right one for a design people all over the world might build, as opposed to a kit.

Any idea how well it will reject the (relatively) high frequency switching noise from the pre-regulator? Would you expect similar performance to the traditional lab supplies with huge heatsinks or do you trade off noise for efficiency? Most three terminal regulators have a fairly limited ripple rejection once the frequency gets much higher than 120 Hz.

I'm aware of one well-designed universal variable power supply, a design by German electronics maganize ELV. There's a link to a PDF of the article on the product page, unfortunately the text is in German. This design is quite flexible in input voltage and current range, and I haven't heard any complaints about stability. It is a more traditional design intended to use with transformers, however.

I would welcome a well documented design of a power supply to be available in English, most that I've found suck in some way (eg. the poorly implemented LM317 designs that you mention).

I might make the over voltage protection adjustable, so you can set it to 6V if that's the absolute max for your components, but I realize that this may be outside the scope, and that feature creep may screw up the intended purpose (simple, cheap).

Interesting that you were able to get the MJE3055 to oscillate at 108 MHz, just make C3 switchable and you have a portable power supply and radio transmitter in one ;).

Intuitively I would be worried about the effect of D5 on the stability at low currents, since you're introducing a component with a dynamic resistance inside the feedback loop, but I don't have time to go over the circuit in detail, and I trust you've done your homework correctly.

I agree about replacing R3 with an active down programming circuit. How about driving M1 in linear mode, to represent a moderate resistance to keep dissipation in check, if D5 is not forward-biased?
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #3 on: March 20, 2012, 07:16:24 am »
That circuit goes way over my head, but it sure looks pretty  :)

On the pre-regulator aspect, what are the possibilities of making a switching pre-regulator that works at a low frequency like 100 Hz to avoid switching noise getting into the output? I'm thinking along the lines of a big filter cap as found in a normal linear supply, but switching current into it to top it up to just the right voltage. What size inductor in the switching circuit would adequately handle the low frequency, high current pulses?

I have seen an example in some application notes where an active SCR switching rectifier/pre-regulator was used, but I couldn't clearly follow how the circuit worked. It seemed to switch just enough of each AC half cycle to top up the reservoir capacitor to the desired voltage. What puzzled me is that this is clearly a very non-linear system and I was interested in how it was made to work in a stable and effective manner.
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #4 on: March 20, 2012, 07:43:21 am »
Any idea how well it will reject the (relatively) high frequency switching noise from the pre-regulator? Would you expect similar performance to the traditional lab supplies with huge heatsinks or do you trade off noise for efficiency? Most three terminal regulators have a fairly limited ripple rejection once the frequency gets much higher than 120 Hz.
I will see if I can test that with my breadboard. Setting up a power MOSFET as a source follower and feeding a signal generator in the gate should be able to modulate the supply input. I will let you know how it goes. Trouble is there are a number of issues with the breadboard version - I really need a PCB version to see accurately how it behaves dynamically.

It is an issue with the LT3080. It has 50dB rejection at 100KHz but it falls off like a stone after that. Most of the modern switching regulators work at 200KHz or higher. The one Dave used in has recent LTSpice simulation of a tracking regulator runs at over 1MHz.
Quote
I'm aware of one well-designed universal variable power supply, a design by German electronics maganize ELV. There's a link to a PDF of the article on the product page, unfortunately the text is in German. This design is quite flexible in input voltage and current range, and I haven't heard any complaints about stability. It is a more traditional design intended to use with transformers, however.
A different approach totally, but it is interesting to see what they have done. They have followed the standard HP method of the floating +/- supply for the opamps with the zero volts connected to the supply positive output. That is the way to get the best performance, but it needs a mains transformer, and it is really hard to find a suitable multi-winding transformer these days.
[quote

I might make the over voltage protection adjustable, so you can set it to 6V if that's the absolute max for your components, but I realize that this may be outside the scope, and that feature creep may screw up the intended purpose (simple, cheap).
[/quote] It certainly could be done, but the protection I implemented was for the power supply protection. For circuit protection, it is probably hard to beat an adjustable crowbar protection using a nice big indestructible SCR.
Quote

Interesting that you were able to get the MJE3055 to oscillate at 108 MHz, just make C3 switchable and you have a portable power supply and radio transmitter in one ;).
I could add one of those voice simulation chips and I could transmit the supply status to any FM radio in the neighborhood.
Quote
Intuitively I would be worried about the effect of D5 on the stability at low currents, since you're introducing a component with a dynamic resistance inside the feedback loop, but I don't have time to go over the circuit in detail, and I trust you've done your homework correctly.
I believe it is OK, but I will admit I left it off the breadboard version.  I can dig up a suitable diode and test it.
Quote
I agree about replacing R3 with an active down programming circuit. How about driving M1 in linear mode, to represent a moderate resistance to keep dissipation in check, if D5 is not forward-biased?
Not a bad idea. I will think on it.

Richard.
 

alm

  • Guest
Re: General Purpose Power Supply Design
« Reply #5 on: March 20, 2012, 08:04:58 am »
It is an issue with the LT3080. It has 50dB rejection at 100KHz but it falls off like a stone after that. Most of the modern switching regulators work at 200KHz or higher. The one Dave used in has recent LTSpice simulation of a tracking regulator runs at over 1MHz.
There are some three-terminal regulators specifically designed to be used with a switching pre-regulator, but this is an issue with the switcher + linear combination in general. Those 200 kHz/1 MHz frequencies are just the fundamentals, the edges produce much faster transients, since the MOSFET gates are usually driven quite hard to improve efficiency. It may be acceptable to aim for a higher noise level than the traditional linear supplies (eg. Agilent E36xx) if the advantages are efficiency, no heatsink and battery-powered operation. Many circuits don't need the <= 1 mV level of noise.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #6 on: March 20, 2012, 08:39:49 am »
1. a low dropout design
2. single input supply
3. supply works to full specs with a wide range of input voltages
4. the regulation of the supply sets the output voltage to be the same as the opamp sense input (ie no voltage divider or voltage references involved in the supply regulation).

The result of #3 and #4 is the result is super flexible as you can feed the supply with whatever source supply voltage you like, and it will output whatever voltage you give it on the voltage control input. So a fully stabilized supply can be designed, and you can then make it output any voltages you like between about 0 and 30V without any change to the supply design at all. I do not have to redesign the control loop just because the voltage divider ratio has been changed.
I very much like those aspects of Daves design. It is really very simple and can be used with a potentiometer, PWM or DAC as control input. Brilliant !

So on to my design.  Here were my design specs:

3V to 30V input source voltage range
1.5V dropout voltage
True regulation down to zero volts
1A output current with 0 to 1A current limit
High level of protection from loads.
Transient performance similar to the LT3080
No-load to full load output voltage regulation  better then 0.001% (Wiring and track resistance is the biggest problem)
Loads like a battery can be connected to the supply while the supply is off without causing any problems to the supply or the battery.
Design based on "garden' components - potential to make it very cheap.
Possibility of a wide range 1A supply using only board mounted devices and no heatsink

I have been toying with a variant of Daves power supply with very similar specs, still based on a LT3080 (I do not have the analog experience to replace it). I think we can live with 10-30V input. But I've based my design on a xMegaA3U because it has a 12bit ADC & DAC, so we need no other digital components. It also has USB with a boot loader, so people can upgrade the Firmware in the field easily (no programmer needed).
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #7 on: March 20, 2012, 09:46:09 am »
That circuit goes way over my head, but it sure looks pretty  :)

On the pre-regulator aspect, what are the possibilities of making a switching pre-regulator that works at a low frequency like 100 Hz to avoid switching noise getting into the output? I'm thinking along the lines of a big filter cap as found in a normal linear supply, but switching current into it to top it up to just the right voltage. What size inductor in the switching circuit would adequately handle the low frequency, high current pulses?

I have seen an example in some application notes where an active SCR switching rectifier/pre-regulator was used, but I couldn't clearly follow how the circuit worked. It seemed to switch just enough of each AC half cycle to top up the reservoir capacitor to the desired voltage. What puzzled me is that this is clearly a very non-linear system and I was interested in how it was made to work in a stable and effective manner.
Definitely can make a switching pre-regulator at 100Hz like the SCR one in the Linear Technology app note, but the high frequency switchers are just so small and efficient, and the ripple can be pretty good - you tend to get a fair amplitude of ripple at 100Hz unless you go to huge capacitors. 

For me, the key to low power is to reduce the ripple amplitude from the switching regulator to minimize the switcher to linear regulator differential, and for that the high frequency switcher is going to be the way to go. 100Hz switching designs were ideas from the 1970's electronics mags. Time to move on.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #8 on: March 20, 2012, 12:39:38 pm »
Yes, I agree, a high frequency switcher to pre-regulate is the way to go. We probably should leave 2V for the linear regulator, this limits its power dissipation to 2W/Amp, something we can live with.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #9 on: March 20, 2012, 03:21:53 pm »
Yes, I agree, a high frequency switcher to pre-regulate is the way to go. We probably should leave 2V for the linear regulator, this limits its power dissipation to 2W/Amp, something we can live with.
I will take a look at the switching regulator soon. Right now, I am seeing if I can get a second version of my design working. It is almost stable, but there is a little ringing on transient load changes. Got to eliminate that - ringing means something is not right yet.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #10 on: March 20, 2012, 03:43:29 pm »
I imagine that the entire thing is powered with a power supply like this one:
Universal laptop power supply (24V)

I like the 1V range of the inputs, my pet micro (xMega32A4U) for this has a 1V internal reference.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #11 on: March 20, 2012, 04:21:25 pm »
Definitely can make a switching pre-regulator at 100Hz like the SCR one in the Linear Technology app note, but the high frequency switchers are just so small and efficient, and the ripple can be pretty good - you tend to get a fair amplitude of ripple at 100Hz unless you go to huge capacitors.

For me, the key to low power is to reduce the ripple amplitude from the switching regulator to minimize the switcher to linear regulator differential, and for that the high frequency switcher is going to be the way to go. 100Hz switching designs were ideas from the 1970's electronics mags. Time to move on.

OK, I understand time marches forward. But my thinking was that larger amplitude, lower frequency ripple might be easier for the linear regulator to filter out than small amplitude, high frequency ripple. You mentioned for example that the LT3080 ripple rejection falls off dramatically above 100 kHz. If a very clean supply is desired, is there a balance to be found somewhere above 100 Hz and below 100 kHz?
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #12 on: March 20, 2012, 09:16:51 pm »
At 100hz, you need a 10000 uf cap to reduce the ripple to 1v peak to peak.

If the regulator is at maximum and you short the load, the regulator had to dissipate all the stored energy in that big capacitor. Remember the whole idea of using a preregister is to reduce the power dissipation in the regulator.

You want to stay away from the rest of the audible frequencies unless you like listening to your regulator. 20khz to 100 khz is workable. For 1v ripple at 100 khz, all you need is a 10uf cap. Much better!

The alternative is a high frequency switcher followed by a LC filter network to eliminate the high frequency. Definitely possible but it might take a few PCB revisions to get it working right.

Richard
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #13 on: March 20, 2012, 09:38:40 pm »
In Daves latest video he looks at a switching regulator in series with a LT3080. The switching regulator in question runs at 750kHz and this is in the official LT3080 data sheet. The TL3080 seems to have no problem with the ripple of the switching regulator there.

I seem to read data sheets too rapidly, at leat I overlooked that part before, looks very interesting !
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #14 on: March 21, 2012, 12:18:03 am »
If I´m understanding correctly, you are feeding the pass transistor (Q1) with a current of 10 mA generated by a constant current source (Q3, D1, D2, R1, R2 and C3) and you regulate the output voltage by bleeding this current with Q2/R2, right?

A couple questions.

1. Shouldn't the dropout voltage be about 2.5V, as you need 1.4V for the current source feeding the base, another 0.7V for the Vbe of Q1 and 0.4V for D5?

2. With a hfe of 20-70, there is no way of getting 1A with an MJE3055 without increasing the current from Q3 (decreasing R1 to 12 ohms), right?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #15 on: March 21, 2012, 02:44:32 am »
In Daves latest video he looks at a switching regulator in series with a LT3080. The switching regulator in question runs at 750kHz and this is in the official LT3080 data sheet. The TL3080 seems to have no problem with the ripple of the switching regulator there.

I seem to read data sheets too rapidly, at leat I overlooked that part before, looks very interesting !
At 750kHz, the LT3080 has only about 13dB of line ripple rejection, and most of that would be the 2.2uF output capacitor that they specify. That means that if you have 500mV ripple going into the LT3080, you will have about 100mV coming out.

So the reality is if you want to use a 750kHz pre-regulator, you have to remove the switching noise before it gets to the LT3080. A good filter could probably get rid of more like 60dB of switching noise.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #16 on: March 21, 2012, 03:01:14 am »
If I´m understanding correctly, you are feeding the pass transistor (Q1) with a current of 10 mA generated by a constant current source (Q3, D1, D2, R1, R2 and C3) and you regulate the output voltage by bleeding this current with Q2/R2, right?

A couple questions.

1. Shouldn't the dropout voltage be about 2.5V, as you need 1.4V for the current source feeding the base, another 0.7V for the Vbe of Q1 and 0.4V for D5?

The dropout of the current source is something like 0.7V as the transistor can turn on to saturation. For the shottky, I just used one in the LTSpice library, but you can get schottky's with 0.3V drop.

Quote

2. With a hfe of 20-70, there is no way of getting 1A with an MJE3055 without increasing the current from Q3 (decreasing R1 to 12 ohms), right?
I tested the gain of the one I had and it was 120, and I did use a lower R1. But there are transistors available with gains of 200 to 350 at 1A, and that is the ones I would go for in a final design. High gain transistors eliminate most of the heat in the driving transistors.

Anyway, I may be close to getting a PMOS based design working with a dropout of 1V. I have a stable design, but I have to check the margins of the stability. A lot less parts then the transistor based design. This would be great if I can pull it off as there are fabulous PCB mounted MOSFETs available. Much easier to find then the super gain PCB mount medium power transistors.

It would be much easier to scale the design up to higher currents with MOSFET power devices, but at the moment, I am a fair way from a circuit that would allow me to swap to different MOSFETs and remain stable.

Richard.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #17 on: March 21, 2012, 05:42:01 am »
How do devices like the LT3080 "miraculously" remain stable with different loads? I had the presumably naive impression it was all down to placing a suitable amount of capacitance at the output? (Qualitatively, the capacitor dominates the properties of the output system and isolates the load from the controller. The feedback loop only "sees" the capacitor, so as long as the loop is stable with the chosen capacitor it will be stable with all reasonable loads.)

In my world I have never had to do the kind of frequency domain stability analysis that EE's often have to do. It is interesting to see the problem from that perspective.
I'm not an EE--what am I doing here?
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #18 on: March 21, 2012, 06:14:23 am »
Design based on "garden' components - potential to make it very cheap.

I will get onto the design in the next post. This design exercise is not to make something similar to Dave's supply. I have left out any attempt at this stage in a uCurrent type device, and I am only looking a very low cost high performance regulator that could be controlled by just plain potentiometers.

Richard, thanks for starting this initiative especially on not choosing exotic part, really appreciate it.

Love the idea on using "garden" components, please keep it this way should this design evolved into more complex circuit. Eagerly waiting to see the pre-regulator section, hopefully you will use those "garden" switcher as well.  :)

Btw, how does this design scale at higher current rating ?

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #19 on: March 21, 2012, 06:45:18 am »
The intuitive thing is that extra capacitance, but capacitance is the most difficult load of all for stability.

I will try and keep it simple. Power supplies use feedback to regulate the output which means you have a high gain amplifier with negative feedback. The negative feedback will change the output voltage until the difference between it and the reference voltage is zero.

Now add frequency to the equation. Due to internal capacitance, amplifiers loose gain as the frequency increases. What goes along with that is phase shift. If at any frequency a control loop has a gain more then 1 and the total phase shifts reaches 180 degrees, the control loop will oscillate.

Opamp designers have known about this forever. What they do is to make the input and output stages of opamps really fast, and then slow the middle gain stage down with a single RC time constant. This has a phase shift of 90 degrees from about 10Hz up to 1MHz (or whatever the opamp goes to). With one single RC dominating, the phase shift through the opamp's whole frequency range is around 90 degrees so it is stable.

Just to make this clear, if you had a 1KHz signal going into a unity gain opamp, the output would look pretty much in phase with the input. But if you looked at the microvolt AC signal between the inverting and non-inverting inputs, that signal would be leading by 90 degrees. Simply to have a zero phase lag 1KHz coming from the output, the actual input signal between the input pins has to be leading by 90 degrees.

Now we come to power supplies. you still have the opamp with its 90 degrees phase shift, but you have extra stuff too -  power transistors, driver transistors, protection circuitry, etc, and no matter how hard you try, these all add extra phase shift. Ok so say you keep all these other things to an extra 45 degrees - the supply is stable?

Unfortunately for the designer, stupid people actually want to put loads on these power supplies. What happens when you put a massive capacitor on the output of a supply? You have another 90 degrees phase shift and it oscillates. The bigger the capacitor, the more likely the supply will oscillate. 

So the power supply designer and the IC designer has to do the impossible - if you disconnect any filter capacitor from the output, the control loop has to have less then 90 degrees phase shift all the way from Dc to the 100kHz+ bandwidth of the loop. You can follow the opamp trick of making everything blindingly fast except for one RC constant and then you do some tricks to slow the roll of to less then the 6dB per octave of the RC time constant, and the result is you get a little less then 90 degrees. This is the technique probably used in the LT3080.

For the discreet componect supply designer, you usually want to use an opamp that has the 90 degrees RC time constant built in, so you have to do tricks with external RC networks to cause a bit of phase lead to cancel out the excessive phase lag. It is not easy which is why Dave went for the LT3080 solution. If he did design a discrete supply, he would probably be on video blog number 23 by now - still fiddling with the compensation.

The conclusion is that for most power supplies, if it is stable with a 100,000uf capacitor under all output voltage and current conditions, it is probably going to be stable for most other loads. Lots of power supplies out there are probably not stable with a huge capacitor, as the voltage is hardly changing on the capacitor - it is the control circuit in the supply going nuts. Most people wouldn't notice. This may seem OK, but it is not, as it will affect regulation, the current limit control, and a few other things.

Richard.

« Last Edit: March 21, 2012, 07:11:39 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #20 on: March 21, 2012, 06:58:44 am »
Design based on "garden' components - potential to make it very cheap.

I will get onto the design in the next post. This design exercise is not to make something similar to Dave's supply. I have left out any attempt at this stage in a uCurrent type device, and I am only looking a very low cost high performance regulator that could be controlled by just plain potentiometers.

Richard, thanks for starting this initiative especially on not choosing exotic part, really appreciate it.

Love the idea on using "garden" components, please keep it this way should this design evolved into more complex circuit. Eagerly waiting to see the pre-regulator section, hopefully you will use those "garden" switcher as well.  :)

Btw, how does this design scale at higher current rating ?

I am close to a simpler MOSFET design that does scale really well. The problem I have now is picking some MOSFETs to focus on. There once was a time when there were only about 20 common MOSFETs and life was extremely simple. Now the numbers are ridiculous.

The transistor design I posted probably works best at 1A. You could push it to 2A by using the really high gain Zetex transistors. That is about it without without a redesign.

Richard.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #21 on: March 21, 2012, 07:31:56 am »
For the discreet componect supply designer, you usually want to use an opamp that has the 90 degrees RC time constant built in, so you have to do tricks with external RC networks to cause a bit of phase lead to cancel out the excessive phase lag. It is not easy which is why Dave went for the LT3080 solution. If he did design a discrete supply, he would probably be on video blog number 23 by now - still fiddling with the compensation.

Bingo, I'm not as silly as I look  :P

BTW, I'm not sure why everyone thinks my supply is locked into using the "exotic" LT3080. You can substitute for an LM317, but then it only goes down to 1.2V which is not a big deal in most cases. Just have to offset the drive voltage by 1.2V. And that aspect can be fixed if you really want.

Dave.
 

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: General Purpose Power Supply Design
« Reply #22 on: March 21, 2012, 08:08:45 am »
Dave ,
what's your thoughts on the numerous articles out there claiming the LM317 to have a similar performing opamp as a LM741 "They claim it's bad , but then i looked , it's a audiophoolery site" ?
Another case of them wanting overkill for the opamp ? I don't know .  ;)
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #23 on: March 21, 2012, 09:54:38 am »
I am close to a simpler MOSFET design that does scale really well. The problem I have now is picking some MOSFETs to focus on. There once was a time when there were only about 20 common MOSFETs and life was extremely simple. Now the numbers are ridiculous.

Yup.
Is the world better or worse off as a result? Sometimes I'm not sure...

Dave.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #24 on: March 21, 2012, 10:31:32 am »
I think people may not get how brilliant and revolutionary Dave's concept is. We are totally used to hand held meters, but we are still stuck to the idea that a power supply has to be anchored to a wall socket on the bench, and the idea that you do development on the bench, rather then the place the design is actually going to be used - whether that is on the roof, half way down a canyon, in the car, on a boat or wherever.

If a supply efficiently uses the energy in a lithium battery, the supply can easily last for days powering a typical modern low power circuit. Given that, why would you want a power cord at all?

Just on the battery part.
I started out with the idea for 3 x 18650's because that's what I fitted in the small case, and I wanted maximum capacity.
Then I dropped to 2 x 18650's because it was cheaper/easier on the charging side.
Now I think I'll be dropping it to 1 x 18650 (or optional larger cell) and going with a proper robust charging solution that gets maximum life out of the cell and better handles the ability to charge and power the supply at the same time. It also adds the USB charging feature back.
The idea is that it's a mains supply most of the time, but when you need it portable, just disconnect and it's ready to go for a few hours or days depending upon the load.

Maybe that belonged in the other thread, but oh well...

Dave.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #25 on: March 21, 2012, 11:03:28 am »
BTW, I'm not sure why everyone thinks my supply is locked into using the "exotic" LT3080. You can substitute for an LM317...
Actually I don't consider the LT3080 as exotic, you can get it at all the big distributors. It may be less common as a LM317, but it contributes greatly to the simple and elegant design. It may be somewhat more expensive that a discrete circuit, but has the great advantage to work reliably, be robust (thermal protection) and to be easy to use.

Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #26 on: March 21, 2012, 11:54:47 am »
I think people may not get how brilliant and revolutionary Dave's concept is. We are totally used to hand held meters, but we are still stuck to the idea that a power supply has to be anchored to a wall socket on the bench, and the idea that you do development on the bench, rather then the place the design is actually going to be used - whether that is on the roof, half way down a canyon, in the car, on a boat or wherever.

If a supply efficiently uses the energy in a lithium battery, the supply can easily last for days powering a typical modern low power circuit. Given that, why would you want a power cord at all?

Just on the battery part.
I started out with the idea for 3 x 18650's because that's what I fitted in the small case, and I wanted maximum capacity.
Then I dropped to 2 x 18650's because it was cheaper/easier on the charging side.
Now I think I'll be dropping it to 1 x 18650 (or optional larger cell) and going with a proper robust charging solution that gets maximum life out of the cell and better handles the ability to charge and power the supply at the same time. It also adds the USB charging feature back.
The idea is that it's a mains supply most of the time, but when you need it portable, just disconnect and it's ready to go for a few hours or days depending upon the load.

Maybe that belonged in the other thread, but oh well...

Dave.

I think one cell is plenty myself. If you think about it, debugging an arduino with some attached accessories is probably going to draw 100mA max at 5V. Even if you were debugging for the whole day, you are not going to flatten the battery.

Even at 20V and 1A, you will probably get over 15 minutes and that is enough for a quick test. If you want longer, you are going to plug in the charger anyway.

To me, power supplies are something you build, and then you keep using it for the next 30 years. It will go through lots of batteries in that time, so replacing one cell is much better then replacing two or three.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #27 on: March 21, 2012, 12:03:47 pm »
I am close to a simpler MOSFET design that does scale really well. The problem I have now is picking some MOSFETs to focus on. There once was a time when there were only about 20 common MOSFETs and life was extremely simple. Now the numbers are ridiculous.

Yup.
Is the world better or worse off as a result? Sometimes I'm not sure...

Dave.
I need to look for the low turn-on voltage MOSFETs, but it doesn't seem to be one of the search parameters on Digikey. I might have to plow through millions of data sheets. Some MOSFETs, I can run with a power supply as low as 3.5 volts to get 1A out. Others need a 5V supply just so the MOSFET gets enough gate drive to turn on.

If anyone knows some good low turn-on voltage P channel MOSFETS with a voltage rating of 20V or more, please make some suggestions.

The design I am working on scales, so anything from 2A to 20A or more is great.

Richard.
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 2003
  • Country: us
Re: General Purpose Power Supply Design
« Reply #28 on: March 21, 2012, 12:15:03 pm »

I started out with the idea for 3 x 18650's because that's what I fitted in the small case, and I wanted maximum capacity.
Then I dropped to 2 x 18650's because it was cheaper/easier on the charging side.
Now I think I'll be dropping it to 1 x 18650 (or optional larger cell)

I like single cell a lot.  You can easily parallel 2 or 3 cells to get more capacity if needed without changing the circuit at all, or replace it with a prismatic LiPo.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #29 on: March 21, 2012, 12:31:32 pm »
I think one cell is plenty myself. If you think about it, debugging an arduino with some attached accessories is probably going to draw 100mA max at 5V. Even if you were debugging for the whole day, you are not going to flatten the battery.

Even at 20V and 1A, you will probably get over 15 minutes and that is enough for a quick test. If you want longer, you are going to plug in the charger anyway.

That's what I thought. Battery capacity is always going to be a tradeoff regardless of what size.
One cell will provide some decent usable time for most loads, and those who want bigger capacity can hack in a bigger cell without any mods. Not that choices in bigger cells are that great, but they exist.

Dave.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #30 on: March 21, 2012, 02:35:21 pm »
Here is where I am up to with a mark II design using a P channel MOSFET.

This is just the regulator minus current limit and voltage booster. It is almost great. It will let you plug in different MOSFETs and different PNP driver transistors without affecting stability.

If you have a MOSFET that can turn on at 2V gate voltage, you can run it with a supply as low as 3V. For 5V and over, the dropout voltage is less then 1 volt.



It is close but not perfect. The combinations of the two RC time constants is somehow allowing a damped resonance around about 200KHz. I haven't started to analyse why yet, but it needs to be eliminated. Otherwise you might attach it to a 200KHz switching regulator load, and the power supply may decide to join in the party with a bit of 200Khz sinewave output.

Otherwise, I couldn't be happier with the loop phase performance. The fact you can easily change the MOSFETs means it is really easy to change this from a 1A supply to a 100mA supply or a  5A supply (or more). With a change to the overvoltage circuit, it could output up to 30V. The only thing you need to change is the current sense resistor. It can be used with PCB mounted FETS and a switching preregulator, or with mosfets on a heatsink as a conventional linear power supply.

Notice I am sticking with the LM324. Basically, it is just a good chip, and I would have to look long and hard to find something that was better in general. It allows the voltage on the inputs to go to +32 volts (even with the supply off), and that allows design choices that many of the new rail-to-rail opamps do not allow. The input can operate at the zero volts supply rail, and with the aid of either a pull up resistor or a pull down resistor, you can get the opamp output to operate to either one of the rails.

Richard.

« Last Edit: March 21, 2012, 02:49:25 pm by amspire »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #31 on: March 21, 2012, 06:17:55 pm »
Kudos, Richard! A linear regulated PSU design, based on plain parts is a brilliant idea!

Thanks to Dave's LT3080 PSU, I begun experimenting to roll out an LT3080 based upgrade for my ancient '723 based PSU, only to find out that almost not one distributor has the LT3080 in TO-220 package available in stock! Which made me once more realise not to rely my designs on so exotic components. I guess that now I have run out of excuses not to be looking into solutions with more conventional parts. But, again, hunting down sub-millivolt/milliamper accuracy forces one to use these less than 1 LSB INL 16-bit digital parts. Oh, well...

On the concept of using MOSFETs at the power stages, I think there is a major drawback: No matter how much I love these parts, the problem lies at the fat gate the beefier parts have, which holds a substantial amount of charge and needs a full blown half bridge driver for the fast charge/discharge of the gate capacitance and to race against the Miller effect --especially when the voltage rises. Using the more flexible N-channel parts makes the design even more complex. Though I've found parts electrically suitable for my needs, the TrenchFets for example, the bad news is that they come in not so heat-sink-friendly packages. Once more, I realise that one can never have it all...


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #32 on: March 21, 2012, 06:46:53 pm »
Richard, took a liberty to redraw the mosfet version since you didn't provide the .ASC, and I made it more representative to myself, hope you don't mind.  The ltspice circuit zipped file attached below.

I'm using the internal ltspice built-in linear op-amp LT1014 instead of LM324, although I have this model myself, decided to ease other member who doesn't have the LM324 model, and can just load this circuit and run it with the standard untouched LTSpice installation.

Btw, LT1014 is the "cross reference" part of LM324. :D

Also I did some tinkering on voltage source at 12 volt with 100mv ripple at 200Khz and with a dynamic load with square wave 50Khz at 100mA.

The circuit, pardon for the color scheme, its just I love dark background.  :P




The result on load current, source voltage and the regulated output at the bottom




Zoomed


« Last Edit: March 21, 2012, 06:56:20 pm by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #33 on: March 21, 2012, 11:37:12 pm »
BravoV, great simulations. Sorry I didn't post the LTSpice files but it was late. Next time I pust a spice file, I better rememebr to add the LM324 files as well, but it looks like the LT1014 does behave pretty similarly.

You got me all excited as it has fabulous offset voltage. Then I saw it doesn't allow the +30 volts on  the inputs, regardless of the opamp supply voltage. The LM324 has these crazy PNP input transistors with a reverse breakdown over 30V. I wish I could buy discrete transistors like that.

The simulation all makes sense. You put in 0.1 ohms for the filter capacitor ESR. If you use low ESR ceramics, you can get down to 0.1 ohms ESr, and the output becomes hugely better. The 200KHz feedthrough and the output transients are much smaller. But there is a cost. If you have 30volts  across 0.01 ohm ESR caps and you short them, you can get a massive discharge current. The only saving you from 3000 amps peak would be various inductance in the circuit, and the lead resistance.

In your simulations, there is a startup issue, so I will have to see what is happening.

All in all though, your results make sense and I think they are reasonable results. I hope to improve the performance at 200KHz, but it does not look too bad. A LC filter between a 200kHz switcher and the supply would wipe out any signifigant 200kHz on the output. The performance is only slightly worse then the LT3080.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #34 on: March 22, 2012, 12:14:57 am »
On the concept of using MOSFETs at the power stages, I think there is a major drawback: No matter how much I love these parts, the problem lies at the fat gate the beefier parts have, which holds a substantial amount of charge and needs a full blown half bridge driver for the fast charge/discharge of the gate capacitance and to race against the Miller effect --especially when the voltage rises. Using the more flexible N-channel parts makes the design even more complex. Though I've found parts electrically suitable for my needs, the TrenchFets for example, the bad news is that they come in not so heat-sink-friendly packages. Once more, I realise that one can never have it all...

George, I am aware about the Miller effect. In the context of this supply, the only time it causes a big problem is if the supply is on, say, 30V out and you then short the output. The Miller effect would cause the gate voltage to increase by 1 to 2 volts. The results then depend on whether you chose a 200 milliohm mosfet or some 1 milliohms monster. The 200 milliohm mosfet might go from 1A to 8A for a few microseconds. The monster mosfet could go to hundreds of amps. either one though could drag the source supply down, and since this is for a single supply design, it affects all the opamps, micro's, etc. I have some idea that I will investigate when I get onto the current limit for this design.

The simplest solution may be to stick with high resistance-low capacitance MOSFETS, and then adding an extra 1nF capacitor across the gate. If you have a MOSFET with a 10pF reverse capacitance, and you short out the 30V output, the gate voltage would only rise by 0.3 volts for a few microseconds with a 1nF gate capacitor, and the peak current will not be too bad. I can also reduce the 1000 ohm gate resistor to 100 ohms at the expense of an extra 27mA of wasted current, and it would reduce the Miller Effect surges on shorts to a few hundred nanoseconds. Perhaps then a tiny bit of inductance to wipe out the surge, and it is then totally fine.

I will probably try the PNP pass transistor option as well. If you drive the base with a constant current, then a PNP will maintain that constant current when you short the output. There will be some Miller Effect to, but the high gain medium power transistors tend to have the gain plummet by the time you get to 2A, so the Miller effect just will not be a big problem.

I still thing the MOSFET solution is probably the best if I can sort out the rough edges, as the design can be extended in terms of current and power  far more easily then with the transistor options. There are not a huge number of high gain transistors, and they are limited to up to about 2A. Low gain power transistors mean either using a darlington arrangement or a driver transistor that has to be on a heatsink to cope with the power at maximum voltage out. Darlingtons tend to be bad for saturation voltage, base voltage, speed. Not great for low dropout designs where you are running the transistor near saturation.

AcHmed99, those MOSFETs are exactly the kind you are best staying away from.  Low resistance is just no advantage for a linear supply as you need resistance to regulate, and the low resistance comes with absolutely massive gate and output capacitances. The buffer IC is not much use either. It is not a great buffer for analog anyway, but anything you add between the opamp and the MOSFETs will mess up the compensation.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #35 on: March 22, 2012, 03:52:26 am »

AcHmed99, those MOSFETs are exactly the kind you are best staying away from.  Low resistance is just no advantage for a linear supply as you need resistance to regulate, and the low resistance comes with absolutely massive gate and output capacitances. The buffer IC is not much use either. It is not a great buffer for analog anyway, but anything you add between the opamp and the MOSFETs will mess up the compensation.

Richard.

I’m afraid I have to disagree with you there Richard. A buffer will add propagation delay hence phase shift but that is why you use compensation to compensate for phase shift through out the loop.

From my experience any extra delay you add double the complexity of stabilizing the loop.  What I am after is a loop that is stable enough that you can swap key transistors. FET's etc without need to re compensate. It works out the less you can have in the loop, the better. I guess it really comes down to putting it in a design  and testing it. Until it is done, it is just opinions.

Quote
Rdson is irrelevant in A FET regulator with the exception it determines drop-out. A fet can sets its rdson via gate voltage to anything virtually. What is desirable in a fet as a pass device is a gradually sloping transcoundactance curve vs a fast steep rise. This means that the fet gate will not be so touchy and less prone to oscillation.

It is not the Rdson that matters - it is the capacitance and the transconductance curves that go with it. My circuit as is can probably handle 1nF gate capacitance but that is probably as high as you want to go. You can get a lot of amps out of a device with a 1nF gate capacitance. Going to a device with 3nf or more gate capacitance is a problem for the circuit, and it doesn't do much for you unless you are trying to build a 50A linear regulator. The other thing, as I said was the added Miller Effect gate voltage when the regulator output is shorted from 30V to 0V instantly. If you are at 1A and you add 2V to the gate of a 0.2 ohms MOSFET, you might go up to 5A. If you add 2V on a 60A MOSFET, you might go very much higher.

It may be that I am thinking of .5A to 5A power supplies, and you are thinking much bigger.

But I do agree with your comments about the transconductance curves. The steep curves are adding gain and nonlinearity where I just do not want it.

One of the biggest problems is to minimize the low voltage dropout of the regulator, I need a low gate voltage MOSFET with guaranteed worse case specs. The manufactures love to be very vague with gate specs. They do tell you usually that you can get full rated current at 10V, but the rest is often typical specs. Ideally, I want a MOSFET where they spec a minimum current at 2V gate voltage and 1V source to drain voltage.

Quote
Mind you I could be wrong it’s been a while since I designed a linear reg from scratch but that’s my recollection from when I did. I will find out in another couple of weeks because I plan on using two of the N-FETS I linked to as pass devices in a 0-30V 220W regulator. I’m soldering together the second revision of the bias supply and PFC right now. Its being fed from a variable output half-bridge. So fifteen amps max current; low drop-out is required to keep the heat sinks reasonable.

I wouldn’t waste too much time simulating a FET regulator most models are switching models and do not model operation in the linear region with reliable accuracy.

Yes. Nothing beats real testing of a design. As I mentioned above, in my first design of this thread, I got a MJE3055 (TO220 2N3055) transistor to oscillate at 108MHz on the bench even though the transistor has a spec'ed FT of 70MHz. Spice was never going to tell me that.

Sounds like an interesting power supply you are building. How big are the input filter caps? If you are going for low dropout voltage, I suspect they are something impressive.

Richard.
« Last Edit: March 22, 2012, 03:57:16 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #36 on: March 22, 2012, 04:26:02 am »
Here is a datasheet on an FET controller for LDO's. Some details are in it regarding gate capacitance and output capacitance.

http://www.ti.com/general/docs/lit/getliterature.tsp?genericPartNumber=lp2975&reg=en&fileType=pdf
Just went back and had a look at the link you posted. Very interesting. I will give it a read.

Looking at the waveforms, they don't seem worried by a bit of damped ringing after transients. A pity they didn't take the inverting amplifier out from the IC so you could use your own reference. 24V maximum input - not bad.

Richard.
« Last Edit: March 22, 2012, 05:09:57 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #37 on: March 23, 2012, 12:06:02 am »
AcHmed99, we are probably at cross purposes here.

I am looking at a general purpose power supply, so I have to assume that the supply has to manage its current limiting without dragging down the source, even if it is only for a few microseconds. If I am designing a short circuit protected supply, I am designing for the case where someone puts a dead short across the power terminals. There may be There may be other stuff running of the regulator source, so I do not want a big glitch on the source - again, that is my design choice.

I just do not want a supply that cannot control the current through the MOSFET properly, so i will look for a solution.

I just did a spice simulation of the Miller Effect current spike. My source impedance was 0.1 ohms which is realistic for a capacitor across the source. Load was .01 ohma and I included a .1 ohms current sense resistor.

I picked a Fairchild FDS6675 mosfet 30V,  20 milliohms resistance.

With a 30V supply and 29V out at 1A, a short results in a peak current through the mosfet of 80 Amps for about 100nS. If you reduce the gate drive to .01 ohm, the peak current is 15 A. If I replace the mosfet with a 200 milliohm one, I get 55A peak with a 100 ohm gate source but with a 1 ohm gate source or less, it reduces to about 8 A peak. A bit better.

If I use a an old 2N2955 PNP power transistor fed by a high impedance constant current base drive, I get a 3.4A peak current on a short. That is more like the number I want to see in a general purpose design.

These numbers sound about right to me.

As far as the buffer is concerned, I just have to be convinced that a buffer with lousy crossover is good for analog. It still looks like a switching buffer to me. I have been experimenting with a Mark III design based around PNP transistors with a constant current base drive, and it might be the way to go. The only trouble is that compensation seems to be more transistor dependant then the MOSFET design.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #38 on: March 24, 2012, 01:20:47 pm »
How to turn four Arduino 8 bit PWM outputs into four independent D/A DC outputs with over 24 bits of monotonic resolution.

I am very close to a low cost power supply design I am really happy with. Different from the previous two, but I think the one I have now is the design I have been aiming at. Better then the Mark I and Mark II designs in many ways.

I have to thank AcHmed99. The discussions with him actually resolved some issue for me.

Anyway, I took a break from that to try out another idea. Going for the low cost solution, I wanted to drive the design from a PWM on something like an Arduino. Pwm is great in that it is totally monotonic which is something I really want in my design, but the resolution is lousy.  There is one 16 bit PWM, but that is still something like 0.5mV increments, if you are really careful about the scaling of the PWM output. The scaling will probably mean that full voltage out from the supply is only about 50% of full scale for the PWM.  I want software calibration, and I want to be able to finely adjust the output voltage so that I can get a 6 1/6 digit meter to show 10.00000 volts. That needs 20 bits of resolution or more.
 
I used the 8 bit PWM's in FAST mode, and correct for accumulated error every PWM cycle. I ran the Arduino's PWM at maximum speed of 32KHz. The filter was a 3 stage 10k/0.1uf RC chain. Two stages are not enough to clean out the sub mV ripple.  I am pretty happy with the results.

It means with some better coding, I should be able to get 4 independent PWM outputs with sub microvolt resolution.

Here is the code I used to test it, if anyone is interested.  Pretty rough - I only wanted to get it to work, and I would probably go to assembler in the interrupt routine to implement it properly.

Code: [Select]

unsigned long value ;
unsigned long pwm_accum ;

volatile int Sec2 = 0;

// Interrupt every PWM cycle - this is where all the magic happens

ISR(TIMER2_COMPA_vect) {
  digitalWrite(13, HIGH);   // set the LED on - just toggling this so I can see when the interrupt routine is running
  OCR2B = (byte) (pwm_accum >> 24) ;   // Send the top byte of the PWM error accumulator to the PWM for the next cycle.
  pwm_accum = pwm_accum - (((unsigned long) OCR2B) << 24 ) ;  // Subtract the byte sent to the PWM from the top byte of the PWM error accumulator.
  pwm_accum = pwm_accum + value;   //Add the intended value for the output to the error from the last cycle
  digitalWrite(13, LOW);    // set the LED off
}

void setup() {

  pinMode(3, OUTPUT);  //  PWM OCR2B
  pinMode(11, OUTPUT); // PWM OCR2A
  pinMode(13,OUTPUT) ;
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
//  TCCR2B = _BV(CS22);
  TCCR2B = 0x01;  //Full 16MHz click for the PWM
//  OCR2A = 180;
//  OCR2B = 255;
  value = 0L ;
  pwm_accum = value ;
  TIMSK2 = (1 << OCIE2A);   // Enable interrupt when Timer reaches OCRA
  sei();
}

void loop() {
 
  value = 0x08980000L; // Equals 0.1678466 volts )
}

The PWM is run in FAST mode at a 16MHz clock rate. There are some things I will need to discover like what can go wrong with a current PWM cycle when you change the PWM register. Even if every PWM cycle is not perfect, if I get a monotonic control output with no evident digitizing steps, no evident voltage fluctuations and as much resolution as the power supply regulator allows, I will be extremely happy.

It is much slower of course then a DAC. Small changes settle quickly, but a large change like from 0V to maximum would take about 1 second to settle properly.

To implement it properly, you cannot use the PWM straight out of the Atmel.  I would probably use a 74HC family non inverting buffer powered from a voltage reference to generate an accurate PWM output.

It may be that running the PWM at full speed adds to many errors due to hardware delay variations, and in that case, I will just slow the PWM down by a factor of 8. A better idea would be to use a high speed 74HC family synchronous flip-flop to reconstitute an accurately times PWM.

Back to the voltage regulator design. I will post it soon.

Richard.
« Last Edit: March 24, 2012, 01:32:17 pm by amspire »
 
The following users thanked this post: cellularmitosis

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #39 on: March 24, 2012, 03:27:23 pm »
How to turn four Arduino 8 bit PWM outputs into four independent D/A DC outputs with over 24 bits of monotonic resolution.

Do you have a clock reference that good? A voltage reference that good? All other parts low drift, low tempco, etc.? Otherwise the LSBs will stagger around like a drunken sailor after a weekend of shore leave.

A 24 bit DAC with a 5V reference means you deal with approx. a 300 nV LSB, with a 3.3V reference the LSB is 200 nV. Is your opamp at the end of the RC filter that good?
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 markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #40 on: March 24, 2012, 05:42:49 pm »
I find a 12 bit resolution plenty. Allows for 0-40V in 10mV steps. This is in the same league as the 0.1% resistors specified by Dave. 24bit is equivalent to 0.1 ppm, way out of my league certainly not in a low cost design.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #41 on: March 24, 2012, 06:59:58 pm »
Don't confuse resolution with accuracy. I want the D/A resolution better the the supply noise, so there is no noticeable digitizing steps at all. I like using my supplies for lots a of things, including some precision work. So if a calibration instruction says "attach 18.0000 volts to the input, I like being able to fine tune the output so a precision voltmeter says "18.0000".

Why would I want to spend extra money for a DAC that could only adjust to 17.99863V, and was not monotonic, so for fine adjustment, it could drop a few mVs as you carefully wind up the voltage?

Richard.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #42 on: March 24, 2012, 07:24:27 pm »
I used the 8 bit PWM's in FAST mode, and correct for accumulated error every PWM cycle. I ran the Arduino's PWM at maximum speed of 32KHz.

Can you give the high level summary of how you get 24 bit resolution from an 8 bit source? I'm not immediately grokking it. Does "correcting for accumulated error" imply some kind of measurement feedback on the output or is it purely a predictive algorithm? As I write this, I am wondering if you are dithering the output so that a combination of different 8 bit words averages out to 24 bit resolution?
I'm not an EE--what am I doing here?
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #43 on: March 24, 2012, 08:13:04 pm »
I want software calibration, and I want to be able to finely adjust the output voltage so that I can get a 6 1/6 digit meter to show 10.00000 volts. That needs 20 bits of resolution or more.

Don't confuse resolution with accuracy. I want the D/A resolution better the the supply noise, so there is no noticeable digitizing steps at all. I like using my supplies for lots a of things, including some precision work. So if a calibration instruction says "attach 18.0000 volts to the input, I like being able to fine tune the output so a precision voltmeter says "18.0000".

With the current discussion on the PWM -> VRef circuit, although I don't know crap about this, Richard, should your design needs quite an intensive adjustments & tunings to reach certain accuracies, just want to say I'm your backer here. Also since this project is aimed for one off DIY project or limited build anyway, even they're time consuming and possibly quite a hassle, they should not be a deal breaker for diy community.

Unlike Dave's design, of course its different story since it will be made into mass produced product, tuning & adjusting manually could be a headache for him.

Eagerly to see the upcoming stages of your design.

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #44 on: March 24, 2012, 08:40:32 pm »
The output of the 8 bit PWM corresponds to about 100mV steps on the output.

Let's say I want 1.05 V out. I get this by outputting a 1v pulse, then a 1.1v pulse and repeating this. Average the result and you get 1.05 V. So I am actually adding a software controlled PWM to the output of the hardware PWM. The value I want is stored in a 32 bit register, and the software will correctly modulate the hardware PWM to get an average pulse width value that exactly mathematically equals that 32 bit number - as long as you average over about 10 minutes.

The algorithm is very simple. First PWM output, it takes the 1.05 V and rounds it down to the nearest 100 mV step - or 1 V. It then adds the .05 V error to 1.05 to give 1.1 and repeats the algorithm. This time it outputs a 1.1 V pulse.

The end result is you can have as much resolution a you want, as long as the filter averages over enough PWM pulses. You just pick a good compromise between speed and resolution, and you can always add a electrolytic cap on the power supply output if you needed more resolution.

I will probably pick a filter that will result in about a 22 bit resolution, and will settle reasonably quickly.

Richard. 
« Last Edit: March 24, 2012, 09:43:45 pm by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #45 on: March 24, 2012, 08:58:43 pm »
BravoB, thanks for the encouragement. I am trying to make something ready cheap that had decent performance.

If it is cheap enough, you can afford to build several, and then use them in parallel for more current, or series for more voltage. If I can work out a master-slave system, then you could build $20 slave supplies that just follow the master.  Slaves would not need a control panel.

The actual regulator board would be well under $5 for parts excluding the PCB, and could be used as a general purpose module in other projects.

Richard.
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 2003
  • Country: us
Re: General Purpose Power Supply Design
« Reply #46 on: March 24, 2012, 09:11:45 pm »
I used the 8 bit PWM's in FAST mode, and correct for accumulated error every PWM cycle. I ran the Arduino's PWM at maximum speed of 32KHz.

Can you give the high level summary of how you get 24 bit resolution from an 8 bit source? I'm not immediately grokking it. Does "correcting for accumulated error" imply some kind of measurement feedback on the output or is it purely a predictive algorithm?

It is a first order sigma-delta loop implemented in software.  You accumulate the error due to the finite resolution of your DAC and add that back into the output.  What this means is that if your ideal final value is halfway between two possible output values the DAC will alternate between those values.  This pushes noise to high frequency, but if you don't need the bandwidth you just put a bit of extra filtering and win.  This works with any DAC, but better with intrinsically linear devices like PWM.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #47 on: March 24, 2012, 09:55:22 pm »
The output of the 8 bit PWM corresponds to about 100mV steps on the output.

Let's say I want 1.05 V out. I get this by outputting a 1v pulse, then a 1.1v pulse and repeating this. Average the result and you get 1.05 B.C. So I am actually adding a software controlled PWM to the output of the hardware PWM. The value I want is stored in a 32 bit register, and the software will correctly modulate the hardware PWM to get an average pulse width value that exactly mathematically equals that 32 bit number - as long as you average over about 10 minutes.

The algorithm is very simple. First PWM output, it takes the 1.05 V and rounds it down to the nearest 100 mV step - or 1 V. It then adds the .05 V error to 1.05 to give 1.1 and repeats the algorithm. This time it outputs a 1.1 V pulse.

The end result is you can have as much resolution a you want, as long as the filter averages over enough PWM pulses. You just pick a good compromise between speed and resolution, and you can always add a electrolytic cap on the power supply output if you needed more resolution.

I will probably pick a filter that will result in about a 22 bit resolution, and will settle reasonably quickly.

Interesting. I note the sigma-delta algorithm that ejeffrey mentioned, but I think this can also be looked at mathematically.

Suppose I have a 24 bit value that I want to output over an 8 bit analog channel. I can break the 24 bit word into three 8 bit bytes, the most significant (MSB), intermediate (ISB), and lowest (LSB). To get the required interpolated result I have to output the MSB 65536 times per cycle (giving it a "weight" 2^16 times greater than the LSB), the ISB 256 times per cycle, and the LSB once per cycle. The total cycle length at 32 kHz is then about 2 seconds, meaning I need a low pass filter that rolls off everything above 0.5 Hz in order to recover the average steady value.
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #48 on: March 24, 2012, 10:08:04 pm »
It is a first order sigma-delta loop implemented in software.

Wow! I have a fancy name for what I am doing now. Thanks for the explanation.

Just so you know why I want the resolution. I have a Fluke 540A AC transfer calibration unit. You can use this to measure AC RMS values to 0.01%. It does this by thermally comparing the heat generated by the AC with the heat generated by an equivalent DC voltage. One of the things you need is a DC supply that can output over 10mA and can be adjusted to within 5uV for the lowest range of the 540A. A bit of ripple or noise down at 5uV does not matter and I can let the supply stabilize for an hour to reduce the opamp drift.

I currently do not have a supply that can do the job, so I hope this design will be good enough.

Old linear supplies with the potentiometers just cannot be adjusted with enough accuracy. The pots get noisy with age as well. With many digital supplies, you are lucky to be able to adjust to better then 1mV.

I could go all out and use auto-zero opamps, expensive references and thick film divider networks to make a variable voltage source that is inherently stable, but I would end up with something expensive and not generally useful. I actually like the LM324 with its weird 30V base breakdown voltage input transistors

Richard.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #49 on: March 24, 2012, 10:17:38 pm »
just want to say I'm your backer here.

You can back him as much as you like. Even with only 20 bits he is playing in 1ppm territory. A 1ppm/°C voltage reference is affordable these days. But with a 1ppm/1°C reference a 1°C temperature change in the case already ruins his LSB. Better, and you start to pay $50 or $100 just for the reference.

And then there is the long-term drift of the reference. Maybe 10ppm/1000h for an affordable reference. Here goes another digit.

Oh, and don't forget the load regulation of the reference. He needs to power the whole micro with that reference, and the micro's current consumption varies. But well, the reference might anyhow not be capable of supplying the micro. So it needs to be used as part of a voltage regulator. The whole voltage regulator needs to be ultra stable. Good luck building that.

The micro itself might also have a few nasty surprises up it's sleeve. E.g. there is no guarantee that the high and low output levels don't vary a little bit, depending on other active pins, active periphery, temperature and whatnot.

And until now we have just looked at the voltage reference and the micro. We haven't looked at the RC filter, the following buffer OpAmp, the power stage and whatever else is there. There is still a long way to got until to get that 1ppm voltage to the load.

In short, don't hold your breath.
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 amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #50 on: March 24, 2012, 10:49:40 pm »
The total cycle length at 32 kHz is then about 2 seconds, meaning I need a low pass filter that rolls off everything above 0.5 Hz in order to recover the average steady value.

You have that exactly right. I think that is too slow for a supply, so I will loose a few bits of filtering and use a faster filter. I have gone for 0.2 seconds to settle within 1mV for a 2V step change. The result is I will add some extra ripple - something like 140uV peak to peak and less then 10uV RMS ripple for a 25V supply. Increasing the RC filter stages from 3 to 6 and I can reduce the peak to peak ripple to about 20uV. Slowing the settling time to around 0.5 seconds with a 3 stage filter also will get you 20uV peak-to-peak noise.  For a lower voltage supply, the noise will scale down proportionally. This kind of ripple does not affect a precision DC voltmeter as you can set it to read over 100 mains cycles and it will average out this noise, and it would not affect my use with a Fluke 540A.

I may be able to come up with a method of correction that goes for slightly less resolution, but has less low frequency components. That is for the future.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #51 on: March 24, 2012, 11:00:07 pm »
just want to say I'm your backer here.

You can back him as much as you like. Even with only 20 bits he is playing in 1ppm territory. A 1ppm/°C voltage reference is affordable these days. But with a 1ppm/1°C reference a 1°C temperature change in the case already ruins his LSB. Better, and you start to pay $50 or $100 just for the reference.

And then there is the long-term drift of the reference. Maybe 10ppm/1000h for an affordable reference. Here goes another digit.

Oh, and don't forget the load regulation of the reference. He needs to power the whole micro with that reference, and the micro's current consumption varies. But well, the reference might anyhow not be capable of supplying the micro. So it needs to be used as part of a voltage regulator. The whole voltage regulator needs to be ultra stable. Good luck building that.

The micro itself might also have a few nasty surprises up it's sleeve. E.g. there is no guarantee that the high and low output levels don't vary a little bit, depending on other active pins, active periphery, temperature and whatnot.

And until now we have just looked at the voltage reference and the micro. We haven't looked at the RC filter, the following buffer OpAmp, the power stage and whatever else is there. There is still a long way to got until to get that 1ppm voltage to the load.

In short, don't hold your breath.
You are missing the point. I don't want great accuracy, and I have already discussed the issue with the micro output problems. 0.1% stability for accuracy after calibration would be absolutely great but I can live with less.  All I want is resolution with no evident digitizing steps on the output.

I definitely wouldn't use the output straight out of the micro - it has to come out via a high speed cmos digital IC powered by a voltage reference, and I  as mentioned above, I can pick a synchronous register for my cmos IC to reconstruct the PWM timing if the micro timing is irregular.

All the problems have been taken care of, so you can breath again.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #52 on: March 25, 2012, 10:31:34 am »
This kind of ripple does not affect a precision DC voltmeter as you can set it to read over 100 mains cycles and it will average out this noise, and it would not affect my use with a Fluke 540A.
Richard, this is all very good and is what you need for your Fluke 540A. But this is far from the 'General Purpose Power Supply Design' I came here to discuss. It may well be that the power stage can used for both, so I'm hanging in here :-).
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 15263
  • Country: za
Re: General Purpose Power Supply Design
« Reply #53 on: March 25, 2012, 10:57:52 am »
An easy way to get the voltage stable is to only power the actual PWM output from a stable reference, by using a 4050 buffer fed from the reference. Will handle the pwm, and will provide isolation. You will need to have a 5V micro and a 5V reference. If you use a single transistor inverter to do level conversion you can run the 4050 off a 10V reference to get a larger output, and make small voltage drops less important.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #54 on: March 25, 2012, 11:49:48 am »
This kind of ripple does not affect a precision DC voltmeter as you can set it to read over 100 mains cycles and it will average out this noise, and it would not affect my use with a Fluke 540A.
Richard, this is all very good and is what you need for your Fluke 540A. But this is far from the 'General Purpose Power Supply Design' I came here to discuss. It may well be that the power stage can used for both, so I'm hanging in here :-).

By general purpose, I mean I am trying to make it useful to as many applications as I can. If I have a supply that outputs in almost 1mv steps but not quite, I will make the supply useless for anyone who wants to be able to do what they could do with their old Course/Fine adjust analog power supply. And remember, the PWM solution will be cheaper then D/A converters, and it gives me up to four D/A outputs. Obviously I need voltage and current outputs. There are possibilities for the other two.

 I have to apologize as I am just putting a picture together in my head about where this could go, and I think my project will end up looking very different from Dave's, which is a good thing I think. I have a few surprises of my own, but my basic regulator board should be able to provide 0 to 24V at 1A  with no heatsink. It will have a linear regulator output with a switching pre-regulator of some kind. That is what I am working on now.

I am concerned about switching noise getting to the outputs, but if I can get a pretty clean switching supply going, then I have some surprises of my own. That is one area that I will have to wait for a bench test.

Running off a battery is definitely  possibility, but it is not a focus of my design. It may be an option on the final package, and anyone could just use the board with a battery in their own package. The control panel is a separate module again for reasons that will become clear. Lets just say that like Dave, I want to come up with a package that does not exist right now, but its new features go in a totally different direction to Dave's supply.

One thing though. I am really starting to appreciate how much work Dave has put into his design.

Richard.



 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #55 on: March 25, 2012, 12:03:49 pm »
An easy way to get the voltage stable is to only power the actual PWM output from a stable reference, by using a 4050 buffer fed from the reference. Will handle the pwm, and will provide isolation. You will need to have a 5V micro and a 5V reference. If you use a single transistor inverter to do level conversion you can run the 4050 off a 10V reference to get a larger output, and make small voltage drops less important.

I love the old 4000 series CMOS, but the speed is too high. The clock to the PWM is at 16MHz and I need very clean switching waveforms at that frequency.  It doesn't matter though as I can use a high speed CMOS family, like the 74HC family. I can get all the stability I need from a lower voltage supply I believe.

It is possible I will have a 2.7V microprocessor and and a 2V reference, but right now, the need for low voltages is fading away. There are fast cmos buffer chips for the PWM output that can work at 2V, and their inputs can connect to 2.7V without buffers. Even a 2V reference is absolutely fine.

Richard.

 

alm

  • Guest
Re: General Purpose Power Supply Design
« Reply #56 on: March 25, 2012, 12:16:49 pm »
I have to apologize as I am just putting a picture together in my head about where this could go, and I think my project will end up looking very different from Dave's, which is a good thing I think. I have a few surprises of my own, but my basic regulator board should be able to provide 0 to 24V at 1A  with no heatsink. It will have a linear regulator output with a switching pre-regulator of some kind. That is what I am working on now.
Feel free to change your mind as often as you want, you're doing 99.9% of the work, so you get to decide.

I love the old 4000 series CMOS, but the speed is too high. The clock to the PWM is at 16MHz and I need very clean switching waveforms at that frequency.
Doesn't clean, fast switching also imply additional HF noise you have to get rid off? Or do you expect the low-pass filter to have enough attenuation to deal with this? I can see that fast edges are critical to the linearity, although I guess you could correct for this in software.

I really like your idea of shooting for similar resolution to the old analog coarse/fine (or multi-turn) pot. These supplies have a lousy accuracy and tempco, but the good ones have no problems with sub-mV settability, and tend to be quite stable once they're warmed up.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #57 on: March 25, 2012, 12:36:23 pm »
Firstly, I would like to thank you both, Richard and AcHmed99, for your interesting exchange of views.

Richard, I would never think of expanding the 256-bit PWM AVR modules because of the dramatically reduced speed of the extended PWM cycles. In the past I had thought to combine (to scale and add the outputs of) the 16-bit hardware PWM module output with the 8-bit one to create a faster 24-bit PWM module; but the 8/16 MHz driven 16-bit PWM cycle was already slow enough for such tasks and this topology would require one AVR device per PWM module.

Now, thanks to your previous idea I was inspired to give it a try, using the AVR tiny261/461/861 or the tiny25/45/85 that have a PLL driven timer-counter clock up to 64 MHz, which speeds up dramatically the 16/24-bit software extended PWM modules. Since I do not use the Arduino platform I do not know how efficient code your example can produce. So, I wrote the TIM1_COMPA/B/D ISR in assembly from scratch, and the results are very promising: Only 52 CPU cycles (including the call and return) for the 24-bit sigma-delta loop! Mind you that I have not even simulated it but I do not think that there are any errors or omissions; anyway, here it is:

Code: [Select]
; This is the ATtiny861 PWM Timer1 Compare-A/B/D ISR handler (in Fast PWM Mode), where:
; * Vlt_Out: 24-bit PWM target output value, in 3 SRAM consecutive bytes, MSB first
; * Vlt_Err: 24-bit PWM error accumulator, in 3 SRAM consecutive bytes, MSB first
; * OCR1C holds the Timer1 TOP value, which must be set equal to 0xFF
; * TC1H (the 10-bit Timer1 high byte) is set equal to 0x00; or else set it to zero before the update of OCR1x
; For the Current reference output 24-bit PWM ISR there will be needed another similar set of 3+3 SRAM
;  registers, the Amp_Out and Amp_Err for the second PWM Timer1 Compare-A/B/D ISR handler
; The registers A0..A3 can be any high or low registers of the AVR register-file

push A0 ; [+3c]
push A1 ; Temps: A3:A0 (Non-destructive)
push A2
push A3
in A3,SREG
push A3 ; [14c]
; A2:A0 = Vlt_Err
lds A0,Vlt_Err+2 ; Load A the PWM error accumulator
lds A1,Vlt_Err+1
lds A2,Vlt_Err+0 ; [20c]
; --Magic part #1:
out OCR1A,A2 ; Send the top byte of the PWM error accumulator to the PWM for the next cycle
; --Magic part #2:
sub A2,A2 ; Subtract the byte sent to the PWM from the top byte of the PWM error accumulator
; --Magic part #3:
lds A3,Vlt_Out+2 ; Add the target output value to the error accumulator remainder
add A0,A3
lds A3,Vlt_Out+1
adc A1,A3
lds A3,Vlt_Out+0
adc A2,A3 ; [31c]
; Vlt_Err = A2:A0
sts Vlt_Out+2,A0 ; Save the PWM error accumulator
sts Vlt_Out+1,A1
sts Vlt_Out+0,A2 ; [37c]
; Done
pop A3
out SREG,A3
pop A3
pop A2
pop A1
pop A0 ; [48c]
reti ; [52c] (= 6.50µs @ 8 MHz)

Feel free to try that piece of code and/or to optimise it further, since I wrote it in such a way in order to be easily readable and not speed or code optimised. Finally, the AVR PWM output can easily drive 1.2V-5.0V powered buffers of the 74LVXxx or similar logic family that have 5V tolerant inputs.


-George


<EDIT> Minor code and comments corrections... ToldYa! :P
« Last Edit: March 25, 2012, 01:33:15 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #58 on: March 25, 2012, 02:22:15 pm »
George, this is brilliant.

I did mention that the control panel is a different module.

What I didn't say is that for reasons to become evident, the regulator module has to be isolated from the control panel electrically. This means that if I want the control panel option, I need another small dedicated micro on the regulator board doing the basic stiff like the PWM.

Also I was looking how to get about a fourfold improvement just to get the PWM noise below 10 uV.

I think you may have solved the problem.

Had a look at your code and it looks right.
« Last Edit: March 25, 2012, 02:35:38 pm by amspire »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #59 on: March 25, 2012, 03:04:50 pm »
Thank you, Richard.

I think that isolation could introduce excessive jitter if not implemented carefully. But I cannot see any problems in using the micro as a dedicated DAC itself, directly producing the reference voltage only, and doing nothing else, while communicating with the control via its fast SPI hardware module as a slave, using isolation. This makes the low power, wide supply voltage range, 8-pin tiny45 become very attractive as a near-ideal DAC with better linearity that any other very expensive <1 LSB INL dedicated DAC.

The only drawback I can see in this topology is the unavoidable introduction of glitches at the output under certain circumstances, where the diff error value loaded at the compare-match registers needs less CPU cycles to complete that the CPU cycles required by the ISR itself. Or glitches, again, when the asynchronous and faster PLL clock finishes before the ISR does. Of course, the OCR1x loading can be moved at the beginning of the ISR (right after pushing the first temp and reading the loaded value) to speed up things a little. But I do not think that there can be any substantial speed code optimizations, since the posted code above is already quite fast. The ISR code can become a little faster if both the 16/24/32-bit variables are loaded not to the SRAM but directly to the 32-byte register-file, which can be more than twice as fast as the SRAM in access time.


-George
« Last Edit: March 25, 2012, 03:07:22 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #60 on: March 25, 2012, 03:24:17 pm »
This makes the low power, wide supply voltage range, 8-pin tiny45 become very attractive as a near-ideal DAC with better linearity that any other very expensive <1 LSB INL dedicated DAC.

Only in your dreams.
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 A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #61 on: March 25, 2012, 03:49:52 pm »
Yes, though I have not given it a try yet, I also believe that it will be quite noisy, even as a 16-bit DAC.
However, given the insignificant cost and the simplicity of the design, I think it is worth spending some time to test how exactly it behaves.


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #62 on: March 25, 2012, 04:50:35 pm »
I have to add an offset to the buffer output amp anyway, because if the tiny PWM is like the Arduino PWM, it doesn't go to 0V.

However, I can see one problem with the tiny. If the PWM is at 64 MHz, and the micro runs at 8MHz, the interrupt takes longer then the PWM cycle. Is there a single 64 bit PWM we can use for the voltage?

I can think of ways we can still use 8 bit PWM at a least resolution for the current limit.

Otherwise there is an already at strategy that works almost as well. You move your code to a timer interrupt - say a 50us interrupt. It calculate the correction based on a PWM cycle count register and puts the PWM preset into a register.

All the PWM    interrupt does is this. If the preset register is non-zero, it loads it into the PWM, zeros the preset register and sets the cycle count register to one. Otherwise it increments the cycle count  register and returns.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #63 on: March 25, 2012, 10:23:37 pm »
Why does the Arduino PWM output not go down to ground? The AVR has true complementary outputs with Rdson 24 ohm at Vdd 5V at room temperature, for both the high and the low output stages. Maybe something is interfering with the PWM out pin or its pull-up feature? Does that pin remain an output even for zero input at the OCRx register? I am nor familiar with the Arduino platform but the m168/m328 are reliable chips. A tiny861 10-bit pure hardware PWM test circuit I had recently implemented was going perfectly down to 0.00V for 0x000 PWM input and had a surprising good linearity. See the t85 and t861[A][P] (go for the [P]ico-Power version) data sheets (Yes, I know, they made their site worse than their AVR Studio 5).

The ATtiny 64/32 MHz PLL clock has a programmable prescaler that outputs the following frequencies: PCK/1, PCK/2, PCK/4, ..., PCK/16384. No need to run the timer at full speed. If, for example the ISR is 52 CPU cycles long, that is 6.50µs @ 8 MHz, 3.25µs @ 16 MHz, 1.625µs @ 32 MHz or 812.5ns @ 64 MHz. You choose the best clock speed in order to have a PWM cycle of at least one and a half ISR's time, to adjust the OCR1x safely. In the paradigm demonstrated above, the time ratio at 8MHz is 1:5, so the timer's clock frequency can safely be raised two times up.

In order to minimise power consumption, you can run only the PWM module with the idle sleep enabled. There is no need to do calculations with such tight code execution. Just implement a simple software SPI with three of the remaining pins that only receives 16/24-bit full length words and updates the PWM unit.


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #64 on: March 25, 2012, 10:35:13 pm »
Obviously the ATtiny PWM is butter designed then the Arduino processor. For a PWM value of 0, the Arduino puts out a single clock width pulse.

The thimg with the prescaling is I want to  run the PWM at 64 MHz.  :)

Anything less and I do get a detectable noise on the output.

I will take a look at  ATtiny specs today.

Richard.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #65 on: March 25, 2012, 10:54:42 pm »
The ATtiny line actually is a stripped down ATmega implementation; for example, the tinies do not have a hardware multiplier or USARTs. Both of these lines are of the same material, with a few special exceptions that have additional LCD/CAN/USB/PLL/etc. support. By the way, the tiny861 10-bit PWM test circuit I wrote about above was constructed on a breadboard! So, if something was nor working as expected, like what you reported, I would rather be suspicious of the "sketch"/"shield" software/hardware platform than the AVR chip itself.


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #66 on: March 25, 2012, 11:57:59 pm »
Just started having a look at the ATtiny data sheet. They give you one or two options don't they.  :o

I have the suspicion that the Fast PWM mode which is the one I used might work the same as the Atmega in that the match is acted on in the following cycle, so if the register has 0 in it, it will only clear the output on the second clock. But they data sheet didn't explain it as clearly as the Atmega, so I will have to actually read it.

But there is good news. I did some testing and the correction calculations can be slowed down to as much as once per millisecond and the results form the filter are still beautiful. The code that would run at the PWM interrupt is probably well under 10 clock cycles.  I have the idea in my mind and so I will put up some code/pseudo code today.

There is actually no advantage at all in doing the correction per PWM cycle at all is seems. This is great as it means even if there is a PWM update issue, only a tiny number of PWM cycles could be effected. Correcting at a 1KHz rate produces in effect a 1KHz square wave with an amplitude of 1mV or less, and my 3 stage 10k/0.1uF filter reduces the amplitude of that to below 1uV. Perfect!

Is there a way to stop any other interrupts occurring during the processing of the PWM interrupt?

Richard.

 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #67 on: March 26, 2012, 12:09:58 am »
All interrupts are disabled during the ISR. The only way another interrupt can occur during an ISR is by enabling the interrupts inside the ISR. The interrupts are re-enabled after reti.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #68 on: March 26, 2012, 01:05:33 am »
All interrupts are disabled during the ISR. The only way another interrupt can occur during an ISR is by enabling the interrupts inside the ISR. The interrupts are re-enabled after reti.

Is there any concept of interrupt priorities on the AVR chips?
I'm not an EE--what am I doing here?
 

Online TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1210
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #69 on: March 26, 2012, 01:14:21 am »
Quote
Is there any concept of interrupt priorities on the AVR chips?

An interrupt's priority is determined by its position in the interrupt vector table.  Interrupts with lower addresses have higher priority.
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #70 on: March 26, 2012, 03:40:01 am »
Complementing on TerminalJack505, only xMegas have a real interrupt priority scheme.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #71 on: March 26, 2012, 05:57:46 am »
If anyone understands the Atmel family, how are 32 "General Purpose Registers" ( addresses 0x00 to 0x1F including the X, Y and Z registers) accessed separately from the thing Atmel calls the "Registers" in the data sheet - the 48 byte locations where all the configuration, ports, ADC outputs, Timers, etc are located. They are located in addresses 0x00 to 0x3F.

Are the "General Purpose Registers" the things called "Registers" in the assembler, and the "Registers" the thing called "Ports" in the assembler?

Richard.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #72 on: March 26, 2012, 06:36:41 am »
Most likely so. I understand the AVR is a RISC architecture, so the 32 general purpose registers would be typical of that kind of architecture and intended for use by programs. The "other" registers are probably what would be called control registers in general processor terminology.
I'm not an EE--what am I doing here?
 

Online TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1210
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #73 on: March 26, 2012, 06:46:42 am »
If anyone understands the Atmel family, how are 32 "General Purpose Registers" ( addresses 0x00 to 0x1F including the X, Y and Z registers) accessed separately from the thing Atmel calls the "Registers" in the data sheet - the 48 byte locations where all the configuration, ports, ADC outputs, Timers, etc are located. They are located in addresses 0x00 to 0x3F.

Are the "General Purpose Registers" the things called "Registers" in the assembler, and the "Registers" the thing called "Ports" in the assembler?

Richard.

It's confusing but once you realize that the CPU has several different address spaces (aka addressing modes) it will make sense.  They did this so that they could reduce the size of the CPU instructions by cramming the 'addresses' into the op code.  The general registers (aka register file) and the ports (aka I/O registers) seem to have overlapping addresses but don't since they live in separate address spaces.  For convenience, they are mapped into data space (SRAM) which means they may have a different address in that space than they do in their normal address space.   

The ports (I/O registers) can be accessed either from the SRAM memory space or via special CPU instructions.  When accessed from the SRAM memory space they will have 0x20 added to the 'address' (the register file is mapped into the first 32 bytes of data memory.)  The I/O register 'address' is used as-is with the special instructions--such as CBI, SBI, etc.

Check out the first couple of pages of the AVR Instructions Set PDF:

http://www.atmel.com/Images/doc0856.pdf

It explains the different data addressing modes.
 

Offline Alex_arg

  • Contributor
  • Posts: 16
  • Country: ar
Re: General Purpose Power Supply Design
« Reply #74 on: March 26, 2012, 03:47:32 pm »
Hi amspire , i've been following Dave's PSU design and got the same idea, because i'm not very handy with microcontrollers , but i didn't find the time to try to make it "analog". The switching pre-regulator it's a great idea, but i
was stuck trying to find a simple way to control both regulators from an unique Vset potentiometer.
By the way i've got a cup of questions :
how you make this regulator go down to 0Volts?  negative control voltage ?

Are you aiming to make it portable? No sophisticated batteries in this zone, but i was thinking to use a 12V 7A bat to make it work (those from alarm systems) and a suitable charger.

Greetings
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #75 on: March 26, 2012, 04:57:19 pm »
Richard, the AVR "32 general purpose registers" is the processor's Register-File, i.e. the special SRAM registers the ALU has direct access to. It is what the older 8051 and the PIC architectures call the Accumulator/Working Register, with the difference that in the AVR it is not a single register but a whole set of 32 registers. You can see that this is the same approach of the MSP and the ARM, for example, family processors that have a register file of 16 uniform registers. In the AVR, everything beyond the Register-File and before the SRAM space is called I/O space and is used to be accessing the microcontroller's peripherals.

The AVR Register-File is not a uniform one. It consists of the low (r0..r15) and the high (r16..r31) registers. The low registers cannot handle immediate values; the high registers can. The first bottom register pair (r1:r0) is also used for the storage of the hardware multiplier 16-bit product. The four top register pairs (r25:r24, r27:r26 or XH:XL or X, r29:r28 or YH:YL or Y, and r31:r30 or ZH:ZL or Z) have 16-bit addressing capability for the 16-bit ADIW and SBIW math instructions. The three top register pairs (X, Y and Z) can be used for indirect addressing of the whole SRAM/EEPROM spaces and the top register pair (Z) can also be used for the indirect access of the FLASH memory space.

Why is the large Register-File important is obvious, since it eliminates the need to be constantly accessing the SRAM space in order, for example, to deal with multi-byte figures, since almost every instruction that accesses the register file takes one CPU cycle only, while the direct access of the SRAM registers takes two.


I hope this helps,
-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #76 on: March 26, 2012, 07:05:13 pm »
Richard, in order to realise the benefits of a large Register-File, I took the time to rewrite the TIM1_COMPA/B/D ISR I posted previously, using exclusively registers of the AVR Register-File. Please, notice that this is a real world example and not an Academic demonstration of the AVR capabilities.

Code: [Select]
; This is the ATtiny861 PWM Timer1 Compare-A ISR handler (in Fast PWM Mode), where:
; * r2:r0: 24-bit PWM target output value, MSB first
; * r5:r3: 24-bit PWM error accumulator, MSB first
; * r15: Used as a temp to preserve the Status Register
; * OCR1C holds the Timer1 TOP value, which must be set equal to 0xFF
; * TC1H (the 10-bit Timer1 high byte) is set equal to 0x00; or else set it to zero before the update of OCR1x
; For the Current reference output 24-bit PWM ISR there will be needed another similar set of 3+3 registers
;  for the second PWM Timer1 Compare-B/D ISR handler, while r15 can be reused for the same task.

in r15,SREG ; [+3c] Preserving the CPU Status Register
; --Magic part #1:
out OCR1A,r5 ; [5c] Send the top byte of the PWM error accumulator to the PWM for the next cycle
; --Magic part #2:
sub r5,r5 ; [6c] Subtract the byte sent to the PWM from the top byte of the PWM error accumulator
; --Magic part #3:
add r3,r0 ; [7c] Add the target output value to the error accumulator remainder
adc r4,r1
adc r5,r2 ; [9c]
; Done
out SREG,r15 ; [10c] Restore the Status Register
reti ; [15c] (= 1.875µs @ 8 MHz)

You can see that the same function has now become three and a half times faster than in the previous implementation! Using the same CPU and Timer1 clock frequency of 8 MHz, it now takes only 1.875µs for the ISR to complete against the 6.50µs previously needed! The obvious penalty is the loss of the registers r5:r0 and r15, that cannot be used anymore for anything else; but this is not really an issue because the processor has 25 general purpose registers left to use for other possible tasks! Isn't AVR a lovely chip?


-George



<EDIT>: Last minute corrections and clarifications...
« Last Edit: March 26, 2012, 11:02:28 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #77 on: March 26, 2012, 07:14:10 pm »
Thanks for the explanation George. What  I found incredible is that the data sheets do not explain this well at all. No nice memory mapping diagram. It has a command summary full of letters like k, P, Rr, etc but they don't explain what the letters are.

There is probably a document somewhere that does explain this, but finding that document is not easy.
I have never touched Atmel assembler before and struggling with the data sheet was just odd. I was thinking there has to be general purpose registers, but where?  They are not in the "Register Summary". They are not in the Memory  section of the datasheet. Older processors like the 8051 used to explain all this extremely carefully, but Atmel can't be bothered.

In your first code, you use A1, A2, etc.  Other code uses R1, R2, etc. I assume they are the same?

Richard.
« Last Edit: March 26, 2012, 07:17:22 pm by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #78 on: March 26, 2012, 07:58:10 pm »
Hi amspire , i've been following Dave's PSU design and got the same idea, because i'm not very handy with microcontrollers , but i didn't find the time to try to make it "analog". The switching pre-regulator it's a great idea, but i
was stuck trying to find a simple way to control both regulators from an unique Vset potentiometer.

The heart of this design is a very cheap board that can be controlled totally from potentiometers if you do not want to use microprocessors. I am making sure that none of the functionality is affected if you leave out the micro. I know that trying to get a micro programmed when you are not set up for it is not fun.
Quote

By the way i've got a cup of questions :
how you make this regulator go down to 0Volts?  negative control voltage ?
There are two parts to this. First getting 0 volts out is easy -if you reduce the current you are supplying down to zero, you have zero volts out.

Secondly is how you actually regulate down to zero volts.

The LM324 opamp inputs can actually work to a little below the negative supply rail. They do this with a clever design using PNP input transistors. A PNP transistor can still be working with the base at -0.1 volts and the collector between zero volts and +0.5 volts.
Quote
Are you aiming to make it portable?
If you put the board in your own box, it can be portable.  It will run of a 12 battery perfectly, but you would have to add a charger. The control panel version may end up being not portable, but I have other issues to work out before I get serious with the packaging.

Richard.
« Last Edit: March 26, 2012, 08:02:33 pm by amspire »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #79 on: March 26, 2012, 08:06:05 pm »
Richard, in the AVR assembler you can assign label names for everything. The original names of the Register-File members are r0, r1, r2, ..., r30 and r31. Since I almost always have to deal with 32-bit or longer figures, I usually rename sets of consecutive registers in order for the code to be easily readable. Regarding the A0, A1, etc. nomenclature I used previously, I just offered the convenience of using any registers available, as I explained it at the header.

In the assembler you can directly use the name "r15" or "R15" to access r15; but since, for example, I usually have a null value register (always loaded with the constant 0x00) I prefer to call it "Zero" instead of r15. Or "tmp1" and "tmp2" instead of "r16" and "r17." Specifically, I usually call A3:A0 the registers r21:r18, B3:B0 the registers r25:r21, etc. But this is only me! There are not any global rules that work for everyone; you just pick a style you are comfortable with and works for you.


-George



<EDIT>
Edited to say that I rather prefer to work with the "mature" AVR Studio 4, which can be found here (v4.19.720), that with that ugly creature they call AVR Studio 5...
« Last Edit: March 26, 2012, 08:39:07 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #80 on: March 26, 2012, 08:55:30 pm »
George, your latest code is probably useable, so I think I will drop my more complicated solution. We can get two PWMs going with a 32MHz clock. I probably need the option of running at 2.7 volts anyway.

I gather that any other interrupt routines will have to reenable the PWM interrupts as the first command.
Any further PWM outputs still just have to be plain 10 bit PWM.

If it is any use, there probably are some I/O registers we can pinch for other duties. I doubt I will be using the timer0 PWM registers or the dead time register.

Richard

Edit: I am happy loosing some general purpose registers to improve the interrupt speed. The micro will not have a lot of tasks to do.
« Last Edit: March 26, 2012, 10:32:16 pm by amspire »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #81 on: March 26, 2012, 10:34:17 pm »
Well, these are a few quick thoughts:

According to the data sheets, at 2.7V both the t85 and the t861 can run at 10 MHz CPU clock frequency and their high-speed timers at 64 MHz. Since the t861 has a three-channel 10-bit hardware fast PWM stage and t85 has a two-channel 8-bit one, this rules out the use of the latter chip. What worries me is the unavoidable noise induced by the CPU/Timer digital stages transitions and the jitter of the RC/PLL clock generators that affects the output linearity. I am afraid that I am not even sure if a decent 16-bit linear output is feasible, where 1 LSB = 41.20µV; this is getting much worse for a 24-bit solution, where 1 LSB = 160.9nV...

Now, the AVR can execute nested subroutines on demand (by the manual enable of the global interrupts flag within the Status Register, at some point within an ISR) but why do that? The idea is to finish the critical ISR code execution as soon as possible and not to extend it any further. But this can be arranged in favour of preventing output glitches in the case of an interrupt firing while another ISR is executed.

After booting up, the firmware initialises the hardware modules and their variables, it starts the PWM modules, enables the global interrupts and enters the main, where it does nothing else than sleeping to reduce power consumption while waiting to receive from the serial line any further commands and/or new values for the PWM modules. The SPI protocol seems to be better for synchronization purposes, since the CPU workload is not negligible in this application.

The latest ISR code above will need 1.875µs for the completion of the extended PWM ISR, which means that 256 timer steps (a complete hardware PWM cycle) should not take less time than that figure, which implies that the PWM clock tick should be no less than 7.32 ns or its frequency be no more than 136 MHz. So, we are good running the PWM timer at full speed. These figures even allow us to add a second extended PWM ISR if we reduce the PWM speed in half.


-George
« Last Edit: March 26, 2012, 10:45:52 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #82 on: March 26, 2012, 11:01:26 pm »
The other thing is if we move to 10 bit, we get a time gain of four, so even though there will be some extra code, it is probably OK.  I will take a look at the PLL stability spec, but with al the filtering, it will probably be OK in the end.

Linearity really isn't a concern, as the truth is every time someone wants a really accurate output, they will use a multimeter. 1% accuracy is all you need for general use, and I am sure we can do better then that. We should get a monotonic output though which is my no.1 demand.

Richard.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 533
  • Country: cz
Re: General Purpose Power Supply Design
« Reply #83 on: March 26, 2012, 11:06:44 pm »
Guys, why do you concern yourself about the ISR length? The 64MHz is PWM CLOCK, not PWM frequency, that will be 256 times less for 8-bit PWM, or 250kHz. Plenty of CPU cycles - you can run CPU at 16MHz (Pclk/4), thats 64 CPU cycles per one PWM cycle/interrupt, more than enough...
And as for the supposed glitches, the PWM registers are double buffered to avoid just that (i.e. whatever you write will affect the next cycle, not current cycle).
At least for the ATtinys I'm familiar with...
I would keep the PWM stuff in interrupt as is and do the SPI reading/target value setting in main loop via polling, no need of nasty interrupt nesting.
Good enough is the enemy of the best.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #84 on: March 27, 2012, 12:01:42 am »
Guys, why do you concern yourself about the ISR length? The 64MHz is PWM CLOCK, not PWM frequency, that will be 256 times less for 8-bit PWM, or 250kHz. Plenty of CPU cycles - you can run CPU at 16MHz (Pclk/4), thats 64 CPU cycles per one PWM cycle/interrupt, more than enough...

And as for the supposed glitches, the PWM registers are double buffered to avoid just that (i.e. whatever you write will affect the next cycle, not current cycle).
We have been working with these numbers. We need two PWM's and that is when it gets very tight. About the glitches, there things that we have to watch out for. For example, triggering off a match means the code can run before the next match. However, it may not complete before the next PWM cycle starts, and so double buffering means that the new value does not get run till the cycle after.

Probably triggering of the end of the PWM is best. That means the one interrupt will process both PWM's at the same time, and that saves a few cycles as well.

Quote
At least for the ATtinys I'm familiar with...
I would keep the PWM stuff in interrupt as is and do the SPI reading/target value setting in main loop via polling, no need of nasty interrupt nesting.
That sound like a good plan. The micro really does not have much to do.

Richard
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #85 on: March 27, 2012, 12:33:59 am »
Richard, moving to a 10-bit PWM is even easier: You just set the module up once and you literally forget about it because everything happens in hardware with absolutely no CPU intervention! The t861 Timer1 has a three-channel 10-bit hardware fast PWM stage that needs no maintenance at all after having it initially set up. You only have to modify a couple of registers (TC1H:OCR1x) in order to change its output.

Speaking of the PWM output, it is monotonic by principle: There are no magic value quantities to be added to/subtracted from, that must be exactly equal to the next_value - 1 LSB to the previous_value + 1 LSB; and the length of the output pulse is directly proportional to the OCRx input value, which is a promise for good linearity. There are not any "missing codes" in this topology. But I do not know what happens in these expanded PWM cycles, where the target RMS output is produced by non symmetrical pulse trains.


hlavac, there is a concern of the ISR code length because the CPU runs at 8 MHz and the ISR at 250 KHz (= 64MHz / 256), which leaves a 4 µs time window for the ISR code to do its magic. In 4 µs time, the CPU has 32 machine cycles (which is 32 CPU clock cycles for the AVR) to do what it needs to be done, while the code above (which I do not consider to be final) takes 15 of them for every extended PWM channel. Yes, this is not a tight situation exactly but the previous implementation of that ISR needed 52 cycles and could not be run at that high speeds that do not require heavy output filtering and are faster in response. Neither would I like to raise the CPU frequency to 16 MHz because the current consumption would almost be doubled and the AVR needs to be powered by an accurate source that usually does not (and should not) deliver much power. We agree, though, in the polling SPI implementation, especially since the tinies do not have a dedicated SPI controller as the megas do.


-George
« Last Edit: March 27, 2012, 01:08:55 am by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #86 on: March 27, 2012, 05:49:58 am »
Since we got into the business of counting cycles, I discovered a few mistakes in my calculations above.

The ISR execution response time is not 3 (this is for a subroutine call) but 4 CPU cycles plus another 4c if this occurs while the AVR is in sleep mode. This makes the time duration of the ISR above to be not 15 cycles but 16c. Now, the worst case scenario is both the ISRs to fire simultaneously while:
1. The AVR is in sleep mode. This extends the 16c time by 4 more cycles.
2. The AVR executes a multi-cycle instruction (a 4 cycles "return," in the worst case), where that instruction will be completely executed before the pending interrupt is served. This extends the 16c time by 4 more cycles.
Notice that when the AVR exits from an ISR, it will always return to the main program and execute one more instruction before any pending interrupt is served.

Under these conditions, the total time needed for both the ISRs to finish will be 4c+16c+4c+16c = 40 CPU cycles plus 1c uncertainty due to the asynchronous nature of the high speed PLL clock. This requires the complete hardware PWM cycle (not the extended one) of 256 timer steps to be taking no less than 41 CPU cycles or, given that the CPU clock is 8 MHz, no less than 41*125ns = 5.125 µs, which is translated into a PLL clock speed of less than 49.9 MHz. The next acceptable PLL clock frequency is 32 MHz, which results in an 8.0 µs 8-bit hardware PWM cycle, in a 2.048 ms 16-bit extended PWM cycle and in a 524.288 ms 24-bit extended PWM extended cycle. This will need some serious filtering...

I think that the most viable option will be a dual 16-bit PWM with low pass filters of a couple of hundred milliseconds settling time to filter out the 2 ms PWM cycle irregularities.


-George



<EDIT>

Since the t861 Timer1 has a 10-bit hardware PWM, a 32 MHz clock will result in:
1. Setting the Timer1 TOP count to 511 (i.e. 9-bit PWM resolution) results in a 16.00 µs 9-bit hardware PWM cycle and in a 8.19 ms 18-bit extended PWM cycle.
2. Setting the Timer1 TOP count to 1023 (i.e. 10-bit PWM resolution) results in a 32.00 µs 10-bit hardware PWM cycle and in a 32.77 ms 20-bit extended PWM cycle.

After all, this set up does not sound to be that bad...
« Last Edit: March 27, 2012, 06:30:26 am by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #87 on: March 27, 2012, 12:34:24 pm »
I suspect the filtering at 32MHz with a 3 stage RC filter is much better then you are expecting. I will definitely give it a go, but I will not return to 16 bit PWM.  Just not good enough.

I might have to do a properly designed filter to get a bit more from the 32 MHz then the very basic RC filters can do. I am sure we can make it work. George, I am totally grateful at all your help so far. It is this kind of detail that takes more time then you think.

Right now I am working to see if it is possible to add a switching pre-converter without making the supply too noisy. If you attach a scope to a circuit under test and see switching noise, it is just not going to work. If I can get the switching supply to work, I totally solve heat issues, allow the supply to run from a huge range of voltages, and I get isolation from the supplies (it is a transformer based switching supply).

I am going to put together a test supply tonight and tomorrow to at least check my choice of a particular toroid can work over the range at full power, but I am sure I will have to do some more design work on the transformer to keep the noise away from the secondary.

Again, I am looking at economy. I want the BOM for the basic supply board and pre-regulator to be under $20.  SMD transformers can be very expensive, and they still may not be right. I have found a small toroid core I can get very cheap, and there are not many turns, so it hopefully will not be hard to make.

Richard.
 

Offline Alex_arg

  • Contributor
  • Posts: 16
  • Country: ar
Re: General Purpose Power Supply Design
« Reply #88 on: March 27, 2012, 07:42:50 pm »
ahh , of course!  thanks for the clarification Richard, i was not thinking in the adjustable current, and all supplies i've built have negative supply to achieve cero volts..(and for the OpAmps) Good luck   
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #89 on: March 28, 2012, 06:01:21 am »
Richard, I know its still in very early stage, just curious on your choice for the power switching part ? or maybe the potential list of switcher ic candidates that you're going to experiment ?

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #90 on: March 28, 2012, 08:29:25 am »
I am building a test switcher with the wrong IC - it is just one I happen to have. A UC3842 which stops working when the input voltage gets down to 10V. It will be enough to get the measurements I need. The reason I need to do testing is that a 3 to 20V input, and a 3 to 27 volts output is a huge range if I want to get a full 1A out for every input/output combinations. I may have to cut the input range back to 10V to 20V. That range means old PC supplies could be used as a power source.

3V input would allow a single Lithium battery to be used, but to get 1A out at 25V, a 3V lithium cell would be outputting about 13A. For people who wanted to make a small 200mA supply, currents of up to 2.5 A peak from the cell sound a lot better.

To get the full range of input and output, I am using a flyback design. I want to get it working to test out the transformer and the secondary circuit. With the peak current that is the result of the big voltage range, I probably have to use a controller with an external power MOSFET, but I am not going to choose a regulator until I have a good feel for the frequency I need and I have worked out the transformer details. It is a spare time job, but I might get a few days to work on it this week, which will be good.

Once I know where I am going with the switching pre-regulator, I will put together something summarizing all the ideas, but to give a preview, the main reason I want the boards to be fully isolated from the power source is that I am designing the 25V 1A supply boards so they can run in parallel or serial in a master-slave configuration. So if you want a 25v 5A supply, just put 5 boards in parallel. If you want 100V 1A supply, put 4 boards in series. Or if you want a 100V 5A supply, then I know you are crazy - but why not? It is only 20 boards.  :)

What I discovered is it is probably impossible to come up with a general purpose design for a single regulator that could be scaled from a 100mA supply to a 10A supply without a redesign. But I can make a single fixed size board that is highly versatile and configurable.

I am borrowing the series/paralleling idea from the old HP supplies, but it is one of those ideas I will have to test for real. No reason why it shouldn't work though. 

If you are building a bigger supply, you could use a PC power supply as a source. One of the compact-sized PC supplies (200W - 350W) is still pretty compact,

It may sound odd, but the thing is if each board is very cheap, it will probably end up being a much cheaper and quicker way to get a supply going then trying to custom design a dedicated supply. It is quite possible that the BOM of the parts for a board excluding the PCB will be under $10. All the parts are easily available through hole, so it is possible to have a through-hole kit - not that I have any real plans at this stage.

It is possible that I can get the board over 1A, but the first rev will be 1A to be conservative. Don't think I want to go above 25Volts. 30V is technically possible, but it is getting too close to the opamp limits for my liking.

There will also be an option of a linear pre-regulator with a heatsink, so you can put the board in a box with with a transformer.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #91 on: March 29, 2012, 04:34:42 pm »
Richard, I really wish your modular design can work with two versions of switching pre-regulator for two kind of sources which are battery powered (step up and down) with much lower current capability, and the 2nd version with higher current source like pc power supply or even step-down transformer (step down only).


Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #92 on: March 30, 2012, 01:18:57 am »
If you are planning on battery operation you may want to look into a sepic converter for your preregulator. There is one here.

http://panteltje.com/panteltje/pic/pwr_pic/

Thanks for the link. Sepic converters have been one of the options I have been looking at. I will finally power up my test flyback transformer converter today. Took longer then I was hoping just because I needed a pretty good layout to have a chance at low noise. If the isolated option turns out to be just too noisy, a non-isolated sepic controller design will probably be my next choice.

I am sticking to the linear output stage, just due to the fact it perfoms better then a switching supply output.  The circuit in the link has a 2000uF capacitor on the output and that will be needed to get reasonable regulation, transient response and reasonably low noise on the output. The problem with that is even if you set the current limit to 10mA on the supply, then if the circuit under tests shorts the supply, then all the energy in the 2000uF cap goes into the component shorting the supply and that can damage the very circuit you intend to protect. A good linear supply can give better regulation, better current limiting and better transient response with only a 10uF cap on the output. 

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #93 on: March 30, 2012, 01:47:51 am »
Richard, I really wish your modular design can work with two versions of switching pre-regulator for two kind of sources which are battery powered (step up and down) with much lower current capability, and the 2nd version with higher current source like pc power supply or even step-down transformer (step down only).

Definitely something like a 100mA supply is all you need for testing circuits like microcontroller and opamp circuits - very useful. Or a 1A 0-5V supply that decreases to 100mA at 20V out. When I get to the stage of have some working preregulators, I will look at how to organize the different options to make it understandable. I know if you give too many options, it just gets too confusing.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #94 on: March 30, 2012, 02:17:51 am »
Not trying to nit-pick here but if your load is shorting out isn’t it safe to assume its already destroyed and therefore it is the regulator you are trying to protect. If you have multipile loads on the regulator if one shorts out, the voltage after the pass device will still collapse no matter how fast your current limiting is if that’s the concern. That’s how current limiting works.
No. The short can be from wiring faults, from say a switching regulator circuit you are debugging that switches hard on, from a transistor bridge ciruit or audio amplifier output stage where both transistors turn on at the same time - lots of reasons. The diea of current limiting is  that you do not blow anything up duing the debugging.
Quote

Yes you are definetly better off using a post regulator not only for noise attenuation but it will ease the magnetics desighn. You may find it to be benificial to use some type of frequency foldback at lower output voltages (powers) where you would be likely to change operating modes from DCM to CCM. A wide input will definetly add to the complexity. May be worthwhile to add a boost to feed your flyback a regulated input.
You are right about the fact that to get a supply working with a wide ranging input and output voltage and current range, I will have to switch between the CCM (a continuous current through the inductor/transformer) and DCM (the inductor/transformer current drops to zero during the discharge cycle) modes.

At high input voltage at minimum volts and amps out, the supply regulation circuit will force a lower switching frequency anyway without an intentional frequency foldback circuit.  The regulation circuit will just not allow the supply to switch again till the output voltage has dropped below the regulation voltage. If there are regulators that implement a deliberate frequency foldback scheme, I would be interested to know about them.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #95 on: March 30, 2012, 10:57:48 am »

No. The short can be from wiring faults, from say a switching regulator circuit you are debugging that switches hard on, from a transistor bridge circuit or audio amplifier output stage where both transistors turn on at the same time - lots of reasons. The idea of current limiting is  that you do not blow anything up duing the debugging.
Sorry but again I'm not following your reasoning for this. You can't control both CC and CV simultaneously. If you have too fast a CC loop then it could prove to be a nuisance.
No, it is not that much of a problem. In normal use, the power supply is not near the constant current limit, so the constant current circuit is hard off. It is tricky getting the supply totally stable right at the precise point where both controls are active at the same time. this crossover window though is extremely tight -  a windows of a few microvolts and a few micro amps, so a problem there is rarely a big problem. The constant current loop has to be pretty fast.
Quote


You are right about the fact that to get a supply working with a wide ranging input and output voltage and current range, I will have to switch between the CCM (a continuous current through the inductor/transformer) and DCM (the inductor/transformer current drops to zero during the discharge cycle) modes.

At high input voltage at minimum volts and amps out, the supply regulation circuit will force a lower switching frequency anyway without an intentional frequency foldback circuit.  The regulation circuit will just not allow the supply to switch again till the output voltage has dropped below the regulation voltage. If there are regulators that implement a deliberate frequency foldback scheme, I would be interested to know about them.

Richard.

I think there are some but what I am doing using the cmos version of the UC384x series is clocking it from a PIC10F. If you control the duty of the clock via a PIC you control the maximum duty of the controller thereby limiting maximum power transfer. If you also provide a regulated voltage in my case to an asymmetrical flyback halfbridge via a APFC this allows for pretty precise power limiting or a lot more precise then wide input. My idea for frequency fold back is just to use a Flip flop to divide by 2 the frequency when the voltage, power demand drops below a certain level.
I am testing with a UC3842, but it does have the problem that is shuts down at 10V. How are you changing the clocking frequency without affecting the Rt/Ct ramp amplitude and shape?

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #96 on: March 30, 2012, 11:50:38 am »
You have definitely given me ideas about getting a big range. It is possible to just let the regulator cope with very low loads by triggering for a few cycles till the voltage is too high and then shutting down till the voltage is too low again, but changing the frequency lets the regulator run in a more predictable way - probably with much better regulation.

Definitely worth a look. Thanks

Richard.

 

Offline robrenz

  • Super Contributor
  • ***
  • Posts: 3035
  • Country: us
  • Real Machinist, Wannabe EE
Re: General Purpose Power Supply Design
« Reply #97 on: March 30, 2012, 01:56:40 pm »
This is the type of peaceable constructive community brainstorming that makes this forum great! Keep up the good work :)

Offline king.oslo

  • Frequent Contributor
  • **
  • Posts: 432
  • Country: no
Re: General Purpose Power Supply Design
« Reply #98 on: March 30, 2012, 02:28:39 pm »
Richard, I am impressed.M
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #99 on: March 31, 2012, 06:01:10 am »
Richard and probably to Achmed as well, not to derail the current discussion and also I'm aware you're working on fly back topology, just for curiosity sake, why Cuk converter topology is not popular since it has excellent ripple output ?

Cause I've been thinking since we're going to wind our transformer anyway. Regarding inverted output of Cuk converter, CMIIW this should not be a problem for this purpose right ?

PS : I don't have any experience in this Cuk, its just I've been reading quite some literatures about it, and it seems like implementation of this topology is quite rare.

Apology if this is way OOT.
« Last Edit: March 31, 2012, 06:06:23 am by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #100 on: March 31, 2012, 06:41:38 am »
I have not actually tried to design a CUK converter. Usually the reason is the simpler design is tried first, and if that works, the more complex design is ignored. I might have to see if someone else has experience.

The flyback design is capable of great range and is about as simple as you can get.  I am really working on costs, and I cannot see how a CUK design would not be more expensive.

The initial tests look good, but now I need to isolate the secondary. Looking around for an optocoupler. I thought I had some, but they are all opto-triacs.

I think I better throw together an adjustable current sink for testing the supply.

Richard
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #101 on: April 01, 2012, 07:39:11 am »
I have a isolating switching pre-regulator working and it is looking pretty good. Everything is running very cool.

Tried out the feedback via an optocoupler and it worked first time.

Once I have put together a constant current load, I will do some tests and post the results. It is not the final circuit as I am using just the parts I had lying around.

The UC3842 chip I am using for the moment only lets me test down to 10V minimum input and I want it to work down to 3V DC input, but using different regulator chip will not change the performance of the switching supply much. Currently using a 300kHz switching frequency.

Since I am using it as a pre-regulator, I do not need much accuracy. The current circuit will run at about 1.3V above the linear supply output voltage and I could end up sticking with that.

I hope to post the circuit and test results tomorrow. Once I have fully tested my test supply, I can put together a full Rev 1 design that allows you to take any voltage source between about 3V and 20V and convert it to an isolated 0 to 24V 1A linear supply.

Richard.

 

Offline electronwaster

  • Regular Contributor
  • *
  • Posts: 60
  • Country: au
Re: General Purpose Power Supply Design
« Reply #102 on: April 01, 2012, 09:13:32 am »
This sounds great, it sounds like (if I'm not misunderstanding) it can be built without a microcontroller, in which case I'm definitely building one (or a combinable pair) as a lab PSU.

I have been trying to design and build a PSU starting from scratch (no electronics knowledge whatsoever), and so far I have an zener/opamp/pass transistor circuit that can go down to 0V and offers reasonable load regulation, but no constant current limit. You have just provided me with a great shortcut! 

Thank you for your efforts putting this together, I am really grateful!

electronwaster
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #103 on: April 01, 2012, 11:03:31 am »
This sounds great, it sounds like (if I'm not misunderstanding) it can be built without a microcontroller, in which case I'm definitely building one (or a combinable pair) as a lab PSU.
Definitely. It can be fully used without any micro. Also the idea will probably be to do two versions - a through hole version that would be easy to build, and a smaller SMD board. So far all the parts I am using are available in both forms, but I still have to pick the switching regulator. If you don't mind having a heatsink, the linear pre-regulator will be a simpler option and will be noise free. A heatsink probably does cost more then the parts for a switching regulator.
Quote

I have been trying to design and build a PSU starting from scratch (no electronics knowledge whatsoever), and so far I have an zener/opamp/pass transistor circuit that can go down to 0V and offers reasonable load regulation, but no constant current limit. You have just provided me with a great shortcut! 

Thank you for your efforts putting this together, I am really grateful!

electronwaster
Thanks for the encouragement.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #104 on: April 01, 2012, 11:18:20 am »
Thank you for your efforts putting this together, I am really grateful!

electronwaster
Thanks for the encouragement.

Richard.
Mee too !

Contrary to electronwaster I like the microcontroller, but the design allows for both. I'm comfortable to design (and program) the micro, but for the analog and switching stuff I'm lacking experience.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #105 on: April 01, 2012, 05:42:31 pm »
Richard, I remember reading an article while I was researching about the efficiency of SEPIC converters, in which was shown that the SEPIC topology is in many ways better than Flyback: SEPIC outperforms the flyback. Not to mention another article, where is shown that SEPIC Converter Benefits from Leakage Inductance.

Now that I finally found some time to play with it, having already a spare ATtiny861A in hand, I constructed a simple test circuit to see how a 16-bit Sigma-Delta PWM loop DAC behaves. I also connected to the t861A an LCD module and a few push-buttons to be changing the 16-bit DAC target value on the fly. Using the t861A Timer1 Compare-A in Fast PWM Mode running at 32 MHz, I observed that:
1. TC1COMPA will start only when the output value is greater than or equal to 0x0081 (129d), and
2. TC1COMPA saturates (PWM output always HIGH) when the output value is equal to 0xFF00 (65280d); beyond that value the output diminishes, since the MSB overflows and the ISR disregards any possible carry bits.

Both of the observations above were expected, since the 8-bit base PWM ISR,
1. Will not fire when the PWM MSB is equal to zero, so there is no update of the error accumulator, and
2. Will have an always high output when the PWM MSB is equal to 0xFF.

The Sigma-Delta extended PWM loop DAC sounds to be a nice idea but, I am sorry, no cigar...


-George
« Last Edit: April 01, 2012, 05:46:01 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #106 on: April 01, 2012, 07:15:38 pm »
The Sigma-Delta extended PWM loop DAC sounds to be a nice idea but, I am sorry, no cigar...

However, I don't think sigma-delta is your only choice of algorithm. You could use a direct computational algorithm.

For instance, to output 16 bits of precision on an 8 bit PWM you could proceed as follows:

1. The MSB has 256 times the magnitude of the LSB, so output it 256 times.
2. After outputting the MSB 256 times, output the LSB once.
3. Repeat from step 1.

Unfortunately the LSB is going to appear as a "bump" every 256 cycles, so heavy filtering is going to be required to obtain the smooth average value.
I'm not an EE--what am I doing here?
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #107 on: April 01, 2012, 07:29:16 pm »
The Sigma-Delta extended PWM loop DAC sounds to be a nice idea but, I am sorry, no cigar...
However, I don't think sigma-delta is your only choice of algorithm. You could use a direct computational algorithm.
I think it may be easier to combine two PWMs one for the upper and one for the lower 8 bits and combine them externally with a resistor network. This requires slightly more external hardware to combine the two PWMs, but the filter remains simple.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #108 on: April 01, 2012, 08:33:02 pm »
Ian, I think that you are correct. <8_bit_MSB>*2^8 + <8_bit_LSB>*2^0 (or <8_bit_MSB>*2^16 + <8_bit_NSB>*2^8 + <8_bit_LSB>*2^0, for a 24-bit solution) using an 8-bit hardware PWM stage sounds right to me. However, this raises the complexity of the code and renders all the remaining fast PWM hardware modules of Timer1 incapable of producing a second PWM output, while the test circuit described above is already producing two 16-bit PWM outputs (using the Timer1 Compare-A and Compare-B fast PWM channels) and it has the third fast PWM channel (the Timer1 Compare-D one) free to produce yet another 8..10-bit PWM output.

Markus, this is right in theory; but the external resistor network adder of the two PWM outputs should be of a 16-bit precision in order to preserve the output linearity and avoid any output missing codes.


In my opinion, it will be easier to use any other AVR (of the mega family, for example) with a hardware 16-bit PWM to produce a 16-bit DAC output. But, again, for every 16-bit PWM DAC it will be needed a separate AVR chip.

Since we are not talking about a mass production device but about an one-off solution, I would prefer to use a <10 USD worth Analog Devices or Linear Technology <1 LSB INL 16-bit DAC of 1 MSPS update rate for each Voltage/Current channel, which will additionally offer me the possibility of modulating the PSU output in a user programmable manner, since my initial thought was to add an arbitrary waveform output functionality to my PSU.


-George
« Last Edit: April 01, 2012, 08:50:00 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #109 on: April 02, 2012, 12:48:05 am »
The Sigma-Delta extended PWM loop DAC sounds to be a nice idea but, I am sorry, no cigar...
However, I don't think sigma-delta is your only choice of algorithm. You could use a direct computational algorithm.
I think it may be easier to combine two PWMs one for the upper and one for the lower 8 bits and combine them externally with a resistor network. This requires slightly more external hardware to combine the two PWMs, but the filter remains simple.

Combining two DACs to get extra resolution is in general a bad idea. As George pointed out, unless the two are matched incredibly well, you end up with a poor result. My no.1 requirement is a monotonic output and that means a single PWM.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #110 on: April 02, 2012, 01:53:10 am »
The Sigma-Delta extended PWM loop DAC sounds to be a nice idea but, I am sorry, no cigar...

However, I don't think sigma-delta is your only choice of algorithm. You could use a direct computational algorithm.

For instance, to output 16 bits of precision on an 8 bit PWM you could proceed as follows:

1. The MSB has 256 times the magnitude of the LSB, so output it 256 times.
2. After outputting the MSB 256 times, output the LSB once.
3. Repeat from step 1.

Unfortunately the LSB is going to appear as a "bump" every 256 cycles, so heavy filtering is going to be required to obtain the smooth average value.

I actually like this idea a lot, and you do not need heavy filtering. Say you use the atiny with the 64MHz clocked PWM. The 8 bit PWM cycle is 250KHz. With your scheme, an 250KHz/256 = 0.976Khz component will be added. The simple 3 stage RC filter (10k/1uF) I was proposing has a rejection of 1KHz components of  over 100dB. That is excellent.

Ok. I want better then 16 bit resolution, and there is no reason not to go for it.

If I increase the filter to a 4 stage 100K/.22u, then by adding an extra correction every 16 of the previous corrections, I end up with a worse case P-P ripple of 1uV. On average it will be half that. Even with 3 stages, the RMS ripple is less then 1uV.

To put these numbers into context, the output noise due to the LM324 opamp will probably be 1-2uV.

The beauty of this method of correction is that the corrections can be pre-calculated, so all we need in the PWM interrupt routine is two counters. Once every 256 PWM cycles, we use the first correction factor. Once every 256* 16 cycles, we use the second. The rest of the time, we use the non-corrected 8bit PWM value. 

I suspect this could work to give a 22 bit PWM result.

Richard.

Edit: The implementation is slightly more complex - but not by much.  The complication is this. Say the 8 PWM value is "186" and at the end of 256 cycles, we need to add an extra 215 - we cannot get a PWM cycle that somehow outputs  186+215 for one cycle.  We can make sure that for PWM counts below 128, we always need a positive correction, and for PWM counts above 128 we always need a negative correction. Then instead of correcting every 256 PWM cycles, we correct every 128 cycles. It also means the amplitude of each correction is half, that all helps.

As long as it works in the end. I have done this kind of micro work before, and you get it working somehow. Once it is working, it doesn't matter how untidy it looks under the bonnet.
« Last Edit: April 02, 2012, 02:42:40 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #111 on: April 02, 2012, 02:12:28 am »
Since we are not talking about a mass production device but about an one-off solution, I would prefer to use a <10 USD worth Analog Devices or Linear Technology <1 LSB INL 16-bit DAC of 1 MSPS update rate for each Voltage/Current channel, which will additionally offer me the possibility of modulating the PSU output in a user programmable manner, since my initial thought was to add an arbitrary waveform output functionality to my PSU.

-George
George everything you say is true, but I am being pretty ruthless with my costs. Any half decent A/D dac with a good monoticity will cost more then all the rest of the main supply board parts combined.  Basically, if there is any way to get a $1 micro to do the job, I will still continue to chase it.

It is fine if the micro is spending 95% of its processing time doing the PWM. I would use a single PWM interrupt to handle both PWM outputs, so that  saves the cycles for one "iret".

In my response to IanB's suggestion, I proposed a 22 bit method that would need two 8 bit counters in the interrupt routine (shared by both channels). The first is incremented every cycle then second is incremented when the first overflows.

Based on the counters one of 3 precalculated PWM values are loaded. This eliminates any calculations from within the PWM interrupt.

The same method would work very much easier with 16 bit PWM, but I don't want to go to a much more expensive processor to get two 16 bit PWM's.  Using two 10 bit PWM's in the ATtiny 861 is worth looking into. It should give more time for the interrupt, even with the fact that two PWM registers have to be controlled instead of one. It would mean that one correction cycle is done every 1024 PWM cycles, and then one secondary correction cycle is done  every 4096 PWM cycles. The rest of the time, the PWM value is unchanging and all the PWM interrupt will be doing is incrementing a 2 byte counter and doing a 10 bit comparison.

Richard.

Richard.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #112 on: April 02, 2012, 03:08:54 am »
Edit: The implementation is slightly more complex - but not by much.  The complication is this. Say the 8 PWM value is "186" and at the end of 256 cycles, we need to add an extra 215 - we cannot get a PWM cycle that somehow outputs  186+215 for one cycle.  We can make sure that for PWM counts below 128, we always need a positive correction, and for PWM counts above 128 we always need a negative correction. Then instead of correcting every 256 PWM cycles, we correct every 128 cycles. It also means the amplitude of each correction is half, that all helps.

I was scratching my head over this before and I thought I was OK to output the LSB alone on the 257th cycle, but your comment above prompted me to think about what happens when the LSB is 0. In that case the algorithm would have sent a zero every 257th cycle, effectively multiplying the required output by 256/257. So I see you are right, it is more complicated. I don't fancy solving the complication as it's not my problem  :)  but apparently you have it covered.

(However, I cannot stop my brain from trying to solve the complication even when I tell it not to. Silly brain.)

So, if you add 186+215 you will overflow the 8 bits into the 9th bit; in other words 186+215 = 256 + 145. However, 256 neatly divides by 256 and becomes the lowest order bit of the MSB. So all we need to do is add one to the MSB and reduce the LSB accordingly. When MSB = 186 and LSB = 215, we output 187 for 255 cycles and 146 on the 256th cycle.
« Last Edit: April 02, 2012, 03:33:18 am by IanB »
I'm not an EE--what am I doing here?
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #113 on: April 02, 2012, 04:30:04 am »
I have a isolating switching pre-regulator working and it is looking pretty good. Everything is running very cool.

Richard, if its not troubling you too much, apart from the circuit that you're going to post, please post few photos of that working switcher, this will at least give us a clue how it looks like physically.

Frankly, I'm particularly interested with the transformer and assuming you made it your self.

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #114 on: April 02, 2012, 05:27:23 am »
I am making it myself using a toroid that can be very cheap from the right source. Something like 7c each if I buy a bag of 500.  I am currently using a Micrometals T50-52 core, and I hope I can use an even smaller T44-52 core that is just 11.2mm outside diameter. I am pretty happy with the way the powder core toriod is working at 300KHz so far, and I will probably try increasing to 500Khz.

http://www.micrometals.com/parts_index.html

These types of cores have been used a lot in things like PC motherboards, so I assume that various Chinese manufacturers are making compatible cores by the truckload.

Ferrite cores can be very expensive, so if I can use this cheap one, it will be great. Somewhere out there, there may be a cheap off-the-shelf transformer that would work at an affordable price, but I am after everyday parts, and that transformer will not really fit with that plan. In general, one off prices for SMD transformers can easily be over $10, and I have to test them first before I even know if they will work adequately.

So I am not even trying to find a transformer. If I was a corporation planning on a production run of 100,000+ supplies, that would be different.

I will post some photos, but I still have to finish building my constant current load so I can test the supply at full power out. (My selection of power resistors is not very good). Probably another hour of work to finish the load this evening before I return to the supply.

Richard.
« Last Edit: April 03, 2012, 03:03:52 am by amspire »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #115 on: April 02, 2012, 11:00:09 pm »
I have found a problem. It might be me but I do not think so, since a 1.5c update delay for the asynchronous t85/t861A PWM timer registers is already documented in the data sheets. Let me explain myself:

Experimenting with the Fast (64/32 MHz) PWM of the t861A asynchronous Timer1, I discovered that though I am able to change the PWM output in one Timer1 clock cycle time by modifying the PWM Output Compare Match registers, I can do it only if I am not updating a previous PWM value of 0x00. This means that the Sigma-Delta extended PWM loop, that often needs to load a PWM value of 0x00 and then change it rapidly to something else, will not be able to run correctly due to the extended restart delay of the PWM module after an update of a zero PWM value.

Since I initially thought that this was happening because of an extremely low PWM value loaded, that could not start the corresponding ISR responsible to update the PWM error accumulator, I moved both the PWM output channel ISRs code to the Timer1 overflow ISR, which is always served every 256 timer cycles, regardless of any possible PWM channel being enabled or not. I did that in order to have a means to be constantly updating the PWM error accumulators, independently of the state of the PWM channels. But I stumbled on the PWM module update delay that occurs when the previous PWM value is equal to 0x00... I will try to further investigate this anomaly, since it might be happening because of a possible detail I may have overlooked.

Of course, there is the ATtiny84 with a true 16-bit dual channel PWM hardware module, able of running at CPU speed, that can produce a two channel 16-bit PWM output with absolutely no CPU intervention. Speaking of cost sensitivity, the 2 Kbyte FLASH t24/t25/t261 are more inexpensive than the 4 Kbyte FLASH t44/t45/t461 or the 8 Kbyte FLASH t84/t85/t861 devices.


-George
« Last Edit: April 02, 2012, 11:18:35 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #116 on: April 02, 2012, 11:57:30 pm »
George, if it helps, I will never be using a PWM value of 0x00 as I am adding some offset.

The reason I need to add some offset is it is essential if I am going to have software calibration - I need to be able to adjust either way near zero.

This is a problem for a design where you were choosing a good reference and high tolerance resistors just so calibration was not needed - in that case you do need 0x00 to be 0V and 0xFF to be maximum volts.

In my case, I want to be able for calibrate for opamp offsets and differential amp errors in my Current measurement circuit, so I will probably be using the PWM range typically from 0x08 to 0xF8.  With calibration, I could get down to 0x04. If there is a problem with low PWM values, I can increase the offset.

Richard.

 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #117 on: April 03, 2012, 10:47:30 am »
In that case, Richard, I think that the 16/24-bit extended PWM code posted previously is ready to be used! There are no problems at all for PWM values between 0x0100[00]+1 and 0xFF00[00]-1; keep in mind though than the TOP value of the extended PWM DAC is equal to 0xFF00[00]-1 (and not 0xFFFF[FF]), for the correct calculation of the DAC output gain coefficients (I am using brackets for the possible 24-bit LSB of the PWM values).

Speaking of the asynchronous Timer1 PWM update delay I mentioned above, here are the readings of the Fast Mode PWM stage output of the t861A asynchronous Timer1 (set for 32 MHz clock frequency), where one clock cycle time is equal to 30.7 ns (f=32.6 MHz) and a complete PWM cycle period of 256 cycles is 7.87 µs (f=127KHz). The clock frequency deviation is due to the fact that the AVR internal oscillator is factory calibrated for use at Vdd=3.0V, while the test circuit supply voltage was 5.0V. If it is required, the oscillator can be re-calibrated for 1% accuracy over a wide supply range of 1.8V .. 5.5V.

The Fast Mode PWM was specifically programmed to output the following pulse train pattern, in nine discrete steps (where c is the PWM Compare-Match value loaded to the OCR1A/OCR1B registers, while the TOP counter value was set to 0xFF). The readings captured below were synchronised to Channel 2 (blue trace) that was triggered by positive pulses (of a specific width for each case), while Channel 1 (the yellow trace) was testing the PWM recovery time after setting the PWM value to 0x00 at Step 4.


Step 1. Ch2 = 1c, Ch1 = 1c: Correct.


Step 2. Ch2 = 2c, Ch1 = 2c: Correct.


Step 3. Ch2 = 3c, Ch1 = 3c: Correct.


Step 4. Ch2 = 4c, Ch1 = 0c: Correct.


Step 5. Ch2 = 5c, Ch1 = 5c: WRONG!
Channel 1 should be producing a 5c positive pulse.


Step 6. Ch2 = 6c, Ch1 = Unchanged (5c):
The Ch1 5c positive pulse (that was loaded and should had been produced at the previous step) is present now, delayed by one Timer1 clock cycle.


Step 7. Ch2 = 7c, Ch1 = 7c: Correct.


Step 8. Ch2 = 8c, Ch1 = 254c: Correct.


Step 9. Ch2 = 9c, Ch1 = 1c: Correct.


It is obvious that the PWM value of 0x05 at step 4, loaded right after the PWM value of 0x00 at step 3, takes two Timer1 clock cycles to be produced while every other PWM update that does not follow a previous PWM value of 0x00 takes only one. Clearly, this is a problem for a Sigma-Delta extended PWM loop DAC implementation that is expected to produce a sub-MSB value output.

This is what the t861A Timer1 Overflow ISR Handler test code looks like:
Code: [Select]
in r4,SREG ; Status Register preservation
push YL
push YH

; Nine-step PWM output sequence
cpi YL,1
brne PC+2
ldi YH,1

cpi YL,2
brne PC+2
ldi YH,2

cpi YL,3
brne PC+2
ldi YH,3

cpi YL,4
brne PC+2
ldi YH,0

cpi YL,5
brne PC+2
ldi YH,5

cpi YL,6
brne PC+2
rjmp _ReloadB
; ldi YH,6

cpi YL,7
brne PC+2
ldi YH,7

cpi YL,8
brne PC+2
ldi YH,-2

cpi YL,9
brne PC+2
ldi YH,1

out OCR1A,YH
 _ReloadB: out OCR1B,YL

inc YL
cpi YL,10
brne PC+2
ldi YL,1

; Done
pop YH
pop YL
out SREG,r4 ; Status Register restore
reti

-George


EDIT: Corrections and additions.
« Last Edit: April 03, 2012, 05:42:34 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #118 on: April 03, 2012, 03:34:00 pm »
Sounds like good news George.

Still trying to finish up my Switching preconverter tests. Managed to blow up a Schottky diode on the transformer output, so I will get back to it tomorrow. I need to get this done so I can document the full Mark III design.

Then I think I will do some kind of micro test.  I want to build up a proper filtered PWM and take a look. I have a digital pot somewhere I can use.

Richard.
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1046
  • Country: fi
Re: General Purpose Power Supply Design
« Reply #119 on: April 08, 2012, 07:13:55 pm »
Somewhat unrelated implementation work but anyway, inspired from amspire's idea, I did a delta-sigma modulator in an Altera 2C8 FPGA just for interest, and reduced the "PWM" to just 1-bit one. It really does work quite nicely, as I was able to clock the modulator up to 150 MHz. That pushes the noise to quite high at frequency spectrum. I used 24-bit resolution, but that is easy to change in VHDL code. This is definitely a strange combination of DC precision and careful high-speed design. Switching a precision voltage reference in such a high rate does add some complications :)

I was able to adjust the output in very small steps, some µV or so. But of course, IO voltage supply is not a precision one by any means, so there were quite significant drift.

First test was just a ramp generator, the analog post filter was just 39k/4n7 RC (just some random convenient values without any design) from a junkbox:



I thought about testing that as an audio DAC but didn't bother to interface it to a SPDIF receiver :) Then I tried adding two inputs which let me adjust the value up and down. I measured the result with Gossen's Metrahit energy after adding second RC stage of 10k/1µ (again, no any design, just a test). As you can see, the result is quite nice:



Of course, there was some drift but the result was still surprisingly good for such a crude and simple circuit.

Here is also the digital signal spectrum measured directly from a FPGA pin (before RC filters).



You can see the notch at 150 MHz, which is the operating frequency of the modulator. That reminds me that some pre-filtering is probably useful, as the attenuation of a "low-frequency" filter tends to suffer at higher frequencies due to nonidealities.

Regards,
Janne
« Last Edit: April 08, 2012, 07:15:42 pm by jahonen »
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #120 on: April 08, 2012, 08:11:12 pm »
Ah! The wonders of the 1-bit DAC! With one only imperfection: The digital output stage limitations of reaching the true Vdd and GND levels, while hunting down 0.06 ppm accuracy of the 24-bit requested resolution... But then again, is there any other way of pursuing such goals?

Very nicely done, Janne!


-George
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #121 on: April 09, 2012, 12:30:07 am »
Janne,

It is pretty amazing seeing the results of your 1 bit PWM. The fact you were able to adjust it to 50.000mV on the meter means you must have had surprising good stability, especially when you consider the clock frequency.

It is very encouraging to see this. With 24 bit resolution, that means you need you need a RC time constant of about 0.1 seconds, so two stages of 100K/1uF RC filters would give a really clean result. That should reduce the PWM noise to well below the 1uV level.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #122 on: April 09, 2012, 10:54:02 am »
Although I can't contribute much on this, just want to say currently this is one the best thread in this forum.

Keep up the excellent works, really appreciate the contributions made.

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #123 on: April 09, 2012, 11:08:21 am »
Thanks. I will start the posts on the switching regulator design - just haven't had much time last few days.

Richard.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #124 on: April 12, 2012, 12:29:00 pm »
I cannot explain my persistence for the implementation of a 16-bit PWM DAC. Maybe it is because the tiny24, which has a true 16-bit dual channel PWM (like all the mega's), costs USD 1.01 a piece in single quantities from Digi-Key and because a dual 16-bit PWM DAC is monotonic by principle; so, in that regard, it is more accurate and better than most of the 12-bit "affordable" stand alone DACs. The beauty of this implementation is its simplicity: You just set it up once and you forget it! The CPU spends all its time in sleep mode, with an overall consumption of less than 5mA (or less than 2.5mA for the Pico-Power parts). Should you need to change any of the outputs, you just modify a 16-bit register pair for each channel and you are done: The hardware takes care of the PWM internal elements update in order to avoid any output glitches!

In the example below, the PWM frequency is set to 8 MHz (a compromise of output update speed and chip current consumption), which gives a full 16-bit PWM cycle time duration of 2^16 * 125ns = 8.192ms. 1 LSB represents a 76.29 µV step for Vdd = 5.0 V (5V/2^16LSB) or a 50.35 µV step for Vdd = 3.3 V or a 41.20 µV step for Vdd = 2.7 V. For the output filter component values I did not even pull a calculator; I just used a simple two stage RC filter of 15K/0µ1 (multilayer) for the first sweep and of 15K/1µ0 (tantalium) for the second one.


1. 16-bit PWM sweep with a 2-stage output filter of 15K/0µ1


2. 16-bit PWM sweep with a 2-stage output filter of 15K/1µ0

I ported the tiny861 code above to a mega88 I have already had in hand and programmed it to output the sweep above, for the codes 0x0000 .. 0xFFFF. Well, not exactly for all the codes because 2^16 steps of 8.192ms per step takes 537 sec and it would take ages to plot; what I did was to increase the PWM code by 32 LSB (8.192ms * 2^16/32 = 16.8s) on every 16-bit PWM cycle completion; much better now!


-George
« Last Edit: April 14, 2012, 09:10:36 am by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #125 on: April 12, 2012, 12:57:48 pm »
George, can you set the PWM to a few static levels and measure the DC stability of the DC out? I do not know what kind of multimeters you have but any results would be very interesting.

I know you are probably just using a test setup and the micro supply stability may be nothing special, but it would be good to see the results. One of the things I was wondering is that if you went from a low duty cycle to a high duty cycle, will the upper FET in the output start increasing in resistance causing the voltage to drop slightly over time.

Also you used 15K resistors. Using 100K would put much less load on the output, so in theory, the stability should be better.

Also what is the AC on the output according to the meter? Can your DMM see any noticeable noise? Test micro circuits tend to be noisy anyway, but again it would be interesting.

Excellent stuff.  I haven't disappeared - I have just been busy with other work the last two weeks, but I will be doing a series of posts very soon on the latest work.

Richard.
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #126 on: April 12, 2012, 03:10:03 pm »
Richard, I am sorry but my multimeters are not capable of reading microvolts or nanoampers. And, even though I do not have second thoughts on spending for example an amount of USD 500 for an SSD of a three-years long life expectancy, or half of that monetary amount for a toy-oscilloscope, I do not feel like investing such figures in immature software-based multimeters that I will not be able to completely trust in the long run --even though the industry seems it does. I guess I'll have to begin watering down my wine in this department, too... Awareness, after a certain point, really sucks! :P

What I could do instead, is to set up a high gain op-amp (100x/1000x) to make such readings; but again, being the whole setup constructed on breadboards, hunting down such resolution and accuracy figures shouts for the need of carefully arranged ground islands beneath the chips and the filters and of guarding loops around the sensitive lines. The digital output stages limitations are also considerable, since their expected characteristics drift due to temperature variations does never work in favour of accuracy or stability.


-George



EDIT: Corrections...
« Last Edit: April 12, 2012, 05:46:56 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #127 on: April 15, 2012, 05:23:39 am »
I did some serious number crunching work on the PWM DAC so I can build up a test circuit for my own, and found that the original scheme of an 8 bit PWM with corrections every PWM cycle performed better then all the other ideas that have come up since then. 10 bit PWM is messy since the lower 8 bits are double buffered and the top 2 bits are not - basically 10 bit PWM is for constant PWM. 16 bit PWM means that the output frequency is pretty low  - 244 Hz for a 16Mhz PWM clock - and the results through the filter is far worse then the results you get with an 8 bit PWM.

I also looked at an active filter instead of the simple PWM, but the problem there is the main noise is at 62Khz when the opamps are loosing a lot of their gain. The simple RC filter gives far superior results. So I will take Georges code and modify it for an Atmega328  (that's what I have for now), and set it up with a good reference.

The best filter looks like a three stage RC filter consisting of 22K resistors and 1u capacitors. There are no stability and accuracy requirement for these parts, so supply filter 1uF caps are fine. With these values, the output settles from a large voltage change to within 1% in less then 0.6 seconds, and to within 1uV of the final value within 1.5 seconds. I can live with that. Theoretically, the ripple from the PWM + correction with a 16Mhz PWM clock should be less then 1uV RMS on the final supply output  - probably below the noise from the opamps. It works out better then I expected, as the PWM cycle-by-cycle correction code is pretty good at minimizing the end noise because it spreads out corrections over the full correction cycle is a smooth way.

I will try both the PWM straight from the chip, and also PWM from a CMOS synchronous register powered by the reference. I will use the synchronous register to restore the timing for the PWM output using the Atmega's clock. The resulting waveform should be much better formed, and the levels more precise, as the CMOS chip is dedicated to this task - not handling 10 other loads like a Micro.

I aim to get some numbers out for linearity, short and long term stability and noise. 

Richard.
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #128 on: April 15, 2012, 09:52:32 pm »
An AVR output lower mosfet has an Rdson between about 20 R (-40C),  23 R (25C)  and 28R (85C) and the upper one has between 10 R (-40C), 12.5 R (25C) and 15 R (85C), both at 5V. These are typical figures, taken from the datasheet (m328P) graphs of the pin driver strength and 10 mA draw.

An HC00 @ 4.5V (there is no figure for 5V, even for the HCT) has Ron for the lower one of 37.5 R typical (25C) and max of 82.5 R (entire temperature range) and 45 R typical (25C) and 165 R (entire temperature range) for the upper one. The HC244 doesn't have typical figures but has a maximun Ron for 67 R (lower mosfet) and 133 R (upper mosfet). These are taken from NXP's datasheets.

Of course you can parallel multiple CMOS drivers to lower the Ron, but the pin driver of the AVR is better.
 

Offline caroper

  • Regular Contributor
  • *
  • Posts: 193
  • Country: za
    • Take your PIC
Re: General Purpose Power Supply Design
« Reply #129 on: April 15, 2012, 10:36:58 pm »
16 bit PWM means that the output frequency is pretty low  - 244 Hz for a 16Mhz PWM clock - and the results through the filter is far worse then the results you get with an 8 bit PWM.

I have some PIC32MX150F128B SPDIP Samples on the way, it may be worth trying the 16Bit PWM with the 40Mz clock.
They are for another project but I am sure I could reserve one or two and try getting the CHIPKIT Bootloader on them and see if I cant get them to work with the MPIDE to make porting Arduino Sketches easier for those that would like a more powerful CPU.

I am busy building a custom bootloader for the 32MX695 at the moment so the groundwork should be in place by the time the 32MX150's arrive.

Cheers
Chris

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #130 on: April 15, 2012, 11:05:02 pm »
An AVR output lower mosfet has an Rdson between about 20 R (-40C),  23 R (25C)  and 28R (85C) and the upper one has between 10 R (-40C), 12.5 R (25C) and 15 R (85C), both at 5V. These are typical figures, taken from the datasheet (m328P) graphs of the pin driver strength and 10 mA draw.

An HC00 @ 4.5V (there is no figure for 5V, even for the HCT) has Ron for the lower one of 37.5 R typical (25C) and max of 82.5 R (entire temperature range) and 45 R typical (25C) and 165 R (entire temperature range) for the upper one. The HC244 doesn't have typical figures but has a maximun Ron for 67 R (lower mosfet) and 133 R (upper mosfet). These are taken from NXP's datasheets.

The problem with using the micro outputs directly is that the other ports are driving other loads, and all the total current and transient loads goes through the common supply pins. The PWM will suffer voltage changes through resistive drops in the power supply pins as the total load changes. It may be I can avoid any heavy loads on other output pins which could make the micro outputs look pretty good. The RC filter look like a resistive load of between 22K and 220K depending on the final value I choose. If it is 220K, then a 10 ohm change in a output driver resistance would cause  something like a 0.005% change. 

i will have to see what kind of resistive change you actually get in the short term, as I am mainly concerned with short term stability after everything has had time to warm up.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #131 on: April 17, 2012, 02:34:02 pm »
My test breadboard to check out the PWM DAC performance is going well. I have an Arduino micro running with a LCD panel and pushbuttons.

So far the PWM looks like it may be able to get at least 0.1% accuracy, and it is definitely adjustable to better then 10uV.

The problems I have at the moment is the variable load from the micro and display is causing the micro supply to vary in the sub-mV range, and since the PWM output is proportional to the micro supply, I cannot measure the PWM stability till I solve the micro supply stability. I will probably take the PWM out to a buffer running from a precision voltage reference.

Also I found that the PWM interrupts are incompatible with the Arduino LCD routine. I suspect the LCD routing is using interrupts, or sharing the timer0 interrupt. So if I write to the display, then PWM output goes pretty bad.  It should be very fixable - no reason for the LCD routine to use any interrupts.

I want to get it running with software calibration, and the means to control the output voltage down to uV level. I am using Arduino 1.0 IDE and finding it pretty good. So far, it has not been hard to update libraries for the changes in Arduino 1.0.

I will post a circuit and some photos tomorrow.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #132 on: April 19, 2012, 01:11:33 am »
I finally got over my problems getting the micro up and running, so I should able able to get a really good test of the PWM DAC working today.

It am using a atmega328 running at 16MHz. Since I do not have the constraints George had, I am able to write the interrupt in C. I can easily fit the interrupt code for managing two timers inside the 16uS PWM period. It will probably end up using something like 8uS, so that is all I need for a good test.

This code does not use any dedicated registers - just standard RAM memory - so it is not nearly as efficient as George's code. There is a good chance I will end up using George's code in a final version, except if I use a micro that does not have a built-in clock multiplier for the PWM clock, then I will not use dedicated registers.

Here is the C code with the assembler the compiler generated:

Code: [Select]
ISR(TIMER2_OVF_vect) {
     b2a: 1f 92        push r1
     b2c: 0f 92        push r0
     b2e: 0f b6        in r0, 0x3f ; 63
     b30: 0f 92        push r0
     b32: 11 24        eor r1, r1
     b34: 2f 93        push r18
     b36: 3f 93        push r19
     b38: 4f 93        push r20
     b3a: 5f 93        push r21
     b3c: 8f 93        push r24
     b3e: 9f 93        push r25
     b40: af 93        push r26
     b42: bf 93        push r27

  OCR2A = (byte) (pwm_accum / 0x01000000L ) ;  // 16 cycles

     b46: 80 91 80 01 lds r24, 0x0180
     b4a: 90 91 81 01 lds r25, 0x0181
     b4e: a0 91 82 01 lds r26, 0x0182
     b52: b0 91 83 01 lds r27, 0x0183
     b56: 2b 2f        mov r18, r27
     b58: 33 27        eor r19, r19
     b5a: 44 27        eor r20, r20
     b5c: 55 27        eor r21, r21
     b5e: 20 93 b3 00 sts 0x00B3, r18

  pwm_accum &= 0x00FFFFFFL ; // 7 cycles

     b62: b0 70        andi r27, 0x00 ; 0
     b64: 20 91 7c 01 lds r18, 0x017C
     b68: 30 91 7d 01 lds r19, 0x017D
     b6c: 40 91 7e 01 lds r20, 0x017E
     b70: 50 91 7f 01 lds r21, 0x017F

  pwm_accum +=  value ;  // 11 cycles

     b74: 82 0f        add r24, r18
     b76: 93 1f        adc r25, r19
     b78: a4 1f        adc r26, r20
     b7a: b5 1f        adc r27, r21
     b7c: 80 93 80 01 sts 0x0180, r24
     b80: 90 93 81 01 sts 0x0181, r25
     b84: a0 93 82 01 sts 0x0182, r26
     b88: b0 93 83 01 sts 0x0183, r27

}
     b8e: bf 91        pop r27
     b90: af 91        pop r26
     b92: 9f 91        pop r25
     b94: 8f 91        pop r24
     b96: 5f 91        pop r21
     b98: 4f 91        pop r20
     b9a: 3f 91        pop r19
     b9c: 2f 91        pop r18
     b9e: 0f 90        pop r0
     ba0: 0f be        out 0x3f, r0 ; 63
     ba2: 0f 90        pop r0
     ba4: 1f 90        pop r1
     ba6: 18 95        reti


I am really impressed that the code optimizer translated

OCR2A = (byte) (pwm_accum / 0x01000000L )

into a move, and three exclusive ORs and a sts command. It didn't try to divide at all. It could have left out the eor commands, but that is just 3 cycles.

Richard.
« Last Edit: April 19, 2012, 01:31:58 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #133 on: April 19, 2012, 04:05:41 pm »
I have my PWM test setup working and it is not bad.

The breadboard is limited by 0v rail digital noise around the 500uV level, so I cannot properly check out the performance of the PWM into the microvolt level, but the results are definitely promising. Transients from things like the LCD display are getting to the output. 

Looks like a linearity and accuracy of less them 10mV error can be expected which is pretty good for a basic 25v supply. I am typically getting within 2mV and since I have scaled the output for 25V maximum output, 2mV equates to 13 to 14 bits of DAC accuracy. That is good. I have a monotonic 32 bit DAC (well 23 bits practically)  that performs at least as well for accuracy as a 13-14 bit commercial DAC. I am very happy with that.

The output works well down to near zero volts just by using the LM324 amplifier on the PWM output with a 10K pull down resistor on the output. I am currently getting 4mV out at  minimum voltage. At 18 mV set, I get 15mV out. At 0.1V set, I get 97mV out. That is not bad performance for a single supply opamp circuit.

Long term accuracy is another issue, but there is no real reason for the output to change much.

As far as I can work out, with a proper layout, you should be able to adjust to within 10uV as a short term stability, but that does depend on the voltage reference used, and an excellent board layout to isolate digital noise from the analog sections.

I found that it may be hard to use the PWM from the micro directly. Loads on other outputs do affect the PWM output levels when you are looking at 0.01% error levels.

I have taken the PWM output to a cmos buffer which is powered by a 0.6ppm/C 5v reference IC just so I can look at the PWM accuracy and not the reference accuracy too. Definitely using something cheaper in the design.

It is a bit late now to get some pictures, but I will hopefully find time tomorrow. Overall though, the concept looks like it is good. It should give me the adjustment resolution I want down into the uV region. The negatives compared to a DAC is that the output takes up to a second to settle fully and the board layout will definitely be much more critical compared to a DAC.

How to adjust the output voltage in a way that gives you fine resolution - that will be another big challenge.

Before I switch it off for the night, here are some random results:

Setting             Output
0.9266V            0.9236V
3.1523V            3.1493V
4.9663V            4.9635V
6.7801V            6.7776V
10.7124V         10.7105V
13.1595V         13.1581V
15.4267V         15.4250V

All the readings are low by two or three millivolts and that is just the calibration is not quite right. I have not done any calibration of the linearity - that is the inherent linearity of the PWM. I just calibrate at 1V and 10V, and all the other voltages are calculated by the PWM reference using those two numbers.

To get a feel for the short term stability that may be possible, I have set the voltmeter to average over 20 mains cycles, and right now, it is stable to 100uV with 15V out and that is on a noisy breadboard.

A precision version of this as a high resolution  programmable reference box (a really good reference , better opamps and a dual supply) may be a handy spinoff from this work.

Richard.

« Last Edit: April 19, 2012, 04:20:21 pm by amspire »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #134 on: April 19, 2012, 04:24:54 pm »
Richard,

Looks really promising ! Thanks for the update !


A precision version of this as a high resolution  programmable reference box (a really good reference , better opamps and a dual supply) may be a handy spinoff from this work.

I'm in if you decided to design this too !

Offline m12lrpv

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: General Purpose Power Supply Design
« Reply #135 on: April 19, 2012, 09:52:50 pm »
I have taken the PWM output to a cmos buffer which is powered by a 0.6ppm/C 5v reference IC just so I can look at the PWM accuracy and not the reference accuracy too. Definitely using something cheaper in the design.

This is something that's completely new to me (references and powering things from them) so i'm interested in knowing what the reference is that you're using so that I can learn more about it.

 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #136 on: April 20, 2012, 12:25:01 am »
I have taken the PWM output to a cmos buffer which is powered by a 0.6ppm/C 5v reference IC just so I can look at the PWM accuracy and not the reference accuracy too. Definitely using something cheaper in the design.

This is something that's completely new to me (references and powering things from them) so i'm interested in knowing what the reference is that you're using so that I can learn more about it.
You won't want to know about the reference IC's I am using. VRE305A made by Thaler Corp. and they are actually hybrids - a buried zener reference IC mounted on a thick film temperature compensation network. It is laser trimmed for accuracy and temperature coefficient. I bought them directly from Thaler at something like $10-$15 each, but Thaler have been taken over by Cirrus, and the one-off price is now about $70. The specs are generally better then the best references IC's but too expensive unless you are desperate.

There are lots of great reference IC's, and a good place to start is to google REF01 and REF02. The 8 pin DIP pinout has become an industry standard, so you can often replace one reference with another completely different part number from a different manufacturer.

There are 2 common type of references. The best is the zener diode based references, but the zener references need at least 6.3V, and so these ICs usually need 10-15V to operate.

The second type uses the voltage differences between the base voltages of matched transistors at different currents to provide a low voltage reference. Not as good as the zeners, but still impressive, and it is excellent for 1.25 to 2.5V low power references running of 2.7V to 5V supplies. Good enough for most uses.

There are few other types of references but these are the most common.

Another really neat reference IC is the Texas Instruments TL431.

This is a very clever 3 pin shunt  regulator. It is not as good as the best of the 8 pin references, but it is far more versatile, and a lot of fun to play with. It basically can be used as an active part of a circuit, rather then just a reference.

Richard.
« Last Edit: April 20, 2012, 05:15:55 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #137 on: April 20, 2012, 12:49:11 am »
Richard,

Looks really promising ! Thanks for the update !


A precision version of this as a high resolution  programmable reference box (a really good reference , better opamps and a dual supply) may be a handy spinoff from this work.

I'm in if you decided to design this too !

Just wondering how to proceed since I am really trying out ideas related to a really cheap quality power supply design rather then making a product.

I think the way I will go is to do it as a modular design. This will mean I can post the finished modules without needing solutions to everything.

If someone wants to integrate the ideas back into a single board - great.

The PWM does work better then expected so I am interested in looking at a high performance design. I have a Kelvin-Varley divider project that is in hybernation for the moment, but this could replace it.

A 2 point calibration for the PWM at zero volts and one reference voltage using a auto zero offset opamp based galvanometer should be straightforward, and if I can get a 0.001% linearity, it would be nice. Looking at the test PWM performance, resistor stability may be a bigger problem then the PWM linearity. Resistors better then 20ppm/C cost a lot, and it takes very little power to make a 20ppm/C resistor change significantly when you are looking for better then 0.1%.

Richard.
 

Offline m12lrpv

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: General Purpose Power Supply Design
« Reply #138 on: April 20, 2012, 12:53:46 am »
You won't want to know about the reference IC's I am using. VRE305A made by Thaler Corp. and they are actually hybrids - a buried zener reference IC mounted on a thick film temperature compensation network. It is laser trimmed for accuracy and temperature coefficient. I bought them directly from Thaler at something like $10-$15 each, but Thaler have been taken over by Cirrus, and the one-off price is now about $70. The specs are generally better then the best references IC's but too expensive unless you are desperate.

...

Thanks.

I was more interested in the specs of what you were using because i've got some TL431's for use as ADC references and i'm looking at them wondering if I really could power a cmos buffer or inverter of them.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #139 on: April 20, 2012, 12:58:45 am »
Thanks, about programmable reference box, if you have time, please design it and definitely I will build it.

About the vref, I'm aware of that high end Thaler's stuff, just asking for other alternatives, though not as good in initial accuracy compared to Thaler, I have few of these in my component bins, these should be good enough right ?

MAX6350 (buried zener)
-> 1ppm/°C Max Tempco , 3µVp-p Noise , ±0.02% initial accuracy, has external trim feature
-> http://www.maxim-ic.com/datasheet/index.mvp/id/1700

or this one

LTC6655
->  2ppm/°C Max Tempco , 0.25 ppm p-p Noise , ±0.025% initial accuracy, has kelvin sense pins
-> http://www.linear.com/product/LTC6655
« Last Edit: April 20, 2012, 04:52:16 am by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #140 on: April 20, 2012, 05:20:38 am »

Thanks.

I was more interested in the specs of what you were using because i've got some TL431's for use as ADC references and i'm looking at them wondering if I really could power a cmos buffer or inverter of them.
References tend to have opamp output rather then power supply outputs, but they can usually manage up to about 10mA that is fine for low power IC's,   Make sure you have a ceramic 1uF cap or similar directly across the CMOS IC as even though they consume almost no power when static, the peak transient switching current can be quite high. The VRE305A is 10mA peak output.

I like to limit the current to 1 to 3mA maximum, but they will still work well at 10mA out.

Richard.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #141 on: April 20, 2012, 07:05:28 am »
I will try both the PWM straight from the chip, and also PWM from a CMOS synchronous register powered by the reference. I will use the synchronous register to restore the timing for the PWM output using the Atmega's clock. The resulting waveform should be much better formed, and the levels more precise, as the CMOS chip is dedicated to this task - not handling 10 other loads like a Micro.

Yes, my guess would have been that a decent accurate 16bit PWM from a direct micro might be asking a bit much, especially if the micro is handling other current stuff like direct LED drive.

Dave.
 

Offline EEVblog

  • Administrator
  • *****
  • Posts: 30265
  • Country: au
    • EEVblog
Re: General Purpose Power Supply Design
« Reply #142 on: April 20, 2012, 07:07:53 am »
I was more interested in the specs of what you were using because i've got some TL431's for use as ADC references and i'm looking at them wondering if I really could power a cmos buffer or inverter of them.

Easily.
I've powered micros directly with voltage references for the supply, and it works a treat at providing an accurate ADC and PWM DAC system.

Dave.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #143 on: April 20, 2012, 07:45:05 am »

Yes, my guess would have been that a decent accurate 16bit PWM from a direct micro might be asking a bit much, especially if the micro is handling other current stuff like direct LED drive.

Dave.
That is exactly what I am seeing. I have an old-style 16x2 LCD display attached, and every time I write to it, I am seeing a 10mV glitch on the Atmega328 outputs. That is nothing as far as digital is concerned, but pretty bad for precision analog.

It may be possible to get accurate PWM out of a dedicated micro that is doing PWM and nothing else. Something like a ATtiny chip. How would you control it though?

I think I will go for the external CMOS buffer run from a reference. I have also found it is really important to get the capacitor in the first RC stage of the filter really close to the CMOS buffer to minimize the path of the transient current. Even though I am using 100K resistors and 0.22uF caps, the transient does infiltrate the later analog stages.

Richard.

 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1046
  • Country: fi
Re: General Purpose Power Supply Design
« Reply #144 on: April 20, 2012, 08:01:42 am »
I think I will go for the external CMOS buffer run from a reference. I have also found it is really important to get the capacitor in the first RC stage of the filter really close to the CMOS buffer to minimize the path of the transient current. Even though I am using 100K resistors and 0.22uF caps, the transient does infiltrate the later analog stages.

Richard.

That's why I thought that it would be probably a good idea to first shave off the highest frequency components (MHz and above), before doing any actual PWM filtering (see my spectrum measurements). Large-valued resistors tend to suffer from parasitic capacitance across which don't mix well with those steep edge rate signals. First thing to try might be putting a small cap (few tens of pF perhaps) directly at the logic gate output, that will slow down edges quite significantly.

Also, forget breadboarding and use that solid copper clad board that Jim Williams would use for the output logic gate buffer and PWM filter.

Regards,
Janne
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #145 on: April 20, 2012, 01:36:22 pm »

Also, forget breadboarding and use that solid copper clad board that Jim Williams would use for the output logic gate buffer and PWM filter.

Regards,
Janne
You mean like this  :)



I know what I should be doing. It is just that trying to work Jim Williams style drives me a bit nuts. I think I will just make a PCB for the next effort. Definitely, my current breadboard is useless below 1mV with all the noise on the 0V line just because of the presence of the micro. I may also try running the micro from batteries, and moving the analog to a different breadboard.

For anyone interested, the Arduino compatible Atmega328 RBBB board is on the left. The small Kapton tape wrapped board (top center) contains  a 4069 hex inverter with all six inverters in parallel plus decoupling caps. I definitely could move the first RC filter stage to that board. I had to use the small board as the 4069 was a smd package.

The 8 pin IC that is in front of the buffer board is the VRE305A reference and right is a LM324  IC.

The 4 switches from left to right are step down, step up, save 1V reference and save 10V reference. The down and up switches step in different increments depending on whether I single click, double click or single click, so that is how I can manage to adjust the 32 bit PWM value with two switches.

Richard
« Last Edit: April 20, 2012, 01:49:03 pm by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #146 on: April 22, 2012, 07:36:00 am »
Inspired by Janne, I though I had better improve my PWM test setup a little.



In the photo above I have my PWM reference set for 10mV out, and it is actually putting out 10.141mV. Just to prove it works down to 0V.

I separated the Analog from the digital breadboard, and powered the micro from batteries, just so the analog breadboard only had one point of contact from the digital circuit. The analog board had a 74HC10A gate acting as a buffer  powered from a 5V reference. The filter was 3 stage RC filter with a 100K/22uF combination. A LM324 unity gain amp followed, and then I had another stage with an offset of about 50mV and a gain of 5.

I decided to check the jitter of the Atmega328 which was using a 16MHz ceramic resonator.

It turned out to be pretty bad - 4 nS jitter and the big errors were erratic, so it would not be hidden by the averaging all that much. It turns out that the clock was in the low power mode which is prone to noise sensitivity.  Changing the fuses to High Power mode for the clock reduced the jitter to below 0.5nS (I cannot measure below that). This is good enough for better then 1 part in 10-5, so I do not need a crystal oscillator or anything to recover the edges accurately.

How did it work out. Well extremely well actually.



If you look at the 14V reading, you see that as I approach the higher voltages, the error seems to be increasing. The error of .2mV amounts to a 15ppm error. A 50ppm/C metal film resistor in my LM324 amplifier circuit feedback can cause this if the resistor's temperature warms by just 0.33 deg C as the voltage across it increases. Also I have scaled this for 25V full scale, so an error of 0.2mV is just 8ppm of full scale. I really think this is amazing from such a simple circuit.

Is there anything for 10 times the cost  that comes close?

I am really on the limits of basic resistor and LM324 performance here. For my power supply, I am very happy to go for 10mV absolute accuracy, with typical accuracy being 1mV, and it looks like I get that with the most basic of parts.

I cannot see any reason why the results would not be even better with high stability resistors and ultra low offset & current opamps.

Richard.

« Last Edit: April 02, 2016, 12:10:54 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #147 on: April 22, 2012, 08:39:06 am »
One of the motivations for starting this power supply project is I need a supply that is adjustable down to the microvolt level for a Fluke540A Thermal Transfer Standard. The 540A can calibrate an AC signal to a 0.01% RMS accuracy by comparing it with an equivalent DC signal.

For this, I really need something that is stable in the short term and settable to 0.001%. With a 400mV RMS AC signal, that means I need to be able to adjust down to 4uV DC. A supply is needed that can drive the 200 ohms/volt of the 540A, and it is amazing how much drift you get out of many standard power supplies. Just about all the digital supplies are totally useless as their resolution is so bad. A supply that has 1mV resolution is marginally useful for measuring above 10VAC and is only properly useful above 100V AC - but then the power supply probably doesn't go that high.

So I tried using the reference to null a random setting on the 540A, and it really worked brilliantly. Adjusting down in the uV level was brilliant - very monotonic and no jumps at all. Stability was perfectly adequate for the task.

I put up a photo. Watching a 540A work is not exciting. All you are trying to do is to get the galvanometer to 0.0 on HIGH sensitivity, but here it is. A deflection of +/- 6 corresponds to a +/- 0.01% error. I didn't wait for thermal equilibrium of the sensor, so the needle was still creeping up very slowly as I took the photo. It looks like it is about 0.003% above zero. This corresponds to an output voltage of about 410 mV from the PWM reference.

Richard.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #148 on: April 22, 2012, 11:01:19 am »
It may be possible to get accurate PWM out of a dedicated micro that is doing PWM and nothing else. Something like a ATtiny chip. How would you control it though?
Through three SPI pins (CS, CLK, MOSI) with inline high value resistors to reduce noise injection from master.
Preferably make their default state low.

Leo

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #149 on: April 22, 2012, 11:16:40 am »
Is there anything for 10 times the cost  that comes close?
Dave has an episode on precision voltage reference that is nothing more than a voltage reference IC and a bunch of resistor dividers in a box.

I know you are excited!  :)

But by the time you put $1 something-duino in a rack enclosure, add power supply, user interface, go through agencies approvals,  issue calibration certificate, print user manual and product shipping package (so that it can be sold side-by-side with big guys) it will cost $500.

Leo

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #150 on: April 22, 2012, 12:47:19 pm »
Is there anything for 10 times the cost  that comes close?
Dave has an episode on precision voltage reference that is nothing more than a voltage reference IC and a bunch of resistor dividers in a box.
Just a bunch of resistors.  ::)

I would love place I could just buy that bunch of resistors at an affordable price. It is very easy to underestimate what Krohn-Hite had to do to get that bunch of resistors. You don't get anything with custom matched resistors like that for anywhere near $1000 new. Out of the range of hobbyists for sure.

Quote

I know you are excited!  :)

But by the time you put $1 something-duino in a rack enclosure, add power supply, user interface, go through agencies approvals,  issue calibration certificate, print user manual and product shipping package (so that it can be sold side-by-side with big guys) it will cost $500.

Leo
Which is why I am not getting involved with that. My PWM DAC is for a basic power supply. The fact it will have a D/A that will probably kill anything in commercial power supplies for 100 times the price is OK - I am not complaining.

If I design a precision programmable voltage reference as well, I think it would be ideal as a hobbyist project - they can make something for $10 - $20 that is probably better then that $500+ commercial stuff that you are talking about.

Richard.
« Last Edit: April 22, 2012, 12:56:44 pm by amspire »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #151 on: April 24, 2012, 04:26:29 am »
If you look at the 14V reading, you see that as I approach the higher voltages, the error seems to be increasing. The error of .2mV amounts to a 15ppm error. A 50ppm/C metal film resistor in my LM324 amplifier circuit feedback can cause this if the resistor's temperature warms by just 0.33 deg C as the voltage across it increases. Also I have scaled this for 25V full scale, so an error of 0.2mV is just 8ppm of full scale. I really think this is amazing from such a simple circuit.

I am really on the limits of basic resistor and LM324 performance here. For my power supply, I am very happy to go for 10mV absolute accuracy, with typical accuracy being 1mV, and it looks like I get that with the most basic of parts.

I cannot see any reason why the results would not be even better with high stability resistors and ultra low offset & current opamps.

Richard, I'm guessing that the resistors you're talking about are those in the 3 stages RC filter ?

Btw, cmiiw, looks like now you've finalized the adjustable vref module right ? How is the linear power part, are you going to work on that soon ?

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #152 on: April 24, 2012, 04:41:56 am »
Is there anything for 10 times the cost  that comes close?
Dave has an episode on precision voltage reference that is nothing more than a voltage reference IC and a bunch of resistor dividers in a box.
I don't think those resistors are just jelly bean resistors, suggesting you to search here at this forum on the metrology discussions, there are plenty of it here, and Richard was also quite active in those discussions, I believe he knows what he is talking about when it comes to resistor in precision circuit.

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #153 on: April 24, 2012, 06:27:06 am »
If you look at the 14V reading, you see that as I approach the higher voltages, the error seems to be increasing. The error of .2mV amounts to a 15ppm error. A 50ppm/C metal film resistor in my LM324 amplifier circuit feedback can cause this if the resistor's temperature warms by just 0.33 deg C as the voltage across it increases. Also I have scaled this for 25V full scale, so an error of 0.2mV is just 8ppm of full scale. I really think this is amazing from such a simple circuit.

I am really on the limits of basic resistor and LM324 performance here. For my power supply, I am very happy to go for 10mV absolute accuracy, with typical accuracy being 1mV, and it looks like I get that with the most basic of parts.

I cannot see any reason why the results would not be even better with high stability resistors and ultra low offset & current opamps.

Richard, I'm guessing that the resistors you're talking about are those in the 3 stages RC filter ?

Btw, cmiiw, looks like now you've finalized the adjustable vref module right ? How is the linear power part, are you going to work on that soon ?

I am entering the circuit into KiCad, but I admit, once I post it, I could really do with some ideas about the interface.

The cheapest approach would be to use an ATtiny processor with the QTouch hardware for capacitive buttons, but a power supply without a knob or two and real switches? - I just do not know.

Every half decent power supply I have built or used can easily last for decades. I want to end up with something that has an efficient interface that lets me switch from rough control to very fine easily.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #154 on: April 24, 2012, 06:40:04 am »
Richard, I'm guessing that the resistors you're talking about are those in the 3 stages RC filter ?
No The resistors and the capacitors in the RC filter can be very cheap - it doesn't matter. As long as the capacitors do not have a really bad ESR and as long as the leakage current is negligible. Drift in the filter resistors cause no real error, so the only problems are if they have a big effective parallel capacitance or are really noisy.

I need to amplify the output of the DAC up to the actual intended supply voltage, so that might mean amplifying by a factor of up to 8 times. The resistors in that amplifier will probably cause more error then the PWM dac. It really does not matter though. If a basic 25V supply is accurate to 10mV, that is impressive. I am not going to try for 100uV accuracy for the power supply. If I need high stability, I am happy to run the supply for half an hour to let it stabilize thermally.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #155 on: April 24, 2012, 06:48:54 am »
Every half decent power supply I have built or used can easily last for decades. I want to end up with something that has an efficient interface that lets me switch from rough control to very fine easily.
I would go for a rotary encoder. Turning a knob is still the best use-interface for fine-tuning stuff. If you take one with a built-in push-button you can switch between fast/slow easily. I also like software-controlled accelleration. If you turn is slowly you change in 1mV steps if you turn faster it changes in 10mV steps, if you turn very fast you change in 100mV steps.

Also a rotary encoder needs 2 pins, like two pushbuttons, there is no difference in consumption of port pins.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #156 on: April 24, 2012, 07:18:15 am »
Every half decent power supply I have built or used can easily last for decades. I want to end up with something that has an efficient interface that lets me switch from rough control to very fine easily.
I would go for a rotary encoder. Turning a knob is still the best use-interface for fine-tuning stuff. If you take one with a built-in push-button you can switch between fast/slow easily. I also like software-controlled accelleration. If you turn is slowly you change in 1mV steps if you turn faster it changes in 10mV steps, if you turn very fast you change in 100mV steps.

Also a rotary encoder needs 2 pins, like two pushbuttons, there is no difference in consumption of port pins.
That is the direction I am leaning, even though it means a more complex build.

One of the build options I have been considering is a small box (battery or power adapter powered) like a large smartphone size and about 15mm - 20mm thick. With touch switches, the back of the PCB can also form the top of the case, with perhaps a thin plastic sheet on top. This would be a lower power version - perhaps 200mA. I do not need a heatsink, so the actual power supply board using surface mount parts can be very thin.

You would have this sitting flat on the bench right next to the load. Once I start adding knobs and switches though, I am not sure that idea works as well. If I add a knob, it will probably have to be one that can be switched between volts and current adjust easily.

Dave is right about the importance of packaging. It is probably the hardest part of the project.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #157 on: April 24, 2012, 07:37:45 am »
Richard, forgot to ask, on the pwm generator, what is your decision ? A separated and dedicated mcu for pulse generation ?

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #158 on: April 24, 2012, 07:55:51 am »
Dave is right about the importance of packaging. It is probably the hardest part of the project.
Yes, very true.

I'm leaning towards a similar small box as Dave is using. I like the vertical front as this allows me to stack them up on the shelf. I may have several of them.

For Volts/Amps I think I prefer separate knobs. You could also switch between the two using the pushbutton, but there is always the danger that you change the wrong thing. Some additional buttons for special functions would be nice too. Something like 'Menu', 'OK', 'Cancel'.

I also like a graphic LCD, something like the 65x128 display from newhaven. Does not cost more than a character display, but gives more options for future firmware with interesting features, like displaying current spikes, etc. The only catch is that you think I'd need a microcontroller with enough flash to hold a character table.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #159 on: April 24, 2012, 08:07:37 am »
Richard, forgot to ask, on the pwm generator, what is your decision ? A separated and dedicated mcu for pulse generation ?
A single micro in the supply.

The PWM drives a cmos logic gate powered by the reference to generate the precision PWM output. I will probably stick to an Arduino processor, but I will have to see how the pin allocation goes - there are never enough. I see programming a micro as being a frustration to many people who want to build the supply, and Arduino probably gives the easiest way in. You can buy a $20 Arduino, and use it to program another blank Atmega IC - or you can just buy the IC pre-programmed with bootloader from any Arduino supplier.

There are great chips in TI's MSP430 family, but there is just no cheap way to program them. As far as I know, the cheapest way to start is a $99 device from TI.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #160 on: April 24, 2012, 08:27:37 am »
The PWM drives a cmos logic gate powered by the reference to generate the precision PWM output. I will probably stick to an Arduino processor, but I will have to see how the pin allocation goes - there are never enough. I see programming a micro as being a frustration to many people who want to build the supply, and Arduino probably gives the easiest way in. You can buy a $20 Arduino, and use it to program another blank Atmega IC - or you can just buy the IC pre-programmed with bootloader from any Arduino supplier.
Why not building it as Arduino shield ?

Then you can concentrate on the power stuff and sort of offload the microcontroller/programming related worries to the Arduino. Things like providing a chip with an Arduino bootloader will be take care of. It also sort of fixes the form-factor.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #161 on: April 24, 2012, 09:38:53 am »
Have you considered using standard 24 or 18 bit delta-sigma audio DAC?  They are very cheap and interfacing to I2S is trivial.  You can drop the sampling clock rate to match your MCU internal frequency.

Leo

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #162 on: April 24, 2012, 11:08:46 am »
Have you considered using standard 24 or 18 bit delta-sigma audio DAC?  They are very cheap and interfacing to I2S is trivial.  You can drop the sampling clock rate to match your MCU internal frequency.

Leo
The problem is they are not designed for DC stability, and there is usually nothing in the spec to tell you much about DC stability. They may be cheap, but cheaper then a few resistors and capacitors, and a cmos gate IC? Also, the idea of this design was as much as possible use common parts - the delta-sigma DACs are moving slightly to the exotic.

Basically, as far as I can see, the micro implements a delta-sigma dac almost perfectly, so in a sense, I already have one. Why buy another?

Richard.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #163 on: April 24, 2012, 11:26:15 am »
Basically, as far as I can see, the micro implements a delta-sigma dac almost perfectly, so in a sense, I already have one. Why buy another?
To reduce output settling time by the factor of 1000?

Leo

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #164 on: April 24, 2012, 12:37:19 pm »
Basically, as far as I can see, the micro implements a delta-sigma dac almost perfectly, so in a sense, I already have one. Why buy another?
To reduce output settling time by the factor of 1000?

Leo
It could be worth it for some people if you can tell me some DC stability specs for the delta-sigma converters.

I am pretty happy with the settling time I have for manual use, but it would be useless for, say, remotely controlled automated testing. Fast settling specs can become useless if the supplies do not have active pull down on the output - something I am considering.

Richard.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7262
  • Country: us
    • SiliconValleyGarage
Re: General Purpose Power Supply Design
« Reply #165 on: April 24, 2012, 02:07:51 pm »
I have to admit that i have not read the whole topic, but just a quick sidenote ( this may or may not have been covered )
Are you using a PWM or a BRM ? In a BRM the pulse width is always fixed but the delay between them changes. This is typically made with an accumulator and checking for overflow.

In cpus this is very efficient.

Slow Timed interrupt :
Add reg, rate
If carry then {flag = true, clear carry}
Output = flag.
Return

Fast timed interrupt:
Flag =false
Return

Fast timed interrupt needs highest priority. So it can clear the flag.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #166 on: April 24, 2012, 02:17:11 pm »
I have to admit that i have not read the whole topic, but just a quick sidenote ( this may or may not have been covered )
Are you using a PWM or a BRM ?
I am using PWM. It turned out to be very important that I was modulating an 8 bit PWM, as it means the fundamental PWM frequency is always 62.5KHz and this is high enough to be very effectively filtered out to DC. 16 bit PWM or BRM can end up with much lower frequency fundamentals that do not get fully removed by the filter.

Richard.
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 2003
  • Country: us
Re: General Purpose Power Supply Design
« Reply #167 on: April 24, 2012, 03:31:24 pm »
I am using PWM. It turned out to be very important that I was modulating an 8 bit PWM, as it means the fundamental PWM frequency is always 62.5KHz and this is high enough to be very effectively filtered out to DC. 16 bit PWM or BRM can end up with much lower frequency fundamentals that do not get fully removed by the filter.

You should be aware that PWM can also generate low frequency components depending on the output code.  For instance, if you have 8 bit PWM @ 62.5 KHz and output the 24 bit code 0x800100 your PWM will be 0x80 for 255 cycles and 0x81 for 1 cycle, giving you a pulses at 244 Hz.  To solve this you have to use a multi-order sigma-delta. Basically this will allow the feedback loop to overshoot and use codes 0x7F and 0x81.  This pushes the noise to higher frequency where they can be filtered more effectively.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #168 on: April 25, 2012, 01:12:04 am »

You should be aware that PWM can also generate low frequency components depending on the output code.  For instance, if you have 8 bit PWM @ 62.5 KHz and output the 24 bit code 0x800100 your PWM will be 0x80 for 255 cycles and 0x81 for 1 cycle, giving you a pulses at 244 Hz.  To solve this you have to use a multi-order sigma-delta. Basically this will allow the feedback loop to overshoot and use codes 0x7F and 0x81.  This pushes the noise to higher frequency where they can be filtered more effectively.
I haven't looked at a multi-order sigma delta at all yet, but it sounds like more cycles of processing in the PWM interrupt that can be a problem. Until I was told, I never knew I was designing a delta-sigma PWM.

But to really understand the noise from my PWM, we have to do some really difficult and complex calculations - well actually no, it turns out to be extremely easy. Don't need to look at a single textbook. Just a bit of LTSpice.

Lets just take my RC filter time constant (100K/0.22uF) as fixed, the micro speed (16MHz) as fixed and the PWM speed (62.5KHz) as fixed. The rejection of anything above above 1Khz is close to absolute - less then 30nV rms on the 25V power supply output. To verify that, all you have to do is work out the impedance of the .22uF cap at 1KHz, and then use that to work out the attenuation of each stage.  As a result, we can ignore totally the normal 62KHz PWM output, and all we have to look at is the effect of the corrections - we can treat them as separate pulses.

The worse case is a single correction pulse, all thanks to the way the algorithm I am using that spreads corrections out evenly.

A single pulse when scaled to the output voltage is 30V in amplitude and 62.5 nS wide (1/16MHz). Here is the result at the output for a 3 stage RC filter and a 6 stage RC filter. The input pulse is too short to plot in the graph but it is there at time 0.0:



These waveforms say everything. The worse case noise will be 9uV p-p which means the worse case RMS noise will be around 3uV RMS. If I used a 6 stage filter, you get about half this.

I think the truth is that 9uV of low frequency noise is low enough to be fine - Agilent are proud to boast that their E36xx series supplies have less then 0.35mV of RMS noise.  However, all  you need to do to reduce the noise further is to control the minimum rate of the error correction. It is a very simple matter of controlling the resolution of the PWM numbers I use. Lets use pulses at 20Hz. you get this:



The 3 stage filter noise has dropped to just over 1uV RMS, and with a 6 stage filter, the noise is essentially gone.
The cost of limiting the minimum correction pulse frequency to 20Hz is that you loose resolution - the smallest adjustment step is 40uV. What is happening is the next correction pulse arrives well before the first has decayed so they combine reducing the peak to peak noise.

I prefer to leave the resolution unlimited, and the user can add a big cap on the supply output terminals if they need lower ripple for some reason. I just think that if you are trying to run a circuit from a power supply that is sensitive to very low frequency noise at the uV level, you will be struggling anyway, particularly if the supply has noise generating microprocessors, a switching pre-regulators, etc.

For people who want minimum noise at the expense of resolution, it is one line of code that needs to be changed.

I could go to a 6 stage filter, but I am not sure it is worth the trouble. I just do not think anyone will notice the difference in reality. With one more capacitor in the gain stage that amplifies the reference output, I can reduce the worse case peak-to-peak noise from 9uV to 5uv and that is probably where I will stop.

It's good enough. It is easy to get carried away with making the numbers look perfect when in reality, it just does not matter. When your load current increases by 1mA, you will get a 9uV+ change anyway due to the resistance of your power leads to the load.

Richard.

EDIT: Thinking about this a bit more, I will limit my resolution to 24 bits. This gives me a minimum adjustment step size of 2uV and the worse case noise will be 7uV p-p. In terms of RMS, it will be more like 1.5uV RMS noise at 1Hz minimum frequency. By setting a minimum frequency for the correction noise, it means that if you needed a super low noise output, add a resistor and capacitor to the output with a time constant over 10 seconds. Going to a 64MHz ATTiny PWM doesn't improve things as much as you would think - you would need 128MHz PWM clock or more to get big improvements. With the ATTiny's 64MHz PWM, I would be worried that jitter might make it worse then the 16MHz Atmega PWM.
« Last Edit: April 25, 2012, 01:59:19 am by amspire »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #169 on: April 25, 2012, 01:40:26 am »
I may not be the only one, but I have a complete mental block on how a sigma-delta algorithm works in this context (and Google doesn't help).

Maybe you could explain it in words of one (mathematical) syllable?

For instance, this is where I am stuck. Suppose you have an 8-bit PWM, and for one cycle you output a value of 200. This corresponds to an analog value of 200/255. If you output 200 indefinitely you get a constant output of 200/255.

Now suppose you output 200 for one cycle, and 100 the next cycle. At this point you care about the filtering. With no filtering at all, the output makes a step change from 200/255 to 100/255. However, with some filtering the output moves slowly from 200/255 to 100/255. By measuring the output at different times you could measure any value between 200 and 100. If you alternate between 200 and 100 you could obtain an average value somewhere between the two. If you adjust the mark/space ratio of the 200 and 100 outputs you could position the average value anywhere in the range you wish. In particular, if you alternated between 200 and 199 you could set the average output at some fractional value between those two limits.

Where I get stuck, is what is the actual algorithm you are using to do this, in layman's terms? You posted some code before, but I couldn't deduce what it was actually doing.

Help me out here, and perhaps you will help many others?
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #170 on: April 25, 2012, 02:25:16 am »
I may not be the only one, but I have a complete mental block on how a sigma-delta algorithm works in this context (and Google doesn't help).

Maybe you could explain it in words of one (mathematical) syllable?
I am just going to explain it.

 Say I take my Atmega328 IC, and apply a 255V supply-  imagine this chip can take it.

Then when you use the 8 bit PWM, if you send it 123, you get 123V DC out from the filter.

What happens if you want 123.3V DC out?

The way I am doing it is this. The first PWM cycle, I use the nearest lower PWM number, so I output 123V for one PWM cycle. I add the error (0.3V) to the value I want to the next cycle so that makes 123.3 + .3 = 123.6.

I repeat the same steps as above, so the nearest lower value I can output is 123V for the second PWM cycle. Total error is now 0.3V + 0.3V = 0.6V.

Repeat again - the value I want this time is 123.3 + 0.6V = 123.9V. So for the third PWM cycle, I output 123 V again, leaving an error now of 0.9V.

On the 4th cycle, I want 123.3 + 0.9V = 124.2 V, so this cycle I output 124 and the error is now 0.2 .

So all I am doing is keeping a running count of the error from the last PWM output, and adding it to the original value I want for the next cycle.

To implement this in code is amazingly easy. This code is run every time the timer counter for the PWM wraps around to zero:

Code: [Select]
  OCR2A = (byte) (pwm_accum / 0x01000000L ) ;  // Output the top byte of my PWM accumulator to the PWM
     // since the PWM uses double buffering, this code will only reach
     // the PWM registers the next time the timer counter reaches 00.
     // This way, the PWM never changes in the middle of a PWM cycle - it only changes just as it is about to
     //     start a new cycle.
  pwm_accum &= 0x00FFFFFFL ; // Delete the top byte leaving just the error
  pwm_accum +=  value ;  // Add the original intended value to the error in the accumulator for the next PWM cycle


Just those 3 steps turn an 8 bit PWM to in this case a 32 bit PWM as my accumulator happens to be 32 bits in size. To actually get 32 bit DC out, I would have to use a filter with a time constant of about an hour though. You can basically choose any resolution you want just by adjusting the number of bits in the accumulator.

In diagrams of sigma-delta PWM's you will see an integrator. My PWM accumulator register is the integrator.

A really interesting thing to come from this is that if you wanted to get 16 bit accuracy, an 8 bit PWM with 8 bits of correction far exceeds the performance of a straight 16 bit PWM. The 16 bit PWM needs a filter time constant for a 3 stage filter of about 1 second. The 8 bit corrected PWM (or sigma-delta or whatever you want to call it) only needs a time constant of about 20 mSecs for a 3 stage filter to equal the 16bit PWM. That is an amazing improvement in speed.

Richard.
« Last Edit: April 25, 2012, 03:01:45 am by amspire »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #171 on: April 25, 2012, 03:53:45 am »
Ah, that almost seems too simple. I will have to reflect on that a bit and convince myself that it always has the desired outcome. Thanks.
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #172 on: April 25, 2012, 04:54:38 am »
Ah, that almost seems too simple. I will have to reflect on that a bit and convince myself that it always has the desired outcome. Thanks.

People understand money really well, so a money analogy might convince you.

Say you have to pay Joe $500 a year, but you have to pay every day, and you have to pay in $1 coins.

Now if you pay $1 a day, that is $365 a year - too low. $2 a day and that makes $730 a year - ouch! Definitely not going to do that.

Joe is a really nice guy and he doesn't mind if you owe him less then $1.

So you work out that you need to pay $1.369863 a day for 2011 (no leap year).

You pay him each day the amount owed rounded down to the nearest dollar and and add the error (the cents part of the amount owed that you didn't pay) to the amount you owe the following day.

At the end of the year, you will have paid exactly $500.  In the case of my accumulator, each day you would have added 1.369863 and each day you will have subtracted the actual coins you have paid. At the end of the year, you will discover the accumulator = 365 * 1.369863 - 500*$1  = $0. It is that simple.

Richard.
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #173 on: April 25, 2012, 08:10:21 am »
There are multi-level delta-sigma DACs that use two or more level outputs.  Say you have two outputs - 100% level output and 10% level output. 
For 1% output instead of triggering main output each 100th cycle you trigger 10% output each 10th.  This increases settling time by a large margin.
Second and further level outputs don't have to be of high precision because they are only "filling the gaps" between the main output action if this makes sense.

Leo
« Last Edit: April 25, 2012, 08:18:10 am by Leo Bodnar »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #174 on: April 25, 2012, 08:31:53 am »
Leo, it makes perfect sense and I have been considering something like that. Something like an 18 bit + a 6 bit secondary PWM would be nice, but it does mean extra parts, and without a negative supply rail, summing the two together gets a bit messy.

So good idea, but the extra parts may end up ruling it out unless I can find a great way to implement it.

Have to admit that right now, I am struggling with something else - the controls. I am not convinced that contact-switch based rotary encoder are reliable. The moment the contacts start bouncing, it is really hard to decode them reliably. I would love to find a cheap optical rotary endcoder.

Richard.

 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #175 on: April 25, 2012, 11:40:04 am »
Have to admit that right now, I am struggling with something else - the controls. I am not convinced that contact-switch based rotary encoder are reliable. The moment the contacts start bouncing, it is really hard to decode them reliably. I would love to find a cheap optical rotary endcoder.
There rotary encoder code has been discussed on the forum before. There is a simple and reliable code here: Buxtronix: Rotary encoders, done properly. The code is for Arduino, but translates to C easily.
Bounce is not a problem at all with that code, the state machine seems immune to simple bouncing. If implemented with simple polling, the polling speed determines the speed you can read the encoder, though.

On the other hand I've played with encoders with 18 steps/revolution and find that too granular, I suspect that the standard 24 step types are not fine enough yet for my taste. So a optical, high resolution encoder would be welcome.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #176 on: April 25, 2012, 12:51:18 pm »
There rotary encoder code has been discussed on the forum before. There is a simple and reliable code here: Buxtronix: Rotary encoders, done properly. The code is for Arduino, but translates to C easily.
Excellent. I missed that discussion but the code is a big help.

I don't see why optical encoders based on the mouse optical encoders that must cost nothing can't be available in a front panel control mounting. They would almost last forever, rather then 20-30000 rotation cycles. But I will probably have to go with a mechanical one.

Do I go with a $1 Chinese one that lasts "30,000 cycles" ?? or a 200000 cycle Bourns one at $4-$5.  $5 will more then cover the costs of all the parts of the regulator circuit - with lots to spare.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #177 on: April 25, 2012, 01:00:44 pm »
I don't see why optical encoders based on the mouse optical encoders that must cost nothing can't be available in a front panel control mounting.

Hey, that is a really cool idea, this will turned into nice thumb wheel with a push button too rather than ordinary knob style.

Time to search those old or broken mouses scattered somewhere in house.  ;D

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #178 on: April 25, 2012, 01:50:11 pm »
Richard, I can't grasp what you are trying to design.

On one hand you are chasing sub-microvolt resolution that only makes sense if other equipment is of the same precision range (which means $$$.)
On the other hand you are dithering about using a $5 encoder.

Leo

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #179 on: April 25, 2012, 02:30:17 pm »
Richard, I can't grasp what you are trying to design.

On one hand you are chasing sub-microvolt resolution that only makes sense if other equipment is of the same precision range (which means $$$.)
On the other hand you are dithering about using a $5 encoder.

Leo
I am going for really really cheap using the most common parts, but I want really really great performance. That is all I ask.

About the resolution, I want something like the old power supplies could do with the course/fine controls - but hopefully a bit better. They could easily be adjusted to better then 1mV, whereas a 25V supply with a 12 bit DAC can only be adjusted in steps of 6mV, or with more convenient scaling 10mV. That is a huge leap backwards. Accuracy doesn't matter since everyone will probably attach a DMM if they want an accurate voltage anyway.

To me, a supply should be adjustable to at least 10uV. That is a starting point. I am not interested in building a supply if it is not as good as the common supplies built 40 years ago.

The reason I am going for cheap is I am trying to build the kind of board that rather then just making one, you could make 5 or 10. I love parts costing less then 10c. Parts costing $1 will be very rare in this design.

I have a way the modules can be used in series in a master slave fashion so with 4, you get a 100V supply, or in parallel in a master slave fashion so with 5 modules, you get a 25V 5A supply. The slave boards do not need micro's. displays, etc, so the whole slave regulator board will be the PCB + under $10 in parts.

Richard.

« Last Edit: April 25, 2012, 02:36:36 pm by amspire »
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #180 on: April 25, 2012, 02:56:03 pm »
Accuracy doesn't matter since everyone will probably attach a DMM if they want an accurate voltage anyway.
To me, a supply should be adjustable to at least 10uV. That is a starting point. I am not interested in building a supply if it is not as good as the common supplies built 40 years ago.
Parts costing $1 will be very rare in this design.
Does this mean your PSU will have less then 10uV of output noise and matching load regulation?  I can't see this built with sub-$1 parts.  Well, if it can be, I'd take my hat off. 

Leo

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #181 on: April 25, 2012, 03:18:25 pm »
Accuracy doesn't matter since everyone will probably attach a DMM if they want an accurate voltage anyway.
To me, a supply should be adjustable to at least 10uV. That is a starting point. I am not interested in building a supply if it is not as good as the common supplies built 40 years ago.
Parts costing $1 will be very rare in this design.
Does this mean your PSU will have less then 10uV of output noise and matching load regulation?  I can't see this built with sub-$1 parts.  Well, if it can be, I'd take my hat off. 

Leo
Probably not, particularly with noise from micro's, and sometimes switching pre-regulators around. But as I said recently, you can add a big external cap if you want lower noise. Also many of the applications where you want the high resolution don't care much about noise. Say I want to set it to 10.00000V out using a precision DMM, so I can test other DMM's. The DMMs on the DC ranges can all handle low level noise without a problem.

With a 12 bit DAC based supply, you will end up with a voltage like 10.002625 and you have to mka e do with that.

And with the DAC, the power supply is not the only point. When I started playing with the idea, I though 1% accuracy would be fine and 0.1% would be really good. When I see that the same basic circuit can probably do 0.01% or lower with just a few improvements, that is really interesting, isn't it? Not for the power supply but for other designs. I am fascinated that at almost no cost, you can get into the realm of the really expensive DACs. I like the fact that I can now say "Yes I can use a PWM output from a micro to build a 24 bit Dac with really great linearity, and perhaps great accuracy for next to nothing". A month ago, I would have said "No way can you do it - you will just have to get the checkbook out and pay big money".

Maybe it is just me.

Richard.
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 2003
  • Country: us
Re: General Purpose Power Supply Design
« Reply #182 on: April 25, 2012, 05:35:57 pm »
I am fascinated that at almost no cost, you can get into the realm of the really expensive DACs. I like the fact that I can now say "Yes I can use a PWM output from a micro to build a 24 bit Dac with really great linearity, and perhaps great accuracy for next to nothing". A month ago, I would have said "No way can you do it - you will just have to get the checkbook out and pay big money".

I don't think it is fair to compare your DAC to commercial offerings.  The settling time of your DAC is going to be 10s of seconds, whereas a commercial sigma-delta DAC costing < $5 will have a settling time of 10s of microseconds.   That isn't to say that your DAC is useless, but the brute force solution of using extremely slow filtering is not suitable for many applications.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #183 on: April 25, 2012, 06:41:23 pm »
The settling time of my DAC is something like 0.6 seconds worse case to a millivolt. 10s of seconds would be useless. For small adjustments, it is much faster.

It is a DAC so of course it is fair to compare it to other DACs.

It is slower, but it has great linearity and resolution. I am making a power supply, not a video card or waveform generator.  Commercial sigma-delta DACs could be interesting if there is one spec'd for DC stability.

Richard. 
 

Offline Leo Bodnar

  • Frequent Contributor
  • **
  • Posts: 659
  • Country: gb
Re: General Purpose Power Supply Design
« Reply #184 on: April 25, 2012, 06:54:36 pm »
I can't believe that discussion about a PWM output fed into an RC filter has spread over 13 pages! ;)
Leo

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: gr
Re: General Purpose Power Supply Design
« Reply #185 on: April 25, 2012, 07:41:47 pm »
Why not, Leo?

Is the practical implementation and testing of such a technology being taught in any textbooks? After all, what I can see happening over here is a bunch of (bigger) boys having a good time playing with their beloved toys! At least, this is the way I feel about it!

In my opinion, the journey to Ithaca is more important than the destination itself.



Richard, I was impressed by the results you got from your last experiment! I think, though, that I will settle for components like LTC2641-16 and LT1461A-2.5, which I find to be more suitable for my PSU needs. But I am following your progress!


-George
« Last Edit: April 25, 2012, 07:45:38 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 2003
  • Country: us
Re: General Purpose Power Supply Design
« Reply #186 on: April 25, 2012, 07:52:06 pm »
The settling time of my DAC is something like 0.6 seconds worse case to a millivolt. 10s of seconds would be useless. For small adjustments, it is much faster.

My bad, I misread your capacitor as 2.2 uF instead of .22.
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #187 on: April 25, 2012, 10:18:04 pm »
Ah, that almost seems too simple. I will have to reflect on that a bit and convince myself that it always has the desired outcome. Thanks.

People understand money really well, so a money analogy might convince you.

Actually I am quite happy with the general principle. But with things like this I tend to ask myself if there are edge cases, or limitations in application that might present unforeseen snags?

For instance your monetary example involves small amounts $1/day averaged over a long period (1 year). But what if the amounts were larger ($100/day) averaged over smaller periods (like 1 month or 1 week)? Or given $1/day, how many days does it take before the error in the $500/year rate is reduced below some tolerance like 0.1%? Where are the limits? What is the noise on the output? Does the noise filter introduce its own errors due to filter lag? All kinds of questions arise...

(...which you have been investigating of course, but still.)
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #188 on: April 25, 2012, 11:55:52 pm »
The worse case error calculation is pretty simple. In the case of the coins, then worse case error is $1 so after $500 has been paid, the worse case error is +/- 0.2%.

In the case of the PWM, just count the resolution of the intended voltage value you are using for your PWM. If it is 24 bits, then you have about an error of about 1/224 (providing everything else in the circuit is perfect and the filter time constant is long enough).
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #189 on: April 27, 2012, 01:39:36 am »
Richard,

You've mentioned several times that everything is going to cost just a few bucks. Which reference you will be using to achieve that and still have good stability in the 10's of uV, even if it is short term?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #190 on: April 27, 2012, 01:54:06 am »
Still thinking about that. It might even end up being something as basic as a TL431. I only need it to be stable after temperatures have stabilized, even if that takes an hour. Most of the time, no great stability is needed at all. For general use without a warm up, then better then 1% is fine, as far as I am concerned.

The reason why I may go for a TL431 is that this circuit like Dave's runs with any voltage from a battery voltage which might be a lithium battery or 3 or for AA cells up to 27V. So that means 3V to 27V . I need a low dropout reference, and as part of the design exercise I set myself, I am minimizing specialized parts. I have a TL431 + transistor combination in mind to make a wide range low dropout 2.5V reference.

I have a TL431 somewhere, so I think I will have to do a test. A TL431B should give about a 0.2% stability over a wide temperature range. The temp coefficient curve for the TL431 flattens in the middle of the range, but they are a bit vague about the actual temperatures where it does  flatten.

Richard.
« Last Edit: April 27, 2012, 02:01:41 am by amspire »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #191 on: April 27, 2012, 02:25:43 am »
Just checking. Linear Technology have the LT1431 which is a higher spec'ed TL431.

I have got the short term stability I need in the past out of a LD117 LDO regulator, and definitely the LT1431 is more stable. So if I go with the LT431, then if people want better performance, they can use the LT1431.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #192 on: April 27, 2012, 03:13:43 am »
Richard, does the selection of the logic buffer for the pwm signal is critical ? or any jelly bean mos based buffer is good enough ?

Also regarding the precision voltage source, it supplies current only to these buffers right ?

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #193 on: April 27, 2012, 03:30:32 am »
The buffer is a little critical, in that I found that 4000 cmos was too slow and was inaccurate. It has to have cmos output, so you cannot use the buffer chips with cmos input stages and transistor output stages.  Most fast CMOS logic chips should be fine.

It is giving me a few options, as I might be able to pick a chip with a spare gate or two that are useful elsewhere.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #194 on: April 27, 2012, 05:54:19 am »
The buffer is a little critical, in that I found that 4000 cmos was too slow and was inaccurate. It has to have cmos output, so you cannot use the buffer chips with cmos input stages and transistor output stages.  Most fast CMOS logic chips should be fine.

It is giving me a few options, as I might be able to pick a chip with a spare gate or two that are useful elsewhere.

Ok, no 4000 cmos series, but with bipolar input and cmos output, which series is that ?

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #195 on: April 27, 2012, 06:37:18 am »
Just about all the cmos logic chips are fine. Some of the driver chips, particularly cmos input mosfet drivers are often bipolar output. If a mosfet driver had a cmos output, it would probably be excellent.
« Last Edit: April 27, 2012, 06:42:13 am by amspire »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #196 on: April 27, 2012, 08:03:36 am »
Just about all the cmos logic chips are fine. Some of the driver chips, particularly cmos input mosfet drivers are often bipolar output. If a mosfet driver had a cmos output, it would probably be excellent.

Your 1st test that was using CD4069 has cmos output and input, but quite slow with transition time @5Volt is 150 ns.

Here your simplified 4069 schematic from it's datasheet :



I'm not nitpicking, its just I'm curious on how this buffer choice affects the accuracy performance ? Faster transition time is better right ? Really eager to learn here.  ;)
« Last Edit: April 27, 2012, 08:05:08 am by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #197 on: April 27, 2012, 08:22:56 am »
it is all about transition speed. Imagine a minimum width PWM pulse of 62.5ns trying to get through a gate with 150nS delay. Basically the cmos buffer characteristics dominate the shape of the waveform, not the reference voltage. You end up with a triangular looking pulse that never reaches maximum.

If you choose a cmos IC with 10-20nS delay time, you get a good looking squarewave out and the top and bottom do reach the reference and zero voltage levels.

If you look at the PWM cycle, with a 10nS rise/fall time gate, 20nS out of 62.5mS are spent in the transitions. That is 0.033 percent of the time. Now if you assume that the rise and fall shapes will stay within about 10% of a normal shape, then you get down to 0.0033% linearity.

A cmos gate with very similar rise and fall time shapes would be ideal. A really fast gate such as 5nS or less could improve this more, but the faster the gate, the more chance transients may affect the levels. Really good decoupling is needed. I will probably use something like a 0.1u capacitor and a 1nF capacitor, and also the first filter capacitor will be very closely coupled to the gate.

Richard.
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #198 on: May 10, 2012, 12:36:45 am »
Any news on the supply? I'm curious about the Rev. 3 :)
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #199 on: May 10, 2012, 01:11:50 am »
Apologies - I will post some news soon. I had started drawing the circuit, and then had an idea about an improvement that would need a slight redesign to the board.

The design is based around a PCB module that does all the regulation, and a pre-regulator - either linear or switching.

What I realized is that rather then limiting the maximum voltage to 25V, if the regulator board is powered by a floating supply that is isolated from the main supply to the pre-regulator, I was no longer limited to 25V maximum. The maximum voltage is only limited by the voltage rating of the pre-regulator so you could easily use the board to make a 50V, 100V or 500V supply - whatever you choose to make. As the regulation is still done on the board, the different voltages do not need any redesign of the compensation network.

However the moment I do allow the module to run in a floating mode, I have to look very carefully at making sure that the supply is still fully protected under fault and overload conditions. I also have to look into what sorts of pre-regulators will work reliably with the floating regulator module.

The pre-regulator can be as simple as a NPN darlington transistor used as an emitter follower. Use of MOSFETs is a bit more of a problem with the big variations in the gate turn on voltages. I would probably have to lower the maximum current a bit if a MOSFET was used so I can cover the gate voltage variations.

The module will still run in non-floating mode, and if you only need a 250mA supply, it can be used without any pre-regulator. The pre-regulator is only needed if the total power dissipation exceeds about 5W.

Richard.
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 1941
  • Country: au
Re: General Purpose Power Supply Design
« Reply #200 on: May 10, 2012, 04:25:52 am »
I am looking forward to making this design up Richard. Thanks for all your effort.
My current PSUs are not really up to scratch, just cheap kit supplies.
Are you going to layout the pcb, and specify hardware?
I really like the idea of very high resolution and good stability and just using my DMM to set the voltage accurately.
Obviously I like the preregulator too, but I would have thought this was fairly standard  these days.

Kudos to you too AHellene, I hope some of your code or ideas will be in the firmware, I would like to compare it against some of my AVR code, to look for improvements that I could include in mine.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #201 on: May 14, 2012, 07:24:03 am »
A bump for this fine thread, and really curious to see the next revision of linear front end part.  ;)

Offline heychris

  • Contributor
  • Posts: 16
Re: General Purpose Power Supply Design
« Reply #202 on: May 15, 2012, 04:37:34 pm »
I was wondering if anyone had thought about putting a couple USB charger ports on here.  I know that I have several USB wall warts I'd like to get rid of.  I know there needs to be a circuit to negotiate with chargers.  I've played with the TI tps2543.  http://www.ti.com/product/tps2543   It works quite well.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #203 on: May 16, 2012, 12:10:40 am »
I will get back to posting some circuits today. The basic regulator board will not have a USB charger output, but there will be a separate isolated full featured control board, and that could have a USB charger.

The issue is that a USB charger outputs really need 5V at at least 1A to cope with modern phones and Kindles, and that is just not available on the basic regulator board.

Anyway, I just do not like USB outputs that are floating at the same potential as the power supply negative output. The whole idea of a floating output is you can connect it to anything - a 400V DC line, or a high voltage AC line, and I hate to think of a USB charging output at the same potential.

Richard.
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #204 on: May 16, 2012, 09:16:35 am »
I would leave the USB charging port out. While it can come handy at times, this is better served with a dedicated item. I have a four-port USB power supply at my desk for these needs. I also agree that separate potential for the lab power supply and USB devices are a good idea, other wise you are setting yourself a trap to break something down the road.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #205 on: May 16, 2012, 12:25:27 pm »
I would leave the USB charging port out. While it can come handy at times, this is better served with a dedicated item. I have a four-port USB power supply at my desk for these needs. I also agree that separate potential for the lab power supply and USB devices are a good idea, other wise you are setting yourself a trap to break something down the road.

I will probably leave it out. The best way to add a USB port that is isolated from everything else is to buy a $5 USB adapter, break it open and put the board inside the supply. Why not just leave the adapter as it is in its fully double insulated rated adapter enclosure.

If I add a USB port to the version with a full control panel that will probably be able to control several supplies, it will be because it is functioning in some way as a USB port (such as datalogging, or programmable sequencing) rather then just being a 5V supply output.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #206 on: May 16, 2012, 03:10:54 pm »
I will get back to the supply design.

Below I have the basic regulator, but the circuit will be changing a lot over the next few days as I add in the voltage and current reference components, the pre-regulator, high voltage mods and a few other enhancements.



I have settled on a PNP pass transistor, but instead of using a single PNP on a heatsink, I have gone for multiple 2N2907A transistors, or PZT2907A surface transistors on 1 square cm of PCB as a heatsink. The driver transistor is a 2N2222A or PZT2222A for surface mount use. The regulator board can have up to a 5V voltage drop at 1A without any heatsink. I am assuming the board will run at 75 deg C or less. A pre-regulator circuit will allow for the full 0 to 25V range at 1A.

You get a few things with this approach - the transistors can be very cheap particularly in quantity, and the transistors are operating at an optimal DC gain operating point at maximum output current.  There are specialized high gain PNP transistors from companies like Zetex that impressive performance, but the price is higher and the availability is lower. The bandwidth is good, and by eliminating an extra darlington-type gain stage, I get a much better stability margin. I think it will work well - better then my Mark I and Mark II designs.

The intended output is from 0V to 25V maximum for this configuration, but I will have a high voltage configuration that can go much higher without having to redesign the compensation circuit.

In the circuits I will be posting in the next few days, I will be giving three basic circuit choices:

1. Potentiometers for voltage and current control - meter modules for measuring voltage and current.
2. Basic microprocessor control with very basic single supply interface
3. Powerful controls on a separate isolated PCB that can drive several isolated regulator boards. Regulator boards have a simple microcontroller and talk to main controller via optocouplers.

I may also allow for paralleling modules for more then 1A output, and also master slave use for multiple tracking supplies.

I had done a fair bit of work on an isolated switching pre-regulator, but I am concerned about output noise, and the ease of making the transformers. I am not convinced I will go that way yet.

Linear pre-regulators are a simpler solution, and will definitely be an option.

More soon ....

Richard.

 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #207 on: May 16, 2012, 03:58:09 pm »
Richard, I find your solution interesting.

But I'm not convinced that it is better/cheaper than Daves version with a single LT3080. The 2n2907A is $0.80, a LT3080 is $4 so the price is about the same. But I'd feel more comfortable with the TO220 LT3080 screwed to a heatsink dissipating 25W than the same spread over 9 TO-18 devices with their flimsy heat-sinks.

The 25 W is probably about the worst case when drawing a full amp at low voltage.
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #208 on: May 17, 2012, 01:03:48 am »
Richard, I find your solution interesting.

But I'm not convinced that it is better/cheaper than Daves version with a single LT3080. The 2n2907A is $0.80, a LT3080 is $4 so the price is about the same. But I'd feel more comfortable with the TO220 LT3080 screwed to a heatsink dissipating 25W than the same spread over 9 TO-18 devices with their flimsy heat-sinks.

The 25 W is probably about the worst case when drawing a full amp at low voltage.

The 2N2907A is below 10c - if not you are being ripped off. In quantity, the prices get very low. The 2N2907A and the 2N2222A are exactly the kind of transistors it is great to stock in the lab anyway, so you can go for the 100 off prices without straining the wallet too much. I would use the TO92 devices, not the TO18 ones. The exact part number varies from manufacturer to manufacturer. The through hole version of the circuit relies on air cooling of the TO92 packaged transistors - no heatsink is used.  The PZT2907A and PZT2222A can dissipate over 1W, so they are pretty nice surface mount variations to have. I may have to increase the transistors to 10 for the through hole board.

My solution is fine, as long as I can limit the maximum dissipation on the board to 5W which amounts to about 3.6W peak in the transistors. My job is to see that the regulator board does not dissipate more then 5W continuous under any condition.

But why not just use Dave's LT3080? It is an extremely nice chip, but not perfect. Some of the problems are:
  • The supply current for the chip comes from the load, so there is a minimum load the chip needs to regulate. Dave's solution was to add a LM334 temperature dependent current source, but this has issues below 1V output, and the temperature dependency makes it hard to properly compensate for it in the current measurement circuit. I just like supplies that work properly down to zero volts - I do not design lab supplies that do not. It is easy to overcome this limitation by adding an extra resistive load to Dave's supply when workng at low voltages, but my choice is to avoid that.
  • The LT3080 only regulates to the output pin of the chip, not the output terminal of the power supply. If there is a total of 0.1 ohms resistance between the LT3080 and the output terminal (wiring resistance and maybe an output ON/OFF switch), then you get 0.1V regulation only as you go from 0 to 1A.
  • You cannot add a fuse on the LT3080 output as the resistance will wreck the regulation. This limits the ability to protect the supply from something like a SLA battery you accidentally connect in reverse. I can add a fuse to my board with no effect on the regulation and a fuse or breaker is the only protection against excessive high energy positive of negative voltages from a connected load.
  • The LT3080 has a reasonably high thermal resistance from junction to case which limits how much supply you can get in a small case. That is why Dave's original supply was going to be limited to about 10V maximum, and to boost that to 20V, he had to add a switching pre-regulator. As discussed in this thread, there are problems with the switching pre-regulator in that a specially crafted pulsed load can end up cooking my regulator board or in Dave's case, the LT3080.  The LT3080 is thermally protected right?  Well only you a point. In thermal limiting mode, the LT3080 chip is at 160 degC. The Absolute Maximum operating temperature of the chip is 150 deg C. Translated into english, that means Do Not Rely On Thermal Limiting for Normal Operational Modes. In a Lab power supply, difficult loads are a normal operating mode. The whole idea of a Lab supply is it is meant to be able to cope with difficult loads without failing. The thermal limiting of the LM317 chip has the same concerns as the LT3080
  • The LT3080 requires a reverse bias bypass diode across the LT3080 to prevent damage from voltages coming from the load. I like the rather unique property of the LM324 in that is can take over 30V on the input pins even when the LM324 is unpowered, so I can avoid the need for this diode. With the reverse diode solution, I do not like the fact that attaching a 12V SLA battery to the supply while it is off basically powers up the power supply. But this is my preference - not really an issue I want to get into a big discussion about. People choose different colours to paint their house - it does not mean that one colour is right and another colour is wrong - they are just different colours

That list will do for the moment. The LT3080 is a brilliant chip, and Dave chose it for very good and sound reasons. My board is a different solution that will have its own positives and negatives.

Just to go back to the start, I was frustrated with the number of times people had to go to the LM317 IC to make a cheap power supply as it does not make a great lab supply. I initially wanted to see if I could come up with some kind of general purpose regulator board that could be used to make different supplies with different output ranges and current ranges without needing to design a new compensation circuit each time.

It looks like it just cannot be done - change a voltage divider or a regulator power transistor and you need to redesign the compensation. A really well designed power supply compensation circuit is very hard to do for any power supply as all lab power supplies relying on a feedback stabilization operate very close to instability. It is something impossible for beginners to get right, and it can be very time consuming to get right for experienced designers.

The reason why devices like the LM317 are so popular is they have built in compensation. Not perfect for all capacitive loads, but pretty good. The LT3080 also has excellent built in compensation.

There are IC's available that can drive an external MOSFET to make a linear supply, but I really do not like lab supplies using MOSFETS. The thing I just do not like is that if you switch a sudden overload on to a MOSFET supply, the Miller effect causes turn the MOSFET hard on causing  peak current in the 10s to 100s of Amps regardless of your current limit setting. This big current spike is something that can easily be eliminated in transistor-based supplies, but it is extremely hard to prevent in MOSFET based linear supplies. I have chosen to stick to transistor-based supply designs.

Inspired by some ideas in Dave's design - in particular the fact that the regulator was always adjusting for zero difference between the reference voltage in and the out voltage (no voltage dividers, so no loop gain change for different output voltage ranges) and the fact that the the supply to the reference circuit was allowed to change with the required output voltage - I started looking at a regulators board made from common parts that are extremely cheap to make a fully compensated module, and then work out how to add extra external parts to extend the range without affecting the regulation compensation.

Compensation ends up being much harder then looking at Bodes plots and getting the zero's and poles right. Things change for different currents, different voltages, different load capacitances, and even if you get stability with all those variations, then you have to look at conditional instability. If you tailor a load to force the regulating opamp into output slew rate limiting, you have changed the loop gain and opamp speed, and this can cause an instability that is not there with static loads. If you can force the opamp to saturate - more problems. Power supply compensation circuits can look simple when completed, but it can be a total nightmare finding that right solution. I bet there are many commercial lab supplies that are conditionally unstable and this is one of the things that separates the $1000+ quality designs from the $100 designs.

My board can be used directly to make a 0 - 22V 210mA supply or a 0-6V 800mA supply , and with an NPN darlington preregulator transistor, it could be extended to 0-25V at 1A. My latest idea would allow it to be extended further to almost anything -  in theory you could make a 0-1000V 1A supply. I will probably limit any designs to 60V maximum myself, but that will not be limited by my board.

I would be prepared to use my board to make an internal HV supply inside another project, but a HV lab supply is extremely dangerous - I really caution against the idea.

If I can get the module paralleling to work, then you can get 2, 3, 4 amps out and the modules will be cheap enough to make this economical.

All these supplies will regulate fully down to 0V.

At the moment, it is really hard to find any kind of generalized design that allows you to make a supply with exactly the voltage and current specs you need. Hopefully, this design will mean that there is at least one option available.

Richard.
« Last Edit: May 17, 2012, 04:38:33 am by amspire »
 

Offline markus_b

  • Regular Contributor
  • *
  • Posts: 115
  • Country: ch
Re: General Purpose Power Supply Design
« Reply #209 on: May 17, 2012, 08:47:30 pm »
Richard,

You make an, excellent argument, way out of my league and experience to argue!

Personally I'm gunning for 30V/3Amps, sort of what a LT3083 can do. While it is a fine chip, it will have the same short comings as the LT3080 which you elaborated on.

A switching pre-stage will be an essential tool to get reasonable heat dissipation. The linear stage should only have to cope with 2V or so to keep the power losses down.

 I'm working on my own solution, using a 3080 for now, will show my hand when I'm confident not to be laughed out of the forum right away. :-).

Markus
Markus

A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #210 on: May 17, 2012, 11:15:11 pm »
Richard, thanks for posting the update, I did capture in ltspice and it seems like the lowest current in CC mode is around 700ma even the VRef for the current was set below 700mV like below example.

Any idea why ? Glitches at ltspice ?

Also attached the ltspice for the below circuit.

« Last Edit: May 17, 2012, 11:21:11 pm by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #211 on: May 18, 2012, 12:12:49 am »
I did a few late changes without testing properly. I had reduced R10 to boost the drive current and I forgot to reduce R9. Make R9 330 ohms. Also add a 470 ohm from the output of U2 to ground.

When I finish my modifications, I have to go back and tweak the circuit a bit so there will be changes. I am sure I will change the current control a bit.  I will have to get my hands on a batch of PZT2907A and 2N2907A's to work out what gain I can expect for the range of 0.5V to 2V Vce. There are no specs for gain at low voltages, but it looks like gain of the 2N2907A is still very good at 1V.  The properties at about 1V will determine how much current I need through Q9, and after getting that right, I then have to tweak the compensation again.

It is one thing getting a design. it is another thing getting it to work with all the possible component variations.  This is a very much part time project, but I will try and get the bulk of the final circuit worked out over the next few days.

Richard.
 

Offline sorin

  • Regular Contributor
  • *
  • Posts: 247
  • Country: al
Re: General Purpose Power Supply Design
« Reply #212 on: May 26, 2012, 12:43:20 pm »
What method you have used to calculate the value of PI regulator (R13,C1 ; R14,C2)???
thank you!
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #213 on: May 27, 2012, 12:11:22 am »
What method you have used to calculate the value of PI regulator (R13,C1 ; R14,C2)???
thank you!
I used LT Spice to open up the control loop ( a bit like a network analyzer) so I could look at the loop gain and phase. I then tried to adjust for a maximum phase shift of under 80 degrees from 100Hz to the unity gain point with no capacitors on the output (or less then 170 degrees with a huge lossless capacitor on the output). Many supply designs depend on a zero on the output caused by the esr of the load capacitance, and I am trying to avoid that so it will be stable with any capacitance.

To open up the loop, I add a resistor (perhaps 1Mohm) between R20 and the output, feed a signal source onto R20, and look at the output.

I will do something similar on the bench when I get to build a prototype, but I have been struggling to get time to work on this for the last couple of months. The bench work will be important as there is just not enough data in the datasheets to be able to do an accurate paper design.

It sounds like a fairly simple project and perhaps for a one off build, it would be. It is surprising how much work it takes for a really solid design that works with component variations and my design has always been more of a design exercise rather then a commercial product. Power supplies really do operate on the margins of stability which makes them much more work then you might expect. With a fixed load, it is not hard to get stability. With any load, it is hard.

Richard.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #214 on: May 27, 2012, 01:35:30 am »
Richard you might want to consider something like a NJT4031NT1G.
150mVcesat @1A
 
http://canada.newark.com/on-semiconductor/njt4031nt1g/bipolar-transistor-npn-40v-sot/dp/57M9869?ref=lookahead

An NPN pass device would simplify trying to compensate for every conceivable load, and esr  combination. The other advantage is no wasted base current.

I don’t think I’ve seen a GP Lab PSU with a PNP or PFET pass device, mind you I haven’t seen hundreds so who knows.

For those who don’t understand why Richard is having difficulty here is an application note from NATIONAL now TI.

www.national.com/an/AN/AN-1148.pdf
Thanks. That is a great transistor at a great price.

If you go back to the start, I did start with a NPN pass transistor, but it doesn't work as well as a PNP for low dropout mode (this power supply is always working with a low dropout). Of course the configuration can be changed to make it more conventional, but I really like many aspects of this low dropout configuration with the regulation that requires the output is the same voltage as the reference voltage.

What I found is that the PNP pass works great, as long as I can drive the base directly and do not use a darlington configuration. The moment I go to a darlington configuration, the compensation becomes far more critical.  PNP pass designs are widespread in IC regulators and they do perform well if you are driving the base with a current source. With the low dropout, I think the input noise rejection performance at higher frequencies was much better then the NPN circuit.

There are a small number of very high gain transistors, but I decided to really aim at common, extremely cheap parts. Why? I just decided to do it that way. Every time you replace a pass transistor, you have to restabilize the loop. 2907A transistors will always be available from many sources.

Will a njt4031nt1g transistor always be easily available? I doubt it.  Can I substitute it with transistors from other manufacturers without a redesign? Probably not.

The really big problem is that the manufacturers have lost interested in development on new discrete transistors which is a pity. New transistors are being developed all the time - in IC's. I cannot think of the number of times I wish I could get a discrete transistor that matches commonly used IC transistor. The super-beta transistors, the schottky base transistors, the transistors with a 30V base breakdown voltage, super matched transistor pairs, extremely low geometry transistors that work well down in the nA currents, multiple emitter transistors and multiple collector transistors. The standard CA3046 transistor array used in hundreds (thousands?) of analog scope designs has even been slated as obsolete and the supplies are disappearing. The manufactures could make something far superior to the ancient CA3046 today, but they don't bother.

The message is clear - mass production designs use IC's. The need for these devices as discreet designs have too low a volume to be worth much new development.

Richard.
« Last Edit: May 27, 2012, 01:45:07 am by amspire »
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #215 on: May 27, 2012, 09:04:37 am »
I don’t think I’ve seen a GP Lab PSU with a PNP or PFET pass device, mind you I haven’t seen hundreds so who knows.
Agilent E361XA dc linear bench psu series uses mosfets like this below, partly captured schematic on the linear pass section :



The complete circuit is in here -> http://www.physics.fsu.edu/users/Wahl/labmanuals/instruments/ps/AgilentE361xAManual.pdf

I'm not qualified to comment though, but I'm guessing this must be good enough that made Agilent used this technique. Really eager to hear from experts on this linear pass configuration.

For those who don’t understand why Richard is having difficulty here is an application note from NATIONAL now TI.

www.national.com/an/AN/AN-1148.pdf
Thanks, good reading.

« Last Edit: May 27, 2012, 01:31:43 pm by BravoV »
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #216 on: May 27, 2012, 02:39:57 pm »
Bravo,

The  HP/Agilent supplies are more conventional with enough extra supply voltage to drive NPN darlington pass transistors (in 3610A and 3611A) and MOSFETS (in 3612A). Definitely not a low dropout design, and as usual with HP, the custom transformer with a separate winding for the regulator circuit.

I still think transistors are superior to mosfets in terms of the current spike problems of mosfets when the output voltage drops suddenly. If I had to use mosfets, I would use mosfets, but if I have a choice, I use transistors.

The interesting thing is the manual shows three different voltage/current supply combinations all based on the same circuit and perhaps the same PCB. If you look, there are extensive component changes between the models, including all the compensation components.

That is the traditional problems of all supplies - change anything and the changes tend to cascade through the whole design. That is why it has been so hard finding a general purpose design.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #217 on: June 02, 2012, 05:54:05 am »
Richard, about finding the "right" compensation component's value, how hard is that ? Say I have a nice high power PNP with high beta even at high current instead of using multiple 2907s.

Will through trial & error with different compensation values possible ? Any guideline how to find them ? or its way too complicated for a hobbyist level ?
« Last Edit: June 02, 2012, 05:58:06 am by BravoV »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 9608
  • Country: us
Re: General Purpose Power Supply Design
« Reply #218 on: June 02, 2012, 06:15:54 am »
Richard, about finding the "right" compensation component's value, how hard is that ? Say I have a nice high power PNP with high beta even at high current instead of using multiple 2907s.

Will through trial & error with different compensation values possible ? Any guideline how to find them ? or its way too complicated for a hobbyist level ?

Broadly speaking I imagine this is difficult. This meaning of this magic "compensation" word is sometimes lost or not understood with overuse or use without definition. I'm in that boat. My understanding is that it means compensating for an unstable loop gain at certain frequencies.

However, stability is not the only goal. Achieving a loop that is stable under all circumstances is easy. They key thing is to make it stable while also responding fast enough to changes to keep things under control (supply changes or load changes, but especially load changes). If the circuit responds too slowly it ceases to be useful and so mere stability is not sufficient for success.

It follows that the design becomes something of a balancing act, sitting on a knife edge. Too far one way and it responds too slowly. Too far the other way and it is unstable. Given the nature of this balancing act trial and error is going to be difficult. You really need some analytical tools in your toolbox combined with some practical experiments to test the results.
I'm not an EE--what am I doing here?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #219 on: June 02, 2012, 06:22:09 am »
Richard, about finding the "right" compensation component's value, how hard is that ? Say I have a nice high power PNP with high beta even at high current instead of using multiple 2907s.

Will through trial & error with different compensation values possible ? Any guideline how to find them ? or its way too complicated for a hobbyist level ?
The moment you change the transistors, you need to recompensate, and many of the PNP medium power transistors are slower and much harder to get a good broad compensation. I chose the 2907A as they really behaved very well. Trial and error s not always great, as it is really easy to get a conditional stability - it is stable until the right combination of load parameters, and then it is unstable.  Particularly this is an issue with loads that include low ESR electrolytics across the supply.
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 165
  • Country: br
Re: General Purpose Power Supply Design
« Reply #220 on: June 02, 2012, 10:23:06 pm »
Here is the C code with the assembler the compiler generated:

Code: [Select]
ISR(TIMER2_OVF_vect) {

  OCR2A = (byte) (pwm_accum / 0x01000000L ) ;  // 16 cycles
  pwm_accum &= 0x00FFFFFFL ; // 7 cycles
  pwm_accum +=  value ;  // 11 cycles
}

Is that all the code needed for the 24 bit PWM? You se the value you want in the main loop and thats all?
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #221 on: June 02, 2012, 11:09:10 pm »
Here is the C code with the assembler the compiler generated:

Code: [Select]
ISR(TIMER2_OVF_vect) {

  OCR2A = (byte) (pwm_accum / 0x01000000L ) ;  // 16 cycles
  pwm_accum &= 0x00FFFFFFL ; // 7 cycles
  pwm_accum +=  value ;  // 11 cycles
}

Is that all the code needed for the 24 bit PWM? You se the value you want in the main loop and thats all?
Other then the setup code for the PWM and the interrupts, yes - that is all the code you need.

You have to make sure that no other interrupt routine is able to stop this interrupt from running and completing before the next PWM interrupt is due.

So either other interrupts have to be very short, or other interrupts have to re-enable the PWM interrupt in their first line of code so they will not block the pwm interrupt.

If the "value" is being changed regularly in the main loop, you may need some extra code to ensure that all bytes of "value" are written before the PWM interrupt is called. There are several ways to do this, but one way would be for the PWM to maintain a buffered copy of "value", and the PWM would look for a flag to indicate that a new "value" is available. This would mean an extra "if" statement is added to the interrupt routine.

If value is not changed regularly, you can probably live with any slight error in the output for one PWM cycle as value is changing. The effect will be hard to notice anyway and it is probably not worth worrying about.

Richard.
« Last Edit: June 02, 2012, 11:52:06 pm by amspire »
 

Offline m12lrpv

  • Regular Contributor
  • *
  • Posts: 153
  • Country: au
Re: General Purpose Power Supply Design
« Reply #222 on: June 03, 2012, 12:19:13 am »
Is that all the code needed for the 24 bit PWM? You se the value you want in the main loop and thats all?
Here's a full test sketch I put together for a 12 bit implementation of this (I didn't need 24 bit).

I've already thanked Richard for developing this. The results are nothing short of brilliant.

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <digitalWriteFast.h>

LiquidCrystal_I2C lcd(I2C_ADDR,16,2);

unsigned int VoltageValue = 0;
unsigned int pwm_Voltage_accum;

void setup()
{
  lcd.init();                      // initialize the lcd
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
 
  pinMode( 13, OUTPUT );
  digitalWrite( 13, LOW );

  pinMode(A0, INPUT);

  SetupTimer2();

  VoltageValue = 4000;  // pin3

  digitalWrite( 4, HIGH );

}

void loop()
{
  int i, j;
  String TempString;
  int sensorValue = analogRead(A0);   
  sensorValue = analogRead(A0);   
  sensorValue = sensorValue + analogRead(A0);   
  sensorValue = sensorValue /2;
  lcd.clear();

  lcd.setCursor(0, 0);
  TempString = "A0 = ";
  TempString += sensorValue;
  TempString += "  ";
  lcd.print(TempString);


  delay(2000);
}

void SetupTimer2() {
  // Disable interrupts while setting registers
  cli();

  TCCR2A = 0xA3;
  VoltageValue = 0L ;
  pwm_Voltage_accum = VoltageValue ;
  TCCR2B = 0x01;  //1 gives no prescale 
  TIMSK2 = 0x01;   // Enable interrupt when Timer reaches OCRA
  sei();

}
ISR(TIMER2_OVF_vect) {
 
  //OCR2B = (byte) (pwm_Voltage_accum / 0x010L ) ;
  OCR2B = (byte) (pwm_Voltage_accum >> 4 ) ;  //Reduce from 12 bit to 8 bit
  pwm_Voltage_accum &= 0x00F ;
  pwm_Voltage_accum +=  VoltageValue ;
  if( pwm_Voltage_accum > 0xFFF ) pwm_Voltage_accum = 0xFFF;
}

 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #223 on: June 03, 2012, 01:11:17 am »
I've already thanked Richard for developing this. The results are nothing short of brilliant.

Don't forget to thank George (A Hellene) for all the research and work he did in developing this PWM code.

By the way, if you are using  this PWM code, you have to check for the use of delayMicroseconds() in other libraries. This is the No1 source of errors for this routine on the Arduino.

delayMicroseconds() disables interrupts for the period of the delay. The Arduino LiquidCrystal library includes some very long delays involving delayMicroseconds(), and in my test code, I made a new local copy of LiquidCrystal.cpp and  LiquidCrystal.h (that I renamed) and I changed all the delayMicroseconds() calls (excluding calls to delayMicroseconds(1) - I do not change them) to calls to this new delay function:

Code: [Select]
void delayMicroseconds2(long delaytime) {
  long j;
  for (j = 0L; j <= delaytime/2L; j++)delayMicroseconds(1);
}

Not as accurate, but it allows for other interrupts to be serviced during the delay. This was just a quick hack to fix the problem, but it is not the best solution.

There is a better discussion of the issue at:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1248706486

It is possible to drive a LCD with no lost PWM interrupts.

Richard.
« Last Edit: June 03, 2012, 01:19:49 am by amspire »
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1414
  • Country: dk
Re: General Purpose Power Supply Design
« Reply #224 on: June 03, 2012, 05:58:53 pm »
Regarding delays on the AVR
This is still the best (most accurate delay lib i have seen) for an AVR , if not using timers.

http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=665&item_type=project

/Bingo

 

alm

  • Guest
Re: General Purpose Power Supply Design
« Reply #225 on: June 03, 2012, 08:11:45 pm »
What's wrong with the standard avr-libc util/delay.h?
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: General Purpose Power Supply Design
« Reply #226 on: June 03, 2012, 09:03:52 pm »
What's wrong with the standard avr-libc util/delay.h?

For most practical purposes nothing. Under some circumstances the delay in avr-libc gets a few clock cycles wrong (thing of a kind of rounding). But that is irrelevant for most applications, because the surrounding code anyhow uses an unaccounted number of cycles. E.g. if you wrap the delay in some function, the calling of the function can anyhow (but must not) require some time. Or if you wrap the delay in some condition (if(x) delay(100);), the if() adds an unaccounted number of cycles.

As a rule of thumb, delays are not the right way to ensure clock cycle precise timing in an embedded C application. If you need it, you either have to study the resulting assembler code or directly write in assembler.  More often than not delays are anyhow used because the application's architecture is messed up. E.g. someone desperately trying to avoid a timer and interrupts.
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 amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #227 on: June 04, 2012, 12:05:20 am »
What's wrong with the standard avr-libc util/delay.h?
I haven't looked at the code. If the standard avr-libc delay routines do not disable interrupts, then they might be great. If they do disable the interrupts during the period of the delay, then they are useless.

What's wrong with the standard avr-libc util/delay.h?
As a rule of thumb, delays are not the right way to ensure clock cycle precise timing in an embedded C application. If you need it, you either have to study the resulting assembler code or directly write in assembler.  More often than not delays are anyhow used because the application's architecture is messed up. E.g. someone desperately trying to avoid a timer and interrupts.
When you are writing general purpose routines designed to be able to run together, then as much as possible, you do not want the libraries to require any dedicated timers or interrupts. The moment two libraries both require Timer1, then they cannot be used together.  If the timing requirements are not critical (like a minimum settling time in a hardware handshake), the use of delay routines is an excellent solution by any programming "rule of thumb" in a simple dedicated microcontroller usage. It is just a matter of the best compromise. The Arduino LiquidCrystal library is a good example, because who wants to loose a timer or a hardware interrupt just to talk to a simple LCD module?

The issue is that if you write an delay routine to be very accurate, you have to disable interrupts. If you write a delay that is good enough to ensure a minimum settling time has passed, then you can allow for interrupts to stay enabled during the delay.

Two different delay routines are needed for the two different situations, and there is no way you can find one single perfect solution.

Richard.
 

Offline BravoV

  • Super Contributor
  • ***
  • Posts: 6452
  • Country: 00
  • +++ ATH1
Re: General Purpose Power Supply Design
« Reply #228 on: June 17, 2012, 08:05:15 am »
Bump just hate to see this nice thread buried deep down there.  :P

Richard, understand you're still working on the linear front end part, any chance you could share the current pwm digital + vref generator module that you're currently using ?
« Last Edit: June 17, 2012, 08:06:54 am by BravoV »
 

Offline GK

  • Super Contributor
  • ***
  • Posts: 2604
  • Country: au
Re: General Purpose Power Supply Design
« Reply #229 on: June 18, 2012, 07:24:32 am »
The conclusion is that for most power supplies, if it is stable with a 100,000uf capacitor under all output voltage and current conditions, it is probably going to be stable for most other loads.


Not really.

Suppose you have that 100,000 uF capacitor connected with 0.005 ohms of total lead resistance. Neglecting the capacitors ESR, that gives you a zero already at 318 Hz.

318 Hz is likely to be much lower than the unity loop gain frequency of your power supplies control loop, so in effect, that 100,000uF of capacitance plonked on the output will not degrade the control loops phase margin at all.
Bzzzzt. No longer care, over this forum shit.........ZZzzzzzzzzzzzzzzz
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #230 on: June 18, 2012, 08:44:54 am »
The conclusion is that for most power supplies, if it is stable with a 100,000uf capacitor under all output voltage and current conditions, it is probably going to be stable for most other loads.


Not really.

Suppose you have that 100,000 uF capacitor connected with 0.005 ohms of total lead resistance. Neglecting the capacitors ESR, that gives you a zero already at 318 Hz.

318 Hz is likely to be much lower than the unity loop gain frequency of your power supplies control loop, so in effect, that 100,000uF of capacitance plonked on the output will not degrade the control loops phase margin at all.
When you put a 100,000uF cap on the output, the unity gain of the control loop often drops to a low value - probably under 318Hz.

Anyway, you can get caught out if you think the power supply can only oscillate at the frequency where the control loop gain is unity, as virtually any frequency below the unity gain frequency can become a unity gain frequency - if the control loop is allowed to saturate. The only way to make sure a power supply is unconditionally stable with all capacitive loads is to make sure that total phase shift is less then 180 degrees at all positive gain frequencies. This means that without any output capacitor, the phase shift should be less then 90 degrees for all frequencies below the unity loop gain frequency. This is often not possible.

So lets say in the example you gave, the unity gain point was 400Hz. In this case, the zero at 318Hz would really help to make the supply very stable at 400Hz.  The supply may still be able to oscillate at 10Hz if at 10 Hz, the total phase shift reached 180 degrees. The small signal loop gain would be up around 30dB, but if the loop is driven towards saturation, then the effective gain starts to drop down to 0dB allowing an oscillation.

When you have a conditional instability, the supply appears to be totally stable, until it has just the right kind of load to trigger the instability. Often a load with a pulsed overload current at just the right frequency will trigger the instability.

Many supplies may be unstable with a big capacitor, and you probably would not notice. There may only be a 1mv triangular wave effect of the oscillation on the output DC volts, but if you look at the regulating opamp, it is a square wave out. The frequency can be low - even below 1Hz. It is still better to try for stability.

Richard.

 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3787
  • Country: au
Re: General Purpose Power Supply Design
« Reply #231 on: June 18, 2012, 08:56:13 am »
Bump just hate to see this nice thread buried deep down there.  :P

Richard, understand you're still working on the linear front end part, any chance you could share the current pwm digital + vref generator module that you're currently using ?
I have slacked of this design a bit, as I have been thinking about a few other devices, and I was thinking about giving them a common design appearance.

A great way to manage the voltage and current setting still eludes me a bit, so I haven't rushed into a final control panel design, until I get inspiration.

This was never intended to be a commercial product, so it has been a design I do when I have the time. The type of build I was thinking about was something simple and functional, and I would leave it to others if they want to make it look more professional.

Richard.
 

Offline GK

  • Super Contributor
  • ***
  • Posts: 2604
  • Country: au
Re: General Purpose Power Supply Design
« Reply #232 on: June 18, 2012, 09:13:19 am »
Quote
When you put a 100,000uF cap on the output, the unity gain of the control loop often drops to a low value - probably under 318Hz.


It could; it all depends on the open loop output impedance of the supply. The only real point I would like to make here is that putting a really large capacitor on the output of a power supply isn't a very good stability test. It is typically not a really small or a really large value of capacitance which causes stability problems; it is usually a range in the middle.

I certainly wasn't suggesting that a conditionally stable contol loop (that being one in which the loop phase dips below +180 degrees at some point prior to the unity loop gain frequency) cannot oscillate under some conditions (such as control loop saturation); you've gone off on a bit of a tangent there. However since you bring it up, there are actual means of mittigating the dangers of conditionally stable loop and they do in fact have some benefits (such as greater loop gain prior to the ULGF due to a >1 pole roll of