cancel
Showing results for 
Search instead for 
Did you mean: 

matlab coefficient to stm32f429i discovery board

lokesh
Associate II
Posted on March 30, 2015 at 08:46

I am trying to implement iir Band Pass filter design in STM32F429i discovery kit.

I konw that it needs coefficients to be generated from matlab and feed them into cmsis api to achiev filtered data.

My SOS Matrix look like shown below:

1,  0,  -1,  1, -1.9974,   0.99743,        

1,  0,  -1,  1, -1.9995,  0.99947,        

1,  0,  -1,  1,  -1.9937,  0.99371,        

1,  0,  -1,  1, -1.9982,  0.99817,       

1,  0,  -1,  1, -1.995,  0.99499,

above matrix i put into my coeff array removing column 4th which contains all 1's since its A0 in coeff.

static float32_t filter_coeffs[] = {

1,  0,  -1,  -1.9974,   0.99743,        

1,  0,  -1,  -1.9995,  0.99947,        

1,  0,  -1,  -1.9937,  0.99371,        

1,  0,  -1,  -1.9982,  0.99817,       

1,  0,  -1,  -1.995,  0.99499,

};

here is the code snippet am using :

&sharpdefine NUMSTAGES 5

static float32_t firStateF32[2*NUMSTAGES];

arm_biquad_cascade_df1_init_f32(&S, NUMSTAGES, filter_coeffs, firStateF32);

when I am using matlab my signal are filtered perfect, but in microcontroller output is initially oscillating and than ''1.&sharpQNAN''

am i missing any step??

please correct me.

Regards,

Lokesh Bhatt

#arm-cmsis-dsp #biquad-coefficient-matlab-stm32m
1 REPLY 1
vincenthamp9
Associate III
Posted on July 21, 2015 at 15:27

Hello there

Sorry for the thread necro, but have you found a soultion to this?

I've been running into the same problem lately and it drives me crazy. I'm testing a float64 example and have experienced the same thing you did... And this is kinda strange, since float64 should almost be identical to what MATLAB uses for its internal precision.

What I'd try on your behalf is to force MATLAB into a float32 calculation. The precision difference between float32 and ''something-double-like'' is _huge_. So you could try to limit MATLABs internal precision and see if the filter is still unstable.