Check out Part 1 and Part 3 of the project
Introduction
After learning about the problems with the ADC and DAC of the XMega I gave up building this power supply until recently when I decided to see for myself how bad things are. I’ve used the header board, a 2.56V reference some potentiometers and a lot of patience.
DAC
On the DAC side things are quite ok. The minimum output is about 30mV for 0 loaded into the DAC register. Using the factory data to compensate decreases the output for 0 to about 10-12mV, but it is useless since some code values afterward are outputting bad values until it gets to about 100mV when things start to be ok. I’ve tested the DAC for about 40 values throughout the scale (some far from each other, some close) and after manually subtracting the offset it turned out that the DAC had a consistent gain error of + 1.4 to 1.6% (using factory calibration data). So, all ok here.
ADC
I’ve used the recommended settings from here: Use it with external reference, differential mode and measure the ground level. PA0 is used for external reference, PA3 is connected to ground and used as NEG input and the rest of the channels are used as POS inputs. PA4 is connected to ground for measuring the ground level. As it turns out, the ground level fluctuates around -5…-8LSB constantly. I am reading the ground level, then the desired level and subtracting. The result has a lot of noise, so I am averaging 8192 values to get a reasonably stable result. Probably better filter methods will require fewer readings. As with the DAC, I’ve used a potentiometer to feed the ADC different voltages and measured the results for about 50 points. Apart from the huge noise, the error stayed constantly below 1%, except for voltages below 20mV which had a larger error.
The prototype
With the above in mind it seems possible to use the XMEGA for a digital power supply. Just after the experiments I’ve discovered that the errata claim large errors for reference voltages above 2.4V so I’ve moved things to 2.048V. Since I didn’t have a proper reference IC, I’ve divided the 2.5V from a LM285 with a pot. With this in mind, my prototype could turn into a 0-20V, 0-2A power supply, with 0.01V setting resolution and 1mA current limiting resolution. But, given the DAC lower limit at about 30mV, the minimum voltage would be about 0.3V and the minimum current limit about 30mA. I can live with this.
I already had a prototype board from long ago (before my enthusiasm was killed by learning about the XMEGA problems), but some modifications were needed. The schematic evolved a bit from the ###previously mentioned prototype. Some additions were required to make the supply stable and adjust it to the above mentioned range. The board requires 5V input because it was meant to connect to a LCD too and has a 3.3V regulator for the XMEGA. For the high power part, I’ve used a 25V input from another power supply.
The schematic for the analog part is below, there’s nothing special about the digital part, I’m just using the USART to get data around.
The ADC connections are made as i’ve described at the beginning:
The prototype is built around a tool box, it’s not meant to take a final form as a working PSU. The goal was to put it together in a single piece so I could handle it easily.
Adjustments
So far the software is rudimentary, it just outputs a predetermined DAC value and reads the ADC and sends the corresponding voltage and current through a serial port to display on a computer. There are three adjustments to make. The first one is to set the reference to 2.048V (really high precision is not necessary since it is used both for the ADC and DAC). The second is to adjust the pot on the voltage divider for the voltage measurement. I set the supply to output about 10V then adjust the pot until the multimeter and the supply read the same value. The third is to adjust the current gain pot and it is done in a similar way: the supply is set to limit around 1A and then the pot is adjusted until it measures what the meter reads.
Once this is done, I set the DAC to 100 and measure the output voltage: this will let me calculate the voltage offset. Then I adjust the DAC value until I get 10V output. With these two values I can calculate what I have to put into the DAC to get any voltage I want. The same is done for the current limiting. For the prototype I am using a spread sheet to calculate the DAC value for the desired output value, but a final power supply will do this all on its own.
With the calibration done I’ve tested the supply for some common used voltages and the results are surprisingly good. Below 15V the error is maximum 10mV which is just as desired.
For the current limiting I get zero error for larger values (due to multimeter resolution limit) and a bit higher for lower values, but this is not a problem since the current limit is usually not required to be very precise.
Transient response
Below is a transient response when connecting a 10 ohm load when the supply output 10V, so a 1A load. As you might see, there is just a slight voltage drop at the output, but it stabilizes quickly. CH1 shows the voltage, CH2 shows the current with 1V/div = 1A/div.
With the current limit set to 1A, the supply is shorted through a 0.1 ohm resistor (which is used for current measurement) . There is a high peak due to the 100uF output capacitor and the supply’s response time. This peak may be reduced by reducing the output capacitor which is a thing that I will have to determine. The supply stabilizes to the set current limit in about 500us which is sufficiently fast.
The same situation as above, but this time the current limit is set to 0.1A. Again, there is a current spike due to the output capacitor:
The more common situation is when the supply has to limit the current but without having a short. The picture below shows what happens when connecting a 36 ohm load while it is set to output 10V and limit the current to 0.1A.
Conclusions
With these results in mind I think building this supply is actually achievable using the XMEGA. It can be done as a single board device and for a low desired power it can be made very compact.
Limitations:
– Minimum voltage is 0.3V (for 20V max scale)
-Output voltages below 1V will not be as precise as the rest (for 20V max scale)
-Minimum current limit 30mA (for 2A max scale)
-Output current limiting below 100mA will not be as precise as the rest (for 2A max scale)
-ADC needs a lot of samples to get stable results
Things to add for the final version
-lots of software
-temperature measuring for heat sink + maybe fan control
-soft output on/off
-bicolor LED for constant voltage/constant current
-display
-rotary encoder + buttons
-added bonus: 1-2 channel voltmeter: quite often I find that it is required to measure a voltage on the circuit that I am working on. Having this directly in the power supply helps a lot.
Hi Bogdan,
It’s not exactly in that way what I mean. I though that I could just multiply the ADC value with a fixed number and display that as a voltage on the lcd ou GLCD in my case, and the same for the amps. But it doesn’t work that way, because the relationship between what’s being output from the power supply and the ADC value in not linear. If you take the output voltage from the power supply and divide that by the ADC value, you get a specific number for a perticular DAC value, then you change the DAC value and do the same math, the specific number you get will not be the same. This is what I mean by not being linear.
So my question is how do you go about determining what value to set the DAC to, and how do you get a voltage reading on a LCD if the relationship is not by a fixed number. One way would be to use a look-up table, but then you need 2 of these table (one for the DAC and one for the ADC).
I hope that my explanations are clearer now.
Thanks Patrice.
Pingback: Digital Power Supply – Part 3: Concept comparison « Electro Bob
Hello Bogdan,
I’ve buildt your circuit, and it works.
But my results are not linear, what I mean is what I’m outputing from the DAC, and what I’m measuring from the ADC is not linear.
So I decided to look at your results, and I see that your are not also.
How can you display 20.03 from your measured ADC value, if the relationship between your DAC output and your ADC input is not constant.
My idea was to multiply the measured value by a fixed amount, and display that value.
Thanks for a great circuit, and taking time to share this with us.
P.S. My input voltage is also around 20Vdc, at the lower and higher end of DAC output the relationship between the DAC and ADC is about the same, but starts to change as the DAC output is going toward the middle range. The change in relationship is not random but slowly drift, then start to come back past the middle range toward the higher end.
Hi Patrice,
Are you talking about bigger error than what i got? (~30mV) ?
Hi Bogdan, this is an interesting project. Why did you decide you needed T9 and T10? Withoug T9 and T10, the op amps will still only need to provide 0.6V to turn the transistors fully on – well withing the 5V range you are designing to. I’m curious as to your design decision? Thanks for posting your design notes!
Richard.