# Fundamentals of Signals and Systems _SOLUTION

Lab 3: Continuous-Time Filter Design and Analysis

Files necessary to compute this assignment: clean.wav, noisy.wav

Equipment necessary to compute this assignment: A ﬁlter board that can be checked-out from the stockroom (do not check out until you need it), resistors (1: 29 kΩ, 6: 16 kΩ, 1: 68 kΩ, 1: 24 kΩ, and any others needed for your ﬁnal design), and capacitors (1: 0.001 µF, 2: 0.01 µF, and any others needed for your ﬁnal design).

Introduction

Many traditional analog circuits are designed through the principles of Fourier analysis. Common types of analog circuits are lowpass ﬁlters, highpass ﬁlters, bandpass ﬁlters, bandstop ﬁlters, and allpass ﬁlters. Lowpass ﬁlters remove high frequency content from a signal. Highpass ﬁlters remove low frequency content from a signal. Bandpass ﬁlters retain small sections (bandwidths) of frequencies and remove all other frequency content. Bandstop ﬁlters remove small sections (bandwidths) of frequencies and retain all other frequency content. Allpass ﬁlters distort signals while not aﬀecting the magnitude response of the signal.

In this lab, we will focus on developing lowpass analog ﬁlters. These ﬁlters are frequently used in systems to remove high frequency noise and aliasing eﬀects. Speciﬁcally, we will design and build a lowpass ﬁlter with operational ampliﬁers (op-amps). We will use this lowpass ﬁlter to remove noise from a music signal.

This lab assignment has three learning objectives:

1. To analyze a complex op-amp ﬁlter design using continuous-time Fourier analysis

2. To design a op-amp ﬁlter for a speciﬁc noise removal application

3. To experimentally build that design with op-amps and test its eﬀectiveness

Your experiment will be divided into three parts. In your lab report, you should address each part in separate subsections. See the lab report guidelines on the class website for more information.

Deliverables

This lab assignment has three deliverables:

1. One (1) lab report (see the “Lab Report Guidelines” on how to write it)

2. One (1) name processed.wav ﬁle with your digitally ﬁltered version of name processed.wav

3. One (1) demonstration of you analog ﬁlter system to your lab instructor

Please submit a hard copy of the paper deliverables and e-mail the electronic deliverables to your lab instructor before your assigned lab session between Nov. 18th – Nov. 24th.

1

Part 1: Analyzing a high-order ﬁlter system

In this part of the lab, we will analyze ﬁlter system with operational ampliﬁers (op-amps) and continuous-time Fourier analysis. First, we will analyze a bi-quad ﬁlter systems, which is based on an collection of inverting op-amp systems. We will then analyze a ﬁrst-order noninverting low-pass ﬁlter system. Finally, we will combine one ﬁrst order noninverting low-pass ﬁlter system with two bi-quad ﬁlter systems. This is the system that will experimental with in the rest of the lab.

In this part lab, you will use MATLAB to analyze the low-pass ﬁlter system and bi-quad ﬁlter systems. In the next section, we will experimental validate your analysis.

Analyzing inverting op-amp systems:

The inverting op-amp system: −

+

Z2(ω)

x(t)

y(t)

Z1(ω)

x(t) −

Z1(ω) Z2(ω)

y(t)

Figure 1: An inverting op-amp circuit (left) and it block diagram representation (right)

The op-amp realization as shown in Figure 1 is of an inverting ampliﬁer. The transfer function of the inverting ampliﬁer is deﬁned by

H(ω) =

Y (ω) X(ω)

= −

Z1(ω) Z2(ω)

.

If you are familiar with impedances in terms of s, i.e. Z1(s) and Z2(s), assume s = jω.

On the left side of Figure 1, we see the circuit diagram for the inverting ampliﬁer. On the right side of Figure 1, we see the equivalent block diagram system representation of the operational ampliﬁer system. We will use these block diagrams to simplify our ﬁlter representations when build a bi-quad ﬁlter from inverting ampliﬁer circuits. In the following sections, we will analyze speciﬁc realizations of the inverting ampliﬁer. These realizations will gradually lead to building a bi-quad ﬁlter system.

Analyzing analog ﬁlters in MATLAB: Throughout this lab, we will be analyzing analog ﬁlters. We will want to plot their transfer function magnitude and phase characteristics. We will do this using the MATLAB function freqs(num, den). When given no output, freqs plots the magnitude and phase of the transfer function is with numerator num(1)sN+num(2)sN−1+···+num(N-1)s+num(N) and denominator den(1)sM + den(2)sM−1 +···+ den(M-1)s + den(M), where N = length(num) and M = length(den) and s = jω.

2

A classic inverting op-amp system: −

+

R2x (t)

y(t)

R1

x(t) −

R1 R2

y(t)

Figure 2: An classic inverting op-amp circuit (left) and it block diagram representation (right)

For the inverting op-amp system in Figure 1, when Z1(ω) is a resistor R1 and Z2(ω) is a resistor R2, we have an inverter. This is shown in Figure 2. In the frequency domain, the transfer function for this system can be expressed as

H(ω) =

Y (ω) X(ω)

= −R1 R2

.

MATLAB Exercise: Let R1 = 16 kΩ and R2 = 16 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

An integrator system: −

+

R4x (t)

y(t)

C3

x(t) −

1 jωR4C3

y(t)

Figure 3: An integrator op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when Z1(ω) and Z2(ω) represents a resistor and capacitor, respectively, we generate an inverting integrator. This is shown in Figure 3. We call this system an inverting integrator because the input-output relationship for the system (assuming x(0) = 0) is

y(t) = −

1 R4C3Zt1 0

x(τ)dτ .

The time-domain impulse response h(t) and the frequency-domain transfer function H(ω) of the integrator system is given by

h(t) = −

1 R4C3

u(t) , H(ω) =

Y (ω) X(ω)

= −

1 jωC3 R4

= −1 jωR4C3

MATLAB Exercise: Let C3 = 0.01 µF and R4 = 16 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

3

An integrator system with decay: −

+

R8x (t)

y(t)

R7

C7

x(t) −R7 R8(1 + jωR7C7)

y(t)

Figure 4: An integrator with decay op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when Z1(ω) and Z2(ω) represents a resistor and a parallel resistor-capacitor, respectively, we generate an inverting integrator with decay. When integrating, this system adds recent values with greater weight than older values.

The time-domain impulse response h(t) and the frequency-domain transfer function H(ω) of the integrator with decay system is given by

h(t) = −

1 R8C7

e−1/(R7C7)u(t) , H(ω) = Y (ω) X(ω)

= −R7 R8(1 + jωR7C7)

.

MATLAB Exercise: Let R7 = 68 kΩ, C7 = 0.01 µF, and R8 = 1 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and plot its transfer function H(ω).

A summation system: −

+

Z3(ω)

x2(t)

Z2(ω)

x1(t)

y(t)

Z1(ω)

x1(t)

Z−1 2 (ω) P −Z1(ω) y(t)

Z−1 3 (ω)

x2(t)

Figure 5: An summation op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when a new input is added with input impedance Z3(ω), we generate summation system. This is shown in Figure 5. A summation system allows us to add multiple inputs together.

The frequency-domain transfer function H(ω) of the summation system is given by Y (ω) = −Z1(ω)X1(ω) Z2(ω) + X2(ω) Z3(ω) .

4

Combining systems: In this previous subsections, we analyzed fundamental inverting ampliﬁer circuits. Now we will demonstrate how to combine these circuits together through system analysis and the properties of the Fourier trasnform.

A cascaded system:

x(t)

H1(ω) H2(ω)

y(t)

Figure 6: A cascade system.

Figure 6 shows a cascaded system where the output of one system become the input of the next. In Part 1 of the course, we learned that the time-domain impulse response of the overall system is given by the convolution of the two impulse responses. The frequency-domain transfer function of the overall circuit is given by the convolution property of the Fourier transform h(t) = h1(t)∗h2(t) F ←→ H(ω) = H1(ω)H2(ω) . This implies that if we can easily combine our systems to build better ﬁlters by feeding the output of one ﬁlter into the input of the next.

A feedback system:

x(t) P H1(ω)

H2(ω)

y(t)

Figure 7: A feedback system.

Figure 7 shows a feedback system where the output overall system is manipulated and then added back to the input. In a feedback system, the system H1(ω) is often known as the “plant” or “process” that modiﬁes a signal over time. The system H2(ω) is often known as the “controller” that steers your output y(t) to a particular value.

The frequency-domain transfer function for a feedback system is deﬁned by

H(ω) =

Y (ω) X(ω)

=

X(ω)H1(ω) + Y (ω)H1(ω)H2(ω) X(ω) H(ω) = H1(ω) + H(ω)H1(ω)H2(ω) H(ω)(1−H1(ω)H2(ω)) = H1(ω) H(ω) = H1(ω) 1−H1(ω)H2(ω) This shows that we can use the Fourier transform to analyze a rather complex process, such as a feedback.

5

A bi-quad ﬁlter system: −

+

R8x (t)

R7

C7 −

+

R4

y(t)

C3 −

+

R2

R9

R1

x(t)

H1(ω) P H2(ω) H3(ω)

H4(ω)H 5(ω)

y(t)

Figure 8: An bi-quad op-amp circuit (top) and it block diagram representation (bottom)

Figure 8 shows a bi-quad ﬁlter. The top part of Figure 8 shows the circuit representation and the bottom part of Figure 8 shows the equivalent block diagram which corresponds to each of the circuits and properties discuss in the previous subsections.

