I am trying to sense the power factor angle using microcontroller.

Now the mechanism that I have thought it that

  1. Measure the zero crossing of voltage
  2. When the voltage zero is sensed, start the timer of micrcontroller and then start sensing the zero of current.
  3. But how to sense zero of currrent? By using a zero crossing current circuit

My problem: I have made zero voltage circuit using transistor and opamps. The transistor is dependant upon the voltage applied between the emitter and base.When the voltage is zero, the transistor is off and the collector 5 V pulse is obtained accross collector and emitter.

But what for current? Is there any electronic device that is turned on/off by current ?

So I think the only solution is to convert the current into voltage and then sense the zero of voltage. Is it a viable solution?

@Andy AKA

  1. Convert voltage and current to digital.
  2. Sample the V and I at much much higher rate-more than 2 times of 60hz ('dont stick close to nyquist:-)') .
  3. Apply low pass filter to the voltage and current.
  4. Apply atleast 6 LP filters,so that I can remove harmonics and get pure 60 Hz wave.
  5. Now I have V and I.
  6. Find Vrms and Irms.
  7. Do cosQ=V*I/(Vrms*Irms).

Doubt: In order to sample current, I must use current transformer(to lower the current) and convert it to voltage and then use a 12 bit ADC or is a ADC avaliable that can directly convert current input to digital?

  • \$\begingroup\$ VI - you need to do this over one cycle (or several cycles) multiplying and accumulating - this gives you the integral of VI. Then you divide that integral by the number of samples you integrated/accumulated over - this gives you average power. Average power / (Vrms*Irms) = cosQ. Hope that makes sense. \$\endgroup\$ – Andy aka Jul 18 '13 at 14:48
  • \$\begingroup\$ Yes...and I wanted to ask about sampling the current. Is an ADC avaliable that converts the current to digital signal directly or current transformer->voltage->ADC is only option? \$\endgroup\$ – Santosh Jul 18 '13 at 16:02
  • \$\begingroup\$ I'm not aware of an ADC that directly takes current especially as you might be wanting to measure AC power circuits and the CT gives isolation too. \$\endgroup\$ – Andy aka Jul 18 '13 at 17:19

I am trying to sense the power factor angle using microcontroller.

To do this with any degree of accuracy and for unknown load conditions is a lot tricker than you think. Consider the following: -

  1. Say your load current doesn't look anything like a sinewave - let's say it looks like the current drawn by a conventional transformer and bridge rectifier - when does the current begin - it begins right as the voltage is reaching its peak and ends just after the voltage peak - the diode bridge draws a thin-ish pulse of current to restore the charge in the smoothing capacitor. What will be the phase angle of the current relative to the voltage waveform? Can you use a simple timer based on zero-crossing? No you can't because it won't relate to real power-factor angles at all.
  2. What if your current wobbled as it passed through zero i.e. it passed thru zero then went back below then continued upwards to its normal peak - what would you take as the reference zero cross? Would either accurately reflect power or the real angle associated with power-factor? No, not necessarily.
  3. What about the amplitude of the current waveform? When it is tiny, noise could have a bearing - what will this do with respect to false triggers on the zero cross? Probably throw out any meaningful reading into the garbage. Maybe comaparotor hysteresis will help?
  4. Comparator hysteresis won't help - this will give you a zero-cross slightly above zero and therefore the zero-cross will be amplitude dependent.

It's tricky for sure. If I were doing it I'd recall that power, for a good sinewave supply voltage is voltage x the fundamental frequency of the current. For a sinewave supply, any harmonics that distort the current DO NOT contribute to power as measured by the utility companies.

On this basis, I'd apply equal low-pass filtering to both voltage and current before doing anything. The filtering doesn't need to be applied to the voltage but, applying it to both keeps both current and voltage waveforms in sync regarding the time delays incurred by such filters and I shouldn't need to say why this is important.

How many orders of low-pass filtering? I'd say minimum 6 and realistically, to keep both filters spot-on I wouldn't waste time doing it in the analogue realm - I'd go straight for converting volts and amps to digital and apply as much digital LP filtering as possible.

Where does this get you? Ultimately I'm trying to calculate real power by multiplying V and I to get real watts. I don't need to filter V and I to do this but, if i want to understand what the RMS value of current is at the fundamental frequency of the supply voltage (the only frequency applicable to power calculations based on a decent voltage waveform) I need to use the filtered waveforms.

So, I've got power (sampled V waveform x sampled I waveform, then averaged per cycle) and I've got RMS volts and RMS amps (based on samples squared, then averaged then square rooted). Don't stick close to nyquist - lets see a thousand samples per cycle in order to capture all the harmonic nuances of the current and avois aliasing.

Next I divide power by the product of the rms values of I and V and this gives me power factor - a value that is zero for current being 90 degrees out of phase to voltage and 1 for volts and amps being totally in-phase - remember I'm talking about the fundamentals being in phase here, not all the harmonics of current - they play no part when the driving voltage is a sinewave.

Power factor converts to phase angle by taking Arc cos and you now have phase angle.

I have designed utility electricity meters in case you wondered!!

  • \$\begingroup\$ 1.Convert voltage and current to digital. 2.Sample the V and I for much much more than 2 times of 16.67 ms ('dont stick close to nyquist:-)') 3.Apply low pass filter to the voltage and current. 4.Apply atleast 6 LP filters,so that I can remove harmonics and get 60 Hz wave. 5.Now I have V and I. 6.Find Vrms and Irms 7.Do cosQ=VI/(VrmsIrms) \$\endgroup\$ – Santosh Jul 18 '13 at 13:28
  • \$\begingroup\$ Sorry for the above comment. Comment section does not allow formatting and after few min edit option is not avaliable. However your answer was very helpful and I found a new way to measure power factor. So I wrote some procedure that I understood. Please check it and correct me where I am wrong. \$\endgroup\$ – Santosh Jul 18 '13 at 13:43

How about an optocoupler in series with the load? You would need a small circuit to rectify (BR1) and limit (D2, D3, R3) the current. D2 and D3 at the same time limit the voltage over the circuit, but worst case there is still about 3V voltage drop from load perspective. V1 should therefore be much higher than 3V.


simulate this circuit – Schematic created using CircuitLab

The output will be pulled high when the LED stops conducting current, hence during the zero crossing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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