You are on page 1of 69

Laboratory Manual for

Digital Signal Processing

B. Tech.
SEM. VI (EC)

Department of Electronics& Communication


Faculty of Technology
Dharmsinh Desai University
Nadiad

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 15
PART I

LAB MANUAL

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 16
TABLE OF CONTENTS

Sr. Title Page No.


No.
1 Basic Discreate Signal Generation 3

2 Discreate Signal Operations 7

3 Convolution And Correlation 12

4 Application Of Correlation 16

5 Dft & Idft 22

6 Analog Filter Design 28

7 Applications Of Dsp 42

8 Introduction To Ccstudio 57

9 Assembly Programming In CCs 61

10 Programming Techniques In Ccs 65

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 17
LAB 1
Discrete Signal Generation

AIM: To generate basic discrete signal used in Digital Signal Processing

Introduction:

Signals are broadly classified into analog & discrete signals. An analog signal will be denoted by x(t), in
which the variable t can represent any physical quantity. A discrete signal will be denoted by x(n), in
which the variable n is integer valued and represents discrete instances in time. Therefore it is called a
discrete time signal, which is a number sequence and will be denoted by one of the following
notations:

x(n)=,…,x(-1),x(0),x(1),….-

clc;
clear;
xdel(winsid());
t=0:0.1:20;
f=0.2;
pi=3.14;

//////////////////////// SINEWAVE /////////////////


x1=sin(2*pi*f*t);
//scf();
subplot(231);
plot(t,x1,'cya+','marker','d','markerfac','green','markeredg','red');
title('Sinewave','color','red','fontsize', 4);
//xtitle( 'Sinewave', 'Index', 'Amplitude') ;
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

//////////////////////// Cosine Wave /////////////////


