lab 4: first/second order dt systems and a commu- nications...

32
ECEN 3300 Linear Systems Spring 2010 3-01-10 P. Mathys Lab 4: First/Second Order DT Systems and a Commu- nications Example (Second Draft) 1 Introduction The main components from which linear and time-invariant discrete-time (LTI DT) systems are made are adders, gains, and delay or memory elements. DT systems use DT sequences x n as inputs and produce DT sequences y n as outputs. The index n is an integer and x n , y n , and the state of a DT system are undefined when n is not an integer value. In practice DT signals are very often obtained by sampling continuous-time (CT) signals with a sampling rate F s =1/T s samples per second or hertz (Hz). Time t in seconds is then related to the index values n by t = nT s = n/F s . DT systems are typically implemented using digital computers in the form of microprocessors or DSP (digital signal processing) chips which are essentially computers whose architecture has been optimized for DT signal processing. 1.1 Difference Equations Consider the first order CT lowpass filter (LPF) with system function H L (s)= Y (s) X (s) = ω L s + ω L . In the time domain this is described by the differential equation y (1) (t)+ ω L y(t)= ω L x(t) , where x(t) is the input and y(t) is the output of the LPF. One way to convert this to a discrete time (DT) system is to approximate the derivative by y (1) (t) y(t) - y(t-T s ) T s , and to evaluate the differential equation at discrete time instants t = nT s , i.e., y (1) (nT s )+ ω L y(nT s )= ω L x(nT s ) = y(nT s ) - y(nT s -T s ) T s + ω L y(nT s )= ω L x(nT s ) , where n is an integer and F s =1/T s is the sampling rate in samples per second. Replacing y(nT s ) by y n and x(nT s ) by x n yields y n - y n-1 T s + ω L y n = ω L x n = y n - y n-1 L y n L x n , 1

Upload: others

Post on 24-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

ECEN 3300 Linear Systems Spring 20103-01-10 P. Mathys

Lab 4: First/Second Order DT Systems and a Commu-

nications Example (Second Draft)

1 Introduction

The main components from which linear and time-invariant discrete-time (LTI DT) systemsare made are adders, gains, and delay or memory elements. DT systems use DT sequencesxn as inputs and produce DT sequences yn as outputs. The index n is an integer and xn, yn,and the state of a DT system are undefined when n is not an integer value. In practice DTsignals are very often obtained by sampling continuous-time (CT) signals with a samplingrate Fs = 1/Ts samples per second or hertz (Hz). Time t in seconds is then related to theindex values n by t = n Ts = n/Fs. DT systems are typically implemented using digitalcomputers in the form of microprocessors or DSP (digital signal processing) chips which areessentially computers whose architecture has been optimized for DT signal processing.

1.1 Difference Equations

Consider the first order CT lowpass filter (LPF) with system function

HL(s) =Y (s)

X(s)=

ωL

s + ωL

.

In the time domain this is described by the differential equation

y(1)(t) + ωL y(t) = ωL x(t) ,

where x(t) is the input and y(t) is the output of the LPF. One way to convert this to adiscrete time (DT) system is to approximate the derivative by

y(1)(t) ≈ y(t)− y(t−Ts)

Ts

,

and to evaluate the differential equation at discrete time instants t = nTs, i.e.,

y(1)(nTs) + ωL y(nTs) = ωL x(nTs) =⇒ y(nTs)− y(nTs−Ts)

Ts

+ ωL y(nTs) = ωL x(nTs) ,

where n is an integer and Fs = 1/Ts is the sampling rate in samples per second. Replacingy(nTs) by yn and x(nTs) by xn yields

yn − yn−1

Ts

+ ωL yn = ωL xn =⇒ yn − yn−1 + ΩL yn = ΩL xn ,

1

Page 2: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

where ωLTs = ωL/Fs = ΩL is normalized frequency in radians. Thus, the system describedby the first order difference equation

(1 + ΩL) yn − yn−1 = ΩL xn ,

can be interpreted as a DT version of a first order LPF. A block diagram, using an adder,gains, and a delay cell D, that implements this difference equation is shown below.

ΩL + 11+ΩL

• Dxn

yn

yn yn−1

+

+

More generally, an N -th order DT system is described by a difference equation that relatesthe output yn and its shifts yn−1, . . . , yn−N to the input xn and its shifts xn−1, . . . , xn−N . Tobe able to work conveniently with difference equations and to obtain system functions for DTsystems, the next step is to use a transformation that converts time shifts into multiplicativeoperators.

1.2 z-Transform

The unilateral or one-sided z-transform X(z) of a DT sequence xn, n ≥ 0, is defined as

X(z) =∞∑

n=0

xn z−n ,

and if |xn| < r for all n > n0, then X(z) converges for all values of z in the complex z-planeoutside a circle of radius r.

Example: DT Exponential. The DT exponential function an un has z-transform

∞∑n=0

an z−n =1

1− a z−1,

if |a z−1| < 1. The region of convergence (ROC) of this z-transform is |z| > |a|, i.e., thewhole z-plane outside a circle of radius |a|. Note that if a = 1 then the transform pair

un ⇐⇒ 1

1− z−1

is obtained. A related z-transform pair is

δn ⇐⇒∞∑

n=0

δn z−n = 1

2

Page 3: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

where the DT impulse δn = 1 if and only if n = 0.

Example: DT Sinusoids. The complex-valued DT exponential function e±jΩ0 n un hasz-transform

∞∑n=0

e±jΩ0 n z−n =1

1− e±jΩ0 z−1, ROC: |z| > 1 .

Using Euler’s relation

cos(Ω0 n) un =ejΩ0 n + e−jΩ0 n

2un ⇐⇒ 1− cos(Ω0) z−1

1− 2 cos(Ω0) z−1 + z−2

and

sin(Ω0 n) un =ejΩ0 n − e−jΩ0 n

2jun ⇐⇒ sin(Ω0) z−1

1− 2 cos(Ω0) z−1 + z−2

z-Transform Properties. Linearity. The z-transform is linear, i.e.,

α x1[n] + β x2[n] ⇐⇒ α X1(z) + β X2(z) ,

for any (real or complex valued) constants α and β.

Time Shift. If xn ⇔ X(z), then xn−1 has z-transform

∞∑n=0

xn−1 z−n = x−1 + z−1

∞∑n=1

xn−1 z−(n−1) ,

and thusxn−1 ⇐⇒ z−1 X(z) + x−1 ,

where z−1 is recognized as a multiplicative delay operator.

1.3 First Order DT Systems

