Signals and Systems Lecture 8: Finite Impulse Response Filters
Total Page:16
File Type:pdf, Size:1020Kb
Signals and Systems Lecture 8: Finite Impulse Response Filters Dr. Guillaume Ducard Fall 2018 based on materials from: Prof. Dr. Raffaello D’Andrea Institute for Dynamic Systems and Control ETH Zurich, Switzerland G. Ducard 1 / 46 Outline 1 Finite Impulse Response Filters Definition General Properties 2 Moving Average (MA) Filter MA filter as a simple low-pass filter Fast MA filter implementation Weighted Moving Average Filter 3 Non-Causal Moving Average Filter Non-Causal Moving Average Filter Non-Causal Weighted Moving Average Filter 4 Important Considerations Phase is Important Differentiation using FIR Filters Frequency-domain observations Higher derivatives G. Ducard 2 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations Outline 1 Finite Impulse Response Filters Definition General Properties 2 Moving Average (MA) Filter MA filter as a simple low-pass filter Fast MA filter implementation Weighted Moving Average Filter 3 Non-Causal Moving Average Filter Non-Causal Moving Average Filter Non-Causal Weighted Moving Average Filter 4 Important Considerations Phase is Important Differentiation using FIR Filters Frequency-domain observations Higher derivatives G. Ducard 3 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations FIR filters : definition The class of causal, LTI finite impulse response (FIR) filters can be captured by the difference equation M−1 y[n]= bku[n − k], Xk=0 where 1 M is the number of filter coefficients (also known as filter length), 2 M − 1 is often referred to as the filter order, 3 and bk ∈ R are the filter coefficients that describe the dependence on current and previous inputs. G. Ducard 4 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations Outline 1 Finite Impulse Response Filters Definition General Properties 2 Moving Average (MA) Filter MA filter as a simple low-pass filter Fast MA filter implementation Weighted Moving Average Filter 3 Non-Causal Moving Average Filter Non-Causal Moving Average Filter Non-Causal Weighted Moving Average Filter 4 Important Considerations Phase is Important Differentiation using FIR Filters Frequency-domain observations Higher derivatives G. Ducard 5 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations FIR: general properties The filter length is equal to the length of the finite impulse response, given by h = {b0,b1,...,bM−1}. see brief calculations during class Stability From the impulse response, we can directly conclude that FIR filters are always stable (they have M − 1 poles at z = 0). G. Ducard 6 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations FIR: general properties Frequency Response Furthermore, their frequency response is straightforward to calculate from the transfer function: M−1 M−1 z=ejΩ H(z)= h[k]z−k −−−−→ H(Ω) = h[k]e−jΩk Xk=0 Xk=0 M−1 −jΩk = bke . Xk=0 G. Ducard 7 / 46 Finite Impulse Response Filters Moving Average (MA) Filter Definition Non-Causal Moving Average Filter General Properties Important Considerations Filter design FIR filter design methods consist in finding the coefficients bk based on a desired frequency response. There are powerful FIR filter design tools available (see, for example, MATLAB fdatool that can generate almost arbitrary frequency responses. In this lecture, you will learn : the concepts that underly FIR filters, and, using the simple example of the moving average filter, how to analyze filters using the tools, learnt in the course. G. Ducard 8 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations Outline 1 Finite Impulse Response Filters Definition General Properties 2 Moving Average (MA) Filter MA filter as a simple low-pass filter Fast MA filter implementation Weighted Moving Average Filter 3 Non-Causal Moving Average Filter Non-Causal Moving Average Filter Non-Causal Weighted Moving Average Filter 4 Important Considerations Phase is Important Differentiation using FIR Filters Frequency-domain observations Higher derivatives G. Ducard 9 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations MA filter: simple low-pass FIR filter A very simple type of low-pass (LP) FIR filter: the moving average (MA) filter. The MA filter averages the current and past inputs to produce its output, and is described by the difference equation M−1 1 y[n]= u[n − k], M Xk=0 i.e. bk = 1/M for k = 0,...,M − 1. The frequency response of the MA filter is therefore: M−1 1 − H(Ω) = e jΩk. M Xk=0 We can easily see that H(0) = 1: a constant signal remains unchanged by the filter (property of a LP filter). G. Ducard 10 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations MA filter: simple low-pass FIR filter M−1 M−1 1 1 k H(Ω) = e−jΩk = e−jΩ . M M Xk=0 Xk=0 Therefore, 1 (1 − e−jΩM ) ∴ H(Ω) = , M (1 − e−jΩ) which shows that: H(Ω) = 0 iff e−jΩM = 1 and e−jΩ 6= 1. The zeros of the MA filter therefore occur at frequencies Ω = 2πk/M where k is an integer not equal to 0 or a multiple of M. G. Ducard 11 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations MA filter: simple low-pass FIR filter 1 (1 − e−jΩM ) H(Ω) = M (1 − e−jΩ) Magnitude response : |H(Ω)| 1 M = 2 | M = 3 (Ω) M = 4 0.5 H | 0 π 2π π 2 3 Ω G. Ducard 12 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations MA filter: simple low-pass FIR filter 1 (1 − e−jΩM ) H(Ω) = M (1 − e−jΩ) The phase response ∠H(Ω) of the filter is shown below. π M = 2 π M = 3 2 M = 4 (Ω) 0 H ∠ π − 2 −π π 2π π 2 3 G. Ducard 13 / 46 Ω Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations MA filter: simple low-pass FIR filter Phase response analysis: For small values of Ω, the filter’s frequency response can be approximated as: 1+(1 − jΩ) + · · · + (1 − jΩ(M − 1)) H(Ω) ≈ . M The real part of H(Ω) is equal to 1, and the imaginary part is given by 1+2+ · · · +(M − 1) Ω M(M − 1) Ω(M − 1) −Ω = − = − . M M 2 2 Therefore, the phase can be approximated by Ω(M − 1) Ω(M − 1) ∠H(Ω) ≈ arctan − ≈− , 2 2 using the small angle assumption. This approximation is exact until the first zero of H(Ω), as you will show in the problem set. G. Ducard 14 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations Magnitude response The magnitude response of the filter can be derived as follows: − 1 (1 − e jΩM ) 1 − cos ΩM + j sin ΩM H(Ω) = = M (1 − e−jΩ) M(1 − cos Ω + j sin Ω) (1 − cos ΩM)2 + sin2 ΩM ∴ |H(Ω)|2 = M 2((1 − cos Ω)2 + sin2 Ω) 1 − 2 cos ΩM + cos2 ΩM + sin2 ΩM = M 2(1 − 2 cos Ω + cos2 Ω + sin2 Ω) (1 − cos ΩM) = M 2(1 − cos Ω) sin2( ΩM ) = 2 since 1 − cos(2p) = 2 sin2(p). 2 2 Ω M sin ( 2 ) G. Ducard 15 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations Magnitude response sin ΩM sin ΩM sin ΩM 1 2 Ω/2 2 2 1 |H(Ω)| = Ω = Ω = · Ω M sin MΩ/2 sin MΩ/2 sin 2 2 2 Ω/2 ΩM sinc 2 = Ω sinc 2 ΩM ≈ sinc 2 for small Ω. Therefore, the magnitude response of the MA filter is approximated by the absolute value of the sinc function for small Ω. This function, below, has peaks (lobes) and is not a great LP filter. | 1 ) w ( 0.5 sinc | 0 0 5 w G. Ducard 16 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations Outline 1 Finite Impulse Response Filters Definition General Properties 2 Moving Average (MA) Filter MA filter as a simple low-pass filter Fast MA filter implementation Weighted Moving Average Filter 3 Non-Causal Moving Average Filter Non-Causal Moving Average Filter Non-Causal Weighted Moving Average Filter 4 Important Considerations Phase is Important Differentiation using FIR Filters Frequency-domain observations Higher derivatives G. Ducard 17 / 46 Finite Impulse Response Filters MA filter as a simple low-pass filter Moving Average (MA) Filter Fast MA filter implementation Non-Causal Moving Average Filter Weighted Moving Average Filter Important Considerations Fast MA filter implementation Consider a MA filter with M coefficients and output given by M−1 1 y[n]= u[n − k].