EmonLib: Inaccurate power factor

Andries,

It is remarkable that both of us pointed out the same thing in the span of 3 days.

My point is mathematically you are doing linear interpolation (X, Y are constants) and it is equivalent to adding gain to the filter, or adjusting the calibrated gain of the voltage.

Let:
   Gain = X + Y
   PHASECAL = X/(X+Y) = X/Gain

Then:
  phaseShiftedV = (lastFilteredV + PHASECAL * (filteredV - lastFilteredV)) * Gain
            = lastFilteredV*Gain + PHASECAL*Gain * (filteredV - lastFilteredV)
            = X*lastFilteredV + Y*lastFilteredV + X*filteredV - X*lastFilteredV
            = X * filteredV + Y * lastFilteredV

I believe you are confusing filter with the relationship between φ (the phase difference) and PHASECAL which as you point out is not linear, but as it is calibrated, rather than derived, it doesn’t matter.
Of greater concern is

  • the zero point filter was not nearly slow enough (low pass enough) and it introduces a distortion around the middle zero crossing
  • the general insensitivity of PF on resistive loads to PHASECAL (i.e. near unity PF and small phase deltas)

I am surprised that PHASECAL can be calibrated accurately, but then I don’t have ‘shop’ hardware to try and I am often surprised. In Rms calculations in EmonLib and Learn documentation - #9 by dBC there is a link to a paper that suggests a way to improve that calibration (if your interested).

mike