Topic # Feedback Control Systems

Similar documents
Topic # /31 Feedback Control Systems

Topic # Feedback Control. State-Space Systems Closed-loop control using estimators and regulators. Dynamics output feedback

Topic # /31 Feedback Control Systems. State-Space Systems Closed-loop control using estimators and regulators. Dynamics output feedback

Topic # Feedback Control Systems

Topic # Feedback Control Systems

Topic # Feedback Control Systems

Topic # Feedback Control

Topic # Feedback Control

Topic # /31 Feedback Control Systems

Control Systems Design

to have roots with negative real parts, the necessary and sufficient conditions are that:

D(s) G(s) A control system design definition

Topic # /31 Feedback Control Systems

Pole placement control: state space and polynomial approaches Lecture 2

Topic # Feedback Control Systems

Topic # Feedback Control Systems

Professor Fearing EE C128 / ME C134 Problem Set 7 Solution Fall 2010 Jansen Sheng and Wenjie Chen, UC Berkeley

Systems Analysis and Control

CONTROL DESIGN FOR SET POINT TRACKING

ECEEN 5448 Fall 2011 Homework #4 Solutions

5. Observer-based Controller Design

Introduction to Feedback Control

ELECTRONICS & COMMUNICATIONS DEP. 3rd YEAR, 2010/2011 CONTROL ENGINEERING SHEET 5 Lead-Lag Compensation Techniques

State Regulator. Advanced Control. design of controllers using pole placement and LQ design rules

Course Outline. Higher Order Poles: Example. Higher Order Poles. Amme 3500 : System Dynamics & Control. State Space Design. 1 G(s) = s(s + 2)(s +10)

Design Methods for Control Systems

Synthesis via State Space Methods

MODERN CONTROL DESIGN

Principles of Optimal Control Spring 2008

1 (30 pts) Dominant Pole

EECS C128/ ME C134 Final Thu. May 14, pm. Closed book. One page, 2 sides of formula sheets. No calculators.

Control System Design

Linear State Feedback Controller Design

Fall 線性系統 Linear Systems. Chapter 08 State Feedback & State Estimators (SISO) Feng-Li Lian. NTU-EE Sep07 Jan08

Outline. Classical Control. Lecture 1

Return Difference Function and Closed-Loop Roots Single-Input/Single-Output Control Systems

MAE 143B - Homework 7

Module 08 Observability and State Estimator Design of Dynamical LTI Systems

ECSE 4962 Control Systems Design. A Brief Tutorial on Control Design

Engraving Machine Example

Exam. 135 minutes, 15 minutes reading time

State Feedback and State Estimators Linear System Theory and Design, Chapter 8.

EECS C128/ ME C134 Final Wed. Dec. 15, am. Closed book. Two pages of formula sheets. No calculators.

ECE 388 Automatic Control

Review: transient and steady-state response; DC gain and the FVT Today s topic: system-modeling diagrams; prototype 2nd-order system

Overview of Bode Plots Transfer function review Piece-wise linear approximations First-order terms Second-order terms (complex poles & zeros)

S I X SOLUTIONS TO CASE STUDIES CHALLENGES. Antenna Control: Stability Design via Gain K s s s+76.39K. T(s) =

EECS C128/ ME C134 Final Wed. Dec. 14, am. Closed book. One page, 2 sides of formula sheets. No calculators.

Homework Assignment 3

CDS 101/110a: Lecture 8-1 Frequency Domain Design

ECE317 : Feedback and Control

FREQUENCY-RESPONSE DESIGN

Subject: Optimal Control Assignment-1 (Related to Lecture notes 1-10)

Controls Problems for Qualifying Exam - Spring 2014

INTRODUCTION TO DIGITAL CONTROL

Control Systems. Design of State Feedback Control.

Intro. Computer Control Systems: F9

APPLICATIONS FOR ROBOTICS

Outline. Classical Control. Lecture 5

Time Response Analysis (Part II)

