Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to calculate phase shift between two sine wave signals, implementing embedded c

Status
Not open for further replies.

veerubiji

Full Member level 2
Joined
Feb 24, 2011
Messages
122
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
2,301
I two sinewave signals with same frequency. I want to measure phase shift between two signals. There will be a small phase difference between two signals. I am using ATmega32-A micro controller and external ADC AD7798 to read the voltage of both signal. I am able to read both signal voltages using SPI communication. How to find Phase difference between two sine signals. I am using CodeVisionAVR compiler.

I know that phase shift between two signals can be find out using the fallowing formula.
Code:
    A(t)= Am sin(Wt+/-theta).
I know only amplitude(Am) and w =2*pi*f. But How to calculate phase difference between two sinewave signals with knowing amplitude and frequency. Any suggestions please.
 

You could measure the time difference between the zero-crossing of the two signals. (You would also have to pay attention to the slope of the signals at the zero cross as well). Then the phase difference would be:

(360 degrees/period)*time difference
 
That formula alone is enough then Barry why is there a need for slope to be considered here
 

You could measure the time difference between the zero-crossing of the two signals. (You would also have to pay attention to the slope of the signals at the zero cross as well). Then the phase difference would be:

(360 degrees/period)*time difference
Can anyone explain me how to calculate time difference between the zero-crossing of the two signals. Any algorithm or procedure? Because I am just reading the both signals amplitude using ADC and i know the frequency. How to calculate time difference?
 

The point where the ADC op is 0V that point is the zero point comparing the op of the ADC will suffice you
 

The point where the ADC op is 0V that point is the zero point comparing the op of the ADC will suffice you

I am able to read ADC value when output is 0V, then I can read when it is maximum. But how to measure time difference. I didn't understand the concept really. That is why I have asked like that.
 

Since discrete entries are only sampled by the ADC 's at the same time Use a counter that gets initialised to 0 when the first ADC op is 0 till the time the second ADC points to 0

Also consider the Slope of the curve they must be same other wise an error of 180 deg is possible
 

Ok, here's an algorithm:

Sample the first signal
When the signal crosses zero with positive slope, initialize a counter
Now sample the second signal
When the second signal crosses zero with positive slope, stop the counter. The counter now contains a value proportional to phase difference
 

Hi ,

I am using external ADC to signal voltage. I am selecting input or output signal through MUX (multiplexer). I can read only one signal at a time.

- - - Updated - - -

Thanks for the algorithm, Now I will try to implement.
 

Can any one suggest me which is the best method to calculate the phase shift between two signals with same frequency 250KHz.

I am selecting input and output signals through multiplexer. I want to calculate phase shift between input and output signals.

After selecting signal through multiplexer, the signal is passing through demodulator. I am getting demodulator output as D.C signal with max peak voltage of multiplexer output(Sinewave)signal.I am reading that signal using ADC.

Can I calculate phase shift using software without adding any hardware? If not possible with software then suggest me any other way? I am using CodeVision AVR compiler.
 

Sense makes this not.

1) What kind of 'demodulation' is occurring?
2) You are sampling two DC signals which are proportional to magnitude, DC SIGNALS HAVE NO RELATIVE PHASE SHIFT!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top