Digital Filters

Aim of the Experiment

A goal of this experiment is to design discrete-time digital filters and implement them in real time.

In this experiment, you will design and implement finite impulse response (FIR) filters and infinite impulse response (IIR) filters in Matlab. You will implement digital filters using linear and circular buffers. Circular buffer implementation can be accelerated using special instruction set architectural features such as hardware addressing modes to perform the modulo indexing into an array. You will measure the response of the filters using a variety of input test signals and quantify the change in magnitude response due to an increase in filter order.

Reading assignment


Downloads

Recitation slides part 1, part 2 and part 3 by Mr. Chao Jia and Ms. Debarati Kundu, The University of Texas at Austin

Lab #3 instructions part 1, part 2 and part 3 by Mr. Yunseong Cho and Mr. Dan Jacobellis, The University of Texas at Austin

MATLAB code


Supplemental Information

FIRmono_ISRs.c

Assembly code files convol1.sa and convolve.sa

LabVIEW transmitter demonstration by Dr. Zukang Shen to show how labs 1-6 fit together

Overview Slides by Prof. Steven Tretter, University of Maryland (from Jan. 2008 lab manual)


Lab Report

All measurements and findings should be in lab report (cycle counts, frequency response, phase responses, etc.). In addition, please answer the following questions:

  1. Number of taps before you run out of time for FIR filtering.
  2. Why use circular buffers?
  3. What happens if you do not multiply the scale factor in an IIR filter implementation using a cascade of second-order sections (SOS)?
  4. Advantages and disadvantages of FIR vs. IIR filters.
Note from second week of lab: The frame-based FIR program filters both the left and the right channel, and the sample based FIR filter filters only one channel. So, the number of machine cycles for frame-based filtering should be divided by two in order to be compared with the corresponding value for sample-based filtering.

Milestones to Demonstrate to the TA

After each one of these parts, show them to the TA:

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 5, 6, and 7 will directly involve performing multiple convolutions for FIR filters, so it makes sense to go ahead and put the Lab #3 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.


Debugging and Troubleshooting Tips

MATLAB tips

For IIR filter implementation, a common mistake is to forget to negate the feedback coefficients. For a biquad, the difference equation for the output y[n] given the input x[n] is
 
y[n] = a1 y[n-1] + a2 y[n-2] + b0 x[n] + b1 x[n-1] + b2 x[n-2]
The transfer function, which assumes zero-valued initial conditions, is
 
         -1      -2
b0 + b1 z  + b2 z  
-------------------
        -1      -2
1 - a1 z  - a2 z   
Note the negative signs in front of a1 and a2.

Board tips

When connecting the USB cable from the PC to the C6748 DSP board, please use the USB port on the opposite side of the board from the power connector.

Here are troubleshooting tips for Code Composer Studio v4.

Here are general tips for debugging and troubleshooting:

  1. Please notice which channel are you using when reading samples from signal generator. You can also use T connector to feed both channels with signal.
  2. Some students found that the frame-based FIR filter yielded a larger number of machine cycles compared to sample-based FIR filtering. The frame based FIR program filters both the left and the right channel, and the sample based FIR filter filters only one channel. So, the number of machine cycles for frame-based filtering should divided by two in order to be compared with the corresponding value for sample-based filtering.

When seeing an incorrect output on the oscilloscope, the cause may be one of the following:

  1. Changed the sampling rate in Interrupt Service Routine (isr) file but forgot to change it in the configuration file. The sampling frequency specified in isr file is only used for computation.
  2. The interrupt is not working. Even though the interrupt is not working, the oscilloscope could still show sinusoidal-like noise. This can be easily checked by measuring the magnitude of the waveform, and knowing that noise should have a very small magnitude.
  3. Using the single-channel versions of ReadSample(data) and WriteSample(data) defined in the files for lab 3. These functions have bugs in them. Instead, use the two-channel versions ReadSample(left, right) and WriteSample(left, right).


Assignment

Submitting this assignment is optional, but doing it would be useful with your QUIZ preparations

Assignment

Back to the course home page


Next Experiment

Previous Experiment