ECEN 605 LINEAR SYSTEMS. Lecture 20 Characteristics of Feedback Control Systems II Feedback and Stability 1/27

] [ 200. ] 3 [ 10 4 s. [ ] s + 10 [ P = s [ 10 8 ] 3. s s (s 1)(s 2) series compensator ] 2. s command pre-filter [ 0.

6.1 Sketch the z-domain root locus and find the critical gain for the following systems K., the closed-loop characteristic equation is K + z 0.

Today (10/23/01) Today. Reading Assignment: 6.3. Gain/phase margin lead/lag compensator Ref. 6.4, 6.7, 6.10

Dynamic Compensation using root locus method

ME 132, Fall 2015, Quiz # 2

ECE317 : Feedback and Control

TRACKING AND DISTURBANCE REJECTION

EL 625 Lecture 10. Pole Placement and Observer Design. ẋ = Ax (1)

Topic # Feedback Control

Richiami di Controlli Automatici

Lecture 7 (Weeks 13-14)

ECE382/ME482 Spring 2005 Homework 7 Solution April 17, K(s + 0.2) s 2 (s + 2)(s + 5) G(s) =

EE C128 / ME C134 Final Exam Fall 2014

Analysis of SISO Control Loops

Bangladesh University of Engineering and Technology. EEE 402: Control System I Laboratory

Lecture 12. Upcoming labs: Final Exam on 12/21/2015 (Monday)10:30-12:30

Dr Ian R. Manchester

EEE 184: Introduction to feedback systems

SAMPLE SOLUTION TO EXAM in MAS501 Control Systems 2 Autumn 2015

Classify a transfer function to see which order or ramp it can follow and with which expected error.

Internal Model Principle

Control Systems I. Lecture 7: Feedback and the Root Locus method. Readings: Jacopo Tani. Institute for Dynamic Systems and Control D-MAVT ETH Zürich

(Continued on next page)

6 OUTPUT FEEDBACK DESIGN

Raktim Bhattacharya. . AERO 422: Active Controls for Aerospace Vehicles. Frequency Response-Design Method

School of Mechanical Engineering Purdue University. ME375 Feedback Control - 1

Automatic Control 2. Loop shaping. Prof. Alberto Bemporad. University of Trento. Academic year

Prashant Mhaskar, Nael H. El-Farra & Panagiotis D. Christofides. Department of Chemical Engineering University of California, Los Angeles

Stochastic Optimal Control!

Module 03 Linear Systems Theory: Necessary Background

Topic # /31 Feedback Control Systems

Control Systems Design

Due Wednesday, February 6th EE/MFS 599 HW #5

Mechanical Systems Part A: State-Space Systems Lecture AL12

sc Control Systems Design Q.1, Sem.1, Ac. Yr. 2010/11

(b) A unity feedback system is characterized by the transfer function. Design a suitable compensator to meet the following specifications:

H 2 Optimal State Feedback Control Synthesis. Raktim Bhattacharya Aerospace Engineering, Texas A&M University

Control Systems I. Lecture 6: Poles and Zeros. Readings: Emilio Frazzoli. Institute for Dynamic Systems and Control D-MAVT ETH Zürich

Control Systems Design, SC4026. SC4026 Fall 2010, dr. A. Abate, DCSC, TU Delft

Transcription:

Topic #16 16.31 Feedback Control Systems State-Space Systems Closed-loop control using estimators and regulators. Dynamics output feedback Back to reality

Fall 2007 16.31 16 1 Combined Estimators and Regulators Now evaluate stability and/or performance of a controller when K designed assuming u(t) = Kx(t) but implemented as u(t) = K ˆx(t) Assume we have designed a closed-loop estimator with gain L ˆx(t) = (A LC)ˆx(t) + Bu(t) + Ly(t) ŷ(t) = C ˆx(t) The closed-loop system dynamics are given by: ẋ(t) = Ax(t) + Bu(t) ˆx(t) = (A LC)ˆx(t) + Bu(t) + Ly(t) y(t) = Cx(t) ŷ(t) = C ˆx(t) u(t) = K ˆx(t) Which can be compactly written as: [ ] [ ] [ ] ẋ(t) A BK x(t) = ˆx(t) LC A BK LC ˆx(t) ẋ cl (t) = A cl x cl (t) This does not look too good at this point not even obvious that the closed-system is stable. λ i (A cl ) =??

Fall 2007 16.31 16 2 Can fix this problem by introducing a new variable x = x ˆx and then converting the closed-loop system dynamics using the similarity transformation T x cl (t) [ x(t) x(t) Note that T = T 1 ] = [ I 0 I I ] [ x(t) ˆx(t) ] = T x cl (t) Now rewrite the system dynamics in terms of the state x cl (t) A cl T A cl T 1 Ācl Since similarity transformations preserve the eigenvalues we are guaranteed that λ i (A cl ) λ i (Ācl) Work through the math: [ ] [ ] [ I 0 A BK I 0 Ā cl = I I LC A BK LC I I [ ] [ ] A BK I 0 = A LC A + LC I I [ ] A BK BK = 0 A LC ] Because Ācl is block upper triangular, we know that the closedloop poles of the system are given by det(si Ā cl ) det(si (A BK)) det(si (A LC)) = 0

Fall 2007 16.31 16 3 Observation: Closed-loop poles for this system consist of the union of the regulator poles and estimator poles. So we can just design the estimator/regulator separately and combine them at the end. Called the Separation Principle. Keep in mind that the pole locations you are picking for these two sub-problems will also be the closed-loop pole locations. Note: Separation principle means that there will be no ambiguity or uncertainty about the stability and/or performance of the closedloop system. The closed-loop poles will be exactly where you put them!! And we have not even said what compensator does this amazing accomplishment!!!

Fall 2007 16.31 16 4 The Compensator Dynamic Output Feedback Compensator is the combination of the regulator and estimator using u(t) = K ˆx(t) ˆx(t) = (A LC)ˆx(t) + Bu(t) + Ly(t) ˆx(t) = (A BK LC)ˆx(t) + Ly(t) u(t) = K ˆx(t) Rewrite with new state x c (t) ˆx(t) ẋ c (t) = A c x c (t) + B c y(t) u(t) = C c x c (t) where the compensator dynamics are given by: A c A BK LC, B c L, C c K Note that the compensator maps sensor measurements to actuator commands, as expected. Closed-loop system stable if regulator/estimator poles placed in the LHP, but compensator dynamics do not need to be stable. λ i (A BK LC) =??

Fall 2007 16.31 16 5 For consistency with the implementation of classical controllers, define the compensator transfer function as G c (s) = C c (si A c ) 1 B c so that u(t) = G c (s)y(t) Note that it is often very easy to provide classical interpretations (such as lead/lag) for the compensator G c (s). Can then implement this compensator with a reference command r(t) using feedback on e(t) = r(t) y(t) rather than just y(t) r(t) e(t) u(t) y(t) G c (s) G(s) u(t) = G c (s)e(t) = G c (s)(r(t) y(t)) Still have u(t) = G c (s)y(t) if r(t) = 0. So now write state space model of the compensator as ẋ c (t) = A c x c (t) + B c e(t) u(t) = C c x c (t) Intuitively appealing setup because it is the same approach used for the classical control, but it turns out not to be the best approach More on this later.

Fall 2007 16.31 16 6 Mechanics Basics: e(t) = r(t) y(t), u(t) = G c e(t), y(t) = Gu(t) G c (s) : ẋ c (t) = A c x c (t) + B c e(t), u(t) = C c x c (t) G(s) : ẋ(t) = Ax(t) + Bu(t), y(t) = Cx(t) Loop dynamics L(s) = G(s)G c (s) y(t) = L(s)e(t) ẋ(t) = Ax(t) +BC c x c (t) ẋ c (t) = +A c x c (t) +B c e(t) L(s) : [ ẋ(t) ẋ c (t) ] = [ A BCc 0 A c ] [ x(t) x c (t) ] y(t) = [ C 0 ] [ x(t) x c (t) ] [ 0 + B c ] e(t) To close the loop, note that e(t) = r(t) y(t), then [ ] [ ] [ ] [ ] ( ẋ(t) A BCc x(t) 0 = + r(t) [ C 0 ] [ x(t) ẋ c (t) 0 A c x c (t) B c x c (t) [ ] [ ] [ ] A BC c x(t) 0 = + r(t) B c C A c x c (t) B c y(t) = [ C 0 ] [ ] x(t) x c (t) A cl is not exactly the same as on page 16-1 because we have re-arranged where the negative sign enters into the problem. Same result though. ])

Fall 2007 16.31 16 7 Simple Compensator Example Let G(s) = 1/(s 2 + s + 1) with state-space model given by: [ ] [ ] 0 1 0 A =, B =, C = [ 1 0 ], D = 0 1 1 1 Design the regulator to place the poles at s = 4 ± 4j λ i (A BK) = 4 ± 4j K = [ 31 7 ] Regulator pole time constant τ c = 1/ζω n 1/4 = 0.25 sec Put estimator poles with faster time constant τ e 1/10 Use real poles, so Φ e (s) = (s + 10) 2 [ ] 1 [ ] C 0 L = Φ e (A) CA 1 [ ] 2 [ ] [ ] [ 0 1 0 1 100 0 1 0 = + 20 + 1 1 1 1 0 100 0 1 [ ] [ ] [ ] 99 19 0 19 = = 19 80 1 80 ] 1 [ 0 1 ]

Fall 2007 16.31 16 8 Compensator: A c = A [ BK ] LC [ 0 1 0 = 1 1 1 [ ] 19 1 = B c = L = 112 8 [ 19 80 ] C c = K = [ 31 7 ] ] [ 31 7 ] [ 19 80 ] [ 1 0 ] Compensator transfer function: G c (s) = C c (si A c ) 1 B c U E s + 2.553 = 1149 s 2 + 27s + 264 Note that the compensator has a low frequency real zero and two higher frequency poles. Thus it looks like a lead compensator.

Fall 2007 16.31 16 9 Figure 1: Plant is pretty simple and the compensator looks like a lead 2 10 rads/sec.

Fall 2007 16.31 16 10 Figure 2: Loop transfer function L(s) shows the slope change near ω c = 5 rad/sec. Note that we have a large PM and GM.

Fall 2007 16.31 16 11 Figure 3: Freeze compensator poles and zeros; look at root locus of closed-loop poles versus an additional loop gain α (nominally α = 1.) Figure 4: Closed-loop transfer function.

Fall 2007 16.31 16 12 Dynamic Output Feedback Example (reg est.m) 1 % Combined estimator/regulator design for a simple system 2 % G= 1/(s^2+s+1) 3 % 4 % Jonathan How 5 % Fall 2007 6 % 7 close all;clear all 8 for ii=1:5 9 figure(ii);clf;set(gcf, DefaultLineLineWidth,2);set(gcf, DefaultlineMarkerSize,10) 10 end 11 12 a=[0 1;-1-1];b=[0 1] ;c=[1 0];d=0; 13 k=acker(a,b,[-4+4*j;-4-4*j]); 14 l=acker(a,c,[-10-10] ) ; 15 % 16 % For state space for G_c(s) 17 % 18 ac=a-b*k-l*c;bc=l;cc=k;dc=0; 19 20 G=ss(a,b,c,d); 21 Gc=ss(ac,bc,cc,dc); 22 23 f=logspace(-1,2,400); 24 g=freqresp(g,f*j);g=squeeze(g); 25 gc=freqresp(gc,f*j);gc=squeeze(gc); 26 27 figure(1);clf 28 subplot(211) 29 loglog(f,abs(g),f,abs(gc), -- );axis([.1 1e2.02 1e2]) 30 xlabel( Freq (rad/sec) );ylabel( Mag ) 31 %legend( Plant G, Compensator Gc ); 32 grid 33 subplot(212) 34 semilogx(f,180/pi*angle(g),f,180/pi*angle(gc), -- ); 35 axis([.1 1e2-200 50]) 36 xlabel( Freq (rad/sec) );ylabel( Phase (deg) );grid 37 legend( Plant G, Compensator Gc ) 38 39 L=g.*gc; 40 41 figure(2);clf 42 subplot(211) 43 loglog(f,abs(l),[.1 1e2],[1 1]);axis([.1 1e2.2 1e2]) 44 xlabel( Freq (rad/sec) );ylabel( Mag ) 45 legend( Loop L ); 46 grid 47 subplot(212) 48 semilogx(f,180/pi*phase(l. ),[.1 1e2],-180*[1 1]); 49 axis([.1 1e2-290 0]) 50 xlabel( Freq (rad/sec) );ylabel( Phase (deg) );grid 51 % 52 % loop dynamics L = G Gc 53 % 54 al=[a b*cc;zeros(2) ac]; 55 bl=[zeros(2,1);bc]; 56 cl=[c zeros(1,2)]; 57 dl=0; 58 figure(3) 59 rlocus(al,bl,cl,dl) 60 % 61 % closed-loop dynamics 62 % unity gain wrapped around loop L 63 % 64 acl=al-bl*cl;bcl=bl;ccl=cl;dcl=d; 65 % 66 % scale closed-loop to get zero SS error 67 N=inv(ccl*inv(-acl)*bcl) 68 69 hold on;plot(eig(acl), d, MarkerFaceColor, b );hold off 70 grid on

Fall 2007 16.31 16 13 71 axis([-25 5-15 15]) 72 % 73 % closed-loop freq response 74 % 75 Gcl=ss(acl,bcl*N,ccl,dcl*N); 76 gcl=freqresp(gcl,f*j);gcl=squeeze(gcl); 77 78 figure(4);clf 79 loglog(f,abs(g),f,abs(gcl), -- ); 80 axis([.1 1e2.01 1e2]) 81 xlabel( Freq (rad/sec) );ylabel( Mag ) 82 legend( Plant G, closed-loop G_{cl} );grid 83 title([ Factor of N=,num2str(N), applied to Closed loop ]) 84 85 figure(5);clf 86 margin(al,bl,cl,dl) 87 88 figure(1);orient tall;print -dpng -r300 reg_est1 89 figure(2);orient tall;print -dpng -r300 reg_est2 90 figure(3);print -dpng -r300 reg_est3 91 figure(4);print -dpng -r300 reg_est4 92 figure(5);print -dpng -r300 reg_est5

Fall 2007 16.31 16 14 Figure 5: Example #1: G(s) = 8 14 20 (s+8)(s+14)(s+20)

Fall 2007 16.31 16 15 Figure 6: Example #1: G(s) = 8 14 20 (s+8)(s+14)(s+20) closed-loop poles, open-loop poles, Compensator poles, Compensator zeros Two compensator zeros at -21.54±6.63j draw the two lower frequency plant poles further into the LHP. Compensator poles are at much higher frequency. Looks like a lead compensator.

Fall 2007 16.31 16 16 Figure 7: Example #2: G(s) = 0.94 s 2 0.0297

Fall 2007 16.31 16 17 Figure 8: Example #2: G(s) = 0.94 s 2 0.0297 closed-loop poles, open-loop poles, Compensator poles, Compensator zeros Compensator zero at -1.21 draws the two lower frequency plant poles further into the LHP. Compensator poles are at much higher frequency. Looks like a lead compensator.

Fall 2007 16.31 16 18 Figure 9: Example #3: G(s) = 8 14 20 (s 8)(s 14)(s 20)

Fall 2007 16.31 16 19 Figure 10: Example #3: G(s) = 8 14 20 (s 8)(s 14)(s 20) closed-loop poles, open-loop poles, Compensator poles, Compensator zeros Compensator zeros at 3.72±8.03j draw the two higher frequency plant poles further into the LHP. Lowest frequency one heads into the LHP on its own. Compensator poles are at much higher frequency. Note sure what this looks like.

Fall 2007 16.31 16 20 Figure 11: Example #4: G(s) = (s 1) (s+1)(s 3)

Fall 2007 16.31 16 21 Figure 12: Example #4: G(s) = (s 1) (s+1)(s 3) closed-loop poles, open-loop poles, Compensator poles, Compensator zeros Compensator zero at -1 cancels the plant pole. Note the very unstable compensator pole at s = 9!! Needed to get the RHP plant pole to branch off the real line and head into the LHP. Other compensator pole is at much higher frequency. Note sure what this looks like.

Fall 2007 16.31 16 22 Separation principle gives a very powerful and simple way to develop a dynamic output feedback controller Note that the designer now focuses on selecting the appropriate regulator and estimator pole locations. Once those are set, the closed-loop response is specified. Can almost consider the compensator to be a by-product. These examples show that the design process is extremely simple.

Fall 2007 16.31 16 23 Reference Input - II On page 16-5, compensator implemented with a reference command by changing to feedback on e(t) = r(t) y(t) rather than y(t) r(t) e(t) u(t) y(t) G c (s) G(s) So u(t) = G c (s)e(t) = G c (s)(r(t) y(t)) Intuitively appealing because same approach used for classical control, but it turns out not to be the best. Can improve the implementation by using a more general form: ẋ c (t) = A c x c (t) + B c y(t) + Gr(t) u(t) = C c x c (t) + Nr(t) Now explicitly have two inputs to the controller (y(t) and r(t)) N performs the same role that we used it for previously. Introduce G as an extra degree of freedom in the problem. Turns out that setting G = B N is a particularly good choice. Following presents some observations on the impact of G

Fall 2007 16.31 16 24 First: this generalization does not change the closed-loop poles of the system, regardless of the selection of G and N, since ẋ(t) = Ax(t) + Bu(t), y(t) = Cx(t) ẋ c (t) = A c x c (t) + B c y(t) + Gr(t) [ ẋ(t) ẋ c (t) u(t) = C c x c (t) + Nr(t) ] = [ ] [ ] A BCc x(t) + B c C A c x c (t) ] y(t) = [ C 0 ] [ x(t) x c (t) So the closed-loop poles are the eigenvalues of [ ] A BCc [ B N G ] r(t) B c C A c (same as 16 6 except in a different place, gives same closed-loop eigenvalues) regardless of the choice of G and N G and N impact the forward path, not the feedback path Second: if N = 0 and G = L = Bc, then we recover the original implementation, on 16 5 since the controller reduces to: ẋ c (t) = A c x c (t) + B c (y(t) r(t)) = A c x c (t) + B c ( e(t)) u(t) = C c x c (t) With G c (s) = C c (si A c ) 1 B c, then this compensator can be written as u(t) = G c (s)e(t) as before (since the negative signs cancel).

Fall 2007 16.31 16 25 Third: Given this extra freedom, what is the best way to use it? One good objective is to select G and N so that the state estimation error is independent of r(t). With this choice, changes in r(t) do not tend to cause such large transients in x(t) Note that for this analysis, take x(t) = x(t) x c (t) since x c (t) ˆx(t) x(t) = ẋ(t) ẋ c (t) = Ax(t) + Bu(t) (A c x c (t) + B c y(t) + Gr(t)) = Ax(t) + B( C c x c (t) + Nr(t)) ({A BC c B c C}x c (t) + B c Cx(t) + Gr(t)) x(t) = Ax(t) + B( Nr(t)) ({A B c C}x c (t) + B c Cx(t) + Gr(t)) = (A B c C)x(t) + B Nr(t) ({A B c C}x c (t) + Gr(t)) = (A B c C) x(t) + B Nr(t) Gr(t) = (A B c C) x(t) + (B N G)r(t) Thus we can eliminate the effect of r(t) on x(t) by setting G B N

Fall 2007 16.31 16 26 Fourth: if this generalization does not change the closed-loop poles of the system, then what does it change? Zeros of SISO y/r transfer function are given by: si A BC c B N general det B c C si A c G = 0 C 0 0 original det si A BC c 0 B c C si A c B c C 0 0 = 0 new det si A BC c B N B c C si A c B N C 0 0 = 0 Hard to see how this helps, but consider the scalar new case: C( BC c B N + (si A c )B N) = 0 CB N(BC c (si [A BC c B c C])) = 0 CB N(sI [A B c C]) = 0 So zero of the y/r path is the root of si [A B c C] = 0, which is the pole of the estimator. So by setting G = B N, the estimator dynamics are canceled out of the response of the system to a reference command. Cancelation does not occur with original implementation.

Fall 2007 16.31 16 27 So in summary, if the SISO system is G(s) = b(s)/a(s), then with DOFB control, the closed-loop transfer function will be of the form: T (s) = Y (s) R(s) = K γ(s)b(s) g Φ e (s)φ c (s) Designer determines Φ c (s) and Φ e (s) Plant zeroes b(s) remain, unless canceled out Many choices for γ(s), one is to set it to Φ e (s) to cancel out the estimator dynamics. Fifth: select N to ensure that the steady-state error is zero. As before, this can be done by selecting N so that the DC gain of the closed-loop y/r transfer function is 1. y [ C 0 ] [ ] 1 [ ] A BC c B N = I r DC B c C B A c The new implementation of the controller is ẋ c (t) = A c x c (t) + B c y(t) + B Nr(t) u(t) = C c x c (t) + Nr(t) Which has two separate inputs y(t) and r(t) Selection of N ensure that the steady-state performance is good The new implementation gives better transient performance.

Fall 2007 16.31 16 28 Figure 13: Example #1: G(s) = 8 14 20 (s+8)(s+14)(s+20). Method #1: original implementation. Method #2: original, with the reference input scaled to ensure that the DC gain of y/r DC = 1. Method #3: new implementation with both G = B N and N selected. New method should show less of a transient impact of applying r(t).

Fall 2007 16.31 16 29 Figure 14: Example #2: G(s) = 0.94 s 2 0.0297. Method #1: original implementation. Method #2: original, with the reference input scaled to ensure that the DC gain of y/r DC = 1. Method #3: new implementation with both G = B N and N selected.

Fall 2007 16.31 16 30 Figure 15: Example #3: G(s) = 8 14 20 (s 8)(s 14)(s 20). Method #1: original implementation. Method #2: original, with the reference input scaled to ensure that the DC gain of y/r DC = 1. Method #3: new implementation with both G = B N and N selected.

Fall 2007 16.31 16 31 Dynamic Output Feedback Codes (dofb examp2.m) 1 % Code for Topic 16 2 % Examples of dynamic output feedback 3 % 4 % Jonathan How 5 % 6 fig=1; 7 % system 8 switch model 9 case 1 10 G=tf(8*14*20,conv([1 8],conv([1 14],[1 20])));name= nexamp1 11 tt=[-20 0-10 10]*2.5; 12 t=[0:.0025:1]; 13 case 2 14 G=tf(8*14*20,conv([1-8],conv([1-14],[1-20])));name= nexamp2 ; 15 tt=[-10 10-10 10]*2.5; 16 t=[0:.0025:1]; 17 case 3 18 G=tf(.94,[1 0-0.0297]);name= nexamp3 ; 19 tt=[-10 10-10 10]/5; 20 t=[0:.01:5]; 21 case 4 22 G=tf([1-1],conv([1 1],[1-3]));name= nexamp4 ; 23 tt=[-10 10-10 10]; 24 t=[0:.01:10]; 25 case 5 26 G=tf(conv([1-2],[1-4]),conv(conv([1-1],[1-3]),[1 2*.2*2 2^2 0 0])); 27 name= examp5 ; 28 case 6 29 G=tf(8*14*20,conv([1 8],conv([1 14],[1 20])));name= nexamp1h ; 30 tt=[-20 0-10 10]*2.5; 31 t=[0:.0001:1]; 32 otherwise 33 return 34 end 35 36 %%% 37 [a,b,c,d]=ssdata(g);na=length(a); 38 % 39 figure(fig);clf;fig=fig+1; 40 % controller gains to place poles at specified locations -- see 13-5 41 if model == 6 42 R=.00001; 43 else 44 R=.01; 45 end 46 % choose the regular poles using LQR 14-5 47 [k,p,reg_poles]=lqr(a,b,c *c,r); 48 %hold on 49 %plot(reg_poles+j*eps, md, MarkerSize,12, MarkerFaceColor, m ) 50 %hold off 51 52 % design the estimator by doubling the real part of the regulator poles 53 PP=2*real(reg_poles)+imag(reg_poles)*j; 54 % see 15-9 55 ke=place(a,c,pp);l=ke 56 % see 16-4 57 ac=a-b*k-l*c;bc=l;cc=k;dc=0; 58 % see 16-6 59 acl=[a -b*cc;bc*c ac];ccl=[c,zeros(1,na)];dcl=0; 60 % standard case 61 bcl1=[zeros(na,1);-bc]; 62 %scale up the ref path so that at least the Gcl(s) has unity DC gain 63 bcl2=[zeros(na,1);-bc]; % original implementation on 16-24 64 scale=ccl*inv(-acl)*bcl2; 65 bcl2=bcl2/scale; 66 % 67 bcl3=[b;b]; % new implementation on 16-24 68 scale=ccl*inv(-acl)*bcl3; 69 bcl3=bcl3/scale; 70 %

Fall 2007 16.31 16 32 71 Gcl1=ss(acl,bcl1,ccl,dcl); % original implementation (16-5) unscaled 72 Gcl2=ss(acl,bcl2,ccl,dcl); % original implementation (16-5) scaled 73 Gcl3=ss(acl,bcl3,ccl,dcl); % new implementation on 16-24 scaled 74 Gc=ss(ac,bc,cc,dc); 75 76 f=logspace(-2,3,400); 77 g=freqresp(g,f*j);g=squeeze(g); 78 gc=freqresp(gc,f*j);gc=squeeze(gc); 79 gcl1=freqresp(gcl1,f*j);gcl1=squeeze(gcl1); 80 gcl2=freqresp(gcl2,f*j);gcl2=squeeze(gcl2); 81 gcl3=freqresp(gcl3,f*j);gcl3=squeeze(gcl3); 82 83 figure(fig);fig=fig+1;clf 84 orient( tall ) 85 subplot(211) 86 loglog(f,abs(g),f,abs(gc), --, LineWidth,2);axis([.1 1e3 1e-2 500]) 87 xlabel( Freq (rad/sec) );ylabel( Mag ) 88 legend( Plant G, Compensator Gc );grid 89 subplot(212) 90 semilogx(f,180/pi*unwrap(angle(g)),f,180/pi*unwrap(angle(gc)), --, LineWidth,2); 91 axis([.1 1e3-200 50]) 92 xlabel( Freq (rad/sec) );ylabel( Phase (deg) );grid 93 legend( Plant G, Compensator Gc ) 94 95 L=g.*gc; 96 97 figure(fig);fig=fig+1;clf 98 orient( tall ) 99 subplot(211) 100 loglog(f,abs(l),[.1 1e3],[1 1], LineWidth,2);axis([.1 1e3 1e-2 10]) 101 xlabel( Freq (rad/sec) );ylabel( Mag ) 102 legend( Loop L ); 103 grid 104 subplot(212) 105 semilogx(f,180/pi*phase(l. ),[.1 1e3],-180*[1 1], LineWidth,2); 106 axis([.1 1e3-290 -0]) 107 xlabel( Freq (rad/sec) );ylabel( Phase (deg) );grid 108 % 109 % loop dynamics L = G Gc 110 % see 16-6 111 al=[a b*cc;zeros(na) ac];bl=[zeros(na,1);bc];cl=[c zeros(1,na)];dl=0; 112 113 figure(fig);fig=fig+1;clf 114 margin(al,bl,cl,dl); 115 figure(fig);fig=fig+1;clf 116 rlocus(al,bl,cl,dl) 117 hold on; 118 plot(eig(acl)+eps*j, bd, MarkerFaceColor, b ) 119 plot(eig(a)+eps*j, mv, MarkerFaceColor, m ) 120 plot(eig(ac)+eps*j, rs, MarkerSize,9, MarkerFaceColor, r ) 121 plot(tzero(ac,bc,cc,dc)+eps*j, ro, MarkerFaceColor, r ) 122 hold off;grid on 123 % 124 % closed-loop freq response 125 % 126 figure(15);clf 127 loglog(f,abs(g),f,abs(gcl1),f,abs(gcl2), --, LineWidth,2); 128 axis([.1 1e3.01 1e2]) 129 xlabel( Freq (rad/sec) );ylabel( Mag ) 130 legend( Plant G, Gcl unscaled, Gcl scaled );grid 131 132 figure(fig);fig=fig+1;clf 133 loglog(f,abs(g),f,abs(gcl1),f,abs(gcl2),f,abs(gcl3), --, LineWidth,2); 134 axis([.1 1e3.01 1e2]) 135 xlabel( Freq (rad/sec) );ylabel( Mag ) 136 legend( Plant G, Gcl1, Gcl2, Gcl3 );grid 137 138 ZZ=-1+.1*exp(j*[0:.01:1]*2*pi); 139 figure(fig);fig=fig+1;clf 140 semilogy(unwrap(angle(l))*180/pi,abs(l)) 141 hold on; 142 semilogy(unwrap(angle(zz))*180/pi-360,abs(zz), g- ) 143 hold off 144 axis([-270-100.1 10])

Fall 2007 16.31 16 33 145 hold on;plot(-180,1, rx );hold off 146 if max(real(eig(a))) > 0 147 title( Nichols: Unstable Open-loop System ) 148 else 149 title( Nichols: Stable Open-loop System ) 150 end 151 ylabel( Mag );xlabel( Phase (deg) ) 152 153 figure(fig);fig=fig+1;clf 154 plot(unwrap(angle(l))*180/pi,abs(l), LineWidth,1.5) 155 hold on 156 plot(unwrap(angle(l))*180/pi,.95*abs(l), r-., LineWidth,1.5) 157 plot(unwrap(angle(l))*180/pi,1.05*abs(l), m:, LineWidth,1.5) 158 plot(unwrap(angle(zz))*180/pi,abs(zz), g- ) 159 plot(-180,1, rx );hold off 160 hold on; 161 semilogy(unwrap(angle(zz))*180/pi-360,abs(zz), g- ) 162 hold off 163 legend( 1, 0.95, 1.05 ) 164 axis([-195-165.5 1.5]) 165 if max(real(eig(a))) > 0 166 title( Nichols: Unstable Open-loop System ) 167 else 168 title( Nichols: Stable Open-loop System ) 169 end 170 ylabel( Mag );xlabel( Phase (deg) ) 171 172 figure(fig);fig=fig+1;clf 173 loglog(f,abs(1./(1+l)),f,abs(l), --, LineWidth,1.5);grid 174 title( Sensitivity Plot ) 175 legend( S, L ) 176 xlabel( Freq (rad/sec) );ylabel( Mag ) 177 axis([.1 1e3 1e-2 100]) 178 179 figure(fig);fig=fig+1;clf 180 [y1,t]=step(gcl1,t); 181 [y2,t]=step(gcl2,t); 182 [y3,t]=step(gcl3,t); 183 plot(t,y1,t,y2,t,y3,t,ones(size(t)), --, LineWidth,1.5) 184 setlines(2) 185 legend( meth1, meth2, meth3 ) 186 title( Step Response ) 187 188 for ii=[1:gcf 15] 189 eval([ print -f,num2str(ii), -dpng -r300,name, _,num2str(ii),.png ]) 190 if ii==5; 191 figure(ii);axis(tt) 192 eval([ print -dpng -r300,name, _,num2str(ii), a.png ]) 193 % axis(tt) 194 end 195 end 196 197 eval([ save,name, R G Gc Gcl1 Gcl2 Gcl3 k l P PP ]) 198 199 return 200