Use everything we previously learned about to derive the transfer function of this system. You will ﬁnd that the transfer function for the bi-quad circuit is deﬁned as

H(ω) =

(R2R9R7/R8) R7R1 + R2R9(1 + jωR7C7)R4C3jω

Furthermore, this can be simpliﬁed into the form

H(ω) =

Kω2 c −ω2 + jBωcω + Aω2 c

where K = (R9/R8), ω2 c = 1/(R4R9C3C7), Bωc = 1/(R7C7), and A = R1/R2. MATLAB Exercise: Let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 68 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and plot its transfer function H(ω). Repeat this analysis for R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 24 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. What changed?

6

A ﬁrst-order noninverting low-pass ﬁlter: −

+

R1x (t)

y(t)

R2

R3

C1

Figure 9: A ﬁrst-order low-pass ﬁlter circuit (left) and it block diagram representation (right)

Figure 9 shows a ﬁrst-order noninverting low-pass ﬁlter made with op-amps (note: the bi-quad ﬁlter system is a second-order ﬁlter). In our experimental setup, we use this system and two bi-quad ﬁlters. The frequency-domain transfer function for the ﬁrst-order noninverting low-pass ﬁlter is

H(ω) =

1 + (R3/R2) 1 + jωR1C1

MATLAB Exercise: Let R1 = 29 kΩ, R2 = 1 kΩ, R3 = 1 kΩ, and C1 = 0.001 µF. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

Our experimental setup (putting everything together):

x(t)

First-order low-pass ﬁlter Bi-quad ﬁlter # 1 Bi-quad ﬁlter # 2

y(t)

Figure 10: A block diagram of our complete ﬁlter system.

Figure 10 illustrates the system we will be designing and testing throughout the rest of this lab. It consists of a ﬁrst-order low-pass ﬁlter in series with two bi-quad ﬁlters. When cascaded together, we build a 5th-order ﬁlter (one 1st-order ﬁlter and two 2nd-order ﬁlters).

Use the properties you previously learned in this lab to derive the transfer function for the entire ﬁlter system in Figure 10. You may want to use the function tf in MATLAB to help you.

MATLAB Exercise: • For the ﬁrst-order non-inverting low-pass ﬁlter, let R1 = 29 kΩ, R2 = 1 kΩ, R3 = 1 kΩ, and C1 = 0.001 µF. • For the ﬁrst bi-quad ﬁlter, let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 68 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. • For the second bi-quad ﬁlter, let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 24 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ.

Use the MATLAB function freqs (with no outputs and s = jω) to analyze this complete system and plot its transfer function H(ω).

7

Include in Lab Report “Experimental Design” Section:

Include: A block diagram of your bi-quad ﬁlter similar to bottom plot of Figure 8, but with the transfer functions H1(ω), H2(ω), H3(ω), H4(ω), and H5(ω) identiﬁed (in terms of resistances, i.e., R1, R2, etc., and capacitances, i.e., C3,C7). Include: A block diagram of the of the entire ﬁlter system, similar to Figure 10.

Include in Lab Report “Analytical Methods” Section:

Include: Your derivation of the bi-quad ﬁlter (using the other transfer functions and properties discussed in this lab).

Include in Lab Report “Results and Discussion” Section:

Include: Your MATLAB plots of the each bi-quad circuit’s transfer function.

Include: Your MATLAB plot of the ﬁrst-order non-inverting low-pass ﬁlter circuit’s transfer function.

Include: Your MATLAB plot of the entire system’s transfer function

Answer: With the given conﬁguration, would you consider each of the stages (and the system as a whole) low pass ﬁlters?

8

Part 2: Validate your analysis

Check out a customized ﬁlter board from the stockroom. The diagrams in Figure 11 and Figure 12 illustrate the circuit board that we will use. Note that some of the boards diﬀer slightly from the diagram. To power the board, attach a +15 V line to the red input, attach a -15 V line to the blue input, and attach the ground to the green input. Before inputting a signal the board, verify your setup with your lab instructor.

R1

C1

R1

R2

C3R4R7

R1

R2

C3R4R7

Figure 11: Block diagram of the circuit board.

Figure 12: Block diagram of the circuit board.

Our goal is to verify our analyses from part one. Collect the necessary resistors and capacitors speciﬁed at the end of Part I to build the system. Note that several capacitors and resistors are already on the board. Speciﬁcally, R2 and R3 for the ﬁrst-order noninverting low-pass ﬁlter are already on the board. Also, C7 R8, and R9 for each of the bi-quad ﬁlters are already on the board. Place the remaining resistors and capacitors into the appropriate locations.

Using the equipment available to you, measure the magnitude response of each block (the ﬁrstorder low-pass ﬁlter and each of the bi-quad ﬁlters). Measure the frequency responses by inputting sinusoids at diﬀerent frequencies and measuring the amplitude of the response. Estimate the phase response by estimating the time lag between the input and output signals and converting the lag to radians. First measure the response for each stage separately and then measure the response for the entire system.

