Vous êtes sur la page 1sur 20

Figure 7.35 A simplified flowchart for a real-time, transversal.

FIR filter

7.13 Design example


Example 7.20 Design and implement a linear phase bandpass filter meeting the
following specifications:
Passband 900-1100 Hz
passband ripple 0.87 dB
stopband attenuation >30 dB
sampling frequency 15 kHz
number of coefficients 41

The TMS32010 target board (see Chapter 13) is to be used to implement the filter
Table 7.16​ Unquantized, ​h(m)​, and quantized, h​q​(m). coefficients for the design
example.
m Unquantized coefficients, h(m) Quantized coefficients, h​q(m)
0 -1.534638e-02 -503
1 -5.780550e-05 -2
2 5.023483e-03 165
3 1.266706e-02 415
4 2.108206e-02 691
5 2.776418e-02 910
6 3.005362e-02 985
7 2.586935e-02 848
8 1.444566e-02 473
9 -3.189323e-03 -105
10 -2.416137e-02 -792
11 -4.420712e-02 -1449
12 -5.857453e-02 -1919
13 -6.318557e-02 -2070
14 -5.575461e-02 -1827
15 -3.654699e-02 -1198
16 -8.540099e-03 -280
17 2.308386e-02 756
18 5.201380e-02 1704
19 7.224807e-02 2367
20 7.951681e-02 2606
21 7.224807e-02 2367
22 5.201380e-02 1704
23 2.308386e-02 756
24 -8.540099e-03 -280
25 -3.654699e-02 -1198
26 -5.575461e-02 -1827
27 -6.318557e-02 -2070
28 -5.857453e-02 -1919
29 -4.420712e-02 -1449
30 -2.416137e-02 -792
31 -3.189323e-03 -105
32 1.444566e-02 473
33 2.586935e-02 848
34 3.005362e-02 985
35 2.776418e-02 910
36 2.108206e-02 691
37 1.266706e-02 415
38 5.023482e-03 165
39 -5.780550e-05 -2
40 -1.534638e-02 -503

Solution As discussed earlier, there are ftive steps involved in the design of
an FIR filter.
▪ Step 1: ​specifications​ The specifications are already given
▪ Step 2: ​coefficient calculation​ We will use the optimal ncthod
to calculate the filter coefficients because it would yield the
lowest number of filter coefficients (for nonrecursive FIR),
and because it is available. We have already computed the
coefficients for this filter in a previous example; see Table 7.7.
The corresponding frequency response is given in Figure 7.13.
▪ Step 3: ​realization​ The transversal structure is selected (Figure
7.29(a)), as it leads to the most efficient implementation using
the TMS32010 processor. The difference equation for this
structure is
▪ Step 4: ​quantization and analysis of errors​ Since the
TMS32010 is to be used, each coefficient should be quantized
to 16 bits for efficient operation. To do this, we multiply each
coefficient by 2​15​ and then round up to the nearest integer. For
example, the first two coefficients are quantized as follows:
h(0)=-0.015 346 38 x 2​15​ = -502.87 ≈ -503
h(1)=-0.000 057 805 5x 2​15​ = -1.89 ≈ -2
The quantized and unquantized coefficients are listed in Table 7.16. The
frequency response of the quantized filter should be checked
to verify that the specifications are still met, particularly in the
stopband. We found that, after quantization to 16 bits, there
was little difference between the response of the quantized and
unquantized filters.
With the TMS32010, partial sums implied in the difference
equation will be carried out in a 32-bit accumulator. A fairly
wide product register (32 bits) is used. Thus the effects of
roundoff errors for N = 41 will be small. In this example,
overflow is ignored. If it was a concern, we could overcome it
by simply dividing each coefficient oblained in step 2 by a
suitable scale factor, SF, for example
40
S F = ∑ |h(m)|
m=0

The target board has only an 8-bit ADC. This would restrict
the dynamic range of the signal that can be handled to only
about 48 dB. In a high quality audio system, for example, the
level of quantization noise would have been unacceptable, and
in such cases the ADC resolution must be increased.
▪ Step 5: ​Implementation​ A flowchart for the FIR filtering
operation is given in Figure 7.35. The flowchart is next
translated into a TMS32010 assembly code and stored in the
program memory (see Chapter 12 for the development and
coding of FIR filtering operations).

