Filter-Based Algorithm for Metering Applications

Here’s an interesting application note from NXP: Filter-Based Algorithm for Metering Applications. Unfortunately the library appears to be closed source but the API is well described. @danbates is it too late to move to NXP processors? :wink: (although I haven’t researched what their licensing arrangement is).

It’s also a cautionary tale for anyone who thinks calculating VarHours is as simple as integrating sqrt(Apparent^2 - Real^2).

Thanks, I’ll take a look.
Oh man I’ve done enough CAD on this board laready :joy:

I didn’t understand all of it, but that was still interesting. Cheap chips too…

The 90 phase shift is done because it’s easier to detect phase errors right?

I implemented a FIR-like filter in the stm32 firmware y’know…

. STM32/main.c at e01a1a854b9415119a876d306f764e49de35caeb · danbates2/STM32 · GitHub

Per CT channel based phase correction. If the sample needed for the phase correction is in the future, the processing of the DMA buffer hangs back a few cpu cycles until it’s there.

The adc conversion settings put the sampling speed and hence phase correction resolution at 0.18˚ at 50Hz.

I’ve done a bit of testing on this method… needs more testing some time. The main thing I want to improve is the speed at which the maximum PF is found in the automated routine.

That’s how they measure reactive energy, which is a billable thing in some places.