Sie sind auf Seite 1von 93

Pakpong Chirarattanaon

MBE4039
Computer Controlled Systems

April 10, 2017

Semester B 2016/17
City University of Hong Kong
Contents

1 Review of Continuous Control 7


1.1 Introduction to Digital Control 7
1.2 Differential Equations 7
1.3 Laplace Transforms and Transfer Functions 8
1.4 Final Value Theorems 8
1.5 Block Diagrams 9
1.6 Stability 9
1.7 Steady-State Errors 9
1.8 PID Control 10
1.9 Frequency Response 10
1.10 Response versus Pole Locations 11

2 Introductory Digital Control 13


2.1 Digitization 13
2.2 Digital Signals 14
2.3 Sampling and Effects of Sampling 15
2.4 Linear Difference Equations 15
2.5 Z-Transform 17
2.6 Transfer Function 19
2.7 Time Response 19
2.8 Frequency Response 20

3 State Space Methods 23


3.1 Discrete-Time State Space Model 23
3.2 Difference Equation to State Space 23
3.3 State Space Model to Transfer Function 25
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

3.4 Discretization of Linear Continuous-Time State Space Models 25


3.5 Stability 28
3.6 Pole Placement 28
3.7 Reference Input 30
3.8 Estimator Design 34

4 Design using Transform Methods 37


4.1 Design of Discrete Equivalents via Numerical Integrations 37
4.2 Direct Design by Root Locus 39
4.3 Frequency Reponse Methods 40

5 Robot Control 45
5.1 Linearization 45
5.2 Proportional, Integral, and Derivative 46
5.3 Low-Pass Filtering 46
5.4 Case Study: Mobile Robot 47

A Tutorial 1: Review of Continuous Control 53


A.1 Lead-Lag Compensator 53
A.2 Final Value Theorem 53
A.3 Feedback System 53

B Tutorial 2: Introductory Digital Control I 55


B.1 Time Shifts 55
B.2 Stability of a Discretized System 55
B.3 Sampling Rate 55
B.4 The zTransform 56

C Tutorial 3: Introductory Digital Control II 57


C.1 Time Response 57
C.2 Stability 57
C.3 Block Diagram and Transfer Function 57
C.4 Inverse z-Transform 57

City University of Hong Kong 4


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

D Tutorial 4: Discrete State Space Methods I 59


D.1 Difference Equation to State Space 59
D.2 State Space to Transfer Function 59
D.3 Transfer Function, Conanical Form, and Partial Fraction 59
D.4 Solve the Difference Equation 60

E Tutorial 5: State Space Methods and Transform Methods 61


E.1 Pole Placement and Estimator 61
E.2 Direct Design by Root Locus 61
E.3 Discrete Equivalents 62

F Tutorial 6: Transform Methods 65


F.1 Discrete Equivalents 65
F.2 Frequency Response 65
F.3 Stability Margins 65

G Practice Exam Questions 67

H Solutions 69

City University of Hong Kong 5


1
Review of Continuous Control

1.1 Introduction to Digital Control

In computer controlled systems, analog electronics used for continuous


systems are replaced with computers or microcontrollers, an analog-to-
digital (A/D) converters, and digital-to-analog (D/A) converters.

Design of a digital control system can be accomplished by transforming a


continuous design as known as emulation, or designing the digital system
directly.

The design process of a digital control system includes determining the


effect of the sample rate and selecting a rate that is sufficiently fast to
meet all specifications.

Nowadays, most designs are carried out using computer-based methods;


however, the designer needs to know the fundamental principles in order
to intelligently guide the computer design.

1.2 Differential Equations

We focus on linear dynamic systems which can be described by differential


equations. A set of differential equations of any order can be transformed
into a coupled set of first-order equations called the state-variable form.
The standard expression of the dynamics of a linear system is:

x = Fx + Gu
y = Hx + Ju, (1.1)
where x is an n 1 column vector called the state, u is an m 1 input
vector, y is a p 1 output vector, F is an n n system matrix, G is an n m
input matrix, H is 1 n and J is a scalar.

Example: A driven mass-spring-damper system can be described by the


differential equation
m x (t) + b x (t) + kx (t) = u (t) . (1.2)
If we can only observe/measure the displacement x (in other words y =
x (t)), write down the equations describing the system in the state-variable
form.
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

1.3 Laplace Transforms and Transfer Functions

In continous setting, linear systems can be analysed by using the Laplace


transform. One example is

L f (t) = sF (s) . (1.3)

That is, the transform of the derivative of a signal is a mutiplication by a


Laplace variable. Laplace transfom allows us to represent the relationship
between input u(t) and output y(t) of the system in the Laplace domain

y = g (y (t) , u (t)) Y (s) = G (s) U (s) ,

therefore the transfer function G (s) is Y (s) /U (s). Generally, a transfer


function is specified in a polynomial form

b1 sm + b2 sm1 + ... + bm+1


G (s) = ,
a1 sn + a2 sn1 + ... + an+1

where b1, b2, ..., bm+1 are coefficients of the numerator, and a1 , a2, ..., an+1 are
coefficients of the denominator. Alternatively, a transfer fuction can be
written as the ratio of factored polynomials (called zero-pole-gain or zpk
form)
(s z1 ) (s z2 ) ... (s zm )
G (s) = k , (1.4)
(s p1 ) (s p2 ) ... (s pn )
where k is a scalar gain, zs and ps are zeros and poles of the system.
Given the standard expression of a linear system as in equation (1.1), the
transfer function of the system can be calculated as


G (s) = H (sI F)1 G + J . (1.5)

Example: Use the result from equation (1.2) to evaluate the transfer function
of the driven mass-spring-damper system according to equation (1.5).

1.4 Final Value Theorems

If the system is stable and has a final, constant value then

lim x (t) = lim sX (s) .


t s 0

This allows us to solve for the final steady-state value without solving for
the entire response.

Example: Suppose the mass-spring-damper system in equation (1.2) is


driven by a constant input force u (t) = f , determine the final steady-state
value of x (t) as t . You may use the fact that L (1) = 1/s.

City University of Hong Kong 8


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

U(s) Y(s) Figure 1.1: An elementary


G(s) feedback system.
-

H(s)

1.5 Block Diagrams

Block diagram manipulation is a useful skill in the study of feedback con-


trol system. The most common and useful result is the reduction of the
block diagram in figure 1.1 to the transfer fuction
Y (s) G (s)
= . (1.6)
U (s) 1 + H (s) G (s)

1.6 Stability

U(s) Y(s) Figure 1.2: An elementary


G(s) open-loop system.

Stability of a system is determined by the poles of the system. A continuous-


time linear system is deemed stable if the real part of all poles are less than
zero (in the left half plane). For an open-loop system like in figure 1.2 it is
the poles of the transfer function G (s). On the other hand, the stability of a
closed-loop system as in figure 1.1 is determined by the poles of the transfer
function in equation (1.6), that is, the roots of

1 + H (s) G (s) = 0.

This equation is called the characteristic equation.

1.7 Steady-State Errors

reference error Figure 1.3: A unity feedback


R(s) E(s) U(s) Y(s) system.
D(s) G(s)
-
Compensation Plant

An open-loop system in figure 1.2 can be improved by the addition of


feedback including the dynamic compensation D (s) as shown in figure 1.3.
In this scheme, the difference between the reference r (t) and the output
y (t) is called the system error e (t). It can be shown that
E (s) 1
= = S (s) .
R (s) 1 + D (s) G (s)
The transfer function S is often reffered to as the sensitivity. The Final
Value Theorem tells us that the steady-state error ess for a constant unit
input r (t) = 1 can be determined from

ess = lim S (s) .


s 0

City University of Hong Kong 9


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

If lims0 D (s) G (s) = K p , then

1
ess = .
1 + Kp

1.8 PID Control

Proportional, integral, and derivative (PID) control contains three terms:


Z t
Ki
u ( t ) = K p e ( t ) + Ki e ( ) d + k d e(t) D (s) = K p + + sKd .
0 s

Proportional feedback control can lead to reduced errors to dusturbances


but still has a small steady-state error, which can be eliminated by adding
the integral term. The derivative term adds damping to the dynamic re-
sponse, typically reduces transient overshoot and improves closed-loop
stability.

Example: Consider the same mass-spring-damper system, but now the


driven force is configured to provide feedback. The configuration becomes
identical to that shown in figure 1.1, where G (s) is the transfer function
evalulated in the exercise earlier, and H (s) is a transfer function of the PD
control law in the form H (s) = k p + k d s. Show that the condition for stabiliy
as given by equation (1.6) is m, b + k d , k + k p > 0 .

1.9 Frequency Response

The response of a linear system to a sinusoidal input is referred to as the


systems frequency response.

Y (s) = G (s) U (s) ,

where U (s) is a sine wave with an amplitude U0 and frequency , u (t) =


U0 sin (t), which has a Laplace transform

Uo
U (s) = .
s2 + 2
The systems response is then

Uo
Y (s) = G (s) .
s2 + 2
Providing that the system is stable, the transient response will die out and
only terms left in the steady state are those due to the sinusoidal excitation.
The steady-state tiem response is

y (t) = U0 A sin (t + ) ,

where

Im [ G ( j )]
A = | G ( j )| = | G (s)| and = tan1 = G ( j ) .
s= jo = Re [ G ( j )]

City University of Hong Kong 10


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

So, a stable linear system G (s) excited by a sinusoid will eventually exhibit
a sinusoidal output y with the same frequency as the input u. The magni-
tude of y with respect to the input is | G ( j )| and the phase is G ( j ).
The plot of the frequency response of a system is called a Bode plot.
Both magnitude and phase are plotted against a horizontal axis propor-
tional to the logarithm of frequency. An example of a Bode plot of a second
order linear system is shown in figure 1.4.

Figure 1.4: A bode plot of a


Bode Diagram
second order linear system.
10

0
Magnitude (dB)

10

20

30

40
0
Phase (deg)

45

90

135

180
0 1 2
10 10 10
Frequency (rad/s)

1.10 Response versus Pole Locations

Given a system with one pole


1
H (s) = ,
s
the impulse response of the system is h (t) = et , that is

1. The system is unstable for positive as the response will grow indefi-
nitely, or

2. The system is stable for < 0 and the respose will exponentially decay
towards zero.
The settling time ts is the time
Similarly, for a system with two poles, the general form of the factorised it takes the system transient to
4.6
decay, ts .
transfer function is
The overshoot is the maximum
1 amount the system overshoots
H (s) = , its final value devided by its
(s j) (s + j)
final value.
The rise time tr is the time
meaning the poles are located at s = j. This representation of poles is
the system takes to reach the
rather useful as gives an indication whether the system is asymptotically vicinity of its new setpoint,
stable or how rapidly the response exponentially grows or decays (which tr 1.8/r.

determines the settling time for the stable case), while informs whether
there will be oscillation in the response. They, however, does not immedi-
ately indicate the amount of overshoot, which is related to the damping
ratio of the system. The conventional damping
ratio (which 0 < 1) is
related to as cos = .
City University of Hong Kong 11
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

On the complex plane, the pole locations can be represented as magni-


tude r and phase , using s = re j = r (cos + j sin ), where
p  
1
r = + = tan
2 2 .

Using this notion, we find the, r is the resonant frequency of the system,
and the amount of overshoot M is given as M e/ = e cot . For a
stable system /2 < < 3/2, the amount of overshooting is maximum
near = /2, 3/2 and minimum near = .

City University of Hong Kong 12


2
Introductory Digital Control

2.1 Digitization

Figure 2.1 shows (a) a typical continuous system and (b) a digital controlled
systems. The fundamental differences between the two implementations are
that the digital system operates on samples of the sensed plant output.

Figure 2.1: Basic controlled


systems. (a) continuous sys-
tem. (b) digital system.

First, we consider the analog-to-digital (A/D) converter. This device most


commonly senses an electrical voltage and converts it into a binary number.
A binary number with 10 bits can take on 210 = 1024 values; therefore an
A/D converter with 10 bits has a resolution of 0.1%. This conversion
occurs repetitively every T seconds. This quantity T is called the sample
period and 1/T is the sample rate (in Hz). The sampled signal is y (kT ),
often abbreviately written as y (k ), where k can be any integer value. This
type of a variable is a discrete signal.

2.1.1 Reasons for Sampling


Sisgnal processing:
Sampled signals are easier to transmit.
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Transmitted signals can be regenerated without transmission error.

Sampled signals can be coded (cryptology) more easily.

Sampled signals can be modulated better (mutiplexing).

Control

Reduce number of equipments required (digital computer, data transfer


channels).

Data are available at particular time instant only.

Data can be modified at particular time only.

Data are naturally discrete.

Signals can be stored over longer time span.

2.2 Digital Signals

Followings are common digital representations of numbers:

2.2.1 Positive Integers


Binary representation, word lengh n 2n numbers can be represented.

2.2.2 Integers
First bit taken as a sign bit. Hence n bits 2n1 .

