Sei sulla pagina 1di 58

Filtering

Filtering is one of the most widely used complex signal processing operations The system implementing this operation is called a filter A filter passes certain frequency components without any distortion and blocks other frequency components
1

Filtering
The range of frequencies that is allowed to pass through the filter is called the passband, and the range of frequencies that is blocked by the filter is called the stopband In most cases, the filtering operation for analog signals is linear
2

Filtering
The filtering operation of a linear analog filter is described by the convolution integral y (t ) = h(t ) x()d

where x(t) is the input signal, y(t) is the output of the filter, and h(t) is the impulse response of the filter
3

Filtering
A lowpass filter passes all low-frequency components below a certain specified frequency f c , called the cutoff frequency, and blocks all high-frequency components above f c A highpass filter passes all high-frequency components a certain cutoff frequency f c and blocks all low-frequency components below
4

Filtering
A bandpass filter passes all frequency components between 2 cutoff frequencies, f c1 and fc 2, where f c1 < f c 2 , and blocks all frequency components below the frequency f c1 and above the frequency fc 2 A bandstop filter blocks all frequency components between 2 cutoff frequencies, f c1 and fc 2, where f c1 < f c 2 , and passes all frequency components below the frequency f c1 and above the frequency fc 2
5

Filtering
Figures below illustrate the lowpass filtering of an input signal composed of 3 sinusoidal components of frequencies 50 Hz, 110 Hz, and 210 Hz
I p ts n l n u ig a 4 2 A plitude m 0 2 4 0 A plitude m 1 0 .5 0 - .5 0 1 0 L wasf ro tp t o p s ilte u u

2 0

4 0 6 0 T e me im, s c

8 0

10 0

2 0

4 0 6 0 T e me im, s c

8 0

10 0

Filtering
Figures below illustrate highpass and bandpass filtering of the same input signal
Highpass filter output 1 0.5 Amplitude 0 -0.5 -1 Amplitude 1 0.5 0 -0.5 -1 0 Bandpass filter output

20

40 60 Time, msec

80

100

20

40 60 Time, msec

80

100

Filtering
There are various other types of filters A filter blocking a single frequency component is called a notch filter A multiband filter has more than one passband and more than one stopband A comb filter blocks frequencies that are integral multiples of a low frequency
8

Filtering
In many applications the desired signal occupies a low-frequency band from dc to some frequency fL Hz, and gets corrupted by a high-frequency noise with frequency components above fH Hz with fH > fL In such cases, the desired signal can be recovered from the noise-corrupted signal by passing the latter through a lowpass filter with a cutoff frequency f c where f L < f c < f H
9

Digital Filter Design


Objective - Determination of a realizable transfer function G(z) approximating a given frequency response specification is an important step in the development of a digital filter If an IIR filter is desired, G(z) should be a stable real rational function Digital filter design is the process of deriving the transfer function G(z)
10

Digital Filter Specifications


Usually, either the magnitude and/or the phase (delay) response is specified for the design of digital filter for most applications In some situations, the unit sample response or the step response may be specified In most practical applications, the problem of interest is the development of a realizable approximation to a given magnitude response specification
11

Digital Filter Specifications


We discuss in this course only the magnitude approximation problem There are four basic types of ideal filters with magnitude responses as shown below
H LP (e j ) 1

HHP (e j ) 1

c 0

HBP (e j ) 1

HBS (e j ) 1

12

c2 c1

c1 c2

c2 c1

c1 c2

Impulse Responses of Ideal Filters


Ideal lowpass filter H LP (e j ) 1

sin c n hLP [n] = n , n

c 0

Ideal highpass filter HHP (e j ) 1

13

1 c , n=0 hHP [n] = sin( c n) n , n 0


Copyright 2005, S. K. Mitra

Impulse Responses of Ideal Filters


Ideal bandpass filter HBP (e j ) 1

c2 c1

c1 c2

14

sin( c 2 n) sin( c1n) , n 0 n n hBP [n] = c 2 c1 , n=0


Copyright 2005, S. K. Mitra

Impulse Responses of Ideal Filters


Ideal bandstop filter HBS (e j ) 1

c2 c1

c1 c2

1 (c 2 c1 ) , n=0 hBS [n] = sin( c1n) sin( c 2 n) n n , n 0


15
Copyright 2005, S. K. Mitra

Impulse Responses of Ideal Filters


Ideal multiband filter H ML (e j ) A5 A1 A4 A2 A3 0 1 2 3 4

H ML (e j ) = Ak , k 1 k , k = 1, 2, , L

sin( L n) hML [n] = ( A A+1 ) n


