Basics on Digital Signal Processing
z - transform - Digital Filters
Vassilis Anastassopoulos
Electronics Laboratory, Physics Department, University of Patras Outline of the Lecture
1. The z-transform 2. Properties 3. Examples 4. Digital filters 5. Design of IIR and FIR filters 6. Linear phase
2/31 z-Transform
2 N 1 N 1 j nk n X (k) x(n) e N X (z) x(n) z n0 n0 Time to frequency Time to z-domain (complex)
Transformation tool is the Transformation tool is complex wave z e j e j j j2k / N e e With amplitude ρ changing(?) with time With amplitude |ejω|=1
The z-transform is more general than the DFT
3/31 z-Transform For z=ejω i.e. ρ=1 we work on the unit circle N 1 X (z) x(n) z n And the z-transform degenerates n0 into the Fourier transform.
I -z z=R+jI |z|=1
R
The DFT is an expression of the z-transform on the unit circle.
The quantity X(z) must exist with finite value on the unit circle i.e. must posses spectrum with which we can describe a signal or a system.
4/31 z-Transform convergence
We are interested in those values of z for which X(z) converges. This region should contain the unit circle.
I Why is it so?
|a| N 1 N 1 X (z) x(n) zn x(n) (1/zn ) n0 n0 R At z=0, X(z) diverges ROC
The values of z for which X(z) diverges are called poles of X(z).
5/31 z-Transform example
Which is the z-transform and the ROC of a discrete time sequence x(n)=an for n0 and a<1 ?
I x(n) 1 a |a| a2 a3 a4 R
n ROC
N 1 X (z) x(n) zn an zn (az1)n n0 n0 n0 -1 1 z which for |az |<1 or |z|>|a| converges to X (z) 1 az1 z a The pole z=a, is never included in the ROC
6/31 Poles and zeros of X(z)
I Poles: X(z)= Zeros: X(z)=0
For infinite sequences, X(z) converges |a| everywhere outside the circle with radius the pole with maximum value. R
ROC For finite sequences, X(z) converges everywhere except at z=0
x(n) 5 3 3 X(z) x(n)z n z 1 3z 2 5z 3 3z 4 z 5 1 1 n n
For stable, causal digital systems the region of convergence includes the Unit Circle so that the system possesses spectrum
7/31 z-Transform general form
a a z1 a z2 a zN k(z z )(z z )(z z ) 0 1 2 N X (z) 1 2 N X (z) 1 2 M b0 b1z b2z bN z (z p1)(z p2 )(z pN )
Those values of z (zi) that make the nominator zero are called zeros.
While the poles are the values of z (pi) that make the denominator zero and thus X(z) diverges.
For stable, causal digital systems the region of convergence includes the Unit Circle so that the system possesses spectrum
H(e jT ) H(z) h(n)z n h(n)e jT ze jT n ze jT n
8/31 Inverse z-Transform
A simple way to evaluate the signal from the X(z) is to perform the division
1 2z 1 z 2 X(z) 1 z 1 0.356z 2
X(z) 1 3z 1 3.6439z 2 2.5756z 3
The signal is x(0)=1, x(1)=3, x(2)=3.6439, x(3)=2.5756
9/31 z-Transform properties
x1(n) X1(z) Linearity x2 (n) X 2 (z)
ax1(n) bx2 (n) aX1(z) bX 2 (z)
x(n) X (z) Delay or Shift x(n m) zm X (z)
Convolution y(n) h(k)x(n k) Y(z) H(z)X(z) k
10/31 z-Transform and digital systems
N M y(n) ak x(n k) bk y(n k) k0 k1
x(n) x(n-1) x(n-2) x(n-Ν+1) x(n-Ν) Ts Ts Ts
a0 a1 a2 aΝ-1 aΝ
y(n) N + k ak z k0 H (z) N bΜ bΜ-1 b2 b1 k 1 bk z k1 T T T y(n-Μ) s y(n-Μ+1) y(n-2) s y(n-1) s
11/31 Digital system z-Transform derivation
N M y(n) ak x(n k) bk y(n k) z-transform both sides k0 k1 N M Interchange zn y(n) zn a x(n k) zn b y(n k) k k summations n0 n0 k0 n0 k1
N M n n Y (z) ak z x(n k) bk z y(n k) Replace transforms k0 n0 k1 n0 N M Y (z) ak X (z k) bkY (z k) Shift property k0 k1 N M k k Common factors Y(z) ak z X(z) bk z Y(z) k0 k1 N M k k Y (z) X (z)ak z Y (z)bk z k0 k1
12/31 Digital system z-Transform derivation
M N k k Common factors Y (z) Y (z)bk z X (z)ak z k1 k0
M N k k Y (z)(1 bk z ) X (z) ak z x(n) x(n-1) x(n-2) x(n-Ν+1) x(n-Ν) Ts Ts Ts k1 k0
a0 a1 a2 aΝ-1 aΝ N k ak z y(n) Y (z) + k0 H(z) Frequency X (z) N 1 b z k k bΜ bΜ-1 b2 b1 k1
T T T y(n-Μ) s y(n-Μ+1) y(n-2) s y(n-1) s N M y(n) ak x(n k) bk y(n k) Time k0 k1
13/31 Application
Find the impulse response h(n) and the input-output relationship of the filter described by 1 z 1 H(z) 1 0.5z 1 Examine the stability of the filter and find its frequency response.
Solution -1 Y(z) 1 z 1 x(n) z H(z) X(z) 1 0.5z 1 1 1 Z1 -1 Y(z) 0.5Y(z)z X(z) X(z)z y(n) y(n) 0.5y(n 1) x(n) x(n 1) -0.5 y(n) x(n) x(n 1) 0.5y(n 1) z-1 h(n) is obtained from the terms of the polynomial which results after the division (1 z 1 ) / (1 0.5z 1 ) 11.5z 1 0.75z 2 0.375z 3
14/31 Application
Im 1 z 1 H(z) Stable 1 0.5z 1 |z|=1 1 Re
Frequency response using MATLAB
5 2
4.5 1.8
4 1.6
3.5 1.4
3 1.2
2.5 1 Phase
Magnitude 2 0.8
1.5 0.6
1 0.4
0.5 0.2
0 0 0 0.1 0.2 0.3 0.4 0 0.1 0.2 0.3 0.4 Frequency Frequency
15/31 Frequency on the Unit Circle
π/2 or Fs/4 Im z=ejωt |z|=1 1 z 1 π or F /2 H(z) s 0 1 0.5z 1 Re
The region from 0 to π corresponds to the region 0-
Fs/2 of the Frequency response
16/31 Digital Filters
•They are characterized by their Impulse Response h(n), their Transfer Function H(z) and their Frequency Response H(ω).
•They can have memory, high accuracy and no drift with time and temperature.
•They can possess linear phase.
•They can be implemented by digital computers.
17/31 Digital Filters - Categories
N M IIR y(n) a(k)x(n k) bk y(n k) k0 k1 N k ak z x(n) x(n-1) x(n-2) x(n-Ν+1) x(n-Ν) Ts Ts Ts k0 H(z) M 1 b z k k a a a a a k1 0 1 2 N-1 N
y(n) +
bΜ bΜ-1 b2 b1
T T T y(n-Μ) s y(n-Μ+1) y(n-2) s y(n-1) s
18/31 Digital Filters - Categories
N N y(n) h(k)x(n k) a(k)x(n k) FIR k0 k0 N N k k H(z) ak z h(k)z k0 k0
x(n) x(n-1) x(n-2) x(n-Ν+2) x(n-Ν+1) Ts Ts Ts
aΝ-2 ή a ή a0 ή a1 ή a2 ή Ν-1 h(0) h(1) h(2) h(Ν-2) h(Ν-1)
y(n) + •Stable •Linear phase
19/31 Digital Filters - Examples
a a z 1 a z 2 0 1 2 1.5 1 H(z) 1 2 1 b1z b2 z 0 1 a0=0.498, a1=0.927, -1 a2=0.498, b1=-0.674
b2=-0.363. 0.5 IIR Phase IIR Magnitude -2 0 -3 0 0.1 0.2 0.3 0.4 0 0.1 0.2 0.3 0.4 Frequency Frequency 11 1.5 4 H(z) h(k)z k 2 k0 1 0 h(1)=h(10)=-0.04506
0.5 FIR Phase
h(2)=h(9)=0.06916 FIR Magnitude -2
h(3)=h(8)=-0.0553 0 -4 0 0.1 0.2 0.3 0.4 0 0.1 0.2 0.3 0.4 h(4)=h(7)=-.06342 Frequency Frequency
h(5)=h(4)=0.5789
20/31 IIR filter design
Design using the Bilinear z-transform, BZT
Design using the position of poles and zeros on the unit circle
Fs/4 Im •The frequency response is zero at the points of zeros |z|=1 Fs/2 1 0 or Fs •The frequency response takes a peak at the position of poles. -Fs/2 •In order to have real coefficients of the filter, the poles must appear in pairs. The 3F /4 s same happens for the zeros as well.
21/31 IIR Filter Design - position poles and zeros on the unit circle
Design a band-pass filter with the following specifications Sampling frequency 1000Hz, full rejection at dc and 500 Hz, Narrow pass-band at 250 Hz, 20Hz 3dBs bandwidth.
18 Im 16
14
12 |z|=1
10 1
8 Magnitude Re 6
4
2
0 0 0.1 0.2 0.3 0.4 Frequency
ο Zeros at 0 and Fs/2 or 180 (dc 0, 500/1000 Fs/2). ο ο Poles at 250/1000 Fs/4 or 90 and complex conjugate at -90 The radius of poles should be smaller than 1 (stability)
r 1 (bw / Fs ) 1 (20 /1000) 0.937
22/31 IIR Filter Design - position poles and zeros on the unit circle
x(n) Im z-2
|z|=1 y(n) 1 Re 0.87 z-2 y(n) x(n) x(n 2) 0.877969y(n 2) r 1 (bw/ Fs ) 1 (20/1000) 0.937 (z 1)(z 1) z2 1 1 z 2 H(z) (z re j / 2 )(z re j / 2 ) z2 0.877969 1 0.877969z 2
18 2
16 1.5
14 1
12 0.5 10 0
8 Phase Magnitude -0.5 6
-1 4
2 -1.5
0 -2 0 0.1 0.2 0.3 0.4 0 0.1 0.2 0.3 0.4 Frequency Frequency
23/31 FIR filters
N N N N y(n) h(k)x(n k) a(k)x(n k) k k H(z) ak z h(k)z k0 k0 k0 k0
x(n) x(n-1) x(n-2) x(n-Ν+2) x(n-Ν+1) Ts Ts Ts
aΝ-2 ή a ή a0 ή a1 ή a2 ή Ν-1 h(0) h(1) h(2) h(Ν-2) h(Ν-1)
y(n) + Design Methods •Stable • Optimal filters • Windows method •Linear phase • Sampling frequency
24/31 Main categories of ideal filters
Low-pass Band-pass High-pass |Η(ω)| |Η(ω)| |Η(ω)|
1 1 1
0 ωc π 2π 0 ωc1 ωc2 π 2π 0 ωc π 2π
Η(ω) Η(ω) j j 0 π 2π -j
0 π 2π Differentiator Hilbert Transformer
25/31 FIR filter design – basic concept
1 h (n) H ()e jn d D 2 D
1 c e jn d 2 c 2 f sin(n ) c c nc
c / 2 1 sin(n / 2) The filter coefficients result from the Inverse Fourier h(n) Transform of the Desired Frequency Response. 2 (n / 2)
26/31 FIR filter design – Windows method
|HD(ω)| 0.5 hD(n) 1
...... -π -π/2 0 π/2 π
Ts |H (ω)| 0.5 t ht(n) 1 Gibbs phenomenon
-π 0 π -8 0 8
|W(ω)| 1 w(n) 1 Hamming Window 2n a (1 a)cos( ) wR (n) N -π 0 π -8 8 0
|H(ω)| 0.5 h(n) 1
-π 0 π -8 8
27/31 FIR filter design – Optimal filters
Parks and McClellan method. Distributes Approximation error from the discontinuity all over the frequency band.
28/31 FIR filter design – Comparisons
0
0 -20
-10 -40
-20 -60 Magnitude
-30 -80
-40 0 100 200 300 400 500 Frequency
-50 5 Magnitude
-60
-70 0 Phase -80
-90 0 100 200 300 400 500 -5 Frequency 0 100 200 300 400 500 Frequency
0.4
Windows: 61 Coefficients 0.2 IR
Parks and McClellan method: 46 0 and equiripple -0.2 0 5 10 15 20 25 30 35 40 45 Time
29/31 FIR filters – Linear phase
Linear phase is strictly related with the symmetry of the Impulse Response () a () b a
Condition h(n) h(N n 1) 6 H() h(k)e jkT k0 h(0) h(1)e jT h(2)e j2T h(3)e j3T h(4)e j4T h(5)e j5T h(6)e j6T e j3T h(0)e j3T h(1)e j2T h(2)e jT h(3) h(4)e jT h(5)e j2T h(6)e j3T e j3T h(0)(e j3T e j3T ) h(1)(e j2T e j2T ) h(2)(e jT e jT ) h(3) e j3T 2h(0)cos(3T ) 2h(1)cos(2T ) 2h(2)cos(T ) h(3)
The phase is introduced by the term e-j3ωT and equals θ(ω)=3ωΤ=ωΤ (7-1)/2
30/31 Linear phase - Same time delay
180o
3*180o
5*180o
If you shift in time one signal, then you have to shift the other signals the same amount of time in order the final wave remains unchanged. For faster signals the same time interval means larger phase difference. Proportional to the frequency of the signals. -αω
31/31