AnsweredAssumed Answered

IIR biquad testing - float64 MATLAB vs. CMSIS [solved]

Question asked by Vinci on Jul 21, 2015
Hello there

I've been trying to implement an IIR biquad lowpass filter with the DSP library lately. I started out by designing the filter in MATLAB and calculating the IIR parameters before I pretty much copied the code from ARMs CMSIS page.

The low pass should filter a 320 double long input signal stored in "testInput_f64". The filter itself should also be double precision, so I used the df2T float64 version of the IIRs.

float64_t testInput_f64[320] = { * here are 320 doubles ... * };
float64_t testOutput_f64[320] = {0};
const float64_t coeffs[5] = {    0.0168191501070571,
static float64_t biquadStateBandF64[4];    // one stage -> 4x state variables   {x[n-1], x[n-2], y[n-1], y[n-2]}

int main(void)
    arm_biquad_cascade_df2T_instance_f64 S1;
    float64_t  *inputF64, *outputF64;

    /* Link */
    inputF64 = &testInput_f64[0];
    outputF64 = &testOutput_f64[0];

    /* Initialize biquad f64 */
    arm_biquad_cascade_df2T_init_f64 (&S1, 1, (float64_t *) &coeffs[0], &biquadStateBandF64[0]);

    /* Run biquad */
    arm_biquad_cascade_df2T_f64(&S1, inputF64, outputF64, 320);


Although the code compiles and runs fine the results aren't really satisfying. The first two results come somewhat close to what I get in MATLAB, but everything else is plain wrong. How could that be?
I chose the double precision for a reason, since I though its almost 1:1 compareable to what MATLAB would calculate...

Am I missing something here?


For future reference...
MATLABs denominator is negated, compared to the definition used in the DSP lib.