cancel
Showing results for 
Search instead for 
Did you mean: 

how to calculate coefficients in matlab?

arsalan_elec
Associate II
Posted on June 05, 2014 at 20:53

hi, im going to design and IIR biquad filter in matlab FTDTOOL and use generated coefficients in cmsis dsp function arm_biquad_cascade_df1_f32 () .

i design an IIR filter for example 8th order and set filter arithmetic to single precision floating point and then export filter to workspace. there will be two matrix. i copy bx0 bx1 bx2 and ax1 ax2 (ax0 alway 1) from sos matrix to keil and dont use gain matrix because i dont know where to use it. and the filter does not work.(output is near zero)

my question is how to generate coefficient to use in arm_biquad_cascade_df1_f32 () ?

thanks

#biquad-coefficient-matlab-stm32m
2 REPLIES 2
arsalan_elec
Associate II
Posted on June 06, 2014 at 23:40

ok i found the solution! for every one who's not advance in matlab like me:

to generate coefficients for iir biquad filter in FDATOOL in matlab :

setting parameter in FDATOOL and Design Filter,

go to ''Set Quantization Parameters'' and set filter arithmetic to ''Single precision''.

goto Edit-> Convert Structure and select direct form I or direct form II transposed depend on your requirement.

goto Edit->Reorder and Scale Second order sections. check Scale check box and click apply. you can reorder sections and change other setting here. note that ''scale value constraint''should be unit, this will scale coefficient for unit gain. so the gain matrix G will all be 1; check it in Analysis->Filter Coefficients , all section gain should be 1 and overall gain should be near 1 if not ,change settings in ''Reorder and Scale Second order sections''.

now you can export coefficients to workspace. please not all numbers in 4th column in the sos matrix are 1 (ax0), you have to remove them. and note that matlab equation for iir biquad is alittle different than cmsis dsp library equation so you have to negate the numbers in 5th and 6th columns.thats all!

sorry for my English...

fohrer
Associate II
Posted on July 28, 2014 at 12:07

Hi,

Sorry to disturb you but i'm trying to use this filtering function arm_biquad_cascade_df1_f32 (), but i'm facing some troubles to generate Coefficients with MATLAB, the first Gain is never around 1 even if i change configurations.

May i ask you an example about using the function ?

Sorry for my bad English,

Luc