Вы находитесь на странице: 1из 55

School of Engineering & Technology

Department of Electronics & Communication Engineering

14EC2018 DIGITAL SIGNAL PROCESSING LAB (CREDIT 0:0:2)

LABORATORY MANUAL

Academic Year: 2018 – 2019

Prepared by Verified by
Dr.A.Diana Andrushia Mr. D.Sugumar
Asst. Prof/ECE Asst. Prof / ECE
DSP Lab In-Charge

Approved by

Head of the Department


(Dr.D.Nirmal)

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:

 Translate the basic signal processing concepts using softwares


 Analyze the various mathematical transforms using softwares
 Design the digital filters by applying suitable transformations or techniques using
softwares
 Express the basic signal processing concepts using DSP Processor
 Implement the mathematical transforms using DSP Processorr
 Demonstrate the real time filtering of audio signals using DSP Processor

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

Exp. No Name of the experiment Page No.

MATLAB/SIMULINK

1 Generation of DT signals & Sample rate Conversion 4

2 Discrete Convolution & its properties 10

3 Calculation of DFT of a Signal 14

4 Design of IIR Filters-1 (Butterworth) 17

5 Design of IIR Filters-2 (Chebyshev) 23

6 Design of FIR filter 27

TMS 320C 6416/TMS320C6713/BF533

7 Waveform Generation 32

8 Implementation of Convolution 37

9 Implementation of DFT 42

10 Configuration of ADC 46

11 Implementation of FIR Filter 50

12 Implementation of IIR Filter 53

3
FLOWCHART-GENERATION OF DT SIGNALS:

START

ASSIGN VALUES FOR THE


SIGNAL PARAMETERS
(AMPLITUDE, TIME AND FREQUENCY)

GENERATE THE WAVEFORM BY USING THE


APPROPRIATE LIBRARY FUNCTION

PLOT THE WAVEFORMS

STOP

FLOWCHART-SAMPLING RATE CONVERSION:

START

GENERATE CT SIGNALS USING THE


APPROPRIATE LIBRARY FUNCTION

SAMPLE THE SIGNLS WITH UP SAMPLING &


DOWN SAMPLING

PLOT THE SAMPLED SIGNALS

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

 Exponential sequence. x(n) = A.an where A and a(base) are constant.

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.

SAMPLE ASSIGNMENT QUESTIONS:


1. Generate square with duty cycle 75 % and triangle signals
2. Generate sine wave with different frequencies and play them using wavplay in
MATLAB.
3. Generate a waveform which is sum of two sinusoidal signals, one with frequency 50
Hz and other with 120 Hz and twice in amplitude.
4. Plot the harmonics of sine signal eg:(sin(x), sin(2x), sin(3x),..) in 3D plot.
5. Verify sin 2 t  cos 2 t  1.
6. Write a MATLAB program to generate the following type of signals
Continuous time signals where d =10 and t varies from -10 to 10
 y1(t)=10 sin (2 π t/d);
 y2(t)=5 cos (2 π t/d);
 y3(t)=y1(t)+y2(t);
 y4(t)=y1(t)-y2(t);
7. Write a MATLAB program to plot the following type of signals
Discrete Time Signals (n varies from -10 to 20)
 Advanced Unit impulse
 Unit negative Ramp

9
FLOWCHART:

START

ASSIGN THE INPUT SEQUENCE


x[n] & IMPULSE RESPONSE h[n]

PERFORM LINEAR, CIRCULAR AND LINEAR VIA


CIRCULAR CONVOLUTION IN TIME DOMAIN

CHECK THE PROPERITIES & PLOT THE


WAVEFORMS

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].
 

y[n] = x[n]*h[n] =  x[k ]h[n  k ] or  h[k ]x[n  k ]


k   k  

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.

STEPS IN LINEAR CONVOLUTION:


