FIR Filter Low pass/High pass (LP/HP) Using Triangular window

AIM:    To verify FIR filters Using Triangular window 

SOFTWARE REQUIREMENTS:

Operating System – Windows XP

Constructor - Simulator

Software – Code Composer 3.1v,6713DSK  Diagnostics

HARDARE REQUIREMENTS:

TMS320C67XXDSP KIT  / example TMS320C6713DSP KIT 

USB cable  

Power Supply +5v  

PROGRAM CODE:

1. Triangular window (Highpass)

#include "filtercfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include "stdio.h"

//float filter_coeff[]={0.000000,0.001445,0.002648,0.003127,0.002391,
 //    -0.000000,-0.004383,-0.010943,-0.019672,-0.030353,
//      -0.042554,-0.055647,-0.068853,-0.081290,-0.092048,
//       0.902380,-0.092048,-0.081290,-0.068853,-0.055647,
//      -0.042554,-0.030353,-0.019672,-0.010943,-0.004383,
//                                                           -0.000000,0.002391,0.003127,0.002648,0.001445,
//                  0.000000};
                                         //FIR High pass Triangular filter pass band range 400Hz-3.5KHz


//float filter_coeff[]={0.000000,-0.000897,-0.003126,-0.005080,-0.004567,
//        -0.000000,0.008373,0.017782,0.023225,0.018839,
//         0.000000,-0.034539,-0.081287,-0.132092,-0.175834,
//         0.805541,-0.175834,-0.132092,-0.081287,-0.034539,
//         0.000000,0.018839,0.023225,0.017782,0.008373,
//        -0.000000,-0.004567,-0.005080,-0.003126,-0.000897,
//          0.000000};
                                        //FIR High pass Triangular filter pass band range 800Hz-3.5KHz


float filter_coeff[]={0.000000,-0.000901,0.001021,0.005105,0.006317,
     -0.000000,-0.011581,-0.017868,-0.007583,0.018931,
      0.042944,0.034707,-0.026541,-0.132736,-0.243196,
      0.708287,-0.243196,-0.132736,-0.026541,0.034707,
                            0.042944,0.018931,-0.007583,-0.017868,-0.011581,
                           -0.000000,0.006317,0.005105,0.001021,-0.000901,
      0.000000};
                                         //FIR High pass Triangular filter pass band range 1200Hz-3.5KHz

//static short int  in_buffer[100];

DSK6713_AIC23_Config config={0x0017,0x0017,0x00d8,0x00d8,0x0011,0x0000,0x0000,0x0043,0x0081,0x0001};

void main( )
{
 DSK6713_AIC23_CodecHandle hCodec;
 Uint32 l_input, r_input,l_output, r_output;
 DSK6713_init();
 hCodec = DSK6713_AIC23_openCodec(0, &config);

 DSK6713_AIC23_setFreq(hCodec, 1);

 while(1)
 {
      while(!DSK6713_AIC23_read(hCodec, &l_input));

   while(!DSK6713_AIC23_read(hCodec, &r_input));
   
     l_output=(Int16)FIR_FILTER(&filter_coeff ,l_input);
              r_output=l_output;
               
      while(!DSK6713_AIC23_write(hCodec, l_output));
       
      while(!DSK6713_AIC23_write(hCodec, r_output));
 }

DSK6713_AIC23_closeCodec(hCodec);
}

signed int FIR_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
static short int  in_buffer[100];
in_buffer[0] = x;

for(i=30;i>0;i--)
in_buffer[i] = in_buffer[i-1];

for(i=0;i<32;i++)
output = output + h[i] * in_buffer[i];
//output = x;
return(output);
}

 

Expected Output: Observed the output in CRO with respect to input signal, it pass the signal at range of pass band frequency 400-3.5KHz,and attenuate at other than pass band frequency

 

2. Triangular window (Lowpass)

 

PROGRAM CODE:

#include "filtercfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include "stdio.h"

//float filter_coeff[ ]={0.000000,-0.001185,-0.003336,-0.005868,-0.007885,
//      -0.008298,-0.005988,0.000000,0.010265,0.024895,
//         0.043368,0.064545,0.086737,0.107877,0.125747,
//       0.138255,0.125747,0.107877,0.086737,0.064545,
//       0.043368,0.024895,0.010265,0.000000,-0.005988,
//      -0.008298,-0.007885,-0.005868,-0.003336,-0.001185,
//                                                            0.000000};
                                           //FIR Low pass Triangular Filter pass band range 0-500Hz


//float filter_coeff[ ]={0.000000,-0.001591,-0.002423,0.000000,0.005728,
//       0.011139,0.010502,-0.000000,-0.018003,-0.033416,
//      -0.031505,0.000000,0.063010,0.144802,0.220534,
//       0.262448,0.220534,0.144802,0.063010,0.000000,
//      -0.031505,-0.033416,-0.018003,-0.000000,0.010502,
//       0.011139,0.005728,0.000000,-0.002423,-0.001591,
//                   0.000000};
                                                 //FIR Low pass Triangular Filter pass band range 0-1000Hz


float filter_coeff[ ]={0.000000,-0.001104,0.001287,0.005467,0.003043,
     -0.007731,-0.013469,0.000000,0.023089,0.023194,
     -0.016737,-0.060136,-0.033474,0.100508,0.282844,
      0.386435,0.282844,0.100508,-0.033474,-0.060136,
     -0.016737,0.023194,0.023089,0.000000,-0.013469,
     -0.007731,0.003043,0.005467,0.001287,-0.001104,
      0.000000};
                                                  //FIR Low pass Triangular Filter pass band range 0-1500Hz

//static short int  in_buffer[100];

DSK6713_AIC23_Config config={0x0017,0x0017,0x00d8,0x00d8,0x0011,0x0000,0x0000,0x0043,0x0081,0x0001};

void main( )
{
 DSK6713_AIC23_CodecHandle hCodec;
 Uint32 l_input, r_input,l_output, r_output;
 DSK6713_init();
 hCodec = DSK6713_AIC23_openCodec(0, &amp;config);

 DSK6713_AIC23_setFreq(hCodec, 1);

 while(1)
 {
      while(!DSK6713_AIC23_read(hCodec, &amp;l_input));

   while(!DSK6713_AIC23_read(hCodec, &amp;r_input));
   
     l_output=(Int16)FIR_FILTER(&amp;filter_coeff ,l_input);
              r_output=l_output;
               
      while(!DSK6713_AIC23_write(hCodec, l_output));
       
      while(!DSK6713_AIC23_write(hCodec, r_output));
 }

DSK6713_AIC23_closeCodec(hCodec);
}

signed int FIR_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
static short int  in_buffer[100];
in_buffer[0] = x;

for(i=30;i>0;i--)
in_buffer[i] = in_buffer[i-1];

for(i=0;i<32;i++)
output = output + h[i] * in_buffer[i];
//output = x;
return(output);
}  

 

Expected Output: Observed the output in CRO with respect to input signal, it pass the signal at range of pass band frequency 0-1500KHz,and attenuate at other than pass band frequency