Sept'05CS32911 CS3291 Sect 2: Review of analogue systems Example of an analogue system: Represent as...

Post on 26-Dec-2015

220 views 1 download

Tags:

Transcript of Sept'05CS32911 CS3291 Sect 2: Review of analogue systems Example of an analogue system: Represent as...

Sept'05 CS3291 1

CS3291 Sect 2: Review of analogue systems

Example of an analogue system:

Represent as “black box”

RC

y(t)

x(t)

x(t) y(t)

Sept'05 CS3291 2

Linearity:

(1) for any x(t),

if x(t) y(t) then ax(t ) ay(t)

(2) for any x1(t) & x2(t),

if x1(t) y1(t) & x2(t) y2(t)

then x1(t) + x2(t) y1(t) + y2(t)

Sept'05 CS3291 3

Linearity: alternative definition

• For any x1(t) & x2(t),

if x1(t) y1(t) & x2(t) y2(t)

then a1x1(t) +a2 x2(t) a1y1(t) +a2 y2(t)

for any a1 & a2

Sept'05 CS3291 4

Linear

x1(t)

t

y1(t)

t

t x2(t)

y2(t)

t

If x1(t) --> y1(t) & x2(t) --> y2(t) then 3 x1(t) + 4 x2(t) --> 3 y1(t) + 4 y2(t)

Sept'05 CS3291 5

Time-invariance:

A time-invariant system must satisfy:

for any x(t), if x(t) y(t) then x(t-) y1(t-) for any

Delaying input by seconds delays output by seconds

(Not all systems have this property)

An LTI system is linear & time invariant.

Sept'05 CS3291 6

x(t) y(t)

t t

Ex 2.1: Is it true that for all LTI systems, output has same shape as input?

Answer: nope

Sept'05 CS3291 7

Volts

t

V

T

V.T = 1

T -> 0

t

1

t

1

Delayed impulse Impulse

t t

t

Delayed & weighted

0.8

t 0.8

2.2. Unit impulse:

Sept'05 CS3291 8

(1) (t) = 0 for all values of t except t=0

(2) ( )t d t

1

Fundamental properties of unit impulse:

Sept'05 CS3291 9

Sampling property of impulse

x()

t