The process of computing convolution between x[k] and h[k] involves four steps.
1. Folding: Fold h[k] about k=0 to obtain h[-k]
2. Shifting: Shift h[-k] by „n0‟to right if „n0‟ is positive and shift h[-k] by „n0‟ to the
left if „n0‟ is negative. Obtain h[n0-k]
3. Multiplication: Multiply x[k] and h[n0-k] to obtain the product sequence
x[k] h [n0 –k]
4. Summation: Find the sum of all the values of the product sequence to obtain
values of output at n = n0
5. Repeat steps 2 to 4 for all possible time shifts „n0‟ in the range -  <n< 
METHODS FOR LINEAR CONVOLUTION:
Matrix Multiplication Method, Tabulation method and Graphical method.
CIRCULAR CONVOLUTION
The convolution of two periodic sequences with period N is called circular convolution of
two signals x1[n] and x2[n] denoted by
N 1 N 1
y[n] = x1[n] * x2[n] =  x 1 [(n-k) mod N] x2 [k] or
k 0
 x1[k ] x2 [(n-k) mod N]
k 0
where x1[(n-k) mod N] is the reflected and circularly translated version of x1[n].
x1[n] * x2[n] = IDFTN { DFTN (x1[n] ) . DFTN (x2[n])}

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.

METHODS FOR CIRCULAR CONVOLUTION:


Matrix Multiplication Method and Concentric Circle Method

Discrete Time Convolution Properties


Let f1, f2, f3 are the discrete time signals which satisfies the following properties

Associativity f1 ∗ (f2 ∗ f3) = (f1 ∗ f2) ∗ f3


Commutativity f1 ∗ f2 = f2 ∗ f1
Distribitivity f1 ∗ (f2 + f3) = f1 ∗ f2 + f1 ∗ f3
Multilinearity a (f1 ∗ f2) = (af1) ∗ f2 = f1 ∗ (af2)
Impulse Convolution f1 ∗ δ =f1

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.

SAMPLE ASSIGNMENT QUESTIONS:


1. For the same sequence perform the linear Convolution & Circular Convolution. Also
comment on the result
2. Compare convolution & correlation (conv, xcorr)
3. Find the discrete linear convolution for the following sequences x[n] and h [n] to get y [n]
through linear method and circular method
x [n] = [1, 1, 1,1,1] & h[n] = [2,2] and Prove manually also
4.Prove that the convolution of any sequence with unit sample sequence result in the same
sequence through linear method and circular method. Prove manually also

13
FLOWCHART:

START

ENTER THE DISCRETE


TIMEINPUT SEQUENCE

PERFORM THE DFT USING IN-BUILT FFT AND


USING DIRECT FORMULA ON THE GIVEN
INPUT SEQUENCE

PLOT THE MAGNITUDE AND PHASE


RESPONSE

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
n0

The inverse transform is defined as


N 1
1 j 2 n k N
x(n) 
N
 X (k ) e , for n  0...N  1
k 0
Although the functions here are described as complex series, setting the imaginary part to 0
can represent real valued series. In general, the transform into the frequency domain will be a
complex valued function, that is, with magnitude and phase.
Magnitude  X (k )  ( X real * X real  X imag * X imag ) 0.5

 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)).

disp: Display array.


disp (X) is called for the object X when the semicolon is not used to terminate a
statement.

max: Maximum elements of an array


C = max (A, B) returns an array of the same size as A and B with the largest elements
taken from A or B.

fft: Fast Fourier transform.


fft(x) is the discrete Fourier transform (DFT) of vector x. For the matrices, the FFT
operation is applied to each column. For N-Dimensional arrays, the FFT operation
operates on the first non-singleton dimension.

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.

SAMPLE ASSIGNMENT QUESTIONS:


1. Compute DFT of the sequence (sine wave) with N = 8, 16, 32, 50 sample points and
compare the results.
2. Find the spectrum of sum of two sin signals with frequencies f1=100Hz & f2=200Hz.
3. Implement the DFT in MATLAB by matrix method.
4. Perform inverse FFT by using forward FFT for the given complex number.
5. Explore in MATLAB about the following library functions FFT2 & FFTSHIFT.
6. Write a program in MATLAB to find the DFT of a given two sequence in direct
method and FFT method. Plot the error signal
a.x1 [n] = [1 1 11] b. x2[n] = [1 2 3 4]
7. Write a program in MATLAB to Prove that time domain convolution is equal to
frequency domain Multiplication.
a. x1 [n] = [1 1 2 2 ] b. x2[n] = [1 2 3 4 ].