The difference equation of a general first order DT system is of the form

yn + a1 yn−1 = b0 xn + b1 xn−1 .

Using the one-sided z-transform and assuming zero intial conditions, this yields

(1 + a1 z−1) Y (z) = (b0 + b1 z−1) X(z) =⇒ H(z) =Y (z)

X(z)=

b0 + b1 z−1

1 + a1 z−1.

—- To be completed —-

3

Page 4: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

1.4 Second Order DT Systems

A general second order DT system is characterized in the time domain by a differenceequation of the form

yn + a1 yn−1 + a2 yn−2 = b0 xn + b1 xn−1 + b2 xn−2 .

In the z-domain this translates into

(1 + a1 z−1 + a2 z−2) Y (z) = (b0 + b1 z−1 + b2 z−2) X(z) ,

and thus

H(z) =Y (z)

X(z)=

b0 + b1 z−1 + b2 z−2

1 + a1 z−1 + a2 z−2,

if zero initial conditions are assumed.

—- To be completed —-

1.5 Frequency Response of DT Systems

—- To be completed —-

1.6 First Order DT LPF

The system function of a first order DT LPF with a zero at z = −1 and a pole at z = r is

HL(z) = K1 + z−1

1− r z−1.

The frequency response of this system is

HL(ejΩ) = K1 + e−jΩ

1− r e−jΩ= K

1 + cos Ω− j sin Ω

1− r cos Ω + j r sin Ω

= K1 + e−jΩ

1− r e−jΩ

1− r ejΩ

1− r ejΩ= K

(1− r)(1 + cos Ω)− j(1 + r) sin Ω

1− 2r cos Ω + r2,

where the first form is more suitable for the computation of |HL(ejΩ)| and the second formis better suited for the computation of ∠HL(ejΩ). Note that

HL(ej0) = K2

1− r=⇒ select K =

1− r

2for a dc gain of 1.

With this value of K the magnitude squared of the frequency response is

|HL(ejΩ)|2 =(1− r)2

4

(1 + cos Ω)2 + sin2 Ω

(1− r cos Ω)2 + r2 sin2 Ω=

(1− r)2

4

2(1 + cos Ω)

1 + r2 − 2r cos Ω.

4

Page 5: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

The -3 dB (or half power) frequency Ω3 is thus defined implicitly as

|HL(ejΩ3)|2 =(1− r)2

4

2(1 + cos Ω3)

1 + r2 − 2r cos Ω3

=1

2.

From this it follows that

(1− r)2(1 + cos Ω3) = 1 + r2 − 2r cos Ω3 =⇒ cos Ω3 =2r

1 + r2.

Using the trigonometric identity

tan2(α

2

)=

1− cos α

1 + cos α,

this can be converted to

tan2(Ω3

2

)=

1− cos Ω3

1 + cos Ω3

=1 + r2 − 2r

1 + r2 + 2r=

(1− r)2

(1 + r)2=⇒ Ω3 = 2 tan−1

(1− r

1 + r

).

Another frequency of interest is Ω45, the frequency at which the phase response ∠H(ejΩ) is−45. The phase response of a first order DT LPF is (from the second form of H(ejΩ) givenabove)

∠H(ejΩ) = − tan−1( (1 + r) sin Ω

(1− r)(1 + cos Ω)

).

Therefore, Ω45 is defined by

(1 + r) sin Ω45

(1− r)(1 + cos Ω45)= 1 =⇒ 1− r

1 + r=

sin Ω45

1 + cos Ω45

= tan(Ω45

2

),

where the last equality is the trigonometric identity

tan(α

2

)=

sin α

1 + cos α.

The interpretation of the result is that Ω3 = Ω45 for a first order DT LPF, which is the sameproperty that a first order CT LPF has.

1.7 Second Order DT LPF

A second order DT LPF with poles at r e±jθ, |r| < 1, has system function

HL(z) = K(1 + z−1)2

(1− r ejθ z−1)(1− r e−jθ z−1)= K

(1 + z−1)2

1− 2r cos θ z−1 + r2 z−2.

Note that

HL(1) = K4

1− 2r cos θ + r2, and HL(−1) = 0 .

5

Page 6: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

For a dc gain of 1, set K to

K =1− 2r cos θ + r2

4=⇒ HL(z) =

1− 2r cos θ + r2

4

(1 + z−1)2

1− 2r cos θ z−1 + r2 z−2.

Multiplying top and bottom by z yields

HL(z) =1− 2r cos θ + r2

4

z + 2 + z−1

z − 2r cos θ + r2 z−1.

The frequency response of this system is

HL(ejΩ) =1− 2r cos θ + r2

4

ejΩ + 2 + e−jΩ

ejΩ − 2r cos θ + r2 e−jΩ.

Use Euler’s relation for e±jΩ to obtain

HL(ejΩ) =1− 2r cos θ + r2

4

2 (1 + cos Ω)

(1 + r2) cos Ω− 2r cos θ + j (1− r2) sin Ω.

Thus, the magnitude squared of the frequency response is

|HL(ejΩ)|2 =(1− 2r cos θ + r2)2

16

4 (1 + cos Ω)2((1 + r2) cos Ω− 2r cos θ

)2+ (1− r2)2 sin2 Ω

,

and the phase of the frequency response is

∠HL(ejΩ) = − tan−1( (1− r2) sin Ω

(1 + r2) cos Ω− 2r cos θ

).

To determine the normalized natural frequency Ω0, which is defined as the frequency atwhich the phase of the LPF is −90, look at

∠HL(ejΩ0) = − tan−1( (1− r2) sin Ω0

(1 + r2) cos Ω0 − 2r cos θ

)= −90 .

This is satisfied if

(1 + r2) cos Ω0 − 2r cos θ = 0 =⇒ cos Ω0 =2r

1 + r2cos θ.

Using the trigonometric formula

tan2(α

2

)=

1− cos α

1 + cos α=

sin2 α

(1 + cos α)2=

(1− cos α)2

sin2 α,

this result can be reformulated as

tan2(Ω0

2

)=

1− cos Ω0

1 + cos Ω0

=1 + r2 − 2r cos θ

1 + r2 + 2r cos θ,

6

Page 7: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

and thus

Ω0 = 2 tan−1(√

1 + r2 − 2r cos θ

1 + r2 + 2r cos θ

).

The frequency response at Ω0 is

HL(ejΩ0) =1− 2r cos θ + r2

4

2 (1 + cos Ω0)

(1 + r2) cos Ω0 − 2r cos θ︸ ︷︷ ︸= 0

