0% found this document useful (0 votes)
18 views16 pages

DSP Hardware

Uploaded by

Amoolam Rupesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views16 pages

DSP Hardware

Uploaded by

Amoolam Rupesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Digital Signal Processing BVRIT, Narsapur

Experiment – 8
%Architecture of TMS320C6748
Digital Signal Processing BVRIT, Narsapur
Digital Signal Processing BVRIT, Narsapur

Experiment - 9
%Convolution%
Linear Convolution

AIM:
To perform linear convolution of two signals using Code Composer Studio (CCS).

Apparatus: System with Code Composer Studio 7.4


TMS320C6748 DSP Starter Kit
C Program:

#include<stdio.h>
int x[15],h[15],y[15];
main()
{ int i,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
scanf("%d",&n);
printf("Enter values for i/p x(n):\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for i/p h(n) \n");
for(i=0;i<n; i++)
scanf("%d",&h[i]);
// padding of zeors
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
/* convolution operation */
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
for(i=0;i<m+n-1;i++)
printf("\n The Value of output y[%d]=%d",i,y[i]);
}
Digital Signal Processing BVRIT, Narsapur

OUTPUT:
Console output:
enter value for m 5
enter value for n 5
Enter values for i/p
12345
Enter Values for h
12345
The Value of output y[0]=1
The Value of output y[1]=4
The Value of output y[2]=10
The Value of output y[3]=20
The Value of output y[4]=35
The Value of output y[5]=44
The Value of output y[6]=46
The Value of output y[7]=40
The Value of output y[8]=25
Digital Signal Processing BVRIT, Narsapur

Circular Convolution

AIM: To perform circular convolution of two signals on CCS


Apparatus: System with Code Composer Studio 7.4
TMS320C6748 DSP Starter Kit
C Program:
#include<stdio.h>
int main()
{
int i,j,d,k,l,frst,f,s,last_ele,last,a[10],c[10],d2[10],prev, frst_ele, b[10], final[10][10],
result[10],pad[10];
int rslt,sum;
for(i=0;i<10;i++)
{
c[i]=0;
d2[i]=0;
}
printf("Enter the length of the first matrix : ");
scanf("%d",&f);
printf("\nEnter the elements of the first matrix : ");
for(i=0;i<f;i++)
{
scanf("%d",&c[i]);
}
printf("Enter the length of the Second matrix : ");
scanf("%d",&s);
printf("\nEnter the elements of the first matrix : ");
for(i=0;i<s;i++)
{
scanf("%d",&d2[i]);
}
printf("\n First matrix before padding: ");
printf("\n[ ");
for(i=0;i<f;i++)
{
printf("%d\t",c[i]);
}
printf("]\n");
printf("\n Second matrix before padding: ");
printf("\n[ ");
for(i=0;i<s;i++)
{
printf("%d\t",d2[i]);
Digital Signal Processing BVRIT, Narsapur

}
printf("]\n");
if(f>s)
{
for(i=0;i<f;i++)
{
a[i]=c[i];
}
frst=f;
for(i=0;i<frst;i++)
{
pad[i]=d2[i];
}
}
else
{
for(i=0;i<s;i++)
{
a[i]=d2[i];
}
frst=s;
for(i=0;i<frst;i++)
{
pad[i]=c[i];
}
}
printf("\n Both the Matrix After padding : \n\t1st Matrix\t 2nd Matrix ");
for(i=0;i<frst;i++)
{
printf("\n\t %d\t\t ",c[i]);
printf("%d",d2[i]);
}
for(j=0;j<frst;j++)
{

last=frst-1;
frst_ele=a[0];
last_ele=a[last];
if(j>0)
{
for(k=0;k<frst;k++)
{
if(k>0 && k<frst)
Digital Signal Processing BVRIT, Narsapur

{
prev=k-1;
b[k]=a[prev];
final[k][j]=b[k];
}
else
{
b[0]=last_ele;
final[k][j]=b[k];
}
}
for(d=0;d<frst;d++)
{
a[d]=b[d];
}
}
else
{
for(k=0;k<frst;k++)
{
final[k][j]=a[k];

}
}
}
printf("\n\n ******* Final Matrix *****\n");
for(i=0;i<frst;i++)
{

for(j=0;j<frst;j++)
{
printf("\t%d",final[i][j]);
}
printf("\n");
}
printf("\n ******* Circular Convulated Matrix *****\n");
printf("\n[ ");
for(i=0;i<frst;i++)
{
sum=0;
for(j=0;j<frst;j++)
{
rslt=final[i][j]*pad[j];
Digital Signal Processing BVRIT, Narsapur

sum=sum+rslt;
}
result[j]=sum;
printf("%d\t",result[j]);
}
printf("]\n");
return 0;
}

