Name: ______________________________________________ Date of lab: ______________________ Lab 6 Section number: M E 345._______ Precalculations – Individual Portion Filter Lab: Building and Testing Electrical Filters Precalculations Score (for instructor or TA use only): _____ / 20 1. (4) Draw the circuit diagram for a simple first-order low-pass filter, constructed from one resistor and one capacitor. Be sure to label both the input and output voltages. 2. (4) Draw the circuit diagram for a simple first-order high-pass filter, constructed from one resistor and one capacitor. Be sure to label both the input and output voltages. 3. (4) Suppose a capacitor is available with a capacitance of 0.0100 microfarads. A low-pass filter is to be constructed with a cutoff frequency around 800 Hz. Calculate the appropriate resistance of the resistor that should be used, in units of k. Show all your calculations, and be sure to include all units. Required resistance, R = ___________ k 4. (4) Suppose that you need a resistance of 15 k, but all you have available is a bunch of 10 k resistors. Draw a schematic diagram showing how could use only 3 resistors to generate the desired resistance. 5. (4) Instruments are commercially available that contain Butterworth low-pass filters of various orders (for example n = 1, 2, 4, 6, and 8). Suppose you are using one of these instruments, and have it set to a cutoff frequency of 800 Hz. Compare the gain (both G and GdB) at a frequency of 10,000 Hz for the cases with n = 1, n = 2, and n = 4. n 1 2 4 G GdB Lab 6, Filter Lab Page 1 Cover Page for Lab 6 Lab Report – Group Portion Filter Lab: Building and Testing Electrical Filters Name 1: ___________________________________________________ Section M E 345._______ Name 2: ___________________________________________________ Section M E 345._______ Name 3: ___________________________________________________ Section M E 345._______ [Name 4: ___________________________________________________ Section M E 345._______ ] Date when the lab was performed: ______________________ Group Lab Report Score (For instructor or TA use only): Lab experiment and results, plots, tables, etc. _____ / 50 Discussion _____ / 30 TOTAL ______ / 80 Lab Participation Grade and Deductions – The instructor or TA reserves the right to deduct points for any of the following, either for all group members or for individual students: Arriving late to lab or leaving before your lab group is finished. Not participating in the work of your lab group (freeloading). Causing distractions, arguing, or not paying attention during lab. Not following the rules about formatting plots and tables. Grammatical errors in your lab report. Sloppy or illegible writing or plots (lack of neatness) in your lab report. Other (at the discretion of the instructor or TA). Name Reason for deduction Comments (for instructor or TA use only): Points deducted Total grade (out of 80) Lab 6, Filter Lab Page 2 Filter Lab: Building and Testing Electrical Filters Author: John M. Cimbala; also edited by Mikhail Gordin and Savas Yavuzkurt, Penn State University Latest revision: 13 October 2014 Introduction and Background (Note: To save paper, you do not need to print this section for your lab report.) This lab involves building some electrical circuits on a breadboard. To refresh your memory, the circuit for two resistors in series is shown below. One way to wire these on a breadboard is also sketched below. VB R2 Short bus Note: The color stripes R1 R2 VB VA on the resistors are I1 I2 of arbitrary colors. R1 VA Similarly, the circuit for two resistors in parallel is shown below, along with one way to wire these on a breadboard. R2 R1 Note: The color stripes I1 on the R1 VB VA resistors are of arbitrary Itotal R2 colors. VA VB I2 When taking measurements, there is often the presence of “noise” in addition to the desired signal. In such circumstances, the desired signal must be separated from other competing signals. Unwanted signals can arise from external sources such as electrical devices (vacuum cleaner, radio, or television) or can result directly from the measurement technique itself. Generally, a priori knowledge of the desired signal and of the noise is required in order for noise to be adequately reduced while retaining the desired signal. Since the exact results are rarely known before an experiment is performed, selection of a proper filter incorporates some degree of trial and error. There are four basic categories of filters: low-pass, high-pass, band-pass, and band-stop. These are described in the learning modules, and the details are not repeated here. These filter circuits may be approximated by the response of simple first-order (RC) type circuits. In practice, a filter does not completely eradicate signals whose frequencies fall above, below, or outside the designated cutoff frequency, but attenuates them to some degree. For example, consider a low-pass filter. The amplitude of the signal at frequencies much lower than the cutoff frequency fcutoff are not attenuated at all. The amplitude of the signal at frequencies near the cutoff frequency are attenuated somewhat, and the amplitude at frequencies which are much greater than the cutoff frequency are attenuated significantly. The rate at which this attenuation occurs, given in dB/octave, depends on the order of the filter. A first-order Butterworth filter has a cutoff rate of 6 dB/octave; a second-order Butterworth filter has a cut-off rate of 12 dB/octave (one octave is defined as two times the original frequency). In general, for an nth-order Butterworth low-pass filter, the gain G is V Vout 1 1 G out G 20log G 20log , and the gain in decibels is , where the dB 10 10 2n 2n Vin Vin f 1 1 cutoff f cutoff cutoff radian frequency for a simple first-order RC filter is cutoff 1 1 . The physical frequency is fcutoff . RC 2 RC Filter circuits impart a phase shift to the signal. This phase shift is normally not a problem unless synchronization between the input and output signals is required. Phase shift will be investigated in this lab for a simple first-order Lab 6, Filter Lab Page 3 f low-pass filter. Theoretically, the phase shift for a first-order low-pass Butterworth filter is arctan . f cutoff In previous labs (and also in class and homework), it has been shown that aliasing can be a serious problem with digital data acquisition if the experimenter is not careful. One way to avoid aliasing is to employ a low-pass filter to attenuate undesired high frequencies. Such a filter is called an anti-aliasing filter. For example, suppose we are interested in signals around 100 to 500 Hz. For adequate resolution at these frequencies, we choose to sample data at, say, 5000 Hz. But suppose there is also some high frequency noise (above 5000 Hz) in the signal. The problem is that the high frequency noise will cause aliasing. One possible solution is to put in an anti-aliasing filter with a cutoff frequency of around 1000 Hz. This filter will allow the desired signal to pass through without much effect, but will significantly attenuate the high frequency noise, thereby reducing the aliasing. In this lab, such a case will be demonstrated. Objectives 1. Practice combining resistors in series and/or parallel to produce a desired resistance from available resistors. 2. Construct simple first-order low-pass and high-pass filters, using only resistors and capacitors. 3. Apply a low-pass filter to some music to see how the music is changed 4. Measure the amplitude (gain) and phase characteristics of a low-pass filter as a function of frequency, and compare to theory. 5. Construct Bode plots for a low-pass filter based on experimental measurements. Equipment digital oscilloscope function generator six resistors of nominal value 10 kohm (10,000 ) two capacitors of nominal value 0.010 microfarad (0.010 10-6 F) capacitor decade box Music player (cell phone, MP3 or MP4 player, iPod, this computer, etc.) 2 stereo patch cords (1/8-inch for iPod, cell phones, and MP3 players) 2 1/8-inch stereo plugs with connections soldered to jumper wires (green to ground and yellow to signal) powered breadboard (plugged in for the ground connection, but turned off – power not needed for this lab) various BNC and banana cords and breadboard jumper wires as needed digital multimeter computer with digital data acquisition system (DAQ) and software Lab 6, Filter Lab Page 4 Procedure Basic set-up and measurements 1. (1) Measure and record the resistance of three of the available resistors. (The nominal value of each resistor should be 10,000 ohms.) Measured resistances: R1 = ___________ , R2 = ___________ , and R3 = ___________ 2. (1) (a) Measure and record the capacitance of one of the available capacitors. (The nominal value of each capacitor should be 0.010 microfarads.) Measured capacitance, Ccapacitor = ___________ F (1) (b) Dial in the same capacitance value (about 0.010 microfarads) on the capacitor decade box. Measure and record the capacitance of the capacitor decade box. Measured capacitance from the capacitor decade box, Cdecade box = ___________ F From now on, for convenience, you may use the capacitor decade box instead of the physical capacitor. 3. (4) For this capacitance, calculate the resistance needed to create a simple first-order low-pass filter with a cutoff frequency of 1000 Hz. Show your work here, including all units. Required resistance, R = ___________ 4. (4) Combine your resistors (in series and/or parallel) on the breadboard in such a way that the total resistance is close to the required resistance (say within 10% or so). Sketch a schematic diagram. 5. (2) Measure and record the equivalent resistance of your resistor circuit, and compare to the theoretical value. Measured equivalent resistance, R = ___________ Percentage error between measured and theoretical equivalent resistance = ___________ % Important note: In all the circuits you will build in this lab (and in several other labs), it is critical that the ground bus be connected to a physical ground, such as the black ground post of the powered breadboard with the breadboard plugged in (but turned off) to secure the ground. Lab 6, Filter Lab Page 5 Low-pass filtering of music 1. Construct a first-order low-pass filter using a combination of resistors and the capacitor decade box, with a cutoff frequency of approximately 1000 Hz. A circuit diagram for a simple first-order low-pass filter is provided below, along with a sketch of one possible wiring configuration on the breadboard. R R Vout Vin Vin C Ground Ground bus C Vout Note: A single resistor (of arbitrary colors) is shown here, but it is replaced by a combination of resistors. Note: A capacitor is shown here, but it is replaced by the capacitor decade box. 2. (3) Test your filter by connecting the function generator to the filter input and the filter output to the oscilloscope. Start with a sine wave input of about 100 Hz and amplitude 1 V. Increase the frequency of the sine wave until you start noticing that the output amplitude decreases – the low-pass filter is doing its job. Keep increasing the frequency until the filter output amplitude is 90% attenuated – in other words, G = 0.1; the output amplitude is about 10% of the input amplitude, or 0.1 V. At what frequency does this occur? Frequency at which G = 0.1: f = ___________ Hz 3. Connect the output of a music player as the input to your low-pass filter, using a stereo patch cord and stereo plug. Note: We use only one channel (Left or Right) – ignore the other channel. The green wire is the ground, and the yellow wire is the signal. Using the second stereo plug and stereo patch cord, connect the filter output directly into the computer’s speaker input. Note: If you’re trying to play music from a web browser, make sure the speakers are plugged in when you start playing; if the speakers aren’t plugged in to begin with or you need to unplug them for some reason, you will need to refresh the browser window to hear anything. 4. (5) Play a song [a song with good range (both high notes and low notes) is best] on your music player and test whether this simple low-pass filter works – does it attenuate high frequencies and let low frequencies pass through? Hint: A quick way to turn the filter on or off is to dial the capacitance on the capacitor decade box to zero (filter off), and then to the required value (filter on). Record qualitative results in the space below. 5. (3) Adjust the capacitance on the capacitor decade box to decrease the cutoff frequency of the low-pass filter to about 100 Hz, noting that higher capacitance means lower cutoff frequency since fcutoff = 1/(2RC). Play a song again and record your observations below. How does this low-pass filter affect the music? Lab 6, Filter Lab Page 6 Testing the performance of the low-pass filter 1. Connect the output of the function generator To Ch. 1 of scope. to the input of your low-pass filter and to one Call this Vin channel of the oscilloscope (use a T-splitter). 2. Wire the output of the low-pass filter to another channel of the oscilloscope, as T-splitter R sketched to the right. Signal from To Ch. 2 of scope. 1. Important: Push the DC offset button on C function the function generator in (or out in some Call this Vout generator cases) to remove any DC voltage from the signal, so that the DC offset does not Ground bus Ground influence the measurements. 2. Notation: Vin is the signal coming into the low-pass filter, and Vout is the signal coming from the low-pass filter, as indicated in the above diagram. Our goal is to compare these two signals. 3. (3) Adjust R and C as necessary to generate a low-pass filter with a cutoff frequency of around 1000 Hz. Measure the values of R and C, and calculate the physical cutoff frequency of the filter, showing your work below. Note: The cutoff frequency should be around 1000 Hz, but may not be exact say within 10%. Measured resistance, R = ___________ Measured capacitance, C = ___________ F Physical cutoff frequency, fcutoff = ___________ Hz 4. Set the function generator to supply a sine wave of frequency equal to the filter’s cutoff frequency, such that the amplitude of the signal we are calling Vin is around 8 V peak-to-peak. 5. Now we are ready to test the performance of the low-pass filter. The digital oscilloscope can be set up to display the frequency of each signal and the peak-to-peak voltage of both channels as follows: 1. Push the Measure button on the oscilloscope. 2. Select channel 1 by pushing Ch 1. 3. Scroll on the right-side menu to select Frequency and Pk-Pk. 4. Repeat for channel 2. 5. Push Menu Off. 6. At this point, two signals should be visible on the oscilloscope screen: the input to the filter, Vin, and the output from the filter, Vout, along with the frequency and peak-to-peak amplitude of each signal. 7. Consult the instructor or teaching assistant if you are unable to accomplish this yourself. 6. Measure and record the frequency of the signal, the peak-to-peak amplitude going into the low-pass filter, the peak-to-peak amplitude coming out of the low-pass filter, and the time shift t between the two signals. Then, using these measured values, calculate the gain G of the low-pass filter and the phase angle shift . Here are some hints regarding these measurements and calculations: 1. Gain G is the ratio of output voltage amplitude |Vout| to input voltage amplitude |Vin|, i.e., G = |Vout| / |Vin|. Note that peak-to-peak voltage is twice the amplitude, i.e., |Vin|p-to-p = 2|Vin| and |Vout|p-to-p = 2|Vout|. 2. The voltage scale on the scope can be adjusted as necessary for better amplitude resolution. 3. To measure the time shift, use the oscilloscope’s cursor feature. You can measure the time increment between peaks or troughs in the two signals. Or, you can measure the time increment between the zero crossing of the input signal and the zero crossing of the output signal. Note: If zero crossings are used, it is critical that the vertical position of each oscilloscope trace be adjusted so that zero volts corresponds to a grid line. Otherwise it will be very difficult to tell (by eye) where the signal crosses zero. 4. The time scale on the scope can be adjusted for better time shift resolution. 5. The period of the signal is calculated as T = 1/f. t 360o . The sign of is positive if 6. (4) The absolute value of phase angle is then calculated as T the output leads the input, and negative if the output lags the input. Lab 6, Filter Lab Page 7 Signal frequency, fsignal = ___________ Hz Peak-to-peak amplitude going into the low-pass filter, |Vin|p-to-p = ___________ V Peak-to-peak amplitude coming out of the low-pass filter, |Vout|p-to-p = ___________ V Time shift between the two signals, t = ___________ s Gain of the low-pass filter, G = ___________ Period of the signal, T = ___________ s 7. 8. 9. 10. Phase angle shift (in degrees) of the low-pass filter, = ___________ o Create an Excel file with the following columns of data, one row for each frequency: 1. input frequency f (Hz) 2. normalized input frequency f /fcutoff 3. input peak-to-peak amplitude |Vin|p-to-p (volts) 4. output peak-to-peak amplitude |Vout|p-to-p (volts) 5. gain G = |Vout|p-to-p / |Vin|p-to-p (4 for #7,8) Take data for several frequencies, and enter the results into your spreadsheet. The following are recommended as a minimum to start with: 1. approximately 100 Hz 2. approximately 200 Hz 3. approximately 400 Hz 4. approximately 750 Hz 5. approximately 1,000 Hz 6. approximately 2,000 Hz 7. approximately 4,000 Hz 8. approximately 7,500 Hz 9. approximately 10,000 Hz Create a Bode diagram, namely a frequency response diagram – a plot of gain G as a function of relative frequency f /fcutoff – within your Excel spreadsheet. Use symbols only (no line) for your data points: Here are some specifics about the plots: 1. Use your actual calculated value of fcutoff, not 1000 Hz, for better accuracy. 2. Use a log scale for both horizontal and vertical axes. 3. At this point, data have been collected for about nine frequencies. This should be sufficient to start to see a trend in the plot. However, many more data points are needed to produce an acceptable plot. Repeat the measurements for a wide range of frequencies. 4. Hint: Enter data and update the plot as data are taken, so that the plot can be used as a guide to determine which frequencies to study. 5. Make sure you take enough data to create a smooth curve of gain vs relative frequency. Start with the lowest possible stable frequency, and end with frequencies at least 100 times fcutoff. (This will generate a minimum of four decades in the horizontal scale.) Fill in with as many frequencies as necessary to obtain a nice-looking plot this should be 10-20 data points. 6. A significant part of the grade for this lab report will be determined by the quality of your plot make sure there are enough data points before you leave the lab. (2 for #9,10) Attach a printout of your tabulated data. Excel table – See attached page(s) from the spreadsheet ___________ 11. (3) On the same graph as your frequency response diagram, plot the theoretical gain for a first-order passive low-pass filter for comparison. For consistency, use symbols only (no line) for your data, and a line only (no symbols) for the theoretical curve. For plot of theoretical gain line , data should be in descending or ascending order. Label, number and attach your frequency response diagram. Frequency response diagram – See attached, Figure number ___________ 12. When all finished, disconnect your circuits (clean off the breadboard) so that the next group has to build the circuits from scratch like you did. Lab 6, Filter Lab Page 8 High-pass filter 1. Construct a simple first-order high-pass filter with fcutoff 1000 Hz. The circuit diagram is sketched below, along with one possible wiring configuration on the breadboard. C C Vout Vin R Vin Vout R Note: A capacitor is shown here, but it is replaced by the capacitor decade box. Ground bus 2. Note: A single resistor (of arbitrary colors) is shown here, but it is replaced by a combination of resistors. Ground (2) Show here any necessary calculations to verify the cutoff frequency of your circuit. 3. (4) Connect the function generator output as Vin and connect Vout to the oscilloscope. Play around with sine waves of various frequencies and DC offsets, and test whether this simple high-pass filter works – does it remove the DC offset, attenuate low frequencies, and let high frequencies pass? Record qualitative results. 4. Now imagine that the resistor is of infinite value. In other words, it isn’t even there, as sketched below. This circuit represents the simplest possible high-pass filter; it has a cutoff frequency of zero. In other words, all it does is cut off DC (zero frequency) signals, but lets AC signals of any frequency pass through. C C Vin Vin R R Vout Ground Vout Ground bus 5. Remove the resistor from your high-pass filter circuit so that you are left with the simplest possible high-pass filter, as sketched above (just a capacitor in series with the voltage signal). 6. (4) Play around with the input frequency and DC offset of the function generator, and record your observations. In particular, see if this simple circuit removes DC offset from the signal. Just record qualitative results. 7. Remove the high-pass filter from the breadboard – we no longer need it. Lab 6, Filter Lab Page 9 Discussion Questions 1. (8) How does a low-pass filter affect music? Discuss how this might be useful in concerts or recordings. 2. (8) Do the experimental gain measurements of your low-pass filter agree with the theoretical values? If not, suggest possible reasons why not. 3. (7) Did the simplified high-pass filter perform as expected? Briefly justify your answer. 4. (7) Discuss how the predicted and actual cutoff frequency compare, based on your Bode plot.