Sie sind auf Seite 1von 58

FIR Filter Design

Outline

aFIR Filter Characteristics


aLinear Phase
aWindowing Method
aFrequency Sampling Method
aEquiripple Optimal Method
aDesign Examples
FIR Filter Characteristics
aFIR difference equation
M M
y ( n) = ∑ bk x(n − k ) = ∑ h(k ) x(n − k )
k =0 k =0
The output only depends on the previous input samples

aFIR transfer function


N −1 N −1
H ( z ) = ∑ h( n) z −n
=z − ( N −1)
∑ h ( n ) z N −1− n

n =0 n =0

All poles are at the origin and also called all zeros filter
Advantages of FIR Filter

aStability is never an issue


`All poles at origin => must within unit circle
aLinear Phase FIR Filter is very easy to design
aA lot of applications require linear phase:
`Digital Communication System
`Audio Signal Processing
`Image Processing
Properties of Linear Phase

aPhase delay of a system is defined as


− θ (ω )
Tp =
ω
aA linear phase system has phase response of the
following relationships:

θ(ω) = -αω or θ(ω) = β - αω


where α is a constant phase delay and β =±π
Linear Phase Filters: Type 1 and 2
a It can be shown that for θ(ω) = -αω the filter impulse
response must have positive symmetry:

 n = 0,1,..., ( N − 1) / 2 ( N odd)
h(n) = h( N − n − 1), 
n = 0,1,..., ( N / 2) − 1 ( N even)

a Type 1 linear phase FIR filter:


`N is odd number and α = (N-1)/2 is an integer.
a Type 2 linear-phase filter
`N is even number and α = (N-1)/2 is not an integer
Linear Phase Filters: Type 3 and 4
a It can be shown that for θ(ω) = β - αω the filter impulse
response must have negative symmetry:

h(n) = -h(N-n-1)
α = (N-1)/2
β = ±π/2
a Type 3 linear phase FIR filter:
`N is odd number
aType 4 linear-phase filter
`N is even number
Example 1

An FIR digital filter has impulse response, h(n), defined


over the interval 0 ≤ n ≤ N - 1. Show that if N = 7 and h(n)
satisfies the positive symmetry condition

h(n) = h(N - n - 1)

the filter has a linear phase characteristic.


Types of linear phase FIR filters
Impulse response comparison of the 4 linear phase filters
FIR Filter Coefficient Design Method

aGiven filter specification,


`⇒ Determine the impulse response h(n)
aPopular FIR Design Methods:
- Window Method
- Frequency Sampling Method
- Optimal Filter Design
aMatlab functions for FIR filter design
`fir1( ), fir2( ), remez( )
Window Method

H d (ω ) : ideal (desired) frequency response



1 π jωn
hd (n) = ∫− π
H d (ω ) e dω


h( n) = hd ( n) ⋅ w(n) ⇒ H (ω ) = H d (ω ) *W (ω )
where w(n) is a window sequence
Ideal Lowpass Filter

1 π 1 π j ωn
∫ ∫
jωn
hD (n) = 1 × e dω = e dω
2π −π 2π −π

2 f sin( nω c )
= c , n = 0, − ∞ ≤ n ≤ ∞
nω c
= 2 fc n = 0(using L' Hopital' s rule)
Ideal Impulse Responses for Standard
Frequency Selective filters
Gibb’s Effect
Comment

aNote that ripple in the neighbourhood of 10%


overshoot in the passband represents only 0.7
dB, but that 10% ripple in the stop represents
20 dB.
aWe would probably find this filter in adequate to
meet filtering requirements in the stop band.
aHow do we improve performance?
aWe have commented that the poor ripple
characteristics are due to the bumpy function used in
the convolution
aTo reduce the ripple, we need a truncation function
whose Fourier Transform is not as bumpy (i.e.
smoother)
aThe bumpy behaviour of the transform is related to
the discontinuity of the truncation function.
Window Design Example
Important Features of Common Window Functions
Rectangular Window
Triangular Window
Hamming Window
Blackman Window
Kaiser Window
Window functions comparison

(a) Rectangular

(b) Hamming

(c) Blackman
Comments

aWindows with smoother behavious in the time-


