cancel
Showing results for 
Search instead for 
Did you mean: 

How to compute filter coefficients?

lowpowermcu
Associate II
Posted on December 20, 2011 at 14:26

Hi every stm32 fan,

In my application I am sampling my input signal at 8KHz and now I need to filter out my samples in order to remove high components.

Is there a software tool which computes the coefficients of an FIR filter?

I am thinking to use the FPU inside the cortex M4.

Is there someone who did it?

So viel Dank
4 REPLIES 4
raptorhal2
Lead
Posted on December 20, 2011 at 15:45

Consider using a simple first order lag:

X = Xprevious + (Xcurrent - Xprevious)/A

This can easily be done in real time with integer arithmetic, and if A is a power of 2, can be done with arithmetic right shifts. For the first sample, make X = Xcurrent to start the filter. This method works well if your highest desired frequency is not close to the sample frequency.

If you need a sharper cutoff filter, perhaps someone else can chime in.

Willkommen, Hal

raffael
Associate II
Posted on December 20, 2011 at 17:03

I used the arm_fir_q15 function. (This is fixed point filtering)

Coefficients can be computed using Octave (free) / Matlab.

In Octave you could use: fir1

''help fir1'' for doc.

-> b = fir1(n, w [, type] [, window] [, noscale]) ...

You have to scale these coeffictions to q15 fixed point format.

Example:

coeff = fir1(15, 0.1); %Lowpass filter with fs=0.1. Returning the 15+1 filter coefficients.

coeff_fixedp = round(coeff * 2^15) % Scaling and rounding

freqz(coeff); %Plot filter response

Gern geschehen,

raffael

http://www.gnu.org/software/octave/

http://guioctave.com/

dreschel
Associate II
Posted on December 23, 2011 at 02:42

http://www-users.cs.york.ac.uk/~fisher/mkfilter/racos.html

This is a great site for calculating FIR coefficients. I have used it quite a bit... it actually generates the C code also...

Good Luck!
lowpowermcu
Associate II
Posted on December 23, 2011 at 10:24

Hi William,

Thank you for your proposal. I really appreciate it.

Is there some other on line tools for coefficients but other than the raised cosine filter type?