Professor Fearing EE C28 / ME C34 Problem Set Solution Fall 2 Jansen Sheng and Wenjie Chen, UC Berkeley. (5 pts) Final Value Given the following continuous time (CT) system ẋ = Ax+Bu = 5 9 7 x+ u(t), y = [ ] x, e = r y Find lim t e(t) for input r(t) a unit step and control law u(t) = r(t) y(t). Solution: With the control law u = r y = r Cx, the closed loop system becomes ẋ = Ax+Bu = (A BC)x+Br = 5 9 7 x+ r = Āx+ Br, y = [ ] x = Cx 2 TheclosedlooppolesofthesystemaretheeigenvaluesofĀ,whichare.96±.262i, 8.68. Thus, the closed loop system is stable. For r(t) as a unit step, the steady state error is lim e(t) = (+ CĀ B)r(t) =.5 () t 2. (35 pts) Reduced Order Observer Given the following model of the inverted pendulum [ ] [ ] [ Aaa A ẋ = Ax+Bu = x+ u(t) = ab 4 A ba A bb ] [ b x+ B b ] u(t), y = [ ] x The reduced order observer is given by ẑ c = (A bb TA ab )ẑ b +(B b Tb )u+(a ba TA aa )y, ẑ b = ẑ c +Ty Hand calculate state feedback gains F (i.e., u = F[x ẑ b ] T ) and observer gain T such that the controller has closed loop poles at ± j and the observer has its pole at λ obs = 6. Plot the states and estimated state for closed-loop system with initial condition x = [.rad.rad/sec] T in MATLAB. Solution: The reduced order observer ẑ c = (A bb TA ab )ẑ b +(B b Tb )u+(a ba TA aa )y, ẑ b = ẑ c +Ty can be written as ẑ b = (A bb TA ab )ẑ b +(B b Tb )u+(a ba TA aa )y +Tẏ (2) Since y = [ ] x = x, and ẋ 2 = A ba x +A bb x 2 +B b u, thus ẋ 2 = A ba x +A bb x 2 +B b u Tẏ +Tẏ = A ba x +A bb x 2 +B b u T(A aa x +A ab x 2 +b u)+tẏ = (A bb TA ab )x 2 +(B b Tb )u+(a ba TA aa )y +Tẏ (3)
Define the estimation error as e = ẑ b x 2, yielding ė = ẑ b ẋ 2 = (A bb TA ab )e (4) Thus, with control law u = F[x ẑ b ] T = [f f 2 ][x ẑ b ] T, the closed loop system becomes [ ] x ẋ = Ax+Bu = Ax BF ẑ b [ ] x = Ax BF x 2 +e [ ] = (A BF)x BF e = [ ] [ ] x A BF Bf 2 (5) e Combined with reduced order observer, the overall system becomes [ẋ ] [ ][ ] A BF Bf2 x = ė A bb TA ab e (6) This confirms with Separation Principle that, the closed loop system poles would be the eigenvalues of A BF, and the observer pole is given by the eigenvalue of A bb TA ab. For the closed loop poles at ±j, we have λ (A BF) = λ 4+f λ+f 2 = λ2 +f 2 λ 4+f = (λ++j)(λ+ j) = Thus, F = [f f 2 ] = [6 2]. The observer pole is A bb TA ab = T = λ obs = 6. Thus, T = 6 giving the observer as ẑ c = (A bb TA ab )ẑ b +(B b Tb )u+(a ba TA aa )y = 6ẑ b +u+4y (7) The closed loop system with the reduced order observer in MATLAB Simulink is shown in Fig.. The states and estimated state for this closed loop system with initial condition x = [.rad.rad/sec] T is shown in Fig.2. A = [ ; 4 ]; B = [ ] ; C = [ ]; D = ; x = [..] ; P = [ +i i ] ; F = place(a,b,p); P2 = 6; T = (A(2,2) P2)/A(,2); Ao = P2; Bu = B(2) T B(); By = A(2,) T A(,); sim( pspb2 ); figure (); plot (t,x(:,), b.,t,x(:,2), r.,t,zb, r, LineWidth,); grid on; legend( x, x2, Zb ); xlabel ( Time (sec ), FontSize, 2); ylabel ( States, FontSize, 2); title ( States and Estimated State for u= Fx, x = [..]ˆT ); 2
Clock [ ] Constant r t To Workspace 2 F* u F u C=eye(2) x = Ax+Bu y = Cx+Du State Space x x To Workspace y C* u C=[ ] [x Zb] Zb Ao To Workspace Ao=Abb TAab Bu Zc_dot /s Zc Zb Bu=Bb Tb Integrator By By=Aba TAaa Add T T Figure : Closed Loop System with Observer in MATLAB Simulink pspb2.mdl.6.5 States and Estimated State for u= Fx, x = [..] T x x2 Zb.4.3 States.2...2 2 3 4 5 Figure 2: State and Estimated State for Closed Loop System with x = [.rad.rad/sec] T 3. (5 pts) Discrete Time Control 3
Given the following continuous time (CT) system ẋ = Ax+Bu = [ 2 2 ] [ x+ ] u(t), y = [2 ] x the corresponding discrete time (DT) system is x[n+] = Gx[n]+Hu[n], y[n] = Cx[n] which can be found using the Matlab function c2d(sys,t, zoh ). Solution: a) With initial condition x = [ ], plot the ZIR using Matlab function initial() for the CT system and the DT system (with T =.4 sec). Since the continuous time system is stable (poles in the OLHP), our equivalent discrete time system is also stable (the map G = e AT has poles inside the unit circle). Using the zero order hold approximation, we end up with a discrete time system where x(nt) = x[n]. From Matlab, we have: Part a: Response to Initial Conditions for CT and DT systems 2 CT system DT system.5 Amplitude.5.5 2 3 4 5 6 7 8 9 Figure 3: ZIR from CT and DT systems A = [ ; 2 2]; B = [ ] ; C = [2 ]; D = ; x = [ ] ; T =.4; sys=ss(a,b,c,d); dsys = c2d(sys,t, zoh ); figure (); hold on; initial (sys, r, dsys, b.,x); grid on; legend( CT system, DT system ); title ( Part a: Response to Initial Conditions for CT and DT systems ); 4
b) For output feedback control u = k(r y), sketch the root locus for the equivalent transfer function for the continuous time (CT) system. If u = k(r y), then our new system has dynamics: ẋ = Ax+Bu = Ax+Bk(r y) = Ax+Bk(r Cx) = (A BkC)x+Bkr (8) [ ] [ ] ẋ = x+ r(t), y = [2 ] x 2k 2 k 2 k (9) To determine the closed loop transfer function, notice that we almost have control canonical form except for a scaling factor of k in front of r(t). We can accommodate this easily by scaling the standard control canonical form transfer function by k: Y(s) R(s) = k s+2 s 2 +(k+2)s+2k +2 () This also results in a characteristic equation of: s 2 +(k+2)s+2k +2 = () Rearranging terms, we can put this into a form that is more useful for root locus: s 2 +2s+2+(s+2)k = (2) s+2 +k s 2 +2s+2 = (3) Now we can use Eq. 3 to plot the root locus of our system in MATLAB, which gives:.5 Part b: Root locus for CT system Imaginary Axis.5.5.5 7 6 5 4 3 2 Real Axis Figure 4: Root locus for continuous time system with output feedback 5
cttf=tf ([ 2],[ 2 2]); figure (2); rlocus ( cttf ); title ( Part b: Root locus for CT system ); c) Determine the closed loop pole locations for the CT system for k = 5 and plot the closed-loop step response using Matlab. For k = 5, we have closed loop pole locations given by the solutions of Eq. : Which gives poles at -4 and -3. s 2 +(k +2)s+2k +2 = s 2 +7s+2 = (s+4)(s+3) = (4).9 Part c: Step response for CT system.8.7.6 Amplitude.5.4.3.2. 2 3 4 5 6 7 8 9 Figure 5: Step response for closed loop CT system k=5; t=; A2 = A k B C; B2 = B k; sys2 = ss (A2,B2,C,D); figure (3); step(sys2, t ); title ( Part c: Step response for CT system ); d) The closed loop DT system has state equation x[n+] = (G khc)x[n]+khr[n], y[n] = Cx[n] (which can be found using the Matlab feedback function). Using Matlab, determine the closed loop pole locations for the DT system for k = 5 and sampling period T =.4 sec and plot the step response. From MATLAB, the closed loop pole locations are at.3723 and -.54. Wecan seefromthe responsethat thesystemisunstable. Notethat thisisnotthesameastakingthezohapproximation 6
of the CT system in part c), which would result in a stable system (G = G khc which is not equal to e (A kbc)t) ). Instead, we are closing the feedback loop in the discrete time system and from the root locus we can see that for large k we would get poles outside of the unit circle. 5 Part d: Step response for DT system with T=.4 4 3 Amplitude 2 2 3 2 3 4 5 6 7 8 9 Figure 6: Step response for closed loop DT system k = 5; t = ; T =.4; dsys = c2d(sys,t, zoh ); dsys2 = feedback(k dsys,); pole(dsys2) figure (4); step(dsys2, t ); title ( Part d: Step response for DT system ); e) Use Matlab (iteratively if necessary) to find a sampling period T which gives a closed-loop step response that is reasonably close to the CT closed-loop step response. Determine closed-loop pole locations, and plot the DT step response. We want the discrete time system to match so we lowered the time step to T =.. From MATLAB, the closed loop pole locations are at.7658 and.5365. k = 5; t = ; T =.; dsys = c2d(sys,t, zoh ); dsys2 = feedback(k dsys,); pole(dsys2) figure (5); step(dsys2, t ); title ( Part e: Step response for DT system with T=. ); f) Briefly explain why the CT and DT ZIR responses from a) above are reasonably close, but theclosed loop responsesfromc) andd)(with T =.4 sec) donot agree at all. (Hint, consider e AT.) The responses from a) are reasonably close because c2d(sys,t, zoh ) gives a discrete time system that matches the continuous time input system (in this case, the zoh approximation). 7
Part e: Step response for DT system with T=..9.8.7 Amplitude.6.5.4.3.2. 2 3 4 5 6 7 8 9 Figure 7: Step response for closed loop DT system with T =. However, under the output feedback in parts c) and d), the T value affects the G = e AT term in the discrete approximation. The output feedback G = G khc has poles that depend on both T and k. For large enough values of T, the poles of the discrete system grow outside of the unit circle and can potentially result in an unstable system. 8