EmonLibPro Released - Continuous sampling, Multi sensor, Interrupt based, implements a zero cross detector and PLL.

Released to GitHub an Arduino Library demo for EmonLibPro with Ethernet support:

https://github.com/chaveiro/EmonLibPro

I've developed a new generic library for everybody to use. It's called Energy monitor Library Pro .

Based on emonTx hardware from OpenEnergyMonitor http://openenergymonitor.org/emon/

  • This version is a generic library for any number of voltage and current sensors.
  • Interrupt based, implements a zero cross detector and phase-locked loop for better precision.
  • Completely line frequency independent.

  
Reports Voltage, Frequency, Current, Active Power, Apparent Power and Power Factor.
This library idea comes from ATMEL AVR465: Single-Phase Power/Energy Meter.

Updated  21-02-2015 v2.0:

  • Changed ADC Trigger from Timer1 A comparator to Timer1 B comparator with ADC hardware auto trigger activated. Less jitter.
  • Long term tests shows PLL is not required, its disabled by default..
  • Improved line frequency calculation by now using full Timer1 range.
  • Added auto sample rate detection mode.
  • Adjusts automatically max attainable sample rate for any line frequency.

Included is a demonstration usage for Arduino.

The library was developed in AtmelStudio 6.1. See http://arduinoinstaller.codeplex.com/
Compiles fine on GCC/WINAVR without Arduino libs.
 

This is the mother off all power meter libraries, highly precise and highly configurable.
The demo is working for 1 x voltage sensor + 2 x Current sensor at 1600 samples per second.

Possible improvements:

  1. Can easily be added a KW/hr meter variable to Result data structure. No sampled data is lost at any time!
  2. Add calculations for Reactive Power (VAr). The sampled data is there already.

 

Demo printscreen:

Ready                                                
ETH: DHCP ok                                         
EmonLipPro Demo
 1 - Print cycle data. (internal vars data for each cycle)
 2 - Print Calculated data. Change interval in define CALCULATESAMPLES.
 3 - Print Lib Status.
 4 - Post to server.
Press a key...
Got: 2
Result0: 238.03VAC      50.00Hz 1.56A   283.57W 370.55VA        0.77Pfact
Result1: 238.03VAC      50.00Hz 1.58A   282.71W 377.11VA        0.75Pfact
Result0: 238.03VAC      50.00Hz 1.55A   283.00W 369.67VA        0.77Pfact
Result1: 238.03VAC      50.00Hz 1.58A   282.17W 376.11VA        0.75Pfact
Got: 3
PLL: Locked
ADC samples per Cycle: 120
VOLTSCOUNT: 1
CURRENTCOUNT: 2
SAMPLESPSEC: 2000
CALCULATESAMPLES: 100
Got: 4
ETH: Post...Sent

 

Program flow for the variables that contain measured data.

 

Update 21-Jun-2013: Added support for realtime cycle monitor via browser, printscreen below:

Update 21-09-2015 - 1CT + 1V doing 6400 samples per second:

 

john.b's picture

Re: EmonLibPro Released - Continuous sampling, Multi sensor, Interrupt based, implements a zero cross detector and PLL.

Rather than using a zero cross detector and phase locking to improve accuracy, would it make sense to use a more robust method of integration, such as trapezoidal or simpsons?

Trapezoidal integration could be implemented without much processor overhead and would improve accuracy.