domain are smoother in the frequency domain
aWindows that are “smoother” in the time-domain
tend to have narrower time duration
aWindows that are “smoother” in the domain tend to
have wider bandwidths
aWhen convolving with a wider function, the
resultant function will have wider transitions
Summary of the Window method
aStep 1:
`Specify the ‘ideal’ or desired frequency response of filter,
HD(ω).
aStep 2:
`Obtain the impulse response hD(n) by evaluation the inverse
Fourier transform.
aStep 3:
`Select a window function that satisfies the specifications
`Determine the filter order based on ∆f
aStep4.
` Calculate the filter coefficients, h(n), by h(n) = hD(n)w(n)
Example

Obtain the coefficients of an FIR lowpass to meet the


specifications given below using the window method.
Passband edge frequency 1.5 kHz
Transition width 0.5 kHz
Stopband attenuation >50 dB
Sampling frequency 8 kHz
Solution

aThe unit sample response of an ideal lowpass


filter is given by

 ω c / π , n=0
hd (n) =  sin(ω c n)
 πn , n ≠ 0
Solution

aHamming window is used for simplicity.


aTo find the normalized transition width as
transition width 0.5
∆f = = = 0.0625
sampling frequency 8

aThe minimum filter length of the FIR filter using


Hamming window is determined by
3 .3 3.3
N= = = 52.8 ≈ 53
∆f 0.0625
Solution

aThe filter coefficients can be obtained by


hd ( n) w(n) − 26 ≤ n ≤ 26

 2πn 
where w(n) = 0.54 + 0.46 cos 
 N 

aThe cutoff frequency fc is on the center of the


transition band:
fp ∆f 1.5 0.0625
fc = + = + = 0.21875
Fs 2 8 2
Matlab Solution
a fc=2*(1.5+0.25)/8; % calculate the cutoff
frequency
a h=fir1(53,fc); % generate the filter
coefficients
a [H, F]=freqz(h,1,100,8000);
a magH=abs(H);
a db=20*log10(magH);
a phase=unwrap(angle(H))*(180/pi);
a subplot(2,1,1); plot(F, db, 'b'); grid;
a axis([0,4000,-90,10]);
a xlabel('Frequency in Hz'); ylabel ('Magnitude in
dB');
a subplot(2,1,2); plot(F,phase, 'b'); grid;
a xlabel('Frequency in Hz'); ylabel ('Phase in
degrees');
Matlab Results
Advantages and Disadvantages
of the window method

aAdvantage:
`Simplicity: it is simple to apply and simple to
understand.
aDisadvantages:
`Lack of flexibility. Both the peak passband and
stopband ripples are approximately equal.
`The passband and stopband edge frequencies
cannot be precissely specified.
Frequency Sampling Method

Hd’(ω) = Hd(ω) with linear phase


H(k) = Hd’(ω) | ω = (2π/N)k

↓ IDFT
N −1
1
h(n) =
N
∑ H
k =0
( k ) e j ( 2π / N ) nk
Example
A requirement exists for a lowpass FIR satisfying the
following specifications:

Passband 0 - 5 kHz
Sampling frequency 18kHz
Filter length 9

Obtain the filter coefficients using the frequency sampling


method.
Solution
Parks-McClellan Method

aOften called the Remez exchange method.


aThis method designs an optimal linear phase
filter directly from the design specifications.
aThis is the standard method for FIR filter
design.
aIn matlab, this method is available as remez()
Approximation Errors

aFrom the theory of the Fourier series, the rectangular


window design method (truncation of the impulse
response) gives the best mean square approximation
to a desired frequency response for a given filter
length M.
Minimax Design

aHowever simple truncation leads to adverse


behaviour near discontinuities and in the stopband.
aBetter filters generally result from minimization of
the maximum error (L∞) or a frequency weighed
error criterion.
Design Procedures
aTo specify the frequency response
aTo estimate the filter order:
`Equations are available to estimate the filter order
`Matlab function: remezord()
aAn optimization program is run to compute the filter
coefficients.
`Matlab functon: remez()
ato check the result meets the requirements or not
`Matlab functon: freqz()
Example: Lowpass Filter

Design a digital FIR lowpass filter to meet the


specifications given below using the equiripple method.

Sampling frequency 16 kHz


Passband 0 – 3800 Hz
Stopband 4000 – 8000 Hz
Passband ripple less than 0.1 dB
Stopband attenuation > 40 dB
Solution

aThe passband ripple to be less than 0.1 dB, we have

Rp = 0.1 = 20log10(1+ δp) ⇒ δp = 100.1/20 –1 = 0.011

