Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR]MCU controlled power supply project, thoughts of structure and communication.

Not open for further replies.


Advanced Member level 2
Dec 6, 2013
Reaction score
Trophy points
Activity points
Hello everyone.

I am designing a lab power supply that will be controlled by a AVR micro-controller, but I am not very knowledgeable regarding MCUs and I have some different approaches to how to implement the control part of the circuit.

The supply has two identical isolated channels(0-30V/2,5A), the output voltage and the current limit is set by individual one channel DACs and the output voltage and actual current through the rail is read by a 4 channel ADC. The channels are isolated and the digital communication is being transferred with a digital isolator and all chips are using I2C.

I found online a person how has done a very similar project and I am using the same ADC as he is, MCP4324.
Its a ADC that can read in 18, 16, 14 and 12 bit mode but he found that the 18bit mode was to slow and he had to go with 16bit.
However I'm not really satisfied with 16bit ADC reading, as the first MSB bit is used to indicate polarity the circuit can set the voltage in 65,536 steps but only read the output in 32,767 steps. MCP3422 is rated with 3,75SPS for 18bit and 15SPS for 16bit.

I am going for as high precision as I can possibly get and the first thing that comes to mind is speeding up the communication?
I am using arduino IDE and if I'm not mistaken the Wire library(I2C) is going at 100kHz as default, if so the chips I use can support up to 400kHz, that might help some.
Or I might look for new ICs that use SPI instead, am I right in thinking that if I would use SPI communication the over all preformens of the system could be increased?

If so a idea could be to use two smal uCs, one for each channel to monitor its channel and report to a master that takes care of LCD and such. As it is now ATmega328 won't do it and I am currently designing with a ATmega 2560 in mind. It would save me some hazzle by using two smaler to controll each channel and one 328 to control user interface.

All thoughts is appreciated.

18bit is an extremely high precision, even a 75,000$ oscilloscope from Agilent does not support an 18 bit vertical resolution!
The resistors and other components in the circuit will limit precision much before the ADC's limit.
What is the maximum error percentage that you desire?
  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating

mrinalmani is right.

Additionally iwant to say: Resolution is not equal to precision.

I recently used an ADC with 18 bits but didn´t read dataheet carefully. There they speak of 14 ENOB. This is exactely what i see in the digital data.
So i´d better used my good old 16 bit ADC that is really stable down to 16 bits (with same analog bandwith and sample rate).

For me the results of the 18 bit adc is the same as with a good 14 bit with appending 4 bits of random LSBs.

Back to your application.
Usually a 30V, 2.5A Supply is built with SMPS. Did you consider voltage ripple at the output with
* no load (maybe burst operation mode)
* and full load
In both conditions you have to develop your power supply very carefully to get 12 bits precision.

But on the other hand i don´t want you to stop your project. There is always a lot to learn.
And YES, go for precision. (If you want to build a low cost solution, then it´s better to buy a cheap one and save time and money.)


Let us know how things develop.

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
Then I will settle for the 16bit ADC, MCP3424 it seems very nice with self calibration of internal offset and gain per
each conversion. As far as maximum error percentage I have not put up a specific goal, when I begun this project was a massive undertaking and beside a basic lm317 part of the circuit(to get a +5V rail) everything is new. But from the start I wondered what kind of precision that I could achieve and without having a goal I have gone with pushing the preformens as far as I possible can, but now that the question arose I will take a moment to research what is available commercially and then set out to determine my goal.
This hole thing will be used in general experimenting as I learn, I have been occupied with this project for a while but I have many experiments with magnetics and other things that I would like to preform but I felt that it all needs to start with a power supply that I can trust and that will be "exact", so I am willing to design a supply that is not optimized to draw as little power as possible as long as output noise, accuracy and stability is as good as possible. It has been as expected a great way to learn and although I have come to realize that this approach might not be in the end favorable I do plan to finish it as learning have come to be the main point. But it might turn out that it is a better idea to finish this project meaning to get a working prototype but not to produce the hole thing in full. And use a better solution for a full power supply.
Is it a SMPS with post-regulation that is the usual way?

I have never done anything with data converters and the best way to learn is by doing something even if it's not the best way to do something i guess, I can think of many things that motivates this project but one main thing is that I need to learn programming. But as I suffer from ADD I really can't get anywhere with programming without a practical relation to the programming, hence this supply controlled by software.

