I'll assume the following:
1.) you have a sampling system.
2.) you can sample voltage and current.
3.) you have synchronized the sampling system to the line frequency.
4.) you are only concerned with fundamental power factor.
in this case, you can determine power factor from the classic equations above. you can take several samples from voltage and current and find the sum of v(0)*i(0) + v(1)*i(1) + ... + v
*i
to find real power. you can use sqrt(v(0)^2 + ... + v
^2) * sqrt(i(0)^0 + ... + i
^2) to find apparent power.
keep in mind the following:
1.) the above only works for specific lengths of data.
2.) it only works for synchronized frequencies.
3.) it may be affected by elements at non-line frequencies.
The reason is because the operation is essentially a decimating FIR filter on a signal A + A*cos(2t). the filter's rejection of the double-frequency component is critical. the standard moving average works when the filter length is the same as the cycle length, as this places a zero at this double frequency component. however, off-frequency signals or different filter lengths correspond to the case where the filter length is not the same as the cycle length. The filter no longer provides the high attenuation of the double frequency component. as a result, the measurement will not be correct in most cases. Likewise, the design is fairly broadband, so it is possible that harmonics on the line will also be included. The error in the equation is based on the filter length in cycles. eg, if 60 cycles of data is analyzed, the effects of being off-frequency or analyzing slightly more/less data will be small. if one cycle is analyzed, then the error due to being off-frequency might be unacceptably high. This first case has a long delay and would be less suitable for real time control. the latter is more suitable for the slow but not very slow outer control loop used in power factor control.