EE5103/ME5403 Lecture Two Computer Control and Discrete-Time Systems
EE5103/ME5403 Lecture Two Computer Control and Discrete-Time Systems
Computer Control
and Discrete-Time Systems
Xiang Cheng
Associate Professor
Department of Electrical & Computer Engineering
The National University of Singapore
• If I want you to choose ONLY ONE that you think is the most important
concept for control theory, what would you say?
Feedback
2
Control of the robotic manipulator
For small y =θ −π
Angle
r=0 INPUT Robotic OUTPUT
REFERENCE Difference: Torque manipulator
ERROR
1
Controller
+ s2 −1
–
Objective: To bring the system OUTPUT to zero (upright position) for any small
nonzero initial conditions.
3
Open-loop control
r u 1 y
C(s)
s2 −1
Zero. So it is possible to cancel out the poles and zeros if the whole system is stable.
s +1 1
≈
( s + 1)( s + 2) s + 2
If the whole system is stable, then the common poles and zeros can cancel out
each other such that the reduced T.F. is good approximation of the original one.
5
Let’s take a look at another example.
r u s−2 y
C(s) 2
s −1
Let 1
C (s) =
s−2 s−2
The transfer function from r to y is
( s − 2)( s 2 − 1)
Should we cancel out this common factor (s-2)?
Let’s write down the differential equation relating y and u
s−2
Y (s) = 2
U (s) ( s 2 − 1)Y ( s ) =
(s− 2) U(s)
s −1
Let’s write down the equation relating r and u
1
U (s) = R( s) (s− 2) U(s) =
R(s)
s−2
What is the differential equation relating r and y?
1
What is the transfer function from r to y?
( s 2 − 1)
We need to cancel out this common factor (s-2) in order to get the correct answer! 6
Let’s compare the two examples carefully.
r 1 y r 1 u s−2 y
s-1
s2 −1 s−2 s2 −1
The transfer function from r to y is
s −1 1
( s 2 − 1) ( s 2 − 1)
7
r u 1 y r 1 u s−2 y
s-1
s2 −1 s−2 s2 −1
The transfer function from r to y is
s −1 1
( s 2 − 1) ( s 2 − 1)
U(s)= ( s − 1) R( s ) (s− 2) U(s) =
R(s)
Overall, we have
Overall, we have
2
( s − 1)Y ( s ) =
( s − 1) R( s ) ( s 2 − 1)Y ( s ) =
R( s )
This common factor (s-1) This common factor (s-2) has
cannot cancel out. to cancel out.
If the common factors are operating on the same variable, they should cancel out.8
If the common factors are operating on different variables, they should remain.
What is a feedback control system?
9
r y r y
C(s) H(s) C(s) H(s)
+ –
Y (s)
= C (s) H (s) Y ( s) C ( s) H ( s)
R( s) =
R( s) 1 + C ( s) H ( s)
• There are so many wonderful properties about the feedback controller.
• What is the most important one?
• No. Only feedback controller can change the dynamic property of the whole system!
Therefore, an unstable system can be stabilized by feedback!
• But it is a double-edged sword! It can also destabilize the system!
• Whenever a feedback controller is used, the dynamic property of the system has
been changed!
• Therefore, you have to design your feedback controller carefully because it can
make the performance better, and also possibly worse.
• However, there is one obvious advantage for open loop controller from the point of
view of implementation, what is that?
It is much easier to implement!
Drawing the feedback link in one second, which may cost the engineers one year!
10
What is a Computer Control System?
The controller is implemented by a computer instead of an analog circuit!
How to convert an analog controller into computer control system?
Replace the analog circuit controller with a computer!
Difference: INPUT
Torque Angle
r=0 ERROR
OUTPUT
REFERENCE
KComputer
p + Kd s robotic manipulator
+
–
Sampling!
Zero-order Hold
First-order Hold
( sI − A) −1 e At
t
x(t ) = e x(0) + ∫ e A(t −τ ) bu (τ )dτ
At
0 t
y = cx = ce x(0) + c ∫ e A( t −τ ) bu (τ )dτ
At
Assume that the state at time t k is known, how to calculate the future state at
time t, x(t), where t is in the interval [t k , t k +1 ] ?
t
x(t ) = e A( t −t k )
x(t k ) + ∫ e A(t −τ )bu (τ )dτ
tk
tk t −t k 0
t −t k
h
x(kh + h) = e x(kh) + ( ∫ e Av dv)bu (kh) = Φx(kh) + Γu (kh)
Ah
0
Choose the sampling period as the time unit
State-space Model
How to calculate e At ? ( sI − A) −1 e At
16
State-space Model
x(k + 1) = Φx(k ) + Γu (k )
y (k ) = cx(k )
Given x(k) and u(k), how to predict the future values of x(k)?
zero-input response
zero-state response
Given x(k) and input signal, can you predict the whole future of the system?
17
Yes. Therefore, it is verified that this is indeed the state space model.
•Input-Output Models
For continuous-time, we have differential equations. For discrete-time, we have
y (k + 1) = a1 y (k ) + a2 y (k − 1) + b0u (k ) + b1u (k − 1)
For continuous-time, we have differentiation operator. For discrete-time, we have
•Shift-Operator ---to simplify the representation
forward-shift operator q q f (k ) = f (k + 1)
−1
backward-shift operator or the delay operator q q −1 f (k ) = f (k − 1)
•Operator calculus gives compact descriptions of systems
y (k + 1) = a1 y (k ) + a 2 y (k − 1) + b0 u (k ) + b1u (k − 1)
y (k + 1) − a1 y (k ) − a 2 y (k − 1) = b0 u (k ) + b1u (k − 1)
•Use of the shift operator gives
qy (k ) − a1 y (k ) − a 2 q −1 y (k ) = b0 u (k ) + b1 q −1u (k )
(q − a1 − a2 q −1 ) y (k ) = (b0 + b1q −1 )u (k )
18
(q − a1 − a2 q −1 ) y (k ) = (b0 + b1q −1 )u (k )
−1
How to get rid of q ? q (q − a1 − a2 q −1 ) y (k ) = q (b0 + b1q −1 )u (k )
(q 2 − a1q − a2 ) y (k ) = (b0 q + b1 )u (k )
y (k + 1) = a1 y (k ) + a2 y (k − 1) + b0u (k ) + b1u (k − 1)
19
How to solve difference equation?
y (k + 1) = a1 y (k ) + a2 y (k − 1) + b0u (k ) + b1u (k − 1)
Given input u(k), how to find out output y(k) from this equation?
Superposition Principle
Yes. 20
Fundamental property of linear system----Superposition Principle
Why is superposition principle so important?
Suppose you try to figure out the response of the system to a complicated input u.
u (t ) ???
Let input u be resolved into a set of basis functions
φ1 (t ) y1 (t )
φ2 (t ) y2 (t )
if the system is linear
21
The trick of superposition principle is
to choose proper basis functions whose response can be easily obtained.
What did we choose for the continuous time system?
We can still try the exponential function just replacing t with t=kh!
a k H (a)a k
Does it really work?
We need to verify whether they satisfy the equation or not.
y (k + 1) = a1 y (k ) + a2 y (k − 1) + b0u (k ) + b1u (k − 1)
u (k ) = a k , y (k ) = H (a)a k
y (k + 1) − a1 y (k ) − a2 y (k − 1) = b0u (k ) + b1u (k − 1)
b0 + b1a −1
H (a)a k +1 k
− a1 H (a )a − a2 H (a )a k −1 k
= b0 a + b1a k −1
H (a) =
a − a1 − a2 a −1 22
So it works again!
k
Can we decompose any discrete-time signal f(k) by the exponentials a ?
1
∫
k −1
f (k ) = F ( z ) z dz zk → ak
2πi
What is F(z)?
23
Break
24
•The z-Transform
∞
F ( z ) = ∑ f (k ) z − k = f (0) = 1
k =0
25
•The z-Transform
What is the little trick to calculate this type of summation (Geometric series)?
1 z
F ( z) = =
a z−a
1−
z 26
What is the most important property of Laplace transform?
The relationship between y(t) and y’(t) in s-domain!
L( y (t )) = Y ( s ) d
⇔s
L( y ' (t )) = sY ( s ) − y (0) dt
y (k + 1) = a1 y (k ) + a2 y (k − 1) + b0u (k ) + b1u (k − 1)
y (k + 2) − a1 y (k + 1) − a2 y (k ) = b0u (k + 1) + b1u (k )
z 2Y ( z ) − a1 zY ( z ) − a2Y ( z ) = b0 zU ( z ) + b1U ( z )
28
How to get y(k) in time-domain? How to do inverse z-Transform?
1
∫
k −1
y (k ) = Y ( z ) z dz
2πi This is the hard way!
What is y(0)? Let’s try to find it out from the definition of z-transform
30
y(0)=0.
Let’s apply z-transform to the state-space equation
x(k + 1) = Φx(k ) + Γu (k )
y (k ) = cx(k )
z ( X ( z ) − x(0)) = ΦX ( z ) + ΓU ( z )
zX ( z ) − ΦX ( z ) = zx(0) + ΓU ( z )
X ( z ) = ( zI − Φ ) −1 zx(0) + ( zI − Φ ) −1 ΓU ( z )
What is the output?
Y ( z ) = cX ( z ) = c( zI − Φ ) −1 zx(0) + c( zI − Φ ) −1 ΓU ( z )
Y ( z ) = c( zI − Φ ) −1 ΓU ( z ) = H ( z )U ( z )
•What is the transfer function? H ( z ) = c( zI − Φ ) −1 Γ
U (z ) H(z) Y(z) 31
Transfer function: H(z) -----Transfer the input into output
U (z ) H(z) Y(z)
Since Y(z)=H(z)U(z), does the same input always produce the same output?
If intial conditions are not zero, there are extra terms in the solution!.
Y ( z ) = cX ( z ) = c( zI − Φ ) −1 zx(0) + c( zI − Φ ) −1 ΓU ( z )
32
Transfer function:
A representation of the system which is equivalent to difference equation.
q⇔z y (k + 2) − y (k ) = u (k + 1) + 2u (k )
y (k + 1) = y (k ) + y (k − 1) + u (k − 2) y (k + 1) − y (k ) − y (k − 1) = u (k − 2)
u (k ) = δ (k )
U ( z ) = 1, Y ( z ) = H ( z )
1 H (1)
C H (1)C
What is steady-state gain in continuous time?
s=0
1 H (0)
35
U (z ) H(z) Y(z)
−1 Q( z )
H ( z ) = c( zI − Φ ) Γ =
P( z )
•What are the poles? P( z ) = 0
What is P(z)?
* *
* *
( zI − Φ ) −1 = P ( z ) = det{( zI − Φ )}
det{( zI − Φ )}
λ = σ + jω eσt --stability
λ = ρe jθ ρk ---stability
λ = σ + jω teσt ---stability
λ = ρe jθ kρ k ---stability
te λt = teσt e jωt e jωt ---oscillation kλk = kρ k e jθk ---oscillation
e jθk
σ < 0 teσt → 0 Stable ρ < 1 kρ k → 0 Stable
Continuous-time Discrete-time
λ = σ + jω λ = ρe jθ
σ >0 Unstable
ρ >1 Unstable
σ =0 ρ =1
Multiple Multiple
Single Single
The zeros decide the weights of the components in the impulse response.
a k H (a)a k
What is the output if a is the zero of the system, ie. H(a)=0?
Zero! Signal blocking property
Example: H(1)=0
1 ???
0
It means that the effect of the input can be completely rejected!
When do we want this to happen?
40
We will use this property for disturbance rejection later!
Zeros are related to an important concept in control system design:
•Inverse of a system
Q( z )
If the transfer function of a system is H ( z) =
P( z )
The inverse of a system is defined as 1 P( z )
=
H ( z ) Q( z )
The inverse of a system can be imagined as the original system with inverse direction
of the signal flow: the input becomes output while the output becomes input!
Y ( z ) = H ( z )U ( z ) 1
U ( z) = Y ( z)
H ( z)
U (z ) H(z) Y(z) U (z )
1
H ( z) Y(z)
41
•Inverse of a system
Q( z )
If the transfer function of a system is H ( z) =
P( z )
The inverse of a system is defined as 1 P( z )
=
H ( z ) Q( z )
•System with stable inverse (1/H(z) is stable): All the zeros are stable.
•If a system has unstable zeros, does it imply that the system is unstable ?
This concept is important for controller design, we will discuss it next week.
42
What happens to the poles of the system after sampling?
Av = λv, Ak v = λk v
If Av = λv Then Φv = e hλ v
43
λ ⇒ e hλ
λ ⇒ e hλ
λ = σ + jω ⇒ e hλ = e h (σ + jω ) = e hσ e jhω
•This is the mapping from the continuous-time poles to the discrete-time poles.
Yes.
Yes.
44
The map of the poles: λ ⇒ e hλ
•How about zeros? Can we use the same map to get zeros?
•Example Second-order system
46
b1 z + b2
H ( z) = 2
z + a1 z + a2
return
47
b1 z + b2
H ( z) = 2
z + a1 z + a2
return
48
return
return
49