0% found this document useful (0 votes)
88 views

Example: Design A Low Pass Filter, Butterworth, With 3dB Bandwith of 500Hz

Here are the steps to design an IIR filter using Matlab: 1. Use BUTTORD, CHEB1ORD or CHEB2ORD to design the analog prototype filter and determine the order N. Specify the passband and stopband edge frequencies (p, s) and desired passband ripple/stopband attenuation. 2. Use BUTTAP, CHEB1AP or CHEB2AP to generate the poles and zeros of the analog prototype filter based on the order N from step 1. 3. Use BUTTER, CHEBY1 or CHEBY2 to transform the analog prototype filter into digital IIR filter coefficients based on the cutoff frequency 

Uploaded by

Fahmi Ihza
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)
88 views

Example: Design A Low Pass Filter, Butterworth, With 3dB Bandwith of 500Hz

Here are the steps to design an IIR filter using Matlab: 1. Use BUTTORD, CHEB1ORD or CHEB2ORD to design the analog prototype filter and determine the order N. Specify the passband and stopband edge frequencies (p, s) and desired passband ripple/stopband attenuation. 2. Use BUTTAP, CHEB1AP or CHEB2AP to generate the poles and zeros of the analog prototype filter based on the order N from step 1. 3. Use BUTTER, CHEBY1 or CHEBY2 to transform the analog prototype filter into digital IIR filter coefficients based on the cutoff frequency 

Uploaded by

Fahmi Ihza
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/ 22

46

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.
47
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  +1 Chebychev 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)
48
P  T3 = +1 P  T3 = +1
T3 ( x)
B D
P( x) − T3 ( x) +
A
P( x) + C
− D


A C
P  T3 = −1 P  T3 = −1 root
B root root

But: has degree 2 …


P( x) − T3 ( x) = 4 x 3 + ax 2 + bx + c − 4 x 3 + 3x
… 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.
49

Chebychev Filter:
1
| H ()| =
2

 
1 +  TN 
2 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
50
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
r1,2 =
2

 =  
 2
  

 
 k= + (2 k + 1) , k = 0,..., N − 1
2 2N

s-plane
51

Example: design a Chebychev low pass filter with the following specs:
• passband Fp = 500 Hz, with a 1dB ripple,
• stopband Fs = 1000Hz, with attenuation of at least 40dB.
Step 1: determine  , p . The passband frequency  = 1000
p

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 −  + 1 −  (1 +  ) /   
2
2
2
2 2
2

log( /  ) + ( /  ) − 1
s p s p
2

with 2 = 0.01, to obtain N = 4 


p
52

Frequency Transformations
We can design high pass, bandpass, bandstop filters from transformations of low pass filters.
Low Pass to High Pass: c2  c 2 
s → H
 j 

| H ()| s

− c c  − c c 

same value at c

 c2   c 
H  = H   = H ( − j c )
 j c   j 
53

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 )
54
Low Pass to Band Stop

− c c

− u − l l u

s( u −  l )
s → c 2
s + cl
55
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) HT ( s) = H ( F ( s)) =
we obtain
( F ( s) − p )...( F ( s) − p )
1 n

F ( s) = zk , 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 56

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 c from specifications

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).
57
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  = 26  103 rad / sec
3
 10 

 s = 2(40  10 ) tan  = 58  103 rad / sec
3
 5
58

2 1
H ( ) = 2N
Step 3: choose (say) Butterworh Filter 
2 

1+   
 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
59

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/)
60

Magnitude and Phase Plots:


61

Example 3
• A filter is described by the following equation:
• y(n)=0.5x(n) + 0.2x(n-1) + 0.5y(n-1) + 0.2y(n-2),
with initial condition y(-1)=y(-2) = 0
• What kind of filter is it?
• Plot the filter’s transfer function on the z plane
• Is the filter stable?
• Plot the filter’s unit step response
• Plot the filter’s unit impulse response
62

Software Implementation of
FIR filters
63

Fixed-Point Binary Representation


• Representation of a number with integer and
fractional part: (d n −1d n − 2 ...d 0 .d −1d − 2 ...d − k ) 2
n −1
N= d r
i =− m
i
2

• This is denoted as Qnm representation


• The binary point is implied
• It will affect the accuracy (dynamic range and
precision) of the number
• Purely a programmer’s convention and has no
relationship with the hardware.
64

EFFECTS OF FINITE FIXED-POINT


BINARY WORD LENGTH
• Quantization Errors
• ADC
• Coefficients
• Truncation
• Rounding
• Data Overflow
65

Coefficient Quantization Error

• Effects on FIR filters


• Location of zeroes changes
• Therefore, frequency response changes
• Effects on IIR filters
• Location of poles and zeroes change
• Could move poles outside of unit circle, leading to unstable implementations
66

Overflow error

• signals and coefficients normalized in the range of


−1 to 1 for fixed-point arithmetic, the sum of two B-
bit numbers may fall outside the range of −1 to 1.
• Severely distorts the signal
• Overflow handling
• Saturation arithmetic
• “Clips” the signal, although better than overflow
• Should only be used to guarantee no overflow, but should not be
the only solution
• Scaling of signals and coefficients
67

Coefficient representation

• Fractional 2’s complement (Q) representation is


used
• To avoid overflow, often scaling down by a power of
two factor (S) (right shift) is used.
• The scaling factor is given by the equation:
S=Imax(|h(0)|+|h(1)|+|h(2)|+…)
• Furthermore, filter coefficient larger than 1, cause
overflow and are scaled down further by a factor B,
in order to be less than 1

You might also like