Anda di halaman 1dari 13

EE 422G Notes Instructor: Cheung

Analysis and Design of Digital Filter


I. What is filter design?

H ( e jω )
N

∑ Li z −i
H (z) = i=0
M
1+ ∑ i=
K i z −i
Filter specification in terms
of amplitude response and Transfer function
error tolerance

II. Two major categories

1. IIR – typically based on transforming a continuous-time analog filter (such


as Butterworth) into discrete-time

Advantages:
- Decades of experiences in designing analog filters
- Typical less complex (fewer registers, arithmetic units) than
FIR in realizing the design filter spectrum

2. FIR – entirely discrete-time domain method

Advantages:
- Advantages of any FIR filter : always stable, linear phase
- “Optimal” CAD method (not covered in this class)

III. IIR Filter Design

General procedure:
1. Design an analog filter Ha(s) that satisfies the specification.
2. Map the analog filter Ha(s) into a discrete-time filter Hd(z)

Focus on step 2. There are two approaches:


1. Invariance Design
Simple to understand
Requires high sampling rate to mitigate aliasing

Page 9-1
EE 422G Notes Instructor: Cheung

2. Bilinear Mapping Design – Frequency warping


No aliasing
Frequency distortion

III.1 Invariant Design

ya(t) ya(nT)

x(t) ya(t) ya(nT)


Ha(s)

y(nT)

x(nT) y(nT)
H(z)

Goal: for a GIVEN x(t), we want the output of our digital filter y(nT) to be
identical to the sampled version ya(nT) of the continuous-time filter output.

If x(t) is the delta function, we effectively have


h(nT) = ha(nT)

This is called IMPULSE-INVARIANCE design.

Let’s see an example to illustrate all the steps.

0.5( s + 4)
Example: Given H a ( s ) =
( s + 1)( s + 2)

Find digital filter H(z) by impulse-invariance.

Page 9-2
EE 422G Notes Instructor: Cheung

Step 1: Compute the response of the analog filter ya(t)

Since xa(t) = δ(t) ⇒ Xa(s)=1, thus


ya (t ) = L−1[ H a ( s ) X a ( s )]
= L−1 [H a ( s )]
 0.5( s + 4) 
= L−1  
 ( s + 1)( s + 2) 
 1 .5 1 
= L−1  −  = 1.5e −t − e −2t
s +1 s + 2

Step 2: Sample ya(t) to get ya(nT)


ya (nT ) = 1.5e − nT − e −2 nT

Step 3: Perform Z-transform on ya(nT)


Y ( z ) = Z [ ya ( nT )] =
1.5 1
− T −1
− − 2T −1
1− e z 1− e z

Step 4: Perform Z-transform on xa(nT)


X ( z ) = Z [xa ( nT )] = 1

Step 5: Find Hd(z) = Y(z)/X(z)


1 .5 1
H ( z) = −T −1

1− e z 1 − e −2T z −1

Step 6: Finally choose a sampling period T and obtain the numerical representation
of the digital filter.

>> % Impulse-Invariance Design


>> num = 0.5 * [ 1 4];
>> den = conv([1 1], [1 2]);
>> Fs = 10; % Sampling freq = 10Hz
>> [bz,az] = impinvar(num,den,Fs);
>>
>> % Compare Analog and Digital Filter
>> [ha,w] = freqs(num,den);
>> f = w/(2*pi); % Convert to Normal Freq.
>> hd = freqz(bz,az,f,Fs);
>> plot(w,abs(ha),’b’,w,abs(hd),’r’); % Blue:Analog,
Red:Digital

Page 9-3
EE 422G Notes Instructor: Cheung

1.4

1.2

1
Amplitude Response

0.8

0.6

0.4

0.2

0
0 10 20 30 40 50 60 70 80 90 100
Frequency (rad/s)
Frequency (Hz)

What happen around 63 rad/s?

Ans: The FT of the discrete filter is periodic with period 2πfs=2π(10)≈ 63 rad/s.

If your client cannot stomach the divergence starting at 30Hz, what should you do?

Ans: Increase the sampling rate.


s3
What about if we want to design a highpass filter H HP ( s) = ?
( s + 2)( s 2 + 2 s + 4)

1.8

1.6
Important: We cannot use
invariance method to design
1.4 any non band-limited filter
Amplitude Response

1.2 such as high-pass or band-


stop. To design these filters,
1
we need to understand the
0.8 concept of “frequency
0.6 transformation”.
0.4

0.2

0
0 2 4 6 8 10
Frequency (Hz)

Page 9-4
EE 422G Notes Instructor: Cheung

III.2 Bilinear Transformation

The basic idea of frequency transformation is straightforward:

1. Start with a low-pass prototype filter Hp(jω).


2. Design a frequency transform ω’=f(ω) such that …
3. Hp(jω’) is your desired filter!

