LABORATORY 5 DIGITAL FILTERS STRUCTURES · vector C which contains the coefficients of the ladder...
Transcript of LABORATORY 5 DIGITAL FILTERS STRUCTURES · vector C which contains the coefficients of the ladder...
5. DIGITAL FILTERS STRUCTURES
1
LABORATORY 5
DIGITAL FILTERS STRUCTURES
Infinite Impulse Response filters structures (for more theoretical details, please see the lecture)
Fie funcţia de transfer
0
1
1
Mk
k
k
Nk
k
k
b zB z
H zA z
a z
(0.1)
În domeniul timp, filtrul poate fi caracterizat prin ecuaţia cu diferenţe finite:
1
[ ] [ ] [ ]M N
k k
kk 0
y n = b x n k a y n k
(0.2)
Această ecuaţie permite calculul unui eşantion al ieşirii pe baza a M
eşantioane ale intrării şi a 1N eşantioane anterioare ale ieşirii. Modul în care este
calculată ieşirea (întâi partea nerecursivă şi apoi partea recursivă etc.) poate fi
reprezentat grafic sub forma unei structuri cu unităţi de înmulţire, adunare şi
elemente de întârziere.
5. DIGITAL FILTERS STRUCTURES
2
5.1.1. Forma directă
Pornind de la ecuaţia cu diferenţe finite (0.2) operaţiile prin care se
calculează ieşirea filtrului pot fi reprezentate în structuri de tipul forma directă 1
sau forma directă 2 ca în figurile 5.1 şi 5.2 prin simpla identificare a coeficienţilor
ka şi kb .
Figura 5.1. Direct form 1
5. DIGITAL FILTERS STRUCTURES
3
1z
0b [ ]y n
1z
1b
1z
2b
Nb
[ ]x n
1a
2a
Na
Figura 5.2 Direct form 2
5.1.2. The cascade form
Funcţia de transfer poate fi factorizată sub forma:
1 * 1 1 2
0, 0, 1, 2,
1 * 1 1 21 1 11, 2,
(1 )(1 )( )
(1 )(1 ) 1
P P Pk k k k k k
k
k= k= k=k k k k
b z z z z b b z b zH z = = H z
p z p z a z a z
(0.3)
unde kz sunt zerourile iar kp sunt polii funcţiei de transfer grupaţi în perechi
complex conjugate pentru obţinerea funcţiilor de transfer de ordin 2 cu coeficienţi
reali ( )kH z . Dacă funcţia de transfer are zerouri sau poli reali atunci se poate face
o descompunere şi cu polinoame de ordin 1. Rezultă o realizare în cascadă,
reprezentată în figura 5.3.
)(1 zH )(2 zH )(zH P
[ ]x n1[ ]y n 2[ ]y n [ ] [ ]Py n y n
Figura 5.3. Realizarea în cascadă
Fiecare din filtrele componente, având o funcţie de transfer de ordinul 2,
poate fi realizată în una din formele directe 1 sau 2.
5. DIGITAL FILTERS STRUCTURES
4
The MATLAB functions zp2sos, şi tf2sos allow to determine the 2nd
order transfer functions (Second Order Sections) for the cascade form.
Syntax:
[SOS,G]=tf2sos(B,A)
it returns a SOS matrix which contains the coefficients of the 2nd order sections
for the factorization of the transfer function ( )H z . B represents the vector of the
coefficients of the numerator ( )B z and A represents the vector of the
coefficients of the denominator ( )A z .
SOS is a matrix of the following form: SOS = [ b01 b11 b21 1 a11 a21
b02 b12 b22 1 a12 a22
...
b0L b1L b2L 1 a1L a2L ]
where each line of the matrix contains the coefficients of a 2nd order structure.
1 2
0, 1, 2,
1 2
1, 2,1
k k k
k
k k
b b z b zH z =
a z a z
G is a scalar which represents the global gain of the system. If G is not specified,
it is included in the first section.
[SOS,G]=zp2sos(Z,P,K)
it returns a SOS matrix which contains the coefficients of the 2nd order sections
for the factorization of the transfer function ( )H z . Z represents the vector of
zeros, P represents the vector of poles and K represents the gain of the pole-
zeros decomposition. The poles and zeros must be given in complex conjugated
pairs.
G is a scalar which represents the global gain of the system. If G is not specified,
it is included in the first section.
5.1.3. The parallel form
În acest caz se porneşte de la descompunerea în fracţii simple a funcţiei
( )H z . Presupunând coeficienţii funcţiei de transfer ,k ka b R , fracţiile simple (cu
numitor de gradul 1) au în general coeficienţi complecşi. Grupând însă fracţiile
5. DIGITAL FILTERS STRUCTURES
5
corespunzătoare perechilor de poli complex conjugaţi, rezultă funcţiile ( )pH z de
gradul 2, cu coeficienţi reali, , ,,k p k pa b R . Funcţia de transfer poate fi scrisă sub
forma:
1
0, 1,
1 21 11, 2,1
P Pp p
p
p pp p
b b zH z C C H z
a z a z
(0.4)
Se obţine schema din figura 5.4.
1[ ]y n
1( )H z
2 ( )H z
)(zH p
2[ ]y n
[ ]py n
[ ]y n
[ ]x n
C
Figura 5.4. The parallel form
The MATLAB function residuez achieves the decomposition in simple
fractions of the transfer function ( )
( )( )
B zH z
A z . It can be applied in 2 ways:
[R,P,K]=residuez(B,A)
it decomposes in simple fractions the function ( )
( )( )
B zH z
A z defined by the
coefficients vectors B and A as follows:
111 21 1
1
( )
( ) 1 1
N
N
B z r rk k z
A z p z p z
R and P are column vectors containing the residuez and poles, respectively.
5. DIGITAL FILTERS STRUCTURES
6
K isa line vector for the free terms (if the order of the numerator is greater than
the one of the denominator).
If jp is a multiple pole of order m, the decomposition in simple fractions will
contain terms of the form:
1 1
21 1 11 1 1
j j j m
m
j j j
r r r
p z p z p z
[B,A]=residuez(R,P,K)
it makes the transfer function ( )H z from the decomposition in simple fractions.
In this way, in order to obtain the decomposition in the parallel structure with
real coefficients, the following method can be applied (only if the poles are ordered
in complex conjugated pairs).
[r,p,k]=residuez(b,a)
[b1,a1]=residuez(r(1:2),p(1:2),[])
[b2,a2]=residuez(r(3:4),p(3:4),[])
etc...
5.1.4. The lattice form
Sinteza funcţiei de transfer a unui filtru RII:
( ) ( )
( )( ) ( )
B z Y zH z
A z X z (0.5)
în forma latice se face completând structura latice recursivă cu o structură în scară
(figura 5.5).
5. DIGITAL FILTERS STRUCTURES
7
1z 1z1z
[ ]x n
Nk 1k
Nk 1k1Nk
1 Nk
Nc1Nc 1c 0c
[ ]y n
2Nc
2[ ]y n
1[ ]y n
Figura 5.5. Lattice-ladder form
În figură apar pe lângă nodurile de intrare [ ]x n şi de ieşire [ ]y n încă două
noduri 1[ ]y n şi 2[ ]y n . Se demonstrează că funcţiile parţiale de transfer asociate
acestor două ieşiri sunt:
11
( ) 1( )
( ) ( )
Y zH z
X z A z (0.6)
1
22
( ) ( ) ( )( )
( ) ( ) ( )
NY z z A z A zH z
X z A z A z
(0.7)
Din ecuaţia (0.6) rezultă că în cazul unei funcţii de transfer numai cu poli
structura latice nu are şi structura în scară, iar ieşirea filtrului va fi 1[ ]y n .
În ecuaţia (0.7) s-a notat cu ( )A z polinomul reciproc al numitorului ( )A z
obţinut din polinomul ( )A z prin inversarea ordinii coeficienţilor.
1
1 0( ) N
N NA z a a z a z
(0.8)
Evident funcţia 2 ( )H z este o funcţie trece-tot şi aceasta poate fi sintetizată în
forma latice fără structura în scară, ieşirea filtrului fiind 2[ ]y n .
Sinteza structurii latice pentru o funcţie de transfer RII se face pornind de la
coeficienţii 0 1, ,..., Na a a ai numitorului ( )A z şi se obţin coeficienţii de reflexie
1,..., Nk k după algoritmul recursiv:
5. DIGITAL FILTERS STRUCTURES
8
,
,
, ,
1, 2
1 1,1
for = 0 :1:
end
for = : -1: 2
for = 1:1: -1
1
end
end
N j j
i i i
i j i i i j
i j
i
j N
a a
i N
k a
j i
a k aa
k
k a
Calculul coeficienţilor scară 0,..., Nc c se face, de asemenea, recursiv folosind
şi coeficienţii 0 1, ,..., Nb b b ai numărătorului ( )B z .
,
1
1, 2, ,0
N N
N
l l i i i l
i l
c b
l N N
c b c a
for
end
The MATLAB function tf2latc computes the coefficients of the lattice
structure.
Syntax:
[K,C]=tf2latc(B,A)
it returns the vector K which contains the reflection coefficients ik and the
vector C which contains the coefficients of the ladder structure ic for an IIR
filter with the coefficients of the numerator in vector B and the coefficients of
the denominator in vector A, normalized to 0a .
K=tf2latc(B)
5. DIGITAL FILTERS STRUCTURES
9
it returns the vector K which contains the reflection coefficients ik for a FIR
filter with the coefficients of the transfer function in vector B, normalized to 0b .
K=tf2latc(1,A)
it returns the vector K which contains the reflection coefficients ik for an IIR
filter only with poles, with the coefficients of the denominator in vector A,
normalized to 0a .
Remark. If from the computations one of the reflection coefficients equals 1, then the
function tf2latc will generate an error (because the term 21 ik which appears
in the denominator is 0).
The transfer function can also be obtained starting from the reflection coefficients
and the coefficients of the ladder structure, using the function latc2tf. For
details type help latc2tf.
Example:
Let an IIR filter have the following transfer function: 1 1 1 2
1 3 4
( ) (0.5 )(1 0.5 )(1 1.2 1.8 )( )
( ) 1 0.5 1.2 0.5
B z z z z zH z
A z z z z
Synthetize the structures for the cascade, parallel and lattice forms.
// The polynomial at the denominator is: a=[1 0.5 0 1.2 0.5];
// The polynomial at the numerator is obtained from the zeros of the transfer
function. z1=[-2; -0.5];
z2=roots([1 -1.2 1.8]);
// Because the first free term is 0.5, the polynomial must be multiplied by 0.5. b=0.5*poly([z1; z2])
b =
0.5000 0.2500 -0.5000 2.7500 1.5000
5. DIGITAL FILTERS STRUCTURES
10
// The cascade form [SOS,G]=tf2sos(b,a)
SOS =
1.0000 2.5000 1.0000 1.0000 1.5206 0.4564
1.0000 -1.2000 1.8000 1.0000 -1.0206 1.0955
G =
0.5
The cascade decomposition:
1 2 1 2
1 2 1 2 1 2
1 2.5 1 1.2 1.8( ) ( ) 0.5
1 1.52 0.456 1 1.02 1.095
z z z zH z G H z H z =
z z z z
// The parallel form [r,p,k]=residuez(b,a)
r =
-0.6541
-0.6329 + 0.1741i
-0.6329 - 0.1741i
-0.5800
p =
-1.1091
0.5103 + 0.9138i
0.5103 - 0.9138i
-0.4115
k =
3.0000
It can be noticed that there are complex poles and residuez. Because we want a
structure with real coefficients, we will group the pair of complex conjugated
values into a 2nd order transfer function with real coefficients:
[b2,a2]=residuez(r(2:3),p(2:3),[])
b2 =
-1.2659 0.3278
a2 =
1.0000 -1.0206 1.0955
5. DIGITAL FILTERS STRUCTURES
11
The parallel decomposition:
1 2 4
1 1
21 4
1
1 1 2 1
( )( )
( )1 1
0.65 1.26 0.32 0.583
1 1.1 1 1.02 1.09 1 0.41
r B z rH z k
A zp z p z
z
z z z z
// The coefficients of the lattice form are obtained directly: [k,c]=tf2latc(b,a)
k =
0.3061
-0.2794
1.2667
0.5000
c =
-2.3898
-1.4985
-0.2333
2.0000
1.5000
Remarks:
The exact values of the coefficients obtained above have a much greater
number of decimal digits than the ones displayed in MATLAB in short format.
In practice, because of the representation of numbers on a finite number of bits,
differences (truncations) of the coefficients’ values with respect to the
simulated ones.
In the previous example it can be seen that the system is unstable, either by
noticing that one of the poles has a modulus greater than 1 or by using the
Schür-Cohn test for the reflection coefficients k and noticing that the coefficient
3k is greater than 1.
E1. Exercises: Given the IIR systems with the following transfer functions:
1. 1 2 3 4
1 2 3 4
2 3.6 1.3 0.4 0.2( )
1 2.8 3.15 1.75 0.425
z z z zH z =
z z z z
5. DIGITAL FILTERS STRUCTURES
12
2. 1 2 3 3
2 4 6
(1 2 3 4 )(1 )( )
1 0.8 0.66 0.35
z z z zH z
z z z
3. 1 2 3 4
1( )
1 1.27 1.19 1.18 0.4H z
z z z z
4. 1 2 3
1 2 3
0.4 0.7 0.175( )
1 0.175 0.7 0.4
z z zH z
z z z
5. 0.95 / 4 0.95 / 4 1.05 / 4 1.05 / 4
/ 4 / 4 / 4 / 4
( 0.9 )( 0.9 )( 0.9 )( 0.9 )( )
( 0.95 )( 0.95 )( 0.9 )( 0.9 )
j j j j
j j j j
z e z e z e z eH z
z e z e z e z e
Synthetize and draw the structures for the direct 1 and 2, cascade, parallel, lattice.