Академический Документы
Профессиональный Документы
Культура Документы
LABORATORY MANUAL
Prepared by Verified by
Dr.A.Diana Andrushia Mr. D.Sugumar
Asst. Prof/ECE Asst. Prof / ECE
DSP Lab In-Charge
Approved by
1
Co-Requisite: 17EC2010 Digital Signal Processing
Course Objective:
To gain knowledge in DSP applications like FIR,IIR filters and FFT using MATLAB
To gain knowledge on Texas instrument TMS320C6416/6713 DSK and work on real
time applications.
Course Outcome:
The students will be able to:
LABORATORY INSTRUCTIONS:
1. Do not handle any equipment without reading the instructions /Instruction manuals.
2. Observe type of sockets of equipment power to avoid mechanical damage.
3. Do not insert connectors forcefully in the Sockets.
4. Strictly observe the instructions given by the Teacher/ Lab Instructor.
5. After the experiment is over, the students must hand over the DSP trainer kits, cables and
speakers to the lab assistant / teacher.
6. It is mandatory to come to lab in a formal Lab uniform dress.
7. It is mandatory to come with the observation book and lab record in which previous
experiment should be written in the record and the present lab experiment written in
the observation note book.
8. Correction for the observation book of the present lab experiment should be obtained on
the same day and in the record on the next scheduled lab session.
9. Mobile Phones should be Switched OFF in the lab session.
10. Students have to come to lab in-time. Late comers are not allowed to enter the lab.
11. Prepare for the viva questions. At the end of the experiment, the lab faculty will ask the
viva. Questions and marks are allotted accordingly.
12. The experiments have been designed to be performed with in the 3-hour laboratory time.
13. To successfully complete the experiment in one lab turn, come prepared to the laboratory.
14. Read the experiment in advance and follow the experimental steps judiciously.
2
TABLE OF CONTENTS
MATLAB/SIMULINK
7 Waveform Generation 32
8 Implementation of Convolution 37
9 Implementation of DFT 42
10 Configuration of ADC 46
3
FLOWCHART-GENERATION OF DT SIGNALS:
START
STOP
START
STOP
4
EX. NO : 1
DATE :
GENERATION OF DISCRETE TIME SIGNALS
AIM:
To write a program in MATLAB to generate the following waveforms in Discrete Time(DT)
and also perform sampling rate conversion of Continuous Time(CT) signals
(a) Unit Impulse sequence (b) Unit step sequence (c) Unit Ramp sequence (d)
Sinusoidal sequence (e) Exponential sequence (f) Random sequence
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
Real signals can be quite complicated. The study of signals therefore starts with the analysis
of basic and fundamental signals. For linear systems, a complicated signal and its behavior
can be studied by superposition of basic signals. The basic discrete time signals are:
1, for n 0
Unit impulse sequence. x (n) (n)
0, otherwise
1, for n 0
Unit step sequence. x (n) u(n)
0, otherwise
n, for n 0
Unit ramp sequence. x (n) r (n)
0, otherwise
Sinusoidal sequence. x(n) A sin(n ) , where A is amplitude
5
LIBRARY FUNCTIONS:
clc:
Clear command window.
CLC clears the command window and homes the cursor.
clear all:
Clear variables and functions from memory. CLEAR removes all
variables from the workspace. CLEAR VARIABLES do the same thing.
close all:
Close figure. CLOSE, by itself, closes the current figure window.
CLOSE ALL closes all the open figure windows.
exp:
EXP Exponential.
EXP(X) is the exponential of the elements of X, e to the X.
input:
INPUT Prompt for user input.
R = input ('How many apples') gives the user the prompt in the text string and then
waits for input from the keyboard. The input can be any MATLAB expression, which
is evaluated, using the variables in the current workspace, and the result returned in R.
If the user presses the return key without entering anything, INPUT returns an empty
matrix.
linspace:
LINSPACE Linearly spaced vector.
LINSPACE (X1, X2) generates a row vector of 100 linearly equally spaced points
between X1 and X2.
rand:
The rand function generates arrays of random numbers whose elements are
uniformly distributed in the interval (0,1).
ones:
ONES(N) is an N-by-N matrix of ones.
ONES (M, N) or ONES ([M, N]) is an M-by-N matrix of ones.
zeros:
ZEROS(N) is an N-by-N matrix of Zeros.
ZEROS (M, N) or ZEROS ([M, N]) is an M-by-N matrix of zeros
6
plot:
PLOT Linear plot.
PLOT (X, Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is
plotted versus the rows or columns of the matrix, whichever line up.
subplot:
SUBPLOT Create axes in tiled positions.
H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-
n matrix of small axes, selects the p-th axes for the current plot, and returns the axis
handle. The axes are counted along the top row of the Figure window, then the
second row, etc.
stem:
STEM Discrete sequence or "stem" plot.
STEM(Y) plots the data sequence Y as stems from the x axis terminated with circles
for the data value.
STEM (X, Y) plots the data sequence Y at the values specified in X.
title:
TITLE Graph title.
TITLE('text') adds text at the top of the current axis.
xlabel:
XLABEL X-axis label.
XLABEL('text') adds text beside the X-axis on the current axis.
ylabel:
YLABEL Y-axis label.
YLABEL('text') adds text beside the Y-axis on the current axis.
interp:
Resample data at a higher rate using lowpass interpolation
interp (X,R) resamples the sequence in vector X at R times the original sample rate.
decimate:
Resample data at a lower rate after lowpass filtering.
decimate(X,R) resamples the sequence in vector X at 1/R times the original sample
rate
resample:
Change the sampling rate of a signal.
resample(X,P,Q) resamples the sequence in vector X at P/Q times the original sample
rate using a polyphase implementation
7
PROCEDURE FOR MATLAB:
1. Click on the MATLAB icon on the desktop (or go to Start - All Programs and click on
MATLAB) to get into the MATLAB desktop / Command Window
2. Click on NEW M-File from the file Menu and the editor window is opened
3. Write the program in the „Editor‟ window and save it as „m-file‟
4. Then Click on DEBUG from Menu bar and Click Run
5. Enter the input parameters in the command window
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window
RESULT:
The program for DT waveform generation and sampling rate conversion are written, executed
and the outputs are verified using MATLAB.
8
Viva Questions:
1. What is digital signal processing?
2. Draw and explain a DSP model for processing analog signals.
3. What are the advantages of digital signal processing?
4. What are the limitations of digital signal processing?
5. Define a discrete time signal.
6. Give the analytical and graphical representation of an arbitrary sequence.
7. Give the mathematical and graphical representation of unit-step sequence u(n).
8. Draw u(3-n)
9. Prove whether folding and Shifting are commutative.
10. What are energy and power signals?
11. State Parseval‟s energy theorem.
12. Distinguish between time limited and band-limited signals.
9
FLOWCHART:
START
STOP
10
EX. NO : 2
DATE :
DISCRETE CONVOLUTION
AIM:
To write a MATLAB Script to perform discrete convolution (Linear and Circular) for the
given two sequences and also prove by manual calculation.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
LINEAR CONVOLUTION:
The response y[n] of a LTI system for any arbitrary input x[n] is given by convolution of
impulse response h[n] of the system and the arbitrary input x[n].
If the input x[n] has N1 samples and impulse response h[n] has N2 samples then the
output sequence y[n] will be a finite duration sequence consisting of (N1 + N2 - 1) samples.
The convolution results in a non-periodic sequence called Aperiodic convolution.
11
It can be performed only if both the sequences consist of equal number of samples. If the
sequences are different in length then convert the smaller size sequence to that of larger size
by appending zeros.
LIBRARY FUNCTION:
conv: Convolution and polynomial multiplication.
C = conv (A, B) convolves vectors A and B. The resulting vector C‟s length is given
by length(A)+length(B)-1. If Aand B are vectors of polynomial coefficients,
convolving them is equivalent to multiplying the two polynomials in frequency
domain.
length: Length of vector.
length(X) returns the length of vector X. It is equivalent to size(X) for non-empty
arrays and 0 for empty ones.
cconv: Modulo-N circular convolution.
C = cconv (A, B, N) circularly convolves vectors A and B. The resulting vector is
length N. If omitted, N defaults to LENGTH(A)+LENGTH(B)-1.
When N = LENGTH(A)+LENGTH(B)-1, the circular convolution is equivalent to the
linear convolution computed by CONV.
RESULT:
The linear and circular convolutions are performed and their properties are checked using
MATLAB and results are verified.
12
VIVA QUESTIONS:
1. Explain convolution sum.
2. What is the impulse response of two LTI systems connected in cascade?
3. List the steps performed in discrete convolution
4. What is impulse response?
5. What is meant by discrete convolution?
6. What will be the output of a system having impulse as impulse response h(n) for any
input signal.
7. Compute the convolution between the two sequences x[n]= {1,2,3} and h[n]= {1,1,1,1,1}.
8. Identify the aliasing effect in circular convolution in comparison with that of linear
convolution.
9. Distinguish between linear and circular convolution.
10. Verify convolution in time domain is multiplication in frequency domain.
13
FLOWCHART:
START
STOP
14
EX. NO : 3
DATE :
DISCRETE/FAST FOURIER TRANSFORM
AIM:
To write a MATLAB program to perform the Discrete Fourier Transform for the given two
sequences and to plot their magnitude and phase response.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
DISCRETE FOURIER TRANSFORM
Fourier analysis is extremely useful for data analysis, as it breaks down a signal into
constituent sinusoids of different frequencies. For sampled vector data Fourier analysis is
performed using the Discrete Fourier Transform (DFT).
It finds its application in Digital Signal processing including Linear filtering, Correlation
analysis and Spectrum analysis.
Consider a complex series x[n] with N samples of the form x0, x1, x2, x3… xk ... xN-1, Where x
is a complex number xi = xreal + jximag. Further, assume that the series outside the range 0, N-1
is extended N-periodic, that is, xk = xk+N for all k. The FT of this series is denoted as X (k)
and has N samples. The forward transform is defined as
N 1
j2 n k N
X(k) x ( n) e , for k 0...N 1
n0
X imag
Phase tan 1
X real
15
LIBRARY FUNCTIONS:
exp: Exponential Function.
exp (X) is the exponential of the elements of X, e to the power X. For complex
Z=X+i*Y, exp (Z) = exp(X)*(COS(Y) +i*SIN(Y)).
RESULT:
The program for Discrete Fourier Transform was performed with library functions and
without library functions using MATLAB. The results were verified by manual calculation.
16
SAMPLE VIVA QUESTIONS:
1. Define DFT of a sequence x[n].
2. What are the „Twiddle factors‟ of FFT?
3. Calculate the DFT of x[n]=δ[n-n0], 0≤n0≤N-1.
4. State the Linearity property and Circular shift property of Discrete Fourier transforms.
5. Prove the Linearity property of DFT.
6. Prove the Circular shift property of DFT.
7. List out the properties of DFT.
8. X[n] is obtained from the inverse DFT of an N-point sequence X(K), where K=0,1,
2,….N-1 is defined as _______________.
9. What is meant by Zero padding? What are its uses?
10. State the relationship between DTFT and Z-transform.
11. State the relationship between Z transform and DFT.
12. State the relationship between DTFT and DFT.
13. The direct computation of the discrete Fourier transform of a sequence x[n] requires
__________ real multiplications and _________ real additions.
14. The direct computation of the Discrete Fourier transform of a sequence x[n] requires
______ complex multiplications and ______ complex additions.
17
FLOWCHART:
START
STOP
18
EX. NO : 4
DATE :
DESIGN OF IIR FILTER-I (Butterworth)
AIM:
To write a MATLAB Script to design a IIR Butterworth low pass filter using
i. Bilinear Transformation
ii. Impulse Invariant Transformation
.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
A digital filter is a linear time invariant discrete time system. The digital filters are classified
into two, based on their lengths of impulse response
1. Finite Impulse response (FIR)
They are of non-recursive type and h [n] has finite number of samples
2. Infinite Impulse response (IIR)
h[n] has infinite number of samples. They are of recursive type. Hence, their transfer
function is of the form
H ( z ) h( n ) z n
n 0
M 1
bk Z k
H (Z ) K 0
N 1
1 a jZ j
j 1
BUTTERWORTH FILTER:
Low pass Analog Butterworth filters are all pole filters characterised by magnitude frequency
response by
1
H ( j ) 2 =
2N
1
c
where N is the order of the filter and c is the cut-off frequency.
As N , the low pass filter is said to be ideal. All types of filters namely-Low pass, High
pass, Band pass and Band elimination filters can be derived from the Normalized Low pass
filter.
The digital filters are designed from analog filters. The two widely used methods for
digitizing the analog filters include
1. Bilinear transformation
2. Impulse Invariant transformation
19
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, find pre-warped analog frequencies using
2
tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 Z 1
3. Substitute S in the H(s) of Step:2
T 1 Z 1
k 1
LIBRARY FUNCTIONS:
butter: Butterworth digital and analog filter design.
[B, A] = butter (N,Wn) designs an Nth order Low pass digital Butterworth filter and
returns the filter coefficient vectors B (numerator) and A (denominator) in length
N+1. The coefficients are listed in descending powers of z. The cut-off frequency Wn
must be in the range 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Bandpass: Wp = [.2 .7], Ws = [.1 .8]
20
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
buttord: also returns Wn, the Butterworth natural frequency (or) the "3 dB frequency" to be
used with BUTTER to achieve the specifications.
[N, Wn] = buttord (Wp, Ws, Rp, Rs, 's') does the computation for an analog filter, in which
case Wp and Ws are in radians/second. When Rp is chosen as 3 dB, the Wn in BUTTER is
equal to Wp in BUTTORD.
given the numerator and denominator coefficients in vectors B and A. The frequency
response is evaluated at the points specified in vector W (in rad/s). The magnitude
and phase can be graphed by calling freqs(B,A,W) with no output arguments.
Bilinear: Bilinear transformation method for analog-to-digital filter conversion. The bilinear
transformation is a mathematical mapping of variables. In digital filtering, it is a standard
method of mapping the s or analog plane into the z or digital plane. It transforms analog
filters, designed using classical filter design.
RESULT:
Butterworth Low pass filter is designed using Bilinear Transformation and Impulse
Invariance technique and the waveforms are obtained in MATLAB.
21
SAMPLE VIVA QUESTIONS:
1. Why Butterworth filters is called maximally flat filters?
2. Give any two properties of Butterworth low pass filter.
3. Sketch the magnitude squared response of a Butterworth filter
4. Give the pole location for the 5th and 6th order Butterworth filters graphically
5. Derive second order Butterworth polynomial.
6. Derive second order Butterworth transfer function
7. Mention any two procedures for digitizing the transfer function of an analog filter.
8. What do you understand by backward differences?
9. What do you understand by forward difference?
10. What is meant by Impulse-Invariant Transformation?
11. If the poles of the all pole analog filter is known, give the formula for obtaining the
transfer function of the digital filter.
12. Explain how S-plane is mapped to the Z plane in impulse invariant method.
13. What is aliasing?
14. Why impulse invariance method is not preferred in the design of IIR filters other than low
pass filters?
15. What is meant by bilinear transformation in IIR filter design?
16. Give the bilinear transformation equation
17. Explain how S-plane is mapped to the Z plane in bilinear transformation method
18. State the properties of bilinear transformation.
19. What is frequency warping?
20. How does the linear transformation avoid the problem of aliasing encountered with the
use of impulse invariance?
21. Mention the advantages of bilinear transformation technique
22. Mention the disadvantages of bilinear transformation technique
23. Compare the merits and demerits of impulse invariant method and bilinear transformation
method in IIR filter design
24. Distinguish between IIR and FIR filters.
2. Design a third and sixth order Butterworth filter that eliminates the sin(8t) component from
the signal x(t)=2+sin(8t).
3. Design a Butterworth filter by using FDA tool and by using SP tool show the elimination
of the sin(8t) component from the signal x(t)=2+sin(8t).
22
FLOWCHART:
START
STOP
23
EX. NO : 5
DATE :
DESIGN OF IIR FILTER-II (Chebyshev)
AIM:
Write a MATLAB Script to design a digital IIR Chebyshev low pass filter using
i. Bilinear Transformation
ii. Impulse Invariant Transformation
.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
CHEBYSHEV FILTER:
There are two types of Chebyshev filters.
Type I are all-pole filters that exhibit equi-ripple behaviour in pass band and monotonic
characteristics in stop band.
Type II are having both poles and zeros and exhibit monotonic behavior in pass band and
equi-ripple behaviour in stop band. The zero lies on the imaginary axis.
BILINEAR TRANSFORMATION:
DESIGN STEPS:
1. From the given specifications, Find pre-warped analog frequencies using
2
tan
T 2
2. Using the analog frequencies, find H(s) of the analog filter
2 1 Z 1
3. Substitute S in the H(s) of Step:2
T 1 Z 1
24
IMPULSE INVARIANT TRANSFORMATION:
DESIGN STEPS:
1. Find the analog frequency using =
T
2. Find the transfer function of analog filter Ha(s)
3. Express the analog filter transfer function as a sum of single pole filters
4. Compute H(Z) of digital filter using the formula
N
Ck
H (Z ) TPk Z 1
k 1 1 e
LIBRARY FUNCTIONS:
cheb1ord: Chebyshev Type I filter order selection.
[N, Wn] = cheb1ord (Wp, Ws, Rp, Rs) returns the order N of the lowest order digital
Chebyshev Type I filter that loses no more than Rp dB in the pass band and has at
least Rs dB of attenuation in the stop band. Wp and Ws are the pass band and stop
band edge frequencies, normalized from 0 to 1 (where 1 corresponds to pi
radians/sample). For example,
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Bandpass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
cheb1ord also returns Wn, the Chebyshev natural frequency to use with cheby1 to
achieve the specifications.
[N, Wn] = cheb1ord (Wp, Ws, Rp, Rs, 's') does the computation for an analog filter,
in which case Wp and Ws are in radians/second.
[B,A] = cheby1 (N,R,Wn) designs an Nth order Low pass digital Chebyshev filter
with R decibels of peak-to-peak ripple in the pass band. cheby1 returns the filter
coefficient vectors B (numerator) and A (denominator) of length N+1. The cut-off
frequency Wn must be in the range 0.0 < Wn < 1.0, with 1.0 corresponding to half the
sample rate. Use R=0.5 as a starting point, if you are unsure about choosing R.
Bilinear: Bilinear transformation method for analog-to-digital filter conversion. The bilinear
transformation is a mathematical mapping of variables. In digital filtering, it is a standard
method of mapping the s or analog plane into the z or digital plane. It transforms analog
filters, designed using classical filter design
RESULT:
Chebyshev Low pass filter is designed using Bilinear Transformation and Impulse
Invariance technique and the waveforms are obtained in MATLAB.
26
SAMPLE VIVA QUESTIONS:
1. What is a Chebyshev filter?
2. Give the expression for the magnitude squared function of a Chebyshev filter
3. State the features of elliptic filters
4. Chebyshev approximation is also called ___________
5. Derive the 4th order Chebyshev polynomial
6. When is a Chebyshev approximation applied for filter design?
7. State the features of Chebyshev filters
8. Type II Chebyshev filter is also known as _____________ Chebyshev filter.
9. For Chebyshev approximation, the locus of the system function is _____________
10. What is the property of Chebyshev filters?
11. Distinguish between type I and type II Chebyshev Low pass filter
12. Compare Butter worth filter and Chebyshev filter
27
FLOWCHART:
START
STOP
28
EX. NO : 6
DATE :
DESIGN OF FIR FILTERS
AIM:
To write a MATLAB Script to design a low pass FIR filter using Window Method for the
given specifications.
.
APPARATUS REQUIRED:
Computer with MATLAB software
THEORY:
A digital filter is a linear time invariant discrete time system. The digital filters are
classified into two, based on their lengths of impulse response
1. Finite Impulse response (FIR)
They are of non-recursive type and h [n] has finite number of samples
2. Infinite Impulse response (IIR)
h[n] has infinite number of samples. They are of recursive type.
The FIR filter can be designed by:
Fourier series method
Frequency sampling method
Window method
Most of the FIR design methods are interactive procedures and hence require more memory
and execution time. Also, implementation of narrow transition band filter is costly. But there
are certain reasons to go for FIR.
Types of windows:
1. Rectangular
2. Triangular
3. Hamming
4. Hanning
5. Blackman
6. Kaiser
LIBRARY FUNCTIONS:
B = fir1(N,Wn) designs an Nth order low pass FIR digital filter and returns the filter
coefficients of vector B of length (N+1). The cut-off frequency Wn must be between 0 < Wn
< 1.0, with 1.0 corresponding to half the sample rate. The filter B is real and has linear phase.
The normalized gain of the filter at Wn is -6 dB.
B = fir1(N,Wn,'high') designs an Nth order high pass filter. You can also use B =
fir1(N,Wn,'low') to design a low pass filter.
29
If Wn is a two-element vector, Wn = [W1 W2], fir1 returns an order N band pass
filter with pass band W1 < W < W2.You can also specify
B = fir1(N,Wn,WIN) designs an N-th order FIR filter using the vector WIN of (N+1)
length to window the impulse response. If empty or omitted, fir1 uses a Hamming
window of length N+1. For a complete list of available windows, see the Help for the
WINDOW function. KAISER and CHEBWIN can be specified with an optional
trailing argument. For example,
B = fir1(N,Wn,'noscale'),
B = fir1(N,Wn,'high','noscale'),
We can specify windows from the Signal Processing Toolbox, such as boxcar, hamming,
hanning, bartlett, blackman, kaiser or chebwin
w = hanning(n) returns an n-point symmetric Hann window in the column vector w. n must
be a positive integer.
w=triang(n) returns an n-point triangular window in the column vector w. The triangular
window is very similar to a Bartlett window. The Bartlett window always ends with zeros at
30
samples 1 and n, while the triangular window is nonzero at those points. For n odd, the center
(n-2) points of triang(n-2) are equivalent to bartlett(n).
RESULT:
The given low pass filter was designed using Window method and manually verified the filter
co-efficients of the filters using MATLAB.
31
SAMPLE VIVA QUESTIONS:
1. What are filters?
2. What are the advantages of FIR filters?
3. Define Phase delay and Group delay.
4. When will FIR filters have constant phase and group delays?
5. What is the necessary and sufficient condition for linear phase characteristics of FIR
filters?
6. What are linear phase filters?
7. A filter is specified by its unit sample response h(n), given by
H (n) = -⅓δ (n+1) + δ (n) - ⅓ δ (n-1). Is it a linear phase filter?
8. What are the various design techniques for FIR filter?
9. State why the Fourier series representation of the frequency response of a digital filter is
unsuitable for FIR filter design.
10. Explain Gibbs phenomenon.
11. Explain design of FIR filters using frequency sampling:
12. Give the equation of the frequency sampling realization of FIR filter:
13. What is meant by “window method” of FIR filter design?
14. The width of the main lobe for a N-point rectangular window is _______.
15. Draw the log magnitude response of a rectangular window.
16. Highlight the advantages and disadvantages of the rectangular window.
17. Define a Barlett window?
18. Give the equation specifying a Hanning window.
19. Define Hanning and Hamming windows.
20. Why Hanning and Hamming windows widely used?
32
FLOWCHART:
START
STOP
33
EX. NO : 7
DATE :
WAVEFORM GENERATION
AIM:
To write and simulate an embedded C-program using Code Composer Studio and generate
waveforms using TMS320C6416 and visualize it.
REQUIREMENTS:
1. Operation System – Windows XP.
2. Software – CC STUDIO 3
3. DSK 6416 DSP Trainer kit
4. USB cable.
5. Power supply
THEORY:
A sine wave can be generated by using trigonometric expression
[ ] ∗
A – Amplitude of the signal
– Frequency of the message signal
– Phase of the signal.
PROCEDURE:
1. Open Code Composer Studio 3.1 Setup, Select the family 64xx and platform dsk.
Click add then save and quit.
2. Start a new project using „Project New‟ pull down menu, save it in a separate
directory.
(Path c:\CCStudio\Myproject\sinusoidal.pjt)
3. Create a source file sinusoidal.c to the project using „Project New Source File
menu and save it in the project folder.
4. Add the source file (sinusoidal.c) to the project.
ProjectAdd files to ProjectSelect sinusoidal.c
5. Add the run time support library file rts6400.lib
ProjectAdd files to ProjectSelect rts6400.lib from the below mentioned path.
(Path: c:\CCStudio\c6000\cgtools\lib\rts6400.lib)
6. To allocate memory in the RAM add linker file hello.cmd
ProjectAdd files to ProjectSelect helo1.cmd from the below mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ menu or press Ctrl+F7.
8. Build the program using the „Project Build‟ menu or press F7.
9. Load the file(sinusoidal.out) in program memory of DSP chip.
FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
Select ViewGraphTime and Frequency.
34
RESULT:
The above code was written and executed in Code Composer Studio and the output
waveforms were observed graphically.
35
VIVA QUESTIONS:
1. Define signal and signal processing
2. Differentiate digital and analog signals?
3. How the DSP processor will differ from conventional processors?
4. Expand the abbreviation TMS320C 5X/6X
5. What kind of processor is DSP processor?
6. What are the main building blocks of DSP processor?
7. What is the main function of MAC unit?
8. Explain Harward architecture?
36
FLOWCHART:
START
STOP
37
EX. NO : 8
DATE :
IMPLEMENTATION OF CONVOLUTION
AIM:
To write and simulate an embedded C-program using Code Composer Studio to implement
linear and circular convolution using TMS320C6416 and visualize it.
REQUIREMENTS:
1. Operation System – Windows XP.
2. Software – CC STUDIO 3
3. DSK 6416 DSP Trainer kit
4. USB cable.
5. Power supply
THEORY:
Linear convolution:
If x[n] is the input sequence and h[n] is the impulse response of a system or the filter
coefficients of a filter, then the linear convoluted sequence y[n] is given by
For eg.:
x[n] = { 1,2,3,4}
h[n] = {1,2,3,4}
where n = 4, k = 4; Values of n and k should be multiples of 4 in this case.
If n and k are not multiples of 4, pad with zeros to make multiples of 4
r = n+k-1; Size of output sequence
here r = 4+4-1=7.
CIRCULAR CONVOLUTION:
Steps for circular convolution are the same as the usual convolution, except all index
calculations are done “mod N” = “on the wheel”
Here let f[m] be the input sequence and h[n] impulse response of the system and y[n] be the
circular convoluted sequence.
38
Steps for cyclic convolution:
Step 1: plot f[m] and h[-m]
Step 3: Pointwise multiply the f[m] wheel and the h[n-m] wheel and sum them up to get y[n].
39
PROCEDURE:
1. Open Code Composer Studio 3.1 Setup, Select the family 64xx and platform dsk,
Click add then save and quit.
2. Start a new project using „Project New‟ pull down menu, save it in a separate
directory.
i. (Path c:\CCStudio\Myproject\convolution.pjt)
3. Create a source file convolution.c to the project using „Project New Source File
menu and save it in the project folder.
4. Add the source file (convolution.c) to the project.
i. ProjectAdd files to ProjectSelect convolution.c
5. Add the run time support library file rts6400.lib
i. ProjectAdd files to ProjectSelect rts6400.lib from the below
mentioned path.
(Path: c:\CCStudio\c6000\cgtools\lib\rts6400.lib)
6. To allocate memory in the RAM add linker file hello.cmd
i. ProjectAdd files to ProjectSelect helo1.cmd from the below
mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ menu or press Ctrl+F7.
8. Build the program using the „Project Build‟ menu or press F7.
9. Load the file(convolution.out) in program memory of DSP chip.
i. FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
i. Select ViewGraphTime and Frequency.
RESULT:
The above code was written and executed in Code Composer Studio and the circular and
linear convoluted sequence were observed graphically.
40
VIVA QUESTIONS:
1. Explain the significance of convolution.
2. Define linear convolution.
3. Why linear convolution is called as a periodic convolution?
4. Why zero padding is used in linear convolution?
5. What are the four steps to find linear convolution?
6. What is the length of the resultant sequence in linear convolution?
7. How linear convolution will be used in calculation of LTI system response?
8. List few applications of linear convolution in LTI system design.
9. Give the properties of linear convolution.
10. How the linear convolution will be used to calculate the DFT of a signal?
41
FLOWCHART:
START
STOP
42
EX. NO : 9
DATE :
N-POINT DFT COMPUTATION
AIM:
To write and simulate an embedded C-program using Code Composer Studio for
computing DFT of any discrete signal using TMS320C6416 and visualize it.
APPARATUS REQUIRED:
1. Operation System – Windows XP.
2. Software – CC STUDIO 3
3. DSK 6416 DSP Trainer kit
4. USB cable.
5. Power supply
THEORY:
Discrete Fourier Transform:
The Discrete Fourier Transform is a powerful computation tool which allows us to evaluate
the Fourier Transform X (ejω) on a digital computer or specially designed digital hardware.
Since X(ejω) is continuous and periodic, the DFT is obtained by sampling one period of the
Fourier Transform at a finite number of frequency points. Apart from determining the
frequency content of a signal, DFT is used to perform linear filtering operations in the
frequency domain. The sequence of N complex numbers x0,..., xN−1 is transformed into the
sequence of N complex numbers X0, ..., XN−1 by the DFT according to the formula:
1 N 1 j2 n k N
X(k)
N n 0
x ( n) e , for k 0...N 1
43
PROCEDURE:
1. Open Code Composer Studio 3.1 Setup, Select the family 64xx and platform dsk,
Click add then save and quit.
2. Start a new project using „Project New‟ pull down menu, save it in a separate
directory.
i. (Path c:\CCStudio\Myproject\convolution.pjt)
3. Create a source file DFT.c to the project using „Project New Source File menu
and save it in the project folder.
4. Add the source file (DFT.c) to the project.
i. ProjectAdd files to ProjectSelect convolution.c
5. Add the run time support library file rts6400.lib
i. ProjectAdd files to ProjectSelect rts6400.lib from the below
mentioned path.
(Path: c:\CCStudio\c6000\cgtools\lib\rts6400.lib)
6. To allocate memory in the RAM add linker file hello.cmd
i. ProjectAdd files to ProjectSelect helo1.cmd from the below
mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ menu or press Ctrl+F7.
8. Build the program using the „Project Build‟ menu or press F7.
9. Load the file(DFT.out) in program memory of DSP chip.
i. FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
Select ViewGraphTime and Frequency.
RESULT:
The above code was written and executed in Code Composer Studio and the
magnitude and phase value of DFT were observed graphically.
44
VIVA QUESTIONS:
1. Define transform. What is the need for transform?
2. Differentiate Fourier transform and discrete Fourier transform.
3. Differentiate DFT and DTFT.
4. What are the advantages of FFT over DFT?
5. Differentiate DITFFT and DIFFFT algorithms.
6. What is meant by radix?
7. What is meant by twiddle factor and give its properties?
8. How FFT is useful to represent a signal?
9. Compare FFT and DFT with respect to number of calculation required?
10. How the original signal is reconstructed from the FFT of a signal?
45
FLOWCHART:
START
STOP
46
EX. NO : 10
DATE :
CONFIGURATION OF ADC
AIM:
To configure the ADC-codec TLV320AIC23 for a talk through program using the
board support library.
APPARATUS REQUIRED:
1. Operation System – Windows XP.
2. Software – CC STUDIO 3
3. DSK 6416 DSP Trainer kit
4. Audio source and Speaker
5. USB cable.
6. Power supply
THEORY:
AIC23 Codec
The DSK uses a Texas Instruments AIC23 (part #TLV320AIC23) stereo codec for
input and output of audio signals. The codec samples analog signals on the microphone or
line inputs and converts them into digital data so it can be processed by the DSP. When the
DSP is finished with the data it uses the codec to convert the samples back into analog signals
on the line and headphone outputs so the user can hear the output. The codec communicates
using two serial channels, one to control the codec‟s internal configuration registers and one
to send and receive digital audio samples.
McBSP2 is used as the bi-directional data channel. All audio data flows through the
data channel. Many data formats are supported based on the three variables of sample width,
clock signal source and serial data format. The DSK examples generally use a 16-bit sample
width with the codec in master mode so it generates the frame sync and bit clocks at the
correct sample rate without effort on the DSP side. The preferred serial format is DSP mode
which is designed specifically to operate with the McBSP ports on TI DSPs.
The codec has a 12MHz system clock. The 12MHz system clock corresponds to USB
sample rate mode, named because many USB systems use a 12MHz clock and can use the
same clock for both the codec and USB controller. The internal sample rate generate
subdivides the 12MHz clock to generate common frequencies such as 48KHz, 44.1KHz and
8KHz. The sample rate is set by the codec‟s SAMPLERATE register. The figure below
shows the codec interface on the C6416 DSK.
47
TMS320C6416 DSK CODEC INTERFACE
• All the Real-time implementations covered in the Implementations module follow code
Configuration using board support library.
• The board Support Library (CSL) is a collection of functions, macros, and symbols used to
configure and control on-chip peripherals.
• The goal is peripheral ease of use, shortened development time, portability, hardware
abstraction, and some level of standardization and compatibility among TI devices.
• BSL is a fully scalable component of DSP/BIOS. It does not require the use of other
DSP/BIOS components to operate.
48
Procedure for Real Time Programs:
1. Connect CRO to the Socket Provided for LINE OUT.
2. Connect a Signal Generator to the LINE IN Socket.
3. Switch on the Signal Generator with a sine wave of frequency 500 Hz. and Vp-p=1.5v
4. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
5. Create a new project with name codec.pjt.
6. From the File Menu -> new ->DSP/BIOS Configuration -> select “dsk6416.cdb” and save
it as “xyz.cdb”
7. Add “xyz.cdb” to the current project.
8. Add the given “codec.c” file to the current project which has the main function and calls
all the other necessary routines.
9. Add the library file “dsk6416 bsl.lib” to the current project
Path à “C:\CCStudio\C6000\dsk6416\lib\dsk6416 bsl.lib”
10. Copy files “dsk6416.h” and “dsk6713_aic23.h” from
C:\CCStudio\C6000\dsk6416\include and paste it in current project.
11. Build, Load and Run the program.
12. You can notice the input signal of 500 Hz. appearing on the CRO verifying the codec
configuration.
13. You can also pass an audio input and hear the output signal through the speakers.
14. You can also vary the sampling frequency using the DSK6416_AIC23_setFreq Function
in the “codec.c” file and repeat the above steps.
RESULT:
The codec TLV320AIC23 successfully configured using the board support library and
verified.
49
EX. NO : 11
DATE :
IMPLEMENTATION OF FIR FILTER
AIM:
To design and implement a digital linear phase FIR filter on TMS320C6416 interfacing with
Simulink and observe the effects of the filter for different cut - off frequencies.
APPARATUS REQUIRED:
1. Operation System – Windows XP.
2. DSK 6416 DSP Trainer kit
3. Audio source and Speaker
4. USB cable.
5. Power supply
PROCEDURE:
1. Open the Simulink model in MATLAB
2. For any model in this targeting environment, a user must choose the discrete-time solver.
(Optional)
Simulation>>Simulation Parameters>>Solver>>Solver Options>>Fixed Step discrete (no
continuous states)
3. The embedded target board for this project is the C6416. It is selected and dragged to the
new Simulink Model from Target Preferences
Target Preferences>>C6416 DSK
4. The line in C6416 ADC and line out C6416 DAC blocks provide physical pathways from
and to external sources and displays. They are different from sources and sinks in that they
exchange data with external devices through analog input and output connectors. The ADC
and DAC blocks are selected and dragged to the new Simulink Model from library of C6000.
50
6.Compile the model and invoke CCS. The machine generated code is compiled and linked,
and the executable is loaded onto board.
7.Now apply the real-time audio and observe the filtered audio output in the speaker.
RESULT:
The above design was implemented and the effect of the digital linear phase FIR filter was
observed for different cut off frequencies.
51
VIVA QUESTIONS:
1. What is a filter?
2. Differentiate analog filter and digital filter.
3. Define FIR filter.
4. What are the differences between recursive and non-recursive systems?
5. List a few Applications of FIR filters.
6. Explain advantages of FIR filters over IIR filters.
7. Explain limitations of FIR filters.
8. What is the different method to design FIR filters?
9. Explain different window functions.
10. Differentiate rectangular, triangular and Kaiser windows.
52
EX. NO : 12
DATE :
IMPLEMENTATION OF IIR FILTER
AIM:
To design and implement a digital linear phase IIR filter on TMS320C6416 interfacing with
Simulink and observe the effects of the filter for different cut - off frequencies.
APPARATUS REQUIRED:
6. Operation System – Windows XP.
7. DSK 6416 DSP Trainer kit
8. Audio source and Speaker
9. USB cable.
10. Power supply
PROCEDURE:
1. Open the Simulink model in MATLAB
2. For any model in this targeting environment, a user must choose the discrete-time solver.
(Optional)
Simulation>>Simulation Parameters>>Solver>>Solver Options>>Fixed Step discrete (no
continuous states)
3. The embedded target board for this project is the C6416. It is selected and dragged to the
new Simulink Model from Target Preferences
Target Preferences>>C6416 DSK
4. The line in C6416 ADC and line out C6416 DAC blocks provide physical pathways from
and to external sources and displays. They are different from sources and sinks in that they
exchange data with external devices through analog input and output connectors. The ADC
and DAC blocks are selected and dragged to the new Simulink Model from library of C6000.
53
6.Compile the model and invoke CCS. The machine generated code is compiled and linked,
and the executable is loaded onto board.
7.Now apply the real-time audio and observe the filtered audio output in the speaker.
RESULT:
The above design was implemented and the effect of the digital linear phase IIR filter was
observed for different cut off frequencies.
54
VIVA QUESTIONS:
1. List some advantages of digital filters over analog filters.
2. Write some differences between FIR and IIR filters.
3. What are the different methods to design IIR filters?
4. Why IIR filters are not reliable?
5. What are different applications of IIR filters?
6. What are advantages of IIR filters?
7. What are disadvantages of IIR filters?
8. Differentiate Butterworth and Chebyshev approximations.
9. What is meant by impulse response?
10. What is the importance of impulse response to calculate the o/p response of the filter?
55