DSPRelated.com
Forums

FIR Filter

Started by phuture_project June 30, 2004
Hi,

As i've got problems using FFT or Goertzel algorithm (for those who
are interested by the reason see my previous post called "some
goertzel questions"), i'll try to use a narrow bandpass filter. I
already made one some months ago. It was a FIR filter with a bandpass
300-1000 Hz and a sample frequency of 8000 Hz.

Now i'd like to design a narrower filter centered on 9 kHz with a
higher sample frequency, let's say between 100 kHz and 400 kHz, i
don't know for the moment.

For the filter i made some months ago i used the software
http://www.digitalfilter.com/jvfir/jvfir.html in order to get the
coefficients value. But now it doesn't work anymore, the requirements
seem to be too "big".
So is there anybody here who can give me a link to a FREE fir filter
design software which will stand these requirements and allow me to
get the coefficients value? I'll be very grateful!
If this FREE software doesn't exist, could someone tell me how i can
do it with Matlab? I think i'm able to design the filter (i believe i
tried some months ago) with Matlab but not to get the coefficients
value. What code lines must i write?

Thanks again for all the people who will help me. I do apreciate.
Just a thought:

Low bandwidth FIR filters at high samp rates tend to get very long. If 
you want to have 500Hz of bandwidh at fs=400kHz, expect to need about 
800 coefficients (400/0.5)!

I used to design FIR filters in an iterative way using Matlab: Just 
randomly modify your coefficients, and accept a change if it gets you 
closer to what you want. You have to define an error function here. If 
you find no improvement anymore, lower the modification factor, if you 
do, increase it slightly. Let this run for some 1000 iterations. The 
filter is NOT linear phase, but has a better frequency response for a 
given FIR size.

best regards,

Andre



phuture_project wrote:

> Hi, > > As i've got problems using FFT or Goertzel algorithm (for those who > are interested by the reason see my previous post called "some > goertzel questions"), i'll try to use a narrow bandpass filter. I > already made one some months ago. It was a FIR filter with a bandpass > 300-1000 Hz and a sample frequency of 8000 Hz. > > Now i'd like to design a narrower filter centered on 9 kHz with a > higher sample frequency, let's say between 100 kHz and 400 kHz, i > don't know for the moment. > > For the filter i made some months ago i used the software > http://www.digitalfilter.com/jvfir/jvfir.html in order to get the > coefficients value. But now it doesn't work anymore, the requirements > seem to be too "big". > So is there anybody here who can give me a link to a FREE fir filter > design software which will stand these requirements and allow me to > get the coefficients value? I'll be very grateful! > If this FREE software doesn't exist, could someone tell me how i can > do it with Matlab? I think i'm able to design the filter (i believe i > tried some months ago) with Matlab but not to get the coefficients > value. What code lines must i write? > > Thanks again for all the people who will help me. I do apreciate.
-- Please change no_spam to a.lodwig when replying via email!
winfilter is a digital filter design freeware.

http://www.winfilter.20m.com

A new version will be avalaible very soon with 8/16-bit coefficient 
quantization and a possibility of vhdl code generation for fir.

Adrian

phuture_project wrote:
> Hi, > > As i've got problems using FFT or Goertzel algorithm (for those who > are interested by the reason see my previous post called "some > goertzel questions"), i'll try to use a narrow bandpass filter. I > already made one some months ago. It was a FIR filter with a bandpass > 300-1000 Hz and a sample frequency of 8000 Hz. > > Now i'd like to design a narrower filter centered on 9 kHz with a > higher sample frequency, let's say between 100 kHz and 400 kHz, i > don't know for the moment. > > For the filter i made some months ago i used the software > http://www.digitalfilter.com/jvfir/jvfir.html in order to get the > coefficients value. But now it doesn't work anymore, the requirements > seem to be too "big". > So is there anybody here who can give me a link to a FREE fir filter > design software which will stand these requirements and allow me to > get the coefficients value? I'll be very grateful! > If this FREE software doesn't exist, could someone tell me how i can > do it with Matlab? I think i'm able to design the filter (i believe i > tried some months ago) with Matlab but not to get the coefficients > value. What code lines must i write? > > Thanks again for all the people who will help me. I do apreciate.
phuture_project wrote:
> Hi, > > As i've got problems using FFT or Goertzel algorithm (for those who > are interested by the reason see my previous post called "some > goertzel questions"), i'll try to use a narrow bandpass filter. I > already made one some months ago. It was a FIR filter with a bandpass > 300-1000 Hz and a sample frequency of 8000 Hz. > > Now i'd like to design a narrower filter centered on 9 kHz with a > higher sample frequency, let's say between 100 kHz and 400 kHz, i > don't know for the moment.
Hi, I assume you don't have the signal processing toolbox, otherwise use the function fir1 (or similar). Below some code I wrote good luck firsize=1024 fs=80000 fl=300 fh=1000 minfreqbins=3; % choose an appropriate value binsize=fs/firsize; if floor(fl/binsize) < minfreqbins ; % check if you've got enough resolution NUMBER_OF_BINS_TO_LOW_INCREASE_FIRSIZE_OR_LOWER_SAMPLERATE=1 end; % clear transfer h0=zeros(1,firsize/2); % fill pass band with ones h0([round(300/binsize)+1:1:round(1000/binsize)])=1; % make fft spectrum h=[h0(1:firsize/2) fliplr(conj(h0(1:firsize/2)))]'; % make fir, you could window the fir (you should!) f=real(fftshift(ifft(h))); % plot the fir figure(1) plot(f) y=fft(f); % plot amplitude figure(2) semilogx(binsize*[0:1:firsize/2-1],20*log10(abs(y(1:firsize/2))),'r');
Hi Andre,

