EE C128 / ME C134 Final Exam Fall 2014
December 19, 2014
Your PRINTED FULL NAME
Your STUDENT ID NUMBER
Number of additional sheets
1. No computers, no tablets, no connected device (phone etc.)
2. Pocket calculator allowed.
3. Closed book, closed notes, closed internet.
4. Allowed: 2 sheets (each double sided) Chi Chi.
5. Additional sheets are available and may be submitted (e.g. for graphs).
6. Write your name below, and your SID on the top right corner of every page (including this one).
7. If you turn in additional sheets:
Write your name and/or SID on every sheet, and
Write the number of additional sheets you are turning in above where indicated.
8. Do not write on the back of any page.
Part 1 2 3 4 5 6 7 8
Score 9 10 8 + 2 13 12 12 6 6
1
EE C128 / ME C134 Fall 2014 Final Exam Name:
1. Laplace transform, controllable canonical form
(a) Derive the following Laplace property for convolution integrals
Lg1(t) = G1(s)
Lg2(t) = G2(s)
L∫ t
0g1(τ)g2(t− τ)dτ
= G1(s)G2(s)
Answer: (4 pts)
There are multiple methods for solving this, the following proof is done by working backwards
from the solution
Lg1(t) =
∫ ∞0
g1(t)e−stdt = G1(s)
Lg2(t) =
∫ ∞0
g2(t)e−stdt = G2(s)
G1G2 =
∫ ∞0
g1(x)e−sxdx
∫ ∞0
g2(y)e−sydy
=
∫ ∞0
g1(x)
∫ ∞0
g2(y)e−sye−sxdydx
=
∫ ∞0
g1(x)
∫ ∞0
g2(y)e−s(y+x)dydx
Let t = x+ y then,
=
∫ ∞0
g1(x)
∫ ∞x
g2(t− x)e−stdtdx
=
∫ ∞0
∫ ∞x
g1(x)g2(t− x)e−stdtdx
Switch order of integration
=
∫ ∞0
∫ t
0g1(x)g2(t− x)e−stdxdt
=
∫ ∞0
∫ t
0g1(τ)g2(t− τ)e−stdτdt
= L∫ t
0g1(τ)g2(t− τ)dτ
UC Berkeley, 12/19/2014 2 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(b) Find the solution to the following ODE with the given initial conditions:
d2x
dt2− dx
dt+ 2x =
∫ t
0δ(τ) sin (t− τ)dτ
x(0) = −2, x(0) = 1
Answer: (5 pts) 12
[sin t+ cos t+ e
t2
(cos
√72 t−
11√7
sin√72 t)]
Taking the Laplace transform of the ODE then solving for X(s),∫ t
0δ(τ) sin (t− τ)dτ = sin(t)
s2X(s)− sx(0)− x′(0)− [sX(s)− x(0)] + 2X(s) =1
s2 + 1
(s2 − s+ 2)X(s) = s− 3 +1
s2 + 1
=s3 − 3s2 + s− 2
(s2 + 1)(s2 − s+ 2)
X(s) =s3 − 3s2 + s− 2
(s2 + 1)(s2 − s+ 2)
Doing partial fraction decomposition we get,
X(s) =As+B
(s2 + 1)+
Cs+D
s2 − s+ 2
=(A+ C)s3 + (−A+B +D)s2 + (−B + 2A+ C)s+ 2B +D
(s2 + 1)(s2 − s+ 2)
Solving for coefficients A,B,C,D
A+ C = 1
(2B +D) = −2
−A+B +D = −3
2A−B + C = 1 = 2
Thus
A = 1/2 B = 1/2 C = 1/2 D = −3
Taking the laplace transform with the coefficients,
X(s) =s+ 1
2(s2 + 1)+
s− 6
2(s2 − s+ 2)
=1
2
[sin t+ cos t+ e
t2
(cos
√7
2t− 11√
7sin
√7
2t
)]
UC Berkeley, 12/19/2014 3 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
2. Bode Plotting and Nyquist Stability
Consider the following transfer function:
G(s) =100(s+ 4)
(s2 + 12s+ 20)(s+ 2)
(a) Sketch a Bode plot of the system (magnitude and phase). Label all slopes and points on the
graph. (3 pts)
UC Berkeley, 12/19/2014 4 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(b) Using the Bode plots you created in Part (a), calculate the phase margin and gain margin for
G(s).
Answer: (2 pts) Gain margin =∞ Phase margin = 52.3 For phase margin find where the
gain is 1 and draw a line to where it crosses the phase diagram For gain margin find where the
phase is 180 and draw a line to where it crosses the gain
(c) Draw a Nyquist plot of the system and use the Nyquist stability criterion to determine if the
closed loop system under unity feedback is stable.
Answer: (3 pts) The systems is stable, there are no encirclements of -1
(d) Assume we have a closed loop system below where G(s) is given in Part (a) and C(s) = K.
For what values of K is the system stable?
Answer: (2 pts) Stable for all K The closed loop transfer function is:
ClosedLoop =100K(s+ 4)
100K(s+ 4) + (s2 + 12s+ 20)(s+ 2)
UC Berkeley, 12/19/2014 5 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
3. Solution in time domain, stability
(a) For the following system, explicitly determine the time-domain solution x(t)
x =
[4 1
0 10
]x+
[1
0
]u, x(0) =
[1
1
]
y =[
1 0]x
where u(t) is a unit step function.
Answer: (5 pts)
x(t) =
[1312e
4t + 16e
10t − 14
e10t
]The solution to a system of this form is
x(t) = eAtx0 +
∫ t
0eA(t−τ)Bu(τ)dτ
We first need to find the eigne vaues of A:
det(λI −A) = (λ− 4)(λ− 10)
λ1 = 4 λ2 = 10
Then we can find the eigen vectors and diagonalize A
v1 =
[1
0
]v2 =
[1
6
]
A = PDP−1
P =
[1 1
0 6
]Taking the inverse of P gives us
P−1 =1
6
[6 −1
0 1
]
The diagonalized D = P−1AP
D =1
6
[6 −1
0 1
][4 1
0 10
][1 1
0 6
]=
[4 0
0 10
]
We can then find eAt:
eAt =1
6
[6e4t −e4t + e10t
0 6e10t
]
UC Berkeley, 12/19/2014 6 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
We can then find the solution by taking the integral
x(t) =1
6
[6e4t −e4t + e10t
0 6e10t
][1
1
]+
∫ t
0
1
6
[6e4(t−τ) −e4(t−τ) + e10(t−τ)
0 6e10(t−τ)
][1
0
]dτ
x(t) =
[1312e
4t + 16e
10t − 14
e10t
](b) Determine the transfer function G(s) for the zero initial state response, given the system in
Part (a).
Answer: (3 pts) 1s−4
G(s) = C(sI −A)−1B
(sI −A)−1 =
[s− 4 −1
0 s− 10
]−1=
1
(s− 4)(s− 10)
[s− 10 1
0 s− 4
]
G(s) =[
1 0] 1
(s− 4)(s− 10)
[s− 10 1
0 s− 4
][1
0
](c) BONUS: Does the degree of your state space model and transfer function match? Why or
why not?
Answer: (2 pts) No, the degree of the state space is 1 while the state space is 2nd degree.
This is because systems that aren’t controllable or observable when converted to TF’s will be
of lesser degree.
UC Berkeley, 12/19/2014 7 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
4. Electrical Circuit and Root Locus
(a) For the above circuit derive the transfer function C(s) =VoutVin
.
Answer: (3 pts) (R2 + 1C2s
)( 1R1
+ C1s) or s2R1R2C1C2+(R1C1+R2C2)s+1sR1C2
Looking at the first opamp we know
VoutVin
=−R2eq
R1eq
R1eq =1
1R1
+ C1s
R2eq = (R2 +1
C2s)
The second opamp is simply an inverter so the entire transfer function is
=R2 + 1
C2s1
1R1
+C1s
UC Berkeley, 12/19/2014 8 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(b) Assume the system below, G(s), is in unity negative feedback. Determine the value of K such
that the steady state error to a step response is 111 . Also determine the percent overshoot and
settling time of the feedback system at this K.
G(s) =K
(s+ 5)(s+ 15)
Answer: (4 pts) K = 750 OS = 31% Ts = .40
The steady state error of a closed loop systems is given by
ess = lims−>01
1 +G(s)
=1
1 + k75
=1
11
Thus
K = 750
Gcl =750
s2 + 20S + 825
wn =√
825 2ξwn = 20 ξ = .348
OS = e−ξπ√1−ξ2 = 31% Ts =
4
wnξ=
4
(28.7)(.348)= 0.40s
UC Berkeley, 12/19/2014 9 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(c) Now assume that the system is described by the figure below, where C(s) and G(s) are ob-
tained from parts (a) and (b) respectively. Draw the root locus given R1 = 125 MΩ, C1 = 15 µF,
R2 = 625 MΩ and C2 = 0.1 µF. Watch your signs!
Answer: (3 pts)
In order to draw the root locus we first need to find all the poles and zeros
G(s) has two poles at p = −5,−15 and C(s) has one pole at p = 0
G(s) has no zeros and C(s) has two zeroes at z = − 1R1C1
,− 1R2C2
= − 162.5 ,−
11875
UC Berkeley, 12/19/2014 10 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(d) Label on the root locus a suitable region if the goal is to achieve a settling time (Ts) ≤ 0.4 sec
and percent overshoot (%OS) ≤ 20%.
Answer: (3 pts) The necessary damping to achieve the desired overshoot is:
ξ =−ln(OS)√
(π2 + ln2(OS))= .456
θ = sin−1 ξ = 27
To achieve the desired settling time:
.4 =4
ξwn
ξwn = 10
Re(pole) > 10
UC Berkeley, 12/19/2014 11 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
5. Controller design using State-feedback
Consider the mechanical system shown above. Here, V denotes the voltage applied to the motor
(control input) and x(t) is the position of the mass. You may assume the back emf from the motor
is negligible (EMF = 0) and the torque supplied by the motor is equal to T = IKm − Jmθwhere,
Km : Constant relating T and I
Jm : Inertia of the motor
(a) Show that G(s) is the transfer function from V to x. To do this, you MUST derive the governing
equations for the mechanical/electrical system.
G(s) =X(s)
V (s)=N2
N1
Kmr
R+ Ls
[(J1 + J2 + Jm
(N2
N1
)2)s2 + r2(Ms2 + fvs+ k)
]−1
Answer: (5 pts)
V = I(R+ Ls)
T =V
R+ LsKm − Jms2θm
For ease of solving set the angle of the gear to θ2
x = rθ2
θm =N2
N1θ2 =
N2x
N1r
Doing a balance of forces on the rotating masses:
(J1 + J2)θ2s2 + Fr =
N2
N1T
F = (Ms2 + fvs+ k)θ2r
UC Berkeley, 12/19/2014 12 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
Substituting
N2
N1
[(KmV
R+ Ls)− Jms2
N2
N1θ2
]= (J1 + J2)θ2s
2 + (Ms2 + fvs+ k)r2θ2
AlgebraN2
N1
KmV
R+ Ls= (J1 + J2 + Jm
(N2
N1
)2
)θ2s2 + (Ms2 + fvs+ k)r2θ2
Since we have θ2 = xr we get the solution:
X(s)
V (s)=N2
N1
Kmr
R+ Ls
[(J1 + J2 + Jm
(N2
N1
)2)s2 + r2(Ms2 + fvs+ k)
]−1
(b) Choosing x =[x x
]Tas the state vector and x as the output, derive a state space model
(matrices A, B, C and D) for the above system. Use the following parameters:
R = 1, Km = 0.1, L = 0, N2/N1 = 10, r = 1, J1 = J2 = 1, Jm = 0, M = 1, k = 1, fv = 1.
Note your input to the system should be V .Answer: (2 pts)
x =
[0 1
−13 −1
3
]x+
[013
]V, y =
[1 0
]x
Plugging the values above into the given transfer function we get
X
V=
1
3s2 + s+ 1
Using this we can formulate the state space model by inspection
x =[
1 0]x
x =[−1
3 −13
]x+
1
3V
Putting the two together
x =
[0 1
−13 −1
3
]x+
[013
]V, y =
[1 0
]x
UC Berkeley, 12/19/2014 13 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(c) Explicitly write the observability and controllability matrices. Is the system controllable? Is it
observable? (Use parameters from Part (b))
Answer: (2 pts) Controllability:
[0 1
313 −1
9
]Observability:
[1 0
0 1
]And it is both control-
lable and observable, full rank
The controllability matrix is given by
[B AB
]=
[0 1
313 −1
9
]
This is full rank so it is controllable The observability matrix is given[C
CA
]=
[1 0
0 1
]
This is full rank so it is observable
(d) Determine the eigenvalues of matrix A you found in Part (b).
Answer: (1 pts)λ = −16 ±
√116 i
det(Is−A) = det
([s −113 s+ 1
3
])= s2 − 1
3s+
1
3
The roots of the polynomial are the eigen values
s = −1
6±√
11
6i
(e) We will now control the system using a state feedback controller as shown in the diagram below
where K =[k1, k2
]and r =
[r1
r2
].
Write the dynamics of the closed-loop system as x = Ax+ Br. That is, find both A and B in
terms of the system parameters given in Part (b) and the elements of the controller gain matrix
K.
Answer: (2 pts) A =
[0 1
−13(1 + k1) −1
3(1 + k2)
]B =
[0 0
−13k1 −1
3k2
]x = Ax+Bu
= Ax+BK(r − x)
UC Berkeley, 12/19/2014 14 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
= (A−BK)x+BKr = Ax+ B
UC Berkeley, 12/19/2014 15 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
6. State-feedback and observer design
Consider the following system:
x = Ax+Bu, y = Cx with A =
[7 1
−2 4
], B =
[0
1
], C =
[0 1
](a) Compute the eigenvalues and eigenvectors for A.
Answer: (3 pts)λ1 = 5 λ2 = 6 v1 =
[1
−2
]v2 =
[1
−1
]To determine the eigenvalues we do the following
det(Is−A) = det
([s− 7 −1
2 s− 4
])= s2 − 11s+ 30
s2 − 11s+ 30 = (s− 5)(s− 6)
To find the eigenvectors we do the following
det(λ1I −A)v1 = 0[−2 −1
2 1
][v11
v12
]=
[0
0
]v11 = 1 v12 = −2
det(λ2I −A)v2 = 0[−1 −1
2 2
][v21
v22
]=
[0
0
]v21 = 1 v22 = −1
(b) Use state-feedback of the form of u = −Kx. Determine the gain K = [k1 k2] such that the
poles of the closed loop system are located at s1,2 = −2± 5j.
Answer: (2 pts)K =[
104 15]
Give the state-feedback we find the equivalent system is
equal to
A = A−BK =
[7 1
−(2 + k1) 4− k2
]The eigenvalues of A are the desired closed loop poles, thus k1 and k2 can be determined
det(Is− A) = det
([s− 7 −1
2 + k1 s+ k2 − 4
])= s2 + (k2 − 11)s+ (30 + k1 − 7k2)
(s+ 2 + 5i)(s+ 2− 5i) = s2 + 4s+ 29
k2 − 11 = 4 k2 = 15
30 + k1 − 7k2 = 29 k1 = 29− 30 + 7 ∗ 15 = 104
UC Berkeley, 12/19/2014 16 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(c) Unfortunately for this system we are unable to measure all the states. In order to do state
feedback we must use a Luenberger observer of the form:
˙x = Ax+Bu+ L(y − y)
y = Cx
and the system is controlled using state feedback, given by
u = −Kx
Determine the error dynamics of the system, e, where e = x− x. The result must be in terms
of e only.
Answer: (2 pts)e = (A− LC)e
e = ˙x− x
= A(x− x) + L(y − y)
y − y = C(x− x)
e = A(x− x)− LC(x− x)
= (A− LC)e
(d) Determine the observer matrix L = [l1 l2]T such that the error dynamics have poles at
s1,2 = −2± 5j.
Answer: (2 pts) L =[−52 15
]The desired closed loop characteristic equation is
s2 + 4s+ 29
Using the results from the previous problem
A = A− LC
det(A− LC) = s2 + (l2 − 11)s+ (30− 2l1 − 7l2)
l2 − 11 = 4 l2 = 15
30− 2l1 − 7l2 = 29 l1 = −52
(e) Comment on the performance of the state observer given the previously placed poles. What
are we interested in when designing an observer and how could we improve the observer?
Answer: (1 pts)The observer is slow and converges at the same rate as the system. We
want the observer to converge faster than the system so we have an accurate reperesnetation
of the current states. We can improve the observer by making the real part of the poles more
negative
UC Berkeley, 12/19/2014 17 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(f) Complete the following block diagram of the system described in part(c). (2 pts)
UC Berkeley, 12/19/2014 18 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
7. Linear Quadratic Regulator
Consider the LTI system
x = Ax+Bu x = [x1, x2]T
where
A =
[1 1
0 −1
], B =
[1
0
]
We would like to solve an LQR problem for the system. That is, we want to find the optimal
control u∗(t) that minimizes the cost functional
J =
∫ ∞t=0
(x21(t) + u2(t)) dt
(a) Solve the Algebraic Riccati Equation for the infinite horizon LQR. Hint: the solution of the
Algebraic Riccati equation is a positive semi-definite matrix. A (2 × 2) matrix P is positive
semi-definite everywhere when:
p11 ≥ 0 p22 ≥ 0 p212 ≤ p11p22 for P =
[p11 p12
p12 p22
]
Answer: (4 pts) P =
[1 +√
2 1
1 12
]The algebraic riccati equation is
P +ATP + PA− PBR−1BTP +Q = 0
For the infinit case P = 0
Looking at the cost function we can see that
Q =
[1 0
0 0
]R = 1
Solving for P we get a system of 4 equations
P =
[p1 p2
p3 p4
]
2p1 − p21 + 1 = 0
p1 − p1p2 = 0
p1 − p3p1 = 0
p2 − 2p4 + p3 − p3p2 = 0
UC Berkeley, 12/19/2014 19 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
Solving we get P =
[1 +√
2 1
1 12
](b) Determine the optimal feedback matrix K1 such that the optimal control is u∗(t) = −K1x(t).
Answer: (2 pts)K =[
1 +√
2 1]
K = R−1BTP = 1[
1 0] [ 1 +
√2 1
1 12
]=[
1 +√
2 1]
UC Berkeley, 12/19/2014 20 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
8. Linear Quadratic Regulator
Consider the system where the dynamics are scalar:
x = ax+ bu x is a scalar
We want to create a finite horizon optimal controller given the cost function:
J =
∫ tf
t=0(qx2(t) + ru2(t))dt
(a) Write the Ricatti Equation for this system as well as the terminal condition.
Answer: (2 pts) p+ 2ap− p2b2
r + q = 0
(b) Find P for the static case where tf =∞. Your answer should be in terms of q, r, a, and b. Note
the P should be positive semi-definite everywhere.
Answer: (2 pts)p = arb2
+√
a2r2
b4+ ra
b2
During the infinite case p = 0 thus
p+ 2ap− p2b2
r+ q = 0
Becomes
2ap− p2b2
r+ q = 0
This is a quadratic equation with the roots
ar
b2±√a2r2
b4+rq
b2
Since P is positive semi-definite we know the answer is
ar
b2+
√a2r2
b4+rq
b2
UC Berkeley, 12/19/2014 21 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
(c) For this scalar system, given any tf , the Riccati equation can be analytically solved:
P (τ) =(aP (tf ) + q) sinh(βτ) + βP (tf ) cosh(βτ)(
b2P (tf )r − a
)sinh(βτ) + β cosh(βτ)
where τ = tf − t, β =
√a2 +
b2q
rand sinh(.) and cosh(.) are the hyperbolic trigonometric
functions. Taking the limit as tf →∞, the solution becomes:
P (τ) =q
−a+ β
Show that this is equivalent to your solution from Part (b).
Answer: (2 pts)
P (τ) =q
−a+ β=
q
−a+
√a2 +
b2q
r
P (τ) =q
−a+ β=
q
−a+
√a2 +
b2q
r
√a2 +
b2q
r+ a√
a2 +b2q
r+ a
=q
√a2 +
b2q
r+ aq
−a2 +b2q
r+ a2
=ar
b2+r
b2
√a2 +
b2q
r
This result is the same as the solution found in part b
UC Berkeley, 12/19/2014 22 of 23
EE C128 / ME C134 Fall 2014 Final Exam Name:
f(t) F (s)
δ(t) 1
u(t) 1s
tu(t) 1s2
tnu(t) n!sn+1
sin(ωt)u(t) ωs2+ω2
cos(ωt)u(t) ss2+ω2
e−αt sin(ωt)u(t) ω(s+α)2+ω2
e−αt cos(ωt)u(t) s+α(s+α)2+ω2
Table 1: Laplace transforms of common functions
sinh(θ)eθ − e−θ
2
cosh(θ)eθ + e−θ
2
tanh(θ)sinh(θ)
cosh θ=
1− e−2θ
1 + e−2θ
Table 2: Trigonometric functions
UC Berkeley, 12/19/2014 23 of 23