Open Energy Monitor

What are you developing?
Post Reply
User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Open Energy Monitor

Post by RogerClark » Wed Jul 22, 2015 9:37 pm

I need to build a home power monitoring system, which can detect whether mains electricity is being consumed from the grid or exported back to the grid from a solar PV array.

I've looked the the Open Energy Monitor project in the past, and in particular their eMonLib, and i was pleased to find out that they added support for ARM devices a while ago, and the latest version compiles fine on the STM32.

I didn't even need to change any settings for the number of ADC bits, as they default it to 12 bits for ARM.

The hardware side of things, has proved to be the trickiest, and don't think i have the optimal solution yet.

The system needs an AC input to measure the voltage and phase of the mains voltage, which is achieved using a transformer. I looked in my box of salvaged parts, and tried a small transformer from a mains alarm clock, but the waveform on the 12V output was far from a perfect sine wave. I then tried another transformer (of unknown origin) and it was better but not perfect.
But in the end, i found a 12V DC charger branded as Panasonic, and i removed the internal bridge rectifier and smoothing caps etc, and this delivers a nice sine wave, albeit at around 16V , as its not under any load.
The 16V is fed into a voltage divider, consisting of a 10k resistor in series with a 10k trim pot. Actually, i should change this for a 33k in series with 10k pot, to get better resolution on the pot, but does allow me to reduce the 16V down to 3V even as it stands.

The current is measured by a current clamp. The one i have is labeled SCT-013-030, and designed to measure up to 30A. But the 30A value, must relate to its use with a particular monitoring system, because the only difference between any of the models of this cheap brand of clamp, is the limiting circuit inside the clamp.
On the 030 it has a 68 Ohm resistor in parallel with the output, but i found this reduced the voltage being produced by normal domestic loads ( of a few kW) to just a new hundred millivolts. So i took the clamp apart, which is an easy process, as its not glued or even screwed together; and I removed the internal (ballast) resistor, and i use an external 200 ohm trim pot, on my input conditioning board, to calibrate 3V AC to about 4kW.

Anyway, its now all working, but i find that noise on the ADC inputs is a bit of an issue.
I think the noise is mostly coming in on the supply, i.e the USB from the computer.
I've taken a look at supply noise from various USB power supplies and some are better than the PC and some are worse.
But either way, I think i need to try to remove as much noise as i can, because at the moment, my system is registering around 40W of fluctuating power consumption even when my test rig (an oil filled electrical radiator) is not turned on.

But i also meed to confirm whether this stray noise is actually pickup by the current transformer, from the mains wire to my soldering iron etc etc.

The next steps are a probably going to be more of a software challenge, as i need to transmit this data, and i have selected a NRF905 device for this purpose, as the data has to go thorough several brick walls, which i know greatly attenuate high frequency signals like WIfi or devices like the NRF24L01.

I think there are a choice of 2 libs for the NRF905, RadioHead is one of them, but AFIK this has not been ported yet, and my prove to be challenging.

Anyway, i will keep you guys posted with any progress.

User avatar
mrburnette
Posts: 1783
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Open Energy Monitor

Post by mrburnette » Thu Jul 23, 2015 12:53 am

So i took the clamp apart, which is an easy process, as its not glued or even screwed together; and I removed the internal (ballast) resistor, and i use an external 200 ohm trim pot, on my input conditioning board, to calibrate 3V AC to about 4kW.
The term for the resistor is "burden" resistor and the value must be reasonably low to reduce noise; in fact, the subject is rather complex, but adequately represented on the Internet. The resistor, ideally must match the impedance of the current-sensing coil at the AC frequency being monitored. Otherwise, the voltage across the resistor will not be linear to the current flow.

Ray

User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Thu Jul 23, 2015 1:44 am

Hi Ray

Sorry for the misnomer on that resistor name.

Re: Resistor value to match the impedance of the coil.

From what I understood by reading the Open Energy Monitor website, was that the two different models of current clamps (transformers), had the same coil but the one labelled SCT-013-000 doesnt have a burden resistor, but has back to back 22V zeners, where as the SCT-013-030 (which I have), has an internal 68 ohm resistor.

But its common for people to take these apart and use an external resistor which is a higher value, - normally 2 or 3 times higher.