17
FLOWCHART:

START

ASSIGN VALUES FOR THE


FILTER SPECIFICATIONS (PASS,
STOP BAND GAINS AND EDGE
FREQUENCIES)

DESIGN THE ANALOG BUTTERWORTH LOW


PASS FILTER

CONVERT THE LOW PASS FILTER IN TO


DIGITAL FILTER BY USING THE IMPULSE
INVARIANT AND BILINEAR
TRANSFORMATIONS

PLOT THE WAVEFORMS

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

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 )  
1  e TPk 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.

butter (N,Wn,'s'),butter (N,Wn,'low','s'),butter (N,Wn,'high','s'),butter


(N,Wn,'pass','s')and butter (N,Wn,'stop','s')design analog Butterworth filters. In this
case, Wn is in [rad/s] and it can be greater than 1.0.

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 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]
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.

angle : Phase angle.


Theta=angle (H) returns the phase angles, in radians, of a matrix with complex
elements.
freqs : Laplace-transform (s-domain) frequency response.
H = freqs(B,A,W) returns the complex frequency response vector H of the filter
B/A:

B(s) b (1)s nb-1 + b(2)s nb-2 + ... + b(nb)


H(s) = =
A(s) a(1)s na-1 + a(2)s na-2 + ... + a(na)

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.

tf: Transfer function


SYS = tf(NUM,DEN) creates a continuous-time transfer function SYS with
numerator(s) NUM and denominator(s) DEN. The output SYS is a tf object.

Impinvar: Impulse Invariant method for analog-to-digital filter conversion [bz,az] =


impinvar(b,a,fs) creates a digital filter with numerator and denominator coefficients bz and
az, respectively, whose impulse response is equal to the impulse response of the analog filter
with coefficients b and a, scaled by 1/fs. If you leave out the argument fs (or) specify fs as an
empty vector [ ], it takes the default value of 1 Hz.

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.

SAMPLE ASSIGNMENT QUESTIONS:


1. Design an IIR filter and test its stability. Apply the filter for different audio signal and
observe the result.

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

ASSIGN VALUES FOR THE


FILTER SPECIFICATIONS (PASS,
STOP BAND GAINS AND EDGE
FREQUENCIES)

DESIGN THE ANALOG CHEBYSHEV LOW PASS


FILTER

CONVERT THE LOW PASS FILTER IN TO


DIGITAL FILTER BY USING THE IMPULSE
INVARIANT AND BILINEAR
TRANSFORMATIONS

PLOT THE WAVEFORMS

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.

The magnitude-squared function is given as


2 1
H ( j ) 
1   C N ( / p )
2 2

 is the ripple parameter in pass band


CN(x) is the Nth order Chebyshev polynomial defined as
Cos( N cosh 1 x) , x 1

CN(x) = 
Cos( N cosh 1 x), x 1
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

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.

cheby1: Chebyshev Type I digital and analog filter design.

