Author Topic: Power Supply Meter  (Read 4649 times)

0 Members and 1 Guest are viewing this topic.

Offline AnsonTopic starter

  • Regular Contributor
  • *
  • Posts: 135
  • Country: us
Power Supply Meter
« on: April 15, 2013, 05:25:45 pm »
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.
 

Offline kxenos

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: gr
Re: Power Supply Meter
« Reply #1 on: April 15, 2013, 06:13:45 pm »
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.
 

Offline AnsonTopic starter

  • Regular Contributor
  • *
  • Posts: 135
  • Country: us
Re: Power Supply Meter
« Reply #2 on: April 15, 2013, 09:40:19 pm »
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.
 

Offline kxenos

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: gr
Re: Power Supply Meter
« Reply #3 on: April 16, 2013, 08:24:53 am »
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 measurement
If 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. See http://www.linear.com/docs/12479 for 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?  :P
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Power Supply Meter
« Reply #4 on: April 16, 2013, 11:12:59 am »
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)

« Last Edit: April 16, 2013, 11:59:50 am by codeboy2k »
 

Offline AnsonTopic starter

  • Regular Contributor
  • *
  • Posts: 135
  • Country: us
Re: Power Supply Meter
« Reply #5 on: April 16, 2013, 01:44:27 pm »
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?  :P

Because 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.

Since it's a power supply, you don't need to measure negative voltages, and you can increase your range.

But it has both positive and negative outputs along with ground so I would like to be able to set my negative voltage with the display as well.

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.

This sounds interesting but I have no idea how to use a voltage reference I will have to research this. 

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.

Kinda lost me. This is all done in software right?

This will give you a maximum voltage of 40V (you can always add another range too, if you need it)
That is plenty.

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)



Ok 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?
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Power Supply Meter
« Reply #6 on: April 16, 2013, 03:57:37 pm »
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.00
ATxmega16A4
ATxmega32A4
ATxmega32D4
ATxmega32D4

With USB            $3.50
ATxmega128A4U
ATxmega16A4U
ATxmega16C4
ATxmega32A4U
ATxmega32C4
ATxmega64A4U
ATxmega64A4U

ARM Cortex M4  $9.00 or more
ATSAM4LC4B

The 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.




 

Offline kxenos

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: gr
Re: Power Supply Meter
« Reply #7 on: April 16, 2013, 04:33:15 pm »
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
« Last Edit: April 16, 2013, 04:37:50 pm by kxenos »
 

Offline AnsonTopic starter

  • Regular Contributor
  • *
  • Posts: 135
  • Country: us
Re: Power Supply Meter
« Reply #8 on: April 16, 2013, 06:13:48 pm »
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.
 

Offline ptricks

  • Frequent Contributor
  • **
  • Posts: 671
  • Country: us
Re: Power Supply Meter
« Reply #9 on: April 16, 2013, 08:52:26 pm »
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.096
http://ww1.microchip.com/downloads/en/DeviceDoc/41579D.pdf
« Last Edit: April 16, 2013, 09:00:23 pm by ptricks »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf