Digital Signal Processing Lab Manual Updated
Digital Signal Processing Lab Manual Updated
(Course Code:19EC603)
B.Tech (Electronics and Communication Engineering)
6thSemester
Roll No.
Batch: _________
Section: _________
1
GMR NAGAR, RAJAM-532 127
Page
S.No. Name of the Experiment Marks Signature
Number
2
Page
S.No. Name of the Experiment Marks Signautre
Number
11 Study of Architecture of DSP Chips- TMS 320C 5X/6X
Marks Avg :
Augmented Experiments:
Page Mark
S.No. Name of the Experiment Signature
Number s
1 Mixing and separation of two voice signals
3
16EC703 DIGITAL SIGNAL PROCESSING Lab
0032
Course Outcomes
List of Experiments
Minimum twelve experiments to be conducted:
4. Determine the power spectral density of the given sequence and plot the spectrum
6. Determine the FFT for given sequence using DIT radix-2 algorithm
7. Plot the Magnitude and phase response of IIR filter (LP/HP) using Butterworth Filter
8. Plot the Magnitude and phase response FIR LP/HP filter using windowing technique
11. DFT of the given sequence and plot Magnitude and Phase response
3. Design a notch filter for the removal of power line interference from ECG signal by using
TMSprocessor
Reading Material(s)
2. Digital Signal Processing, Principles, Algorithms, and Applications: John G. Proakis, Dimitris
G. Manolakis, Pearson Education, PHI, 2007
5
Date:
INTRODUCTION TO MATLAB
6
INTRODUCTION TO MATLAB
7
INTRODUCTION TO MATLAB
8
Date:
EXPERIMENT NO-1
GENERATION OF DISCRETE TIME SIGNALS AND SUM OF SINUSOIDAL SIGNALS
AIM:
To generate basic signals like unit impulse, unit step, unit ramp signal, Exponential signals and
sinusoidal signal.
APPARATUS:
THEORY:
A Signal is a function of time, space, or another observation variable that conveys information.
They are classified into two types
Continuous-Time/Analog Signal
Discrete-Time Signal
A finite, real-valued, smooth function x(t) of a variable t which usually represents time. Both x
and t in x(t) are continuous
9
Discrete – Time signals:
1, for n 0
x ( n) ( n)
Unit impulse sequence. 0, otherwise
1, for n 0
x ( n ) u( n )
Unit step sequence. 0, otherwise
n, for n 0
x ( n) r ( n)
Unit ramp sequence. 0, otherwise
Sinusoidal sequence. x (n) A sin(n ) .
A continuous-time signal x(t) is said to be periodic with period T if it satisfy the condition
A signal is periodic if the above condition is not satisfied for at least one value of T. The smallest
value of T that satisfies the above condition is known as fundamental period. Complex
exponential and sinusoidal signals are examples for continuous time periodic signals. Consider a
sinusoidal signal
x(t)=Asin(wt+θ) ……………………eq2
Where A is tha amplitude, w is tha frequency in radians per second (rad/sec), and θ the phase in
radians. The frequency f0 in hertz is given by f0 = w /2π or periodic signal we have
X(t+T)=x(t) ………………eq3
Equation 5 and 2 are equal if wT = 2π , T =2π/ w Thu the sinusoidal is periodic with period 2π/
w The sum of two periodic signals x1(t) and x2(t) with periods T1 and T2 respectively may or
may not be periodic, then the ratio T1/T2 can be written as the ratio a/b of two integers a and b.
If T1/T2 = a/b, then bT1 = aT2, and since a and b are integers, x1(t) and x2(t) are periodic with
period bT1. If a and b are co-prime (i. e. a and b have no common integer factors other than 1)
then T = bT1 is the fundamental period of the sum of two signals.
ALGORITHM:
10
5. Plot the graph.
6. Stop.
CODE:
%Basic signals
clc;
clear all;
close all;
n=-20:1:20;
x1=1; x2=0;
xi=x1.*(n==0)+x2.*(n~=0);
subplot(3,2,1);
stem(n,xi);
title('Impulse sequence');
x1=1; x2=0;
xu=x1.*(n>=0)+x2.*(n<0);
subplot(3,2,2);
stem(n,xu);
title('Unit step sequence');
x1=n; x2=0;
xr=x1.*(n>=0)+x2.*(n<0);
subplot(3,2,3);
stem(n,xr);
title('Ramp sequence');
x1=exp(-n); x2=0;
xe=x1.*(n>=0)+x2.*(n<0);
subplot(3,2,4);
stem(n,xe);
title('Exponential sequence');
t=20;
f=1/t;
xs=sin(2*pi*f*n);
subplot(3,2,5);
stem(n,xs);
title('Sinusoidal sequence');
11
%Sum of sinusoidal signals
clc;
clear all;
close all;
n=-20:1:20;
t1=20;
f1=1/t1;
x1=sin(2*pi*f1*n);
subplot(2,2,1);
stem(n,x1);
title('First signal');
t2=40;
f2=1/t2;
x2=sin(2*pi*f2*n);
subplot(2,2,2);
stem(n,x2);
title('Second signal');
xa=x1+x2;
subplot(2,2,3);
stem(n,xa);
title('Sum of first and second signal');
MODEL GRAPHS:
12
PROCEDURE:
RESULT:
VIVA QUESTIONS:
13
Date:
EXPERIMENT -2
ESTIMATE THE POWER AND POWER SPECTRAL DENSITY OF THE GIVEN
SEQUENCE
AIM:
APPARATUS:
THEORY:
In general signals can be classified into three broad categories, power signals, energy signals, or
neither. Deterministic signals which are made up of sinusoids is an example of power signals
which have infinite energy but finite average power. Random signals also have finite average
power and fall into the category of power signals. A transient signal is an example of energy
signals which start and end with zero amplitude. There are still other signals which cannot be
characterized as either power or energy signals.
For any signal in discrete form, power and energy can be calculated using the following
equations
Here T=duration of the signal, and x[n] denotes discrete samples of the signal at regular intervals
(The sampled signal contains N points stretching from 0 to N-1). “NORM” function in Matlab
can be utilized for calculating the power or energy content of a signal.
Case Study:
x(t) is a sine wave of amplitude A and frequency fc represented by the following equation.
x(t)=Asin(2πfct)
When represented in frequency domain, it will look like the one on the right side plot in the
following figure. This is evident from the fact that the sinewave can be mathematically
represented by applying Euler’s formula.
14
Asin(2πfct)=A(ej2πfct−e−j2πfct)/2j
When considering the amplitude part, the above decomposition gives two spikes of amplitude
A/2 on either side of the frequency domain at fc and −fc.
Squaring the amplitudes gives the magnitude of power of the individual spikes/frequency
components. The power spectrum is plotted below.
Thus if the pure sine wave is of amplitude A=1V and frequency=100Hz, the power spectrum will
have two spikes of value A2/4=0.25 at 100 Hz and -100 Hz frequencies. The total power will be
A2/4+A2/4=0.25+0.25=0.5W.
Power spectral density (PSD), which describes how the power of a signal or time series is
distributed with frequency. Here power can be the actual physical power, or more often, for
convenience with abstract signals, can be defined as the squared value of the signal, that is, as the
actual power dissipated in a load if the signal were a voltage applied across it. This instantaneous
power (the mean or expected value of which is the average power)
The total or the average power in a signal is often not of as great an interest. We are most
often interested in the PSD or the Power Spectrum. We often want to see is how the input power
has been redistributed by the channel and in this frequency-based redistribution of power is
where most of the interesting information lies. The total area under the Power Spectrum or PSD
is equal to the total average power of the signal. The PSD is an even function of frequency or in
other words To compute PSD:The value of the auto-correlation function at zero-time equals the
total power in the signal. To compute PSD we compute the auto-correlation of the signal and
15
then take its FFT. The auto-correlation function and PSD are a Fourier transform pair. (Another
estimation method called “period gram” uses sampled FFT to compute the PSD.)
ALGORITHM:
CODE:
clc;
clear all;
close all;
N=1024;
fs=8000;
f=input('Enter the frequency[1 to 5000]:');
n=0:N-1;
x=sin(2*pi*(f/fs)*n);
pxx=spectrum(x,N);
specplot(pxx,fs);
grid on;
xlabel('freq(Hz)');
ylabel('magnitude(dB)');
title('Power spectrum of x(n)');
power=0;
for n=1:N
power=power+(norm(x)^2)/N;
end
display(power);
16
MODEL GRAPHS:
PROCEDURE:
RESULT:
VIVA QUESTIONS:
3. What do you mean by phase spectrum and magnitude spectrum/ give comparison?
17
5. What do you mean by spectral resolution?
Date:
EXPERIMENT 3
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES OF DIFFERENT LENGTHS
AIM:
Write a MATLAB Script to perform discrete linear convolution for the given two Sequences and
also prove by manual calculation.
APPARATUS:
THEORY:
LINEAR CONVOLUTION:
The response y[n] of a LTI system for any arbitrary input x[n] is given by convolution of
impulse response h[n] of the system and the arbitrary input x[n].
CODE:
clc;
clear all;
close all;
x=[1,2,3,4,5];
h=[2,3,4];
N1=length(x);
N2=length(h);
N=N1+N2-1;
x=[x,zeros(1,N-N1)];
h=[h,zeros(1,N-N2)];
s=zeros(1,N);
for n=1:N
for k=1:n
s(n)=s(n)+x(k)*h(n-k+1);
end
end
display(s)
n=1:N;
subplot(3,1,1);
stem(n,x);
title('First signal');
subplot(3,1,2);
stem(n,h);
title('Second signal');
subplot(3,1,3);
stem(n,s);
title('Convolution of signal1 and signal2');
19
MODEL GRAPHS:
PROCEDURE:
RESULT:
20
VIVA QUESTIONS
1. Explain the significance of convolution.
2. Define linear convolution.
3. Why linear convolution is called as a periodic convolution?
4. Why zero padding is used in linear convolution?
5. What are the four steps to find linear convolution?
6. What is the length of the resultant sequence in linear convolution?
7. How linear convolution will be used in calculation of LTI system response?
8. List few applications of linear convolution in LTI system design.
9. Give the properties of linear convolution.
10. How the linear convolution will be used to calculate the DFT of a signal?
21
Date:
EXPERIMENT 4
AIM:
Toverify the circular convolution of two given sequences of different lengths
APPARATUS:
PC with Matlab Software
THEORY:
CIRCULAR CONVOLUTION
The convolution of two periodic sequences with period N is called circular convolution of two
signals x1[n] and x2[n] denoted by
N−1 N−1
∑ x1 ∑ x 1( k )
y[n] = x1[n] * x2[n] = k=0 [(n-k) mod N] x2 (k) or k=0 x2 [(n-k) mod N]
Where x1[(n-k) mod N] is the reflected and circularly translated version of x1[n].
It can be performed only if both the sequences consist of equal number of samples. If the
sequences are different in length then convert the smaller size sequence to that of larger size by
appending zeros
ALGORITHM :
22
3. check whether the lengths are equal using the loop
4. if(N3=0)
h=[h,zeros (1,N3)];
else
g=[g,zeros (1,-N3)];
end
6. y(n) = y(n)+g(i)*h(j);
7. stop.
CODE:
clc;
clear all;
close all;
x=[2,2];
h=[1,1,-1];
l1=length(x);
l2=length(h);
N=max(l1,l2);
x=[x,zeros(1,N-l1)];
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x');
title('Sequence1 x=[2,2]');
h=[h,zeros(1,N-l2)];
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h');
title('Sequence2 h=[1,1,-1]');
y=zeros(1,N);
for n=1:N
for m=1:N
j=mod(n-m,N);
r=j+1;
y(n)=y(n)+x(m)*h(r);
end
23
end
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y');
title('Circular convolution of the given sequences');
MODEL GRAPHS:
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run.
RESULT:
24
VIVA QUESTIONS:
3. How to compute maximum length N for a circular convolution using DFT and IDFT.
(what is command).
4. If x 1(n)={1,2,3,4} and x 2(n)={5,6,7,8} Find the circular representation for the above
sequences.
25
Date:
EXPERIMENT-5
DETERMINE THE FFT FOR GIVEN SEQUENCE USING DIT RADIX-2 ALGORITHM
AIM:
Write a MATLAB Script to compute Discrete Fourier Transform of the given sequence using
FFT algorithms (DIT-FFT & DIF-FFT)
APPARATUS:
PC with Matlab Software
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run.
THEORY:
DFT is a powerful tool for performing frequency analysis of discrete time signal and it is
described as a frequency domain representation of a DT sequence.
The DFT of a finite duration sequence x[n] is given by
N 1
x(n)e j 2πnk/N
X (k) = n0 k=0, 1….N-1
Which may conveniently be written in the form
N 1
nk
x ( n) w N
X (k) = n0 k=0, 1….N-1
26
Where WN=e-j2/N which is known as Twiddle or Phase factor.
COMPUTATION OF DFT:
FFT is a method of having computationally efficient algorithms for the execution of DFT, under
the approach of Divide and Conquer. The number of computations can be reduced in N point
DFT for complex multiplications to N/2log2N and for complex addition to N/2log2N.
Types of FFT are,
(i) Decimation In Time (DIT)
(ii) Decimation In Frequency (DIF)
RADIX-2 DECIMATION IN TIME FFT:
The idea is to successively split the N-point time domain sequence into smaller sub
sequence. Initially the N-point sequence is split into xe[n] and xo[n], which have the even and odd
indexed samples of x[n] respectively. The N/2 point DFT’s of these two sequences are evaluated
and combined to give N-point DFT. Similarly N/2 point sequences are represented as a
combination of two N/4 point DFT’s. This process is continued, until we are left with 2 point
DFT.
RADIX-2 DECIMATION IN FREQUENCY FFT:
The output sequence X(k) is divided into smaller sequence.. Initially x[n] is divided into
two sequences x1[n], x2[n] consisting of the first and second N/2 samples of x[n] respectively.
Then we find the N/2 point sequences f[n] and g[n] as
f[n]= x1[n]+x2[n],
g[n]=( x1[n]-x2[n] )wNk
The N/2 point DFT of the 2 sequences gives even and odd numbered output samples. The above
procedure can be used to express each N/2 point DFT as a combination of two N/4 point DFTs.
This process is continued until we are left with 2 point DFT.
ALGORITHM:
27
1. Determine N
2. Find twiddle factor
3. Computer FFT for each stage
4. Stop
CODE:
clc;
clear all;
close all;
x=input('Enter input sequence');
N=length(x);
%twiddle factor calculation
for i=1:4
w(i)=exp(-j*2*pi*(i-1)/N);
end
y=bitrevorder(x);
%Stage 1
for i=1:2:N
s(i)=y(i)+w(1)*y(i+1);
s(i+1)=y(i)-w(1)*y(i+1);
end
%Stage 2
for i=1:4:N
s1(i)=s(i)+w(1)*s(i+2);
s1(i+1)=s(i+1)+w(3)*s(i+3);
s1(i+2)=s(i)-w(1)*s(i+2);
s1(i+3)=s(i+1)-w(3)*s(i+3);
end
%Stage 3
for i=1:4
s2(i)=s1(i)+w(i)*s1(i+4);
s2(i+4)=s1(i)-w(i)*s1(i+4);
end
k=1:N;
subplot(2,1,1);
stem(k,abs(s2));
title('Magnitude response');
subplot(2,1,2);
stem(k,angle(s2));
title('Phase response');
28
MODEL GRAPHS:
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run.
RESULT:
29
VIVA QUESTIONS:
30
Date:
EXPERIMENT-6
AIM:
Write a MATLAB Script to Plot the Magnitude and phase response of IIR filter (LP/HP) using
Butterworth Filter
APPARATUS:
THEORY:
A digital filter is a linear time invariant discrete time system. The digital filters are
classified into two, based on their lengths of impulse response
1. Finite Impulse response (FIR)
They are of non-recursive type and h [n] has finite number of samples
2. Infinite Impulse response (IIR)
h[n] has finite number of samples. They are of recursive type. Hence, their
transfer function is of the form
H ( z ) h( n) z n
n 0
M 1
bk Z k
H (Z ) K 0
N 1
1 a jZ j
j 1
The digital filters are designed from analog filters. The two widely used methods for
digitizing the analog filters include
31
1. Bilinear transformation
2. Impulse Invariant transformation
This transformation maps the jΩ axis (from Ω = -∞ to +∞) repeatedly around the unit circle (exp(
jw), from w=-π to π ) by
2
tan
T 2
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, Find pre-warped analog frequencies using
2
tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 Z 1
S
3. Substitute T 1 Z 1 in the H(s) of Step:2
N =(log√(10^0.1αs-1)(10^0.1αp-1))/(log(Ωs/Ωp)).
7. Stop.
CODE:
clc;
clear all;
close all;
%Low pass filter
alphap=0.4;
alphas=30;
fp=400;
fs=800;
F=2000;
wp=2*pi*fp/(2*pi*F);
ws=2*pi*fs/(2*pi*F);
[n,wn]=buttord(wp,ws,alphap,alphas);
[b,a]=butter(n,wn);
w=0:0.01:pi;
[H,f]=freqz(b,a,w);
33
subplot(2,1,1);
plot(f/pi,20*log(abs(H)));
title('Magnitude plot');
subplot(2,1,2);
plot(f/pi,angle(H));
title('Phase plot');
wp=2*pi*fp/(2*pi*F);
ws=2*pi*fs/(2*pi*F);
[n,wn]=buttord(wp,ws,alphap,alphas);
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[H,f]=freqz(b,a,w);
figure;
subplot(2,1,1);
plot(f/pi,20*log(abs(H)));
title('Magnitude plot');
subplot(2,1,2);
plot(f/pi,angle(H));
title('Phase plot');
MODEL GRAPHS:
34
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
35
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run.
RESULT:
VIVA QUESTION:
36
Date:
EXPERIMENT-7
A digital filter is a discrete time LTI system. It is classified based on the length of the
impulse response as
IIR filters:
Where h [n] has infinite number of samples and is recursive type.
FIR filters:
37
They are non-recursive type and h [n] has finite number of samples.
The transfer function is of the form:
N 1
H ( z ) hn z n
n 0
This implies that it has (N-1) zeros located anywhere in the z-plane and (N-1) poles at Z
= h.
The FIR filter can be designed by:
Fourier series method
Frequency sampling method
Window method
Most of the FIR design methods are interactive procedures and hence require more
memory and execution time. Also implementation of narrow transition band filter is costly. But
there are certain reasons to go for FIR.
TYPES OF WINDOWS:
1. Rectangular
2. Triangular
3. Hamming
4. Hanning
5. Blackman
6. Kaiser
LIBRARY FUNCTIONS:
fir1 FIR filter design using the Window method.
B = fir1(N,Wn) designs an Nth order low pass FIR digital filter and returns the filter
coefficients of vector B of length (N+1). The cut-off frequency Wn must be between 0<Wn<
1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has linear phase.
The normalized gain of the filter at Wn is -6 dB.
B = fir1(N,Wn,'high') designs an Nth order high pass filter. You can also use
B = fir1(N,Wn,'low') to design a low pass filter.
If Wn is a two-element vector, Wn = [W1 W2], fir1 returns an order N band pass filter with pass
band W1 < W < W2.You can also specify B = fir1(N,Wn,'bandpass'). If Wn = [W1 W2], B =
fir1(N,Wn,'stop') will design a band-stop filter.
38
If Wn is a multi-element vector, Wn = [W1 W2 W3 W4 W5 ... WN], fir1 returns a N-order
multi-band filter with
bands 0< W < W1, W1 < W < W2, ..., WN < W < 1.
B = fir1(N,Wn,'DC-1') makes the first band a pass band.
B = fir1(N,Wn,'DC-0') makes the first band a stop band.
B = fir1(N,Wn,WIN) designs an N-th order FIR filter using the vector WIN of (N+1) length to
window the impulse response. If empty or omitted, fir1 uses a Hamming window of length N+1.
For a complete list of available windows, see the Help for the WINDOW function. KAISER and
CHEBWIN can be specified with an optional trailing argument. For example, B =
fir1(N,Wn,kaiser(N+1,4)) uses a Kaiser window with beta=4. B =
fir1(N,Wn,'high',chebwin(N+1,R)) uses a Chebyshev window with R decibels of relative
sidelobeattenuation.For filters with a gain other than zero at Fs/2, e.g., high pass and band stop
filters, N must be even. Otherwise, N will be incremented by one. In this case, the window
length should be specified as N+2. By default, the filter is scaled so the center of the first pass
band has magnitude exactly one after windowing. Use a trailing 'noscale' argument to
prevent this scaling, e.g.
B = fir1(N,Wn,'noscale'), B = fir1(N,Wn,'high','noscale'),
B = fir1(N,Wn,wind,'noscale'). You can also specify the scaling explicitly, e.g.
fir1(N,Wn,'scale'), etc.
We can specify windows from the Signal Processing Toolbox, such as boxcar, hamming,
hanning, bartlett, blackman, kaiser or chebwin
w = hamming(n) returns an n-point symmetric Hamming window in the column vector w. n
should be a positive integer.
w = hanning(n) returns an n-point symmetric Hann window in the column vector w. n must be a
positive integer.
w=triang(n) returns an n-point triangular window in the column vector w. The triangular
window is very similar to a Bartlett window. The Bartlett window always ends with zeros at
samples 1 and n, while the triangular window is nonzero at those points. For n odd, the center (n-
2) points of triang(n-2) are equivalent to bartlett(n).
w = rectwin(n) returns a rectangular window of length n in the column vector w. This function is
provided for completeness. A rectangular window is equivalent to no window at all
ALGORITHM :
3. Calculate hd(n), hw(n), h(n) for various values for rectangular window.
39
∞
hd(n)=1/2π∫H(e^jω).e^jωhω(n)=1.
-∞
4. Calculate hd(n), w(n), h(n) for various values for hamming window.
hd(n)=1/πn sin(πn/2).
6. Stop.
CODE:
clc;
clear all;
close all;
wc=0.5*pi;
N=25;
n=0:1:(N-1);
alpha=(N-1)/2;
hd=sin(wc*(n-alpha+0.001))./((n-alpha+0.001)*pi);
wt=boxcar(N);
w=0:0.01:pi;
hn=hd.*wt(N);
h=freqz(hn,1,w);
figure;
subplot(2,1,1);
plot(w/pi,abs(h));
title('Magnitude plot');
subplot(2,1,2);
plot(w/pi,angle(h));
title('Phase response');
40
MODEL GRAPHS
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run
RESULT:
41
VIVA QUESTION:
1. What is FIR and IIR filter define, and distinguish between these two?
2. What is window method? How you will design an FIR filter using window method?
3. What are low-pass and band-pass filter and what is the difference between these two?
10. What are the advantages of FIR Filters (compared to IIR filters)?
11. What are the disadvantages of FIR Filters (compared to IIR filters)?
Date:
EXPERIMENT-8
42
system generally is proportional to the sampling rate, so the use of a lower sampling rate usually
results in a cheaper implementation.
ALGORITHM :
CODE:
clc;
clear all;
close all;
N=input('Enter the number of samples: ');
D=input('Enter the decimation factor: ');
f=input('Enter the frequency: ');
t=0:0.001:1;
n=0:N-1;
x=sin(2*pi*f*t);
subplot(2,1,1);
stem(n,x(1:N));
y=decimate(x,D);
m=0:(N/D)-1;
subplot(2,1,2);
stem(m,y(1:(N/D)));
MODEL GRAPHS
43
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
3. Click on the ‘FILE’ Menu on menu bar.
4. Click on NEW M-File from the file Menu.
5. An editor window open, start writing code.
6. Now SAVE the file in directory.
7. Then Click on Run.
RESULT:
44
VIVA QUESTIONS:
3. How to compute maximum length N for a circular convolution using DFT and IDFT.
(what is command).
4. If x 1(n)={1,2,3,4} and x 2(n)={5,6,7,8} Find the circular representation for the above
sequences.
Date:
EXPERIMENT-9
IMPLEMENTATION OF INTERPOLATION PROCESS
AIM:
To verify the Interpolation of a given sequence.
APPARATUS:
PC with Matlab Software
THEORY:
45
sampling rate at the output of one system so that another system operating at a higher
sampling rate can input the signal.
ALGORITHM :
CODE:
clc;
clear all;
close all;
N=input('Enter the number of samples: ');
L=input('Enter the interpolation factor: ');
f=input('Enter the frequency: ');
t=0:0.001:1;
n=0:N-1;
x=sin(2*pi*f*t);
subplot(2,1,1);
stem(n,x(1:N));
y=interp(x,L);
m=0:(N*L)-1;
subplot(2,1,2);
stem(m,y(1:(N*L)));
46
MODEL GRAPHS
PROCEDURE:
RESULT:
47
VIVA QUESTION:
Date:
EXPERIMENT-10
IMPLEMENTATION OF I/D SAMPLING RATE CONVERTER
AIM:
To verify the Interpolation of a given sequence.
APPARATUS:
PC with Matlab Software
THEORY:
"Multirate" means "multiple sampling rates". A multirate DSP system uses multiple
sampling rates within the system. Whenever a signal at one rate has to be used by a
system that expects a different rate, the rate has to be increased or decreased, and some
processing is required to do so. Therefore "Multirate DSP" refers to the art or science of
changing sampling rates. "Resampling" means combining interpolation and decimation to
48
change the sampling rate by a rational factor. Resampling is done to interface two systems
with different sampling rates.
ALGORITHM :
CODE:
clc;
clear all;
close all;
N=input('Enter the number of samples: ');
L=input('Enter the interpolation factor: ');
D=input('Enter the decimation factor: ');
f=input('Enter the frequency: ');
t=0:0.001:1;
n=0:N-1;
x=sin(2*pi*f*t);
subplot(2,1,1);
stem(n,x(1:N));
y=resample(x,L,D);
m=0:(N*L/D)-1;
subplot(2,1,2);
stem(m,y(1:(N*L/D)));
49
MODEL GRAPHS
PROCEDURE:
1. Click on the MATLAB Icon on the desktop.
2. MATLAB window open.
50
VIVA QUESTION:
3. Define interpolation.
4. Define decimation.
5. Define aliasing.
Date:
EXPERIMENT-11
AIM:
THEORY:
A signal can be defined as a function that conveys information, generally about the state or
behavior of a physical system. There are two basic types of signals viz. Analog (continuous time
signals which are defined along a continuum of times) and Digital (discrete-time).Remarkably,
under reasonable constraints; a continuous time signal can be adequately represented by samples,
obtaining discrete time signals. Thus digital signal processing is an ideal choice for anyone who
needs the performance advantage of digital manipulation along with today’s analog reality.
Hence a processor which is designed to perform the special operations (digital manipulations) on
51
the digital signal within very less time can be called as a Digital signal processor. The difference
between a DSP processor, conventional microprocessor and a microcontroller are listed below.
-No RAM
-No ROM
-No Timer
Contains - CPU
- RAM
- ROM
-I/O ports
- Timer &
- Interrupt circuitry
Some Micro Controllers also contain A/D, D/A and Flash Memory
Contains - CPU
- RAM
-ROM
- I/O ports
- Timer
- Extended precision
52
- Dual operand fetch
- Circular buffering
This chapter provides an overview of the architectural structure of the TMS320C67xx DSP,
which comprises the central processing unit (CPU), memory, and on-chip peripherals. The
C67xE DSPs use an advanced modified Harvard architecture that maximizes processing power
with eight buses Separate program and data spaces allow simultaneous access to program
instructions and data, providing a high degree of parallelism. For example, three reads and one
write can be performed in a single cycle. Instructions with parallel store and application-specific
instructions fully utilize this architecture. In addition, data can be transferred between data and
program spaces. Such Parallelism supports a powerful set of arithmetic, logic, and bit-
manipulation operations that can all be performed in a single machine cycle. Also, the C67xx
DSP includes the control mechanisms to manage interrupts, repeated operations, and function
calling.
53
Bus Structure
The C67xx DSP architecture is built around eight major 16-bit buses (four program/data buses
and four address buses):
The program bus (PB) carries the instruction code and immediate operands from program
memory.
Three data buses (CB, DB, and EB) interconnect to various elements, such as the CPU,
data address generation logic, program address generation logic, on-chip peripherals, and
data memory.
The CB and DB carry the operands that are read from data memory.
Four address buses (PAB, CAB, DAB, and EAB) carry the addresses needed for
instruction execution.
Central Processing Unit (CPU)
The CPU is common to all C67xE devices. The C67x CPU contains:
Barrel shifter
17 × 17-bit multiplier
40-bit adder
The C67x DSP performs 2s-complement arithmetic with a 40-bit arithmetic logic unit (ALU)
and two
40-bit accumulators (accumulators A and B). The ALU can also perform Boolean operations.
The ALU
OBSERVATIONS:
55
RESULT: The architecture of DSP chips-TMS 320c 5x/6x is studied successfully.
VIVA QUESTIONS
56
Date:
EXPERIMENT-12
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES AND PLOT USING TMS
PROCESSOR
AIM:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
USB Cable
Power supply
PC
THEORY:
LINEAR CONVOLUTION:
The response y[n] of a LTI system for any arbitrary input x[n] is given by convolution of
impulse response h[n] of the system and the arbitrary input x[n].
PROCEDURE:
2. Create a new project, give a meaningful name ,save into working folder, select target as
3. Click on file open→new→source file save it with .c extension in working folder and
write .ccode for desired task.
tools\lib\rts6700.lib].
11. Connect the kit to the system through the USB cable
59
CODE:
60
RESULT:
61
VIVA QUESTIONS
10. How the linear convolution will be used to calculate the DFT of a signal?
Date:
62
EXPERIMENT 13:
MAGNITUDE RESPONSE OF FIR LOW PASS FILTER USING RECTANGULAR
WINDOWING TECHNIQUE
AIM:
To find Magnitude response of FIR Low pass filter using rectangular windowing technique CC
STUDIO.
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
USB Cable
Power supply
PC
THEORY:
A digital filter is a discrete time LTI system. It is classified based on the length of the impulse
response as
IIR filters:
Where h [n] has infinite number of samples and is recursive type.
FIR filters:
They are non-recursive type and h [n] has finite number of samples.
The transfer function is of the form:
N 1
H ( z ) hn z n
n 0
This implies that it has (N-1) zeros located anywhere in the z-plane and (N-1) poles at Z = h.
Most of the FIR design methods are interactive procedures and hence require more memory and
execution time. Also implementation of narrow transition band filter is costly. But there are
certain reasons to go for FIR.
63
PROCEDURE TO CREATE NEW PROJECT:
64
4. Enter the source code and save the file with “.C” extension.
5. Right click on source, Select add files to project and Choose “.C “ file Saved before.
65
6. Right Click on libraries and select add files to Project and choose
7. a) Go to Project to Compile .
b) Go to Project to Build.
66
8. Go to file and load program and load “.out” file into the board..
67
2. Observe the output in output window.
3. To see the Graph go to View and select time/frequency in the Graph, And give the
correct Start
address provided in the program, Display data can be taken as per user.
68
CODE:
69
RESULT:
VIVA QUESTIONS
1. What is a filter?
4. What are the differences between recursive and non recursive systems?
70
Date:
EXPERIMENT 14:
MAGNITUDE RESPONSE OF IIR LOW PASS FILTER
AIM:
To find Magnitude response of IIR Low pass filter using CC STUDIO.
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
USB Cable
Power supply
PC
THEORY:
A digital filter is a linear time invariant discrete time system. The digital filters are
classified into two, based on their lengths of impulse response
1. Finite Impulse response (FIR)
They are of non-recursive type and h [n] has finite number of samples
2. Infinite Impulse response (IIR)
h[n] has finite number of samples. They are of recursive type. Hence, their
transfer function is of the form
H ( z ) h( n) z n
n 0
M 1
bk Z k
H (Z ) K 0
N 1
1 a jZ j
j 1
The digital filters are designed from analog filters. The two widely used methods for
digitizing the analog filters include
71
1. Bilinear transformation
2. Impulse Invariant transformation
This transformation maps the jΩ axis (from Ω = -∞ to +∞) repeatedly around the unit circle (exp(
jw), from w=-π to π ) by
2
tan
T 2
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, Find pre-warped analog frequencies using
2
tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 Z 1
S
3. Substitute T 1 Z 1 in the H(s) of Step:2
k 1
72
PROCEDURE TO CREATE NEW PROJECT:
73
4. Enter the source code and save the file with “.C” extension.
5. Right click on source, Select add files to project and Choose “.C “ file Saved before.
74
6. Right Click on libraries and select add files to Project and choose
7. a) Go to Project to Compile .
b) Go to Project to Build.
75
8. Go to file and load program and load “.out” file into the board..
76
5. Observe the output in output window.
6. To see the Graph go to View and select time/frequency in the Graph, And give the
correct Start
address provided in the program, Display data can be taken as per user.
77
CODE:
78
RESULT:
VIVA QUESTIONS
79
Date:
Augmented Experiment:
80
81
82
83
84
85