# How to mesure phase in a signal

Status
Not open for further replies.

#### penrico

##### Full Member level 5
Hey guys, i have a signal that there is no way to get the exact frecuency of it , I know it's between 50khz to 80Khz.

My problem is that I need to know the phase of it. Can you give me some advices in what techniques to use to get the phase of this signal. Thanks

You need to know the frequency to measure phase exactly. Also, phase is in comparison with either another signal or with a time reference point like t=0.

For crude measurements, you could use a comparator and find out the positive and negative going zero crossings.

flatulent: I know that I must know the frecuency to get the phase, if I multiply the signal with sines and cosines at same frecuency I can get the phase, but the problem is that my signal can vary from the central frecuency, and I don't have the exactly frecuency that I receive, my question is if there's some method to obtain the phase without know the frecuency.

That sounds like an impossible situation, unless you know something about the expected phase variations. I assume these variations are some sort of modulated information, yes?

If you do that complex multipication using a frequency guess such as 65kHz, do you see any useful information in the output? Maybe you can lock onto some known repeating pattern in the information, and use it as a phase reference.

echo47, I can say the phase variations are a kind of modulation, but there's not pattern at all, except that phase changes are slow and never strongs.

Hi penrico,

You must have a reference. The phase is defined with respect to this reference.
In general, phase is time-dependent.
Think in phasors. At any time, the phase is the angle between the signal phasor and the reference phasor.
If your signal is a sinusoid with frequency different from the reference signal, its phase increases (or decreases) with time.

Let the signal
x(t)=Re{A(t)*exp[j*(w*t+phi(t))]}
where A(t), w, phi(t) are real.

If the reference signal is
r(t)=Re{exp[j*(w0*t+phi0)]},

The phase of x(t) [with respect to the reference] is phiX(t) that satisfies
x(t)=Re{ A(t)*exp[j*(w0*t+phiX(t))]}

So, the phase of x(t) is
phiX(t) = (w-w0)t + phi(t)-phi0

Regards

Z

Thanks Zorro, but is there a way to eliminate the (w-w0)t factor?

Hmmm...
You should make w0=w, but if w is not known... it’s not possible.
Anyway, a measure of phase makes sense related to a reference. You should define:
2) What do you intend to do with this phase?

Z

Hello all.
I'm not very sure that I undertood completely the problem, but ....
My idea is the following:
I think a reference is really needed to measure this phase.
This reference can just be a delay. Provided that for all freqquencies in the required range this delay is less than 360 degrees...
Assuming that the amplitude is constant (it can be obtained by using any kind of amplitude limiter, for example using opamps and diodes). It is aproximately a sinusoidal form, and that it has some phase modulation, i.e., the information you want to get....

If you multiply the input signal by itself delayed by the fixed delay above you will get:

v1= A0 sin (wt)
v2= A0 sin (wt + w t0)
A0= sqrt(2) * A

v1*v2= (A**2) [sin wt * sin (wt + w t0)]

Then
v1*v2= (A**2) [cos (2wt + wt0) + cos(wt0)]

Using a low pass filter to suppress the second harmonic and assuming that the second harmonic of the lowest frequency is higher than the highest frequency.

v1*v2= (A**2) [cos(w t0)]

Assuming that the information you want is a kind of phase or frequency modulation of the carrier:

w=w0 + dw(t)

v1*v2= (A**2) cos [(w0 + dw(t)) t0]

If t0 is very small:

v1*v2 ~ (A**2) t0 [w0 + dw(t)]

Using a high pass filter to suppress the DC

v1*v2 = (A**2) t0 dw(t)

Now, using an integrator (low pass filter):

Integral (v1*v2) dt = (A**2) t0 Integral (dw(t) dt)

Integral (v1*v2) dt = (A**2) t0 PHI(t)

And then the desired phase is:

PHI(t) = [1/((A**2) t0)] Integral (v1*v2) dt

Hope it can be of any help.
Greetings to all
S.

### penrico

Points: 2
Sinatra, as I know

sin(w1*t)*sin(w2*t+d) = 0.5 * {sin[(w1-w2)*t-d] + sin[(w1+w2)*t+d]}

but not

sin(wt)*sin(wt+d) != sin (wt) + sin(wt+d)

