FILTERING OBJECTIVES The objectives of this lecture are to: Introduce signal filtering concepts Introduce filter performance criteria Introduce Finite Impulse Response (FIR) filters Introduce Infinite Impulse Response (IIR) filters Consider advantages of digital filters Consider advantages of using DSP in digital filter implementation Consider sources of noise in digital filters
Signals and Filtering AMPLITUDE Time Domain The Filter V in C R V out TIME AMPLITUDE Frequency Domain AMPLITUDE FILTERED OUT: f 1 f 2 SURVIVED: f 3 f 4 f 5 f 1 f 2 f 3 f 4 f 5 FREQUENCY f 1 f 2 f 3 f 4 f 5 FREQUENCY
Depending on the application, some frequencies may be undesirable. Filters can be used to remove these undesirable frequency components. Low-pass Filters (LPF) - These filters pass low frequencies and stop high frequencies. High-pass Filters (HPF) - These filters pass high frequencies and stop low frequencies. Band pass Filters (BPF) - These filters pass a range of frequencies and stop frequencies below and above the set range. Band-Stop Filters (BSF) - These filters pass all frequencies except the ones within a defined range. All-Pass Filters (APF) - These filters pass all frequencies, but they modify the phase of the frequency components.
Phase AMPLITUDE TIME We can see phase response A A t 90 0 PHASE SHIFT t 180 0 PHASE SHIFT Can we hear phase response? Non-linear phase response is undesirable in: Music Video Data Communications Humans locate medium frequency sound by working out the phase difference between signals arriving at each ear. This is a property that is used in stereo hi-fi reproduction.
Analog Filters I High Pass H(ω) = V out V in H(ω) = R R + 1 jωc V in C R V out Re [H(ω)] φ A Im[H(ω)] X C = 1 jωc ω = 2πf j = -1 Re = Real Part Im = Imaginary Part V in = I ( R + X C ) Gain = A = Re [H(ω)] 2 + Im[H(ω)] 2 V out = I*R Phase = φ = tan -1 Im [H(ω)] Re [H(ω)]
High-Pass Response A High Pass A = R R 2 + 1 (ωc) 2 Phase (Degrees) 90 60 30 f c f f c is when A = (1/ ) A 2 1 φ = tan -1 ( ) ωrc f c = f c = cut-off frequency (3dB point) 1 2πRC 0 f c f
V in A R Low-Pass Response C V out H(ω) = R + 1 jωc 1 jωc f c f A = 1 1 + ω 2 R 2 C 2 Phase (Degrees) 0 f c = 1 2πRC - 30-60 φ = tan -1 ( ωrc ) - 90 f c f
Performance Criteria Amplitude Response A PASS BAND RIPPLE 3dB POINT 20 log 10 A = Gain in db f c = Cut-off frequency f c STOP BAND RIPPLE f Gain at 3dB point (at f c ) = A 2 PASS BAND STOP BAND Ripple in pass band causes uneven gain Possible to design with no ripple Ripple in stop band is less important than in pass band Fall off db/decade (Gain in db/decade of f) Stop band attenuation
φ Phase Response of a Linear Phase Filter Phase Response Phase response represents time delay of different frequencies Time Delay f 1 f 2 Uniform Time Delay of a Linear Phase Filter f Linear phase response delays all frequencies by the same amount Time delays at f 1 and f 2 are equal Non-linear phase response Delays all frequencies by different amounts Causes distortion to original signal Is audible in a music application Is visible in a video application f 1 f 2 f Linear phase is only important in pass band Some non-linearity can be tolerated
A Butterworth Filter 1.0 0.1 0.01 0.1 Delay n=1 n=2 n=4 n=32 n=8 f / f c 1 10 A = f 1+ ( ) 2n Maximally flat magnitude response Poor phase response, nonlinear around cut-off frequency 1 f c 0 1.0 2.0 f / f c Excessively high-order filter needed to achieve adequate roll-off
Filter Types Chebyshev Steeper roll-off than Butterworth More ripple in pass band Poor phase response Bessel Maximally flat phase response Less steep roll-off Filter design software packages allow us to: Experiment with many designs Evaluate suitability of gain and phase responses
Digital Filters Input x(n) Z -1 x(n-1) Z -1 x(n-2) Tap b 0 b 1 b 2 Weight Σ Σ Summing junction y(n) Output x(n) sampled analog waveform, x(0) at t = 0, x(1) at t = t s, x(2) at t = 2 t s... t s = sampling period f s =1/t s b n = weights (coefficients, scaling factor) Z -1 unit time delay = one sampling period y(n) = b 0 x(n) + b 1 x(n - 1) + b 2 x(n - 2)
Moving Average Filter x(n) Z -1 x(n-1) Z -1 x(n-2) Assume no previous inputs X(0) = 20; X(-1) = 0; X(-2) = 0 0.25 0.5 0.25 40 30 20 10 40 30 20 10 $ $ Input 12 40 mon tue wed thu fri sat sun Output mon tue wed thu fri sat sun Σ Σ y(n) time time And let b 0 = 0.25 b 1 = 0.5 b 2 = 0.25 y(0) = 0.25*x(0) + 0.5*x(-1) + 0.25*x(-2) = 5 y(1) = 0.25*20 + 0.5*20 + 0.25*0 = 15 y(2) = 0.25*20 + 0.5*20 + 0.25*20 = 20 y(3) = 0.25*12 + 0.5*20 + 0.25*20 = 18 y(4) = 0.25*40 + 0.5*12 + 0.25*20 = 21 y(5) = 0.25*20 + 0.5*40 + 0.25*12 = 28 y(6) = 0.25*20 + 0.5*20 + 0.25*40 = 25 Moving average calculation
Width = 0 Amplitude = Weighted Impulse Function A - Area under pulse δ(t) d(t) = 1 Weighted Impulse Function A - Aδ(t) d(t) = A t A 3 3 5 t=5 t=3 Area under pulse pulse(t) d(t) = 3 d(t) = 6 Area = A Amplitude = Sampling Waveform as Weighted Impulse Train s(t) = δ (t-( ) +...+ δ (t ( - t s ) + δ (t) ( + δ (t ( + t s ) +...+ δ (t ( + ) t t=5 t=3 -t s t s 2t s 3t s 4t s... t s(t) = n = n = δ ( t nt s )
40 30 20 10 0.5 0.25 $ y(t) IMPULSE RESPONSE OF FILTER Filter Functions FILTER INPUT AS WEIGHTED IMPULSES 0 1 2 3 4 5 6 time MONDAY S INPUT VALUE - 20 δ(t) d(t) = 20 Output waveform is obtained for a single-unit weighted impulse applied at t=0 Impulse response consists of finite number of pulses; hence finite impulse response (FIR) filter 0 1 2 3 t Impulse response may be used to obtain response to any input
FIR Filters An FIR Filter with a steeper roll-off: x(t) Z -1 Z -1 b 1 b 0 b 63 64 taps Σ Σ y(t) A more realistic filter designed using a software filter design package Specifications: Cut-Off Frequency = 975 Hz Stop Band Attenuation > 80dB Sharp Roll-Off Filter with 64 taps 64 different gain values This filter is used in our demonstration
FIR Response f C f C f c = cut off frequency
Infinite Impulse Response Filters Input b 0 Output x(t) Σ y(t) Z -1 b 1 a 1 Z -1 Z -1 b 2 a 2 Z -1 y(t) = b 0 x(t) + b 1 x(t - 1) + b 2 x(t - 2) + a 1 y(t - 1) + a 2 y(t - 2) }Moving Average Portion }Auto Regressive Portion Feedback loop Non-linear phase response Fewer taps than FIR for given roll-off May be unstable
Input x(t) Comb Filter Σ Z -1 Z -1 Σ w(t) k unit delays -1 Output y(t) Gain a y(t) = x(t) + aw(t k) w(t k) f s /k 2f s /k 3f s /k f Less Multiplication No Filter Coefficients Simple to Extend, Easy to Design Can Be Used at Higher Sampling Rates Than FIR
DSP and Digital Filters Advantages of Digital Filters Programmable It is possible to implement adaptive filters that change coefficients under certain conditions Why use DSP for digital filter implementation? REMEMBER: A = B*C + D y(n) = a 0 x(n) + a 1 x(n 1) + a 2 x(n 2)
0010 + 1111 = 10001 Performance Issues Dynamic-Range Constraints Noise in Digital Filters Signal Quantization Noise introduced is proportional to the number of bits that the conversion uses Coefficient Quantization Coefficients determine the behavior of filters More significant in IIR Truncation 0.64 x 0.73 = 0.4672 which truncates to 0.46 Double-width product registers and accumulators help reduce truncation errors Internal Overflow OVERFLOW 16 bit 20 log 10 ( 2 16 ) = 96dB 32 bit 20 log 10 ( 2 32 ) = 192dB SATURATE 1111
Digital Filter Design Automates design task by software Design software requires information such as: Pass Band, Stop Band, Transition Region Ripple in Pass Band Required Roll-Off Design Software Generates: Number of Taps Coefficients Required DSP Specific Assembly Code Response Plots Gain Phase Impulse Enables evaluation of design before implementation A low cost evaluation board such as DSK can be used for actual testing
Summary Filters are used for frequency selection Low and high pass analog filters Performance Pass Band Ripple, Roll-Off and Phase Response Digital finite impulse response (FIR) filters Digital infinite impulse response (IIR) filters Advantages of Digital Filters Programmable Adaptive Filters DSP makes digital filter implementation easier