OUTPUT:

Enter the length of the first matrix : 3


Enter the elements of the first matrix : 12 10 20
Enter the length of the Second matrix : 5
Enter the elements of the first matrix : 10 5 6 7 8
First matrix before padding:
[ 12 10 20]

Second matrix before padding:


[ 10 5 6 7 8]

Both the Matrix After padding :


1st Matrix 2nd Matrix
12 10
10 5
20 6
0 7
0 8

******* Final Matrix *****


10 8 7 6 5
5 10 8 7 6
6 5 10 8 7
7 6 5 10 8
8 7 6 5 10

******* Circular Convulated Matrix *****

[ 340 320 322 244 286 ]


Digital Signal Processing BVRIT, Narsapur

Experiment - 10
FAST FOURIER TRANSFORM OF A GIVEN SEQUENCE

Aim: To find the Fast Fourier Transform of a given sequence

Apparatus: System with Code Composer Studio 7.4


TMS320C6748 DSP Starter Kit
C Program:

#include<math.h>
#define PTS 64
#define PI 3.14159265358979
typedef struct{float real,imag;} COMPLEX;
void FFT(COMPLEX*Y,int n);
float iobuffer[PTS];
float x1[PTS];
short i;
short buffercount=0;
short flag=0;
COMPLEX w[PTS];
COMPLEX samples[PTS];
main()
{
for(i=0;i<PTS;i++)
{
w[i].real=cos(2*PI*i/(PTS*2.0));
w[i].imag=-sin(2*PI*i/(PTS*2.0));
}
for(i=0;i<PTS;i++)
{
iobuffer[i]=sin(2*PI*10*i/64.0);
samples[i].real=0.0;
samples[i].imag=0.0;
}
for(i=0;i<PTS;i++)
{
samples[i].real=iobuffer[i];
}
for(i=0;i<PTS;i++)
samples[i].imag=0.0;
FFT(samples,PTS);
for(i=0;i<PTS;i++)
{
x1[i]=sqrt(samples[i].real*samples[i].real+ samples[i].imag*samples[i].imag);
}
}

//**FFT Function:
void FFT(COMPLEX*Y, int N)
{
COMPLEX temp1,temp2;
int i,j,k;
int upper_leg,lower_leg;
Digital Signal Processing BVRIT, Narsapur

int leg_diff;
int num_stages=0;
int index,step;
i=1;
do
{
num_stages+=1;
i=i*2;
}while(i!=N);
leg_diff=N/2;
step=(PTS*2)/N;
for(i=0;i<num_stages;i++)
{
index=0;
for(j=0;j<leg_diff;j++)
{
for(upper_leg=j;upper_leg<N;upper_leg+=(2*leg_diff))
{
lower_leg=upper_leg+leg_diff;
temp1.real=(Y[upper_leg]).real+(Y[lower_leg]).real;
temp1.imag=(Y[upper_leg]).imag+(Y[lower_leg]).imag;
temp2.real=(Y[upper_leg]).real+(Y[lower_leg]).real;
temp2.imag=(Y[upper_leg]).imag+(Y[lower_leg]).imag;
(Y[lower_leg]).real=temp2.real*(w[index]).imag+ temp2.imag*(w[index]).real;
(Y[upper_leg]).real=temp1.real;
(Y[upper_leg]).imag=temp1.imag;
}
index +=step;
}
leg_diff=leg_diff/2;
step*=2;
}
j=0;
for(i=1;i<(N-1);i++)
{
k=N/2;
while(k<=j)
{
j=j-k;
k=k/2;
}
j=j+k;
if(i<j)
{
temp1.real=(Y[j]).real;
temp1.imag=(Y[j]).imag;
(Y[j]).real=(Y[i]).real;
(Y[j]).imag=(Y[i]).imag;
(Y[j]).real=temp1.real;
(Y[j]).imag=temp1.imag;
}}
return;
}
Digital Signal Processing BVRIT, Narsapur