2.2.3 Fixed-point Real


For example, an 8-bit fixed point: 1_0110.101 (sign_integer.decimal) is
-6.625.

In this case, the total range is 24 = 16. The resolution is 23 = 1/8.


There are still 2n different numbers possible.

Fixed-point real numbers are nothing new, just a re-intepretation of the


previous data representation.

2.2.4 Floating-point Real


In contrast to fixed-point numbers, the placement of the decimal point
can float relative to the significant digits of the number.

For example, an 8-bit floating point: x_xxxx_xxx (sign_mantissa_exponent).


Smallest number is 1 103 = 1/1000, largest number is 15 103 =
15, 000.

There are still 28 = 256 numbers possible, but they are no longer equidis-
tantly spaced.

City University of Hong Kong 14


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

2.3 Sampling and Effects of Sampling

The single most important impact of implementing a control system digi-


tially is the delay associated with the hold. Because each value of u (kT ) is
held constant until the next value is available.
Zero-order hold: Extrapolating the sampled data using the latest sam-
pled value.
Suppose a signal to be sampled at sample period T is a sinusoidal signal
u (t) = A sin t, we expect the spectral content of the sampled signal to be
primarily composed of a component with the same frequency . However,
this may not be true if > 21 2/T.
Nyquist Frequency: The minimum rate at which a signal can be sampled
without introducing errors, which is twice the highest frequency present in
the signal.
In other words, when sampling with the rate 1/T, the maximum fre-
quency of the input signal that can be sampled without introducing an error
is m = /T. If the input signal contains a component at higher frequency
(for example 1 = m + ), it would appear as a signal with frequency
m when sampled. This causes signals at m and m +
become indistinguisable after sampling. The phenomanon is known as
aliasing.
Aliasing: an effect that causes different signals to become indistinguish-
able (or aliases of one another) when sampled.
To avoid aliasing issue and ambiguity, in practice, we apply low-pass
antialias filter that will remove substantially all spectral content above the
half-sampling frequency prior to the sampling operation.

2.4 Linear Difference Equations

Consider the scenario where a computer receives discrete-time signals from


an analog-to-digital (A/D) converter as e0 , e1 , e2 ..., ek and provides the out-
put signal u0 , u1 , u2, ..., uk1 . To obtain the next output, the machine com-
putes some function, which can be expressed in a symbolic form as

uk = f (e0 , e1 , ..., ek ; u0 , u1 , ...uk1 ) .

In the case that the function f is linear and depends only on a finite number
of past es and us, we write

uk = a1 uk1 a2 uk2 ... an ukn + b0 ek + b1 ek1 + ... + bm ekm . (2.1)

Equation ,(2.1) is a linear recurrence equation or difference equation,


which has many similarities with a linear differential equation.

Example: Difference Equations using Eulers Method I


Define uk = uk uk1 , show that the equivalence of the difference equa-
tion uk = a1 uk1 a2 uk2 + b0 ek is

a2 2 uk + ( a1 2a2 ) uk + ( a1 + a2 + 1) uk = b0 ek .

solution:

City University of Hong Kong 15


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

From the definition uk = uk uk1 , we obtain uk1 = uk uk .


Applying the same operator on uk yields

(uk ) = 2 uk = uk uk1
= (uk uk1 ) (uk1 uk2 ) = uk 2uk1 + uk2
= u k 2 ( u k u k ) + u k 2 = u k + 2 u k + u k 2 or
2
u k 2 = u k + u k 2 u k

Substituting uk1 and uk2 back to the difference equation gives


 
uk = a1 (uk uk ) a2 2 uk + uk 2uk + b0 ek

uk = a2 2 uk + ( a1 + 2a2 ) uk + ( a1 a2 ) uk + b0 ek
b0 ek = a2 2 uk + ( a1 2a2 ) uk + ( a1 + a2 + 1) uk

Example: Difference Equations using Eulers Method II


Using Eulers method (hint: u = (u (k + 1) u (k)) /T), find the difference
equations to be programmed into the control computer for the case where

U (s) s+a
D (s) = = K0 .
E(s) s+b
solution:

u + bu = K0 e + aK0 e
u ( k + 1) u ( k ) e ( k + 1) e ( k )
+ bu (k) = K0 + aK0 e (k)
T T
u (k + 1) u (k) + bTu (k) = K0 e (k + 1) K0 e (k) + aTK0 e (k)
u (k + 1) + (bT 1) u (k) = K0 e (k + 1) + ( aT 1) K0 e (k )

2.4.1 Solution of linear difference equations


Given a linear difference equation written in the form as in equation (2.1), it
can be re-written as

uk + a1 uk1 + a2 uk2 + ... + an ukn = b0 ek + b1 ek1 + ... + bm ekm , (2.2)

where we have group the output terms (ui ) together on the left hand side
and the input terms (ei ) together on the right hand side. We would like to
find a solution uk that satisfies the difference equation given the input ei
and a set of initial conditions u0 , u1 ,..., un . The general solution to equa-
tion (2.2) may be derived as the sum of two solution components

u (k ) = uc (k ) + u p (k ) ,

where uc (k )the complementary/homogeneous solutionis the solution


of the homogeneos equation (that is e (k ) = 0 for all k), and u p (k) is a
particular solution that satisfies (2.2) for the specific e (k).

City University of Hong Kong 16


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

It turns out that complementary solutions of a linear difference equation


takes the form uc (k ) = Ak (c.f. the general solution of continuous, ordi-
nary, differential equations takes the form est ). Substitution of uc (k ) = Ak
in the homogeneous equation gives:

Azk + a1 Ak1 + a2 Ak2 + ... + an Akn = 0


1 + a1 1 + a2 2 + ... + an n = 0
n n 1 n 2
+ a1 + a2 + ... + an = 0,

assuming A 6= 0. The equation that we obtain after we substitute u (k ) =


Ak is a polynomial in is known as the characteristic equation of the
difference equation. For an n-th order system, there are n complex roots of
the characteristic equation. The complementary solution will be the sum of
all terms:
uc (k ) = C1 1k + c2 2k + ... + Cn kn

with coefficients Ci s to be found from the initial conditions. If any roots of


the characteristic equation is outside the unit circle, the correponding differ-
ence equation is internally unstable in the sense that the solution will grow
without bound as time goes to infinity. If all the roots of the characteristic
equation are inside the unit circle, the corresponding difference equation is
stable.

Example: Complementary solution to a difference equation


Consider a system with no input

y (k + 3) 6y (k + 2) + 11y (k + 1) 6y (k) = 0.

Find the system response y (k) for k > 2 given the initial conditions y (0) =
2, y (1) = 1 and y (2) = 2.
solution:
the characteristic equation is 3 62 + 11 6 = 0, = 1, 2, 3. The
system response is
y (k) = A1 .1k + A2 .2k + A3 .3k ,

where A1 , A2 , A3 can be found by solving y (0) = 2, y (1) = 1 and y (2) =


2.

2.5 Z-Transform

If a signal has a destrete values y0 , y1 , ..., yk, ... we define the ztransform of
the signal as the function

Y (z) Z {y (k)}

yk zk ,
k =

assuming the series converges.

City University of Hong Kong 17


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

2.5.1 Table of common Z-transform pairs


Here:
1 k0
u = k 7 u (k) =
0 k<0

is the unit (or Heaviside) step function and



1 k=0
: k 7 u (k) =
0 k 6= 0

is the discrete-time unit impulse function.

Signal x (k) z-transform X (z) ROC Table 2.1: z-transform


(k) 1 all z
(k k0 ) zk0 z 6= 0
1
u (k) 1 z 1
|z| > 1
1
ak u (k ) 1 az1
|z| > | a|
z 1
ku (k) 2 |z| < 1
( 1 z 1 )
1
1z cos( )
cos (k) u (k) 12z1 cos( )+z2
|z| > | a|
z1 sin( )
sin (k) u (k) 12z1 cos( )+z2
|z| > | a|

Example: The z-Transform


The data ek are taken as samples from the time signal e at u (t) at sampling
period T where u (t) is the unit step function. Find the z-transform of this
signal.
solution:

z
ek zk = z eaT |z| > eaT .
k =

2.5.2 Useful z-Transform Properties


Linearity
Z { a f (t)} + b g (t)} = aZ { f (t)} + bZ { g (t)}
Shifting
Z { f (t kT )} = zk Z { f (t)}
Damping
 
Z eat f (t) = F ze aT where Z { f (t)} = F (z).
Initial Value Theorem

lim f (t) = lim F (z) if the right limit exists.


t 0 z

Final Value Theorem


If the system is stable and has a final, constant value then

z1
lim f (t) = lim F (z) if the left limit exists.
t z 1 z

City University of Hong Kong 18


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

2.6 Transfer Function

The z-transform has the same role in discrete systems that the Laplace
transform has in analysis of continuous system. The transfer function is
defined as the ratio of the transform of the ouput to the transform of the in-
put. For a system described by the difference equation as given by equation
(2.1), the general form of the transfer function is

b0 + b1 z1 + ... + bm zm
H (z) = . (2.3)
1 + a1 z1 + a2 z2 + ... + an zn

Oftentimes this is defined by the numerator b (z) and the denominator a (z)
as
b (z)
H (z) = ,
a (z)
h i h i
where b (z) = b0 b1 ... bm and a (z) = 1 a1 ... an . Another
representation of the discrete transfer function parallels the zero-pole-gain
representaion of the continous systems (c.f. equation 1.4):

(z z1 ) (z z2 ) ... (z zm )
H (z) = k .
(z p1 ) (z p2 ) ... (z pn )

A discrete system is defined by the discretehtransferi function and the sam-


pling time unit. Notice that in case b (z) = 0 1 and a (z) = 1, we have
H (z) = z 1 and uk = ek1 , that is the output of the system is the input to
the system in the previous unit time. Another interpretation of this is that
the transfer function of z1 is a delay of one time unit.

2.7 Time Response

Suppose we have a knowledge of a discrete-time transfer function of the


system of interest H (z), let u (z) be in input variable and y (z) be the input
variable, then
y (z) = H (z) u (z) .

If u (z) is determined, there are several ways to evaluate the corresponding


time response y (z). One direct method is to obtain the difference equation
from the transfer function and use that to calculate the response y (k). The
second method is to perform z-transform.

Example: Time response from the difference equation


Suppose we are given a transfer function

0.2z1
H (z) = ,
1 0.9z1
which can be re-written as the difference equation

y (k) = 0.9y (k 1) + 0.2u (k 1) .

Assume u is a step function of amplitude U and the initial value of y is


y (0) = y0 , evaluate y (1) and y (2).
solution:

City University of Hong Kong 19


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

y (1) = 0.9y0 + 0.2U


y (2) = 0.81y0 + 0.38U

Example: Time response by inverting the z-tranform


Consider a discrete-time system with sample time T described by
z
H (z) =
z2
1
subject to a unit step input u (k) = 1 z 1
, take the inverse z-transform to
find the output signal y (k).
solution:

y (z) = H (z) U (z)


z2 2z z
= =
( z 2) ( z 1) z2 z1
1 1
= 2
1 2z1 1 z 1
 
Z 1 {y (z)} = 2 2k 1k u ( k )

Example: Final value to a step input


Suppose the system H (z) is subject to a step input u (k)

0 k < 0
u (k) = ,
U k 0

the response of the system as k can be shown to be limk y (k) =


ys = H (1) U.
solution:
!"#$%&#" '(& )" *%+&, +#-&. /0" !&(1 2(1+" /0"%!"34

!"# !$"% & !" & !"# $# ! '%!$#% 5667


!!" #!!
& !"# $# ! '%$$#%%$#% 5687
#!!
#&
& !"# $# ! '%$$#% 5697
#!! #!'
& $$'%& 58:7

2.8 Frequency Response

Given a discrete transfer function H (z) with sampling time T, we may


calculate the frequency response of the discrete system similar to the fre-
quency response of a continuous system. Assume the input signal exciting
the system is a sinusoid
e (k) = E sin (kT ) ,

the output response of the system is

u = EA sin (kT + ) ,

City University of Hong Kong 20


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

where the amplitude gain A ( ) and the phase can be found from the fre-

quency response H e jT defined as
 

H e jT = H (z)
z=e jT

from
 

A ( ) = H e jT , and
 jT
  
1 Im  H e
( ) = tan  = H e jT
.
Re H e jT

Example: Frequeny Response


Manually calculate the frequency response of the transfer function

b
H (z) = .
za
solution:
  b

A ( ) = H e jT = q
(cos T a)2 + sin2 T
   
sin T
( ) = H e jT
= tan 1
cos T a

City University of Hong Kong 21


3
State Space Methods

3.1 Discrete-Time State Space Model

The general form of a linear discrete-time state-space model is

x ( k + 1) = Ad x (k ) + Bd u (k )
y (k) = Cd x (k ) + Dd u (k ) , (3.1)

where Ad (indexed d for discrete-timethis will be omitted in the future) is


