Jump to content


Photo

Volt/Amp/Watt meter


  • Please log in to reply
26 replies to this topic

#1 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 904 posts
  • LocationMichigan, USA


Posted 20 July 2012 - 06:09 PM

This is a simple voltage and current meter that uses the TI INA219 chip. Voltage measurement range is 0 to 26 volts with 4 mV resolution and current measurement range is -4 to +4 amps with 1 mV resolution (when using a 0.01 ohm shunt). The specs are inferior to a pair of quality multimeters, but it is a fraction of the price and shows wattage in addition to voltage and current. The Nokia 5110 display is used so the firmware could be enhanced to do simple graphing. Sending the measurements to a computer could also be done.

Using the INA219 makes for a very simple circuit.
vam_schematic.png

The normal display is three lines with voltage, amperage and wattage.
vaw_meter_small.jpg

Pressing the P1.3 switch will show the 6 registers in the INA219 in hex and signed decimal.
vam_regs_small.jpg

The code is written in C++ and uses templates for the LCD, IIC and INA219. Software SPI and IIC is used for maximum portability.

Attached Files

  • Attached File  vam.zip   12.11KB   2524 downloads

  • bluehash, timotet, thanhtran and 22 others like this
Think in assembly, write in C. Sent from a bunker in an undisclosed location deep beneath a mountain.

#2 Arch_ETS

Arch_ETS

    Member

  • Members
  • PipPip
  • 15 posts

Posted 20 July 2012 - 11:19 PM

Just awesome. Thanks for sharing!

#3 Nytblade

Nytblade

    Level 1

  • Members
  • 73 posts
  • LocationChicago

Posted 21 July 2012 - 08:15 PM

Interesting use of templates... is that just to save on stack space vs passing the values as arguments to the function?

#4 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 904 posts
  • LocationMichigan, USA


Posted 22 July 2012 - 12:03 PM

Using templates allows the compiler to do compile time optimization that is not possible with C or C++ classes. It knows the pins and ports won't change at run time, so it can generate optimal code for I/O. This results in code that is smaller, faster and uses less RAM.
Think in assembly, write in C. Sent from a bunker in an undisclosed location deep beneath a mountain.

#5 rbasoalto

rbasoalto

    Member

  • Members
  • PipPip
  • 24 posts

Posted 25 July 2012 - 01:12 AM

Using templates allows the compiler to do compile time optimization that is not possible with C or C++ classes. It knows the pins and ports won't change at run time, so it can generate optimal code for I/O. This results in code that is smaller, faster and uses less RAM.

Nice technique. Now, I think you should put the method definitions of Nokia5110 inside the struct/class, to avoid repeating the whole template <...> before every definition. I don't know MSP compiler internals, but if you use -Os, it most likely won't inline the calls.

#6 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 904 posts
  • LocationMichigan, USA


Posted 25 July 2012 - 01:18 AM

Yes, that is something I have to take a look at. Would clean it up quite a bit.
Think in assembly, write in C. Sent from a bunker in an undisclosed location deep beneath a mountain.

#7 pillum

pillum

    Advanced Member

  • Members
  • PipPipPip
  • 37 posts

Posted 25 July 2012 - 10:42 PM

How accurate is it at the fastest mode and how fast is the fastest mode of that chip?

#8 cde

cde

    Enigmatic Decadence

  • Members
  • 939 posts

Posted 31 July 2012 - 12:51 AM

How does it measure voltage and current at the same time?

#9 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 904 posts
  • LocationMichigan, USA


Posted 31 July 2012 - 07:23 PM

The accuracy is +/- 0.2% typical. That is similar to a low cost 3 1/2 digit DMM.

It alternates between current and voltage samples. It only has one ADC.

For 12 bit resolution it takes about 1 millisecond to sample both current and voltage, so about 1000 samples per second. The resolution can be adjusted down to 9 bits for an almost 10x increase in speed. It is also possible to average up to 128 samples.

Full details are in the spec sheet linked in the first post.
  • thanhtran likes this
Think in assembly, write in C. Sent from a bunker in an undisclosed location deep beneath a mountain.

#10 MadhaV

MadhaV

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts
  • LocationSurat

Posted 15 August 2012 - 11:48 AM

Awesome work Buddy.
Void main()
{
for(;;)
{
}
}

#11 kff2

kff2

    Level 1

  • Members
  • 63 posts

Posted 15 August 2012 - 07:03 PM

Thank you for sharing this oPossum.

