0% found this document useful (0 votes)
86 views44 pages

Lecture-2-IIR Digital Filter Design-DG

Here are the key steps to design analog filters: 1. Specify the filter specifications in terms of passband ripple p, stopband ripple s, cutoff frequency c, and transition bandwidth . 2. Choose a filter approximation (Butterworth, Chebyshev, etc.) based on the required filter response. 3. Determine the filter order N based on the approximation and required specifications. 4. Use filter design equations/tables to find the element values for the chosen filter approximation. 5. Realize the designed filter using common analog filter structures like Butterworth, Chebyshev, etc.

Uploaded by

Alina Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views44 pages

Lecture-2-IIR Digital Filter Design-DG

Here are the key steps to design analog filters: 1. Specify the filter specifications in terms of passband ripple p, stopband ripple s, cutoff frequency c, and transition bandwidth . 2. Choose a filter approximation (Butterworth, Chebyshev, etc.) based on the required filter response. 3. Determine the filter order N based on the approximation and required specifications. 4. Use filter design equations/tables to find the element values for the chosen filter approximation. 5. Realize the designed filter using common analog filter structures like Butterworth, Chebyshev, etc.

Uploaded by

Alina Raza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

IIR Digital Filter Design

1
Pole Zero Placement Method
Second-Order BPF Design
Poles are complex conjugate with magnitude r and the angle 𝜃
Zeros are placed at z=1 corresponding to DC (zero frequency), and
z= -1, corresponding to the folding frequency

Pole-zero
placement for a
second-order
narrow BPF.

scale to have unit pass-band BPF gain 2


Poles amplitude Determines Pole Zero Placement Method
the 3 dB bandwidth
Second-Order BSF (Notch) Design
The zeros are placed on the unit circle with
the same angles with respect to poles.

Poles angle
Determines the
center frequency

scale factor to adjust the BRF


so it has a unit pass-band gain

Example  Sampling rate = 8,000 Hz


Design a second-order notch filter with  3 dB bandwidth: BW = 100 Hz
 Narrow stop-band centered at f0 = 1,500 Hz

3
Pole Zero Placement Method
𝑓𝑠
First-Order LPF Design
Pole placed on When Cut-off frequency 𝑓𝑐 < 4 Pole placed on When Cut-off frequency 𝑓𝑐 > 𝑓𝑠 4
the real axis the real axis

The zero is placed


at (𝑧 = −1)

unit pass-band
Transfer function gain scale factor

Example
transfer function of first-order LPF is required to satisfy: unit gain scale factor:

transfer function:
𝑓𝑠
Since cut-off frequency = 100 Hz < 4
= 2000𝐻𝑧, pole at:

4
Pole Zero Placement Method
𝑓𝑠
First-Order HPF Design
Pole placed on When Cut-off frequency 𝑓𝑐 < 4 Pole placed on When Cut-off frequency 𝑓𝑐 > 𝑓𝑠 4
the real axis the real axis

The zero is placed


at (𝑧 = +1)

unit pass-band
Transfer function gain scale factor

Example
transfer function of first-order HPF is required to satisfy: unit gain scale factor:

transfer function:
𝑓𝑠
Since cut-off frequency = 3800 Hz > 4
= 2000𝐻𝑧, pole at

5
IIR Filter realization
Example: Realize the first-order digital high-pass Butterworth filter using
a direct-form I realization.

Solution:
Filter coefficients:

DSP equation:

Implementation:

6
Application1: 60 –Hz Hum Eliminator
Hum noise: created by poor power supply or electromagnetic interference and characterized
by a frequency of 60 Hz and its harmonics.

Eliminate the 60-Hz hum


frequency with its second
and third harmonics in most
practical applications.

We can do this by cascading 3


notch filters having frequencies of
60 Hz, 120 Hz, and 180 Hz,
respectively.

7
Application2: ECG Pulse
The ECG signal is produced by the electrical activity of the human heart, it is characterized by five peaks and
valleys P, Q, R, S, and T.

The properties of the QRS