the transition matrix, Bd is the input matrix, Cd is the output matrix and Dd
is the direct output matrix (in most cases Dd = 0).

3.2 Difference Equation to State Space

In section (2.4), we introduced the difference equation that relates the out-
put y to the input u as

yk = a1 yk1 a2 yk2 ... an ykn + b0 uk + b1 uk1 + ... + bm ukm . (3.2)

The transfer function of this differene equation (as previously given in equa-
tion (2.3)) is
b0 + b1 z1 + ... + bm zm
H (z) = . (3.3)
1 + a1 z1 + a2 z2 + ... + an zn
If b0 6= 0, we must pull out the term

(b1 b0 a1 ) z1 + ... + (bm b0 am ) zm


H (z) = b0 +
1 + a1 z1 + a2 z2 + ... + an zn
1 z1 + ... + m zm
= b0 + (3.4)
1 + a1 z1 + a2 z2 + ... + an zn

and set D = b0 in the state space model. The controller canonical form is
then written as

a 1 a 2 a n 1 a n 1
1 0 0 0 0


A = 0 1 0 0 0
B=
.. .. .. .. ..
. . . . .
0 0 1 0 0
h i
C = 1 2 m D = b0 .
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Remarks:
From equation (3.4), if we write y (k) = H (z) u (k) ,we have

1 z1 + ... + m zm
y (k) b0 u (k) = u (k) .
1 + a1 z1 + a2 z2 + ... + an zn

Here, if we define

1
= u (k) , (3.5)
1 + a1 z 1 + a2 z2 + ... + an zn
then
 
y (k) b0 u (k) = 1 z1 + ... + m zm

z 1
h i
z 2


= 1 2 m 0 0
..
for m n.
| {z } .
Cd zn
| {z }
x(k)

It follows that we can also write equation (3.5) in a vector form as


 
0 = 1 + a1 z1 + a2 z2 + ... + an zn + u (k )

z 1
h i
z 2

= i a1 a2 a n .
+ u (k)
..
zn

z 1
h i
z 2


= a1 a2 an .. + u (k)

.

z n

a1 a2 a n 1 an
1
1 1 0 0 0 z 1
2
z 1 z 0
.. = 0 1 0 0 . + .. u (k)
.
. .. .. .. .. . .
. . . .
z n +1 zn 0
0 0 1 0

a1 a2 a n 1 an
z 1 z
1 1
2 1 0 0 0 2
z z 0
z = 0 1 0 0 . + . u (k)
.. . .
. .. .. .. .. . .
. . . .
zn z n 0
| {z } 0 0 1 0 | {z } | {z }
x ( k +1) | {z } x(k) Bd
Ad

Example: Difference equation to state space


Given the discrete-time transfer function

1 + 2z1 + 3z2
H (z) = ,
1 + 21 z1 + 31 z2

City University of Hong Kong 24


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

show that the corresponding state space representation is


" # " #
12 13 1 h i
A= B= C = 32 83 D = 1.
1 0 0
Solution:
     
1 + 21 z1 + 13 z2 + 2 12 z1 + 3 13 z2
H (z) =
1 + 12 z1 + 31 z2
3 1
2z + 83 z2
= 1+
1 + 12 z1 + 31 z2
1 z 1 + 2 z 2
= b0 + .
1 + a 1 z 1 + a 2 z 2

3.3 State Space Model to Transfer Function

Consider the n-th order discrete-time linear system in equation (3.1), which
can be re-written in the z-domain with a delay variable z1

zX (z) Ad X (z) = Bd U (z)


h i
Y (z) = Cd (zI Ad )1 Bd + Dd U (z) ,

which allows us to solve for the transfer function


Y (z)
= Cd (zI Ad )1 Bd + Dd .
U (z)
Note that the characteristic equation (i.e., the denominator of the transfer
function) is
|zI Ad | = 0. (3.6)

Example: State space to transfer function


Given the discrete-state-space of a mass-spring-damper system for T = 0.01
as
" # " #" # " #
x ( k + 1) 0.9990 0.0095 x (k) 0
= + u (k)
v ( k + 1) 0.1903 0.9030 v (k) 0.0095
" #
h i x (k)
y (k) = 1 0 .
v (k)

Turn this into a transfer function.

3.4 Discretization of Linear Continuous-Time State Space Models

In many circumstances, physical laws provide a continous-time model of


the system, which can be written as a continuous-time state-space model
as described by equation (1.1). The design of computer controlled systems;
however, calls for a discrete-time model for simulation and design of control
laws. There are several discretization methods for converting a continuous
state-space model to discrete state-space model. A few popular methods are
given below.

City University of Hong Kong 25


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

3.4.1 Zero Order Hold Method


Assume the following continuous-time state space model identical to the
one in equation (1.1):

x = Fx + Gu
y = Hx + Ju, (3.7)

if the system has a zero order hold on its input u with the sample time T,
then it can be shown that the analogous discrete state space model can be
written as in equation (3.1), where

Ad = eFT ,
Z T
Bd = eF dG,
0
Cd = H
Dd = J. (3.8)

While the relations above can be proved exactly, here we offer a less rigor-
ous proof via numerixal approximaions. Starting from

Ad = eFT
F2 T 2 F3 T 3
= I + FT + + + ...
2! 3!
I + FT as T 0. (3.9)

Similarly,
Z T
Bd = eF dG
0
Z T
F2 T 2 F3 T 3
= I + FT + + + ...dG
0 2! 3!
 
FT 2 FT 3
= IT + + + ... G
2 3
GT as T 0. (3.10)

3.4.2 Eulers Forward Method


The approximations obtained above are, in fact, identical to Eulers forward
method, where the approximation x (k ) [x (k + 1) x (k)] /T is used.
Substitute the results from equations (3.9) and (3.10) back to equation (3.1),
we obtain

x ( k + 1) = ( I + FT ) x (k) + GTu (k)


x ( k + 1) x ( k )
= Fx (k) + Gu (k)
T
x (k) Fx (k) + Gu (k) . (3.11)

3.4.3 Eulers Backward Method


x(k )x(k 1)
The Eulers backward method makes the approximation x (tk ) T ,
which leads to

City University of Hong Kong 26


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

x ( k ) x ( k 1)
= Fx (k) + Gu (k) . (3.12)
T
Re-arranging the equation yields

x (k ) = ( I FT )1 x (k 1) + ( I FT )1 GTu (k) .

3.4.4 Tustins Method


Tustins method is a combination of Eulers forward and backward method:

x ( k ) x ( k 1) x ( k ) + x ( k 1) u ( k ) + u ( k 1)
=F +G .
T 2 2
From here, it can be shown that
  1    
FT FT FT 1 GT
x (k) = I I+ x ( k 1) + I (u (k) + u (k 1)) .
2 2 2 2

Remarks: We can re-write equation (3.11) as

x ( k ) x ( k 1)
= Fx (k 1) + Gu (k 1) .
T
The left hand side of the above equation is now identical to that of equation
(3.12). Therefore, we can combine the two equations using the average of
the right hand sides:

x ( k ) x ( k 1) Fx (k 1) + Gu (k 1) Fx (k) + Gu (k)
= +
T 2 2
x ( k ) + x ( k 1) u ( k ) + u ( k 1)
=F +G .
2 2

Example: Discretization of state space models


A continuous time state space representation of a linear second order sys-
tem
" # " #
0 1 0
x = x+ u
3 2 1
| {z } | {z }
F G
h i
y = 1 0 x + [0] u
| {z } |{z}
H J

h i
where x = x1 x2 is the state vector. Discretize this system using the
Tustins method for sample time T = 0.5.
Solution:
" # " #
8 1
1 27
x (k) = x (k 1) + 27 (u (k) + u (k 1))
49 27
5 4
27
h i
y (k) = 1 0 x ( k ) + [0] u ( k )

City University of Hong Kong 27


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

3.5 Stability

When the input to the discrete time system is zero, the state response of a
system reduces to
x ( k + 1) = A d x ( k ) , (3.13)

that is
x (k) = Akd x (0) .

For asymptotic stablity, the homogenous response of the state vector x (k )


returns to the origin for arbitrary initial conditions x (0) at time k , or

lim x (k) = lim Akd x (0) = 0 for all x (0) . (3.14)


k k

The condition for the equation (3.14) to hold is that the magnitudes of all
eigenvalues of Ad are less than unity. If || > 1, the state vector will grow
exponentially with time the system is unstable.
A linear discrete-time system described by the state equation x (k + 1) =
Ad x (k ) is asymptotically stable if and only if all eigenvalues have magnitude
smaller than one.
To evaluate eigenvalues of Ad , one solves the equation |I Ad | = 0.
This is identical to the characteristic equation of the system in the transfer
function form (3.6). Hence, the roots of the characteristic equation obtained
from the transfer function are eigenvalues of Ad . The system is deemed
stable if and only if all roots have magnitude smaller than one.

Example: Discrete Stability


Determine the characteristic equation and characteristic roots of the differ-
ence equation
u (k) = 0.9u (k 1) 0.2u (k 2) .

Is the equation stable?


Solution:

u (k ) 0.9z1 u (k) + 0.2z2 u (k) = 0


 
z2 0.9z + 0.2 u (k) = 0

(z 0.5) (z 0.4) = 0
z = 0.5, 0.4

The equation is stable.

3.6 Pole Placement

Similar to continuous-time systems, the control law for a discrete-time can


simply be the feedback of a linear combination of all state elements, that is

x1
h i
u (k ) = Kx (k ) = K1 K2 ... x
2 .
..
.

City University of Hong Kong 28


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

It follows that the closed-loop system can be expressed as

x ( k + 1) = Ad x (k) + Bd (Kx (k))


= (Ad Bd K) x (k ) . (3.15)

Compared to equation (3.13), the closed-loop system is stable when all


eigenvalues of Ad Bd K have magnitude smaller than one. In fact, we may
choose K1 ,K2 , ... such that all the poles of the system take the desired values
1 , 2 , ... such that the closed-loop characteristic equation is

(z 1 ) (z 2 ) ... (z n ) = 0.

Example: Pole Placement for Satellite Attitude Control


One-dimensional dynamics of the satellites attitude (orientation) are de-
The angle could be control with torque
scribed by its angle and its rate .
as an input to the system. The discrete-time state space of the satellite atti-
tude dynamics takes the form
" # " #" # " #
( k + 1) 1 T (k) T 2 /2
= + u (k) ,
(k + 1) 0 1 (k) T

where a sample period T is 0.1 second. Design a control matrix K in order


to place the poles at z = 0.8 0.25j.
Solution:
The desired characteristic equation is

(z 0.8 0.25j) (z 0.8 + 0.25j) = 0


z2 1.6z + 0.70 = 0.

The actual equation is


" # " #" # " #
( k + 1) 1 T (k) T 2 /2 
(k + 1) = 0 K1 (k) + K2 (k)
1 (k) T
" # " #! " #
1 T T2 T2 (k)
= 2 K1 2 K2
0 1 TK1 TK2 (k)
" 2 2
# " #
1 T2 K1 T T2 K2 (k)
= .
TK1 1 TK2 (k)

The poles are found from solving the equation


   
T2 T2
z1+ K1 (z 1 + TK2 ) ( TK1 ) T + K2 = 0
2 2
  T2
z2 + TK2 + K1 T 2 /2 2 z + 1 TK2 + K =0
2 1
By matching the coefficients of two equations, we get

TK2 + K1 T 2 /2 2 = 1.6 and


T2
1 TK2 + K = 0.70.
2 1
This yields
2 1
K1 = K2 = .
30T 2 3T

City University of Hong Kong 29


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

3.7 Reference Input

Thus far, we have shown that the pole placement method could stabilise
the system output limk y (k) = 0 by ensuring x (k) 0 as k . In
more general settings, we may desire to have the output y (k) following a
constant non-zero reference signal r (k). To achieve such result, let us first
define xr (k ) as the desired value of the state and a matrix Nr that satisfy

Nr r ( k ) = xr
y = Cd xr = r.

The two equations reduce to Cd Nr = I, which allows us to find Nr . Further- We are assuming Dd = 0,
more, assuming the system is at desired steady state (with no errors) when hence, Y = Cd x.

the input to the system is some constant ur :

xr ( k + 1) = A d xr ( k ) + B d ur ( k ) (3.16)
xr ( k ) = A d xr ( k ) + B d ur ( k )
( I A d ) xr ( k ) = B d ur ( k )
( I A d ) Nr r ( k ) = B d ur ( k )

The result suggests that ur is a linear function of r. We may write ur = Nu r,


where
( I A d ) Nr = B d N u .
In summary, given the system matrices, we may calculate Nr and Nu from
" #" # " #
Cd 0 Nr I
= .
I Ad Bd Nu 0

Finally, if we subtract equation (3.16) from the standard discrete-time state


space equation and define the state error e (k ) = x (k) xr (k ), we obtain

x ( k + 1) xr ( k + 1) = Ad (x (k) xr (k)) + Bd (u (k) ur (k))


