CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 7.3. Window Method We have seen that in the design of FIR filters, Gibbs oscillations are produced in the passband and stopband, which are not desirable features of the FIR filter. To solve this problem, window method (Fourier transform design with window method) is developed. The Gibbs oscillations mainly result from the abrupt truncation of the infinite-length coefficient sequence of impulse response of the FIR filter. A window function is a symmetrical function which can gradually weight the designed FIR coefficients down to zeros at both ends of for the range βπ΄ β€ π β€ π΄. Applying the window sequence to the filter coefficients gives ππ (π) = π(π) β π(π) where, π(π) designates the window function. Commonly used window functions in FIR filters are: 1. Rectangular Window: (7.15) ππππ (π) = π, βπ΄β€πβ€π΄ 2. Triangular (Bartlett) Window: (7.16) ππππ (π) = π β |π| , π΄ βπ΄β€πβ€π΄ 3. Hanning Window: (7.16) ππ ), π΄ ππππ (π) = π. π + π. π ππ¨π¬ ( βπ΄β€πβ€π΄ 4. Hamming Window: (7.16) ππ ), π΄ ππππ (π) = π. ππ + π. ππ ππ¨π¬ ( βπ΄β€πβ€π΄ 5. Blackman Window: (7.16) ππ πππ ) + π. ππ ππ¨π¬ ( ), π΄ π΄ ππππππ (π) = π. ππ + π. π ππ¨π¬ ( βπ΄β€πβ€π΄ Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 Example 7.5 (a) Calculate the filter coefficients for a 3-tap FIR lowpass filter with a cutoff frequency of 800 Hz and a sampling rate of 8000 Hz using the Hamming window function. (b) Determine the transfer function and difference equation of the designed FIR system. (c) Compute and plot the frequency response. Solution Part (a): We first determine the normalized cutoff frequency πππ ππ = ππ ππ π»π = ππ × ππππ = π. ππ radians In this case ππ΄ + π = π, therefore, using table 7.1 ππ , π=π π π(π) = { sin(ππ π) βπ΄ β€ π β€ π΄ π π Therefore, π(π) = ππ π. ππ = = π. π π π π(π) = sin(ππ ) sin(π. ππ ) = = π. ππππ π π π(βπ) = π(π) = π. ππππ (using symmetry) The windowed impulse response is calculated as ππ (π) = π(π) ππππ (π) = π. π × π. π = π. π ππ (π) = π(π) ππππ (π) = π. ππππ × π. ππ = π. πππππ ππ (βπ) = π(βπ) ππππ (βπ) = π. ππππ × π. ππ = π. πππππ Delaying π(π) by π΄ = π samples, we get ππ = ππ (βπ) = π. πππππ, ππ = ππ (π) = π. π, and ππ = ππ (π) = π. πππππ. Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 Part (b): Therefore, the transfer function in this case is π―(π) = ππ + ππ πβπ + ππ πβπ = π. πππππ + π. ππβπ + π. ππππππβπ The difference equation is π(π) = π. ππππππ(π) + π. ππ(π β π) + π. ππππππ(π β π) Part (c): The frequency response of the filter is π―(πππ ) = π. πππππ + π. ππβππ + π. ππππππβπππ It can be written as π―(πππ ) = πβππ (π. ππππππππ + π. π + π. ππππππβπππ ) = πβππ (π. π + π. πππππ(πππ + πβπππ )) = πβππ (π. π + π. πππππ × πcos(π)) = πβππ (π. π + π. πππππ cos(π)) Thus, the magnitude frequency response is |π―(πππ )| = π. π + π. πππππ cos(π) And the phase response is β π―(πππ ) = { βπ, βπ + π π. π + π. πππππ cos(π) > 0 π. π + π. πππππ cos(π) < 0 A MATLAB program to plot the frequency response is given in the following. % % Example 7.5 % fs = 8000; B = [0.01497 0.2 0.01497]; A = [1]; [h w] = freqz(B, A, 1024); f = w*fs/(2*pi); phi = 180*unwrap(angle(h))/pi; figure subplot(2,1,1), plot(f, 20*log10(abs(h))); grid on; axis([0 fs/2 -30 0]); xlabel('Frequency (Hz)'); ylabel('Magnitude'); subplot(2,1,2), plot(f, phi); grid on; axis([0 fs/2 -200 50]); xlabel('Frequency (Hz)'); ylabel('Phase (degrees)'); Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 Figure 7.4: Frequency response in Example 7.2 Example 7.6 (a) Design a 5-tap FIR bandreject filter with a lower cutoff frequency of 2000 Hz, an upper cutoff frequency of 2400 Hz and a sampling rate of 8000 Hz using the Hamming window method. (b) Determine the transfer function. Solution Part (a): We first determine the normalized cutoff frequencies ππππ ππ³ = ππ ππ³ π»π = ππ × ππππ = π. ππ radians ππππ ππ― = ππ ππ― π»π = ππ × ππππ = π. ππ radians In this case ππ΄ + π = π, therefore, using table 7.1 π β ππ― + ππ³ π=π π π(π) = { π¬π’π§(ππ― π) π¬π’π§(ππ― π) β + βπ β€ π β€ π ππ ππ Therefore, Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 π(π) = π β ππ― + ππ³ π β π. ππ + π. ππ = = π. π π π π(π) = β π¬π’π§(ππ― ) π¬π’π§(ππ― ) π¬π’π§(π. ππ ) π¬π’π§(π. ππ ) + =β + = π. πππππ π π π π π(π) = β π¬π’π§(πππ― ) π¬π’π§(ππ― π) π¬π’π§(π. ππ ) π¬π’π§(π ) + =β + = π. πππππ ππ ππ π π π(βπ) = π(π) = π. πππππ (using symmetry) π(βπ) = π(π) = π. πππππ (using symmetry) Applying the Hamming window function, we have π×π ππππ (π) = π. ππ + π. ππ ππ¨π¬ ( ) = π. π π π×π ππππ (π) = π. ππ + π. ππ ππ¨π¬ ( ) = π. ππ π π×π ππππ (π) = π. ππ + π. ππ ππ¨π¬ ( ) = π. ππ π ππππ (βπ) = ππππ (π) = π. ππ (using symmetry) ππππ (βπ) = ππππ (π) = π. ππ (using symmetry) The windowed impulse response is calculated as ππ (π) = π(π) ππππ (π) = π. π × π. π = π. π ππ (π) = π(π) ππππ (π) = π. πππππ × π. ππ = π. πππππ ππ (π) = π(π) ππππ (π) = π. πππππ × π. ππ = π. πππππ ππ (βπ) = π(βπ) ππππ (βπ) = π. πππππ × π. ππ = π. πππππ ππ (βπ) = π(βπ) ππππ (βπ) = π. πππππ × π. ππ = π. πππππ Delaying π(π) by π΄ = π samples, we get ππ = ππ (βπ) = π. πππππ, ππ = ππ (βπ) = π. πππππ, ππ = ππ (π) = π. π, ππ = ππ (π) = π. πππππ and ππ = ππ (π) = π. πππππ. Part (b): Therefore, the transfer function in this case is π―(π) = ππ + ππ πβπ + ππ πβπ + ππ πβπ + ππ πβπ = π. πππππ + π. ππππππβπ + π. ππβπ + π. ππππππβπ + π. ππππππβπ Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 FIR Filter Length Estimation using Window Functions Given the required passband ripples specification and stopband attenuation, the appropriate window length can be estimated based on the performances of the window functions. For illustrative purpose, we use the lowpass filter frequency domain specification (the same can be extended to other types of filter specifications). The normalized transition band frequency is defined as βπ = |πππππ β πππππ |/ππ Based on this, the FIR filter lengths for various window functions are given in Table 7.7 below. It can be noted that the cutoff frequency is determined by ππ = (πππππ β πππππ )/π The passband ripple is defined as πΉπ π π© = ππ β log10 (π + πΉπ ) while the stopband attenuation is defined as πΉπ π π© = βππ β log 10 (πΉπ ) Table 7.7: Filter length estimation using window (βπ = |πππππ β πππππ |/ππ ) Window Type Rectangular Hanning Hamming Blackman Window Function π(π), βπ΄ β€ π β€ π΄ π ππ π. π + π. π ππ¨π¬ ( ) π΄ ππ π. ππ + π. ππ ππ¨π¬ ( ) π΄ ππ πππ π. ππ + π. π ππ¨π¬ ( ) + π. ππ ππ¨π¬ ( ) π΄ π΄ Window Length π΅ = π. π/βπ Passband Ripple (dB) 0.7416 Stopband Attenuation (dB) 21 π΅ = π. π/βπ 0.0546 44 π΅ = π. π/βπ 0.0194 53 π΅ = π. π/βπ 0.0017 74 Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 Example 7.10 Design a bandpass FIR filter with the following specifications: Lower Stopband = 0 - 500 Hz Passband = 1600 - 2300 Hz Upper Stopband = 3500 - 4000 Hz Stopband Attenuation = 50 dB Passband ripple = 0.05dB Sampling rate = 8000 Hz Determine the FIR filter length and the cutoff frequency to be used in the design equation. Solution We first determine the normalized transition band |ππππ β πππ| = π. ππππ ππππ |ππππ β ππππ| βππ = = π. ππ ππππ βππ = The filter lengths based on above transition bands (for Hamming window) are π. π = ππ π. ππππ π. π π΅π = = ππ π. ππ The nearest higher odd π΅ is chosen as for the Hamming window π΅ = ππ π΅π = The lower and higher cutoff frequencies for the bandpass filter will be ππππ + πππ = ππππ π―π π ππππ + ππππ ππ = = ππππ π―π π ππ = The normalized lower and higher cutoff frequencies for the bandpass filter will be ππππ ππ³ = ππ ππ³ π»π = ππ × = π. πππππ π«πππ’ππ§π¬ ππππ ππ― = ππ ππ― π»π = ππ × ππππ = π. ππππ π«πππ’ππ§π¬ ππππ In this case ππ΄ + π = ππ will be the number of taps for the bandpass filter. Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 A MATLAB program to plot the frequency response is given in the following. % % Example 7.10 % Ntap = 25; % number of filter taps Ftype = 3; % lowpass filter WnL = 0.2625*pi; % lower cutoff frequency WnH = 0.725*pi; % upper cutoff frequency Wtype = 4; % Hamming window type fs = 8000; % sampling rate % use firwd to compute B coefficients B = firwd(Ntap, Ftype, WnL, WnH, Wtype); A = 1; omega = 0:0.01:pi; fHz = omega*fs/(2*pi); % frequency response of the fir filter [hz, w] = freqz(B, A, omega); magnitude = 20*log10(abs(hz)); phase = 180*unwrap(angle(hz))/pi; figure, subplot(2,1,1); plot(fHz, magnitude,'k','LineWidth',2); grid on; xlabel('Frequency (Hz)'); ylabel('Magnitude response(dB)'); subplot(2,1,2); plot(fHz, phase,'k','LineWidth',2); grid on; xlabel('Frequency (Hz)'); ylabel('Phase response(degrees)'); Figure 7.18: Frequency response in Example 7.2 Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia CEN352 Digital Signal Processing by Dr. Anwar M. Mirza Lecture No. 22 Date: December, 2012 Department of Computer Engineering College of Computer & Information Sciences, King Saud University Ar Riyadh, Kingdom of Saudi Arabia
© Copyright 2025 Paperzz