[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.

cheby1 (N,R,Wn,'s'), cheby1 (N,R,Wn,'low','s'), cheby1 (N,R,Wn,'high','s'), cheby1


(N,R,Wn,'pass','s') and cheby1 (N,R,Wn,'stop','s') design analog Chebyshev Type I
filters. In this case, Wn is in [rad/s] and it can be greater than 1.0.

Impinvar: Impulse Invariant method for analog-to-digital filter conversion [bz,az] =


impinvar(b,a,fs) creates a digital filter with numerator and denominator coefficients bz and
25
az, respectively, whose impulse response is equal to the impulse response of the analog filter
with coefficients b and a, scaled by 1/fs. If you leave out the argument fs (or) specify fs as an
empty vector [ ], it takes the default value of 1 Hz.

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

SAMPLE ASSIGNMENT QUESTIONS:


1. Design a Chebyshev filter with
Ap = 1dB ripple in the pass band 0    0.2
As = 15 dB ripple in the stop band 0.3    
using Bilinear transformation method. Realize the filter using MATLAB.
2. Design a Chebyshev filter with the following specifications
0.707  | H( ej)|  1 0    /2
| H (e )|  0.2
j
3 /4    
using impulse invariance method. Use MATLAB for realization.

27
FLOWCHART:

START

ASSIGN THE ORDER OF


THE FILTER AND CUT
OFF FREQUENCY

DETERMINE THE FILTER COEFFICIENTS USING


THE FUNCTION „fir1‟ FOR VARIOUS TYPES OF
WINDOWS

DETERMINE THE TRANSFER FUNCTION USING


THE FUNCTION „tf‟

DETERMINE THE FREQUENCY RESPONSE


OF THE FILTER USING THE FUNCTION
„FREQZ‟ AND PLOT THE MAGNITUDE AND
THE ANGLE RESPONSES.

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:

fir1 FIR filter design using the Window method.

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,'bandpass'). If Wn = [W1 W2], B = fir1(N,Wn,'stop') will design a


band-stop filter.

If Wn is a multi-element vector, Wn = [W1 W2 W3 W4 W5 ... WN], fir1 returns a N-


order multi-band filter with bands 0 < W < W1, W1 < W < W2, ..., WN < W < 1.

B = fir1(N,Wn,'DC-1') makes the first band a pass band.

B = fir1(N,Wn,'DC-0') makes the first band a stop band.

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,kaiser(N+1,4)) uses a Kaiser window with beta=4.

B = fir1(N,Wn,'high',chebwin(N+1,R)) uses a Chebyshev window with R decibels of


relative sidelobe attenuation.For filters with a gain other than zero at Fs/2, e.g., high
pass and band stop filters, N must be even. Otherwise, N will be incremented by one.
In this case, the window length should be specified as N+2. By default, the filter is
scaled so the center of the first pass band has magnitude exactly one after windowing.
Use a trailing 'noscale' argument to prevent this scaling, e.g.

B = fir1(N,Wn,'noscale'),

B = fir1(N,Wn,'high','noscale'),

B = fir1(N,Wn,wind,'noscale'). You can also specify the scaling explicitly,e.g.


fir1(N,Wn,'scale'), etc.

We can specify windows from the Signal Processing Toolbox, such as boxcar, hamming,
hanning, bartlett, blackman, kaiser or chebwin

w = hamming(n) returns an n-point symmetric Hamming window in the column vector w. n


should be a positive integer.

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).

w = rectwin(n) returns a rectangular window of length n in the column vector w. This


function is provided for completeness. A rectangular window is equivalent to no window at
all.

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?

SAMPLE ASSIGNMENT QUESTIONS


1. Design an FIR filter and test its stability. Apply the filter for different audio signal
and observe the result.
2. Design a Nine tap linear phase filter having ideal response
Hd (ej) = 1, | ω| ≤ /6
= 0, /6 ≤ | ω| ≤ /3
=1 /3 ≤ | ω| ≤  using Hamming window
Realize the filter using MATLAB.
3. Design an ideal filter with the following specifications
Hd (ej) = e - j 2, 0≤ | ω| ≤ /4
= 0, /4 ≤ | ω| ≤ 
using Hanning window. Realize the filter using MATLAB.

32
FLOWCHART:

START

INITIALIZE THE VARIABLES

DEFINE THE PARAMETERS FOR


SIGNAL GENERATION

GENERATE THE WAVEFORM BY USING THE


APPROPRIATE LOGIC

PLOT THE WAVEFORMS

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.
ProjectAdd files to ProjectSelect sinusoidal.c
5. Add the run time support library file rts6400.lib
ProjectAdd files to ProjectSelect 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
ProjectAdd files to ProjectSelect helo1.cmd from the below mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ 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.
FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
Select ViewGraphTime 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

INITIALIZE THE VARIABLES

ENTER THE INPUT SEQUENCE