-.any tfor )()()( txdtx

Sept'05 CS3291 10

)(

)()(

)()(

)()()()(

tx

dtx

dttx

dttxdtx

Proof of sampling property

x() (t-) = 0 except at = t .

x()(t-) = x(t)(t-) . It follows that:

Sept'05 CS3291 11

Impulse-response:

(t) h(t)

Impulse-response of RC circuit in Fig. 2.1 is:

0 : t < 0 h(t) = (1/RC)e - t / R C : t 0

Sept'05 CS3291 12

1/RC

t

h(t)

Impulse-response of RC circuit.

See Appendix A for proof.

Sept'05 CS3291 13

Convolution

x(t) y(t)LTI

h(t)x(t) h(t)

dthx )()(

dtxh )()(

Sept'05 CS3291 14

Proof of formula for convolution:

(t) h(t)

(t-) h(t-) (by time-invariance)

x()(t-) x()h(t-) (by linearity)

x(t) x(t) h(t) (by sampling property (convolution)

dthxdtx )()()()(

Sept'05 CS3291 15

Ex 2.3: An LTI system has

t

h(t)1

1Calculate its response to sin(t)

Solution:

)2/sin()2/sin(2

cos)1(cos1

)(cos1

))(sin(.1)()(

1

0

1

0

t

ttt

dtdtxh

Sept'05 CS3291 16

2.5: Properties of analogue LTI systems

Stability: An LTI system is stable if h(t), satisfies:

|h(t)| dt < . -

Causality: An LTI system is causal if h(t), satisfies: h(t) = 0 for t < 0 (No crystal ball!)

Sept'05 CS3291 17

Looks stable

but is not causal.

t

h(t) h(t)

t

Causal, but not stable

h(t)

Causal & looks stable.

t

Sept'05 CS3291 18

dtethjH

jHe

dehe

dehty

tj

tj

jtj

tj

)()( where

)(

)(

)()( )(

Consider response to x(t) = cos(t) + j sin(t) = e j t

Frequency response: Fourier transform of h(t).

Complex number for any .

Sept'05 CS3291 19

G() = H(j) is "gain response,

() = Arg{H(j)} is the "phase response".

Therefore: H(j) = G()e j () As h(t) is real, H(-j) is complex conjugate of H(j).

Sept'05 CS3291 20

Let input be A cos(t) = real part of A e j t

We know that e j t e j t H(j),

Response to A cos(t) will be: A . RE { e j t H(j) }

= A . RE { e j t G() e j ( ) }

= A . G( ) . RE { e j ( t + ( ) ) }

= A . G() . cos( t + () )

= A . G() . cos( (t - ) ) where = -()/

Sept'05 CS3291 21

Gain

Phase lag

1

Gain & phase response graphs

G(

Sept'05 CS3291 22

Arctan(Ts)

Linear phase response.

TS

(Phase lag)

Linear phase

Sept'05 CS3291 23

Phase-response (cont)

• Meaning of phase-response not as obvious as ‘gain response’:

() / is ‘phase delay’ in seconds

• Ideal is to have same delay at all frequencies: linear phase.

• True if - () = TS for all , where TS constant.

• All components of a Fourier series delayed by same time TS.

• Avoids changes in wave-shape due to ‘phase distortion’;

i.e different frequencies being delayed by differently.

• Ear not very sensitive to phase distortion on normal telephones.

• Quite different wave-shapes can sound the same.

• But phase distortion of digital transmissions can be serious.

Sept'05 CS3291 24

2.6: Inverse Fourier Transform: :

1

h(t) = H(j) e j t d

2 -

There are some interesting things to notice:-

(1). Range of integration is - to .

(2). Differences between this formula & “forward” FT:

(i) the (1/2) factor

(ii) sign of jt ( + for inverse, - for forward)

(iii) variable of integration is d for inverse transform

& dt for forward.

Sept'05 CS3291 25

• Replacing s by j gives H(s) = H(j) = freq-resp = Fourier transform of h(t).

• Fourier transform = Laplace transform with s = j.

dtethsH st)( )( where

0)( )( dtethsH st

2.7 Laplace transform •Given analogue LTI system with impulse-response h(t).•Response to x(t) = est where s = + j is

-

)( )( )( )( )( sHedehedehty stsstts

• H(s) is "bilateral Laplace transform" of h(t). • For causal system, H(s) becomes normal Laplace transform

Sept'05 CS3291 26

• For causal stable LTI system, ... H(s) is finite for any s with real part 0 . H(s) cannot be infinite for values of s with real part 0

Proof: Consider |H(s)| for some value of s = + j with > 0:

stabilityby )(

)( )(

)( )(

causalityby )( )()(

0

00

00

0

dtth

dtethdteeth

dteethdteth

dtethdtethsH

ttjt

tjtst

stst

Sept'05 CS3291 27

• If x(t) = est then y(t) = H(s)est. • Also dx(t)/dt = sest, d2 x(t)/dt2 = s2 e s t , dy(t)/dt = sH(s)est etc.

H(s)est(b0+b1s+b2s2+...+bMsM) = est(a0 + a1s + a2s2 + ... + aNsN)

i.e. a0 + a1s + a2s2 + ... + aNsN

H(s) = b0 + b1s + b2s2 + ... + bMsM

b y t bdy t

dtb

d y t

dta x t a

dx t

dta

d x t

dt0 1 2

2

2 0 1 2

2

2( )

( ) ( )( )

( ) ( )

2.8. ‘System function’ for analogue LTI circuits: •Relationship between input x(t) & output y(t):

Sept'05 CS3291 28

2.9 Poles & zeros of H(s): • Factorise numerator & denom of H(s) to obtain: (s-z1)(s-z2) .... (s-zN) H(s) = K (s-p1)(s-p2) .... (s-pM)

• Poles: p1, p2, .... pM.

• Zeros: z1, z2, .... zN.

•H(s) normally zero at a zero infinite at a pole. •For real system, poles & zeros real or in complex conj. pairs. •Since H(s) must be finite for all s with real part 0,

for causal stable system, no pole can have real part 0. •On Argand diag, no poles can be on RHS or on imaginary axis. •Poles are restricted to LHS. No such restrictions on zeros.

Sept'05 CS3291 29

Real Part

Imaginary partPoles must be on left of imag axis.Zeros can be anywhere

ZeroPole

Poles & zeros on real axis or in complex conjugate pairs

Pole

Sept'05 CS3291 30

2.10. Design of analogue filters • Two stages given a frequency response specification:

1) Find realisable H(s) which approximates the specification:2) Find circuit to realise H(s):

• Many design techniques for digital filters use the same approximations as are used for analogue filters.

• It is useful to review one of these.

Sept'05 CS3291 31

2.10.1. Approximation stage for a low-pass analog filter:

Ideal "brick-wall" gain response & linear phase response i.e

c

c

> :

:

0

1 )( )(

jHG () = arg(H(j)) = -k

() G()

1

0 C

Sept'05 CS3291 32

•Need expressions for G() & () which are approximations to the ideal specification. •Must correspond to the H(s) of a realisable circuit whose order is practically manageable.•Concentrate on G() first. •Consider Butterworth approximation of order n:

nc

G2)/(1

1 )(

Properties(i) G(0) = 1 ( 0 dB gain at =0)(ii) G(C) = 1/(2) ( -3dB gain at = C)

(iii) When >> C, G() (C/)n

(iv) G() is maximally flat at = 0 & at = .

Sept'05 CS3291 33

Examples of Butterwth low-pass gain responses

nc

G2)/(1

1 )(

• Let C = 100 radians/second & n = 2, 4, & 7.

• G(C) is always 1/(2)

• Shape gets closer to ideal ‘brick-wall’ response as n increases.

• Common to plot G() in dB, i.e. 20 log10(G()), against .

• With on linear or log scale.

• As 20 log10(1/(2)) = -3, all curves are -3dB when = C .

Sept'05 CS3291 34

0 50 100 150 200 250 300 350 4000

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

radians/second

G()

n = 2n=4n=7

1 / (2)

LINEAR-LINEAR PLOT

Sept'05 CS3291 35

0 50 100 150 200 250 300 350 400-90

-80

-70

-60

-50

-40

-30

-20

-10

0dB

radians/second

-3dB

dB-LINEAR PLOT

n=2

n=4

n=7

Sept'05 CS3291 36

100 101 102 103-80

-70

-60

-50

-40

-30

-20

-10

0dB

radians/second

dB-LOG PLOT

n=2

n=4

3 dB

Sept'05 CS3291 37

MATLAB program to plot these graphs

clear all; for w = 1 : 400

G2(w) = 1/sqrt(1+(w/100)^4); G4(w) = 1/sqrt(1+(w/100)^8) ; G7(w) = 1/sqrt(1+ (w/100)^14); end; plot([1:400],G2,'r',[1:400],G4,'b',[1:400],G7,'k'); grid on;

DG2=20*log10(G2); DG4=20*log10(G4); DG7=20*log10(G7); plot([1:400],DG2,'r',[1:400],DG4,'b',[1:400],DG7,'k'); grid on;

semilogx([1:990], DG2,'r', [1:990], DG4, 'b’);

Sept'05 CS3291 38

‘Cut-off’ rate

• This is best seen on a dB-Log plot

• By property (iii), cut-off rate is 20n dB per decade or 6n dB per octave at frequencies much greater than C.

• Decade is a multiplication of frequency by 10.• Octave is a multiplication of frequency by 2.

• So for n=4, gain drops by 80 dB if frequency is multiplied by 10 or by 24 dB if frequency id doubled.

Sept'05 CS3291 39

2.10.3 H(s) for nth order Butterworth low-pass approxn:

1 H(s) = [n/2] (1+s/C)P {1 + 2sin[(2k-1)/2n]s/C + (s/C)2} k=1

• [n/2] is integer part of n/2, • P=0 / 1 for n even/odd. sign means ‘product’. • Denominator is product of 1st & 2nd order polynomials in s. • H(s) is often realised by analogue circuits. • Can also be realised by IIR digital filters.

Sept'05 CS3291 40

Examples

1ωn whe 1

1

)/( )/( / 1

1

))/(/1)(/1(

1 H(s) 3,n If

C32

32

2

sss

sss

sss

CCC

CCC

))/(/ 414.1 1(

1 H(s) 2,n If

2CC ss

)/1(

1 H(s) 1,n If

Cs

Sept'05 CS3291 41

More Examples

1ω if )...1)(...1(

1 H(s) 4,n If C22

ssss

… and if C 1 replace ‘s’ by ‘s /C ’ in formula

1ω if )...1)(...1)(1(

1 H(s) 5,n If C22

sssss

• Not easy to show that replacing s by j & taking modulus gives appropriate Butterwth G(). But it’s true!

Sept'05 CS3291 42

2.10.4 Frequency-band transformations:

Given H(s) for low-pass approxn with C=1 (pass-band -1 1),

we can produce the transfer functns of other useful approxns:

• Low-pass: s s/C Scales cut-off from1 to C.

• High-pass: s C/s H(C /s) is high-pass with cut-off C

• Band-pass: s (s+p/s)/d where d = U - L & p = UL .

Produces band-pass transfer function with cut-off U & L .

• Band-stop : s d/(s+p/s) where d=U-L & p=UL

Sept'05 CS3291 43

Examples: use of freq band transformations

1. Transform the 1st order Butterwth low-pass system function with 3 dB cut-off 1 radian/second: H(s) = 1 / (1+s) into a high-pass system fn with cut-off C

2. Transform H(s) = 1/(1+s) into a band-pass (narrow-band) transfer fn with cut-off frequencies: L = 2, U= 3.

3. Transform H(s) = 1/(1+s) into a band-stop (narrow-band) transfer fn with cut-off frequencies: L = 2, U= 3.

4. Transform H(s) = 1/(1+s) to band-pass (broad-band) transfer fn with cut-off frequencies: L = 2, U= 9

Sept'05 CS3291 44

G()

1

G() 1

C

1 radian/s

Low-pass with C = 1

Low-pass

Ideal

Approximatn

Sept'05 CS3291 45

G()

1

G() 1

C

L U

High-pass

Band-pass

Sept'05 CS3291 46

G()

1

L U

Band-stop

Sept'05 CS3291 47

G()

1

L U

Narrow-band

(U < 2 L )

Broad-band

(U > 2 L )

Two types of band-pass gain-responses

L U

G()

1

Sept'05 CS3291 48

G()

1

L U

Narrow-band

(U < 2 L )

Broad-band

(U > 2 L )

Three types of ‘band-stop’ gain-responses

L U

G()

1

Sept'05 CS3291 49

G()

1

N

Notch

All-pass

Third type of ‘band-stop’ gain-response

Yet another type of gain-responseG()

1

Sept'05 CS3291 50

Comments:

• Given H(s) for low-pass gain-resp. with C =1, freq-band transfns always work & must be used for narrow-band.

•‘Broad-band’ band-pass & band-stop transfer fns can be obtained by combining low-pass & high-pass.

• ‘Notch’ gain-resp. is band-stop with very narrow stop-band. Used for ‘notching out’ sinusoidal tone at one frequency.

• All-pass gain-responses do nothing to magnitudes of sinusoids but can change their phases in useful ways.

Sept'05 CS3291 51

2.11. Use of MATLAB for analogue filter design

• High level language for matrix operations & complex numbers.• Ideal for studying & implementing signal processing operations.• Variables declared automatically when first used. • Each variable may be a matrix with complex elements. E.g.: X = [ 1 2 3 4 -5+3j ]; % Comment

• If semicolon omitted, print result of assignment.

• It is easy to generate sections of sine-waves.

• You need to know the sampling frequency fS in Hz.

• Can make fS = 1 Hz which means 1 sample every second).

Sept'05 CS3291 52

Produce row matrix x containing 100 samples of 1/20 Hz sine-wave when fS = 1 Hz. Plot this as a graph: for n = 1:100 x(n) = sin(n*2*pi / 20); % 2/20 radians/second end; plot(x);

0 10 20 30 40 50 60 70 80 90 100-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

seconds

Sept'05 CS3291 53

Produce 100 samples of a 0.7 Hz sine-wave when fS = 10 Hz: fs = 10; f = 0.7; for n = 1:100 x(n) = sin(n*2*pi * f /fs ); end; plot( [1:100]/fs, x);

0 1 2 3 4 5 6 7 8 9 10-1-0.8-0.6-0.4-0.2

00.20.40.60.8

1

seconds

Sept'05 CS3291 54

• Note: ‘ [1:100] / fs ’ is a row matrix [1, 2, …, 100] with each element divided by fs.

• Following example shows how a WAV file containing speech or music may be read in, listened to & plotted in sections.

• Sections may be processed and written to a second file.

• ‘Control-C’ will interrupt a running MATLAB program even when in a infinite loop.

Sept'05 CS3291 55

clear all;[x, fs, nbits] = wavread('cap4th.wav');SOUND(x,fs,nbits);for n=1:1000 y(n)=x(n+10000);end; plot([1:1000]/fs,y);wavwrite(y,fs,nbits,’newfile.wav’);

0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

Sept'05 CS3291 56

2.11.1 MATLAB Signal Processing toolbox:

A set of functions available to user of MATLAB for:

(i) carrying out operations on signal segments stored in

row matrices

(ii) evaluating the effect of these operations,

(iii) designing analogue & digital filters.

Some of these functions are as follows: are:

Sept'05 CS3291 57

zplane(a,b) % Plot poles & zeros of H(s) on Argand diag.

[a,b] = butter(n, wc,’s’) % H(s) for nth order analog Butterw% low-pass with cut-off wc.

[a,b] = butter(n, wc, ‘high’,’s’); % High-pass analog Butterw.

[a,b] = butter(n, [wL wU],’s’ ); % Band-pass analog Butterw.

[a,b] = butter(n, [wL wU],’stop’,’s’); % Band-stop ..

freqs(a,b) % Plot analogue frequency-response H(j) when

)(...)1(...)3()2()1(

)(...)1(...)3()2()1()(

321

321

MbsMbsbsbsb

NasNasaasasH

MMM

NNN

Sept'05 CS3291 58

Other analogue gain response approximations:

[a,b] = cheby1(n, Rp,wc,’s’ ); % Low-pass Chebychev type 1. % Rp = pass-band ripple in dB

.[a,b] = cheby2(n, Rs,wc,’s’ ); % Low-pass Chebychev type 2.

% Rs = stop-band ripple in dB

(Slight error in notes (‘discrete time’).

Sept'05 CS3291 59

Examples:-

1. Use MATLAB to plot gain response of Butterwth type analog low-pass filter of order 4 with C = 100 radians/second.

for w = 1 : 400G(w) = 1/sqrt(1+(w/100)^8) ;end;plot(G); grid on;

Sept'05 CS3291 60

Result obtained:-

Sept'05 CS3291 61

2. Using Signal Processing toolbox calculate coeffs of 3rd order Butt low-pass filter with C = 5, & plot gain & phase resp.

Solution: [a,b] = butter(3,5,’s’); freqs(a,b);

Result obtained:-a = 0 0 0 125.0b = 1.0 10.0 50.0 125.0

1255010

125)(

23

ssssH

Sept'05 CS3291 62

Sept'05 CS3291 63

Postscript

• MATLAB goes not give H(s) with its denominator expressed in 2nd order sections as our earlier formula did.

• This is sometimes inconvenient.

• As an exercise, find out how to use MATLAB to produce H(s) in 2nd order sections.

Sept'05 CS3291 64

2.7: Problems on Section 2:

2.1 Is it true that if a system is linear & its input is a sine-wave, its output must be a sine-wave?2.2. If L1 & L2 are LTI with imp-responses h1(t) & h2(t), calculate imp-response of each arrangement below. Show that these 2 arrangements with input same x(t) produce same output y(t):

2.3. An LTI system has impulse response: 1 : 0 t 1 h(t) = 0 : otherwise Sketch its gain & phase responses.

L1 L2

L2 L1

Sept'05 CS3291 65

2.4. An LTI system has impulse response: 1 : 1 t 2 h(t) = 0 : otherwise Sketch its gain & phase responses & compare with previous.

2.5. We wish to design an LTI system with impulse response: cos ( 0 t) : 0 t 2/ 0

h(t) = 0 : otherwise Is it stable and/or causal & what is its frequency-response?

2.6. Show that for stable system, H(j) cannot be infinite for any .

Sept'05 CS3291 66

2.7. Calculate impulse-response of analogue filter with: 1 : || 1 radian/second H(j) = 0 : || >1 Why can this ideal filter not be realised as a practical circuit?

2.8. Write down inverse FT to give h(t) in terms of H(j). Split it into 2 integrals, & express H(j) in polar form. Show that when H(-j) = H*(j) for all 1 h(t) = | H(j) | cos(() + t )d if ()= Arg [H(j)] 0 Then show that if -()/ = D for all , h(t) must be symmetric about t = D; i.e. h(D+t) = h(D-t) for all t. What does this tell us about the possibility of designing analog filters which are exactly linear phase?

Sept'05 CS3291 67

2.9 An LTI analog crt has: H(s) = 1 / (1 + s) Give its gain & phase responses & its phase delay at = 1.2.10 Give H(s) for a Butterwth low-pass gain response with 3dB cut-off at 1 rad/sec, of order: (i) n=6 & (ii) n=7.2.11. Can we design 4th order Butterwth lowpass filter with 3dB cut-off C by cascading two identical 2nd order Butterwth low-pass filters?2.12. Give H(s) for a Butterwth high-pass gain response with 3dB cut-off C =2 & of order (i) n=2, (ii) n=3 and (iii) n=4.2.13. Give H(s) for Butterwth band-pass approxn with L=3 & U = 4, of order (i) n=2, (ii) n=3, & (iii) n=4. This will involve 4th order denominator polynomials in s.2.14 Convert the 4th order polynomials in previous question to product of two 2nd order polynomials in s. Hence express H(s) as product of 2nd order sections. Use MATLAB!

Sept'05 CS3291 68

2.15. With 2nd order Butterwth low-pass prototype, use a frequency band transformn to derive H(s) for 4th order band-pass filter with L=2 & U =20. Express H(s) as product of 2nd order sections using MATLAB. 2.16. Consider an easier approach to deriving H(s) for 4th order band-pass & band-stop filters where we express H(s) = HLP(s) HHP(s) , i.e. product of a 2nd order low-pass & a 2nd order high-pass section. Repeat the 4th order band-pass design exercises above by this method & use MATLAB to compare gain responses. The exercises have (i) L=3, U=4 ("narrow-band") and (ii) L=2, U=20 ("wide-band")

Sept'05 CS3291 69

RR1

x y

R1

y = x R + R1

RC

X(s) Y(s)

1/CsY(s) = X(s) R + 1/Cs

Appendix A: Analysis of RC circuit

Sept'05 CS3291 70

Y(s) 1/Cs 1/(RC)H(s) = = = X(s) R + 1/Cs s + 1/(RC)

H(s) is Laplace transform of h(t).

By tables, the Laplace transform of 0 : t < 0 1 x(t) = is X(s) = e - a t : t 0 s + aReplacing "a" by 1/RC:

0 : t < 0 h(t) = (1/RC)e - t / R C : t 0