Offsets...

There is one issue with the above calibration method that I haven't quite worked out how to get around yet, if anyone has any ideas how to get around it that would be great!

The equation of the line gives us two values m and c. m is the gradient and we call m either factorA (current calibration) or factorB (voltage calibration) and c is the intercept and is called Ioffset or Voffset again depending on our calibration.

Irms_corrected = factorA * Irms + IoffsetVrms_corrected = factorB * Vrms + Voffset

Apparent power = Irms_corrected*Vrms_corrected;

what about real power?

If you work through the maths factorA/factorB can be applied just after we calculate Irms/Vrms after our 6000 samples. They could also be applied in each cycle to the instantaneous current value, for example:

Iinst_corrected = factorA * Iinst.

and then you can work the factorA and factorB back through the real power equation to yield a nice and simple:

realPower_corrected = factorA*factorB*realPower

I'm having trouble however working Ioffset and Voffset through the maths to get a correction for realPower.

If you apply Ioffset and Voffset to Irms and Vrms only, you get an accurate Irms and Vrms and apparent power but when you then calculate realpower and powerfactor, powerfactor will either come out above 1 or significantly below 1 when it should be 1.

So my interim solution is to only apply factorA and factorB calibration and ignore the offsets and not to apply factorA and factorB values that the equation of the line gives but to adjust the values given by the equation of the line to try to reduce the mean of the potential error to zero... 

This gives the best possible accuracy without taking into acount offsets.

Any thoughts on the above would be very welcome.