I do prefer low-cost but it is in the end not something really important, I mean that even if I could by a thing to match my own and get away cheaper I still would like to do it on my own. Things like no-load, full-load and other conditions is something I can't find out until I have a prototype. I had strived to have a complete prototype to produce but I am now in the process of making a non-isolated version with one channel so I can make some real deductions about preformens, about time now. Just need to ensure access to my scope. I like to make it all smt but the first will not.
I have a arduino mega board so one channel does not need to be very complex, I can just find suitable DIP DACs and such and put together a working prototype even if the chips is not those I want in the end. I have a strong feeling that I will have put a lot of work and effort into something that will not turn out as expected, but learning do have a price sometimes and as long as I get away with knowledge it will be worth the effort.

In the datasheet for the TPS7A4701, the NOISE vs OUTPUT CURRENT graph is somewhat unclear to me.
The vertical axis have Noise (µV Hz) and the horizontal axis have Frequency (Hz), I don't understand what that represents.
Is it the amount of noise at different frequency's that is always present on the output?

Returning to the ADC, is it always such that 16bit gives 15bit data(first MSB being polarity) or is there any way to get 16bit data?
And regarding communication, it seems that it would be much better if the uC could receive and send data at 3MHz with ISP instead of 100-400kHz with I2C, I know I2C have a fast-speed mode that can go up to ~3MHz but the chips I use do not support more than 400kHz.
I don't know, this might be wrong but as it seems to me 3MHz speed would allow the uC to make many more corrections to the output than 100kHz could, if the regulator, DAC and ADC can react fast enough to make any differens. What time different data-rate actually reflect is hard for me to understand but I will begin with the uC and the go through all chips and note how fast they can react.
I guess that will determine if there could be a improvement to use more than one uC, small uC does not need to cost much at all. All peripherals is beginning to grow but I question if I can produce a fine enough PCB to use ATmega2560, I am really hold back by economy otherwise I had just printed out a overhead to find out. I got for free a very nice laser printer that is intended for office work but the darn thing refuse to work because the yellow color is no more, so to print a PCB version I need to spend money on a new ink cartridge and overhead paper for laser printers, and actual PCB, and flux. Since I have used all my materials I need to re-stock but as always $$$.

- - - Updated - - -

as for resolution I figured I would have a encoder with a push-button, one step would change with the push of the button between 0,01V 0,1V and 1V, so 100mV resolution is fine. But it will be interesting to see how I do achieve accuracy, 16bit DAC should enable a pretty precise 100mV step.

So in short, the minimum desired step is 0.01V ie. 10mV
The step size of different different ADC with a 20V input is:

10 bit = 19 mV error = 0.1%
11 bit = 9.8 mV error = 0.05%
12 bit = 4.9 mV error = 0.02%
14 bit = 1.2 mV error = 0.006%
16 bit = 0.3 mV error = 0.002%

Now, as you may notice, resolutions beyond 12bit are un-usably precise.
Resistors will limit your accuracy to 0.1% typical. In my opinion a 12V ADC is all what you need. It is still 5x more accurate than the limit imposed by resistors and other components. Extremely precise components with tolerances better than 0.1% are very expensive and also difficult to implement while maintaining the same accuracy.

A better way of achieving precision throughout the entire 20V range would be to use voltage dividers and NOT ultra-high resolution ADC.
Although high precision ADCs seem impressive, but extracting that precision on a practical level is not a cake-walk!
  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating

16bit DAC should enable a pretty precise 100mV step.

With 16 bit you have a resolution of 1mV with +/- 32V range.

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
I see, the one in my circuit right know use a voltage divider to get it down to below 2,048V.
I think I need to more seriously question my approach that the best possible without any hard take on what the choices will bring, though since this will be my first experience with data converter I am bound to learn quite a lot by my first circuit board. The part that is used simply has to be smd parts and as I will have to etch and solder it for real I can't make any educated deduction before I get my hands on the boards, or should I say informed deductions.

As for the resolution I'm not quite sure, I have had and still do have some real problematic problems:) with the keyboard that will be used to enter desired output voltage and currents. I plan to open a thread about it tomorrow if I do not make any headway tonight, I can't really even plan the software without having a solid peace to start with and right now nothing works. I can't figure out or find on the internet a explanation on how to enter a float number in this case between 00,001(I think) and 30,000, and store that in a way so I can use it. Its done by char but storing each number in succession and with comma have turned out to be the hardest thing with this hole program, even though I know kind of how it will turn out I can't be sure if I will settle on that but know it seams that 00,001V will be the target. I'm not sure but I have a few sort of examples when I'd like to have 10mV instead of 100mV, or way not 1mV, as pointed out it is in my range, the final decision will come when I finally do get to program the DAC - ADC loop. First then will I properly get my head around the values and there implication on performens.

