Fully Programmable Modular Bench Power Supply – Part 7

Now I have the requirements for the control ranges I need its time to get down to the nitty-gritty and get a DAC up and running so we can make some measurements. The maximum dynamic range I need for this project is 6000 individual steps – this was identified in the calculations for the voltage control for the 0-6V rage in Part 5, so let us start there.

There are many options for DAC’s to choose from, I want to keep the cost and component count down so my starting point is a low-cost single component solution from Microchip, part number MCP4822. This is a dual 12-bit DAC with two channels and a built-in voltage reference. I get independent voltage and current control from one 8-pin chip – wow! However, there is a problem with this part, it only has 12-bit resolution which will only give me 4096 individual steps and my design calls for 6000. The problem with choosing components with a higher number of bits is that they start to get expensive. I want to see if it’s possible to extend the range of the DAC using software and a technique called “dithering” or “modulation”.

The idea here is pretty simple, to increase the resolution of the DAC you can continuously switch the output between two or more codes, feed the result into a low-pass filter and get the average voltage. If you switch between two adjacent codes with a variable mark space ratio like you do in PWM, it should be possible to extend the range of the DAC without creating large ripples on the voltage head making the low pass filter easy to construct. That is the theory at least, I need to try it and see what the results are in practice.

Before getting too complicated though, I thought it would be good to run the DAC in static mode, set some codes and measure what we get. The DAC has 4096 steps, the internal reference voltage is 2.048v and the chip has a x2 gain option so I should be able to program any voltage between 0v and 4.096v in 1mV steps by simply programming a digital code between 0 and 4096 into the DAC channel. To get this up and running I hooked up a PIC micro controller, the DAC chip and an RS232 serial interface. The firmware in the PIC will allow me to interact with the DAC through a simple serial terminal on my computer.

Before any MPS430, Atmel or Arduino die-hard fans start giving me advice on micro controller choice — forget it. They are all good parts, I just happen to personally like PIC’s because I know them and I have the tools and a whole bunch of them sitting here to play with – if you are not happy with my choice of micro controller thats tough…. I am not going to change it or enter into any debate over the pro’s and cons of other devices – I am sticking with PIC’s for this one and if you try to change my mind I will ignore you – sorry.

Here is the schematic diagram for the prototype I am using.

For the dithering I have decided to extend the DAC by 2 bits. Extending by two bits means I have to write a sequence of four codes continuously in succession to the DAC. I am writing approximately 1000 codes per second within a timer driven high-priority interrupt routine which ensures that the timing remains constant. Timing errors will introduce more DNL errors so the code stream needs to be constant and accurate. The codes written are the base code value followed by the base code value + 1. The two least significant bits from the now 14-bit word controls how many times each of the two values is written. For example, to get four steps between code 100 and code 101 we would write the following codes: –

100.00       100   100   100   100
100.25       100   100   100   101
100.5        100   100   101   101
100.75       100   101   101   101

Extending by 3 bits is an option and would mean I have to write a sequence of eight codes, again following the same explanation as above, here are the codes that would be written

100.00        100   100   100   100   100   100   100   100
100.125       100   100   100   100   100   100   100   101
100.250       100   100   100   100   100   100   101   101
100.375       100   100   100   100   100   101   101   101
100.500       100   100   100   100   101   101   101   101
100.625       100   100   100   101   101   101   101   101
100.750       100   100   101   101   101   101   101   101
100.875       100   101   101   101   101   101   101   101

I tried the three bits as an academic exercise but I have decided not to go to three bits because of the noise, ripple and integral errors generated. The cost of the filter circuitry and the expansion of the line items in the bill of materials would probably outweigh the cost of upgrading the DAC component to a higher resolution part.

I have selected a number of spot voltages in the range to benchmark what I get from the DAC. The following table sets out the results I measured. (I am using a calibrated HP 34401A meter for all measurements).

