You are on page 1of 31

IFTM UNIVERSITY

Lodhipur-Rajput Road, Moradabad

DEPARTMENT OF ELECTRONICS &COMMUNICATION


ENGINEERING

LAB MANUAL

DIGITAL SIGNAL PROCESSING LAB

(EEC-652)
IFTM UNIVERSITY
MORADABAD
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

DIGITAL SIGNAL PROCESSING LAB (EEC-652)


EXPERIMENT LIST

1. With the help of Fourier series, make a square wave from sine wave and cosine waves. Find out
coefficient values.

2. Evaluate 4 point DFT of and IDFT of x(n) = 1, 0 n 3; 0 elsewhere.

3. Implement the FIR Filters for 2 KHz cutoff frequency and 2 KHz bandwidth for band pass filter.

4. Design FIR filter using Fourier series expansion method.

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.

7. Implement the filter functions.

8. Generate DTMF sequence 1234567890*# and observe its spectrogram.

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.

12. To study the circular convolution.


EXPERIMENT NO.2

OBJECT:- Evaluate 4 point DFT of and IDFT of x(n) = 1, 0 n 3; 0 elsewhere.

APPARATUS REQUIRED :- TMS320 6713 DSP Processor kit.

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:

Where j is the imaginary unit and is a primitive N'th root of unity.

The inverse discrete Fourier transform (IDFT) is given by


A simple description of these equations is that the complex numbers Xk represent the amplitude and phase of
the different sinusoidal components of the input "signal" xn. The DFT computes the Xk from the xn, while the
IDFT shows how to compute the xn as a sum of sinusoidal components

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] = {1,1,1,1}; //1-cycle cosine

//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

int out[2] = {0,0}; //init Re and Im results

void dft(short *x, short k, int *out) //DFT function


{
int sumRe = 0, sumIm = 0; //init real/imag components
float cs = 0, sn = 0; //init cosine/sine components
int i = 0;
for (i = 0; i < N; i++) //for N-point DFT
{
cs = cos(2*pi*(k)*i/N); //real component
sn = sin(2*pi*(k)*i/N); //imaginary component
sumRe = sumRe + x[i]*cs; //sum of real components
sumIm = sumIm - x[i]*sn; //sum of imaginary components
}
out[0] = sumRe; //sum of real components
out[1] = sumIm;
//printf("\n%d",sumRe);
//printf("\n%d",sumIm);
printf("\n%d",out[0]);
// printf("\n%d",out[1]); //sum of imaginary components
}

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;

short x[N] = {4,0,0,0}; //1-cycle cosine

int out[2] = {0,0}; //init Re and Im results

void dft(short *x, short k, int *out) //DFT function


{
int sumRe = 0, sumIm = 0; //init real/imag components
float cs = 0, sn = 0; //init cosine/sine components
int i = 0;
for (i = 0; i < N; i++) //for N-point DFT
{
cs = cos(2*pi*(k)*i/N); //real component
sn = sin(2*pi*(k)*i/N); //imaginary component
sumRe = (sumRe + x[i]*cs); //sum of real components
sumIm = (sumIm + x[i]*sn); //sum of imaginary components
}
out[0] = sumRe/4; //sum of real components
out[1] = sumIm;

printf("\n%d",out[0]);
}

void main()
{
int j;

for (j = 0; j < N; j++)


{
dft(x,j,out); //call DFT function
}
}
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 dft.pjt.
3. Add the source files dft.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 (dft. 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.

FLOW OF CODE:

1. Codec configuration settings initialize the DSP codec.


2. Main program starts initialize the variable.
3. Initializations of the dsp kit.
4. Opening the codec (reading the data) set the page.
5. Read the output data.
6. Process the data.
7. Write the output data.
8. Close the codec.

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:

Operating System Windows XP


Constructor - Simulator
Software - CCStudio 3

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

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-1;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;

}
}
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:

Operating System Windows XP


Constructor - Simulator
Software - CCStudio 3

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

The difference equation for such a system is described by the following:


M N
y ( n) bk x ( n k ) a k y (n k ) (3)
k 0 k 1

M and N are order of the two polynomials


bk and ak are the filter coefficients. These filter coefficients are generated using FDS (Filter
Design software or Digital Filter design package).

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:

Operating System Windows XP


Constructor - Simulator
Software - CCStudio 3

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

OBJECT:- Generate an Amplitude Modulation having side low frequencies 1200


Hz and 800 Hz.

EQUIPMENTS:

Operating System Windows XP


Constructor - Simulator
Software - CCStudio 3

THEORY:-

Amplitude Modulation: It is a type of modulation in which the amplitude of high


frequency sine wave is varied in accordance with the instantaneous value of the
modulating signal.
Consider a sine signal Vm(t) with frequency f
Vm(t)= B Sin (2 fc t)
The signal Vm(t) is called modulating signal ; the signal Vc(t) is called carrier
signal.
Vc(t) = A Sin (2 fct)
Vary the amplitude of the carrier Vc(t) adding the modulating signal Vm(t) to A.
Amplitude modulated signal VM(t) is obtained, which can be expressed as

VM(t) = [A+k B sin (2fc t)] sin (2fct)


= A [1+m. sin (2f.t)] sin(2fct)
With K = constant of proportionality.
Percentage modulation signal is defined as the value:
KB
m = ------------ .100
A
With reference to fig.2, the modulation index m can calculated in this way
H-h
m = ------------ .100 %
H+h

Spectrum of the modulated signal:


With simple trigonometric passages, the relation expressing the modulating signal
VM becomes
Vm(t) = ASin(2fct) +mA/2Cos [(2(fc-fm)t] mA/2 Cos [(2(fc+fm)t]
For which it is deduced that the signal modulated in amplitude by a sine modulator
consists in three sine components:

Asin (2fc t) Carrier

m A/2 . cos [(2(fc-fm) t] lower side band

m A/2 . cos [(2(fc+fm) t] upper side band

Particularly effective is the representation of the modulated signal into an


Amplitude/frequency diagram. Fig.1.1 reports the different components of the AM
signal, in the amplitude / Frequency diagram as well as the amplitude / time
diagram.

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:

9. Codec configuration settings initialize the DSP codec.


10. Main program starts initialize the variable.
11. Initializations of the dsp kit.
12. Opening the codec (reading the data) set the page.
13. Read the output data.
14. Process the data.
15. Write the output data.
16. Close the codec.

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:-

Operating System Windows XP


Constructor - Simulator
Software - CCStudio 3

THEORY:-

FREQUENCY MODULATION- It is a type of modulation in which the frequency of the high


frequency (Carrier) is varied in accordance with the instantaneous value of the modulating signal.
Consider a sin wave signal vm(t) with pulse w
vm (t) = B.sin (.t)
and another sin wave vc(t) with upper pulse:
vc(t) = A.sin (.t)
The signal vm(t) is called modulating signal, the signal vc(t) is called carrier signal.
Vary the frequency of the carrier vc(t) in a way proportional to the amplitude of the modulating
signal vm(t). You obtain a vm(t) frequency modulated diagonal, which can be expressed by the
relation:
vm(t) = A. sin [ (t)]
with (t) instantaneous angle function of vm (t).

Mathematical expression of the frequency modulated signal:


The instantaneous pulse (t) of the FM signal by definition:
(t) = + K.vm (t)
with h = carrier pulse
K = modulation sensitivity
The instantaneous angle (t) to be used as subject of the sin to obtain the mathematical operation of
the FM signal, is detected by integrating (t):
(t) = (t) dt
In the case of modulating sin wave signal [ vm (t) = B. sin (.t)], (t) it results:
(t) = . (t) (K.B/). Cos (.t).
The expression of the frequency modulated signal vm (t) becomes:
Vm (t) = A sin [. (t) (K.B/). Cos (.t)]
PROGRAM:-
#include<stdio.h>
#include<math.h>
float a[1000],b[1000],m[1000];
main()
{
int i;
for(i=0;i<=500;i++)
{
a[i]=sin((2*3.14*200*i/10)+3.14); //message signal
b[i]=sin(2*3.14*1000*i/10); //carrier signal
m[i]=cos((2*3.14*1000*i/10)+2*cos(2*3.14*200*i/10)); //modulated signal
printf("%f",&m[i]);
}
}

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:

1. Codec configuration settings initialize the DSP codec.


2. Main program starts initialize the variable.
3. Initializations of the dsp kit.
4. Opening the codec (reading the data) set the page.
5. Read the output data.
6. Process the data.
7. Write the output data.
8. Close the codec.

RESULT:- The frequency modulated output is shown in graphically.

(a) Message signal , (b) Carrier signal , (c) Frequency modulated signal.

(a) Message Signal


(b) Carrier Signal

(c) Frequency Modulated Signal


PRECAUTIONS:-

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:-

FREQUENCY SHIFT KEYING:-


Frequency Shift Keying uses the bit to affect the frequency of a carrier sinusoid.
In frequency-shift keying (FSK), the bit affects the frequency of a carrier sinusoid.
s 0 (t)=Ap T (t)sin(2f 0 t)
(1)
s 1 (t)=Ap T (t)sin(2f 1 t)

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.

Figure 2: This plot shows the FSK waveform for


same bitstream used in the BPSK example.
To determine the bandwidth required by this signal set, we again consider the alternating bit
stream. Think of it as two signals added together: The first comprised of the signal s 0 (t) , the
zero signal, s 0 (t) , zero, etc., and the second having the same structure but interleaved with
the first and containing s 1 (t) (Figure 3).
Figure 3: The depicted decomposition of the FSK-modulated
alternating bit stream into its frequency components simplifies the
calculation of its bandwidth.
Each component can be thought of as a fixed-frequency sinusoid multiplied by a square wave
ofperiod 2T that alternates between one and zero. This baseband square wave has the same
Fourier spectrum as our BPSK example, but with the addition of the constant term c 0 . This
quantity's presence changes the number of Fourier series terms required for the 90% bandwidth:
Now we need only include the zero and first harmonics to achieve it. The bandwidth thus equals,
with f 0 <f 1 ,f1 +1 2T (f 0 1 2T )=f 1 f 0 +1 T .

If the two frequencies are harmonics of the bit-interval duration, f 0 =k 0 T and


f 1 =k 1 T with k 1 >k 0 , the bandwidth equals k 1 +k 0 +1 T . If the difference
between harmonic numbers is 1 , then the FSK bandwidth is smaller than the BPSK bandwidth.
If the difference is 2 , the bandwidths are equal and larger differences produce a transmission
bandwidth larger than that resulting from using a BPSK signal set.

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:

1. Codec configuration settings initialize the DSP codec.


2. Main program starts initialize the variable.
3. Initializations of the dsp kit.
4. Opening the codec (reading the data) set the page.
5. Read the output data.
6. Process the data.
7. Write the output data.
8. Close the codec.
RESULT:-
PRECAUTIONS:-

You might also like