DSPRelated.com
Forums

coefficients compared

Started by Gert Baars September 13, 2005
Hello,

For a low-pass filter with hammingwindow I can calculate
the coefficients manually.

Lets say for n = (L-1)/2  the middle tap (#taps is odd)

coefficient is 2*Fc/Fs. (The Hammingwindow here is 1).

Compared to the FIR filter program ScopeFIR I get exactly
the same values for manually calculated middle-tap coefficient if Fc >= 
1 KHz < Fs/2 while Fs = 12 KHz.
The problem with Fs < 1 KHz is that the difference becomes bigger and 
bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09.

What is causing the difference? All help here is much appreciated.




Gert Baars wrote:

I corrected the previous message.

Hello,

For a low-pass filter with hammingwindow I can calculate
the coefficients manually.

Lets say for n = (L-1)/2  the middle tap (#taps is odd)

coefficient is 2*Fc/Fs. (The Hammingwindow here is 1).

Compared to the FIR filter program ScopeFIR I get exactly
the same values for manually calculated middle-tap coefficient
if Fc >= 1 KHz < Fs/2 while Fs = 12 KHz.

The problem with Fc < 1 KHz is that the difference becomes bigger
and bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09.

What is causing the difference? All help here is much appreciated.



> >
"Gert Baars" <g.baars13@chello.nl> wrote in message 
news:8db2b$4327bdf1$3ec23590$24049@news.chello.nl...
> Gert Baars wrote: > > I corrected the previous message. > > Hello, > > For a low-pass filter with hammingwindow I can calculate > the coefficients manually. > > Lets say for n = (L-1)/2 the middle tap (#taps is odd) > > coefficient is 2*Fc/Fs. (The Hammingwindow here is 1). > > Compared to the FIR filter program ScopeFIR I get exactly > the same values for manually calculated middle-tap coefficient > if Fc >= 1 KHz < Fs/2 while Fs = 12 KHz. > > The problem with Fc < 1 KHz is that the difference becomes bigger > and bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09. > > What is causing the difference? All help here is much appreciated. >
It would help to know what algorithm you're using for designing the filter "by hand". Only then might one compare the two.... Fred
The easiest way is to compare only the center tap which origins
from sinc(0). Here hn = 2*Fc/Fs and the Hamming window = 1.

This equals the centre tap of the ScopeFir design as long as
Fc >= 1 KHz with Fs = 12KHz with LPF.
The difference also gets very small if #TAPS gets very large
no matter what Fc is.





Fred Marshall wrote:
> "Gert Baars" <g.baars13@chello.nl> wrote in message > news:8db2b$4327bdf1$3ec23590$24049@news.chello.nl... > >>Gert Baars wrote: >> >>I corrected the previous message. >> >>Hello, >> >>For a low-pass filter with hammingwindow I can calculate >>the coefficients manually. >> >>Lets say for n = (L-1)/2 the middle tap (#taps is odd) >> >>coefficient is 2*Fc/Fs. (The Hammingwindow here is 1). >> >>Compared to the FIR filter program ScopeFIR I get exactly >>the same values for manually calculated middle-tap coefficient >>if Fc >= 1 KHz < Fs/2 while Fs = 12 KHz. >> >>The problem with Fc < 1 KHz is that the difference becomes bigger >>and bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09. >> >>What is causing the difference? All help here is much appreciated. >> > > > It would help to know what algorithm you're using for designing the filter > "by hand". Only then might one compare the two.... > > Fred > >
Gert Baars wrote:
> Gert Baars wrote: > > I corrected the previous message. > > Hello, > > For a low-pass filter with hammingwindow I can calculate > the coefficients manually. > > Lets say for n = (L-1)/2 the middle tap (#taps is odd) > > coefficient is 2*Fc/Fs. (The Hammingwindow here is 1). > > Compared to the FIR filter program ScopeFIR I get exactly > the same values for manually calculated middle-tap coefficient > if Fc >= 1 KHz < Fs/2 while Fs = 12 KHz. > > The problem with Fc < 1 KHz is that the difference becomes bigger > and bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09. > > What is causing the difference? All help here is much appreciated.
Are the unwindowed coefficients the same? You and ScopeFIR may calculate them differently. To see if the Hamming window is just a red herring, calculate the coefficients with a rectangular window. 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;



Jerry Avins wrote:
> Gert Baars wrote: > >> Gert Baars wrote: >> >> I corrected the previous message. >> >> Hello, >> >> For a low-pass filter with hammingwindow I can calculate >> the coefficients manually. >> >> Lets say for n = (L-1)/2 the middle tap (#taps is odd) >> >> coefficient is 2*Fc/Fs. (The Hammingwindow here is 1). >> >> Compared to the FIR filter program ScopeFIR I get exactly >> the same values for manually calculated middle-tap coefficient >> if Fc >= 1 KHz < Fs/2 while Fs = 12 KHz. >> >> The problem with Fc < 1 KHz is that the difference becomes bigger >> and bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09. >> >> What is causing the difference? All help here is much appreciated. > > > Are the unwindowed coefficients the same? You and ScopeFIR may calculate > them differently. To see if the Hamming window is just a red herring, > calculate the coefficients with a rectangular window. > > Jerry
What I did was do an IFT on H(W) with: H = 1 for -Wc < W < Wc and 0 else the result is now sin(Wc.n) / (pi.n) this equals (Wc/pi) (sin(Wc.n) / (Wc.n)) sinx/x = 1 for x=0 so for n = 0 -> h=Wc/pi = (2.pi.Fc/Fs)/pi = 2.Fc/Fs (a Hamming window = 1 for n = 0) Compared with ScopeFIR the results match if #TAPS is very large or if Fc/Fs is not too small. (with a LPF). What occurs to me is that all the coefficients from ScopeFIR add up to precisely 1 which should be te case indeed. Now I have to find out how I differ from ScopeFIR's method (I selected the Windowed Sinc type of filter).
Gert Baars wrote:

   ...

> Now I have to find out how I differ from ScopeFIR's method > (I selected the Windowed Sinc type of filter).
ScopeFIR uses a different method. It involves no window. There is no reason to expect the results to be identical. In fact, for a given number of taps, you can expect the Parks/McClellan design to match the specs more closely. 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;
Jerry Avins wrote:
> Gert Baars wrote: > > ... > >> Now I have to find out how I differ from ScopeFIR's method >> (I selected the Windowed Sinc type of filter). > > > ScopeFIR uses a different method. It involves no window. There is no > reason to expect the results to be identical. In fact, for a given > number of taps, you can expect the Parks/McClellan design to match the > specs more closely. > > Jerry
What I think ScopeFIR does is correct afterwards. I tried adding up all coefficients with my method (including the Hammingwindow) and then afterwards correct all coefficients so they DO add up to 1. The results sound pretty good.
Gert Baars wrote:
> Jerry Avins wrote: > >> Gert Baars wrote: >> >> ... >> >>> Now I have to find out how I differ from ScopeFIR's method >>> (I selected the Windowed Sinc type of filter). >> >> >> >> ScopeFIR uses a different method. It involves no window. There is no >> reason to expect the results to be identical. In fact, for a given >> number of taps, you can expect the Parks/McClellan design to match the >> specs more closely. >> >> Jerry > > > > What I think ScopeFIR does is correct afterwards. I tried adding up all > coefficients with my method (including the Hammingwindow) and then > afterwards correct all coefficients so they DO add up to 1. The results > sound pretty good.
Windowed sinc is good; numerical approximation methods are a bit better. Coefficients summing to one gives unity gain at DC. For a high-pass filter, they will sum to zero. In fact, with an odd number of symmetric taps, subtracting the sum of a low-pass's taps from the middle one makes an inverting high-pass. Do you see why? 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;
Gert Baars wrote:
> Hello, > > For a low-pass filter with hammingwindow I can calculate > the coefficients manually. > > Lets say for n = (L-1)/2 the middle tap (#taps is odd) > > coefficient is 2*Fc/Fs. (The Hammingwindow here is 1). > > Compared to the FIR filter program ScopeFIR I get exactly > the same values for manually calculated middle-tap coefficient if Fc >= > 1 KHz < Fs/2 while Fs = 12 KHz. > The problem with Fs < 1 KHz is that the difference becomes bigger and > bigger. 2*0.3/12 = 0.05 while scopeFIR calculates 0.09. > > What is causing the difference? All help here is much appreciated.
The formula for determining the number of taps for a given specification seems to be based om empiri. Only general guidelines are given in my books, experienced filter designers might have found more efficient formulas that they might keep quiet about. So given a spec and a filter length N, the sin(Nn)/Nsin(n) terms might be computed differently. Rune