7.14 Summary
The design of digital filters can be divided into five interdependent stages: filter
specifications, coefficient calculation, realization, analysis of errors and
flter implementation.
Filter specification is application dependent, but should include a
specification of the amplitude and/or phase characteristics.
Coefficient calculation essentially involves finding values of ​h(m)​ that
will satisfy the desired specifications. The three most common methods of
calculating FIR filter coefficients are (1) the window, (2) the frequency
sampling. and 3) the optimal methods. The window method is the easiest,
but lacks flexibility especially when the passband and stopband ripples are
different. The frequency sampling method is well suited to recursive
implementation of FIR filters and when filters other than the standard
frequency selective filters (lowpass, highpass, bandpass and bandstop) are
required. The optimal method is the most powerful and flexible. All three
methods were covered in detail in this chapter.
The three most common FIR filter structures are the transversal, which
involves a direct convolution using the filter coefficients, the frequency
sampling structure, which is directly linked to the frequency sampling
method of coefficient calculation, and the fast convolution. The choice
between the structures is influenced by the intended application.
The performance of FIR filters of long lengths or high stopband
attenuation may be affected by finite wordlength effects. For example,
their frequency responses could be altered after coefficient quantization.
Thus the characteristics of such filters should be checked to ensure that
adequate wordlengths have been allowed, especially when wordlengths of
less than about 12 bits are contemplated.
Implementation is normally embarked on when the first four steps are
satisfactory and involves software coding or hardware realization of the
chosen structure.

7.15 Application examples of FIR filters


There are many areas where FIR filters have been employed, including multirate
processing (Crochiere and Rabiner, 1981), noise reduction (Hamer ​et al.,
1985), matched filtering (see Chapter 13), and image processing (Wade ​et
al.,​ 1990).
In multirate processing, for example, FIR filters have been successfully
used for efficient digital anti-aliasing and anti-imaging filtering for
multirale systems such as high quality data acquisition and the compact
disc player (see Chapter 9).
Problems
Concepts of FIR filters
7.1 The frequency response, H( ω ), of a type 2, linear phase FIR filter may be
expressed as (see Table 7.1)
N /2
1
H (ω) = e−jω(N −1)/2 ∑ b (n) cos [ω (n − 2 )]
n=1

where ​b(n)​ is related to the filter coeticients. Explain why filters with the response
above are unsuitable as highpass filters. Use a simple case (such as N-4) to
illustrate your answer.
7.2 An FIR filter has an impulse response, ​h(n),​ which is defined over the
interval 0 ≤ n ≤ N-1. Show that if N is even and ​h(n)​ satisfies the positive
symmetry condition, that is h(n) = h(N-n-1), the flter has a lincar phase
response. Obtain expressions for the amplitude and phase responses of the
filter

Window method
7.3 Show that the impulse response for an ideal bandpass filter (see Table 7.2)
is given by
sin sin n ω 2 sin sin nω 1
ho (n) = 2f 2 nω 2
− 2f 1 nω 1
n≠0

= 2 (f 2 − f 1 ) n=0

where f​1​ is the lower passband frequency and f​2​ is the upper passband frequency
7.4 (1) Obtain the coefficients of an FIR lowpass digital filter to meet the
following specifications using the window method:
stopband attenuation 50 dB
passband edge frequency 3.4 kHz
transition width 0.6 kHz
sampling frequency 8 kHz
Include in your answer the type of window used and the reason for
your choice.
(2) Assuming that the filter coefficients are stored in contiguous memory
locations in a microcomputer, list the values of the coefficients in the
order in which they are stored.
(3) Draw and briefly describe a flowchart of the direct software
implementation of the filter in real time, and suggest two ways of
improving the efficiency of the software implementation.
Note: you may use the information given in Table 7.2 in your design.

Optimal (Parks-McClellan) method


