0% found this document useful (0 votes)
59 views

Digital Signal Processing Lab: Dr. Nanda Kumar M

Digital Signal Processing lab taught by Dr. Nanda Kumar M. The lab covers topics including: 1. Finding the impulse response of first and second order systems and programming filters. 2. Designing and analyzing low pass, high pass, and band pass analog and digital filters. 3. Implementing techniques like circular and linear convolution, DFT, IDFT, FFT, and finding the power spectral density of sequences. 4. Designing IIR and FIR filters using methods like Butterworth, Chebyshev, and windowing and analyzing their frequency responses. Experiments are implemented using MATLAB and CCS to study DSP chip architecture, filtering, sampling, and generating signals.

Uploaded by

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

Digital Signal Processing Lab: Dr. Nanda Kumar M

Digital Signal Processing lab taught by Dr. Nanda Kumar M. The lab covers topics including: 1. Finding the impulse response of first and second order systems and programming filters. 2. Designing and analyzing low pass, high pass, and band pass analog and digital filters. 3. Implementing techniques like circular and linear convolution, DFT, IDFT, FFT, and finding the power spectral density of sequences. 4. Designing IIR and FIR filters using methods like Butterworth, Chebyshev, and windowing and analyzing their frequency responses. Experiments are implemented using MATLAB and CCS to study DSP chip architecture, filtering, sampling, and generating signals.

Uploaded by

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

Digital Signal Processing lab

Dr. Nanda Kumar M