AND THE IMPULSE RESPONSE
OF THE SYSTEM

PERFORM CONVOLUTION (LINEAR/CIRCULAR)


USING APPROPRIATE LOGIC

PLOT THE CONVOLUTED SEQUENCE AND


DISPLAY THE VALUE

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
 

y[n] = x[n]*h[n] =  x[k ]h[n  k ] or  h[k ]x[n  k ]


k   k  

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.

Output: y[r] = {1,4,10,20,25,24,16}.

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 2: Spin h[-m] n times anti-clock wise(counter clockwise) to get h[n-m]


(i.e. Simply rotate the sequence, h[n], clockwise by n steps)

Step 3: Pointwise multiply the f[m] wheel and the h[n-m] wheel and sum them up to get y[n].

Step 4: Repeat for all 0≤n≤N-1.

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. ProjectAdd files to ProjectSelect convolution.c
5. Add the run time support library file rts6400.lib
i. ProjectAdd files to ProjectSelect 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. ProjectAdd files to ProjectSelect helo1.cmd from the below
mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ 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. FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
i. Select ViewGraphTime 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

INITIALIZE THE DSP BOARD

INITIALIZE THE VARIABLES

READ THE INPUT SEQUENCE


AND IMPULSE RESPONSE OF THE
SYSTEM.

PERFORM DFT USING


APPROPRIATE LOGIC

PLOT THE MAGNITUDE AND


PHASE OF DFT SEQUENCE

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. ProjectAdd files to ProjectSelect convolution.c
5. Add the run time support library file rts6400.lib
i. ProjectAdd files to ProjectSelect 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. ProjectAdd files to ProjectSelect helo1.cmd from the below
mentioned path.
(Path c:\CCStudio\tutorial\dsk6416\hello1)
7. Compile the project using „ProjectCompile‟ 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. FileLoad Program
10. Run the program using „DebugRun‟ menu or press F5.
11. To view output graphically
Select ViewGraphTime 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

INITIALIZE THE DSP BOARD

CONFIGURE DSK6416_AIC23 (CODEC)

TAKE THE NEW INPUT DATA


FROM ANALOG IN OF CODEC
IN OF THE DSP BOARD

POLL THE READY BIT, OUTPUT =INPUT_DATA


WHEN ASSERTED PUT THE DATA IN
PROCEEDS. INPUT_DATA ARRAY

WRITE THE VALUE OUTPUT


TO ANALO G OUTPUT OF
CODEC

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.

McBSP1 is used as the unidirectional control channel. It should be programmed to


send a 16-bit control word to the AIC23 in SPI format. The top 7 bits of the control word
should specify the register to be modified and the lower 9 should contain the register value.
The control channel is only used when configuring the codec, it is generally idle when audio
data is being transmitted.

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

Embedded Target for TI C6000 DSP:


The Embedded Target for TI C6000 DSP platform integrates Simulink and Matlab
with Texas Instrument CCS 3.1. The software allows a user to develop DSP designs from
concept through code and automates rapid prototyping on the C6416 DSP starter kit. The
Build process builds a Code Composer Studio (CCS) project from the C code generated by
Real-Time Workshop. The CCS project is automatically compiled and linked, and the
executable is loaded onto your board, and run on the C6416 DSP.

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.

5. The FIR filter is designed using FDATool from


>> Signal Processing block set>>Filtering>>Digital Filter Design>>FIR

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

Embedded Target for TI C6000 DSP:


The Embedded Target for TI C6000 DSP platform integrates Simulink and Matlab
with Texas Instrument CCS 3.1. The software allows a user to develop DSP designs from
concept through code and automates rapid prototyping on the C6416 DSP starter kit. The
Build process builds a Code Composer Studio (CCS) project from the C code generated by
Real-Time Workshop. The CCS project is automatically compiled and linked, and the
executable is loaded onto your board, and run on the C6416 DSP.

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.

5. The FIR filter is designed using FDATool from


>> Signal Processing block set>>Filtering>>Digital Filter Design>>FIR

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

Вам также может понравиться