Skip to main content
sebastien
Associate
June 25, 2013
Question

overflow with arm_biquad_cascade_df2T_f32 function

  • June 25, 2013
  • 7 replies
  • 1991 views
Posted on June 25, 2013 at 14:40

Hi,

I try to implement a IIR filter with the ''

arm_biquad_cascade_df2T_f32

'' function from the CMIS dsp libraries and I encountered a problem: my output datas and my pstate table are overflowed after few iterations. I generated my coefficients with fdatool from matlab. They are stored in the followed order:

{b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...}

float32_t iir_coeff[30] = {
1, -0.0249943904456238, 0.999999999999993, -1.77729633861929, 0.845140679514385,
1, -1.42288228590609, 0.999999999999998, -1.72245970919624, 0.896574493119215,
1, -1.99973299802181, 1, -1.91581723732986, 0.929183550605981,
1, -1.5986745646875, 1, -1.72677706239042, 0.969582040573283,
1, -1.99845599796938, 0.999999999999999, -1.97568100711438, 0.981035519941801,
1, -1.99766610993993, 1, -1.99201600960503, 0.995968747765197
};

I don't know how to incorporate the ''Scale factors''. I try to add it to my coeff table as follow but it dosn't work.

float32_t iir_coeff[35] = {
0.001843832549177, 0, 0, 0, 0,
1, -0.0249943904456238, 0.999999999999993, -1.77729633861929, 0.845140679514385,
1, -1.42288228590609, 0.999999999999998, -1.72245970919624, 0.896574493119215,
1, -1.99973299802181, 1, -1.91581723732986, 0.929183550605981,
1, -1.5986745646875, 1, -1.72677706239042, 0.969582040573283,
1, -1.99845599796938, 0.999999999999999, -1.97568100711438, 0.981035519941801,
1, -1.99766610993993, 1, -1.99201600960503, 0.995968747765197
};

Here a part of my code:

#define NUM_STAGE 7 // if I don't incorporate the ''Scale factors'' NUM_STAGE = 6 

static
float32_t iirStateF32X[2*NUM_STAGE];
arm_biquad_cascade_df2T_instance_f32 SX;
int
main(
void
)
{ 
arm_biquad_cascade_df2T_init_f32(&SX, NUM_STAGE, (float32_t *)&iir_coeff[0], &iirStateF32X[0]);
...
// in the interruption:
float32_t *inputF32X, *outputF32X
inputF32X = &temp_buffer[0];
outputF32X = &AccBufferX_filter[0]; 
arm_biquad_cascade_df2T_f32(&SX, inputF32X, outputF32X, FILTER_BUFFER_SIZE);

This code works with the fir functions. Does someone know where the problem is ? Thanks.
    This topic has been closed for replies.

    7 replies

    frankmeyer9
    Associate III
    June 26, 2013
    Posted on June 26, 2013 at 08:37

    I can't serve with detailed knowledge about IIR and FIR filter implementations, but how about debugging ?

    Had your mathlab tool possibly creating code for double, and not float ?

    sebastien
    sebastienAuthor
    Associate
    June 26, 2013
    Posted on June 26, 2013 at 11:41

    Hi,

    I don't think that is a problem of precision. Actually the IIR ST function only accepts floats coefficients.

    frankmeyer9
    Associate III
    June 26, 2013
    Posted on June 26, 2013 at 13:24

    Actually the IIR ST function only accepts floats coefficients.

     

    Correct. The most you can get in this Cortex M world is a M4 with single-precicision FPU, so double would be a performance hog.

    I don't think that is a problem of precision.

     

    There is certainly a difference in precicision for float and double. Look

    http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    , for instance.

    The generated code might work with double, but exhibit instabilities when clipped to float.

    I would check intermediary results with a debugger.

    zzdz2
    Associate
    June 26, 2013
    Posted on June 26, 2013 at 16:38

    To me it looks like you don't  have enough coefficients in 

    iir_coeff.

    Try to generate those 35 coeffs somehow.

    sebastien
    sebastienAuthor
    Associate
    June 26, 2013
    Posted on June 26, 2013 at 17:50

     

    To me it looks like you don't  have enough coefficients in 

    iir_coeff.

     

    Try to generate those 35 coeffs somehow.

     

    My bad, when I  put the IIR coefficients without the ''scale fators'' the iir_coeff table size is 30 and NUM_STAGE is egal to 6.

    zzdz2
    Associate
    June 26, 2013
    Posted on June 26, 2013 at 19:34

    I don't know, those bx1 and ax1 looks suspicious, mostly close to -2, I would rather expect something close to +-1 or fractional.

    zzdz2
    Associate
    June 27, 2013
    Posted on June 27, 2013 at 21:50

    You can try to negate the axx coefficients, it may solve the problem.