=1
16
Copyright 2005, S. K. Mitra

Impulse Responses of Ideal Filters


Ideal discrete-time Hilbert transformer j, < < 0 H HT (e ) = j , 0 < <
j

for n even 0, hHT [n] = 2/ n, for n odd


17
Copyright 2005, S. K. Mitra

Impulse Responses of Ideal Filters


Ideal discrete-time differentiator H DIF (e ) = j,
j

n=0 0, hDIF [n] = cos n n , n0


18
Copyright 2005, S. K. Mitra

Digital Filter Specifications


As the impulse response corresponding to each of these ideal filters is noncausal and of infinite length, these filters are not realizable In practice, the magnitude response specifications of a digital filter in the passband and in the stopband are given with some acceptable tolerances In addition, a transition band is specified between the passband and stopband

19

Digital Filter Specifications

For example, the magnitude response G (e ) of a digital lowpass filter may be given as indicated below

20

Digital Filter Specifications


As indicated in the figure, in the passband, defined by 0 p , we require that j G (e ) 1 with an error p , i.e., 1 p G (e ) 1 + p ,
j

In the stopband, defined bys , we j require that G (e ) 0 with an error s , i.e., j G ( e ) s , s


21

Digital Filter Specifications


p - passband edge frequency s - stopband edge frequency p - peak ripple value in the passband s - peak ripple value in the stopband Since G (e j ) is a periodic function of , j and G (e ) of a real-coefficient digital filter is an even function of As a result, filter specifications are given only for the frequency range 0

22

Digital Filter Specifications


Specifications are often given in terms of j loss function A () = 20 log10 G (e ) in dB Peak passband ripple p = 20 log10 (1 p ) dB Minimum stopband attenuation s = 20 log10 ( s ) dB
23

Digital Filter Specifications


Magnitude specifications may alternately be given in a normalized form as indicated below

24

Digital Filter Specifications


Here, the maximum value of the magnitude in the passband is assumed to be unity 1 / 1 + 2 - Maximum passband deviation, given by the minimum value of the magnitude in the passband 1 - Maximum stopband magnitude A
25

Digital Filter Specifications


For the normalized specification, maximum value of the gain function or the minimum value of the loss function is 0 dB Maximum passband attenuation 2 max = 20 log10 1 + dB For p << 1, it can be shown that max 20 log10 (1 2 p ) dB

26

Digital Filter Specifications


In practice, passband edge frequency Fp and stopband edge frequency Fs are specified in Hz For digital filter design, normalized bandedge frequencies need to be computed from specifications in Hz using p 2 Fp p = = = 2 FpT FT FT s 2 Fs s = = = 2 Fs T FT FT

27

Digital Filter Specifications


Example - Let Fp = 7 kHz, Fs = 3 kHz, and FT = 25 kHz Then 2(7 103 ) p = = 0.56 3 25 10 2(3 103 ) s = = 0.24 3 25 10
28

Selection of Filter Type


The transfer function H(z) meeting the frequency response specifications should be a causal transfer function For IIR digital filter design, the IIR transfer 1 function is a real rational function of z : H ( z) = p0 + p1z
1 1

+ p2 z + d2 z

2 2

+ + pM z ++ dN z

d 0 + d1z

, M N

29

H(z) must be a stable transfer function and must be of lowest order N for reduced computational complexity

For FIR digital filter design, the FIR transfer function is a polynomial in z 1 with real coefficients: H ( z ) = h[n] z
n =0 N n

Selection of Filter Type

30

For reduced computational complexity, degree N of H(z) must be as small as possible If a linear phase is desired, the filter coefficients must satisfy the constraint: h[n] = h[ N n]

Selection of Filter Type


Advantages in using an FIR filter (1) Can be designed with exact linear phase, (2) Filter structure always stable with quantized coefficients Disadvantages in using an FIR filter - Order of an FIR filter, in most cases, is considerably higher than the order of an equivalent IIR filter meeting the same specifications, and FIR filter has thus higher computational complexity

31

Digital Filter Design: Basic Approaches


Most common approach to IIR filter design (1) Convert the digital filter specifications into an analog prototype lowpass filter specifications (2) Determine the analog lowpass filter transfer function H a (s ) (3) Transform H a (s ) into the desired digital transfer function G (z )
32

Digital Filter Design: Basic Approaches


This approach has been widely used for the following reasons: (1) Analog approximation techniques are highly advanced (2) They usually yield closed-form solutions (3) Extensive tables are available for analog filter design (4) Many applications require digital simulation of analog systems

33

Digital Filter Design: Basic Approaches


