Professional Documents
Culture Documents
New DSP Lab
New DSP Lab
LAB MANUAL
(EEC-652)
IFTM UNIVERSITY
MORADABAD
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
1. With the help of Fourier series, make a square wave from sine wave and cosine waves. Find out
coefficient values.
3. Implement the FIR Filters for 2 KHz cutoff frequency and 2 KHz bandwidth for band pass filter.
5. Implement IIR low pass filter for a 4 KHz cutoff frequency and compare it the FIR filter with the
same type use chirp as input signal.
6. Verify Blackman and Hamming windowing techniques for square wave as an input which
window will give good results.
9. Generate an Amplitude Modulation having side low frequencies 1200 Hz and 800 Hz. Observe
and verify the theoretical FFT characteristics with the observed ones.
10. Generate Frequency Modulation having carrier frequencies 1 KHz and modulating frequency
200 Hz with the modulation index of 0.7. Observe and verify the theoretical FFT characteristics with
the observed ones.
11. Generate an FSK wave form for transmitting the digital data of the given bit sequence. Predict
and verify the FFT for the same one.
THEORY:
THEORY OF DFT & IDFT:-
In mathematics, the discrete Fourier transform (DFT) is a specific kind of discrete transform, used
in Fourier analysis. It transforms one function into another, which is called the frequency domain
representation, or simply the DFT, of the original function (which is often a function in the time
domain). But the DFT requires an input function that is discrete and whose non-zero values have a
limited (finite) duration. Such inputs are often created by sampling a continuous function, like a
person's voice. Unlike the discrete-time Fourier transform (DTFT), it only evaluates enough
frequency components to reconstruct the finite segment that was analyzed. Using the DFT implies
that the finite segment that is analyzed is one period of an infinitely extended periodic signal; if this
is not actually true, a window function has to be used to reduce the artifacts in the spectrum. For the
same reason, the inverse DFT cannot reproduce the entire time domain, unless the input happens to
be periodic (forever). Therefore it is often said that the DFT is a transform for Fourier analysis of
finite-domain discrete-time functions. The sinusoidal basis functions of the decomposition have the
same properties.
The input to the DFT is a finite sequence of real or complex numbers (with more abstract
generalizations discussed below), making the DFT ideal for processing information stored in
computers. In particular, the DFT is widely employed in signal processing and related fields to
analyze the frequencies contained in a sampled signal, to solve partial differential equations, and to
perform other operations such as convolutions or multiplying large integers.
Definition
The sequence of N complex numbers x0, ..., xN1 is transformed into the sequence of N
complex numbers X0, ..., XN1 by the DFT according to the formula:
PROGRAM :-
DFT PROGRAM-
#include <stdio.h>
#include <math.h>
short x[4];
void dft(short *x, short k, int *out); //function prototype
#define N 4 //number of data values
float pi = 3.1416;
int sumRe,sumIm;
//short x[N]={0,602,974,974,602,0,-602,-974,-974,-602,
// 0,602,974,974,602,0,-602,-974,-974,-602};//2-cycles sine
void main()
{
int j;
for (j = 0; j < N; j++)
{
dft(x,j,out); //call DFT function
}
}
IDFT PROGRAM-
#include <stdio.h>
#include <math.h>
short x[4];
void dft(short *x, short k, int *out); //function prototype
#define N 4 //number of data values
float pi = 3.1416;
int sumRe,sumIm;
printf("\n%d",out[0]);
}
void main()
{
int j;
FLOW OF CODE:
RESULT:
Output DFT
, the computed DFTs are shown for N=1024, and zero-padded versions with N = 2048 and N = 4096
PRECAUTIONS:
EXPERIMENT No. 3
AIM
Implement the FIR Filters for 2 KHz cutoff frequency and 2 KHz bandwidth for band pass
filter.
EQUIPMENTS:
THEORY:
A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is
based on the weighted summation of a finite number of past inputs. An FIR transversal filter
structure can be obtained directly from the equation for discrete-time convolution.
N 1
y ( n) x ( k ) h( n k ) 0 n N 1 (1)
k 0
In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is
the transversal filter coefficients at time n. These coefficients are generated by using FDS (Filter
Design Software or Digital filter design package).
FIR filter is a finite impulse response filter. Order of the filter should be specified. Infinite
response is truncated to get finite impulse response. placing a window of finite length does this.
Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann window
etc. This FIR filter is an all zero filter.
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);
}
}
RESULT:
EXPERIMENT No. 4
AIM
Implement IIR low pass filter for a 4 KHz cutoff frequency and compare it the FIR filter with
the same type use chirp as input signal.
EQUIPMENTS:
THEORY:
The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer
function, described by polynomials in z in both the numerator and the denominator:
M
b
k 0
k z k
H ( z) N (2)
a
k 1
k Z k
IIR filters can be expanded as infinite impulse response filters. In designing IIR filters, cutoff
frequencies of the filters should be mentioned. The order of the filter can be estimated using
butter worth polynomial. Thats why the filters are named as butter worth filters. Filter
coefficients can be found and the response can be plotted.
PROGRAM:
//iirfilters
#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);
}
RESULT :
EXPERIMENT No. 5
AIM
With the help of Fourier series, make a square wave from sine wave and cosine waves. Find
out coefficient values.
EQUIPMENTS:
THEORY:
Square Wave from Sine Waves
The Fourier series expansion for a square-wave is made up of a sum of odd harmonics.
We start by forming a time vector running from 0 to 10 in steps of 0.1, and take the sine of all the
points. Let's plot this fundamental frequency.
Now add the third harmonic to the fundamental, and plot it.
Now use the first, third, fifth, seventh, and ninth harmonics.
For a finale, we will go from the fundamental to the 19th harmonic, creating vectors of successively
more harmonics, and saving all intermediate steps as the rows of a matrix.
These vectors are plotted on the same figure to show the evolution of the square wave. Note that
Gibbs' effect says that it will never really get there.
Program
#include<stdio.h>
#include<math.h>
float a[100],b[100];
main()
{
int i;
for(i=0;i<=100;i++)
{
a[i]=sin(0.1*i);
b[i]=sin(0.1*i)+((sin(0.3*i))/3)+((sin(0.5*i))/5)+((sin(0.7*i))/7)+((sin(0.9*i))/9)+((sin(1.1*i))/11)+
((sin(1.3*i))/13)+((sin(1.5*i))/15)+((sin(1.7*i))/17)+((sin(1.9*i))/19);
printf("%f",b[i]);
}
}
Result
EXPERIMENT No. 6
EQUIPMENTS:
THEORY:-
PROGRAM:-
#include<stdio.h>
#include<math.h>
float a[1000],b[1000],m[1000];
main()
{
int i;
for(i=0;i<=100;i++)
{
a[i]=sin(2*3.14*200*i/10+3.14); //message signal
b[i]=sin(2*3.14*1000*i/10+3.14); //carrier signal
m[i]=a[i]*b[i]; // amplitude modulation
printf("%f",&m[i]);
}
}
PROCEDURE:-
10. Open code composer studio , make sure the DSP kit is turned on.
11. Start a new project using Project-new pull down menu , save it in a separate directory
(c:\ti\my projects) with name AM.pjt.
12. Add the source files AM.c to the project using project-add files to project pull down
menu.
13. Add the linker command file hello .cmd.
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
14. Add the run time support library file rts 6700.lib.
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
15. Compile the program using the Project-compile pull down menu or by clicking the shortcut
icon on the left side of program window.
16. Build the program using the Project-build pull down menu or by clicking the shortcut icon
on the left side of program window.
17. Load the program (AM. out) in program memory of DSP chip using the file load program
pull down menu.
18. Run the program and result display in result window.
19. View graph and show that the output of Amplitude Modulation.
FLOW OF CODE:
RESULT:-
CARRIER SIGNAL(a), MODULATED SIGNAL(b), AMPLITUDE MODULATED SIGNAL(c)
PRECAUTIONS:-
EXPERIMENT No. :- 7
OBJECT:- Generate frequency modulation having carrier frequency 1 Khz and modulating
frequency 200 hz with modulation index 0.7.
APPARATUS REQIRED:-
THEORY:-
PROCEDURE:-
1. Open code composer studio , make sure the DSP kit is turned on.
2. Start a new project using Project-new pull down menu , save it in a separate directory
(c:\ti\my projects) with name FM.pjt.
3. Add the source files FM.c to the project using project-add files to project pull down
menu.
4. Add the linker command file hello .cmd.
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
5. Add the run time support library file rts 6700.lib.
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
6. Compile the program using the Project-compile pull down menu or by clicking the shortcut
icon on the left side of program window.
7. Build the program using the Project-build pull down menu or by clicking the shortcut icon
on the left side of program window.
8. Load the program (FM. out) in program memory of DSP chip using the file load program
pull down menu.
9. Run the program and result display in result window.
10. View graph and show that the output of Frequency Modulation.
FLOW OF CODE:
(a) Message signal , (b) Carrier signal , (c) Frequency modulated signal.
EXPERIMENT No. :- 8
OBJECT:- Generate an FSK waveform for transmitting the digital data of the given bit sequence.
APPARATUS REQIRED:-
Operating System Windows XP
Constructor - Simulator
Software - CCStudio 3
THEORY:-
Figure 1
The frequencies f 0 ,f1 are usually harmonically related to the bit interval. In the depicted
example, f 0 =3 T and f 1 =4 T . As can be seen from the transmitted signal for our
example bit stream (Figure 2), the transitions at bit interval boundaries are smoother than those of
BPSK.
PROGRAM:-
#include<stdio.h>
#include<math.h>
float m[500];
int a, b[10],i,j;
main()
{
printf("\n enter the number of bits(max 10)\n");
scanf("%d",&a);
printf("\n enter the sequance\n");
for(i=0;i<a;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<a;i++)
{
if(b[i]==1)
{
for(j=(i*100);j<=((i*100)+100);j++)
{
m[j]=sin(2*3.14*j/100);
}
}
else if(b[i]==0)
{
for(j=(i*100);j<=((i*100)+100);j++)
{
m[j]=sin(2*2*3.14*j/100);
}
}
}
}
PROCEDURE:-
1. Open code composer studio , make sure the DSP kit is turned on.
2. Start a new project using Project-new pull down menu , save it in a separate directory
(c:\ti\my projects) with name FM.pjt.
3. Add the source files FM.c to the project using project-add files to project pull down
menu.
4. Add the linker command file hello .cmd.
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
5. Add the run time support library file rts 6700.lib.
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
6. Compile the program using the Project-compile pull down menu or by clicking the shortcut
icon on the left side of program window.
7. Build the program using the Project-build pull down menu or by clicking the shortcut icon
on the left side of program window.
8. Load the program (FM. out) in program memory of DSP chip using the file load program
pull down menu.
9. Run the program and result display in result window.
10. View graph and show that the output of Frequency Modulation.
FLOW OF CODE: