Escolar Documentos
Profissional Documentos
Cultura Documentos
M
SE
DEPARTMENT OF ELECTRONICS & COMMUNICATION
ENGINEERING
KS
E,
EC
Prepared By
Mr. Ravikiran B. A., Asst. Professor
Mrs. Vidhya R., Asst. Professor
Table of Contents
M
PART – A
SE
2 Impulse response of a given system 4
KS
4 Circular convolution of two given sequences 11
Autocorrelation of a given sequence and verification of its
5 15
properties.
Cross-correlation of given sequences and verification of
6 18
its properties.
E,
7 Solving a given difference equation. 21
Computation of N point DFT of a given sequence and to
EC
8 23
plot magnitude and phase spectrum.
Linear convolution of two sequences using DFT and
9 26
IDFT.
Circular convolution of two given sequences using DFT
10 29
of
and IDFT
Design and implementation of FIR filter to meet given
11 32
specifications.
pt
M
About the DSP Trainer Kit 44
Using Code Composer Studio 47
SE
1 Linear convolution of two given sequences. 56
2 Circular convolution of two given sequences 58
KS
3 Computation of N point DFT of a given sequence. 60
Viva Questions 64
E,
EC
of
pt
De
DSP Laboratory (10ECL57) 5th Sem KSSEM, Bangalore
PROGRAM 1
M
Generate a sinusoidal wave of 1kHz. Calculate the Nyquist frequency, and verify
Sampling Theorem, showing output waveforms for undersampled, oversampled and right
SE
sampled cases.
Theory:
Sampling is the process of converting an continuous time signal into a discrete time signal.
KS
In sampling, the values of the continuous time signal is recorded at discrete intervals of time
(usually equidistant). The number of samples taken during one second is called the sampling
rate.
Where ( ) is the discrete-time signal obtained by sampling the analog signal every T
E,
seconds. = 1/ is known as the Sampling Frequency.
Now, assuming the sampling frequency is more than the Nyquist Frequency, the
pt
continuous time signal can be reconstructed accurately using the interpolation function:
sin 2
( )=
2
De
( )= −
Whenever the Sampling frequency is greater than or equal to the Nyquist Frequency, the
signal can be reconstructed faithfully, capturing all the essential properties of the original
continuous-time signal. However, when < 2 , we encounter a problem called “Aliasing”,
where distortion is caused by high frequencies overlapping low frequencies. A lot of data is
lost in this process and the signal cannot be recovered.
M
MATLAB CODE:
SE
% Experiment 1 : Sampling Theorem Verification
% Signal Parameters
f1 = 1000; % Signal 1 Frequency = 1kHz
KS
f2 = 1900; % Signal 2 Frequency = 1.4 kHz
fmax = max(f1,f2); % Maximum frequency component of signal
T = 1/min(f1,f2); % Signal Period should cover entire length
t = 0:0.01*T:2*T; % Time index
% Oversampling Condition:
fs1 = 10*fmax; % Oversampling (fs > 2f)
n2 = 0:1/fs2:2*T;
x2 = cos(2*pi*f1*n2)+cos(2*pi*f2*n2);
subplot(2,2,3);
De
stem(n2,x2);
hold on;
plot(n2,x2,'r'); grid on;
hold off;
title('Sampling at Nyquist Frequency : Fs = 2F');
xlabel('n');
ylabel('x(n)');
n3 = 0:1/fs3:2*T;
x3 = cos(2*pi*f1*n3)+cos(2*pi*f2*n3);
subplot(2,2,4);
M
stem(n3,x3);
hold on;
plot(n3,x3,'r'); grid on;
hold off;
SE
title('Undersampling Condition : Fs = 1.2 f');
xlabel('n');
ylabel('x(n)');
OUTPUT:
KS
E,
EC
of
pt
De
PROGRAM 2
Aim: To write the MATLAB code to find the impulse response of a given second-order
M
system whose difference equation representation is given.
SE
Theory:
Impulse response of a system is defined as the output of a given system, when the input
applied to the system, is in the form of a unit impulse, or a Dirac delta function. The impulse
KS
response completely characterizes the behaviour of any LTI system. The impulse response is
often determined from knowledge of the system configuration and dynamics, or can be
measured by applying and approximate impulse to the system input.
Discrete-time LTI systems can also be described using Difference Equations. A linear
constant-coefficient difference equation can be of the form:
E,
[ − ]= [ − ]
EC
Where the integer N is termed the order of the difference equation, and corresponds to the
maximum memory involving the system output. The order generally represents the number of
energy storage devices in a physical system.
We can calculate the impulse response of the system using Z-transforms as shown in the
following example:
Or:
( )[1 + 3 − 0.12 ] = ( )[1 + 0.2 − 1.5 ]
( ) [1 + 3 − 0.12 ]
( )= =
( ) [1 + 0.2 − 1.5 ]
M
By long division, we get:
SE
By taking Inverse-Z transform, we can obtain the Impulse Response as:
KS
MATLAB CODE:
% Experiment 2 : Impulse Response of a Given Second-Order System
[h,t] = impz(b,a,N);
OUTPUT:
pt
M
SE
KS
E,
EC
of
pt
De
PROGRAM 3
Aim: To write the MATLAB code to perform Linear Convolution upon two given discrete
M
time signals.
Theory:
SE
Convolution is the process used to find the response of a Linear Time Invariant system to a
given input, assuming we already know the impulse response of that system. In case of
continuous-time signals, we can find the system response using the Convolution Integral,
while in case of discrete-time systems, the response can be calculated using the Convolution
Sum.
KS
Let ( ) and ( ) be two discrete-time signals. The convolution sum of the two signals
can be calculated using the formula:
( ) = 1( ) ∗ 2( ) = 1( ) 2( − )
Assume two discrete-time sequences 1 and 2 in a Linear Time Invariant System, given
by:
pt
Using any of the above given methods, we see that the resultant convolved sequence can be
given by:
( ) = 1( ) ∗ 2( ) = { 2 7 2 − 1 11 − 6}
MATLAB CODE:
M
clear all; close all; clc;
SE
%Perform Linear Convolution using CONV command
y=conv(x1,x2);
KS
stem(x1);
title('Input Signal x1(n)');
xlabel('n'); ylabel('x1(n)');
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
E,
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
EC
n2=length(x2);
for n = 1:N
% y(n) = 0R;
for k = 1:n
y(n)=y(n)+x1(k)*x2(n-k+1);
end
end
M
% Plot Input and Output Sequences:
subplot(3,1,1);
stem(T,x1);
SE
title('Input Signal x1(n)');
xlabel('n'); ylabel('x1(n)');
subplot(3,1,2);
stem(T,x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
KS
subplot(3,1,3);
stem(T,y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
OUTPUT:
M
SE
KS
E,
EC
of
pt
De
PROGRAM 4
Aim: To write the MATLAB code to perform Circular Convolution upon two given discrete
M
time signals.
Theory:
SE
The Circular convolution, also known as cyclic convolution, of two aperiodic functions occurs
when one of them is convolved in the normal way with a periodic summation of the other
function. Circular convolution is only defined for finite length functions (usually equal in
length), continuous or discrete in time. In circular convolution, it is as if the finite length
functions repeat in time, periodically. Because the input functions are now periodic, the
KS
convolved output is also periodic.
Circular convolution sum can be calculated using the formula:
( ) = 1( ) ∗ 2( ) = 1( ) 2 ( − )
= 0,1, … . , −1
E,
For
1. Using the expression for linear convolution sum, but assuming the signal repeats
periodically. This can be done by changing the negative indices of (n-k) to repetitions
of the latter portions of the original aperiodic signal.
2. Convolution in time domain corresponds to multiplication in frequency domain. To
make use of this property, we can calculate the DTFT of each of the aperiodic signals,
multiply these in the frequency domain, and find the IDFT of the product, to get the
periodic convolved signal in time domain.
of
Let us take the case of two discrete-time aperiodic signals given by:
1( ) = {2,1,2,1} and 2( ) = {1,2,3,4}
Using the formula with N = 4.
pt
For m = 0:
(0) = 1( ) 2 (− ) = 14
De
For m = 1:
(1) = 1( ) 2 (1 − ) = 16
For m = 2:
(2) = 1( ) 2 (2 − ) = 14
For m = 3:
M
(3) = 1( ) 2 (3 − ) = 16
SE
So, we get the circular convolution sum as: ( ) = {14,16,14,16}
MATLAB CODE:
KS
%% Circular Convolution using Formula
end
y(m)=y(m)+x1(n)*x2(i); %Convolution Sum Formula
end
end
De
subplot(3,1,2);
stem(T,x2);
subplot(3,1,3);
stem(T,y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
M
xlabel('n'); ylabel('y(n)');
SE
disp(y);
KS
% Accept input signal sequences
x1 = input('Enter Input Sequence for Signal x1(n): ');
x2 = input('Enter Input Sequence for Signal x2(n): ');
n=max(length(x1),length(x2));
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
subplot(3,1,3);
stem(y);
of
OUTPUT:
Convolved sequence:
14 16 14 16
M
SE
KS
E,
EC
of
pt
De
PROGRAM 5
Aim: To write the MATLAB code to perform Autocorrelation on a given signal and to verify
M
its properties.
Theory:
SE
In signal processing, Correlation is a measure of similarity of two waveforms, as a function
of a time-lag applied to one of them. This is also known as a sliding dot product or sliding
inner-product. It is commonly used for searching a long-signal for a shorter, known feature.
KS
itself. It is a mathematical tool for finding repeating patterns, such as the presence of a
periodic signal which has been buried under noise, or identifying the missing fundamental
frequency in a signal implied by its harmonic frequencies. It is often used in signal processing
for analyzing functions or series of values, such as time domain signals.
| |
( )= ( ) ( − )
[ ( )+ ( − )] = ( )+ ( − )+ 2 ( ) ( − )
= (0)+ (0) + 2 () ≥ 0
pt
That is, autocorrelation sequence of a signal attains its maximum value at zero lag. This is
consistent with the notion that a signal matches perfectly with itself at zero shift.
( ) = {4,11,20,30, 20,11,4}
= ( ) = 1 + 2 + 3 + 4 = 30 = (0)
M
Hence, it is an energy signal.
We see that the Total energy of the signal is equal to the amplitude of the autocorrelation
SE
signal at the origin.
MATLAB CODE:
% Experiment 5 : Autocorrelation of a Signal.
KS
% Accept user-defined input sequence and define time index
x = input('Enter a finite-length signal sequence : ');
n = 0:length(x)-1;
subplot(2,1,1);
stem(n,x);
title('Input Signal');
xlabel('n'); ylabel('x(n)');
subplot(2,1,2);
stem(n2,rxx);
title('Autocorrelation Sequence');
xlabel('n'); ylabel('rxx(l)');
of
grid on;
midpoint
fprintf('Energy of Input Signal : %d\n',E);
fprintf('Amplitude of Midpoint of Autocorrelation Sequence :
%d\n',E0);
De
if rxx_r == rxx_l
disp('Autocorrelation Sequence is Even. Hence, verified.');
else
disp('Autocorrelation Sequence is not Even. Hence, not
M
verified.');
end
SE
OUTPUT:
Enter a finite-length signal sequence : [1 2 3 4]
Autocorrelation Sequence :
KS
4 11 20 30 20 11 4
PROGRAM 6
Aim: To write the MATLAB code to perform cross-correlation on a given signal and to verify
M
its properties.
Theory:
SE
Cross-correlation is a process, in which a signal is convolved with another signal. It is
commonly used for searching a long-signal for a shorter, known feature. It also has
applications in pattern recognition, single particle analysis, electron tomographic averaging,
cryptanalysis, and neurophysiology. Cross-correlation of two signals 1( ) and 2( ) is
KS
given by the formula:
()= ( ) ( − )
[ ( )+ ( − )] = ( )+ ( − )+ 2 ( ) ( − )
of
= (0)+ (0) + 2 () ≥ 0
Note that the shape of the autocorrelation sequence does not change with amplitude scaling
of input signals. Only the amplitude of the autocorrelation sequence changes accordingly.
()= (− )
MATLAB CODE:
% Experiment 6 : Cross-correlation of two Signals.
M
% Accept user-defined input sequences and define time index for it
x1 = input('Enter a finite-length signal sequence X1(n): ');
n1 = 0:length(x1)-1;
x2 = input('Enter a finite-length signal sequence X2(n): ');
SE
n2 = 0:length(x2)-1;
x= max(x1,x2);
% Perform Cross - Correlation using xcorr function.
rxy = xcorr(x1,x2); % rxy(l)
ryx = xcorr(x2,x1); % ryx(l)
% Generate Time Index for Cross - Correlation sequence, about origin
n3 = -length(x)+1:length(x)-1;
KS
disp('Cross - Correlation Sequence rxy(l): ');
disp(int8(rxy));
disp('Cross - Correlation Sequence ryx(l): ');
disp(int8(ryx));
subplot(3,1,2);
EC
stem(n2,x2);
title('Input Signal 2');
xlabel('n'); ylabel('x2(n)');
subplot(3,1,3);
stem(n3,rxy);
title('Cross - Correlation Sequence');
xlabel('n'); ylabel('rxy(l)');
grid on;
of
M
disp('Cross - Correlation property is not verified.');
end
SE
OUTPUT:
KS
16 24 25 20 10 4 1
Cross - Correlation Sequence ryx(l):
1 4 10 20 25 24 16
Energy of Input Signal X1 : 30
Energy of Input Signal X2 : 30
Max Amplitude of Cross - Correlation Sequence : 25
Cross - Correlation Energy Property is verified
E,
Since rxy(l) = ryx(-l), Cross - Correlation property is verified.
EC
of
pt
De
PROGRAM 7
Aim: To write the MATLAB code to solve a given difference equation, given the co-efficients
M
and initial values.
Let us consider the difference equation as y (n) – 3/2 y (n-1) + ½ y (n-2) = x (n). Given
x(n) = (1/4)n *u(n). Assume initial conditions as y(-1) = 4, y(-2) = 10.
SE
Theory:
KS
Let n take values from 0 to 5,
n=0:5
n=0, x(0)=1
n=1, x(1)=0.25
n=2, x(2)=0.0625
n=3, x(3)=0.0156
n=4, x(4)=0.0039
n=5, x(5)=0.0010
E,
For n=0;
y(0) - 3/2 y(0-1) + 1/2 y(0-2) = x(0)
Substituting the initial conditions and the value of x(0) in the above equation we get,
EC
y(0) = 1 + 6 - 5 = 2
Similarly,
MATLAB CODE:
M
%Plot Input and Output
subplot(2,1,1);
stem(n,x);
SE
title('Input Sequence x(n)');
xlabel('n'); ylabel('x(n)');
subplot(2,1,2);
stem(n,Yout);
grid on;
title('Output Sequence y(n)');
KS
xlabel('n'); ylabel('y(n)');
OUTPUT:
PROGRAM 8
Aim: Computation of N point DFT of a given sequence and to plot magnitude and phase
M
spectrum.
Theory:
SE
DFT stands for Discrete Fourier Transform. It is used to find the amplitude and phase
spectrum of a discrete time sequence.
KS
x(n) X(k)
( )= ( )
E,
For example: Find the DFT of the sequence x(n) = {0,1,2,3}
For k=0,
For k=1,
.
(1) = ( ) = (1) + (1) + (2) + (3)
of
= - j- 2 + 3j = -2 + j2
Similarly,
For k=2,
pt
( ) .
(2) = = (1) + (1) + (2) + (3)
= 0-1+2-3 = -2
De
For k=3,
X(3) = -2 –j2
MATLAB CODE:
M
%Accept Input sequence from user
xn = input ('Enter the sequence x(n) : ');
xn=xn';
N = length(xn);
Xk = zeros(N, 1); %Initialize zero matrix for DFT sequence
SE
%Calculate DFT using formula
n = 0:N-1;
for k = 0:N-1
Xk(k+1) = exp(-j*2*pi*k*n/N)*xn;
end
KS
%Display DFT Sequence
disp('DSP Sequence : X(k) :');
disp(int8(Xk));
%Plot Signals
n = 0:N-1; %Time base
% Input Sequence
E,
subplot (2,2,[1:2]);
stem(n, xn);
title('Input Sequence x(n)');
xlabel('n');ylabel('x(n)');
EC
subplot(2,2,4);
stem(n, angle(Xk)');
grid on;
title('Phase Plot of DFT : angle(X(k))');
xlabel('n');ylabel('Angle');
OUTPUT:
pt
6.0000 + 0.0000i
-2.0000 + 2.0000i
-2.0000 - 0.0000i
-2.0000 - 2.0000i
M
SE
KS
E,
EC
of
pt
De
PROGRAM 9
M
Aim: To calculate the Linear Convolution of two sequences using DFT and IDFT
Theory:
SE
An interesting property of the Discrete Fourier Transforms, is the effect it has on
convolution. Convolution of two signals in the time domain translates to a multiplication of
their Fourier transforms in the frequency domain. In this procedure, we find the discrete
Fourier transforms of the individual signals, multiply them, and apply an Inverse Fourier
Transform upon the product, to get the convolved signal in the time domain.
KS
If x(n) and h(n) are the two sequences of length ‘l’ and ‘m’ respectively. then X(k) and
H(k) their DFT’s of length N=L+M-1.
Y(k)=x(k)h(k)
Therefore the linear convolution of two sequence is the N point IDFT of Y(k).
E,
Ex: Find the linear convolution of x(n)={1,2} and h(n)={1,2,3} using DFT and IDFT method.
h(n)={1,2,3}
here L = 2, M = 3
Y(k) = X(k)H(k)
( ) = { 18 , −6 + 2j , −2 , 6 − 2j }
y(n) = { 1 , 4 , 7 , 6 }
MATLAB CODE
M
%Accept input sequences
x1 = input('Enter Input Sequence for Signal x1(n): ');
n1 = length(x1);
SE
x2 = input('Enter Input Sequence for Signal x2(n): ');
n2=length(x2);
KS
y1=fft(x1,N); % N-point DFT of x1
y2=fft(x2,N); % N-point DFT of x2
y3=y1.*y2; % Multiplication in time domain
y=ifft(y3,N); % N-point IDFT of y to recover result
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
EC
xlabel('n'); ylabel('x2(n)');
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)');
disp('Convolved sequence:');
disp(y);
OUTPUT
pt
M
SE
KS
E,
EC
of
pt
De
PROGRAM 10
Aim: To calculate the Circular Convolution of two sequences using DFT and IDFT
M
Theory:
SE
Convolution in time domain corresponds to multiplication in frequency domain. To make use
of this property, we can calculate the DTFT of each of the aperiodic signals, multiply these in
the frequency domain, and find the IDFT of the product, to get the periodic convolved signal
in time domain.
Example: Find the circular convolution of x(n)={1,2,3,4} and h(n)={4,3,2} using DFT and
KS
IDFT method.
Y(k) = X(k)H(k)
y(n) = { 22 , 19 , 20 , 29 }
of
MATLAB CODE
n2=length(x2);
x1=[x1 zeros(1,N-n1)];
x2=[x2 zeros(1,N-n2)];
M
% Plot Input and Output Sequences:
subplot(3,1,1);
stem(x1);
title('Input Signal x1(n)');
SE
xlabel('n'); ylabel('x1(n)');
subplot(3,1,2);
stem(x2);
title('Input Signal x2(n)');
xlabel('n'); ylabel('x2(n)');
KS
subplot(3,1,3);
stem(y);
title('Convolved Signal y(n) = x1(n)*x2(n)');
xlabel('n'); ylabel('y(n)'); grid on;
Convolved sequence:
22 19 20 29
of
pt
De
M
SE
KS
E,
EC
of
pt
De
PROGRAM 11
Aim: To design and implement a FIR Filter for the given specifications.
M
Theory:
SE
A linear-phase is required throughout the passband of the filter to preserve the shape of the
given signal in the passband. A causal IIR filter cannot give linear-phase characteristics and
only special types of FIR filters that exhibit center symmetry in its impulse response give the
linear-space. An FIR filter with impulse response h(n) can be obtained as follows:
KS
h(n) = hd(n) 0≤n≤N-1
= 0 otherwise ……………….(a)
The impulse response hd(n) is truncated at n = 0, since we are interested in causal FIR Filter. It
is possible to write above equation alternatively as
h(n) = hd(n)w(n) ……………….(b)
where w(n) is said to be a rectangular window defined by
w(n) = 1 0≤n≤N-1
E,
= 0 otherwise
Taking DTFT on both the sides of equation(b), we get
H(ω) = Hd(ω)*W(ω)
EC
Hamming window:
Problem: Using MATLAB design an IIR filter to meet the following specifications choosing
Hamming window:
Window length, N = 27
pt
MATLAB CODE
M
% Accept Filter Parameters from User
N = input('Enter the window length N : ');
fc = input('Enter the cut-off frequency fc (Hz) : ');
SE
Fs = input('Enter the sampling frequency Fs (Hz) : ');
KS
b = fir1(N-1, Wc ,Wh);
% Display Values
E,
disp('Hamming Window Co-efficients : ');
disp(Wh);
disp('Unit Sample Response of FIR Filter h(n) : ');
disp(b);
EC
OUTPUT
0.0934
0.1327
0.1957
De
0.2787
0.3769
0.4846
0.5954
0.7031
0.8013
0.8843
0.9473
0.9866
1.0000
M
0.9866
0.9473
0.8843
SE
0.8013
0.7031
0.5954
0.4846
0.3769
KS
0.2787
0.1957
0.1327
0.0934
0.0800
Columns 8 through 14
-0.0185 0.0000 0.0374 0.0890 0.1429 0.1840 0.1994
Columns 15 through 21
0.1840 0.1429 0.0890 0.0374 0.0000 -0.0185 -0.0209
Columns 22 through 27
of
M
SE
KS
E,
EC
of
pt
De
PROGRAM 12
Aim: To design and implement a IIR Filter for the given specifications.
M
Theory:
SE
A desired frequency response is approximated by a transfer function expressed as a ratio of
polynomials. This type of transfer function yields an impulse response of infinite duration.
Therefore, the analog filters are commonly referred to as infinite impulse response (IIR)
filters.
KS
The main classes of analog filters are -
1.Butterworth Filter.
2.Chebyshev Filter.
These filters differ in the nature of their magnitude responses as well as in their design and
implementation.
BUTTERWORTH FILTERS:
E,
Butterworth filters have very smooth passband, which we pay for with a relatively wide
transition region. A Butterworth filter is characterized by its magnitude frequency response,
EC
where N is the order of the filter and Ωc is defined as the cutoff frequency where the filter
magnitude is 1/√2 times the dc gain (Ω=0)
of
pt
De
M
N=3; (s2 +s+1)(s+1)
N=4; (s2+0.76536s+1)(s2+1.864776s+2)
N=5; (s+1)( s2+0.6180s+1)( s2+1.6180s+1)
SE
CHEBYSHEV FILTERS:
Chebyshev filters are equiripple in either the passband or stopband. Hence the magnitude
response oscillates between the permitted minimum and maximum values in the band a
number of times depending upon the order of filters. There are two types of chebyshev filters.
KS
The chebyshev I filter is equiripple in passband and monotonic in the stopband, whereas
Chebyshev II is just the opposite.
Using MATLAB design an IIR filter with passband edge frequency 1500Hz and stop band
M
edge at 2000Hz for a sampling frequency of 8000Hz, variation of gain within pass band 1db
and stopband attenuation of 15 db. Use Butterworth prototype design and Bilinear
Transformation.
SE
MATLAB CODE :
KS
% Accept Input Parameters from user
Rp = input('Enter Passband Attenuation in dB : ');
Rs = input('Enter Stopband Attenuation in dB : ');
fp = input('Enter Passband Frequency in Hz : ');
fs = input('Enter Stopband Frequency in Hz : ');
Fs = input('Enter Sampling Frequency in Hz : ');
disp(Wn);
OUTPUT:
M
SE
KS
E,
EC
Using MATLAB design an IIR filter with passband edge frequency 1500Hz and stop band
edge at 2000Hz for a sampling frequency of 8000Hz, variation of gain within pass band 1 db
and stopband attenuation of 15 db. Use Chebyshev prototype design and Bilinear
Transformation.
of
DESIGN:
W1 = (2*pi* F1 )/ Fs = 2*pi*100)/4000 = 0.05Π rad
pt
Prewarp:
T=1sec
De
Order:
έ = 10 −1
M
έ = 0.765
A= 10-As/20 , A = 1020/20 , A=10
g= (A2 - 1) / έ , g = 13.01
SE
Ωr= Ω2 / Ω1 Ωr=0.828/0.157 = 5.27 rad\sec
n = log10 + ( − ) / log10{Ωr + √( – )}
n= 1.388
KS
Therefore n= 2.
Cut-off Frequency:
Ωc = Ωp = Ω1 = 0.157 rad\sec
Apply BLT:
of
H(Z) = H(s)|s=(2/T)[(1-z-1)/(1+z-1)]
MATLAB CODE:
M
% Accept Input Parameters from user
Rp = input('Enter Passband Attenuation in dB : ');
Rs = input('Enter Stopband Attenuation in dB : ');
fp = input('Enter Passband Frequency in Hz : ');
SE
fs = input('Enter Stopband Frequency in Hz : ');
Fs = input('Enter Sampling Frequency in Hz : ');
KS
% Calculate Chebyshev filter order and cutoff Frequency:
% N = Minimum order of Filter Wn = Cutoff Frequencies
[N,Wn]=cheb1ord(Wp,Ws,Rp,Rs);
OUTPUT:
0.3750
M
SE
KS
E,
EC
of
pt
De
M
SE
KS
PART B:
Exercises using the
E,
DSP Kit
EC
of
pt
De
TMS320C6748 DSP
BOARD
Package content:
M
SE
KS
E,
EC
coursesThe Experimenter Kit for Universities is a low-cost, flexible development platform for the
OMAP-L138 which is a low-power dual core processor based on C6748 DSP plus an ARM926EJ-S
32-bit RISC MPU.
The C6748 DSP kit has a TMS320C6748 DSP onboard that allows full-speed verification of
pt
code with Code Composer Studio. The C6748 DSP kit provides:
A USB Interface
128MB DDRAM and ROM
De
Connectors on the C6748 DSP kit provide DSP external memory interface (EMIF) and
peripheral signals that enable its functionality to be expanded with custom or third party daughter
boards.
The C6748 DSP kit includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
M
• Interfaces directly to digital or analog microphones
SE
• High SNR (100-102dB DAC, 92dB ADC)
KS
• Programmable digital audio effectsinclude 3D sound, bass, treble, EQ and de-emphasis
The 6748 DSP KIT kit is a low-cost standalone development platform that enables customers
EC
to evaluate and develop applications for the TI C67XX DSP family. The DSP KIT also serves
as a hardware reference design for the TMS320C6748 DSP. Schematics, logic equations and
application notes are available to ease hardware development and reduce time to market.
An on-board AIC3106 codec allows the DSP to transmit and receive analog signals.
McASP is used for the codec control interface and for data. Analog audio I/O is done through
two 3.5mm audio jacks that correspond to line input, and line. The analog output is driven to
of
the line out .McASP1 can be re-routed to the expansion connectors in software.
The DSP KIT includes 2 LEDs and 8 DIP switches as a simple way to provide the user with
interactive feedback.
An included 5V external power supply is used to power the board. On-board voltage
pt
regulators provide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A
voltage supervisor monitors the internally generated voltage, and will hold the board in reset
until the supplies are within operating specifications and the reset button is released.
De
Code Composer communicates with the DSP KIT through an embedded JTAG emulator with a
USB host interface. The DSP KIT can also be used with an external emulator through the
external JTAG connector.
M
Extended Temperature Devices Available
Advanced Very Long Instruction Word (VLIW) TMS320C67x™ DSP Core
Eight Independent Functional Units:
Two ALUs (Fixed-Point)
SE
Four ALUs (Floating- and Fixed-Point)
Two Multipliers (Floating- and Fixed-Point)
Load-Store Architecture With 64 32-Bit General-Purpose Registers
Instruction Packing Reduces Code Size
All Instructions Conditional
KS
Instruction Set Features
Native Instructions for IEEE 754
Single- and Double-Precision
Byte-Addressable (8-, 16-, 32-Bit Data)
8-Bit Overflow Protection
Saturation; Bit-Field Extract, Set, Clear; Bit-Counting; Normalization
67x cache memory.
32K-Byte L1P Program Cache (Direct-Mapped)
E,
32K-Byte L1D Data Cache (2-Way)
256K-Byte L2 unified Memory RAM\Cache.
Real-Time Clock With 32 KHz Oscillator and Separate Power Rail.
Three 64-Bit General-Purpose Timers
EC
M
1. Launch ccs
Launch the CCS v4 icon from the Desktop or goto All Programs ->Texas Instruments -
>CCSv4
SE
KS
2.
Choose the location for the workspace, where your project will be saved.
E,
EC
3.
Click the CCS icon from the welcome page to go the workbench, it is marked in the below
picture.
of
pt
De
M
It will open a window like given below.
Specify any arbitrary target name. For Eg., 6748config.ccxml (Extension should be
.ccxml).. Click Finish then you will get configuration window for the created target.
SE
KS
E,
EC
B.
1. Select the Connection: Texas instruments XDS100v1 USB Emulator
2. Select the Device: TMS320C6748. To make search easier type 6748 in device block.
*
Check the box
TMS320C674
of
8 and finally
Click Save.
pt
De
M
Follow the path.
“C:\6748support\c6748.gel”
SE
KS
E,
D.
Go to view option and select the Target Configuration:
View->Target Configuration.
A wizard will open in the workspace expand the User Defined folder and you can find your
EC
target, Right click on 6748config.ccxml and select the Launch Selected Configuration.
of
pt
Step P1:
M
Change the Perspective Debug to C/C++ from the right corner of the CCS
Step P2:
Go to File New CCS Project.
SE
KS
E,
Step P3:
Specify the name of the project in the
EC
M
Click Next
SE
KS
E,
*However our target is based on C6000 family, Based on the family we need to select the
Project
Type.
EC
Click finish
M
SE
KS
B. Specify the arbitrary source file name. It should be in the source folder (current project
name.).
E,
EC
Note:
of
Extension of the source file must be the language what we preferred to write the code.
Eg:
For c-> .c
C++ -> .cpp
Assembly -> .asm
pt
M
warnings. Go to
SE
KS
If your code doesn‟thave any errors and warnings, a message will be printed in the console
window that
M
load program on to target.
SE
KS
E,
During debug ccs will display following error message.
EC
of
Now press reset button on the 6748 hardware , then click on retry.
pt
Once you click on retry ccs will load program on to processor and then ccs will guide
us to debug mode, if it is not done automatically.
De
M
Go to Target Run
SE
KS
E,
Once you run the program the output will be printed in the Console
EC
of
pt
De
PROGRAM 1
M
LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES
Aim: To write the C code to perform Linear Convolution upon two given discrete time
signals.
SE
C Code:
KS
int y[20];
main()
{ int m=6; /*Length of i/p samples sequence*/
int n=6; /*Length of impulse response Coefficients*/
int i=0,j;
/*Input Signal Samples*/
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0};
E,
/*Impulse Response Coefficients*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0};
/*Calculate Values*/
EC
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
of
/* Display Values*/
printf("Sequence 1: \n");
for(i=0;i<m;i++)
printf("%d\t",x[i]);
pt
printf("\nSequence 2: \n");
for(i=0;i<n;i++)
printf("%d\t",h[i]);
De
OUTPUT:
Sequence 1:
1 2 3 4 5 6
M
Sequence 2:
1 2 3 4 5 6
Convolved Sequence:
1 4 10 20 35 56 70 76 73 60 36
SE
Procedure:
KS
3. Create new project with name as sine wave (step 5).
4. Create new source file and type the code linear.c and save it.(step 6)
5. Now perform steps 7, 8and 9.Once you run the program you can watch convolution
result in the console window.
E,
6. To view the values in graph
Buffer size : 11
Start Address: y
of
8. Click : Ok
9. Note down the output waveform.
pt
NOTE : Follow the same procedure for the rest of the experiments.
De
PROGRAM 2:
M
Aim: To write the C code to perform Circular Convolution upon two given discrete time
signals.
SE
C Code:
KS
{
printf("Enter the length of the first sequence\n");
scanf("%d",&m);
printf("\nEnter the length of the second sequence\n");
scanf("%d",&n);
printf("\nEnter the first sequence\n");
for(i=0;i<m;i++)
E,
scanf("%d",&x[i]);
printf("\nEnter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
EC
n=m;
}
/*Initialize Array of Zeros*/
for(i=m;i<n;i++)
x[i]=0;
pt
m=n;
}
/* Convert linear sequence to circular sequence*/
y[0]=0;
De
a[0]=h[0];
for(j=1;j<n;j++) /* folding h(n) to h(-n) */
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
M
for(k=1;k<n;k++)
{
y[k]=0;
SE
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
KS
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/* displaying the result */
E,
printf("\nConvolved Sequence:\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
EC
OUTPUT:
Enter the length of the first sequence
4
Enter the length of the second sequence
4
of
14 16 14 16
De
PROGRAM 3:
M
Aim: Computation of N point DFT of a given sequence.
C Code:
SE
#include<stdio.h>
#include<math.h>
int N,k,n,i;
float pi=3.1416,sumre=0, sumim=0,out_real[8]={0.0},
out_imag[8]={0.0};
KS
int x[32];
void main(void)
{
printf("Enter the length of the sequence\n");
scanf("%d",&N);
printf("\nEnter the sequence\n");
for(i=0;i<N;i++)
E,
scanf("%d",&x[i]);
for(k=0;k<N;k++)
{
sumre=0;
EC
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);
}
of
out_real[k]=sumre;
out_imag[k]=sumim;
printf("DFT of the Sequence :\n");
printf("X([%d])=\t%f\t+\t%fi\n",k,out_real[k],out_imag[k]);
}
pt
}
De
OUTPUT:
Enter the length of the sequence
4
Enter the sequence
M
0 1 2 3
DFT of the Sequence
6.0
SE
-2.0 + 2.0i
-2.0 - 0.0i
-2.0 - 2.0i
KS
E,
EC
of
pt
De
PROGRAM 4:
M
Aim: To Calculate the Impulse Response of the First Order and Second Order Systems.
SE
C Code:
#include <stdio.h>
KS
#define Len 10 /*Length of Impulse Response*/
main()
{
int j,k;
float b[Order+1]={1, 3}; /*Input Coefficients*/
E,
float a[Order+1]={1, 0.2}; /*Output Coefficients*/
printf("Impulse Response Coefficients:\n");
for(j=0;j<Len;j++)
{
sum = 0;
EC
for (k=1;k<=Order;k++)
{
if ((j-k)>=0)
sum=sum+(b[k]*y[j-k]);
}
if(j<=Order)
y[j]=a[j]-sum;
else
of
y[j]=-sum;
printf("Response [%d] = %f\n",j,y[j]);
}
}
pt
OUTPUT:
M
C Code:
#include <stdio.h>
SE
#define Order 2 /*Second Order Filter*/
#define Len 10 /*Length of Impulse Response*/
main()
KS
{
int j,k;
float b[Order+1]={1, 3, -0.12}; /*Input Coefficients*/
float a[Order+1]={1, 0.2, -1.5}; /*Output Coefficients*/
printf("Impulse Response Coefficients:\n");
for(j=0;j<Len;j++)
{
sum = 0;
E,
for (k=1;k<=Order;k++)
{
if ((j-k)>=0)
sum=sum+(b[k]*y[j-k]);
EC
}
if(j<=Order)
y[j]=a[j]-sum;
else
y[j]=-sum;
printf("Response [%d] = %f\n",j,y[j]);
}
}
of
OUTPUT:
M
2. What do you mean by process of reconstruction?
3. What are techniques of reconstructions?
4. What do you mean Aliasing? What is the condition to avoid aliasing for sampling?
5. Write the conditions of sampling.
SE
6. How many types of sampling there?
7. Explain the statement- t= 0:0.000005:0.05
8. In the above example what does colon (:) and semicolon (;) denote?
9. What is a) Undersampling b) Nyquist Plot c) Oversampling.
10. Write the MATLAB program for Oversampling.
KS
11. What is the use of command ‘legend’?
12. Write the difference between built in function, plot and stem describe the function.
13. What is the function of built in function and subplot?
14. What is linear convolution?
15. Explain how convolution syntax built in function works.
16. How to calculate the beginning and end of the sequence for the two sided
E,
controlled output?
17. What is the total output length of linear convolution sum.
18. What is an LTI system?
19. Describe impulse response of a function.
EC
function?
30. How to calculate output of DFT using MATLAB?
31. What do you mean by filtic command, explain.
De
32. How to calculate output length of the linear and circular convolution.
33. What do you mean by built in function ‘fliplr’ and where we need to use this.
34. What is steady state response?
35. Which built in function is used to solve a given difference equation?
36. Explain the concept of difference equation.
37. Where DFT is used?
M
41. How to compute maximum length N for a circular convolution using DFT and
IDFT.(what is command).
42. Explain the statement- y=x1.*x2
43. What is FIR and IIR filter define, and distinguish between these two.
SE
44. What is filter?
45. What is window method? How you will design an FIR filter using window
method.
46. What are low-pass and band-pass filter and what is the difference between these
two?
KS
47. Explain the command : N = ceil(6.6 *pi/tb)
48. Write down commonly used window function characteristics.
49. What is the MATLAB command for Hamming window? Explain.
50. What do you mea by cut-off frequency?
51. What do you mean by command butter, cheby1?
52. Explain the command in detail- [N,wc]=buttord(2*fp/fs,2*fstp/fs,rp,As)
E,
53. What is CCS? Explain in detail to execute a program using CCS.
54. Why do we need of CCS?
55. How to execute a program using ‘dsk’ and ‘simulator’?
56. Which IC is used in CCS? Explain the dsk, dsp kit.
EC