You are on page 1of 7

Lakehead University

Department of Electrical Engineering

Lab Manual
Engr. 0532 (Digital Signal Processing)

Instructor: Dr. M. Nasir Uddin

Last updated on January 16, 2003

1
Contents:

Item Page #

Guidelines 3

Lab #1 4

Lab #2 6

Lab #3 7

Lab #4 7

2
Guidelines:

Group formation – For labs 1 and 2 two students will be working in a group. For labs 3 and 4
four students will be working in a group.

Attendance – You must have to complete all the four labs, otherwise your result for
Engr.532 (DSP) will be incomplete. Labs 1 and 2 are project type of labs and
you will do it on your own way. For Labs 3 and 4, you have to be present
physically in the al b to do the experiment at the scheduled time (Check with Mr.
Bruce Misner – Technologist for this course) of your group.

Report - Labs 1 and 2 are based on Matlab programming and Labs 3 and 4 are based on
assembly language programming of DSKC50 DSP. In the report include all the
codes, calculation, observations, answer to the questions, plots and discussions (if
any). Submit Labs 1 and 2 directly to the Instructor and Labs 3 and 4 to the
Technologist.

Marks - Total marks for the lab is 15. Each of the labs is weighted equally.

Deadline – The deadline to submit labs 1 and 2 is the last day of class. Labs 3 and 4 are due
two weeks after those are performed.

3
Lakehead University
Dept. of Electrical Engineering
Engr. 0532 (Digital Signal Processing)

Lab #1 (Signal Processing with application of Correlation and Convolution)

Instructor: Dr. M. Nasir Uddin

1) The objective of this lab is to determine the distance between a transmitter and an object
reflecting the signal being transmitted.

A data set with 4 signals (sampled at 1ms) in different columns is stored in a file
(dsl.mat=file name) in the Lab. computer. The first column is the signal sent out and
columns 2, 3 and 4 of this file contain various return signals after reflection. By using
correletion between the signal in column 1 and signals in columns 2, 3 and 4 answers to the
following questions will be sought: a) Is(are) there object(s) reflecting the input signal in the
received signals in each of columns 2, 3 and 4. If so, how many. b) If the signal velocity is
700m/sec, what is the distance of such objects from the receiver/transmitter (located at the
same site).

Procedure:
a) In Matlab write the following codes:

load ds1.mat; (then do)

r1=Xcorr(ds1(:,1),ds1(:,2));
r1=r1/4096; % (4096=of samples in each column)
plot(r1);
(if needed) [a1,b1]=ginput(2) %click at desired points using mouse, a1 will contain the X-
coordinate of plot at point clicked.

Similarly find the correlation between col. 1 and other columns. After correlation check
whether any spike (which should be far from the noise threshold level) exists, if so that will
indicate the object.

b) The distance between the object and the receiver/transmitter can be determined as,
1
d = S − 4096 Ts V
2
where, S is the number of sample at which the reflection (spike) occur, Ts is the sampling
period and V is the velocity of the signal.

2) The impulse response of an LTI system is given be, h [n]={1/2, 1, 2, 1, 1/2}. Calculate

the output sequence y[n] by hand if the input to the system is, x[n]={0, 1, -2, 3, -4}.

4
Verify your calculation by using Matlab function conv. Print this result and mark the correct
starting instant on the result from Matlab.

3) A data set containing a periodic sine wave of unknown frequency corrupted by noise is
available in the file ds2.mat (approximate SNR = -21 dB) with sampling period =1 ms.

a) consider the probability of estimating the frequency of this sinusoid by doing an


autocorrelation (normalized) on this data. Can this be done? Are you confident of this
estimation? If affirmative, particularly in the light of the cross-correlation of Q-1 in this
lab.

b) Now consider cleaning up the raw signal by a simple (exponential) filter (first order
low pass filter)
y[n] = a y[n-1] +x[n], y[0]=0