e ( k + 1) = Ad e (k) + Bd (u (k) ur (k)) .

The state error e (k) would asymptotically goes to zero as k if we


choose the control u (k) = ur (k) Ke (k) as the state space equation be-
comes

e ( k + 1) = Ad e (k) Bd Ke (k)
= (Ad Bd K) e (k ) ,

which is identical to the closed-loop system in equation (3.15).

Example: A driven, damped mass-spring device


The mass-spring-damper device is driven by the input force f (t) is con-
trolled by a computer system. The digital controller takes a displacement
measurement x (k ) and updates the force input f (k ) at the rate of 5 Hz. The
continuous transfer function of the corresponding physical system is given
by
0.2
G (z) = 2 .
5z 1

City University of Hong Kong 30


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

1. Convert the system to discrete-state space form.

2. Design a digital controller for returning the mass to the origin using the
pole placment method to place tho poles at z = 3, 5. In fact, this is a poor example
as poles at z = 3, 5 would
3. Instead of stabilizing the mass at the origin, we intend to stabilize the destabilize the system.
mass at a reference position yr = 1, calculate Nr and Nu and find the new
control law based on the controller evaluated in (2).

Solution:
1.
" # " #
0 0.2 1
x (k) = x ( k 1) + f ( k 1)
1 0 0
h i
y (k) = 0 0.04 x (k)

City University of Hong Kong 31


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

3.8 Estimator Design

The control law designed using the pole placement method or other meth-
ods typically assume that all state elements are available for feedback. In
reality, not all elements are measured. The missing portion of the state has
to be estimated for use in the control law.
We call the current estimate x (k). This state estimate is calculated based
on measurements y (k ) up to and including the kth instant. For a discrete
state space system in the form of equation (3.1), its estimated are obatined
from
x (k) = x (k) + L [y (k) Cd x (k)] , (3.17)
where L is an n 1 estimator gain matrix, x (k ) is the predicted estimate
based on a model prediction from the previous time estimate according to

x (k) = Ad x (k 1) + Bd u (k 1) . (3.18)

Together, they become

x (k) = Ad x (k 1) + Bd u (k 1) + L [y (k ) Cd ( Ad x (k 1) + Bd u (k 1))]
= Ad x (k 1) + Bd u (k 1) + L [Cd ( Ad x (k 1) + Bd u (k 1)) Cd ( Ad x (k 1) + Bd u (k 1))]
= Ad x (k 1) + Bd u (k 1) + LCd ( Ad x (k 1) x (k 1)) (3.19)

To understand how the estimator works, we introduce the estimation error


x (k) = x (k) x (k). Subtracting equation (3.19) by equation (3.1), we obtain

x (k) x (k) = Ad x (k 1) + Bd u (k 1) + LCd ( Ad x (k 1) x (k 1))


Ad x (k 1) Bd u (k 1)
x (k) = Ad x (k 1) LCd Ad x (k 1)
= ( Ad LCd Ad ) x (k 1) . (3.20)

Using the stability analysis we discussed in section (3.5), it follows that the
estimation error is asymptotically stable (that is the error reduces to zero
over time) if the all eigenvalues of Ad LCd Ad are in the unit circle. This
could be achived by choosing a suitable estimator gain matrix L by placing
the pole of Ad LCd Ad at desired locations.

Example: Estimator Design


Given a discrete-time system with a sample time T:
" # " #
1 T 1
x ( k + 1) = x (k) + u (k)
0 1 0
h i
y (k) = 1 0 x (k) .

Construct an estimator such that the poles are located at z = 0.4 0.4j for
T = 0.1s.
Solution:
We are looking for L that makes
" # " # " # " #
1 0 1 T L1 h i 1 T

z + 1 0 =0
0 1 0 1 L2 0 1

City University of Hong Kong 34


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

identical to
(z 0.4 + 0.4j) (z 0.4 0.4j) = 0.

City University of Hong Kong 35


4
Design using Transform Methods

4.1 Design of Discrete Equivalents via Numerical Integrations

An example system
U (s) a
= G (s) =
E (s) s+a
is equivalent to
u + au = ae,
or
Z t
u (t) = au ( ) + ae ( ) d
0
Z kT
u (kT ) = u (kT T ) + au ( ) + ae ( ) d. (4.1)
kT T

Apply the numerical integration concept identical to the Eulers Forward


method in section 3.4.1,

u (kT ) = u (kT T ) + T [ au (kT T ) + ae (kT T )]


= (1 aT ) u (kT T ) + aTe (kT T ) ,

which can be re-written as a discrete-time transfer function


a
H (z) = (forward rectangular rule).
(z 1) /T + a
Instead, if we re-write equation 3.13 to approximate the integral using the
value looking backward from kT towards kT T then

u (kT ) = u (kT T ) + T [ au (kT ) + ae (kT )]


u (kT T ) aT
= + e (kT ) ,
1 + aT 1 + aT
leading to
a
H (z) = . (backward rectangular rule)
(z 1) /Tz + a
The final version is the trapezoid rule, which involves taking the average of
both previous approximation.
T T
u (kT ) = u (kT T ) + [ au (kT T ) + ae (kT T )] + [ au (kT ) + ae (kT )]
2 2
1 aT/2 aT/2
= u (kT T ) + [e (kT T ) + e (kT )] .
1 + aT/2 1 + aT/2
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

The corresponding transfer function is


a
H ( z ) = 2 z 1 . (trapezoid rule)
T z +1 + a
In summary, we see that From here, we can deduce three conventions

H (s) Method Discrete transfer function Table 4.1: Discrete transfer


a functions from three integra-
Forward rule (z1)/T + a tion methods.
a a
s+ a Backward rule (z1)/Tz+ a
a
Trapezoid rule 2 z 1
T z +1 + a
for converting between a Laplace transfer function and a discrete transfer
function. The trapezoid-rule substitution is also known as Tustins

Method s z zs Table 4.2: Conversions between


z 1 continuous-time and discrete-
Forward rule s T z 1 + Ts time transfer functions from
Backward rule s zTz 1 z 11Ts three integration methods.
Trapezoid rule s T2 zz
+1
1
z 11+ Ts/2
Ts/2
method and bilinear transformation.
Remarks Recall that for a continuous-time system, it is stable if all poles are
located in the left half plane. If we let s = j in these equations, we obtain
the boundaries of the regions in the z-plane which originate form the stable
portion of the s-plane. Only the bilinear transformation maps the stable
region in the s-plane to a unit circle in z-plane. In fact, all conversion suffers
some degree of distortion.

4.1.1 Zero-Pole Matching Equivalents


Another simple yet effective method of obtaining a discrete equivalent to
a continuous transfer function is by ensuring that the poles of the discrete
transform E (z) are related to the poles of E (s) according to z = esT . We
must go through the z-transform process to locate the zeros of E (z). In
summary, the rules are as follows:
Map all the poles of H (s) from s = a to z = e aT .

All finite zeros are mapped by z = esT .

Zeros at s = are mapped to z = 1.

Match the gain at the critical frequency s = 0 so that H (s)|s=0 =


H (z)|z=1 .

Example: A Zero-Pole Matching Equivalent


Compute the discrete equivalent to
a
H (s) =
s+a
by zero-pole matching.
solution:

1 1 e aT
H (z) = aT
.1. (z + 1) . .
ze 2

City University of Hong Kong 38


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

4.2 Direct Design by Root Locus

In continuous-time systems, the root locus method involves graphically


plotting the roots of closed-loop characteristic polynomial in the s-plane as
the loop gain is varied from 0 to . In linear discrete systems, the stability
and dynamic performance is largely determined by the roots of the closed-
loop characteristic polynomial in z.
To begin, we note that poles in the s-plane are mapped to z = esT . Ex-
pressing s = + j as introduced in section 1.10, z becomes

z = |{z} e jT .
eT |{z}
rz e jz

The first part eT describes the magnitude of z in the complex plane and
the second part e jT determines the phase of z. Writing z = rz e jz , a stable
system has < 0, rendering rz < 1, which, as anticipated, a stable condition
for a discrete system.
When analysising a discrete-time system, it is sometimes useful to vi-
sualise the system response using notions from continuous-time systems,
particularly the damping ratio and resonant frequency. On the z-plane,
we can plot the contour of different from 0.1 to 0.9 as illustrated in figure
4.1 (red dashed lines). As decreases (or cos 0 as discussed in section
1.10), the system leans towards unstability, and the contours in figure 4.1
approaches the z = 1 line (unit circle).
To inspect the resonant frequeny, we use the representation s = re j ,
which leads to

z = er(cos + j sin )T
= e|rT{z
cos jrT sin
} e| {z } .
magnitude phase

Suppose we would like to obtain the system with one particular resonant
frequency r, then the location of pole on the z-plane follows one of the blue
dashed lines as we varies.

Example: z-Plane Specifications


We are assigned to design a discrete-time system with two closed-loop poles
with the sampling time T = 0.1 s. The poles must be placed to ensure that
i) < 2 for guaranteed stability, ii) the resonant frequency r < 3 s1 to
prevent oscillation at high frequency, and iii) > 0.4 to minimize overshoot.
Find the region on the z-plane that satisfies all three requirements.
Solution:

City University of Hong Kong 39


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Figure 4.1: Lines of constant


1
0.5/T
damping and natural fre-
0.6/T 0.4/T quency in the z-plane.
0.8 0.1
0.7/T 0.3/T
0.2
0.6 0.3
0.8/T 0.4 0.2/T
0.5
0.4 0.6
0.7
0.9/T 0.8 0.1/T
0.2 0.9
1/T
0
1/T

0.2
0.9/T 0.1/T
0.4

0.8/T 0.2/T
0.6

0.7/T 0.3/T
0.8
0.6/T 0.4/T
0.5/T
1
1 0.5 0 0.5 1

1
0.5/T
0.6/T 0.4/T
0.8 0.1
0.7/T 0.3/T
0.2
0.6 0.3
0.8/T 0.4 0.2/T
0.5
0.4 0.6
0.7
0.9/T 0.8 0.1/T
0.2 0.9
1/T
0
1/T

0.2
0.9/T 0.1/T
0.4

0.8/T 0.2/T
0.6

0.7/T 0.3/T
0.8
0.6/T 0.4/T
0.5/T
1
1 0.5 0 0.5 1

4.3 Frequency Reponse Methods

Frequency response methods are standard tools for controlling continuous


linear systems as they allow convenient visualisation of rational transfer
function. In the absence of physical realization of the system (unknown
transfer function), the frequency response can be measured experimentally.
Major concepts applicable to continous-time systems can be transferred to
discrete-time systems.

4.3.1 Discrete Bode Plot

For a discrete transfer function H (z), plots of magnitude and phase are
accmplished by letting z takes on values allow the unit circle z = e jT , that

City University of Hong Kong 40


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

is,

magnitude = | H (z)|e jT


phase = H (z) .
jT e

Figure 4.2 shows the frequency response of a simple plant

Bode Plot Figure 4.2: Bode plot of a sim-


50 ple plant G (s). (i) The black
line is from a continuos-time
Magnitude (dB)

transfer function, whereas


0 blue, red and cyan lines are
obtained from equivalent dis-
crete transfer fuction using
50 Eulers Forward, Eulers Back-
ward and Bilinear methods.

100 2 1 0 1
10 10 10 10
Frequency (Hz)
90
Phase (deg)

180

270

360 2 1 0 1
10 10 10 10
Frequency (Hz)

1
G (s) = . (4.2)
s (s + a)

Observe that the magnitude is often plotted showing the decibel (dB) value,
defined as 20 log (magnitude). The frequency could be in Hz or in radian
per second. It can be seen that there are small discrepancies between the
original continuous-time transfer function and discrete-transfer functions
described by three methods from section 4.1.

Example: Equivalent Discrete Transfer Function


Convert the transfer function in equation (4.2) to a discrete transfer func-
tion using three methods. Determine the phase of the plant at 1 Hz for the
continous-time transfer function and three discrete-time transfer functions
when a = 1 and T = 0.05 s.
Solution:

Continuous-time 171.0 .

Forward 188.8

Backward 153.2

Bilinear 171.0 .

City University of Hong Kong 41


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Figure 4.3: Phase differences


180 between the continuous-time
Phase Diff (deg)

transfer function and the


converted transfer functions
(colour scheme identical to
0 that in figure 4.2).

180 2 1 0 1
10 10 10 10
Frequency (Hz)
180
Phase lag (deg)

180
0 1 2 3
T ( r ad)

To inspect the result from the above example further, figure In fact, con-
version from continous-time transfer function to discrete-time transfer func-
tions may result in phase lag/lead, depending on the method used and the
transfer function itself. General rules are

The bilinear method results in minimal phase lag.

Each Laplace variable s in the denominator results in T/2 radian phase


lag/lead when using the Eulers forward/Eulers backward method.

Each Laplace variable s in the numerator results in T/2 radian phase


lead/lag for the Eulers forward/Eulers backward method.

As a consequence, the phase shift is negligible at low frequency ( 0) or


small sampling time ( 0).

4.3.2 Gain and Phase Margins

Figure 4.4: A discrete unity


reference error feedback system
R(z) E(z) U(z) Y(z)
D(z) G(z)
-
Compensation Plant

Consider a unity feedback system illustrated in figure 4.4, where the


plant transfer function G (z) is preceded by the feedback controller D (z).
The closed-loop transfer function is given by

D (z) G (z)
Y (z) = R (z) ,
1 + D (z) G (z)

City University of Hong Kong 42


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

whereas the difference between the reference and the output, r y = e, is

1
E (z) = R (z)
1 + D (z) G (z)
S (z) R (z) ,

where we have de fined the sensitivity function S (z).


Gain margin is the factor by which the gain can be increased before causing Reasonable ranges of the
stability margins are: 2
the system to go unstable. It is usually the inverse of the magnitude of
6dB GM 4 12dB and
D (z) G (z) when its phase is 180 . 0
30 PM 60 .
Phase magin is the difference between 180 and the phase of D (z) G (z)
when its amplitude is 1. This measures how much additional phase lag or
time delay can be tolerated in the loop before the system becomes unstable.
Stability magin
Considering the definition of the sensitivity function, which suggests that
the system would become unstable when D (z) G (z) = 1. In a controlled
situation, we wish this does not happen (and theoretically it should not).
To evaluate how far we are from the unstability condition, we can look at
the distance of D (z) G (z) from the critical point 1 as | D (z) G (z) + 1|.
There will be a z value that minimizes this quantity, which put the system
closest to the instability. The inverse of this quantity, | D (z) G (z) + 1|1 is
maximized when the system is closet to the instability. As a result, we can
define a stability margin as |S (z)|max . The larger the stability margin is, the
more stable the system is.

City University of Hong Kong 43


5
Robot Control

5.1 Linearization

Most, if not all, physical systems are nonlinear, and many systems have
important nonlinearities such as friction that cannot be ignored even for
a small range of operation. However, the variety of nonlinear systems is
so vast that it would not be possible to consider all issues and concepts.
Robotic systems are typically highly nonlinear as they often involve rota-
tions and revolute joints.
Linearization is the procedure in which a set of nonlinear differential
equations is approximated by a linear set. There are at least two primary
reasons why the process is useful in control. First, there are many good
design and analysis tools for linear systems (for example, we can evaluate
its stability, or design a controller using the pole placement method). Sec-
ond, it can be proven that if the linearized model is stable, there will exist a
small region (though this could be infinitesimally small), within which the
nonlinear system will be stable. Thus, al most always, the first technique for
analysing and controlling a nonlinear system is to obtain a linear approxi-
mation and design a controller for it.
To begin, let x (t) be a state vector, u (t) be the input, and y (t) be the
output of the system. We may write

x (t) = f (x (t) , u (t)) . (5.1)

Suppose we are looking to operate this system near a nominal condition, In the case of a linear system,
provided by x 0 = f (x0 (t) , u0 (t)), but the current state of the system given f (x (t) , u (t)) = Fx + Gu.

by equation (5.1) is slightly different from the nominal condition, we can


write down the difference between them as

x x 0 = f (x (t) , u (t)) f (x0 (t) , u0 (t)) . (5.2)

Define x = x x0 and u = u u0 , it follows that x = x x 0 and


f (x (t) , u (t)) = f (x0 + x, u0 + u). Equation (5.2) becomes

x = f (x0 + x, u0 + u) f (x0 (t) , u0 (t)) . (5.3)

Applying Taylors expansion:



f (x, u) f (x, u)
f (x0 + x, u0 + u) = f ( x0 , u0 ) + x + u (5.4)
x x0 ,u0 u x0 ,u0

1 2 f (x, u) 1 T 2 f (x, u)
+ xT x + u u + . . .
2 x2 x0 ,u0 2 2 u x0 ,u0
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Keeping only upto the first order terms, we can substitute the result from
equation (5.4) to equation (5.3) to yield

f (x, u) f (x, u)
x = x + u
x x0 ,u0 u x0 ,u0
= Ax
+ Bu, (5.5)

f (x,u) f (x,u)
where we have used A = x and B = u . Equation (5.5) is
x0 ,u0 x0 ,u0
in the continuous state space form (c.f equation (1.1)). This can be converted
into the discrete-time state space representation using the methods we have
learned for computer controlled purposes.

Example: Torque Driven Pendulum


For a point mass m hung from a ceiling by a rod of length l, it forms a sim-
ple pendulum system. Let desribes the angle of the pendulum with re-
spect to the vertical. If the attachment point to the ceiling is actuated and
the motor provides a torque , we may write the dynamics equation as


mgl sin = ml 2 .

Find the linearised system for a small deviation from:

1. = 0, = 0.

2. = 0 6= 0, = 0.

5.2 Proportional, Integral, and Derivative

A proportionalintegralderivative controller (PID controller) is a control


loop feedback mechanism (controller) commonly used in industrial control
systems. We have typically been exposed to PID controller expressed in
the continuous-time systems. How can they be expressed in a discrete-time
domain?
Consider a scenario where we have a second order system with the state
h iT
vector x = x x . If the goal is to drive the state vector x to the origin,
one common strategy is to employ a PD control law in the form u = k p x
k d x or u = k p x k d sx (we leave out the integral term for now). To see
how this control law becomes in the discrete-time domain, we express the
Laplace variable s to z using three rules provided in table 4.2. It becomes

Method sz PID control law u = k p x k d sx Table 5.1: PID law in discrete-


z 1 kd time domain.
Forward rule s T u (k) = k p x (k) T ( x (k + 1) x (k))
z 1 kd
Backward rule s Tz u (k) = k p x (k) T ( x (k) x (k 1))
2 z 1
Trapezoid rule s T z +1

5.3 Low-Pass Filtering

In practice, control signals obtained from taking a derivative is typically


very noisy. To avoid applying jittery signals to the physical systems, one

City University of Hong Kong 46


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

usually pass the derivative part of the signal through a low-pass fitler with
a suitable cutoff frequency. This inevitably results some delay which may
affect the stability of the controller. There are various kind of low-pass
fitlers that can also be designed in the continuous-time domain and later
converted to the discrete-time representation. Examples include Butter-
worth, Chebyshev type I & II, etc.

5.4 Case Study: Mobile Robot

A wheeled mobile robot with differential drive is a non-holonomic system


that can navigate in 2D (think of a car). The robot would move forward
with respect to its current orientation () at speed v as described by

x = v cos y = v sin .

Simultaneously, the robot takes two control inputs u1 and u2 in a way that
the first input regulates (increases or decreases) the speed and the second
input changes the orientation of the robot as mathematically written as

v = u1
= u2 .

To capture the dynamics of the robot in 2D space, we construct a state vec-


h iT
tor x = x y v . The nonlinear dynamics of the system is, there-
fore,

x = f (x, u1 , u2 )

x v cos
d y


v sin

= . (5.6)
dt v u1
u2

Task I: Setup Octave Online


If you do not have Matlab on your laptop, you can install Octave (basi-
cally a free Matlab) from https://www.gnu.org/software/octave/ or use
Octave online (very limited performance) at http://octave-online.net/.
Once you have signed it or created an account, script files can be uploaded.
You can also use an online editor to modify the scripts and run them.

Take the script files provided from the Canvas, upload them in the same
folder.

Run the file runMobileRobot.m by simply typing runMobileRobot on


the console and press enter.

Familarise yourself with the code.

Task II: Open loop


By default, control signals generated in robotController.m are u1=0 and
u2=0. That is v and are constant.

City University of Hong Kong 47


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Modify the controller so that u1=50.0*sin(2*pi*t), see the result.

Make u1=0, but u2=pi/2, see the result.

Task III: Design a circular trajectory


Suppose we would like the robot to follow a circular trajectory centred at
the origin with the radius of 1 at constant speed. If we would like the robot
to complete a circle in t = 4:

What should be the nominal value of x0 (t), y0 (t), v0 (t), and hence
u1,0 (t)?

What should be the nominal value of 0 (t), 0 (t), and hence u2,0 (t)?

Change the initial condition in runMobileRobot.m for the robot to start at


[1, 0, v0 (0) , 0 (0)]T , set par.ref=1, and the control u1 and u2 in robotController.m,
see the result.

Enable the disturbance, see run again and see the result (leave it enabled
after this point).

Task IV: Linearisation and Discretisation


Given the desired trajectory x (t) , y (t) , (t) and nominal u1 (t) , u2 (t)
you obtained from Task III, derived the linearised dynamics of the robot
along this trajectory based on equation 5.6. That is, you are to find A (t) , B (t)
for the following equation:

x x 0
d y
y

0

= A +B .
dt v v u1
u2

Then, discretise the linearised dynamics using Forward Euler method as-
suming the sample time is T.

Task V: Design a controller I


To ensure that the robot follows the desired trajectory, we need to devise
a controller. One obvious policy is to have u1 = K11 x K12 y
K13 v K14 and u2 = K21 x K22 y K23 v K24 . Consequently,
the closed-loop dynamics become

x x 0 0 0 0 x
y y 0 0
0 0 y
= A (k) T .
v v K11 K12 K13 K14 v
k+1 k K21 K22 K23 K24 k

x x x
y y y

= A (k) KT = ( A (k ) KT ) .
v v v
k k k

Hence, we can verify whether the proposed control policy stabilises the
system or not by looking at eigenvalues of A (k) TK. However, since A (k)

City University of Hong Kong 48


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

is a function of time or K, it is possible that A (k ) TK might be stable at


some k and unstable at some k. Can you find a set of K that stabilises the
system? Try K13 = 5, K24 = 5 and others being zero, what do you see (with
and without disturbances)?

Task V: Design a controller II


To ensure that A (k) TK is stable for all k, we can make K time-varying.
That is K K (k). You are regularly required to do this for a nonlinear
system with time-varying trajectory. A proof will not be given here, but you
might have a luck if you try to control the robot using this set of gain:

0 0 0 0
0 0 0 0

K= ,
v cos v sin 0
sin cos 0

where we need to include the current state of the system (v and ) in the
gain matrix. Try = 5 = 5 and = 10 = 5. What is the difference? In
fact, one of the parameters acts like a proportional gain and the other acts
like a derivative gain, can you identify which is which?

City University of Hong Kong 49


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

MBE 4039 Computer Controlled Systems


Formula Sheet
Semester B 2016/2017

I. C ONTINUOUS C ONTROL II. I NTRODUCTORY D IGITAL C ONTROL


A. State Space Representation and Transfer A. Linear Difference Equations
Function
For an input e and output k, the difference
The standard expression of the dynamics of equation is
a continuous-time linear system is:
uk = a1 uk1 a2 uk2 ... an ukn
x = F x + Gu
+b0 ek + b1 ek1 + ... + bm ekm
y = Hx + Ju.

The corresponding transfer function can be B. Z-Transform


calculated as
The ztransform of the signal y (k) is de-
1
G (s) = H (sI F ) G + J . fined by

X
B. Final Value Theorems Y (z) Z {y (k)} yk z k .
k=
If the system is stable and has a final, con-
stant value then TABLE I
z- TRANSFORM
lim x (t) = lim sX (s) .
t s0
Signal x (k) z-transform X (z) ROC
(k) 1 all z
C. Frequency Response (k k0 ) z k0 z 6= 0
1
u (k) 1z 1
|z| > 1
Given a transfer function G (s) we can find ak u (k) 1
1az 1
|z| > |a|
the magnitude and phase response of the system ku (k) z 1
|z| < 1
(1z 1 )2
for the input with frequency from 1z 1 cos()
cos (k) u (k) |z| > |a|
q 12z 1 cos()+z 2
2 2 z 1 sin()
|G (j)| = Re [G (j)] + Im [G (j)] sin (k) u (k) 12z 1 cos()+z 2
|z| > |a|

Im [G (j)]
G (j) = tan1 .
Re [G (j)]
C. Initial and Final Value Theorems

D. Response versus Pole Locations


Given a
pole location s = j =  re ,
j
lim f (t) = lim F (z)
t0 z
where r = + = tan
2 2
then:
1
if the right limit exists.
The settling time ts .
4.6
z1
The rise time tr 1.8/r. lim f (t) = lim F (z)
t z1 z
The resonant frequency is r. if the left limit exists.

City University of Hong Kong 50


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

D. Frequency Response D. Reference Input


 For a a constant non-zero reference signal
Define H ejT = H (z) , then
 z=ejT r (k), we define Nr r (k) = xr and ur = Nu r,
Gain = H e
jT where Nr and Nu are calculated from:
and
    
