LAB 6: FIR Filter Design Summer 2011

Similar documents
LAB 2: DTFT, DFT, and DFT Spectral Analysis Summer 2011

Lecture 14: Windowing

Basic Design Approaches

-Digital Signal Processing- FIR Filter Design. Lecture May-16

(Refer Slide Time: 01:28 03:51 min)

Filter Design Problem

UNIT - 7: FIR Filter Design

Review of Fundamentals of Digital Signal Processing

Review of Fundamentals of Digital Signal Processing

Exercises in Digital Signal Processing

Stability Condition in Terms of the Pole Locations

LABORATORY 3 FINITE IMPULSE RESPONSE FILTERS

Problem Set 9 Solutions

Signal Processing. Lecture 10: FIR Filter Design. Ahmet Taha Koru, Ph. D. Yildiz Technical University Fall

Chapter 7: Filter Design 7.1 Practical Filter Terminology

EEL3135: Homework #4

E : Lecture 1 Introduction

IT DIGITAL SIGNAL PROCESSING (2013 regulation) UNIT-1 SIGNALS AND SYSTEMS PART-A

Filter structures ELEC-E5410

Filter Analysis and Design

ECSE 512 Digital Signal Processing I Fall 2010 FINAL EXAMINATION

Digital Signal Processing Lecture 9 - Design of Digital Filters - FIR

UNIVERSITY OF OSLO. Please make sure that your copy of the problem set is complete before you attempt to answer anything.

How to manipulate Frequencies in Discrete-time Domain? Two Main Approaches

EECE 301 Signals & Systems Prof. Mark Fowler

Discrete Time Fourier Transform (DTFT)

EE 521: Instrumentation and Measurements

Lecture 13: Discrete Time Fourier Transform (DTFT)

ELEG 305: Digital Signal Processing

The Discrete-Time Fourier

Chirp Transform for FFT

LINEAR-PHASE FIR FILTERS DESIGN

ECE503: Digital Signal Processing Lecture 5

2.161 Signal Processing: Continuous and Discrete Fall 2008

UNIVERSITY OF OSLO. Faculty of mathematics and natural sciences. Forslag til fasit, versjon-01: Problem 1 Signals and systems.

Discrete Time Signals and Systems Time-frequency Analysis. Gloria Menegaz

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur DEPARTMENT OF INFORMATION TECHNOLOGY. Academic Year

Linear Convolution Using FFT

Lecture 7 Discrete Systems

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

REAL TIME DIGITAL SIGNAL PROCESSING

Multimedia Signals and Systems - Audio and Video. Signal, Image, Video Processing Review-Introduction, MP3 and MPEG2

Vel Tech High Tech Dr.Ranagarajan Dr.Sakunthala Engineering College Department of ECE

Fourier Analysis of Signals Using the DFT

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

/ (2π) X(e jω ) dω. 4. An 8 point sequence is given by x(n) = {2,2,2,2,1,1,1,1}. Compute 8 point DFT of x(n) by

ELEG 5173L Digital Signal Processing Ch. 5 Digital Filters

ECE 410 DIGITAL SIGNAL PROCESSING D. Munson University of Illinois Chapter 12

1. FIR Filter Design

On the Frequency-Domain Properties of Savitzky-Golay Filters

Fourier Series Representation of

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science Discrete-Time Signal Processing Fall 2005

ELEG 305: Digital Signal Processing

Let H(z) = P(z)/Q(z) be the system function of a rational form. Let us represent both P(z) and Q(z) as polynomials of z (not z -1 )

Lab 4: Quantization, Oversampling, and Noise Shaping

INF3440/INF4440. Design of digital filters

Discrete-Time Fourier Transform

Discrete Fourier Transform

DSP. Chapter-3 : Filter Design. Marc Moonen. Dept. E.E./ESAT-STADIUS, KU Leuven

Multidimensional digital signal processing

EE123 Digital Signal Processing

Signals and Systems. Problem Set: The z-transform and DT Fourier Transform

Review of Discrete-Time System

Lecture 3 - Design of Digital Filters

Convolution. Define a mathematical operation on discrete-time signals called convolution, represented by *. Given two discrete-time signals x 1, x 2,

Department of Electrical and Computer Engineering Digital Speech Processing Homework No. 6 Solutions

Contents. Digital Signal Processing, Part II: Power Spectrum Estimation

EE301 Signals and Systems In-Class Exam Exam 3 Thursday, Apr. 19, Cover Sheet

Computer-Aided Design of Digital Filters. Digital Filters. Digital Filters. Digital Filters. Design of Equiripple Linear-Phase FIR Filters