Sorry Penrico.
I just mistyped that equation.
The continuation should be all right.
Another remark: I believe that there could be some dynamic range limitation or too much noise in the output signal.
This should be checked further by some kind of simulation or a real construction to verify if the technique can be used.....
I believe the technique should be ok.
The interesting remark is that the phase could be obtained without the need of an external frequency reference.
Please check to see if there are other possible mistakes.
Greetings to all.
S.

Thanks sinatra, I will study what you post me...

hello all.
Just a last remark:
A fixed frequency reference is not needed anymore because of the suppression of the term w0t0 by the high pass filter (DC suppression).
This term w0t0 could also be used to tell what is the frequency that is in the input of the system......

Penrico, do you have a dsp to test this?????
What type of dsp????
greetings
S.

Sinatra, I'll on a small DSP TMS320LF2401A,

I simulate it, making a software in Builder C++ but don't work, I think is wrong that the delay can be expresed as: w t0, and then the modulation be replaced as (w0 + dw/dt) * t0

Anyway, the idea is too good, i'm tring the same, but can't get the expected results.

Hi,

an interesting idea. sinatra, how do you think, is there a possibility to eliminate a phase difference of 2 signals having the same frequency in this way?
Here 1 signal is the reference, the other is its copy but mixed with white noise. This small signal must be detected in the presence of amounts of
uncorrelated noise in the way a lock-in amplifier acts: phase shifting and demodulation followed by a low-pass filter. Are there algorithms for eliminating phase difference of this 2 signals automatically at all?

Thanks

Hello penrico.
w t0 is all right. It is the phase delay that a sinusoidal signal will have after it will have passed the delay t0. I think there is no problem there....

Sorry also for the notation I have used for dw, this means delta ohmega.....this means a small variation of w when compared to the DC value w0. I will have to study more to see if this is a wrong assumption when I use it again later to build the integral that will give us the phase....but I believe it is also all right. Maybe you could try Matlab. It could probably help you more with its nice plot function....

kirgizz: your problem seems similar, a kind of inverse problem. In fact I think if you multiply the 2 signals as a lock in you willl find the phase difference. Normally when you use this process the phase difference is what you are looking for. So I didn't understand very well your problem. Why do you want to eliminate the phase difference? What is the information you would like to extract from these small signal???

Greetings to all.
S.

PS: Sorry again guys. I had to edit the 3 last equations and add the "dt" term that was missing in the integrals....

Read all posts. It leans towards a digital processor solution.

Hello sinatra,

I read about methods used in analogue lock-in amps. And I want to make the same in DSP. These methods (phase shitfing followed by multiplying) are used to find the resonance between the reference and the identical small signal "hidden" in white noise. This narrow width small signal is amplified by that (and as good as identified). That's why I want to eliminate the phase difference: to achieve the resonance. It might be possible I'm wrong but it's my understanding of lock-in principle.

regards

Sinatra,

Finally I study well your sollution, it's OK that a delay is w t0, I was simultaing how the method works, and work's ok for phase changes, you can get phase changes when you compare a periodical signal with it same signal delayed, if signal changes, when you compare it with the same signal some time ago, you will see that the signal changes itself, and its the result, if phase changes, I can have it result.

Thanks sinatra, it's whats i'm looking for.

Hello Kirgizz.

I think I understood now. You just want to get a signal out of the noise,. And the frequency of the signal is a parameter that you now.

You can use the lock-in technique. There is no problem if there is a phase difference. The phase difference is an extra para meter that the lock in technique will give to you.
If this parameter is not needed just ignore it.

If your signal (the one inside of the noise) has some kind of modulation the lock-in technique will get it also.

In principle I would try to do the following:

1- Multiply the signal by a reference frequency that is the same of the signal I want to get.
2- Pass the result into a sharp low pass filter, high order FIR if you have enough processing power. And with a bandwidth large enough to let the modulation of your incoming signal pass.
3-After that you will get as output the modulation of your signal plus some DC proportional to the phase difference or something like that.....
4-If you don't want the phase difference just pass this output signal through a DC block (very low cut-off frequency high pass filter).

Then I think that is it, you got your information.....

What is the dsp that you are using????

Penrico: I'm glad I could help you. If you get any result just get in touch again and keep us informed of the progress.
A question, could you check the dynamic range and the signal noise ratio? I believe those are 2 important parameters in this application and those parammeters will tell if the algorithm is really good.

Greetings
S.

Status
Not open for further replies.