Syllabus
1. Impulse response of first order and second order systems.
2. Program to find frequency response of LP/HP filters (difference equation/ transfer function).
3. To find Circular convolution of given sequence with and without built in function.
4. To find the DFT/IDFT, FFT of given DT signals with and without built in functions.
5. To find Power Spectral Density of a sequence.
6. To implement IIR filter (LP/HP/BP)
• a) Butterworth filter
• b) Chebyshev Type-I and Type-II filters
7. To design FIR filter (LP/HP) using windowing technique
• a) Using rectangular window
• b) Using triangular window
• c) Using Kaiser Window
8. Down sampling and up sampling of given sequence by specified factor.
9. Conversion of Analog filter to Digital Filter.
• a) impulse invariant transformation
• b) bilinear transformation
10. Generation of DTMF signals
11. Noise removal: Add noise above 3 KHz and then remove, interference suppression using 400
Hz tone.
The following experiments are to be
implemented using CCS
1. Study the architecture of DSP chips-TMS 320C
5X/6X Instructions
2. To find Linear convolution of given sequence.
3. To find Circular convolution of given sequence
4. To find the DFT & FFT of given sequence
5. Generation of DTMF Signals
6. Implementation of Decimation Process &
Interpolation Process.
1. Impulse Response of First Order and
Second Order Systems
AIM: program to implement sampling rate conversion.
SOFTWARE: MATLAB
THEORY: The response of an LTI system when an unit
impulse sequence is applied at the input of the system.
It is denoted by h(n).
Program
clc;
close all;
clear all;
n=0:10; %impulse response of first order system
b=[2 0 0];
a=[1 -0.9 0];
y=dimpulse(b,a,length(n));
subplot(2,1,1);
stem(n,y); xlabel('n--->');
ylabel('amplitude');
title('impulse response of first order system');
b=[1 0 0];
a=[1 0.6 0.8];
y1=dimpulse(b,a,length(n));
subplot(2,1,2);
stem(n,y1);
xlabel('n---->');
ylabel('amplitude');
title('impulse response of second order system');
2. Frequency response of analog LP/HP filters.
Aim: write a program to find frequency response of analog LP/HP
filters
APPARATUS REQUIRED:
System with Matlab, windows OS
Theory:
A digital filter may be represented mathematically in many different
forms, but the most common are: 1) factored form or pole-zero
form, 2) polynomial form, and 3) cascaded second order systems
form. Each one of these is a ratio of polynomials and regardless of
the form, they are all equivalent mathematically. The middle list of
values in the Create_Filter.vi front panel is the zeros and poles of
the filter with the gain shown above them. This would lead to H(z)
written as
Program
• clc; clear all;
• b=input('Enter the numerator coefficients:');
a=input('Enter the denominator coefficients:');
[h,w]=freqz(b,a);
• subplot(2,1,1);
• plot(w/pi,abs(h)); grid;
• xlabel('Normalised Frequency'); ylabel('Magnitude in
dB'); title('Magnitude Response'); subplot(2,1,2);
plot(w/pi,angle(h));
• grid;
• xlabel('Normalised Frequency'); ylabel('phase in
radians'); title('Phase Response');
3. Circular Convolution
Aim: write a program find the circular convolution of
given sequences
APPARATUS REQUIRED:
System with Matlab, windows OS
Theory
Circular convolution is analogous to the linear convolution, but
with a subtle difference. Linear convolution produces a sequence
of length (M+N-1) with two sequences of lengths M,N respectively.
Where as in circular convolution the resultant sequence would
have Max(M,N) samples in it. It is achieved by circular time shifting
and circular time reversal. Mathematically, circular convolution is
defined as
Program
clc;
clear all;
close all;
x1=input('Enter the first sequence x1(n) = ');
x2=input('Enter the second sequence x2(n) = ');
L=length(x1);
M=length(x2); N=L+M-1;
yn=cconv(x1,x2);
disp(‘The values of yn are= ‘); disp(yn);
• n1=0:L-1;
• subplot(311); stem(n1,x1); grid on;
• xlabel('n1--->'); ylabel('amplitude--->');
• title('First sequence');
• n2=0:M-1;
• subplot(312); stem(n2,x2); grid on;
• Xlabel('n2--->'); ylabel('amplitude--->');
• Title(‘ Second sequence’)
• subplot(313); stem(n1,yn); grid on;
• xlabel('n1--->'); ylabel('amplitude--->');
• Title(‘ output sequence’)
First sequence

amplitude--->
4

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
n1--->
amplitude--->

10

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
n2--->
amplitude--->

40

20

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
n2--->
Linear convolution
• clc; clear all; close all;
• x1=input('Enter the first sequence x1(n) = ');
x2=input('Enter the second sequence x2(n) = ');
• L=length(x1);
• M=length(x2); N=L+M-1;
• yn=conv(x1,x2);
• disp(‘The values of yn are= ‘); disp(yn);
• n1=0:L-1;
• subplot(311); stem(n1,x1); grid on;
• xlabel('n1--->'); ylabel('amplitude--->');
title('First sequence');
• n2=0:M-1;
• subplot(312); stem(n2,x2); grid on;
• xlabel('n2--->');
• ylabel('amplitude--->');
• N2=0:N-1;
• subplot(313); stem(n2,yn); grid on;
• xlabel('n2--->');
• ylabel('amplitude--->');
First sequence

amplitude--->
4

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
n1--->
amplitude--->

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
n2--->
amplitude--->

20

10

0
0 0.5 1 1.5 2 2.5 3 3.5 4
n2--->
4. DFT/IDFT and FFT of given
DTsignal
clc; close all; clear all;
xn=input('Enter the sequence x(n)');
ln=length(xn);
xk=zeros(1,ln);
ixk=zeros(1,ln);
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((-i)*2*pi*k*n/ln));
End
end
%Plotting input sequence %
t=0:ln-1;
subplot(221);
stem(t,xn);
ylabel ('Amplitude');
xlabel ('Time Index');
title('Input Sequence'); %-----------------------
• magnitude=abs(xk);
• t=0:ln-1;
• subplot(222);
• stem(t,magnitude);
• ylabel ('Amplitude');
• xlabel ('K'); title('Magnitude Response');
phase=angle(xk);
• t=0:ln-1;
• subplot(223);
• stem(t,phase);
• ylabel ('Phase');
• xlabel ('K'); title ('Phase Response');
IDFT
for n=0:ln-1
for k=0:ln-1
ixk(n+1)=ixk(n+1)+(xk(k+1)*exp(i*2*pi*k*n/ln));
end
End
ixk=ixk./ln;
t=0:ln-1;
subplot(224);
stem(t,ixk);
ylabel ('Amplitude'); xlabel ('Time Index’)
FFT
• clc; clear all;close ll;
• x=input('Enter the sequence : ')
• N=length(x)
• xK=fft(x,N)
• xn=ifft(xK)
• n=0:N-1;
• subplot (2,2,1); stem(n,x); xlabel('n >'); ylabel('amplitude');
title('input sequence');
• subplot (2,2,2); stem(n,abs(xK));xlabel('n ---------------- >');
ylabel('magnitude'); title('magnitude response');
• subplot (2,2,3); stem(n,angle(xK));xlabel('n ---------------- >');
ylabel('phase'); title('Phase responce');
• subplot (2,2,4); stem(n,xn); xlabel('n >'); ylabel('amplitude');
title('IFFT');
5.PSD
Program
clc; clear all;close all;
N=256;
fs=8000;
f=input('enter the frequency[1 to 5000]:'); n=0:N-1;
x=sin(2*pi*(f/fs)*n)
Y = fft(y,512);
Pyy = Y.* conj(Y) / 512;
f = 1000*(0:256)/512;
subplot(2,1,2);
plot(f, Pyy(1:257))
title('Frequency content of y');
xlabel('frequency (Hz)');
6. Implement IIR filter (LP/HP/BP)
Aim: write a program to implement IIR filter (LP/HP/BP)
a) Butterworth filter b) Chebyshev Type-I filter
c) Chebyshev Type- II filter
APPARATUS REQUIRED:
System with Matlab, windows OS
Program
• clc; clear all; close all;
• disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple:'); rs=input('enter
the stopband ripple:'); wp=input('enter the passband
freq:'); ws=input('enter the stopband freq:');
fs=input('enter the sampling freq:'); w1=2*wp/fs;
• w2=2*ws/fs;
• [n,wn]=buttord(w1,w2,rp,rs,'s');
• disp('Frequency response of IIR LPF is:');
• [b,a]=butter(n,wn,'low','s');
• w=0:.01:pi;
• [h,om]=freqs(b,a,w);
• m=20*log10(abs(h));
• an=angle(h);
• figure,subplot(2,1,1);
• plot(om/pi,m);
• title('magnitude response of IIR filter is:');
• xlabel('(a) Normalized freq. -->');
• ylabel('Gain in dB-->');
• subplot(2,1,2);plot(om/pi,an);
• title('phase response of IIR filter is:');
• xlabel('(b) Normalized freq. -->');
• ylabel('Phase in radians-->');
7. Design FIR filter (LP/HP) using windowing technique