aThe minimum stopband attenuation at least 40 dB,

Ap = 40 = -20log10(δs) ⇒ δs = 10-40/20 = 0.01


Matlab for Filter Order Estimation
a F=[3800 4000];
a M=[1 0];
a dev=[0.011 0.01];
a Fs=16000;
a [N Fo Mo W]=remezord(F, M, dev, Fs)
Results: N = 154
Fo = {0, 0.4750, 0.5000, 1.000},
Mo = {1, 1, 0, 0}
W = {1.0, 1.0}.
Matlab codes for filter design
a h=remez(N, Fo, Mo, W);
a [H, F]=freqz(h, 1, [0:10:8000], Fs);
a magH=abs(H);
a db=20*log10(magH);
a phase=unwrap(angle(H))*(180/pi);
a subplot(2,1,1); plot(F, db, 'b'); grid;
a xlabel('Frequency in Hz'); ylabel
('Magnitude in dB');
a axis([0,8000,-110,10]);
a subplot(2,1,2); plot(F,phase, 'b'); grid;
a xlabel('Frequency in Hz'); ylabel ('Phase
in degrees');
Frequency Response of the Designed
FIR Filter
Frequency Response between 0 to 400 Hz

The plots show that the designed filter could meet


the passband ripple of 0.011.
Example: Band-Reject Filter
This example is to design a 1 KHz band-reject filter
with a 40 Hz bandwidth (980 to 1020 Hz) and 8 KHz
sampling rate. The over all specifications are:

Sampling frequency 8 kHz


Passband 0 – 980 Hz and 1020 - 4000 Hz
Stopband 980 – 1020 Hz
Passband ripple less than 1 dB
Stopband attenuation > 60 dB
Solution

aThe passband ripple to be less than 1 dB, we have

Rp = 1 = 20log10(1+ δp) ⇒ δp = 101/20 –1 = 0.12

aThe minimum stopband attenuation at least 60 dB,

Ap = 60 = -20log10(δs) ⇒ δs = 10-60/20 = 0.001


Matlab for Filter Order Estimation
a F = [750 980 1020 1250];
a M = [1 0 1];
a dev = [0.12 0.001 0.12];
a Fs = 8000;
a [N Fo Mo W] = remezord(F, M, dev, Fs);

Results:
N = 67
Fo = {0, 0.1875, 0.2450, 0.2550, 0.3125, 1.000},
Mo = {1, 1, 0, 0, 1, 1}
W = {1, 120, 1.0}.
Matlab codes for filter design
a h = remez(N, Fo, Mo, W);
a [H, F]=freqz(h, 1, [500:10:1500], Fs);
a magH=abs(H);
a db=20*log10(magH);
a phase=unwrap(angle(H))*(180/pi);
a subplot(2,1,1); plot(F, db, 'b'); grid;
a xlabel('Frequency in Hz'); ylabel
('Magnitude in dB');
a subplot(2,1,2); plot(F,phase, 'b'); grid
a xlabel('Frequency in Hz'); ylabel ('Phase
in degrees');
Frequency Response of the Designed FIR Filter

The plots shows the initial design with the estimated


order N=69 failed to converge to an equiripple solution.
Frequency Response with N = 80
Finite Wordlength Effects of FIR Filter

aADC noise
aCoefficient quantization errors
aRoundoff errors from quantizing results of
arithmetic operations
aArithmetic overflow
Example

Determine the effects of quantizing, by rounding, the


coefficients of the following filter to 8 bits:

stopband attenuation > 90 dB


passband ripple < 0.002 dB
passband edge frequency 3.375 kHz
stopband edge frequency 5.625 kHz
sampling frequency 20 kHz
number of coefficients 45
Solution

Use the design program optimal.c with the following input:


number of filter coefficients 45
band edge frequencies 0, 0.16875, 0.28125, 0.5
weight 1, 7.28
The coefficients of the filter, before and after rounding to 8 bits,
are listed in Table 6.16. The corresponding frequency responses
are given in Figure 6.31. It is seen that, after quantization, the
minimum stopband attenuation is 36 dB, a degradation of more
than 58 dB. Clearly, more than 8 bits of resolution is required for
the coefficients in this particular example.
Filter coefficients before and after quantization to 8 bits.
(a) Effects of coefficient quantization. (b) Passbad. „, unquantized; †, quantized.

Das könnte Ihnen auch gefallen