+j(1− r2) sin Ω0

=1− 2r cos θ + r2

j 2(1− r2)

1 + cos Ω0

sin Ω0

=1− 2r cos θ + r2

j 2(1− r2)

(tan

(Ω0

2

))−1

=1− 2r cos θ + r2

j 2(1− r2)

√1 + r2 + 2r cos θ

1 + r2 − 2r cos θ=

√(1 + r2 − 2r cos θ)(1 + r2 + 2r cos θ)

j 2(1− r2)

=

√(1 + r2)2 − 4r2 cos2 θ

j 2(1− r2).

For a 2’nd order CT LPF HL(jω0) = 1/(j2ζ). Thus, for a 2’nd order DT LPF, the dampingratio ζ can be defined as

HL(ejΩ0) =

√(1 + r2)2 − 4r2 cos2 θ

j 2(1− r2)=

1

j 2ζ=⇒ ζ =

1− r2√(1 + r2)2 − 4r2 cos2 θ

.

1.8 Second Order DT BPF

Consider the following system function of a second order DT BPF

HB(z) = K(1− z−1)(1 + z−1)

(1− r ejθz−1)(1− r e−jθz−1)= K

1− z−2

1− 2r cos θ z−1 + r2 z−2,

with poles at z = re±jθ and zeros at z = ±1. Multiply top and bottom by z to obtain

HB(z) = Kz − z−1

z − 2r cos θ + r2 z−1.

The frequency response can then be written as

HB(ejΩ) = KejΩ − e−jΩ

ejΩ − 2r cos θ + r2 e−jΩ= K

2j sin Ω

(1 + r2) cos Ω− 2r cos θ + j(1− r2) sin Ω.

Thus, the phase of the frequency response of the BPF is

∠HB(ejΩ) = 90 − tan−1( (1− r2) sin Ω

(1 + r2) cos Ω− 2r cos θ

).

7

Page 8: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

For a BPF the normalized natural frequency Ω0 is defined as the frequency at which∠H(ejΩ) = 0. This occurs when the argument of the inverse tangent becomes infinity andtherefore

(1 + r2) cos Ω0 − 2r cos θ = 0 =⇒ cos Ω0 =2r

1 + r2cos θ .

Using the trigonometric identity for tan(α/2) this can also be written as

tan2(Ω0

2

)=

1− cos Ω0

1 + cos Ω0

=1 + r2 − 2r cos θ

1 + r2 + 2r cos θ=⇒ Ω0 = 2 tan−1

(√1 + r2 − 2r cos θ

1 + r2 + 2r cos θ

),

which is the same result as the one found for the 2’nd order DT LPF. Using (1+ r2) cos Ω0−2r cos θ = 0 in HB(ejΩ) at Ω = Ω0 yields

HB(ejΩ0) = K2j sin Ω0

(1 + r2) cos Ω0 − 2r cos θ︸ ︷︷ ︸= 0

+j(1− r2) sin Ω0

= K2j sin Ω0

j(1− r2) sin Ω0

= K2

1− r2.

Since Ω0 is also the center frequency of a second order BPF, the choice

K =1− r2

2,

adjusts the maximum gain of the BPF to 1 at the center frequency Ω0.

1.9 Frequency Response Measurement for DT Systems

The simplest way to measure the magnitude of the frequency response of a DT system inSimulink is to use a sweeping sinusoid (“chirp” signal) with a desired frequency range asinput signal and then to display the absolute value (or the logarithm of the absolute value)of the signal at the output of the DT system. Consider the following first order system.

8

Page 9: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

To generate a DT sinusoidal input signal xn with a sweeping frequency from 0.01 to π radon a logarithmic scale, the following Matlab code can be used:

WW1 = 0.01; %Normalized start frequency [rad]

WW2 = pi; %Normalized end frequency [rad]

nlen = 10000; %# of samples for chirp

nn = [0:nlen]; %Index n axis

WW = logspace(log10(WW1),log10(WW2),length(nn));

%Log-spaced W axis

theta = cumsum(WW); %Phase theta[n] for chirp signal

xn = cos(theta); %Sweeping cosine (chirp) signal

To run the Simulink model with this input for the case when

H(z) = K1 + z−1

1− a1 z−1, with K =

1− a1

2, and a1 = 0.8 ,

the Matlab code shown next is added:

a1 = 0.8; %Pole location

b = (1-a1)/2*[1 1]; %Numerator of H(z)

a = [1 -a1]; %Denominator of H(z)

t = nn’; %Input for Simulink model

u = xn’;

sim(’DT1sys001’,[t(1) t(end)]) %Run Simulink model

%Fixed step (size 1), discrete solver

yn = yout’; %Sinusoidal response of model

The Configuration Parameters used for running the Simulink model are:

• Solver Type: Fixed-step

• Solver: Discrete (no continuous states)

• Fixed-step size: 1

• Input: [t,u], checked

• Limit data points to last: 1000, unchecked

A plot of 20 log10

(|H(ejΩ)|

)versus Ω on a logarithmic scale is shown below.

10−2

10−1

100

101

−50

−40

−30

−20

−10

0

10

Ω [rad] (log scale)

20lo

g 10|H

(ejΩ

)| [d

B]

Frequency Response of DT System, b=[0.1,0.1], a=[1,−0.8]

9

Page 10: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

When it is desired to use a linear Ω axis, the chirp signal can be generated as

WW1 = 0; %Normalized start frequency [rad]

WW2 = pi; %Normalized end frequency [rad]

nlen = 10000; %# of samples for chirp

nn = [0:nlen]; %Index axis

WW = linspace(WW1,WW2,length(nn));

%Lin-spaced W axis

theta = cumsum(WW); %Phase theta[n] for chirp signal

xn = cos(theta); %Sweeping cosine (chirp) signal

The graph below shows |H(ejΩ)| versus a linear Ω/π axis for the same DT system as before.

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.2

0.4

0.6

0.8

1

Ω/π

|H(e

jΩ)|

Frequency Response of DT System, b=[0.1,0.1], a=[1,−0.8]

1.10 Step-Invariant CT to DT Conversion

If a CT system is replaced by a DT system, not all features of the CT system (even if itis bandlimited) can be preserved. If it is important to duplicate the unit step response asclosely as possible, then a step-invariant CT to DT conversion can be used. Starting fromthe CT system function H(s) one can obtain G(s) and, using the inverse Laplace transform,the CT unit step response g(t). Using a sampling rate Fs = 1/Ts, the DT unit step responsethen becomes gn = g(n Ts). The z-transform of gn is G(z) which then leads to the DT systemfunction as H(z) = (1−z−1) G(z).

