Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction to Digital Filters Filter: A filter is essentially a system or network that selectively changes the wave shape, amplitude/frequency and/or.

Similar presentations


Presentation on theme: "1 Introduction to Digital Filters Filter: A filter is essentially a system or network that selectively changes the wave shape, amplitude/frequency and/or."— Presentation transcript:

1

2 1 Introduction to Digital Filters Filter: A filter is essentially a system or network that selectively changes the wave shape, amplitude/frequency and/or phase/frequency characteristics of a system in a desired manner. Filter: A filter is essentially a system or network that selectively changes the wave shape, amplitude/frequency and/or phase/frequency characteristics of a system in a desired manner. Common filtering objectives: Common filtering objectives:  to improve the quality of a signal  to extract information from a signal  to separate two or more signals previously combined.

3 2 Digital Filter: A digital filter is a mathematical algorithm implemented in hardware and/or software that operates on a digital input signal to produce a digital output signal for the purpose of achieving a filtering objective. A simplified block diagram of a real time digital filter is shown below: x(t) Input filter ADC with sample & hold Digital processor DAC output filter

4 3 Advantages of Digital Filters: Digital filters can have characteristics which are not possible with analogue filters, such as a truly linear response. Digital filters can have characteristics which are not possible with analogue filters, such as a truly linear response. Unlike analog filters, the performance of digital filters does not vary with environmental changes. This eliminates the need to calibrate periodically. Unlike analog filters, the performance of digital filters does not vary with environmental changes. This eliminates the need to calibrate periodically. The frequency response of a digital filter can be automatically adjusted if it is implemented using a programmable processor, which is why they are widely used in adaptive filters. The frequency response of a digital filter can be automatically adjusted if it is implemented using a programmable processor, which is why they are widely used in adaptive filters. Several input signals or channels can be filtered by one digital filter without the need to replicate the hardware. Several input signals or channels can be filtered by one digital filter without the need to replicate the hardware. Both filtered and unfiltered data can be saved for further use. Both filtered and unfiltered data can be saved for further use.

5 4 Advantages of Digital Filters: Advantages can be readily taken of the tremendous advancements in VLSI technology to fabricate digital filters and to make them small in size, to consume low power, and to keep the cost down. Advantages can be readily taken of the tremendous advancements in VLSI technology to fabricate digital filters and to make them small in size, to consume low power, and to keep the cost down. In practice the precision achievable with analog filters is restricted. With digital filters precision is limited only by the wordlength used. In practice the precision achievable with analog filters is restricted. With digital filters precision is limited only by the wordlength used. The performance of digital filters is repeatable from unit to unit. The performance of digital filters is repeatable from unit to unit. Digital filters can be used at very low frequencies. Also, digital filters can be made to work over a wide range of frequencies by a mere change to the sampling frequency. Digital filters can be used at very low frequencies. Also, digital filters can be made to work over a wide range of frequencies by a mere change to the sampling frequency.

6 5 Disadvantages of Digital Filters Speed Limitation: The maximum bandwidth of signals that digital filter can handle, in real time, is much lower than for analog filters. In real time situations, the analog- digital-analog conversion processes introduce a speed constraint on the digital filter performance. The conversion time of the ADC and the settling time of the DAC limit the highest frequency that can be processed. Further, the speed of operation of a digital filter depends on the speed of the digital processor used and on number of arithmatic operations that must be performed for the filtering algorithm, which increases as the filter response is made tighter. Speed Limitation: The maximum bandwidth of signals that digital filter can handle, in real time, is much lower than for analog filters. In real time situations, the analog- digital-analog conversion processes introduce a speed constraint on the digital filter performance. The conversion time of the ADC and the settling time of the DAC limit the highest frequency that can be processed. Further, the speed of operation of a digital filter depends on the speed of the digital processor used and on number of arithmatic operations that must be performed for the filtering algorithm, which increases as the filter response is made tighter. Finite Wordlength Effects: Digital filters are subject to ADC noise resulting from quantizing a continuous signal, and to roundoff noise incurred during computation. With higher order recursive filters, the accumulation of roundoff noise could lead to instability. Finite Wordlength Effects: Digital filters are subject to ADC noise resulting from quantizing a continuous signal, and to roundoff noise incurred during computation. With higher order recursive filters, the accumulation of roundoff noise could lead to instability.

