DSPRelated.com
Forums

High frequency and time resolution phase detection

Started by bogdanl March 29, 2011
Hello all!

Before getting to the point, I'd like to mention that I'm a beginner in
DSP, so please, don't throw anything at me.

Lately I've been spending my spare time trying to write a program (in Qt,
if it matters) to detect rapid phase changes in a tone. By rapid, I mean
once every 32 ms, 16 ms, 8 ms, 4 ms, or even 2 ms. But, at the same time, I
need to have a high frequency resolution (1 Hz, or possibly 0.1 Hz). I use
FFT to display a spectrogram, but from what I know, it's not a solution for
rapid phase changes detection.

While researching this, I came across Goertzel's algorithm, and I've tried
it, but some (many :D) things are not clear to me. For example, for a
sample rate of 32000, if I want to check the phase every 32 ms, I need to
run Goertzel for 1024 points, right? But that would give me a frequency
resolution of 31.25 Hz. If I decrease the sampling interval to 16 ms, that
would mean running Goertzel for 512 points and a frequency resolution of
62.5 Hz. I'm not sure if all this is correct, or not.

From what I get, the higher the time resolution, the lower the frequency
resolution gets, and vice-versa.

So, how should I tackle this problem? If you need any more details, please
let me know.

Thanks in advance for your time.


On 03/29/2011 12:24 PM, bogdanl wrote:
> Hello all! > > Before getting to the point, I'd like to mention that I'm a beginner in > DSP, so please, don't throw anything at me. > > Lately I've been spending my spare time trying to write a program (in Qt, > if it matters) to detect rapid phase changes in a tone. By rapid, I mean > once every 32 ms, 16 ms, 8 ms, 4 ms, or even 2 ms. But, at the same time, I > need to have a high frequency resolution (1 Hz, or possibly 0.1 Hz). I use > FFT to display a spectrogram, but from what I know, it's not a solution for > rapid phase changes detection. > > While researching this, I came across Goertzel's algorithm, and I've tried > it, but some (many :D) things are not clear to me. For example, for a > sample rate of 32000, if I want to check the phase every 32 ms, I need to > run Goertzel for 1024 points, right? But that would give me a frequency > resolution of 31.25 Hz. If I decrease the sampling interval to 16 ms, that > would mean running Goertzel for 512 points and a frequency resolution of > 62.5 Hz. I'm not sure if all this is correct, or not. > > From what I get, the higher the time resolution, the lower the frequency > resolution gets, and vice-versa. > > So, how should I tackle this problem? If you need any more details, please > let me know. > > Thanks in advance for your time.
Well, you appear to be a second-stage beginner -- you've progressed beyond thinking "how can I use the FFT to solve this" to "how can I solve this with either the FFT or the Goertzel", or even as far as "wait a minute, there's got to be more to it than that!". Someone needs to ask "phase relative to what"? -- I guess I'll elect myself. If you mean phase relative to the incoming signal's average phase, and unless you have some confounding issues in your signal, I think I'd make PLL follower. This would show zero degrees phase difference once it had settled on a steady tone, but it would quickly show phase differences between it's following tone and the incoming tone. This would not only be used by the PLL to correct its following tone's phase, but you'd use it to estimate your phase difference. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On Mar 29, 9:24&#4294967295;pm, "bogdanl" <bogdanlazanu@n_o_s_p_a_m.yahoo.com>
wrote:
> Hello all! > > Before getting to the point, I'd like to mention that I'm a beginner in > DSP, so please, don't throw anything at me. > > Lately I've been spending my spare time trying to write a program (in Qt, > if it matters) to detect rapid phase changes in a tone. By rapid, I mean > once every 32 ms, 16 ms, 8 ms, 4 ms, or even 2 ms. But, at the same time, I > need to have a high frequency resolution (1 Hz, or possibly 0.1 Hz). I use > FFT to display a spectrogram, but from what I know, it's not a solution for > rapid phase changes detection.
Contrary to popular belief, DSP is about engineering. That is, what a DSP engineer does is utalitarian rather than entertaining. With that in mind: 1) What do you hope to achieve doing this phase detection? 2) Why do you 'need' the frequency resolution you state? 3) Why do you think the question you ask has an answer worth stating? ( see http://en.wikipedia.org/wiki/Not_even_wrong ) Rune
Hello again!

Thank you both for your answers. I'll try to clarify things, a little.

To answer Tim's question ("phase relative to what?"): I'm interested in the
phase relative to the phase the signal had in the previous 32 ms interval.

As for what I hope to achieve... it's purely an attempt to fill up my free
time doing something useful. I'm trying to decode PSK (Phase Shift Keying)
signals. More to the point, binary PSK (BPSK-31, BPSK-63 etc.), which have
31.25 baud and 62.5 baud, respectively. Hence, the 32 ms and 16 ms time
intervals. The 'binary' part of the name states that only two opposite
phases (pi/2 difference) are used.

Let's take BPSK-31 as an example. In theory, it only has a bandwidth of
about 31 Hz, so I 'need' to read the phase of the signal exactly in the
center of the signal. As a test, I've used a software tone generator to
generate a sine wave at 1000 Hz, and with a small test program I wrote, I
was computing the phase using the Goertzel algorithm. The phase I was
getting was constant, but if I'd shift the generated signal by one Hertz
(say, to 1001 Hz) and left it there, the phase I was reading at 1000 Hz
began to fluctuate.

Regarding your third question, Rune, I'm not really sure what you mean. But
I hope I've answered it above. :)

Thank you.
On Mar 30, 7:56&#4294967295;am, "bogdanl" <bogdanlazanu@n_o_s_p_a_m.yahoo.com>
wrote:
> Hello again! > > Thank you both for your answers. I'll try to clarify things, a little. > > To answer Tim's question ("phase relative to what?"): I'm interested in the > phase relative to the phase the signal had in the previous 32 ms interval. > > As for what I hope to achieve... it's purely an attempt to fill up my free > time doing something useful. I'm trying to decode PSK (Phase Shift Keying) > signals. More to the point, binary PSK (BPSK-31, BPSK-63 etc.), which have > 31.25 baud and 62.5 baud, respectively. Hence, the 32 ms and 16 ms time > intervals. The 'binary' part of the name states that only two opposite > phases (pi/2 difference) are used. > > Let's take BPSK-31 as an example. In theory, it only has a bandwidth of > about 31 Hz, so I 'need' to read the phase of the signal exactly in the > center of the signal.
No, you don't. If BPSK is what you play with, you need to read up on BPSK modulation techniques.
> As a test, I've used a software tone generator to > generate a sine wave at 1000 Hz, and with a small test program I wrote, I > was computing the phase using the Goertzel algorithm. The phase I was > getting was constant, but if I'd shift the generated signal by one Hertz > (say, to 1001 Hz) and left it there, the phase I was reading at 1000 Hz > began to fluctuate. > > Regarding your third question, Rune, I'm not really sure what you mean. But > I hope I've answered it above. :)
It means that you have a lot of reading to do, on the techniques you play with, before you can even state a meaningful question. Rune
On Mar 30, 10:02&#4294967295;am, Tim Wescott <t...@seemywebsite.com> wrote:
> On 03/29/2011 12:24 PM, bogdanl wrote: > > > > > Hello all! > > > Before getting to the point, I'd like to mention that I'm a beginner in > > DSP, so please, don't throw anything at me. > > > Lately I've been spending my spare time trying to write a program (in Qt, > > if it matters) to detect rapid phase changes in a tone. By rapid, I mean > > once every 32 ms, 16 ms, 8 ms, 4 ms, or even 2 ms. But, at the same time, I > > need to have a high frequency resolution (1 Hz, or possibly 0.1 Hz). I use > > FFT to display a spectrogram, but from what I know, it's not a solution for > > rapid phase changes detection. > > > While researching this, I came across Goertzel's algorithm, and I've tried > > it, but some (many :D) things are not clear to me. For example, for a > > sample rate of 32000, if I want to check the phase every 32 ms, I need to > > run Goertzel for 1024 points, right? But that would give me a frequency > > resolution of 31.25 Hz. If I decrease the sampling interval to 16 ms, that > > would mean running Goertzel for 512 points and a frequency resolution of > > 62.5 Hz. I'm not sure if all this is correct, or not. > > > &#4294967295;From what I get, the higher the time resolution, the lower the frequency > > resolution gets, and vice-versa. > > > So, how should I tackle this problem? If you need any more details, please > > let me know. > > > Thanks in advance for your time. > > Well, you appear to be a second-stage beginner -- you've progressed > beyond thinking "how can I use the FFT to solve this" to "how can I > solve this with either the FFT or the Goertzel", or even as far as "wait > a minute, there's got to be more to it than that!". > > Someone needs to ask "phase relative to what"? -- I guess I'll elect myself. > > If you mean phase relative to the incoming signal's average phase, and > unless you have some confounding issues in your signal, I think I'd make > PLL follower. &#4294967295;This would show zero degrees phase difference once it had > settled on a steady tone, but it would quickly show phase differences > between it's following tone and the incoming tone. &#4294967295;This would not only > be used by the PLL to correct its following tone's phase, but you'd use > it to estimate your phase difference. > > -- > > Tim Wescott > Wescott Design Serviceshttp://www.wescottdesign.com > > Do you need to implement control loops in software? > "Applied Control Theory for Embedded Systems" was written for you. > See details athttp://www.wescottdesign.com/actfes/actfes.html
He would need to integrate the phase dector output of course since the PD gives rate of change of phase. Hardy
First of all, I've noticed that I've made a mistake in my earlier post. The
phase difference is pi, not pi/2.

