# FIR Filter

Started by June 30, 2004
```Hi,

>> 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.

I thought i mentioned it before. So, my input signal is just a sine at
9 kHz. It has an offset of 1,25 V (in order to meet the requirements
My FIR is a band pass filter, centered on 9 kHz. The cutoff
frequencies are 8 kHz and 10 kHz. There are 401 coefficients. The
sample frequency is about 139 kHz (i know it's not good to have an
approximative sample frequency, but the issue is that i don't succeed
in implementing an interrupt with the timer, so the sampling is done
in a simple for loop).

Can you clarify what you say about the 90&#2013266096; shift? With my FIR filter
the sine might be shifted 90 degrees? If so, that could explain the
results? How can i know if the sine is shifted? From the phase of the
filter?

Moreover the results are varying! I mean that when i look at the
maximum of y(n), the value varies continously. I keep on searching for
the reason...
```
```Hi Jerry,

> 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).

I'm sorry i don't understand. Could you clarify please?

> 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.

My signal surely contains more than one frequency since it deals with
a sine. There surely are harmonics.
Then i don't understand what you mean. Could you clarify please?
(Excuse my little brain!).

Thanks again.
```
```phuture_project wrote:

> 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
>
>
> 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.

The TI Q-15 format is just 2-s complement integers that have been
shifted, so if you start with an array of 16-bit integers ('int' or
'short' in Code Composter) and make one negative with "-decimal number"
it will come out just fine.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```