7.5 (1) A linear phase FIR tilter has an impulse response that satisfies the
following symmetry condition:
h(n) = h(N-n-1),
n = 0,1,….,(N-1)/2
where N is the number of filter coefficients, Assuming that N is odd, determine
the magnitude and phase responses of the filter and show that the filter
has both constant phase and group delays. Comment on the practical
significance of a linear phase response in a digital filter.
(2) A linier phase bandpass digital filter is required for feature extraction
in a certain signal analyzer. The filter is required to meet the following
specification :
passband 12-16 kHz
transition width 3 kHz
sampling frequency 96 kHz
passband ripple 0.01 dB
stopband attenuation 80 dB
Assume that the coefficients of the filter are to be calculated using the optimal
(Remez exchange) method. Determine the following parameters for the
filter:
(a) the number of filter coefficients, N;
(b) suitable weights for the filter bands;
(c) bandedge frequencies, in a form suitable for the optimal method.
Explain briefly the roles of the weights and grid frequencies in the
optimal method.
C ω (δ p ,δ k )
N≈ ∆F
+ g (δ p , δ s ) ∆F + 1

where

[ 2
C ω (δ p , δ s ) = [δ s ] b1 (δ p ) + b2 δ p + b3 ] + [b (δ
4 p
2
) + b5 δ p + b6 ]
∆ F, transition width normalized to the sampling frequency

δ p , passband ripple or deviation


δ s , stopband ripple or deviation

Suggest a suitable grid density for the above problem. You may use the
information given in Table 7.17
7.6 An FIR lowpass digital filter is required to meet the following
specifications:
stopband attenuation > 40 dB
passband edge frequency 100 Hz
passband ripple < 0.05 dB
transition width 10 Hz
sampling frequency 1024 Hz
(1) Calculate and list the coefficients of the filter indicating clearly the
method you used and why you chose it.
(2) The filter is to be implemented for real-time operation using the fast
convolution method Outline how you would implement the filter with
the FT using the overlap-save technique. Indicate clearly parameters
such as the number of samples by which the input sections overlap, the
length of sections, the size of the transforms used and how the output
samples are extracted from the transforms.
7.7 A linear phase, 41-point FIR differentiator is to be designed to meet the
following specifications:
passband edge frequency 1 kHz
stopband edge frequency 1.5 kHz
sampling frequency 10 kHz
passband deviation 0.01
stopband deviation 0.01
Calculate the coefficients of the differentiator using the optimal method
(Parks-McClellan/ Remez exchange algorithm). Plot its magnitude-
frequency response
7.8 A linear phase, 43-point FIR Hilbert transform filter is to be designed to
meet the following specifications:
lower bandedge frequency 1 kHz
upper bandedge frequency 4.5 kHz
sampling frequency 10 kHz
passband deviation 0.01
Calculate the coefficients of the filter using the optimal method. Plot its
magnitude-frequency response in dB

Frequency sampling filters


7.9 A 4-point, linear phase, FIR filter is characterized by the following
frequency samples:
|H (k)| = 1, k=0
1
2, k = 1.3
0, k=2
(a) Starting from the general expression for the transfer function given in
Equation 7.24, show that the transfer function of the above filter
contains four zeros and three poles.
(b) Sketch the pole-zero diagram of the filter.
(c) Sketch the frequency response of the filter.
(d) Develop and sketch the realization diagram for the filter, with the
complex conjugate poles combined, using the frequency sampling
structure
(e) Determine the four coefficienis of the filter. The coefticients must be
real.
7.10 A 4-point, linear phase, frequency sampling, FIR filter is characterized by
the following frequency samples:
|H (k)| = 1, k=0
0, k = 1, 2, 3
(a) Starting from the general expression for the transfer function given in
Equation 7.24, determine the number of zeros and poles in the transfer
function of the filter
(b) Sketch the pole-zero diagram of the filter
(c) Develop and sketch the realization of the filter, with the complex
conjugate poles combined, using the frequency sampling.
(d) Determine the four coefficients of the filter. The coefficients must be
real
7.11 Frequency sampling filters have certain features in common with FIR
filters and others in common with IIR filters. In this problem we will
consider some of these features
(a) What is the main advantage of recursive frequency sampling filters
over non-recursive equivalents?
(b) Comment on the problem of finite wordlength effects associated with
recursive frequency sampling filters, and suggest how it may be
overcome in practice.
(c) The pole-zero diagram of a bandpass frequency sampling filter is
depicted in Figure 7.36.
(i) Write down, by inspection of the pole-zero diagram, the
values of the frequency samples, H(k), of the bandpass filter at
the frequencies
2πk
ωk = N , k = 0, 1, …., 7

