DSP Lab Manual
DSP Lab Manual
STUDENT NAME
ROLL NUMBER
SECTION
DEPARTMENT OF
CERTIFICATE
Mr./Ms.______________________________________ bearing
processing Laboratory
3 Convolution and Correlation (auto and cross correlation) of discrete sequences 21-29
without using built in functions for convolution and correlation operations.
4 DTFT of a given signal 30-45
6 Design of FIR filter using windowing technique and verify the frequency 48-54
response of the filter
7 Design of IIR filter using any of the available methods and verify the frequency 55-57
response of the filter.
8 Design of analog filters. 58-59
Using DSP Processor kits (Floating point) and Code Composure Studio
(CCS) (PART – B)
1 Generation of random signal and plot the same as a waveform showing all the 72-73
specifications.
2 Finding Power and (or) Energy of a given signal. 74-75
Design of FIR filter using windowing technique and verify the frequency
response of the filter.
3 Convolution and Correlation (auto and cross correlation) of discrete sequences 76-80
without using built in functions for convolution and correlation operations.
4 DTFT of a given signal 81
6 Design of FIR filter using windowing technique and verify the frequency 85
response of the filter
7 Design of IIR filter using any of the available methods and verify the frequency 86-87
response of the filter.
8 Design of analog filters. 88-89
Using DSP Processor kits (Floating point) and Code Composure Studio (CCS) (PART – B)
1. Generation of random signal and plot the same as a waveform showing all the specifications.
2. Finding Power and (or) Energy of a given signal.
3. Convolution and Correlation (auto and cross correlation) of discrete sequences without using built in
functions for convolution and correlation operations.
4. DTFT of a given signal
5. N – point FFT algorithm
6. Design of FIR filter using windowing technique and verify the frequency response of the filter.
7. Design of IIR filter using any of the available methods and verify the frequency response of the filter.
8. Design of analog filters
Equipment/Software Required:
1. Licensed MATLAB software with required tool boxes for 30 users.
2. DSP floating Processor Kits with Code Composure Studio (8 nos.),Function generators,CROs,Regulated
Power Supplies
Mission
Impart core knowledge and necessary skills in Electronics and Communication Engineering through
innovative teaching and learning.
Inculcate critical thinking, ethics, lifelong learning and creativity needed for industry and society
Cultivate the students with all-round competencies, for career, higher education and self-
employability
PEO1: Graduates apply their knowledge of mathematics and science to identify, analyze and solve
problems in the field of Electronics and develop sophisticated communication systems.
PEO2: Graduates embody a commitment to professional ethics, diversity and social awareness in
their professional career.
PEO3: Graduates exhibit a desire for life-long learning through technical training and professional
activities.
PSO1: Apply the fundamental concepts of electronics and communication engineering to design a
variety of components and systems for applications including signal processing, image
processing, communication, networking, embedded systems, VLSI and control system
PSO2: Select and apply cutting-edge engineering hardware and software tools to solve complex
Electronics and Communication Engineering problems.
To provide background and fundamental material for the analysis and processing of
digital signals.
and systems.
To study fundamentals of time, frequency and Z-plane analysis and to discuss the
To study the designs and structures of digital (IIR and FIR) filters from analysis to
Course P P
Title P P P P P P P P P P P
P0 E E
0 0 0 0 0 0 0 0 0 0 0
10 0 0
1 2 3 4 5 6 7 8 9 11 12 1 2
CO1 3 3 2 1 3 3 3 3 1 3 2
CO2 3 3 3 3 2 3 1 2 1 1 3 2
CO3 3 3 2 3 3 2 2 1 2 2 2 3 2
CO4 3 1 2 3 3 2 3 1 2 2 1 2 3 2
CO5 3 3 2 2 3 3 3 1 3 2
1. While entering the Laboratory, the students should follow the dress code. (Wear shoes and White
apron, Female Students should tie their hair back).
2. The students should bring their observation book, record, calculator, necessary stationery items and
graph sheets if any for the lab classes without which the students will not be allowed for doing the
experiment.
3. All the Equipment and components should be handled with utmost care. Any breakage or damage
will be charged.
4. If any damage or breakage is noticed, it should be reported to the concerned in charge immediately.
5. The theoretical calculations and the updated register values should be noted down in the
observation book and should be corrected by the lab in-charge on the same day of the laboratory
session.
6. Each experiment should be written in the record note book only after getting signature from the lab
in-charge in the observation notebook.
7. Record book must be submitted in the successive lab session after completion of experiment.
Precautions.
1. Check the connections before giving the supply
Goto file menu-> New -> Script(Mfile) -> In the opened Script file write the Matlab code and save the file
with an extension of .m
Ex: “linear.m”
3)To execute Matlab Program Select the all lines in matlab program(ctrl+A) of mfile and press “F9”
If the command window is displaying the message like “enter the input sequence” then
enter the sequence with square brackets and each sample values is spaced with single space
Ex: Enter input sequence [1 2 3 4] If it is asking a value input write the value without brackets
Ex: “enter length of sequence 4” After entering inputs It displays the Output Graphs.
Test the USB port by running DSK Port test from the start menu
Use Start Programs Texas Instruments Code Composer Studio Code Composer Studio
CMD file – Which is common for all non real time programs.
Compile:
2. Now press F10. See the changes happening in the watch window.
3. Similarly go to view & select CPU registers to view the changes happening in CPU registers.
Check the DSK6713 diagnostics (IF you get the “pass”then click on ok).
Click on ccs studio3.1 desk top icon. Then the window will be opened.
TO CREATE PROJECT
Project new given project name and select the family’TMS320C67XX’Then click ok
File new source file write down the ‘c’program and save it with.’c’ extension in current project file
File new dsp/bios.config file select dsk67xx click on dsk6713 and save it in current project.
Project add files to project add library file by following the given path
Now files are generated and included in generated files . in that open the 3rd file, and copy the
header file and paste it in source file. Copy the include files named as ”dsk6713.h” and
Project build.
File load program project name.pjt debug “project name .out” file click on open debug click on run
INTRODUCTIONTO MATLAB
MATLAB: MATLAB is a software package for high performance numerical computation and visualization
provides an interactive environment with hundreds of built in functions for technical computation, graphics
and animation .
1. Generation of random signal and plot the same as a waveform showing all the specifications.
Aim: To generate random signal and plot the same as a waveform showing all the specifications.
PROCEDURE:
1. OPEN MATLAB
Program:
n=0:N-1;
x=randn(1,N);
figure;
subplot(2,1,1);
plot(n,x);
xlabel('n');
ylabel('x');
subplot(2,1,2);
stem(n,x);
xlabel('n');
ylabel('x');
Output :--
Result : Random signal and plot the same as a waveform showing all the specifications.
VIVA VOCE
1. Random variables give relationship between _____Random event and a real number
2. Which gives the measure of randomness of the random variable?--Variance gives the randomness of the
random variable. It is the difference between the mean square value and square of the mean.
4. A random process is called as stationary in strict sense if-- Its statistics vary with shift in time origin
PROCEDURE:
1. OPEN MATLAB
Program:
n=0:1:50;
x=(1/2).^n;
figure;
subplot(2,1,1);
stem(n,x);
axis([0 25 0 1]);
E=sum(abs(x).^2);
disp(E);
fs=10*f;
n1=0:1/fs:1;
ss=sin(2*pi*f*n1);
p=sum(abs(ss).^2)/length(ss);
subplot(2,1,2);
disp(p);
VIVA VOCE
1) The signal power of the periodic rectangular pulses of height 1 and width 1, is _
2) The signal power of the signal x (t) = 2sin 2t + 4sin 4t + 6cos 4t + 2cos 2t with period 0.5 is __Signal
power = 0.5(22 + 42 + 62 + 22)
= 0.5(4 + 16 + 36 + 4) = 0.5(20 + 40) = 30 W.
3) A signal is a power signal if the signal has average power equal to _Finite
A signal is said to be a power signal if and only if the average power of the signal is finite. In other words, we can say
that a signal is a power signal if the energy of the signal is infinite, i.e., E = ∞.
4) The energy in the time-domain representation of a signal is the same as in the frequency domain
representation normalized by _2π
5) A periodic signal has power P/4 equal to average energy per period then rms value of signal is √P/2
Aim : To write a matlab program for Convolution and correlation(auto and cross correlation)of discrete
sequence without using built in functions for convolutions and correlation operations.
PROCEDURE:
1. OPEN MATLAB
Program:
%Linear Convolution
clc;
clear all;
close all;
m=length(x);
n=length(h);
x=[x,zeros(1,n)];
l1=0:length(x)-1;
subplot(2,2,1);
stem(l1,x);
xlabel('---->n');
ylabel('---->x(n)');grid;
h=[h,zeros(1,m)];
subplot(2,2,2);
stem(l2,h);
xlabel('---->n');
ylabel('---->h(n)');grid;
y=zeros(1,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
end
end
disp(y);
l3=m+n-1;
n1=0:l3-1;
subplot(2,2,[3,4]);
stem(n1,y);
xlabel('---->n');
ylabel('---->y(n)');
grid;
%Circular Convolution
clc;
clear all;
close all;
ECE DEPT. SVR ENGINEERING COLLEGE 21
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
disp('circular convolution program');
m=length(x);
n=length(h);
subplot(2,2,1), stem(x);
xlabel('---->n');
ylabel('---->x(n)');grid;
subplot(2,2,2), stem(h);
xlabel('---->n');
ylabel('---->h(n)');grid;
if(m-n~=0)
if(m>n)
h=[h,zeros(1,m-n)];
n=m;
end
x=[x,zeros(1,n-m)];
m=n;
end
y=zeros(1,n);
y(1)=0;
a(1)=h(1);
for j=2:n
a(j)=h(n-j+2);
end
%ciruclar conv
ECE DEPT. SVR ENGINEERING COLLEGE 22
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
for i=1:n
y(1)=y(1)+x(i)*a(i);
end
for k=2:n
y(k)=0;
% circular shift
for j=2:n
x2(j)=a(j-1);
end
x2(1)=a(n);
for i=1:n
if(i<n+1)
a(i)=x2(i);
y(k)=y(k)+x(i)*a(i);
end
end
end
disp(y);
subplot(2,2,[3,4]),stem(y);
xlabel('---->n');
ylabel('---->y(n)');
grid;
%Cross Correlation
clc;
clear all;
close all;
n1=length(z);
ECE DEPT. SVR ENGINEERING COLLEGE 23
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
x=fliplr(z);
m=length(x);
n=length(h);
l1=0:n1-1;
figure;
subplot(2,2,1);
stem(l1,z);
xlabel('---->n');
ylabel('---->x(n)');
grid;
l2=0:n-1;
subplot(2,2,2);
stem(l2,h);
xlabel('---->n');
ylabel('---->h(n)');
grid;
x=[x,zeros(1,m)];
h=[h,zeros(1,m)];
y=zeros(1,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+x(j)*h(i-j+1);
end
ECE DEPT. SVR ENGINEERING COLLEGE 24
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
end
end
disp(y);
l3=-(m-1):(n-1);
subplot(2,2,[3,4]);
stem(l3,y);
xlabel('---->n');
ylabel('---->y(n)');
grid;
%Auto Correlation
clc;
clear all;
close all;
n=length(x);
z=fliplr(x);
m=length(z);
l1=0:n-1;
figure;
subplot(2,1,1);
stem(l1,x);
xlabel('---->n');
ylabel('---->x(n)');
grid;
x=[x,zeros(1,m)];
z=[z,zeros(1,n)];
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+z(j)*x(i-j+1);
end
end
end
disp(y);
l2=-(n-1):(n-1);
subplot(2,1,2);
stem(l2,y);
xlabel('---->n'); ylabel('---->y(n)');
grid;
Output :
Linear convolution program
enter i/p x(n):[4 5 6 7]
enter i/p h(n):[4 7 8 9]
convolution of x(n) & h(n) is y(n):
16 48 91 146 142 110 63
PROCEDURE:
1. OPEN MATLAB
PROGRAM CODE:
A) TIME SHIFTING PROPERTIES OF DTFT
clf;
w=-pi:2*pi/255:pi;
D=10;
num=[1 2 3 4 5 6 7 8 9];
h1=freqz(num,1,w);
h2=freqz([zeros(1,D) num],1,w);
subplot(2,2,1);
plot(w/pi,abs(h1));
grid;
title('Magnitude Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,abs(h2));
grid;
title('Magnitude Spectrum of Time Shifted Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(h1));
grid;
title('Phase Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
subplot(2,2,4);
plot(w/pi,angle(h2));
grid;
title('Phase Spectrum of Time Shifted Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
clf;
w=-pi:2*pi/255:pi;
wo=0.4*pi;
num1=[1 3 5 7 9 11 13 15 17];
L=length(num1);
h1=freqz(num1,1,w);
n=0:L-1;
num2=exp(wo*i*n).*num1;
h2=freqz(num2,1,w);
subplot(2,2,1);
plot(w/pi,abs(h1));
grid;
title('Magnitude Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,abs(h2));
grid;
title('Magnitude Spectrum of Frequency Shifted Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(h1));
grid;
title('Phase Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
subplot(2,2,4);
plot(w/pi,angle(h2));
grid;
title('Phase Spectrum of Frequency Shifted Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
clf;
w=-pi:2*pi/255:pi;
x1=[1 3 5 7 9 11 13 15 17];
x2=[1 -2 3 -2 1];
y=conv(x1,x2);
h1=freqz(x1,1,w);
h2=freqz(x2,1,w);
hp=h1.*h2;
h3=freqz(y,1,w);
subplot(2,2,1);
plot(w/pi,abs(hp));
grid;
title('Product of Magnitude Spectrum','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,abs(h3));
grid;
title('Magnitude Spectrum of Convolved Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,abs(hp));
grid;
title('Sum of Phase Spectrum','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(h1));
grid;
title('Phase Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
subplot(2,2,4);
plot(w/pi,angle(h3));
grid;
title('Phase Spectrum of Convolved Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
clf;
w=-pi:2*pi/255:pi;
x1=[1 3 5 7 9 11 13 15 17];
x2=[1 -1 1 -1 1 -1 1 -1 1];
y=x1.*x2;
h1=freqz(x1,1,w);
h2=freqz(x2,1,w);
h3=freqz(y,1,w);
subplot(3,1,1);
plot(w/pi,abs(h1));
grid;
title('Magnitude Spectrum of First Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(3,1,2);
plot(w/pi,abs(h2));
grid;
title('Magnitude Spectrum of Second Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(3,1,3);
plot(w/pi,abs(h3));
grid;
title('Magnitude Spectrum of Product Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(h1));
grid;
title('Phase Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
subplot(2,2,4);
plot(w/pi,angle(h3));
grid;
title('Phase Spectrum of Convolved Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
clf;
w=-pi:2*pi/255:pi;
num=[1 2 3 4];
l=length(num)-1;
h1=freqz(num,1,w);
h2=freqz(fliplr(num),1,w);
h3=exp(w*l*pi).*h2;
subplot(2,2,1);
plot(w/pi,abs(h1));
grid;
title('Magnitude Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,abs(h3));
grid;
title('Magnitude Spectrum of Time Reversal Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(h1));
grid;
title('Phase Spectrum of Original Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,4);
plot(w/pi,angle(h3));
grid;
title('Phase Spectrum of Time Reversal Sequence','FontSize',8);
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
clf;
w=-4*pi:8*pi/511:4*pi;
num=[2 1];
den=[1 -0.6];
h=freqz(num,den,w);
subplot(2,2,1);
plot(w/pi,real(h));
grid;
title('Real Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2)
plot(w/pi,imag(h));
grid;
title('Imaginary Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,abs(h));
grid;
title('Magnitude Spectrum[H(e^{j\omega})]')
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,4);
plot(w/pi,angle(h));
grid;
title('Phase Spectrum arg[H(e^{j\omega})]');
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
G) EVALUATION OF DTFT 2
clf;
N=512;
num=[0.7 -0.5 0.3 1];
den=[1 0.3 -0.5 0.7];
[h,w]=freqz(num,den,N);
subplot(2,2,1);
plot(w/pi,real(h));
grid;
title('Real Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,imag(h));
grid;
title('Imaginary Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,abs(h));
grid;
title('Magnitude Spectrum [H(e^{j\omega})]');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,4);
plot(w/pi,angle(h));
grid;
title('Phase Spectrum arg[H(e^{j\omega})]');
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
H) EVALUATION OF DTFT 3
clf;
w=-4*pi:8*pi/511:4*pi;
num=[1 3 5 7 9 11 13 15 17];
den=1;
h=freqz(num,den,w);
subplot(2,2,1);
plot(w/pi,real(h));
grid;
title('Real Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,imag(h));
grid;
title('Imaginary Part of H(e^{j\omega})');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,abs(h));
grid;
title('Magnitude Spectrum [H(e^{j\omega})]');
xlabel('\omega/\pi');
ylabel('Amplitude');
subplot(2,2,4);
plot(w/pi,angle(h));
grid;
title('Phase Spectrum arg[H(e^{j\omega})]');
xlabel('\omega/\pi');
ylabel('Phase in radians');
WAVEFORMS:
PROCEDURE:
1. OPEN MATLAB
Program:
clc;
clear all;
close all;
%compute fft
X=fft(x,n);
subplot(1,2,1);
stem(x);
title('i/p signal');
xlabel('n --->');
ylabel('x(n) -->');grid;
subplot(1,2,2);stem(X);
grid;
Output :
VIVA VOCE
FFT algorithm is designed to perform complex operations.-The FFT algorithm is designed to perform
complex multiplications and additions, even though the input data may be real valued. The basic reason for
this is that the phase factors are complex and hence, after the first stage of the algorithm, all variables are
basically complex valued.
Decimation-in frequency FFT algorithm is used to compute H(k)-The N-point DFT of h(n), which is padded
by L-1 zeros, is denoted as H(k). This computation is performed once via the FFT and resulting N complex
numbers are stored. To be specific we assume that the decimation-in frequency FFT algorithm is used to
compute H(k). This yields H(k) in the bit-reversed order, which is the way it is stored in the memory
How many complex multiplications are need to be performed for each FFT algorithm?-The decimation of
the data sequence should be repeated again and again until the resulting sequences are reduced to one point
sequences. For N=2v, this decimation can be performed v=log2N times. Thus the total number of complex
multiplications is reduced to (N/2)log2N.
6) Design of FIR filter using windowing technique and verify the frequency
response of the filter
Aim: To write a matlab program for Design of FIR filter using windowing technique and verify
the frequency response of the filter.
PROCEDURE:
1. OPEN MATLAB
Program:
function FIR_Filter_WindowingMethod
% Design and Implementation of FIR Filter Package
% Date: 04/16/2011
% Author: Gang LIU
% Contacts: liug "at" yahoo dot cn
%
% This code is based on the some code from MATLAB Singal Processing
% Toolbox.
%
%. Example MATLAB M-file illustrating FIR filter design and evaluation.
% Finite Impulse Response filter design example
% found in the MATLAB Signal Processing Toolbox
% using the MATLAB FIR1 function (M-file)
close all;
Fs=8000; %Specify Sampling Frequency
Ts=1/Fs; %Sampling period.
Ns=512; %Nr of time samples to be plotted.
t=[0:Ts:Ts*(Ns-1)]; %Make time array that contains Ns elements
%t = [0, Ts, 2Ts, 3Ts,..., (Ns-1)Ts]
f1=500;
f2=1500;
f3=2000;
f4=3000;
x1=sin(2*pi*f1*t); %create sampled sinusoids at different frequencies
x2=sin(2*pi*f2*t);
x3=sin(2*pi*f3*t);
x4=sin(2*pi*f4*t);
x=x1+x2+x3+x4; %Calculate samples for a 4-tone input signal
ECE DEPT. SVR ENGINEERING COLLEGE 47
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
%N=16; %FIR1 requires filter order (N) to be EVEN
%when gain = 1 at Fs/2.
%W=[0.4 0.6]; %Specify Bandstop filter with stop band between
%0.4*(Fs/2) and 0.6*(Fs/2)
%B=FIR1(N,W,'DC-1'); %Design FIR Filter using default (Hamming window.
disp('Please specify the filter type');
FilterType={'low','high','bandpass','stop'};
disp('Here is the filter option:');
disp('1: Low Pass Filter ');
disp('2: High Pass Filter');
disp('3: Band Pass Filter');
disp('4: Band Stop Filter');
disp('You only need enter number. EX. 4 means Band Stop filter')
FilterOption=input('FilterOption=');
while FilterOption ~=1 && FilterOption ~=2 && FilterOption ~=3 && FilterOption ~=4
disp('You only need enter number : 1,2,3 or 4. EX. 4 means Band Stop filter');
FilterOption=input('FilterOption=');
end
userFilterType=FilterType{FilterOption};
disp('Enter the order of the filter(Must be a positive even number, should be less than 100');
FilterOrder=input('FilterOrder=');
str=sprintf('Here is all the frequency infromation in this experiment:Fs=%d; f1=%d; f2=%d; f3=%d;
f4=%d;',Fs,f1,f2,f3,f4);
disp(str);
if FilterOption==1
disp('Enter the Edge Freq. in Hz. Note: the value should be within 0~Fs');W=input('omega=');
elseif FilterOption==2
disp('Enter the Edge Freq. in Hz. Note: the value should be within 0~Fs');W=input('omega=');
elseif FilterOption==3
disp('Enter the Edge Freq. in Hz. Note: the value should be within 0~Fs');W=input('omega
cutoff1=');W2=input('omega cutoff2='); W=[W W2];
elseif FilterOption==4
disp('Enter the Edge Freq. in Hz. Note: the value should be within 0~Fs');W=input('omega
cutoff1=');W2=input('omega cutoff2='); W=[W W2];
end
%Fs, W,
W=W./(Fs/2); % [1600 2400]
N=FilterOrder;
Window_Option={'hamming','kaiser','rectwin'};
disp('Here is the Windowing option:');
disp('1: hamming');
disp('2: kaiser');
disp('3: rectwin');
WindowOption=input('WindowOption=');
while WindowOption ~=1 && WindowOption ~=2 && WindowOption ~=3
disp('You only need enter number : 1,2,or 3. EX. 3 means rectwin');
OUTPUT :
Please specify the filter type
You only need enter number. EX. 4 means Band Stop filter
FilterOption=1
Enter the order of the filter(Must be a positive even number, should be less than 100
FilterOrder=6
Here is all the frequency infromation in this experiment:Fs=8000; f1=500; f2=1500; f3=2000; f4=3000;
Enter the Edge Freq. in Hz. Note: the value should be within 0~Fs
omega=1000
1: hamming
3: rectwin
WindowOption=1
Checking the Zero-Phase Response of the designed filter, enter any key to continue
Checking the Freq. Response of the designed filter, enter any key to continue
Checking the Filtering Effect of the designed filter in time domain, enter any key to continue
VIVA VOCE
What are the desirable characteristics of the frequency response of window function?
Advantages:
a) FIR filters have exact linear phase.
b) FIR filters are always stable.
c) FIR filters can be realized in both recursive and non recursive structure.
d) Filters with any arbitrary magnitude response can be tackled using FIR sequency.
Disadvantages:
a) For the same filter specifications the order of FIR filter design can be as high as 5 to n10
times that of IIR design.
b) Large storage requirements needed.
c) Powerful computational facilities required for the implementation.
The Optimum Equi ripple design Criterion is used for designing FIR Filters with Equal level
filteration throughout the Design.
FIR Filter is always stable.
FIR Filter with exactly linear phase can easily be designed.
7) Design of IIR filter using anyof the available methods and verify the frequency
response of the filter
Aim: To write a matlab program for design of IIR filter using anyof the available methods and
verify the frequency response of the filter.
PROCEDURE:
1. OPEN MATLAB
Program:
clc;
clear all;
close all;
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
clc;
clear all;
close all;
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
if(c==1)
[b,a]=butter(n,wn,'low','s');
end
if(c==2)
[b,a]=butter(n,wn,'high','s');
end
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);
ylabel('Gain in dB-->');
subplot(2,1,2);plot(om/pi,an);
ylabel('Phase in radians-->');
Output :--
ECE DEPT. SVR ENGINEERING COLLEGE 55
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
enter the IIR filter design specifications
PROCEDURE:
1. OPEN MATLAB
Program:
clc;
clear all;
close all;
if(c==1)
Cf=100;
[b,a]=butter(N,Cf,'S');
freqs(b,a);
end
if(c==2)
Cf=100;
[b,a]=butter(N,Cf,'HIGH','S');
freqs(b,a);
end
if(c==3)
ECE DEPT. SVR ENGINEERING COLLEGE 57
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
disp('Frequency response of Analog BPF is:');
Cf1=[10 100];
[b,a]=butter(N,Cf1,'S');
freqs(b,a);
end
if(c==4)
Cf1=[10 100];
[b,a]=butter(N,Cf1,'STOP','S');
freqs(b,a);
end
OUTPUT :
CC STUDIO PROGRAMS
bit instructions every 1/(225 MHz) or 4.44 ns. Features of the C6713 include 264 kB of internal memory
(8kB as L1P and L1D Cache and 256kB as L2 memory shared between program and data space), eight
functional or execution units composed of six arithmetic-logic units (ALUs) and two multiplier units, a 32-
bit address bus to address 4 GB (gigabytes), and two sets of 32-bit general-purpose registers.
The C67xx (such as the C6701, C6711, and C6713) belong to the family of the C6x floating-point processors,
whereas the C62xx and C64xx belong to the family of the C6x fixed-point processors. The C6713 is capable
of both fixed- and floatingpoint processing.
An application-specific integrated circuit (ASIC) has a DSP core with customized circuitry for a specific
application. A C6x processor can be used as a standard general-purpose DSp programmed for a specific
application. Specific purpose digital signal processors are the modem, echo canceler, and others. A
fixed-point processor is better for devices that use batteries, such as cellular phones, since it uses less power
than does an equivalent floating-point processor. The fixed-point processors, C1x, C2x, and C5x, are 16-bit
processors with limited dynamic range and precision. The C6x fixed-point processor is a 32- bit processor
with improved dynamic range and precision. In a fixed-point processor, it is necessary to scale the data.
Overflow, which occurs when an operation such as the addition of two numbers produces a result with more
bits than can fit within a processor’s register, becomes a concern.
A floating-point processor is generally more expensive since it has more “real estate” or is a larger chip
because of additional circuitry necessary to handle integer as well as floating-point arithmetic. Several
factors, such as cost, power consumption, and speed, come into play when choosing a specific DSp.
The C6x processors are particularly useful for applications requiring intensive computations. Family
members of the C6x include both fixed-point (e.g., C62x, C64x) and floating-point (e.g., C67x) processors.
Other DSp’s are also available from companies such as Motorola and Analog Devices.
The TMS320C6713 onboard the DSK is a floating-point processor based on the VLIW architecture [6–10].
Internal memory includes a two-level cache architecture with 4 kB of level 1 program cache (L1P), 4 kB of
level 1 data cache (L1D), and 256 kB of level 2 memory shared between program and data space.
It has a glueless (direct) interface to both synchronous memories (SDRAM and SBSRAM) and asynchronous
memories (SRAM and EPROM). Synchronous memory requires clocking but provides a compromise
between static SRAM and dynamic DRAM, with SRAM being faster but more expensive than DRAM. On-
chip peripherals include two McBSPs, two timers, a host port interface (HPI), and a 32-bit EMIF. It requires
3.3 V for I/O and 1.26 V for the core (internal). Internal buses include a 32-bit program address bus, a 256-
bit program data bus to accommodate eight 32-bit instructions, two 32-bit data address buses, two 64- bit
data buses, and two 64-bit store data buses.With a 32-bit address bus, the total memory space is 232 = 4GB,
including four external memory spaces: CE0, CE1, CE2, and CE3. Figure shows a functional block diagram
of the C6713 processor included with CCS.
Step 3: Libraries Add Files to Project My Project C600 CG Tools
Library rts6700.lib
Step 13: Start Address ‘a’ and DSP data type- 32 bit floating point
TMS320C6748 LCDK
Kit Contents:
Power Card
USB Cable
SD Card
User Manual
Description:
The TMS320C6748 DSP development kit (LCDK) is a scalable platform that breaks down development
barriers for applications that require embedded analytics and real-time signal processing, including
biometric analytics, communications and audio. The low-cost LCDK will also speed and ease your hardware
development of real-time DSP applications. This new board reduces design work with freely downloadable
and duplicable board schematics and design files. A wide variety of standard interfaces for connectivity and
storage enable you to easily bring audio, video and other signals onto the board.
The LCDK does not have an onboard emulator. An external emulator from TI (such as the XDS100,
XDS200,XDS510, XDS560) or a third-party will be required to start development.
The TMS320C6748 C6000 DSP processor is a low-power applications processor based on C674x DSP core.
This processor provides significantly lower power than other members of the TMS320C6000™ platform of
DSPs
The architecture of the device provides benefits of both DSP and reduced instruction set computer (RISC)
technologies, incorporating a high-performance TMS320C674x DSP core.
The device DSP core uses a 2-level cache-based architecture. The level 1 program cache (L1P) is a 32- KB
direct mapped cache, and the level 1 data cache (L1D) is a 32-KB 2-way, set-associative cache. The level 2
program cache (L2P) consists of a 256-KB memory space that is shared between program and data space.
L2 memory can be configured as mapped memory, cache, or combinations of the two..
Processor
On-Chip RTC
Memory
Interfaces
Three AUDIO Ports (1 LINE IN-J55 & 1 LINE OUT-J56 & 1 MIC IN-J57)
1.Program --
#include<stdio.h>
#include<math.h>
#define PI 3.14
float x[PTS];
float y[PTS];
float z[PTS];
float n[PTS];
void main()
int i,j;
ECE DEPT. SVR ENGINEERING COLLEGE 71
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
for (i = 0 ; i < PTS ; i++)
x[i] = sin(2*PI*i*20/128.0);
printf("%f\n",x[i]);
y[i]=0.0;
n[i]=x[i] + rand() * 10 ;
RESULT:
2) Program--
#include <stdio.h>
int i;
void main()
for(i=0;i<25;i++)
y[i]=amp;
printf("%d\n",y[i]);
for(i=25;i<50;i++)
ECE DEPT. SVR ENGINEERING COLLEGE 72
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
{
y[i]=-amp;
printf("%d\n",y[i]);
RESULT:
#include<stdio.h>
int main()
int num,i,j,x[32];
scanf("%d",&num);
for(j=0;j<num;j++)
scanf("%d",&x[j]);
for(i=0;i<=num;i++)
sum+=x[i]*x[i];
return 0;
2. Program--Power of a signal
#include<stdio.h>
int main(){
int num,i,j,x[32];
float num1;
scanf("%d",&num);
for(j=0;j<num;j++)
scanf("%d",&x[j]);
for(i=0;i<=num;i++)
sum+=x[i]*x[i];
num=num*2;
num++;
return 0;
correlation operations.
Program:
INPUT :
x[n] = {1, 2, 3, 4}
h[k] = {1, 2, 3, 4}
scanf("%d",&m);
scanf("%d",&n);
for(i=0;i<m;i++)
scanf("%d",&x[i]);
for(j=0;j<n;j++)
scanf("%d",&h[j]);
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];
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;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];
for(i=0;i<n;i++)
printf("%d \t",y[i]);
/*cross correlation*/
#include<stdio.h>
#include<math.h>
int y[10];
main()
{i
nt i,j;
int x[15]={1,2,3,4,0,0,0,0,0,0,0,0,0,0,0};
int h[15]={4,3,2,1,0,0,0,0,0,0,0,0,0,0,0};
int n=4;
for(i=-(n-1);i<=(n-1);i++)
{
ECE DEPT. SVR ENGINEERING COLLEGE 78
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
y[i]=0;
for(j=0;j<=4;j++)
}f
or(i=-(n-1);i<n;i++)
printf("%d\n",y[i]);
/*auto correlation*/
#include<stdio.h>
#include<math.h>
int y[10];
main()
int i,j,k;
int x[15]={0,0,0,0,0,1,1,1,1,1,0,0,0,0,0};
int n=15;
k=n-1;
for(i=-(n-1);i<=(n-1);i++)
y[i+k]=0;
for(j=0;j<=5;j++)
y[i+k]+=x[j+k] * x[i+j+k];
for(i=-(n-1);i<n;i++)
printf("%d\n",y[i+k]);
Program--
#include<math.h>
int N,k,n,i;
int x[32];
void main(void)
scanf("%d",&N);
for(i=0;i<N;i++)
scanf("%d",&x[i]);
for(k=0;k<N;k++)
sumre=0;
sumim=0;
for(n=0;n<N;n++)
sumre=sumre+x[n]* cos(2*pi*k*n/N);
sumim=sumim-x[n]* sin(2*pi*k*n/N);
out_real[k]=sumre;
out_imag[k]=sumim;
printf("X([%d])=\t%f\t+\t%fi\n",k,out_real[k],out_imag[k]);
Program--
#include<math.h>
#define PI 3.14
typedef struct
float real,imag;
}com;
void main()
com xx[8],x[8],temp[8],temp1[8],y[8],a[8],b[8],w[4];
for(i=0;i<8;i++)
scanf("%f",&xx[i].real);
j=0;
for(i=0;i<8;i=i+2)
x[j].real=xx[i].real;
x[j+1].real=xx[i+4].real;
if(i==2)
i=-1;
j=j+2;
for(i=0;i<4;i++)
w[i].real=cos(2*PI*i/8);
w[i].imag=-sin(2*PI*i/8);
for(i=0;i<8;i=i+2)
temp[i].real=x[i].real+x[i+1].real;
temp[i].imag=x[i].imag+x[i+1].imag;
temp[i+1].real=x[i].real-x[i+1].real;
temp[i+1].imag=x[i].imag-x[i+1].imag;
for(i=2;i<8;i=3*i)
a[i].real=temp[i].real*w[0].real-temp[i].imag*w[0].imag;
a[i].imag=temp[i].real*w[0].imag+temp[i].imag*w[0].real;
a[i+1].real=temp[i+1].real*w[2].real-temp[i+1].imag*w[2].imag;
a[i+1].imag=temp[i+1].real*w[2].imag+temp[i+1].imag*w[2].real;
temp[i].real=a[i].real;
temp[i].imag=a[i].imag;
temp[i+1].real=a[i+1].real;
temp[i+1].imag=a[i+1].imag;
for(i=0;i<6;i++)
temp1[i].real=temp[i].real+temp[i+2].real;
temp1[i].imag=temp[i].imag+temp[i+2].imag;
temp1[i+2].real=temp[i].real-temp[i+2].real;
temp1[i+2].imag=temp[i].imag-temp[i+2].imag;
if(i==1)
i=3;
for(i=4;i<8;i++)
b[i].real=temp1[i].real*w[i-4].real-temp1[i].imag*w[i-4].imag;
temp1[i].real=b[i].real;
temp1[i].imag=b[i].imag;
for(i=0;i<4;i++)
y[i].real=temp1[i].real+temp1[i+4].real;
y[i].imag=temp1[i].imag+temp1[i+4].imag;
y[i+4].real=temp1[i].real-temp1[i+4].real;
y[i+4].imag=temp1[i].imag-temp1[i+4].imag;
printf("\nDFT values==\n");
for(i=0;i<8;i++)
printf("\nF(%d)=(%0.1f)+j(%0.1f)\n",i,y[i].real,y[i].imag);
RESULT :
6) Design of FIR filter using windowing technique and verify the frequency response
of the filter
Program:
ECE DEPT. SVR ENGINEERING COLLEGE 83
DIGITAL SIGNAL PROCESSING LAB III B TECH II SEM
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
switch(c)
case 1:
for(n=0;n<=N-1;n++)
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
break;
case 2:
for(n=0;n<=N-1;n++)
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
break;
}}
7 ) Design of IIR filter using any of the available methods and verify the
Program:
//IIRFILTERS USING C
#include<stdio.h>
#include<math.h>
int i,w,wc,c,N;
float H[100];
void main()
scanf("%d",&N);
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
case 1:
for(w=0;w<100;w++)
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
break;
case 2:
for(w=0;w<=100;w++)
printf("H[%d]=%f\n",w,H[w]);
break;
}}
for(i=0;i<x-1;i++)
a*=a;
return(a);
Program:
RESULT :