hi, I want to implement a bandpass filter by using Goertzel algorithm. but i encounter a question 1. if i only need to calculate the power which pass through the bandpass filter, does the the phase of input singal will effect the result? 2. What's the relationship between phase of input singal and power which pass through the bandpass filter ? Thanks gilbert

# Goertzel and phase

Started by ●August 20, 2003

Reply by ●August 20, 20032003-08-20

On Thu, 21 Aug 2003 03:21:12 +0800, "Gilbert" <humanbox@ms1.url.com.tw> wrote:>hi,Hello Gilbert,>I want to implement a bandpass filter by using Goertzel algorithm. > >but i encounter a question > >1. if i only need to calculate the power which pass through the bandpass >filter, does the the phase of input singal will effect the result?If I understand your question (that is a big *if*), I'd say no. The power of the signal, if you've filtered a hundred or so samples, will be the same regardless of the phase of the signal that was applied to your Goertzel filter.>2. What's the relationship between phase of input singal and power which >pass through the bandpass filter ? >Whoa! That's a deep question that maybe the math experts, or statisticians, can answer here. My guess is that in most practical Goertzel filtering applications, there is no relationship between the phase of the input signal and the final computed output power. Good Luck, [-Rick-]

Reply by ●August 20, 20032003-08-20

"Rick Lyons" <ricklyon@REMOVE.onemain.com> wrote in message news:3f4401db.34535843@news.west.earthlink.net...> > Whoa! That's a deep question that maybe the math experts, > or statisticians, can answer here. My guess is that in most > practical Goertzel filtering applications, there is no > relationship between the phase of the input signal and the > final computed output power.Rick, et. al., If your window of samples spans an integral number of cycles, then the measured power is phase independent. However, if the window does not span an integral number of cycles or the "k" value is not an integer, then there is a phase dependence. Does this spell the death knell? In practical cases, no. The phase variation may only be a few percent. To see why this is the case imagine the sum I = sum(n=0,n<N) sin^2(2pi*n*k/N) which is the ideal case of having the incomming data matching frequency and being in phase. Expand the square term into 0.5-0.5cos(4pi*n*k/N) The second part sums to zero if you have a whole number of cycles with the 1st part suming to N/2. If your input signal has a phase shift, then just decompose it into the weighted sine and cosine parts. And again you will see that the sum of the oscillating portions almost add to zero (assuming nonintegral number of periods) . But since the oscillating portion will sum up to a small number, then this gets dwarfed by the N/2 term. So the old adage of oversampling (using a lot of periods) reduces the phase dependence when using non-integral numbers of periods. Rick, does this explain it? Clay> > Good Luck, > [-Rick-] > >

Reply by ●August 21, 20032003-08-21

hi,> If your input signal has a phase shift, then just decompose it into the > weighted sine and cosine parts. And again you will see that the sum of the > oscillating portions almost add to zero (assuming nonintegral number of > periods) . But since the oscillating portion will sum up to a smallnumber,> then this gets dwarfed by the N/2 term. So the old adage of oversampling > (using a lot of periods) reduces the phase dependence when using > non-integral numbers of periods. >i have write a Goertzel algorithm code using matlab as below: N=104; fs=8000; % sample rate fi=153; % filter center frequency k=(N*fi)/fs; c153=cos(2*pi*k/N); % coefficient n=1:104; tn=n/fs; xin_153=sin(2*pi*fi*tn)+1; y153n=0; y153n2=0; y153n1=0; d=0; for i=1:104 d=d+1; adc_value=xin_153(i); if(d==1) y153n=adc_value; else % calcuate the value of yn, using Goertzel y153n=(2*c153)*(y153n1)-(y153n2)+adc_value; y153n2=y153n1; y153n1=y153n; end end % Getting power y153n=(y153n*y153n)+(y153n1*y153n1)-(2*c153*y153n*y153n1) fi= flter central frequency , fs= sample rate , c153 is the coefficient for determining filter frequency. My question is : 1. Is the method of computing c153 correct ? 2. if i add phase in the tern xin_153=sin(2*pi*fi*tn)+1 for example, xin_153=sin(2*pi*fi*tn+180)+1; ^^^^ The result of y153n, locate at last line of code , is big different from original result. if i want to implement it in practical circuit, should i consider the phase error to get correct result ? Thanks, gilbert