Grades will be determined by the correctness of your answers (explanations are not required).

Assignment 2. Signal Processing and Speech Communication Lab. Graz University of Technology

UNIVERSITI SAINS MALAYSIA. EEE 512/4 Advanced Digital Signal and Image Processing

Computer Engineering 4TL4: Digital Signal Processing

DISCRETE-TIME SIGNAL PROCESSING

Definition. A signal is a sequence of numbers. sequence is also referred to as being in l 1 (Z), or just in l 1. A sequence {x(n)} satisfying

Responses of Digital Filters Chapter Intended Learning Outcomes:

Chap 2. Discrete-Time Signals and Systems

University of Illinois at Urbana-Champaign ECE 310: Digital Signal Processing

Digital Speech Processing Lecture 10. Short-Time Fourier Analysis Methods - Filter Bank Design

Question Bank. UNIT 1 Part-A

TTT4120 Digital Signal Processing Suggested Solutions for Problem Set 2

Final Exam ECE301 Signals and Systems Friday, May 3, Cover Sheet

EE123 Digital Signal Processing

Grades will be determined by the correctness of your answers (explanations are not required).

Frequency-Domain C/S of LTI Systems

Digital Signal Processing

Analog vs. discrete signals

Digital Filters Ying Sun

Multirate Digital Signal Processing

1 1.27z z 2. 1 z H 2

University of Illinois at Urbana-Champaign ECE 310: Digital Signal Processing

Fourier Analysis and Spectral Representation of Signals

8 The Discrete Fourier Transform (DFT)

Cast of Characters. Some Symbols, Functions, and Variables Used in the Book

SNR Calculation and Spectral Estimation [S&T Appendix A]


DIGITAL SIGNAL PROCESSING UNIT III INFINITE IMPULSE RESPONSE DIGITAL FILTERS. 3.6 Design of Digital Filter using Digital to Digital

DFT & Fast Fourier Transform PART-A. 7. Calculate the number of multiplications needed in the calculation of DFT and FFT with 64 point sequence.

VII. Discrete Fourier Transform (DFT) Chapter-8. A. Modulo Arithmetic. (n) N is n modulo N, n is an integer variable.

The Discrete Fourier Transform

Transcription:

University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 311: Digital Signal Processing Lab Chandra Radhakrishnan Peter Kairouz LAB 6: FIR Filter Design Summer 011 1 Overview In this lab we will use MATLAB to design FIR filters using truncation, windowing, and frequency sampling. FIR Filter Design While designing frequency selective filters, we look at the desired filter characteristics in the frequency domain in terms of the desired magnitude and phase response of the filter. In filter design we determine the coefficients of a FIR or IIR filter that closely approximates the desired frequency response specifications. The choice between FIR or an IIR filter depends on the nature of the problem and the desired frequency response. Usually FIR filters are employed in filtering problems where there is a requirement of linear phase characteristic in the passband of the filter. If there is no such requirement one can design either an FIR or an IIR filter. However it must be noted that in general an IIR filter has lower sidelobes in the stopband than an FIR filter having the same number of parameters. In this lab we will focus on FIR filter. FIR filters are described by the following difference equation, y[n] = M b[m]x[n m] where y[n] is the filtered signal, b[m] are the numerator coefficients of the transfer function. m=0 3 Ideal and non-ideal filter characteristics Consider the impulse h(n) of an ideal lowpass filter with frequency response characteristic { 1, ω ωc H(ω) = 0, ω c ω π The impulse response of this filter is shown below, h[n] = { ω c π, n = 0 ω c sinω cn π ω, n 0 cn Consider the above expression for ω c = π 4. Is the impulse response physically realizable. How will you will plot this function in MATLAB? We will truncate this function to the interval ( 100, 100). Now plot the truncated sinc(.) function. 1

n = [-100:100] x = (1/4)*n; plot(n,sinc(x)); Is the truncated impulse response physically realizable? 3.1 Causality It is clear that the ideal low pass filter and its truncated version are not causal and cannot be realized in practice. One possible solution is to introduce a large delay n 0 in h[n] and arbitrarily to set h[n] = 0 for n < n 0. This makes the filter causal. Causality results in important implications in filter design, The frequency response of H(ω) cannot be zero except at a finite set of points in frequency. Magnitude H(ω) cannot be constant in any finite range of frequencies and the transition from pass-band to stop-band cannot be infinitely sharp. The real and imaginary parts of H(ω) are interdependent and hence the H(ω) and H(ω) cannot be arbitrarily chosen. The realizable magnitude response is shown in Fig. 1. Figure 1: Realizable Magnitude response 4 Linear Phase Filters A filter whose impulse response is symmetric or antisymmetric about its midpoint is called a (generalized) linear phase filter. That is, h[n] H(ω) = H(ω) e jkω For such filters the phase of the filtered signal will vary linearly with frequency ω. The phase delay (kω/ω) and ( d dω ) will be equal and constant. What is the phase and group delay for an order n linear phase FIR filter? Consider the following FIR filter, Try the following y[n] = 1 (x[n] + x[n 1] + x[n ] + x[n 3] + x[n 4]) ;

h = 0.*ones(1,5) Is the FIR filter linear phase? A system is referred to as generalized linear-phase system if its frequency response can be expressed in the form, H d (ω) = H d (ω) e jα+jβ where α and β are constants. The symmetric impulse response of a linear phase filter can have an odd or even number of points, and can have an odd or even symmetry about the midpoint, leading to four filter types: 1. Type I : Even Symmetry : h[n] = h[m n], 0 n M M is an even integer. Type II : Even Symmetry : h[n] = h[m n], 0 n M M is an odd integer H d (π) = 0 3. Type III : Odd Symmetry : h[n] = h[m n], 0 n M M is an even integer H d (0) = 0 H d (π) = 0 4. Type IV : Even Symmetry : h[n] = h[m n], 0 n M M is an odd integer H d (0) = 0 4.1 FIR filter design by windowing In this method we begin with desired frequency response specification H d (ω) and determine the corresponding unit sample response h d [n]. H d (ω) and h d [n] are related by the following Fourier transform relation, H d (ω) = h d [n]e jωn (1) n=0 π h d [n] = 1 π π H d (ω)e jωn dω () As mentioned earlier, the unit sample response h d [n] obtained from () is infinite in duration and must be truncated at some point, say n = M 1, to yield a FIR filter of length M. Truncation of h d [n] to a length M 1 is equivalent to multiplying h d [n] by a rectangular window defined as, { 1, n = 0, 1,..., M 1 w[n] = 0, otherwise 3

The Fourier transform of the rectangular window is, ωm ω() j W (ω) = e sin ω Plot on the same figure the magnitude and phase response of the window function for window lengths M = 31 and M = 11. What happens to the main lobe? What happens to the side-lobes? What can you say about the phase response? The characteristics of the rectangular window play a significant role in determining the resulting frequency response of the FIR filter obtained by truncating h d [n] to length M. Recall applying a window function in the time domain is equivalent to convolution in the frequency domain and has the effect of smoothing H d (ω).as M is increased, W (ω) becomes narrower and the smoothing action of W (ω) is reduced. On the other had large side-lobes of W (ω) has the effect undesirable ringing effects. The undesirable ringing effects in FIR filters can be reduced by using windows that do now have abrupt discontinuities in their time-domain characteristics. Table 1 lists some window functions, Using Table 1: Window Functions for FIR filter design Window Time Domain Sequence Hamming 0.54 0.46cos πn Blackman 0.4 0.5cos πn 4πn + 0.08cos ( ) 1 Hanning 1 cos πn Kaiser ] I 0 [α ( ) (n frac) I 0[α( )] MATLAB plot the magnitude and phase response of of the Hamming, Blackman and Hanning windows. Use Window length of N = 31, 11. Compare your results to those obtained by rectangular window. Matlab has several window functions. You can see them by typing help window. Matlab also has several functions to design filters. The function fir1 can be used to design a M th order FIR digital filter. Try the following help fir1 h = fir1(31,1/, low ); h = fir1(31,1/, high ); h = fir1(31,1/,hamming(3)); Some other filter design functions are, fir, firpm, fircls1, firls. 4. Filter Design by Frequency Sampling In frequency sampling method of FIT filter design, we specify the desired frequency response H d (ω) at a set of equally spaced frequencies, namely, H( πk 15 ) = 1, k = 0, 1,, 3 0.4, k = 4 0, k = 5, 6, 7 4

We then solve for unit sample response h d [n] of the filter from these equally spaced specifications. To reduce side-lobes, it is desirable to optimize the frequency specification in the transition band of the filter. The optimization can be done by on computer using linear programming techniques. 5 Homework - Due 07/6/011 at 5:00 PM 1. You desire to design a generalized linear phase (GLP) FIR low-pass filter with ω c = π/4 using a truncation (windowing) method. Beginning with an ideal LPF h LP F [n] = sin( π 4 n) πn, we can design a FIR filter by shifting h LP F [n] by N 1 and multiplying by window function w [n], h[n] = sin ( ( )) π 4 n N 1 π ( n N 1 ) w [n], n = 0, 1,..., N 1. For a rectangular window with length N = 1, plot h[n], H d (ω), and H d (ω) in MATLAB. Check the cut-off frequency of this filter from the graph of H d (ω). Use 4096-point DFT to generate H d (ω) and H d (ω). Show these plots over the range of [0, π]. ( (b) Consider a hamming window of with length N = 1, i.e., w [n] = 0.54 0.46cos πn N 1 as in (b) and compare the results. (c) ). Do the same thing Consider rectangular window with length N = 11. Do the same things as in (b) and compare the results.. You desire to design a 11- tap generalized linear phase (GLP) FIR low-pass filter with ω c = π 4 sampling method. using frequency (b) Write down the sampled frequency response H d (ω) at ω = πk N linear phase) for 0 k N 1 (hint: consider generalized Determine the impulse response of this LPF using inverse-fft in MATLAB (ifft). Plot h[n], H d (ω) and H d (ω) in MATLAB. Use a 4096 -point fft to generate H d (ω) and H d (ω). Show the plots over a range of [0, π]. (c) Construct a high-pass filter (HPF) from this filter using modulation property. Plot h[n], H d (ω), and H ( ω) of this HPF with MATLAB. 3. The expression for the coefficients {h n } 31 0 of a length-3 FIR low-pass filter having cutoff at w c = π 4 the window design method with Hamming window is given by, {h n } 31 0 = 1 4 sinc [ π 4 ( n 31 )] [ ( )] πn 0.54 0.46cos 31 radians using (3) (b) (c) Design the same filter using MATLAB command fir1. Plot both the magnitude and phase of the frequency response. Comment on the plots in relation to the frequency response of an ideal low-pass filter. What are the pass-band ripple and stop band attenuations of your filter in db? What is the transition bandwidth? Generate an input signal consisting of sum of two sinusoids with ω = π 6 and ω = π 3. Convolve this signal with the filter specified in (3). Explain the results based on frequency response of the filter. 4. This problem requires you to work with three different low-pass filters which are specified by the coefficient vectors stored in the file phdist.mat, on the course website. Load the the file using the load command. If this file has been loaded correctly, then typing who should result in 5

>>who Your variables are: a1 a3 b xnoise a b1 b3 The vectors a1 through a3 and b1 through b3 contain the coefficient vectors for three discrete-time filters in the format required by freqz and filter. The vector xnoise contains the speech signal with some high-frequency noise added. The original speech signal is in the file orig.mat on the course website. Once you load the orig.mat file the uncorrupted version of the speech signal will be in the vector x. Use freqz to compute the frequency response of all the three filters at 104 evenly spaced points on the interval 0 ω π. Plot the frequency response magnitude of all three filters. Suppose you used the same speech signal as input to all three filters, based on the magnitudes of the frequency responses, which two of the output signals would you expect to sound most similar? (b) Generate appropriately labeled plots of the phase of the frequency response for all three systems. The function angle will return angles between π and π. If just plot the output of angle, you may find it hard to understand some of the plots., since phase will wrap around from the top to the bottom of the graph every time it passes π and π. The function unwrap takes the output of angle and removes the wrap around effect to obtain a more continuous phase function. For example, if H contains the samples of the frequency response at frequencies specified in omega then plot plot(omega/pi,unwrap(angle(h))) displays the unwrapped phase. Which two filters are most alike in phase response? (c) (d) (e) (f) (g) Deliverables Define the vectors y1 through y3 to be the output of the filters when they are applied to the clean speech signal in x using filter. Play each speech signal using soundsc. Is the speech still easy to understand in each case? Which two speech signals sound most alike? Based on your results for this input signal, would you say that the magnitude or phase of these filters is more important? Play both x and xnoise using sound to hear the difference between clean and corrupted speech signals. Use fft to compute the DTFT of x and xnoise at 819 evenly spaced samples in ω and store these values X and Xn. Plot the magnitude of the DTFT for each signal. Can you see the high frequency noise in the DTFT of the corrupted signal? Let yn1 and yn3 be the result of filtering xnoise with each of the three filters. Listen to all three of these signals. Which filter best eliminated the noise? Use fft to compute the DTFT of the filtered speech signals at 819 evenly spaced points in ω and store them in Yn1 through Yn3. Make appropriately labeled plots of the magnitude of the DTFT for each signal. Comment on your results. Email your code, figures, calculation and answers as a.pdf or.doc file to ece311lab.uiuc@gmail.com. Be sure to name your document in the form- ECE311Lab6 firstname lastname.doc/pdf. Late reports will reduce the grade by 0% per day. Make sure to present a clear and concise report having figures labeled and centered. Reminder: Homework is due on 07/6/011 6