Jul 30

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 VoltageDAC CodeMeasured
MCP4822
(12bit static)
ErrorDAC CodeMeasured
MCP4822
(14bit dith)
Error
000.0015V+0.0015V00.0014V+0.0014V
0.001V10.0015V+0.0015V40.0016V+0.0002V
0.002V20.0024V+0.0014V80.0026V+0.0006V
0.003V30.0034V+0.0004V120.0036V+0.0006V
0.004V40.0044V+0.0004V160.0046V+0.0006V
100mv1000.1024V+0.0024V4000.1026V+0.0026V
500mv5000.5024v+0.002420000.5026V+0.0026V
501mv5010.5034v+0.002420040.5036V+0.0026V
1V10001.0004V+0.0004V40001.0006V+0.0006V
1.5V15001.4975-0.002560001.4977V-0.0023V
2.5V25002.5014+0.0014100002.5016V+0.0016V
3V30002.9993-0.0007120002.9995V-0.0005V
3.001V30013.0002+0.0002120043.0005V+0.0005V
3.002V30023.0012-0.0008120083.0014V+0.0006V
3.9v39003.8968-0.0032156003.8969V-0.0031V
4.095v40954.0916-0.0034163794.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 – its not, its a close approximation only. The MCP4922 (MCP4822) is a nice part for the $$$ and useful for some things I have no doubt, but its 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, its 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, thats 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.

Jul 11

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.

RangeVolt
Range
Volt
Resolution
Volt
Steps
Current
Range
Current
Resolution
Current
Steps
Approximate
Power
Regulator
Gain
A0-6v1mV60000-5A1mA500030Wx2
B0-16V5mV32000-2A1mA200040Wx5
C0-20V5mV40000-2A1mA200040Wx10
D0-30V10mV30000-1A1mA100030Wx10

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.

RangeOutput
Range
ResolutionStepsRegulator
Gain
Reference
Range
Reference
Resolution
A0-6v1mV6000x20-3v500µV
B0-16V5mV3200x50-3.2v1mV
C0-20V5mV4000x100-2V500µV
D0-30V10mV3000x100-3V1mV

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.