State any reasonable assumptions made.


(ii) Sketch the magnitude-frequency response of the filter. with
the sampling instants clearly labelled.
(iii) Calculate the coefficients of the filter and hence determine its
transfer function. ​H(z),​ in recursive form.
Figure 7.36

(d) Explain how the radix-2 FFT flow graph of Figure 7.36(b) may be
used to calculate the impulse response of the filter from the frequency
samples obtained above.
7.12 (a) Explain, widh the aid of sketches, the basic concepts of the frequency
sampling filter design method.
(b) A requirement exists for a lowpass digital filter satisfying the
following requirements
passband 0-20 Hz
sampling frequency 300 Hz
stopband attenuation > 50 dB
filter length 15
Table 7.18 Optimum transition band frequency samples for type I lowpass
frequency sampling filters for N=15 (adapted from Rabiner et al,
1970)
Stopband attenuation
BW T​1 T​2 T​3
(dB)
One transition band frequency sample, N=15
1 42.309 322 83 0.433 782 96
2 41.262 992 86 0.417 938 23
3 41.253 337 86 0.410 473 63
4 41.949 077 13 0.404 058 84
5 44.371 245 38 0.392 681 89
6 56.014 165 88 0.357 665 25
Two transition band frequency samples, N=15
1 70.605 405 85 0.095 001 22 0.589 954 18
2 69.261 681 56 0 103 198 24 0.593 571 18
3 69.919 734 95 0.100 836 18 0.589 432 70
4 75.511 722 56 0.084 074 93 0.557 153 12
5 103.460 783 00 0.051 802 06 0.499 174 24
Three transition band frequency samples, N=15
1 94.611 661 91 0.014 550 78 0.184 578 82 0.668 976 13
2 104.998 130 80 0.010 009 77 0.173 607 13 0.659 515 26
3 114.907 193 18 0.008 734 13 0.163 973 10 0.647 112 64
4 157.292 575 84 0.003 787 99 0.123 939 63 0.601 811 54
BW refers to the number of frequency samples in the passband
(c) Find the coefficients of the transfer function of the digital filter. in recursive
form, using the
frequency sampling method and the information in Table 7.18.
(i) Develop and draw the realization diagram for the filter and
compare the storage and computational requirements of the
recursive implementation with direct form FIR.
(ii) Explain why the filter represented by the transfer function above
is still an FIR filter even though its transfer function indicates
that it is a recursive filter. Comment on the difficulties that may
be encountered in practice with recursive frequency sampling
filters and indicate how these may be overcome.

7.13 The pole-zero diagram of a simple, frequency sampling bandpass filler is


shown in Figure 7.37
(a) Sketch the magnitude- frequency response of the filter and hence
write down the values of the magnitude-frequency response at the
sampling points.
(b) Obtain the transfer function of the filter, starting with the general
transfer function of Equation 7.24 for a frequency sampling filter.
Comment on your answer
(c) Sketch the realization diagram of the filter and write down the
difference equation.
(d) Compare the frequency sampling realization and the direct form
realization in terms of their computational and storage requirements.
Figure 7.37

Figure 7.37

7.14 The pole-zero diagram of a simple, frequency sampling bandpass filter is


shown in Figure 7.38.
(a) Sketch the magnitude-frequency response of the comb tilter section
finvolves only zeros).
(b) Sketch the magnitude-frequency response of the filter and hence write
down the values of the magnitude-frequency response at the sampling
points.
(c) Write down the transfer function of the filter in recursive form.
(d) Obtain the transfer function of the filter, starting with the general
transfer function of Equation 7.24 for a frequency sampling filter.
Comment on your answer
(e) Sketch the realization diagram of the filter and write down the
difference equation.