Example: Step-Invariant 1’st Order LPF CT to DT Conversion. Start from theCT LPF

H(s) =ωL

s+ωL

=⇒ G(s) =ωL

s (s+ωL)=

1

s− 1

s+ωL

=⇒ g(t) =(1−e−ωLt

)u(t) .

Next, sampling g(t) at t = n Ts yields

gn = g(n Ts) =(1− e−ΩLn

)un

=⇒ G(z) =1

1− z−1− 1

1− e−ΩL z−1=

(1− e−ΩL) z−1

(1− z−1) (1− e−ΩL z−1),

10

Page 11: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

where ΩL = ωL/Fs. From this the DT system function is obtained as

H(z) = (1− z−1) G(z) =(1− e−ΩL) z−1

1− e−ΩL z−1=

1− e−ΩL

z − e−ΩL.

Thus, H(z) has a pole p1 = e−ΩL , a zero at infinity, and

H(1) = 1 (dc gain) , and H(−1) = −1− e−ΩL

1 + e−ΩL(gain at Ω = π) .

Graphs of g(t) and gn = g(nTs) are shown in the figure below for ωL = 5 rad/sec and Fs = 10Hz.

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

t [sec]

g(t)

, gn=

g(nT

s)

Step Invariant LPF CT −> DT, ωL=5, F

s=10 Hz, F

ss=1000 Hz

CT: g(t)DT: g(n/Fs)

The sampling rate Fss is the rate that was used to simulate the CT model in Simulink. Asexpected, the unit step response of the DT and the CT systems are identical at the samplingtime instants. But for the magnitude and the phase of the frequency response shown below,discrepancies between the DT and the CT system are clearly visible.

11

Page 12: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 5 10 15 20 25 30 35 40 45 500

0.2

0.4

0.6

0.8

1

ω [rad/sec]

|H(jω

)|, |

H(e

jω/F

s )|

Step Invariant LPF CT −> DT, ωL=5, F

s=10 Hz

CT: |H(jω)|

DT: |H(ejω/Fs)|

0 5 10 15 20 25 30 35 40 45 50−300

−250

−200

−150

−100

−50

0

ω [rad/sec]

∠H

(jω),

∠H

(ejω

/Fs )

[deg

]

CT: ∠H(jω)

DT: ∠H(ejω/Fs)

Note that the frequency response plots were generated using the freqs (for the CT system)and the freqz (for the DT system) commands in Matlab.

Example: Step-Invariant 2’nd Order LPF CT to DT Conversion. A second orderCT LPF with natural frequency ω0 and damping ratio ζ, 0 < ζ ≤ 1, has system function

H(s) =ω2

0

s2 + 2ζω0 s + ω20

=ω2

0

(s + α− jβ)(s + α + jβ),

where α = ζω0 and β =√

(1ζ2). Note that α2 +β2 = ω20. The unit step response is obtained

from

G(s) =ω2

0

s (s + α− jβ)(s + α + jβ)=

A

s+

B

s + α− jβ+

B∗

s + α + jβ,

asg(t) = A + B e−αtejβt + B∗ e−αte−jβt , for t > 0 ,

where A = 1 and

B =ω2

0

s(s+α+jβ)

∣∣∣s=−α+jβ

=ω2

0

(−α+jβ)2jβ=−ω2

0/(2β)

β + jα= −β − jα

2β=−1

2+

2β.

Note that

|B| = ω0

2β=

1

2√

1−ζ2, and ∠B = tan−1

( α

−β

)= π − tan−1

β

).

12

Page 13: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

Sampling g(t) at t = nTs, where Fs = 1/Ts is the sampling rate, yields

g(nTs) = A + B e−αnTsejβnTs + B∗ e−αnTse−jβnTs , for n ≥ 0 .

Define

gn = g(nTs) , Ωα =α

Fs

=ζω0

Fs

, Ωβ =β

Fs

=

√1− ζ2 ω0

Fs

,

and rewrite the sampled step response as

gn = A + B e−ΩαnejΩβn + B∗ e−Ωαne−jΩβn , for n ≥ 0 .

The z-transform of this is

G(z) =A

1− z−1+

B

1− e−ΩαejΩβ z−1+

B∗

1− e−Ωαe−jΩβ z−1.

To obtain the DT system function H(z), multiply by 1− z−1:

H(z) = A +B(1− z−1)

1− e−ΩαejΩβ z−1+

B∗(1− z−1)

1− e−Ωαe−jΩβ z−1=

b0 + b1 z−1 + b2 z−2

1− 2e−Ωα cos Ωβ z−1 + e−2Ωα z−2,

whereb0 = A + B + B∗ = 0 ,

b1 = −2e−Ωα(A cos Ωβ + |B| cos(−Ωβ + ∠B)

)− 2ReB ,

b2 = Ae−2Ωα + 2|B|e−Ωα cos(−Ωβ + ∠B) .

Plots of g(t) and gn = g(nTs) are shown in the following figure for ω0 = 5 rad/sec, ζ = 1/2,when Fs = 10 Hz.

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50

0.2

0.4

0.6

0.8

1

1.2

1.4

t [sec]

g(t)

, gn=

g(nT

s)

Step Invariant LPF Order 2 CT −> DT, ω0=5, ζ=0.5, F

s=10 Hz, F

ss=1000 Hz

CT: g(t)DT: g(n/Fs)

As can be seen, the step responses of the CT and DT systems are identical at the samplingtime instants. But the next two plots show that the magnitude and the phase responses ofthe CT and DT systems differ, especially near ω = π Fs.

13

Page 14: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 5 10 15 20 25 30 35 40 45 50−50

−40

−30

−20

−10

0

10

ω [rad/sec]

|H(jω

)|, |

H(e

jω/F

s )|

Step Invariant LPF Order 2 CT −> DT, ω0=5, ζ=0.5, F

s=10 Hz

CT: |H(jω)|

DT: |H(ejω/Fs)|

0 5 10 15 20 25 30 35 40 45 50−250

−200

−150

−100

−50

0

ω [rad/sec]

∠H

(jω),

∠H

(ejω

/Fs )

[deg

]

CT: ∠H(jω)

DT: ∠H(ejω/Fs)

1.11 Step Response Measurement for DT Systems

To generate and display the step response gn of a DT system in Simulink, start from gener-ating an index axis nn and a unit step un as shown below.

nlen = 50; %# of samples for g[n]

nstep = 5; %Step index

nn = [0:nlen]; %Index axis for g[n]

