according to How does one measure the power factor? I can measure the power factor (cos phi) by comparing the zero point crossing of Voltage and Current. This is clear.

The problem I have is what if I can't tell exactly when the zero crossing is? My idea is to measure the cos phi with an arduino using a very simple circuit.

Basically I want to use Resistors to break down the voltage to +- 5, then use a diode to have only the positive waves. With this, I can sample the voltage using the analog input of the Arduino, let's say at least 2 faster than 50 Hz. The arduino nano for example has a clock speed of 16 MHz :-) (Nyqvist).

Now, with the current I plan to do the same. Take a cheap linear current transformer and convert to voltage using resistor, so I will get only + 5V max.

I will calculate resistors and transformers so that for the max V and A I will get the range I need, and I can also secure my Arduino with over voltage security.

I don't need to measure U and A exactly. I don't need this values with precision, that's why the usage of cheap elements and simple approach might be enough.

What I need is to calculate the phase. Please take a look at the picture: current and voltage

Let's asume 1. I can measure Current and Voltage as only positive waves from 0 to 5V max 2. I sample fast enough 3. I can detect the point where they go from zero to some value (I will make an error here as well...) 4. There is some error on the measurement (magnitude) 5. I can calculate dt between V and A. With it, I can calculate cos phi

My question is: is this possible/ feasible? Is the error I make in 3 big enough to make this cos phi measurement impractical? How can I calculate this error?

Thanks a lot

  • \$\begingroup\$ You will need to sample much, much, much faster than 50Hz to measure the phase angle difference of a 50Hz power line. \$\endgroup\$
    – brhans
    Commented Feb 10, 2016 at 15:21
  • 3
    \$\begingroup\$ Instead of feeding the signal the ADC, you could run both signals into zero crossing detectors, and then use a hardware timer to very accurately measure the difference between them. \$\endgroup\$
    – uint128_t
    Commented Feb 10, 2016 at 15:24
  • \$\begingroup\$ @brhans: Is a clock speed of 16 MHz much much faster than 50 Hz? Of course the sample rate will not be 16 MHz, but if the algorithm is good enough maybe close to 1 MHz. \$\endgroup\$
    – otmezger
    Commented Feb 10, 2016 at 15:27
  • \$\begingroup\$ @uint128_t is this what you are talking about? playground.arduino.cc/Main/ACPhaseControl \$\endgroup\$
    – otmezger
    Commented Feb 10, 2016 at 15:29
  • \$\begingroup\$ Pretty much. You just need the zero crossing part, you don't need the triac part. And then you will need a second zero crossing circuit for your current. \$\endgroup\$
    – uint128_t
    Commented Feb 10, 2016 at 15:45

1 Answer 1


See the comments below the post after reading this. My solution here would only be accurate for R-L-C circuits and not if there were pulsed currents due to rectifiers, etc.

Don't worry about Nyquist. Instead:

  • Detect the zero-cross of the voltage signal. Note whether it's positive-going or negative-going.
  • Start two timers - one to measure time to the next voltage zero-cross (Vzc) and the next to detect measure time to the current zero-cross (Izc).
  • When the Izc occurs stop the Izc timer.
  • Figure out whether it's positive or negative going.
  • On the next Vzc stop the Vzc timer. (This gives you the half-cycle time.)

From all the above information you can figure out the angle between the zero-crosses and whether the phase angle is leading or lagging.

Your main problem will be accuracy of the ZC measurements, particularly on the current waveform (which may be zero, don't forget). I would suggest that this might be better done by external discrete circuitry triggering digital inputs. The wideband Zero-Cross Detector by Dave Johnson may be of help.

  • \$\begingroup\$ I'd worry a lot about nyquist if you are going to try and estimate power factor accurately. Zero crossing to calculate PF is missing the point about what PF is and how it applies to highly non-sinusoidal currents such as in bridge rectifiers. A theoretical sinewave with resistor, inductor or capacitor load is fine but for the rest of the real world forget it. \$\endgroup\$
    – Andy aka
    Commented Feb 10, 2016 at 17:45
  • \$\begingroup\$ That's interesting, Andy. I work occasionally with power factor correction and I'm aware of the non-sinusoidal currents and harmonics generated by 3-phase VSDs, etc., and the double-pulse generated on each phase half-cycle. I also have a lot of sub-metering with PF and harmonic analysis but I never considered that aspect. How is it worked out then? On the fundemental of the harmonics? \$\endgroup\$
    – Transistor
    Commented Feb 10, 2016 at 17:55
  • \$\begingroup\$ I know of only one sensible way and that's calculating real power and Vrms x Arms and finding PF from that - see the links under the question I dropped in as a comment. Basically PF can be regarded as a nonsensical value when current harmonics are large. \$\endgroup\$
    – Andy aka
    Commented Feb 10, 2016 at 18:46
  • 1
    \$\begingroup\$ Its an unfortunate issue where PowerFactor & DisplacementPowerFactor is used interchangeably. DisplacementPowerFactor is PURELY the phase difference between the fundamental voltage and the fundamental current. PowerFactor takes into consideration harmonics & neatly resolves to RealPower & VA. For passive loads DPF == PF ... but that isn't always the case. \$\endgroup\$
    – user16222
    Commented Feb 10, 2016 at 22:48
  • 1
    \$\begingroup\$ @otmezger Very late infos ... See this for "other methodology", no cross-detector needed. electronics.stackexchange.com/questions/574979/… \$\endgroup\$
    – Antonio51
    Commented Sep 10, 2021 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.