Actually, its odd if the lower current version i.e the 030 (30A) has the burden resistor and the 000 (100A) does not.
I presume this is because they expect people to use an external burden resistor on the 000

I think perhaps I should have ordered the 100A version, as its the one that they recommend on the Open Energy Monitor site
http://openenergymonitor.org/emon/build ... ransformer

So I'll order another one, as perhaps the coil on the SCT-013-000 is different from the 030.

I can also experiment with various loads to see how linear / non-linear these things are.

I know that even the ( domestic ) commercially available power monitors are terribly non-linear , my dad has a correction table printed next to his display unit on an "OWL" branded monitor, as it overreads below 500W and under-reads above about 1kW

Ultimately I'm sure it would be possible to build some sort of interpolating lookup table and then calibrate a particular clamp in a particular location
Especially if you can do this by using the mains power meter for the whole house (supplied by the power company), as most of these have an LED that flashes at a rate proportionate to current consumption (and I've already built an AVR based solution to monitor that data, several years ago)

BTW.
If you ask why I'm building a current clamp version, when I can read the power company's meter...
Its because their LEDs only seem to flash when consuming power and not exporting it. Often the LED just stays on permanently when you are exporting power (or doesn't flash at all)

Ideally I could get the data straight from the power companies meter, but it seems to be a closed system in most cases, or requires you to only use authorized / certified hardware even to view the data via XBee etc :-(


Edit.

Generally, it appears that people think the two clamps have basically the same windings on the internal transformers

http://openenergymonitor.org/emon/node/2447

However whether this is really true or not us probably open to debate unless someone has really compared then side by side.

stuartw
Posts: 35
Joined: Mon Jun 01, 2015 8:57 am

Re: Open Energy Monitor

Post by stuartw » Thu Jul 23, 2015 5:02 am

All sounds very interesting, I just wonder why not using one of the many and very function anal mains monitoring chips, and just talk to that?

http://www.microchip.com/wwwproducts/De ... e=en567281
http://www.microchip.com/wwwproducts/De ... e=en520376
http://www.st.com/web/en/catalog/sense_ ... ?sc=stpm01
http://www.ti.com/lit/ml/slyt428/slyt428.pdf
http://www.cirrus.com/en/products/cs5463.html

Of course just a tiny sample, and I am sure you are well aware of them, but they are dozens and dozens of functional block sdesigned to monitor just about every parameter you could want, and often pretty damn cheap.
Of course they all have their own particular interfacing requirements, however they do have the advantage of having plenty of information on right/wrong approaches in such interfacing ;)
They also tend to take care of such things as powerfactor, etc.
I know you have working interfacing, just thought I would throw those out there..


Just make sure you get the isolation nice and solid ;)

User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Thu Jul 23, 2015 5:22 am

Stuart

Actually, I do have some power measurement chips. But I can't recall who makes them.

I did consider using them a while ago, but I'd need to write a library for them, and the OpenEnergyMonitor guys already did a great job with their code, and its well supported.

Also, I can't recall how much the measurement chips cost. I don't think they were that expensive, but for some people ,if the Arduino will a decent job without external specialized chips, then they'll take that option. (Me included)

I think the other downside with the chips I have, is that they are surface mount, and I had to solder them manually into an expansion / adaptor board even before I could start to use the,

But now you mention it, I will try to dig them out and see what they are. (None of the part numbers in your list rang a bell with me)

Edit.

I have some of the old Cirrus Logic 5460A devices, which I bought a few years ago. http://www.cirrus.com/en/products/cs5460a.html
They have been succeeded by the one you linked to.

I'm not sure what the differences are between the old and new versions, I'm sure the new one is better somehow.


If you know of any example code set setting up the registers on the 5460 (or the 5463), please could you post a link, as at the moment all I can find is the datasheet, and these devices have multiple registers (20 or more) that need to be configured for them to work correctly.

User avatar
mrburnette
Posts: 1783
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Open Energy Monitor

Post by mrburnette » Thu Jul 23, 2015 1:50 pm

I know that even the ( domestic ) commercially available power monitors are terribly non-linear , my dad has a correction table printed next to his display unit on an "OWL" branded monitor, as it overreads below 500W and under-reads above about 1kW

Ultimately I'm sure it would be possible to build some sort of interpolating lookup table and then calibrate a particular clamp in a particular location
Some of this is due to the "power factor" but, if your design can calculate AC power factor, you also have the answer to the power flow back into the commercial system.
http://hyperphysics.phy-astr.gsu.edu/hb ... owfac.html
http://hyperphysics.phy-astr.gsu.edu/hb ... werac.html


Ray

User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Thu Jul 23, 2015 9:18 pm

Hi Ray,

I've not looked at how eMonLib does it, but its calculates both real and apparent power as well as power factor ( which are all related )

You have to calibrate for phase offset between the voltage and current inputs, using a parameter in the voltage setup function.

However if the current clamp's detected waveform shifts phase depending on the amount of current being drawn, that will obviously have a big effect on the results.


I'm not sure if I have damaged one of the Analog inputs on my RedPill, but i'm now seeing some strange results when I remove the current clamp and clip it back on in the opposite direction.
The power being shown is a lot different.

I will need to analyse whats going on, using my scope, to see if the amplitude of the current waveform is really any different, or whether this is another phase / power factor issue.


Or, whether, as has been suggested in the OpenEnergyMonitor forum, that I'm getting crosstalk between the two inputs; as they are on adjacent pins PA0 and PA1 and I'm using a Breadboard to connect an external Veroboard, containing the initial signal conditioning components, to the RedPill.

BTW.
Ray...
I was thinking about intergating an ESP8266 with this power monitor, probably running a mini web server.
Have you tried any of the ESP8266 web server stuff recently, (I've only used the web server code before the Arduino port)
Also ESP8266 to STM32 comms... Any ideas?

fredbox
Posts: 84
Joined: Tue Jul 07, 2015 4:44 pm

Re: Open Energy Monitor

Post by fredbox » Fri Jul 24, 2015 2:40 am

Hi Roger,

You've made a couple of references to 3 volts. I hope you mean peak-to-peak and not rms. 1 volt rms (2.8V p-p) would be about optimum for feeding the analog input on a 3.3 volt processor. The zero crossing point should be offset from ground to half the supply voltage, or 1.65 vdc. Otherwise, the cpu could be damaged by the voltage going below ground or above Vcc. The schematic for the open eMon shows this configuration.

If the CT is remote, you should use a twisted pair wire from the CT to the CPU.

User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Fri Jul 24, 2015 2:45 am

@fredbox

No worries

I use basically the same voltage divider as in the OpenEnergyMonitor TX hardware designs, except I use Vcc from the STM32 board, which is 3.3V, and hence generates a mid point voltage of 1.65V

Then the inputs are scaled using pot's (10k resistor in series with a 10k pot for the voltage sense as I'm using a 12V RMS transformer) and a 200 ohm burden resistor on the CT clamp so that all inputs are within 3.3V peak to peak offset by 1.65V

User avatar
RogerClark
Posts: 5936
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Open Energy Monitor

Post by RogerClark » Sat Jul 25, 2015 11:28 am

Update.

This is now working really well.

I thought I had an issue with one of my voltage dividers producing 1.45 instead of 1.65V, however after disassembling and re-assembling the circuit to prove what was wrong, the problem transpired to be the load put on the divider by my scope.
The voltage divider consists of two 270k resistors in series with a 10uF capacitor to ground. The OpenEnergyMonitor Tx board actually uses 470k resistors in its divider, but I didn't have any to hand, and 270k sounded plenty high enough.
I think the high value resistors is to attempt to reduce noise on the bias point voltage produced by the voltage divider.


I compared data capture using the STM32 vs a Nano (after re-adjusting the input values to provide the greater voltage range required by the Nano), and the STM32 seems to give much more stable results for the AC voltage and also the AC current measurements.

I suspect this is caused by a combination of factors.

1. ADC sample time and data processing is substantially faster (this appears to be 3 to 4 times faster than AVR), hence more time slice sampling of the waveform
2. ADC is 12 bits instead of 10, hence 4 x the precision
3. variables in the main calculation are double, but on the AVR these are 4 byte floats not really doubles, but on ARM they will be 8 byte, hence calculation precision will be better (but I'm not sure how much difference that really makes)


So...
I now need to get the NRF905 lib working so I can send this data to where its needed.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest