DSPRelated.com
Forums

How to measure phase difference between generated sine and the same one after delay

Started by luben_i February 4, 2009
Vladimir Vassilevsky wrote:

   ...

> Generating one sinewave and then delaying it for few samples so the > phase shift is roughly 90 degrees (and then taking that into account) is > cheaper then generating sin() and cos() separately.
That depends on how the sinusoid is generated. Often the quadrature signal is almost free. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
On Feb 4, 8:11&#4294967295;pm, HardySpicer <gyansor...@gmail.com> wrote:
> > I meant analogue!
so wiring up parts to his TI eval board would be easier than writing about 20 or 30 lines of code? i guess that's the difference between hardware folk and guys like me that get our hands dirty less enthusiastically. i thought that the OP basically has all the hardware he needs. whatever :-) r b-j
On Feb 4, 9:09 am, "luben_i" <luben.il...@abv.bg> wrote:
> Hi all, > > I am working with DSP of Texas Instruments on an evaluation bard > TMS320C6711. I have to generate a sine wave, send it to the output of the > board. Then this sine wave passes through a system where it is delayed and > distorted in some way, and then I have to measure the phase difference > between the original and the received signal. I have no problems with the > generation of the sine wave, but the problem is with the phase difference. > Tried with FFT transform, but nothing happened. The sine frequency can be > up to 4kHz. > If someone can help me I would appreciate it very much. > > Thank you in advance.
FFT will most definitely work if you can keep the generated sine wave bin centered (i.e., the FFT will be taken with a integer number of sine waves), which should be easy if you are generating it, then sample both waveforms at the same time, then look at the complex bin of both FFT's at the frequecy of the input sine wave, if the input is (x1,y1) and the output is (x2,y2), the phase is angle = atan2(x1*y2-x2*y1,x1*x2+y1*y2) let me know if you need any more clarification
robert bristow-johnson <rbj@audioimagination.com> wrote:
> On Feb 4, 12:09?pm, "luben_i" <luben.il...@abv.bg> wrote: > >> I am working with DSP of Texas Instruments on an evaluation bard >> TMS320C6711. I have to generate a sine wave, send it to the output of the >> board. Then this sine wave passes through a system where it is delayed and >> distorted in some way, and then I have to measure the phase difference
(snip)
> measuring, OR since you said you have no trouble generating sines, you > should generate two identical sinusoids, except one is 90 degrees > advanced over the other. now only one of the sinusoids is being > outputted, but both sin() and cos() are available to you internally, > as well as the received (delayed) sinusoid.
> let's say that you output the cos() signal to the delay element:
> x[n] = cos(w*n )
> the delay element returns:
> y[n] = A*cos(w*n + phi) + noise
> and it's phi that you want to determine.
> consider
> p[n] = y[n] * cos(w*n) > and > q[n] = y[n] * sin(w*n)
> then consider what you get when you identically lowpass filter both p > [n] and q[n] to the point that only the DC components of each > survives. then consider those two DC residuals as the real and > imaginary parts of a complex number. then compute the angle of that > complex number.
I was about to write something similar, but then decided to see what the other replies were. There are analog multiplier ICs which take two voltages in and generate an output proportional to the product. I believe there are also analog ATAN generators to give you the actual phase angle, but that could also be done after digitizing. -- glen
On Feb 4, 8:58 pm, Jerry Avins <j...@ieee.org> wrote:
> Vladimir Vassilevsky wrote: > > ... > > > Generating one sinewave and then delaying it for few samples so the > > phase shift is roughly 90 degrees (and then taking that into account) is > > cheaper then generating sin() and cos() separately. > > That depends on how the sinusoid is generated. Often the quadrature > signal is almost free. > > ... > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
The sin and cos multiplication is okay if you have a fixed phase offset. However, the whole approach naturally complicates itself into a "simple" PLL solution to track any time varying phase offset within the relevant MTIE envelop (G.812).
On Feb 5, 3:06&#4294967295;pm, tariq.hadda...@gmail.com wrote:
> > The sin and cos multiplication &#4294967295;is okay if you have a fixed phase > offset.
or "slowly varying" phase offset. if the phase offset is wild, this is not a case of driving an LTI system with a sinusoid and measuring properties of the output sinusoid. it's not TI. if the phase offset is increasing linearly with time, the system is actually changing the frequency. if this phase variation is sufficiently slow (it doesn't have to be fixed to a constant), and the LPF filters are a little less slow in their response, you can track it. and it's not a PLL (no feedback servo mechanism).
> However, the whole approach naturally complicates itself into > a "simple" PLL solution to track any time varying phase offset within > the relevant MTIE envelop (G.812).
dunno what either MTIE or G.812 is. i s'pose i could google it. r b-j
tariq.haddad06@gmail.com wrote:
> On Feb 4, 8:58 pm, Jerry Avins <j...@ieee.org> wrote: >> Vladimir Vassilevsky wrote: >> >> ... >> >>> Generating one sinewave and then delaying it for few samples so the >>> phase shift is roughly 90 degrees (and then taking that into account) is >>> cheaper then generating sin() and cos() separately. >> That depends on how the sinusoid is generated. Often the quadrature >> signal is almost free.
...
> The sin and cos multiplication is okay if you have a fixed phase > offset. However, the whole approach naturally complicates itself into > a "simple" PLL solution to track any time varying phase offset within > the relevant MTIE envelop (G.812).
The OP wants to measure the signal's delay through an LTI network. Where might time varying phase offset arise? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
>On Feb 4, 8:58 pm, Jerry Avins <j...@ieee.org> wrote: >> Vladimir Vassilevsky wrote: >> >> ... >> >> > Generating one sinewave and then delaying it for few samples so the >> > phase shift is roughly 90 degrees (and then taking that into account)
i=
>s >> > cheaper then generating sin() and cos() separately. >> >> That depends on how the sinusoid is generated. Often the quadrature >> signal is almost free. >> >> ... >> >> Jerry >> -- >> Engineering is the art of making what you want from things you can
get.
>>
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
>=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= >=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF > >The sin and cos multiplication is okay if you have a fixed phase >offset. However, the whole approach naturally complicates itself into >a "simple" PLL solution to track any time varying phase offset within >the relevant MTIE envelop (G.812).
G.812 relates to synchronisation to a remote source in a PCM network. The OP appears to be sending something out, and looking at the phase shift (i.e. delay) in what comes back. He has no reason to use a PLL to recover the source clock. He *has* the source clock. Steve
Thank you for your advices. I decided to make a cross-correlation between
the output and the input signal and calculate the delay in samples between
the two signals. And then having in mind the sampling frequency and the
number of samples the phase difference is easy to find.

Luben.
On Feb 6, 4:34&#4294967295;am, "luben_i" <luben.il...@abv.bg> wrote:
> Thank you for your advices. I decided to make a cross-correlation between > the output and the input signal and calculate the delay in samples between > the two signals. And then having in mind the sampling frequency and the > number of samples the phase difference is easy to find.
if you don't know, a priori, what quadrants can be ruled out, you must cross-correlate the output to the input *and* you must cross-correlate the output to a known phase-shifted version of the input (likely 90 degrees offset). you must do both cross correlations otherwize you will not know the difference between a phase difference of phi from - phi (or 360-phi). if it's only the input to output correlation, both phi and -phi result in the same cross correlation. r b-j