Result:

OUTPUT: FFT
Digital Signal Processing BVRIT, Narsapur

Experiment - 11
% Digital IIR Filter Design%

Aim: To design Infinite Impulse Response (IIR) filters and analyze their responses

Apparatus: System with Code Composer Studio 7.4


TMS320C6748 DSP Starter Kit

C Program:

#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
float mul(float, int);
void main()
{
printf("\n enter order of filter ");
scanf("%d",&N);
printf("\n enter the cutoff freq ");
scanf("%d",& wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
case 2:
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
}
break;
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}
Digital Signal Processing BVRIT, Narsapur

CONSOLE OUTPUT:

[C674X_0]
enter order of filter 2

enter the cutoff freq 50

enter the choice for IIR filter 1. LPF 2.HPF 2

H[0]=1.000000 H[1]=1.000000 H[2]=1.000000 H[3]=1.000000 H[4]=1.000000 H[5]=1.000000 H[6]=1.000000


H[7]=1.000000 H[8]=1.000000 H[9]=0.999999 H[10]=0.999999 H[11]=0.999997 H[12]=0.999995 H[13]=0.999990
H[14]=0.999981 H[15]=0.999967 H[16]=0.999945 H[17]=0.999911 H[18]=0.999859 H[19]=0.999783 H[20]=0.999672
H[21]=0.999516 H[22]=0.999298 H[23]=0.998999 H[24]=0.998594 H[25]=0.998053 H[26]=0.997338 H[27]=0.996404
H[28]=0.995199 H[29]=0.993658 H[30]=0.991706 H[31]=0.989259 H[32]=0.986217 H[33]=0.982470 H[34]=0.977897
H[35]=0.972365 H[36]=0.965735 H[37]=0.957862 H[38]=0.948601 H[39]=0.937816 H[40]=0.925382 H[41]=0.911197
H[42]=0.895188 H[43]=0.877322 H[44]=0.857608 H[45]=0.836105 H[46]=0.812922 H[47]=0.788216 H[48]=0.762185
H[49]=0.735063 H[50]=0.707107 H[51]=0.678585 H[52]=0.649766 H[53]=0.620909 H[54]=0.592252 H[55]=0.564010
H[56]=0.536367 H[57]=0.509476 H[58]=0.483458 H[59]=0.458404 H[60]=0.434380 H[61]=0.411425 H[62]=0.389559
H[63]=0.368786 H[64]=0.349093 H[65]=0.330458 H[66]=0.312851 H[67]=0.296235 H[68]=0.280569 H[69]=0.265810
H[70]=0.251913 H[71]=0.238832 H[72]=0.226523 H[73]=0.214940 H[74]=0.204042 H[75]=0.193786 H[76]=0.184135
H[77]=0.175049 H[78]=0.166494 H[79]=0.158435 H[80]=0.150842 H[81]=0.143685 H[82]=0.136935 H[83]=0.130567
H[84]=0.124557 H[85]=0.118881 H[86]=0.113519 H[87]=0.108451 H[88]=0.103658 H[89]=0.099123 H[90]=0.094831
H[91]=0.090765 H[92]=0.086912 H[93]=0.083260 H[94]=0.079796 H[95]=0.076509 H[96]=0.073388 H[97]=0.070423
H[98]=0.067605 H[99]=0.064926
Digital Signal Processing BVRIT, Narsapur

For plotting the graph:

Tools -> Graph->FFT Magnitude Phase

FFT Magnitude phase window will be opened:

Acquisition Buffer Size: 128

DSP data type: 32bit floating point

Start address: h

Magnitude Response

Phase Response
Digital Signal Processing BVRIT, Narsapur

Experiment - 12
% Digital FIR Filter Design%

Aim: To design Finite Impulse Response (FIR) filters and analyze their responses

Apparatus: System with Code Composer Studio 7.4


TMS320C6748 DSP Starter Kit

C Program:

#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang\n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}
}
Digital Signal Processing BVRIT, Narsapur

OUTPUT:

For plotting the graph:

Tools -> Graph->FFT Magnitude Phase

FFT Magnitude phase window will be opened:

Acquisition Buffer Size: 128

DSP data type: 32bit floating point

Magnitude Response

Phase Response

You might also like