7 6 Disadvantages of Digital Filters Long Design and Development Times: The design and development times for digital filters, especially hardware development, can be much longer than for analog filters. However, once developed the hardware and/or software can be used for other filtering or DSP tasks with little or no modifications. Long Design and Development Times: The design and development times for digital filters, especially hardware development, can be much longer than for analog filters. However, once developed the hardware and/or software can be used for other filtering or DSP tasks with little or no modifications.

8 7 Filter Design Steps: Specification of the filter requirements. Specification of the filter requirements. Calculation of suitable filter coefficients. Calculation of suitable filter coefficients. Representation of the filter by a suitable structure (realization). Representation of the filter by a suitable structure (realization). Analysis of the effects of finite wordlength on filter performance. Analysis of the effects of finite wordlength on filter performance. Implementation of filter in software and/or hardware. Implementation of filter in software and/or hardware.

9 8 Types of digital filters: FIR and IIR filters FIR filters FIR filters IIR filters IIR filters

10 9 Finite Impulse Response (FIR) Filters Definition: These filters are represented by the following equation: The corresponding transfer function of the filter is given by where h[i] are impulse response coefficients, y[n] is output and x[n] is input of the filter. Alternative Names: Non-recursive filters, All-zero filters. Reason for the name Finite Impulse Response filter: the unit impulse response consists of a finite number (M+1) of terms, i.e. its duration in real time is finite. (M+1) is called the filter Length. (1) (2)

11 10 Designing Frequency-Selective FIR Filters Ideally we wish to realize a “brick-wall” magnitude response and a linear phase response. In practice we can realize a reasonable approximation to this magnitude response, together with a linear phase response. The design problem may be stated thus: Given an ideal/desired frequency response F d (jw), decide on a filter length and decide on a filter coefficients which will give an actual response F(jw) approximating to F d (jw) to within a given specification in magnitude and phase.

12 11 Digital Filters: A digital filter can be represented by the following equation: y n = b 0 x n + b 1 x n-1 + …. + b M x n-M + a 1 y n-1 + … + a P y n-P (4) This equation This equation  Mathematically describes a digital filter  Can be directly implemented in a computer, real time processor, or special purpose hardware to do the actual filtering. Design Issues: Determination of the filter coefficients. Software / hardware implementation of the filter.

13 12 Finite Impulse Response (FIR) Filters Definition: These filters have all the a coefficients zero in equation (4): y n = b 0 x n + b 1 x n-1 + …… + b M x n-M Alternative Names: Non-recursive filters, All- zero filters. Reason for the name Finite Impulse Response filter: the unit impulse response consists of a finite number (M+1) of terms, i.e. its duration in real time is finite. (M+1) is called the filter Length.

14 13 Designing Frequency-Selective FIR Filters Ideally we wish to realize a “brick-wall” magnitude response and a linear phase response. In practice we can realize a reasonable approximation to this magnitude response, together with a linear phase response. The design problem may be stated thus: Given an ideal/desired frequency response F d (jw), decide on a filter length and decide on a filter coefficients which will give an actual response F(jw) approximating to F d (jw) to within a given specification in magnitude and phase.

15 14 Design of FIR filter using Fourier Methods Transform Pair: (5) (6) To illustrate the method, we try to obtain a design for the ideal low-pass, zero delay filter H d (w) = 1  0 0, -w c < w < w c (7) = 0, |w| > w c where w c is the cutoff frequency. On substituting this into (6) we get (8)