I really hate this keypad thing now, well might be a bit much but I can't wait to get into the program but the keypad input function stands in front of me like a big bully not letting me pass, but with persistence I shall prevail, I hope.

I've sorted out the encoders pretty much, the I2C is straight forward but the control-loop will be interesting. I have a few solutions to try out.

- - - Updated - - -

There are so much new and so confusingly many choices that has to be done all the time and there are no choices that I feel good to make half informed about what it will result in, so I might say some things and make points that is way of what I actually intend to go for. But all things will come into the spotlight in its appropriate time, or at a unappropriated time who knows.

- - - Updated - - -

I've found a example online, although I have not gone through the code and that I do not(jet) understand it all I am 100% sure that this code example holds the hole key for my keyboard application. Finally, even though it's not done I have to sleep before I can chew through it but its bagged and ready to use so that's solved.
If anyone have the same problem here's a great and after hour and hours of searching and reading I am almost convinced that this is the only place that it is actually explained(In arduino and in a application that is applicable to one like the one I will use)


I can't figure out or find on the internet a explanation on how to enter a float number in this case between 00,001(I think) and 30,000, and store that in a way so I can use it.
Store it as 16 bit integer in millivolts.

0mV to 32000mV.

Don't worry about the expected problems in advance. Doing things the first time always seems hard, but in the end you have learned how to do handle theese problems and suddenly the same problems seem easy.

Regarding precision:
You have a ucontroller and that eases things. In former one needs to build electronics and it was hard to calibrate each pot by hand with a screwdriver. With the micro you can do this automatically. Offset, gain... no problem now. As long as the values don't drift.
And even drifting values you usually can manage with a little hardware ad software.... but this is another story.

Have a lot of fun.
Good luck

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
Does the voltage supply to ADCs/DACs matter in regard to the precise voltage level?
Cous I have in place a LM317 circuit to set a +5V supply but it would be much easier if it could just as well be replaced with a +5V regulator, though these are not precision devices.

I've found this which gave me some inspiration:

Its a app note describing a "A standards lab grade 20-bit DAC with 0.1ppm/°C drift", it relies on a LTC2400 24bit No Latency Delta-Sigma ADC to control a "slave" DAC comprised of two 16bit DACs that work together to result in a 20bit DAC output.

I figure I will use LTC2400 or LTC2415 which has better specs but no offset calibration like LTC2400, LTC2415 is has double output rate compared to 2400 but as a result no offset calibration but offset should be easy to take care of my self.

I have read up on data converter noise and noise in general and I will pay attention to the layout so it will be interesting to see how high a resolution I can manage.

- - - Updated - - -

I am messing with resolutions that as it is now I have no means of measuring, but I will through the design pay attention to layout to minimize thermal noise and trace voltage drops.

As for other noise, if I have a voltage rail of 32Vdc with a 15µVrms and through a voltage divider scale it down to 2,5Vdc.
Would I also scale down the noise an equal amount?


the linear application note helped me a lot in understanding electronics, especially for precision signal processing.

To your question.
I don´t think it matters if you choose LM317 or other voltage regulators like 7805.
You need proper bypassing with both devices.

Also a good technique is to use separated RC combinations to devices for precision signal processing. At least splitting digital devices supply from analog devices supply.

The precison of DAC mainly depend on the reference voltage and less from the supply voltage.
Usually you may find that relative REF erros are transferred 1:1 as relative output errors.

With supply voltage you often may find a chart named PSRR - power supply rejection ratio. There you see that high frequency errors cause more errors in output than low frequency.
Therfore the need for filtering out HF noise in the power supply - with RC.

..and trace voltage drops...
this often causes gain error that can easily compensated.
But better to avoid an error than to compensate an error.

Would I also scale down the noise an equal amount?
From the sight as voltage divider it will be scaled down. But every resistor adds noise.
In my "1990 linear applications handbook" there is a very informative design note "DN15" called "Noise Calcualtions in OpAmp Circuits".
Google will find it for you..

..voltage rail of 32Vdc with a 15µVrms..
Here the bandwidth is important to know.

Layout: Groundplane, short traces to capacitors and device supply pins, avoid loops....
A defined "R" to the device supply (including C) helps to reduce ringing and other resonance effects. (resonace by loops of "Cs and the "L" of wire traces)

Seems you are doing a great job.
Good luck.

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
Thank God for application notes:) Its really incredible that all this information is available online, I've would be ****** without them. Although I had not until now thought of the idea to start of searching in a collection such as Linears app notes instead of googling specific topics.