9

Plot the frequency response on log-log graphes for magnitude and phase similar to that generated by the freqs MATLAB function. You must have at least 20 measurements from 100 Hz to 20 kHz. Choose your frequencies so that they are uniformly (at least approximately) distributed on the log-log graph. Compare your measurements with the MATLAB plots results from Part I.

Include in Lab Report “Results and Discussion” Section:

Include: Your frequency response plots of the each bi-quad circuit’s transfer function.

Include: Your frequency response plots of the ﬁrst-order non-inverting low-pass ﬁlter circuit’s transfer function/

Include: Your frequency response plots of the entire system’s transfer function.

Answer: Does your analysis from Part I match your experimental results? If not, why?

Answer: Do these results illustrate a low pass ﬁlter? Is it a “good” low pass ﬁlter? What makes a ﬁlter “good?”

10

Part 3: Designing and implementing an analog ﬁlter

Analyze the music: In this part of the lab, we will combined everything we previously learned to design our own analog ﬁlter and implement it with our ﬁlter board. Two pieces of music should be included with the lab. One ﬁle (clean.wav) is a clean segment of Christopher Tin’s “Baba Yetu.” The other ﬁle (noisy.wav) was obtained by adding noise to the clean signal. These digital signals are sampled at fs = 44100 samples/s.

Our goal is to design an analog ﬁlter that will remove the noisy components from (noisy.wav). We will use clean.wav to determine the low frequency range containing all the signiﬁcant the components for the clean signal. Note that, in practice, we usually do not have the clean signal. In this case, however, the clean signal will help to design the best possible ﬁlter.

Load clean.wav using the functions you learned in Lab 2. Estimate the frequency components of the clean signal with the power spectrum estimation function

pwelch(x,hann(1024),512,2048,fs)

with the parameters given above. This is similar to the fanalysis function used in Lab 2, but slightly more sophisticated. We will not get into the details in course (if you want to learn more, look up “Welch’s method”).

From the resulting plot generated by pwelch, identify a continuous range of frequencies for which the signal spectrum is within 20 dB of the frequency component with the maximum strength. This represents the dominate frequencies in the music.

Design the analog ﬁlter: Using MATLAB and the freqs function, choose component values to design a ﬁlter (based on the 3-stage ﬁlter system we are using experimentally) that retains frequency components within the range of the music (determined in the previous subsection) and removes frequency components outside the range of the music. Try to make the best ﬁlter possible.

Load noisy.wav using the functions you learned in Lab 2. To test your ﬁlter, run

[numd,dend] = bilinear(num,den,fs); % Convert analog filter to discrete filter x_filtered = filter(numd,dend, x_noisy); % Implement discrete filter

The ﬁrst function approximates our analog ﬁlter as a discrete ﬁlter (we cannot perfectly implement an analog ﬁlter in a computer). The second function performs the ﬁltering. The variables num and den are the same as used for freqs. Use this code to test your custom ﬁlter on the noisy data in noisy.wav. You should be able to remove most of the noise and retain only the singing without distortion. Save a new wave ﬁle called name processed.wav with you ﬁltered result.

Implement the analog ﬁlter: Identify and retrieve the resistors and capacitors needed to implement the ﬁlter you designed with the ﬁlter board. Build your design. After Fall break, the lab instructors will have a portable music player with which you can test your ﬁlter. Listen to the noisy audio and the processed audio (processed with your ﬁlter) and verify if the noise levels are smaller for the processed signal than the original noisy signal.

You should also listen for any change in the quality of the music itself because of the ﬁltering (i.e. distortion). Remember that low-strength components in the audio signal will be removed by your ﬁlter. If necessary, make adjustments to the ﬁlter design and repeat the testing process.

11

Include in Lab Report “Results and Discussion” Section:

Include: The power spectrum estimation plot from pwelch.

Include: The frequency range containing the dominant frequency components in the clean music.

Include: All the resistor and capacitor component values in your ﬁnal ﬁlter design.

Include: A MATLAB plot of the frequency response (from freqs) for your designed ﬁlter.

Answer: Does your ﬁnal ﬁlter introduce any distortions into the signal? Why or why not?

Answer: Does your ﬁnal experimental system sound like your ﬁnal digital system? Explain.

Submit: The .wav ﬁle name processed.wav, which contains your digitally ﬁltered version of “Baba Yetu.”

Demonstrate: When your ﬁlter design is ﬁnalized, present the ﬁnal result to your lab instructor who will grade it on ﬁltering quality.

Files necessary to compute this assignment: clean.wav, noisy.wav

Equipment necessary to compute this assignment: A ﬁlter board that can be checked-out from the stockroom (do not check out until you need it), resistors (1: 29 kΩ, 6: 16 kΩ, 1: 68 kΩ, 1: 24 kΩ, and any others needed for your ﬁnal design), and capacitors (1: 0.001 µF, 2: 0.01 µF, and any others needed for your ﬁnal design).

Introduction

Many traditional analog circuits are designed through the principles of Fourier analysis. Common types of analog circuits are lowpass ﬁlters, highpass ﬁlters, bandpass ﬁlters, bandstop ﬁlters, and allpass ﬁlters. Lowpass ﬁlters remove high frequency content from a signal. Highpass ﬁlters remove low frequency content from a signal. Bandpass ﬁlters retain small sections (bandwidths) of frequencies and remove all other frequency content. Bandstop ﬁlters remove small sections (bandwidths) of frequencies and retain all other frequency content. Allpass ﬁlters distort signals while not aﬀecting the magnitude response of the signal.

In this lab, we will focus on developing lowpass analog ﬁlters. These ﬁlters are frequently used in systems to remove high frequency noise and aliasing eﬀects. Speciﬁcally, we will design and build a lowpass ﬁlter with operational ampliﬁers (op-amps). We will use this lowpass ﬁlter to remove noise from a music signal.

This lab assignment has three learning objectives:

1. To analyze a complex op-amp ﬁlter design using continuous-time Fourier analysis

2. To design a op-amp ﬁlter for a speciﬁc noise removal application

3. To experimentally build that design with op-amps and test its eﬀectiveness

Your experiment will be divided into three parts. In your lab report, you should address each part in separate subsections. See the lab report guidelines on the class website for more information.

Deliverables

This lab assignment has three deliverables:

1. One (1) lab report (see the “Lab Report Guidelines” on how to write it)

2. One (1) name processed.wav ﬁle with your digitally ﬁltered version of name processed.wav

3. One (1) demonstration of you analog ﬁlter system to your lab instructor

Please submit a hard copy of the paper deliverables and e-mail the electronic deliverables to your lab instructor before your assigned lab session between Nov. 18th – Nov. 24th.

1

Part 1: Analyzing a high-order ﬁlter system

In this part of the lab, we will analyze ﬁlter system with operational ampliﬁers (op-amps) and continuous-time Fourier analysis. First, we will analyze a bi-quad ﬁlter systems, which is based on an collection of inverting op-amp systems. We will then analyze a ﬁrst-order noninverting low-pass ﬁlter system. Finally, we will combine one ﬁrst order noninverting low-pass ﬁlter system with two bi-quad ﬁlter systems. This is the system that will experimental with in the rest of the lab.

In this part lab, you will use MATLAB to analyze the low-pass ﬁlter system and bi-quad ﬁlter systems. In the next section, we will experimental validate your analysis.

Analyzing inverting op-amp systems:

The inverting op-amp system: −

+

Z2(ω)

x(t)

y(t)

Z1(ω)

x(t) −

Z1(ω) Z2(ω)

y(t)

Figure 1: An inverting op-amp circuit (left) and it block diagram representation (right)

The op-amp realization as shown in Figure 1 is of an inverting ampliﬁer. The transfer function of the inverting ampliﬁer is deﬁned by

H(ω) =

Y (ω) X(ω)

= −

Z1(ω) Z2(ω)

.

If you are familiar with impedances in terms of s, i.e. Z1(s) and Z2(s), assume s = jω.

On the left side of Figure 1, we see the circuit diagram for the inverting ampliﬁer. On the right side of Figure 1, we see the equivalent block diagram system representation of the operational ampliﬁer system. We will use these block diagrams to simplify our ﬁlter representations when build a bi-quad ﬁlter from inverting ampliﬁer circuits. In the following sections, we will analyze speciﬁc realizations of the inverting ampliﬁer. These realizations will gradually lead to building a bi-quad ﬁlter system.

Analyzing analog ﬁlters in MATLAB: Throughout this lab, we will be analyzing analog ﬁlters. We will want to plot their transfer function magnitude and phase characteristics. We will do this using the MATLAB function freqs(num, den). When given no output, freqs plots the magnitude and phase of the transfer function is with numerator num(1)sN+num(2)sN−1+···+num(N-1)s+num(N) and denominator den(1)sM + den(2)sM−1 +···+ den(M-1)s + den(M), where N = length(num) and M = length(den) and s = jω.

2

A classic inverting op-amp system: −

+

R2x (t)

y(t)

R1

x(t) −

R1 R2

y(t)

Figure 2: An classic inverting op-amp circuit (left) and it block diagram representation (right)

For the inverting op-amp system in Figure 1, when Z1(ω) is a resistor R1 and Z2(ω) is a resistor R2, we have an inverter. This is shown in Figure 2. In the frequency domain, the transfer function for this system can be expressed as

H(ω) =

Y (ω) X(ω)

= −R1 R2

.

MATLAB Exercise: Let R1 = 16 kΩ and R2 = 16 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

An integrator system: −

+

R4x (t)

y(t)

C3

x(t) −

1 jωR4C3

y(t)

Figure 3: An integrator op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when Z1(ω) and Z2(ω) represents a resistor and capacitor, respectively, we generate an inverting integrator. This is shown in Figure 3. We call this system an inverting integrator because the input-output relationship for the system (assuming x(0) = 0) is

y(t) = −

1 R4C3Zt1 0

x(τ)dτ .

The time-domain impulse response h(t) and the frequency-domain transfer function H(ω) of the integrator system is given by

h(t) = −

1 R4C3

u(t) , H(ω) =

Y (ω) X(ω)

= −

1 jωC3 R4

= −1 jωR4C3

MATLAB Exercise: Let C3 = 0.01 µF and R4 = 16 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

3

An integrator system with decay: −

+

R8x (t)

y(t)

R7

C7

x(t) −R7 R8(1 + jωR7C7)

y(t)

Figure 4: An integrator with decay op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when Z1(ω) and Z2(ω) represents a resistor and a parallel resistor-capacitor, respectively, we generate an inverting integrator with decay. When integrating, this system adds recent values with greater weight than older values.

The time-domain impulse response h(t) and the frequency-domain transfer function H(ω) of the integrator with decay system is given by

h(t) = −

1 R8C7

e−1/(R7C7)u(t) , H(ω) = Y (ω) X(ω)

= −R7 R8(1 + jωR7C7)

.

MATLAB Exercise: Let R7 = 68 kΩ, C7 = 0.01 µF, and R8 = 1 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and plot its transfer function H(ω).

A summation system: −

+

Z3(ω)

x2(t)

Z2(ω)

x1(t)

y(t)

Z1(ω)

x1(t)

Z−1 2 (ω) P −Z1(ω) y(t)

Z−1 3 (ω)

x2(t)

Figure 5: An summation op-amp circuit (left) and it block diagram representation (right)

In Figure 1, when a new input is added with input impedance Z3(ω), we generate summation system. This is shown in Figure 5. A summation system allows us to add multiple inputs together.

The frequency-domain transfer function H(ω) of the summation system is given by Y (ω) = −Z1(ω)X1(ω) Z2(ω) + X2(ω) Z3(ω) .

4

Combining systems: In this previous subsections, we analyzed fundamental inverting ampliﬁer circuits. Now we will demonstrate how to combine these circuits together through system analysis and the properties of the Fourier trasnform.

A cascaded system:

x(t)

H1(ω) H2(ω)

y(t)

Figure 6: A cascade system.

Figure 6 shows a cascaded system where the output of one system become the input of the next. In Part 1 of the course, we learned that the time-domain impulse response of the overall system is given by the convolution of the two impulse responses. The frequency-domain transfer function of the overall circuit is given by the convolution property of the Fourier transform h(t) = h1(t)∗h2(t) F ←→ H(ω) = H1(ω)H2(ω) . This implies that if we can easily combine our systems to build better ﬁlters by feeding the output of one ﬁlter into the input of the next.

A feedback system:

x(t) P H1(ω)

H2(ω)

y(t)

Figure 7: A feedback system.

Figure 7 shows a feedback system where the output overall system is manipulated and then added back to the input. In a feedback system, the system H1(ω) is often known as the “plant” or “process” that modiﬁes a signal over time. The system H2(ω) is often known as the “controller” that steers your output y(t) to a particular value.

The frequency-domain transfer function for a feedback system is deﬁned by

H(ω) =

Y (ω) X(ω)

=

X(ω)H1(ω) + Y (ω)H1(ω)H2(ω) X(ω) H(ω) = H1(ω) + H(ω)H1(ω)H2(ω) H(ω)(1−H1(ω)H2(ω)) = H1(ω) H(ω) = H1(ω) 1−H1(ω)H2(ω) This shows that we can use the Fourier transform to analyze a rather complex process, such as a feedback.

5

A bi-quad ﬁlter system: −

+

R8x (t)

R7

C7 −

+

R4

y(t)

C3 −

+

R2

R9

R1

x(t)

H1(ω) P H2(ω) H3(ω)

H4(ω)H 5(ω)

y(t)

Figure 8: An bi-quad op-amp circuit (top) and it block diagram representation (bottom)

Figure 8 shows a bi-quad ﬁlter. The top part of Figure 8 shows the circuit representation and the bottom part of Figure 8 shows the equivalent block diagram which corresponds to each of the circuits and properties discuss in the previous subsections.

Use everything we previously learned about to derive the transfer function of this system. You will ﬁnd that the transfer function for the bi-quad circuit is deﬁned as

H(ω) =