1 Im[H (e )]
jT
Phase = tan Cd 0 Nr I
Re[H(ejT )] = .
I Ad Bd Nu 0
III. S TATE S PACE M ETHODS
E. Estimator
A. Discrete-Time State Space Model
Given and estimator gain matrix L, the esti-
The general form of a linear discrete-time mator equations are
state-space model is
(k) =
x (k) + L [y (k) Cd x
x (k)]
x (k + 1) = Ad x (k) + Bd u (k) (k) =
x (k 1) + Bd u (k 1) .
Ad x
y (k) = Cd x (k) + Dd u (k) ,
The corresponding estimation error x
(k) =
(k) x (k) is
x
B. Difference Equation, State Space, Transfer
function (k) = (Ad LCd Ad ) x
x (k 1) .
Given the transfer function IV. T RANSFORM M ETHODS
1 z 1 + ... + m z m
H (z) = b0 + , A. Discrete Equivalents
1 + a1 z 1 + a2 z 2 + ... + an z n
then the controller canonical form is TABLE II
zs
a1 a2 an1 an
1 0 0 0 Method sz zs

0 1 0 0 Forward rule s z1 z 1 + Ts
A = T
.. .. .. .. Backward rule s z1
Tz
z 1T1
s
. . . . Trapezoid rule s2 z1
z1+T s/2
T z+1 1T s/2
0 0 1 0
 T B. Direct Design by Root Locus
B = 1 0 0 0
  For a pole in s-plane s = + j, in the
C = 1 2 m D = b0 .
z-plane, we obtain
And the transfer function is
eT e|jT
z = |{z} rT cos jrT sin
{z } = |e {z } |e {z } .
1
Cd (zI Ad ) Bd + Dd . rz ejz magnitude phase
The damping ratio is = cos .
C. Discretization of Linear Continuous-Time
State Space Models V. ROBOT C ONTROL
Eulers Forward A. Linearisation
x (k + 1) x (k) Given a nonlinear system x (t) =
= Fx (k) + Gu (k)
T f (x (t) , u (t)), the lineaised equation about
Eulers Backward the nominal point x0 , u0 that satisfies
x (k) x (k 1) x 0 = f (x0 (t) , u0 (t)) is
= Fx (k) + Gu (k)
T f (x, u)
x = x
Tustins x x0 ,u0

x (k) x (k 1) x (k) + x (k 1) f (x, u)
= F + u
T 2 u x0 ,u0
u (k) + u (k 1)
+G = Ax
+ Bu.
2

City University of Hong Kong 51


A
Tutorial 1: Review of Continuous Control

A.1 Lead-Lag Compensator

A lead-lag compensator is a component that improves an undesirable fre-


quency response in a feedback and control system. Both lead compensators
and lag compensators introduce a pole-zero pair into the open-loop transfer
function as
z ,
lead-lag compenstor = ss p

where the pole p and zero z are both typically negative (or on the left half
plane). In a lead compensator, |z| < | p| , while in a lag compensator |z| > | p|.

Sketch bode plots for a lead compensator and a lag compensator.

A.2 Final Value Theorem

Determine the final value to a unit step input for the open-loop systems:
4
G (s) = s2 +4s+4
4
G (s) = s2 4s+4

A.3 Feedback System

An unstable open-loop system has a transfer function G (s) = s1 n where


n > 0. We would like to stabilise the system by closing the loop as seen in
the block diagram in figure 1.1. Suppose n = 5, and the controller takes the
form of a lead-lag compensator
sz
H (s) = .
sp
Find the characteristic equation of a closed-loop system as a function of
n, z, and p.

Assume both z and p are negative, what are the conditions for the closed-
loop system to be stable?

According to the evaluated conditions, should H (s) be a lead compen-


sator or a lag compensentor? Give an example pair of z, p that stabilises
the system.
B
Tutorial 2: Introductory Digital Control I

B.1 Time Shifts

Given the difference equation:

u(k + 2) + au(k + 1) = b1 e (k + 1) + b0 e (k) + b1 e (k 1)

Re-write the difference equation such that it has only zero or negative time
shifts without altering the meaning of the equation (only k x is allowed,
not k + x).

B.2 Stability of a Discretized System

The continuous transfer function


1
G (s) =
sa + 1

is stable for a > 0 as the pole lies in the left half plane. We can discretize
G (s) with time step T using Eulers method. The resultant discrete-time
transfer function is
T/a
H (z) = .
z (1 T/a)
What is a required condition for T (positive) such that the discretized sys-
tem is asymtotically stable?

B.3 Sampling Rate

Consider a continuous-time signal y a (t) = sin t, which is sampled at rate


T to yield a discrete-time signal y (k) = y a (kT ).

Show that y (k) = sin (k) where = T.

Draw signals y (k) for cases i. = /6 and ii. = 5/6 .

One can notice that although the sampled sinusoid is a pure harmonic
at frequency , the time waveform appears to consist of beats as ap-
proaches . Some insight into this appearance may be gained as follows.
Specifically, show that a discrete-time signal y (k) = sin k may be writ-
ten as y (k ) = sin ( ) cos k.
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Hint: First use the periodicity of discrete-time frequencies to write

1
sin k = [sin k + sin ( 2 ) k] .
2
The following trigonometric identity may be helpful:
   
a+b ab
sin a + sin b = 2 sin cos .
2 2

B.4 The zTransform


1 az1 cos( )
Prove that the z-transform of ak cos (k) u (k) is 12az1 cos( )+ a2 z2
.

Prove the linearity and shifting properties of z-transform.

City University of Hong Kong 56


C
Tutorial 3: Introductory Digital Control II

C.1 Time Response

Consider a signal with the transform


z
U (z) =
( z 1) ( z 2)

What is the value given by the Final Value Theorem applied to this U (z)?

Find the final value of u (k) by taking the inverse transform of U (z),
using partial-fraction expansion and the tables.

Explain why the two results differ.

C.2 Stability

Check the following for stability

uk = 0.5uk1 0.3uk2

uk = 1.6uk1 uk2

uk = 0.8uk1 + 0.4uk2 .

C.3 Block Diagram and Transfer Function

Find the transfer functions from the two block diagrams in figure C.1. Ver-
ify that they are identical.

C.4 Inverse z-Transform

Compute the inverse transform, f (k) for


z ( z 1)
F (z) = z2 1.25z+0.25
, |z| > 1
8z19
F (z) = (z2)(z3)
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Figure C.1: block diagrams

City University of Hong Kong 58


D
Tutorial 4: Discrete State Space Methods I

D.1 Difference Equation to State Space

Consider the difference equation

16yk+3 20yk+2 + 8yk+1 yk = 5uk+2 7uk+1 + 2uk ,

find the state space realization of the system.

D.2 State Space to Transfer Function

From the state system


" # " #" # " #
x1 ( k + 1) 0.5 1.5 x1 ( k ) 2
= + u (k)
x2 ( k + 1) 1 2 x2 ( k ) 0
" #
h i x (k)
1
y (k) = 1 1 + 2u (k) ,
x2 ( k )

evaluate the transfer function of the system.

D.3 Transfer Function, Conanical Form, and Partial Fraction

Consider a discrete-time system with the corresponding transfer function


3
H (z) =
( z + 1) ( z + 3)
Express the system in control conanical form, that is to find the corre-
sponding matrices Ad , Bd , Cd , and Dd such that
" # " #
x1 ( k + 1) x1 ( k )
= Ad + Bd u (k )
x2 ( k + 1) x2 ( k )

Perform partial fraction on H (z). The result can be regarded as two


subsystems (with the same input) running in parallel, find the matrices
Ad1 , Ad2 , Bd1 , Bd2 , Cd1 , Cd2 , Dd1 and Dd2 of these two subsystems.

In facts, the matrices Ad1 , Ad2 , Bd1 , Bd2 , Cd1 , Cd2 , Dd1 and Dd2 are just
scalars. And the two subsystems can be recombined to create a new
system using
" # " #
Ad1 0 Bd1
Ad12 = Bd12 ,
0 Ad2 Bd2
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

find C12 and D12 .

If I assert that there exists a 2 2 transformation matrix T such that

Ad = T1 Ad12 T
Bd = T1 Bd12
Cd = C12 T
Dd = D12 .

Can you find such matrix?

D.4 Solve the Difference Equation

Use the z-transform to solve the difference equation

y (k) 3y (k 1) + 2y (k 2) = 2u (k 1) 2u (k 2)

U k 0
0
u (k) =
0 k<0

City University of Hong Kong 60


E
Tutorial 5: State Space Methods and Transform Meth-
ods

E.1 Pole Placement and Estimator

The simplified discrete-time model of a stellite attitude-control system with


the sample period of T = 0.1s is

" # " #
1 T T 2 /2
x ( k + 1) = x+ u.
0 1 T

Find the control law for placing the closed-loop poles at z = 0.8 0.25j.

Construct an estimator for the case


h whereithe measurement is the posi-
tion state element x1 so that C = 1 0 . Pick the desired poles of the
estimator to be at z = 0.4 0.4j. Write down the corresponding estimator
algorithm.

E.2 Direct Design by Root Locus

In the process of controlling a discrete-time system using the pole place-


ment method, we would like to ensure that the closed-loop (meaning, con-
trolled) system has the desired properties by placing the poles in the right
location in the z-space. This required specifications are typically using the
notion of continuous-time domain. For example,

If we would like to ensure that the rise time of the system is less than 0.1
second, what should be the magnitude of the pole, r, in the s domain?

Given the sample time T = 0.1 s. Which area in the z-plane that the pole
of the discrete-time system should be in?
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

1
0.5/T
0.6/T 0.4/T
0.8 0.1
0.7/T 0.3/T
0.2
0.6 0.3
0.8/T 0.4 0.2/T
0.5
0.4 0.6
0.7
0.9/T 0.8 0.1/T
0.2 0.9
1/T
0
1/T

0.2
0.9/T 0.1/T
0.4

0.8/T 0.2/T
0.6

0.7/T 0.3/T
0.8
0.6/T 0.4/T
0.5/T
1
1 0.5 0 0.5 1

If we would also like t the discrete-time state vector x (k ) follows the


contraint
|x (k + 1)| = |x (k)| ,
for 0.6 < < 0.8. This means that, when controlled, the magnitude of
the state vector decreases by at each time step. To ensure this happens,
we have to make sure the pole of the controlled system lies between two
circles of radius 0.6 and 0.8 in the z-plane. Highlight this region in the
plot above.

Find the intersection between the areas to yield the area that satisfies all
the requirements.

Comment whether which following set of poles satisfy the requirements:


i) z = 0.6 0.4j or ii) z = 0.4 0.4j.

For the system in the first question, find the control law using the pole
placement to place the poles at i) or ii) as you just found above.

E.3 Discrete Equivalents

The second order linear system of interest has a continuous transfer func-
tion
s+1
H (s) = 2 .
s + 5s + 6
Find the discrete-time transfer function of the system using Forward,
Backward, and Zero-pole matching methods for sample time T = 0.1 s.

In the continuous-time domain, if we would like to find the system


response to the input signal with frequency 2 Hz, we can substitute
s = j = j2 2, which yields

H (s = 4j) = 0.0236 0.0730j


= 0.0767e j1.258 .

The means that at this frequency, the phase of the transfer function is
-1.258 rad, or 72 . In the lecture, we learned that when we convert the

City University of Hong Kong 62


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

continuous-time transfer function to the discrete-time transfer function


using Forward or Backward method, there would be phase lead/lag de-
pending on the method and the frequency of interest. What are the pre-
dicted phase lead/lag due to the conversion at = 4 for the Forward
and Backward methods?

City University of Hong Kong 63


F
Tutorial 6: Transform Methods

F.1 Discrete Equivalents

Given a lead filter which has the continuous transfer function


s+1
H (s) = ,
0.1s + 1

Evaluate the corresponding discrete-time transfer functions with T = 0.25


using

Forward rule

Backward rule

Trapezoid rule

Pole-zero mapping

Then comment on the stability of the continuous-time system and converted


discrete-time systems.

F.2 Frequency Response

Continuted from the previous question, show that

The phase of the continous-time system at 3 rad/sec is 54.9 .

Evaluate the phase of discrete-time systems at the same input frequency


obtained from the forward, backward, trapezoid methods. How are they
compared to the continuous-time system?

F.3 Stability Margins

Take the open-loop discrete-time transfer function with sample time T = 0.2
from the following:

z+1
G (z) = 0.05 .
z2 1.9z + 0.9
Find the poles, is the system stable in open-loop?
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

To stabilize the system, we closed the loop using a proportional con-


troller with the elementary feedback configuration (shown in figure 1.1) with
the gain K = 1. What is the characteristic equation of the closed-loop
transfer function? What are the poles of the close-loop system? Comment
on the stability.

For the closed-loop gain K = 1, calculate the phase and magnitude of the
KG when z = e j2.26T .

Re-calculate the characteristic equation and the stability analysis for


K = 2.

What is the gain margin of the closed-loop system when K = 1?

City University of Hong Kong 66


G
Practice Exam Questions

Make sure you are confident with the examples, tutorial questions, and
mid-term exam questions. The final exam will be closed-book, but you will
be provided with the formula sheet. Study the meaning of material on the
formula sheet and how to use them. Content not provided by the formula
sheet could be in the exam.

