Power Supply Meter - Page 1
Forum section: electronics / beginners

author: Anson
author_rank: Regular Contributor
timestamp: April 15, 2013, 05:25:45 pm
content: I am in the process of designing a meter for my power supply. I will need it to display voltage and amperage of both the positive and negative voltage rails. Display will be on a 20x4 character lcd. I will be using AVR mcu's I don't know which one would suit the task best. Displaying voltage to 50 is relatively easy as I have read however I would like this to be as accurate as possible. I am not sure how to measure negative voltage other than maybe reversing the inputs and just adding the negative symbol in software. Don't know if that would work. So I need to know the best AVr for the task and possibly any other chips to handle measuring amperage or negative voltage or getting a more accurate 0 to 50 volt reading. My power supply actually only goes up to 34 volts anyway.

author: kxenos
author_rank: Frequent Contributor
timestamp: April 15, 2013, 06:13:45 pm
content: At what stage of the design process are you? It seems you're going to face serious difficulties judging from your questions. Have you tried googling for a voltage meter schematic? uC is the last part you want to consider except if you plan to use the uC's A/D converters in which case all AVRs are 12bit and you can find info on the part datasheet. In general datasheets and app notes have a wealth of information and design ideas that can help you a lot.

author: Anson
author_rank: Regular Contributor
timestamp: April 15, 2013, 09:40:19 pm
content: I'm trying to decide which MCU to use. I know I need ADC at some point either onboard or on a separate chip. If I use a separate ADC chip would I be able to have a more accurate meter? And I do not know how to set up for reading negative voltages. I have found no examples of anyone measuring negative voltages on a diy meter. I have found a few examples of AVR and PIC controlled meters even one PIC meter that was 20x4 lcd reading dual voltages and amperage but they were both positive inputs. I will like base most of my design around this at first and fine tune from there unless I am advised otherwise.

author: kxenos
author_rank: Frequent Contributor
timestamp: April 16, 2013, 08:24:53 am
content: Using the embedded A/D of the uC is possible but has limitations: Very few uCs have A/D with more than 12 bits. Also all A/D inputs have a common reference ground.12 bits mean 2^12 = 4096 values. If you want single range 0 to +-50V thats 100V in total and that means a resolution of 0.024V. Having a common ground reference means that it will not be safe to measure voltage and current at the same time without using circuitry to bring the 2 measurements to a common reference. Look up high/low side current measurementIf you want to measure voltage and current of the same circuit for example to do a power calculation this will be no problem as your ground reference will be the same. Seehttp://www.linear.com/docs/12479for some examples.Also, negative voltages are not a problem. If for example your measurement range is 0 to 5V, you can reference 0V in your measured circuit to 2,5V in your measurement range. In this way you will get reading 4095 for +50V, 0 for -50V and 2047 for 0 volts.Why do you need to measure - voltages if it's a PS? Don't you just want to measure the voltage in the binding posts? Are you going to use lead color autodetect to automatically swap the output polarity?

author: codeboy2k
author_rank: Super Contributor
timestamp: April 16, 2013, 11:12:59 am
content: Since it's a power supply, you don't need to measure negative voltages, and you can increase your range.If you use a 4.096V reference like the ADR392 (0.12%, 9 ppm/C) or the MAX6126 (.02%, 5 ppm/C) then you can use a 12-bit ADC on the CPU, and get 4.096/4096 = 1mV resolution for an input scale of 0-4.096V, and you won't need to calibrate it.With this setup, you will have to scale the input (divide it by 10) when the voltage to be measured is greater than about 4V, so this will give you 2 ranges... 0-4.096V and 0-40.96. You can autorange easily with just 2 ranges... when you are on the first range and your ADC output is above 4000 counts or so, you set an output port bit that enables a resistor divide by 10 on the input voltage and move the decimal point to the right on your display. Reverse that going down. Add some hysteresis so you don't flip between ranges at the transition point, ie.. up range at 4090, downrange at 4050 or so. You'll need to protect the ADC input from voltages higher than its maximum allowable input.This will give you a maximum voltage of 40V (you can always add another range too, if you need it)If you really must have 0-50V, then use a 5V reference with the same auto-ranging plan, a single divide by 10 switched in near the 4090 count and switched out near the 4050. Your display will be out by 1mV some of the time, because a 5.0V reference with a 12 bit ADC gives 1.22mv for each count. (with 0-4.096V it will also likely be out sometimes by 1mV... you can't help that, but it will be out less times than if you use a 5V reference).You'll still have to deal with the voltage and current common reference issues that kxenos pointed out (i.e. your GND reference for measurement). If you can find a CPU with a 12-bit ADC with differential inputs, that would be best and will help with this.Choosing the CPU with an appropriate ADC can be tricky, because you have to get one that can handle a 4.096V input. Many cannot. I haven't looked at CPUs with 12-bit ADC's, however, the LTC2302 is a 12-bit differential ADC that can handle inputs up to the reference, 0-4.096 and has a unipolar count output where the count 0-4096 is mapped to 0-4.096 if you use a 4.096V reference. So one option is to use an external ADC and save money with a lower cost CPU with little features, i.e. a cheap PIC with no ADC or just an 8-bit ADC onboard.EDIT: just took a look at CPUs, the MSP430AFE232 is just a little over $2, has 2x24bit differential ADCs, a hardware multiplier for Watts display, has an internal reference, and can use the external reference too, plus its got a whole crapload of other stuff you won't use, but it's cheaper than 2 external ADCs plus a micro, and if you can use the internal reference it will save you a bit (but the internal reference might not be great)