where, x[n] = noisy signal and y[n]= hopefully less noisy signal after filtering. A routine
called ‘clean’ (which actually represents the above filter) is available. y = clean (a,x) is its
calling sequence (file clean.m). Try cleaning the raw signal using this routine with values of
a = 0.95 to 0.99 in a step of .01. Using the cleaned raw signal, compute the auto-correlation
and estimate the frequency of the original signal.

Procedure:

b) After autocorrelation (Matlab function ‘xcorr’) of the cleaned signal find x-coordinate of each
peak. Difference between successive peaks will be the period. Make an average of these periods
and multiply by the sampling time to get the estimated period in seconds.

5
Lakehead University
Dept. of Electrical Engineering
Engr. 0532 (Digital Signal Processing)

Lab #2 (Signal Processing with application of DFT (FFT) and DTFT)

Instructor: Dr. M. Nasir Uddin

1) The inrush current to a 60 Hz Transformer has been sampled at 1000 Hz. The sampling is
done after feeding the continuous time signal to a 2nd order low pass filter with transfer
ω 2n . Find the frequencies (in
function H ( s) = 2 , where ωn = 2p x 4 x 60 and ?=1/√2
S + 2ζω n S + ω n
2

Hz) of the harmonics in the signal & their corresponding amplitudes the data of 4096 pts is stored in file
ds3.mat.

Procedure:
Do the FFT analysis of data in ds3.mat. In order to get the amplitude spectrum take the absolute
value of current at each harmonic. Calculate the frequency using the formulae,

Frequency = Number of samples where the magnitude exists x Resolution

sampling frequency (1000 Hz )


Where, Resolution =
Total number of samples used for FFT
Now plot the amplitude spectrum of the low pass filter. Get the magnitudes introduced by the
filter at the corresponding frequencies and then do the correction to get the actual magnitude of
the inrush current at different frequencies.

2) Consider the rectangular pulse defined by ,

r[n] = 1, 0≤n<L

0, elsewhere

a. Show that the DTFT of r[n] is given by the mathematical formula


ωL
sin( )

R( e ) = 2 e − jω ( L −1) / 2
ω
sin( )
2
b. Evaluate DTFT of a 12 point pulse using Matlab ‘dtft’ function. Make plot of the DTFT
values versus ω over the range -π ≤ ω ≥ π. Plot the magnitude and phase of the DTFT.
Comment on the plots. To make the plot appear smooth choose a number of frequency
samples that is 5 to 10 times the pulse length.

c. Repeat (b) when the pulse length L=15. Notice the zero locations and the peak height.

6
ENG 0532 – DSP Lab #1
Objectives

Lab #3 – The objectives of this lab are to become familiar with the TMS320C50 DSK board, its
assembly codes and how to run the codes through the Linker/Loader or Debugger.

The report should include functional block diagram of the board , explanation of the
observations you made in the lab and verification of the frequencies and the sampling rates.

Lab #4 – The objective of this experiment is to design a 2nd order band pass digital IIR filter
based on a certain center frequency and bandwidth. Another objective is the experimental
verification of your design through the DSK board.

The report should include the necessary codes with explanations which reflect your
understanding about the codes.

Instructions

First with lab1.asm do

Edit program so that the AIC_CTR variable is 18h. This disables the bandpass filter and
sets the gain to 1 (+/-3V input).

To assemble type dsk5a lab1

To run type dsk5l lab1

Set the function generator to 800 Hz square wave input. Grab the waveform from the
scope. Then decrease the frequency to 400 Hz. Sketch the waveform. Comment on changes in
waveform shape.

Now edit program to set AIC_CTR to 19h enabling bandpass filter and change TA
register variable to 90. This divides the 10 MHz master clock by this value and modifies the
sample rate of both A/D and D/A. Recompile and download, then set the function generator
back to 800 Hz. Sketch and comment on the waveforms.

Next with lab2.asm do

Set the function generator to 500 Hz. What is the wave shape. Now, scan frequencies
highe rand lower than 500 Hz. What kind of filter is it? From the transfer function obtained from
within the code, calculate the cutoff frequencies.

You might also like