You are on page 1of 12

EECS 16B Designing Information Devices and Systems II

Fall 2017 Miki Lustig and Michel Maharbiz Homework 7


This homework is due October 24, 2017, at Noon.

1. Buoyancy
An engineer would like to deploy an autonomous communications balloon (like Project Loon’s balloons:
https://plus.google.com/+ProjectLoon/posts/PVitgyeYweY) to provide internet con-
nectivity to a particular geographical region. To provide reliable connectivity, the balloon must hold its
position over the region it services. The balloon can control its altitude (a) by changing its buoyancy, but
it doesn’t have any engines. In order to move horizontally (horizontal position p), the balloon drifts on air
currents.
Consulting meteorologists, the engineer has modeled the air currents around the desired balloon position
(the point (0,0)) and found the flow field shown in Figure 2.

Figure 1: Project Loon Balloon Figure 2: Wind speeds

where the wind speed at each point is described by the equations:

v p = −20p + 20a
va = −20p + 20a

where the velocities are in kilometers per hour and the horizontal position and altitude are in kilometers.
Putting this together with the balloon’s buoyancy control, the balloon’s dynamics are described by:
" # " #" # " #
ṗ −20 20 p 0
= + u
ȧ −20 20 a 5

EECS 16B, Fall 2017, Homework 7 1


(a) Write the dynamics equation in controllable canonical form.

Solution:


λ + 20 −20
=0
20 λ − 20
λ2 = 0
λ1 = λ2 = 0

Since both eigenvalues are 0, the controllable canonical form is:


" # " #" # " #
ż1 0 1 z1 0
= + u
ż2 0 0 z2 1

(b) What is the matrix T for the change of variables~z = T~x that transforms the original A and B matrices
into controllable canonical form?

Solution:
" #
h i 100 0
R̃n = ÃB̃ B̃ =
100 5
" #
h i 1 0
Rn = AB B =
0 1
" #
0.01 0
T = Rn R̃−1
n =
−0.2 0.2

(c) The engineer would like the balloon to converge to (0,0) with eigenvalues -1 and -1. What should be
the state feedback gains K̃ multiplying the original state vector ~x to achieve this behavior? Write the
expression for u in terms of p and a.

Solution: With state feedback in controllable canonical form, we have:


" #
0 1
A + BK =
k1 k2


λ −1
=0
−k1 λ − k2
λ 2 − k2 λ − k1 = 0

We would like our characteristic polynomial to be:

(λ + 1)(λ + 1) = 0
λ 2 + 2λ + 1 = 0

EECS 16B, Fall 2017, Homework 7 2


Matching coefficients, we can solve for k1 and k2 :
k1 = −1 and k2 = −2
K̃ = KT so " #
h i 0.01 0 h i
K̃ = −1 −2 = 0.39 −0.4
−0.2 0.2
u = 0.39p − 0.4a

2. Design for controllability and observability I


We are given a system
" # " #
˙ = −3 3 1
~x(t) ~x(t) + u(t)
γ −4 0
h i h i
y(t) = 1 1 ~x(t) + 0 u(t)
with tuneable parameter γ.
(a) How should we tune γ to make the system controllable but not observable?

Solution: The controllability matrix is


" #
h i 1 −3
C = B AB =
0 γ
and the observability matrix is "# " #
C 1 1
O= = .
CA γ − 3 −1
Thus to make the system controllable but not observable we should choose γ = 2.
(b) How should we tune γ to make the system observable but not controllable?

Solution: To make the system observable but not controllable we should choose γ = 0.

3. Design for controllability and observability II


We are given a new system " #
˙ = 1 0
~x(t) ~x(t).
−1 −2
along with only one sensor and one actuator to control and observe the system.

(a) Which state should we control with the actuator to make the system controllable?
" #
1
Solution: We should control the state x1 . This makes the control matrix B = hence
0
" #
1 −1
C= .
0 1

EECS 16B, Fall 2017, Homework 7 3


(b) Which state should we measure with the sensor to make the system observable?
h i
Solution: We should measure the state x2 . This makes the measurement matrix C = 0 1 hence
"#
0 1
O= .
−1 −2

4. Observability
Consider the following continuous time system.
ẋ(t) = Ax(t) + Bu(t)
(1)
y(t) = Cx(t)
We want to construct an estimate z of the system state x. To do so, we construct a pretend system with the
same [A, B,C, D] models, the same input and the output of the last system along with an L system matrix.
We do this to try and exploit the difference between the output of our pretend state and the actual output,
with L being the "knob" that we can control.

ż(t) = Az(t) + Bu(t) + L(Cz(t) − y(t)) (2)

Define e(t) = z(t) − x(t). This is the error term as a function of time.
(a) Using the two systems defined above, construct a system of the form,
de
(t) = (A + LC)e(t) (3)
dt

Solution: Subtracting (1) from (2), we get the desired answer:

ż(t) − ẋ(t) = Az(t) + Bu(t) + L(Cz(t) − y(t)) − Ax(t) − Bu(t)


ė(t) = A(z(t) − x(t)) + L(Cz(t) −Cx(t))
ė(t) = Ae(t) + LC(z(t) − x(t))
ė(t) = (A + LC)e(t)

(b) We want,
lim e(t) = 0
t→∞
What does that imply about (3)?
Solution: This means that we want (3) to be stable: all of the eigenvalues of (A + LC) should have a
real component less than zero.
(c) Does the initial value of the guess z(0) matter in the long term?
Solution: Not really, since the e(t) tends to 0. This means that, no matter how bad our initial guess,
we will eventually have a good estimate.

5. CCR circuit
Consider the circuit below driven by a current source with current u(t). The output y(t) is the voltage across
the resistor and the state variables are the capacitor voltages as marked in the circuit diagram.

EECS 16B, Fall 2017, Homework 7 4


R1
I2 (t)
+ −
y(t)
I1 (t)

u(t)
+ +

x1 (t) C1 x2 (t) C2
− −

Figure 3: Two Capacitor Circuit with Current Source


(a) Write a state model for this circuit.

Solution: From KCL:


u − I1 − I2 = 0
dx1 dx2
u −C1 −C2 =0
dt dt
From KVL around the capacitors and resistor:
−R1 I2 − x2 + x1 = 0
dx2
−R1C2 − x2 + x1 = 0
dt
and
y − x2 + x1 = 0
y = x1 − x2
So the equations can be written in state space form as:
" # " #" # " #
d x1 (t) − R11C1 R
1
C x1 (t) 1
= 1
1 1
1 + C1 u(t)
dt x2 (t) R1C2 − R1C2 x2 (t) 0
" #
h i x (t) h i
1
y(t) = 1 −1 + 0 u(t)
x2 (t)

(b) Find all equilibrium points when u(t) = 0 for all t.


" #" # " #
− R11C1 R
1
C x 1 (t) 0
Solution: Setting 1
1 1
1 = we see that there is an entire subspace of equi-
R1C2 − R1C2 x 2 (t) 0
libria when x1 = x2 .
(c) Determine if the system is controllable.

Solution: The controllability matrix


" #
h i 1
− R 1C2
C1
C = B AB = 1
1 1
0 R1C1C2

has full rank so the system is controllable.

EECS 16B, Fall 2017, Homework 7 5


(d) Determine if the system is observable.

Solution: The observability matrix


" #  
C 1 −1
O= =  1   
CA − R1C1 + R11C2 1
R1C1 + 1
R1C2

has rank 1 so the system is not observable. ee16b - spring’17


(e) If your answer to part (c) or (d) is no, explain the physical reason for lack of controllability or observ-
ability, whichever is applicable.

To bringNote
Solution: t) to
~x (that theofequilibrium
at any xpart
the equilibria in~ 0 we
=(b) apply
the output is identically zero. So there is no way
to distinguish between for example the system being in configuration x1 = 1, x2 = 1 from x1 = 0, x2 = 0.
u(t) = K~x (t)

and
6. Inverted obtain
pendulum the closed-loop system
Consider the inverted pendulum depicted below, whose equations of motion are
 d 
x
~ ( t ) = ( A + BK )~x ( t ).
ÿ = M
1  udt+ θ̇ 2 ` sin θ − g sin θ cos θ 
2 m
m + sin θ
The only difference from  discrete-time is the stability criterion:  we
must choose θ̈ = K Msuch 2that
1  Re u λi ( A +2 BK )} < 0 for
− {cos θ − θ̇ ` cos θ sin θ +
M +each
m
g sineigenvalue
θ . λi .
`( m + sin θ ) m m
Example 3: Consider the inverted pendulum system depicted below.
m
θ `

u
M

y
The equations of motion are
(a) Write the state model using the variables x1 (t) = θ (t), x2 (t) = ! θ̇ (t), and x3 (t) = ẏ(t). We do not
1 variableubecause
include y(t) as a state 2 we are interested in stabilizing the point θ = 0, θ̇ = 0, ẏ = 0,
ÿ are
and we = not
M concerned
2 about +
the θ̇
final` sin θ
value −
of g
thesin θ cos
position θ
y(t).
m + sin θ m
!
Solution: We have,
1 u M + m
x˙1θ̈ =
= x2 M − cos θ − θ̇ 2 ` cos θ sin θ + ,gf1sin
(x1 ,θx2 , x3 , u)
`( m + sin2 θ ) m m

1
x˙2 = l M +sin − mu cos(x1 ) − x22 l cos(x1 ) sin(x1 ) + M+m
m g sin(x1 ) , f2 (x1 , x2 , x3 , u)
 ( m
2
(x1 ))

and linearization about the upright position  θ = 0, θ̇ = 0 gives
x˙3 = M +sin1 2 (x ) u
m + x 2 l sin(x
2 1 ) − g sin(x 1 ) cos(x1 ) , f3 (x1 , x2 , x3 , u)
m 1
m 1
ÿ = − gθ + u
M M (5)
EECS 16B, Fall 2017, Homework 7 M+m 1 6
θ̈ = gθ − u.
M` M`
We write (5) in state space form as
(b) Linearize this model at the equilibrium x1 = 0, x2 = 0, x3 = 0, and indicate the resulting A and B
matrices.

Solution: We can keep in mind that x1 = x2 = x3 = 0 to make the derivative much easier. Since we
aren’t asked to linearize about a particular input, we can linearize about u∗ = 0. This is fine because f2
and f3 are affine (linear plus a constant term) with respect to u.
∂ f1 ∂ f1 ∂ f1
∂ x1 (0, 0, 0, 0) =0 ∂ x2 (0, 0, 0, 0) =1 ∂ x3 (0, 0, 0, 0) =0
∂ f2 M+m ∂ f2 ∂ f2
∂ x1 (0, 0, 0, 0) = lM g ∂ x2 (0, 0, 0, 0) =0 ∂ x3 (0, 0, 0, 0) =0
∂ f3 m ∂ f3 ∂ f3
∂ x1 (0, 0, 0, 0) = −M g ∂ x2 (0, 0, 0, 0) =0 ∂ x3 (0, 0, 0, 0) =0

And,
∂ f1 ∂ f2 1 ∂ f3 1
∂ u (0, 0, 0, 0) =0 ∂ u (0, 0, 0, 0) = − lM ∂ u (0, 0, 0, 0) = M
Since x∗ = 0 and u∗ = 0, we can use the same state variables x and u. Then,
      
x1 0 1 0 x1 0
d    M+m    1 
x2  =  lM g 0 0 x2  + − lM u
dt m 1
x3 −M g 0 0 x3 M
| {z } | {z }
A B

(c) Show that the linearized model is controllable.

Solution: Observe that,  T


1
AB = − , 0, 0
lM
and,  T
2 M+m m
A B = 0, − g, g
(lM)2 lM 2
Then,  
1
0 − lM 0
− 1 M+m 
C =  lM 0 − (Ml)2 g
1 m
M 0 lM 2
g
Since we are trying to test rank, we can remove scalar terms from the vectors. We then get,
 
0 1 0
 
rank C = rank  −1 0  −1  
 m

l 0 M+m l

We want to show that,


m
6= 1
M+m
This must be the case because this is only true when M = 0, which is not possible since an object at
this macro scale must have mass.

EECS 16B, Fall 2017, Homework 7 7


(d) Suppose M = 1, m = 0.1, l = 1, and g = 10, and design a state feedback controller,

u(t) = k1 θ (t) + k2 θ̇ (t) + k3 ẏ(t),

such that the eigenvalues of A + BK (the “closed-loop eigenvalues") are λ1 = λ2 = λ3 = −1.

Solution: Plugging in values, the system is,


      
x1 0 1 0 x1 0
d       
x2  =  11 0 0 x2  + −1 u
dt
x3 −1 0 0 x3 1

Setting u = K~x, we get,


       
x 0 1 0 0 h i x1
d  1       
x2  = 
 11 0 0  + −1  k 1 k2 k 3  x2 
dt
x3 −1 0 0 1 x3

or,     
x1 0 1 0 x1
d     
x2  = 11 − k1 −k2 −k3  x2 
dt
x3 k1 − 1 k2 k3 x3
The characteristic polynomial is,

p(A+BK) (λ ) = λ 3 + λ 2 (k2 − k3 ) + λ (k1 − 11) + 10k3 = 0

Our target polynomial is,


p(A+BK) (λ ) = λ 3 + 3λ 2 + 3λ + 1
Comparing coefficients, we get,
k1 = 14, k2 = 3.1, k3 = 0.1

(e) Suppose we set k2 = k3 = 0 and vary only k1 ; that is, the controller uses only θ (t) for feedback. Does
there exist a k1 value such that all closed-loop eigenvalues have negative real parts?

Solution: The characteristic polynomial is,

p(A+BK) (λ ) = λ 3 + λ (k1 − 11) = 0

No matter what k1 is, there will always be an eigenvalue at 0.

7. Open-loop control of SIXT33N


Last time, we learned that the ideal input PWM for running a motor at a target velocity v∗ is:

v∗ + β
u(t) =
θ

EECS 16B, Fall 2017, Homework 7 8


In this problem, we will extend our analysis from one motor to a two-motor car system and evaluate how
well our open-loop control scheme does.

vL (t) = dL (t + 1) − dL (t) = θL uL (t) − βL


vR (t) = dR (t + 1) − dR (t) = θR uR (t) − βR

(a) In reality, we need to "kickstart" electric motors with a pulse in order for them to work. That is, we
can’t go straight from 0 to our desired input signal for u(t), since the motor needs to overcome its
initial inertia in order to operate in accordance with our model.
Let us model the pulse as having a width (in timesteps) of t p . In order to model this phenomenon, we
can say that u(t) = 255 for t ∈ [0,t p − 1]1 . In addition, the car initially (at t = 0) hasn’t moved, so we
can also say d(0) = 0.
Firstly, let us examine what happens to dL and dR at t = t p , that is, after the kickstart pulse has passed.
Find dL (t p ) and dR (t p ). (Hint: if it helps, try finding dL (1) and dR (1) first, and then generalizing to the
t p case.)
Note: it is very important that you distinguish θL and θR , as the motors we have are liable to vary in
their parameters, just as how real resistors vary from their ideal resistance.

Solution: Applying the model directly, we get:

d(1) = d(0) + (255θ − β )


d(2) = d(1) + (255θ − β ) = d(0) + (255θ − β ) + (255θ − β ) = d(0) + 2(255θ − β )
d(3) = d(2) + (255θ − β ) = d(0) + 2(255θ − β ) + (255θ − β ) = d(0) + 3(255θ − β )
d(t p ) = d(0) + t p (255θ − β ) (by analogy)
d(t p ) = t p (255θ − β ) (substitute d(0))

Thus we get:

dL (t p ) = t p (255θL − βL )
dR (t p ) = t p (255θR − βR )

(b) Let us define δ (t) = dL (t) − dR (t) as the difference in positions between the two wheels. If both
wheels of the car are going at the same velocity, then this difference δ should remain constant, since
no wheel will advance by more ticks than the other. As a result, this will be useful in our analysis and
in designing our control schemes.
Find δ (t p ). For both an ideal car (θL = θR , βL = βR ) where both motors are perfectly ideal and a
non-ideal car (θL 6= θR , βL 6= βR ), did the car turn compared to before the pulse?
(Since d(0) = dL (0) = dR (0) = 0, δ (0) = 0.)
1 x ∈ [a, b] means that x goes from a to b inclusive.

EECS 16B, Fall 2017, Homework 7 9


Solution:

δ (t p ) = dL (t p ) − dR (t p )
δ (t p ) = t p (255θL − βL ) − t p (255θR − βR )
δ (t p ) = t p ((255θL − βL ) − (255θR − βR ))
δ (t p ) = t p (255(θL − θR ) − (βL − βR ))

For an ideal car, both the θL − θR and βL − βR terms go to zero, so the pulse made the car go perfectly
straight. However, in the non-ideal car, we aren’t so lucky, since the car did turn somewhat during the
initial pulse.
(c) We can still declare victory, though, even if the car turns a little bit during the initial pulse (t p will be
very short in lab), so long as the car continues to go straight afterwards when we apply our control
scheme; that is, as long as δ (t → ∞) converges to a constant value (as opposed to going to ±∞ or
oscillating).
Let’s try applying the open-loop control scheme we learned last week to each of the motors indepen-
dently, and see if our car still goes straight.

v∗ + βL
uL (t) =
θL

v + βR
uR (t) =
θR

Let δ (t p ) = δ0 . Find δ (t) for t ≥ t p in terms of δ0 . (Hint: as in part (a), if it helps you, try finding
δ (t p + 1), δ (t p + 2), etc and generalize to the δ (t) case.)
Does δ (t → ∞) change from δ0 ? Why or why not?

Solution:

δ (t p + 1) = dL (t p + 1) − dR (t p + 1)
= dL (t p ) + θL u(t) − βL − (dR (t p ) + θR u(t) − βR )
= dL (t p ) + θL u(t) − βL − dR (t p ) − θR u(t) + βR
  
= dL (t p ) − dR (t p ) + θL u(t) − βL − θR u(t) − βR

= dL (t p ) − dR (t p ) + v∗ − v∗

= dL (t p ) − dR (t p )
= d(t p )
= δ0
δ (t) = δ0 (by generalization: every step does not change δ )

Since we are able to apply just the right amount of input PWM to keep a constant velocity on both
wheels, neither wheel gets ahead of the other, so δ (t) does not change, meaning that the car does not
turn.
(d) Unfortunately, in real life, it is hard to capture the precise parameters of the car motors like θ and β ,
and even if we did manage to capture them, they could vary as a function of temperature, time, wheel
conditions, battery voltage, etc. In order to model this effect of model mismatch, we consider model

EECS 16B, Fall 2017, Homework 7 10


mismatch terms (such as ∆θL ) which reflects the discrepancy between the model parameters and actual
parameters.

vL (t) = dL (t + 1) − dL (t) = (θL + ∆θL )uL (t) − (βL + ∆βL )


vR (t) = dR (t + 1) − dR (t) = (θR + ∆θR )uR (t) − (βR + ∆βR )

Let us try applying the open-loop control scheme again to this new system. Note that no model
mismatch terms appear below - this is intentional, since we our control scheme is derived from the
model parameters for θ , β , not from the actual θ + ∆θ , etc.2
v∗ + βL
uL (t) =
θL

v + βR
uR (t) =
θR

As before, let δ (t p ) = δ0 . Find δ (t) for t ≥ t p in terms of δ0 .


Does δ (t → ∞) change from δ0 ? Why or why not, and how is it different from the previous case of no
model mismatch?

Solution:

δ (t p + 1) = dL (t p + 1) − dR (t p + 1)
 
= dL (t p ) + (θL + ∆θL )uL (t) − (βL + ∆βL ) − dR (t p ) + (θR + ∆θR )uR (t) − (βR + ∆βR )
  
= dL (t p ) − dR (t p ) + (θL + ∆θL )uL (t) − (βL + ∆βL ) − (θR + ∆θR )uR (t) − (βR + ∆βR )
 
= δ (t p ) + (θL + ∆θL )uL (t) − (βL + ∆βL ) − (θR + ∆θR )uR (t) − (βR + ∆βR )
 
= δ0 + θL uL (t) − βL + ∆θL uL (t) − ∆βL − θR uR (t) − βR + ∆θR uR (t) − ∆βR
 
= δ0 + v∗ + ∆θL uL (t) − ∆βL − v∗ + ∆θR uR (t) − ∆βR
 
= δ0 + v∗ − v∗ + ∆θL uL (t) − ∆βL − ∆θR uR (t) − ∆βR
 
= δ0 + ∆θL uL (t) − ∆βL − ∆θR uR (t) − ∆βR
   
∆θL ∗ ∆θR ∗
= δ0 + (v + βL ) − ∆βL − (v + βR ) − ∆βR
θL θR
   !
∆θL ∗ ∆θR ∗
δ (t) = δ0 + (t − t p ) (v + βL ) − ∆βL − (v + βR ) − ∆βR (generalizing)
θL θR

If there is no model mismatch (i.e. all mismatch terms are zero), then we are back to the same case as
last time (all those terms drop out and δ does not change).
If there is model mismatch, however, we are not so lucky though :-(
   !
∆θL ∗ ∆θR ∗
As t → ∞, the term (v + βL ) − ∆βL − (v + βR ) − ∆βR (which is highly unlikely
θL θR
to be zero) causes δ to either steadily increase or decrease, meaning that the car turns steadily more
and more.
2 Why not just do a better job of capturing the parameters, one may ask? Well, as noted above, the mismatch can vary as a

function of an assortment of factors including temperature, time, wheel conditions, battery voltage, and it is not realistic to try to
capture the parameters under every possible environment, so it is up to the control designer to ensure that the system can tolerate a
reasonable amount of mismatch.

EECS 16B, Fall 2017, Homework 7 11


You may have noticed that open-loop control is insufficient in light of non-idealities and mismatches.
Next time, we will analyze a more powerful form of control (closed-loop control) which should be
more robust against these kinds of problems.

Contributors:

• Justin Yim.

• John Maidens.

• Siddharth Iyer.

• Murat Arcak.

• Edward Wang.

EECS 16B, Fall 2017, Homework 7 12

You might also like