Laboratory 7: Active Filters

Similar documents
Laboratory 5: RC Circuits and Filtering

Class #16: Experiment Matlab and Data Analysis

George Mason University Signals and Systems I Spring 2016

FREQUENCY RESPONSE AND PASSIVE FILTERS LABORATORY

ECEN Network Analysis Section 3. Laboratory Manual

Open Loop Frequency Response

Real Analog - Circuits 1 Chapter 11: Lab Projects

BME 3512 Bioelectronics Laboratory Two - Passive Filters

UNIVERSITY OF NORTH CAROLINA AT CHARLOTTE Department of Electrical and Computer Engineering

The above figure represents a two stage circuit. Recall, the transfer function relates. Vout

Operational Amplifiers

EK307 Active Filters and Steady State Frequency Response

EE233 Autumn 2016 Electrical Engineering University of Washington. EE233 HW7 Solution. Nov. 16 th. Due Date: Nov. 23 rd

STATION NUMBER: LAB SECTION: Filters. LAB 6: Filters ELECTRICAL ENGINEERING 43/100 INTRODUCTION TO MICROELECTRONIC CIRCUITS

EECS 216 Winter 2008 Lab 2: FM Detector Part I: Intro & Pre-lab Assignment

Use of the LTI Viewer and MUX Block in Simulink

Pre-Lab. Introduction

EE 233 Circuit Theory Lab 3: First-Order Filters

BIOE 123 Module 3. Electronics 2: Time Varying Circuits. Lecture (30 min) Date. Learning Goals

Experiment 8 Frequency Response

4 Experiment 4: DC Motor Voltage to Speed Transfer Function Estimation by Step Response and Frequency Response (Part 2)

SMS045 - DSP Systems in Practice. Lab 1 - Filter Design and Evaluation in MATLAB Due date: Thursday Nov 13, 2003

EK307 Passive Filters and Steady State Frequency Response

EES42042 Fundamental of Control Systems Bode Plots

Laboratory Project 4: Frequency Response and Filters

EECS40 RLC Lab guide

v(t) = V p sin(2π ft +φ) = V p cos(2π ft +φ + π 2 )

DOING PHYSICS WITH MATLAB FILTER CIRCUITS

Frequency Selective Circuits

Designing Information Devices and Systems II Fall 2018 Elad Alon and Miki Lustig Homework 4

DOING PHYSICS WITH MATLAB RESONANCE CIRCUITS SERIES RLC CIRCUITS

Mechatronics. Analog and Digital Electronics: Studio Exercises 1 & 2

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Circuits & Electronics Spring 2005

THE CITADEL THE MILITARY COLLEGE OF SOUTH CAROLINA. Department of Electrical and Computer Engineering. ELEC 423 Digital Signal Processing

Lab 4 Fourier Series and the Gibbs Phenomenon

ECE 203 LAB 2 PRACTICAL FILTER DESIGN & IMPLEMENTATION

Downloaded from

EE Experiment 8 Bode Plots of Frequency Response

Bode plot, named after Hendrik Wade Bode, is usually a combination of a Bode magnitude plot and Bode phase plot:

Build Your Own Bose WaveRadio Bass Preamp Active Filter Design

PHYS 3322 Modern Laboratory Methods I AC R, RC, and RL Circuits

Core Technology Group Application Note 6 AN-6

Complex Numbers in Electronics

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2

Precalculations Individual Portion Filter Lab: Building and Testing Electrical Filters

Signal Processing First Lab 20: Extracting Frequencies of Musical Tones

UNIVERSITY OF WARWICK

AC BEHAVIOR OF COMPONENTS

Lab 2: Capacitors. Integrator and Differentiator Circuits

Laboratory 4: Amplification, Impedance, and Frequency Response

NPTEL Online Course: Control Engineering

Rotary Motion Servo Plant: SRV02. Rotary Experiment #03: Speed Control. SRV02 Speed Control using QuaRC. Student Manual

Assist Lecturer: Marwa Maki. Active Filters

Laboratory Assignment 1 Sampling Phenomena

DSP First Lab 03: AM and FM Sinusoidal Signals. We have spent a lot of time learning about the properties of sinusoidal waveforms of the form: k=1

ECE 2100 Experiment VI AC Circuits and Filters

Comparison of Signal Attenuation of Multiple Frequencies Between Passive and Active High-Pass Filters

DOING PHYSICS WITH MATLAB RESONANCE CIRCUITS RLC PARALLEL VOLTAGE DIVIDER

DO NOT REMOVE FROM LABORATORY Operating Instructions for the Vibration Experiment

Department of Electrical & Computer Engineering Technology. EET 3086C Circuit Analysis Laboratory Experiments. Masood Ejaz

Fourier Series and Gibbs Phenomenon

EXPERIMENT 14 Variable-frequency networks

ET 304A Laboratory Tutorial-Circuitmaker For Transient and Frequency Analysis

Lab 9 Frequency Domain

DSP First. Laboratory Exercise #2. Introduction to Complex Exponentials

ECE 3155 Experiment I AC Circuits and Bode Plots Rev. lpt jan 2013

Designing Information Devices and Systems II Fall 2018 Elad Alon and Miki Lustig Homework 4

EE 221 L CIRCUIT II. by Ming Zhu

Low Pass Filter Introduction

Lab 10: Oscillators (version 1.1)

DC and AC Circuits. Objective. Theory. 1. Direct Current (DC) R-C Circuit

ECE317 Homework 7. where

Operational Amplifier Circuits

EE 462G Laboratory #1 Measuring Capacitance

Knowledge Integration Module 2 Fall 2016

Cleveland State University MCE441: Intr. Linear Control Systems. Lecture 12: Frequency Response Concepts Bode Diagrams. Prof.

Lab 9: Operational amplifiers II (version 1.5)

EE 230 Lab Lab nf C 2. A. Low-Q low-pass active filters. (a) 10 k! Figure 1. (a) First-order low-pass. (b) Second-order low-pass.

Signals and Systems Lecture 6: Fourier Applications

Simulating Circuits James Lamberti 5/4/2014

Fourier Signal Analysis

, answer the next six questions.

PYKC 13 Feb 2017 EA2.3 Electronics 2 Lecture 8-1

AC CURRENTS, VOLTAGES, FILTERS, and RESONANCE

2.161 Signal Processing: Continuous and Discrete

Xcircuit and Spice. February 26, 2007

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering. EIE2106 Signal and System Analysis Lab 2 Fourier series

EEL2216 Control Theory CT2: Frequency Response Analysis

Transmit filter designs for ADSL modems

LABORATORY #3 QUARTZ CRYSTAL OSCILLATOR DESIGN

ECE 2713 Design Project Solution

Frequency Response Analysis

Frequency Responses and Active Filter Circuits

FREQUENCY RESPONSE OF R, L AND C ELEMENTS

ECE 4670 Spring 2014 Lab 1 Linear System Characteristics

(A) Based on the second-order FRF provided, determine appropriate values for ω n, ζ, and K. ω n =500 rad/s; ζ=0.1; K=0.

BME 3512 Bioelectronics Laboratory Six - Active Filters

Analog Filters D R. T A R E K T U T U N J I P H I L A D E L P H I A U N I V E R S I T Y, J O R D A N

Lab 8 - INTRODUCTION TO AC CURRENTS AND VOLTAGES

Lab 6 rev 2.1-kdp Lab 6 Time and frequency domain analysis of LTI systems

Transcription:

EGR 224L - Spring 208 7. Introduction Laboratory 7: Active Filters During this lab, you are going to use data files produced by two different low-pass filters to examine MATLAB s ability to predict transfer functions based on voltages collected at the input and output of the filter. You will get to hear the difference between the original signals and their filtered version, hear how aliasing can be reduced by using a good low pass filter, and see just how accurate estimates of the transfer function can be. For each circuit, you will be using two different input signals - one is a chirp signal that spans a broad range of frequencies while another is an actual song. 7.2 Getting Started Because you are using sound, you will need to run MATLAB on the PC in the lab. To log in, use the FROSHNN\Michael account (the password is empty). You will then need to start the 32-bit version of MATLAB on the local PC - not remotely. Single-click the icon to make sure it explicitly states it is the 32-bit version before double-clicking it to start it. Once started, make sure the working directory is empty. 7.3 Background 7.3. Passive Low-Pass Filter In a previous lab, you generated an experimental version of a Bode plot for an RC circuit by examining amplitude ratios and phase shifts between a sinusoidal input and the output across the capacitor. A unity-gain, first-order low-pass filter can thus be built as follows: R v in v out C The transfer function between the input and output voltages is: V out V in = sc sc + R = + src As a Fourier transform, the transfer function and its magnitude are given as: + jωrc + ω2 R 2 C 2 The maximum magnitude is, when ω = 0, and the half-power frequency is where (H(jω hp )) 2 = 2, so: + ωhp 2 R2 C 2 = 2 ω hp = RC Copyright 208, Gustafson et al. Lab 7

EGR 224L - Spring 208 7.3.2 Sallen-Key Low-Pass Filter While the filter above is simple and provides a means for diminishing signal components at frequencies higher than the half-power frequency, it is not a particularly sharp filter. That is, the rate of attenuation as a function of frequency is such that elements past the half-power frequency remain with some non-negligible amplitude. There are several methods available for obtaining a sharper cutoff. One simple active circuit that provides such properties is a Sallen and Key Filter. The specific configuration for a unity gain, second-order low-pass filter with a sharper cutoff than a simple first-order low pass filter is: C 2 v in R R 2 + v out C The transfer function between the input and output voltages is: If R = R 2 = R, C = C, and C 2 = 2C, this simplifies to: V out V in = V out = V in R R 2 C C 2 s 2 + (R + R 2 )C s + 2R 2 C 2 s 2 + 2RCs + = 2R 2 C 2 s 2 + RC s + From this, the natural frequency and damping ratio can be determined: 2R 2 C 2 ω n = RC 2 As a Fourier transform, the transfer function is given as: ζ = 2RCω n = 2 and the magnitude of the Fourier transform is: 2R 2 C 2 (jω) 2 + 2RC(jω) + = ( 2R 2 C 2 ω 2 ) 2 + (2RCω) 2 + 4ω4 R 4 C 4 The maximum magnitude is, when ω = 0, and the half-power frequencies are where (H(jω c )) 2 = 2, so: + 4ω 4 hp R4 C 4 = 2 4ωhpR 4 4 C 4 = ω hp = RC 2 74-85. Sallen, R. P.; E. L. Key 955-03). A Practical Method of Designing RC Active Filters. IRE Transactions on Circuit Theory 2 ): Copyright 208, Gustafson et al. Lab 7 2

EGR 224L - Spring 208 For this filter, then, the half-power frequency is the same as the natural frequency. Note that this is a repeated root, so there are actually two corners here - they just happen to be on top of each other. This is what leads to a sharper drop after the half-power frequency than is the case for a first-order filter. To compare, look at the following transfer functions and Bode plots. The first - represented by a solid line - is for a first-order filter with a half-power frequency of 20 krad/s - this can be generated with an RC series circuit with a kω resistor and a 50 nf capacitor. The second - represented by a dashed line - is for a second-order Sallen-Key filter with a half-power frequency of 20.797 krad/s - this can be generated with R=680 Ω and C= 50 nf. H st (s) = 5 0 5 s + H 2nd (s) = 2.32 0 9 s 2 + 6.8 0 5 s + Bode Diagram 0 0 First order Second order 0 Magnitude (db) 20 30 40 50 60 0 0 2 0 3 0 4 0 5 0 6 Frequency (rad/sec) Copyright 208, Gustafson et al. Lab 7 3

EGR 224L - Spring 208 7.3.3 Numerical Estimation of Transfer Function In a previous lab, you generated an experimental companion to a theoretical Bode magnitude plot by recording a circuit s response to eight single-frequency inputs then taking the amplitude ratio for each frequency. While this method works, it is quite inefficient. For this week, you will be using the concept of the transfer function: V out(jω) V in (jω) to generate a magnitude plot and a phase plot of an experimentally determined transfer function. MATLAB has a function called tfestimate that will produce a numerical estimate of the magnitude and phase of a transfer function given an input signal, an output signal, and possibly other information. The specific form of this command used for this lab is: [Hest, Fvals ] = tfestimate (Vin, Vout, [], [], [], Fs) where: 0 Vin - vector containing the input voltage values 0 Vout - vector containing the output voltage values 0 Fs - the sampling frequency for the voltage values, in Hz 0 Hest - vector containing complex numbers that contain the amplitudes and phases of the estimate of the transfer function 0 Fvals - vector containing the corresponding frequencies, in Hz, for the magnitudes and phases stored in Hest The square brackets in the third through fifth arguments are placeholders for parameters whose default values are fine for this experiment. Essentially, this command will determine the frequency content of the input and of the output using subsections of the data; it will then compute the magnitude ratio and phase difference between the input and the output and provide an approximation of the transfer function at particular frequencies contained in Fvals. One issue that comes into play is you must make sure the input signal has energy at as many frequencies as possible to give tfestimate values to work with. Using a single-frequency cosine as an input, for example, might lead to a disaster - if that frequency happens to exactly hit one of the frequencies tfestimate is using - since there would only be one input frequency on which to base an estimate for the response to all frequencies. This would be similar to estimating the acoustics of a concert hall by hitting a single tuning fork. It is important to note, however, that what MATLAB is really doing is assuming that your input is one period s worth of some periodic input - meaning T is t end t start and ω 0 = 2π T. Furthermore, the tfestimate command breaks the signal up into several windows, further reducing the possibility that a problem of this nature will occur. If, however, the input signal does not have any energy in the higher frequency ranges, the tfestimate program will not be able to compensate. You should therefore make sure that whatever signal gets used contains a wide range of frequencies. Ideally, the input signal would be an impulse function since that contains all frequencies at equal amounts. Barring that 2, generating a noise signal or a sweeping frequency signal with energy in the bands of interest works well. You will investigate the latter possibility in this lab. 2..and the Laws of Nature do a pretty nice job o barring that. Copyright 208, Gustafson et al. Lab 7 4

EGR 224L - Spring 208 7.4 Experimental Procedure 7.4. Downloading Data Files For this lab, you will need to download four data files. Open a web browser and point it to: http :// classes. pratt. duke. edu / FILES / EGR224 / DAQS / FilterFiles Right-click and save each of the files to MATLAB s working directory. These files contain four vectors each: 0 SoundIn - the voltages collected at the input of the signal 0 SoundOut - the voltages collected at the output of the filter 0 duration - the duration, in seconds, of the signal 0 samplerate - the sample rate, in samples per second, for the signals In each case, the sample rate was set to 40 khz, fast enough to capture signals below 20 khz. The volumes of the signals are such that the measured voltages are between - V and V; this is so the voltage measurements themselves can be sent directly to the sound command in MATLAB. 7.4.2 Let s Go Duke The first file you are going to analyze is in the DukeFightSong.m file. Start a new script and add the lines: clear load DukeFightSong sound ( SoundIn, samplerate ) pause sound ( SoundOut, samplerate ) then save this script as HearDuke.m. Run the script - the first time through, you will be hearing the original. Once that is done playing, hit return. The second time, you will be hearing the sound filtered through a first-order low-pass filter with a half-power frequency of 2000 rad/s. Among other things, you should notice that the drums stand out more. To analyze the frequency content, use the following script (also available on the Pundit page for the lab). The specific commands will be explained below. clear load DukeFightSong Filter constants R = 0000; C = 50 e -9; Experimental Transfer Function [EstH, EstF ] = tfestimate ( SoundIn, SoundOut, [], [], [], samplerate ); EstMag = abs ( EstH ); EstOmega = EstF *2* pi; Analytical Transfer Function s = tf ([ 0], []); H = / ( + s * R * C); [HMag, HPhase, HOmega ] = bode (H, {, max ( EstOmega )}); HMag = squeeze ( HMag ); Make plot figure (); clf semilogx ( EstOmega, 20* log0 ( EstMag ), b - ) hold on semilogx ( HOmega, 20* log0 ( HMag ), r - ) hold off xlabel ( \ omega, rad /s ); ylabel ( H, db ) legend ( Estimates, Theoretical, 0) The code above to get magnitudes and phases out of the tfestimate program, once the data set is loaded is: Copyright 208, Gustafson et al. Lab 7 5