In the test board design which I hope will be done soon I have a RC filter between the ADC/DAC reference regulators and buffer op-amps and I will add RC's to each of the data converters supplies. I have also added a RC filter on the output regulator's input, since the output current will go through a external pass element the current into the regulator should be low. And one more RC between the regulator output and the base of the pass element, though I have not jet calculated the values for the RC filters, could this be over kill?

Instead of using separate RC filter at the supply of every data converter why not put a active two-pole low-pass filter at the 5V regulator output? or a single pole.

I have been thinking about home made more than two layer PCBs, it would be some work but why not.
In order to improve the performans of this circuit it would be nice to have a power plane and a GND plane, or maybe two signal layers with a GND plane in between.

Say for example 3 layers, start with a double layer PCB and then on top of that a single layer glued on or something, one could use on singele side on each side of the double layer board. It will be a pain to assemble but not impossible, see illustration:
**broken link removed**

All vias is made with a pin or something, and the single layer board would need to be drilled in order to make room for the solder joints.

Might be something to try.

I have a thought about DAC DNL errors and how one would implement a "dual DAC", in a app note I found a implementation where there where two 16bit DACs who's outputs where combined in such a scale that there ranges overlapped to some extent in order to create a 20bit DAC output.

It uses a 20bit word for user input and one 24bit feedback word from the ADC output, they where then put through a code comparator to finally write the resulting 24bit values to the two DACs, but the comparator was in hardware in part and software in part. I will post the address to the app note below, it contains the hole code needed but as I am not that good at programming I have a hard time in getting any ideas from the code.

Any way, I am about to use MAX5217, its a 16bit DAC. There are another exactly the same MAX5215 that's 14bit, the 14bit versions DNL is quite a bit better than the 16bit's version. If one would use two 14bit version in parallel as the app note to create a 16, or 18bit output wouldn't the new 16bit outputs DNL be better than the 16bit version alone?

The concept is very interesting but I have a hard time determining if the comparator function is to refined for me to attempt my self, as well as if it can be done solely in software. I don't really understand or rather I can't think about binary numbers in such a efficient way as to understand how to implement such a solution of the bat, might someone have anything to say about how complex such a thing can become?

I am not opposed to some hard work but it would be nice to have any idea of its complexity before jumping in, in my current single DAC code I am using the arduino PID library. though if I use two DACs maybe two PIDs could be used.

First the needed value is calculated from user input(Set point, SP) and feedback(process variable, PV) to get the needed correction of the output(Error, Err). Put together Err and the previously written value, then to splitt that number into two exactly the same values and then adjust the accordingly to the low DAC and to the High DAC.

Could it really this easy?(see below):
Just get the resistor ratio right.


My hint: 16 bit is enough resolution.

the 14bit versions DNL is quite a bit better than the 16bit's version

i don´t think so:

at a 14 bit DAC the resolution is 1/16384 (= 1 LSB)
at a 16 bit DAC the resolution is 1/65536 (also 1 LSB)

but both LSB values differ. the 16 bit LSB is 1/4 of the 14 bit LSB.

Therefore the 16 bit DAC is the better (but only marginally. With INL at the typ..values, with DNL at the min/max values).

but 4 LSB at a 16 bit DAC is only 0.006%.
If you want to build a +/-30V supply then this is only 2mV.
30.000V or 30.002V both gives a "30.00" reading.

In my eyes this is more a "nice looking value" than a really needed precision.

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
I know its stupid but I am always tempted to go for higher resolution, resolution is one such obsession that I want more and more:) And precision as a arbitrary thing can be pushed to far as well.

But I will go with the 16bit, I did not think about the facts you point out. I will terminate my thoughts about higher res and be perfectly happy with 16bit.

I have been reading to find out how to implement ferrite beads but it has raised several points that sound most concerning, I had thought simply to put a ferrite bead in series with a digital VCC to separate it from the other otherwise analog supplies. But know I worry of peaking if I go with a single bead with no other resistor or cap, a cap will be present anyhow.

But as to the cut-off frequency or the targeted frequency range, on one hand I think to check the relevant IC and see what freq its internal oscillator runs and to check at what speed the communication of the chip is being transmitted/received(this question is concerning the RC filters as well).
Knowing those two frequency I can set the RC/bead frequency to attenuate frequency a bit below that. For example to attenuate frequency's over 50kHz, or might I use a 1k resistor with a 100µF cap the set it to 1,59Hz or at least in the Hz range not kHz.