Spot Voltage DAC Code Measured
MCP4822
(12bit static)
Error DAC Code Measured
MCP4822
(14bit dith)
Error
0 0 0.0015V +0.0015V 0 0.0014V +0.0014V
0.001V 1 0.0015V +0.0015V 4 0.0016V +0.0002V
0.002V 2 0.0024V +0.0014V 8 0.0026V +0.0006V
0.003V 3 0.0034V +0.0004V 12 0.0036V +0.0006V
0.004V 4 0.0044V +0.0004V 16 0.0046V +0.0006V
100mv 100 0.1024V +0.0024V 400 0.1026V +0.0026V
500mv 500 0.5024v +0.0024 2000 0.5026V +0.0026V
501mv 501 0.5034v +0.0024 2004 0.5036V +0.0026V
1V 1000 1.0004V +0.0004V 4000 1.0006V +0.0006V
1.5V 1500 1.4975 -0.0025 6000 1.4977V -0.0023V
2.5V 2500 2.5014 +0.0014 10000 2.5016V +0.0016V
3V 3000 2.9993 -0.0007 12000 2.9995V -0.0005V
3.001V 3001 3.0002 +0.0002 12004 3.0005V +0.0005V
3.002V 3002 3.0012 -0.0008 12008 3.0014V +0.0006V
3.9v 3900 3.8968 -0.0032 15600 3.8969V -0.0031V
4.095v 4095 4.0916 -0.0034 16379 4.0916V -0.0034V

Well, that is disappointing given I am aiming for a precision of 1mV and to get a control voltage of 0-6V I need accurate 500µV steps. So whats wrong here? Having read the data sheet there are some gotcha’s that naively you might ignore as I did. Every DAC has two really important parameters called Integral Non-linearity (INL) and Differential Non-Linearity (DNL). The DNL defines the maximum deviation to expect from the “ideal” voltage for any given code, expressed in LSB’s (or counts from ideal) and INL is the accumulated DNL errors that occur over the whole range. Fundamentally, the DAC is based on a resistor string network and its not easy to make highly accurate resistors, as soon as you start needing more accuracy the cost of the part rises very steeply, and even with the best part money can buy there will still be errors. The more bits you extend the DAC by using dithering, the more error you introduce and the more noise you introduce too. While extending by two bits is probably acceptable with a decent low-pass filter, extending by three bits and beyond is not really practical. As an aside, the noise figures for the MCP4x22 parts are not that great – something one must consider when the reference voltage generated is going to be amplified, the noise will also be amplified.

In summary then, I want accuracy and precision but I want reasonable cost and even if I spend a lot of money I will still have errors. The lesson learned for me is I now no longer think of a DAC as an accurate programmable voltage source – it’s not, it is a close approximation only. The MCP4922 (MCP4822) is a nice part for the $$$ and useful for some things I have no doubt, but it’s not good enough for what I want to achieve in this project. Even with the resolution extension to 14-bits it falls short. Actually to be fair, even with the errors in the DAC this would be make a pretty good degree of control, it is probably more accurate than most of the lower end bench PSU’s out there, but my benchmark is the Agilent E3631A so I need to achieve much better than this. The MCP4x22 device is the best resolution DAC Microchip do so I must now search for other parts instead – Linear Technologies and Analog Devices are the logical starting point for my search.

There is one further possibility which I have yet to try, which is to combine both 12-bit DAC outputs to create a much higher resolution DAC, the block diagram for such a solution is shown in the data sheet for the part. This is well worth a look because if it works well enough, the cost of the two chips may well still be cheaper than an upgraded DAC part. I will build this out at some point and give it a try.

This project also needs to implement metering in order to monitor the output volts and current drawn by the load connected to the PSU, and this needs to be reasonably accurate to 1mV too, that’s 5-digits I need which in its self is a tall order. However, it occurred to me that if I could get an ADC that was accurate enough and a DAC with enough resolution to provide headroom for trimming it might be possible to build a self-calibrating system that trims the DAC output to match the desired programmed voltage each time you set a new voltage. That is what I will look at in Part 8.

Fully Programmable Modular Bench Power Supply – Part 5

I have set the regulator aside for a while, its time to turn to the control circuitry. However, before we get into the circuitry we need to do some pretty important calculations to help us select the right parts for the job. If you recall one of the aims for the power supply module is to be able to set its personality (supported voltage and current range) to suit a variety of voltage ranges. I have chosen a number of ranges to work within and specified them in the table below. Obviously its a relatively trivial task to add other ranges in the future so long as we stay within the confines of the working ranges of the components we have used in the system.

Range Volt
Range
Volt
Resolution
Volt
Steps
Current
Range
Current
Resolution
Current
Steps
Approximate
Power
Regulator
Gain
A 0-6v 1mV 6000 0-5A 1mA 5000 30W x2
B 0-16V 5mV 3200 0-2A 1mA 2000 40W x5
C 0-20V 5mV 4000 0-2A 1mA 2000 40W x10
D 0-30V 10mV 3000 0-1A 1mA 1000 30W x10