Aim: write a program to design FIR filter (LP/HP) using


windowing technique
a) Using rectangular window b) Using triangular window
c) Using Kaiser Window

APPARATUS REQUIRED:
System with Matlab, windows OS
clc; clear all; close all;
clc; clear all; close all;
n=20; fp=200; fq=300; fs=1000; n=20; fp=300; fq=200; fs=1000;
fn=2*fp/fs; fn=2*fp/fs; window=blackman(n+1);
window=blackman(n+1); b=fir1(n,fn,'high',window);
b=fir1(n,fn,window); [H W]=freqz(b,1,128);
[H W]=freqz(b,1,128); subplot(2,1,1);
subplot(2,1,1); plot(W/pi,abs(H));
plot(W/pi,abs(H)); title('mag res of lpf');
title('magnitude response of lpf'); ylabel('gain in db >');
ylabel('gain in db >');
xlabel('normalized frequency ----- >');
xlabel('normalized frequency ----- >');
subplot(2,1,2);
subplot(2,1,2); plot(W/pi,angle(H));
title('phase response of lpf'); plot(W/pi,angle(H)); title('phase res of
ylabel('angle ------- >'); lpf'); ylabel('angle >');
xlabel('normalized frequency ----- >'); xlabel('normalized frequency ----- >');
8. Down sampling and Up sampling of given
sequence
• Aim: write a program to find Power Spectral Density of a sequence
• APPARATUS REQUIRED:
• System with Matlab, windows OS
• Theory:
• • Down-sampling operation is implemented by keeping every M-th
sample of x[n] and removing in-between samples to generate y[n]
• • Input-output relation
• y[n] = x[nM]

• Up sampling
• x [n] =x[n / M],
Program
Down sampling Up sampling
clc; Clear all; Close all; clc; clear all; close all;
D=input('enter the downsampling factor'); L=input('enter the upsampling factor');
L=input('enter the length of the input signal'); N=input('enter the length of the input signal');
f1=input('enter the frequency of first sinusodal');
f1=input('enter the frequency of first
f2=input('enter the frequency of second sinusodal');
sinusodal');
n=0:L-1;
f2=input('enter the frequency of second
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
sinusodal');
y=decimate(x,D,'fir');
subplot(2,1,1); n=0:N-1;
stem(n,x(1:L)); x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
title('input sequence'); xlabel('time(n)'); y=interp(x,L);
ylabel('amplitude'); subplot(2,1,1) stem(n,x(1:N))
subplot(2,1,2) m=0:(L/D)-1; title('input sequence'); xlabel('time(n)');
stem(m,y(1:L/D)); 117 ylabel('amplitude'); subplot(2,1,2)
title('Decimated sequence'); xlabel('time(n)');
m=0:N*L-1;
ylabel('amplitude');
stem(m,y(1:N*L)) title('output sequence ');
xlabel('time(n)'); ylabel('amplitude');
Up sampling
Down sampling
input sequence
input sequence 2
2
1

amplitude
1
amplitude

0
0
-1
-1
-2
-2 0 1 2 3 4 5 6 7 8 9
0 10 20 30 40 50 60 70 80 90 100 time(n)
time(n) output sequence
2
Decimated sequence
2
0
1
amplitude

0 -2

-1
-4
0 5 10 15 20 25 30 35 40 45 50
-2
0 2 4 6 8 10 12 14 16 18 20
time(n)
9. Conversion of Analog filter to Digital Filter
Aim: write a program Conversion of Analog filter to
Digital Filter.
a) impulse invariant transformation
b) bilinear transformation
APPARATUS REQUIRED:
System with MATLAB, windows OS
10. Generation of DTMF signals
Aim: Write a program to generate DTMF signals
APPARATUS REQUIRED:
System with MATLAB, Windows OS
Theory: Dual-tone Multi-Frequency (DTMF)
signalling is the basis for voice communications
control and is widely used worldwide in modern
telephony to dial numbers and configure
switchboards. It is also used in systems such as in
voice mail, electronic mail and telephone banking.
Program
Fs = 8000; N = 800; t = (0:N-1)/Fs; pit = 2*pi*t;
tones = zeros(N,size(f,2));
for toneChoice=1:12,
tones(:,toneChoice) = sum(sin(f(:,toneChoice)*pit))‘;
subplot(4,3,toneChoice),
plot(t*1e3,tones(:,toneChoice)); title(['Symbol "', symbol {toneChoice},'":
[',num2str(f(1,toneChoice)),',',num2str(f(2,toneChoice)),']']) set(gca, 'Xlim', [0
25]); ylabel('Amplitude');
if toneChoice>9, xlabel('Time (ms)'); end
end
set(gcf, 'Color', [1 1 1], 'Position', [1 1 1280 1024])
annotation(gcf,'textbox', 'Position',[0.38 0.96 0.45 0.026],...
'EdgeColor',[1 1 1],...
'String', '\bf Time response of each tone of the telephone pad', ...
'FitHeightToText','on');
11. Generation of DTMF signals
Aim: Write a program to generate DTMF signals
APPARATUS REQUIRED:
System with MATLAB, Windows OS
Theory: Dual-tone Multi-Frequency (DTMF)
signalling is the basis for voice communications
control and is widely used worldwide in modern
telephony to dial numbers and configure
switchboards. It is also used in systems such as in
voice mail, electronic mail and telephone banking.
• clc;
• clear all;
• close all;
• t = -2:0.05:2;
• x=input('enter the input number');
• fr1=697;
• fr2=770;
• fr3=852;
• fr4=941;
• fc1=1209;
• fc2=1336;
• fc3=1477;
• fc4=1633;
• y0 = sin(2*pi*fr4*t) + sin(2*pi*fc2*t); % 0
• y1 = sin(2*pi*fr1*t) + sin(2*pi*fc1*t); % 1
• y2 = sin(2*pi*fr1*t) + sin(2*pi*fc2*t); % 2
• y3 = sin(2*pi*fr1*t) + sin(2*pi*fc3*t); % 3
• y4 = sin(2*pi*fr2*t) + sin(2*pi*fc1*t);
• y5 = sin(2*pi*fr2*t) + sin(2*pi*fc2*t); % 5
• y6 = sin(2*pi*fr2*t) + sin(2*pi*fc3*t); % 6
• y7 = sin(2*pi*fr3*t) + sin(2*pi*fc1*t); % 7
• y8 = sin(2*pi*fr3*t) + sin(2*pi*fc2*t); % 8
• y9 = sin(2*pi*fr3*t) + sin(2*pi*fc3*t); % 9
• y_start = sin(2*pi*fr4*t) + sin(2*pi*fc1*t); % *
• y_canc = sin(2*pi*fr4*t) + sin(2*pi*fc3*t); % #
• if (x==1)
• plot(t,y1)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==2)
• plot(t,y2)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==3)
• plot(t,y3)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==4)
• plot(t,y4)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==5)
• plot(t,y5)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==6)
• plot(t,y6)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==7)
• plot(t,y7)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==8)
• plot(t,y8)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==9)
• plot(t,y9)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==0)
• plot(t,y0)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==11)
• plot(t,y_start)
• xlabel('time(t)')
• ylabel('amplitude')
• elseif (x==12)
• plot(t,y_canc)
• xlabel('time(t)')
• ylabel('amplitude')
• else
• disp('enter the correct input')
• end

You might also like