Forums

FIR Filter

Started by phuture_project June 30, 2004
phuture_project wrote:


> In fact i find a way to design the filter. I'm using Scilab. It seems > to work.
> 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.
Never take code from a stranger ;)
Suodatin Pussi wrote:

> phuture_project wrote: > > > >>In fact i find a way to design the filter. I'm using Scilab. It seems >>to work. > > >>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. > > > Never take code from a stranger ;)
Unless it's shrink wrapped. Jerrt -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Jerry Avins wrote:


> Multiply by 32,768. Round to nearest integer. Discard fractional part.
Would dithering have any advantage here? Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein
Hi,

Thanks everyone for your answers.

> 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.
I knew how to do it but i just wanted to know if there existed a software that automatically converts real numbers into Q15 ones. I found a way to do it quite rapidly : i use a function given by TI "fltoq15.asm" which allows to convert all the real numbers defined in a table into Q15 numbers and arranged them in another table. Then i recover these new values and arrange them into the FIR filter coefficients table! The longest step is to copy all the coefficients obtained with scilab into the real numbers table and to copy the Q15 numbers into the FIR filter coefficients table! But apparently i can't do it another way?! Now i'm copying the 401 coefficients given by scilab...
I've just designed a FIR bandpass filter centered on 9 kHz with 401
coefficients.

My aim is to recover the max of the incoming signal (which is at 9
kHz). I thought that searching for the max of the y(n) i'll recover
this maximum but actually this max of y(n) is much bigger than the
maximum of the incoming signal.
Can someone explain why the maximum of y(n) isn't equal to the maximum
of x(n)? Of course my filter has a gain of 1 in the band pass.

Thanks


phuture_project@yahoo.fr (phuture_project) wrote in message news:<25fe518f.0406292347.474ee808@posting.google.com>...
> 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:

> I've just designed a FIR bandpass filter centered on 9 kHz with 401 > coefficients. > > My aim is to recover the max of the incoming signal (which is at 9 > kHz). I thought that searching for the max of the y(n) i'll recover > this maximum but actually this max of y(n) is much bigger than the > maximum of the incoming signal. > Can someone explain why the maximum of y(n) isn't equal to the maximum > of x(n)? Of course my filter has a gain of 1 in the band pass. > > Thanks > >
What's the input signal? what does your fir look like? suppose the input are all sines (zero at t=0) and shifted 90 degrees by the filter (hilbert transform), they would all add up.
Bob Cain wrote:

> Jerry Avins wrote: > >> Multiply by 32,768. Round to nearest integer. Discard fractional part. > > Would dithering have any advantage here?
With filter coefficients, I don't think so. It would at best be ugly. Two filters designed to the same spec would come out the same only by unlikely accident. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
phuture_project wrote:

> I've just designed a FIR bandpass filter centered on 9 kHz with 401 > coefficients. > > My aim is to recover the max of the incoming signal (which is at 9 > kHz). I thought that searching for the max of the y(n) i'll recover > this maximum but actually this max of y(n) is much bigger than the > maximum of the incoming signal. > Can someone explain why the maximum of y(n) isn't equal to the maximum > of x(n)? Of course my filter has a gain of 1 in the band pass.
There could be many reasons. To begin with, the maximum sample probably doesn't fall on an analog peak. The peak of the waveform represented by +1 +1 -1 -1 ... is sqrt(2). The peak of the waveform represented by 0, +1, +1, 0, -1, -1, ... is (2/3)*sqrt(3). Your signal evidently contains more than one frequency. There may be an interaction among the sidebands, but I nevertheless think it odd that some output samples should be larger than any input samples by a factor of more than 2. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
phuture_project wrote:

> Hi, > > Thanks everyone for your answers. > > >>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. > > > I knew how to do it but i just wanted to know if there existed a > software that automatically converts real numbers into Q15 ones. > I found a way to do it quite rapidly : i use a function given by TI > "fltoq15.asm" which allows to convert all the real numbers defined in > a table into Q15 numbers and arranged them in another table. Then i > recover these new values and arrange them into the FIR filter > coefficients table! > The longest step is to copy all the coefficients obtained with scilab > into the real numbers table and to copy the Q15 numbers into the FIR > filter coefficients table! But apparently i can't do it another way?! > > Now i'm copying the 401 coefficients given by scilab...
In SciLab: xQ15 = floor(x * (2^15-1) + 0.5); Now it's in Q15. Look in your Scilab documentation for how to write it out as a text file. Scilab is a programming environment. You're a programmer. Why are you copying 401 numbers by hand when you can write 10 lines of code? You should be able to make it 12 lines of code and have it come out in formatted C, with comments. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Hi Tim,

> In SciLab: > > xQ15 = floor(x * (2^15-1) + 0.5); > > Now it's in Q15. Look in your Scilab documentation for how to write it > out as a text file. > > Scilab is a programming environment. You're a programmer. Why are you > copying 401 numbers by hand when you can write 10 lines of code? You > should be able to make it 12 lines of code and have it come out in > formatted C, with comments.
Thanks for the advice. I thought about converting the real coefficients into Q15 ones thanks to scilab, but when the real numbers are negative the result is simply "-decimal number". However, i need to have true Q15 numbers, that is to say that when a number is negative the MSB is at '1'. Surely i don't express me very well, i hope you understand what i mean. Anyway, i didn't think i could store the coefficients in a text file! Thanks for the idea. I just saw how to do it. Now i've got all my coefficients stored in a text file. I just have to make a "copy-paste" in my program and that's ok. Thanks.