author: Anson
author_rank: Regular Contributor
timestamp: April 16, 2013, 01:44:27 pm
content: Quote from: kxenos on April 16, 2013, 08:24:53 amBecause I have an adjustable dual polarity linear power supply. I can adjust positive and negative voltages and they share a common ground. I need this for experimenting with audio projects. I want to be able to read on an lcd the volts amps of each output. It sounds like I should probably use a separate A/D which was one of my main questions. Should I use a separate A/D for each side?I'm not understanding the math, but it seems high bits means higher accuracy.Quote from: codeboy2k on April 16, 2013, 11:12:59 amOk so I need a 4.096V reference and at least 12bit differential ADC. I will be using AVR because that is what I am able to use. Is there a chip that has these features built in? And how will I be able to measure amps for each rail?

author: codeboy2k
author_rank: Super Contributor
timestamp: April 16, 2013, 03:57:37 pm
content: The Atmel parts aren't going to work with a 4.096V reference. They are limited to 3.3-3.6 Volts input range.To use an AVR or even Atmel's ARM Cortex devices you'd need to use a 3.0V reference, and then your ranges are 3V, 30V, 300V. On the plus side, 1 LSB is 3.0 / 4096 = 732 uV so you get a little more resolution, which may not be usable anyways.From the parametric search, the following have Atmel devices have multiple 12 bit differential ADC inputs:NO USB $3.00ATxmega16A4ATxmega32A4ATxmega32D4ATxmega32D4With USB $3.50ATxmega128A4UATxmega16A4UATxmega16C4ATxmega32A4UATxmega32C4ATxmega64A4UATxmega64A4UARM Cortex M4 $9.00 or moreATSAM4LC4BThe problem is the price.. if all you want is a Volt/Amp meter to drive a LED display or LCD, then these devices are all overkill and you pay for that. They have touch interface, multiple SPI, multiple UARTs, DACs, crypto, audio, etc..You can certainly use a lesser device here, with or without any internal ADCs. Mating a smaller micro with an external ADC will get a better voltmeter ,at the cost of more parts. A single chip solution with an MSP430 or other micro can also be done, using the built-in ADC and reference (but it won't be a 4.096V reference, that will need to be external). 4.096 works well because you get 1mV resolution from that and you can have a 4 digit display.Yes, the determination of when to up-range and down-range would be done in software. Basically, when ever you get a reading from the ADC of 4090 counts or more and you are in the lower range, jump to the higher range. When you are in the higher range and get an ADC reading of 405 counts or less, jump to the lower range. That gives about 40mV hysteresis, and you might actually find in practice you need more, you can tweak it. You change ranges by outputting a control signal to insert a divide-by-10 in the input, and move the decimal point one digit to the right. (If the voltage input was 4.090V, it becomes 04.09V at the changeover point). Note that you would be dividing the 4.090V input by 10, so the ADC sees 0.4090 Volts (ADC output = 409, display =04.09V ). You've gone up a range and dropped down to the beginning of the ADC counts again.And you'll need to protect the inputs against overvoltage with some zener clamping at 4.1V or so, and resister current limiting for external transients. Remember that your reading the voltage from you PSU output which was binding posts that users can touch. If they give a shock to the inputs, your ADC will take it all if you don't protect it.

author: kxenos
author_rank: Frequent Contributor
timestamp: April 16, 2013, 04:33:15 pm
content: As for current measurement, please have a look in the Linear app note I linked to in my previous post. As for using AVRs, the only AVRs with 12bit A/Ds are in the XMega series and these uCs are 3,3V parts. They're also quite expensive. In that price I would suggest using a 2 channel ADC like MCP3427 which can do 12 to 16bits resolution, has a programmable gain amplifier built-in so that you can implement ranges if you like (though this is not the best way to do it, it will be adequate) and a built-in voltage reference and connect it through I2C to an arduino board or a tinyAVR like ATtiny2313 or ATtiny24.edit: codeboy explained the AVR issue pretty well

author: Anson
author_rank: Regular Contributor
timestamp: April 16, 2013, 06:13:48 pm
content: Ok I think I have enough info for a good start. Thanks everyone. It will take me some time to work on the details and the schematic but I will post later with results and questions.

author: ptricks
author_rank: Frequent Contributor
timestamp: April 16, 2013, 08:52:26 pm
content: Really give some thought about using LCD for the display. LCD can provide more information but when on a bench I find LED much easier to read from a distance.For micro to use check out the PIC16F1783, 12bit differential DAC and also contains opamps you may need to amplify the current for reading and lots of other power supply related goodies. Cost about $3.00 I know you said you are an AVR guy but sometimes you have to use the best part for the job regardless.Voltage refs are 1.024,2.048,4.096http://ww1.microchip.com/downloads/en/DeviceDoc/41579D.pdf