16 15 which evaluates to (9) n = -  … . A filter with the impulse response (8) would realize the ideal specification (7) exactly, However, (a)This impulse response is infinite in length i.e. the filter would require an infinite number of coefficients. Solution: Truncate to a finite number of coefficients. The response will now be an approximation to the ideal. (b) This impulse response is double-sided as shown in the fig on the next slide.If we truncate the series symmetrically, it will have terms for negative k and the filter will be non-causal i.e. will require foreknowledge. It will not be realizable in real time.

17 16 -20-15-10-505101520

18 17 Solution: Shift the impulse response by N sampling intervals in time, where N = M/2. On denoting the shifted response by h[n], this gives h[n] = h d (n-N) (10) and now we have a standard finite length causal filter. This will have the effect of delaying the response by N sampling intervals. Instead of the zero delay filter of (7), we will have a constant delay filter with delay time . This is equivalent to a linear phase filter, the phase being given by  = 2  f  radians. On taking account of the truncation and the shift, (8) becomes (11)

19 18 Shifting of impulse response 0510152025303540

20 19 The effect of truncation: The effect is to introduce Gibbs Oscillations into the frequency response. Reducing the effects of truncation: Increasing the filter length has relatively little effect. A better method is to window the impulse response: each term h[n] is multiplied by the corresponding term w[n] in a window: h w [n] = h[n]w[n] (12) h w [n] = h[n]w[n] (12) Many windows have been proposed. Some of these are described below:

21 20 Rectangular Window: The rectangular window is defined as The filter coefficients b[n] = h[n] can now be computed as Example 1: Design a low-pass FIR filter with cut-off frequency at 200 Hz relative to a Nyquist frequency of 1KHz. Use the rectangular window to truncate the impulse response. The length of the filter is 21. (13) (14)

