Swarthmore College

Engineering Methodology

Digital Filtering Lab

OBJECTIVES

• To understand the concepts of resistance, capacitance, and inductance
• To learn the time and frequency characteristics of resistors, capacitors, and inductors.
• To construct simple filters from passive analog components
• To learn to write MATLAB programs to perform digital filtering of signals

PROCEDURE

I. Becoming familiar with the operation of capacitors and inductors in both time and frequency domains.

A. Select several R, L, and C components and measure their values with the RLC meter (label them below). Set up the following circuits on the breadboard using the breadboard's internal oscillator in a square-wave mode (you may adjust the frequency of the square-wave to see what happens). Examine both the input and the output of each circuit on an analog oscilloscope, and sketch the waveforms on this sheet next to the circuits with all pertinent information included on the figure.

B. Repeat the three circuits but with a sine wave as input. Vary the frequency of the sine wave in 20 increments and record both the peak-to-peak input voltage and the peak-to-peak output voltage for each frequency. Type these data into Matlab (create a script) and plot them with angular frequency on the x-axis and the decibel ratio of output to input voltage on the y-axis. These are Bode plots describing the frequency response of the circuit.

II. Write a Matlab script to generate 1 second of white noise (using the Matlab rand function) and play it on the computer at the default rate of 22254 Hz (using the Matlab sound function). Prompt the user for a frequency (in Hz) to correspond to the "knee" of low-pass and high-pass filters (use the variable knee). The following commands will generate low-pass and high-pass digital filters (4th order Butterworth) with a "knee" at the user's desired frequency:

[B,A] = butter(4,2*pi*knee); % low pass digital filter

[D,C] = butter(4,2*pi*knee,'high'); % high pass digital filter

Apply the digital filter coefficients A and B (for low-pass filter) or C and D (for high-pass filter) to the data in the white noise array to generate pink and blue noise, respectively. To do this , use the Matlab filter command as follows (assuming you have the white noise data in an array called white):

pink = filter(B,A,white);

blue = filter(D,C,white);

Have the script play the filtered sounds for the user to hear, and loop back so that the user can try other "knee" frequencies and hear the results. When it is finished, hand in the script in the usual way (please name your script with your username and then a "6" before the ".m"). Also remember to put your name on this sheet and hand it in to show your sketches in Part I.A.