un = zeros(size(nn)); %Prepare unit step

ix = find(nn>=nstep); %Unit step starts at nstep

un(ix) = ones(size(ix)); %DT unit step signal

Note that nlen and nstep may have to be adjusted depending on the properties of thesystem to be measured. To obtain the step response of a first order DT system with

H(z) = K1 + z−1

1− a1 z−1, with K =

1− a1

2, and a1 = 0.8 ,

the following Matlab code can be used:

14

Page 15: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

a1 = 0.8; %Pole location

b = (1-a1)/2*[1 1]; %Numerator of H(z)

a = [1 -a1]; %Denominator of H(z)

t = nn’; %Input for Simulink model

u = un’;

sim(’DT1sys001’,[t(1) t(end)]) %Run Simulink model

%Fixed step (size 1), discrete solver

gn = yout’; %Step response

The Configuration Parameters used for running the Simulink model are:

• Solver Type: Fixed-step

• Solver: Discrete (no continuous states)

• Fixed-step size: 1

• Input: [t,u], checked

• Limit data points to last: 1000, unchecked

The graph below shows the unit step response of the DT system.

0 5 10 15 20 25 30 35 40 45 500

0.2

0.4

0.6

0.8

1

n

g[n]

Step Response of DT System, b=[0.1,0.1], a=[1,−0.8]

The command that was used to produce the stem plot in Matlab is

stem(nn,gn,’.-r’)

1.12 Application: FSK Data Transmission

Frequency shift keying (FSK) is a data transmission method for digital data that uses sinu-soids with different frequencies to transmit different data values. The simplest case is binaryFSK which uses two different frequencies, f0 to transmit binary 0 or “space” (S) and f1 totransmit binary 1 or “mark” (M). One way to describe a binary FSK signal s(t) is as follows.Let dn be the binary data sequence that is to be transmitted and define

d0[n] =

1 , if dn = 0,0 , if dn = 1 ,

d1[n] = dn .

15

Page 16: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

Then use the DT sequences d0[n] and d1[n] to define the two CT data waveforms

d0(t) =∞∑

n=0

d0[n] p(t− nTB) , and d1(t) =∞∑

n=0

d1[n] p(t− nTB) ,

where FB = 1/TB is the symbol or baud rate at which the data is transmitted and p(t) is arectangular pulse of width TB and amplitude 1, i.e.,

p(t) =

1 , if 0 ≤ t < TB,0 , otherwise .

The next step is to convert d0(t) and d1(t) to sinusoidal on-off signals s0(t) and s1(t) withfrequencies f0 and f1 by setting

s0(t) = d0(t) cos(2πf0t + θ0) , and s1(t) = d1(t) cos(2πf1t + θ1) .

In general, the phases θ0 and θ1 of s0(t) and s1(t) could be fixed or time varying and mayor may not be known at the receiving end. Finally, the complete binary FSK signal is

s(t) = s0(t) + s1(t) = d0(t) cos(2πf0t + θ0) + d1(t) cos(2πf1t + θ1) .

An example of an FSK signal with FB = 100 baud, f0 = 300 Hz, f1 = 200 Hz is shown belowfor the data sequence dn = [1, 1, 0, 1, 0, 0, 1, 0, 1, 1].

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

−1

0

1

d 0(t),

s0(t

)

FSK Example: f0=300 Hz, f

1=200 Hz, F

B=100 Baud, d

n=[1,1,0,1,0,0,1,0,1,1]

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

−1

0

1

d 1(t),

s1(t

)

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−1.5

−1

−0.5

0

0.5

1

1.5

d 1(t),

s(t

)

t [sec]

16

Page 17: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

The first graph shows d0(t) (dashed, green) and s0(t) (solid, blue) and the second graphshows d1(t) (dashed, green) and s1(t) (solid, blue). The third graph shows the FSK signals(t) that actually transmits the data sequence dn, and the data pattern is easy to see directlyby visual inspection.

Let r(t) = γs(t), where γ represents the attenuation of the transmission channel, be areceived binary FSK signal. The goal of an FSK receiver is to recover the transmitted datasequence dn, despite the unknown channel attenuation, phase and frequency errors, and noisepicked up during the transmission. Conceptually, the simplest way to do this is is to usetwo bandpass filters (BPF), one centered at f0 and one centered at f1. At suitably chosensampling time instants TB seconds apart, the average power (averaged over TB seconds) atthe outputs of the BPFs is compared and dn is set to one if the average power at f1 is largerthan the average power at f0; otherwise dn is set to zero.

Another approach is to use the fact that the product of two sinusoids with frequencies fa

and fb yields the sum of two sinusoids, one at the difference frequency fa− fb and the otherone at the sum frequency fa + fb. In this way the signal s0(t) can be shifted down to dc(or baseband) by multiplication with a sinusoid with frequency f0, and s1(t) can be shifteddown to dc (or baseband) by multiplication with a sinusoid with frequency f1. One slightproblem is that in general the phases of the sinusoids that were used at the transmitter arenot known at the receiver. This problem can be solved by multiplying the received signalwith both a sine and a cosine at the frequencies f0 and f1 at the receiver. The block diagramof a FSK receiver that uses this strategy is shown in the figure below.

×

−2 sin 2πf0t

×

2 cos 2πf0t

×

−2 sin 2πf1t

×

2 cos 2πf1t

LPFat fL

(.)2

LPFat fL

(.)2

LPFat fL

(.)2

LPFat fL

(.)2

+

+

r(t)

d21(t)

d20(t)

+

+

+

+

v1i(t) v1Li(t)

v1q(t) v1Lq(t)

v0i(t) v0Li(t)

v0q(t) v0Lq(t)

Using the trigonometric identities

cos α cos β =1

2

[cos(α−β)+cos(α+β)

], and −cos α sin β =

1

2

[sin(α−β)−sin(α+β)

],

17

Page 18: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

the quantity v0i(t) after multiplication of r(t) with 2 cos 2πf0t is computed as

v0i(t) = 2r(t) cos 2πf0t = 2γ(d0(t) cos(2πf0t + θ0) + d1(t) cos(2πf1t + θ1)

)cos 2πf0t

= γd0(t) cos θ0 + γd0(t) cos(4πf0t + θ0)+

+γd1(t) cos(2π(f1 − f0)t + θ1) + γd1(t) cos(2π(f1 + f0)t + θ1) .

The main term of interest is the underlined γd0(t) cos θ0. All other terms are at higherfrequencies, like 2f0, and |f1 ± f0|. Thus, if the LPF at fL is designed to reject thesefrequencies, then v0Li = γd0(t) cos θ0. The quantity v0q(t) is similarly computed as

