mesure phase shift

I want measure phase shift between two analog signal which will be feed to two analog pin of arduino uno.

That is very difficult using the ADC.

There is only one ADC in the Arduino Uno, and it is connected in turn to each pin to make a measurement.

Two zero crossing detectors would help.

is it possible to measure it by using any other hardware device with arduino uno.

See reply #1

Hi nabin, the 'zero crossing detector' that jremington mentioned is a circuit that will send a pulse when a waveform crosses zero, so twice per period. Since the pulses are on or off, you don't need to use the adc. Then you can measure the time between pulses.

I'm a new Arduino new learner.can Anyone give me the arduino code to measure phase shift of two signal?

How is it hooked up?

I want to measure power factor using emonlib.h how can I do it?I can't understand the program related with emonlib.h which is in this forum.

What happened to the phase shift measurement? Myself and Mr. Remington have been trying to follow you, and help, but you ignore our suggestions, and when asked questions, you restate the same question, or change the topic.

Good luck with your project.

Sorry sir.I think If I can measure power factor with the help of Emonlib.h then I able to find phase shift by cos-1(power factor).and also this library can find Vrms and Irms and pf which I need.So please sir help me.

code:
#include “EmonLib.h” // Include Emon Library
EnergyMonitor emon1; // Create an instance

void setup()
{
Serial.begin(9600);

emon1.voltage(2, ?, ?); // Voltage: input pin, calibration, phase_shift
emon1.current(1, ?); // Current: input pin, calibration.
}

void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of crossings, time-out
emon1.serialprint(); // Print out all variables
}

How can I calculate those “?” marked in program by multimeter according to my system(attached as jpg).

ChrisTenone:
What happened to the phase shift measurement? Myself and Mr. Remington have been trying to follow you, and help, but you ignore our suggestions, and when asked questions, you restate the same question, or change the topic.

Good luck with your project.

power factor is the cosine of the phase-shift, its the same measurement.

MarkT:
power factor is the cosine of the phase-shift, its the same measurement.

Ok, but the OP was not responding to suggestions or questions. Now that I throw up my hands, code gets posted, and a diagram is shown.

Hi Nabin,

I apologize for misunderstanding your intent. Thank you for posting more details about your project. I've never used that library, so hopefully someone here will be able to help.

nabin1994:
Sorry sir.I think If I can measure power factor with the help of Emonlib.h then I able to find phase shift by cos-1(power factor).and also this library can find Vrms and Irms and pf which I need.So please sir help me.

code:
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance

void setup()
{
Serial.begin(9600);

emon1.voltage(2, ?, ?); // Voltage: input pin, calibration, phase_shift
emon1.current(1, ?); // Current: input pin, calibration.
}

void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of crossings, time-out
emon1.serialprint(); // Print out all variables
}

How can I calculate those "?" marked in program by multimeter according to my system(attached as jpg).

Hi
I realize this was some time back.
Lets assume you are going to measure 60 Hz. That is slow enough that
you can measure about 10 samples of each per cycle. You know the frequency so
it is relatively easy to generate a delay for 180 degrees of the voltage
signal. Multiply the each of these times the current samples.
Take the average peaks of the two. Use inverse tangent to determine
the angle.
Hope this helps some.
Dwight

jremington:
That is very difficult using the ADC.

There is only one ADC in the Arduino Uno, and it is connected in turn to each pin to make a measurement.

Two zero crossing detectors would help.

Is it that difficult? You can determine the phase of each signal relative to the sample time for each,
then correct for the sample time difference since delta phase = frequency x delta time. Indeed
you can run two software phase-locked-loops in tandem referenced to micros() and get the phase
difference directly.

So I reckon its the same problem as implementing a software PLL.

I think I forgot a square root in there.
Before doing an arc tan you need to do a square root.
Using off chip zero cross detectors is not as good as
doing a correlation of the two signals. Still, for
most things, it is probably good enough. It works good
for nice things like motors but not so good for things
like switcher power supplies.
Dwight

MarkT:
Is it that difficult?
So I reckon its the same problem as implementing a software PLL.

For a beginner, yes, it is very difficult.

But maybe a question in “science and measurement” isn’t a beginner question?

Can't you judge for yourself?

nabin1994:
I'm a new Arduino new learner.can Anyone give me the arduino code to measure phase shift of two signal?

An old trick for finding an accurate zero crosssing on a signal ( +ve or -ve ) it to invert the signal and put a comparator beween the inverted and non-inverted signal.

Given fast devices, this works up to quite a high frequency - MHz.

Do this for each of your signals, and time between the two resultant square waves

this comparison even takes out the delay of the invertors and comparators ( which should be pretty small).

regards

Allan