22 21 Solution: The normalized cut-off frequency is w c = 2  f c /f s = 2  (200/(1000) = 0.4  h[0] = 0.0000 = h[20] h[1] = -0.03364 = h[19] h[2] = -0.02339 = h[18] h[3] = 0.02673 = h[17] h[4] = 0.05046 = h[16] h[5] = 0.00000 = h[15] h[6] =-0.07568 = h[14] h[7] =-0.06237 = h[13] h[8] =0.09355 = h[12] h[9] = 0.30273 = h[11] h[10]= 0.40000 0100200300400500 0 0.2 0.4 0.6 0.8 1 1.2 1.4 Frequency (Hz) Amplitude gain where M = 20

23 22 Hamming Window The Hamming window is defined as M-1 0 1 The filter coefficients can be found as follows: h[n] = h d [n – N]  w[n] (15) (16)

24 23 Example 2: Repeat example 1 for a Hamming window. The filter coefficients can be computed by using equation (16) as: h[0] = 0.00000 = h[20] The magnitude response h[0] = 0.00000 = h[20] The magnitude response h[1] = -0.00345 = h[19] of the filter and its h[1] = -0.00345 = h[19] of the filter and its h[2] = -0.00393 = h[18] comparison with h[2] = -0.00393 = h[18] comparison with h[3] = 0.00721 = h[17] the magnitude response h[3] = 0.00721 = h[17] the magnitude response h[4] = 0.02007 = h[16] of the filter with h[4] = 0.02007 = h[16] of the filter with h[5] = 0.00000 = h[15] rectangular window is h[5] = 0.00000 = h[15] rectangular window is h[6] = -0.05163 = h[14] given in the figure on h[6] = -0.05163 = h[14] given in the figure on h[7] = -0.05054 = h[13] the next slide. h[7] = -0.05054 = h[13] the next slide. h[8] = 0.08533 = h[12] h[8] = 0.08533 = h[12] h[9] = 0.29592 = h[11] h[9] = 0.29592 = h[11] h[10]= 0.40000 h[10]= 0.40000

25 24 0100200300400500 0 0.2 0.4 0.6 0.8 1 1.2 1.4 Frequency (Hz) Amplitude gain Hamming window Rectangular window Hamming window is better than rectangular window.

26 25 Hann Window The Hann Window is defined as The Hann Window is defined as 0M-1 0 1 Yellow = Hamming Red = Hann window (17)

27 26 Example 3: Repeat Example 1 with the Hann Window Solution: The coefficients of the filter in this case can be computed as follows: (18) The coefficients are: h[0] = 0.00000 = h[20] h[1] = -0.00082 = h[19] h[2] = -0.00223 = h[18] h[3] = 0.00551 = h[17] h[4] = 0.01743 = h[16] h[5] = 0.0000 = h[15] h[6] = -0.04953 = h[14] h[7] = -0.04951 = h[13] h[8] = 0.08462 = h[12] h[9] = 0.29532 = h[11] h[10] = 0.40000

28 27 0100200300400500 0 0.2 0.4 0.6 0.8 1.2 1.4 Frequency (Hz) Amplitude gain 1 Hamming and Hann window Rectangular window

29 28 Kaiser Window The windows studied so far are very simple, but do not provide good control over the filter design specifications. Kaiser window is a highly suitable for achieving the required pass-band and/or stop-band ripple, along with the cut-off requirements. Consider the following figure. 1-  1 Passband ripple wpwp wsws 22 1+  1 w c Ideal response

30 29 The passband/stopband frequencies {w p, w s } are related to the ideal cutoff frequency w c and transition width  w by w c = ½ (w p + w s ),  w = w s – w p (19) w c = ½ (w p + w s ),  w = w s – w p (19) The passband and stopband overshoots {A p, A s } are expressed in dB as, (20) Equation (20) can be inverted to give: (21) Although  1 and  2 can be specified independently of each Other, it is a property of all windows designs that the final designed filter will have equal pass-band and stop-band ripples.

31 30 Therefore, we must design the filter on the basis of the smaller of the two ripples, that is,  = min(  1,  2 ) (22) = min(  1,  2 ) (22) The Kaiser window is mathematically represented as The Kaiser window is mathematically represented as (23) where I 0 (x) is the modified Bessel function of the first kind And 0 th order. The parameter  can be computed as follows: (24)

32 31 The filter length can be obtained as (25) (26) where f s is the sampling frequency in Hz,  f is the transition Width in Hz and The shape of the Kaiser window for M = 51 &  = 7 is given below: 1020304050 0 1

33 32 Example 4: Using Kaiser Window, design a low- pass digital filter with the following specifications: Sampling frequency = 20 KHz pass-band frequency = 4 KHz Stop-band frequency = 5 KHz A p = 0.1 dB, A s = 80 dB Solution: and Therefore,  = min(  1,  2 ), which in db is A = -20log 10  = A s = 80.  = 0.1102(A-8.7) = 7.857, D = (A-7.95)/14.36 = 5.017. The transition width =  f = f s – f p = 5 – 4 = 1KHz f c = ½ (f s + f p ) = 4.5 KHz, w c = (2  f c /f s ) = 0.45 . M– 1 = Df s /  f  M = 103  (M-1)/2 = 102/2 = 51

34 33 The windowed impulse response will be (27)

35 34 Generalized FIR Digital Filter Design: The windows described above can easily be used to design a High-pass and other frequency selective filters FIR filter. Following are the main steps: Define an ideal magnitude response function. Define an ideal magnitude response function. Obtain the ideal (infinite) impulse response sequence h d [n]by evaluating the Fourier inverse transform of the magnitude response of step1. Obtain the ideal (infinite) impulse response sequence h d [n]by evaluating the Fourier inverse transform of the magnitude response of step1. Use appropriate delay factor and window to compute the coefficients of the filter. Use appropriate delay factor and window to compute the coefficients of the filter.

36 35 High Pass Filter: The magnitude response of a normalized ideal high-pass filter is given by (28) By evaluating the inverse Fourier Transform, we obtain the ideal impulse response sequence (29) Tutorial Q1: Derive equation (29) from equation (28). Example 5: Design a high-pass filter with a cutoff frequency of 2.5 KHz and a sample interval of 0.0001 s; The length of the filter is 21 and the rectangular window is used to truncate the ideal impulse response function.

37 36 Solution: The normalized cutoff frequency is w c = 2500  0.0001 = 0.25 w c = 2500  0.0001 = 0.25 The filter coefficients can be found from equation (29) with M = 20. These coefficients are given below: h[0] = -0.00000 = h[20] H[1] = -0.03537 = h[19] The magnitude response is as shown below: H[2] = -0.00000 = h[18] h[3] = 0.04547 = h[17] h[4] = -0.00000 = h[16] h[4] = -0.00000 = h[16] H[5] = -0.06366 = h[15] H[6] = -0.00000 = h[14] H[7] = 0.10610 = h[13] H[8] = -0.00000 = h[12] H[9] = -0.31831 = h[11] H[10]= 0.500000 012345 0 1 Frequency (kHz) Amplitude

38 37 Band-Pass Filter: The magnitude of an ideal constant delay band-pass filter is given by (30) where w L and w H are the low and high edges of the pass-band and M/2 is the delay. When H d (w) of (30) is inverse transformed, we find that the Band-pass impulse response is given by (31) Tutorial Q2: Derive equation (31) from (30)

39 38 Example 6:Design a Band-Pass Digital FIR filter of length 21. The band edges are specified to be at 1.5 and 3.5 kHz and the sampling interval is 0.0001s. Use the Hamming window. Solution: The normalized cutoff frequencies are.15 and 0.35. The filter coefficients are obtained by multiplying (31) and (15) and are given below: h[0] = 0.00000 = h[20] h[8] = -0.27614 = h[12] h[0] = 0.00000 = h[20] h[8] = -0.27614 = h[12] h[1] = -0.00000 = h[19] h[9] = 0.000000 = h[11] h[1] = -0.00000 = h[19] h[9] = 0.000000 = h[11] h[2] = -0.01270 = h[18] h[10] = 0.40000 h[3] = 0.00000 = h[17] h[4] = 0.02481 = h[16] h[4] = 0.02481 = h[16] h[5] = 0.00000 =h[15] h[6] = 0.06381 =h[14] H[7] = -0.00000 = h[13] The magnitude response of the Designed filter is shown overleaf

40 39 012345 0 0.2 0.4 0.6 0.8 1 1.2 1.4 Frequency (kHz) Amplitude

41 40 Band-Stop Filter: The ideal frequency response of a Band-Stop filter is given by where w L and w H now specify the low and high edges of the stop-band. Taking the inverse Fourier transform of (32) yileds (32) (33) Example 7: Design a band-stop filter with edges frequencies At 1.5 and 3.5 kHz relative to a sample interval of 0.0001. Use Hann window. Length of the filter is 21. Solution: the normalized frequencies are 0.15 and.35. The Filter coefficients can be obtained by multiplying (33) and (17) and are given by

42 41 0 0.00000 7 0.00000 14 -0.06123 1 0.00000 8 0.27382 15 0.00000 1 0.00000 8 0.27382 15 0.00000 2 0.00723 9 0.00000 16 -0.02155 2 0.00723 9 0.00000 16 -0.02155 3 0.00000 10 0.60000 17 0.00000 3 0.00000 10 0.60000 17 0.00000 4 -0.02155 11 0.00000 18 0.00723 4 -0.02155 11 0.00000 18 0.00723 5 0.00000 12 0.27382 19 0.00000 5 0.00000 12 0.27382 19 0.00000 6 -0.06123 13 0.00000 20 0.00000 6 -0.06123 13 0.00000 20 0.00000 The magnitude response is as under: 012345 0 1.4 Amplitude


Download ppt "1 Introduction to Digital Filters Filter: A filter is essentially a system or network that selectively changes the wave shape, amplitude/frequency and/or."

Similar presentations


Ads by Google