Frequency transformation is useful in both analog filter design and analog to


discrete conversion.

Example: Convert a low-pass analog filter to high-pass analog filter

Let’s say you have a low-pass analog filter with cutoff frequency (-3dB frequency)
at 1 rad/s as follows:
1
H ( s) =
( s + 1)( s 2 + s + 1)
To design a HIGH-PASS filter with cutoff frequency at ωp, we use the following
transformation:
ω ω
ω ' = p or equivalently s ' = p
ω s
1 s3
Let ωp=2, H HP ( s ) = =
 2   2  2 
2
( s + 2)( s 2 + 2 s + 4)
 + 1    + + 1
 s   s  s 

0.8
Amplitude Response

0.6

0.4
ω=∞→ω’=0 ω=0→ω’= ∞

0.2

0
0 2 4 6 8 10
Frequency (rad/s)

Page 9-5
EE 422G Notes Instructor: Cheung

Question: How do we use frequency transformation to map analog filter to digital?

CTFT extends from negative infinity to positive infinity, while DTFT is periodic
with period equal to the sampling frequency (2π/T). To ELIMINATE ALIASING,
we need to come up with a frequency transform f such that

f maps analog frequency ωc∈[-∞,∞] to ωd∈[- π/T, π/T]

One such example of f is the arctan:


ω d = 2 T arctan (ωc )

In the following example T = 2:


2
ωd
1.5

0.5ω s = π
1

T
ωc
0.5

-0.5

-1 − 0.5ω s = − π
T
-1.5

-2
-5 0 5

When ωc is small (-1≤ ωc ≤1), the distortion is relatively small and we have
2
ωd ≈ ωc
T
Beyond that, the transformation compresses ωc causing a fair amount of distortion.

If we are designing a low-pass filter with passband -C≤ ωc ≤C, we can scale ωc first
by C and use the transform:
ω d = 2 T arctan (ω c
C )
In most applications, the analog filter is specified in terms of the Laplace variable
s=jωc and the target discrete filter needs to be expressed in Z-transform variable
z=ejωd. Thus, it will be nice if we can derive a transform directly from s to z.
1 − z −1
Bilinear Transformation: s=C
1 + z −1

Page 9-6
EE 422G Notes Instructor: Cheung

Proof:
1 − e − jωd T
jωc = C
1 + e − jωd T
ωd T ωd T
1 − e− j 2
e− j 2

=C ωd T ωd T
1 + e− j 2
e− j 2

ωd T ωd T
ej 2
− e− j 2

=C ωd T ωd T
e j 2 + e− j 2
2 j sin(ωd T 2 )
=C ωd T
= Cj tan (ωd T 2 )
2 cos( 2 )
⇔ ωc = C tan (ωd T 2 )
⇔ ωd = 2 T arctan (ωc C )

To determine C, we typically assume there is a “fixed-point” or “anchor”


frequency ωr which maps to itself:
2 ω  ωr
ωr = arctan  r  ⇒ C =
T C ω T 
tan r 
 2 
Example 9-7 H a ( s ) = ωc 2
(2nd order Butterworth filter) with
s + 2ω c s + ω c
2 2

ωc=1000π as the anchor frequency and ωs=4000π.

Applying bilinear transformation:


ωc2
H d ( z) =
(1 − z −1 ) 2 1 − z −1
+ 2ω c + ωc
2 2
C −1 2 −1
(1 + z ) 1+ z
ω c 2 (1 + z −1 ) 2
=
C 2 (1 − z −1 ) 2 + 2ω c (1 − z − 2 ) + ω c (1 + z −1 ) 2
2

Solving C:
ωc
C= = 229168.76
 ωc T 
tan  
 2 
0.292893 + 0.585786 z −1 + 0.292893z −2
H d ( z) =
 1 + 0.171573z −2

Page 9-7
EE 422G Notes Instructor: Cheung

IV FIR Digital Filter

IV.1 Design Procedure:

1. Start with desired amplitude response with zero phase.

2. Apply inverse DTFT to recover acausal, symmetric and possibility infinitely-


long impulse response hd (nT )
π
T
x ( nT ) = ∫ X ( e jωT )e jωnT dω
T
DTFT Formula:
2π − πT
0.5
or in normalized frequency: x ( nT ) = ∫−0.5 X (e j 2πr )e jn 2πr dr

3. Truncate hd (nT ) to finite extent by multiplying it by an appropriate window


function and form hnc (nT ) .

0
4. Delay hnc (nT ) to make it casual.

Page 9-8
EE 422G Notes Instructor: Cheung

1
Example: Design a FIR filter that approximates H ( r ) = (1 + cos 2π r )
2
Solution:

(1) Inverse DTFT (explicit calculation)



1
H (r ) = (1 + cos 2πr ) = ∑ hd ( nT )e − jn 2π r Notice n ranges from -∞ to ∞
2 n = −∞

