state regulator

23
Advanced Control State Regulator Scope design of controllers using pole placement and LQ design rules Keywords pole placement, optimal control, LQ regulator, weighting matrices Prerequisites state space description Contact Roland Büchi, [email protected] Markus Kottmann, [email protected] Date January 17, 2011

Upload: rishi-kant-sharma

Post on 29-Sep-2015

28 views

Category:

Documents


2 download

DESCRIPTION

State regulator using matlab

TRANSCRIPT

  • Advanced Control

    State Regulator

    Scope design of controllers using pole placement and LQ design rules

    Keywords pole placement,optimal control, LQ regulator, weighting matrices

    Prerequisites state space description

    Contact Roland Bchi, [email protected] Kottmann, [email protected]

    Date January 17, 2011

  • Advanced Control, State Regulator MSE

    0 Preliminary Remarks

    The path to be followed in this and the next document is the following:

    The first point to be discussed concerns the design of regulators which makeuse of the state vector x to control a plant. It is assumed that the plant iscontrollable.

    The next point concerns the estimation of the state vector x in case that it isnot completely measured. To design such estimators (observers) it is assumedthat the plant is observable.

    The third theme concerns the cooperation between the regulator and the ob-server. Instead of using the true state-vector, the regulator then utilizes theestimated state-vector. Assumed that the two separate designs of regulatorand observer met their specific requirements are these requirements stillfulfilled if the regulator and the observer are used together?

    The assumptions about the plant to be controlled are as follows:

    Preferably, the plant is controllable and observable. If the plant lacks one or both of the above-mentioned properties (see the ex-amples in Fig. 1), then the non-controllable or non-observable parts can beremoved from the model our methods will work for the remaining modelwhich is controllable and observable.

    a) b)

    c)U

    UU

    Y

    YY

    X1

    X1X1

    X2

    X2X2++++

    1s+1

    1s+1

    2s+1

    1s2

    s2s+1

    1s2

    Figure 1: Examples of systems that are not controllable

    If the removed parts are e.g. unstable or badly damped then the control systemwill not be very successful. In that case, additional actuators or sensors areneeded.

    The plant is assumed to be a low-pass system with a feed-through matrixD = 0. The case D 6= 0 is not difficult it just produces larger equationsand diagrams.

    In the sequel, the plant often is given as a SISO-system. Of course, that is not arestriction. In principle, it is easier to control a plant with more sensors and moreactuators.

    2 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    1 Feedback of the Full State Vector

    Figure 2: Control structure with feedforward term and full state feedback

    In Fig. 2, the control system has two components: the feedback part K, and thefeedforward part Kvf . The state feedback K is used to determine the dynamics ofthe closed-loop system, while the prefilter Kvf is used to guarantee the static gain(y = r)1.Note that the error signal e = r y which is used in classical output feedback doesnot appear in this control structure.

    In the feedback signal uR, the state variables x1(t), x2(t) . . . xn(t) are weighted bythe coefficients k1, k2, . . . , kn.

    uR = k1x1 + k2x2 + ... + knxn =[

    k1 k2 ... kn]

    x1x2...

    xn

    = KxThe control signal u is

    u = w uR = Kvf r K xThe matrix equations are

    x = A x + B (Kvf r Kx) = A x BKx + BKvf rx = (A BK) x + BKvf r and y = C x

    The whole system can be described by a new set of matrices Ag, Bg, Cg

    Ag = A BK , Bg = BKvf , Cg = C1The prefilter, as used here, is just a gain. More sophisticated prefilters might be used to shape

    the dynamics of Y (s)/R(s).

    January 17, 2011 Roland Bchi, Markus Kottmann 3

  • Advanced Control, State Regulator MSE

    The I/O-description becomes

    G(s) =Y (s)

    R(s)= Cg(sI Ag)1Bg = C(sI A + BK)1BKvf

    For the moment we assume that K is known. Then the static gain can beadjusted by setting G(0) = 1 or

    Kvf =(C(A + BK)1B)1 (1)

    This method is sensitive to parameter variations, so in section 4 we will discuss analternative which includes integral action.

    Sections 2 and 3 deal with the question how to calculate K.

    2 Pole Placement

    According to Definition B of controllability, the controllability of (A, B) ensuresthat the eigenvalues 1 . . . n of Ag = A BK can be placed arbitrarily by properchoice of K. The eigenvalues of Ag are given by the roots of det(I A + BK). Toachieve some desired eigenvalues 1 . . . n the following polynomials must coincide:

    det(I A + BK) = ( 1)( 2) . . . ( n) (2)

    The question which arises is about the choice of good pole locations. Someconsiderations are:

    Obviously, the poles must be chosen in the left half plane for stability reasons. Transients of the signals should decay towards zero faster than some C e1 . The transients should be well damped, e.g. > 1/2. Forcing transients to decay fast towards zero needs energy. Therefore, anupper bound 2 > is meaningful.

    While the placement of poles is simple for low order systems, it gets somehowunsatisfying when handling systems of order e.g. 4 or higher.

    3 Optimal Control

    An alternative way to determine K makes use of the fundamental idea of optimality.Changing the value of K results in a different behavior of the control system. If thebehavior of the control system is judged quantitatively, it is convenient to have ascalar performance index (or cost function) J = f(K). Normally, better performancecorresponds to smaller values of J . The optimal value of K then can be found byminimizing J , e.g. by varying K systematically. In control theory, systems that

    4 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    Re

    Im

    = 1/

    (2)

    = 1/

    (2)

    2 1

    s

    Figure 3: Qualitative sketch of region of good pole locations

    are adjusted to provide a minimum performance index are called optimal controlsystems.

    The function f often is defined based on some intermediary variables such as thestate vector x or the input u

    J = f(K) =

    tf0

    g(x, u)dt

    where, of course, x and u depend on K. Since it is useless to look at the valuesof x and u at some specific time only, the index J is formulated as an integralover time. For theoretical considerations, it is convenient to set the final time tf toinfinity. Quadratic terms for the function g are prevalent on one hand these aremeaningful measures, and on the other hand they often yield nice analytical results.

    Figure 4: Regulator problem

    January 17, 2011 Roland Bchi, Markus Kottmann 5

  • Advanced Control, State Regulator MSE

    Consider the following regulator problem, see Fig. 4. The initial state of thesystem is x(0) = x0. The intention is to take x towards zero as fast as possible byusing state feedback. If the norm of x is taken,

    |x|2 = x12 + x22 + ... + xn2 =[

    x1 x2 ... xn]

    x1x2...

    xn

    = xT x

    and integrated over time we get the performance index J =tf0

    xT x dt. In the following

    derivation the time horizon is set to infinity, and a more general weighting schemefor the state variables is used with a symmetric, positive semidefinite matrix Q:

    J =

    0

    xT Qx dt (3)

    Note that the general form of the performance index incorporates a term con-taining u to weigh the control energy. This will be discussed in section 3.1.

    To obtain the minimum value of J , we follow [1] and postulate the existence ofan exact differential with a constant symmetric matrix P such that

    d

    dt(xT Px) = xT Qx

    where P is to be determined. Applying the product rule for differentiation,

    d

    dt(xT Px) = xT Px + xT P

    0

    x + xT P x

    defining

    H = A BK (4)and substituting x = Hx, we get

    d

    dt(xT Px) = (Hx)T Px + xT P (Hx) = xT HT Px + xT PHx

    = xT (HT P + PH) Q

    x = xT Qx (5)

    which is the exact differential we are seeking. Substituting that expression in (3)results in the performance index

    J =

    0

    ddt

    (xT Px)dt = xT Px0

    = (0 xT (0)Px(0)) = xT (0)Px(0)

    6 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    In the evaluation of the limit at t = , we have assumed that the system is stableand hence x() = 0, as desired. Therefore to minimize the performance index J ,we consider the two equations:

    J =

    0

    (xT Qx)dt = xT (0)Px(0) and (HT P + PH) = Q

    The design steps are then as follows:

    1. Determine the matrix P , where H and Q are assumed to be known.

    2. Minimize J = xT (0)Px(0) by adjusting one ore more unspecified system pa-rameters.

    3.1 Linear Quadratic Regulator (LQR)

    In a more general case, we also consider the control energy of u. A method suitablefor computer calculation is stated without proof in the following. Consider theuncompensated MIMO system

    x = Ax + Bu

    with feedbacku = Kx.

    The performance index is

    J =

    0

    (xT Qx + uT Ru)dt (6)

    With Q and R both positive definite, it can be shown that (6) is minimized with

    K = R1BT P (7)

    To calculate the symmetric n n matrix P , an algebraic matrix Riccati (ARE)equation must be solved:

    AT P + PA PBR1BT P = Q.Since the ARE is a quadratic equation, it has multiple solutions. Equation (6) de-mands for the (only) solution P which is positive definite. The resulting optimalcontroller is called the linear quadratic regulator (MATLAB command: lqr).

    The condition about Q can be relaxed: if Q = CT C 0 is positive semidefiniteand if (A, C) is observable, then P and K can be calculated in the same way. Theseconditions guarantee that x is observable through the virtual output y = Cx. Incase that Q 0 (instead of Q > 0) equation (6) delivers at least a solution P 0.

    January 17, 2011 Roland Bchi, Markus Kottmann 7

  • Advanced Control, State Regulator MSE

    3.2 Robustness of the Linear Quadratic Regulator

    If the control loop is opened at the input u of the plant (see Fig. 4) then the open-loop transfer function is given by G0(s) = K(sI A)1B. It can be shown, thatG0(j) has at least a phase margin of 60 and a gain margin of [0.5 . . .[ on eachchannel. This makes the LQ-regulator a considerably robust controller.

    4 State Regulator Including Integral Part

    In this section we discuss the problem of designing a compensator that provides anasymptotic tracking of a constant reference input r(t) = r0 with zero steady-stateerror. From classical control it is known that this can be achieved if the open-loopis at least of type 1. Fig. 5 illustrates a possible structure of such a controllerincluding an open integrator.

    8 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    Figure 5: Block diagram of a regulator with K1 containing an integral part

    If K1 and K2 are regarded as cascaded controllers then their design can beperformed in two steps:

    A faster inner loop is designed by determining K2, e.g. by means of LQR orpole placement.

    K1, e.g. a PI-controller, is then tuned using classical methods, resulting in aslower outer loop.

    Obviously, in this method the optimality of the inner loop may be destroyedby K1. To overcome this disadvantage a monolithic controller design is presented,which delivers K1 and K2 at once. The idea is formalized here by introducing aninternal model of the reference input in the compensator. In Fig. 5 the trackingerror e is defined as

    e = y r, (note the sign!)and its time derivative yields

    e = y 0r = y = Cx

    Defining two intermediate variables, z and w, as

    z = x and w = u,

    a new system results:

    x [ez

    ]=

    A [0 C0 A

    ] x [ez

    ]+

    B [0B

    ] uw (8)

    If the system (A, B) is controllable, then some feedback gain K which stabilizes (8)can be designed e.g. by pole placement or using the LQR method

    u = Kx.

    January 17, 2011 Roland Bchi, Markus Kottmann 9

  • Advanced Control, State Regulator MSE

    Since the error e is a state variable it converges towards zero, i.e. the requirementof an asymptotic tracking with zero steady-state error is fulfilled. Splitting thefeedback term yields

    u = w = K x = [K1 K2][

    ez

    ]= K1eK2z

    and by integration the final control law

    u(t) = K1t

    0

    e()d K2x(t)

    which is illustrated in Fig. 5.

    10 Roland Bchi, Markus Kottmann January 17, 2011

  • Bibliography

    [1] Richard C. Dorf and Robert H. Bishop. Modern Control Systems. Pearson, 2008.

    [2] William S. Levine, editor. The Control Handbook. The Electrical EngineeringHandbook Series. CRC Press/IEEE Press, 1996.

    January 17, 2011 Roland Bchi, Markus Kottmann 11

  • Advanced Control, State Regulator MSE

    Solved Exercises

    1 Pole Placement

    Given is a system in state space description

    A =

    [0 10 a

    ], B =

    [0

    Ks

    ], C =

    [c1 0

    ], D = 0

    a = 4 , Ks = 8 , c1 = 6.4

    For each of the following cases, find a controller u = k x + kvf r such that theclosed loop system has a unitary static gain and the poles p1 and p2:

    1. p1 = p2 = 152. p1,2 = 15 15j3. p1 = p2 = 50

    12 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    2 Optimal Control (1)

    Consider the control system shown below. The state vector is x = [x1 x2]T . Theopen-loop system is unstable, therefore state feedback is introduced.

    Figure 6: Block diagram of a LQ regulator

    The performance index is

    J =

    0

    (xT Qx)dt.

    Additional conditions are:

    Q = I and k1 = k2 = k and |u| 10 at initial conditions x(0) =[

    10

    ]1. Find the plants matrices A, B, C and D.

    2. Find the matrices H and P .

    3. Find k by minimizing the performance index J .

    January 17, 2011 Roland Bchi, Markus Kottmann 13

  • Advanced Control, State Regulator MSE

    3 Optimal Control (2)

    Given is a scalar systemx = ax + bu

    with a simplified algebraic Riccati equation: 2ap 1rb2p2 + q = 0

    1. Find a controller u = kx by minimizing the performance index J

    J =

    0

    (qx2 + ru2)dt , (q > 0, r > 0)

    2. Find a controller u = kx, which stabilizes the system using minimal controlenergy (q = 0).

    14 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    4 LQ-Regulator of an Inverted Pendulum

    Consider an inverted pendulum, where the input signal u(t) is a force, applied tothe cart, and the output signal y(t) is the position of the cart. The state vector[x1, x2, x3, x4]

    T is assumed to be [y, y, , ]T . The parameters are given by M = 1kg,m = 0.1kg, g = 10m/s2, l = 1m.

    Figure 7: inverted pendulum

    Thus, the following system description can be found:

    A =

    0 1 0 00 0 mg

    M0

    0 0 0 1

    0 0 (M+m)gMl

    0

    , B =

    01M

    0 1

    Ml

    , C = [ 1 0 0 0 ] , D = 01. Compute some optimal control regulators using Matlab command lqr and

    plot step responses of the closed-loop systems at different weights of controlenergy r. Find also suitable prefilters Kvf .

    2. For the same weights r of the control energy, plot the Bode diagram of theclosed-loop systems and discuss the results.

    3. Discuss the robustness of the system.

    January 17, 2011 Roland Bchi, Markus Kottmann 15

  • Advanced Control, State Regulator MSE

    Solutions

    1 Solution Pole Placement

    From equation (2) we get

    det (I A + BK) = ( p1)( p2)det([

    00

    ][0 10 a

    ]+

    [0 0

    Ksk1 Ksk2

    ])=

    det([

    1Ksk1 + a + Ksk2

    ])=

    ( + a + Ksk2) + Ksk1 =

    2 + (a + Ksk2) + Ksk1 = 2 (p1 + p2) + p1p2

    mp1p2 = Ksk1 k1 = p1p2

    Ks

    (p1 + p2) = a + Ksk2 k2 = p1 + p2 + aKs

    The prefilter kvf is calculated according equation (1)

    kvf =(C (A + BK))1 B + D)1

    =

    [c1 0][a + Ksk2 1Ksk1 0

    ]Ksk1

    [0

    Ks

    ]1

    =

    (c1KsKsk1

    )1=

    k1c1

    1.

    k1 =(15)(15)

    8= 28.125

    k2 = 15 15 + 48

    = 3.25

    kvf =28.125

    6.4= 4.39453125

    16 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    2.

    k1 =(15 + 15j)(15 15j)

    8= 56.25

    k2 = 15 + 15j 15 15j + 48

    = 3.25

    kvf =56.25

    6.4= 8.7890625

    3.

    k1 =(50)(50)

    8= 312.5

    k2 = 50 50 + 48

    = 12

    kvf =312.5

    6.4= 48.828125

    January 17, 2011 Roland Bchi, Markus Kottmann 17

  • Advanced Control, State Regulator MSE

    2 Solution Optimal Control (1)

    1. Read out the equations directly from the block diagram or write down thetransfer function G(s) = 1

    s2and use the controllable canonical form.

    x1 = x2

    x2 = u

    [x1x2

    ]=

    [0 10 0

    ] [x1x2

    ]+

    [01

    ]u

    y =[1 0

    ] [x1x2

    ]+[0]u

    2. The solution can be found using equations (4) and (5):

    H = A BK=

    [0 10 0

    ][01

    ] [k k

    ]=

    [0 1k k

    ]

    HT P + PH = Q

    It follows from P = P T that p12 = p21:[0 k1 k

    ] [p11 p12p12 p22

    ]+

    [p11 p12p12 p22

    ] [0 1k k

    ]=

    [1 00 1

    ][ kp12 kp22p11 kp12 p12 kp22

    ]+

    [kp12 p11 kp12kp22 p12 kp22

    ]=

    [1 00 1

    ][

    2kp12 p11 + kp12 + kp22p11 + kp12 + kp22 2p12 + 2kp22

    ]=

    [1 00 1

    ]m

    2kp12 = 1 p12 = 12k

    2p12 + 2kp22 = 1 p22 = k + 12k2

    p11 + kp12 + kp22 = 0 p11 = 2k + 12k

    18 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    3.

    J(k) = xT (0)Px(0)

    =[1 0

    ] [p11 p12p12 p22

    ] [10

    ]= p11 =

    2k + 1

    2k= 1 +

    1

    2k

    Because P has to be positive definite (P > 0), k has to be positive (k > 0).You can verify this condition by checking the eigenvalues of P which have tobe positive.

    J(k) is monotonically decreasing for k > 0. The optimum is achieved for thehighest possible k. Because we have the additional condition |u| 10, k isbounded by

    u(0) = Kx(0) =[k k

    ] [10

    ]= k 10

    kopt = 10

    January 17, 2011 Roland Bchi, Markus Kottmann 19

  • Advanced Control, State Regulator MSE

    3 Solution Optimal Control (2)

    1. Solving the Riccati Equation(1

    rb2)

    p2 + 2ap + q = 0

    results in the two solutions

    p =2a

    4a2 + 41

    rb2q

    21rb2

    =r

    b2

    (a

    a2 + b2

    q

    r

    )We are only interested in the positive solution. Because q 0 and r > 0

    b2q

    r 0 a

    a2 + b2

    q

    r

    The positive solution is

    p =r

    b2

    (a +

    a2 + b2

    q

    r

    )The optimal feedback gain k according equation (7) is

    k = r1bp =1

    b

    (a +

    a2 + b2

    q

    r

    )2. If q 0, the Riccati Equation becomes

    1rb2p2 + 2ap =

    (1

    rb2p + 2a

    )p = 0

    with the two solutionsp1 =

    2ar

    b2p2 = 0

    it follows that the solution p of the Riccati Equation is

    p =

    {0 if a 0

    2arb2

    if a > 0

    Note that the solution p is positive only if r is positive, too.

    The feedback gain k = r1bp is then

    k =

    {0 if a 02ab

    if a > 0

    The interpretation of this result is: if the system is stable (a 0), then weneed no control input to stabilize the system (the system operates in openloop). For an unstable system, the feedback k moves the unstable pole a > 0to

    a bk = a b2ab

    = a

    20 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    4 Solution LQ-Regulator of an Inverted Pendulum

    1.

    Listing 1: Calculate LQ-Regulators and plot step responsesg = 10;l = 1;M = 1;m = 0.1;

    A = [0 1 0 0;0 0 -m*g/M 0;0 0 0 1;0 0 (M+m)*g/(M*l) 0];

    B = [0; 1/M; 0; -1/(M*l)];C = [1 0 0 0];

    Q = eye(size(A));R = logspace (-2,2,5);

    L = cell(1, length(R));G = cell(1, length(R));

    for i = 1: length(R)K = lqr(A,B,Q,R(i));kvf = 1/(C/(-A+B*K)*B);G{i} = ss(A-B*K,B,C,[])*kvf ;L{i} = ss(A,B,K,[]) ;

    end

    figure (1);step(G{:});legends = cell(1, length(R));for i = 1: length(R)

    legends{i} = [R = num2str(R(i),%g)];endlegend(legends ,Location ,East);

    Refer to figure 8 for the step responses.

    2.

    Listing 2: Create Bode diagramsfigure (2);bode(G{:});grid on;legend(legends ,Location ,East);

    Decreasing the weight r for the input u leads to a closed loop system with afaster response. This can be seen in the step responses in figure 8 and in theincreased bandwidth in the Bode diagrams in figure 9.

    January 17, 2011 Roland Bchi, Markus Kottmann 21

  • Advanced Control, State Regulator MSE

    0 5 10 15 20 25 30 35-0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    Step Response

    Time (sec)

    Amplitude R = 0.01

    R = 0.1R = 1R = 10R = 100

    Figure 8: Step responses

    3. The robustness of a system can be determined in the nyquist plot of the openloop system. One can verify that none of the plots in figure 10 enter the unitcircle around 1. This means that all loops have a phase margin m > 60and a gain margin 1

    2< Gm < .Listing 3: Create Nyquist plots

    figure (3);phi = (0:100) *2* pi /100;nyquist(L{:}) ;hold on;plot(cos(phi) -1,sin(phi),k);hold off;axis ([-6 10 -6 6]);axis equal;legend(legends ,Location ,East);

    22 Roland Bchi, Markus Kottmann January 17, 2011

  • MSE Advanced Control, State Regulator

    -150

    -100

    -50

    0

    Mag

    nitude

    (dB)

    10-2 10-1 100 101 102 1030

    90

    180

    270

    360

    Phase (de

    g)

    Bode Diagram

    Frequency (rad/sec)

    R = 0.01R = 0.1R = 1R = 10R = 100

    Figure 9: Bode diagrams

    -6 -4 -2 0 2 4 6 8 10-6

    -4

    -2

    0

    2

    4

    6

    Nyquist Diagram

    Real Axis

    Imag

    inary Ax

    is

    R = 0.01R = 0.1R = 1R = 10R = 100

    Figure 10: Nyquist plots

    January 17, 2011 Roland Bchi, Markus Kottmann 23