v0q(t) = −2r(t) sin 2πf0t = −2γ(d0(t) cos(2πf0t + θ0) + d1(t) cos(2πf1t + θ1)

)sin 2πf0t

= γd0(t) sin θ0 − γd0(t) sin(4πf0t + θ0)+

+γd1(t) sin(2π(f1 − f0)t + θ1)− γd1(t) sin(2π(f1 + f0)t + θ1) .

Except for the term of interest (underlined), all other terms are at higher frequencies, namely2f0, and |f1±f0|. Thus, using an LPF that rejects these terms, results in v0Lq = γd0(t) sin θ0.But note that the LPFs need to have sufficient bandwidth to pass a data sequence of al-ternating 0’s and 1’s which has a fundamental frequency of FB/2. The last step needed toobtain an estimate d2

0(t) of d0(t) is

d20(t) =

(γd0(t) cos θ0

)2+

(γd0(t) sin θ0

)2= γ2d2

0(t) .

The quantities v1Li(t) and v1Lq(t) are obtained using entirely analogous computations as

v1Li(t) = γd1(t) cos θ1 , and v1Lq(t) = γd1(t) sin θ1 ,

and thus the estimate d21(t) of d1(t) is

d21(t) =

(γd1(t) cos θ1

)2+

(γd1(t) sin θ1

)2= γ2d2

1(t) .

From d20(t) and d2

1(t) the CT version d(t) of the received data sequence dn can be obtainedas

d(t) =

1 , if d2

1(t)¿d20(t) ,

0 , otherwise ,

for any given value of t. Finally, dn is recovered by sampling d(t) as

dn = d(nTB + τ) ,

where τ is a suitably chosen delay which compensates for the delay through the LPFs at thereceiver.

The next figure shows v0i(t), v0Li(t), v0q(t), v0Lq(t), v1i(t), v1Li(t), and v1q(t), v1Lq(t), for thesample FSK signal that was given earlier. The LPFs that were used to produce the graphswere 2’nd order LPFs with ω0 = 2πFB/2 and ζ = 1/2.

18

Page 19: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−2

0

2

v 0i(t

), v

0Li(t

)

FSK Receiver: f0=300 Hz, f

1=200 Hz, F

B=100 Baud, d

n=[1,1,0,1,0,0,1,0,1,1]

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−2

0

2

v 0q(t

), v

0Lq(t

)

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−2

0

2

v 1i(t

), v

1Li(t

)

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−2

0

2

v 1q(t

), v

1Lq(t

)

t [sec]

The next set of graphs shows d20(t), d2

1(t), d(t), and the sampled values at times t = nTB + τ .The sampling delay τ is approximately equal to TB.

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10

1

2

dhat

02 (t)

FSK Receiver: f0=300 Hz, f

1=200 Hz, F

B=100 Baud, d

n=[1,1,0,1,0,0,1,0,1,1]

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10

1

2

dhat

12 (t)

0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1−0.5

0

0.5

1

1.5

dhat

(t)

t [sec]

19

Page 20: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

From the samples in the last graph it is easy to see that the transmitted data sequence canbe successfully recovered at the receiver.

2 Prelab Questions

P1. Phase Shift of First Order DT Filters. Let

H(z) = K1− z1 z−1

1− p1 z−1,

be the system function of a first order DT system. Assuming that the system is BIBO stableand |z1| < 1, determine for which values of p1 and z1 the phase ∠H(ejΩ) of the frequencyresponse is > 0 and for which it is < 0.

P2. Pole-Zero Specification of DT System. The following pole-zero plot defines asecond order DT system with real poles at a and −a.

Rez

Imz

1

1

a-a

0 < a < 1

Determine the system function H(z) such that maxΩ H(ejΩ) = 1. What type of filter is this?What is the unit step response gn of this system?

P3. Step Invariant CT to DT System Conversion. (a) Start from the CT systemwith system function

H(s) =s

s + ωx

.

Determine the system function H(z) of the corresponding step-invariant DT system.

(b) Repeat (a) for the CT system with system function

H(s) =2ζω0 s

s2 + 2ζω0 s + ω20

.

Assume that 0 < ζ ≤ 1.

20

Page 21: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

3 Lab Experiments

E1. Pole/Zero Placement for First and Second Order DT Systems. The goal ofthis experiment is to explore the relationship between pole/zero placement and the step andfrequency responses of first and second order DT systems. Use the Simulink model shownbelow for first order DT systems.

The Simulink model shown in the next figure is used to simulate second order DT systems.

In both cases use the following Configuration Parameters for running the Simulink model:

• Solver Type: Fixed-step

• Solver: Discrete (no continuous states)

• Fixed-step size: 1

21

Page 22: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

• Input: [t,u], checked

• Limit data points to last: 1000, unchecked

(a) Let H(z) be the first order system function

H(z) = K1− z1 z−1

1− p1 z−1,

with zero z1 and pole p1. Make plots of the magnitude of the frequency response |H(ejΩ)|,the unit step response gn, and the pole/zero locations for the following combinations of polesand zeros: p1 = 0.9, 0.3 and z1 = 0,−1, +1 (6 combinations). In each case choose K suchthat the passband gain (dc gain for LPF, center frequency gain for BPF, gain at highestfrequency for HPF) of H(z) is 1. If the -3 dB frequency is much smaller than π, display themagnitude of the frequency response in dB versus Ω on a logarithmic scale, as shown in theexample below.

10−2

10−1

100

101

−50

−40

−30

−20

−10

0

10

Ω3 Ω [rad] (log scale)

20lo

g 10|H

(ejΩ

)| [d

B]

Frequency Response of DT System, b=[0.05,0], a=[1,−0.95]

0 50 100 150 2000

0.2

0.4

0.6

0.8

1

n

g[n]

Step Response

−1 −0.5 0 0.5 1−1

−0.5

0

0.5

1

Rez

Imz

Pole−Zero Plot

If the -3 dB frequency is close to 1 or larger, then use a linear display for |H(ejΩ)| as shownin the next example.

22

Page 23: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 0.5 1 1.5 2 2.5 3 3.50

0.2

0.4

0.6

0.8

1

Ω3 Ω [rad]

|H(e

jΩ)|

Frequency Response of DT System, b=[0.45,0.45], a=[1,−0.1]

0 2 4 6 8 100

0.2

0.4

0.6

0.8

1

n

g[n]

Step Response

−1 −0.5 0 0.5 1−1

