This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

using DSP library but its not giving faithful result

hello

this first time i am using DSP library(IIR filter),,

i've designes a cascaded(3) LPF(1KHz) to which i am giving a combined sine wave of 500Hz+1500Hz and i want to verify my result.But its result is not faithful.I am also attaching my code...

Kindly give suggestion for its improvement.

My code is as follows:

 

#include<stdio.h>
   
void DSP_iir(short *r1, short *x, short *r2, short *h2,
short *h1, int nr);
void main()
{
short r1[184]={0},i=0;
short output1[184]={0};
short output2[184]={0};
short output3[184]={0};
int output4[184]={0};
short input[180]={0};
short input1[180]={-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0,334,362,138,0,138,362,334,0,-335,-363,-139,0,-139,-363,-335,0};
short    dc_num[15] = {
        713, 1426, 713,0,0,
        798, 1600, 801,0,0,
        1016, 2028, 1012,0,0};
                                           
short    dc_den[12] = {
        -8192, 6884, -1543,0,
        -8192, 7723, -2731,0,
        -8192, 9793, -5657,0};


DSP_iir( r1, &input1[0], output1,&dc_num[0],&dc_den[0],  176);
DSP_iir( r1,  &output1[0], output2,&dc_num[5],&dc_den[4],  176);
DSP_iir( r1, &output2[0], output3,&dc_num[10],&dc_den[8],  176);


for(i=0;i<176;i++)
output4[i]=output3[i];

printf("\n done");

}

  • In what way is your filter not performing the way you want it to perform?

    Do any of the stages work well?

    If your input is just a 500 Hz waveform, do you get the expected result?

    What if it is just the 1500 Hz waveform?

  • yes i have checked individual stages of filter but it didn't work . i have also checked for seperate sine wave of 500hz and 1500 hz.. i didn't get fruitful result out of it

  • Which DSPLIB Programmer's Reference Guide are you using for your documentation? Your prototype for DSP_iir does not match what is in the latest that I just downloaded from www.ti.com.

    What output were you expecting? What output did you get?

    Your inputs are small for Q14 numbers. Is this intentional?

    Why do you have so many tags? Some seem unrelated to your question, and confuse me on which processor you are using.

  • hello

    now i want put my previous question in different way... i want to use IIR filter library with numerator coefficient as={713, 1426, 713} and denominator coefficient as ={-8192, 6884, -1543}.but as could be seen in equivalent C code of iir filter is is not using den[0] coefficient which is important for me. so how can i tackle such problem to get faithful result

  • We show you the equivalent C code for these library functions so you can evaluate their application for your case. If this algorithm does not execute the way you want it to, you can choose to:

    1. Use a different DSPLIB function is another one comes closer to what you are looking for.
    2. Modify the C implementation to match what you want, and run the optimizer to generate your own new "library" function with a different name.

    In some cases, the TI library functions may be hand-optimized in assembly, so please be aware of this if you do not get the same performance results when you use optimized C in your own version of the function.