(R2R9R7/R8) R7R1 + R2R9(1 + jωR7C7)R4C3jω

Furthermore, this can be simpliﬁed into the form

H(ω) =

Kω2 c −ω2 + jBωcω + Aω2 c

where K = (R9/R8), ω2 c = 1/(R4R9C3C7), Bωc = 1/(R7C7), and A = R1/R2. MATLAB Exercise: Let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 68 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and plot its transfer function H(ω). Repeat this analysis for R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 24 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. What changed?

6

A ﬁrst-order noninverting low-pass ﬁlter: −

+

R1x (t)

y(t)

R2

R3

C1

Figure 9: A ﬁrst-order low-pass ﬁlter circuit (left) and it block diagram representation (right)

Figure 9 shows a ﬁrst-order noninverting low-pass ﬁlter made with op-amps (note: the bi-quad ﬁlter system is a second-order ﬁlter). In our experimental setup, we use this system and two bi-quad ﬁlters. The frequency-domain transfer function for the ﬁrst-order noninverting low-pass ﬁlter is

H(ω) =

1 + (R3/R2) 1 + jωR1C1

MATLAB Exercise: Let R1 = 29 kΩ, R2 = 1 kΩ, R3 = 1 kΩ, and C1 = 0.001 µF. Use the MATLAB function freqs (with no outputs and s = jω) to analyze this circuit and its transfer function H(ω).

Our experimental setup (putting everything together):

x(t)

First-order low-pass ﬁlter Bi-quad ﬁlter # 1 Bi-quad ﬁlter # 2

y(t)

Figure 10: A block diagram of our complete ﬁlter system.

Figure 10 illustrates the system we will be designing and testing throughout the rest of this lab. It consists of a ﬁrst-order low-pass ﬁlter in series with two bi-quad ﬁlters. When cascaded together, we build a 5th-order ﬁlter (one 1st-order ﬁlter and two 2nd-order ﬁlters).

Use the properties you previously learned in this lab to derive the transfer function for the entire ﬁlter system in Figure 10. You may want to use the function tf in MATLAB to help you.

MATLAB Exercise: • For the ﬁrst-order non-inverting low-pass ﬁlter, let R1 = 29 kΩ, R2 = 1 kΩ, R3 = 1 kΩ, and C1 = 0.001 µF. • For the ﬁrst bi-quad ﬁlter, let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 68 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ. • For the second bi-quad ﬁlter, let R1 = 16 kΩ, R2 = 16 kΩ, C3 = 0.01 µF, R4 = 16 kΩ, R7 = 24 kΩ, C7 = 0.01 µF, R8 = 1 kΩ, R9 = 1 kΩ.

Use the MATLAB function freqs (with no outputs and s = jω) to analyze this complete system and plot its transfer function H(ω).

7

Include in Lab Report “Experimental Design” Section:

Include: A block diagram of your bi-quad ﬁlter similar to bottom plot of Figure 8, but with the transfer functions H1(ω), H2(ω), H3(ω), H4(ω), and H5(ω) identiﬁed (in terms of resistances, i.e., R1, R2, etc., and capacitances, i.e., C3,C7). Include: A block diagram of the of the entire ﬁlter system, similar to Figure 10.

Include in Lab Report “Analytical Methods” Section:

Include: Your derivation of the bi-quad ﬁlter (using the other transfer functions and properties discussed in this lab).

Include in Lab Report “Results and Discussion” Section:

Include: Your MATLAB plots of the each bi-quad circuit’s transfer function.

Include: Your MATLAB plot of the ﬁrst-order non-inverting low-pass ﬁlter circuit’s transfer function.

Include: Your MATLAB plot of the entire system’s transfer function

Answer: With the given conﬁguration, would you consider each of the stages (and the system as a whole) low pass ﬁlters?

8

Part 2: Validate your analysis

Check out a customized ﬁlter board from the stockroom. The diagrams in Figure 11 and Figure 12 illustrate the circuit board that we will use. Note that some of the boards diﬀer slightly from the diagram. To power the board, attach a +15 V line to the red input, attach a -15 V line to the blue input, and attach the ground to the green input. Before inputting a signal the board, verify your setup with your lab instructor.

R1

C1

R1

R2

C3R4R7

R1

R2

C3R4R7

Figure 11: Block diagram of the circuit board.

Figure 12: Block diagram of the circuit board.

Our goal is to verify our analyses from part one. Collect the necessary resistors and capacitors speciﬁed at the end of Part I to build the system. Note that several capacitors and resistors are already on the board. Speciﬁcally, R2 and R3 for the ﬁrst-order noninverting low-pass ﬁlter are already on the board. Also, C7 R8, and R9 for each of the bi-quad ﬁlters are already on the board. Place the remaining resistors and capacitors into the appropriate locations.

