I am Sudarshan HT from Bangalore, India. I am working on a project on Thyristors and one of the things that I am working on is finding out the Power Factor of the circuit which has a bulb load. In order to find the power factor I need to find the Zero Crossing of both the voltage waveform and the current waveform. After this I will be able to find the phase difference and then the Power Factor.

Project Specifications:

Voltage Input - 415V which is stepped down to 5V before sending it to the Arduino.
Current Input - Given through a Current Transformer
Arduino - Arduino Mega 2560
The input is level shifted and is given to the Analog Pins A0 and A1.

Can anyone help me with the Zero Crossing Detector Code?

sudarshanht:
In order to find the power factor I need to find the Zero Crossing of both the voltage waveform and the current waveform. After this I will be able to find the phase difference and then the Power Factor.

Eh, I don't know if finding the PF based on zero crossing is the best idea. The problem is that if you have a non-linear load, your waveform's zero crossings won't give you an accurate PF reading. What you need to do is compare when your voltage and current waveforms reach their peak values. The time difference between their peak values will give a better measurement of PF.

I am Sudarshan HT from Bangalore, India. I am working on a project on Thyristors and one of the things that I am working on is finding out the Power Factor of the circuit which has a bulb load. In order to find the power factor I need to find the Zero Crossing of both the voltage waveform and the current waveform. After this I will be able to find the phase difference and then the Power Factor.

When you have thyristor switching the zero crossings are not useful to calculate power factor since that
only works for sinusoidal waveforms.

Power factor is actual power / (rms current x rms voltage)
For switched waveforms you need to measure true rms current, power and true power.

Only if the waveforms are pure sinusoids can you use amplitudes and phases as proxy measurements
for this.

No they are not. The voltage may be but you are switching the current taken from the source with
your thyristor circuit, so the current is not a sinusoid. Unless you have an LC tank circuit to filter
out the harmonics (unlikely).