Question 1
The plant of a continuous-time feedback system is

10
G (s) =
s2 + 3s + 9
1. Convert the system to discrete state-space form with T = 0.1 s.

2. Find a controller matrix K using the pole placement method to obtain


equivalent s-plane control poles at = 0.5 and r = 4 rad/sec.

3. Find the estimator matrix L to obtain equivalent s-plane control poles at


= 0.5 and r = 8 rad/sec.

4. Determine Nu and Nr , then write down the equations desrcibing the


control method for a reference input yr .

Question 2
Take the open-loop discrete-time transfer function with sample time T = 0.2
from the following:

z+1
G (z) = 0.05 .
z2 1.9z + 0.9
1. This system is unstable, to stabilize the system, we closed the loop using
a proportional controller with the elementary feedback configuration (shown
in figure 1.1) with the controller H (z) = K zz0.9 with the gain K = 1. Is
the closed-loop system stable?

2. For the closed-loop gain K = 1, calculate the phase and magnitude of the
HG when = 5 rad/s.

3. What is the gain margin of the closed-loop system when K = 5?


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

4. If you would like to find the stability margin of this closed-loop system,
what is the equation you have to evaluate to find it?
hint: the stability margin can be found from

M (z = z ) when

d
M (z) = 0,
dz z=z

what is M (z) ?

Question 3
Consider a system with no input

y (k + 3) 3y (k + 2) 18y (k + 1) + 40y (k ) = 0.

If you are informed that y (0) = 2, y (1) = 3, and y (2) = 4, find the general
solution of y (k). (hint: one root of the equation x3 3x2 18x + 40 = 0 is 2)
control strategy that only relies on easily obtainable state body reaches its maximum height during flight with y = 0.
measurements. Another inquiry on how to achieve effective Another important event, not illustrated in the figure, is bottom,
control of the SLIP model, now extended to a spatial setting, corresponding to the point of maximal leg compression during
Question 4 is provided in [8], focusing on lateral motions of the model. In stance. Table I details the notation used throughout the paper.
conjunction with these studies primarily focused on running
[y , x ] [ya , x a ]k+1
behaviors, similar analytically motivated contributions were
Convert the following discrete-time transfer function to continous-time a a k [rlo, lo, rlo, lo]
also made to the structurally different walking behaviors [15, [td , rtd , td ]
transfer functions 22,
when T = 0.5
40], providing using
evidence that forward, backward,
the same dynamic model can and trapezoid
provide a unified description for both walking and running
rules. Is the discrete-time system stable? What about the continous-time
touchdown
[17].
systems? Our contributions in the present paper have a number of

lifto

apex
apex

important differences from existing work. Firstly, our plant


z (z the
model is dissipative, impairing 1)accuracy of most existing descent stance ascent
2
.
z 1.25z + 0.25
analytic approximations and associated predictions. Secondly,
Fig. 2. A single TD-SLIP stride with definitions of transition states
in contrast to the usual energy regulation mechanisms in the
literature through adjustments of the leg length or changing TABLE I
Question 5 stiffness, our model uses only a single torque actuator at
N OTATION USED THROUGHOUT THE PAPER
the hip relative to a virtual body with fixed orientation to
compensate for energy losses. These changes are motivated System States, Event States and Control Inputs
Consider an actuatedby beingspring-loaded robotic
much more realistic from anleg as shown
implementation in the figure
point x, y, x, ybe- Cartesian body position and velocities
r, , r, Leg length, leg angle and velocities
low. The equationsof view, as evidenced by the successful use of similar actuation
of motion when the leg is in the air
mechanisms in the Scout quadrupeds [26] and the RHex hexa-
are Hip torque command during stance
ya , x a Apex height and velocity
" pod [30]# as well " as a number of other monopedal platforms # td td td
, r
,
Touchdown leg angle, polar velocities
d [12,
m r 32]. Finally, our mg cos
2
mrapproximate tokthe
solutions ri )map
(r return t b , r b ,
cr tlo , rlo , lo , rlo , lo Bottom
b time, leg length and angle
Liftoff time, leg length, angle and velocities
also take = into account the effect of gravity on the angular ,
dt mr 2 mgr sin + respect to p Angular momentum around the toe
momentum for steps that are non-symmetric with Kinematic and Dynamic Parameters
the gravitational vertical, increasing the practical applicability m, g Body mass and gravitational acceleration
of associated stability results. k, r0 , c Leg stiffness, rest length and damping
where m is the mass of the leg, ri is the natural length, k is a sprint constant
During flight, the body obeys ballistic flight dynamics
and c is a damping II.coefficient.
T HE T ORQUE -ACTUATED D ISSIPATIVE SLIP M ODEL
! " ! "
A. System Dynamics and the Apex Return Map x 0
=
y g
and the massless leg can be arbitrarily positioned. In contrast,
during stance, the toe remains stationary on the ground while
r the body mass feels forces generated by both the passive
k spring-damper pair and the hip torque. The stance dynamics
c
of the planar SLIP model in polar leg coordinates with respect
y to the toe location take the form
! " ! "
x d mr mr2 mg cos k(r r0 ) cr
= . (1)
dt mr2 mgr sin +

A very useful abstraction for the analysis and control of


Fig. 1. TD-SLIP : Dissipative spring-mass hopper with rotary hip actuation
cyclic TD-SLIP trajectories is provided by the apex return
Identify the state Fig.
vector of thethesystem,
1 illustrates x, and
Torque-actuated linearise
Dissipative the map,
Spring- dynamics
defined asof a Poincare map from one apex point to the
next. In the following sections, we will use this map to study
Loaded Inverted Pendulum (TD-SLIP)
the system about the constant nominal operating point x0 (whereplant we investigate in = 0 and
r 0properties
stability of TD-SLIP, and later adopt it as a task-
this paper. It consists of a fixed orientation (2-DOF) planar
0 = 0). rigid body with mass m, connected to a massless, fully passive
level gait representation for a closed-loop running controller.
The apex return map can be formulated as P := Pa Ps Pd
leg with linear compliance k, rest length r0 and linear viscous
by composing three individual submaps Pd , Ps , Pa for the
damping c, through an actuated rotary joint with torque .
descent, stance and ascent phases, respectively. The descent
The system alternates between stance and flight phases during
and ascent maps are trivial and are given by
running, with the flight phase further divided into the ascent ! " ! "
and descent subphases. Fig. 2 illustrates the three important rtd x a
Pd : = R(/2 td ) # (2)
events that define transitions between these phases: touchdown, r0 td 2g(ya r0 cos td )
! " ! 2
"
where the leg comes into contact with the ground, liftoff, where y a r lo cos lo + y
lo /(2g)
Pa : = (3)
x a x lo
City University of theHong Kong
toe takes off from the ground and finally apex, where the 68
H
Solutions
MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 70


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

A2.
From
4
G (s) =
s2 + 4s + 4
4
=
(s + 2)(s + 2)
Poles of the system are at s = 2, therefore, the system is stable.
Final Value is found from
4 s 4
lim = = 1.
s0 ( s + 2)( s + 2) s 4
From
4
G (s) =
s2
4s + 4
4
= ,
(s 2)(s 2)
and
4 s 4
lim = = 1.
s0 ( s 2)( s 2) s 4
But the poles of the system are at s = 2. Hence, the system is unstable.
There is no final value.

A.3
From figure 1.1 and

Y (s) G (s)
=
U (s) 1 + G (s) H (s)
1
sn
= z )
1 + ( s1 n )( ss p
sp
=
(s n)(s p) + (s z)
The characteristic equation is
(s n)(s p) + (s z) = 0
2
s + (1 n p)s + (np z) = 0

Conditions for stable system are


1n p > 0
and
np z > 0.

If n=5, then
p > 4
5p > z.
For example, we may choose
p = 5
z = 30.

City University of Hong Kong 71


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

B.1
u(k) + au(k 1) = b1 e(k 1) + b0 e(k 2) + b1 e(k 3)

B.2
A discrete transfer function is stable if the magnitude off all poles are
smaller than unity, i.e., |1 Ta | < 1. In this case, it becomes

T
1 <1
a
and
T
1 > 1,
a
which can be re-written as T > 0 and 2a > T.

City University of Hong Kong 72


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 73


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 74


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

C.1
Applying the Final Value Theorem :
z1 z1 z
lim U (z) = lim
z 1 z z1 z ( z 1)( z 2)
1
= lim ]
z 1 z 2
= 1

Let
a b ( z 2) a + ( z 1) b
U (z) = + = ,
z1 z2 ( z 1) ( z 2)
it follows that

( z 2) a + ( z 1) b = z
( a + b)z + (2a b) = z.

By comparing coefficients, the following equations are formed