−0.5

0

0.5

1

Rez

Imz

Pole−Zero Plot

For which values of z1 do you get LPFs? For which do you get HPFs? What happensif z1 = 1/p1 is selected? For which values of p1 can you use a straight line Bode plotapproximation for |H(ejΩ)| over at least one decade to the left and to the right of the -3dBfrequency?

(b) Let H(z) be the second order DT system function

H(z) = K(1− z1 z−1)(1− z2 z−1)

(1− rejθ z−1)(1− re−jθ z−1),

with zeros z1, z2, poles re±jθ and gain factor K. Now there are essentially three quantitiesthat determine the behavior of the system: The location of the zeros, often at z = 1, z = −1,or both, the magnitude r, and the angle θ of the complex conjugate poles. Consider thefollowing three sets of zero locations: z1 = z2 = −1, z1 = −1, z2 = 1, and z1 = z2 = 1. Makeplots of the magnitude of the frequency response |H(ejΩ)|, the unit step response gn, and thepole/zero locations for the three sets of zero locations and the following r, θ combinations:

(i) r = 0.93, θ = 4.

(ii) r = 0.98, θ = 4.

(iii) r = 0.5, θ = 50.

(iv) r = 0.8, θ = 50.

23

Page 24: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

In each case adjust the gain factor K so that the passband gain of the system is 1. Whatdetermines whether H(z) is the system function of a LPF, BPF, or HPF? Try to determinethe natural frequency Ω0 and the damping factor ζ for each of the cases above. Whichparameters determine the values of Ω0 and ζ? Hint: In addition to using Simulink, consideralso using the freqz command to plot the magnitude and the phase of the frequency response.Depending on the pole locations you may want to choose between a logarithmic or a lineardisplay of the frequency response. For which of the above cases would a straight line Bodeplot approximation be useful? For which would it not be useful? Here is an example of alogarithmic frequency response display when r = 0.98 and θ = 45. The purple lines showthe sinusoidal output from the Simulink simulation with a chirp signal. The blue line wascomputed using the freqz command.

10−2

10−1

100

101

−60

−50

−40

−30

−20

−10

0

Ω [rad] (log scale)

20lo

g 10|H

(ejΩ

)| [d

B]

Frequency Response of DT System, b=[0.0198,0,−0.0198], a=[1,−1.39,0.96]

0 20 40 60 80 100−0.05

0

0.05

n

g[n]

Step Response

−1 −0.5 0 0.5 1−1

−0.5

0

0.5

1

Rez

Imz

Pole−Zero Plot

The next figure shows the same system with a linear frequency response display for Ω =0 . . . π.

24

Page 25: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 0.5 1 1.5 2 2.5 3 3.50

0.2

0.4

0.6

0.8

1

Ω31

Ω32 Ω [rad]

|H(e

jΩ)|

Frequency Response of DT System, b=[0.0198,0,−0.0198], a=[1,−1.39,0.96]

0 20 40 60 80 100−0.05

0

0.05

n

g[n]

Step Response

−1 −0.5 0 0.5 1−1

−0.5

0

0.5

1

Rez

Imz

Pole−Zero Plot

The lines at Ω31 and Ω32 show the locations of the lower and upper -3dB frequencies of thisBPF.

(c) Suppose you would like to design a second order DT LPF with Ω0 = 0.5 radians andζ = 1/2. Find z1, z2, r, and θ of the corresponding system function. Determine K such thatthe dc gain is 1. How easy (or difficult) is it to find these parameters by trial and error? thefigure below shows |H(ejΩ)| and gn of the desired LPF

25

Page 26: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 0.5 1 1.5 2 2.5 3 3.50

0.2

0.4

0.6

0.8

1

1.2

1.4

Ω [rad]

|H(e

jΩ)|

Frequency Response of DT System, with Ω0=0.5 and ζ=0.5

0 5 10 15 20 25 300

0.2

0.4

0.6

0.8

1

1.2

1.4

n

g[n]

Step Response

E2. Comparison of CT Systems and their DT Replacements. Modern signal pro-cessing implementations use programmable digital hardware whenever possible. A task thatis encountered frequently is to convert an idea or a concept or an existing implementationfrom continuous time to discrete time. Because of the periodic nature of the frequency re-sponse of DT systems, a perfect match between CT and DT systems in both the time andfrequency domains is impossible for practical implementations. Starting from a given CTsystem, the goal of this experiment is to determine an approximate DT equivalent and tocompare the performance of the two systems in terms of their unit step response and themagnitude and the phase of the frequency response. In Simulink, use the same DT modelsand Configuration Parameter settings as in experiment 1. For first and second order CTsystems use the following CT models.

26

Page 27: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

Because Simulink has to use discrete time instants for both continuous time and discrete timesystem simulations, two sampling frequencies have to be used. One, which will be denotedby Fss, is the sampling rate used to simulate the CT system. The other one, denoted by Fs,is the sampling rate of the DT system that is supposed to replace the CT system. Typically,Fss Fs, e.g., Fss = 10 . . . 100Fs. Here is some sample Matlab code that can be used as astarting point to generate the unit step responses g(t) and gn:

27

Page 28: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

Fs = ... %Sampling rate DT system

Fss = 100*Fs; %Sampling rate CT system

bCT = ... %Numerator of H(s)

aCT = ... %Denominator of H(s)

bDT = ... %Numerator of H(z)

aDT = ... %Denominator of H(z)

nlen = 100; %Number of samples for g[n]

nstep = 10; %Step index of u[n]

un = zeros(size(nn)); %Prepare DT unit step

ix = find(nn>=nstep);

un(ix) = ones(size(ix)); %DT unit step

b = bDT; %DT model parameters

a = aDT;

t = nn’; %Input for Simulink model

u = un’;

sim(’DTsys’,[t(1) t(end)]) %Run DT Simulink model

%Fixed step (1) discrete solver

gn = yout’; %DT step response

tlen = nlen/Fs; %Duration of g(t) in sec

tstep = nstep/Fs; %Step time of u(t)

tt = [0:round(tlen*Fss)-1]/Fss; %Time axis for g(t)

ut = zeros(size(tt)); %Prepare CT unit step

ix = find(tt>tstep);

ut(ix) = ones(size(ix)); %CT unit step

b = bCT; %CT model parameters

a = aCT;

t = tt’; %Input for Simulink model

u = ut’;

sim(’CTsys’,[t(1) t(end)]) %Run CT Simulink model

%Fixed step (1/Fss) ode3 solver

gt = yout’; %CT Step response

