Basics of Digital FIlters
Basics of Digital FIlters
Elena Punskaya
www-sigproc.eng.cam.ac.uk/~op205
Some material adapted from courses by Prof. Simon Godsill, Dr. Arnaud Doucet, Dr. Malcolm Macleod and Prof. Peter Rayner
xn
Input sequence
Digital Filter
Output sequence
yn
Desired features
Desired features depend on the application, for example Input Signal generated by sensing device (microphone) speech Output having less noise or interferences with reduced redundancy for more efficient transmission
Examples of filtering operations Noise suppression received radio signals signals received by image sensors (TV, infrared imaging devices) electrical signals measured from human body (brain heart, neurological signals) signals recorded on analog media such as analog magnetic tapes
4
communication radio or TV signal transmitted over specific channel has to have a limited bandwidth to prevent interference with neighbouring channels frequency components outside the permitted band are attenuated below a specific power level
6
These operations can be approximated by digital filters operating on the sampled input signal
7
Linear: defined by the principle of linear superposition xn1 LTI yn1 xn2 LTI LTI yn2
scaling & additivity properties
a1xn1+ a2xn2
a1yn1+ a2yn2
Analysis We analyse DSP algorithms by determining: their time-domain characteristics linear difference equations filters unit-sample (impulse) response their frequency-domain characteristics more general, Z-transform domain system transfer function poles and zeros diagram in the z-plane Fourier domain frequency response spectrum of the signal
9
The linear time-invariant digital filter can then be described by the linear difference equation:
where {ak} and {bk} real The order of the filter is the larger of M or N
10
x1 n
Multipliers:
yn=x1n+x2n x2 n
xn
yn=axn
xn
Z-1
yn= xn-1
allows to look ahead, e.g. image processing
xn
yn= xn+1
Components that allow access to future and past values in the sequence
12
1/3
xn
Order: number of delays & advances needed to implement Z-1
yn
second-order filter
xn
+
Z-1
yn a
one delay first-order
The operations shown in the slides above are the full set of possible linear operations: constant delays (by any number of samples) addition or subtraction of signal paths multiplication (scaling) of signal paths by constants - (including -1) Any other operations make the system nonlinear.
15
Linear difference equations and digital filter structure Useful for implementing digital filter structures
xn b0 bM
= unit delay yn
a1
aN
xn= is determined
k=-
xk n-k
Taking into account properties of the LTI system, the response of the system to xn is the corresponding sum of weighted outputs
xn=
k=-
xk n-k
LTI
yn=
k=-
xk hn-k
17
Linear convolution
Linear convolution
yn=
k=-
xk hn-k
gives the response of the LTI system as a function of the input signal and the unit sample (impulse) response
Impulse response: hn = 0
Thus
for n<0
yn=
k=-
xk hn-k =
k=0
hk xn-k
19
where
is a complex variable
20
Indeed,
21
22
Finite Impulse Response (FIR) Filters: N = 0, no feedback Infinite Impulse Response (IIR) Filters
23
The roots of the numerator polynomial in H(z) are known as the zeros, and the roots of the denominator polynomial as poles. In particular, factorize H(z) top and bottom:
24
where
b = [b0 b1 b2 ... bM ]; a = [ 1 a1 a2 a3 ... aN ];
Or step response,
y = filter( b, a, [ones(1,P)]);
25
DTFT
26
xn
LTI
yn=
k=0
hk xn-k convolution
Fourier Transform
Fourier transform of hk
is also in the form of complex exponential but altered by the multiplicative factor
28
Example Assume
where for 0 otherwise
Frequency response
29
=
is called magnitude response of a system
and argument:
Suppose we have a system with 2 poles (o) and 2 zeros (x) We are going around the unit circle with
O 1
-1
32
Transfer function:
-1
O
C1
D2
C2
O 1
Frequency response:
C1C2 D1D2
33
-1
O
C1
D2
C2
O 1
The magnitude of the frequency response is given by times the product of the distances from the zeros to divided by the product of the distances from the poles to
The phase response is given by the sum of the angles from the zeros to minus the sum of the angles from the poles to plus a linear phase term (M-N) 34
-1
O
C1
D2
C2
O 1
35
36
36
Filtering example
Generate a Gaussian random noise sequence:
x=randn(100000,1); figure(1), plot(x) figure(2), plot(abs(fft(x))) a = [1 -0.99 0.9801]; b = [1, -0.1, -0.56]; y=filter(b,a,x); figure(3), plot(y) Figure(4), plot(abs(fft(y)))
freqz(b,a);
Filter specification
Before a filter is designed and implemented we need to specify its performance requirements. There are four basic filter types: Low-pass High-pass Band-pass Band-stop
Frequency band where signal is passed is passband Frequency band where signal is removed is stopband
38
39
40
41
42
43
Indeed,
In some applications it is critical for this property to hold (at least approximately)
45
phase distortion
46
The derivative of the phase/signal respect with respect to is known as group delay of the filter - effectively time delay of the frequency
48
49
Filter Design
Lets have a go
50
Im(z)
Thus when 'is close to' a pole, the magnitude of the response rises (resonance). When 'is close to' a zero, the magnitude falls (a null).
X
D1
-1
O
C1
D2
C2
O 1
51
One needs to put the poles within the unit circle to ensure stability
52
Rule 2: The closer to a zero, the lower the magnitude of the response
53
54
one can simply reflect the poles-zeros locations of the lowpass filter about the imaginary axis
55
56
in time domain
57
58
Resonator
This filter is actually more a digital resonator than an bandpass filter; see its frequency response for r = 0.9 and 0 = /4 - it has a large magnitude response around 0
59
Band-pass Filter
60
Band-pass Filter
Notch Filter
a filter that contains one or several deeps/ notches in its frequency response
to eliminate 0
Frequencies around the desired null are also seriously attenuated
62
Notch Filter
Frequencies around seriously attenuated
63
64
Inverse Filter
65
3.
4.
67
Thank you!
68