N-Point algorithm using code composer studio
AIM: To verify Linear Convolution using Code Composer Studio.
SOFTWARE REQUIREMENTS:
Operating System – Windows XP
Constructor - Simulator
Software – Code Composer 3.1v,6713DSK Diagnostics
PROGRAM CODE:
#include <stdio.h>
#include <math.h>
void butterfly(double *,double *,double *,double *,double *,double *);
int main( )
{
int i;
double x[8]={1,2,3,4,4,3,2,1};
//double x[8]={4,3,2,1,0,0,0,0};
double XR[8];
double XI[8]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
double WNR[4]={0.999969, 0.707092, 0.0, -0.707092};
double WNI[4]={0.0 , -0.707092,-0.999969,-0.707092};
double spectrum[8];
// store data in bit reversal order
XR[0]=x[0];
XR[1]=x[4];
XR[2]=x[2];
XR[3]=x[6];
XR[4]=x[1];
XR[5]=x[5];
XR[6]=x[3];
XR[7]=x[7];
// clrscr( );
// FIRST STAGE OF BUTTERFLY
butterfly(&amp;XR[0],&amp;XI[0],&amp;XR[1],&amp;XI[1],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[2],&amp;XI[2],&amp;XR[3],&amp;XI[3],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[4],&amp;XI[4],&amp;XR[5],&amp;XI[5],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[6],&amp;XI[6],&amp;XR[7],&amp;XI[7],&amp;WNR[0],&amp;WNI[0]);
// SECOND STAGE OF BUTTERFLY
butterfly(&amp;XR[0],&amp;XI[0],&amp;XR[2],&amp;XI[2],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[1],&amp;XI[1],&amp;XR[3],&amp;XI[3],&amp;WNR[2],&amp;WNI[2]);
butterfly(&amp;XR[4],&amp;XI[4],&amp;XR[6],&amp;XI[6],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[5],&amp;XI[5],&amp;XR[7],&amp;XI[7],&amp;WNR[2],&amp;WNI[2]);
// THIRD STAGE OF BUTTERFLY
butterfly(&amp;XR[0],&amp;XI[0],&amp;XR[4],&amp;XI[4],&amp;WNR[0],&amp;WNI[0]);
butterfly(&amp;XR[1],&amp;XI[1],&amp;XR[5],&amp;XI[5],&amp;WNR[1],&amp;WNI[1]);
butterfly(&amp;XR[2],&amp;XI[2],&amp;XR[6],&amp;XI[6],&amp;WNR[2],&amp;WNI[2]);
butterfly(&amp;XR[3],&amp;XI[3],&amp;XR[7],&amp;XI[7],&amp;WNR[3],&amp;WNI[3]);
for(i=0;i<8;i++)
{
XR[i]*=64.0;
XI[i]*=64.0;
}
for(i=0;i<8;i++)
{
printf("\n FFT XR[%d] = %lf XI[%d]= %lf",i,XR[i],i,XI[i]);
}
return(0);
}
void butterfly(double *ar,double *ai,double *br,double *bi,double *wr,double *wi)
{
double tr,ti;
*ar/=4.0;
*ai/=4.0;
tr=*ar*2;
ti=*ai*2;
*br/=4.0;
*bi/=4.0;
*ar+=*br * *wr - *bi * *wi;
*ai+=*br * *wi + *bi * *wr;
*br= tr - *ar;
*bi= ti - *ai;
}
Expected Output:
XR[0]=19.9999070; XI[0]=0.000000;
XR[1]=-5.828134; XI[1]=-2.414237;
XR[2]=0.000813; XI[2]=-0.000093;
XR[3]=-0.171618; XI[3]=-0.414175;
XR[4]=0.000248; XI[4]=0.000000;
-
UpdatedFeb 04, 2020
-
Views1,573
Generation of basic signals using MATLAB
Design of FIR filters of Low pass and high pass filter using Matlab commands
Find DFT / IDFT of given DT signal
Implementation of analog IIR low pass and high pass filter for a given sequence
Find frequency response of a given system given in (Transfer Function/ Differential equation form
Implementation of FFT of a given sequence