The Configuration Parameters for running the CT Simulink model are:

• Solver Type: Fixed-step

• Solver: ode3 (Bogacki-Shampine)

• Fixed-step size: 1/Fss

• Input: [t,u], checked

• Limit data points to last: 1000, unchecked

Here is an example of a step-invariant CT to DT conversion of a 1’st order LPF withωL = 5000 rad/sec, Fs = 1/Ts = 8000 Hz, and Fss = 800000 Hz. The unit step responsesg(t) and gn are identical at times t = nTs.

28

Page 29: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

0 0.5 1 1.5 2 2.5 3 3.5 4

x 10−3

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

t [sec]

g(t)

, gn=

g(nT

s)

Step Invariant LPF Order 1 CT −> DT, ωL=5000, F

s=8000 Hz, F

ss=800000 Hz

CT: g(t)DT: g(n/Fs)

The magnitude and the phase of the frequency responses of the CT and DT systems, com-puted using the freqs and freqz commands, respectively, are shown next.

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

−25

−20

−15

−10

−5

0

ω [rad/sec]

|H(jω

)|, |

H(e

jω/F

s )|

Step Invariant LPF Order 1 CT −> DT, ωL=5000, F

s=8000 Hz

CT: |H(jω)|

DT: |H(ejω/Fs)|

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

−400

−300

−200

−100

0

ω [rad/sec]

∠H

(jω),

∠H

(ejω

/Fs )

[deg

]

CT: ∠H(jω)

DT: ∠H(ejω/Fs)

There are clearly some differences here, especially for ω near πFs and beyond. Note that theunwrap command was used for the phase to remove phase jumps by ±360. It is instructiveto compare this also with a DT LPF with system function

H(z) =1− r

2

1 + z−1

1− r z−1.

29

Page 30: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

This has a pole at r. But the main difference is that it has a zero at z = −1, whereas thestep-invariant DT system has no finite zero. The graph below shows the unit step responsesof the CT system and the two DT systems. The value of r for the 2nd DT system isr = 0.5116.

0 0.5 1 1.5 2 2.5 3 3.5 4

x 10−3

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

t [sec]

g(t)

, gn=

g(nT

s)

Step Invariant LPF Order 1 CT −> DT, ωL=5000, F

s=8000 Hz, F

ss=800000 Hz

CT: g(t)DT1: g(n/Fs)DT2: g(n/Fs)

In the frequency response which is shown below for all three systems, the efect of placing azero at z = −1 for the second DT system is clearly visible.

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

−30

−25

−20

−15

−10

−5

0

ω [rad/sec]

|H(jω

)|, |

H(e

jω/F

s )|

Step Invariant LPF Order 1 CT −> DT, ωL=5000, F

s=8000 Hz

CT: |H(jω)|

DT1: |H(ejω/Fs)|

DT2: |H(ejω/Fs)|

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

x 104

−400

−300

−200

−100

0

100

ω [rad/sec]

∠H

(jω),

∠H

(ejω

/Fs )

[deg

]

CT: ∠H(jω)

DT1: ∠H(ejω/Fs)

DT2: ∠H(ejω/Fs)

30

Page 31: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

(a) Replacement of first order CT LPF with system function

HL(s) =ωL

s + ωL

,

by either a first order step-invariant DT system (DT1) or a first order DT system with a poleat z = r and a zero at z = −1 (DT2). Let ωL = 1000 rad/sec and determine the minimumsampling rate Fs needed for both DT replacements if the following requirements are set:

(i) The unit step response gn has to satisfy gn−gn−1 ≤ 0.2 fo all n and |g(nTs)−gn| ≤ 0.02for all n. Adjust the value of r for the second DT system (DT2) as necessary.

(ii) The phase of the frequency response has to satisfy |∠HL(jω)− ∠HL(ejω/Fs)| ≤ 5 for0 ≤ ω ≤ 2ωL. Adjust the value of r for the second DT system (DT2) as necessary.

(b) Replacement of second order CT LPF with system function

HL(s) =ω2

0

s2 + 2ζω0 s + ω20

,

by either a second order step-invariant DT system (DT1) or a second order DT system withpoles at z = rejθ and a double zero at z = −1 (DT2). Let ω0 = 1000 and ζ = 0.46 anddetermine the minimum sampling rate Fs needed for both DT replacements if the followingconditions have to be met:

(i) The maximum overshoot of gn has to be between 18% and 20% and the -3 dB frequencyof the DT system has to be within ±5% of the -3 dB frequency of the CT system.Adjust the values of r and θ for the second DT system (DT2) as necessary.

(ii) The maximum overshoot of gn has to be between 18% and 20% and the magnitude ofthe frequency response in decibel of the DT system can differ by at most 2 dB fromthe magnitude of the frequency response in decibel of the CT system for frequenciesin the range ω = 0 . . . 10000 rad/sec. Adjust the values of r and θ for the second DTsystem (DT2) as necessary.

E3. Design of a Receiver for FSK Signals. The goal of this experiment is to demodulatebinary FSK signals and extract the received ASCII text messages. The parameters used forthe FSK signals are identical to the ones that are used for caller ID in the US. The baud (orsymbol) rate is 1200 baud. The frequency to transmit a binary 0 (or “space”) is f0 = 2200Hz and the frequency to transmit a binary 1 (or “mark”) is f1 = 1200 Hz. A known testsignal with the text “The quick brown fox jumps over the lazy dog, 0123456789.” is recordedin the wav file FSKsig001.wav with a sampling rate Fs = 12000 Hz. The ASCII text uses8 bits per character and the parallel to serial conversion is done such that the LSB (leastsignificant bit) is transmitted first, in the same way as described for Lab 2.

(a) Write a Matlab script that reads an FSK signal from a wav file and processes it usingthe FSK receiver described in the introduction. For the LPFs design 2’nd order DT LPFs

31

Page 32: Lab 4: First/Second Order DT Systems and a Commu- nications …ecee.colorado.edu/~mathys/ecen3300/pdf/lab04.pdf · Lab 4: First/Second Order DT Systems and a Commu-nications Example

with natural frequencies (in Hz) approximately equal to FB/2. Choose a ζ such that thestep response of the LPF has an overshoot of about 10 . . . 15%. Implement the LPFs usingSimulink. Use the test FSK signal in FSKsig001.wav to test the correct operation of yourreceiver.

(b) Use the receiver you designaed in (a) to extract the text message from the binary FSKsignal in FSKsig002.wav.

c©2002–2010, P. Mathys. Last revised: 03-09-10, PM.

32