FIR filter design is based on a direct approximation of the specified magnitude response, with the often added requirement that the phase be linear The design of an FIR filter of order M may be accomplished by finding either the length-(N+1) impulse response samples { h[n]} or the (N+1) samples of its frequency j response H (e )
34

Digital Filter Design: Basic Approaches


Three commonly used approaches to FIR filter design (1) Windowed Fourier series approach (2) Frequency sampling approach (3) Computer-based optimization methods

35

Gibbs Phenomenon
Gibbs phenomenon - Oscillatory behavior in the magnitude responses of causal FIR filters obtained by truncating the impulse response coefficients of ideal filters
1.5 N = 20 N = 60 Magnitude 1

0.5

36

0.2

0.4 /

0.6

0.8

1
Copyright 2005, S. K. Mitra

Gibbs Phenomenon
As can be seen, as the length of the lowpass filter is increased, the number of ripples in both passband and stopband increases, with a corresponding decrease in the ripple widths Height of the largest ripples remain the same independent of length Similar oscillatory behavior observed in the magnitude responses of the truncated versions of other types of ideal filters
Copyright 2005, S. K. Mitra

37

Gibbs Phenomenon
Gibbs phenomenon can be explained by treating the truncation operation as an windowing operation: ht [n] = hd [n] w[n] In the frequency domain H t ( e j ) =
1 2

H d (e j ) (e j () ) d

38

H t (e j ) and (e j ) are the DTFTs where of ht [n] and w[n] , respectively


Copyright 2005, S. K. Mitra

Gibbs Phenomenon
Thus H t (e j ) is obtained by a periodic H d (e j ) with continuous convolution of ( e j )

39
Copyright 2005, S. K. Mitra

Gibbs Phenomenon
If (e j ) is a very narrow pulse centered at = 0 (ideally a delta function) compared to H d (e j ), then H t (e j ) will variations in approximate H d (e j ) very closely Length M+1 of w[n] should be very large On the other hand, length M+1 of ht [n] should be as small as possible to reduce computational complexity
40
Copyright 2005, S. K. Mitra

Gibbs Phenomenon
A rectangular window is used to achieve simple truncation: 1, 0 n M wR [n] = 0, otherwise j Presence of oscillatory behavior in H t (e ) is basically due to: 1) hd [n] is infinitely long and not absolutely

41

summable, and hence filter is unstable 2) Rectangular window has an abrupt transition to zero
Copyright 2005, S. K. Mitra

Gibbs Phenomenon
Oscillatory behavior can be explained by j examining the DTFT R (e ) of wR [n] :
Rectangular window 30 20 Amplitude 10 0 -10 -1 M = 10 M=4

main lobe side lobe

-0.5

42

R (e ) has a main lobe centered at = 0 Other ripples are called sidelobes


Copyright 2005, S. K. Mitra

0 /

0.5

43

Main lobe of R (e j ) characterized by its width 4 /( M + 1) defined by first zero crossings on both sides of = 0 As M increases, width of main lobe decreases as desired Area under each lobe remains constant while width of each lobe decreases with an increase in M Ripples in H t (e j ) around the point of discontinuity occur more closely but with no decrease in amplitude as M increases
Copyright 2005, S. K. Mitra

Gibbs Phenomenon

Gibbs Phenomenon
Rectangular window has an abrupt transition to zero outside the range M / 2 n M / 2 , which H t ( e j ) results in Gibbs phenomenon in Gibbs phenomenon can be reduced either: (1) Using a window that tapers smoothly to zero at each end, or (2) Providing a smooth transition from passband to stopband in the magnitude specifications
44
Copyright 2005, S. K. Mitra

Using a tapered window causes the height of the sidelobes to diminish, with a corresponding increase in the main lobe width resulting in a wider transition at the discontinuity Hann: 2 n
w[n] = 0.5 + 0.5 cos( M ),

Fixed Window Functions

M /2 n M /2

Hamming:

w[n] = 0.54 + 0.46 cos( 2 n), M

M /2 n M /2

Blackman:
45

w[n] = 0.42 + 0.5 cos( 2 n) + 0.08 cos( 4 n) M M


Copyright 2005, S. K. Mitra

Fixed Window Functions


Plots of magnitudes of the DTFTs of these windows for M = 50 are shown below:
Rectangular window Rectangular window
Hanning window Hann window

0 -20
Gain, dB Gain, dB

0 -20 -40 -60 -80

Gain, dB Gain, dB

-40 -60 -80

-100 0

0.2

0.4

0.6

0.8

-100 0

0.2

0.4

0.6

0.8