(
a+b = 1
2a b = 0

Solving the equations yields a = 1 and b = 2.


1 2
U (z) = +
z1 z2
z 1 z 1
=
+2
1z 1 1 2z1
Since
u(k) = Z 1 {U (z)} ,
we have (using the inverse z-transform table)

u ( k ) = u ( k 1 ) + 2 2k 1 u ( k 1 )

= u ( k 1 ) + 2k u ( k 1 )
It can be seen that the final value is

lim u(k)
k

The difference is because the system is unstable. The poles of the system
is outside the unit circle, hence u(k) does not have a constant final value.

C.2
From

uk = 0.5uk1 0.5uk2
0 = uk 0.5uk1 + 0.3uk2 .

The characteristic equation is

1 0.5z1 + 0.3z2 = 0
z2 0.5z1 + 0.3 = 0.

City University of Hong Kong 75


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

We find
p
0.5 (0.5)2 4(0.3)
z=
2
= 0.25 0.487i
|z| = 0.548 < 1.
Therefore, the system is stable.

From

uk = 1.6uk1 uk2
0 = uk 1.6uk1 + uk2

The characteristic equation is

1 1.6z1 + z2 = 0
z2 1.6z + 1 = 0.

We have
p
1.6 (1.6)2 4
z=
2
= 0.8 0.6i
|z| = 1
Therefore, the system is marginally stable.
For

uk = 0.8uk1 + 0.4uk2
0 = uk 0.8uk1 0.4uk2

The characteristic equation :

1 0.8z1 0.4z2 = 0
z2 0.8z1 0.4 = 0,

we get
p
0.8 (0.8)2 + 4(0.4)
z=
2
= 0.4 0.748
z = 1.148 and z = 0.348 < 0
Therefore, the system is not stable.

C.3
Consider the first system.
u = b0 e + x1 ,
where

x1 = (b1 e a1 u + x2 )z1
x2 = (b2 e a2 u + x3 )z1
x3 = (b3 e a3 u)z1 .

City University of Hong Kong 76


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Together, we have

u = b0 e + z1 (b1 e a1 u + z1 (b2 e a2 u + z1 (b3 e a3 u)))


uz3 = b0 ez3 + b1 ez2 a1 uz2 + b2 ez a2 uz + b3 e a3 u
u(z3 + a1 z2 + a2 z + a3 ) = e(b0 z3 + b1 z2 + b2 z + b3 )
u b z3 + b1 z2 + b2 z + b3
H (z) = = 03 .
e z + a1 z2 + a2 z + a3
Consider the second system.

u = b0 x1 z + b1 x1 + b2x2 + b3 x3 ,

with

x 1 = ( e a 1 x 1 a 2 x 2 a 3 x 3 ) z 1
x 2 = x 1 z 1
x 3 = x 2 z 1 .

This becomes

u = b0 x1 z + b1 x1 + b2x2 + b3 x3
= b0 x1 z + b1 x1 + b2 x1 z1 + b3 x1 z2
= (b0 z + b1 + b2 z1 + b3 z2 ) x1
x 1 = ( e a 1 x 1 a 2 x 2 a 3 x 3 ) z 1 , (1)

whereas

x1 = ez1 a1 x1 z1 a2 x1 z2 a3 x1 z3
ez1 = x1 + a1 x1 z1 + a2 x1 z2 + a3 x1 z3
e = ( z + a 1 + a 2 z 1 + a 3 z 2 ) x 1 . (2)

Combine (1) and (2)

u (b z + b1 + b2 z1 + b3 z2 ) x1
H (z) = = 0
e ( z + a 1 + a 2 z 1 + a 3 z 2 ) x 1
b0 z3 + b1 z2 + b2 z1 + b3
= .
z3 + a1 z2 + a2 z1 + a3
As both systems have the same transfer function, they are identical.

C.4

z ( z 1)
F (z) =
z2 1.25z + 0.25
z ( z 1)
=
(z 1)(z 0.25)
z
=
(z 0.25)
1
=
(1 0.25z1 )
Z 1 { F (z)} = 0.25k u(k)

City University of Hong Kong 77


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

Let
a b
F (z) = + ,
z2 z3
where
a(z 3) + b(z 2) = 8z 19
( a + b)z + (3a 2b) = 8z 19.
By comparing coefficients, the following equations are obtained
(
a+b = 8
3a 2b = 19
Solving the equations yields a = 3 and b = 5. That is

3 5
F (z) = +
z2 z3
3z1 5z1
= +
1 2z1 1 3z1
Z { F (z)} = 3(2 u(k 1)) + 5(3k1 u(k 1)).
1 k 1

D.1
Starting from
16yk+3 20yk+2 + 8yk+1 yk = 5uk+2 7uk+1 + 2uk
16yk z3 20yk z2 + 8yk z yk = 5uk z2 7uk z + 2uk
(16z3 20z2 + 8z 1)yk = (5z2 7z + 2)uk
yk 5z2 7z + 2
H (z) = =
uk 16z3 20z2 + 8z 1
5 1 7 2 2 3
16 z 16 z + 16 z
= 20 1 8 2 1 3
.
1 16 z + 16 z 16 z
Use the canonical form,

20 8 1
16 16 16

A=1 0 0
0 1 0

1

B = 0
0
h i
C = 165 7 2
16 16

D=0
That is


20 8 1
x1 ( k + 1) 16 x1 ( k ) 1
16 16

x2 ( k + 1) = 1 0 0 x2 ( k ) + 0 u ( k )
x3 ( k + 1) 0 1 0 x3 ( k ) 0

h i x1 ( k )
Y (k) = 5 7 2
16 16 16 x2 ( k ) .
x3 ( k )

City University of Hong Kong 78


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

D.2
From
" #
0.5 1.5
Ad =
1 2
" #
2
Bd =
0
h i
Cd = 1 1

Dd = 2

We have

Y (z)
H (z) = = Cd (zI Ad )1 Bd + Dd
U (z)
" # " #!1 " #
h i z 0 0.5 1.5 2
= 1 1 +2
0 z 1 2 0
" #!1 " #
h i z + 0.5 1.5 2
= 1 1 +2
1 z2 0
" #" #
1 h i z 2 1.5 2
= 2 1 1 +2
z 1.5z + 0.5 1 z + 0.5 0
" #
1 h i 2
= z1 z2 +2
z2 1.5z + 0.5 0
2z 2
= +2
z2
1.5z + 0.5
2z2 z 1
= 2 .
z 1.5z + 0.5

City University of Hong Kong 79


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 80


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 81


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 82


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

D.4

y(k) 3y(k 1) + 2y(k 2) = 2u(k 1) 2u(k 2)


Y (z) 3Y (z)z1 + 2Y (z)z2 = 2U (z)z1 2U (z)z2
2z1 2z2
Y (z) = U (z)
1 3z1 + 2z2
2z 2
= 2 U (z)
z 3z1 + 2z
2( z 1)
= U (z)
(z 1)(z 2)
2
= U (z)
( z 2)

Consider u(k ) = U0 for k > 0, this is

1
U (z) = U0
1 z 1
Hence,
2 1
Y (z) = U
( z 2 ) 0 1 z 1
2z
= U0
(z 1)(z 2)

By partial fraction,
 
2 4
Y (z) = U0 +
z1 z2
 
2z1 4z1
= U0 +
1 z 1 1 2z1
y (k) = U0 (2 u(k 1) + 4 2k1 u(k 1))
= 2U0 u(k 1) + 2k+1 U0 u(k 1)
 
= 2 2k 1 U0 u(k 1).

E.1
h i
Use the control in the form u (k) = k1 k2 x (k) . The closed-loop
dynamics become
" 2 2
#
1 T2 k1 T T2 k2
x ( k + 1) = x.
Tk1 1 Tk2

The poles are found from solving


" #
2 2
1 T2 k1 T T2 k2
Iz = 0
Tk1 1 Tk2
 
z2 + TK2 K1 T 2 /2 2 z + K1 T 2 /2 TK2 + 1 = 0

Match the characteristic equation to z2 1.6z + 0.7 = 0 , which yields


K1 = 0.1/T 2 = 10 and K2 = 0.35/T = 3.5.

City University of Hong Kong 83


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

h iT
For the observer design, we write L = L1 L2 and find the eigen-
values of A LCA, which becomes

z2 + ( L1 2) z + TL2 + 1 L1 = 0.

The desired characteristic equation is z2 0.8z + 0.32 = 0. Equating the


two equations provide L1 = 1.2 and L2 = 0.52/T = 5.2. That is, the
observer equations are

x1 (k + 1) = x1 (k) + 0.1x2 (k) + 0.005u (k) + 1.2 (y (k) x1 (k))


x2 (k + 1) = x2 (k) + 0.1u (k) + 5.2 (y (k) x1 (k)) .

E.2
The rise time requirement:

tr = 1.8/r
r > 1.8/0.1 = 18 = 0.57/T.

The poles should be on the left hand side of the red line.

1
0.5/T
0.6/T 0.4/T
0.8 0.7/T 0.10.3/T
0.2
0.6 0.3
0.8/T 0.4 0.2/T
0.5
0.4 0.6
0.7
0.9/T 0.8 0.1/T
0.2 0.9

1/T
0
1/T

0.2
0.9/T 0.1/T

0.4

0.8/T 0.2/T
0.6

0.7/T 0.3/T
0.8
0.6/T 0.4/T
0.5/T
1
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1

The poles should also be in between two blue circles.

z = 0.6 0.4j satisfies the requirements.

For pole placement, we look for K1 and K2 that satisfy


 
z2 + TK2 K1 T 2 /2 2 z + K1 T 2 /2 TK2 + 1 = (z 0.6 0.4j) (z 0.6 + 0.4j)
= z2 1.2z + 0.52

That is

TK2 K1 T 2 /2 2 = 1.2
2
K1 T /2 TK2 + 1 = 0.52.

City University of Hong Kong 84


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 85


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 86


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 87


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 88


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

City University of Hong Kong 89


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

F.2
You would fne the the phase of the continous transfer function is 55 ,
forward method 74 , backward method 40 , and the bilinear 55 .

Notice that the results might not be the same as what you expected. In
fact, you are not seeing the phase lag/lead effect from the denumerator
of the transfer function. This is because you can re-write the original
transfer function as
s+1
10 .
s + 10
The effect of the denominator would only kick in at the frequency s > 10
(approximately). That is > 10, which is larger than 3 rad/s we tested.
That is why we do not see it.

In this case, the sampling time is 0.25 s (or 4 Hz), hence the maximum
frequency for the discretized system is 2 Hz, or = 2 2 = 12. This is
not really bigger than 10, so we are unlikely to see it.

F.3
Poles are at z = 1.0, 0.9. The system is not stable.

The characteristic equation is 1 + KG (z) = 0, where K = 1. This turns out


to be

z2 1.9z + 0.9 + 0.05 (z + 1) = 0


2
z 1.85z + 0.95 = 0.
The poles are at z = 0.925 0.3072j, the magnitude is 0.5. Hence, the
closed-loop system is stable when K = 1.

When K = 2, the characteristic equation is z2 1.8z + 1 = 0. The poles are


at z = 0.9 0.4359j. The magnitude of the pole is 1. Hence, the system is
marginally unstable.

The gain magin is 1/0.5 = 2, consistent with the fact that the system
becomes marginally unstable when K = 2.

G.1
First we convert the system into the state-space form:
" # " #
0 1 0
x (t) = x (t) + u (t)
9 3 1
h i
y (t) = 10 0 x (t) ,

then use the Forward method to discretize the system:


" # ! " #
0 1 0
x ( k + 1) = I+ T x (k) + Tu (k )
9 3 1
" # " #
1 0.1 0
= x (k) + u (k)
0.9 0.7 0.1
h i
y (k) = 10 0 x (k)

City University of Hong Kong 90


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

h i
Suppose we use the controller u (k) = K1 K2 x (k). The close-loop
dynamics become
" #
1 0.1
x ( k + 1) = x (k) ,
0.9 0.1K1 0.7 0.1K2

of which the poles can be found from

(z 1) (z 0.7 + 0.1K2 ) + 0.1 (0.9 + 0.1K1 ) = 0


z2 + (0.1K2 1.7) z + 0.02K1 + 0.79 0.1K2 = 0

From the specification in the s-plane, express the pole s as s = re j , where


= cos = 0.5 = 120 = 2/3. That is s = 4e j2/3 . In the z-plane,
2 2
we have z = esT = e0.4(cos 3 + j sin 3 ) = 0.77 + 0.28j. Naturally, we expect
another pole at z = 0.77 0.28j. That is we are looking for the following
characteristic equation

(z 0.77 0.28j) (z 0.77 + 0.28j) = 0.

Equating two characteristic equations (by matching the coefficients in


front of z) to determine K1 and K2 .
h iT
The estimator gain L = L1 L2 provides the dynamics of the esti-
mation error as

x (k + 1) = ( A LCA) x (k)
" # " # !
1 0.1 L1 h i
= 10 10 x (k )
0.9 0.7 L2
" #
1 10L1 0.1 10L1
= x (k)
0.9 10L2 0.7 10L2

The poles of the above equation can be found from solving


" #
z 1 10L 0.1 + 10L1
1
= 0.
0.9 + 10L2 z 0.7 + 10L2

From the desired, specifications, we woud like to place them at z = esT =


2 2
e0.8(cos 3 + j sin 3 ) = 0.52 0.43j. Hence, we look for L1 and L2 that
produce the following characteristic equation:

(z 0.52 0.43j) (z 0.52 + 0.43j) = 0.

Nr and Nu are found from solving


" #" # " #
C 0 Nr I
=
I A B Nu 0

10 0 0 Nr1 1

0 0.1 0 Nr2 = 0
0.9 0.018 0.1 Nu 0

The equations for control with the refence input yr is

u (k ) = Nu yr K (x (k) Nr yr ) .

City University of Hong Kong 91


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

G.2
The closed-loop stability is determined from the zeros of 1 + G (z) H (z),
which is
 
z z2 1.9z + 0.9 + 1 0.05 (z 0.9) (z + 1) = 0
z (z 0.9) (z 1) + 0.05 (z + 1) (z 0.9)
h i
(z 0.9) z2 0.95z + 0.05 = 0

or z = 0.9, 0.89, 0.06. That is the closed-loop system is stable.

At = 5 rad/s, z = e j/2 = j, we get

( z + 1)
GH = 0.05
z ( z 1)
z2 + 2z + 1
= 0.05 = 0.05.
z ( z2 1)

That is the magnitude is 0.05 and the phase is 180 . It follows that the
gain margin is 1/0.05 = 20.

The gain margin would become 20/5=4.

To find a stability margin, we first need to find z such that

1
z = arg max
z |1 + G (z) H (z)|

that is the stability margin is |1 + G (z ) H (z )|1 , which is found from


solving the equation

d
|1 + G (z) H (z)|1 = 0
dz

G.3
A general solution of a linear difference equation is y = Ak . The substi-
tution yields,

3 32 18 + 40 = 0
( 2) ( 5) ( + 4) = 0.

Hence y (k ) = A1 2k + A2 5k + A3 (4)k . We find

y (0) = A1 + A2 + A3 = 2
y (1) = 2A1 + 5A2 4A3 = 3
y (2) = 4A1 + 25A2 + 16A3 = 4.

Solve the system of linear equations, we obtain A1 = 13/6, A2 = 2/9,


and A3 = 1/18. Therefore

13 k 2 k 1
y (k) = 2 5 + (4)k .
6 9 18

City University of Hong Kong 92


MBE4039 Computer Controlled System
Semester B 2016/17 P Chirarattananon

G.4
The discrete-time system
z ( z 1) z ( z 1) z
= =
z2 1.25z + 0.25 (z 1) (z 0.25) z 0.25
is stable as the pole is smaller than unity.

Forward rule z = 1 + Ts,


2s + 4
G (s) = .
2s + 3
The system is stable as the pole is negative.

Backward rule z = 1/ (1 Ts)


8
G (s) = .
s+6
The system is stable as the pole is negative.

Trapezoid rule z = 1/ (1 Ts)


4 ( s + 4)
G (s) = .
(5s + 12)
The system is stable as the pole is negative.

G.5
h iT
The state vector x is x = r r . The provided equations of
motion can be re-written as:
k c
r = r 2 g cos (r ri ) r
m m
r g
2 + = sin + .
r r mr2
The dynamics of the system is then

r
r 2 g cos k (r r ) c

x = f (x, ) = m i m r
.

g r
r sin + 2 r + mr2

At the constant nominal operating point we have



0 r 0
0
r0 0 g cos 0 mk (r0 ri )
2 c
m r 0
x 0 = = ,
0 0

g 0
0 r0 sin 0 + mr2
0

which means g cos 0 + mk (r0 ri ) = 0 and 0 = mgr0 sin 0 . The


linearised dynamics about this point are

0 1 0 0 r 0

02 mk mc g sin 0 0 r
0
x = + .
0 0 0 1 0

g2 sin 2 03
r0
0
mr0
g
r cos 0 0 0

1
2 mr0

City University of Hong Kong 93

Das könnte Ihnen auch gefallen