Is there a reason not to use hardware SPI when talking to 5110 besides compatibility with older chips? Or are there other issues, such as the D/C signal somehow getting in the way?

Also, am I correct to assume that 5110 is no longer manufactured and that the displays that we buy from ebay come from recycled phones? Is there a similarly cheap / easy to use display that is still in production and can be bought outside of ebay (e.g. from Mouser)?

#12 thanhtran

thanhtran

    Level 1

  • Members
  • 67 posts

Posted 11 September 2012 - 01:20 AM

Very nice work! I just duplicate this. It makes a very nice meter for my bench power supply :) Still trying to see if my shunt resistor (0.01ohm .5%) is wrong or what but my amp meters (fluke 179 and a clamp meter) show 0.5A less than what the INA219 gives the code. I had to parallel a 0.1Ohm with the 0.01 to get the reading closer to my meters.

It looks sophisticated with the memory dump too :)

Thanks

-Thanh

#13 cde

cde

    Enigmatic Decadence

  • Members
  • 939 posts

Posted 20 October 2012 - 01:30 PM

Was just looking at the code, and I have to ask, how are you getting anything for registers 3, 4, and 5 (Power, Current, and Calibration), if you never set the calibration register? On power-on, the calibration register should be blank, as should the power and current (because anything multiplied by 0 is 0)?

#14 hova

hova

    Level 1

  • Members
  • 71 posts

Posted 21 October 2012 - 09:23 PM

First post , looks like a great forum so far. I have been looking to make a simple voltmeter that outputs to a binary style display using Led's , that would end up being up to the 16's place. Basically long story short , I'm looking to make a test light for automotive wiring (low load preferable , but I have a great multimeter for CMOS lines) .

Any idea how to output from the 430 to a binary display?


Thanks
-hov

#15 bluehash

bluehash

    Site Admin

  • Administrators
  • 6,429 posts

Posted 17 November 2012 - 07:07 PM

The accuracy is +/- 0.2% typical. That is similar to a low cost 3 1/2 digit DMM.

It alternates between current and voltage samples. It only has one ADC.

For 12 bit resolution it takes about 1 millisecond to sample both current and voltage, so about 1000 samples per second. The resolution can be adjusted down to 9 bits for an almost 10x increase in speed. It is also possible to average up to 128 samples.

Full details are in the spec sheet linked in the first post.

Opossum.. can I use this in conjunction with the DP ATX breakout board to detect an over current situation (by sampling current)

This would help me to:
- Adjust the current threshold.
- Relay the voltage rail off when current reaches threshold.

43oh - MSP430, TivaC, ARM-Sitara and C2000 Discussion, News, Projects and Hacks

 

 


#16 chytech

chytech

    Noob Class

  • Members
  • 4 posts

Posted 27 December 2012 - 01:19 PM

Very good, it is usefull



#17 juani_c

juani_c

    Level 1

  • Members
  • 115 posts
  • LocationParaná-Entre Rios-Argentina

Posted 22 March 2013 - 08:04 PM

I have a doubt about the INA219 resolution. The bus voltage measurement has two full-scale ranges: 16V or 32V, but for what i understand from the datasheet the resolution is allways 4mV. This makes sense with the 16V range because it has a 12 bit adc, so 16/4096=0.0039 V

The 32 range should have twice that resolution, wright?

 

 


Improving my english a couple of words at a time...
http://ssihla.wordpress.com/

#18 oPossum

oPossum

    Poke me with a Stick

  • Members
  • 904 posts
  • LocationMichigan, USA


Posted 22 March 2013 - 09:35 PM

The resolution of the bus voltage register is always 4 mV. The resolution of the ADC is programmable up to 12 bits. So in some cases the lower bit(s) of the bus voltage register may not change. The ADC reading is shifted internally as necessary to maintain the same reading granularity in the register.


  • juani_c likes this
Think in assembly, write in C. Sent from a bunker in an undisclosed location deep beneath a mountain.

#19 4yang

4yang

    Noob Class

  • Members
  • 9 posts
  • LocationKL

Posted 15 November 2013 - 04:03 PM

Just wonder if i could use the same codes in Energia software?
 



#20 Rei Vilo

Rei Vilo

    Level 4

  • Members
  • 1,235 posts
  • LocationFrance

Posted 16 November 2013 - 09:31 PM

Just wonder if i could use the same codes in Energia software?
 

 

You can have a look at [Energia Library] I²C Voltage-Current-Power INA219 Sensor in this very 43oh forum and at Digital Volt-Amp-Watt Meter.


  • 4yang likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users