/ Hamming window Hamming window


0 -20 Gain, dB Gain, dB -40 -60 -80 Gain, dB Gain, dB 0 -20 -40 -60 -80 0.2 0.4 / 0.6 0.8 1 -100 0 0.2

/ Blackman window Blackman window

46

-100 0

0.4

0.6

0.8

/ Copyright 2005, S. K. Mitra

Fixed Window Functions


Magnitude spectrum of each window characterized by a main lobe centered at = 0 followed by a series of sidelobes with decreasing amplitudes Parameters predicting the performance of a window in filter design are: Main lobe width Relative sidelobe level
47
Copyright 2005, S. K. Mitra

Fixed Window Functions


Main lobe width ML - given by the distance between zero crossings on both sides of main lobe Relative sidelobe level As - given by the difference in dB between amplitudes of largest sidelobe and main lobe

48
Copyright 2005, S. K. Mitra

Fixed Window Functions

Observe H t (e j (c + ) ) + H t (e j (c ) ) 1 j c H t (e ) 0.5 Thus, Passband and stopband ripples are the same
49
Copyright 2005, S. K. Mitra

Fixed Window Functions


Distance between the locations of the maximum passband deviation and minimum stopband value ML

Width of transition band = s p < ML


50
Copyright 2005, S. K. Mitra

Fixed Window Functions


To ensure a fast transition from passband to stopband, window should have a very small main lobe width To reduce the passband and stopband ripple , the area under the sidelobes should be very small Unfortunately, these two requirements are contradictory
51
Copyright 2005, S. K. Mitra

Fixed Window Functions


In the case of rectangular, Hann, Hamming, and Blackman windows, the value of ripple does not depend on filter length or cutoff frequency c , and is essentially constant In addition, c M where c is a constant for most practical purposes
52
Copyright 2005, S. K. Mitra

Fixed Window Functions


ML = 4 /( M + 1) Rectangular window As = 13.3 dB, s = 20.9 dB, = 0.92 /( M / 2) ML = 8 /( M + 1) Hann window As = 31.5 dB, s = 43.9 dB, = 3.11 /( M / 2) Hamming window - ML = 8 /( M + 1) As = 42.7 dB, s = 54.5 dB, = 3.32 /( M / 2) ML = 12 /( M + 1) Blackman window As = 58.1 dB, s = 75.3 dB, = 5.56 /( M / 2)
53
Copyright 2005, S. K. Mitra

Fixed Window Functions


Filter Design Steps (1) Set c = ( p + s ) / 2 (2) Choose window based on specified s c (3) Estimate M using M (4) Find coefficients by multiplying ideal impulse response with the window function (5) Shift by M/2 samples to make the filter causal
Copyright 2005, S. K. Mitra

54

FIR Filter Design Example


Lowpass filter of length 51 and c = / 2
Lowpass Filter Designed Using Hann window 0 Lowpass Filter Designed Using Hamming window 0 Gain, dB Gain, dB

-50

-50

-100 0 0.2 0.4 / 0.6 0.8 1

-100 0 0.2 0.4 0.6 0.8 1

/ Lowpass Filter Designed Using Blackman window 0

Gain, dB

-50

-100

55

0.2

0.4 /

0.6

0.8

Copyright 2005, S. K. Mitra

Adjustable Window Functions


Kaiser Window I 0 { 1 (2n / M ) 2 } w[n] = , I 0 ( ) M /2 n M /2

56

where is an adjustable parameter and I 0 (u ) is the modified zeroth-order Bessel function of the first kind: (u / 2) r 2 I 0 (u ) = 1 + [ ] r! r =1 Note I 0 (u ) > 0 for u > 0 20 (u / 2) r 2 ] In practice I 0 (u ) 1 + [ r! r =1
Copyright 2005, S. K. Mitra

Adjustable Window Functions


controls the minimum stopband attenuation of the windowed filter response is estimated using
0.1102( s 8.7 ), = 0.5842( s 21)0.4 + 0.07886( s 21), 0, Filter order is estimated using
s 8 M= 2.285( )

for s > 50 for 21 s 50 for s < 21

57

where is the normalized transition bandwidth


Copyright 2005, S. K. Mitra

FIR Filter Design Example


Specifications: p = 0.3 , s = 0.5 , s = 40 dB Thus c = ( p + s ) / 2 = 0.4 s / 20 s = 10 = 0.01 0 .4 = 0.5842(19) + 0.07886 19 = 3.3953
32 M= = 22.2886 2.285(0.2 )

Choose M = 24
58
Copyright 2005, S. K. Mitra

Potrebbero piacerti anche