Analog and Digital Filter Design by Jens Hee http://jenshee.dk October 208
Change log 28. september 208. Document started.. october 208. Figures added. 6. october 208. Bilinear transform chapter extended. i
Contents Introduction 2 2 Frequency Selective Filters 3 2. Filter specification................................... 3 2.2 Butterworth filters................................... 5 2.2. Filter poles................................... 5 2.2.2 Filter order................................... 6 2.3 Chebyshev filters.................................... 6 2.3. Filter poles................................... 6 2.3.2 Filter order................................... 7 2.4 Inverse Chebyshev filters................................ 8 2.4. Filter zeros and poles.............................. 8 2.4.2 Filter order................................... 9 3 Low pass to High pass transform 0 4 Low pass to Band pass transform 5 The Bilinear transform 2
Chapter Introduction The analog and digital filter design method depends on the type of filter to be designed. Roughly speaking filters fall in two groups: Frequency Selective Filters with approximately piecewise constant frequency weighting and Frequency Weighting Filters where the frequency weighting is some desired curve. The Frequency Selective Filters are often designed using approximating functions, whereas Frequency Weighting Filters are designed using iterative methods. Frequency Selective filter are also sometimes designed using iterative methods for example if a certain phase or group delay is desired. Since Frequency Selective Filters have an approximately piecewise constant frequency weighting they can be designed as analog filters and then transformed to digital filters using the bilinear transform. This is normally not possible for Frequency Weighting Filters since the bilinear transform distorts the frequency axis and thereby the desired frequency response. When transforming an analog filter to a digital filter using the bilinear transform the result is a so called IIR filter(infinite impulse response). Another type of digital filter is the FIR filter (finite impulse response).these filters are usually designed using time domain weighting or iterative methods (e.g. the Remez method). FIR filter design is not covered by this paper. Iterative methods are also excluded from this paper. 2
Chapter 2 Frequency Selective Filters The most common filters of this type are: Low Pass filters, High Pass Filters, Band Pass Filters an Band Stop Filters, where only the magnitude response is specified. These analog filters can be designed using appoximating functions. A prototype LP filter is designed first and it is then converted to the desired type. If a digital filter is to be designed, the analog filter can be transformed to a digital filter using the bilinear transform. It is important to remember that the bilinear transform also in this case distorts the frequency axis, but since the desired frequency response is piecewise constant, this can be handled by adjusting the cut-off frequencies of the analog filter. 2. Filter specification A normalized ideal low pass filter has a magnitude frequency response as shown in Figure 2.. T (jω) 2 ω Figure 2.: Ideal frequency response of low-pass filter This ideal response cannot be achieved in practice and it is therefore necessary to change the 3
T (jω) 2 ɛ 2 ɛ 2 2 ω p ω s ω Figure 2.2: Modified frequency response of low-pass filter specification to an approximate one as shown in Figure 2.2. If the magnitude of the frequency response is written: T (jω) 2 = + K(jω) 2 then the filter specification can be given by the magnitude of K as shown in Figure 2.3. K(jω) 2 ɛ 2 2 ɛ 2 ω p ω s ω Figure 2.3: Modified frequency response of K It is seen that K(jω) 2 must approximate zero in the passband and infinity in the stop band. If therefore the zeros and poles are placed on the imaginary axis, K(ω) can be written: K(ω) = ω k i (ω 2 ω 2 i ) 4
or K(ω) = ω k i(ω 2 ωi 2 ) j(ω 2 ωj 2 ) If the zeroes are placed in the passband and the poles in the stop band, then the specification can be met. The following expressions are used in the next sections: k = f p f s where f p is the passband cut-off frequency and f s is the stop band frequency. k = ap 0 0 0 as 0 where a p is the maximum damping in the passband and a s is the minimum damping in the stop band: K(ω) = ɛf n (ω) 2.2 Butterworth filters 2.2. Filter poles The Butterworth filter is obtained if F n (0) = 0 and the first n derivatives of F n are zero, giving: F n (ω) = ω n and T n (jω) 2 = + ω 2n ɛ is omitted since it only scales the frequency axis. Note that T n (jω) 2 = for ω = independent of n. 2 We now have: and the poles are found by solving: or The poles are now given by: T n (s)t n ( s) = ( s 2 ) n + = 0 s 2n = ( ) n+ + ( s 2 ) n s k = e j v+2kπ 2n, k {0,, 2,..., 2n } where v = 0 for n odd and v = π for n even. The poles in the left half plane of T n (s) are given by: s k = sin( 2k + 2n + π) + j cos(2k π), k {0,, 2,..., n } 2n 5
The denominator polynomials of T n (s) for n =, 2, 3 are: s + s 2 + 2s + s 3 + 2s 2 + 2s + 2.2.2 Filter order If the damping in the passband is a p and the damping in the stop band a s then: giving and a p = 0 log( + ( f p f 0 ) 2n ) a s = 0 log( + ( f s f 0 ) 2n ) ( f p f s ) 2n = k n = log k 2 log k n is rounded up and a lower and upper bound of f 0 is found from the formulas for a p and a s. Since ω 0 = for the poles given above, the poles must be scaled by 2πf 0 in order to give the desired f p and f s. 2.3 Chebyshev filters 2.3. Filter poles For the Butterworth filter the error in the passband increase with frequency. The maximum error can be reduced by letting the error oscillate through the passband. This is obtained by letting the polynomial F above be a Chebyshev polynomial: F n (ω) = C n (ω) = cos(n arccos(ω)) or C n (ω) = cos(nu), To see this is a polynomial, cos(nu) is expanded: ω = cos(u) C n (ω) = cos(nu) = cos n (u) ( n 2) cos n 2 (u) sin 2 (u) + ( n 4) cos n 4 (u) sin 4 (u) +... Since cos 2 (u) + sin 2 (u) =, sin 2 (u) = ω 2 and: C n (ω) = ω n ( n 2)ω n 2 ( ω 2 ) + ( n 4)ω n 4 ( ω 2 ) 2 +... 6
The Chebyshev polynomials all oscillates between ± in the interval - to. They can be found using the recursion: C n+ (ω) = 2C n (ω)ω C n (ω), C 0 (ω) = The first three polynomials are: The zeros are given by: We now have: ω 2ω 2 ω = cos( 2k + π), k {0,, 2,..., n } 2n T n (jω) 2 = + ɛ 2 C 2 n(ω) Note that T n (jω) 2 = for ω = independent of n. +ɛ 2 And T n (s)t n ( s) = + ɛ 2 Cn( 2 s) j The poles in the left half plane of T n (s) are given by: where s k = sinh(u) sin( 2k + 2n + π) + j cosh(u) cos(2k π), k {0,, 2,..., n } 2n u = n sinh ( ɛ ) T (s) is given by: where T (s) = G 0 = k G 0 k (s s k ) s k, nodd 2.3.2 Filter order G 0 = s + ɛ 2 k, neven If the damping in the passband is a p and the damping in the stop band a s then: a p = 0 log( + ɛ 2 ) a s = 0 log( + ɛ 2 C 2 n( f s f p )) k ɛ 2 = 0 ap 0 7
k and k are given in the previous section. Using the Chebyshev approximation: we have: ɛ 2 C 2 n( f s f p ) = 0 as 0 Cn( 2 f s ) = 0 as 0 f p ɛ 2 C n ( k ) = k C n (ω) (ω + ω 2 ) n 2 n = log(2 k ) log(k + k 2 ) n is rounded up and ɛ is given by the formula for a p. Since ω p = for the poles given above, the poles must be scaled by 2πf p in order to give the desired f p and f s. 2.4 Inverse Chebyshev filters 2.4. Filter zeros and poles The Chebyshev filter has ripple in the passband and decays monotonically in the stop band. If a ripple free passband is required and ripple in the stop band is acceptable, then the following polynomial can be used: F n (ω) = C n ( ω ) We then have: Note that T n (jω) 2 = And T n (jω) 2 = ɛ2 C 2 n( ω ) + ɛ 2 C 2 n( ω ) ɛ2 for ω = independent of n. +ɛ 2 T n (s)t n ( s) = ɛ2 C 2 n( j s ) + ɛ 2 C 2 n( j s ) The zeros of T n (s) are all on the imaginary axis and determined by the reciprocals of the zeros of the Chebyshev polynomial: s k = j cos( 2k+ 2n π), k {0,, 2,..., n } In case the order is odd, the zero of the Chebyshev polynomial at ω = 0 is discarded and the number of zeros is n. 8
The poles in the left half plane are the reciprocal of the poles of the Chebyshev filter given in the previous section: where s k = sinh(u) sin( 2k+ 2n 2k+ π) + j cosh(u) cos( 2n u = n sinh ( ɛ ) π), k {0,, 2,..., n } T (s) is given by: where k (s s zk ) T (s) = G 0 k (s s pk ) k s pk G 0 = k s zk 2.4.2 Filter order If the damping in the stop band is a s then: and n = ɛ 2 a s = 0 log( + ɛ ) 2 log(2 k ) log(k + k 2 ) n is rounded up and ɛ is given by the formula for a s. Since ω s = for the poles and zeros given above, the poles and zeros must be scaled by 2πf s in order to give the desired f p and f s. 9
Chapter 3 Low pass to High pass transform The following mapping: ω LP = ω HP can be used to transform a HP filter specification into a LP filter specification. Thereafter the LP filter poles and zeros can be transformed to a HP filter using: s HP = s LP If the LP filter has n poles and m zeros, then high pass filter transfer function must be multiplied by s n m. 0
Chapter 4 Low pass to Band pass transform The following mapping: ω LP = ω BP ω c ω c ω BP, ω 2 c = ω l ω u where ω l and ω u are the two band edges of the passband or the stop band, can be used to transform a BP filter specification into a LP filter specification. Thereafter the LP filter poles and zeros can be transformed to a BP filter using: s BP = ω c 2 ( s LP ± s 2 LP + 4) If the LP filter has n poles and m zeros, then high pass filter transfer function must be multiplied by s n m.
Chapter 5 The Bilinear transform As mentioned above the Bilinear transform can be used for designing a digital filter knowing a corresponding analog filter. But since the frequency axis is distorted the specification of the digital filter must first be converted to the analog filter specification using: F = f s π tan(π f f s ) where F is the frequency used when designing the analog filter,f is the desired frequency and f s is the sampling frequency. Example A bandpass filter is to be realized as a digital filter where: The specification of the analog BP filter is then: f s = 48000Hz f pl = 0000Hz f pu = 4000Hz f su = 6000Hz fc 2 = f p f p2 f sl = f 2 c f su = 8750Hz F pl = 724Hz F pu = 992Hz F su = 26464Hz F sl = 985Hz F pc = 5279Hz 2
F sc = 646Hz It is seen that the center frequency is different for the passband and stop band. This is not allowed using the mapping between BP and LP filter described above. Assuming the center frequency is to be determined by the passband, then using F su = 26464Hz will give a F sl outside the specified band and it is therefore necessary to calculate F su from F sl, leading to F su = 23698Hz. The band pass specification is now transformed to a low pass filter specification and the procedure described above is used to find the poles and zeros of the analog bandpass filter. The final step is to transform poles and zeros to digital form using: z = + s 2f s s 2f s Note that f pl f pu f sl f su for the final digital filter and that f su is lower than required. 3
Program example A programming example written in C# can be found here: https://github.com/grubleren/filterdesign 4