EGR 224L - Spring 208 [EstH, EstF ] = tfestimate ( SoundIn, SoundOut, [], [], [], samplerate ); EstH will be a set of complex numbers representing both the magnitudes and phases of the transfer function while EstF will be the frequencies (in Hz) at which the estimates are given. The lines below this generate a vector of magnitudes of the transfer function estimates (EstMag) as well as a vector of the angular frequencies of the estimates (EstOmega). For the theoretical transfer function, you first need to set up a transfer function object in MATLAB using the tf command, then use the bode command to get an array of magnitudes, phases, and frequencies. The lines s = tf ([ 0], []); H = / ( + s * R * C); take care of this by first defining s as a transfer function: s = () s + (0) s 0 () s 0 and then using that to build the transfer function for the low-pass filter. The code above to get theoretical values for a transfer function H using the bode command is: [HMag, HPhase, HOmega ] = bode (H, {, max ( EstOmega )}); HMag = squeeze ( HMag ); where HMag and HPhase will be real numbers that give the magnitudes and phases, respectively, of the transfer function at angular frequencies denoted by HOmega. The limits on the Bode analysis are set to obtain frequencies between and the maximum value obtained by tfestimate - so make sure the tfestimate line runs first The bode command is capable of performing much more powerful tasks than we have asked for it, and as a result the output is more complicated than it needs to be for us. Specifically, the magnitude and phase vectors are three dimensional - one row, one column, and several layers. Before plotting with these then, you need MATLAB to squeeze out the extra singleton dimension - the command for this is: HMag = squeeze ( HMag ); The plot commands generate Bode plots for the experimental and analytical estimates and put them on the same graph. You should see that the experimental estimates are good for a certain range of frequencies - generally those near the middle of the graph. The low and high ends are not quite as good. Part of the reason for these errors is that the song you used does not contain a great deal of very high or very low frequencies. The next task will be to examine a file that does have those. Copyright 208, Gustafson et al. Lab 7 6

EGR 224L - Spring 208 7.4.3 Chirp Another file you have been given is the ChirpData file. This file contains a chirp signal that sweeps through frequencies from Hz to 0 khz over the course of 20 seconds. Because of that, it is a better candidate for providing information about the transfer function of the filter. First, you will want to listen to the signal and the filtered version of the signal. Save your HearDuke.m script as HearChirp.m and then change the file name loaded on line 2 to ChirpData. At the beginning, it may seem that nothing is playing - this is because the super-low frequencies in the signal are below the range of human hearing. Eventually, you will hear the signal. You may, in fact, want to move your headphones away from your ears for the latter parts of the signal as the high frequency parts are...very high. When you listed to the filtered version, you should note that the higher frequency parts now have a lower volume. To see the frequency information, go ahead and save your SeeDuke.m file as SeeChirp.m. Again, change the name of the file you are loading on line 2 of the program and run it. This time, you should see that there is a much cleaner experimentally determined transfer function. The extreme low and high ends are still not great, but the midrange should very closely match the analytically determined magnitudes. 7.4.4 2nd Order Filtering In both these cases, a first-order filter was used to eliminate the high-frequency information. Often it is preferable to use a higher-order filter, such as the Sallen-Key filter discussed above. The remaining two data files - which end in SK - were taken when passing the input signal through a Sallen-Key filter. Your job is to determine the resistor value used in the filter given that 50 nf and 00 nf capacitors were used. You should create Hear -type programs for each so you can hear how the second order filters eliminate the higher frequency sounds, then generate See -type programs. You will need to change not only the name of the file being loaded but also the structure of the transfer function. Type in a guess for the resistance value and run the See program; you can then keep adjusting your estimated R values until the experimentally determined magnitudes match the analytically determined ones. As you might imagine, using the Chirp data is probably more useful than using the Duke data because of the wider range of frequencies in the Chirp signal. 7.5 Assignment Your assignment is to go through this lab, determine good estimates for the resistance used for the Sallen-Key filter, and show the TAs the results from your four See programs. Copyright 208, Gustafson et al. Lab 7 7