complex, (rate of occurrence
and times, heights, and widths,
provide information to
cardiologists concerning various
pathological conditions of the
heart.

ECG + Hum ⟶ makes difficult


to analyze.

8
Heart Beat Detection Using ECG Pulse

• Initial corrupted ECG data (with 60-Hz


interference and its 120 and 180 Hz
harmonics, and muscle noise).
• The 60-Hz interference and its
harmonics of 120 and 180 Hz have been
removed
• Result after the band-pass filter
• Original ECG signal occupies the
frequency range from 0.01 Hz to 250 Hz
(used for diagnostic-quality ECG). 9
Example: ECG Signal pre-processing
Problem: Design the ECG signal pre-processing system for heart beat rate detection

Solution:
60-Hz eliminator design (notch frequency of 60Hz)

10
Example: ECG Signal pre-processing -contd
transfer functions and the difference equations

Frequency responses of three cascaded notch filters.

11
Example: ECG Signal pre-processing -contd
The second-stage design using the BLT

12
See the meaning of this:

 T 
  2tg 1

 2 
  
2   
tg 


T 2 

it is a frequency mapping between analog frequency and digital freqiency.

 c c 
 
0

  c 0 c  
Example: we want to design a digital low pass filter with a bandwidth Fo  8kHz
and a sampling frequency Fs  24 kHz
. Use the Bilinear Transformation.

Solution:

• Step 1: specs in the digital freq. domain c  ( 2 )(8 / 24)  2 / 3 rad


• Step 2: specs of the analog filter to be digitized:

 c 
 c  2 Fs tg    ( 2)( 24  103 ) tg ( / 3)  8313
.  103 rad / sec
 2 

or equivalently Fc  13.23kHz

• Step 3: design an analog low pass filter (more later) with a bandwith ; Fc  13.23kHz
• Step 4: apply Bilinear Transformation to obtain desired digital filter.
Design of Analog Filters

| H ()|2
Specifications: 1
1  2

1
2

2 2

p c s 

pass transition stop


band band band
Two Major Techniques: Butterworth, Chebychev

Butterworth:
1 1
| H ()| 
2
2N  2N
    
1   1  
2

 c   p 

Specify  ,  p from passband, determine N from stopband:


 1  2 2 
log 2 2 
| H ( s )| 2 1
 s 
2N  2 2  N 
  2 
 s 
1  
2
 2 log 
 p   p 
Poles of Butterworth Filter:

1 1
| H ()|  H ( s) H (  s) s j
2
 H ( s) H (  s)   
2N

s  2 N

1   1  2 
 c  
s  c 
j
which yields the poles as solutions

  k 2  
 s2

1 j ( 2 k 1)
 N
j j
2  1 s  j c e 2N
 ce 2
e 2N
, k  0,...,2 N  1
c

N=2
and choose the N poles in the stable region.
+ +
poles

+ +
s-plane
Example: design a low pass filter, Butterworth, with 3dB bandwith of 500Hz and 40dB attenuation at 1000Hz.
Solution:
 c  1000 ;  s  2000 ,

solve for N from the expression

1 1
 2 N  0.01
2

 s 
2N
1 2
1  
 c 
| H (  )|dB
log(104  1)
N   6.64  N  7
2 log(2)

poles at
sk  1000 e j (  / 2  ( 2 k 1)  /14 ) , k  0,...,6

Chebychev Filters.
Based on Chebychev Polynomials: TN ( x )  cos( Nt ) x  cos( t )
T0 ( x )  cos( 0)  1, T3 ( x )

T1 ( x )  cos( t ) x  cos( t )
 x,
T2 ( x )  cos( 2t )  2 cos2 ( t )  1 x  cos( t )  2 x 2  1,

TN 1 ( x )  2 xTN ( x )  TN 1 ( x )
x
Property of Chenychev Polynomials:
within the interval  1  x  1Chebychev polynomials have least maximum deviation from 0 compared to polynomials
of the same degree and same highest order coefficient

P( x )  4 x 3  ax 2  bx  c

T3 ( x )  4 x 3  3x

x
Why? Suppose there exists P( x )  4 x 3  ax 2  bx  c with smaller deviation then T3 ( x )
P  T3  1 P  T3  1
T3 ( x )
B D
P ( x )  T3 ( x ) 
A
 C

P( x )
D


A C
P  T3  1 P  T3  1 root B root root

But: P( x )  T3 ( x )  4 x 3  ax 2  bx  c  4 x 3  3x has degree 2 …

… and it cannot have three roots!!!

So: you cannot find a P(x) which does better (in terms of deviation from 0) then the Chebychev polynomial.
Chebychev Filter:

1
| H ()|  2

  
1   TN2 2
 
 p 
1
Since TN (1)  1 (easy to show from the definition), then | H (  p )| 
2
1  2

| H ()|2 1
1  2


p
Design of Chebychev Filters:
Formulas are tedious to derive. Just give the results:

Given:  p the passband, and


 which determines the ripple in the passband,
compute the poles from the formulae

 2 1
1
 1   1 N

2

   

r1, 2
2
  

 
 k  ( 2 k  1) , k  0,..., N  1
2 2N

s-plane
Example: design a Chebychev low pass filter with the following specs:
• passband Fp  500 Hz , with a 1dB ripple,
• stopband Fs  1000 Hz , with attenuation of at least 40dB.

Step 1: determine  ,
. p The passband frequency  p  1000
For 1dB ripple,
1
 

1 2
20 log 
 1  2 

 10 log(1   2 )  1dB   0.5088
| H ()|
Step 2: determine the order N. Use the formula

N 
log  1  2 2  1  2 2 (1   2
/  2


log (  s /  p )  ( s /  p ) 2  1 
with 2  0.01 , to obtain N 4 
p
Frequency Transformations
We can design high pass, bandpass, bandstop filters from transformations of low pass filters.

Low Pass to High Pass: c 2  c2 


s  H
 j 

| H ()| s

 c c   c c 

same value at c

 c 2   c 
H   H   H (  j c )
 j c   j 
Low Pass to Band Pass:

 c c

 u  l l u
s2   l  u
The tranformation s  c
s(  u   l )
maps
 l 2  l u
s  j l  c   j c
j l ( u   l )
 u 2  l u
s  j u  c   j c
j u ( u   l )
Low Pass to Band Stop

 c c

 u  l l u

s(  u   l )
s  c 2
s  cl
How to make the transformation:
Consider the transfer function
K ( s  z1 )( s  z2 )...( s  zm )
H ( s)  , mn
( s  p1 )( s  p2 )...( s  pn )
K  F ( s)  z1 ...  F ( s)  zm 
then with s  F ( s)we obtain HT ( s)  H  F ( s)  
 F ( s)  p ...  F ( s)  p 
1 n

F ( s)  z k , k  1,..., m
with zeros and poles solutions of F ( s)  p j , j  1,..., n
also n-m extra zeros at s where F ( s)  

 
 


IIR filter design using Matlab
In Matlab there are three functions for each class of filters (Butterworth, Chebytchev1, Chebytchev2):
BUTTAP CHEB1AP CHEB2AP Poles and Zeros of Analog Prototype Filter
BUTTER CHEBY1 CHEBY2 Numerator and Denominator from N and c
BUTTORD CHEBY1ORD CHEBY2ORD N and from specifications c

Example. We want to design an IIR Digital Filter with the following specifications:
Pass Band 0 to 4kHz, with 1dB ripple;
Stop Band > 8kHz with at least 40 dB attenuation
Sampling frequency 40kHz
Type of Filter: Butterworth.
Using Matlab:
>> [N, fc]=butterord(fp, fs, Rp, Rs); % fp, fs=passband and stopband freq relative to Fs/2
>> [B, A]=butter(N, fc); % B, A vectors of numerator and denominator coefficients.
In our case:
[N, fc]=butterord(4/20, 8/20, 1, 40), would yield N=7, fc=0.2291;
[B, A]=butter(7, 0.2291), would yield the transfer function B(z)/A(z).
Let’s verify these numbers:
Step 1: specifications in the digital frequency domain:

4 
 p  2  rad band pass freq
40 5
8 2
s  2  rad stop band freq
40 5

Step 2: specifications for analog filter from the transformation   2 Fs tan 
 2
 
p  2( 40  10 ) tan
3
  26  103 rad / sec
 10 

 s  2( 40  10 ) tan   58  103 rad / sec
3
 5
2 1
Step 3: choose (say) Butterworh Filter H ( )  2N
  
1  
2

 p 

with  p  26  103 rad / sec and  from the ripple specification


1
 1  2
20 log10  2   1    0.5
 1  

Step 4: determine order N from attenuation of 40dB

1
10 log10 2N
 40
 s 
1  0.5  2 
 
 p 

s 58
with  yields N=7
p 26
Step 5: finally the cutoff frequency, from the equation

2 1 1
H ( c )  
c
14
2  2
1  0.5  
 26  103 

Which yields  c  28.7  103 rad / sec , corresponding to a digital frequency

 28.7 
c  2atan   0.6889 radians
 2  40 

Step 6: the desired Filter is obtained by the function


[num, den] = butter( 7 , 0.6889/)
Magnitude and Phase Plots:
IIR Direct Form I
• Rational transfer function leads to a direct implementation:

x[n] y[n]
+
Z-1 b0 Z-1

x[n-1] y[n-1]
-a1 Z-1
Z-1 b1

x[n-2]
y[n-2]
b2
-a2

y[n]  b0 x[n]  b1 x[n  1]  b2 x[n  2]  a1 y[n  1]  a2 y[n  2]

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 33


IIR Direct Form II
• Re-order feed-forward and feed-back sections:

x[n] + + y[n]
b0
Z-1
-a1 b1
Z-1
-a2 b2

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 34


Implementation Issues
• Coefficient quantization
• Precision usually limited to word size (24 bits on 56300)
• Want coefficients to be large in magnitude to use as many significant bits as
possible
• Roundoff error (least significant bits lost)
• Result from big accumulator (e.g., 60 bits) must be stored back as a single
word (24 bits)
• Roundoff error can accumulate due to recursive (feedback) structure of IIR
filters

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 35


Implementation Issues (cont.)
• Overflow error (most significant bits lost)
• Occurs when arithmetic result is too large to fit in accumulator or in storage
word size
• Overflow can linger due to feedback
• Requires scaling of the input and output
• Coefficient quantization, roundoff error, and overflow error behavior
can vary from one filter structure to another: choose wisely…

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 36


Engineering an IIR filter
• Verify filter performance with quantized coefficients
• Assess roundoff error by modeling the truncation as a noise source in
the filter structure. Determine the transfer function from each
roundoff noise source to the output.
• Calculate overflow situations by looking for peaks in frequency
response from input to each accumulation point in the filter.

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 37


nd
2 -order Sections
• Generally implement high-order IIR filters as a sum or cascade of 2nd-
order filters.
• This reduces the sensitivity of the overall response to the precision
of each coefficient
• Each 2nd-order filter (biquad) implements two zeros and two poles
(real or complex conjugate)

b0  b1 z 1  b2 z 2
H ( z) 
1  a1 z 1  a 2 z  2

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 38


nd
2 -order Sections (cont.)
• High-order polynomial is factored to find poles and zeros
• Poles and zeros are grouped in pairs—usually try to group in such a
way that minimizes peak gain of each section
• If cascaded, 2nd-order sections are usually ordered from lowest gain
to highest gain to minimize overflow likelihood
• Scaling may be needed for overall response or for each section
individually (computation vs. quality)

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 39


Bilinear Transform
• Design algorithms for continuous-time filters are well known, while
Nyquist issues make discrete-time IIR filter design somewhat
complicated
• Concept: use a continuous-time filter design, then transform s-plane
poles and zeros to the z-plane
• Need: an invertible mapping function between s and z planes

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 40


Bilinear Transform (cont.)
• Mapping function must:
• Take j axis in s-plane and map it to unit circle in z-plane (warped frequency
response)
• Take left half of s-plane and map to interior of unit circle (stable poles
remain stable poles)
• Have a smooth, monotonic warping
• Customary function:

1 s
z   (s) 
1 s
ECEN4002 Spring 2003 IIR and EQ R. C. Maher 41
Bilinear Transform (cont.)

• Inverse mapping is:


z 1
s  1
( z) 
z 1
• Frequency warping: z=ej

sin 2   
j  j  j tan  
cos 2  2

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 42


Bilinear Transform (cont.)
• Plan:
• Determine required critical frequencies and levels in digital domain, then use
bilinear transform to find analog specs
• Design continuous-time filter meeting warped specs
• Inverse transform to get resulting digital design
• Verify, then alter and repeat process as necessary

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 43


Lab Exercise #4
• MATLAB functions: butter, scope, iirtable
• Write IIR filter function using output from iirtable. Use a “do loop” with
iterations determined from iirtable.
• Verify with file I/O and real time observation
• Get working, then consider optimizations
• Parametric equalizer (EQ) filter
• Tune gain, center freq, and bandwidth
• Adjust parameters with debugger and verify

ECEN4002 Spring 2003 IIR and EQ R. C. Maher 44

You might also like