Department of Electrical and Electronic Engineering Dedan Kimathi University of Technology Digital Signal Processing Laboratory Manual
Department of Electrical and Electronic Engineering Dedan Kimathi University of Technology Digital Signal Processing Laboratory Manual
Department of Electrical and Electronic Engineering Dedan Kimathi University of Technology Digital Signal Processing Laboratory Manual
May 2015
Contents
1 Introduction 2
1.1 Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 System Setup 2
2.1 Software Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1
1 Introduction
This laboratory manual is designed to accompany the Digital Signal Processing (DSP) course at
Dedan Kimathi University of Technology. It describes laboratory exercises aimed at integrating
the Raspberry Pi into the curriculum. The development of these laboratory exercises was made
possible by a generous grant from The Kenya Education Network (KENET).
The Raspberry Pi which retails at approximately $30 was developed with the aim of improving
computing education by providing access to an affordable computer with most of the capabilities
of a modern computer. It is about the size of a credit card (see Figure 1) and as we will see in
the labs described here, it can perform a number of important DSP tasks.
Figure 1: The Raspberry Pi. A Kenyan bank card is shown for comparison.
2 System Setup
The computing environment used in this lab is the raspbian Debian Wheezy operating system.
This operating system is quite similar to Ubuntu. The labs will be based on Octave, which is very
similar to MATLAB, and will make use of other open source tools such as SoX, the Swiss Army
knife of sound processing programs. The exercises have been tested on Octave version 3.6.2.
To install Octave, ensure you are connected to the internet and type sudo apt-get install
octave
We will also require the signals package which can be installed by typing sudo apt-get install
octave-signal
2
To install SoX type sudo apt-get install sox
These software has already been installed on the devices that will be issued to you. To verify
that the pieces of software are installed you should type octave --version and sox --version on the
command line.
3.2 Background
Octave is a high level programming language that is very similar to Matlab. It is very useful
for numerical computations and this makes it ideal for prototyping DSP applications. Also, by
making use of a number of packages, you have access to a number of useful functions.
3. To determine the version of Octave installed, type version in the command line.
5. We can define variables and perform mathematical operations on them for example
octave:1> N=2
octave:1> N*N
3
3.2.3 Built in Functions
There are a number of built in functions in Octave
4. To find out what a function does and how it works, use help. For example help sin.
3. We can determine the dimensions of the vector using the function size(a)
4. As defined, a is a row vector. We can form a column vector by typing a which computes
the transpose of a vector.
5. We can create M-by-N matrices using the functions ones and zeros. For example
ones(2,2)
6. We can take the element-wise multiplication of two vectors using the .* operator, for example
a.*a.
7. We can also take the dot product of two vectors by multiplying the vectors a*a
8. Two compatible matrices can be multiplied using the * operator, for example ones(5,5)*ones(5,1)
4
(b) Define y, y=x;
(c) To generate the figure type plot(x,y)
3. Explore the use of title, xlabel, ylabel, legend to label the axes and include titles for graphs.
4. The figure can be saved as a jpeg file by typing print(figname.jpg,-djpg)
5
The file is saved as function name.m and this function can be called from other scripts.
3.3 Procedure
1. Sample the function x(t) = sin(2t) at 100Hz and plot the function for 2 t 2. What
is the period, T0 , of x(t)? What is the sampling period Ts ?
2. Let x[n] be the discrete time signal formed from sampling x(t) at 100Hz. Is x[n] periodic?
What is the period N ? If x[n] is periodic, select an index n and print x[n] and x[n + N ].
Are the values equal? If not explain any differences observed.
(c) Write a for loop to estimate Px . How does your value compare with the value computed
theoretically.
6
A Laboratory Report Format
For each of the laboratory exercises in this manual, you will be required to had in a report. Each
report should have the following sections:
1. Title page:
The title page should include
2. Introduction:
In the introduction you should indicate the objectives of the laboratory and give any nec-
essary background information such as relevant theory.
3. Procedure:
Here you should describe in detail the steps carried out in the lab. The details should allow
someone else to reproduce your work. You can include short code segments here but code
listings should be placed in the appendix.
5. Conclusion:
Summarize the laboratory report and indicate whether the objectives of the lab were
achieved.
6. References:
Include any references using the IEEE format http://www.ieee.org/documents/ieeecitationref.
pdf.
7. Appendix:
Include any additional information such as detailed schematics and code listings here.