AC Phase sensing, and active power metering with a clamp

Hi,

I'm Nicolas, a new and enthusiastic member of the Flukso community.

It was really a surprise for me to discover how most of my modern (switching) supplies lead to such a bad "base-load" power factor. And an overstimation of my consumption as the clamp does measure the apparent power and not an expected active power (aka the Watts).

As many of you, I'm going to add a DIN rail meter that will feed 1600 pulses/kWh. So, basically problem solved.

Nevertheless, I'm quite sure the hardware would be able to compute an active power and a cos(phi).

We could easily feed an AC phase information using a 5V analog (sinusoidal) input, or, as easily, a zero-crossing detection circuit that would pulse at 100 Hz.

I think I've read the FLM analog input are polled at around 600 Hz, which would be more than enough.

Does it seem reasonable ?

For reference, here is my previous experience in mains phase sensing and zero-crossing (about at the middle of the page) : http://letsmakerobots.com/node/4750

I can easily wire a prototype, but have no clue where in the Flukso code I could make use of the new phase input.

Greetings

Nico

gebhardm's picture

"Does it seem reasonable?" - IMHO, no. Why? As interfacing would not only change the measuring software, but also require a hardware change on the interface side and a hardware change implies altering the controller board and altering the controller board may impact complete operation of the FLM. By the way, the used clamps are much too slow to let you reasonably detect the AC wave form (300ms rise time, as far as I remember, but check with an oscilloscope)
If you want a DIY-solution, look for http://openenergymonitor.org/emon/buildingblocks and set this up with an RPi or Arduino - there are plenty of tinkerer proposals out there which make any change to the FLM not justifiable.
(but if you want to change the controller board, go ahead; the FLM base is a Dragino v1, so "just" an openWRT router with accessible gpio pins - but if you are not also in software, well, ...)

ndupont's picture

Don't get me wrong, I have no plan on altering the hardware, but just feed a second input, be it analog or pulse with a phase information. :)

And not by means of the original clamp but with a small additional circuit, but then I assume an additional external mcu could interface both the sensors and take care of all power factor consideration. Which is basically what the DIN module will do.

My question being : "How complicated in the software architecture would it be to multipy two phases instead of adding them ?"

Thanks for the openenergymonitor link

gebhardm's picture

As the source code is available, you may judge for yourself, on how "complicated" the software "architecture" (actually just the code, not an "architecture") is; I regard it as not too complicated...
Here an explanation on the pulse input code (ref to FLM v2b):
The AVR controller board in the FLM uses pin change interrupts (PCINT) to detect pulses (https://github.com/flukso/flm02/blob/develop/avr/b/main.c#L459) (in the FLM v2a this is "direct" interrupts INT0 and INT1)
The corresponding interrupt routine ISR(PCINT1_vect) (https://github.com/flukso/flm02/blob/develop/avr/b/main.c#L256) detects the direction of a pin change (low->high, high->low) on all assigned PCINT-pins (the enabled pulse ports) and correspondingly registers on falling edge (high->low) a pulse in its internal sensor counter. So far, so easy.
If you want a dedicated PCINT signal to behave differently, then you actually "just" have to write a proper "register function" and call this on the corresponding pulse occuring within the PCINT-interrupt routine.
For that you may use AVR Studio and to bring it into the FLM a proper "programmer", e.g. an AVR ISP - or you tweak the update routine of the FLM and pray that you don't ...
Have you ever programmed in an embedded environment? If not, start with an easier project...

gebhardm's picture

By the way, if you just want to pass on further information, then don't interface with the FLM itself but its MQTT broker; through that you have all freedom to do with the registered values what you like - https://www.flukso.net/content/use-flms-mqtt-broker-further-extending-yo...
And for this all you need is just a little MQTT publisher, something like an Arduino Ethernet, RPi, JeeNode, ESP8266, you name it...

gebhardm's picture

Slowly I begin to sense what you are heading for; you want to provide a "power factor correcting clamp"...
To do this, there are indeed two options:
If you want to interface with the pulse input, refer to the S0 specification respectively EN 62053-31; here you have to generate just a pulse proportional to energy provided to an open-collector output/opto-coupler; pulse length ca. 30ms. See, for example, https://github.com/gebhardm/energyhacks/tree/master/Impulsformer - here I interface one to three additional clamps to a pulse port; how you determine the energy respectively correct the power factor then is just a matter of the "external MCU", as you suggest.
To do the same for an FLM's analog input is a bit more tricky as then you need to meet the input impedance of the FLM. Here a 1k91 resistor serves as a voltage divider to bring the clamp's voltage (0-5V) into the measuring range of the ADC (0-1V1). I guess, this can be done using PWM and a proper filter/RC-circuit.
Look at the stuff the openenergymonitor guys do; they actually solved all of this already.

icarus75's picture

The upcoming FLM03E will sense amplitude and phase of the line voltage and thus take care of power factor correction.

netweaver's picture

Hi Bart,

will it work for 3x400+N too?
If so, I just bought the FLM02 (you just posted it today :D ), I guess it's not upgradable? What about a trade-in, potentially with extra?

To get accurate electricity reading I also have ordered a 3 phase Eastron kwh counter, with only 800 pulses/kwh. I was already thinking the resolution is rather small to get the peak power consumption visualized. Trade-off money vs measurement resolution.
If I had known about the new (more capable) FLM coming up, I think I would have waited and got the new version, if it indeed does that...

ndupont's picture

Thanks Markus, the impulseformer is indeed the kind of additional circuit I had in mind if it's not possible to reasonably calulate it directly in the FLM02b.
I could also take advantage of MQTT to merge my weather and sky condition readings as well. But first things first, I'll start with a full revamp of my mains distribution enclosure while inserting the DIN kwH meter.

@Bart that's some really good news, as people tend to like having their nerdy monitoring matching the official meter readings. More importantly when using energieID services.

@Netweaver, "only" 800 pulses/kWh will give a pulse every 45sec at 100W (which is not that bad), and a bunch of pulses each second under a heavy load.

Speaking about heavy loads, what will happen to my FLM2b if I reach the 60Amp limit of my power connection while using a 50A clamp ? Is there any risk to fry the sensor board ? (I haven't used EAGLE for 16 years, so I havent' seen the FLM schematics).

gebhardm's picture

With respect to the clamps' maximum measuring range: The 50A-clamps corresponding to the spec provide up to 7V5 (equiv. 75A) with an internal over-voltage suppression; as the FLM brings 0-5V (corresponding to the intended measuring range) down to 0-1V1, even the 7V5 won't harm the circuit (otherwise I bet also the CE certification would be invaldidated) - so, no issue, just inaccuracy.