Thanks for your answer.

> Low bandwidth FIR filters at high samp rates tend to get very long. If > you want to have 500Hz of bandwidh at fs=400kHz, expect to need about > 800 coefficients (400/0.5)!
That's the way to know how many coefficients we have to use? Indeed, it will be very long. That won't be acceptable! Isn't there another way to do it or a way to decrease the execution time? Thanks again.
Hi Adrian,

Thanks for your answer.

> winfilter is a digital filter design freeware. > > http://www.winfilter.20m.com > > A new version will be avalaible very soon with 8/16-bit coefficient > quantization and a possibility of vhdl code generation for fir.
Thanks for the link. I'm sorry but i'm unable to donwload it, there is an error!
Hi Suodatin,

Thanks for your answer.

> Hi, > I assume you don't have the signal processing toolbox, otherwise use the > function fir1 (or similar). Below some code I wrote
In fact i find a way to design the filter. I'm using Scilab. It seems to work. The only drawback is that the coefficients are real so i must translate each one in Q15. It's very long! Is there an automatic way (under excel?) or software that can allow to do it rapidly?
> good luck > > firsize=1024 > fs=80000 > fl=300 > fh=1000 > > minfreqbins=3; % choose an appropriate value > > binsize=fs/firsize; > if floor(fl/binsize) < minfreqbins ; > % check if you've got enough resolution > NUMBER_OF_BINS_TO_LOW_INCREASE_FIRSIZE_OR_LOWER_SAMPLERATE=1 > end; > > % clear transfer > h0=zeros(1,firsize/2); > > % fill pass band with ones > h0([round(300/binsize)+1:1:round(1000/binsize)])=1; > > % make fft spectrum > h=[h0(1:firsize/2) fliplr(conj(h0(1:firsize/2)))]'; > > % make fir, you could window the fir (you should!) > f=real(fftshift(ifft(h))); > > % plot the fir > figure(1) > plot(f) > > y=fft(f); > > % plot amplitude > figure(2) > semilogx(binsize*[0:1:firsize/2-1],20*log10(abs(y(1:firsize/2))),'r');
Really thanks for this code. I'm sorry you spend time writing it and i won't use it. I do apreciate your help. Thanks again.
If all coefficients are < 1, just multiply them with 32768!
Best regards,

Andre


phuture_project wrote:

> Hi Suodatin, > > Thanks for your answer. > > >>Hi, >>I assume you don't have the signal processing toolbox, otherwise use the >>function fir1 (or similar). Below some code I wrote > > > In fact i find a way to design the filter. I'm using Scilab. It seems > to work. > The only drawback is that the coefficients are real so i must > translate each one in Q15. It's very long! Is there an automatic way > (under excel?) or software that can allow to do it rapidly? > > > >>good luck >> >>firsize=1024 >>fs=80000 >>fl=300 >>fh=1000 >> >>minfreqbins=3; % choose an appropriate value >> >>binsize=fs/firsize; >>if floor(fl/binsize) < minfreqbins ; >> % check if you've got enough resolution >> NUMBER_OF_BINS_TO_LOW_INCREASE_FIRSIZE_OR_LOWER_SAMPLERATE=1 >>end; >> >>% clear transfer >>h0=zeros(1,firsize/2); >> >>% fill pass band with ones >>h0([round(300/binsize)+1:1:round(1000/binsize)])=1; >> >>% make fft spectrum >>h=[h0(1:firsize/2) fliplr(conj(h0(1:firsize/2)))]'; >> >>% make fir, you could window the fir (you should!) >>f=real(fftshift(ifft(h))); >> >>% plot the fir >>figure(1) >>plot(f) >> >>y=fft(f); >> >>% plot amplitude >>figure(2) >>semilogx(binsize*[0:1:firsize/2-1],20*log10(abs(y(1:firsize/2))),'r'); > > > Really thanks for this code. I'm sorry you spend time writing it and i > won't use it. I do apreciate your help. > > Thanks again.
-- Please change no_spam to a.lodwig when replying via email!
phuture_project wrote:
> Hi Suodatin, > > Thanks for your answer. > > >>Hi, >>I assume you don't have the signal processing toolbox, otherwise use the >>function fir1 (or similar). Below some code I wrote > > > In fact i find a way to design the filter. I'm using Scilab. It seems > to work. > The only drawback is that the coefficients are real so i must > translate each one in Q15. It's very long! Is there an automatic way > (under excel?) or software that can allow to do it rapidly? >
... Multiply by 32,768. Round to nearest integer. Discard fractional part. +32,768 is not a permitted value. If it appears, either knock it down to 32,767, thereby creating a small error, or redo the whole set, using 32,767 instead of 32,768 as the multiplier. 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;
phuture_project wrote:

> Hi Andre, > > Thanks for your answer. > > >>Low bandwidth FIR filters at high samp rates tend to get very long. If >>you want to have 500Hz of bandwidh at fs=400kHz, expect to need about >>800 coefficients (400/0.5)! > > > > That's the way to know how many coefficients we have to use? > Indeed, it will be very long. That won't be acceptable! Isn't there > another way to do it or a way to decrease the execution time? > > > Thanks again.
IIR. Goertzel. Not all that different. 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;