You are on page 1of 4

Mohammed Zafar Ali Khan zafar@iith.ac.

in
EE 5301 Course Phone: +91-40 2301 6010

EE 5301 DSP Lab
Department of Electrical Engineering, IITH


Lab 2
Digital Filters
Aim of the Experiment:
A goal of this experiment is to implement discrete-time (digital) filtering techniques in real
time.
In this experiment you will come across the special architectural features of digital signal
processors such as circular buffers that make the processors well suited for signal processing.
You will implement different digital filters using in two different programming approaches:
Using Circular Buffers in C program (a C program)
Using Circular Buffers supported by the TMS320C6713B Hardware
In this experiment, you will construct finite impulse response (FIR) filter and an infinite impulse response (IIR)
filter on the DSP. For the FIR method, you will use the C-based convolution routine as well as the two assembly
routines contained in the lab manual .
The response of these filters will be measured Using the codec and the signal generator/
oscilloscope
Directions:
Do everything in the lab manual (Sections 3.8.1, 3.8.2, 3.8.3).
Note: for the IIR part, use the "digital" option.
The list of tasks to complete for the lab is given at the end of this document and the
accompanying assembly code files convol1.sa and convolve.sa can be found from Prof.
Tretters website.

Lab Report
All measurements and findings should be in lab report (cycle counts, frequency response,
phase responses, etc.). Your report must contain the following:
1. Theoretical and experimental amplitude response of the FIR filter.
2. Profiler results for different optimization levels for FIR/C and FIR/Assembly.
3. Number of taps before you run out of time for FIR/C.
4. Why use circular buffers?
5. What restrictions does the C6713 impose on the use of hardware circular buffers and why?
6. Theoretical and experimental amplitude response of the IIR filter.
7. Theoretical and experimental phase response of the IIR filter.
8. What happens if you do not multiply by the scale factor in the IIR filter implementation?
9. Advantages and disadvantages of FIR vs. IIR filters.

Mohammed Zafar Ali Khan zafar@iith.ac.in
EE 5301 Course Phone: +91-40 2301 6010

EE 5301 DSP Lab
Department of Electrical Engineering, IITH

Milestones to Demonstrate to the TA
After each one of these parts, show them to the TA:
FIR using C routine (codec)
FIR using assembly routines (codec)
IIR filter (codec)
Coding Guidelines For this lab, it is especially important to realize that the addition of an
element into a circular array and the actual convolution calculation are two entirely separate
operations.
Labs 4, 5, and 6 will directly involve performing multiple convolutions for FIR filters, so it
makes sense to go ahead and put the Lab #2 convolution routine in a function.
As mentioned on the code grading page, the use of the C modulo operator "%" is discouraged
and will be penalized.

Recitation Slides for Lab 2 by Prof. Steven Tretter (See the attached filters.pdf file)

Assignment
Submit Q 6, 7, 13, 15 submitting others questions in this assignment is optional, but doing it
would be useful.
DIGITAL FILTERS

1 . Circular buffers are implemented in software by actually shifting the values in the
buffer locations circularly. (T/F)

2 . With 4/8/16 khz i/p signal how much time do you have to process a sample?

3 . Enumerate steps in setting up a circular buffer.

4 . Window method is an optimal filter design technique. (T/F)

5 . The REMEZ Algorithm uses an Analog to Digital Transformation to design digital filters
. (T/F)

6 . What is the delay in a causal FIR filter of N points.

7 . How can we compensate for the delay in Q 6. in a areal-time application.


8 . Explain the purpose of .cprog and .reg assembler directives in TMSC6701 assembly
language.


Mohammed Zafar Ali Khan zafar@iith.ac.in
EE 5301 Course Phone: +91-40 2301 6010

EE 5301 DSP Lab
Department of Electrical Engineering, IITH


9 . When implementing an FIR filter in TMSC6701 assembly, why is it necessary to
compute the first product before performing the remaining N-1 products using a parallel
instruction?

