Ec8562 DSP Manual
Ec8562 DSP Manual
LABORATORY MANUAL
Regulation - 2017
SRM VEC/ECE/LM/EC8562/DSPL/2020-21/ODD 1
SRM VALLIAMMAI ENGINEERING COLLEGE
(An Autonomous Institution)
SRM Nagar, Kattankulathur – 603 203
M1: To educate the students with the state of art technologies to compete
internationally, able to produce creative solutions to the society`s needs,
conscious to the universal moral values, adherent to the professional ethical code
M2: To encourage the students for professional and software development career
M3: To equip the students with strong foundations to enable them for continuing
education and research.
SRM VEC/ECE/LM/EC8562/DSPL/2020-21/ODD 2
SRM VALLIAMMAI ENGINEERING COLLEGE
(An Autonomous Institution)
SRM Nagar, Kattankulathur – 603 203
PROGRAM OUTCOMES
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solution of complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design system
components or processes that meet the specified needs with appropriate consideration for the public health and
safety, and the cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods including
design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid
conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and
IT tools including prediction and modelling to complex engineering activities with an understanding of the
limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health,
safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering
practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal
and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the
engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams,
and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and
management principles and apply these to one‟s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent
and life-long learning in the broadest context of technological change.
PSO1: Ability to apply the acquired knowledge of basic skills, mathematical foundations, principles of
electronics, modelling and design of electronics based systems in solving engineering Problems.
PSO2: Ability to understand and analyze the interdisciplinary problems for developing innovative sustained
solutions with environmental concerns.
PSO3: Ability to update knowledge continuously in the tools like MATLAB, NS2, XILINIX and technologies
like VLSI, Embedded, Wireless Communications to meet the industry requirements.
PSO4: Ability to manage effectively as part of a team with professional behaviour and ethics.
3
SRM
SYLLABUS LTP
C004
2
OBJECTIVES:
The student should be made:
• To perform basic signal processing operations such as Linear Convolution, Circular Convolution,
Auto Correlation, Cross Correlation and Frequency analysis in MATLAB
• To implement FIR and IIR filters in MATLAB and DSP Processor
• To study the architecture of DSP processor
• To design a DSP system to demonstrate the Multi-rate and Adaptive signal processing concepts.
LIST OF EXPERIMENTS:
TOTAL: 60 PERIODS
OUTCOMES:
At the end of the course, the student should be able to:
• Carryout basic signal processing operations
• Demonstrate their abilities towards MATLAB based implementation of various DSP systems
• Analyze the architecture of a DSP Processor
• Design and Implement the FIR and IIR Filters in DSP Processor for performing filtering
operation over real-time signals
• Design a DSP system for various applications of DSP
4
SRM
LIST OF EXPERIMENTS
CYCLE I
5
SRM
Ex No: Date:
Aim:
To write a MATLAB program to generate unit step, unit impulse, unit ramp, exponential, sine
waveform, cosine waveform, random signal and correlation.
Description:
Input : Enter the sequence length for the generation of signals.
Algorithm:
6
SRM
Program:
8
SRM
Model Graph:
amplitude
amplitude
0.5
0.5
0
-4 -2 0 2 4 0
0 2 4 6
t --->
t --->
Ramp Signal Exponential Signal
6
150
4 100
amplitude
amplitude
2 50
0 0
0 2 4 6 0 2 4 6
t ---> t --->
0.5 0.5
amplitude
amplitude
0 0
-0.5 -0.5
-1
-4 -2 0 2 4 -1
-4 -2 0 2 4
t --->
t --->
Discrete Sine waveform
Discrete Cosine waveform
1
1
0.5
0.5
amplitude
amplitude
0
0
-0.5
-0.5
-1
-4 -2 0 2 4 -1
-4 -2 0 2 4
t --->
t --->
9
SRM
%Program for Random Signal
t = rand(1,10);
subplot(2,1,1);
plot(t);
ylabel('amplitude --->');
xlabel('t --->');
title('Random Signal');
disp('t=');
disp(t);
a=2;
b=3;
t1 = a + (b-a).*rand(100,1);
subplot(2,1,2);
plot(t1)
ylabel('amplitude --->');
xlabel('t --->');
title('Random Signal');
disp('t1=');
disp(t1);
Random Signal
1
amplitude
0.5
0
1 2 3 4 5 6 7 8 9 10
t --->
Random Signal
3
amplitude
2.5
2
0 10 20 30 40 50 60 70 80 90 100
t --->
1
SRM
% Program for computing cross-correlation of the sequences x[1 2 3 4] and h[4 3 2 1]
clc;
clear all;
close all;
x=input('enter the 1st sequence');
h=input('enter the 2nd sequence');
y= xcorr(x,h);
subplot(3,1,1);
stem(x);
ylabel('Amplitude --.');
xlabel('(a) n --.');
title('input sequence');
subplot(3,1,2);
stem(h);
ylabel('Amplitude --.');
xlabel('(b) n --.');
title('impulse sequence');
subplot(3,1,3);
stem(y);
ylabel('Amplitude --.');
xlabel('(c) n --.');
title('Cross correlated
sequence'); disp('The resultant
signal is y='); disp(y)
Output:
enter the 1st sequence[1 2 3 4]
enter the 2nd sequence[4 3 2 1]
The resultant signal is y=
1.0000 4.0000 10.0000 20.0000 25.0000 24.0000 16.0000
1
SRM
Model Graph:
input sequence
4
Amplitude
2
0
1 1.5 2 2.5 3 3.5 4
(a) n --.
impulse sequence
4
Amplitude
0
1 1.5 2 2.5 3 3.5 4
(b) n --.
Cross correlated sequence
40
Amplitude
20
0
1 2 3 4 5 6 7
(c) n --.
Output:
enter the sequence[1 2 3 4]
The resultant signal is y=
4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000
1
SRM
Model Graph
original signal
4
Amplitude 3
0
1 1.5 2 2.5 3 3.5 4
(a) n --.
Auto correlated sequence
30
20
Amplitude
10
0
1 2 3 4 5 6 7
(a) n --.
Postlab Questions:
1. Modify Program (b) to generate a delayed unit step sequence u[n] with an advance of “n”
samples. Run the modified program and display the sequence generated.
2. What is the subplot command used to plot 4 figures in 2 rows and 2 columns?
3. How can you compute the average power of the generated sinusoidal sequence?
4. Write the syntax to determine auto correlation of the given signal x[n].
5. Give the examples for 1-D, 2-D & 3-D signals.
Result:
Thus a program to generate sequence for unit step, unit impulse, unit ramp, exponential, sine,
cosine and correlation signal using MATLAB was written and executed and the corresponding simulation
output is plotted.
1
SRM
Ex No: Date:
Aim:
To write a program to find out the linear convolution of two sequence using Matlab.
Algorithm:
Program:
% Program for Linear Convolution
clc;
clear all;
close all;
%x=[1 1 1 1];
%h=[4 5 6 7];
x=input('enter the value x=');
h=input('enter the value h=');
subplot(3,1,1);
stem(x);
title('Input x(n)');
ylabel('x(n) --->');
xlabel('t --->');
subplot(3,1,2);
stem(h);
1
SRM
title('Input h(n)');
ylabel('h(n) --->');
xlabel('t --->');
h1=fliplr(h);
n1=length(x);
n2=length(h);
n=n1+n2-1;
x=[zeros(1,n2-1),x];
h1=[h1,zeros(1,n1-1)];
for i=1:n
new=[zeros(1,i-1),h1(1:n-i+1)];
out(i)=x*new';
end
disp('output=');
disp(out);
subplot(3,1,3);
t=0:1:n-1;
stem(t,out);
title('Output y(n)');
ylabel('y(n) --->');
xlabel('t --->');
MODEL GRAPH
Input x(n)
1
0.5
x(n)
0
1 1.5 2 2.5 3 3.5 4
t --->
Input h(n)
10
5
h(n)
0
1 1.5 2 2.5 3 3.5 4
t --->
Output y(n)
20
y(n)
10
0
0 1 2 3 4 5 6 7
t --->
THEORETICAL CALCULATION
∞
𝑦(𝑛) = ∑ 𝑥(𝑘)ℎ(𝑛 − 𝑘)
𝑘=−∞
1
SRM
EX NO: 2b CIRCULAR CONVOLUTION
Aim:
To write a program to find out the circular convolution of two sequences using MATLAB.
Description:
Input: Give the input x(n) and h(n) in matrix form.
N 1
y(n)
x(k)h(n k)
k 0
Algorithm:
1. Start the program.
2. Get the two input sequence x(n) and h(n) and compute the length of the sequence.
3. Append zeros to x(n) or h(n) to make both sequence of same length.
4. Rotate the sequence h(-k), „n‟ times. If „n‟ is positive shift the sequence in anticlockwise direction
else in the clockwise direction.
5. Determine the product of sequence x(n) and shifted h(n) sequence and sum it.
6. Execute the program, display the result and verify it theoretically.
7. Plot the output graph for each sequence.
8. Stop the process.
Program:
% Program for Circular Convolution
clc;
clear all;
close all;
%g=[1,2,3,4];
%h=[2,4,6];
x=input('enter the
sequence'); h=input('enter
the sequence'); N1=length(x);
N2=length(h);
subplot(3,1,1);
n=0:1:N1-1;
stem(n,x);
title('x(n)');
ylabel('amplitude --->');
xlabel('time --->');
subplot(3,1,2);
n=0:1:N2-1;
stem(n,h);
title('h(n)');
ylabel('amplitude --->');
1
SRM
xlabel('time --->');
N=max(N1,N2);
if(N1<=N);
x1=[x,zeros(1,N-N1)];
end
if(N2<=N);
h1=[h,zeros(1,N-N2)];
end
for n=1:N
y(n)=0;
for i=1:N
j=n-i+1;
if(j<=0)
j=N+j;
end
y(n)=y(n)+x1(i)*h1(j);
end
end
disp('y=');
disp(y);
subplot(3,1,3);
n=0:1:N-1;
stem(n,y);
title('output y(n)');
ylabel('amplitude --->');
xlabel('time --->');
MODEL GRAPH
g(n)
4
amplitude
0
0 0.5 1 1.5 2 2.5 3
time --->
h(n)
10
amplitude
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
time --->
output y(n)
40
amplitude
20
0
0 0.5 1 1.5 2 2.5 3
time --->
1
SRM
THEORITICAL CALCULATION
N 1
y(n)
x(k)h(n k)
k 0
Output Sequence is = 36 32 20 32
Matrix Method:
x(0) x(N-1) x(n-2) ….. x(1) h(0) y(0)
x(1) x(0) x(N-1)… x(2) h(1) y(1)
x(2) x(1) x(0)… x(N-1) h(2) y(2)
. . .
. . = . . .
.
x(N-1) x(N-2) x(N-3).. x(0) h(N-1) y(N-1)
Postlab Questions :
Result:
Thus a program to find out the linear and circular convolution of two sequences using Matlab was
written and executed.
1
SRM
Ex No: Date:
3(a). SPECTRUM ANALYSIS USING DFT
Aim:
To analyze the amplitude and phase response of the DFT and IDFT signal using MATLAB.
Algorithm:
Program:
% Program for Discrete Fourier Transform
clc;
clear all;
close all;
%x=[1 2 3 4 5 6 7 8];
%N=[8];
x=input('enter the input x=');
N=input('enter the order of dft
N='); k=0:1:N-1;
disp('Input Sequence x=');
disp(x);
XK=fft(x,N);
disp('XK=');
disp(XK);
R=real(XK);
disp('Real part=');
disp(R);
I=imag(XK);
disp('Imaginary part=');
disp(I);
mag=abs(XK);
1
SRM
disp('Magnitude=');
disp(mag);
ang=angle(XK);
disp('Angle=');
disp(ang);
xn=ifft(XK,N);
disp('IDFT xn=');
disp(xn);
figure(1);
subplot(2,1,1);
stem(x);
xlabel('time -->');
ylabel('Amplitude -->');
title('Given sequence');
subplot(2,1,2);
stem(R,'r*');
hold on;
stem(I);
legend('Real Part','Imaginary Part');
xlabel('time -->');
ylabel('Amplitude -->');
title('Discrete Fourier Transform')
figure(3);
subplot(2,2,1);
stem(k,mag);
xlabel('time -->');
ylabel('x(k) --->');
title('Magnitude response');
subplot(2,2,2);
stem(k,ang);
xlabel('time -->');
ylabel('ang x(k) --->');
title('Phase response');
subplot(2,2,3);
stem(k,xn);
xlabel('time -->');
ylabel('x(n)');
title('Inverse Discrete Fourier transform');
%Spectrum analysis
Fs=[10];
xdft = XK(1:N/2+1);
psdx = (1/(Fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/N:Fs/2;
2
SRM
subplot(2,2,4);
plot(freq,psdx);
grid on;
xlabel('hz -->');
ylabel('db');
title('Spectrum analysis DFT');
disp('Spectrum analysis DFT=');
disp(psdx);
Output:
enter the input x = [1 2 3 4 5 6 7 8]
enter the order of dft N=[8]
Input Sequence x = 1 2 3 4 5 6 7 8
XK=
36.0000 + 0.0000i
-4.0000 - 9.6569i
-4.0000 - 4.0000i
-4.0000 - 1.6569i
-4.0000 + 0.0000i
-4.0000 + 1.6569i
-4.0000 + 4.0000i
-4.0000 + 9.6569i
Real part= 36 -4 -4 -4 -4 -4 -4 -4
IDFT xn = [1 2 3 4 5 6 7 8]
Spectrum analysis DFT= 16.2000 2.7314 0.8000 0.4686 0.2000
Model Graph
Given sequence
8
6
Amplitude
0
1 2 3 4 5 6 7 8
time -->
Discrete Fourier Transform
40
Real Part
Imaginary Part
20
Amplitude
-20
1 2 3 4 5 6 7 8
time -->
2
SRM
Magnitude response
Phase response
40
4
30 2
ang x(k)
20 0
x(k)
10
-2
0
0 2 4 6 -4
8 0 2 4 6 8
time --> time -->
Inverse Discrete Fourier
Spectrum analysis DFT
transform 8
20
6
15
4
x
10
d
2
5
0
0 2 4 6 8 0
0 2 4 6
time -->
hz -->
Postlab Questions :
Result:
Thus a MATLAB program for Spectrum analysis of the DFT and IDFT signal was written, executed and
the graphs were plotted.
2
SRM
Ex: No: Date:
Aim:
To write a program to find out the Fast Fourier transform and Inverse Fast Fourier transform of the
sequence using MATLAB and display the magnitude and phase response.
Description
FFT
X (k) N 1 kn
x(n)
n N
0
IFFT
1 N1
x(n) kn
X (k)
Nk0 N
j2kn
N
kn
Algorithm: N
e
1. Start the program.
2. Get the two input sequence x (n) and type of the FFT.
3. Compute the fast Fourier transform (FFT) of the given sequence.
4. Find out the magnitude and phase response of the given sequence.
5. Execute the program, display the result and verify it.
6. Plot the output graph for magnitude and phase.
7. Compute the inverse fast Fourier transform (FFT) of the given sequences.
8. Display the results verify it and plot the result.
2
SRM
9. Stop the process.
2
SRM
Program:
% Program for FFT & IFFT
clc;
clear all;
close all;
%x=[2 2 2 2 1 1 1 1];
%N=[8];
x=input('enter the input x=');
N=input('enter the order of fft
N='); k=0:1:N-1;
XK=fft(x,N);
disp('XK=');
disp(XK);
R=real(XK);
disp('Real part=');
disp(R);
I=imag(XK);
disp('Imaginary part=');
disp(I);
mag=abs(XK);
disp('Mag=');
disp(mag);
ang=angle(XK);
disp('angle=');
disp(ang);
xn=ifft(XK,N);
disp('IFFT xn=');
disp(xn);
figure(1);
stem(R,'r*');
hold on;
stem(I);
legend('Real Part','Imaginary Part');
xlabel('time -->');
ylabel('Amplitude -->');
title('Fast Fourier Transform')
2
SRM
figure(2);
subplot(2,2,1);
stem(x);
xlabel('time -->');
ylabel('Amplitude -->');
title('Given sequence');
subplot(2,2,2);
stem(k,mag);
xlabel('time -->');
ylabel('x(k) --->');
title('Magnitude response');
subplot(2,2,3);
stem(k,ang);
xlabel('time -->');
ylabel('ang x(k) --->');
title('Phase response');
subplot(2,2,4);
stem(k,xn);
xlabel('time -->');
ylabel('x(n)');
title('Inverse Fast Fourier transform');
Output:
enter the input x = [2 2 2 2 1 1 1 1]
enter the order of fft N = [8]
Input Sequence x = 2 2 2 2 1 1 1 1
XK=
12.0000 + 0.0000i
1.0000 + 2.4142i
0.0000 + 0.0000i
1.0000 + 0.4142i
0.0000 + 0.0000i
1.0000 - 0.4142i
0.0000 + 0.0000i
1.0000 - 2.4142i
Real part = 12 1 0 1 0 1 0 1
IFFT xn = 2 2 2 2 1 1 1 1
2
SRM
Model Graph:
Fast Fourier Transform
12
Real Part
Imaginary Part
10
6
Amplitude
-2
-4
1 2 3 4 5 6 7 8
time -->
Given sequence
Magnitude response
2
15
1.5
10
Amplitude
1
x(k)
0.5 5
0
0 2 0
4 6 8 0 2 4 6 8
time --> time -->
Phase response Inverse Fast Fourier transform
2 2
1 1.5
ang x(k)
0 1
x(
-1
0.5
-2
0 2 4 6 8 0
0 2 4 6 8
time --> time -->
2
SRM
2
SRM
Postlab Questions:
1. How many multiplications and additions are involved in radix-2 FFT for N=1024 when compared to
DFT?
2. Draw the 2-point DIF-FFT butterfly structure.
3. Compare DIF and DIT FFT algorithm.
4. Why FFT is needed?
5. Mention the applications of FFT algorithm?
Result:
Thus a program to find out the fast Fourier (FFT) and inverse fast Fourier transform (IFFT) of the
sequence using Matlab was written and executed.
2
SRM
Ex No: Date:
4. FIR FILTER DESIGN
Aim:
To write a program to design the FIR low pass, high pass, band pass and band stop filters and obtain the
frequency response of the filter using MATLAB.
Description:
Output: 1) Find the impulse response hd (n) for the given cut-off frequency and
Order of the filter.
2) Decide the window function w (n) and compute the window
Coefficients.
3) Find the filter coefficients h (n) =hd (n)*w (n).
4) Plot the frequency response for Low pass, High pass, Band pass and
Band stop filters
Algorithm:
3
SRM
Program:
% Function:
function [hd]=ideal_lp(wc,M)
alpha=(M-1)/2;
n=0:1:M-1;
N=n-alpha+eps; % add smallest number to avoid divide by zero
hd=sin(wc*N)./(pi*N);
Program:
%PROGRAM FOR LOW PASS FILTER
clc;
clear all;
close all;
M=7;
wc=1.2;
n=0:1:M-1;
hd=ideal_lp(wc,M);
w=hamming(M);
h=hd.*w';
disp('Filter coefficients for LPF=');
[M1,P]=freqz(h,1,2000);
mag=20*log10(abs(M1));
subplot(2,2,1);
stem(n,hd);
xlabel('n--->');
ylabel('hd(n)--->');
title('Ideal Impulse Response');
disp('hd=');
disp(hd);
subplot(2,2,2);
stem(n,w);
xlabel('n--->');
ylabel('w(n)--->');
title('Hamming Window');
disp('w=');
disp(w);
subplot(2,2,3);
stem(n,h);
xlabel('n--->');
3
SRM
ylabel('h(n)--->');
title('Actual Impulse Response');
disp('h=');
disp(h);
subplot(2,2,4);
plot(P/pi, mag);
grid on;
xlabel('Normalized frequency--->');
ylabel('Magnitude in db--->');
title('Frequency Response ');
Output:
Filter coefficients for LPF=
Model Graph:
0.4
hd(n)--
w(n)--
0.2
0.5
-0.2
0 2 4 6 0
0 2 4 6
n--->
n--->
Actual Impulse Response Frequency Response
0.6 0
0.4
-50
Magnitude in
0.2
h(n)--
0 -100
-0.2
-150
0 2 4 6
0 0.5 1
n--->
Normalized frequency--->
3
SRM
%PROGRAM FOR HIGH PASS FILTER
clc;
clear all;
close all;
M=11;
wc=1.2;
n=0:1:M-1;
hd=ideal_lp(pi,M)-ideal_lp(wc,M);
w=hann(M);
h=hd.*w';
disp('Filter coefficients for HPF=');
[M1,P]=freqz(h,1,2000);
mag=20*log10(abs(M1));
subplot(2,2,1);
stem(n,hd);
xlabel('n--->');
ylabel('hd(n)--->');
title('Ideal Impulse Response');
disp('hd=');
disp(hd);
subplot(2,2,2);
stem(n,w);
xlabel('n--->');
ylabel('w(n)--->');
title('Hanning Window');
disp('w=');
disp(w);
subplot(2,2,3);
stem(n,h);
xlabel('n--->');
ylabel('h(n)--->');
title('Actual Impulse Response');
disp('h=');
disp(h);
subplot(2,2,4);
plot(P/pi, mag);
grid on;
xlabel('Normalized frequency--->');
ylabel('Magnitude in db--->');
title('Frequency Response ');
3
SRM
Output:
hd = 0.0178 0.0793 0.0470 -0.1075 -0.2967 0.6180 -0.2967 -0.1075 0.0470 0.0793
0.0178
Model Graph:
0.5
hd(n)--
w(n)--
0.5
0
-0.5 0
0 5 10 0 5 10
n---> n--->
Actual Impulse Response Frequency Response
1 50
0.5 0
Magnitude in
h(n)--
0 -50
-0.5 -100
0 5 10 0 0.5 1
n---> Normalized frequency--->
3
SRM
%PROGRAM FOR BAND PASS FILTER
clc;
clear all;
close all;
M=11;
wc1=1.2;
wc2=2;
n=0:1:M-1;
hd=ideal_lp(wc2,M)-ideal_lp(wc1,M);
w=hann(M);
h=hd.*w';
disp('Filter coefficients for BPF=');
[M1,P]=freqz(h,1,2000);
mag=20*log10(abs(M1));
subplot(2,2,1);
stem(n,hd);
xlabel('n--->');
ylabel('hd(n)--->');
title('Ideal Impulse Response');
disp('hd=');
disp(hd);
subplot(2,2,2);
stem(n,w);
xlabel('n--->');
ylabel('w(n)--->');
title('Hanning Window');
disp('w=');
disp(w);
subplot(2,2,3);
stem(n,h);
xlabel('n--->');
ylabel('h(n)--->');
title('Actual Impulse Response');
disp('h=');
disp(h);
subplot(2,2,4);
plot(P/pi, mag);
grid on;
xlabel('Normalized frequency--->');
ylabel('Magnitude in db--->');
title('Frequency Response ');
3
SRM
Output:
Model Graph:
BANDPASS FILTER
0.2
hd(n)--
w(n)--
0 0.5
-0.2
-0.4 0
0 5 10 0 5 10
n---> n--->
Actual Impulse Response Frequency Response
0.6 0
0.4 -20
Magnitude in
h(n)--
0.2 -40
0 -60
-0.2 -80
0 5 10 0 0.5 1
n---> Normalized frequency--->
3
SRM
%PROGRAM FOR BAND STOP FILTER
clc;
clear all;
close all;
M=7;
wc1=1.2;
wc2=2;
n=0:1:M-1;
hd=ideal_lp(pi,M)-ideal_lp(wc2,M)+ideal_lp(wc1,M);
w=rectwin(M);
h=hd.*w';
disp('Filter coefficients for BSF=');
[M1,P]=freqz(h,1,2000);
mag=20*log10(abs(M1));
subplot(2,2,1);
stem(n,hd);
xlabel('n--->');
ylabel('hd(n)--->');
title('Ideal Impulse Response');
disp('hd=');
disp(hd);
subplot(2,2,2);
stem(n,w);
xlabel('n--->');
ylabel('w(n)--->');
title('Rectangular Window');
disp('w=');
disp(w);
subplot(2,2,3);
stem(n,h);
xlabel('n--->');
ylabel('h(n)--->');
title('Actual Impulse Response');
disp('h=');
disp(h);
subplot(2,2,4);
plot(P/pi, mag);
grid on;
xlabel('Normalized frequency--->');
ylabel('Magnitude in db--->');
title('Frequency Response ');
3
SRM
Output:
w= 1 1 1 1 1 1 1
Model Graph:
BANDSTOP FILTER
0.5
hd(n)--
w(n)--
0.5
0
-0.5 0
0 2 4 0 2 4 6
6
n--->
n--->
Frequency Response
Actual Impulse Response
5
1
Magnitude in db---
0
0.5
h(n)--
-5
0
-10
-0.5 -15
0 4 0 0.5 1
Normalized frequency--->
2 6
n--->
Windows:
Theoretical calculation:
3
SRM
Rectangular Window
1,
w(n) 0 n M 1
0,
otherwise
Hanning Window
2n
0.5* 1 cos 0 n M 1
, M
1
w(n)
0,
otherwise
Hamming Window
2n
0.54 0.46*
cos , 0 n M 1
M 1
1. w(n)
0, otherwise
Kaiser window
1
w(n)
I
1 (n ) /
2
2
/ I ( ) 0 n M 1
0 0
0 otherwise
M-1)/2 and I0 = the zeroth order Modified Bessel Function
If p , s , Rp , and As are given then the following equations are needed for design.
Transition width s p
f 2
0 As 21
Postlab questions:
1. What is meant by linear phase filters?
2. What is the condition for the impulse response of FIR filter to satisfy for constant and
Phase delay and for only constant group delay?
3. What are Gibbs oscillations?
4. Give the equation for rectangular, hamming and Kaiser Windows.
5. State the condition for linear phase characteristics in FIR.
4
SRM
Result:
Thus a program to design the FIR low pass, high pass, band pass and band stop filters was
Written and response of the filter using MATLAB was executed.
4
SRM
Ex No: Date:
5. IIR FILTER DESIGN
Aim:
To write a program to design the Butterworth low pass, high pass filters and find out the response of the
filter using MATLAB.
Description:
Output : (a) Find the order and cutoff frequency using bilinear and
impulse Invariant transformation
(b) Calculate the Analog filter coefficients H(s)
(c) Transform the Analog filter to digital filter and find H (z)
(d) Plot the responses for all the filters.
Algorithm:
Program:
% function to find order of butterworth filter using impulse invariant transformation
% Save as butt_impord
function [N,Wc]=
butt_impord(w1,w2,a1,a2) l=sqrt((1/a2^2)-1)
e=sqrt((1/a1^2)-1)
num=log10(l/e)
den=log10(w2/w1)
4
SRM
N
=
c
e
i
l
(
(
n
u
m
/
d
e
n
)
)
4
SRM
Wc=(w1)/((e)^(1/N))
%function to find order of butterworth filter using bilinear transformation Save is as butt_biord.
function [N1,Wc1]= butt_biord(w1,w2,a1,a2)
T=1;
wp1=(2/T)*tan(w1/2)
ws1=(2/T)*tan(w2/2)
lam=sqrt((1/a2^2)-1)
ep=sqrt((1/a1^2)-1)
num1=log10(lam/ep)
den1=log10(ws1/wp1)
N1=ceil((num1/den1))
Wc1=wp1/((ep)^(1/N1))
N = 2 , Wc = 0.7255
b= 0 0.3015 0
T = 1, wp1 = 0.6498
ep = 0.7500
N1 = 2
Wc1 = 0.7504
num1 = 1 0 0
4
SRM
Model graph
Low Pass Butterworth Filter
0
-5
-10
-15
-20
magnitude
-25
-30
-35
-40
-45
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency --->
-20
-40
-60
-80
magnitude
-100
-120
-140
-160
-180
-200
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency --->
4
SRM
Theoretical calculation
Bilinear Transformation
wp1=(2/T)*tan(w1/2)
ws1=(2/T)*tan(w2/2)
lam=sqrt((1/a2^2)-1)
ep=sqrt((1/a1^2)-1)
N=log10(lam/ep) / log10(ws1/wp1);
Wc1=wp1/((ep)^(1/N1));
S= 2 (Z-1)
T (Z+1)
l=sqrt((1/a2^2)-1)
e=sqrt((1/a1^2)-1)
N=log10(l/e) / log10(w2/w1); ;
Wc=(w1)/((e)^(1/N));
H(S) is same
4
SRM
Postlab questions:
1. What are the properties of Butterworth low pass filters?
2. Give the magnitude function of Butterworth filter.
3. What is meant by conformal mapping?
4. Define warping effect?
5. What are the advantages and disadvantages of bilinear transformations?
Result:
Thus a program to design the Butterworth low pass and high pass filter using Matlab was written and
response of the filter was executed.
4
SRM
Ex No: Date:
6. MULTIRATE FILTERS
Aim:
Write a program to perform the decimation and interpolation on the given input sequence operation using
Matlab.
Description:
Output: Find the decimated and interpolated output signal for the given number of samples.
Algorithm:
1. Start the program.
2. Get the amplitude of the input signal.
3. Get the decimation and interpolation factor.
4. Perform the decimation and interpolation operations using Matlab functions.
5. Plot the output signals.
6. Stop the process.
Program:
%Program for Decimate signal
clc;
clear all;
close all;
t=0:0.00025:1; % Time vector
x=sin(2*pi*30*t)+sin(2*pi*60*t);
r=4; % Factor of 4
y=decimate(x,r);
4
SRM
title('Original Signal');
5
SRM
Model graph:
Original Signal
2
1
Amplitude---
-1
-2
0 20 40 60 80 100 120
n--->
Decimated Signal
2
1
Amplitude---
-1
-2
0 5 10 15 20 25 30
n--->
5
SRM
Original Signal
2
Amplitude---
0
-1
-2
0 5 10 15 20 25 30
n--->
Interpolated Signal
2
1
Amplitude---
-1
-2
0 20 40 60 80 100 120
n--->
Postlab Questions:
Result:
Thus a program to perform decimation and interpolation the input signal was written using MATLAB
and plotted.
5
SRM
Ex No: Date:
7. EQUALIZATION
Aim:
ALGORITHM:
1. The Input values are all set
2. For input generate normally distributed random matrix.
3. For filter generate uniform distributed pseudo random matrix.
4. The filter coefficients are determined.
5. The input vector is filtered with the specified vector and stored in another vector.
6. Now all the outputs and vectors are initialized.
7. Now the LMS adaptation curve is determined using the equation
w=w+mu(Re(e(n)*conj(in))-iImg(e(n)*conj(in)))
8. Finally the generated output waveform is plotted in a semilog graph sheet
% ****************************************************
% LEAST MEAN SQUARE ALGORITHM
% ****************************************************
clear all;
close all;
randn('state',sum(100*clock)); % Returns a matrix with pseudorandom values in normal
distribution
rand('state',sum(100*clock)); % Returns a matrix with pseudorandom values in uniform
distribution
numpoints=5000; % Sampling points
numtaps = 10; % No of filter coefficients
Mu=0.01;
x=randn(numpoints,1)+i*randn(numpoints,1); % Complex Random Input Signal
5
SRM
h=rand(numtaps,1); % filter transfer function
h=h /max(h);
d = filter(h,1,x); % digital filter with num coeff h and den coeff 1 and vector x
w=[];
y=[];
in=[];
e=[];
w=zeros(numtaps+1,1)+i*zeros(numtaps+1,1); % initialize the w matrix
for n=numtaps+1:numpoints
in=x(n:-1:n-numtaps);
y(n)=w'*in;
e(n)=d(n)-y(n); % Calculates the error value
w=w+Mu*(real(e(n)*conj(in))-i*imag(real(e(n)*conj(in))));
end
figure(10);
semilogy(abs(e));grid on;
title(['LMS Adaptation Learning Curve using Mu=',num2str(Mu)]);
xlabel('Iteration Number');
ylabel('Output estimation error in db');
OUTPUT
RESULT:
Thus the Least Mean Square (LMS) channel equalizer was designed and the generated output sequence
was plotted using MATLAB software.
5
SRM
Ex No: Date:
Description:
The TMS320VC5416 fixed-point, digital signal processor (DSP) (hereafter referred to as the device
unless otherwise specified) is based on an advanced modified Harvard architecture that has one program
Memory bus and three data memory buses. This processor provides an arithmetic logic unit (ALU) with a High
degree of parallelism, application-specific hardware logic, on-chip memory, and additional on-chip Peripherals.
The basis of the operational flexibility and speed of this DSP is a highly specialized instruction Set. Separate
program and data spaces allow simultaneous access to program instructions and data, providing, a high degree
of parallelism. Two read operations and one write operation can be performed in a single cycle. Instructions
with parallel store and application-specific instructions can 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. The device also includes
the control mechanisms to manage interrupts, repeated
Operations, and function calls.
Architecture:
The ‟54x DSPs use an advanced, modified Harvard architecture that maximizes processing power by
maintaining one program memory bus and three data memory buses. These processors also provide an
arithmetic logic unit (ALU) that has a high degree of parallelism, application-specific hardware logic, on-chip
memory, and additional on-chip peripherals. These DSP families also provide a highly specialized instruction
set, which is the basis of the operational flexibility and speed of these DSPs. Separate program and data spaces
allow simultaneous access to program instructions and data, providing the high degree of parallelism. Two
reads and one write operation can be performed in a single cycle. Instructions with parallel store and
application-specific instructions can 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 included are the control mechanisms to
manage interrupts, repeated operations, and function calls.
5
SRM
Architecture of TMS320VC5416 Fixed-Point Digital Signal Processor:
5
SRM
Circular-Buffer Size Register (BK)
The ARAUs use16-bit circular-buffer size register (BK) in circular addressing to specify the data
block size. For information on BK and circular addressing.
Block-Repeat Registers (BRC, RSA, REA)
The 16-bit block-repeat counter (BRC) register specifies the number of times a block of code is
to repeat when a block repeat is performed. The 16-bit blockrepeat start address (RSA) register contains
the starting address of the block of program memory to be repeated. The 16-bit block-repeat end address
(REA) register contains the ending address of the block of program memory to be repeated.
Memory-Mapped Registers
The 64K words of data memory space include the device‟s memory-mapped registers, which
reside in data page 0 (data addresses 0000h–007Fh).
The peripheral registers are used as control and data registers in peripheral circuits. These
registers reside within addresses 0020h–005F and reside on a dedicated peripheral bus structure. For a
list of peripherals on a particular C54x device.
The scratch-pad RAM block (60h–7Fh in data memory) includes 32 words of DARAM for
variable storage that helps avoid fragmenting the large RAM block.The data memory space contains
memory-mapped registers for the CPU and the on-chip peripherals. Simplifying access to them. The
memory-mapped access provides a convenient way to save and restore the registers for context switches
and to transfer information between the accumulators and the other registers.
Data Memory
The data memory space addresses up to 64K of 16-bit words. The device automatically accesses
the On-chip RAM when addressing within its bounds. When an address is generated outside the RAM
bounds, the device automatically generates an external access.
The advantages of operating from on-chip memory are as follows:
· Higher performance because no wait states are required
· Higher performance because of better flow within the pipeline of the central arithmetic logic
unit (CALU)
· Lower cost than external memory
· Lower power than external memory
The advantage of operating from off-chip memory is the ability to access a larger address space.
Program Memory
Software can configure their memory cells to reside inside or outside of the program address
map. When the cells are mapped into program space, the device automatically accesses them when their
addresses are within bounds. When the program-address generation (PAGEN) logic generates an
address outside its Bounds, the device automatically generates an external access.
The advantages of operating from on-chip memory are as follows:
· Higher performance because no wait states are required
· Lower cost than external memory
· Lower power than external memory
The advantage of operating from off-chip memory is the ability to access a larger address space.
5
SRM
Overview of the TMS320VC5416 DSK
The TMS320VC5416 DSK is a stand-alone development and evaluation module. It allows
evaluators to examine certain characteristics of the C5416 digital signal processor (DSP) to determine if
it meets their application requirements. Furthermore, the module is an excellent platform to develop and
run software for the TMS320VC5416 family of processors.
The DSK allows full speed verification of VC5416 code. With 64K words of on board RAM
memory, 256K words of on board Flash ROM, and a Burr Brown PCM 3002 stereo codec, the board can
solve a variety of problems as shipped. Three expansion connectors are provided for interfacing to
evaluation circuitry not provided on the as shipped configuration.
To simplify code development and shorten debugging time, a special version of Code Composer
Studio is shipped with the board.
Key Features of the TMS320VC5416 DSK
The VC5416 DSK has the following features:
• VC5416 operating at 16-160 MHz
• On board USB JTAG controller with plug and play drivers
• 64K words of on board RAM
• 256K words of on board Flash ROM
• 3 Expansion Connectors (Memory Interface, Peripheral Interface, and Host Port Interface)
• On board IEEE 1149.1 JTAG Connection for Optional Emulation Debug
• Burr Brown PCM 3002 Stereo Codec
• +5 volt operation
Code Composer Studio - 3.1v
INTRODUCTION TO CODE COMPOSER STUDIO
Code Composer is the DSP industry's first fully integrated development environment (IDE) with
DSP-specific functionality. With a familiar environment liked MS-based C++TM, Code Composer lets
you edit, build, debug, profile and manage projects from a single unified environment. Other unique
features include graphical signal analysis, injection/extraction of data signals via file I/O, multi-
processor debugging, automated testing and customization via a C-interpretive scripting language and
much more.
Initial setup to work on Code Composer Studio:
To execute using Simulator Open Setup CCStudio_v3.1 add C5416 Device Simulator Save and
Quit.
(OR)
To Execute using DSP Processor Kit -DSK Diagnostic
UtilityStart Check for PASS in the display and continue the
Procedure
Select 5416 dskCCStudio_v3.1DebugConnect
To Compile:
Project Compile
To Build:
Project Build
If there is more number of warnings after build, then
Project Build Options Advanced (in Category) Use Far Calls (- mf)
To execute project:
Debug Run.
To Plot Graph:
View Graph (OR Right click in the program Insert Graph)
Select proper Properties and specify the address.
Result:
Thus the architecture of TMS320C5416 Digital Signal Processor Starter Kit (DSK) and programming
steps for Code Composer Studio was studied.
6
SRM
Ex No: Date:
9. MAC OPERATION USING VARIOUS ADRESSING MODES
Aim:
To perform MAC operation using various addressing modes of TMS320C5416 DSP processor.
Algorithm:
Program:
.global _main
.mmregs
.data
X: .word 50h
Y: .word 20h
.text
_main
STM X,AR2
STM Y,AR3
STM #1500h,AR4
ADD *AR2,*AR3,A
STL A,*AR4+
STH A,*AR4
.end
6
SRM
Output:
0x1500: 0x0000
0x1501: 0x0070
.global _main
.mmregs
.data
X: .word 60h
Y: .word 20h
.text
_main
STM X,AR2
STM Y,AR3
STM #1500h,AR4
SUB *AR2,*AR3,A
STL A,*AR4+
STH A,*AR4
.end
Output:
0x1500: 0x0000
0x1501: 0x0040
.global _main
.mmregs
.data
X: .word 30h
Y: .word 20h
.text
_main
STM X,AR2
STM Y,AR3
STM #1500h,AR4
MPY *AR2,*AR3,A
STL A,*AR4+
STH A,*AR4
.end
Output:
0x1500: 0x0600
6
SRM
; Program for Division
.global _main
.mmregs
.data
X: .word 90h
Y: .word 30h
.text
_main
STM X,AR2
STM Y,AR3
STM #1500h,AR4
LD *AR2+,A
RPT #15
SUBC *AR2,A
STL A,*AR4+
STH A,*AR4
.end
Output:
0x1500: 0x0003
Postlab Questions:
1. Give an example for immediate and indirect addressing modes?
2. What do you mean by bit reversal addressing mode?
3. What are the registers available for indirect addressing mode?
4. What are barrel shifters?
5. What is arithmetic and logical shift in DSP Processors?
Result:
Thus the assembly coding for MAC operation using various addressing modes of DSP processor
TMS320C5416 was written and executed.
6
SRM
Ex No: Date:
10. LINEAR CONVOLUTION
Aim:
Write a program to find out the linear convolution of two sequence using TMS320C5416 processor.
Description:
#include<stdio.h>
int x[10]; /*={1 2 3 4 0 0 0} Input Signal Samples*/
int h[10]; /*={1 2 3 4 0 0 0} Impulse Response */
/*At the end of input sequences pad 'M' and 'N' no. of zero's*/
int y[10];
int m=4; /*Lenght of input samples sequence x(n)*/
int n=4; /*Lenght of impulse response h(n) */
int i,j;
main()
{
printf(" enter the first sequence\n");
for(i=0;i<m+n-1;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
for(j=0;j<m+n-1;j++)
scanf("%d",&h[j]);
for(i=0;i<m+n-1;i++)
6
SRM
{ y[i]=
0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
printf("output\n");
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Result:
6
SRM
MODEL GRAPH
Postlab Questions :
Result:
Thus a program to find out the linear convolution of two sequences using TMS320C5416 processor was
written and executed.
6
SRM
Ex No: Date:
11. CIRCULAR CONVOLUTION
Aim:
Write a program to find out the circular convolution of two sequences using TMS320C5416 processor.
1. What is the MATLAB function used to perform linear & circular convolution?
2. How will you determine the maximum length of the convolution of the sequences?
3. List the methods used to find the circular convolution.
Description:
Input: Give the input x (n) and h (n) in matrix form.
N 1
y(n)
x(k)h(n k)
k 0
Algorithm:
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf(" enter the length of the first sequence\n");
6
SRM
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\
n"); for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0) /*If length of both sequences are not equal*/
{
if(m>n) /* Pad the smaller sequence with zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{ y[k]=
0;
/*circular
shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
6
SRM
Model Graph:
Output:
7
SRM
Properties to Plot Graph:
Postlab Questions:
Result:
Thus a program to find out the circular convolution of two sequences using TMS320C5416 processor
was written and executed.
7
SRM
Ex No: Date:
12. FFT IMPLEMENTATION
Aim:
To write a program to perform Discrete Fourier transform using TMS320C5416 DSP Processor.
Program:
for (i=0;i<=N-1;i++)
{
xr[i]=sin(2*pi*10*i/8.0);
xi[i]=0;
}
for (k=0;k<N;k++)
{
XR[k]=0;
XI[k]=0;
7
SRM
for (n=0;n<N; n++)
{
XR[k]+=(xr[n]*cos(2*pi*k*n/N))+(xi[n]*sin(2*pi*k*n/N));
XI[k]+=(xr[n]*sin(2*pi*k*n/N))-(xi[n]*cos(2*pi*k*n/N));
}
X[k]=sqrt((XR[k]*XR[k])+(XI[k]*XI[k]));
}
printf("X(k) and magnitude of X(k)\n");
for (k=0;k<N;k++)
{
printf("\n X[%d] = %f + j %f \n",k,XR[k],XI[k]);
printf(" magnitude of X(%d) = %f\n",k,X[k]);
}
}
Model Graph:
Graph Properties:
7
SRM
Sample Values:
X(k) and magnitude of X(k)
Calculation:
Formula:
nk
X (k) M j 2
e n
;0 N 1
x(n) k
k 0
Postlab Questions :
Result:
Thus a program was written to perform Discrete Fourier Transform and executed using DSP processor.
7
SRM
Ex No: Date:
13. WAVEFORM GENERATION
Aim:
To write a program to generate Sine wave and Ramp wave form using TMS320C5416 DSP Processor.
Algorithm:
.global _main
.mmregs
.def start
.data
.text
_main
7
SRM
RPTB RAMP2
STL A,*AR4+
LD #1h,0,B
Model Graph:
Graph Property:
7
SRM
Program:
#include <stdio.h>
#include<math.h>
#define FREQ 1000
float a[128];
main()
{
int i=0;
for(i=0;i<128;i++)
{
a[i]=sin(2*3.14*FREQ*i/24000);
printf("%f",a[i]);
}
}
7
SRM
Model Graph:
Graph Property:
Result:
Thus the program was written to generate a Ramp signal, Sine signal and executed using DSP processor.
7
SRM
Ex No: Date:
14. IIR AND FIR IMPLEMENTATION
Aim:
To write a program to implement Low pass filter using Finite Impulse Response in TMS320C5416 DSP
Processor.
Description:
Input: Give the cutoff frequency and order of the filter
Output: 1. Find the ideal impulse response hd (n) of the filter order.
2. Find the window coefficients w (n) using the appropriate window
Function.
3. Find the filter coefficients h (n) =hd (n)*w (n).
4. Plot hd (n), w (n) and h (n).
Algorithm:
Program:
#include<stdio.h>
#include<math.h>
#define pi 3.14
int n,N;
float hd[10],alpha,w[10],h[10],wc;
main()
{
printf("enter N value");
scanf("%d",&N);
printf("enter wc value");
7
SRM
scanf("%f",&wc);
for(n=0;n<N;n++)
{
/*Hamming window function*/
w[n]=0.54-0.46*(cos((2*pi*n)/(N-1)));
printf("w[%d]= %f \n",n,w[n]);
}
alpha=(N-1)/2;
/* Impulse function */
for(n=0;n<N;n++)
{
if(n!=alpha)
hd[n]=sin(wc*(n-alpha))/(pi*(n-alpha));
else
hd[n]=wc/3.14;
printf("hd[%d]= %f\n",n,hd[n]);
}
/*Filter coefficients*/
for(n=0;n<N;n++)
{
h[n]=hd[n]*w[n];
printf("h[%d]= %f\n",n,h[n]);
}
Output:
enter N value11
enter wc value1.2
window coefficients:
w[0]= 0.080000 w[1]= 0.167766 w[2]= 0.397574 w[3]= 0.681730
w[4]= 0.911803 w[5]= 0.999999 w[6]= 0.912664 w[7]= 0.683123
w[8]= 0.398967 w[9]= 0.168629 w[10]= 0.080002
8
SRM
Model Graph:
Graph Property:
8
SRM
Theoretical calculation:
1. hd (n)=1/2π ∫ Hd(w)ejwn dw
2. Select w (n)
3. Find h (n) = hd (n) w (n)
Rectangular Window
1,
w(n) 0 n M 1
0, otherwise
Hanning Window
2n
0.5* 1 cos , 0 n M 1
M 1
w(n)
0,
otherwise
Hamming Window
2n
0.54 0.46*
cos , 0 n M 1
M 1
2. w(n)
0, otherwise
Postlab Questions:
1. What is the necessary and sufficient condition for linear phase characteristics in
FIR filter?
2. What is the principle of designing FIR filter using frequency sampling method?
3. What is the principle of designing FIR filter using frequency sampling method?
4. What are the disadvantages of' Fourier series method?
Result:
Thus a program was written to implement Low pass filter using Finite Impulse Response and executed
using DSP processor.
8
SRM
Ex No: Date:
Aim:
To study the functions of finite word length effect in fixed point DSP systems..
Apparatus Required:
Hardware : Personal Computer & TMS320C67XX kit
Software : Code Composer Studio version4
Program:
function ADCNoiseGain=ADCNoise(b,a,n,FM) [B,A] = sos2tf([b a]);
%form A(z) and B(z) [h,t] = impz(B,A,n);
ADCNoiseGain = sum(h.^2)/12.0;
fprintf('ADC noise gain is %f\n\n',ADCNoiseGain);
if FM~=1
fprintf('ADC noise is %g^2*%g*q^2\n',[FM ADCNoiseGain]);
else
fprintf('ADC noise is %g*q^2\n',ADCNoiseGain);
end function
CoeffQuantizeErr(b,a,maxbits,ftype,f,Fs)
%COEFFICIENT QUANTIZATION ERROR ANALYSIS
n=256;
for nbits=2:maxbits [B,A]=QuantizeCoeff(b,a,nbits);
[B,A] = sos2tf([B A]);
[h,w] = freqz(B,A,n);
amag = abs(h);
amag = amag/max(amag); fprintf('\n\nnbits\tstage\tA1\tA2\tradius1\
tangle1\tradiu s2\tangle2\n'); for nbits=2:maxbits
[B,A]=QuantizeCoeff(b,a,nbits);
for i=1:size(b,1) r1 = sqrt(abs(A(i,3)));
angle1 = 180/pi*acos(A(i,2)/(-2.0*r1));
r2 = sqrt(abs(a(i,3)));
angle2 = 180/pi*acos(a(i,2)/(-2.0*r2));
fprintf('%d\t%d\t%-7.4f\t%-7.4f\t%-7.4f\t%-7.2f\t%- 7.4f\t%-7.2f\n', nbits, i,A(i,2) , A(i,3),
r1,angle1,r2,angle2);
end
end format;
8
SRM
function ScaleFactor(b,a,nstep,size,structure) norm0 = DirectScale(b,a,0,nstep);
norm1 = DirectScale(b,a,1,nstep);
norm2 = DirectScale(b,a,2,size);
else norm0 = CanonicScale(b,a,0,nstep);
norm1 = CanonicScale(b,a,1,nstep);
norm2 = CanonicScale(b,a,2,size);
end disp('L1-norms of the second order sections:');
disp(norm0); disp('L2-norms of the second order sections:');
disp(norm1); disp('Loo-norms of the second order sections:');
disp(norm2);
function s = DirectScale(b,a,iopt,n)
if(iopt>=3) s = ones(1,size(b,1));
return;
else
A = 1; B = 1;
for i=1:size(b,1)
%loop for each
stage A =
conv(A,a(i,:));
B = conv(B,b(i,:));
s(i) = GetScaleFactor(B,A,iopt,n);
end
end function
s = CanonicScale(b,a,iopt,n)
if(iopt>=3)
s = ones(1,size(b,1));
return;
else
A = 1;
B = 1;
for i=1:size(b,1)
A = conv(A,a(i,:));
if i>1 B = conv(B,b(i-1,:));
end
s(i) = GetScaleFactor(B,A,iopt,n);
end
end
Postlab Questions:
1. What are the advantages of floating point arithmetic?
2. What are the methods to prevent overflow?
3. What are the two kinds of limit cycles?
4. What is the relationship between truncation error e and the bits b for representing a decimal
into binary?
5. What are the three quantization errors to finite word length registers in digital filters?
Result:
Thus the function of finite word length effect in fixed point DSP processor is studied.
8
SRM
Ex No: Date:
Description:
Input: Give input images from MATLAB edit window.
Output: Perform various image processing techniques given and display it in different Figure
window.
Algorithm:
Program:
8
SRM
K = imadd(I,J);
figure, imshow(K)
% PROGRAM FOR CONVERTING COLOR IMAGE TO GRAY SCALE
I = imread('board.tif');
J = rgb2gray(I);
figure, imshow(I), figure, imshow(J);
Sample Output
ORIGINAL IMAGE
IMAGE HISTOGRAM
1600
1400
1200
1000
800
600
400
200
8
SRM
COLOR IMAGE GRAY SCALE IMAGE
Postlab Questions:
Result:
Thus a MATLAB program for studying the image processing tool box was written, executed and the
graphs were plotted.
8
SRM
Ex No: Date:
Description:
Input: Generate sine input signal for low and high frequencies.
Output:
i. Represent the generated low and high frequency signals using DFT.
ii. Generate the Matlab code for the generation and visualization of the DTMF tones
Algorithm:
1. Start the program.
2. Generate the sinusoidal signal with low frequency group f = 697 Hz, 770 Hz, 852 Hz, 941 Hz
and high frequencies h= 1209 Hz, 1336 Hz, 1477Hz.
3. Set the sampling frequency 8 KHz, N = 800, No of samples at a spacing of 100ms.
4. Generate and visualize the DFT of the corresponding low and high frequency signal.
5. Stop the program.
Theory:
Dual-tone Multi-Frequency (DTMF) signaling 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.
Generating DTMF Tones. A DTMF signal consists of the sum of two sinusoids - or tones - with frequencies
taken from two mutually exclusive groups. These frequencies were chosen to prevent any harmonics from being
incorrectly detected by the receiver as some other DTMF frequency. Each pair of tones contains one frequency
of the low group (697 Hz, 770 Hz, 852 Hz, 941 Hz) and one frequency of the high group (1209 Hz, 1336 Hz,
1477Hz) and represents a unique symbol. The frequencies allocated to the push-buttons of the telephone pad are
shown below:
Matlab Program
i. Generation of the twelve frequency pairs
Clear all;
Close all;
symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};
8
SRM
lfg = [697 770 852 941]; % Low frequency group
hfg = [1209 1336 1477]; % High frequency group
f = [];
for c=1:4,
for r=1:3,
f = [ f [lfg(c);hfg(r)] ];
end
end
ans =
697 1209
697 1336
697 1477
770 1209
770 1336
770 1477
852 1209
852 1336
852 1477
941 1209
941 1336
941 1477
Matlab code for the generation and visualization of the DTMF tones
tones = zeros(N,size(f,2));
for toneChoice=1:12,
% Generate tone
tones(:,toneChoice) = sum(sin(f(:,toneChoice)*pit))';
% Plot tone
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', ...
'FitBoxToText','on');
8
SRM
MODEL GRAPH
Time response of each tone of the telephone pad
Amplitu
Amplitu
0 0 0
-2
0 5 10 15 20 -2 -2
25 0 5 10 15 20 0 5 10 15 20 25
25
Amplitu
Amplitu
0 0 0
-2
0 5 10 15 20 -2 -2
25 0 5 10 15 20 0 5 10 15 20 25
25
Amplitu
Amplitu
0 0 0
-2
0 5 10 15 20 -2 -2
25 0 5 10 15 20 0 5 10 15 20 25
25
Amplitu
Amplitu
0 0 0
-2 -2
0 5 10 15 20 25 0 5 -2
10 15 20 25 0 5 10 15 20 25
Time (ms) Time (ms) Time (ms)
Postlab Questions:
1. What are the applications of DSP systems?
2. List the procedure for generation of DTMF signals.
3. Define Goertzel algorithm for DFT estimation.
4. What are the types of multiple access in communication systems?
5. Define OFDM.
Result:
Thus a program to generate and visualize DTMF tones for telephone communication using Matlab was
written and executed.
9
SRM