Summary Dig Filt

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Brief Notes on Digital Filters

Z-transforms
X ( z) =
For us the xn are usually samples from a signal. Remember that terms in the series must approach zero as n tends to . This defines the region of convergence. Most often we use Geometric Progression formulae to do n the sums which can then be expressed as: ao a 1 a Finite number of terms: sum = ao 1 a
N
n

n =

xn z

1 Infinite number of terms: sum = ao 1 a

| a |< 1

Z-transforms - Continued
Regions of convergence in the z-plane
Of the form |z| > some value (defines a region outside a circle) Time, n sec when the signal is zero for - < n < n0 and then has values for n0 +1 < n < +
Imag (z)

Real (z)

Of the form |z| < some value (defines a region inside a circle) Time, n sec when the signal has values for - < n < n0 and then is zero for n0 +1 < n < +

Imag (z)

Real (z)

Inverse z-Transfroms X(z) to xn


Definition:

n 1 1 xn = z X ( z ) dz = residues 2 j

Contour of integration inside region of convergence Residues only at poles inside contour of integration SIMPLE POLE at z = zo, residue is: n 1 lim z zo ( z zo) z X ( z ) M POLES at z = zo, residue is: lim z zo
m n 1 1 d ( z zo) z X ( z ) ( m 1 ) ( m 1)! dz ( m 1)

Inverse z-Transfroms X(z) to xn


Other methods:
1.Express as known z-transforms, through partial fraction expansion. 2.Long division

______________________________________________________________________________________________

In both cases, use the region of convergence to tell you whether you want to land up with a signal decaying away to zero for:

positive time, xn = 0 for n < no negative time, yn = for n > no or both, split into two parts a positive and a negative time part.

Digital Systems (IIR Filters)


Xn X(z)
1

hn H(z)
2

Yn Y(z)
NB

Often H(z) is in a polynomial form:

+ ....... a NA z This is an infinite impulse response (IIR) filter.


Difference Equation: [recall Z{xn-q } = z q X(z) ] yn = bo xn + b1xn 1 + b2 xn 2 + ....... bNB xn NB a1 yn 1 a2 yn 2 ....... a NA yn NA

H ( z) =

bo + b1z 1 + a1z

+ b2 z

+ a2 z

+ ....... bNB z

Y ( z) = NA X ( z)

Digital Systems (FIR Filters)


Some digital systems have transfer functions [H(z)] like:

+ ....... b1z + bo + 1 2 M Y ( z) b1z + b2 z + ....... bM z = X ( z) This is a Finite Impulse Response (FIR) Filter. Difference equation is:
yn = b M xn + M + b M +1xn + M 1 + ....... b1xn +1 + bo xn + b1xn 1 + b2 xn 2 + ....... bM xn M Note that this 2M+1 length filter is non-causal, and yn depends on future as well as past values of xn.

H ( z ) = b M z

+M

+ b M +1z

+ M 1

+1

Digital Systems (FIR Filters) continued


Coefficients give the impulse response of these FIR filters: hn = bn for M n +M; hn = 0 for |n| > M.

Note that the response is a convolution of xn with the impulse response hn = bn:

yn =

k =M

bk xn k =

n+ M m=n M

bn m xm

Fastest way to implement this, unless M is very small, is through convolution via FFTs, not forgetting to zero pad appropriately.

Non Causal IIR Digital Filters


You can have non-causal IIR filters too,
(response now is a function of future values of the response as well as current and future values of the input)

but they are tricky to implement.

We split the transfer function into causal and acausal parts: H(z) = H c(z) . Hac(z) where:
Hc ( z) = bo + b1z 1 + a1z
1

+ ...... + .....

H ac ( z ) =

co + c1z 1 + d1z

+1

+ ...... + .....

+1

Non Causal IIR Digital Filters (cont)


Hc(z) is implemented in the usual way (see difference equation on slide 5) The output of this part of the system becomes the input to Hac(z) Hac(z) is implemented through use of the following difference equation: yn = co xn + c1xn +1 + c2 xn + 2 + ....... c NC xn + NC d1 yn +1 d 2 yn + 2 ....... d NA yn + ND To implement this you start at the end of the input series and work back towards the start. This is equivalent to:
Time Reverse Signal

causal system: Hac(z 1)

Time Reverse Signal

Frequency Response of Digital Filters


Evaluate H(z) around the unit circle

H ( z) =

bo + b1z 1 + a1z

+ b2 z

+ a2 z

+ ....... bNB z + ....... aNA z

NB z = exp( j 2f )

NA

and f=k.fs/N, k=0,1,.N-1.

This can be time-consuming. Note: you are actually doing:

and hence this can be done efficiently in MATLAB by using: Hfreq=fft{b,N}./fft{a,N} Make N very large (and a power of 2 for efficiency) to get a finely resolved spectrum.

DFT {bo , b1, b2 ,....bNB ,0,0,0....0 N 1} H ( z) = DFT {1, a1, a2 ,......., a NA ,0,0,....0 N 1}

Digital Filter Design


All digital systems are filters but we usually we design filters to:
remove noise from a signal differentiate or integrate a signal calculate the Hilbert transform of a filter

We also sometimes design filters


to simulate physical systems to act as controllers (not in this class)

FIR Filter Design (Brief Overview)


Method 1: (Sample in time) N = 2M+1 point filter
Start with H(f), the desired frequency response of an analog filter E.g. High-pass: H(f) = 1 for |f| > fc, and H(f) = 0 for |f| < fc This is a severe change at |f|=fc, not really a good idea, having a gentler transition is desirable.

