```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
```
```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.
```
```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 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.
```
```phuture_project wrote:

> Hi,
>
>
>
>>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

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```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;

```
```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.
>
> 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.
```
```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.
```
```Hi,

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