Reply by phuture_project July 5, 20042004-07-05
Hi Tim,

> Everything is based on the sampling frequency, but this just means that > everything changes should you change the sampling frequency. So if you > sample at 40kHz and design a filter for 9kHz, you have a filter that's > designed for 1.41 radians/sample. If you change your sampling rate to > 80kHz your 9kHz signal is now at 0.707 radians/sample and you have to > redesign your filter.
> This was my point about buying the book. It should have been mentioned, > but the Goetzel algorithm is just an IIR bandpass filter with the poles > right on the unit circle, which means that for a sine wave input it has > a response equal to n * sin(theta*n) -- so after N samples you need to > divide by N, and you need to make sure you're measuring the peak (or > calculating it from two successive values). This would require 1000 > words of explanation to scratch the surface, but is patently obvious if > you've read the book.
Thanks for all the explanations. It does help.
Reply by Tim Wescott July 2, 20042004-07-02
phuture_project wrote:

> Hi Tim, > > > >>Once you sample, the signal is no longer in the domain of continuous >>time of seconds, days and years. It's just this sample, the previous >>sample, and the next sample. You have to bridge between the real >>frequency (9kHz) and the frequency in the sampled domain, which depends >>on the sample rate. > > > I completely understand it. Nevertheless i thought the frequency of > the sampled domain is just the sample frequency? Apparently that's not > what you suggest, aren't you? >
Everything is based on the sampling frequency, but this just means that everything changes should you change the sampling frequency. So if you sample at 40kHz and design a filter for 9kHz, you have a filter that's designed for 1.41 radians/sample. If you change your sampling rate to 80kHz your 9kHz signal is now at 0.707 radians/sample and you have to redesign your filter.
> >> Yes, you need to divide the final result by N. > > > Really? Yes! For me it's logical but as nobody told me about it i > thought i was wrong. But why none paper about the goertzel algorithm > says it? >
This was my point about buying the book. It should have been mentioned, but the Goetzel algorithm is just an IIR bandpass filter with the poles right on the unit circle, which means that for a sine wave input it has a response equal to n * sin(theta*n) -- so after N samples you need to divide by N, and you need to make sure you're measuring the peak (or calculating it from two successive values). This would require 1000 words of explanation to scratch the surface, but is patently obvious if you've read the book.
> > > >>Both of the answers that I gave you should have ended with "but if you >>got a basic DSP book and read it you wouldn't need to ask". If you get >>a book you'll get 200000 words of information presented in a clear >>(well, hopefully) and consistent manner, that present all of the little >>bits and pieces in a way that makes sense and supports follow-on >>information. You'll also be able to carry it around with you and read >>it whenever you get a chance (I'd say that if you're in placement your >>managers should welcome a sign that you're studying something new, but >>that assumes rational management). >> >>If you want to get the information on USENET or on the web you'll have >>to search Google for the right keywords and you'll have to coax us for >>information (remember your complaint about the thread drying up?). >>You'll spend a lot more time time digging up 200000 words on the >>internet than you will by buying a book, and what you do get will be >>disjointed, inconsistent, with some parts repeated many times and large >>parts not mentioned at all. >> >>I'd recommend the web and USENET for one of two things: if you're not a >>DSP person but you need to do one single, simple thing in which case you >>can get a cookbook recommendation and follow it, or if you _are_ a DSP >>person and you need to find out about a new technique in which case you >>will hear an outline and fill in the rest from your understanding. > > > > I know you're right. I'll surely buy one since i will follow my > studies and since i want, if possible, to work in this domain. > > Thank you.
-- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by phuture_project July 2, 20042004-07-02
Hi Tim,

 
> Once you sample, the signal is no longer in the domain of continuous > time of seconds, days and years. It's just this sample, the previous > sample, and the next sample. You have to bridge between the real > frequency (9kHz) and the frequency in the sampled domain, which depends > on the sample rate.
I completely understand it. Nevertheless i thought the frequency of the sampled domain is just the sample frequency? Apparently that's not what you suggest, aren't you?
> Yes, you need to divide the final result by N.
Really? Yes! For me it's logical but as nobody told me about it i thought i was wrong. But why none paper about the goertzel algorithm says it?
> Both of the answers that I gave you should have ended with "but if you > got a basic DSP book and read it you wouldn't need to ask". If you get > a book you'll get 200000 words of information presented in a clear > (well, hopefully) and consistent manner, that present all of the little > bits and pieces in a way that makes sense and supports follow-on > information. You'll also be able to carry it around with you and read > it whenever you get a chance (I'd say that if you're in placement your > managers should welcome a sign that you're studying something new, but > that assumes rational management). > > If you want to get the information on USENET or on the web you'll have > to search Google for the right keywords and you'll have to coax us for > information (remember your complaint about the thread drying up?). > You'll spend a lot more time time digging up 200000 words on the > internet than you will by buying a book, and what you do get will be > disjointed, inconsistent, with some parts repeated many times and large > parts not mentioned at all. > > I'd recommend the web and USENET for one of two things: if you're not a > DSP person but you need to do one single, simple thing in which case you > can get a cookbook recommendation and follow it, or if you _are_ a DSP > person and you need to find out about a new technique in which case you > will hear an outline and fill in the rest from your understanding.
I know you're right. I'll surely buy one since i will follow my studies and since i want, if possible, to work in this domain. Thank you.
Reply by Tim Wescott July 1, 20042004-07-01
phuture_project wrote:

> Hi Tim, > > Thanks for your answer. > > > >>For the Goertzel to work omega needs to equal the sampled-time frequency >>of your signal, or 2*Pi*target_frequency/F_sample. If you do the math >>you'll find that this is the case. > > > I'm sorry but what is "the sampled-time frequency of the signal"? > Moreover, in the initialization, one sets > omega=2*Pi*target_frequency/F_sample. So what do you mean exactly? >
Once you sample, the signal is no longer in the domain of continuous time of seconds, days and years. It's just this sample, the previous sample, and the next sample. You have to bridge between the real frequency (9kHz) and the frequency in the sampled domain, which depends on the sample rate.
> > >>The magnitude of the signal is the same, but the Goertzel filter's state >>will increase as the integral of the energy at that signal frequency, so >>running it longer will increase its internal magnitude. > > > I'm sorry once again but i can't see how one can rely on this > algorithm if the final result doesn't remain the same. Studying the > algorithm it's clear that if N increases so does the final result. But > for me it's not logic, the final result one expects should be always > the same since it deals with the magnitude of the incoming signal. > Isn't there one more step in the algorithm? I don't know but such as > dividing the final result by N? Could you explain, please? >
Yes, you need to divide the final result by N.
> > >>The FFT only computes things with respect to the sample frequency, so >>all of it's frequencies must be translated if you want real-world units. > > > ?? > > > >>You chose to dive in at the deep end. There's way more to DSP than you >>can learn from just newsgroup postings. I suggest that you get a good >>book on DSP (ask the group, I can tell you what university classes to >>take but not what books to read for self help). If you have the time >>and are close to a school with a good electronics engineering program >>you may want to take some signal processing classes. > > > > I'm currently in placement. Nobody in this company is familiar with > DSP so i must do with my knowledges and try to find an external help. > I do it with the means i have : internet. I don't have the time to > search for a book, buy it then read it. I thought it was quicker to > ask specialists their help. Maybe i'm wrong, but i must do with it. > I'm all alone here! > > Thanks again.
Both of the answers that I gave you should have ended with "but if you got a basic DSP book and read it you wouldn't need to ask". If you get a book you'll get 200000 words of information presented in a clear (well, hopefully) and consistent manner, that present all of the little bits and pieces in a way that makes sense and supports follow-on information. You'll also be able to carry it around with you and read it whenever you get a chance (I'd say that if you're in placement your managers should welcome a sign that you're studying something new, but that assumes rational management). If you want to get the information on USENET or on the web you'll have to search Google for the right keywords and you'll have to coax us for information (remember your complaint about the thread drying up?). You'll spend a lot more time time digging up 200000 words on the internet than you will by buying a book, and what you do get will be disjointed, inconsistent, with some parts repeated many times and large parts not mentioned at all. I'd recommend the web and USENET for one of two things: if you're not a DSP person but you need to do one single, simple thing in which case you can get a cookbook recommendation and follow it, or if you _are_ a DSP person and you need to find out about a new technique in which case you will hear an outline and fill in the rest from your understanding. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by phuture_project July 1, 20042004-07-01
Hi Dave,

Thanks for your answer.

> but I subtract the signal DC or offset before processing and I think it > behaved badly before I did this.
Why does the offset make the algorithm work badly?
> I also start and stop on a signal zero crossing - ditto.
Is it really important to start on a zero crossing? Why? Thanks again for your help.
Reply by phuture_project July 1, 20042004-07-01
Hi Tim,

Thanks for your answer.


> For the Goertzel to work omega needs to equal the sampled-time frequency > of your signal, or 2*Pi*target_frequency/F_sample. If you do the math > you'll find that this is the case.
I'm sorry but what is "the sampled-time frequency of the signal"? Moreover, in the initialization, one sets omega=2*Pi*target_frequency/F_sample. So what do you mean exactly?
> The magnitude of the signal is the same, but the Goertzel filter's state > will increase as the integral of the energy at that signal frequency, so > running it longer will increase its internal magnitude.
I'm sorry once again but i can't see how one can rely on this algorithm if the final result doesn't remain the same. Studying the algorithm it's clear that if N increases so does the final result. But for me it's not logic, the final result one expects should be always the same since it deals with the magnitude of the incoming signal. Isn't there one more step in the algorithm? I don't know but such as dividing the final result by N? Could you explain, please?
> The FFT only computes things with respect to the sample frequency, so > all of it's frequencies must be translated if you want real-world units.
??
> You chose to dive in at the deep end. There's way more to DSP than you > can learn from just newsgroup postings. I suggest that you get a good > book on DSP (ask the group, I can tell you what university classes to > take but not what books to read for self help). If you have the time > and are close to a school with a good electronics engineering program > you may want to take some signal processing classes.
I'm currently in placement. Nobody in this company is familiar with DSP so i must do with my knowledges and try to find an external help. I do it with the means i have : internet. I don't have the time to search for a book, buy it then read it. I thought it was quicker to ask specialists their help. Maybe i'm wrong, but i must do with it. I'm all alone here! Thanks again.
Reply by Dave Davies June 30, 20042004-06-30
I use Goertzel and it works well. You are welcome to the Java code if 
you want it. Email me and I'll dig it out. It is a while since I wrote 
it - using an algorirthm from the net - but I subtract the signal DC or 
offset before processing and I think it behaved badly before I did this. 
I also start and stop on a signal zero crossing - ditto. Being IIR seems 
to require some care but I doubt you can do the job more efficiently.

I also implemented a Chirp-Z hack with it that worked fine within small 
domain limits i needed - near the unit circle.


dave

phuture_project wrote:
> Nobody wants to help me anymore??
Reply by Tim Wescott June 29, 20042004-06-29
phuture_project wrote:

> Nobody wants to help me anymore?? > > I repost some of my previous questions: > > "I've got a question about k : what is its use? Sorry for this idiot > question but as we have the following equations: > k=(N*target_frequency)/F_sample > omega=(2*Pi*k)/N > I guess that : omega=(2*Pi*N*target_frequency)/(F_sample*N) > Ans so : omega=(2*Pi*target_frequency)/F_sample > If we modify N, k is modified but omega isn't! And as we don't need k > for other calculations, k is used for nothing! Maybe i'm too tired and > i talk nonsense, but am i wrong?"
For the Goertzel to work omega needs to equal the sampled-time frequency of your signal, or 2*Pi*target_frequency/F_sample. If you do the math you'll find that this is the case.
> > "As my prog doesn't work, I've just tried the prog given by Kevin > Banks > in http://www.embedded.com/story/OEG20020819S0057. First i thought it > works. But i've noticed one thing : when we increase N the final > result increases too. I can understand it, i think the reason is that > as N is bigger the calculations are made more times (oups i don't > think this sentence is right in english!). But it disturbs me : > normally we should obtain the same result since it deals with the > magnitude of the signal. This magnitude doesn't depend on N?! Could > you explain me why this fact happens? Maybe I'm too tired again!" >
The magnitude of the signal is the same, but the Goertzel filter's state will increase as the integral of the energy at that signal frequency, so running it longer will increase its internal magnitude.
> > As i don't succeed in making goertzel algorithm work fine, i decided > to use a classic FFT. I chose a 256 real FFT. According to what i > understand the FFT allow to compute the real and imaginary parts of > all the frequencies defined by k*Fs/N with k=0..N-1 Fs:sample rate > frequency N: number of input samples. I don't understand, this is > surely an idiot question, how can the FFT compute these things since > one never gives it the sample frequency? Anyway i guess that if my > signal is at a frequency which doesn't verify k*Fs/N i will never know > the magnitude at this frequency? To adjust it one can only set the > sample frequency since N must be a power of 2, am i wrong? >
The FFT only computes things with respect to the sample frequency, so all of it's frequencies must be translated if you want real-world units.
> > I have another idea. If i made a narrow band-pass filter centered on > my target frequency, will i be able to recover the magnitude of the > signal at about this target frequency?
Yes. I believe I suggested this.
> > That's all for the moment. > I hope somebody will answer. It's hard to develop for a newbie like > me!
You chose to dive in at the deep end. There's way more to DSP than you can learn from just newsgroup postings. I suggest that you get a good book on DSP (ask the group, I can tell you what university classes to take but not what books to read for self help). If you have the time and are close to a school with a good electronics engineering program you may want to take some signal processing classes. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by phuture_project June 29, 20042004-06-29
Nobody wants to help me anymore??

I repost some of my previous questions:

"I've got a question about k : what is its use? Sorry for this idiot
question but as we have the following equations:
k=(N*target_frequency)/F_sample
omega=(2*Pi*k)/N 
I guess that : omega=(2*Pi*N*target_frequency)/(F_sample*N)
Ans so : omega=(2*Pi*target_frequency)/F_sample
If we modify N, k is modified but omega isn't! And as we don't need k
for other calculations, k is used for nothing! Maybe i'm too tired and
i talk nonsense, but am i wrong?"

"As my prog doesn't work, I've just tried the prog given by Kevin
Banks
in http://www.embedded.com/story/OEG20020819S0057. First i thought it
works. But i've noticed one thing : when we increase N the final
result increases too. I can understand it, i think the reason is that
as N is bigger the calculations are made more times (oups i don't
think this sentence is right in english!). But it disturbs me :
normally we should obtain the same result since it deals with the
magnitude of the signal. This magnitude doesn't depend on N?! Could
you explain me why this fact happens? Maybe I'm too tired again!"


As i don't succeed in making goertzel algorithm work fine, i decided
to use a classic FFT. I chose a 256 real FFT. According to what i
understand the FFT allow to compute the real and imaginary parts of
all the frequencies defined by k*Fs/N with k=0..N-1 Fs:sample rate
frequency N: number of input samples. I don't understand, this is
surely an idiot question, how can the FFT compute these things since
one never gives it the sample frequency? Anyway i guess that if my
signal is at a frequency which doesn't verify k*Fs/N i will never know
the magnitude at this frequency? To adjust it one can only set the
sample frequency since N must be a power of 2, am i wrong?


I have another idea. If i made a narrow band-pass filter centered on
my target frequency, will i be able to recover the magnitude of the
signal at about this target frequency?

That's all for the moment.
I hope somebody will answer. It's hard to develop for a newbie like
me!
Reply by phuture_project June 29, 20042004-06-29
Nobody wants to help me anymore??