Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

FIR filter in TMS320F28335

$
0
0

Hello!

I got the following code from control suite for FIR filter. I dont know how to set the cutoff frequency in this code.

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

#include "FPU.h"

#include "math.h"

#include "float.h"

 

/* Filter Symbolic Constants                        */

#define FIR_ORDER   63/* ORDER = NUM_TAPS - 1 */     

#define SIGNAL_LENGTH (FIR_ORDER+1)* 4 

                                     

                                        

/* Create an Instance of FIRFILT_GEN module and place the object in "firfilt" section       */ 

#pragma DATA_SECTION(firFP, "firfilt")

//#pragma DATA_SECTION(firFP_c, "firfilt")

FIR_FP  firFP = FIR_FP_DEFAULTS;

                                            

/* Define the Delay buffer for the 50th order filterfilter and place it in "firldb" section */  

#pragma DATA_SECTION(dbuffer, "firldb")

float dbuffer[FIR_ORDER+1];

#pragma DATA_SECTION(sigIn, "sigIn");

#pragma DATA_SECTION(sigOut, "sigOut");  

float sigIn[SIGNAL_LENGTH];

float sigOut[SIGNAL_LENGTH];

         

/* Define Constant Co-efficient Array  and place the

.constant section in ROM memory                */

#pragma DATA_SECTION(coeff, "coefffilt");

float const coeff[FIR_ORDER+1]= FIR_FP_LPF64;

/*

 * Calculating a digital frequency

 * Let sampling frequency = 1MHz

 * primary signal @ 10KHz and a secondary signal @ 40KHz

 * Therefore k1 = 1K/100k = 0.01

 *           k2 = 33K/100k = 0.33

 * composite signal = 1/2(sin(2*pi*i*k1) + sin(2*pi*i*k2))

 *                  = 1/2(sin(0.062831853071 * i) + sin(2.073451151*i))

 */

floatRadStep = 0.062831853071f;

float   RadStep2 = 2.073451151f;

floatRad = 0.0f;

float Rad2 = 0.0f;

/* Filter Input and Output Variables                */   

float xn,yn;

int count = 0;

void main()

{

unsigned int i;

//Initalize sys clocks and PIE table

InitSysCtrl();

DINT;

InitPieCtrl();

IER = 0x0000;

IFR = 0x0000;

InitPieVectTable();

EINT;   // Enable Global interrupt INTM

ERTM;   // Enable Global realtime interrupt DBGM   

// Generate sample waveforms:

Rad = 0.0f;

  

for(i=0; i < SIGNAL_LENGTH; i++)

    {

sigIn[i]=0;

        sigOut[i]=0;

    }   

/* FIR Generic Filter Initialisation    */ 

firFP.order=FIR_ORDER; 

firFP.dbuffer_ptr=dbuffer;

firFP.coeff_ptr=(float *)coeff; 

firFP.init(&firFP);

   for(i=0; i < SIGNAL_LENGTH; i++)

  {

  xn=0.5*sin(Rad) + 0.5*sin(Rad2); //Q15

sigIn[i]=xn;

        firFP.input= xn;

        firFP.calc(&firFP);

        yn = firFP.output;

        sigOut[i]=yn;

Rad = Rad + RadStep;

Rad2 = Rad2 + RadStep2;

   }

while(1) 

{

}       

} /* End: main() */

If i want a low pass filter, which allows only till 5 Hz, how should i modify this code?

Pls help me to solve this problem.

regards

Mahesh


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>