Dual power supply with digital readouts

This was a project I've had on the list for a while. It's nothing special, just a power supply using LM338 regulators to give an output of 2 - 20 Volts at up to 2 Amps, off each channel.


What I wanted to do was to have digital displays of the output voltage and current for each channel. I had done something similar many years ago, using an A-D convertor that had 7-segment drivers built in. This worked well enough (until one of the A-D's failed and wouldn't display voltages any more). It also had the disadvantage that I was displaying the output current by measuring the voltage across a small resistance in the negative rail - so the two outputs couldn't be tied together, or feed parts of the same circuit.


With this design I used a PIC 16f870 which has 5 channels of 10-bit A-D and can sink enough current for 7 segment LEDs itself (though as the photos show, high-brightness red LEDs are best). I also discovered some high side current sense amplifers, the MAX4172 which meant I could monitor the current going out of the supply, thus allowing me to couple the two 0 Volt lines together.

I had decided to use red LEDs for the voltage display and green ones for the current, showing the voltage to 2 decimal places and the current to three (although the 10 bit ADs can't actually give a full 4 digit resolution). As the picture above shows, the red LEDs are quite bright, but the green ones are a lot dimmer. The next photo does show that they are actually on!

It may be that the understated current display grows on me, we'll see.


The MAX4172's are quite interesting. Essentially they turn a small voltage drop across a current sensing resistor (I used a 24mm length of resistance wire, to give 0.1 Ohms) into a larger volatage drop across a bigger resistor - In this case 0 - 2.56 Volts across a 1K resistor. The key point is that this larger resistor is referenced to 0V, so the voltage can be measured directly by the PICs A-D converters, which use a 4.096 Volt reference (and supply).
The circuit diagram shows how the current and voltage sensors are set up. For the output Volts, it's simply a potential divider across the output terminals.

The software

This project was written in Hi Tech C for the 16f870. (source code here and here ) It uses a timed interrupt routine to drive the displays and a main loop which takes voltage and current measurements. The displays are multiplexed and driven directly from the processor. This means that the numeric values to be displayed have to be converted into bit patterns to light the correct segments of the displays. These patterns are held in a simple look up table. I decided to run the displays from a 1 mSec interrupt to ensure that they would be refeshed at a constant rate - so the brightness doesn't vary, and one that's fast enough so I don't get any flicker. With 16 displays and a 1 mSec interrupt, each digit gets displayed for 1 mSec in every 16, which comes out at about 60 refreshes per second.
I originally ran the 16f870 at 5.120 Volts (which is within the 5.5 Volt maximum for this device), but fount it was getting warm. I reckoned this might affect the accuracy of the A-D convertor, so I dropped the voltage to 4.096 Volts. As the A-D reference voltage comes from the supply, I wanted to use a supply that was a nice "binary" value. This one gives me 4 mVolts per count from the ADC.



I did discover that I was getting a lot of jitter in the converted voltages. After trying a few things, I came to the conclusion that the large currents being switched during the interrupt routine were affecting the ADC, which was occasionally performing a conversion when an interrupt occurred. The simple expedient of disabling interrupts (see the code) while performing an A-D conversion cured this. However I also noticed an odd effect: that when the output voltage was varied slowly from (say) 9 - 11 Volts, the Volts digit and the 10-s of Volts digits would "stick". As an example, I might see values displayed of 9.77 9.86 9.97 9.04 10.10, or (even worse) when going in the other direction: 10.04 19.95 19.82 9.76 where the changed digit wasn't being updated in sync. with the others. I fixed this by adding a little bit of state information to the main loop and interrupt routine, so I would measure all four outputs (Voltage and current from each channel) and only display the data when all the measurements were done - then not update the measurements until all the digits had been displayed. Since the A-D runs fast, and the binary - BCD routine is in assembler (and also very fast - much better than coding it in C) there is no visible delay in updating the displays.


In conclusion I'm pleased with the versatility of this power supply. Since I had a few inputs and outputs spare, I've since added a temperature sensor to the power supply's heatsink and added an RS232 connection which outputs the voltage, current and heatsink temperature every 100mSec. Note: these mods aren't on the circuit diagram

I've been asked about the front panel I used. This was a standard aluminium panel that I cut rectangles out of for the displays. The red and green filters were stuck to into those holes with hot-melt glue and the decorative front added after that.This was printed onto an A4 sized stick-on label. I designed it using a basic graphics package, printed off the label and applied it to the aluminium front panel of the case.