Lecture2 Models

download Lecture2 Models

of 40

Transcript of Lecture2 Models

  • 8/2/2019 Lecture2 Models

    1/40

    EE392m - Winter 2003 Control Engineering 2-1

    Lecture 2 - Modeling and Simulation Model types: ODE, PDE, State Machines, Hybrid

    Modeling approaches: physics based (white box)

    input-output models (black box)

    Linear systems

    Simulation

    Modeling uncertainty

  • 8/2/2019 Lecture2 Models

    2/40

    EE392m - Winter 2003 Control Engineering 2-2

    Goals Review dynamical modeling approaches used for control

    analysis and simulation Most of the material us assumed to be known

    Target audience

    people specializing in controls - practical

  • 8/2/2019 Lecture2 Models

    3/40

    EE392m - Winter 2003 Control Engineering 2-3

    Modeling in Control Engineering Control in a

    system

    perspective

    Physical system

    Measurement

    system

    Sensors

    Control

    computing

    Control

    handles

    Actuators

    Physicalsystem

    Control analysis

    perspective

    Control

    computing

    System model Controlhandle

    model

    Measurement

    model

  • 8/2/2019 Lecture2 Models

    4/40

    EE392m - Winter 2003 Control Engineering 2-4

    Models Model is a mathematical representations of a system

    Models allow simulating and analyzing the system Models are never exact

    Modeling depends on your goal

    A single system may have many models

    Always understand what is thepurpose of the model

    Large libraries of standard model templates exist

    A conceptually new model is a big deal

    Main goals of modeling in control engineering

    conceptual analysis

    detailed simulation

  • 8/2/2019 Lecture2 Models

    5/40

    EE392m - Winter 2003 Control Engineering 2-5

    ),,(

    ),,(

    tuxgy

    tuxfx

    =

    =&

    Modeling approaches Controls analysis uses deterministic models. Randomness and

    uncertainty are usually not dominant.

    White box models: physics described by ODE and/or PDE

    Dynamics, Newton mechanics

    Space flight: add control inputs u and measured outputs y

    ),( txfx =&

  • 8/2/2019 Lecture2 Models

    6/40

    EE392m - Winter 2003 Control Engineering 2-6

    vr

    tFr

    rmv pert

    =

    +=

    &

    & )(3

    Orbital mechanics example

    Newtons mechanics

    fundamental laws

    dynamics

    =

    3

    2

    1

    3

    2

    1

    v

    v

    v

    r

    r

    r

    x),( txfx =&

    Laplace

    computational dynamics(pencil & paper computations)

    deterministic model-based

    prediction1749-1827

    1643-1736 rv

  • 8/2/2019 Lecture2 Models

    7/40

    EE392m - Winter 2003 Control Engineering 2-7

    Orbital mechanics example

    Space flight mechanics

    Control problems: u - ?

    =

    3

    2

    1

    3

    2

    1

    v

    v

    v

    r

    r

    r

    x

    ),,(

    ),,(

    tuxgy

    tuxfx

    =

    =&

    =

    )(

    )(

    r

    ry

    vr

    tutFr

    rmv pert

    =

    ++=

    &

    & )()(3

    Thrust

    state

    model

    observations /

    measurementscontrol

  • 8/2/2019 Lecture2 Models

    8/40

    EE392m - Winter 2003 Control Engineering 2-8

    Gene

    expression

    model

  • 8/2/2019 Lecture2 Models

    9/40

    EE392m - Winter 2003 Control Engineering 2-9

    ),,(

    ),,()(

    tuxgy

    tuxfdtx

    =

    =+

    Sampled Time Models Time is often sampled because of the digital computer use

    computations, numerical integration of continuous-time ODE

    digital (sampled time) control system

    Time can be sampled because this is how a system works

    Example: bank account balance

    x(t) - balance in the end of day t

    u(t) - total of deposits and withdrawals that day

    y(t) - displayed in a daily statement

    Unit delay operatorz-1:z-1x(t) =x(t-1)

    ( ) kdttuxfdtxdtx =++ ),,,()(

    xytutxtx

    =

    +=+ )()()1(

  • 8/2/2019 Lecture2 Models

    10/40

    EE392m - Winter 2003 Control Engineering 2-10

    Finite state

    machines TCP/IP State Machine

  • 8/2/2019 Lecture2 Models

    11/40

    EE392m - Winter 2003 Control Engineering 2-11

    Hybrid systems Combination of continuous-time dynamics and a state machine

    Thermostat example

    Tools are not fully established yet

    off on

    72=x

    75=x

    70=x

    70

    =

    xKxx&

    75

    )(

    =

    x

    xxhKx&

  • 8/2/2019 Lecture2 Models

    12/40

    EE392m - Winter 2003 Control Engineering 2-12

    PDE models Include functions of spatial variables

    electromagnetic fields

    mass and heat transfer

    fluid dynamics

    structural deformations

    Example: sideways heat equation

    1

    2

    2

    0)1(;)0(

    =

    =

    ==

    =

    xx

    Ty

    TuT

    x

    Tk

    t

    T

    yheat flux

    x

    Toutside=0Tinside=u

  • 8/2/2019 Lecture2 Models

    13/40

    EE392m - Winter 2003 Control Engineering 2-13

    Black-box models Black-box models - describe P as an operator

    AA, ME, Physics - state space, ODE and PDE

    EE - black-box, ChE - use anything

    CS - state machines, probablistic models, neural networks

    P

    x

    u

    input data

    y

    output data

    internal state

  • 8/2/2019 Lecture2 Models

    14/40

    EE392m - Winter 2003 Control Engineering 2-14

    Linear Systems Impulse response

    FIR model IIR model

    State space model

    Frequency domain Transfer functions

    Sampled vs. continuous time

    Linearization

  • 8/2/2019 Lecture2 Models

    15/40

    EE392m - Winter 2003 Control Engineering 2-15

    Linear System (black-box) Linearity

    Linear Time-Invariant systems - LTI

    )()( 11 yuP

    )()( TyTuP

    )()()()( 2121 ++ byaybuauP

    )()( 22 yuP

    Pu

    t

    y

    t

  • 8/2/2019 Lecture2 Models

    16/40

    EE392m - Winter 2003 Control Engineering 2-16

    Impulse response Response to an input impulse

    Sampled time: t= 1, 2, ...

    Control history = linear combination of the impulses system response = linear combination of the impulse responses

    ( ) )(*)()()(

    )()()(

    0

    0

    tuhkukthty

    kukttu

    k

    k

    ==

    =

    =

    =

    )()( hP

    u

    t t

  • 8/2/2019 Lecture2 Models

    17/40

    EE392m - Winter 2003 Control Engineering 2-17

    Linear PDE System Example Heat transfer equation,

    boundary temperature input u

    heat flux outputy

    Pulse response and step response

    00. 2

    0. 40. 6

    0. 81 0

    0. 2

    0 .4

    0. 6

    0 .8

    1

    0

    0. 2

    0. 4

    0. 6

    0. 8

    1

    TIME

    TEMPER ATURE

    COORDINATE

    0)1()0(

    2

    2

    ==

    =

    TTux

    Tk

    t

    T

    1=

    =

    xx

    Ty

    0 20 40 60 80 1000

    2

    4

    6x 10

    -2

    TIME

    HEATFLUX

    PULSE RESP ONSE

    0 20 40 60 80 1000

    0.2

    0.4

    0.6

    0.8

    1

    TIME

    HEATFLUX

    STEP RESPONSE

  • 8/2/2019 Lecture2 Models

    18/40

    EE392m - Winter 2003 Control Engineering 2-18

    FIR model

    FIR = Finite Impulse Response

    Cut off the trailing part of the pulse response to obtain FIR

    FIR filter statex. Shift register

    ),(

    ),()1(

    uxgy

    uxftx

    =

    =+

    h0

    h1

    h2

    h3

    u(t)

    x1=u(t-1)

    y(t)

    x2=u(t-2)

    x3=u(t-3)

    z-1

    z-1

    z-1

    ( ) )(*)()()(0

    tuhkukthty FIR

    N

    k

    FIR ===

  • 8/2/2019 Lecture2 Models

    19/40

    EE392m - Winter 2003 Control Engineering 2-19

    IIR model IIR model:

    Filter states: y(t-1), ,y(t-na), u(t-1), , u(t-nb)

    ==

    +=ba n

    k

    k

    n

    k

    k ktubktyaty01

    )()()(

    u(t) b0

    b1

    b2

    u(t-1)

    u(t-2)

    u(t-3)

    z

    -1

    z-1

    z-1

    -a1

    -a2

    y(t-1)

    y(t-2)

    y(t-3)

    z

    -1

    z-1

    z-1

    y(t)

    b3-a3

  • 8/2/2019 Lecture2 Models

    20/40

    EE392m - Winter 2003 Control Engineering 2-20

    IIR model Matlab implementation of an IIR model: filter

    Transfer function realization: unit delay operatorz-1

    ( ) ( ) )(...)(...1...

    ...

    ...1

    ...

    )(

    )()(

    )()()(

    )(

    1

    10

    )(

    1

    1

    1

    1

    1

    10

    1

    1

    1

    10

    tuzbzbbtyzazaazaz

    bzbzb

    zaza

    zbzbb

    zA

    zBzH

    tuzHty

    zB

    N

    N

    zA

    N

    N

    N

    NN

    N

    NN

    N

    N

    N

    N

    4444 34444 21444 3444 21

    +++=+++

    +++

    +++=

    +++

    +++==

    =

    FIR model is a special case of an IIR with A(z) =1 (orzN)

  • 8/2/2019 Lecture2 Models

    21/40

    EE392m - Winter 2003 Control Engineering 2-21

    IIR approximation example Low order IIR approximation of impulse response:

    (prony in Matlab Signal Processing Toolbox)

    Fewer parameters than a FIR model

    Example: sideways heat transfer

    pulse response h(t)

    approximation with IIR filter a = [a1 a2 ], b=[b0 b1 b2 b3 b4 ]

    0 20 40 60 80 1000

    0.02

    0.04

    0.06

    TIME

    IMPULSE RESPONSE

    2

    2

    1

    1

    4

    4

    3

    3

    2

    2

    1

    10

    1)(

    ++

    ++++=

    zaza

    zbzbzbzbbzH

  • 8/2/2019 Lecture2 Models

    22/40

    EE392m - Winter 2003 Control Engineering 2-22

    Linear state space model Generic state space model:

    LTI state space model

    another form of IIR model

    physics-based linear system model

    Transfer function of an LTI model

    defines an IIR representation

    Matlab commands for model conversion: help ltimodels

    ( )[ ]

    ( ) DBAIzzH

    uDBAIzy

    +=

    +=

    1

    1

    )(

    )()()(

    )()()1(

    tDutCxty

    tButAxtx

    +=

    +=+

    ),,(

    ),,()1(

    tuxgy

    tuxftx

    =

    =+

  • 8/2/2019 Lecture2 Models

    23/40

    EE392m - Winter 2003 Control Engineering 2-23

    Frequency domain description Sinusoids are eigenfunctions of an LTI system:

    LTIPlant

    tiititieeeez

    ==

    )1(1

    Frequency domain analysis

    uzHy )(=

    ==

    deueHydeuu

    ti

    y

    iti

    43421)(~

    )(~)()(~

    )(~

    u

    e tiu

    Packet

    of

    sinusoids)(~

    y

    e tiPacketof

    sinusoids

    )( ieH y

  • 8/2/2019 Lecture2 Models

    24/40

    EE392m - Winter 2003 Control Engineering 2-24

    Frequency domain description Bode plots:

    tii

    ti

    eeHy

    eu

    )(==

    Example:

    )(arg)(

    )()(

    i

    i

    eH

    eHM

    =

    =

    7.0

    1)(

    =

    zzH

    Bode Diagram

    Frequency (rad/sec)

    Phase(deg)

    Magnitude(dB)

    -5

    0

    5

    10

    15

    10-2

    10-1

    100

    -180

    -135

    -90

    -45

    0

    |H| is often measured

    in dB

  • 8/2/2019 Lecture2 Models

    25/40

    EE392m - Winter 2003 Control Engineering 2-25

    Black-box model from data Linear black-box model can be determined from the data,

    e.g., step response data

    This is called model identification

    Lecture 8

  • 8/2/2019 Lecture2 Models

    26/40

    EE392m - Winter 2003 Control Engineering 2-26

    z-transform, Laplace transform Formal description of the transfer function:

    function of complex variablez

    analytical outside the circle |z|r

    for a stable system r1

    k

    kzkhzH

    == 0 )()(

    Laplace transform:

    function of complex variable s

    analytical in a half plane Re s a for a stable system a1

    = dtethsHst)()(

    )()()( susHsy =

  • 8/2/2019 Lecture2 Models

    27/40

    EE392m - Winter 2003 Control Engineering 2-27

    Stability analysis Transfer function poles tell you everything about stability

    Model-based analysis for a simple feedback example:

    )(

    )(

    d

    yyKu

    uzHy

    =

    =dd yzLy

    KzH

    KzHy )(

    )(1

    )(=

    +=

    IfH(z) is a rational transfer function describing an IIR

    model

    ThenL(z) also is a rational transfer function describing anIIR model

  • 8/2/2019 Lecture2 Models

    28/40

    EE392m - Winter 2003 Control Engineering 2-28

    Poles and Zeros System not quite so!

    Example:

    7.0)(

    ==

    zzuzHy

    19

    171819

    0011400016280...4907.0)(z

    .z.z.zzuzHy FIR +++++==

    Impulse Response

    Time (sec)

    Am

    plitude

    0 5 10 15 20 250

    0.2

    0.4

    0.6

    0.8

    1

    Impulse Response

    Time (sec)

    Amplitude

    0 5 10 15 20 250

    0.2

    0.4

    0.6

    0.8

    1

    FIR model - truncated IIR

  • 8/2/2019 Lecture2 Models

    29/40

    EE392m - Winter 2003 Control Engineering 2-29

    IIR/FIR example - contd Feedback control:

    Closed loop:

    )()(7.0

    )(

    dd yyyyKuz

    zuzHy

    ==

    ==

    Impulse Response

    Time (sec )

    Amplitude

    0 5 10 15 20 250

    0.2

    0.4

    0.6

    0.8

    uzLuzH

    zHy )(

    )(1

    )(=

    +=

    uzLuzH

    zH

    y FIRFIR

    FIR

    )()(1

    )(

    =+=

  • 8/2/2019 Lecture2 Models

    30/40

    EE392m - Winter 2003 Control Engineering 2-30

    -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8-0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    IIR/FIR example - contd

    Poles and zeros Blue: Loop

    with IIRmodel poles x

    and zeros o

    Red: Loopwith FIRmodel poles x

    and zeros o

  • 8/2/2019 Lecture2 Models

    31/40

    EE392m - Winter 2003 Control Engineering 2-31

    LTI models - summary Linear system can be described by impulse response

    Linear system can be described by frequency response =Fourier transform of the impulse response

    FIR, IIR, State-space models can be used to obtain close

    approximations of a linear system

    A pattern of poles and zeros can be very different for asmall change in approximation error.

    Approximation error model uncertainty

  • 8/2/2019 Lecture2 Models

    32/40

    EE392m - Winter 2003 Control Engineering 2-32

    Nonlinear map linearization Nonlinear - detailed

    model

    Linear - conceptualdesign model

    Static map, gain

    range, sector

    linearity

    Differentiation,

    secant method

    )()( 0uuufufy =

  • 8/2/2019 Lecture2 Models

    33/40

    EE392m - Winter 2003 Control Engineering 2-33

    Nonlinear state space model

    linearization

    Linearize the r.h.s. map

    Secant method

    Or capture a response to small step and build an

    impulse response model

    BvAqq

    uu

    u

    fxx

    x

    fuxfx

    vq

    +=

    +

    =

    &

    4342143421& )()(),( 00

    {]0...1...0[

    )(

    # j

    j

    j

    j

    j

    s

    ssxf

    xf

    =

    +=

  • 8/2/2019 Lecture2 Models

    34/40

    EE392m - Winter 2003 Control Engineering 2-34

    Sampled time vs. continuous time Continuous time analysis (Digital implementation of

    continuous time controller)

    Tustins method = trapezoidal rule of integration for

    Matched Zero Pole: map each zero and a pole in accordance with

    Sampled time analysis (Sampling of continuous signalsand system)

    +

    ==

    1

    1

    1

    12)()(

    z

    z

    TsHzHsH s

    ssH

    1)( =

    sTes =

  • 8/2/2019 Lecture2 Models

    35/40

    EE392m - Winter 2003 Control Engineering 2-35

    Sampled and continuous time Sampled and continuous time together

    Continuous time physical system + digital controller

    ZOH = Zero Order Hold

    Sensors

    Control

    computing

    ActuatorsPhysicalsystem

    D/A, ZOHA/D, Sample

  • 8/2/2019 Lecture2 Models

    36/40

    EE392m - Winter 2003 Control Engineering 2-36

    Signal sampling, aliasing

    Nyquist frequency:

    N= S; S= 2/T

    Frequency folding: kS map to the same frequency

    Sampling Theorem: sampling is OK if there are no frequency

    components above

    N

    Practical approach to anti-aliasing: low pass filter (LPF)

    Sampledcontinuous: impostoring

    Digitalcomputing

    D/A, ZOHA/D, Sample

    Low

    Pass

    Filter

    LowPass

    Filter

  • 8/2/2019 Lecture2 Models

    37/40

    EE392m - Winter 2003 Control Engineering 2-37

    Simulation ODE solution

    dynamical model:

    Euler integration method: Runge-Kutta: ode45 in Matlab

    Can do simple problems by integrating ODEs

    Issues: mixture of continuous and sampled time

    hybrid logic (conditions)

    state machines

    stiff systems, algebraic loops systems integrated out of many subsystems

    large projects, many people contribute different subsystems

    ),( txfx =&

    ( )ttxfdtxdtx ),()()( +=+

  • 8/2/2019 Lecture2 Models

    38/40

    EE392m - Winter 2003 Control Engineering 2-38

    Simulation environment

    Block libraries

    Subsystem blocks

    developed independently

    Engineered for developing

    large simulation models

    Supports code generation

    Simulink by Mathworks

    Matlab functions and analysis

    Stateflow state machines

    Ptolemeus -

    UC Berkeley

  • 8/2/2019 Lecture2 Models

    39/40

    EE392m - Winter 2003 Control Engineering 2-39

    Model block development Look up around for available conceptual models

    Physics - conceptual modeling

    Science (analysis, simple conceptual abstraction) vs.

    engineering (design, detailed models - out of simple blocks)

  • 8/2/2019 Lecture2 Models

    40/40

    EE392m - Winter 2003 Control Engineering 2-40

    Modeling uncertainty Modeling uncertainty:

    unknown signals

    model errors

    Controllers work with real systems:

    Signal processing: data algorithm data

    Control: algorithms in a feedback loop witha realsystem

    BIG question: Why controller designed for a model would

    everwork with a real system?

    Robustness, gain and phase margins,

    Control design model, vs. control analysis model Monte-Carlo analysis - a fancy name for a desperate approach