Top Banner

of 114

CD Reference

Jun 03, 2018

Download

Documents

JonaHdz
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/12/2019 CD Reference

    1/114

    LabVIEW Control Design andSimulation ModuleAlgorithm References

    This document contains an index of Control Design VIs that use specific

    algorithms to calculate the output of the VI. These algorithms include ones

    derived by National Instruments and published algorithms. Table1-1lists

    the VIs of the LabVIEW Control Design and Simulation Module that use

    special algorithms to calculate the VI outputs. Table1-1lists the VIs by

    palette. The first column contains the name of the palette, the second

    column contains the name of the VI, and the third column provides the

    name of the algorithm and links to the sections that contain the algorithm

    derivation.

    The derivations of the algorithms are located in sections that follow

    Table1-1. Each section also contains references to published algorithms,

    which National Instruments used to implement the Control Design VIs.

    This document also contains the derivations of theLyapunov and Sylvester

    Equationsand theRiccati Equations.

  • 8/12/2019 CD Reference

    2/114

    Control Design and Simulation Module Algorithm Reference 2 ni.com

    Table 1-1. Algorithm References for Control Design VIs

    Palette Name VI Name Reference

    Dynamic Characteristics CD Covariance

    Response VI

    Lyapunov Equation Solver

    Discrete Lyapunov Equation Solver

    Staircase

    CD DC Gain VI Convert State-Space Model toTransfer Function Model

    Staircase

    CD Norm VI Lyapunov Equation Solver

    Convert State-Space Model to

    Transfer Function Model

    Discrete Lyapunov Equation Solver

    State-Space Norm

    Staircase

    CD Parametric Time

    Response VI

    Convert State-Space Model to

    Transfer Function Model

    Linear Response

    Staircase

    Zero-Order-Hold

    CD Pole-Zero Map VI Staircase

    Transmission Zeros (State-Space)

    CD Root-Locus VI Convert State-Space Model to

    Transfer Function Model

    Root Locus Plots

  • 8/12/2019 CD Reference

    3/114

    National Instruments Corporation 3 Control Design and Simulation Module Algorithm Reference

    Frequency Response CD All Margins Convert State-Space Model to

    Transfer Function Model

    All Margins (Linear System)

    CD Bandwidth Convert State-Space Model to

    Transfer Function Model

    CD Bode Convert State-Space Model to

    Transfer Function Model

    Bode, Nyquist, and Nichols Analysis

    CD Gain and

    Phase Margins VI

    Convert State-Space Model to

    Transfer Function Model

    Gain and Phase Margin (Linear

    System)

    CD Nichols VI Convert State-Space Model to

    Transfer Function Model

    Bode, Nyquist, and Nichols Analysis

    CD Nyquist VI Convert State-Space Model to

    Transfer Function Model

    Bode, Nyquist, and Nichols Analysis

    CD Singular Values VI Convert State-Space Model to

    Transfer Function Model

    Singular Values

    Staircase

    Table 1-1. Algorithm References for Control Design VIs (Continued)

    Palette Name VI Name Reference

  • 8/12/2019 CD Reference

    4/114

  • 8/12/2019 CD Reference

    5/114

  • 8/12/2019 CD Reference

    6/114

    Control Design and Simulation Module Algorithm Reference 6 ni.com

    Model Interconnections CD Append VI Staircase

    CD Feedback VI Convert State-Space Model to

    Transfer Function Model

    Staircase

    Unit Feedback

    CD Parallel VI Convert State-Space Model to

    Transfer Function Model

    Pade Approximation of Delay for a

    SISO Transfer Function Model

    Staircase

    CD Series VI Convert State-Space Model to

    Transfer Function ModelPade Approximation of Delay for a

    SISO Transfer Function Model

    Staircase

    Model Reduction CD Minimal Realization VI Staircase

    Canonical State-Space Realization

    Minimal State-Space Realization

    CD Model Order

    Reduction VI

    Model Order Reduction

    Table 1-1. Algorithm References for Control Design VIs (Continued)

    Palette Name VI Name Reference

  • 8/12/2019 CD Reference

    7/114

    National Instruments Corporation 7 Control Design and Simulation Module Algorithm Reference

    State Feedback Design CD Ackermann Ackermann

    CD Kalman Gain VI Continuous Algebraic Riccati

    Equation Solver

    Discrete Algebraic Riccati Equation

    Solver

    Hamiltonian Reduction Algorithm

    for Solving Riccati Equations

    Kalman Gain

    Continuous Algebraic Riccati

    Equation Somer via Schur and QZ

    Discrete Algebraic Riccati Equation

    Solver via Schur and QZ

    Full Rank Factorization

    CD Linear Quadratic

    Regulator VI

    Continuous Algebraic Riccati

    Equation Solver

    Discrete Algebraic Riccati Equation

    Solver

    Hamiltonian Reduction Algorithm

    for Solving Riccati Equations

    Continuous Algebraic Riccati

    Equation Somer via Schur and QZ

    Discrete Algebraic Riccati Equation

    Solver via Schur and QZ

    Full Rank Factorization

    CD Pole Placement VI Lyapunov Equation Solver

    Pole Placement

    CD State Estimator State Estimator and State-Space

    Controller

    Unit Feedback

    CD State-Space Controller State Estimator and State-Space

    Controller

    Unit Feedback

    Table 1-1. Algorithm References for Control Design VIs (Continued)

    Palette Name VI Name Reference

  • 8/12/2019 CD Reference

    8/114

  • 8/12/2019 CD Reference

    9/114

    National Instruments Corporation 9 Control Design and Simulation Module Algorithm Reference

    Implementation CD Current Observer

    Corrector / Predictor

    Implementation Current Observer

    (Point-by-Point)

    CD Predictive Observer Implementation Predictive Observer

    (Point-by-Point)

    CD Discrete Recursive

    Kalman Corrector /

    Predictor

    Adjust Stochastic State-Space System

    with Non-Zero-Mean Noise

    Excitation

    Discrete-Time Recursive Kalman

    Filter

    Implementation

    (Simulation Module)

    CD Continuous Observer Implementation Continuous

    Observer (Point-by-Point)

    CD Continuous Recursive

    Kalman Filter

    ContinuousTime Recursive

    Kalman-Bucy FilterAdjust Stochastic State-Space System

    with Non-Zero-Mean Noise

    Excitation

    Table 1-1. Algorithm References for Control Design VIs (Continued)

    Palette Name VI Name Reference

  • 8/12/2019 CD Reference

    10/114

    Control Design and Simulation Module Algorithm Reference 10 ni.com

    Pole Placement

    Assume the pair (A, B) is controllable and consider Kthe controller gain

    such that it places the poles, Eig(A BK), in the location you specify.

    Then, there exists a similarity transformation Tsuch that

    Where represents the user-defined poles along the diagonal. Rearrangingthe terms, you get the following equation.

    AT+ BKT= T

    AT T= BKT

    When KTis unknown, set KTequal to G. You get the following equation.

    AT T= BG

    Note that Tmust be invertible. Therefore, (, G) should be observable

    The CD Pole Placement VI is implemented such that Gis random but

    (, G) is observable.

    Reference:

    Varga, A.Robust Pole Assignment via Sylvester Equation Based State

    Feedback Parametrization. IEEE International Symposium on Computer

    Aided Control Systems Design, CACSD' 2000. Anchorage, AK, 2000.

    Singular Values

    Consider a system defined in terms of the state space model, and the

    equivalent transfer function model, shown below.

    T1

    A BK( )T =

    Eig ( ) Eig A( ) 0=

    x Ax Bu+=

    y Cx Du+=

    X s( ) Is A( )1

    BU s( )=

    Y s( ) CX s( ) DU s( )+=

    Y s( )

    U s( )----------- C

    Is A( )

    1B D

    +=

  • 8/12/2019 CD Reference

    11/114

    National Instruments Corporation 11 Control Design and Simulation Module Algorithm Reference

    The CD Singular Values VI calculate the eigenvalues of the following

    equation:

    (): [(I A)1B+ D)]

    This calculation uses a singular values decomposition. To show this result

    in decibels, you convert as 20log(w).

    First-Order-HoldThis algorithm implements what is called the triangle-hold equivalent of a

    first-order hold. The effect of this hold is to extrapolate samples and

    connect them in a straight line. In discrete form, this extrapolation is

    non-causal. You derive the filter that does this extrapolation as follows.

    Consider the following unit impulse.

    A first-order hold transfer function gives the following impulse response.

    In order to construct this function in the s-domain, apply the superposition

    principle of ramp functions.

  • 8/12/2019 CD Reference

    12/114

    Control Design and Simulation Module Algorithm Reference 12 ni.com

    As shown in the figure, the ramp has a slope of , which you can describe

    in the s-domain as follows:

    slope =

    At time T, the ramp starts at .

    At time 0, the ramp changes the sign of the slope .

    At time T, the response levels are .

    The composite transfer function becomes

    H(s) =

    Placing the first-order hold in series with the system transfer function G(s),

    you get the following:

    Y(s) = H(s)*G(s) *U(s)= *G(s)*U(s)

    Define the unit impulse function as

    and the auxiliary input variables as

    By applying the Inverse Laplace Transform to the definitions above and

    expressing G(s) in state-space form, you get the following:

    = Ax+ Bv

    = u(t + T)(t + T) 2u(t)(t) + u(t T)(t T) =

    You can place these expressions in one state-space model, as illustrated in

    the following expression:

    1

    T---

    1

    s2

    ----

    eTs

    s2

    ------1

    T---

    2s

    2---- 1T---

    eTs

    s2

    ---------1

    T---

    eTs

    2 eTs

    +

    s2T

    -------------------------------

    eTs

    2 eTs

    +

    s2T

    -------------------------------

    U s( ) eTs

    2 eTs

    +( )U s( )=

    sW s( ) U s( )=

    sT V s( ) W s( )=

    x

    v wT----=

    x w u

  • 8/12/2019 CD Reference

    13/114

    National Instruments Corporation 13 Control Design and Simulation Module Algorithm Reference

    where represents the unit impulse function. This model is shown in the

    following figure.

    Looking at theZero-Order-Holdsolution for the equation above,

    in which case the impulse response becomes

    = u[(K 1)T](t (K 1)T) 2u(KT)(t KT) +

    u[(K + 1)T](t (K + 1)T)

    because only consists of impulses

    x

    v

    w

    t( )

    A B 0

    0 0 I

    T---

    0 0 0

    M

    x

    v

    w

    t( )

    0

    0

    1

    u

    B

    +=

    u

    t( ) M t( ) Bu+=

    eAt

    t( ) eMt

    M t( ) eMt

    Bu=

    deMt

    t( )dt

    ----------------------- eMt

    Bu=

    K 1+( )T[ ] eMt KT[ ] e M t K 1+( )T[ ] BudtKT

    K 1+( )T

    +=

    u

    u

  • 8/12/2019 CD Reference

    14/114

    Control Design and Simulation Module Algorithm Reference 14 ni.com

    Similarly for (t (K + 1)T)

    Using Taylor Series expansion to evaluate the exponential of a matrix, you

    get the following:

    eMT= I + MT + +... =

    In the case of matrix M,

    M0= I; ; ;

    ; ... ;

    Substituting of such terms into the Taylor Series Expansion results in the

    following:

    To simplify the expression for eMT, define the following matrices,

    , ,

    f t( ) t KT( ) f t( ) 0=KT

    KT

    =KTK 1+( )T

    K 1+( )T[ ] eMT

    KT[ ]=

    MT( )2

    2!---------------- MT( )

    i

    i!---------------

    i 0=

    M1

    A B 0

    0 0 1 T0 0 0

    = M2

    A2

    AB B T

    0 0 00 0 0

    =

    M3

    A3

    A2B ABT

    0 0 0

    0 0 0

    = Mi

    Ai

    Ai 1

    B Ai 2

    BT

    0 0 0

    0 0 0

    =

    eMT MT( )

    i

    i!---------------

    i 0=

    AT( )

    i

    i 0=

    AT( )i 1

    B

    i 1=

    AT( )i 2

    B

    i 2=

    0 1 1

    0 0 1

    = =

    AT( )i

    i 0=

    = 1 AT( )i 1 B

    i 1=

    = 2 AT( )i 2 B

    i 2=

    =

  • 8/12/2019 CD Reference

    15/114

    National Instruments Corporation 15 Control Design and Simulation Module Algorithm Reference

    which give

    Therefore

    x(k + 1) = x(k) + 1v(k) + 2w(k)

    Based on Franklin Powell

    v(k) = u(k)

    w(k) = u(k + 1) u(k)

    substituting into the state-space model results in the following:

    x(k + 1) = x(k) + 1u(k) + 2[u(k + 1) u(k)]

    = x(k) + [1 2]u(k) + 2u(k + 1)

    Because all k + 1 terms need to be on the right-hand side of the equation,

    you need the following definition:

    (k) =x(k) 2u(k)

    Evaluating the previous equation at k + 1 results in the following:

    (k + 1) =x(k + 1) 2u(k + 1) =

    = [x(k) 2u(k)] + 2u(k) + (1 2)u(k)

    = [x(k) 2u(k)] + [1 2+ 2]u(k)

    = (k) + [1 2+ 2]u(k)

    eMT

    12

    0 I 0

    0 0 I

    =

    x k 1+( )

    v k 1+( )

    w k 1+( )

    12

    0 1 0

    0 0 1

    x k( )

    v k( )

    w k( )

    =

    x k( )

    1 2( )u k( )

    1u k( ) 2u k( )+

  • 8/12/2019 CD Reference

    16/114

    Control Design and Simulation Module Algorithm Reference 16 ni.com

    From this expression you can recognize the following system matrix, which

    is equivalent for the state dynamics,

    = , = 1 2+ 2

    and for the output calculation,

    y(k) = Cx(k) + Du(k)

    = C[x(k) 2u(k)] + C2u(k) + Du(k)

    = C(k) + [C2+ D]u(k)

    = C, = C2+ D

    Notice that because the change of variables are made to have all k + 1 terms

    on the left-hand side of the system equation, the initial conditions are

    affected by the inputs at time t = 0 in the following manner:

    Initial Conditions: (0) = (0) =x(0) 2u(0)

    , ICMAT = [I 2]

    where ICMAT is used to calculate the initial conditions based on the new

    set of states, .

    Reference:

    Franklin, G.F., J. D. Powell, and M. L. Workman.Digital Control of

    Dynamic Systems, 3th ed., p. 204. Reading, MA: Addison-Wesley, 1997.

    Linear Response

    Linear Response for continuous systems: After applying a zero-order-hold

    conversion from continuous to discrete, the following assumptions are

    made to the input profile:

    In the case of a unit step, the input is hold at 1

    In the case of an impulse response, you look at the effect of the impulse

    before the system has been converted to discrete form. Therefore, in a

    continuous system,

    = Ax+ Bu

    y = Cx+ Du

    AdF.O.H

    BdF.O.H

    CdF.O.H

    DdF.O.H

    xdF.O.H

    I 2[ ] x 0( )

    u 0( )=

    x

  • 8/12/2019 CD Reference

    17/114

    National Instruments Corporation 17 Control Design and Simulation Module Algorithm Reference

    Taking the Laplace transform,

    X(s)s x(0) = AX(s) + Bu(s)

    X(s) = (Is A)1[x(0) + Bu(s)]

    Because u(s) of impulse (0) is 1, you get

    X(s) = (Is A)

    1

    [x(0) + B]

    Note Impulse enter to the system as if you were using or shifting initial conditions.

    Therefore, for impulse in input i, =x(0) + bi, where biis the ithcolumn of B.

    Therefore, the system is discretized and the impulse enters as an initial condition

    equivalent to bi.

    Linear Simulation

    Discrete System:

    x(k + 1) = Ax(k) + Bu(k)

    y(k) = Cx(k) + Du(k)

    which makes integration straightforward after initial conditions are

    defined.

    Continuous System:

    The system must be discretized, and the initial conditions must be adjusted

    properly depending on the discretization method.

    For Zero-Order-Hold: (Ac, Bc, Cc, Dc) (Ad, Bd, Cd, Dd)

    IC not a function of u0. Integration is identical to Discrete Systems.

    First-Order-Hold: Based on the algorithm in the First-Order-Holdsection,

    the initial conditions needs to be re-evaluated based on the change of

    variables.

    which you can evaluate at t = 0.

    xi*

    0( )

    k( ) x k( ) 2u k( )

    0( ) I 2[ ] x 0( )

    u 0( )=

  • 8/12/2019 CD Reference

    18/114

    Control Design and Simulation Module Algorithm Reference 18 ni.com

    Unit Feedback

    Consider the following continuous state-space model.

    for unit feedback in the SISO case, as shown in the following figure.

    Notice there is no one-to-one correspondence between randyin the MIMO

    case, as shown in the following figure.

    Therefore, a Matrix describes connectivity for the feedback path. Forexample, in the figure above, you obtain that:

    where u = r +y'= r + y

    x

    Ax Bu+=

    y Cx Du+=

    y1'

    y2'

    0 0 1

    1 0 0

    y1

    y2

    y3

    =

  • 8/12/2019 CD Reference

    19/114

    National Instruments Corporation 19 Control Design and Simulation Module Algorithm Reference

    Substituting, you get the following:

    y= Cx+ D(r + y)

    y= (I D)1Cx+ (I D)1Dr

    or , where , .

    Substituting the previous expressions in the state-space model dynamics

    expression gives:

    = Ax+ Bu

    = Ax+ B(r + y)

    where y is a function of the states and the reference, r:

    = Ax+ B(r + + )

    grouping common terms for the states and the reference:

    = (A + )x+ B(I + )r

    In this manner the equivalence of A and B matrices are identified:

    = A + B(I D)1C

    = B(I + (I D)1D)

    In summary,

    y Cx Dr+= C I D( )1C= D I D( )

    1CD=

    x

    Cx Dr

    BC D

    A

    B

  • 8/12/2019 CD Reference

    20/114

    Control Design and Simulation Module Algorithm Reference 20 ni.com

    is equivalent to

    If (I D) is not invertible, there is at least one unfeasible ri, as thefollowing example illustrates.

    A = 0, B = 0, C = 0,

    and connectivity

    from G

    y = u

    Therefore r is not an independent input to the system but identical to the

    null vector r = 0.

    r is not chosen but fixed. In this case, you cannot calculate the unit

    feedback transfer function.

    D1 0

    0 1=

    u1 r1 y1=

    u2 r2 y2=u r y+=

  • 8/12/2019 CD Reference

    21/114

    National Instruments Corporation 21 Control Design and Simulation Module Algorithm Reference

    Grammians

    Controller Continuous: By definition the Controllable Grammians is given

    by the following expressions

    and

    The easier way to calculate the grammians is by pre and post multiplying

    Wcby A and AT, and adding the two terms, as illustrated below:

    Notice that the right-hand side of the equation can be grouped in the

    following way:

    Substituting the end values into the expression above and considering thatfor stable systems the exponential goes to zero at infinite, you get the

    following expression:

    AWc+ WcAT+ BBT= 0

    which solved using Lyapunov.

    Observer Continuous: By definition the Observable Grammians is given by

    the following expressions:

    ,

    Wc 0 tf( , ) eA

    BBTe

    AT

    d

    0

    tf

    Wc Wc 0 tf( , )tf lim

    AWc WcAT

    + A eA

    BBTe

    AT

    d

    0

    eA

    BBTe

    ATdA

    T

    0

    +=

    d eA

    BBTe

    AT

    ( )

    d-------------------------------------d

    0

    =

    eA

    BBTe

    AT

    0

    BBT

    ==

    W0 0 tf( , ) eAT

    CTCeAd0

    tf

    = W0 W0 0 tf( , )

    tf lim

  • 8/12/2019 CD Reference

    22/114

    Control Design and Simulation Module Algorithm Reference 22 ni.com

    Following an identical reasoning than for the Controller Grammians, you

    obtain the following expression:

    which also is solved using Lyapunov.

    Controller Discrete: The following expression defines the Controller

    Grammians for discrete systems:

    Multiply each side by A, ATrespectively

    If you define J = k + 1, you get the following:

    To reinitialize the index to start at J = 0 and make it identical to Wcthe term

    BBT must be added and subtracted giving:

    Therefore, AWcAT= Wc BBTis also solved using Discrete Lyapunov.

    ATW0 W0A C

    TC+ + 0=

    Wc AkBB

    TA

    T( )

    k

    k 0=

    n

    Wc Wcn lim A

    kBB

    TA

    T( )

    k

    k 0=

    =

    AWcAT

    Ak 1+

    BBT

    AT

    ( )k 1+

    k 0=

    =

    AJ

    BBT

    AT

    ( )J

    J 1=

    =

    AWcAT

    AJBB

    TA

    T( )

    J

    J 0=

    BBT

    =

  • 8/12/2019 CD Reference

    23/114

    National Instruments Corporation 23 Control Design and Simulation Module Algorithm Reference

    Observer Discrete: The following expression defines the Observer

    Grammians for discrete systems:

    for which, following a similar reasoning in the Controller Grammians for

    discrete systems, you get ATW0A = W0 CTC.

    The previous expression is also solved using Discrete Lyapunov.

    Implementation:

    B is decomposed using SVD

    B = USVTBBT= Us2UT

    UUT= UTU = I

    For Controller Continuous, substitution of the previous expression gives:

    AWc+ WcAT+ Us2UT= 0

    which could be pre- and post-multiplied by UT and U, respectively.

    UTAWcU + UTWcATU + s2= 0

    because Wcis symmetric.

    Continuous Lyapunov

    For Controller Discrete

    AWcAT Wc+ Us

    2UT= 0

    W0 AT

    ( )kC

    TCA

    k

    k 0=

    n

    W0 W0n lim AT( )kCTCAk

    k 0=

    =

    UTAU

    A

    UTWcU

    Wc

    UTWcU

    Wc

    UTA

    TU

    AT

    s2

    + + 0=

    AWc WcAT

    s2

    + + 0=

  • 8/12/2019 CD Reference

    24/114

    Control Design and Simulation Module Algorithm Reference 24 ni.com

    which could be pre- and post-multiplied by UT and U, respectively.

    UTAWcATU UTWcU + s

    2= 0

    Discrete Lyapunov

    Note: Wc= UWcUT

    Reference:

    Kailath, T.Linear Systems, 1st ed., p. 609. Englewood, NJ: Prentice-Hall,

    1980.

    Balancing

    The CD Balance State-Space Models (Grammians) VI has only one entry

    per column or row in the transformation matrix T.

    The tolerance is defined as follows.

    Rearranging the terms, you get the following relationship.

    If TRUE, Tis not adjusted. If FALSE, set K equal to the following:

    UTAU

    A

    UTWcU

    Wc

    UTA

    TU

    A( )T

    UTWcU

    Wc s

    2+ 0=

    T

    1

    2

    3

    4

    =

    ma xmi n----------- tolerance

    ma xmi n-----------

    1

    tolerance---------------------- 1 0

    Kma xmi n-----------

    old

    ma xmi n-----------

    new

    tolerance=,

  • 8/12/2019 CD Reference

    25/114

    National Instruments Corporation 25 Control Design and Simulation Module Algorithm Reference

    The new maxand the new minare as follows:

    This way, the new set of maxand min satisfies the tolerance.

    Tis rescaled accordingly to the modifications made, and the procedure is

    repeated until one of the following conditions are met.

    1. K min= 0, Tis not full rank.2. K max= 0, Tis not full rank.

    3. .

    4. The number of iterations is equal to the dimension of T.

    Reference:

    Alan J. Laub, Michael T. Heath, Chris C. Paige, and Robert C. Ward,

    Computation of System Balancing Transformations and Other

    Applications of Simultaneous Diagonalization Algorithms. IEEETransactions on Automatic Control, vol. AC-21, num. 2, 1987.

    Tustins Transformations

    The Model Conversion VIs use Tustins methods to convert models from

    discrete to continuous and from continuous to discrete. The following

    section describes the algorithm used to implement the discrete to

    continuous conversion.

    maxnew maxoldtolerance

    K----------------------=

    minnew minoldK

    tolerance----------------------=

    ma xmi n-----------

    new

    ma xmi n-----------

    old

    tolerance

    K----------------------

    K

    tolerance----------------------

    -------------------------- tolerance==

    ma xm in-----------

    tolerance

  • 8/12/2019 CD Reference

    26/114

    Control Design and Simulation Module Algorithm Reference 26 ni.com

    Discrete to Continuous

    *

    *

    *

    *

    I AT2

    --------+ I AT

    2--------

    1

    =

    AT

    2------------

    I AT2

    --------+=

    I( ) I+( )T

    2---A=

    A I+( )1

    I( )2

    T---=

    IAT

    2--------

    1

    B T=

    B1

    T------- I

    AT

    2--------

    =

    1

    T------- I I+( )

    1 I( )( )=

    H TC IAT

    2--------

    1

    =

    C 1T

    -------H I AT2

    -------- 1T

    -------H I I+( ) 1 I( )( )==

    J D C IAT

    2--------

    1 BT

    2-------+=

    D J C I I+( )1

    I( )( )1 BT

    2-------=

    D J

    1

    T---

    T

    2---H I I+( )1

    I( )( )

    2

    =

    D JH

    2---- I I+( )

    1 I( )( )=

  • 8/12/2019 CD Reference

    27/114

    National Instruments Corporation 27 Control Design and Simulation Module Algorithm Reference

    Reference:

    Franklin, G.F., J. D. Powell, and M. L. Workman.Digital Control of

    Dynamic Systems, 3th ed., p. 200. Reading, MA: Addison-Wesley, 1997.

    Note The continuous to discrete conversion for Tustins method uses the algorithms

    presented inDigital Control of Dynamic Systems.

    Model Order Reduction

    Step 1: Find a similarity transformation that place the state to eliminate at

    the end.

    For example,

    Eliminate state 1 and 2. (Place them at the bottom of the state vector.) The

    similarity transformation is given by the following similarity matrix T:

    ,

    ,

    This way: ,

    The states have been reordered. The following procedure explains how to

    obtain T.

    x

    x1

    x2

    x3

    =

    T

    0 0 1

    1 0 0

    0 1 0

    = A

    a11 a12 a13

    a21 a22 a23

    a31 a32 a33

    =

    TA

    a31 a32 a33

    a11 a12 a13

    a21 a22 a23

    = TATT

    a33 a31 a32

    a13 a11 a12

    a23 a21 a22

    =

    x

    x3

    x1

    x2

    = A TAT1

    =

  • 8/12/2019 CD Reference

    28/114

    Control Design and Simulation Module Algorithm Reference 28 ni.com

    Consider the number of states to eliminate in descending order.

    where

    e = number of states to eliminate,

    n = total number of states

    Consider Tinitialized as the identity matrix, and counter index iinitialized

    at 1.

    1. Take Jirow from T, denoted as .

    2. Take n irow from T, denoted as tni.

    3. Swap them in T. In other words, substitute in row niand tniin

    row Ji.

    4. Make inew= i+ 1 and continue to point 1 until inew> e.

    The Match Gain OptionMatch Gain allows you to maintain a steady-state gain while eliminating

    states.

    Consider the following continuous system description:

    Where sstands for selected and estands for eliminated.

    Sets the dynamics of the eliminated states to zero, , which is a

    quasi-steady state assumption, where represents fast dynamics.

    J

    J1

    J2

    Je

    =

    tJi

    tJi

    x s

    xe

    Ass Ase

    Aes Aee

    xs

    xe

    Bs

    Be

    u+=

    y Cs Cexs

    xe

    Du+=

    xe 0=

    x e

    0 Aesxs Aeexess

    Beu+ +=

  • 8/12/2019 CD Reference

    29/114

    National Instruments Corporation 29 Control Design and Simulation Module Algorithm Reference

    Solving for

    Substituting in the selected set of states dynamics, :

    where now a new set of A, B, C and D matrices are identified, as illustrated

    below.

    Substituting fory, you get the following equation:

    y= Csxs+ Ce[Aesxs + Beu] + Du

    Note In the case of Discrete Systems, = (I A)1.

    Canonical State-Space Realization

    A state-space model can be transformed into a controllable canonical formusing the transformation matrix T defined as follows:

    T = QW

    where Q is the controllability matrix

    Q = [B: AB: ... An1B]

    where |SI A| = sn+ a1sn1+ ... + an1z + an= 0

    x ess

    xess

    A ee1

    Aesxs Beu+[ ] Aesxs Beu+[ ]= =

    xs

    xs Assxs Ase Aesxs Beu+[ ] Bsu+ +=

    Ass AseAes+[ ]xs

    Ass

    Bs AseBe+[ ] u

    Bs+=

    Cs CeAes+[ ] xs

    Cs

    D CeBe+[ ] u

    D+=

    W

    an 1 an 2 a1 1

    an 2

    an 3

    1 0

    a1 1 0 0

    1 0 0 0

    =

  • 8/12/2019 CD Reference

    30/114

    Control Design and Simulation Module Algorithm Reference 30 ni.com

    Reference:

    Ogata, K.,Discrete-Time Control Systems. Englewood, NJ: Prentice-Hall,

    1987.

    Minimal State-Space Realization

    The CD Minimal State Realization VI eliminates states that do not have anyeffect on the control problem. For example, this function eliminates states

    that are unobservable and/or uncontrollable.

    The controllability matrix is defined as,

    Q= [BAB... An1B]

    The observability matrix is defined as,

    Each row of Cand OTrefers to the controllability and observability of the

    corresponding state.

    Let Cirefers to row iand Cjrefers to columnjin the matrix.

    If CiCiT, the state is uncontrollable.

    If OjTOj, the state is unobservable.

    is a small constant that represents tolerance.

    The CD Minimal State Realization VI eliminates all states that are either

    uncontrollable or unobservable and returns a reduced model.

    O

    C

    CA

    :

    CAn 1

    =

  • 8/12/2019 CD Reference

    31/114

    National Instruments Corporation 31 Control Design and Simulation Module Algorithm Reference

    Zero-Order-Hold

    Continuous to Discrete: Consider the state dynamics equation:

    Pre-multiply the expression above by the exponential term

    The right-hand side of the equation can be grouped in the following

    derivative term:

    Integration of the previous expression between K and K + 1 gives

    Evaluation of the left-hand side of the equation provides the following

    terms:

    Set = t KT. Substituting this change of variables in the equation abovegive the following result:

    u(+ KT) = u(t)

    d= dt

    Which leads to

    x Ax Bu+=

    eAt

    x eAt

    Ax eAt

    Bu+=

    eAt

    x eAt

    Ax eAt

    Bu=

    d eAt

    x( )dt

    -------------------- eAt

    Bu=

    eAt

    xKT

    K 1+( )T

    eAt

    BudtKT

    K 1+( )T

    =

    eA K 1+( )T

    x K 1+( )T[ ] eAK T

    x KT[ ]

    eAt

    eA KT+( )

    =

    eA KT+( )

    Bu KT+( )d0

    T

    e

    AKTe

    ABu KT+( )d

    0

    T

    ==

    eAT

    x K 1+( )T[ ] x KT[ ] eA

    Bu KT+( )d0

    T

    =

  • 8/12/2019 CD Reference

    32/114

    Control Design and Simulation Module Algorithm Reference 32 ni.com

    Solving forx[(K + 1)T]

    Zero-Order-Hold

    Consider the following equation where the input u(t) remains constant in

    the [K K+1] interval:

    Substituting this assumption in the previous expression gives:

    You can take the input out of the integral.

    and you can evaluate the integral accordingly.

    This last expression allows you to identify the system matrices A and B for

    the zero-order-hold conversion.

    ,

    Code Implementation using the Taylor Series Expansion

    x K 1+( )T[ ] eAT

    x KT[ ] eA T( )

    Bu KT+( ) d0

    T

    +=

    eAT

    x KT[ ] eAT

    eA t KT( )

    Bu t( )dtKT

    K 1+( )T

    +=

    eAT

    x KT[ ] eA t K 1+( )T[ ]

    Bu t( )dtKT

    K 1+( )T

    +=

    u t( )KT

    K 1+( )Tcons t tan u KT( )= =

    eAT

    x KT[ ] eA t K 1+( )T[ ]

    dtBu KT( )KT

    K 1+( )T

    +=

    eAT

    x KT[ ] eA t K 1+( )T[ ]

    A1

    KT

    K 1+( )T

    Bu KT( )=

    eAT

    x KT[ ] A1

    eAT

    A1

    [ ]Bu KT( )=

    eAT

    x KT[ ] I eAT

    ( )A1Bu KT( )=

    AdZOH

    eAT

    = BdZOH

    eAT

    I( )A1B=

    eMT

    I MTMT( )

    2

    2!---------------- + + + MT

    ( )i

    i!---------------

    i 0=

    = =

  • 8/12/2019 CD Reference

    33/114

    National Instruments Corporation 33 Control Design and Simulation Module Algorithm Reference

    Consider that matrices A and B can be appended together. Therefore, the

    exponential of the appended matrix is given by:

    The addition of the infinite number of terms in the series gives,

    Because the matrix summation is equivalent to the summation of each of its

    elements, you get the following expression:

    where the definition of the exponential of the A matrix can be substituted,

    and therefore, the system matrices can be identified:

    Note:

    y = Cx+ Duy(K) = Cx(K) + Du(K)

    MA B

    0 0M

    2 A B

    0 0

    A B

    0 0

    A2

    AB

    0 0= = =

    M3 A3

    A2

    B0 0

    = Mi Ai

    Ai 1

    B0 0

    =

    eMT A

    iA

    i 1B

    0 0i 1=

    1

    i!---=

    I 00 0

    +

    eMT e

    AT Ai 1

    B

    i!----------------

    i 1=

    0 0

    eAT A

    i

    i!-----

    i 1=

    A1B

    0 0

    = =

    eAT

    eAT

    I( )A1B

    0 0=

    eA B T Ad

    ZOHBd

    ZOH

    =

  • 8/12/2019 CD Reference

    34/114

    Control Design and Simulation Module Algorithm Reference 34 ni.com

    Initial Conditions: For the initial condition, as the zero order hold makes the

    response causal, you get the following:

    and the initial conditions are not a function of the inputs at t = 0. In

    summary you have:

    When going from discrete to continuous, you solve for the continuous set

    of system matrices, as shown in the following:

    State-Space Norm

    The CD Norm VI calculates two types of normsthe 2-norm and the

    infinity-norm.

    2-normFor stable systems, the following procedure outlines the steps for

    computing the 2-norm.

    For continuous systems, when you solve AX+ XAT+ BBT= 0 for X, you

    get the following norm and frequency.

    Frequency = NaN

    xdZOH

    0( ) x 0( ) Ou 0( )+ ICMAT I O==

    BdZOH

    eAcT

    I( )Ac1Bc=

    AdZOH

    eAcT

    =

    CdZOH

    C=

    DdZOH

    D=

    AclnAd

    ZOH

    T------------------=

    Bc Ac eAT

    I( )1Bd

    ZOH=

    Ac AdZOH

    I( )1Bd

    ZOH=

  • 8/12/2019 CD Reference

    35/114

    National Instruments Corporation 35 Control Design and Simulation Module Algorithm Reference

    where Gis the transfer function matrix.

    For discrete systems, when you solve AXAT X+ BBT= 0 for X, you get

    the following norm and frequency.

    Frequency = NaN

    If the system is unstable, the CD Norm VI produces an error. In this case,

    the norm is and frequency is NaN. Systems with also have asthe norm and NaNas the frequency.

    Infinity-normThe procedure for computing the infinity-norm is different for SISO

    systems and MIMO systems.

    SISO SystemsFor SISO systems, the CD Norm VI converts a state-space model to a

    transfer function model.

    Create frequency vector. For example, a vector of i.

    Compute the norm according to the following formula.

    MIMO SystemsCreate frequency vector. For example, a vector of i.

    For each i, compute the USVT decomposition of H(ji)

    Use this to compute the norm according to the formula,

    Marginally stable systems have -norm of infinity.

    G 2 Trace CX CT( )=

    G 2 Trace CXCT DD T+( )=

    D 0

    G arg maxi

    arg iI A( )( )=

    G arg maxi

    ma x S H ji( )( )( )( )=

  • 8/12/2019 CD Reference

    36/114

    Control Design and Simulation Module Algorithm Reference 36 ni.com

    For the generation of the frequency vector, the continuous function is

    approximated by multiple evaluation at grid points. The grid is a geometric

    sequence, adjusted based on whether you are dealing with the continuous

    domain (j) or discrete domain (ejT).

    References:

    Doyle, J. C., K. Glover, P. P. Khargonekar, and B. A. Francis. State space

    solutions to standard H2 and Hcontrol problems. IEEE Transaction onAutomatic Control, vol. 34, no. 8, p. 83, 1989.

    Robel, A. On computing the infinity norm. IEEE Transaction on Automatic

    Control, vol. 34, no. 8, p. 882, 1989.

    Lyapunov Equation Solver

    The Lyapunov equation is defined by the following equation.

    AX+ XB= C

    The implementation of a solver for this algorithm is based on the Bartels

    Stewart algorithm.

    The following procedure outlines the steps for computing the Lyapunov

    algorithm.

    1. Compute the real Schur decomposition of A. For example, UTAU= R.

    2. Compute the decomposition for B. For example, VTBTV= S.

    3. Construct a matrix F= UTCV.

    4. Solve RY+ YST= Fas a Sylvester equation.

    5. Compute the Lyapunov solution X= UYVT.

    References:

    R. H. Bartels and G. W. Stewart.Algorithm 432: Solution of the matrix

    equation AX + XB = C. Communications of the ACM, September 1972.

    G.H. Golub, S. Nash, and C. Van Loan.A Hessenberg Schur Method for the

    problem AX + XB = C. IEEE Transaction on Automatic Control, December

    1979.

  • 8/12/2019 CD Reference

    37/114

    National Instruments Corporation 37 Control Design and Simulation Module Algorithm Reference

    Discrete Lyapunov Equation SolverThe Continuous Lyapunov equation is

    where

    If (I A1)1exists and then Ais defined as follows.

    A= (I+ A1)1(I+ A1)

    and

    A1= (A I) (A+ I)1

    Rewrite the continuous Lyapunov equation as follows:

    (A+ I)H(AH I)X+ X(A I)(A+ I)1= C1

    Rearranging the equation results in the following equation:

    Let

    This equation yields

    AHXA X= C

    This equation is the discrete Lyapunov equation.

    Therefore, to solve the discrete equation, use the continuous solver and set

    A1= (A I) (A+ I)1

    The resulting equation is

    A1H

    X XA 1+ C1=

    C1 C1H=

    AH

    XA X1

    2--- A I+( )

    HC1 A I+( )=

    C 12--- A I+( )HC1 A I+( )=

    C1

    2--- A I+( )

    HC1 A 1+( )=

  • 8/12/2019 CD Reference

    38/114

    Control Design and Simulation Module Algorithm Reference 38 ni.com

    Reference:

    S. J. Hammarling.Numerical solution of the stable, non-negative definite

    Lyapunov equation. IMA J. Numerical Analysis, vol. 2, pp. 303323, July

    1982.

    Hamiltonian Reduction Algorithm for

    Solving Riccati EquationsThe Riccati equation is defined as follows:

    ATX+ XA XBR-1BTX+ Q= 0

    To solve this, in the context of optimal control, begin with the Hamiltonian

    equation.

    H(x(t), u(t), (t), t) = [xT(t)Qx(t) + UT(t)Ru(t)] + T(t) [Ax(t) + Bu(t)]

    From the Euler LaGrange equations ,

    This system matrix is symplectic, which means, if is an eigenvalue, isalso an eigenvalue.

    Let Vbe a modal matrix of the Hamiltonian system.

    The Riccati solution is as follows:

    S(t) = (t)X1(t)

    J+and Jare Jordan blocks containing unstable and stable subpartitions ofthe Hamiltonian matrix.

    As tf, 0, and ,

    X(t) = V12 Z

    1

    2---

    H

    x-------= H

    x------- 0=

    x t( )

    t( )

    A B R1

    BT

    Q AT

    x t( )

    t( )=

    X t( )

    t( )

    V11 V12

    V21 V22

    eJ+ t tf( )

    0

    0 eJ t tf( )

    V11 V12

    V21 V22

    1

    I

    Sf

    =

    eJ+ t tf( )

    eJ t tf( )

    eJ t tf( )

  • 8/12/2019 CD Reference

    39/114

    National Instruments Corporation 39 Control Design and Simulation Module Algorithm Reference

    (t) = V22 Z

    where

    As tf, S(t) becomes

    S(t) = (t) X1(t) = V22 Z[V12 Z]1

    Therefore S0= V22V121

    Numerical solutions involve computing this algorithm on the modal matrix

    of Hfor stable eigenvalues.

    References:

    A.J. Laub.A Schur method for solving algebraic riccati equation. IEEE

    Transaction on Automatic Control, vol. AC24, no. 6, pp. 913921,

    December 1979.

    Uy Loi Ly.Linear Multivariable Control, Course Notes, U. Washington,

    Dec 31, 1996

    Continuous Algebraic Riccati Equation Solver

    The continuous Algebraic Riccati Equation is defined as follows:

    ATX+ XA (XB+ S)R1(BTX+ ST) + Q= 0

    Using the Hamiltonian reduction algorithm to solve this equation, the

    above equation is equivalent to the following equation.

    By applying the following transformations,

    A= A BR1ST

    M= BR1BT

    Q= Q SR1ST

    eJ t tf( )

    *

    z

    V11 V12

    V21 V22

    1

    I

    Sf

    =

    eJ t tf( )

    eJ t tf( )

    AT

    X XA Q+ S RT

    BT

    X XBR 1

    ST

    XBR1

    BT

    X SR1

    ST

    + 0=

  • 8/12/2019 CD Reference

    40/114

    Control Design and Simulation Module Algorithm Reference 40 ni.com

    the continuous Algebraic Riccati Equation reduces to the following form:

    ATX+ XA XMX+ Q= 0

    This form of the continuous Algebraic Riccati Equation can be solved by

    the Hamiltonian reduction procedure, as inHamiltonian Reduction

    Algorithm for Solving Riccati Equationssection.

    Discrete Algebraic Riccati Equation SolverThe equation that is being solved is

    (A BR1ST)TX(A BR1ST) (A BR1ST)XB(BTXB+ R)1BTX(A BR1ST) + Q SR1ST= X

    By making the following two transformations

    F= A BR1S, G1= B, G2= R

    and

    H= Q SR1S,

    then the equation reduces to

    FTXF X FTXG1(G2+ XG1)1 XF+ H= 0

    As seen in the references, this equation has the symplectic matrix, similar

    to Hamiltonian matrix in the Continuous Algebraic Riccati Equation Solver

    section.

    Then this algorithm uses a basis for the stable eigenspace of Zto compute

    the desired Riccati solution, using the same procedure as in the

    Hamiltonian Reduction Algorithm for Solving Riccati Equationssection.

    References:

    T. Pappas, A. J. Laub, N. R. Sandell. On the numerical solution of the

    discrete time algebraic riccati equation, IEEE Transaction on Automatic

    Control, Vol AC25, No. 4, pp. 631641, Aug 1980.

    G G1G21

    G1T

    =

    G1T

    G1T

    Z F GF

    TH+ G F

    T

    FT

    H FT

    =

  • 8/12/2019 CD Reference

    41/114

    National Instruments Corporation 41 Control Design and Simulation Module Algorithm Reference

    A. J. Laub.A Schur method for solving algebraic riccati equations.IEEE

    Transaction on Automatic Control, Vol AC24, No. 6, pp. 913921,

    Dec 1979.

    Convert State-Space Model to Transfer Function Model

    Consider the following transfer function matrix.

    H(s) = C(sI A)1B+ D

    If you begin with

    you obtain

    Transposing this equation gives you H(s). The expression is then evaluated

    for each input-output pair and the result is transposed.

    Reference:

    C. Chen.Linear System Theory and Design. pp. 90 91. Oxford University

    Press.

    Covert Transfer Function Model to State-Space ModelConsider the following strictly proper MIMO transfer function model.

    To convert the whole transfer function model into a state-space model,consider the first outputy1.

    sI A BC+( ) sI A( ) DT sI A( )+sI A

    -----------------------------------------------------------------------------------------------

    BC

    sI A--------------- DT+

    y1

    y2

    :

    ym

    G11 G12 G1l

    G21 G2l

    :

    :

    Gm1 Gml

    u1

    u2

    :

    ul

    =

    y1 G1iui

    i 1=

    l

    y1 ii 1=

    l

    = =

  • 8/12/2019 CD Reference

    42/114

  • 8/12/2019 CD Reference

    43/114

    National Instruments Corporation 43 Control Design and Simulation Module Algorithm Reference

    Transmission Zeros (State-Space)

    Consider the following state-space model

    and the following transfer function matrix

    H(s) = C(sI A)1B+ D

    This algorithm allows you to compute the zeros of this transfer function

    matrix.

    To get the zeros, solve a generalized eigenvalue problem of the form

    Mx = Nx where

    When Mand Nare square matrices and the dimensions match, this problem

    is solved directly by using the Analysis VIs. When the dimensions of the

    matrices do not match, the algorithm creates matrices M1and M2by using

    random numbers to pad the matrix with a smaller dimension.

    Then, if a transmission zero corresponds to original system, it has to be

    (with probability close to 1) a zero of both M1and M2.

    The algorithm picks the zeros based on the following criteria where

    z1= set of zeros of M1

    z2= set of zeros of M2

    For each element in z1, select the closest element in z2and set distance as d.

    If d < threshold, meaning d is 1020times the norm of M, then the element

    is a transmission zero of M.

    References:

    A.J. Laub and B. C. Moore. Calculation of transmission zeros using QZ

    techniques. Tech report ESL-P-802.

    A. S. Hodel. Computation of system zeros with Balancing. Linear Algebra

    and its Applications. 188, 189: 423436, 1993.

    x Ax Bu+=

    y Cx Du+=

    M A B

    C D= N

    In

    0

    0 0=

  • 8/12/2019 CD Reference

    44/114

    Control Design and Simulation Module Algorithm Reference 44 ni.com

    Pade Approximation of Delayfor a SISO Transfer Function Model

    The objective of the CD Convert Delay with Pade Approximation VI is to

    approximate a delay of by using a polynomial approximation. To

    approximate the exponential, use the following rational polynomial.

    Rpq(z) = Dpq(z)1Npq(z)

    where

    and

    When approximating time delays,

    where

    k = 0 N = 1

    k = 1 N =

    k= 2 N =

    etc.

    is defined as the order of the polynomial.

    The function sequentially computes the terms and takes the sum of products

    (from k = 0 to p). Finally, the denominator is made monic and incorporated

    back into the model.

    e std

    Npq z( ) p q k+( )!p!

    p q+( )!k! p k( )!-------------------------------------------

    k 0=

    p

    zk

    =

    Dpq z( )p q k+( )!q!

    p q+( )!k! q k( )!-------------------------------------------

    k 0=

    q

    z( )k

    =

    Npq Ts s( )p q k+( )!p!

    p q+( )!k! p k( )!-------------------------------------------

    k 0=

    p

    Ts( )ks

    k=

    1

    2--- Tss

    12 2 2 1( )------------------------------- T( )s

    2s

    2( )

  • 8/12/2019 CD Reference

    45/114

    National Instruments Corporation 45 Control Design and Simulation Module Algorithm Reference

    Reference:

    G.H. Golub and C.F. Van Loan.Matrix Computations, 3rd ed.,

    pp. 572573. Baltimore, MD: Johns Hopkins University Press, 1996.

    Root Locus Plots

    Consider the closed-loop transfer function of a linear time-invariantsystem.

    The characteristic equation is

    1 + D(s)G(s)H(s) = 0

    You can rewrite this equation as

    1 + KL(s) = 0 where .

    K is some parameter that enters the characteristic equation linearly.

    The following are some alternate ways to represent the same equation.

    (s) = D(s) + K(s)N(s) = 0

    Then, because , D'(s)N(s) D(s)N'(s) = 0.

    The roots sof this equation would solve the equation

    such that if for any s,

    then that value of sis also a root of (s).

    Each of these properties are used in various ways in this algorithm.

    T s( ) Y s( )

    R s( )-----------

    D s( )G s( )1 D s( )G s( )H s( )+---------------------------------------------= =

    L s( ) N s( )

    D s( )-----------=

    ds K( )dk

    --------------dK s( )

    ds-------------- 1=

    K D s( )

    N s( )-----------=

    K D s( )

    N s( )-----------=

  • 8/12/2019 CD Reference

    46/114

    Control Design and Simulation Module Algorithm Reference 46 ni.com

    The high level structure of the algorithm is as follows:

    1. Determine bifurcation points, for example, the roots of the equation

    D'(s)N(s) D(s)N'(s) = 0.

    Verify that these points are indeed bifurcation points by checking the

    equation

    to make sure it is real, which means the bifurcation point lies on the

    real axis, etc.

    2. Perform pole-zero cancellations to derive the minimal system for

    analysis.

    3. Determine the maximum gain required for plotting (and some

    additional parameters).

    To get the maximum gain, notice that the nature of the root locus is

    such that roots move from poles to zeros. If you evaluate the following

    equation at the zero,

    you get an idea of the final gain required to visually depict this path. If

    you look at this value for each zero of the system, you get an idea of

    what the appropriate, final gain Kf, for the entire plot. Use a default Kf

    for systems with no zeros. The largest pole/zero/bifurcation point also

    is used to determine the extent of the axes for the plots.

    4. Once you know the final gain value, you create a grid of gain values

    based on the geometric series, and iteratively refine this grid, until theplot is estimated to be visually correct. Here you use some specialized

    heuristics based on interpoint distances.

    Lastly, you fill in the appropriate infinity and special points for the

    plots.

    References:

    A.M. Krall and R. Fornaro.An Algorithm for Generating Root Locus

    Diagrams. Communications of the ACM, Vol. 10, No. 3, pp. 186188,

    Mar 1967.

    T. O. e Silva.Automatic Generation of Root Locus Plots. Revista DoDetua, Vol 2, No. 3, pp. 273278, Sept 1998.

    K D s( )

    N s( )

    -----------=

    D s( )N s( )-----------

  • 8/12/2019 CD Reference

    47/114

    National Instruments Corporation 47 Control Design and Simulation Module Algorithm Reference

    Bode, Nyquist, and Nichols Analysis

    Consider the transfer functionH(s).

    When you apply a sinusoidal input as

    x(t) =Xsin(t)

    For linear time-invariant systems, the output is

    y(t) = Ysin(t + )

    Define

    as the magnitude or input ratio and

    as the phase shift of the output sinusoid with respect to the input sinusoid.

    If you repeat this operation for all the possible frequencies, you obtain a

    magnitude and phase shift for each frequency, creating the frequency

    response of the system.

    The frequency response is obtained by transforming from the s-domain to

    thejdomain:

    H(s) =H(j) =M(j)ej(j)

    where

    and

    H s( ) Y s( )

    x s( )----------=

    G j( ) Y

    X---=

    /G j( )imag G j( )( )real G j( )( )

    --------------------------------atan= =

    M j( ) Y j( )X j( )---------------=

    j( ) /Y j( ) /X j( )=

  • 8/12/2019 CD Reference

    48/114

    Control Design and Simulation Module Algorithm Reference 48 ni.com

    For discrete systems, the frequency response is obtained by the

    transformationz= ejT.

    H(z) =H(ejT) =M(ejT)ej(j)T

    If the system is a multiple-input multiple-output (MIMO) system, this

    process is repeated for each input-output pair.

    It is possible to visualize the frequency response in three types of plots.

    The Bode plot is composed by two plots that shows the magnitude (in linear

    or dB scale) against frequency and phase (degree) against frequency.

    Nichols Plot is a graph that shows the magnitude (in dB) of the frequency

    response of the input system plotted against its phase (in degrees).

    Nyquist Plot is a graph that shows the imaginary part of the complex

    frequency response of the input system plotted against its real part.

    The algorithm used to evaluate the frequency response of a transfer

    function is based on following steps:

    1. Create a vector of frequencies that capture the relevant dynamics of the

    system. This vector spans a frequency band that includes three decades

    around the relevant natural frequencies of the system.

    2. Evaluate the transfer function at each frequency and obtain the

    magnitude and phase of the signal for each frequency.

    For continuous systems:

    where:

    n = number of zeros at zero in the complex plane

    m = number of poles at zero in the complex plane

    num1 = numerator polynomial without the roots at zeroden1 = denominator polynomial without the roots at zero

    This algorithm corrects the initial frequency of the Bode response to

    start at the correct angle.

    M num j( )

    den j( )----------------------=

    0num1 j( )den1 j( )-------------------------

    jn

    jm

    ---------+atan=

  • 8/12/2019 CD Reference

    49/114

    National Instruments Corporation 49 Control Design and Simulation Module Algorithm Reference

    For discrete systems:

    3. Correct phase for wrapping and transport delay:

    For continuous:

    = 0 delay= 0Tdelay

    For discrete:

    = 0delay= (0TdelayTd)

    4. Repeat the operation for each input-output pair of the MIMO system.

    5. Correct the result for units.

    The frequency, magnitude, and phase are calculated in radians/seconds,

    linear, and radians, respectively. If you need the result in hertz, decibels, or

    degrees, use one of the following conversions:

    = 2f

    Mdb = 20log (M)

    degree= 180/

    All Margins (Linear System)The algorithm used for the CD All Margins VI is based on the calculation

    of the frequency response, where it computes the frequency at which the

    phase crosses 180, gm, for a system,H(s):

    The corresponding gain margin at gmis calculated as:

    gain margin (dB) = 0 20log10|H(jgm)

    The algorithm is based on the following steps:

    1. Generate a frequency response for system using the Bode algorithm.

    Refer to theBode, Nyquist, and Nichols Analysissection for

    information about the Bode algorithm.

    M num jd( )den jd( )-------------------------=

    0num1 jd( )den1 jd( )----------------------------

    atan=

    180

    --------- H j( )

    gm= 180=

  • 8/12/2019 CD Reference

    50/114

    Control Design and Simulation Module Algorithm Reference 50 ni.com

    2. In the magnitude response, calculate all crossovers for phase 180

    (2k+ 1). Using bisection algorithm, obtain the crossover frequency

    and gain. This will define all the Frequencies and Gain Margins of the

    system.

    3. In the phase response, calculate all crossovers for magnitude equal to

    1 (0 dB) and using bisection algorithm obtain the crossover frequency

    and phase. This will define all the Frequencies and Phase Margins of

    the system.

    Gain and Phase Margin (Linear System)

    The CD Gain and Phase Margin VI is based on the CD All Margin VI

    algorithm. The response of the CD Gain and Phase Margin VI is defined as:

    Gain margin (dB) is smallest gain margin of the system.

    Frequency (radians/seconds) is the nearest crossover frequency of 180

    (2k + 1), where k = 0, 1, 2 corresponding to the smallest gain margin.

    Phase margin (degrees) is the smallest phase margin of the system.

    Frequency (radians/seconds) is the 0 dB crossover frequency

    corresponding to the smallest phase margin.

    Staircase

    Reference:

    Web Site of Math Department of Escuela Politecnica Nacional, Ecuador,Staircase Algorithm. http://epn.edu.ec/~fc/dpto_mat/pdf/

    staircase.pdf

    Kalman Gain

    The CD Kalman Gain VI uses the derivation found in the following

    references.

    Kwakernaak, H. & Sivan, R.,Linear Optimal Control Systems.

    Wiley-Interscience, 1972.

    Ogata, K.,Discrete-Time Control Systems. Englewood, NJ: Prentice-Hall,

    1987.

  • 8/12/2019 CD Reference

    51/114

    National Instruments Corporation 51 Control Design and Simulation Module Algorithm Reference

    Ackermann

    The CD Ackermann VI uses the derivation found in the following

    reference.

    Ogata, K.,Discrete-Time Control Systems. Englewood, NJ: Prentice-Hall,

    1995.

    State Estimator and State-Space Controller

    Refer to theLabVIEW Control Design User Manualfor information about

    the implementation of the CD State Estimator VI and CD State-Space

    Controller VI.

    Generating Correlated Gaussian Random Vectors

    Problem Statement

    We need to generate random samples (denoted as x andy) of the random

    vectorsxRnandyRmsuch that the random vectorsxandyareGaussian-distributed and are characterized by the second-order statistics:

    E{x} =mxCov{x} = Cxx=E{xxT} mxmxT

    E[y} =my

    Cov{y} = Cyy=E{yyT} mymy

    T

    Cov {x,y} = Cxy=E{xyT} mxmyT

    SolutionLets first focus on the problem of generating random samples of a single

    Gaussian random vectorxwith mean mx and covariance matrix Cxx. Then,we will generalize the solution to generating random samples of the two

    vectorsXand Y.

    Single Vector CaseSay we are able to generate one sample of the Gaussian random variable z

    (denoted as ) such that z is characterized by the statistics z ~ N (mz = 0,z

    2 = 1).

    Now, lets generate n-independent samples {1, 2, ..., n}of the randomvariables {z1, z2, ..., zn} that are identically distributed as z~N (0, 1).

  • 8/12/2019 CD Reference

    52/114

    Control Design and Simulation Module Algorithm Reference 52 ni.com

    Define

    Czz= Cov{z}

    =E{zzT} mzmzT

    z~N(0, I)

    Define the affine transformation:

    X=Az+b

    whereARnn, b Rn

    Since affine transformation of a Gaussian random vectors yields a Gaussian

    random vector xis Gaussian-distributed.

    We will find the matrixAand the vector b that will generatexsuch thatx~ N(mx, Cxx).

    z

    z1

    z2

    zn

    =

    mz

    00

    0

    =

    1 0 0

    0 1 0

    0 0 1

    I==

    E x{ } E Az b+{ }=

    A=E z{ }

    0=

    b+

    E x{ } b=

  • 8/12/2019 CD Reference

    53/114

    National Instruments Corporation 53 Control Design and Simulation Module Algorithm Reference

    recall, given a real-symmetric matrixMRnnwith Eigenvalues{1, 2,..., n}, then M is similar to a diagonal matrix given by

    under the transformation:

    V1MV=

    where, V= [v1, v2, ..., vn]

    with {v1, v2, ..., vn} being the orthonormal Eigenvectors corresponding tothe Eigenvalues {1, 2, ..., n}

    but, since {v1, v2, ..., vn} for an orthonormal basis for V

    Vis unitary

    VTV=I

    VT= V1

    VTMV=

    M= VVT

    now, if we factor = 1/21/2, and since = T

    1/2= (1/2)T

    M = 1/21/2VT

    Cov x{ } Cov Az b+{ }=

    E Az b+[ ] Az b+[ ]T

    { } E Az b+{ } ET

    Az b+{ }=

    AE zzT

    { }AT

    AE z{ }bT

    bE ZT

    { }AT

    bbT

    ++ +=

    AE z{ } b+[ ] AE z{ } b+[ ]T

    A Czz

    I

    AT

    bbT

    bbT

    +=

    Cxx A AT

    =

    1 0 0

    0 2

    0

    0 0 n

    =

  • 8/12/2019 CD Reference

    54/114

  • 8/12/2019 CD Reference

    55/114

    National Instruments Corporation 55 Control Design and Simulation Module Algorithm Reference

    transformation w=Az+b. Finally, taking the first n-elements of the randomvector sample wgives the random vector sample x and taking the lastm-elements of the random vector sample wyields the random vectorsampley.

    Implementation Current Observer (Point-by-Point)

    @ time k = 0: is already available.

    Calculate thepredictedstate :

    @ time k: is already available.

    A new measurement becomes available.

    Calculate the corrected/currentstate

    Calculate thepredicted state :

    Relationship between Lpand Lc:

    The Current Gainmatrix Lcis related to the Predicted Gainmatrix Lp

    through the relationship.

    this means that Ad needs to be full-rank.

    Algorithm adapted from:

    Franklin, Powell, Workman, Digital Control of Dynamic Systems, 3rd.

    Ed., pp. 295

    x 0( )

    x 1( )

    x 1( ) Ad x 0( ) Bd u 0( )+=

    x 1( ) Ad x 0( ) Bd u 0( )+=

    x k( )

    y k( )

    x k( )

    x k( ) x k( ) Lc y k( ) y k( )[ ]+=

    y k( ) Cdx k( ) Ddy k( )+=

    x k 1+( )

    x k 1+( ) Ad x k( ) Bd u k( )+=

    Lp Ad Lc=

  • 8/12/2019 CD Reference

    56/114

  • 8/12/2019 CD Reference

    57/114

    National Instruments Corporation 57 Control Design and Simulation Module Algorithm Reference

    The observer gain (L) can be computed through pole-placement or

    Ackermann.

    Algorithm adapted from:

    John Bay, Fundamentals of Linear State Space Systems, McGraw Hill,

    1999.

    ContinuousTime Recursive Kalman-Bucy Filter

    Note The following derivation assumes the familiarity of the reader with basic concepts

    of Estimation Theory and Linear Algebra. Much of the derivations herein follows the

    developments outlined in the following references:

    1. I. Rhodes, A Tutorial Introduction to Estimation and Filtering, IEEE

    Transactions on Automatic Control, Vol. A C-16, No. 6, December

    1971, pp. 688-706.

    2. Jerry Mendel, Lessons in Estimation Theory for Signal Processing,

    communications, and Control, Prentice Hall, 1995.

    3. John Bay, Fundamentals of Linear State-Space Systems, McGraw

    Hill, 1999.

    Problem StatementGiven the continuous-Time (C.T.) Linear Time-Varying (LTV) stochastic

    state-space system.

    The control input vector is deterministic and known .

    The matrices , , ,

    , , are deterministic and

    known .

    The disturbance vectors and are assumed to be white (i.e.

    zero-mean and temporally uncorrelated) random processes with the

    following first- and second-order statistics.

    x t( ) A t( )x t( ) B+ t( )u t( ) G t( )w t( )+=

    y t( ) C t( )x t( ) D+ t( )u t( ) H t( )w t( ) v t( )+ +=

    u t( ) IRr

    t

    A t( ) IRnx n

    B t( ) IRnx r

    G t( ) IRnx q

    C t( ) IR

    mx n D t( ) IR

    mx r H t( ) IR

    mx q

    t

    w t( ) v t( )

    E w t( ){ } o= t

    cov w t( ) w t( ),{ } E w t( ) wT

    t( ){ } Q t( )s t t( ) Q t( ) QT

    t( ) 0=,==

    E v t( ){ } o= t

  • 8/12/2019 CD Reference

    58/114

    Control Design and Simulation Module Algorithm Reference 58 ni.com

    where is the Dirac delta function.

    Also, it is assumed that the initial state vector is uncorrelated w/ the

    random processes and

    We need to find the best linear estimator in terms of

    the measurements

    SolutionThe best linear estimator of the state vector in terms of the

    measurements has the following dynamical structure:

    Kalman-Bucy Filter Derivation:

    Estimator dynamics structure:

    Estimator Error:

    Error Dynamics:

    cov v t( ) v t( ),{ } E v t( ) vT

    t( ){ } R t( )s t t( ) R t( ) RT

    t( ) 0>=,==

    cov w t( ) v t( ),{ } E w t( ) vT

    t( ){ } N t( )s t t( )==

    S t( )

    x to( )w t( ) v t( ) t

    cov w t( ) x to( ),{ } 0 cov v t( ) x to( ),{ } 0=,=

    x t( ) E*

    x t( ) yt{ }=Yt y s( ) S;( )S to t),[{ , }=

    x t( ) x t( )Yt

    x t( ) A t( )x t( ) B t( )u t( ) L t( ) y t( ) y t( )[ ]+ +=

    y t( ) C t( )x t( ) D t( )u t( )+=

    L t( ) P t( )C

    Tt( ) G t( )Q t( )H

    Tt( ) G t( )N t( )+ +[ ]

    . H t( )Q t( )HT

    t( ) H t( )N t( ) NT

    t( )HT

    t( ) R t( )+ + +[ ]1

    =

    P

    t( ) A= t( )P t( ) P t( )AT

    t( ) G t( )Q t( )GT

    t( )+ +

    P t( )C t( ). H t( )Q t( )HT

    t( ) H t( )N t( ) NT

    t( )HT

    t( ) R t( )+ + +[ ]1.C t( )P t( )

    G t( )Q t( )HT

    t( ) G t( )N t( )+[ ]. H t( )Q t( )HT

    t( ) HtN t( ) NT

    t( )HT

    t( ) R t( )+ + +[ ]

    . G t( )Q t( )HT

    t( ) G t( )N t( )+[ ]T

    x t( ) Ax t( ) Bu t( ) L t( ) y t( ) y t( )[ ]+ +=

    y t( ) Cx t( ) Du t( )+ +

    e t( ) x= t( ) x t( )

  • 8/12/2019 CD Reference

    59/114

    National Instruments Corporation 59 Control Design and Simulation Module Algorithm Reference

    Covariance of estimation error:

    e t( ) x t( ) x t( )=

    Ax t( ) Bu t( ) Gw t( )+ +=

    Ax t( ) Bu t( ) Lt yt Cx t( ) Du t( )[ ]+ +[ ]

    e t( ) Ae t( ) Gw t( )+=

    L t( ) Cx t( ) Du t( ) Hw t( ) v t( ) Cx t( ) Du t( )+ + +[ ]

    Ae t( ) Gw t( ) L t C e t( ) Hw t( ) v t( )+ +[ ]+=

    e t( ) A LC[ ]e t( ) G LH[ ]w t( ) Lv t( )+=

    e t( ) t to,( )e to( ) t ,( ) G LH( )w ( ) Lv ( )[ ] d

    to

    t

    +=

    P t( ) E e t( ).eT ( ){ } E e t( ){ }0

    . E

    T

    e ( ){ }0

    =

    E t to,( )e to( ) t ,( ) G LH( )w t( ) Lv t( )[ ] td

    to

    t

    +

    =

    . t to,( )e to( ) t s,( ) G LH( )w s( ) Lv s( )[ ] sd

    to

    t

    +

    T

  • 8/12/2019 CD Reference

    60/114

    Control Design and Simulation Module Algorithm Reference 60 ni.com

    E t to,( )e to( )eT

    to( )T

    t to,( ){ }=

    E t to,( )e to( ). t s,( ) G LH( )w s( ) Lv s( )[ ] sd

    to

    t

    T

    +

    E t ,( ) G LH( )w ( ) Lv ( )[ ] t.e to( ).T t to,( )d

    to

    t

    +

    E t ,( ) G LH( )w ( ) Lv t( )[ ] td

    to

    t

    . G LH( )w s( ) Lv s( )[ ]T

    Tt to,( ) sd

    to

    t

    +

    t( ) t to,( )P to( )T

    t to,( )=

    E t ,( ) G LH( )w t( ) Lv t( )[ ] G LH( )w s( ) Lv s( )[ ]T

    Tt s,( ) d d

    to

    t

    to

    t

    +

    t to,( )P to( )T

    t to,( )=

    t ,( )E G LH( )w ( ) Lv ( )[ ] wT

    s( ) G LH( )T

    vT

    s( )LT

    [ ]{ }T

    t s,( ) d

    to

    t

    to

    t

    +

    t to,( )P to( )T

    t to,( )=

    t ,( ) G LH( )Q t( )s t s( ) G LH( )T

    G LH( ) N ( )s s( )LT

    [

    to

    t

    to

    t

    +

    LNT

    ( )s s( ) G LH( )T

    LR ( )s s( )+ ]T

    t s,( )d

    t to,( )P to( )T

    t to,( )=

    t ,( ) G LH( )Q ( ) G LH( )T

    G LH( ) N( )LT

    [

    to

    t

    +

    LNT

    ( ) G LH( )T

    LR LT

    + ]T

    t ,( )d

  • 8/12/2019 CD Reference

    61/114

    National Instruments Corporation 61 Control Design and Simulation Module Algorithm Reference

    recall:

    denote:

    but,

    P t( ) t to,( )P to( )T

    t to,( )=

    t ,( ) G LH( )Q ( ) G LH( )T

    G LH( ) N ( )LT

    [

    to

    t

    +

    LNT

    ( ) G LH( )T

    LR LT

    + ]T

    t ,( )d

    d

    dt----- f

    g t( )

    h t( )

    x t,( )dx

    t

    f x t,( ){ } x f h t ( ) t,( )[ ]+d h t( )d

    dt------------

    g t( )

    h t( )

    =

    f g t( ) t,[ ] g t( )d

    dt------------

    Z G LH( )Q ( ) G LH( )T

    G LH( )N ( )LT

    LN ( ) G LH( )T

    =

    LR LT

    +

    t( )

    t to,( )P to( )

    Tt to,( ) t to,( ) to( )

    Tto( )+=

    t ,( )ZT

    t ,( ) t ,( )Z t ,( )

    +

    d

    to

    t

    +

    t ,( )

    IZ

    t ,( )

    IT

    dt

    dt-----

    t to,( )ZT

    t to,( )dt odt--------

    0=

    0=

    +

    t to,( )P to( )T

    t to,( ) t to,( )P to( ) T

    t to,( )+=

    t ,( )ZT

    t ,( ) t ,( )Z T

    t ,( )+ d

    to

    t

    +

    Z+

    e t( ) A LC[ ]e t( ) G LH[ ]w t( ) Lv t( )+=

    t to,( ) state transition mtx for above D.E.=

  • 8/12/2019 CD Reference

    62/114

    Control Design and Simulation Module Algorithm Reference 62 ni.com

    >Different Riccati Equation.

    Now, to optimize the Gain , the chosen criterion will be to minimize

    the squared estimation error.

    t to,( ) A LC[ ] t to,( )=

    t( ) A LC[ ] t to,( )P to( )

    Tt to,( )=

    t to,( )P to( )T

    t to,( ) A LC[ ]T

    +

    A LC[ ] t ,( )ZT

    t ,( ) d

    to

    t

    +

    t ,( )ZT

    t ,( ) A LC[ ]T

    d

    to

    t

    +

    Z+

    A LC[ ] t to,( )P t to,( )T

    t to,( ) t ,( )ZT

    t ,( ) d

    to

    t

    +=

    t to,( )P to( )T

    t to,( ) t ,( )ZT

    t ,( ) d

    to

    t

    +

    P t( )

    A LC[ ]T

    +

    Z+

    P

    t( ) A LC[ ]P t( ) P t( ) A LC[ ]T

    Z+ +=

    t( ) A LC[ ]P t( ) P t( ) A LC[ ]

    T

    +=

    G LH[ ]Q t( ) G LH[ ]T

    G LH[ ]N t( )LT

    LNT

    t( ) G LH[ ]T

    LR t( )LT

    + +

    L t( )

    Ee

    Tt( ).e t( )

    scalar

    tr E eT

    t( ).e t( ){ }[ ]=

    E tr eT

    t( ).e t( )[ ]{ }=

    E tr e t( ).eT

    t( )[ ]{ }=

    tr E e t( ).eT

    t( ){ }[ ]=

    tr P t( )[ ]=

  • 8/12/2019 CD Reference

    63/114

    National Instruments Corporation 63 Control Design and Simulation Module Algorithm Reference

    ma x

    L t( )tr P

    t( )[ ]{ }

    L t( )

    tr{ } P t( )[ ]

    L t( )

    tr{ } P

    t( )[ ]L

    AP LC P PAT

    PCTL

    T+

    GQ GT

    GQ HTL LHQGT LHQHTL+ +

    GN LT

    LHNLT

    LNT

    GT

    + LNTHTLT=

    LR LT

    +

    =

    .x

    tr XAT

    [ ]{ } A=

    .x

    tr XTA[ ]{ } A=

    .x

    tr AB AT

    [ ]{ } AB ABT

    +=

    1L

    tr LC P[ ]{ } CP( )T

    PT

    CT

    = =

    2L

    tr PCTL

    T[ ]{ }

    L

    tr LT

    CPT

    [ ]{ } PCT

    = =

    3L tr GQ H

    TL

    T[ ]{ }

    L tr L

    TGQ H

    T[ ]{ } GQ H

    T= =

    4L

    tr LHQGT

    [ ]{ } HQ GT

    ( )T

    GQTH

    T= =

    5L

    tr LHQHTL

    T[ ]{ }

    LHQHT

    L HQ HT

    ( )T

    +=

    LH QHT

    LH QTH

    T+=

    6L tr GN LT[ ]{ }

    L tr LTGN[ ]{ } GN= =

    7L

    tr LHNLT

    [ ]{ } LHN L HN ( )T

    + LHN LN TH

    T+= =

  • 8/12/2019 CD Reference

    64/114

    Control Design and Simulation Module Algorithm Reference 64 ni.com

    substituting for into :

    8L

    tr LNT

    GT

    [ ]{ } NT

    GT

    ( )T

    GN= =

    9L

    tr LNTH

    TL

    T[ ]{ }

    LNTH

    TL N

    TH

    T( )

    T+=

    LNTH

    TLH N+=

    10 L

    tr LRL

    T

    [ ]{ } LR LRT

    +=

    now,L

    tr P

    t( )[ ]{ } 0

    PCT

    PCT

    GQ HT

    GQ HT

    LHQHT

    + LHQHT

    =

    GN LHN LN TH

    TGN LN

    TH

    TLH N LR LR 0+ + + + + +

    2PCT

    2GQ HT

    2LH QHT

    2GN 2LH N 2LNTH

    T2LR 0+ + + +

    LH QHT

    LNTH

    TLR LH N PC

    TGQ H

    TGN+ ++ +=

    L HQ HT

    R HN NTH

    T+ + +[ ] PC

    TGQ H

    TGN+ +

    L t( ) PCT

    GQ HT

    GN+ +[ ]. HQ HT

    HN NTH

    TR+ + +[ ]

    1=

    L t( ) P

    t( )

    t( ) AP LCP PA T PCTLT+=

    GQ GT

    GQ HTL

    T LHQG

    T LHQH

    TL

    T+ +

    GN LT

    LNT

    GT

    LHNLT

    LNTH

    TL

    T+ +

    LR LT

    +

    AP LC P PAT

    PCTL

    T+=

    GQ GT

    GQ HTL

    T LHQG

    T GN L

    T LN

    TG

    T+

    L HQ HT

    HN NTH

    TR

    T+ + +[ ]+

    P

    t( ) AP PAT

    GQ GT

    +=

    L CP HQ GT

    NT

    GT

    +( )[ ]

    PCT

    GQ HT

    GN+ +[ ]

  • 8/12/2019 CD Reference

    65/114

    National Instruments Corporation 65 Control Design and Simulation Module Algorithm Reference

    P t( ) AP PA GQG + +=

    L CP HQ GT

    NT

    GT

    + +[ ]

    1

    PCT

    GQ HT

    GN+ +[ ]LT

    2

    L HQHT HN NTHT R+ + +[ ]LT

    3

    +

    1 PCT

    GQ HT

    GN+[ ] HQ HT

    HN NTH

    TR+ + +[ ]

    1. CP HQG

    TN

    TG

    T+ +[ ]

    2 PCT

    GQ HT

    GN+[ ]. HQ HT

    HN NTH

    TR+ + +[ ]

    1[ ]

    T. PC

    TGQ H

    TGN+ +[ ]

    T

    PCT

    GQ HT

    GN+[ ] HQ HT

    HN NTH

    TR+ + +[ ]

    T[ ]

    1CP HQG

    TN

    TG

    T+ +[ ]=

    PCT

    GQ HT

    GN+[ ] HQ HT

    HN NTH

    TR+ + +[ ]

    1CP HQG

    TN

    TG

    T+ +[ ]=

    3 PCT

    GQ HT

    GN+[ ]. HQ HT

    HN NTH

    TR+ + +[ ]

    1

    . HQ HT

    HN NTH

    TR+ + +[ ]

    . HQ HT

    HN NTH

    TR+ + +[ ]

    1[ ]

    T. PC

    TGQ H

    T GN+[ ]

    T

    PCT

    GQ HT

    GN+[ ]= . HQ HT

    HN NTH

    TR+ + +[ ]

    1CP HQG

    TN

    TG

    T+ +[ ]

    1 2 3+ + 1=

    P t( ) AP PAT

    GQ GT

    + +=

    PCT

    GQ HT

    GN+ +[ ] . HQ H

    THN N

    TH

    TR+ + +[ ]

    1

    . CP HQG T

    NT

    GT

    + +[ ]

    AP PA GQ GT

    PCT

    GQ HT

    GN+ +[ ].. HQ GT

    NT

    GT

    +[ ]+ +=

    AP PA GQ G

    T

    PC

    T

    CP GQH

    T

    GN+[ ].

    . HQ G

    T

    N

    T

    G

    T

    +[ ]+ +=

    P

    t( ) AP PAT

    PCT

    [ ] HQ HT

    HN NTH

    TR+ + +[ ]

    1. CP[ ] GQ G

    T+ +=

    GQ HT

    GN+[ ] HQ HT

    HN NTH

    TR+ + +[ ]

    1. GQ H

    TGN+[ ]

    T

  • 8/12/2019 CD Reference

    66/114

    Control Design and Simulation Module Algorithm Reference 66 ni.com

    n-step-Ahead Kalman Predictor

    Note:

    Much of the derivations herein follow the developments in the following

    reference:

    [1] Ian Rhodes, A Tutorial Introduction to Estimation and Filtering,

    IEEE Transactions on Automatic Control, Vol. AC-16, No. 6,

    December 1971, pp. 688706.

    Problem statement:

    Given the Discrete-Time LTV XXXX state-space system:

    Need to find the n-step-ahead Kalman Predictor, i.e. find the state estimate

    given the knowledge of the one-step-ahead

    predicted state and assuming the knowledge of the matrices

    and the central input

    Solution:

    Define,

    Then, we may re-write the state difference equation as:

    Similarly, we may expressxk+ n(n 2) as:

    xk 1+ Akxk Bkuk Gkwk+ +=

    yk Ckxk Dkuk Hkwk vk+ + +=

    x k n+ k E*

    xk n+ Yk{ },=

    x k 1+ k

    Ai{ }i k 1+=k n 1+

    Bi{ }i k 1+=k n 1+

    , ui{ }i k 1+=k n 1+

    .

    k j, Ak 1 Ak 2 Aj =

    j j, I=

    xk 1+ k 1 0,+ x0 k 1 i 1+,+ Biui( ) k 1 i 1+,+ Giwi( )+[ ]

    i 0=

    k

    +=

    xk n+ k n k 1+,+ xk 1+ k n i 1+,+ Biui( ) k n i 1+,+ Giwi( )+[ ]

    i k 1+=

    k n 1+

    +=

  • 8/12/2019 CD Reference

    67/114

    National Instruments Corporation 67 Control Design and Simulation Module Algorithm Reference

    Now:

    but,

    E*{ui| Yk} = ui, since uiis a deterministic input vector.

    since the sequence Yk= {y0,y1, ,yk} depends only and linearly on

    , all of which are assumed uncorrelated

    with .

    If the system is Time-Invariant, then the n-step-ahead Kalman predictorcan be represented more compactly.

    k n k+ E*

    xk n+ Yk{ }=

    k n+ k 1+, E*

    xk 1+ Yk{ }=

    k n i 1+,+ BiE*

    ui Yk{ } k n i 1+,+ GiE*

    wi Yk{ }+[ ]i k 1+=

    k n 1+

    +

    E*

    wi Yk{ } 0 k 1+ i k n 1+ =

    x0{ } wi{ }i 0=k, xi{ }i 0=

    k vi{ }k

    i 0=,,

    wi{ }i k 1+=k n 1+

    x k n k+ k n k 1+,+ x k 1 k+ k n i 1+,+ BiUi

    i k 1+=

    k n 1+

    +=

    xk n k+

    k n+ k 1+,Ak n 1+ Ak n 2+ Ak 1+

    k n 1 k 1+( ) 1+ n 1=+=

    An 1

    =

    k n+ i 1+,

    Ak n 1+ Ak n 2+ Ai 1+

    k n 1 i 1+( ) 1+ k n i 1+=+=

    Ak n i 1+

    =

  • 8/12/2019 CD Reference

    68/114

    Control Design and Simulation Module Algorithm Reference 68 ni.com

    Lyapunov and Sylvester Equations

    The Lyapunov and Sylvester equations are similar in form. Table1-2

    defines both the continuous and discrete versions of each equation.

    These equations differ in the underlying assumptions and meaning

    attributed to the coefficient matricesA,B, and C. These differences ensurecertain properties of the solutionX.

    You can use this set of equations to analyze the stability of systems and

    related applications such as the computation of Grammians, norms, and

    so on. Refer toNumerical Linear Algebra Techniques for Systems and

    Control1for more information about these computations. Refer toRobust

    Pole Assignment via Sylvester Equation Based State Feedback

    Parametrization2for more information about the Sylvester equation.

    The Sylvester equation is the basis for solving both forms of these

    equations. The solution is based on the Bartels-Stewart algorithm, which

    reduces bothAandFto the real Schur form and then performs a backwardsubstitution to complete the solution. The underlying implementation

    of this algorithm uses the Mathematics VIs, which are based on

    BLAS/LAPACK algorithms.

    Complete the following steps to solve the continuous version of the

    Lyapunov equation.

    4. Calculate the Schur decompositions ofAandB.

    UTAU=Rand VTBTV= S

    5. ConstructF= UTCV.

    Table 1-2. Lyapunov and Sylvester Equations

    Equation Continuous Discrete

    Lyapunov AX+XAT+ Q= 0 AXATX+ Q= 0

    Sylvester AX+XB+ C= 0 AXBX+ C= 0

    1 Laub, Alan J., Paul Van Dooren, and R.V. Patel (eds).Numerical Linear Algebra Techniques for Systems and Control.Piscataway, NJ: IEEE Press, 1994.

    2 Varga, A.Robust Pole Assignment via Sylvester Equation Based State Feedback Parametrization. IEEE InternationalSymposium on Computer Aided Control System Design, CACSD'2000. Anchorage, Alaska, 2000.

    x k n k+ An 1

    x k 1 k+ Ak n i 1+

    B Ui

    i k 1+=

    k n 1+

    +=

  • 8/12/2019 CD Reference

    69/114

    National Instruments Corporation 69 Control Design and Simulation Module Algorithm Reference

    6. SolveRY+ YST=Fusing the backward-substitution procedure.

    7. SolveX= UYVT.

    You can apply the same methodology to the discrete version of the

    Lyapunov equation if you complete the following steps:

    1. Consider the continuous Lyapunov equation, .

    2. If (IA1)1exists and ifA= (IA1)1(I+A1) and

    A1= (AI)(A+I)1, the Lyapunov equation is as follows:

    (A+I)T(ATI)X+X(AI)(A+I)1+ C1= 0

    3. If you define the matrix Cwith the following equation:

    4. Rearranging the terms in the above equation produces the following

    discrete equation:

    ATXAX+ C= 0

    Riccati Equations

    The symmetric n nalgebraic Riccati equation for the continuous timecase isATX+XAXMX+ Q= 0.

    The solution of this equation is based on the reduction of a Hamiltonian

    matrix, defined by the following equation:

    If Vis the modal matrix of this Hamiltonian matrix, for stable eigenvalues,you can express Vwith the following equation:

    You then can express the steady state solution of the Riccati equation with

    the following equation:

    A1TX XA 1 C1 0=+ +

    C1

    2--- A I+( )

    TC1 A I+( )=

    H AT

    M

    Q A=

    V V11 V12

    V21

    V22

    =

    X V22V121

    =

  • 8/12/2019 CD Reference

    70/114

    Control Design and Simulation Module Algorithm Reference 70 ni.com

    You can reduce a continuous algebraic Riccati equation,

    ATX+XA (XB+ S)R1(BTX+ ST) + Q= 0, to the simpler form byapplying the following transformations:

    A=ABR1ST

    M=BR1BT

    Q= Q SR1

    ST

    The following equation defines the discrete version of the Riccati equation.

    If , the following equation defines the Hamiltonian matrix

    for this equation.

    You can use this Hamiltonian matrix in a reduction procedure to compute

    the solution of the discrete algebraic Riccati equation.

    If the discrete Riccati equation is defined as follows, you can reduce the

    equation using the Hamiltonian matrix.

    The following transformations reduce the discrete Riccati equation to the

    simpler form based on the determined Hamiltonian matrix.

    A=ABR1ST

    B1=B

    B2=R

    C= QSR1ST

    Convert Continuous Model to Discrete Model with InputDelay

    Problem 1: ZoH discretization with uniform input delay

    ATXA X A

    TXB1 B2 B1

    TXB1+( )

    1B1

    TXA C+ 0=

    B B1B21B1

    T=

    H A BA

    TC+ BA

    T

    A T

    C A T=

    A BR1S

    T( )X A BR

    1S

    T( ) A BR

    1S

    T( )

    TXB B

    TXB R+( )

    1B

    TX A BR

    1S

    T( ) Q SR

    1S

    T+ X=

  • 8/12/2019 CD Reference

    71/114

    National Instruments Corporation 71 Control Design and Simulation Module Algorithm Reference

    = (lm) Tl = 1,2,3...0m

  • 8/12/2019 CD Reference

    72/114

    Control Design and Simulation Module Algorithm Reference 72 ni.com

    which if we employ a ZOH discretization technique will result in capturing

    the input sample for the previous time-step, i.e. u(k1) intoy(k).

    y(k)=Cx(k)+Du(k1)

    +[0]u(k)

    Cd[C D}

    Dd= 0

    Problem 2: ZOH discretization with vectorized input delay.

    li= 1, 2, 3, ...

    0mi,1

    y k( ) C D[ ]x k( ) k( )----------=

    y k( ) Cd k( )x k( ) Ddu k( )+=

    Ad T( ) 1

    0 0=

    Bd 2

    I-----=

    x t( ) Ax t( ) Bu t ( )+=

    y t( ) Cx t( ) Du t ( )+=

    x t( ) Ax t( ) b1 b2 br[ ]

    u1 t 1( )

    u2 t 2( )

    ur t r( )

    +=

    1 l1 m1( )T=

    2 l2 m2( )T=

    r lr mr( )T=

  • 8/12/2019 CD Reference

    73/114

    National Instruments Corporation 73 Control Design and Simulation Module Algorithm Reference

    We will consider the case when li1, 0mi 1, the (li1) delay will be set to the discrete model @ input channel i,

    independently after the discretization is achieved.

    x(k+1) = (T)x(k) + 1u(k-1) + 2u(k)

    (T) = eAT

    where,

    where,

    define the state vector (k) = u(k1)

    y(k) = Cx(k) +Du(k1)

    Problem 3: ZoH discretization with uniform output delay

    1

    1 1,

    1 2,

    1 r,

    [ ]=

    1 i, eA

    d

    miT

    bi=

    1 i, miT( ) i T miT( )=

    miT( ) e mi

    =

    i T miT( ) eA

    d

    0

    T miT

    bi=

    2 2 1, 2 2, 2 r,[ ]=

    2 i, eA

    d

    0

    mi

    bi=

    i miT( )= i miT( ) eA d

    0

    mi

    bi=

    x k 1+( ) k 1+( )--------------------

    x k 1+( )

    T( ) 1

    0 0

    x k( ) k( )----------

    2I-----u k( )+=

    y k( )CD[ ]

    Cd

    x k( ) k( )----------

    x k( )

    0[ ]u k( )+=

  • 8/12/2019 CD Reference

    74/114

    Control Design and Simulation Module Algorithm Reference 74 ni.com

    We will consider the case when j 1, 0 q 1, the (j1) delay will be set to the discrete model independently

    after the discretization is achieved.

    , ,

    y(t) = Cx(t) +Du(t)

    y(kT) = Cx(kT) +Du(kT)

    = Cx(kT(lm)T) +Du(kT(lm)T)

    = Cx[T(k(lm)] +Du[T(k(lm))]

    but,

    to ,

    x t( ) Ax t( ) Bu t( )+=

    y t +( ) Cx t( ) Du t( ) y t( ) Cx t ( ) Du t ( )+=+=

    j q( )T=

    j 1 2 3 , , ,=

    0 q 1

  • 8/12/2019 CD Reference

    75/114

    National Instruments Corporation 75 Control Design and Simulation Module Algorithm Reference

    but, ,

    Note that, u[T(k(1q)] = u[k(1q)]= u(k1+q)

    = u(k-1)

    It can be noted that ~1 ZoH, the input signal u(t) will be sampled @

    time-step kTand the value of the sample is led through time-step (k+1)T.

    So, if we delay the signal by k-1 and then advance the signal by m s.t. weget u(k1+q) we will still be capturing the value of the signal @ time-step

    k1, i.e. u(k1)

    y(kt) = Cx[T(k(1q))] +Du[T(k(1q))]

    y(k) = C[(qt)x(k1) + (qT)u(k1)] +Du(k1)

    u t( ) u k 1( )T[ ]= k 1( )T t k 1 q+( )T kT<

  • 8/12/2019 CD Reference

    76/114

    Control Design and Simulation Module Algorithm Reference 76 ni.com

    y(k) = C[(qT)x(k1) + [C(qT)+D]u(k1)

    y(k+1) = C(qT)x(k) + [C(qT)+D]u(k)

    Note Few of the derivations here follows the development in

    Franklin, Powell, Workman, Digital Control of Dynamic Systems, 3rd.

    Ed., 1998, pp. 110-114.

    Problem 4: ZOH discretization with vectorized output delay

    x k 1+( )y k 1+( )-------------------

    x k 1+( )

    T 0

    C qT( ) 0

    Ad

    x k( )y k( )----------

    x k( )

    C qT( ) D+-------------------------------

    Bd

    u k( )

    u k( )= =

    y k( )0 I[ ]

    Cd

    x k( )y k( )----------

    0[ ]

    Ddu k( )+=

    x t( ) Ax t( ) Bu t( )+=

    y t +( ) Cx t( ) Du t( )+=

    y1 t 1+( )

    y2 t 2+( )

    ym t m+( )

    C1

    C2

    Cm

    x1 t( )

    x2 t( )

    xn t( )

    D1

    D2

    Dm

    u1 t( )

    u2 t( )

    ur t( )

    +=

    y1 t 1+( )

    y2 t 2+( )

    ym t m+( )

    C11x1 t( ) C12x2 t( ) C1nxn t( ) D11u1 t( ) D12u2 t( ) D1rur t( )+ + + + + + +

    C21x1 t( ) C22x2 t( ) C2nxn t( ) D21u1 t( ) D22u2 t( ) D2rur t( )+ + + + + + +

    Cm1x1 t( ) Cm2x2 t( ) Cmnxn t( ) Dm1u1 t( ) Dm2u2 t( ) D2mrur t( )+ + + + + + +

    =

  • 8/12/2019 CD Reference

    77/114

    National Instruments Corporation 77 Control Design and Simulation Module Algorithm Reference

    Define,

    We will only consider the case where .

    Ifj1> 1, the (j11) delay will be set to the discrete model at the output

    channel i, independently after the discretization is achieved.

    y1 t( )

    y2 t( )

    ym t( )

    C11x1 t 1( ) C12x2 t 1( ) C1nxn t 1( )+ + +

    C21x1 t 2( ) C22x2 t 2( ) C2nxn t 2( )+ + +

    Cm1x1 t m( ) Cm2x2 t m( ) Cmnxn t m( )+ + +

    D11u1 t 1( ) D1ru t 1( )+ +

    D21u1 t 2( ) D2ru t 2( )+ +

    Dm1u1 t m( ) Dmru t m( )+ +

    +=

    y1 t( )

    y2 t( )

    ym t( )

    C1x t 1( )

    C2x t 2( )

    Cmx t m( )

    D1u t 1( )

    D2u t 2( )

    Dmu t m( )

    +=

    1 j1 q1( )T=

    2 j2 q2( )T=

    m jm qm( )T=

    j1 1, 2, 3, ...= i 1, 2, ..., m=

    0 q1 1

  • 8/12/2019 CD Reference

    78/114

    Control Design and Simulation Module Algorithm Reference 78 ni.c