1 1/ 2
Compute hd ( nT ) = ∫ (1 + cos 2πr )e jn 2πr dr
2 −1 / 2
1 1/ 2 1 1/ 2 1 1/ 2 1
For n = 0, dh ( 0 ) = ∫ (1 + cos 2πr ) dr = ∫ dr + ∫ cos 2πrdr =
2 −1 / 2 2 −1 / 2 2 −1 / 2 2
For n ≠ 0 ,
1 1 / 2 jn 2π r 1 1/ 2 e j 2π r + e − j 2π r j 2πnr
hd ( nT ) = ∫ e dr + ∫ e dr
2 −1/ 2 2 −1 / 2 2
1 1/ 2 1 1/ 2 1
= ∫ e j 2π ( n +1) r dr + ∫ e j 2π ( n −1) r dr = for n = ±1 and 0 otherwise
4 −1 / 2 4 −1/ 2 4

 1 − j 2π r 1 1 − j 2π r
 H ( r ) = ∑
n = −∞
hd ( nT ) e − j 2πn r
=
4
e + + e
2 4
 
h (0) = 1 , h ( ±T ) =
1
, hd (nT ) = 0, | n |≥ 2
 d
2
d
4
The impulse response is finite duration. Thus there is no need to truncate.

(3) Make it acasual by delaying one sample.


1 1 1
H ( z ) = + z −1 + z − 2
4 2 4

IV.2 Effect of windowing 2M+1 terms

M ∞

Truncation => H nc ( z ) = ∑ hd (nT ) z −n =


n=− M
∑ w ( n )h
n = −∞
r d ( nT ) z −n

1 | n |≤ M
where wr ( n ) = 
0 | n |> M
Truncation = time multiplication with rectangular window function
 Convolving in frequency domain with a sinc function

Page 9-9
EE 422G Notes Instructor: Cheung

M
sin π (2 M + 1) r
wr (e j 2π r ) = ∑e
n=− M
− j 2π n r
=
sin π r
- Sinc function in frequency domain

Suppose the original analog filter H(r) is an ideal low-pass filter, windowing in
time domain corresponds to convolution in frequency with a sinc function.
Sliding sinc function in convolution
Ideal LP

Frequency Spectrum of the resulting truncated


sequence

Spectrum of the rectangular window that retains 15 samples (M=7):

The frequency spectrum of a good truncation window should resemble as much as


possible to a delta function. Typically, it is measured based on two criteria:
1. Narrow Main Lobe
- for rectangular window : main lobe width = 2π/(M+1)
- a narrow main lobe produce better frequency transition

Page 9-10
EE 422G Notes Instructor: Cheung

2. Small Side Lobes


- measured by the highest peaks
- caused by the sharp cutoff of the rectangular window
By tapering the window smoothly to zero at each end, the height of the sidelobes
can be diminished; however, this is achieved at the expense of a wider mainlobe
and thus a wider transition at the discontinuity.

Some commonly used windows include:


 2n / M 0 ≤ n ≤ M /2
Bartlett (triangular): w( n ) = 2 − 2n / M M /2 ≤ n ≤ M
 0 otherwise

0.5 − 0.5 cos(2πn / M ) 0 ≤ n ≤ M


Hanning: w( n ) = 
 0 otherwise

 nπ
0.54 − 0.46 cos 0≤n≤M
Hamming : wh (n ) =  M
0 otherwise

0.42 − 0.5 cos(2πn / M ) + 0.08 cos(4πn / M ) 0 ≤ n ≤ M


Blackman: w( n ) = 
 0 otherwise

Hanning vs. Rectangular Hamming vs. Rectangular Blackman vs. Rectangular

Page 9-11
EE 422G Notes Instructor: Cheung

Example: Design a 17-tap low-pass FIR digital filter with Hamming window to
approximate
1 | r |≤ 0.15
H (r ) = 
0 0.15 <| r |≤ 0.5
Step 1: Inverse Fourier Transform
0.15 1 1
hd ( nT ) = ∫ e j 2π n r dr =
( e j 0.3π − e − j 0.3π ) = sin 0.3π n
− 0.15 j 2πn πn
d (sin 0.3π n) / d (π n) 0.3 cos 0.3π n
hd (0T ) = lim = lim = 0.3
π n →0 d (π n) / d (π n) π n →0 1
hd (0) = 0.3
  sin 0.3πn
 h ( nT ) = n≠0
d
πn
Step 2 & 3: Multiply by 17-tap Hamming window (M=8) and make it acausal.
8
H NC ( z ) = ∑h
n = −8
d ( nT ) wh (n) z − n , H C = z −8 H NC ( z )

Page 9-12
EE 422G Notes Instructor: Cheung

Page 9-13

Anda mungkin juga menyukai