Google Search

Thursday, November 10, 2011

Linear Convolution DSP PROGRAMS IN C


DSP PROGRAMS IN C


1. Linear Convolution
AIM
To verify Linear Convolution.

EQUIPMENTS

TMS 320C6713 Kit.
RS232 Serial Cable
Power Cord

THEORY

Convolution is a formal mathematical operation, just as multiplication, addition, and integration. Addition takes two numbers and produces a third number, while convolution takes two signals and produces a third signal. Convolution is used in the mathematics of many fields, such as probability and statistics. In linear systems, convolution is used to describe the relationship between three signals of interest: the input signal, the impulse response, and the output signal.
In this equation, x1(k), x2 (n-k) and y(n) represent the input to and output from the system at time n. Here we could see that one of the input is shifted in time by a value everytime it is multiplied with the other input signal. Linear Convolution is quite often used as a method of implementing filters of various types.

ALGORITHM


Step 1 Declare three buffers namely Input buffer, Temporary Buffer, Output Buffer.
Step 2 Get the input from the CODEC, store it in Input buffer and transfer it to the first location of the
Temporary buffer.
Step 3 Make the Temporary buffer to point to the last location.
Step 4 Multiply the temporary buffer with the coefficients in the data memory and accumulate it with
the previous output.
Step 5 Store the output in the output buffer.
Step 6 Repeat the steps from 2 to 5.
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\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for n \n");
for(i=0;i<n;i++)
scanf("%d",&h[i]);
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;


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]);
}

Result:
 enter value for m4

 enter value for n4
Enter values for i/p
1 2 3 4
Enter Values for n
1 2 3 4

 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]=25
 The Value of output y[5]=24
 The Value of output y[6]=16

0 comments:

Post a Comment