DSPRelated.com
Forums

A stupid question about FIR filter

Started by phuture_project July 28, 2004
Hi everyone,

Jim wrote:
>No I probably, haven't read all your posts. Have you somewhere
explained what
>results you are getting? Disregarding the first 400 samples of your
output -
>Is the output a scaled version of your input sinusoid? Or what?
I don't remember if i explained the results i get. Anyway my output is a "kind of sine". It has the same number of "samples" per period as the input, but as it has negative part (the input doesn't at all), this sine looks bad. Above all it's not my input sine with a delay, which is the result i should get. I don't understand why a negative part appears. In order for you to have an image of the result i get, i can tell you that my input sine evolves between 50 and 195 (unsigned int values) whereas the FIR output evolves between -70 and 70. Maybe it will help to know these values. As i said it before, i have to make some data type conversions along my program. I have to change the unsigned int input samples in Q15 values and change the Q15 FIR output "samples" (do we call them samples?) in unsigned int in order to compare. I bet the issue comes from these several conversions. What do you think? Jerry wrote:
>The beginning and end of the output are transients. Removing the
first
>and last 401 samples will leave only the completely valid ones.
Removing
>the first and last 350 samples will leave samples that approxcimate >reality. (Ususally, an FIR filter's impulse response is small at the >ends, so ignoring those effects doesn't make a signal
unrecognizabile.) I don't really understand what you say about "removing the samples". When you say "removing the first and last 401 samples", do you mean to recover the first and the last samples of the 401 i obtain? or do you mean other thing? Same question for the "350 samples". If you mean to remove the first and the last samples of the 401 (or 350) i obtain, do you mean that before applying the FIR filter i must eliminate the first and the last samples? It seems that nobody answered to my question about the number of samples to obtain. If i have 401 FIR coefficients, how many samples must i get? Is there a rule? Jerry wrote:
>All filters, even analog, need time to settle. Amplifiers "thump" at >power-on and power-off. It's usually tolerable because the signals we >want are much longer than the settling times.
Yes, you're right, I'm aware of that. Nevertheless i forget it. I didn't think it applies with digital filters. I'm not a good electrical and computing "engineer" (student anyway for the moment) yet! ;:) Jerry wrote:
>I'm not going to read your code. I don't have the means to compile
it,
>but if I did and if it were complete, I would do that. You can
provide
>anough data for an adequate test, or build a short test filter to >exercise the rest of your code. Either approach might show you what
you
>need to know.
Thanks anyway. I'll try to test the filter with Fred's idea in a first time. Fred wrote:
>I won't read the code either .... but you should definitely test the
filter.
>One good way is this: >Input a sequence that is 1 0 0 0 0 0 0 0 0 0 0 0 0 ..... >The output should recreate the filter coefficients - with whatever
scaling
>is being done. >If it does, then it appears that a good part of the filter is
working.
>There should be 401 nonzero output samples (as long as none of the >coefficients are zero...).
Yes i will try to test my filter with this idea. Thanks. I didn't think of that. The results will be given in my next post! ;:) Thanks everyone once again.
phuture_project wrote:

> Hi everyone, > > Jim wrote: > >>No I probably, haven't read all your posts. Have you somewhere > > explained what > >>results you are getting? Disregarding the first 400 samples of your > > output - > >>Is the output a scaled version of your input sinusoid? Or what? > > > I don't remember if i explained the results i get. Anyway my output is > a "kind of sine". It has the same number of "samples" per period as > the input, but as it has negative part (the input doesn't at all), > this sine looks bad. Above all it's not my input sine with a delay, > which is the result i should get. I don't understand why a negative > part appears.
I'm confused. Sines range between 1 and -1 (if scaled, between A and -A). If your input has no negative values, it is not a sine, but it may be the sum of a sine and DC. With the DC removed, you should see a normal sine.
> In order for you to have an image of the result i get, i can tell you > that my input sine evolves between 50 and 195 (unsigned int values) > whereas the FIR output evolves between -70 and 70. Maybe it will help > to know these values.
I'm not confused any more, and I know why you are. Your input signal goes from +50 to +195. Your input sine goes from -72.5 to +72.5 and there is a DC component of +122.5. The filter completely removes the DC part and reduces the amplitude of the sine by a factor of 0.966.
> As i said it before, i have to make some data type conversions along > my program. I have to change the unsigned int input samples in Q15 > values and change the Q15 FIR output "samples" (do we call them > samples?) in unsigned int in order to compare. I bet the issue comes > from these several conversions. What do you think?
I think you need to get back to basics, and remember what a sine is and is not. Conversions along the way can cloud the issue and lead away from meaning and essence. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

phuture_project wrote:
> > Hi everyone, > > Jim wrote: > >No I probably, haven't read all your posts. Have you somewhere > explained what > >results you are getting? Disregarding the first 400 samples of your > output - > >Is the output a scaled version of your input sinusoid? Or what? > > I don't remember if i explained the results i get. Anyway my output is > a "kind of sine". It has the same number of "samples" per period as > the input, but as it has negative part (the input doesn't at all), > this sine looks bad. Above all it's not my input sine with a delay, > which is the result i should get. I don't understand why a negative > part appears. > In order for you to have an image of the result i get, i can tell you > that my input sine evolves between 50 and 195 (unsigned int values) > whereas the FIR output evolves between -70 and 70. Maybe it will help > to know these values.
This sounds like the filter is doing pretty much what it is supposed. Your input appears to be a sin wave plus a constant DC plus maybe some noise. Your output is the pure sin wave. The test Fred suggested and this description of the output suggest everything is working OK. -jim
> As i said it before, i have to make some data type conversions along > my program. I have to change the unsigned int input samples in Q15 > values and change the Q15 FIR output "samples" (do we call them > samples?) in unsigned int in order to compare. I bet the issue comes > from these several conversions. What do you think? > > Jerry wrote: > >The beginning and end of the output are transients. Removing the > first > >and last 401 samples will leave only the completely valid ones. > Removing > >the first and last 350 samples will leave samples that approxcimate > >reality. (Ususally, an FIR filter's impulse response is small at the > >ends, so ignoring those effects doesn't make a signal > unrecognizabile.) > > I don't really understand what you say about "removing the samples". > When you say "removing the first and last 401 samples", do you mean to > recover the first and the last samples of the 401 i obtain? or do you > mean other thing? Same question for the "350 samples". > If you mean to remove the first and the last samples of the 401 (or > 350) i obtain, do you mean that before applying the FIR filter i must > eliminate the first and the last samples? > It seems that nobody answered to my question about the number of > samples to obtain. If i have 401 FIR coefficients, how many samples > must i get? Is there a rule? > > Jerry wrote: > >All filters, even analog, need time to settle. Amplifiers "thump" at > >power-on and power-off. It's usually tolerable because the signals we > >want are much longer than the settling times. > > Yes, you're right, I'm aware of that. Nevertheless i forget it. I > didn't think it applies with digital filters. I'm not a good > electrical and computing "engineer" (student anyway for the moment) > yet! ;:) > > Jerry wrote: > >I'm not going to read your code. I don't have the means to compile > it, > >but if I did and if it were complete, I would do that. You can > provide > >anough data for an adequate test, or build a short test filter to > >exercise the rest of your code. Either approach might show you what > you > >need to know. > > Thanks anyway. I'll try to test the filter with Fred's idea in a first > time. > > Fred wrote: > >I won't read the code either .... but you should definitely test the > filter. > >One good way is this: > >Input a sequence that is 1 0 0 0 0 0 0 0 0 0 0 0 0 ..... > >The output should recreate the filter coefficients - with whatever > scaling > >is being done. > >If it does, then it appears that a good part of the filter is > working. > >There should be 401 nonzero output samples (as long as none of the > >coefficients are zero...). > > Yes i will try to test my filter with this idea. Thanks. I didn't > think of that. > The results will be given in my next post! ;:) > > Thanks everyone once again.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Hi,

I thought what you said was right (and msurely it is) but in fact the
output evolves too much (it's not 70 i get but between 70 and 81).
Maybe it comes from noise?

Anyway, my placemnt ends tomorrow and so i'm on vacations. I'm sad not
to have suceed in making it but ? Maybe i'll try later.

By this post i want to thank everyone who helped me. I do apreciate.

See you later. There's no reason why i won't come back here and see
what happens!

Thanks again.