10 . How is an i/p sample stored in x circ[] made available to the assembly function
convol.ASM in a mixed implementation of the FIR filter.

11 . Draw an implementation of an IIR filter using FIR structures.

12 . Does the IIR filter designed by IIR.EXE always represent a stable filter?

13 . Use benchmarking to find out the time taken to process a sample in a
a) C
b) Assembly
c) mixed
implementation.


14 . Increase the order of your filter. What happens to the time to process a sample?

15 . What do you notice about the order of the FIR and IIR filters required to filter a given
data?




Detailed Tasks

This lab deals with designing and implementing digital filters. The design will be done using Matlab (fdatool) and
implementation will be done in the DSP.
We will be designing both FIR (Finite Impulse Response) as well as IIR (Infinite impulse response) filters.

WEEK 1:

Task 1: DSK Magnitude Response

Set the sampling frequency to 8kHz on the audio codec.
Measure the amplitude response of the DSK board by applying a sine wave from the signal generator to the line
input and loop samples internally in the DSP back to the line output. This means you will read both the channels
and write back to both the channels. You can then measure the voltage of the output and divide it by the voltage of
the signal you sent in. This is the gain. You can convert it to decibels (dB).

Obtain the gain in dB at these following frequencies:
400 Hz, 500 Hz, 600 Hz, 700 Hz, 1 kHz, 1.5 kHz, 2 kHz, 2.5 kHz, 3 kHz, 3.5 kHz and 4 kHz.


Task 2: FIR filter design


Design a Remez exchange 25
th
order band pass filter. f
s
= sampling frequency = 8kHz. f
low
= low cut off
frequency = 1kHz. f
high
= 2.5kHz. Use fdatool in Matlab. This is a FIR filter.
Obtain and store the filter coefficients.

We will be plotting a comparison of the theoretical and experimental magnitude response for the lab report.

Mohammed Zafar Ali Khan zafar@iith.ac.in
EE 5301 Course Phone: +91-40 2301 6010

EE 5301 DSP Lab
Department of Electrical Engineering, IITH


This is the first part of point #1 of lab report checklist available here:
Obtain the gain in dB for the theoretical plot from Matlab at these following frequencies:
400 Hz, 500 Hz, 600 Hz, 700 Hz, 1 kHz, 1.5 kHz, 2 kHz, 2.5 kHz, 3 kHz, 3.5 kHz and 4 kHz.

Task 3: FIR filter implementation

Write a circular convolution function. The function will be called convolve. The following will be the function
prototype to be used. Please do not change this as we will be comparing this C function with the assembly
convolve function (This is already available for use).

Prototype: float convolve (float *x, const float *h, const unsigned hlen, const unsigned xlen, const unsigned
newest).

Here x is the circular buffer, h is the filter coefficient array, hlen is the length of the filter coefficient array (in
words) = number of taps = filter order + 1, xlen is the length of the circular buffer array (in words), which is a
power of 2, newest is the newest index.

Modify labmain.c (use polling code).

o The code should initialize the filter coefficients.
o The code should read from both the left channel and right channel, update the circular buffer (using only
the left channel data) and update the newest index.
o The code should make a function call to the convolve function you wrote earlier.
o The code should output the result from the convolve function on the right channel and output the
unfiltered input to the left channel. This way you can see both the input and output on the oscilloscope.
To test the functionality of your code, feed different frequencies from the function generator to both the channels
of your Line In. Feed the stereo output coming from the Line Out to the oscilloscope. If you set it up right, you
should see the input on the left channel and the output on the right channel . Use the same frequencies from
Task 1. Obtain Vout/Vin and convert it into decibels (dB). This is the second part of point #1 of lab report.
Now, plot both the graphs on top of each other (Task 1 and Task 2). This compares the theoretical and the
experimental magnitude plots.

You might also like