> >No, you don't. If BPSK is what you play with, you need to read >up on BPSK modulation techniques. >
Can you suggest some starting points on BPSK modulation? Some books/articles, maybe?
On Mar 30, 2:50&#4294967295;am, "bogdanl" <bogdanlazanu@n_o_s_p_a_m.yahoo.com>
wrote:
> First of all, I've noticed that I've made a mistake in my earlier post. The > phase difference is pi, not pi/2. > > > > >No, you don't. If BPSK is what you play with, you need to read > >up on BPSK modulation techniques. > > Can you suggest some starting points on BPSK modulation? Some > books/articles, maybe?
http://aintel.bi.ehu.es/psk31.html
>On Mar 30, 2:50=A0am, "bogdanl" <bogdanlazanu@n_o_s_p_a_m.yahoo.com> >wrote: >> First of all, I've noticed that I've made a mistake in my earlier post.
T=
>he >> phase difference is pi, not pi/2. >> >> >> >> >No, you don't. If BPSK is what you play with, you need to read >> >up on BPSK modulation techniques. >> >> Can you suggest some starting points on BPSK modulation? Some >> books/articles, maybe? > >http://aintel.bi.ehu.es/psk31.html >
Thanks, but I already know that site. The pages it links to are either in languages I don't read, or are 404 not found.
Yeah, most of the links are either dead or in German, but the fourth you might find useful:
http://det.bi.ehu.es/~jtpjatae/pdf/p31g3plx.pdf - especially page 4, which shows an example of a demodulator.

Chris