Band limit putting H(f) = 0 for |f| > fs/2. Inverse Fourier Transform (analytically) to obtain h(t). Sample and scale to obtain expressions for h(n). Window to have finite sequence M n M and evaluate to obtain coefficients: bj for j = -M,-M+1,.-1,0,1,M. A window that zero smoothly at M is desirable.

FIR Filter Design (continued)


Method 2: (Sample in frequency) N (even) point filter Start with H(f) the desired frequency response for 0<f<fs/2. Beware of sharp transitions as with method 1. Sample H(f) at f=k.fs/N k=0,1,.N/2 to get Bf(k) for k=1,2,(N/2)+1 Specify Bf(k+N/2+1) = conjugate of Bf(N/2+1-k) for k=1,2,(N/2)-1. (Symmetry condition for real filter coefficients). Inverse Discrete Fourier Transform (IFFT) to get coefficients. Rearrange, if you didnt do the phase adjustment in frequency, to move the last N/2 points of the filter to the start of the filter. Now the coefficients in the vector correspond to times: -(N/2) t ( (N/2)-1 ) instead of 0 t (N-1) .

FIR Filter Design (continued)


Method 3 (Remez Exchange Algorithm) N=2M+1 point FIR filter.
This is a nonlinear optimization algorithm that tries to ensure the frequency response error is uniform. (Doesnt always converge.) You specify a frequency and an amplitude vector that specifies the desired frequency response from 0 to fs/2. Example: Band-stop filter. F=[0 0.3 0.35 0.65 0.7 1.0]; A=[1 1 0 0 1 1]. 1.0
PASS BAND Transition Regions STOP BAND PASS BAND

1.0 Normalized Frequency: 1.0 corresponds to fs/2. Can weight the importance of error in each band. E.g., w=[0.9 0.1 0.9]

FIR Filter Design-Validation


Always check out the frequency response of designed filter by zero-padding and FFTing filter coefficients. Remember the FFT program always assumes that the data starts at t=0. You have to adjust the phase yourself to account for time-delays or advances. The impulse response should tend to zero at the filter ends. It not doing so indicates there are problems with the design. You will see large ripples in the frequency response when this happens. Rectify by: Increasing the length of the filter Smoothing transition regions in the frequency domain Windowing the impulse response with a smoother window

Differentiators etc.
Differentiator: H(f) = j 2 f
Amplifies high frequency noise. Digital filter will have a sharp transition at fs/2. Often a good idea to combine this with a low-pass filter also to smooth function at fs/2. Amplifies low frequency noise. Digital filter will have a sharp transition at 0 Hz. Often a good idea to combine this with a high-pass filter also to smooth function at 0. Digital filter has sharp transition regions at f=0 & fs/2. Good idea to smooth function in these regions.

Integrator: H(f) = 1/{j 2 f}

Hilbert Transformer H(f) = -j sign(f).

IIR Filter Design


Analog Design mapped into Digital Design
Impulse invariant mapping H(s) h(t) h(n ) H(z) aliasing an issue, therefore not a good idea for design of, e.g., high-pass filters. Stable in s-plane (poles in LHP) stable in z-plane (poles inside unit circle) Bilinear mapping 1 1 Use H(s) and substitute s = ( 2 / ).( 1 z ) /( 1 + z ) Frequency distortion, must pre-warp to account for this in the design.

ana log = ( 2 / ).tan ( digital . / 2 )

Stability conserved, entire left half plane maps into unit circle.

IIR Filter Design (continued)


We only looked at a Butterworth low-pass filter H(s).H(-s) = 1/[ 1 + (s/jc)2N ]
Poles equispaced around a circle in the s-plane. Radial positions of poles: |Sk| = c Angular positions of H(s) poles: Sk = 90 + [ (1+2k).180/2N ] degrees, k=1,2,..N. Left Half Plane poles correspond to H(s), Right Half Plane poles correspond to H(-s). E.g., N=3, H(s) = [ (1-s/s1) (1-s/s2) (1-s/s3) ]

IIR Filter Design (continued)


Finding N and c
1. Specify desired digital characteristics at digital-1 20 log 10 |Hdigital| = -K1 dB at digital-2 20 log 10 |Hdigital| = -K2 dB 2. Transform digital design to analog (pre-warp) analog-1 = (2/ ) tan (digital-1 /2) analog-2 = (2/ ) tan (digital-2 /2) at analog-1 10 log 10 |Hanalog|2 = -K1 dB (**) at analog-2 10 log 10 |Hanalog|2 = -K2 dB (***)

IIR Filter Design (continued)


Use (**) and (***) to solve for N and c Round up N to make it integer. Write down locations of poles in LHP of Butterworth filter with this N and c.
S1,s2,s3 etc.

Form H(s)
E.g., N=3, H(s) = 1/[ (1-s/s1) (1-s/s2) (1-s/s3) ]

Apply bilinear transform to determine H(z).

s = ( 2 / ).( 1 z

) /( 1 + z

Check out the resulting frequency response of H(z).

IIR High-pass, Notch and Band-pass Filters


You can transform a low-pass Butterworth filter into a high-pass filter by replacing (s/j c) with (j c/s) in the original design. You can combine a low- and high-pass in series to produce a band-pass filter.
H = HLP . HHP

You can combine a low- and high-pass in parallel to produce a band-stop (notch) filter.
H = HLP + HHP Or, you can use mappings to create analog Butterworth band-pass and band-stop filters in the first stage of the design. (Similar to the high-pass mapping in the first bullet, but more complicated.) See Oppenheim and Schafer or most any other Digital Filtering book.

You might also like