Using the equipment available to you, measure the magnitude response of each block (the ﬁrstorder low-pass ﬁlter and each of the bi-quad ﬁlters). Measure the frequency responses by inputting sinusoids at diﬀerent frequencies and measuring the amplitude of the response. Estimate the phase response by estimating the time lag between the input and output signals and converting the lag to radians. First measure the response for each stage separately and then measure the response for the entire system.

9

Plot the frequency response on log-log graphes for magnitude and phase similar to that generated by the freqs MATLAB function. You must have at least 20 measurements from 100 Hz to 20 kHz. Choose your frequencies so that they are uniformly (at least approximately) distributed on the log-log graph. Compare your measurements with the MATLAB plots results from Part I.

Include in Lab Report “Results and Discussion” Section:

Include: Your frequency response plots of the each bi-quad circuit’s transfer function.

Include: Your frequency response plots of the ﬁrst-order non-inverting low-pass ﬁlter circuit’s transfer function/

Include: Your frequency response plots of the entire system’s transfer function.

Answer: Does your analysis from Part I match your experimental results? If not, why?

Answer: Do these results illustrate a low pass ﬁlter? Is it a “good” low pass ﬁlter? What makes a ﬁlter “good?”

10

Part 3: Designing and implementing an analog ﬁlter

Analyze the music: In this part of the lab, we will combined everything we previously learned to design our own analog ﬁlter and implement it with our ﬁlter board. Two pieces of music should be included with the lab. One ﬁle (clean.wav) is a clean segment of Christopher Tin’s “Baba Yetu.” The other ﬁle (noisy.wav) was obtained by adding noise to the clean signal. These digital signals are sampled at fs = 44100 samples/s.

Our goal is to design an analog ﬁlter that will remove the noisy components from (noisy.wav). We will use clean.wav to determine the low frequency range containing all the signiﬁcant the components for the clean signal. Note that, in practice, we usually do not have the clean signal. In this case, however, the clean signal will help to design the best possible ﬁlter.

Load clean.wav using the functions you learned in Lab 2. Estimate the frequency components of the clean signal with the power spectrum estimation function

pwelch(x,hann(1024),512,2048,fs)

with the parameters given above. This is similar to the fanalysis function used in Lab 2, but slightly more sophisticated. We will not get into the details in course (if you want to learn more, look up “Welch’s method”).

From the resulting plot generated by pwelch, identify a continuous range of frequencies for which the signal spectrum is within 20 dB of the frequency component with the maximum strength. This represents the dominate frequencies in the music.

Design the analog ﬁlter: Using MATLAB and the freqs function, choose component values to design a ﬁlter (based on the 3-stage ﬁlter system we are using experimentally) that retains frequency components within the range of the music (determined in the previous subsection) and removes frequency components outside the range of the music. Try to make the best ﬁlter possible.

Load noisy.wav using the functions you learned in Lab 2. To test your ﬁlter, run

[numd,dend] = bilinear(num,den,fs); % Convert analog filter to discrete filter x_filtered = filter(numd,dend, x_noisy); % Implement discrete filter

The ﬁrst function approximates our analog ﬁlter as a discrete ﬁlter (we cannot perfectly implement an analog ﬁlter in a computer). The second function performs the ﬁltering. The variables num and den are the same as used for freqs. Use this code to test your custom ﬁlter on the noisy data in noisy.wav. You should be able to remove most of the noise and retain only the singing without distortion. Save a new wave ﬁle called name processed.wav with you ﬁltered result.

Implement the analog ﬁlter: Identify and retrieve the resistors and capacitors needed to implement the ﬁlter you designed with the ﬁlter board. Build your design. After Fall break, the lab instructors will have a portable music player with which you can test your ﬁlter. Listen to the noisy audio and the processed audio (processed with your ﬁlter) and verify if the noise levels are smaller for the processed signal than the original noisy signal.

You should also listen for any change in the quality of the music itself because of the ﬁltering (i.e. distortion). Remember that low-strength components in the audio signal will be removed by your ﬁlter. If necessary, make adjustments to the ﬁlter design and repeat the testing process.

11

Include in Lab Report “Results and Discussion” Section:

Include: The power spectrum estimation plot from pwelch.

Include: The frequency range containing the dominant frequency components in the clean music.

Include: All the resistor and capacitor component values in your ﬁnal ﬁlter design.

Include: A MATLAB plot of the frequency response (from freqs) for your designed ﬁlter.

Answer: Does your ﬁnal ﬁlter introduce any distortions into the signal? Why or why not?

Answer: Does your ﬁnal experimental system sound like your ﬁnal digital system? Explain.

Submit: The .wav ﬁle name processed.wav, which contains your digitally ﬁltered version of “Baba Yetu.”

Demonstrate: When your ﬁlter design is ﬁnalized, present the ﬁnal result to your lab instructor who will grade it on ﬁltering quality.

You'll get 1 file (5.3MB)