mpc gui manual

Upload: surya-budi-widagdo

Post on 08-Apr-2018

254 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Mpc Gui Manual

    1/109

    The MPC Graphical User Interface

    Users GuideVersion 1

    N. L. RickerM. Morari

    A. Bemporad

  • 8/6/2019 Mpc Gui Manual

    2/109

    MPC Graphical User Interface

    How to Contact N. L. Ricker:

    Dept. of Chemical Engr.

    Box 351750

    University of Washington

    Seattle, WA 98195-1750

    http://weber.u.washington.edu/~control/

    [email protected]

    The MPC Graphical User Interface

    COPYRIGHT 1998 by N. L. Ricker, M. Morari, and A. Bemporad

    The software described in this document is covered by the MPC Tools license agreement. Thesoftware may be used or copied only under the terms of the license agreement. This manual maybe photocopied and reproduced, but no part may be included in any other document without priorwritten consent from the authors.

    U.S. GOVERNMENT: If Licensee is acquiring the Programs on behalf of any unit or agency ofthe U.S. Government, the following shall apply: (a) For units of the Department of Defense: theGovernment shall have only the rights specified in the license under which the commercialcomputer software or commercial software documentation was obtained, as set forth in subpara-graph (a) of the Rights in Commercial Computer Software or Commercial Software Documenta-tion Clause at DFARS 227.7202-3, therefore the rights set forth herein shall apply; and (b) Forany other unit or agency: NOTICE: Notwithstanding any other lease or license agreement that

    may pertain to, or accompany the delivery of, the computer software and accompanying documen-tation, the rights of the Government regarding its use, reproduction, and disclosure are as setforth in Clause 52.227-19 (c)(2) of the FAR.

    MATLAB, Simulink, Handle Graphics, and Real-Time Workshop are registered trademarks andStateflow and Target Language Compiler are trademarks of The MathWorks, Inc.

    Other product or brand names are trademarks or registered trademarks of their respectiveholders.

    Printing History: Sept 1998 Online Draft

    uMAIL

    INTERNET

    @E-MAIL

  • 8/6/2019 Mpc Gui Manual

    3/109

    i

    Contents

    Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viState of Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

    In Case of Difficulty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

    Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

    Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi

    1Introduction

    GUI Philosophy and Overview . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

    Modeling Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

    Controller Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

    Starting the GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

    System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

    Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

    Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4

    Leisurely Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4

    MPC Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5

    Overview: Single-Input, Single-Output (SISO) MPC . . . . . . . . 1-5Sampling period and sampling instants . . . . . . . . . . . . . . . . 1-7

    An MPC sampling instant . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8

    Prediction and control horizons . . . . . . . . . . . . . . . . . . . . . . . 1-9

    Blocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10

    Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11

    Choosing the optimization weights . . . . . . . . . . . . . . . . . . . 1-12

    Solving the Optimization Problem . . . . . . . . . . . . . . . . . . . . 1-13

    Output Constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13

    Multiple Inputs and Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14

  • 8/6/2019 Mpc Gui Manual

    4/109

    ii Contents

    2

    MPC Worksheet Basics

    The Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

    Parts of the Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3

    Loading a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    Creating the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    LTI Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    System Identification Toolbox . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    MPC Tools Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4Unsupported Model Formats . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    Paper machine headbox example . . . . . . . . . . . . . . . . . . . . . . . . 2-4

    Loading the LTI model of the headbox . . . . . . . . . . . . . . . . . . 2-5

    Manipulating Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

    Organizing the Worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8

    Viewing/modifying icon properties . . . . . . . . . . . . . . . . . . . . . . . 2-8

    Designing a Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11

    Simulation Open Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

    Simulation Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16

    Step Response Headbox Example . . . . . . . . . . . . . . . . . . . . . 2-17

    Viewing Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18

    Viewing/Editing Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-20

    Simulation Closed-Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-22

    3

    Using Simulink Models in MPC

    Loading a Simulink Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

    Open the Model Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2

    Check Input and Output Signals . . . . . . . . . . . . . . . . . . . . . . . . 3-2

    Load the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3

  • 8/6/2019 Mpc Gui Manual

    5/109

    iii

    Specify Signal Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3

    Set Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3

    MPC Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7

    Simulations using Simulink Models . . . . . . . . . . . . . . . . . . . . . 3-8

    Using Simulink to Define Inputs and Select Outputs . . . . 3-10

    Initial Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12

    Specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12

    Verifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12

    4

    Disturbance Detection and Estimation

    Disturbance Estimation Goals . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2

    Paper Machine Headbox Example . . . . . . . . . . . . . . . . . . . . . . 4-3

    MPC Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

    Noise Signal Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3

    Disturbance Estimator for Noisy Signal . . . . . . . . . . . . . . . . . . . 4-5

    Sustained Disturbances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7

    Plant with Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

    A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13

    MPC Design with Default Estimator . . . . . . . . . . . . . . . . . . . . 4-13

    Steady-state Offset in MPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14

    MPC Design to Eliminate Offset . . . . . . . . . . . . . . . . . . . . . . . . 4-16

    General Open-Loop Unstable Plants . . . . . . . . . . . . . . . . . . . 4-18

    Theoretical Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19

    One measured output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19

    Multiple measured outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21

  • 8/6/2019 Mpc Gui Manual

    6/109

    iv Contents

    5

    Signal Anticipation

    6

    Working with Plots

    Plot Editing in MPC An Example . . . . . . . . . . . . . . . . . . . . . . 6-2

    Plot Editing Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3

    Context Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3

    The Curve Context Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3

    The Plot Context Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

    Paste Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

    Zoom with Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

    Edit Axis Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

    Change Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4

    Change X-Axis Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4Change Y-Axis Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5

    Import Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5

    Export Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5

    Export All . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5

    Hide/Show Legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5

    Add/Delete Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

    Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

    Editing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

    Text Objects in the MPC GUI . . . . . . . . . . . . . . . . . . . . . . . . . 6-6

    TeX Interpreter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7

    Zooming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7

    The Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10

    7

    Worksheet Icons

    Icon Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2

    Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2

  • 8/6/2019 Mpc Gui Manual

    7/109

    v

    Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2

    Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2

    Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3

    Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3Rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3

    Icon Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4

    Model Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4

    LTI Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5

    STEP Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6

    MDL Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6

    Controller Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7

    LTI Internal Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8

    STEP Internal Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

    Result Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-9

  • 8/6/2019 Mpc Gui Manual

    8/109

    vi

    Preface

    DisclaimerState of DevelopmentThe MPC GUI is in a developmental (beta) stage.It is not an official MathWorks product. It has been

    tested extensively, but it is likely that some problems remain. Please review all calculations with a

    critical eye.

    We will also be improving GUI features in response to your comments.

    In Case of DifficultyThis beta version of the GUI is not being supported by The MathWorks. If you encounter a problem,

    please check the FAQ (see "Updates" below). If that doesnt help, please send a detailed description by

    e-mail to N. L. Ricker at the following address:

    [email protected]

    He would also be happy to have your suggestions for improvements in the usability of the GUI, itsdocumentation, and the MPC Toolbox in general.

    UpdatesThe FAQ and latest beta version of the GUI will be maintained for download at

    http://weber.u.washington.edu/~control/LARRY/GUI/index.html

    AcknowledgementsOscar Crisalle provided many detailed comments on the initial version of the GUI. We also appreciate

    the help of Dominique Bonvin, Jan Maciejowski, Chris Primus, Frank Doyle, Jay Lee, Pascal Gahinet,

    and Greg Wolodkin.

    1

  • 8/6/2019 Mpc Gui Manual

    9/109

    1

    Introduction

    GUI Philosophy and Overview . . . . . . . . . . . . 1-2

    Modeling Options . . . . . . . . . . . . . . . . . . 1-2

    Controller Options . . . . . . . . . . . . . . . . . . 1-2

    Starting the GUI . . . . . . . . . . . . . . . . . . 1-3

    System Requirements . . . . . . . . . . . . . . . . . 1-3

    Installation . . . . . . . . . . . . . . . . . . . . . 1-3

    Quick Start . . . . . . . . . . . . . . . . . . . . . 1-4

    Leisurely Start . . . . . . . . . . . . . . . . . . . 1-4

    MPC Fundamentals . . . . . . . . . . . . . . . . . 1-5

    Overview: Single-Input, Single-Output (SISO) MPC . . . . 1-5

    Multiple Inputs and Outputs . . . . . . . . . . . . . . 1-14

  • 8/6/2019 Mpc Gui Manual

    10/109

    1 Introduction

    1-2

    GUI Philosophy and OverviewIf youre an MPC expert who likes to program MATLAB commands youll

    probably want to customize your own applications. Direct use of the MPC

    commands gives you maximum flexibility and power, and the resulting code

    runs as efficiently as possible.

    But if you dont want to learn all the commands theres another way: the MPC

    GUI. Its designed to help you analyze and simulate the most common plant

    MPC controller and plant model combinations. It also provides a worksheetthat helps you keep track of your progress as you test different designs.

    Modeling OptionsThe GUI supports the following model types:

    Linear. Either an LTI object (transfer function, state-space,etc. see the

    Control Toolbox), or a step-response model.

    Nonlinear. A Simulink block diagram.

    Controller OptionsYou can use all of the standard linear MPC design options. If your plant model

    is nonlinear, you can linearize it to design the controller, then simulate linear

    MPC of the nonlinear plant.

  • 8/6/2019 Mpc Gui Manual

    11/109

    Starting the GUI

    1-3

    Starting the GUISystem RequirementsYoull need the following MATLAB software:

    MPC Toolbox for MATLAB Version 5, including the GUI commands (which

    are currently an add-on to the standard MPC Tools release).

    MATLAB Version 5.2 or greater.

    Simulink Version 2 or greater.

    Control Toolbox.

    Installation

    1 Make a backup copy of your MPC Tools directory (which should be located

    in your MATLAB directory,e.g., MATLAB/toolbox/mpc). This will allow you

    to restore your original configuration if the GUI installation interferes insome unexpected way.

    2 Download the latest version of the GUI from

    http://weber.u.washington.edu/~control/LARRY/GUI/index.html

    Its a ZIP archive. Extract the contents using one of the many available

    utility programs (e.g., WinZip). This should create a new gui directory

    within the mpc directory. It should also add and update files in your mpccmds

    and mpcdemos directories.

    IMPORTANT: The gui ZIP archive is not a full version of MPC Tools. You

    must have existing mpc/mpccmds and mpc/mpcdemos directories. The files

    from the archive only update these directories.

    3 Set your MATLAB Path so the new mpc/gui directory is included. Verify

    that the original mpc/mpccmds and mpc/mpcdemos directories are also on the

    path.

  • 8/6/2019 Mpc Gui Manual

    12/109

    1 Introduction

    1-4

    4 Type mpc in the MATLAB Command window. You should see the MPCWorksheet.

    5 If it doesnt work or you have other problems, see section In Case of

    Difficulty in the preface to this document.

    Quick Start

    1 Type mpc in the command window and wait for the MPC Worksheet toappear.

    2 Click on the Help button (just to the right of Models near the top of the

    window). The resulting Help window will contain a brief tutorial example.

    3 Follow the steps in the tutorial.

    4 Try it with your own applications!

    Leisurely StartThe following sections of this document provide tutorial examples and

    additional details. If possible, work through the steps in MATLAB as you read.

  • 8/6/2019 Mpc Gui Manual

    13/109

    MPC Fundamentals

    1-5

    MPC FundamentalsThis section reviews MPC concepts and defines key terms. If youre already

    familiar with MPC you may prefer to read Chapter 2, MPC Worksheet Basics

    next.

    Overview: Single-Input, Single-Output (SISO) MPCFigure 1-1 shows a situation in which MPC is trying to hold a single variable,

    , at a target value, r, by adjusting the manipulated variable (or actuator)u. See Table 1-1 for a brief description of the signals appearing in Figure 1-1.

    The box labeled plant is the real process or mechanism that produces . It

    responds to changes in u as well as to two types of disturbance signals:

    measured, v, and unmeasured, d. (Some applications have unmeasured

    disturbances only; the v signal is optional.)

    The unmeasured disturbance represents the usual mysterious events that

    upset plant operation, causing variations in . The only sign that such anevent has occurred is a change in the measured output, y.

    Figure 1-1 Block diagram of a single-input, single-output MPC application.

    y

    y

    y

    ++PlantMPC

    v

    r

    yd

    z

    yyu

    v

    Measured Disturbance

    Measured Output (Controlled Variable)

    Noise

    Setpoint

    UnmeasuredDisturbance

    Actuator

    PlantOutput

  • 8/6/2019 Mpc Gui Manual

    14/109

    1 Introduction

    1-6

    The measured disturbance also affects . The MPC block includes models of

    the way in which v and u affect (symbolically, and ). It uses this

    information to calculate u adjustments that keep at its setpoint in spite of

    the (known) disturbance. This calculation considers the effect of any knownconstraints on the adjustments (e.g., an actuator at its upper or lower bound).

    If the models are accurate and the plant responds quickly to u, this

    feedforward compensation counteracts the effect ofv perfectly.

    Table 1-1 Summary of MPC signals (see also Figure 1-1).

    Symbol Description

    d Unmeasured disturbance. A disturbance unknown to

    MPC that affects the plant output. MPC provides

    feedback compensation for such disturbances.

    r Setpoint (or reference signal). The target value for the

    controlled variable.

    u Actuator (or manipulated variable). The signal MPC

    adjusts in order to achieve its control objectives.

    v Measured disturbance (optional). MPCfeedforward

    compensation adjusts for such disturbances as they

    occur to minimize their impact on the controlledvariable.

    Controlled variable (or plant output). The signal to be

    held at the setpoint. This is the true value,

    uncorrupted by measurement noise.

    y Measurement of the controlled variable. Used to

    estimate the true value, .

    z Measurement noise. Represents electrical noise,

    sampling errors, drifting calibration, and other effects

    that reduce the accuracy of the measurement.

    y

    y

    y

    y v y u yy

  • 8/6/2019 Mpc Gui Manual

    15/109

    MPC Fundamentals

    1-7

    NOTE: One may also specify bounds on . These constraint-handling

    properties are a distinguishing feature of MPC and can be particularly

    valuable when one has multiple control objectives to be achieved via multiple

    adjustments.

    In reality, however, model imperfections, plant limitations, and unmeasured

    disturbances cause the measurement,y, to deviate from its expected value.Thus, MPC uses the output measurement and a disturbance model ( )

    topredict future changes in . It then uses its model to calculate

    appropriate adjustments (a form of feedback compensation). This calculation

    also considers the known constraints.

    Various types of noise can corrupt the measurement. The signalz in Figure

    1-1 represents such effects. They may vary randomly about a zero mean or

    exhibit a non-zero, drifting bias. MPC uses a model in combination with

    its model to remove the estimated noise component of the measurement(filtering).

    The above feedforward/feedback actions are MPCs regulator mode. MPC also

    has a servo mode, i.e., it adjusts u such that tracks a time-varying setpoint.

    The tracking accuracy depends on the plant characteristics (including

    constraints), the accuracy of the model, and whether or not future

    setpoint variations can be anticipated, i.e., known in advance (11ref).

    Details: SISO case

    Sampling period and sampling instantsMPC operates at discrete intervals oft time units, the sampling period.

    Suppose that MPC starts at time t = 0. The sampling instants are the times

    at which MPC adjusts the manipulated variable, u. They are integer multiples

    of the sampling period: 0,t, 2t, 3t, ..., kt, where the integer index, k,

    represents the current sampling instant.

    y

    d y

    y u y

    z y

    d y

    y

    u y

  • 8/6/2019 Mpc Gui Manual

    16/109

    1 Introduction

    1-8

    Figure 1-2 The MPC problem at the kth sampling instant.

    An MPC sampling instantFigure 1-2 shows the state of a hypothetical SISO MPC system which has been

    operating for some time; k is the current sampling instant. The current

    measured output,yk, and previous measurements,yk-1,yk-2, ..., are known and

    are the filled circles in Figure 1-2 (a). The current measured disturbance, dk,

    and its past values are also known (not shown).

    y

    ymin

    max

    Setpoint

    Past Future

    Estimated

    Measured

    Prediction Horizon, P

    r

    Sampling Instant

    umin

    umax

    Control

    Horizon

    Past Moves

    Planned Moves

    k +1 +2 +3 +4 +5 +6 +7 +8 +9-1-2-3-4

    (a)

    (b)

  • 8/6/2019 Mpc Gui Manual

    17/109

    MPC Fundamentals

    1-9

    Figure 1-2 (b) shows MPCs previous moves, uk-41

    , ..., uk-1

    , as filled circles. As

    is usually the case, a zero-order hold receives each move from MPC and sends

    that value to the plant continuously until the next sampling instant note the

    resulting step-wise variations ofFigure 1-2 (b).

    MPC must now calculate the current move, uk. It does so in two phases:

    1 Estimation. In order to make an intelligent move, MPC needs to know the

    current state of the system. This includes the true value of the controlled

    variable, ,and any internal plant variables that influence the futuretrend, , ..., . To accomplish this MPC uses all past and current

    measurements and the models , , , and . For

    details, please see Chapter 4, Disturbance Detection and Estimation.

    2 Optimization. Values of setpoints, measured disturbances, and constraints

    are specified over a finite horizon of future sampling instants, k+1, k+2, ...,

    k+P, whereP (a finite integer 1) is the prediction horizon see Figure

    1-2 (a). MPC then computes theMmoves uk, uk+1, ... uk+M-1, whereM( 1,P) is the control horizon see Figure 1-2 (b). In our hypothetical example,P = 9 andM= 4.

    Suppose that the optimal sequence of moves is the series of four open circles in

    Figure 1-2 (b). MPCs model predicts that this will result in the output

    sequence shown as the nine open circles in Figure 1-2 (a).

    These moves are optimal in the sense that no constraints are violated and the

    outputs track the setpoint closely. See 11ref for a detailed definition of

    optimality.

    MPC sends only the move uk to the plant. The plant operates with this input

    until MPCs next sampling instant, t time units later. MPC then obtains a

    new set of measurements and revises completely the plan it had formulated at

    the previous sampling instant, thus compensating for model error and

    unknown disturbances.

    Prediction and control horizonsOne might wonder why MPC bothers to optimize overP sampling periods into

    the future and calculateMmoves when it discards all but the first move.

    Indeed, under certain conditions MPC gives identical results forP =M= 1 as

    ykyk 1+ yk P+

    u y d y w y z y

  • 8/6/2019 Mpc Gui Manual

    18/109

    1 Introduction

    1-10

    it does forP =M= . More often, however, the horizons have an importantimpact. Some examples are:

    Constraints. MPCs current move, uk, depends on future constraints, i.e.,

    MPC plans ahead to avoid future constraint violations.

    Delays in the plant. Suppose that the plant includes a pure time delay; MPCs

    current move has no effect untilD sampling periods into the future. Then we

    needPD andMPD so that MPC can include the effect of eachcontemplated move in its optimization calculations.

    Other nonminimum phase plants. Consider a SISO plant with an

    inverse-response,e.g., its unit-step response is a decrease below the initial

    condition followed by an increase to a final value above the initial condition.

    Experience suggests the following rules of thumb:

    1 Choose the MPC sampling period such that the plants open-loop settling

    time is approximately 20-30 sampling periods (i.e., the sampling period is

    approximately one fifth of the dominant time constant).

    2 ChooseP to be the number of sampling periods used in step 1.

    3 Use a relatively smallM,e.g., 3-5.

    The resulting MPC performance will usually be insensitive to minor

    adjustments in theseMandP values, and further tuning should not be

    necessary. If performance is poor, it is probably due to other factors, such asmodeling errors.

    BlockingIn Figure 1-2 (b),M= 4 andP= 9, and MPC is optimizing the firstMmoves of

    the prediction horizon, after which the manipulated variable remains constant

    forP M= 5 sampling instants.

    Figure 1-3 shows an alternative blocked strategy again withM= 4 inwhich the first planned move occurs at sampling instant k, the next at k+2, the

    next at k+4, and the final at k+6. A block is one or more successive sampling

    periods during which the manipulated variable is constant. The block

    duration is the number of sampling periods in a block. In Figure 1-3 the block

    durations are 2, 2, 2, and 3. (Their sum must equalP.)

  • 8/6/2019 Mpc Gui Manual

    19/109

    MPC Fundamentals

    1-11

    Figure 1-3 Example of blocking with M = [2, 2, 2, 3].

    As for the default (unblocked) mode, only the current move, uk, actually goes to

    the plant, and MPC repeats the optimization ofMmoves at its next sampling

    instant. Thus, the signal going to the plant actually varies every t time units.

    So why use blocking? WhenP >>M(as is generally recommended), and allM

    moves are at the beginning of the horizon, the moves tend to be larger (because

    all but the final move last just one sampling period). Blocking often leads to

    smoother adjustments, all other things being equal.

    OptimizationFor a SISO plant, MPC determines its moves by solving the following

    optimization problem (formulated for the kth sampling instant):

    (1-1)

    such that

    (1-2)

    Sampling Instant

    umin

    umax

    Past Moves

    Planned Moves

    k +1 +2 +3 +4 +5 +6 +7 +8 +9-1-2-3-4

    Min

    uk uk P 1+, ,

    wy

    rk i

    +yk i+( )

    2w

    uu

    k i 1+

    ( )2

    +[ ]

    i 1=

    P

    yk i+ f uk uk i 1+, ,( )=

    1

  • 8/6/2019 Mpc Gui Manual

    20/109

    1 Introduction

    1-12

    (1-3)

    (1-4)

    (1-5)

    where is the adjustment at sampling instantj, and and

    are non-negative weights.

    Equation (1-2) is the model by which MPC predicts the controlled variable at

    instant k+i. In standard MPC, is a linear function of the adjustments

    .

    Note: The prediction is also a function of known and estimated

    disturbances, but these effects are constant, i.e., independent of the

    adjustments. They are implicit in Equation (1-2).

    Equations (1-3) (1-5) are optional. They specify the bounds on the

    manipulated variable, the controlled variable, and the change in the

    manipulated variable.

    WhenP > M(the usual case), there are alsoP Mequality constraints of the

    form , i.e., to hold the manipulated variables constant for a

    specified sequence of sampling instants. This depends on the specified blockdurations. For example, the situation ofFigure 1-3 would have ,

    , etc.

    Choosing the optimization weightsThe main difficulty in an MPC design (other than modeling) is the selection of

    the weights and in eq. (1-1). Trial-and-error tuning is often needed. The

    following guidelines may be helpful:

    A positive value of penalizes predicted deviations of the controlled

    variable from its setpoint. The larger this weight, the more closely MPC tries

    to track the setpoint. If , MPC ignores the setpoint.

    A positive value of penalizes planned changes in the manipulated

    variable. A moderate value makes the controller cautious, which usually

    umin

    uk i 1+ umax

    i 1 P,=

    ymin

    yk i+ ymax

    i 1 P,=

    uk i 1+ umax

    i 1 P,=

    uj uj uj 1= wy

    wu

    yk i+uk uk i 1+, ,

    yk i+

    uk j+ uk j 1+=

    uk 1+ uk=

    uk 3+ uk 2+=

    wy

    wu

    wy

    wy

    0=

    wu

  • 8/6/2019 Mpc Gui Manual

    21/109

    MPC Fundamentals

    1-13

    increases its robustness (making it less sensitive to modeling errors a

    positive effect). A large value makes it sluggish, however. In the extreme

    as goes to infinity, MPC ignores deviations of the controlled variable

    from its setpoint.

    In a SISO problem, only the ratio of to matters. A good strategy is to

    fix one of them at unity and vary the other, testing the performance in

    simulations to obtain the desired trade-off between fast setpoint tracking

    (large ratio) and cautious adjustments of the manipulated variable (small

    ratio). (By default, the MPC GUI sets .)MPC does whatever it must in order to satisfy any hard inequality

    constraints, eqs. (1-3)(1-5). The values of and become less important

    when constraints are encountered.

    Solving the Optimization ProblemThe objective function, eq. (1-1), is quadratic, and the standard MPC

    formulation uses linear constraints, eqs. (1-2)(1-5). This is a quadratic

    programming problem. There areMdecision variables, the moves.

    If none of the inequality constraints are binding, the QP has an analytical

    solution. In general, however, MPC uses an iterative procedure. If the QP is

    feasible, i.e., at least one set of moves satisfies all the constraints, the optimum

    will be obtained in a finite number of iterations. This can be time-consuming,

    especially for the MIMO case in the next section. If this is limiting in your

    application, consider reducingP and/orM.

    Output ConstraintsOutput constraints, eq. (1-4), should be used only when it is essential to hold

    the output within its bounds

    NOTE: to turn off an output constraint set and/or .

    Such constraints can increase the computational effort significantly. More

    importantly, they may make the problem infeasible. Suppose, for example, that

    a large disturbance drivesyk above its upper bound. If there are bounds on uk,

    it may be impossible to bring the output back within the allowed region quickly

    enough to satisfy eq. (1-4).

    wu

    wy

    wu

    w

    y

    1 w

    u

    , 0.1= =

    wy

    wu

    ymin

    = ymax

    =

    1 I t d ti

  • 8/6/2019 Mpc Gui Manual

    22/109

    1 Introduction

    1-14

    An alternative is to replace eq. (1-4) with soft constraints. The mpc tools

    functions allow this, but for the moment the GUI uses hard constraints only.

    Multiple Inputs and OutputsWe now consider the signals ofFigure 1-1 to be vectors. Suppose that there are

    controlled outputs, all measured, i.e.,

    (1-6)

    Signalszk and also have ny elements. There are manipulated

    variables

    (1-7)

    and disturbances dk and vk have and elements, respectively. (As

    discussed in Theoretical Background in Chapter 4, the MPC GUI assumes

    .)

    Much of the previous discussion carries over to the multi-input, multi-output

    (MIMO) case. The same horizons (P,M) and block durations apply regardless

    of the number of controlled and manipulated variables. The main difference is

    in the optimization problem. At the kth sampling period,

    (1-8)

    such that

    (1-9)

    (1-10)

    (1-11)

    (1-12)

    where is the adjustment of the lth manipulated variable at

    the jth sampling instant, and and are non-negative weights.

    ny 1

    yk y1k y2k ynyk, , ,[ ]=

    yk nu 1

    uk u1k u2k unuk, , ,[ ]=

    nd 0 nv 0

    nd ny=

    Min

    uk uk P 1+, ,wj

    yrj k i+, yj k i+,( )

    2wl

    uul k, i 1+( )

    2

    l 1=

    u

    +1=

    y

    i 1=

    yj k i+, f uk uk i 1+, ,( ) j 1 ny,= =

    ulmin

    ul k, i 1+ ulmax

    i 1 P and l, 1 nu,= =

    yjmin

    yj k, i+ yjmax

    i 1 P andj, 1 ny,= =

    ul k, i 1+ u lmax

    i 1 P and l, 1 nu,= =

    ulj ulj ul j, 1=wj

    ywl

    u

    d l

  • 8/6/2019 Mpc Gui Manual

    23/109

    MPC Fundamentals

    1-15

    There are weights to specify. The relative magnitudes of the weights

    are critical; we can again set one to unity and tune the rest. Unfortunately, achange in a single weight can affect the performance of all the controlled and

    manipulated variables, so tuning can be more delicate than in the SISO case.

    Some general guidelines are:

    Ifykj must be held close to its setpoint, the corresponding weight, , should

    be relatively large. If, setpoint tracking is unimportant for this output, its

    weight should be small, perhaps zero.

    If you would prefer that ukj not change rapidly, make relatively large.

    For non-square problems, if , at least of the input weights,

    , must be non-zero so that the QP solution is unique.

    For non-square problems with , it is usually impossible to drive all ny

    outputs to setpoints, i.e., there will be steady-state offset unless of

    the output weights are zero.

    Keep the scaling of the variables in mind as for the SISO case.

    ny

    nu

    +

    wjy

    wju

    nu ny> nu ny

    wju

    nu ny 0 there are two elements

    in . Otherwise, is a scalar.The states of the Gv and Gu are assumed to be known, as noted previously. At

    the kthsampling instant, given the noisy measurementyk, the goal is to

    estimate the disturbance states.

    Referring to Figure 4-15, we first subtract the known components from the

    measured output to obtain the combined disturbance and noise. Let this be the

    noisy measurement of the disturbance,

    (4-5)

    Combining this with (4-4)

    (4-6)

    The matricesAw,Bw, and Cw with estimates of the variances and

    define a steady-state Kalman gain matrix, K. The estimate of the disturbance

    states is then

    (4-7)

    In fact, only the relative noise matters in the calculation ofK. This is

    the noise-to-signal ratio discussed in section Disturbance Estimator for Noisy

    Signal (and specified as shown in Figure 4-3).

    Multiple measured outputsIf there are multiple outputs, the GUI assumes that disturbances to each are

    independent of one another. It treats each output individually, estimating the

    associated disturbance state(s) as shown above for the single-output case.

    xk 1+w

    Awxkw

    Bwwk+=

    dk Cwxkw

    =

    xkw

    xkw

    xkw

    ykd

    ykd

    dk zk+ yk ykv

    yku

    = =

    ykd

    Cwxkw

    zk+=

    w2

    z2

    xk

    wxk 1

    wKyk

    d+=

    z w

    4 Disturbance Detection and Estimation

  • 8/6/2019 Mpc Gui Manual

    84/109

    4-22

    5Signal Anticipation

  • 8/6/2019 Mpc Gui Manual

    85/109

    5 Signal Anticipation

    It is occasionally possible to anticipate changes in a measured disturbance or a

    setpoint. In other words, the plant operator may know in advance that a change

    is coming. MPC tries to track setpoints over a prediction horizon ofP futuresampling periods (see Designing a Controller in Chapter 2). As soon as the

  • 8/6/2019 Mpc Gui Manual

    86/109

    5-2

    change appears in the prediction horizon, MPC can begin planning for it.

    MPCs setpoint tracking performance usually improves when it has advance

    notice of a setpoint change.

    To try this feature, load the LTI PapMach model (see Loading the LTI model

    of the headbox on page 2-5). Set the signal types of the last two inputs to MD

    and UD as before. Then drag the PapMach icon to the Plant and MPC Model

    boxes on the Worksheet.

    Click on the MPC Design button and make the following choices:

    Prediction horizon: 10.

    Number of moves: 3.

    Sampling period: 0.25.

    Blocking: durations of2, 3, 5.

    Turn anticipation on. When you click the Anticipation checkbox, the dialog

    ofFigure 5-1 appears. Anticipation will be On for all signals by default. To

    toggle a signal from On to Off or vice versa, click the signals name in the list.

    In this case we will only anticipate changes in the N2 setpoint, so turn off all

    but that one (as shown in Figure 5-1). Then click Done to return to the MPC

    Design dialog.

    Weight: 0 for output #2.

    All other weights and constraints at their defaults.

    Then click Done on the MPC Design dialog to save the controller.

    If you wish (for comparison), create another controller that is identical except

    that anticipation isOfffor all signals.

  • 8/6/2019 Mpc Gui Manual

    87/109

    5-3

    Figure 5-1 Signal anticipation dialog for PapMach example.

    Drag the controller icon (the one with anticipation) to the Controller box on

    the Worksheet and click Run Simulation. The resulting Setpoint Summary

    display should indicate that anticipation is ON for N2.

    Make sure the Closed Loop radio button is on, and set the Run Duration to

    30.

    Use the Setpoints pop-up to select N2 and click the Specify button. Define a

    unit-step increase that occurs at a Start Time of10.

    Click Done to return to the Simulation dialog, then click Run to start the

    simulation.

    Figure 5-2 shows the response of N2 with anticipation on vs. the default (no

    anticipation). When anticipation is on, MPC begins to vary the MVs as soon as

    the setpoint change appears in the prediction horizon, i.e., (10)(0.25) = 2.5 timeunits in advance. The resulting servo response tracks the step change much

    better than the default case.

    In general, anticipation provides the greatest benefit when the process is

    sluggish or there is a large delay.

    5 Signal Anticipation

    1.2

    PapMach Output N2

  • 8/6/2019 Mpc Gui Manual

    88/109

    5-4

    Figure 5-2 PapMach servo response with and without anticipation.

    0 5 10 15 20 25 300.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Time

    SetpointAnticipation ONAnticipation OFF

    6Working with Plots

  • 8/6/2019 Mpc Gui Manual

    89/109

    Plot Editing in MPC An Example . . . . . . . . . . 6-2

    Plot Editing Options . . . . . . . . . . . . . . . . 6-3

    Context Menus . . . . . . . . . . . . . . . . . . . 6-3The Curve Context Menu . . . . . . . . . . . . . . . 6-3

    The Plot Context Menu . . . . . . . . . . . . . . . . 6-4

    Editing Text . . . . . . . . . . . . . . . . . . . . . 6-6

    Zooming . . . . . . . . . . . . . . . . . . . . . . 6-7

    The Toolbar . . . . . . . . . . . . . . . . . . . . . 6-10

    6 Working with Plots

    Plot Editing in MPC An Example

    Figure 4-7 and Figure 4-8 illustrate several MPC plot editing features (seePlot Editing Options on page 6-3). To reproduce such combined graphs,

  • 8/6/2019 Mpc Gui Manual

    90/109

    6-2

    1 Display the results for the two cases in separate windows (double-click on

    the corresponding results icons).

    2 Change the responses for one of the cases to a new color (red, for example)

    by right-clicking on each curve, then selecting the desired color from the

    context menu.

    3 Copy each of the red curves to the other window by right-clicking on a curve,

    then selecting Copy Line. Then right-click in the corresponding axis of the

    other window and select Paste Line.

    4 Edit the figure titles to add TEX formatting that converts the numbers to

    subscripts. Click on the title you wish to edit. Suppose its N2. Then insert

    an underscore between the N and the 2 (i.e., N_2). Finally, hit the Esc key

    or click somewhere else in the figure. The N_2 should change to N2.

    5 Hide the legends in the upper two plots. Right-click inside each plot (but not

    on a curve) and select Hide Legend in the context menu.

    6 Edit the remaining legend. In the plot on the lower left, right-click on the

    green curve, then select Edit/Add Legend. Edit the legend and hit the Enter

    key. Repeat for the red curve. Then drag the new legend to the location

    shown.

    Plot Editing Options

    Plot Editing Options

    NOTE:

    Editing effects disappear when you close a figure window. If you wish

    h f d h h S d i

  • 8/6/2019 Mpc Gui Manual

    91/109

    6-3

    to save the state after youve made some changes, use the Save command in

    the File menu. Then to retrieve it, use the Open command in the File

    menu.

    Context MenusYou can use special context menus to modify the appearance of MPC plots. To

    see the context menu, right-click on the appropriate region of the plot (when

    using a one-button Macintosh mouse, click while holding down the Optionkey).

    MPC plots have two types of context menus:

    Curve. Right-click on a curve. The context menu options apply to that curve.

    Plot. Right-click within a plot axis, but not on a curve. The operationsperformed by this context menu apply to the plot as a whole.

    The Curve Context MenuThe Curve context menu options are:

    Color. Change the curves color (seven different colors allowed).

    Style. Change the line style (solid, dash, dash-dot,etc.).

    Width. Set the line width (choose a numerical value in points).

    Marker. Add or remove a marker for each data point (14 different markers).

    Zoom with Mouse. See Zooming on page 6-7.

    Edit Axis Limits. See Edit Axis Limits on page 6-4.

    Copy Line. Copy the curve to a special clipboard. You can thenpaste it into

    another MPC plot (see Paste Line on page 6-4). MPC copies the legend and

    formatting information (color, etc.) as well as the data.Delete Line. This removes the curve and its legend (no Undo!).

    Edit/Add Legend. Displays an edit box containing the existing legend (or a

    blank field if no legend exists). Change it as you wish. You may use TEX

    6 Working with Plots

    formatting for special effects (see TeX Interpreter on page 6-7). When

    finished editing, hit theEnter key.

    See Figure 4-8 and related discussion for an example application of some of

    these features.

  • 8/6/2019 Mpc Gui Manual

    92/109

    6-4

    The Plot Context MenuIn the discussion of the following items, a plot is one of the axes in which a

    plot appears. (An MPC plotting window may contain more than one axis.) The

    current plot is the axis in which you have just activated the context menu.

    Paste LineOnce you have used Copy Line to copy a curve to the clipboard (see page 6-3)

    Paste Line pastes the curve into the current plot.

    Zoom with MouseThis allows you to focus on a particular region of a plot. It includes options to

    zoom either thex ory coordinates of all plots in a figure window. See Zoomingon page 6-7 for more details.

    Edit Axis LimitsThis is an alternative to zooming with the mouse. It brings up a standard

    Matlab dialog box. You can then set the axis limits of the current plot. When

    you close the dialog, MPC gives you the option to apply changes to all axes in a

    figure window.

    Change TitleThe plot title (if any) highlights so you can edit it. (Clicking on an existing title

    does the same thing.) When finished, click outside the highlighted area or push

    the Esc key. You may include TEX formatting for special effects (see TeX

    Interpreter on page 6-7). If no title exists, a blank area highlights so you can

    enter one.

    Change X-Axis LabelAs for Change Title, but for the label below the horizontal axis.

    Plot Editing Options

    Change Y-Axis LabelAs for Change Title, but for the label below the vertical axis.

    Import PlotImports plot data from the main Matlab workspace then adds all the curves

  • 8/6/2019 Mpc Gui Manual

    93/109

    6-5

    Imports plot data from the main Matlab workspace, then adds all the curves

    defined therein to the current plot.

    The imported data must be a Matlab structure in the mpcplot format. Type

    help mpcplot in the command window for a summary of the fields. (An easy

    way to generate such data is to Export it from an MPC plot see next section).

    The context menu displays a dialog box that lists all the structures in your

    main workspace. Select the one you wish to import, then click Import.

    NOTE: If the imported data defines multiple plots, you will be asked to choose

    one of them. If the data you wish to import doesnt appear in the list, Matlab

    doesnt recognize that variable as a structure. Use the whos command to check

    the contents of your main Matlab workspace.

    Export PlotSaves the current plots data and formatting information as a structure in the

    main Matlab workspace. See the function mpcplot for details (or type help

    mpcplot in the Command window.

    Export AllAs for Export Plot (previous section), but all plots in the figure window are

    exported (not just the current plot).

    Hide/Show LegendMPC hides the legend associated with the current plot (if its showing) or

    reveals it (if its hidden).

    No legend will appear unless youve defined a legend string for at least one ofthe curves in the plot (seeAdd/Edit Legend on page 6-3).

    6 Working with Plots

    Add/Delete AxisAdd Axis adds a blank axis to the figure window. The new axis will appear after

    all the existing axes. You can then import plot data to the new axis.

    Delete Axis permanently removes the current axis from the figure window (no

    U d !)

  • 8/6/2019 Mpc Gui Manual

    94/109

    6-6

    Undo!).

    FontFont displays a font selection dialog where you can specify the font type and

    size used in all plot labels (including axes and legends). Your selection will

    apply to allaxes in the current figure window.

    Use this feature to increase the font size for presentations (slides and

    transparencies).

    Editing Text

    Text Objects in the MPC GUI

    You can edit the following text objects:

    Plot titles.

    X-axis labels.

    Y-axis labels.

    Legend strings.

    Icon names (on the Worksheet)

    To edit one of the first three, click on it. The text highlights and you can edit it.

    When finished, click outside the edit field or push the Esc key.

    Another way is to use the plots context menu. See page 6-4.

    To edit a legend string, use the curve context menu (Edit/Add Legend). See

    page 6-3.

    To edit the name of an icon on the Worksheet, right-click on the icon to get its

    context menu, then select Rename. This highlights the icon name so you canedit it. When finished, click outside the name field or hit the Esc key.

    Plot Editing Options

    TeX InterpreterAll MPC text objects have the Interpreter property set to TeX. This allows

    you to define plot labels and legends that contain Greek characters, subscriptsand superscripts, mathematical symbols, combinations of bold, italics, and

    normal fonts,etc. Figure 4-8 and associated discussion give you one example of

  • 8/6/2019 Mpc Gui Manual

    95/109

    6-7

    the possibilities.

    For additional information and examples see the on-line Matlab

    documentation:

    Text Properties (Matlab Function Reference)

    Text (Matlab Function Reference)

    ZoomingMPC allows you to zoom in on a plot region.

    If your plot window contains multiple axes, you have the option to zoom all

    plots simultaneously.

    Consider the plot window shown in Figure 6-1. We have just turned the MPCzoom mode On using the context menu (right-click in any plot axis, then select

    Zoom with Mouse; see page 6-4). You can tell that zooming is on because the UI

    controls at the bottom differ from the standard MPC controls (e.g., compare to

    Figure 5-2) and the cursor changes to a crosshair.

    Most of the action is happening between time 8 and 15. Wed like to expand this

    region of each plot without changing the y-axis scales (which are all different).

    Click the X radio button on the lower-left.

    Click the All X radio button on the lower-right.

    Click and drag in any of the plot axes such that you begin at about time = 8,

    and end at about time = 15. In this case it doesnt matter how much you move

    in the y-axis dimension (because neither XY nor Y is selected in the

    lower-left).

    6 Working with Plots

    0.1H2

    4N1

  • 8/6/2019 Mpc Gui Manual

    96/109

    6-8

    Figure 6-1 A plot for which the MPC zoom mode has just been turned on.

    When you release the mouse button, all three x-axis scales should zoom, giving

    you a plot similar to Figure 6-2 (depending on exactly how you dragged).

    Now suppose you want to make it clear that H2 changes relatively little. You

    could set the radio buttons to Y and All Y, then zoom the y-axis range of theN1 signal (which varies the most). This would change all the y-axis limits to

    vary from -0.1 to 2.2 (again, depending on your mouse skills), and H2 would

    become a small wiggle on this scale (not shown, but try it).

    0 10 20 300.1

    0

    Time0 10 20 30

    2

    0

    2

    Time

    0 10 20 301

    0

    1

    2

    Time

    N2

    Setpoint

    Output

    Plot Editing Options

    0.1H2

    4N1

  • 8/6/2019 Mpc Gui Manual

    97/109

    6-9

    Figure 6-2 After zooming all axes of Figure 5-2 in the x-coordinate (note button states).

    When youre satisfied with the axis limits, click Done to return to the normal

    MPC plot mode.

    NOTE: While the zoom mode is on, MPC wont let you resize the window or

    move the legends, and it disables all plot editing functions.

    8 10 12 140.1

    0

    Time8 10 12 14

    2

    0

    2

    Time

    8 10 12 141

    0

    1

    2

    Time

    N2

    Setpoint

    Output

    6 Working with Plots

    If you wish to set the axis limits precisely, its better to use the Edit Axis

    Limits context menu (see page 6-4).

    The MPC zoom mode also provides the following options:

    Left-click to zoom in on the point under the cross hairs (by a factor of 2). Each

    time you click you zoom further

  • 8/6/2019 Mpc Gui Manual

    98/109

    6-10

    time you click you zoom further.

    Right-click to zoom out by a factor of 2.

    Double-click to revert to the original axis limits.

    The ToolbarThe Matlab Toolbar introduced in Version 5.3 (Release 11) provides yet

    another way to modify your plots properties.

    MPC hides the Toolbar by default. To use it, select Show Toolbar in the

    Tools menu (usually found on the Figure window, but this is

    operating-system dependent).

    Excellent on-line help is available. To see it, select Help Plot Editor in the

    Help menu. The Help menu usually appears near the top of a plot window;this is also system-dependent.

    The Toolbar and the MPC editing features overlap to some extent. Each has its

    strengths. Experiment to see which is more convenient for you.

    NOTE: When the Toolbar is in use, it disables other plot editing functions

    (e.g., the MPC GUI context menus). It also replaces MPC context menus with

    its own. If the expected MPC menu no longer appears, you may need to hide

    the Toolbar. You may also experience strange behavior if you switch back

    and forth between the two editing methods.

    7Worksheet Icons

  • 8/6/2019 Mpc Gui Manual

    99/109

    Icon Menus . . . . . . . . . . . . . . . . . . . . 7-2

    Properties . . . . . . . . . . . . . . . . . . . . . 7-2

    Notes . . . . . . . . . . . . . . . . . . . . . . . 7-2

    Export . . . . . . . . . . . . . . . . . . . . . . . 7-2Import . . . . . . . . . . . . . . . . . . . . . . . 7-3

    Delete . . . . . . . . . . . . . . . . . . . . . . . 7-3

    Rename . . . . . . . . . . . . . . . . . . . . . . 7-3

    Icon Data Structures . . . . . . . . . . . . . . . . 7-4

    Model Icons . . . . . . . . . . . . . . . . . . . . . 7-4

    Controller Icons . . . . . . . . . . . . . . . . . . . 7-7

    Result Icons . . . . . . . . . . . . . . . . . . . . . 7-9

    7 Worksheet Icons

    Icon Menus

    MPC Worksheet icons have context menus that allow you to

    view/modify icon properties

    import/export the icon data.

  • 8/6/2019 Mpc Gui Manual

    100/109

    7-2

    p p

    delete the icon and its data from the Worksheet

    rename the icon.

    To see the context menu, right-click on the icon (option-click the one-button

    Macintosh mouse). The following sections describe the effect of each menuitem.

    PropertiesIf the icon is a Model or a Controller, Properties displays the appropriate

    View/Edit dialog (see Figure 2-5 and Figure 2-6).

    If the icon is a Result, Properties plots the response curves.

    NotesThis displays the current icon notes, if any (see Figure 2-14). You can edit the

    information therein if you wish. Notes help you keep track of the special

    features of each icon.

    When you run a simulation (creating a Result icon), MPC automatically copies

    any notes from the Plant and Controller icons into the Result icon. It also

    adds a summary of the simulation conditions.

    ExportThis exports the icons data to the main MATLAB workspace. Then you can

    either import it into another MPC Worksheet (see next section), or use the data

    for some other purpose (e.g., custom plotting). See Icon Data Structures for

    details.

    Icon Menus

    ImportThis imports icon data from the main MATLAB workspace into a blank icon

    slot on the Workspace. (MPC disables the Import option when you right-clickon a full slot.)

    The data must be stored in a MATLAB structure variable. Each type of icon

  • 8/6/2019 Mpc Gui Manual

    101/109

    7-3

    (Model, Controller, Result) has different data requirements. If the data youre

    importing is incompatible with the type of slot youve chosen, an error message

    appears.

    One way to create a compatible structure is to export it from the Worksheet

    (see previous section).

    DeleteClears the icon from the Worksheet.

    If its in the special Plant, MPC Model, or Controller location, its actually

    deleted (because its just a copy of another icon).

    Otherwise MPC moves it to the Overflow (and you can retrieve it if necessary).

    RenameHighlights the icon name on the Worksheet and allows you to edit it. When

    youre finished editing, click outside the icon or push the Esc key.

    7 Worksheet Icons

    Icon Data Structures

    This section details the icon data structures used in the MPC GUI. You mayneed this information if youve exported data from the MPC Worksheet and

    wish to use it for custom plots,etc.

    All data are MATLAB structure variables See the MATLAB documentation for

  • 8/6/2019 Mpc Gui Manual

    102/109

    7-4

    All data are MATLAB structure variables. See the MATLAB documentation for

    details on working with structures.

    Model Icons

    The fields common to all Model icons appear in Table 7-1.

    NOTE: Structure field names are case-sensitive. When you refer to a field in a

    command, you must type it exactly as shown in the table. This applies to all

    MATLAB structures.

    Table 7-1 Fields common to all MPC Model icons.

    Field Contents

    Name String defining the icon name.

    Type A string that can be either:

    LTI a linear time-invariant model in the standardControl Toolbox format.

    STEP a linear time-invariant step-response model inthe MPC Tools format.

    MDL a Simulink model, usually nonlinear.

    Value Structure containing the model data. Its form depends on

    the model type. See LTI Model on page 7-5, STEP

    Model on page 7-6, or MDL Model on page 7-6

    Rev String containing the date and time the icon was created.

    Notes Character array containing the icon notes.

    Icon Data Structures

    The following sections detail the contents of the Model.Value field for each

    model type.

    LTI ModelThe Value field ofTable 7-1 is a standard LTI object (see the Control Toolbox

    for details).

  • 8/6/2019 Mpc Gui Manual

    103/109

    7-5

    MPC stores another structure in this LTI objects UserData field. Table 7-2

    defines its contents. Its primary use is to hold initial conditions and the class

    of each signal.

    Table 7-2 Contents of the UserData field of an MPC LTI object.

    Field Contents

    InputClass 1 by nin cell array, where nin is the number of plant

    inputs. Each element is a 2-character string designating

    the type of signal (MV, MD, or 'UD).

    OutputClass 1 by nout cell array, where nout is the number of plant

    outputs. Each element is a 2-character string designating

    the type of signal ('CV' or 'UO).

    x0 nx by 1 vector of initial values for the model states, where

    nx is the system order (number of states).

    u0 nu by 1 vector of initial values for the model inputs, where

    nu is the number of inputs.

    y0 ny by 1 vector of initial values for the model outputs,

    where ny is the number of outputs.

    f0 nx by 1 vector of initial time-derivatives of the model

    states.

    7 Worksheet Icons

    STEP ModelIn this case the Value field ofTable 7-1 is a structure. Table 7-3 details its

    contents.

    Table 7-3 Contents of a STEP models Value field.

    Field Contents

  • 8/6/2019 Mpc Gui Manual

    104/109

    7-6

    MDL ModelThe Value field is a structure. See Table 7-4 for details.

    Field Contents

    StepData Matrix of step-response model data. See step

    format in the MPC Tools documentation for

    details.

    InputName 1 by nin cell array, where nin is the number of plant

    inputs. Each element is the name of an input signal (a

    string).

    OutputName 1 by nout cell array, where nout is the number of plant

    outputs. Each element is the name of an output signal (a

    string).

    Ts Sampling period of the step-response model (ascalar).

    UserData A structure with two fields, which are the same as

    the first two fields of Table 7-2.

    Table 7-4 Contents of a MDL model icons Value field.

    Field Contents

    MDLname The name of the Simulink.MDL file defining the

    model.

    InputName 1 by nin cell array, where nin is the number of plant

    inputs. Each element is the name of an input signal (astring).

    Icon Data Structures

    OutputName 1 by nout cell array, where nout is the number of plant

    outputs. Each element is the name of an output signal (a

    string).

    Table 7-4 Contents of a MDL model icons Value field.

    Field Contents

  • 8/6/2019 Mpc Gui Manual

    105/109

    7-7

    Controller IconsEach controller icon contains the information shown in Table 7-5.

    Ts Sampling period (a scalar). Usually zero, i.e., a

    continuous-time model.

    UserData A structure with ten fields. The first six are the

    same as in Table 7-2. The remaining four indicate thevariables held constant in the steady-state calculation

    (MPC Trim, see page 3-4). The field names are iu, iy, ix,

    and idx, corresponding to the inputs, outputs, states, and

    derivatives, respectively. Each field is a vector. Vector

    elements are 1 or 0, depending on whether the

    corresponding variable was held or not.

    Table 7-5 Fields common to all MPC controller icons.

    Field Contents

    Name String defining the icon name.

    Type LMPC Linear MPC (currently the only valid controller

    type. A string.).

    Value The contents depend on whether MPCs internal model is

    LTI or STEP. See LTI Internal Model on page 7-8, and

    STEP Internal Model on page 7-9.

    Rev String containing date and time icon was created.

    Notes Character array containing the icon notes.

    ModelName Name of the Model icon used to design the controller.

    7 Worksheet Icons

    LTI Internal ModelIn this case, the Value field is the MPC internal model in a standard LTI,

    discrete state-space format (i.e., an LTI object).

    The objects UserData field contains a structure defining additional controller

    parameters. See Table 7-6 for its contents.

  • 8/6/2019 Mpc Gui Manual

    106/109

    7-8

    Table 7-6 Structure of LMPC Value.UserData.

    Field Contents

    InputClass 1 by nin cell array, where nin is the number of plant

    inputs. Each element is a 2-character string designating

    the type of signal (MV, MD, or 'UD).

    OutputClass 1 by nout cell array, where nout is the number of plant

    outputs. Each element is a 2-character string designating

    the type of signal ('CV' or 'UO).

    x0 nx by 1 vector of initial values for the model states, where

    nx is the system order (number of states).

    u0 nu by 1 vector of initial values for the model inputs, where

    nu is the number of inputs.

    y0 ny by 1 vector of initial values for the model outputs,

    where ny is the number of outputs.

    f0 nx by 1 vector of initial time-derivatives of the model

    states.

    P Prediction horizon (a scalar).

    M Number of moves (if a scalar) or block durations (if a row

    vector).

    ywt Row vector of output weights, length ny.

    ylim 1 by 2 cell array, {ymin, ymax}. where ymin is a row

    vector of lower bounds, and ymax is a row vector of upper

    bounds. Vectors are length ny.

    uwt Row vector of input weights, length nu.

    Icon Data Structures

    ulim 1 by 3 cell array, {umin, umax, dumax}. where umin is a

    row vector of lower bounds, and umax is a row vector of

    upper bounds, and dumax is the rate-of-change bound.

    Vectors are length nu

    Table 7-6 Structure of LMPC Value.UserData.

    Field Contents

  • 8/6/2019 Mpc Gui Manual

    107/109

    7-9

    STEP Internal ModelIn this case, the Value field is the STEP model structure shown in Table 7-3.

    Its UserData field is a structure that defines the controller parameters. Its

    fields are the same as Table 7-6, except that two of the initial condition

    fields(x0 and f0) are omitted.

    Result IconsEach Result structure contains the fields defined in Table 7-7.

    Vectors are length nu.

    Kest Disturbance estimator gain matrix. See MPC Tools

    documentation for details.

    Anti A structure MPC uses to determine which signals are tobe anticipated.

    Table 7-7 Fields common to all MPC result icons.

    Field Contents

    Name String defining the icon name.

    Type A string that can be either:

    LSIM result of a closed-loop simulation with a LMPCcontroller icon.

    OLSIM result of an open-loop simulation.

    Plant Name of the model icon that was the Plant in the

    simulation (a string).

    7 Worksheet Icons

    MPC Name of the controller icon that was the Controller in

    the simulation (a string). Null if the simulation was

    open-loop.

    C l f i hi h l b i d

    Table 7-7 Fields common to all MPC result icons.

    Field Contents

  • 8/6/2019 Mpc Gui Manual

    108/109

    7-10

    t Column vector of times at which results were obtained.

    Length N.

    u N by nu matrix of manipulated variables (MVs) at each

    time, where nu is the number of MVs.

    v N by nv matrix of measured disturbances (MDs) at each

    time, where nv is the number of MDs. May be empty

    (nv=0).

    w N by nw matrix of unmeasured disturbances (UDs) at each

    time, where nw is the number of UDs. May be empty

    (nw=0).

    y N by ny matrix of outputs at each time, where ny is the

    number of outputs.

    r N by ny matrix of output setpoints at each time.

    SimCond Structure containing a record of the simulation

    conditions. See Table 7-8.

    InputName Cell array, nin by 1, where nin is the number of inputs(nin=nu+nv+nw). Each element is a signal name (string).

    They are arranged in the order [u v w], i.e., the first nu

    correspond to the columns ofu, the next nv to the columns

    ofv, and the final nw to the columns ofw.

    OutputName Cell array, ny by 1. Each element is a signal name for the

    corresponding column in y.

    Rev String containing date and time icon was created.

    Notes Character array containing the icon notes.

    Icon Data Structures

    Table 7-8 Simulation Condition Structure.Field Contents

    Time Simulation elapsed time (i.e., duration specified by user).

    T A t i th t b ith

  • 8/6/2019 Mpc Gui Manual

    109/109

    7-11

    Type A string that can be either:

    CL result of a closed-loop simulation.

    OL result of an open-loop simulation.

    R If the simulation was open-loop, this is empty. Otherwise

    it is a nout by 1 cell array defining the setpoint trajectory

    for each output (where nout is the number of outputs).

    The format is that required by the MPC GUI function

    SIG2MAT. (This also applies to U and N below.)

    U An nin by 1 cell array defining the input trajectories for

    the nin inputs. If the simulation was closed loop, all MVtrajectories in U are ignored, i.e., they are instead

    calculated by MPC.

    N An nout by 1 cell array defining the measurement noise

    trajectories.