The values in the table above are what we use to establish the correct control circuitry so they probably deserve a bit of explanation. The voltage and current range columns speak for themselves, they tell us what the expected programmable range of the regulator will be. The voltage and current resolution columns tell us the size of each step in the range, so for example in range “A” which has a resolution of 1mv/1mA we can program the output volts from 0V to 6V in 1mV steps, and for the current we can program the limit from 0A to 5A in 1mA steps. The volts and current steps columns tell us how many digital codes are needed to represent the desired output voltage and resolution.

Getting our Voltage under Control

In oder to get a digitally controlled voltage we need to use a DAC (Digital to Analog Converter). A DAC takes a digital “code” and translates this directly to a static voltage. However, DAC’s typically operate in the 3.3v to 5.5v range so to control higher voltage ranges we need to ensure that the regulator circuit has gain. This is achieved by simply dividing the measured output voltage using two precision resistors before feeding back into the error amplifier. The column called “Regulator Gain” shows the gain factor required for the specified voltage range. You will see in the Part 4 schematic the gain has been set to x10 by R4 and R5. It is also with noting that these two resistors are the only two components in the entire regulator circuit that have any impact on the accuracy of the programmed output. The effects of inaccuracies in the other components are automatically and fully compensated for by the DC Servo effect created by the control loop. It is critical that R4 and R5 are accurate (I am using 0.1% tolerance resistors) and also have good temperature stability.

Alright, get to the point, what about the DAC!

In order to select the right DAC resolution and voltage reference (more on that later) we need to establish the range and resolution of the required control voltage. This is important because we must include the gain of the regulator which in turns affects the resolution requirements of the DAC. The following table expands on this with a key values we need to consider.

Range Output
Range
Resolution Steps Regulator
Gain
Reference
Range
Reference
Resolution
A 0-6v 1mV 6000 x2 0-3v 500µV
B 0-16V 5mV 3200 x5 0-3.2v 1mV
C 0-20V 5mV 4000 x10 0-2V 500µV
D 0-30V 10mV 3000 x10 0-3V 1mV

We calculate the control voltage range by dividing the target voltage by the gain multiplier value. For example, on range A, in order to obtain an output voltage of 6V we need a control voltage of 3V, calculated as 6 ÷ 3 = 2. To work out the reference control voltage resolution required we simply take the maximum controlling reference voltage needed and divide it by the number of steps required, in this case its 500µV per step.

From the above table we can clearly see that we need a maximum of 6000 steps to cover all ranges, which requires a DAC resolution of at least 13-bits. That is really inconvenient because DAC’s increase in price as the bits go up and there is a very notable jump in price as you go above 12-bits. A potential solution to this problem is to increase the step size on the 0-6v range from 1mV to 2mV which would half the resolution but would bring me nicely into range for a 12-bit DAC but I did not want to do that, its not what I set out to do, I needed to maintain the target resolution of 1mV on the 6v range. Thinking about it some more I thought that I could probably increase the resolution of the DAC in software using a technique whereby the DAC output is continuously set to a series of values at high speed to create an average voltage that can sit between between steps, this is known as dithering or modulating the DAC output. The downside to doing this is you introduce a peak ripple which reflects the continuously changing voltage level. However, filtering this out a straightforward affair because the amplitude of the ripple created is actually very small, so as long as we have enough current drive from the DAC a simple second-order passive low-pass filter is all that should be needed. Something worth noting though – the amplitude of the ripple voltage as an overall percentage of the output voltage is not linear; at lower voltages the ripple constitutes a larger proportion of the overall signal and therefore introduces more error. In practice though this should still end up well within tolerance, and if not we can always put in a higher resolution DAC!

One final thing is we need to decide on a reference voltage to use. DAC’s require a reference voltage in order to provide an accurate output voltage. Think of a DAC as a programmable potentiometer where the output is the wiper, the reference voltage is strapped across the two outer pins and the code sets the position of the potentiometer. If we have a 12-bit DAC that gives us 4,096 steps so if we use a reference voltage of exactly 4.096V we will have a theoretical output of 0-4.096V in 1mV steps which are nice round numbers that make software easier to develop, so that’s what we will go for.

So in summary, we have a design plan, we have our calculations and we know we need at least a 12-bit DAC. I am going to start with a DAC from Microchip MCP4822 which is a dual 12-bit DAC, its low cost and seems a reasonable starting point to do some experimenting, it also has a built in 2.048v reference and a x2 amplifier giving us the 0-4.096v @ 1mV steps.

In Part 6 I will work up a circuit, get a micro controller talking to the DAC chip and do some some perormance measurements to see what we come up with.