x2=cos(2*pi*f*t);
//scf();
subplot(232);
plot(t,x2,'cya+','marker','d','markerfac','red','markeredg','yel');
title('Cosinewave','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

//////////////////////// Impulse Wave /////////////////


t1=-10:10;
x3=[zeros(1,10) 1 zeros(1,10)];
//scf();
subplot(233);
plot(t1,x3,'cya+','marker','d','markerfac','green','markeredg','red');

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 18
title('Impulse','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

//////////////////////// Ramp Wave /////////////////


t4=0:10;
x4=t4;
//scf();
subplot(234);
plot(t4,x4,'cya+','marker','d','markerfac','green','markeredg','red');
title('Ramp Wave','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

//////////////////////// Exponetial Wave /////////////////


t5=0:10;
x5=exp(t5);
//scf();
subplot(235);
plot(t5,x5,'cya+','marker','d','markerfac','green','markeredg','red');
title('Exponetial Wave','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

//////////////////////// Random Wave /////////////////


x6=rand(1,100);
//scf();
subplot(236);
plot(1:length(x6),x6,'cya+','marker','d','markerfac','green','markeredg','red');
title('Random Wave','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

/////////////Impulse Sequence /////////////////


n1=1,n0=50,n2=100;
if((n0<n1)|(n0>n2)|(n1>n2))
error('arugument incorrect');
end
n=[n1:n2];
x7=[(n-n0)==0,1];
scf()
subplot(121);
plot(n,x7(n1:n2),'cya+','marker','d','markerfac','green','markeredg','red');
title('Impulse Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

////////////////// Step Sequence ////////////////


n1=1,n0=50,n2=100;
if((n0<n1)|(n0>n2)|(n1>n2))

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 19
error('arugument incorrect');
end
n=[n1:n2];
x8=[(n-n0)>=0,1];
subplot(122);
plot(n,x8(n1:n2),'cya+','marker','d','markerfac','green','markeredg','red');
title('Step Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 20
LAB 2
DISCRETE SIGNAL OPERATIONS

AIM : Implement following operation on discrete signal.


(I) Addition (II) Multiplication (III) Flipping (IV) Shifting

THEORY:

Various signal operations are used in achieving more complex signal operations. The signal operation
like flipping, shifting, addition, multiplication is used in implementation of convolution, correlation
like operations.

Signal Addition & Multiplication:

%%%%%%%% Programm-1 %%%%%%%%%%%%%


clc;
clear;
xdel(winsid());
x1=[1 6 7 4 5 2 3 7 8 9];
n1=[-3 -2 -1 0 1 2 3 4 5 6];
x2=[5 8 6 9 4 2 3 7 5 6 2 8 7];
n2=[4 5 6 7 8 9 10 11 12 13 14 15 16] ;
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))))=x1;
y2(find((n>=min(n2))&(n<=max(n2))))=x2;
y=y1+y2;
x=y1.*y2;
// Addition of Two Sequences //
scf();
subplot(311);
bar(n,y1,0.1,'red');
title('Sequence_1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(312);
bar(n,y2,0.1,'yellow');
title('Sequence_2','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(313)
bar(n,y,0.1,'Green');
//plot(n,y,'cya+','marker','d','markerfac','red','markeredg','yel');
title('Addition of Sequences','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 21
// Multiplication of Two Sequences //
scf();
subplot(311);
bar(n,y1,0.1,'red');
title('Sequence_1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(312);
bar(n,y2,0.1,'yellow');
title('Sequence_2','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(313)
bar(n,x,0.1,'Green');
//plot(n,y,'cya+','marker','d','markerfac','red','markeredg','yel');
title('Multiplication of Sequences','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

Signal Flipping:

clc;
clear;
xdel(winsid());
x2=input("Enter the Sequence :"); // [2 3 5 6 4 8 6];
x3=mtlb_fliplr(x2);
n3=1:length(x2);
n3=-mtlb_fliplr(n3);
scf();
subplot(2,1,1);
bar(x2,0.1,'red');
title('Original Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(n3,x3,0.1,'green');
title('Folded Sequence','color','green','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

Signal Shifting:

clc;
clear;
xdel(winsid());
x2=input("Enter the Sequence :"); // [2 3 5 6 4 8 6];
factor=input("Enter the Shifting Factor :"); // Example : -2 or 2

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 22
a=[];
t=[];
for i=1:length(x2)
t=[t (i-factor)];
a=[a x2(i)];
end
temp=[];
if(factor>0)
a=[a zeros(1,factor)];
for j=1:factor
temp=[temp t(length(t))+j];
end
t=[t temp];
end
if(factor<0)
a=[zeros(1,-factor) a];
for j=1:-factor
temp=[temp j];
end
t=[temp t];
end
scf();
subplot(2,1,1);
bar(x2,0.1,'red');
title('Original Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
title('Original Sequence');
subplot(2,1,2);
bar(t,a,0.1,'green');
title('Shfted Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

CONCLUSION:

ASSIGNMENT

1. x(n)=2delta(n+2)-delta(n-4), -5<=n<=5;

2. x(n)=n[u(n)-u(n-10)+exp(-0.3(n-10))[u(n-10)-u(n-20)], 0<=n<=20;

3. x(n)=n[u(n)-u(n-10)+exp(-0.3(n-10))[u(n-10)-u(n-20)], 0<=n<=20;

4. 2*x(n-5)-3*x(n+4);

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 23
LAB 3
CONVOLUTION AND CORRELATION

(a)AIM: To perform the convolution operation between two discrete sequences.

THEORY : Convolution and polynomial multiplication syntax w=conv(u,v) convolves vectors u and v.

Algebraically, convolution is the same as operation as multiplying the polynomials whose coefficients
are the elements of u and v. Definition: Let m=length (u) and n=length (v). Then w is the vector of
length (m+n-1) whose kth element is the sum over all the values of j which lead to legal subscripts for
u(j) and v(k+1-j), specifically j= max(1,k+1-n): min(k,m). When m=n, this gives

w(1) = u (1)*v (1)

w(2) = u (1)*v (2)+u(2)*v(1)

w(3)= u(1)*v(3)+u(2)*v(2)+u(3)*v(1)

...

w(n)= u(1)*v(n)+u(2)*v(n-1)+...+u(n)*v(1)

...

w(2*n-1)= u(n)*v(n)

The convolution theorem says, roughly, the convolving two sequences is the same as multiplying their
Fourier transforms. In order to make this precise, it is necessary to pad the two vectors with zeros
and ignore round off error. Thus, if X=fft([x,zeros(1,length(y)-1)]) and Y=fft([y,zeros(1,length(y)-1)])
then conv(x,y)=ifft(X.*Y).

If x[n] is input and h[n] is the system impulse response then system response

Y[n] = =

clc;
clear;
xdel(winsid());
x1=input("Enter the Sequence_1 :"); // [1 2 3 4 5];
x2=input("Enter the Sequence_2 :"); // [5 4 8];
n = length(x1);
m = length(x2);
for k = 1:(m+n-1)
w(k) = 0;

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 24
for j =max(1,k+1-m) : min(k,n)
w(k)= w(k)+(x1(j)*x2(k+1-j));
end
end
scf();
subplot(3,1,1);
bar(x1,0.1,'red');
title('Sequence_1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.6 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(3,1,2);
bar(x2,0.1,'yellow');
title('Sequence_2','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.6 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(3,1,3);
bar(w,0.1,'green');
title('Convoled Sequence','color','green','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

1.To Find the Response of Series Connected System Using Convolution


x=[5 6 7];
h1=[1 2 3 4];
h2=[2 3 4 5];
z=conv(x,h1)
y=conv(z,h2)
w=conv(h1,h2)
v=conv(w,x)

OUTPUT:
z=

5 16 34 52 45 28

y=

10 47 136 295 462 569 524 337 140

w=

2 7 16 30 34 31 20

v =10 47 136 295 462 569 524 337 140


Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 25
(b)AIM : To perform the correlation operation between two discrete sequences.

THEORY :Correlation is a measure of similarity between two signals and is found using a process
similar to convolution. The discrete correlation (denoted **) of x[n] and h[n] is defined by

rxy= x[n] ** h[n] =

Correlation is equivalent to performing the convolution of x[n] with flipped signal h[-n].

clc;
clear;
xdel(winsid());
x=[2 4 5 6];
y=[2 4 5];
m=length(x);
n=length(y);
for k=1:m+n-1
w(k)=0;
for j=max(1,k+1-n):min(k,m)
w(k)=w(k)+(x(j)*y(n-k+j));
end
end
scf();
subplot(3,1,1);
bar(x,0.1,'red');
title('Sequence_1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.6 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(3,1,2);
bar(y,0.1,'yellow');
title('Sequence_2','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.6 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(3,1,3);
bar(w,0.1,'green');
title('Correlation of Sequences','color','green','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue",'position',[0.3 0.3]);
ylabel("Amplitude", "fontsize", 2, "color", "blue");

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 26
LAB 4
CORRELATION APPLICATION

AIM :
(I) To detect the object’s presence in RADAR using correlation.
(II) To detect transmitted binary sequence at receiver side

( I ) RADAR Signal Processing

clc;
clear;
xdel(winsid());
x=[0 1 2 3 2 1 0]; //Triangle pulse transmitted by radar
n=[-3 -2 -1 0 1 2 3]; // Index of Triangular Pulse
D=10; // Delay amount
nd=n+D; // Index of Delayed Signal
y=x; // Delayed Signal
scf();
subplot(2,1,1);
bar(n,x,0.1,'red');
title('Original Transmitted Signal','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(nd,y,0.1,'yellow');
title('Delayed Signal','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
w=rand(1,length(x)); // Noise Generation
nw=nd;
scf();
bar(nw,w,0.1,'red');
title('Noisy Signal','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
// If object is present we receive the signal R(n) = x(n-D) + Noise
R=y+w; // Original Signal+Noise
nr=nw; // Index of received signal at RADAR
nr_fold=mtlb_fliplr(nr);
R_fold=mtlb_fliplr(R);
nmin=min(n)+min(nr_fold); // Lowest index of y(n)
nmax=max(n)+max(nr_fold); // Highest index of y(n)
n_received=nmin:nmax;
Received_Presence=conv(x,R_fold); // Convolution of Original signal and Received Signal in the
Presence of Object (Equvalent to Correlation)//
scf();
subplot(2,1,1);
bar(n_received,Received_Presence,0.1,'red');
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 27
title('Correlation in the Presence of Object','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Correlation Value", "fontsize", 2, "color", "blue");
// If object is not present we receive the signal R(n) = Noise
R=w; // only Noise Signal
nr=nw;
nr_fold=mtlb_fliplr(nr);
R_fold=mtlb_fliplr(R);
nmin=min(n)+min(nr_fold); // Lowest index of y(n)
nmax=max(n)+max(nr_fold); // Highest index of y(n)
n_received=nmin:nmax;
Received_Absence=conv(x,R_fold); // Convolution of Original transmitted signal and Received Signal in
the Absence of Object (Equvalent to Correlation)//
subplot(2,1,2);
bar(n_received,Received_Absence,0.1,'Green');
title('Correlation in the Absence of Object','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Correlation Value", "fontsize", 2, "color", "blue");

( II ) Binary Sequence Detection at Receiver

clc;
clear;
xdel(winsid());
N=30; // Length of the signal
n=0:N-1;
pi=3.14;
x0=sin(n*pi/8); // For '0' transmission
x1=sin(n*pi/4); // For '1' transmission
scf();
subplot(2,1,1);
bar(n,x0,0.1,'red');
title('Sin(n*pi/8) to Represent Binary 0','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(n,x1,0.1,'yellow');
title('Sin(n*pi/4) to Represent Binary 1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
w=rand(1,N); // Noise Signal
y0=x0+w; // Original Signal + Noise Signal
y1=x1+w; // Original Signal + Noise Signal
// If received signal is y0(n)
rx0y0=xcorr(x0,y0); // crosscorrelation between x0(n) and y0(n)
rx1y0=xcorr(x1,y0); // crosscorrelation between x1(n) and y0(n)
scf();
subplot(2,1,1);
bar(rx0y0,0.1,'red');
title('Correlation between x0 and y0','color','red','fontsize', 4);
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 28
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(rx1y0,0.1,'green');
title('Correlation between x1 and y0','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
// If received signal is y1(n)
rx0y1=xcorr(x0,y1); // crosscorrelation between x0(n) and y1(n)
rx1y1=xcorr(x1,y1); // crosscorrelation between x1(n) and y1(n)
scf();
subplot(2,1,1);
bar(rx0y1,0.1,'red');
title('Correlation between x0 and y1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(rx1y1,0.1,'green');
title('Correlation between x1 and y1','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 29
CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 30
LAB 5
DFT & IDFT

AIM: To Perform operation of DFT & IDFT with and without MATLAB inbuilt function.

THEORY:

The DSP processors are used to perform frequency analysis of signals. To do the frequency analysis
we should convert the time domain signal into the frequency domain.

For this , the different frequency transformation techniques are used. Using DTFT (discreteTime
Fourier transform) we can convert the discrete time domain sequence into frequencyDomain. But
X(w) is a continuous function of frequency and therefore it is not a convenientRepresentation of x(n).

So, we represent sequence x(n) by samples of its spectrum X(w). Such a frequency domain
Representation leads to DFT.(Discrete Fourier transform).

N-1

X(K)= Σ x(n) e(-j 2*pi*k*n)/N , K=0,1,2,.... N-1

n=0

N-1

x(n)= 1/N Σ X(K) e(j 2*pi*k*n)/N , n=0,1,2,.... N-1

K=0

DFT computes N equally spaced frequency samples of the DTFT. Both the indices n and K are ranging
from 0 to N-1.The integer n is known as time index since it denotes the time instant. The integer K
denotes discrete frequency and is called frequency index.

RESPECTIVE MATLAB FUNCTIONS:

FFT(X) : is the discrete Fourier transform (DFT) of vector X. For matrices, the FFT operation is applied
to each column.

FFT(X,N): is the N-point FFT, padded with zeros if X has less than N points and truncated if it has more.

FFT(X,[ ],DIM) or FFT(X,N,DIM) applies the FFT operation across the dimension DIM.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 31
Y = fftn(X) returns the discrete Fourier transform (DFT) of X, computed with a multidimensional fast
Fourier transform (FFT) algorithm. The result Y is the same size as X.

Y = fftn (X,size) pads X with zeros, or truncates X, to create a multidimensional array of size siz before
performing the transform. The size of the result Y is siz.

Y = fftshift(X) rearranges the outputs of fft, fft2, and fftn by moving the zero-frequency component to
the center of the array. It is useful for visualizing a Fourier transform with the zero-frequency
component in the middle of the spectrum.

Y = fftshift(X,dim) applies the fftshift operation along the dimension dim.

Y = ifft(X) returns the inverse discrete Fourier transform (DFT) of vector X, computed with a fast
Fourier transform (FFT) algorithm. If X is a matrix, ifft returns the inverse DFT of each column of the
matrix.

1. DFT using inbuilt function:


dft
10
x=[1 2 3 4];
y=fft(x); 9

stem(abs(y)); 8

title('dft'); 7
xlabel('time');
6
ylabel('amplitude');
amplitude

0
1 1.5 2 2.5 3 3.5 4
time

2. DFT using user defined function:

clc;
close all;
clear all;
x=[1 2 3 4];
N=length(x);

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 32
for k=1:N
y(k)=0;
for n=1:N
y(k)=y(k)+(x(n)*exp((-2*pi*(k-1)*(n-1)*j)/N));
end
end
stem(abs(y));
title('u-d fft');
xlabel('time');
ylabel('amplitude');

u-d fft
10

6
amplitude

0
1 1.5 2 2.5 3 3.5 4
time

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 33
3. IDFT using inbuilt function:
inbuilt fft
6
clc;
close all; 5
clear all;
x=[1 2 3]; 4

y=fft(x);

amplitude
3
stem(abs(y));
title('inbuilt fft'); 2

xlabel('time');
ylabel('amplitude'); 1

z=ifft(y); 0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
figure(); time

stem(abs(z));
title('inbuilt ifft');
xlabel('time');
ylabel('amplitude');

inbuilt ifft
3

2.5

2
amplitude

1.5

0.5

0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
time

1. IDFT using user defined function:


clc;
close all;
clear all;
x= [1 2 3];
N=length(x);
for n=1:N
p(n)=0;
for k=1:N

p(n)=p(n)+((x(k)*exp((j*2*pi*(k-1)*(n-1))/N))/N);
end
end

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 34
stem(abs(p));
u-d ifft
title('u-d ifft'); 2

xlabel('time'); 1.8

1.6
ylabel('amplitude');
1.4

1.2

amplitude
1

0.8

0.6

0.4

0.2

0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3
time

2. Phase Reversal Property of Circular Shifted Sequence.

clc;
clear;
xdel(winsid());
n=0:10; // Index
x=10*(0.8).^n; // Input Sequence
y=x(pmodulo(-n,length(n))+1); // y is circular shifted sequence of x
scf();
subplot(2,1,1);
bar(x,0.1,'Green');
title('Original Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,1,2);
bar(y,0.1,'yellow');
title('Circular Shifted Sequence','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
X=fft(x,-1); // Discrete Fourier Transform of Original Sequence
Y= fft(y,-1); // Discrete Fourier Transform of Circular Shifted Sequence
scf();
subplot(2,2,1);
bar(n,real(X),0.1,'Green');
title('Real{DFT[x(n)]}','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,2,2);
bar(n,imag(X),0.1,'Green');
title('Imag{DFT[x(n)]}','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
subplot(2,2,3);
bar(n,real(Y),0.1,'Green');
title('Real{DFT[x((-n))]}','color','red','fontsize', 4);

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 35
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

subplot(2,2,4);
bar(n,imag(Y),0.1,'Green');
title('Imag{DFT[x((-n))]}','color','red','fontsize', 4);
xlabel("Index", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 36
LAB 6
ANALOG FILTER DESIGN
AIM: To Design and implement an analog filter with given specification.

THEORY:

Analog filters are indispensable in many situations. The front end of most digital signal Processing
devices is an anti-aliasing analog filter that limits the input signal to range of frequencies that the
digital filter can handle.

The design of classical analog filters is based on approximating the magnitude or phase Specification
by polynomials or rational functions.Of the four classical filter types based on magnitude
specifications, the Butterworth filter is Monotonic in the pass band and stop band, the Chebyshev –I
filter displays ripples in the Pass band but is monotonic in the stop band, the Chebyshev –II filter
displays ripples in the stop band but is monotonic in the pass band, and the elliptical filter has ripples
in both bands.

The table below lists the available parameters for each design/band combination. For lowpass and
highpass band configurations, these parameters include the passband edge frequency, the stopband
edge frequencies, the passband ripple Rp,and the stopband attenuation Rs.Forbandpass and
bandstop configurations, the parameters include the lower and upper passband edge frequencies, p1
and p2, the lower and upper stopband edge frequencies, s1 and s2, the passband ripple Rp, and the
stopband attenuation Rs. Frequency values are in rad/s, and ripple and attenuation values are in dB.

Ωp = passband edge frequency


Ωp1= lower passband edge frequency
Ωp2= upper cut off frequency
Ωs= stopband edge frequency
Ωs1= lower stopband edge frequency
Ωs2= upper stopband edge frequency
Rp=passband ripple in decibels
Rs = stopband attenuation in decibel

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 37
RESPECTIVE MATLAB FUNCTIONS:
FREQZ:
[H,W] = FREQZ(B,A,N) returns the N-point complex frequency response vector H and the N-point
frequency vector W in radians/sample.

if N isn't specified, it defaults to 512.

[H,W] = FREQZ(B,A,N,Fs) ;where Fs is the sampling frequency (in Hz).

BUTTER: Butterworth digital and analog filter design.

[B,A] = BUTTER (N, Wn) designs an Nth order lowpass digital Butterworth filter and returns the filter
coefficients in length N+1 vectors B (numerator) and A (denominator). The coefficients are listed in
descending powers of z. The cutoff frequency Wn must be 0.0 <Wn< 1.0, with 1.0 corresponding to
half the sample rate.

If Wn is a two-element vector, Wn = [W1 W2], BUTTER returns an order 2N bandpass filter with
passband W1 < W < W2.

[B,A] = BUTTER(N,Wn,'high') designs a highpass filter.

[B,A] = BUTTER(N,Wn,'low') designs a lowpass filter.

[B,A] = BUTTER(N,Wn,'stop') is a bandstop filter if Wn = [W1 W2].

BUTTORD: Butterworth filter order selection.

[N, Wn] = BUTTORD(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Butterworth filter
that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in the stopband.

Wp and Ws are the passband and stopband edge frequencies, normalized from 0 to 1 (where 1
corresponds to pi radians/sample).

Description of Stopband and Passband Filter Parameters

ParameterDescription

Wp Passband corner frequency Wp, the cutoff frequency, is a scalar or a two-element


vector with values between 0 and 1, with 1 corresponding to the normalized Nyquist
frequency, radians per sample.
Ws Stopband corner frequency Ws, is a scalar or a two-element vector with values
between 0 and 1, with 1 corresponding to the normalized Nyquist frequency.
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 38
Rp Passband ripple, in decibels. This value is the maximum permissible passband loss in
decibels.
Rp Stopband attenuation, in decibels. This value is the number of decibels the stopband
is down from the passband.

Filter Type Stopband and Passband Conditions

Lowpass Wp<Ws

Highpass WP >Ws

Bandpass The interval specified by Ws contains the one specified by Wp


(Ws (1) <Wp (1) <Wp (2) <Ws(2)).

Bandstop The interval specified by Wp contains the one specified by Ws


(Wp (1) <Ws (1) <Ws (2) <Wp (2)).

FREQS:

Frequency response of analog filters.[h,w] = freqs(b,a,n) uses n frequency points to compute the
frequency response h, where n is a real, scalar value. The frequency vector w is auto-generated and
has length n. If you omit n as an input, 200 frequency points are used. If you do not need the
generated frequency vector returned, you can use the form h = freqs(b,a,n) to return only the
frequency response h.

FDESIGN LOWPASS:It is use to design lowpass filter.

MATLAB PROGRAMS :

1) Frequency response for 10th Order LPBF 1 Khz Cut-off Filter.

Fs = 6280;( 1Khz = 6280 rad/sec)


N = 10;
*b,a+=butter(N,Fs,’s’);
W=[0:25120];
Freqs(b,a,w);

OUTPUT :

b =1.0e+037
Columns 1 through 9 0
0 0 0 0 0 0 0 0 Columns 10
through 11 0 9.5411
a = 1.0e+037 * Columns
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 39
1 through 9 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 Columns 10 through
11 0.97 9.5411

2) Find the order of filter for given specification.

Ap = 1db
As = 60db Slp
= 6280 rad/sec Sls =
7536 rad/sec
*n,Wn+ = buttord(6280,7536,1,60,’s’);

OUTPUT :

n = 42 Wn =
6.3931e+003

3) Design LPBF digital filter for given specification.

Fp = 0.4;
Fs = 0.5
Ap = 1;

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 40
As = 80;
h = fdesign.lowpass(Fp,Fs,Ap,As);

OUTPUT:

h =Response: 'Lowpass'

Specification: 'Fp,Fst,Ap,Ast'
Description: {'Passband Frequency';'Stopband Frequency';'Passband Ripple (dB)';'Stopband
Attenuation (dB)'}
NormalizedFrequency: true
Fpass: 0.4
Fstop: 0.5
Apass: 1
Astop: 80
Butter(h);

Cheby1(h);

Cheby2(h);

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 41
4) Design BPBF for given specification.

Fst1 = 0.35;
Fp1 = 0.45;
Fp2 = 0.55;
Fst2 = 0.65;
Ast1 = 60;
Ap = 1;
Ast2 = 60;

k = fdesign.bandpass(Fst1,Fp1,Fp2,Fst2,Ast1.Ap,Ast2);

OUTPUT :

k =Response: 'Bandpass'

Specification: 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2'

Description: {7x1 cell}


NormalizedFrequency: true
Fstop1: 0.35
Fpass1: 0.45
Fpass2: 0.55
Fstop2: 0.65
Astop1: 60
Apass: 1
Astop2: 60
Butter (k);
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 42
Cheby1 (k);

Cheby2 (k);

%%%%%% Filter generation using FDATOOL %%%%%%%%%%%


FIR filter using Kaiser Window

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 43
Frequency v/s magnitude graph

Phase v/s magnitude graph

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 44
Frequency v/s phase and amplitude combine graph

Poles and Zeros location

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 45
Design of low pass IIR filter using FDATOOL

Frequency v/s magnitude graph

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 46
Frequency v/s phase graph

Frequency v/s phase and amplitude graph

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 47
Poles and Zeros location

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 48
ASSIGNMENT :

1) Design a BPF with pass band of 1000Hz to 2000Hz with less than 3db of ripple in the pass
band and 80db attenuation in the stopband that are 100Hz wide on both sides of
passband.

2) Design a LPF with a cut-off frequency 1050Hz & plot the output if input is sum of sine
wave of frequency 1000Hz &1500Hz.

3) Design Butterworth high pass filter with specification:


Fs = 0.4,
Fp = 0.5,
As = 80,
Ap = 1
Find out order of the also.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 49
LAB 7
APPLICATIONS OF DSP
(a)AIM :

(I) To generate DTMF signal for the given mobile number.


(II) To decode DTMF signal and find out the mobile number.
(III) To study the design of Echo Filter sound processing using scilab.
(IV) To generate ECG wave for biomedical signal processing.
(V) Musical tone generation [sa re ga ma pa dh ni sa] with each tone has time duration 0.5 sec.

THEORY:

OBJECTIVE 1:

DUAL-TONE MULTI-FREQUENCY SIGNALING (DTMF):

DTMF is used for telecommunication signaling over analog telephone lines in the voice-frequency
band between telephone handsets and other communications devices and the switching center. The
version of DTMF that is used in push-button telephones for tone dialing is known as Touch-Tone.

AT&Ts Compatibility Bulletin described the product of DTFT as,


"A method for pushbutton signaling from customer stations using the voice transmission path."

MULTI-FREQUENCY:

Multi-frequency signaling is a group of signaling methods that use a mixture of two pure
tone (pure sine wave) sounds. The earliest of these were for in-band signaling between switching
centers, where long-distance telephone operators used a 12-digit keypad to input the next portion of
the destination telephone number in order to contact the next downstream long-distance telephone
operator. This semi-automated signaling and switching proved successful in both speed and cost
effectiveness. Dual-tone multi-frequency (DTMF) signaling was developed for the consumer to signal
their own telephone-call's destination telephone number instead of talking to a telephone operator.

USAGE:
DTMF tones were used at first in the telephone handsets and other communication devices to dial
any numbers.
DTMF tones were used by cable television broadcasters to indicate the start and stop times of local
commercial insertion points during station breaks for the benefit of cable companies.
DTMF tones are also used by some cable television networks and radio networks to signal the local
cable company/network station to insert a local advertisement or station identification.
DTMF signaling tones can also be heard at the start or end of some VHS (Video Home System)
cassette tapes. Information on the master version of the video tape is encoded in the DTMF tone.
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 50
GENERATING DTMF TONES:
The DTMF system uses seven different frequency signals transmitted in pairs to represent 12 different
numbers, symbols and letters. The DTMF keypad is laid out in a 4×3 matrix, with each row
representing a low frequency, and each column representing a high frequency.
Pressing a single key (such as '1' ) will send a sinusoidal tone for each of the two frequencies (697 and
1209 hertz (Hz)). The original keypads had levers inside, so each button activated two contacts. The
multiple tones are the reason for calling the system multifrequency. These tones are then decoded by
the switching center to determine which key was pressed. These frequencies were chosen to prevent
any harmonics from being incorrectly detected by the receiver as some other DTMF frequency. The
frequencies allocated to the push-buttons of the telephone pad are shown below:

FREQUENCIES 1209 Hz 1336 Hz 1477 Hz


697 Hz 1 2 3
770 Hz 4 5 6
852 Hz 7 8 9
941 Hz * 0 #

1209 Hz 1336 Hz 1477 Hz

697 Hz 1 2 3

770 Hz 4 5 6

852 Hz 7 8 9

941 Hz * 0 #

SPECIAL TONE FREQUENCIES:

The tone frequencies, as defined by the Precise Tone Plan, are selected such
that harmonics and intermodulation products will not cause an unreliable signal. No frequency is a
multiple of another, the difference between any two frequencies does not equal any of the
frequencies, and the sum of any two frequencies does not equal any of the frequencies. The
frequencies were initially designed with a ratio of 21/19, which is slightly less than a whole tone. The
frequencies may not vary more than ±1.8% from their nominal frequency, or the switching center will
ignore the signal. The high frequencies may be the same volume as – or louder than – the low
frequencies when sent across the line. The loudness difference between the high and low frequencies
can be as large as 3 decibels(dB) and is referred to as "twist."

Each DTMF can be represented as: y(t) = A ( sin(ῳ1t) + sin(ῳ2t) )


Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 51
Where ῳ1 and ῳ2 are the 2 frequencies that are to be added.

%%%%%%%%% DTMF Signal %%%%%%%%%%

%%%% Program 1: %%%%


//////////////////////// DTMF //////////////////////
row_f1=[700 770 850 941]; // Row Frequency
colum_f1=[1220 1350 1490]; // Column Frequency
fs=8000; // Sampling Frequency
N=1:4000; // Total No. of Sample
mobile=[9 9 7 8 3 7 4 2 5 3]; // Mobile Number
temp=[]; // Array that Contain total signal for each Digit
figure;
for i=1:length(mobile)
select mobile(i)
case 1
row_f=1;
colum_f=1;
case 2
row_f=1;
colum_f=2;
case 3
row_f=1;
colum_f=3;
case 4
row_f=2;
colum_f=1;
case 5
row_f=2;
colum_f=2;
case 6
row_f=2;
colum_f=3;
case 7
row_f=3;
colum_f=1;
case 8
row_f=3;
colum_f=2;
case 9
row_f=3;
colum_f=3;
case 0
row_f=4;
colum_f=2;
else
row_f=4;
colum_f=1;
end
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 52
y=sin(2*3.14*(row_f1(row_f)/fs)*N)+sin(2*3.14*(colum_f1(colum_f)/fs)*N);
temp=[temp y zeros(1,4000)]; // Append the Signal + zeros After each Number
end
plot(temp);
sound(temp,fs);

OUTPUT WAVEFORMS: press no. 1

%%%% Program 2: (DTMF for the Given Mobile Number) %%%%


clc;
clear all;
close all;
row_f1=[700 770 850 940]; % Row Frequency
colum_f1=[1220 1350 1490]; % Column Frequency
fs=8000; % Sampling Frequency
N=1:800; % Total No. of Samples for each Digit
mobile=[9 9 0 8 4 5 0 6 5 0];
total_signal=[];

for i=1:length(mobile)
switch mobile(i)
case 1
row_f=1;
colum_f=1;
case 2
row_f=1;
colum_f=2;
case 3
row_f=1;
colum_f=3;
case 4
row_f=2;
colum_f=1;
case 5
row_f=2;
colum_f=2;
case 6
row_f=2;
colum_f=3;
case 7
row_f=3;

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 53
colum_f=1;
case 8
row_f=3;
colum_f=2;
case 9
row_f=3;
colum_f=3;
case 0
row_f=4;
colum_f=2;
otherwise
row_f=4;
colum_f=1;
end
y=sin(2*3.14*(row_f1(row_f)/fs)*N)+sin(2*3.14*(colum_f1(colum_f)/fs)*N); %Time
Domain Signal Generation for each Digit
total_signal=[total_signal y zeros(1,8800)];
temp(:,:,i)=y(:,:);
end
figure;
plot(total_signal);
title('DTMF Signal','color','red','fontsize', 10);
sound(total_signal,fs);

OUT PUT:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 54
%%%% Program 3: (DTMF for the Given Mobile Number & Decoder) %%%%

clc;
close;
clear;
row_f1=[700 770 850 940]; // Row Frequency
colum_f1=[1220 1350 1490]; // Column Frequency
fs=8000; // Sampling Frequency
N=1:800; // Total No. of Samples for each Digit
mobile=[9 9 0 8 4 5 0 6 5 0];
total_signal=[];

figure;

for i=1:length(mobile)
select mobile(i)
case 1
row_f=1;
colum_f=1;
case 2
row_f=1;
colum_f=2;
case 3
row_f=1;
colum_f=3;
case 4
row_f=2;
colum_f=1;
case 5
row_f=2;
colum_f=2;
case 6
row_f=2;
colum_f=3;
case 7
row_f=3;
colum_f=1;
case 8
row_f=3;
colum_f=2;
case 9
row_f=3;
colum_f=3;
case 0
row_f=4;
colum_f=2;
else
row_f=4;
colum_f=1;
end

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 55
y=sin(2*3.14*(row_f1(row_f)/fs)*N)+sin(2*3.14*(colum_f1(colum_f)/fs)*N); //Time Domain Signal
Generation for each Digit
total_signal=[total_signal y zeros(1,8800)];
temp(:,:,i)=y(:,:);
end
plot(total_signal);
title('DTMF Signal','color','red','fontsize', 4);
xlabel("Samples", "fontsize", 2,"color", "blue");
ylabel("Amplitude", "fontsize", 2, "color", "blue");
sound(total_signal,fs);

row_f=[];
col_f=[];

for i=1:10
n=length(temp(:,:,i));
p=abs(fft(temp(:,:,i))); // FFT of Signal of respective Digit
f=(0:n-1)*fs/n; // Total Frequency Range
//plot(f,p);
row=p(2:100); // Row Frequency separation
col=p(101:200); // Column Frequency separation
[r1 c1]=find(row==max(row)); // Finding the location of peak for Row Frequency
[r2 c2]=find(col==max(col)); // Finding the location of peak for Column Frequency
row_f=[row_f 10*c1]; // Array containing peak of Row Freqiency
col_f=[col_f (10*(c2+100))-10]; // Array containing peak of Column Freqiency
end

mobile_find=[]; // Blank Array to Store Mobile Number


for i=1:10 // Loop forFinding the Number form the Row and Column Frequency
if(row_f(i)==700 & col_f(i)==1220)
n0=1;
elseif(row_f(i)==700 & col_f(i)==1350)
n0=2;
elseif(row_f(i)==700 & col_f(i)==1490)
n0=3;
elseif(row_f(i)==770 & col_f(i)==1220)
n0=4;
elseif(row_f(i)==770 & col_f(i)==1350)
n0=5;
elseif(row_f(i)==770 & col_f(i)==1490)
n0=6;
elseif(row_f(i)==850 & col_f(i)==1220)
n0=7;
elseif(row_f(i)==850 & col_f(i)==1350)
n0=8;
elseif(row_f(i)==850 & col_f(i)==1490)
n0=9;
elseif(row_f(i)==940 & col_f(i)==1350)
n0=0;

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 56
end
mobile_find=[mobile_find n0]; // Array containing Decoded Digit of Mobile Number.
end

disp("Decoded Mobile Number :");


disp(mobile_find);

OUT PUT:

Decoded Mobile Number:


9 9 0 8 4 5 0 6 5 0

OBJECTIVE 3:

To design Echo Generation Filter:

The digital signal processing of audio signals often involves digital filter to create various special
effects such as echo and reverb for compensation for the acoustics of a listening environment, which
are the most important for modern-day studios processing audio signals. In listening space, what we
hear from an audio source consists not only of direct sound, but also early echoes reflected directly
from the walls and other structures.The direct sound provides clues to the location of the source, the
early echoes provide an indication of the physical size of the listening space. The amplitude of the
echoes decays exponentially with time. An echo filter has the form of equation given by:

Y*n+ = X*n+ + α * X*n - D]

H(z) = 1 + α * zD

+

Input Output
+

Z-D

An echo filter

This describes FIR filter whose output Y[n] equals to the input X[n] and its delayed (by D samples) and
attenuated (by α) replica of X*n+ (the echo term). Its realization by the block marked z-D. This filter is
also called a Comb filter.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 57
PROGRAM:

b = [1 zeros(1,7999) 0.5]; % numerator coefficient correspond to 1 sec delay and 50%


attenuation
a = [1]; %denominator coefficient
[x,Fs] = wavread('e.wav') %read speech file
Y =filter(b,a,x); %pass speech file through filter
wavwrite( Y,'ringecho1.wav') % generate another file with delay

Filter function:
The filter function filters a data sequence using a digital filter which works for both real and complex
inputs. The filter is a direct form II transposed implementationofthestandard difference equation.y =
filter(b,a,x) filters the data in vector ‘x’ with the filter described by numerator coefficient vector b and
denominator coefficient vector a. Here from Direct form II representation of vector ‘b’ we get the
numerator in z-transform as
N(z) = 1 + 0.5z-8000
This shows the delay of 1 second with the power of ‘z’ that is 8000 and the attenuation is given by its
co-efficient 0.5 showing 50% attenuation.
D(z) = 1
Here vector ‘a’ is denominator co-efficient, which is always 1, otherwise it is made 1 by the filter
normalizes its co-efficient to 1. If ‘a’ is 0 then the filter function shows an error.

Wavread function:[y, Fs] = wavread( filename ) loads a WAVE file specified by ‘Filename’, returning
the sampled datain y.

Wavwrite function:wavwrite(y,filename) writes the data stored in the variable y to a WAVE file called
filename. The filename input is a string enclosed in single quotes. The data has a sample rate of 8000
Hz and is assumed to be 16-bit.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 58
(b)AIM : To study applications of DSP in the field of sound processing and biomedical.

THEORY:

OBJECTIVE 3:

Sound Processing:

Digital signal processing (DSP) technology and its advancements have dramatically impacted our
modern society everywhere. Without DSP, we would not have digital/Internet audio or video; digital
recording; CD, DVD, and MP3 players; digital cameras; digital and cellular telephones; digital satellite
and TV; or wire and wireless networks. DSP’s application in field of sound and biomedical is discussed
below.

Rate conversion of sound files:

DSP can be useful in the field of sound processing. Various sound effects can be created using
MATLAB. MATLAB can read and write sound filles in the .wav format. In many areas of digital signal
processing (DSP) applications—such as communications, speech, and audio processing—rising or
lowering of a sampling rate is required. Speed of the audio signal can be altered with the help of
sampling rate. The speed of a sound signal is increased by downsampling and that reduced by
upsampling the signal.

Downsampling is the process of reducing the sampling rateofasignal. This is usually done to reduce
the data rate or the size of the data. The downsampling factor is usually an integer or a rational
fraction greater than unity. This factor multiplies the sampling time or, equivalently, divides the
sampling rate. For example, if an audio signal at 44,100 Hz is downsampled to 22,050 Hz ,the bit rate
is reduced in half, from 1,411,200 bit/s to 705,600 bit/s. The audio was therefore down sampled by a
factor of 2.
The following code illustrates the down sampling of an audio signal. Here, the speed of audio signal
increases.
%Downsampling ("speed up")
%clear all;
[x, Fs] = wavread('e.wav');
y = resample(x,1,2);
sound(y,Fs)
wavwrite(y,44100,'downsamp_ee.wav')

Upsampling is the process of increasing the sampling rateof a signal. It is just opposite to down
sampling. Here, the upsampling factor multiplies the sampling rate or, equivalently, divides the
sampling period. Thus speed of an audio signal can be reduced by increasing the sampling rate.
Upsampling is illustrated in the following MATLAB code.
% Upsampling ("slow down")
[x, Fs] = wavread('e.wav');
z = resample(x,2,1);
sound(z,44100)

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 59
wavwrite(z,44100,'upsamp.wav')

Filtering of sound files:

In sound processing, the audio signal has to be controlled for various frequency components
present. The frequency response of a sound system is corrected so that the frequency balance of the
music as heard through speakers, better matches the original performance picked up by a
microphone. This is done by use of low-cut(high pass) or high-cut(lowpass) filter.
A low-pass filter is an electronic filter that passes low-frequencysignals but attenuates (reduces the
amplitude of) signals with frequencies higher than the cutoff frequency. The following MATLAB code
is used to attenuate the high frequency components of the desired audio file. Here, a fourth order
low pass elliptic filter is designed with a normalized pass band edge frequency 0.15, 5 dB of ripple in
pass band and 80 dB of attenuation in the stop band.

% Lowpass filtering
N = 4;Rp = 5;Rs = 80;
Wn = .15;
[x, Fs] = wavread('e.wav');
[B,A] = ellip(N,Rp,Rs,Wn);
yl= filter(B,A,x);
sound(yl,44100)
wavwrite(yl,44100,'lpf.wav')

A high pass filter is just opposite to a low pass filter. A high pass filter, also called a low-cut filter, or
bass-cut filter when used in audio application, passes high frequency signals but attenuates signals
with lower frequency. For elimination of low frequency sounds the following code is demonstrated in
which a high pass fourth order elliptic filter is designed with a normalized pass band edge frequency
0.15, 5 dB of ripple in pass band and 80 dB of attenuation in the stop band.

% Highpass filtering
N = 4;Rp = 5;Rs = 80;
Wn = .15;
[x, Fs] = wavread('e.wav');
[B,A] = ellip(N,Rp,Rs,Wn,'high');
yh = filter(B,A,x);
sound(yh,44100)
wavwrite(yh,44100,'hpf.wav')

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 60
OBJECTIVE 4:

Generation of ECG signal (Use of DSP in Biomedical signal processing):

Medical instruments would be less efficient or unable to provide useful information for precise
diagnoses if there were no digital electrocardiography (ECG) analyzers or digital x-rays and medical
image systems.
Hum noise created by poor power supplies, transformers, or electromagnetic interference sourced by
a main power supply is characterized by a frequency of 50 Hz and its harmonics. If this noise
interferes with a desired audio or biomedical signal (e.g., in electrocardiography [ECG]), the desired
signal could be corrupted. The corrupted signal is useless without signal processing. It is sufficient to
eliminate the 50-Hz hum frequency with its second and third harmonics in most practical
applications.

% Generation of ECG signals.


clc;
clear all;
close all;
cycle=zeros(1,500);
y=[01 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0]/4; % Triangle pulse segment
t=[0:1:40]; % Local time axis
a=(.05*(t-20).*(t-20)-20)/50; % Parabolic recovery segment
cycle(1:61)=2*[y a]; % Place pulse in 1sec. cycle
cyc=filter([1 1 1 1 1], [1], cycle); % Smooth the corners
x=[cyc cyc cyc cyc cyc]; % Repetition used for 5 cycle of trace
[idum, nsize]=size(x);
t=[0:1:nsize-1]/500; % Sampling frequency 500Hz
plot(t,x);
xlabel('Time(sec)');
ylabel('Amplitude');
title('ECG signal');

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 61
The ECG signals interfered by some noise signals, can be generated using MATLAB. The ‘randn’
function of MATLAB can be used to add noise to the signal .the following code demonstrates the
same.

% Generation of Noisy ECG signals.


clc;
clear;
close;
cycle=zeros(1,500);
y=[01 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0]/4; %Triangle pulse segment
t=[0:1:40]; % Local time axis
a=(.05*(t-20).*(t-20)-20)/50; % Parabolic recovery segment
cycle(1:61)=2*[y a]; % Place pulse in 1sec. cycle
cyc=filter([1 1 1 1 1], [1], cycle) + randn(1,length(cycle));% Smooth the corners
x=[cyccyccyccyccyc]; % Repetitio n used for 5 cycle of trace
[idum, nsize]=size(x);
t=[0:1:nsize-1]/500; % Sampling frequency 500Hz
plot(t,x);
xlabel('Time(sec)');
ylabel('Amplitude');

OBJECTIVE 5: Musical Tone Generation

clc;

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 62
close;
clear;
frequency=[240 254 302 320 358.5 380 451 470]; // Corresponding Frequency
fs=8000; // Sampling Frequency
no=8;
N=1:4000; // Total No. of Samples for Each tone

temp=[];
for i=1:no
y=sin(2*3.14*(frequency(i)/fs)*N);
temp=[temp y];
end
length(temp);
sound(temp,fs);

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 63
LAB 8
INTRODUCTION TO CCSTUDIO

AIM: Introduction to CCStudio and study of TI6x architecture through CCS help.
a. To create a simple project using C file.
b. Perform simulator feature: viewing memory and graph.
c. To study TI6x CPU architecture through help.

PROGRAM STATEMENT:
a. Write a program to display a message “Welcome to the world of TI6x” using .c program.
b. Add .asm file, which contains a table with 10 values to generate a sine wave.

REQUIREMENTS:
CCStudio for 6x

METHOD: A. To create a simple project using .C file.


i. Set up CCS for simulator C67xx CPU
ii. Open CCS
iii. Create a project: Choose project  new  Type the project name say exp1; location to be
…\ti6x\myprojects; project type .out; target 67xx
iv. Create a .c source file: Using a CCS editor, choose, file  new  source file write a simple .C
program to print a message “Welcome to learning TI6x.”
v. Create a .cmd command file: These are basically a system command files which informs the
CCS about memory configuration i.e. the defined segments in a project have to be loaded into which
part of the memory, whether internal, external, serial etc.
vi. Adding files to the project: We need to combine the created files as a project. For that choose
project  add files to the project  select the files to be added lab1a.c and
..ti6x\tutorials\hello1\hello.cmd. We also need to add a library file from
…\ti6x\C6000\cgtools\lib\rts6700.lib
vii. Building project: Building is compiling + linking, which creates executable .out file. Only
compiling or linking options are also available. Choose project  build . Before building a project we
can set proper building options for linker, compiler and optimization level. Here, .c file is converted
into the equivalent machine code for 67x processor (as simulator is selected. If DSK is selected
machine code for that). Higher level to lower level conversion requires optimization.
viii. Loading the program: Now we can load the program into the DSP memory choosing file 
load program options.
ix. Running a file: Select Debug  run to run the program and see the result on stdout window.
B. To add .asm file to a project.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 64
x. create a new .asm file which contains a data to display a sine wave. As we are not to call this
.asm file in the main program, it should be a data file.
xi. Add this file to the project.
xii. Make a change in the .cmd file. The data is defined in the ‘mydata ’ section (a user defined
name). So, we need to declare in the .cmd file that this section should be written in SDRAM area.
xiii. Build and load the project as before. If there is error in each line, upon building, the
reason may be an assembly code requires that all of the lines in the file not start from the first
column. Verify this and modify accordingly. By double clicking on the error message will open the file
and point the cursor at the line where the error is.
xiv. Run it. The output is displayed.

C. To view data in memory and through graph.


xv. Select view  memory
Select the memory location. In our case it is 0x80000000
Format : 16-bit signed int
A memory window appears where the results can be obtained.
xvi. Select view  graph  time/frequency
Start address: 0x80000000
Acquisition buffer size: 10
Display data size: 10
DSP data size: 16-bit signed integer A graph will appear on the screen with a plot of value v/s

D. To study TI6x CPU architecture through help.


Get help on the following CPU architectural features.
i. CPU registers
ii. Data cross path
iii. Addressing modes
iv. MV instruction
v. Address bus and data bus

Sample Program 1:

Create a project and Write a program in CCS to print “Hello”


#include<stdio.h>
main()
{
printf("Hello");
}
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 65
OUTPUT:
Hello

Sample Program 2:
Create a project and Write a program in CCS to print Factorial.

#include<stdio.h>
int main()
{
int n,fac,i;
printf("enter n:");
scanf("%d",&n);
fac=1;
for(i=n;i>1;i--)
{
fac=fac*n;
n--;
}
printf("%d",fac);
return 0;
}

Output:
enter n: 4
24

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 66
LAB 9
Assembly Program in CCS

AIM: Add assembly file to project through CCS.


a. To add assembly file to a project.
b. Write a program to display a message “Welcome to the world of TI6x” using .c
program.
c. Add .asm file, which contains a table with 10 values to generate a sine wave.

REQUIREMENTS:
CCStudio for 6x

METHOD:
A. To add .asm file to a project.
i. create a new .asm file which contains a data to display a sine wave. As we
are not to call this .asm file in the main program, it should be a data file.
ii. Add this file to the project.
iii. Make a change in the .cmd file. The data is defined in the ‘mydata ’ section
(a user defined name). So, we need to declare in the .cmd file that this
section should be written in SDRAM area.
iv. Build and load the project as before. If there is error in each line, upon
building, the reason may be an assembly code requires that all of the lines
in the file not start from the first column. Verify this and modify
accordingly. By double clicking on the error message will open the file and
point the cursor at the line where the error is.
v. Run it. The output is displayed.

Sample Program:

1..Create a project and Write a program in CCS to display full sinewave.

#include<stdio.h>
#include<math.h>
main()
{
int t,i;
float n,*p=(float *)0x80000000,*w=(float *)0x90000000;
float f=50;
for(t=0;t<=360;t++)
{
n=sin(2*3.14*f*(float)t);
*p=n;
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 67
if(n>0)
*w=*(p);
else
*w=-n;
w++;
p++;
}
printf("values stored from memory is as below \n");
for (i=0;i<=360;i++)
{
printf("%f\t",*(w+i-360));
}
printf("end");
}

OUTPUT:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 68
2.Create a project and Write a program in CCS to display half wave sinewave.

#include<stdio.h>
#include<math.h>
main()
{
int t,i;
float n,*p=(float *)0x80000000,*w=(float *)0x90000000;
float f=50;
for(t=0;t<=360;t++)
{
n=sin(2*3.14*f*(float)t);
*p=n;
if(n>0)
*w=*(p);
else
*w=0;
w++;
p++;
}
printf("values stored from memory is as below \n");
for (i=0;i<=360;i++)
{
printf("%f\t",*(w+i-360));
}
printf("end");
}

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 69
OUTPUT:

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 70
LAB 10
Programming Techniques in CCS
AIM: To Perform different programming techniques.
i. C calling assembly function
ii. C calling linear assembly function.
PROGRAM STATEMENT:
a. Write a .C program, calling .asm function to multiply two arrays.
b. Write a .C program to Find Factorial of entered No. using C calling ASM
function(assembly
REQUIREMENTS:
CCStudio for 6x
THEORY about PROGRAMMING TI 6713:

Options: To program TI 6713 there are so many alternative options


1. Only C/C++: CCS project can have only .c source file
2. Assembly: CCS project can have only .asm source file
3. Linear Assembly: CCS project can have only .sa linear assembly source file
4. Mixed: CCS project can have .c calling .asm ; .c calling .sa; .asm calling
.asm
1. Programming through .c –
Usual .c syntax
Program written using higher level is converted into an assembly level program. Over the last
couple of years, C compiler optimizer has become more and more efficient. Although C code is less
efficient (speed performance) than assembly level program, it typically involves less coding effort
than assembly code which can be hand optimized to achieve a 100 percent efficiency but with much
better coding effort.

2. Assembly Level Programming:

A. Instructions: The format of the assembly code line is:


lable parallel bar [condition] instruction unit operands ;comments An assembly
must contain only the label in the first column. So other than labels, directives or mnemonics can
not start from the first column.
B. Assembler directives:
The smallest unit of the object file is called section.
A section is a block of code or data that occupies space in the memory map with other
sections.
There are two basic types of sections.
Initialized sections: They contain code or data. E.g. .text, .data, .sect
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 71
Uninitialized sections: They reserve space in the memory map for uninitialized data. It is a
place for creating and storing variables during execution. E.g. .bss, .usect
Object files always contain three default sections: .text, .data, .bss
.text – To declare the following section as program
.data – To declare the following section as data
.sect “name” – defines a section of code or data named ‘name’ and associates subsequent code or
data with that section. Ex. ‘mydata’
.bss symbol, size in bytes – reserves space for uninitialized variables
.
Other directives are:
Directive that reference or define files
.def ; .ref; .global

Directives that initialize constants (data and memory)


.byte; .short; .float, .int , .double

Directives that define symbols at assembly time


.equ; .set

3. Linear Assembly Programming:

A. General Programming:
In linear assembly programming, syntax of assembly code instructions: ADD, SUB is utilized. But the
operands operands are written as in C. Variables are used to designate the registers. Say,
MPY a, b, prod
ADD prod, sum, sum
Parallel instructions are not valid in a linear assembly program.
Specifying the functional unit, register or NOPs is optional.

B. An alternative to .c or .asm is linear assembly .sa program. An assembler optimizer is used with
linear assembly program to create a .asm program, in much the same way as C compiler is used with
.c to .asm conversion. The assembler optimizer gives better performance than the c compiler
optimizer.
In short, linear assembly code programming provides a compromise between a coding effort and
coding efficiency.
C. Assembler Directives:
.cproc and .endproc:
.cproc is the directive to declare the following section of code as C callable linear assembly function.
It is used always with .endproc, which indicates end of the linear assembly function.
Syntex: label ,cproc a, b, prod

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 72
Where, the label is a name of the procedure and a, b, prod are the variables being passed. All
the input and output parameters being passed must be written after .cproc as we pass parameter to a
C functions.

.proc and .endproc:


They are used to define a general procedure start and end.
The .cproc directive differs from the .proc directive in that the compiler treats the .cproc region as a
C/C++ callable function. The assembly optimizer performs some operations automatically in a .cproc
region in order to make the function conform to the C/C++ calling conventions and to C/C++ register
usage conventions.

.return – This directive is used to return result of calling function.

.reg - The .reg directive allows you to use descriptive names for values that are stored in
registers. The assembly optimizer chooses a register for you such that its use agrees with the
functional units chosen for the instructions that operate on the value.
.reg ahi:alo
ADD a0,ahi:alo,ahi:alo
.def – defines a function

4. Mixed programming mode:

The mixed programming mode is possible where c program can call assembly or linear
assembly functions or assembly program calls an assembly level procedure.

C calling assembly:

Declaration and call reference:


In the c program, calling an assembly function syntax is same as we are calling a c function.

An external declaration of an assembly function called within a c program using extern directive is
optional. Say, extern short dotp_assem_func()
:
:
result = dotp_assem_func(ap, bp);
The function name should be defined in .asm using .def directive and the function name should be
preceded by an undescore, which indicates that this is a c callable .asm function. I.e.
.def _dotp_assem_func
The name of the *.c file should not be same as the *.asm file.

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 73
Parameter passing:
The parameters passed through the C program are in terms of variables.
These parameters are available as input parameters to an assembly level procedure through registers
A4, B4, A6, B6, A8,… sequentially.
Same way, the output parameter is always through A4. (Only one retur parameter as per C notation.)
The return address has to be passed through B3.
C calling linear assembly:
Enough has been discussed before
Assembly calling assembly:
The calling assembly program has to be defined as init and correspondingly the first assembly code
line should be given a label init.
Other declaration and parameter passing is in the same way.

System Initialization:
After reset from where the processor should start the execution that has to be informed. Processor
executes an interrupt service routine (ISR) for reset interrupt, where we can write a code to branch
(jump) to the our required program.

If there is a .c program in our project, before we can run a C/C++ program, other than this
initialization, we must create the C/C++ run-time environment. The C/C++ boot routine performs this
task using a function called c_int00. The run-time-support source library, rts.src, contains the source
to this routine in a module called boot.c. That is why, if our project contains .c program then it is
compulsory to add to the project the run time support source library file.

If there is no .c program in our project, then to inform the processor to start the program execution
after reset from our defined init procedure, we have to add a vector.asm file to our project, which
basically is an reset interrupt service routine (ISR) to make a branch (jump) to the required location.

If there is no .c program in our project, before building the project, we must modify the linker option
(Project  Options) to select “No Autoinitializtion”. Otherwise, the warning “entry point symbol
_c_int00 undefined” is displayed on building this project with no main() function ion C.

PROGRAM:

Find Factorial of entered No. using C calling ASM function(assembly)

//Factorial.c Finds factorial of n. Calls function factfunc.asm

#include <stdio.h> //for print statement


extern short fact_func(short);
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 74
void main()
{
short n=5; //set value
int result; //result from asm function
scanf("%d",&n);
//if (n!=0)
result = fact_func(n); //call assembly function factfunc
//else result=1;
printf("no. = %d \n factorial = %d\n",n,result); //print result from asm function
}

OUTPUT WATCH WINDOW:

;FACT_FUNC.ASM Assembly function called from C to find factorial

.def _fact_func ;asm function called from C


_fact_func: MV A4,A1 ;setup loop count in A1
ZERO A4
ADD A4,1,A4

[A1] B LOOP
NOP 5
B B3
NOP 5
LOOP: MPY A4,A1,A4 ;accumulate in A4
NOP ;for 1 delay slot with MPY
SUB A1,1,A1 ;decrement for next multiply

[A1] B LOOP ;branch to LOOP if A1 # 0


NOP 5 ;five NOPs for delay slots
B B3 ;return to calling routine

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 75
NOP 5 ;five NOPs for delay slots
END
INPUT
INPUT VALUE: 5

OUTPUT
FACTORIAL= 120

CONCLUSION:

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 76
P A R T II

QUESTION PAPERS

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 77
DHARMSINH DESAI UNIVERSITY, NADIAD
FACULTY OF TECHNOLOGY
FIRST SESSIONAL
SUBJECT: (EC611) DIGITAL SIGNAL PROCESSING

Examination : B.TECH - Semester - VI Seat No. :


Date : 08/01/2013 Day : Tuesday
Time : 12:00 to 1:15 pm Max. Marks : 36
INSTRUCTIONS:
1. Figures to the right indicate maximum marks for that question.
2. The symbols used carry their usual meanings.
3. Assume suitable data, if required & mention them clearly.
4. Draw neat sketches wherever necessary.
5. Bold letter in sequence represents n=0 position of sequence.

Q.1 Do as directed. [6]


(a) Consider Analog Signals, x1(t) = 3cos(2π20t) and x2(t) = 3cos(2π70t). Find a sampling [2]
frequency so that 70Hz signal is an alias of the 20Hz signal. Prove your answer.
(b) State True/False with justification. “A discrete sinusoidal signal is always periodic.” [2]
(c) Why Digital Signal Processor can’t work at very high input frequency? [2]

Q.2 Answer the following. (Any three.) [12]


n
(a) x[n] = (0.4) (u[n+2] – u(n-3)). (i) Sketch signal y[n] = x[-n]. (ii) Find the Energy or Power [4]
whichever aplicable. (iii) Would answers of (ii) for x[n] and y[n] be same? Justify your
answer.
(b) Check for periodicity of following signals and compute the common period N if periodic. [4]
(i) x[n] = cos(5nπ/12) + cos(4nπ/9). (ii) x*n+ = cos(n/2) + cos(nπ/2).
(c) For the signal x[n]= 3rect(n/4), Sketch(i) x[n], (ii) x[n+2], (iii) x[-n-2] and(iv) x[-n+4]. [4]
(d) Sketch the signal x[n] = 2tri((n-4)/4) and its even and odd parts. [4]

Q.3 (i) z [2]


Find out z transform of  2n sin(20 n)u(n) u(n) 
if z 1
(ii) 1  z 1 [2]
Find out inverse z transform of H ( z )  , ROC z <0.5
1  z 1  0.5 z 2
(iii) Find out ZIR of y(n)-0.8y(n-1)=x(n) with y(-1)=-5 [2]

Q.4 (a) The difference equation of a discrete time system is given by y(n)-3y(n-1)-4y(n-2) = x(n) + [5]
2x(n-1). Find out impulse response of the system.

(b)
 
Find out inverse z transform of log 1  az 1 , z > a [2]

(c) State and prove time reversal property of z transform. Using the property find out z [3]
transform of u(-n).
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 78
(d) Find out the ZSR of (i) y(n)-0.8y(n-1)=2 and (ii) y(n)-0.8y(n-1)=0.5 [2]
OR
Q.4 (a) Discuss echo and reverb filters briefly. Design an echo filter to generate echo at 60% [4]
attenuation as compared to original sample and after 1 sec. Assume speech sampling rate of
8KHz.
(b) Classify following on the basis of linearity, causality and time invariance. [3]
i. y(n)=x(-n)+2,
ii. y(n)=x(n)cosnwo
(c) What is the significance of ROC in z transform? [2]
(d) Determine z transform of x  n   (0.5) u(n)  (2) u(n  1)
n n [3]

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 79
DHARMSINH DESAI UNIVERSITY, NADIAD
FACULTY OF TECHNOLOGY
SECOND SESSIONAL
SUBJECT: (EC611) DIGITAL SIGNAL PROCESSING
Examination : B.TECH - Semester - VI Seat No. :
Date : 12/02/2013 Day : Tuesday
Time : 11:30 to 12:45 Max. Marks : 36

INSTRUCTIONS:
1. Figures to the right indicate maximum marks for that question.
2. The symbols used carry their usual meanings.
3. Assume suitable data, if required & mention them clearly.
4. Draw neat sketches wherever necessary.
5. Bold letter in sequence represents n=0 position of sequence.

Q.1 Do as directed.
(a) Following is desired frequency response for design of FIR filter. Derive the expression of [2]
impulse response for the same using Fourier series method.
Hd(ejΩ)

e-j3Ω
(b) What are the advantages of FIR filters? Why? [2]
(c) [2]
Given x[n]= {0,2,4,6} and h[n] = {6,4,2,0}. Find Periodic Convolution.

Q.2 (a) Consider a 2-point averaging filter whose present output equals the average of the present [5]
and previous input. (i) Set up a difference equation for this system. (ii) Give impulse response
for the system.
(iii) Given output of the system is

y[n]={1/2,3/2,5/2,7/2,9/2,5/2}, find the input sequence using de-convolution.


(b) Design a linear phase FIR Bandstop filter to reject frequencies in the range 0.4π to 0.65π [7]
rad/sample using rectangular window, by taking 7 samples of window sequence. Draw
practical magnitude response of the filter.
OR
Q.2 (a) Design a linear phase FIR Lowpass filter having cutoff frequency 0.65π rad/sample using [7]
rectangular window, by taking 7 samples of window sequence. Draw practical magnitude
response of the filter.
(b) Let x[n] = tri[(n-4)/2] and h[n] = tri[n/4]. [5]
(i) Find the autocorrelation rxx[n] and rhh[n]. (ii) Find the cross-correlation rxh[n].

Q.3 (I) x[n] is IDFT of X[K] = [4 3 2 1]. Sketch the magnitude spectrum against analog frequency if x(n) [2]
Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 80
is sampled at 8KHz for 0.5ms. Find DC value and highest frequency in x(n).
(II) Compute N points DFT of following sequences: [2]
a. x*n+ = δ(n-n0 ) and b. y[n] = 2, for even N
(III) Let the Z transform of sequence h[n] be given by . Find inverse z [2]

transform assuming system stable.

Q.4 Attempt Following.(Any two) [12]


(a) 1 Sketch transposed realization for following filter. [6]
y[n]-3y[n-2]=3x[n]+4x[n-1]+2x[n-3].
Represent the system in form of transfer function and impulse response.
2. Compute the DFT of the four point sequence x(n)=(1,0,2,3) using twiddle factor matrix.
(b) Prove that circular convolution in time domain is equivalent to multiplication of two DFTs [6]
using following time domain discrete time sequences.
x1[n] = δ (n)+ δ (n-2)+ 2δ (n-3) and x2[n]= 2δ(n) + δ(n-1) + 2 δ(n-2)+ δ(n-3)
(c) 1. If x(n)=,1, 2, 0, 4-↔ X(k)=,7, 1+2j, -5 1-2j } are DFT pair [6]
Find DFT of

i. {0, 4, 1, 2}
ii. x(-n)
2. Discuss All pass filters. How do you apply it to convert non minimum phase system to
minimum phase system?

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 81
DHARMSINH DESAI UNIVERSITY, NADIAD
FACULTY OF TECHNOLOGY
THIRD SESSIONAL
SUBJECT: (EC611) DIGITAL SIGNAL PROCESSING
Examination : B.TECH. - Semester - VI Seat No. :
Date : 06/04/2013 Day : Monday
Time : Max. Marks : 36

INSTRUCTIONS:
1. Figures to the right indicate maximum marks for that question.
2. The symbols used carry their usual meanings.
3. Assume suitable data, if required & mention them clearly.
4. Draw neat sketches wherever necessary.
5. Bold letter in sequence represents n=0 position of sequence.

Q.1 Do as directed.
(a) For a band stop filter having edge frequencies of [20,26,36,40] .Find normalized prototype [2]
Frequencies and expression for frequency transformation.
(b) If a signal g[n] has energy E, then the signal g[n/5] has energy of _______. Justify your [2]
answer.
(c) If a signal is given by x[n]. Find its energy. [2]

Q.2 (a) Design a Butterworth bandstop filter with a 2-db passband edges of 30 Hz of 100Hz, and [6]
40dB stopband edges of 50Hz and 70Hz.
(b) What is the use of window in filter design? Design a Lowpass FIR filter with a cutoff [6]
frequency of 5kHz and a sampling frequency of 20kHz using Hann window with N = 7.
OR
Q.2 (a) Design a fourth order Butterworth Bandpass filter with a 2-dB passband of 200Hz and a [6]
centre frequency of f0 = 1KHz.
(b) 1. Check the periodicity of the following signals and find the periods. [3]
(1) x[n] = 5sin(nπ/8 + π/4) – 5cos(nπ/8 – π/4). (2) h[n] = (0.9)n ejnπ/10.
2. Compare IIR and FIR filters. [3]

Q.3 (I) Find transfer function and impulse response of y[n]-0.4y[n-1]=2x[n]. [2]
(II) The first five points of the 8 point DFT of a real valued sequence are X(k)={0.25,0.125- [2]
j0.3,0,0.12-j0.05,0}.Determine the remaining three points. Find X(15) and X(25)
(III) Write difference between Von Neumann architecture and Harvard architecture. [2]

Q.4 Answer the following. (Any two) [12]


(a) Let H(z) = Z-2 (Z-0.5)(2Z+4)(1- Z-2). [6]
1. Find inverse transform h[n]
2. Does h[n] show symmetry about origin?
3. Does h(n) describe a linear phase system?

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 82
(b) i. Find whether the following systems are LTI system or not? [6]
1. y[n]= mx[n] +c
2. y[n]=x[-n+1]
ii. Discuss Decimation in Frequency FFT algorithm.
(c) 1. X(z) is a Z transform of x[n] = 2nu(n), Use necessary z transform properties to find signal [6]
Y(z) = X(1/z) and Q(z) = X(2z)
2. If X[k] is sampled version of spectrum of x[n], Show that x[n] is reconstructed from the
X[k].

Department of Electronics & Communication, Faculty of Technology, Dharmsinh Desai University, Nadiad 83

You might also like