7.15 (1) Discuss briefly the conditions necessary for a realizable digital filter to
have a linear phase characteristic, and the advantages of filters with
such a characteristic
(2) In a ceriain signal processing application. the input signal, with
significant frequency components in the range 0 ≤ f ≤ 10 Hz, is
contaminated by a 50 Hz mains interference. It is decided to remove
the interference using a linear phase digital filter after digitizing the
composite signal at a rate of 500 samples s​-1​. As a first step in the
design of the filter, the pole-zero diagram given in Figure 7.39 was
developed. Obtain the transfer function, H(z), of the filter and its
difference equation.
(3) The filter obtained in part (2) is to be implemented in a microcomputer
with simple arithmetic limited to only additions/subtractions and shifts.
Redesign the filter so that its coefficients are integers. There should be
no increase in the number of filter coefficients or sampling rate.
(4) Show that the phase response, θ ( ω ), of the filter of part (3) is given
by
θ (ω) =− ωT
Figure 7.39 ​Pole-zero diagram for Problem 7.15; ω 0 T = π5 rad.
7.16 (1) A requirement exists for a real-time, narrowband, linear phase digital
filter for a certain biomedical system. Justify the use of filter for the
system.
Assume that the transfer function of an N-point frequency
sampling filter is given by
1−rN z −N
H (z) = N

( )
M
|H(k)|[2 cos(2πkα/N )−2r cos[2πk(1+α)/N ] H(0)
∑ 1−2r cos(2πk/N )z −1 +r2 z −2
+ 1−z −1
k=1

where the ​H(k)​ are the samples of the desired frequency response taken
at intervals of F​s​/N​s​, α=(N-1)/2.
(2) The desired filter is characterized by the following specifications:
passband 48-52 Hz
transition width 2 Hz
sampling frequency 500 Hz
stopband attenuation > 60 Db
Specify suitable frequeney samples, |​H(k)|​ Develop and draw the realization
diagram for the filter, How does the filter compare with an equivalent
transversal structure interms of storage and computational
requirements?
(3) Comment on the H(z) above and the difficulties that may be
encountered in practice with recursive frequency sampling filters, and
indicate how these may be overcome.
Explain why ​H(z)​ describes a recursive filter and yet its unit
impulse response, ​h(n),​ is of a finite duration.
7.17 A requirement exists for an N-point FIR filter with the frequency response
H (ejω ) = ||H(ejω )|| e−jωα

Where α = (N-1)/2. Assume that N samples of H( ejω ) are taken at intervals of


f​k​=(k+1/2) F​s​/N. k=0,1,….,N-1
(1) Show that, for N odd, the impulse response is given by

{ }
N /2−1
1
h (n) = N
∑ 2|H (k) |cos[2π(n − α)(k + 1/2)/N ]
k=0

(2) Show that, for N odd, the impulse response is given by

{
( N3 )−1
h (n) = 1
N
∑ 2 |H (k)| cos cos
k=0
[ 2π(n−α)(k+ 12 )
N ] + H [(N − 1)/2]cos [π (n

(3) Obtain an expression for the transfer function, ​H(z)​, in recursive from
for each of parts (1) and (2).

Special FIR Filters


7.18 A highpass FIR Filter is characterized by the following impulse response
coefficients
{h(n)} = {0.127, -0.026, -0.237, 0.017, 0.434}
Write down the coefficients of an equivalent lowpass filter with the aid of the
frequeacy transformation given in Section 7.9.2.
7.19 Calculate the coefficients of an FIR half-band filter using the Kaiser
window function. The half band filter should meet the following
specifications :
passband ripple 0.5 dB
stopband attenuation 45 dB
passband edge frequency 2 kHz
sampling frequency 10 kHz

7.20​ Repeat Problem 7.19 using the optimal method.

FIR filter implementation


7.21 An analog signal is contaminatod by a 50 Hz component and its harmonics
at 100 Hz, 150 Hz, 200Hz, 250Hz and 300㎐ Assume that the
contaminated signal is sampled and digitized at 1 kHz.
Find the tansfer function of a simple digital filter to remove the
interference and its harmonics.

Vous aimerez peut-être aussi