to get 1,59Hz response the area would be quite large but on the other hand it might be worth it. I really need to get my self some kind of spectrum analyzer, a DIY if not anything.


Be careful with LC filters. They have a resonant frequency. f = 1 / ( 2 × pi × sqrt ( L × C)), if i remember right.

You need some circuit to dampen the resonant. Either the load itself, a series R, an additional RC....

  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
I have been pondering the idea to use one of micro supply isolation devices(or whatever there calling them), I have not checked the price of this one but I just spotted LTM8057 on the back of LT Journal of....
Ether derive a isolated 5V directly from the raw rectified power rail or supply the isolator device from the analog regulated +5V.

Also I am more and more starting to think that its time for a redesign, there are to many small flaws in my design and it would be interesting to start looking at a switching pre-regulator. In "LT Journal of Analog Innovation, Volume 24 Number 2. July 2014" they present a complete solution for a portable DC bench power supply built with LT8612 "synchronous step-down converter" supplying two parallel LT3081 linear regulators, a LT3092 current source is inserting 2,4mA into the SET pins of the LT3081s in order to avoid output drift caused by temperature coefficient of the internal produced SET current. And there are a LTC3632 Synchronous Step-Down Converter controlling a NPN transistor that they are using to pull 8mA from the regulators output to enable 0V operation, I do not get how that part works jet but it sounds like a great idea. Emitter to supply output, Base to GND and Collector to LTC3632 5V output.
The circuit can be supplied with 10-40Vdc and provided that the input is above 36V it outputs 0-24V/0-3A.

It is not a circuit for me to use but it does give me a start for the pre-reg, although the LT3081s 0V is really attractive, but that would screw up my or klaus's fabulous approach to enable digital steering of regulators. It does not work for this kind of regulator but there might be a version for that, have not found a solution jet though, the cool thing with the LT design is that it does not require any heat sinks.

When looking for a SMPS pre-reg, the higher the frequency used the easier it is to filter the noise, right? Or at least it requires easier component values.

I still don't understand why you want a so accurate ADC.

If you want to measure the current, and you're controlling your output voltage with a DAC, you can separate the measurement scale in several ranges, for example: 0-5V --> 1mA max precision. - 5V-12V-> 3mA max precision. - 12V-20V ->10mA max precision. - 20V-30V-> 10mA precision.

That way you approach the whole ADC voltage operating range, before you had a high current divided by an accuracy, now you would have lower.

The same happens with voltage. By the way, don't you grieve but I think you are wasting your time and money with such an accurate output value measurement.

20mV, even 100mV doesn't affect most circuit working. Your DAC could be a 8-bit one and the same for the ADC, being honest I don't think you will worry about having 3mV less than you wanted.

If you want your ideas come to life fastly, you have to be practical, don't waste resources as time and money.

Good luck with that.
  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
I do agree with you, I feel rather slow when I fail to understand you scale range idea...

But I have found that pushing the limits is a very good way for me to learn and it really forces me to educate my self about all aspects in regard to a successful high res design, and also I am sure I'm wasting some time and perhaps money but I'm fine with that.
I am but in the beginning of what is supposed to be my carrier and I could do it as per the advice I have received here and it would be just great, but I would still wonder about how high I can go and I would certainly miss some valuable lessons as to why its not possible to do it this way.

So I guess in a way I am aiming for failure:)

You are right, if you are learining design skills the best thing you can do is trying to do things better. You also have to consider the costs, like prices, space, power consumption and all that stuff, if you wanted to design for manufacturers in a future.

If you find this useful, something I do to learn more is trying to do the same thing from different ways, and once I have designed a part of a circuit, I try to redesign it using less components, reducing the space and the failure probability. I also try to decrease the current (in case of using batteries you'll find that useful) and the product final cost.
  • Like
Reactions: David_


    Points: 2
    Helpful Answer Positive Rating
Good idea, I will use that approach.

Considering the cost of good voltage references I have been thinking about why I have one for a DAC and another one(exact same chip) for the ADC, its a chip followed by a low-pass filter followed by a op-amp buffer. And considering the cost of the reference and buffer and the boards space of the filters I thought why would it not be convenient to drive both converters from the same reference. I have forgotten why I did not do it like that from the beginning but can you see any problems with that idea?

Not open for further replies.

Part and Inventory Search

Welcome to