371057 e

Upload: narutoseito

Post on 03-Apr-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 371057 e

    1/225

    LabVIEWTM

    Control Design Toolkit User Manual

    Control Design Toolkit User Manual

    August 2007

    371057E-01

  • 7/28/2019 371057 e

    2/225

    Support

    Worldwide Technical Support and Product Information

    ni.com

    National Instruments Corporate Headquarters

    11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100

    Worldwide Offices

    Australia 1800 300 800, Austria 43 662 457990-0, Belgium 32 (0) 2 757 0020, Brazil 55 11 3262 3599,Canada 800 433 3488, China 86 21 5050 9800, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00,Finland 385 (0) 9 725 72511, France 01 57 66 24 24, Germany 49 89 7413130, India 91 80 41190000,Israel 972 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970, Korea 82 02 3451 3400,

    Lebanon 961 (0) 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 (0) 348 433 466,New Zealand 0800 553 322, Norway 47 (0) 66 90 76 60, Poland 48 22 3390150, Portugal 351 210 311 210,Russia 7 495 783 6851, Singapore 1800 226 5886, Slovenia 386 3 425 42 00, South Africa 27 0 11 805 8197,Spain 34 91 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151, Taiwan 886 02 2377 2222,Thailand 662 278 6777, Turkey 90 212 279 3031, United Kingdom 44 (0) 1635 523545

    For further support information, refer to the Technical Support and Professional Services appendix. To commenton National Instruments documentation, the National Instruments Web site at ni.com/info and enter the infocode feedback.

    20042007 National Instruments Corporation. All rights reserved.

  • 7/28/2019 371057 e

    3/225

    Important Information

    WarrantyThe media on which you receive National Instruments software are warranted not to fail to execute programming instructions, due to defectsin materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. National

    Instruments will, at its option, repair or replace software media that do not execute programming instructions if National Instruments receivesnotice of such defects during the warranty period. National Instruments does not warrant that the operation of the software shall beuninterrupted or error free.

    A Return Material Authorization (RMA) number must be obtained from the factory and clearly marked on the outside of the package beforeany equipment will be accepted for warranty work. National Instruments will pay the shipping costs of returning to the owner parts which arecovered by warranty.

    National Instruments believes that the information in this document is accurate. The document has been carefully reviewed for technicalaccuracy. In the event that technical or typographical errors exist, National Instruments reserves the right to make changes to subsequenteditions of this document without prior notice to holders of this edition. The reader should consult National Instruments if errors are suspected.In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.

    EXCEPTASSPECIFIEDHEREIN, NATIONAL INSTRUMENTSMAKESNOWARRANTIES, EXPRESSORIMPLIED, ANDSPECIFICALLYDISCLAIMSANYWARRANTYOFMERCHANTABILITY ORFITNESSFORAPARTICULAR PURPOSE. CUSTOMERSRIGHTTORECOVERDAMAGESCAUSEDBYFAULTORNEGLIGENCEONTHEPARTOFNATIONAL INSTRUMENTSSHALLBELIMITEDTOTHEAMOUNTTHERETOFOREPAIDBYTHECUSTOMER. NATIONAL INSTRUMENTSWILLNOTBELIABLEFORDAMAGESRESULTINGFROMLOSSOFDATA, PROFITS, USEOFPRODUCTS, ORINCIDENTALORCONSEQUENTIALDAMAGES, EVENIFADVISEDOFTHEPOSSIBILITYTHEREOF. This limitation of the liability of National Instruments will apply regardless of the form of action, whether in contract or tort, includingnegligence. Any action against National Instruments must be brought within one year after the cause of action accrues. National Instrumentsshall not be l iable for any delay in performance due to causes beyond its reasonable control. The warranty provided herein does not coverdamages, defects, malfunctions, or service failures caused by owners failure to follow the National Instruments installation, operation, ormaintenance instructions; owners modification of the product; owners abuse, misuse, or negligent acts; and power failure or surges, fire,flood, accident, actions of third parties, or other events outside reasonable control.

    CopyrightUnder the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of NationalInstruments Corporation.

    National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyrightand other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you mayuse NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legalrestriction.

    TrademarksNational Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use sectionon ni.com/legal for more information about National Instruments trademarks.

    MATLAB is a registered trademark of The MathWorks, Inc. Other product and company names mentioned herein are trademarks, registeredtrademarks, or trade names of their respective companies.

    Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have noagency, partnership, or joint-venture relationship with National Instruments.

    PatentsFor patents covering National Instruments products, refer to the appropriate location: HelpPatents in your software, the patents.txt fileon your CD, or ni.com/patents.

    WARNING REGARDING USE OF NATIONAL INSTRUMENTS PRODUCTS(1) NATIONAL INSTRUMENTS PRODUCTS ARE NOT DESIGNED WITH COMPONENTS AND TESTING FOR A LEVEL OFRELIABILITY SUITABLE FOR USE IN OR IN CONNECTION WITH SURGICAL IMPLANTS OR AS CRITICAL COMPONENTS INANY LIFE SUPPORT SYSTEMS WHOSE FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO CAUSE SIGNIFICANTINJURY TO A HUMAN.

    (2) IN ANY APPLICATION, INCLUDING THE ABOVE, RELIABILITY OF OPERATION OF THE SOFTWARE PRODUCTS CAN BEIMPAIRED BY ADVERSE FACTORS, INCLUDING BUT NOT LIMITED TO FLUCTUATIONS IN ELECTRICAL POWER SUPPLY,

    COMPUTER HARDWARE MALFUNCTIONS, COMPUTER OPERATING SYSTEM SOFTWARE FITNESS, FITNESS OF COMPILERSAND DEVELOPMENT SOFTWARE USED TO DEVELOP AN APPLICATION, INSTALLATION ERRORS, SOFTWARE AND HARDWARECOMPATIBILITY PROBLEMS, MALFUNCTIONS OR FAILURES OF ELECTRONIC MONITORING OR CONTROL DEVICES,TRANSIENT FAILURES OF ELECTRONIC SYSTEMS (HARDWARE AND/OR SOFTWARE), UNANTICIPATED USES OR MISUSES, ORERRORS ON THE PART OF THE USER OR APPLICATIONS DESIGNER (ADVERSE FACTORS SUCH AS THESE ARE HEREAFTERCOLLECTIVELY TERMED SYSTEM FAILURES). ANY APPLICATION WHERE A SYSTEM FAILURE WOULD CREATE A RISK OFHARM TO PROPERTY OR PERSONS (INCLUDING THE RISK OF BODILY INJURY AND DEATH) SHOULD NOT BE RELIANT SOLELYUPON ONE FORM OF ELECTRONIC SYSTEM DUE TO THE RISK OF SYSTEM FAILURE. TO AVOID DAMAGE, INJURY, OR DEATH,THE USER OR APPLICATION DESIGNER MUST TAKE REASONABLY PRUDENT STEPS TO PROTECT AGAINST SYSTEM FAILURES,INCLUDING BUT NOT LIMITED TO BACK-UP OR SHUT DOWN MECHANISMS. BECAUSE EACH END-USER SYSTEM ISCUSTOMIZED AND DIFFERS FROM NATIONAL INSTRUMENTS' TESTING PLATFORMS AND BECAUSE A USER OR APPLICATIONDESIGNER MAY USE NATIONAL INSTRUMENTS PRODUCTS IN COMBINATION WITH OTHER PRODUCTS IN A MANNER NOTEVALUATED OR CONTEMPLATED BY NATIONAL INSTRUMENTS, THE USER OR APPLICATION DESIGNER IS ULTIMATELYRESPONSIBLE FOR VERIFYING AND VALIDATING THE SUITABILITY OF NATIONAL INSTRUMENTS PRODUCTS WHENEVERNATIONAL INSTRUMENTS PRODUCTS ARE INCORPORATED IN A SYSTEM OR APPLICATION, INCLUDING, WITHOUTLIMITATION, THE APPROPRIATE DESIGN, PROCESS AND SAFETY LEVEL OF SUCH SYSTEM OR APPLICATION.

  • 7/28/2019 371057 e

    4/225

    National Instruments Corporation v Control Design Toolkit User Manual

    Contents

    About This Manual

    Conventions ...................................................................................................................xiRelated Documentation..................................................................................................xii

    Chapter 1Introduction to Control Design

    Model-Based Control Design ........................................................................................1-2Developing a Plant Model...............................................................................1-3Designing a Controller ....................................................................................1-3Simulating the Dynamic System ..................................................................... 1-4Deploying the Controller.................................................................................1-4

    Overview of the Control Design Toolkit .......................................................................1-4Control Design VIs..........................................................................................1-4Control Design MathScript Functions.............................................................1-5

    Chapter 2Constructing Dynamic System Models

    Constructing Accurate Models ...................................................................................... 2-2Model Representation....................................................................................................2-3

    Model Types....................................................................................................2-3Linear versus Nonlinear Models.......................................................2-3Time-Variant versus Time-Invariant Models ...................................2-4Continuous versus Discrete Models..................................................2-4

    Model Forms ...................................................................................................2-4RLC Circuit Example .................................................................................................... 2-6Constructing Transfer Function Models........................................................................2-6

    SISO Transfer Function Models......................................................................2-7SIMO, MISO, and MIMO Transfer Function Models ....................................2-9Symbolic Transfer Function Models...............................................................2-11

    Constructing Zero-Pole-Gain Models............................................................................2-12SISO Zero-Pole-Gain Models .........................................................................2-13

    SIMO, MISO, and MIMO Zero-Pole-Gain Models........................................2-13Symbolic Zero-Pole-Gain Models...................................................................2-14

    Constructing State-Space Models..................................................................................2-14SISO State-Space Models................................................................................2-16SIMO, MISO, and MIMO State-Space Models .............................................. 2-17Symbolic State-Space Models.........................................................................2-18

    Obtaining Model Information........................................................................................2-18

  • 7/28/2019 371057 e

    5/225

    Contents

    Control Design Toolkit User Manual vi ni.com

    Chapter 3Converting Models

    Converting between Model Forms ................................................................................ 3-1Converting Models to Transfer Function Models........................................... 3-2Converting Models to Zero-Pole-Gain Models .............................................. 3-3Converting Models to State-Space Models..................................................... 3-4

    Converting between Continuous and Discrete Models ................................................. 3-5Converting Continuous Models to Discrete Models....................................... 3-6

    Forward Rectangular Method........................................................... 3-8Backward Rectangular Method ........................................................ 3-8Tustins Method................................................................................ 3-9Prewarp Method ............................................................................... 3-10Zero-Order-Hold and First-Order-Hold Methods............................. 3-11Z-Transform Method ........................................................................ 3-12Matched Pole-Zero Method.............................................................. 3-13

    Converting Discrete Models to Continuous Models....................................... 3-13Resampling a Discrete Model ......................................................................... 3-14

    Chapter 4Connecting Models

    Connecting Models in Series......................................................................................... 4-1Connecting SISO Systems in Series ............................................................... 4-2Creating a SIMO System in Series ................................................................. 4-3Connecting MIMO Systems in Series............................................................. 4-5

    Appending Models ........................................................................................................ 4-6

    Connecting Models in Parallel ...................................................................................... 4-8Placing Models in a Closed-Loop Configuration.......................................................... 4-12

    Single Model in a Closed-Loop Configuration............................................... 4-13Feedback Connections Undefined .................................................... 4-13Feedback Connections Defined ........................................................ 4-14

    Two Models in a Closed-Loop Configuration ................................................ 4-14Feedback and Output Connections Undefined ................................. 4-15Feedback Connections Undefined, Output Connections

    Defined........................................................................................... 4-16Feedback Connections Defined, Output Connections

    Undefined....................................................................................... 4-17Both Feedback and Output Connections Defined ............................ 4-18

    Chapter 5Time Response Analysis

    Calculating the Time-Domain Solution......................................................................... 5-1Spring-Mass Damper Example...................................................................................... 5-2

  • 7/28/2019 371057 e

    6/225

    Contents

    National Instruments Corporation vii Control Design Toolkit User Manual

    Analyzing a Step Response............................................................................................5-4Analyzing an Impulse Response....................................................................................5-7Analyzing an Initial Response ....................................................................................... 5-8Analyzing a General Time-Domain Simulation ............................................................5-10Obtaining Time Response Data ..................................................................................... 5-12

    Chapter 6Working with Delay Information

    Accounting for Delay Information ................................................................................6-2Setting Delay Information ...............................................................................6-2Incorporating Delay Information.....................................................................6-2

    Delay Information in Continuous System Models............................6-3Delay Information in Discrete System Models.................................6-6

    Representing Delay Information....................................................................................6-8Manipulating Delay Information ...................................................................................6-10

    Accessing Total Delay Information.................................................................6-10Distributing Delay Information.......................................................................6-12Residual Delay Information ............................................................................6-13

    Chapter 7

    Frequency Response AnalysisBode Frequency Analysis ..............................................................................................7-1

    Gain Margin.....................................................................................................7-3Phase Margin...................................................................................................7-3

    Nichols Frequency Analysis ..........................................................................................7-5Nyquist Stability Analysis ............................................................................................. 7-5Obtaining Frequency Response Data.............................................................................7-7

    Chapter 8Analyzing Dynamic Characteristics

    Determining Stability.....................................................................................................8-1Using the Root Locus Method.......................................................................................8-2

    Chapter 9

    Analyzing State-Space CharacteristicsDetermining Stability.....................................................................................................9-2Determining Controllability and Stabilizability ............................................................ 9-2Determining Observability and Detectability................................................................9-3Analyzing Controllability and Observability Grammians.............................................9-4Balancing Systems.........................................................................................................9-5

  • 7/28/2019 371057 e

    7/225

    Contents

    Control Design Toolkit User Manual viii ni.com

    Chapter 10

    Model Order ReductionObtaining the Minimal Realization of Models.............................................................. 10-1Reducing the Order of Models ...................................................................................... 10-2

    Selecting and Removing an Input, Output, or State ...................................................... 10-3

    Chapter 11Designing Classical Controllers

    The Root Locus Design Technique ............................................................................... 11-1The Proportional-Integral-Derivative Controller Architecture ..................................... 11-4Designing PID Controllers Analytically ....................................................................... 11-6

    Chapter 12Designing State-Space Controllers

    Calculating Estimator and Controller Gain Matrices .................................................... 12-1Pole Placement Technique .............................................................................. 12-2Linear Quadratic Regulator Technique........................................................... 12-4Kalman Gain ................................................................................................... 12-5

    Continuous Models........................................................................... 12-6Discrete Models ................................................................................ 12-6

    Updated State Estimate ...................................................... 12-6Predicted State Estimate..................................................... 12-7

    Discretized Kalman Gain.................................................................. 12-8Defining Kalman Filters.................................................................................. 12-8

    Linear Quadratic Gaussian Controller ............................................................ 12-9

    Chapter 13Defining State Estimator Structures

    Measuring and Adjusting Inputs and Outputs ............................................................... 13-1Adding a State Estimator to a General System Configuration ...................................... 13-2Configuring State Estimators ........................................................................................ 13-3

    System Included Configuration ...................................................................... 13-4System Included Configuration with Noise .................................................... 13-5Standalone Configuration ............................................................................... 13-6

    Example System Configurations ................................................................................... 13-7Example System Included State Estimator ..................................................... 13-8Example System Included State Estimator with Noise................................... 13-10Example Standalone State Estimator .............................................................. 13-12

  • 7/28/2019 371057 e

    8/225

    Contents

    National Instruments Corporation ix Control Design Toolkit User Manual

    Chapter 14

    Defining State-Space Controller StructuresConfiguring State Controllers........................................................................................14-1

    State Compensator...........................................................................................14-3

    System Included Configuration ........................................................14-4System Included Configuration with Noise......................................14-5Standalone Configuration with Estimator.........................................14-6Standalone Configuration without Estimator....................................14-7

    State Regulator ................................................................................................14-8System Included Configuration ........................................................14-9System Included Configuration with Noise......................................14-10Standalone Configuration with Estimator.........................................14-11Standalone Configuration without Estimator....................................14-12

    State Regulator with Integral Action...............................................................14-13System Included Configuration ........................................................14-14

    System Included Configuration with Noise......................................14-16Standalone Configuration with Estimator.........................................14-17Standalone Configuration without Estimator....................................14-19

    Example System Configurations ................................................................................... 14-20Example System Included State Compensator................................................14-22Example System Included State Compensator with Noise ............................. 14-24Example Standalone State Compensator with Estimator................................14-25Example Standalone State Compensator without Estimator...........................14-27

    Chapter 15

    Estimating Model StatesPredictive Observer........................................................................................................15-2Current Observer............................................................................................................15-6Continuous Observer ..................................................................................................... 15-8

    Chapter 16Using Stochastic System Models

    Constructing Stochastic Models .................................................................................... 16-1Constructing Noise Models ...........................................................................................16-3

    Converting Stochastic Models.......................................................................................16-3Converting between Continuous and Discrete Stochastic Models..................16-4Converting between Stochastic and Deterministic Models.............................16-4

    Simulating Stochastic Models ....................................................................................... 16-4Using a Kalman Filter to Estimate Model States...........................................................16-5Noisy RL Circuit Example ............................................................................................16-7

    Constructing the System Model ...................................................................... 16-8

  • 7/28/2019 371057 e

    9/225

    Contents

    Control Design Toolkit User Manual x ni.com

    Constructing the Noise Model ........................................................................ 16-9Converting the Model ..................................................................................... 16-11Simulating The Model .................................................................................... 16-12Implementing a Kalman Filter ........................................................................ 16-14

    Chapter 17Deploying a Controller to a Real-Time Target

    Defining Controller Models .......................................................................................... 17-3Defining a Controller Model Interactively...................................................... 17-3Defining a Controller Model Programmatically ............................................. 17-4

    Writing Controller Code................................................................................................ 17-4Example Transfer Function Controller Code.................................................. 17-5Example State Compensator Code.................................................................. 17-6Example SISO Zero-Pole-Gain Controller with Saturation Code .................. 17-7Example State-Space Controller with Predictive Observer Code................... 17-8

    Example State-Space Controller with Current Observer Code....................... 17-9Example State-Space Controller with Kalman Filter for Stochastic

    System Code................................................................................................. 17-11Example Continuous Controller Model with Kalman Filter Code ................. 17-12

    Finding Example NI-DAQmx I/O Code ....................................................................... 17-13

    Chapter 18

    Creating and Implementing a Model Predictive ControllerCreating the MPC Controller......................................................................................... 18-3

    Defining the Prediction and Control Horizons ............................................... 18-3Specifying the Cost Function.......................................................................... 18-5Specifying Hard Constraints ........................................................................... 18-7

    Specifying Input Setpoint, Output Setpoint, and Disturbance Profiles ......................... 18-7Implementing the MPC Controller................................................................................ 18-8

    Providing Setpoint and Disturbance Information in Advance ........................ 18-9Updating Setpoint and Disturbance Information Dynamically....................... 18-11

    Appendix ATechnical Support and Professional Services

  • 7/28/2019 371057 e

    10/225

    National Instruments Corporation xi Control Design Toolkit User Manual

    About This Manual

    This manual contains information about the purpose of control design andthe control design process. This manual also describes how to develop acontrol design system using the LabVIEW Control Design Toolkit.

    This manual requires that you have a basic understanding of the LabVIEWenvironment. If you are unfamiliar with LabVIEW, the Getting Started withLabVIEWmanual before reading this manual.

    Conventions

    The following conventions appear in this manual:

    The symbol leads you through nested menu items and dialog box optionsto a final action. The sequence FilePage SetupOptions directs you topull down the File menu, select the Page Setup item, and select Optionsfrom the last dialog box.

    This icon denotes a note, which alerts you to important information.

    bold Bold text denotes items that you must select or click in the software, suchas menu items and dialog box options. Bold text also denotes parameternames.

    italic Italic text denotes variables, emphasis, a cross-reference, or an introductionto a key concept. Italic text also denotes text that is a placeholder for a wordor value that you must supply.

    monospace Text in this font denotes text or characters that you should enter from thekeyboard, sections of code, programming examples, and syntax examples.This font is also used for the proper names of disk drives, paths, directories,programs, subprograms, subroutines, device names, functions, operations,variables, filenames, and extensions.

    monospace bold Bold text in this font denotes the messages and responses that the computerautomatically prints to the screen. This font also emphasizes lines of codethat are different from the other examples.

  • 7/28/2019 371057 e

    11/225

    About This Manual

    Control Design Toolkit User Manual xii ni.com

    Related Documentation

    The following documents contain information that you might find helpfulas you use the Control Design Toolkit.

    LabVIEW Help, available by selecting HelpSearch the LabVIEWHelp

    The LabVIEW Simulation Moduledocumentation

    The LabVIEW Real-Time Moduledocumentation

    LabVIEW PID Control Toolkit User Manual

    LabVIEW System Identification Toolkit User Manual

    Example VIs located in the labview\examples\ControlDesign\ directory. You also can use the NI Example Finder, availableby selecting HelpFind Examples, to find example VIs.

    The following resources contain information about concepts related to theControl Design Toolkit.

    Note The following resources offer useful background information on the generalconcepts discussed in this documentation. These resources are provided for generalinformational purposes only and are not affiliated, sponsored, or endorsed by NationalInstruments. The content of these resources is not a representation of, may not correspondto, and does not imply current or future functionality in the Control Design Toolkit or anyother National Instruments product.

    strm, K., and T. Hagglund. 1995. PID controllers: Theory, design,and tuning. 2d ed. ISA.

    Balbis, Luisella. 2006. Predictive control tool kit. UKACC control,2006. Mini symposia:8796.

    Dorf, R. C., and R. H. Bishop. 2001.Modern control systems. 9th ed.Upper Saddle River, NJ: Prentice Hall.

    Franklin, G. F., J. D. Powell, and A. Emami-Naeini. 2002. Feedbackcontrol of dynamic systems. 4th ed. Upper Saddle River, NJ: PrenticeHall.

    Franklin, G. F., J. D. Powell, and M. L. Workman. 1998.Digitalcontrol of dynamic systems. 3d ed. Menlo Park, CA: Addison WesleyLongman, Inc.

    Nise, Norman S. 2000. Control systems engineering. 3d ed. New York:John Wiley & Sons, Inc.

  • 7/28/2019 371057 e

    12/225

    About This Manual

    National Instruments Corporation xiii Control Design Toolkit User Manual

    Ogata, Katsuhiko. 1995.Discrete-time control systems. 2d ed.Englewood Cliffs, N.J.: Prentice Hall.

    Ogata, Katsuhiko. 2001.Modern control engineering. 4th ed. UpperSaddle River, NJ: Prentice Hall.

    Zhou, Kemin, and John C. Doyle. 1998.Essentials of robust control.Upper Saddle River, NJ: Prentice Hall.

  • 7/28/2019 371057 e

    13/225

    National Instruments Corporation 1-1 Control Design Toolkit User Manual

    1Introduction to Control Design

    Control design is a process that involves developing mathematical modelsthat describe a physical system, analyzing the models to learn about theirdynamic characteristics, and creating a controller to achieve certaindynamic characteristics. Control systems contain components that direct,command, and regulate the physical system, also known as the plant. In thismanual, the control system refers to the sensors, the controller, and theactuators. The reference input refers to a condition of the system that youspecify.

    The dynamic system, shown in Figure 1-1, refers to the combination of thecontrol system and the plant.

    Figure 1-1. Dynamic System

    The dynamic system in Figure 1-1 represents a closed-loop system, alsoknown as a feedback system. In closed-loop systems, the control systemmonitors the outputs of the plant and adjusts the inputs to the plant to makethe actual response closer to the input that you designate.

    One example of a closed-loop system is a system that regulates roomtemperature. In this example, the reference input is the temperature atwhich you want the room to stay. The thermometer senses the actualtemperature of the room. Based on the reference input, the thermostatactivates the heater or the air conditioner. In this example, the room is theplant, the thermometer is the sensor, the thermostat is the controller, and theheater or air conditioner is the actuator.

    Controller Actuators

    Sensors

    Physical System(Plant)

    Reference

    Control System

  • 7/28/2019 371057 e

    14/225

    Chapter 1 Introduction to Control Design

    Control Design Toolkit User Manual 1-2 ni.com

    Other common examples of control systems include the followingapplications:

    Automobile cruise control systems

    Robots in manufacturing

    Refrigerator temperature control systems Hard drive head control systems

    This chapter provides an overview of model-based control design anddescribes how you can use the LabVIEW Control Design Toolkit to designa controller.

    Model-Based Control Design

    Model-based control design involves the following four phases:

    developing and analyzing a model to describe a plant, designing andanalyzing a controller for the dynamic system, simulating the dynamicsystem, and deploying the controller. Because model-based control designinvolves many iterations, you might need to repeat one or more of thesephases before the design is complete. Figure 1-2 shows how NationalInstruments provides solutions for each of these phases.

    Figure 1-2. Using LabVIEW in Model-Based Control Design

    National Instruments also provides products for I/O and signalconditioning that you can use to gather and process data. Using these tools,which are built on the LabVIEW platform, you can experiment withdifferent approaches at each phase in model-based control design andquickly identify the optimal design solution for a control system.

    Developing aPlant Model

    System IdentificationToolkit

    LabVIEW

    Control Design

    Control DesignToolkit

    Simulation

    LabVIEW

    SimulationModule

    Deployment

    LabVIEW Real-TimeModule

  • 7/28/2019 371057 e

    15/225

    Chapter 1 Introduction to Control Design

    National Instruments Corporation 1-3 Control Design Toolkit User Manual

    Developing a Plant ModelThe first phase of model-based control design involves developing andanalyzing a mathematical model of the plant you want to control. You canuse a process called system identification to obtain and analyze this model.The system identification process involves acquiring data from a plant andthen numerically analyzing stimulus and response data to estimate theparameters and order of the model.

    The system identification process requires a combination of the followingcomponents:

    Signal generation and data acquisitionNational Instrumentsprovides software and hardware that you can use to stimulate andmeasure the response of the plant.

    Mathematical tools to model a dynamic systemThe LabVIEWSystem Identification Toolkit contains VIs to help you estimate andcreate accurate mathematical models of dynamic systems. You can usethis toolkit to create discrete linear models of systems based onmeasured stimulus and response data.

    Note This manual does not provide a comprehensive discussion of system identification.Refer to the resources listed in theRelated Documentation section of this manual for moreinformation about developing a plant model.

    Designing a Controller

    The second phase of model-based control design involves two steps.The first step is analyzing the plant model obtained during the systemidentification process. The second step is designing a controller based onthat analysis. You can use the Control Design VIs and tools to completethese steps. These VIs and tools use both classical and state-spacetechniques.

    Figure 1-3 shows the typical steps involved in designing a controller.

    Figure 1-3. Control Design Process

    DetermineSpecifications

    CreateMathematical

    Model

    AnalyzeSystem

    SynthesizeController

  • 7/28/2019 371057 e

    16/225

    Chapter 1 Introduction to Control Design

    Control Design Toolkit User Manual 1-4 ni.com

    You often iterate these steps to achieve an acceptable design that isphysically realizable and meets specific performance criteria.

    Simulating the Dynamic SystemThe third phase of model-based control design involves validating thecontroller design obtained in the previous phase. You perform thisvalidation by simulating the dynamic system. For example, simulating a jetengine saves time, labor, and money compared to building and testing anactual jet engine.

    You can use the Control Design Toolkit to simulate linear time-invariantsystems. The LabVIEW Simulation Module, however, provides a variety ofdifferent numerical integration schemes for simulating more elaboratesystems, such as nonlinear systems. Use the Simulation Module todetermine how a system responds to complex, time-varying inputs.

    Deploying the ControllerThe fourth phase of model-based control design involves deploying thecontroller to a real-time (RT) target. LabVIEW and the LabVIEWReal-Time Module provide a common platform that you can use toimplement the control system.

    Refer to the National Instruments Web site at ni.comfor information aboutthe National Instruments products mentioned in this section.

    Overview of the Control Design ToolkitThe Control Design Toolkit provides a library of VIs and a library ofMathScript functions for designing a controller based on a model of a plant.You can use both tools to complete the entire control design process fromcreating a model of the controller to synthesizing the controller on anRT target.

    Control Design VIs

    The Control Design Toolkit provides VIs that you can use to create anddevelop control design applications in LabVIEW. You can use these VIs todevelop mathematical models of a dynamic system, analyze the models tolearn about their dynamic characteristics, and create controllers to achievespecified dynamic characteristics. You use these VIs to customize aLabVIEW block diagram to achieve specific goals. You also can use

  • 7/28/2019 371057 e

    17/225

    Chapter 1 Introduction to Control Design

    National Instruments Corporation 1-5 Control Design Toolkit User Manual

    other LabVIEW VIs and functions to enhance the functionality of theapplication. Refer to theLabVIEW Help, available by selecting HelpSearch the LabVIEW Help,for information about the Control DesignVIs.

    Creating a LabVIEW application using the Control Design VIs requiresbasic knowledge about programming in LabVIEW. Refer to theLabVIEWHelp for more information about the LabVIEW programming environment.

    Control Design MathScript FunctionsThe Control Design Toolkit also includes numerous functions that extendthe functionality of the LabVIEW MathScript window. Use these functionsto design and analyze controller models in a text-based environment. Yougenerally can use the LabVIEW MathScript engine to execute scripts youhave previously written using The MathWorks, Inc. MATLAB

    application software. However, the MathScript engine is not intended tosupport all functions supported by the MATLAB application software.

  • 7/28/2019 371057 e

    18/225

    National Instruments Corporation 2-1 Control Design Toolkit User Manual

    2Constructing Dynamic System

    Models

    Model-based control design relies upon the concept of a dynamic systemmodel. A dynamic system model is a mathematical representation of thedynamics between the inputs and outputs of a dynamic system. Yougenerally represent dynamic system models with differential equations ordifference equations.

    Obtaining a model of the dynamic system you want to control is the firststep in model-based control design. You analyze this model to anticipatethe outputs of the model when given a set of inputs. Using this analysis, youthen can design a controller that affects the outputs of the dynamic systemin a manner that you specify.

    For example, consider the temperature-regulation example in theintroduction of Chapter 1,Introduction to Control Design. You can analyzethe open-loop dynamics of the plant to effectively design a controller forthis closed-loop dynamic system. A model for this closed-loop dynamicsystem describes the input to the plant as the air flow from the vent. The

    output of the plant is the temperature of the room. By analyzing therelationship between the inputs and output of the plant, you can predict howthe plant reacts when given certain inputs. Based on this analysis, you thencan design a controller for this dynamic system.

    This chapter provides information about using the LabVIEW ControlDesign Toolkit to create dynamic system models. This chapter alsodescribes the different forms that you can use to represent a dynamicsystem model.

    Note Refer to thelabview\examples\Control Design\Getting Started\ModelConstruction.llb for example VIs that demonstrate the concepts explained in thischapter.

  • 7/28/2019 371057 e

    19/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-2 ni.com

    Constructing Accurate Models

    To create a model of a system, think of the system as a black box thatcontinuously accepts inputs and continuously generates outputs. Figure 2-1shows the basic black-box model of a dynamic system.

    Figure 2-1. Black-Box Model of a Dynamic System

    You refer to this model as a black-box model because you often do notknow the relationship between the inputs and outputs of a dynamic system.The model you create, therefore, has errors that you must account for when

    designing a controller.

    An accurate model perfectly describes the dynamic system that itrepresents. Real-world dynamic systems, however, are subject to a varietyof non-deterministic fluctuating conditions and interacting componentsthat prevent you from making a perfect model. You must consider manyexternal factors, such as random interactions and parameter variations. Youalso must consider internal interacting structures and their fundamentaldescriptions.

    Because designing a perfectly accurate model is impossible, you must

    design a controller that accounts for these inaccuracies. A robust controlleris one that functions as expected despite some differences between thedynamic system and the model of the dynamic system. A controller that isnot robust might fail when such differences are present.

    The more accurate a model is, the more complex the mathematicalrelationship between inputs and outputs. At times, however, increasing thecomplexity of the model does not provide any more benefits. For example,if you want to control the interacting forces and friction of a mechanicaldynamic system, you might not need to include the thermodynamic effectsof the system. These effects are complicated features of the system that donot affect the friction enough to impact the robustness of the controller.A model that incorporates these effects can become unnecessarilycomplicated.

    H(s)Input Output

  • 7/28/2019 371057 e

    20/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-3 Control Design Toolkit User Manual

    Model Representation

    You can represent a dynamic system using several types of dynamic systemmodels. You also can represent each type of dynamic system model usingthree different forms. The following sections provide information about the

    different types and forms of dynamic system models that you can constructwith the Control Design Toolkit.

    Model TypesYou base the type of dynamic system model on the properties of thedynamic system on which the model represents. The following sectionsprovide information about the different types of models you can create withthe Control Design Toolkit.

    Linear versus Nonlinear ModelsDynamic system models are either linear or nonlinear. A linear modelobeys the principle of superposition. The following equations are true forlinear models.

    y1 = (x1)

    y2 = (x2)

    Y= (x1 +x2) =y1 +y2

    Conversely, nonlinear models do not obey the principle of superposition.Nonlinear effects in real-world systems include saturation, dead-zone,friction, backlash, and quantization effects; relays; switches; and ratelimiters. Many real-world systems are nonlinear, though you can linearizethe model to simplify a design or analysis procedure. You can use theLabVIEW Simulation Module to perform this linearization task.

    The Control Design Toolkit supports linear models only.

  • 7/28/2019 371057 e

    21/225

  • 7/28/2019 371057 e

    22/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-5 Control Design Toolkit User Manual

    Table 2-1 shows the equations for the different forms of dynamic systemmodels.

    Note Continuous transfer function and zero-pole-gain models use the s variable to define

    time, whereas discrete models in these forms use thez variable. Continuous state-spacemodels use the tvariable to define time, whereas discrete state-space models use thekvariable.

    You can use these forms to describe single-input single-output (SISO),single-input multiple-output (SIMO), multiple-input single-output(MISO), and multiple-input multiple-output (MIMO) systems. The numberof sensors and actuators determines whether a dynamic system is a SISO,SIMO, MISO, or MIMO system.

    The following sections provide information about an example dynamicsystem and how to represent this dynamic system using all three modelforms.

    Table 2-1. Definitions of Continuous and Discrete Systems

    Model

    Form Continuous Discrete

    TransferFunction

    Zero-Pole-Gain

    State-Space

    H s( )b0 b1s bm 1 s

    m 1bms

    m+ + + +

    a0 a1s an 1 sn 1

    ansn

    + + + +----------------------------------------------------------------------------------------------=

    H Hi j=

    H z( )b0 b1z bm 1 z

    m 1bmz

    m+ + + +

    a0 a1z an 1 zn 1

    anzn

    + + + +----------------------------------------------------------------------------------------------=

    H Hi j=

    H s( )k s z1( ) s z2( ) s zm( )

    s p1( ) s p2( )

    s pn( )

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

    H Hi j=

    H z( )k z z1( ) z z2( ) z zm( )

    z p1( ) z p2( )

    z pn( )

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

    H Hi j=

    x Ax Bu+=

    y Cx Du+=

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

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

  • 7/28/2019 371057 e

    23/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-6 ni.com

    RLC Circuit Example

    Figure 2-2 shows an example circuit consisting of a resistorR, an inductorL, a current i(t), a capacitor C, a capacitor voltage vc(t), and an inputvoltage vi(t).

    Figure 2-2. RLC Circuit

    The following sections use this example to illustrate the creation of threeforms of dynamic system models.

    Constructing Transfer Function Models

    Transfer function models use polynomial functions to define the dynamicrelationship between inputs and outputs of a system. You analyze transfer

    function models in the frequency domain. The following equations definecontinuous and discrete transfer function models.

    Continuous Transfer Function Model

    Discrete Transfer Function Model

    Numerators of transfer function models describe the locations of the zerosof the system. Denominators of transfer function models describe thelocations of the poles of the system.

    LR

    vc(t)vi(t)

    i(t)

    C+

    H s( )numerator s( )

    denominator s( )--------------------------------------

    b0 b1s bm 1 sm 1

    bmsm

    + + + +

    a0 a1s an 1 sn 1

    ansn+ + + +

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

    H z( ) numerator z( )denominator z( )-------------------------------------- b0 b1z bm 1 z

    m 1

    bmzm

    + + + +a0 a1z an 1 z

    n 1anz

    n+ + + +---------------------------------------------------------------------------------= =

  • 7/28/2019 371057 e

    24/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-7 Control Design Toolkit User Manual

    Use the CD Construct Transfer Function Model VI to create continuousSISO, SIMO, MISO, and MIMO system models in transfer function form.This VI creates a data structure that defines the transfer function model andcontains additional information about the system, such as the samplingtime, input or output delays, and input and output names. Refer to the

    Obtaining Model Information section of this chapter for information aboutother properties of transfer function models.

    SISO Transfer Function ModelsUsing the example in theRLC Circuit Example section of this chapter, youcan describe the voltage of the capacitor vc using the following secondorder differential equation:

    After taking the Laplace transform and rearranging terms, you then canwrite the transfer function between the input voltage Vi and the capacitorvoltage Vc using the following equation.

    You then can useH(s) to study the dynamic properties of the RLC circuit.

    The following equation defines a continuous transfer function whereR = 20 ,L = 50 mH, and C= 10 F.

    Figure 2-3 shows how you use the CD Construct Transfer Function ModelVI to create this continuous transfer function model.

    Figure 2-3. Creating a Continuous Transfer Function Model

    LCvc RCvc vc+ + vi=

    Vc s( )

    Vi s( )-------------

    1

    LC-------

    s2 Rs

    L------ 1

    LC-------+ +

    ------------------------------- H s( )= =

    H s( )2 10

    6

    s2

    400s 2 106

    + +----------------------------------------------=

  • 7/28/2019 371057 e

    25/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-8 ni.com

    The Numerator and Denominator inputs are arrays with zero-basedindexes. The ith element of the array corresponds to the ith order coefficientof the polynomial. You define the coefficients in ascending order.

    Note The CD Construct Transfer Function Model VI does not automatically cancel

    polynomial roots appearing in both the numerator and the denominator of the transferfunction. Refer to Chapter 10,Model Order Reduction, for information about cancelingpole-zero pairs.

    The CD Construct Transfer Function Model VI creates a continuous model.You can create a discrete transfer function model in one of two ways. Themethod you use depends on whether you know the coefficients of thediscrete transfer function model.

    If you know the coefficients of the discrete transfer function model, you canenter in the appropriate values for Numerator and Denominator and setthe Sampling Time (s) to a value greater than zero. Figure 2-4 shows thisprocess using a sampling time of 10 s.

    Figure 2-4. Using Coefficients to Create a Discrete Transfer Function Model

    If you do not know the coefficients of the discrete transfer function model,you must use the CD Convert Continuous to Discrete VI for the conversion.Set the Sampling Time (s) parameter of this VI to a value greater thanzero. Figure 2-5 shows this process using a sampling time of 10 s.

    Figure 2-5. Using the CD Convert Continuous to Discrete VI to Create a DiscreteTransfer Function Model

  • 7/28/2019 371057 e

    26/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-9 Control Design Toolkit User Manual

    Converting from a continuous model to a discrete model results in thefollowing equation:

    Refer to the Converting Continuous Models to Discrete Models section ofChapter 3, Converting Models, for more information about convertingcontinuous models to discrete models.

    SIMO, MISO, and MIMO Transfer Function ModelsYou can use the CD Construct Transfer Function Model VI to createSIMO, MISO, and MIMO dynamic system models. This section uses aMIMO dynamic system model as an example.

    Consider the two-input two-output system shown in Figure 2-6.

    Figure 2-6. MIMO System with Two Inputs and Two Outputs

    You can define the transfer function of this MIMO system by using thefollowing transfer function matrixH, where each element represents aSISO transfer function.

    H z( )9.9865 10

    5z 9.9732 10

    5+

    z2

    1.9958z 0.996+---------------------------------------------------------------------------=

    H11

    H21

    H12

    H22

    Y1

    Y2

    U1

    U2

    MIMO System

    HH11 H12

    H21 H22

    =

  • 7/28/2019 371057 e

    27/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-10 ni.com

    Suppose the following equations define the SISO transfer functionsbetween each input-output pair.

    Select the MIMO instance of the CD Construct Transfer Function ModelVI to create a MIMO transfer function model. You then can specify eachtransfer function between thej th input and the i th output as the ij th elementof the two-dimensional Transfer Function(s) input array. Figure 2-7shows that the numerator-denominator pair of the first row and first columncorresponds toH11, the numerator-denominator pair of the first row and

    second column corresponds toH12, and so on.

    Figure 2-7. Creating a MIMO Transfer Function Model

    The elements in the Numerator and Denominator arrays correspond tothe coefficients, in ascending order, of the numerator and denominator intheHij transfer function model. For example, the numerator ofH11 is 1,which corresponds to the zero-order coefficient. Therefore, the firstelement in the Numerator array forH11 is 1. The denominator ofH11 is s,which means the value 0 corresponds to the zero-order coefficient and thevalue 1 corresponds to the first-order coefficient. Therefore the firstelement in the Denominator array forH11 is 0 and the second element is 1.

    H111

    s---= H12

    2

    s 1+-----------=

    H21s 3+

    s2

    4s 6+ +--------------------------= H22 4=

  • 7/28/2019 371057 e

    28/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-11 Control Design Toolkit User Manual

    Symbolic Transfer Function ModelsSymbolic models define the transfer function using variables rather thannumerical values. If you want to change the value of R, for example, youonly need to make the change in one location instead of several locations.Select the SISO (Symbolic) or MIMO (Symbolic) instance of theCD Construct Transfer Model VI to create a SISO or MIMO symbolictransfer function model, respectively.

    The following equation is a symbolic version of the transfer functionoriginally defined in the SISO Transfer Function Models section of thischapter.

    Specify the Symbolic Numerator and Symbolic Denominatorcoefficients using the variable namesR,L, and C. You then specify valuesof the numerator and denominator coefficients in the variables input,as shown in Figure 2-8.

    Figure 2-8. Creating a SISO Symbolic Transfer Function Model

    H s( )

    1

    LC-------

    s2 Rs

    L

    ------ 1

    LC

    -------+ +-------------------------------=

  • 7/28/2019 371057 e

    29/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-12 ni.com

    Constructing Zero-Pole-Gain Models

    Zero-pole-gain models are rewritten transfer function models. When youfactor the polynomial functions of a transfer function model, you get azero-pole-gain model. This factoring process shows the gain and the

    locations of the poles and zeros of the system. The locations of these polesdetermine the stability of the dynamic system.

    You analyze zero-pole-gain models in the frequency domain. Thefollowing equations define continuous and discrete zero-pole-gain models,where the numerators and denominators are products of first-orderpolynomials.

    Continuous Zero-Pole-Gain Model

    Discrete Zero-Pole-Gain Model

    In these equations, kis a scalar quantity that represents the gain,zirepresents the locations of the zeros, andpi represents the locations of thepoles of the system model.

    Numerators of zero-pole-gain models describe the location of the zeros of

    the system. Denominators of zero-pole-gain models describe the locationof the poles of the system.

    Use the CD Construct Zero-Pole-Gain Model VI to create SISO, SIMO,MISO, and MIMO system models in zero-pole-gain form. This VI createsa data structure that defines the zero-pole-gain model and containsadditional information about the system, such as the sampling time, input

    Hi j s( ) k

    s zi+

    i 0=

    m

    s pi+

    i 0=

    n

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

    k s z1( ) s z2( ) s zm( )

    s p1( ) s p2( ) s pn( )----------------------------------------------------------------= =

    Hi j z( ) k

    z zi+

    i 0=

    m

    z pi+

    i 0=

    n

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

    k z z1( ) z z2( ) z zm( )

    z p1( ) z p2( ) z pn( )----------------------------------------------------------------= =

  • 7/28/2019 371057 e

    30/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-13 Control Design Toolkit User Manual

    or output delays, and input and output names. Refer to the Obtaining ModelInformation section of this chapter for information about other propertiesof zero-pole-gain models.

    SISO Zero-Pole-Gain ModelsUsing the example in theRLC Circuit Example section of this chapter,the following equation defines a continuous zero-pole-gain model whereR = 20 ,L = 50 mH, and C= 10 F.

    This equation defines a model with one pair of complex conjugate poles at200 1400i.

    Figure 2-9 shows how you use the CD Construct Zero-Pole-Gain Model VIto create this continuous zero-pole-gain model.

    Figure 2-9. Creating a Continuous Zero-Pole-Gain Model

    The CD Construct Zero-Pole-Gain Model VI creates a continuous model.You create a discrete zero-pole-gain model in the same way you create adiscrete transfer function model. Refer to the SISO Transfer FunctionModels section of this chapter for more information about creating adiscrete zero-pole-gain model.

    SIMO, MISO, and MIMO Zero-Pole-Gain ModelsYou create SIMO, MISO, and MIMO zero-pole-gain models the same wayyou create SIMO, MISO, and MIMO transfer function models. Refer to theSIMO, MISO, and MIMO Transfer Function Models section of this chapterfor information about creating these forms of system models.

    H s( )2 10

    6

    s 200 1400i+ +( ) s 200 1400i+( )-------------------------------------------------------------------------------------- 2 10

    6

    s 200 1400i+( )------------------------------------------= =

  • 7/28/2019 371057 e

    31/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-14 ni.com

    Symbolic Zero-Pole-Gain ModelsYou create symbolic zero-pole-gain models the same way you createsymbolic transfer function models. Refer to the Symbolic TransferFunction Models section of this chapter for information about creating asymbolic system model.

    Constructing State-Space Models

    Continuous state-space models use first-order differential equations todescribe the system. Discrete state-space models use difference equationsto describe the system. You analyze state-space models in the time domain.

    Note State-space models can be either deterministic or stochastic. Deterministic modelsdo not account for noise, whereas stochastic models do. This chapter provides information

    about deterministic state-space models. Refer to Chapter 16, Using Stochastic SystemModels, for information about stochastic state-space models.

    The following equations define a continuous and a discrete state-spacemodel.

    Continuous State-Space Model

    Discrete State-Space Model

    Table 2-2 describes the dimensions of the vectors and matrices of astate-space model.

    Table 2-2. Dimensions and Names of State-Space Model Variables

    Variable Dimension Name

    k Discrete time

    n Number of states

    m Number of inputs

    r Number of outputs

    x Ax Bu+=

    y Cx Du+=

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

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

  • 7/28/2019 371057 e

    32/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-15 Control Design Toolkit User Manual

    Use the CD Construct State-Space Model VI to create SISO, SIMO, MISO,

    and MIMO system models in state-space form. This VI creates a datastructure that uses matrices to define the state-space model. The matricesare zero-based two-dimensional arrays of numbers where the ij th element ofthe array corresponds to the ij th element of matrices in a state-space model.You can assume that an nth order system with m inputs and routputs hasstate, input, and output vectors as defined in the following equations:

    State-space models also contain additional information about the system,such as the sampling time, input or output delays, and input and outputnames. Refer to the Obtaining Model Information section of this chapter forinformation about other properties that state-space models contain.

    A n n matrix State matrix

    B n m matrix Input matrixC r n matrix Output matrix

    D r m matrix Direct transmission matrix

    x n-vector State vector

    u m-vector Input vector

    y r-vector Output vector

    Table 2-2. Dimensions and Names of State-Space Model Variables (Continued)

    Variable Dimension Name

    x

    x0

    x1

    .

    .

    .xn 1

    = u

    u0

    u1

    ..um 1

    = y

    y0

    y1

    ..yr 1

    =

  • 7/28/2019 371057 e

    33/225

    Chapter 2 Constructing Dynamic System Models

    Control Design Toolkit User Manual 2-16 ni.com

    SISO State-Space ModelsUsing the example in theRLC Circuit Example section of this chapter, thefollowing equations define a continuous state-space model.

    In these equations,y equals the voltage of the capacitor vc, and u equals theinput voltage vi.

    x equals the voltage of the capacitor and the derivative of that voltage .

    The following matrices define a state-space model whereR = 20 ,L = 50 mH, and C= 10 F.

    When you plug these matrices into the equations for a continuous statespace model defined in the Constructing State-Space Models section of thischapter, you get the following equations:

    x vc

    vc

    0 11

    LC------- R

    L---

    vc

    vc

    01

    LC-------

    vi+= =

    y vc 1 0vc

    vc 0 vi+= =

    vc

    vc

    A0 1

    2 106 400= B

    0

    2 106

    =

    C 1 0= D 0=

    x0 1

    2 106 400

    vc

    vc

    0

    2 106

    vi+=

    y 1 0 vc

    vc 0 vi+=

  • 7/28/2019 371057 e

    34/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-17 Control Design Toolkit User Manual

    Figure 2-10 shows how you use the CD Construct State-Space Model VI tocreate this continuous state-space model.

    Figure 2-10. Creating a Continuous State-Space Model

    Note AlthoughB is a column vector, Cis a row vector, andD is a scalar, you must use the2D array data type when connecting these inputs to the VI.

    The CD Construct State-Space Model VI creates a continuous model. Youcreate a discrete state-space model in the same way you create a discretetransfer function model. Refer to the SISO Transfer Function Models

    section of this chapter for more information about creating a discretestate-space model.

    SIMO, MISO, and MIMO State-Space ModelsYou construct a SIMO, MISO, or MIMO state-space model by ensuring theoutput matrix Cand the input matrixB have the appropriate dimensions.For a SIMO system, construct an output matrix Cwith more than one row.For a MISO system, construct an input matrixB with more than onecolumn. For a MIMO system, construct matrices CandB with more thanone row and column, respectively.

    When you create a SIMO, MISO, or MIMO system, ensure that the directtransmission matrixD has the appropriate dimensions. If you leaveDempty or unwired, the Control Design Toolkit replaces the missing valueswith zeros.

  • 7/28/2019 371057 e

    35/225

  • 7/28/2019 371057 e

    36/225

    Chapter 2 Constructing Dynamic System Models

    National Instruments Corporation 2-19 Control Design Toolkit User Manual

    You can use these data structures with every VI in the Control DesignToolkit that accepts a system model as an input.

    Note Delay information exists in the model properties and not in the mathematical model.Any analysis, such as time- or frequency-domain analysis, you perform on the model doesnot account for delay present in the model. If you want the analysis to account for delaypresent in the model, you must incorporate the delay into the model itself. Refer toChapter 6, Working with Delay Information, for more information about accounting formodel delay.

    You can use the Model Information VIs to get and set various propertiesof the model. Refer to theLabVIEW Help, available by selecting HelpSearch the LabVIEW Help, for more information about using the ModelInformation VIs to view and change the properties of a system model.

    Sampling Time Double-precision,floating-point numeric value

    Represents the sampling time, in seconds,of the system. If a model represents a

    continuous system, the value ofSamplingTime is zero. For discrete system models,the value must be greater than zero.

    State Names Array of strings The i th element of the array defines thename of the i th state of the model. Thisproperty is available with state-spacemodels only.

    Table 2-3. Model Properties (Continued)

    Property Data Type Description

  • 7/28/2019 371057 e

    37/225

  • 7/28/2019 371057 e

    38/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-2 ni.com

    classical control design techniques such as the root locus technique. If themodel is in state-space form, you can design a controller using state-spacecontrol design techniques such as the pole placement technique. Refer toChapter 11,Designing Classical Controllers, and Chapter 12,DesigningState-Space Controllers, for more information about classical and

    state-space control design techniques.The following sections discuss the Model Conversion VIs you can use toconvert between model forms.

    Converting Models to Transfer Function ModelsUse the CD Convert to Transfer Function Model VI to convert azero-pole-gain or state-space model to a transfer function model. Thissection uses a state-space model as an example.

    Note Because transfer function models do not include state information, you lose the statevectorx when you convert a state-space model to a transfer function model. Additionally,the Control Design Toolkit might not be able to recover the same states if you convert themodel back to state-space form.

    Consider the continuous state-space model defined in the ConstructingState-Space Models section of Chapter 2, Constructing Dynamic SystemModels.

    For continuous systems, you can use the Laplace transform to convert fromthe time domain to the Laplace domain model representation.

    Note The equations in this section convert model forms within both the continuous anddiscrete domains. Refer to the Converting between Continuous and Discrete Modelssection of this chapter for information about converting between continuous and discretedomains.

    Applying the Laplace transform to the state-space model results in thefollowing equation:

    In this equation, s is the Laplace variable, andIis the identity matrix withthe same dimensions asA.

    x Ax Bu+=

    y Cx Du+=

    Y s( ) C Is A( )1B D+[ ]U s( )=

  • 7/28/2019 371057 e

    39/225

    Chapter 3 Converting Models

    National Instruments Corporation 3-3 Control Design Toolkit User Manual

    The ratio between the output Y(s) and input U(s) defines the followingmatrix transfer function modelH(s).

    For example, consider the following second-order MISO state-spacesystem model.

    Using the Laplace transform, you obtain the transfer function matrixH(s).

    Converting Models to Zero-Pole-Gain ModelsUse the CD Convert to Zero-Pole-Gain Model VI to convert a transferfunction or state-space model to a zero-pole-gain model. This section usesa transfer function model as an example.

    Note When you convert a state-space model to a zero-pole-gain model, the CD Convertto Zero-Pole-Gain Model VI converts the state-space model to a transfer function modelfirst.

    To convert the transfer function matrixH(s) to the zero-pole-gain form,the Control Design Toolkit calculates the numerator and denominatorpolynomial roots and the gain of each SISO transfer function inH(s).

    H s( )Y s( )U s( )----------- C Is A( ) 1

    B D+=

    x 1 2

    0 1x

    1 0

    0 1u+=

    y 1 0 x 0 0 u+=

    H s( )1

    s 1+----------- 2

    s2

    2s 1+ +--------------------------=

  • 7/28/2019 371057 e

    40/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-4 ni.com

    When you convert the transfer function matrix from the Converting Modelsto Transfer Function Models section of this chapter, you obtain thefollowing zero-pole-gain model:

    This zero-pole-gain model is numerically identical to the transfer functionmodel. The zero-pole-gain form, however, shows the locations of the zerosand poles of a system.

    Converting Models to State-Space ModelsUse the CD Convert to State-Space Model VI to convert a zero-pole-gainor transfer function model to a state-space model. This section uses a

    zero-pole-gain model as an example.

    Note When you convert a zero-pole-gain model to a state-space model, the CD Convertto State-Space Model VI converts the zero-pole-gain model to a transfer function modelfirst.

    When converting a transfer function or zero-pole-gain model, you canspecify whether you want the resulting state-space model to be full orminimal. A full state-space model does not reduce the number of statesdetermined by a least common denominator calculation. A minimal

    state-space model reduces the number of states and produces a minimalrepresentation of the original model. Use the Realization Type parameterof the CD Convert to State-Space Model VI to specify if you want theresulting model to be full or minimal. Refer to the Obtaining the MinimalRealization of Models section of Chapter 10,Model Order Reduction,for more information about minimizing state-space realizations.

    Using the example in the Converting Models to Transfer Function Modelssection of this chapter, the following equation gives the minimal realizationwhen converting a zero-pole-gain model to a state-space model.

    H s( )

    1

    s 1+-----------

    2

    s 1+( )2------------------=

    x 0.33 0.94

    0.47 1.67x

    0.41 0

    0.29 0.87u+=

    y 2.45 0 x 0 0 u+=

  • 7/28/2019 371057 e

    41/225

  • 7/28/2019 371057 e

    42/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-6 ni.com

    In these equations, Trepresents the sample time and w represents theprewarp frequency. T* is a modified sample time that the Prewarp methoduses in converting between continuous and discrete models.

    The following sections provide information about the methods that you canuse to perform continuous to discrete conversions, discrete to continuousconversions, and discrete to discrete conversions.

    Converting Continuous Models to Discrete Models

    To convert a continuous model to a discrete one, first approximate thevalue of the derivative in the continuous equation over each change in time.Then find the area of the geometric region having width dtand height equalto the derivative.

    For example, consider the following first-order continuous differentialequation:

    Tustins Method

    Prewarp Method

    Table 3-1. Mapping Methods for Converting between Continuous and Discrete (Continued)

    Method of Approximation Continuous to Discrete Discrete to Continuous

    s2 z 1( )T z 1+( )--------------------

    z

    1sT

    2------+

    1 sT2

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

    sz z 1( )

    T z 1+( )-----------------------

    T2

    w T2

    ------------- tan

    w-------------------------------=

    z1 sT+1 sT-------------------

    T2

    w T2

    ------------- tan

    w-------------------------------=

    y f t( )=

  • 7/28/2019 371057 e

    43/225

    Chapter 3 Converting Models

    National Instruments Corporation 3-7 Control Design Toolkit User Manual

    To convert this continuous model to a discrete model, evaluate thederivative function (t) at different points to approximate at time t.Figure 3-1 illustrates the function (t) between tand t + T, where Tis thesampling time.

    Figure 3-1. Discretizing a Differential Equation

    Integrating between time tand t + Tresults in the following differenceequation:

    Integratingf() for = tto t+ Trepresents the area under the curve. TheCD Convert Continuous to Discrete VI provides the followingmathematical methods to approximate this area.

    Forward Rectangular

    Backward Rectangular

    Tustins

    Prewarp

    Zero-Order-Hold

    First-Order-Hold

    Z Transform

    Matched Pole Zero

    The following sections provide information about each of these methods.

    y

    f(t)

    t t+ T

    y d

    t

    t T+

    y t T+( ) y t( ) f ( ) dt

    t T+

    = =

  • 7/28/2019 371057 e

    44/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-8 ni.com

    Forward Rectangular MethodThe Forward Rectangular method considers () constant and equal to(t + T) along the integration range. This consideration results in thefollowing equation:

    This method considers the incremental area term between sampling times tand t + Tas a rectangle of width Tand height equal to (t + T), as shownin Figure 3-2.

    Figure 3-2. Forward Rectangular Method

    Figure 3-2 shows that, for this example, the Forward Rectangular methodoverestimates the area under the curve. To minimize this overestimation,use a small sampling interval. Depending on the direction and size of thecurve you are measuring, this overestimation might not occur.

    Backward Rectangular MethodThe Backward Rectangular method considers () constant and equal to(t) along the integration range. This consideration results in the followingequation:

    y t T+( ) y t( ) f t T+( )T+=

    f(t)

    t t+ T

    Forwardf(t+ T)

    y t T+( ) y t( ) f t( )T+=

  • 7/28/2019 371057 e

    45/225

    Chapter 3 Converting Models

    National Instruments Corporation 3-9 Control Design Toolkit User Manual

    This method considers the incremental area term between sampling times tand t + Tas a rectangle of width Tand height equal to (t), as shown inFigure 3-3.

    Figure 3-3. Backward Rectangular Method

    Figure 3-3 shows that, for this example, the Backward Rectangular methodunderestimates the area under the curve. To minimize this underestimation,use a small sampling interval. Depending on the direction and size of thecurve you are measuring, this underestimation might not occur.

    Tustins MethodTustins method, also known as the trapezoid method, uses trapezoidsto provide a balance between the Forward Rectangular and BackwardRectangular methods. Tustins method takes the average of the rectanglesdefined by the Forward and Backward Rectangular methods and uses theaverage value as the incremental area to approximate the area under thecurve.

    Tustins method considers () constant and equal to the average between

    (t) and (t + T) along the integration range, which results in the followingequation:

    f(t)

    t t+ T

    Backwardf(t+ T)

    y t T+( ) y t( )f t( ) f t T+( )+[ ]

    2-----------------------------------------T+=

  • 7/28/2019 371057 e

    46/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-10 ni.com

    The last term in this equation is identical to the area of a trapezoid of heightTand bases (t) and (t + T). Figure 3-4 shows the area under a curve usingTustins method.

    Figure 3-4. Tustins Method

    Figure 3-4 shows that, for this example, Tustins method provides a balancebetween the overestimation of the Forward Rectangular and theunderestimation of the Backward Rectangular method.

    Prewarp MethodThe Prewarp method is a trapezoidal type of transformation that uses the

    prewarp frequency to adjust the sampling time T. This adjustment resultsin a separate sampling time T*. This adjustment also compensates for errorsintroduced in the discretizing process.

    This method also considers () constant and equal to the average between(t) and (t + T*) along the integration range, which results in thefollowing equation:

    t t+ T

    Tustin

    y t T+( ) y t( )f t( ) f t T*+( )+[ ]

    2-------------------------------------------T+=

  • 7/28/2019 371057 e

    47/225

    Chapter 3 Converting Models

    National Instruments Corporation 3-11 Control Design Toolkit User Manual

    The last term in this equation is identical to the area of a trapezoid ofheight Tand bases (t) and (t + T*). Figure 3-5 shows the area under acurve using the Prewarp method.

    Figure 3-5. Prewarp Method

    Figure 3-5 shows that, for this example, the Prewarp method compensatesfor the integration error by adjusting the sampling time to T*. The areabetween t+ Tand t+ T* is roughly equal to the integration error, which isrepresented by the unshaded portion of the area under the curve.

    Use a particular conversion method based on the model that you areconverting and the requirements of the application for which you aredesigning a control system.

    Zero-Order-Hold and First-Order-Hold MethodsThe Zero-Order-Hold and First-Order-Hold methods assume properties ofthe continuous differential equation . The Zero-Order-Holdmethod assumes that (t) consists of an input that you can hold constantduring the integration period between sampling times tand t + T . TheFirst-Order-Hold method assumes that you can increase this input overtime during this same period. These methods also integrate the remaining

    terms of (t) not related to the input because these terms refer to the internalstate dynamics.

    t t+ T

    Prewarp

    t+ T*

    y f t( )=

  • 7/28/2019 371057 e

    48/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-12 ni.com

    You obtain the following equation after integrating a linear time-invariantsystem between sampling times tand t + T.

    In this equation, u(t) is the input to the system and is not necessarilyconstant between sampling times tand t + T. The following equation showsthe Zero-Order-Hold method approximating the input to a constant valueu(t) during the integration time.

    Conversely, the following equation shows the First-Order-Hold methodramping the input values with a constant slope [u(t + T) u(t)]/Tduringintegration time.

    Refer toDigital Control of Dynamic Systems, as listed in theRelatedDocumentation section of this manual, for more information about theZero-Order-Hold and First-Order-Hold methods.

    Z-Transform MethodThe Z-Transform method is defined such that the continuous and discreteimpulse responses maintain major similarities. You calculate the impulseresponse of the discrete transfer function by multiplying the inverseLaplace transform of the continuous transfer function by the samplingtime T.

    Refer toDiscrete-Time Control Systems, as listed in theRelatedDocumentation section of this manual, for more information about theZ-Transform method.

    x t T+( ) eAT

    x t( ) eA t T + +( )

    Bu ( )d

    t

    t T+

    +=

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

    x t T+( ) eAT

    x t( ) eA t T + +( )

    Bd u t( )t

    t T+

    +=

    x t T+( ) eAT

    x t( ) eA t T + +( )

    B u t( ) u t T+( ) u t( )[ ] t( )

    T---------------+

    d

    t

    t T+

    +=

  • 7/28/2019 371057 e

    49/225

    Chapter 3 Converting Models

    National Instruments Corporation 3-13 Control Design Toolkit User Manual

    Matched Pole-Zero MethodThe Matched Pole-Zero method uses the following relationship betweenthe continuous s and discretez frequency domains.

    In this equation, Tis the sampling time used for the discrete system. TheMatched Pole-Zero method maps continuous-time poles and finite zeros tothez-plane using this relation. This method also maps zeros at infinity toz = 0, so these zeros do not affect the frequency response.

    After the algorithm maps the poles and zeros, the algorithm then attemptsto make sure the system gains are equivalent at some critical frequency. Ifthe systems have no poles or zeros at s = 0 orz = 1, the Matched Pole-Zeromethod selects a discrete-time gain such that the system gains match at

    these locations.

    Alternatively, if the systems have no poles or zeros at s =p(i/T) orz = 1,wherep is the location of a pole, this method equalizes the gains at thatfrequency. If the Matched Pole-Zero method cannot match either of thesegains, the algorithm does not choose a gain.

    Refer toDigital Control of Dynamic Systems, as listed in theRelatedDocumentation section of this manual, for more information about theMatched Pole Zero method.

    Converting Discrete Models to Continuous ModelsUse the CD Convert Discrete to Continuous VI to convert a discrete modelto a continuous model. This VI supports the following conversion methods:Forward Rectangular, Backward Rectangular, Tustins, Prewarp,Z Transform, and Zero-Order-Hold. This VI does not support theFirst-Order-Hold or Matched Pole Zero methods. Refer to Table 3-1 for theequations for each mapping method.

    The Z Transform method also is a reverse calculation to map a model in thez-plane to the s-plane. You calculate the impulse response of the continuous

    transfer function by dividing the inversez-transform of the discrete transferfunction by the sampling time T.

    z e

    sT

    =

  • 7/28/2019 371057 e

    50/225

    Chapter 3 Converting Models

    Control Design Toolkit User Manual 3-14 ni.com

    Resampling a Discrete ModelUse the CD Convert Discrete to Discrete VI to resample a discrete model.This VI converts the discrete model to a continuous model and thenconverts the continuous model back to a discrete model. The firstconversion uses the initial sampling time T1. The second conversion usesthe final sampling time T2.

    The CD Convert Discrete to Discrete VI supports the following conversionmethods: Forward Rectangular, Backward Rectangular, Tustins, Prewarp,Zero-Order-Hold, and Z Transform. This VI does not support theFirst-Order-Hold or Matched Pole Zero methods.

  • 7/28/2019 371057 e

    51/225

    National Instruments Corporation 4-1 Control Design Toolkit User Manual

    4Connecting Models

    You typically create a dynamic system model by connecting many models,or subsystems, together. Connecting many models together makesdeveloping a model of a complicated dynamic system less complicatedbecause you can describe the dynamics of individual pieces.

    You only can connect continuous models to other continuous models. Toconnect discrete models together, each model must have the same samplingtime. Connected models might, however, be of any form. For example,you can connect a transfer function model to a state-space model or a

    state-space model to a zero-pole-gain model.

    Furthermore, you can make connections between single-inputsingle-output (SISO), single-input multiple-output (SIMO), multiple-inputsingle-output (MISO), and multiple-input multiple-output (MIMO)systems.

    This chapter provides information about using the LabVIEW ControlDesign Toolkit to connect models in the following four ways: in series,by appending, in parallel, and with feedback.

    Note Refer to thelabview\examples\Control Design\Getting Started\ModelConnection.llb for example VIs that demonstrate the concepts explained in thischapter.

    Connecting Models in Series

    A series connection joins the outputs of the first model to the inputs of asecond model. Use the CD Series VI to connect two models in series.

    Note When connecting models of different forms, the Series Model outputterminal returns a model based on the following hierarchy: state-space>transferfunction>zero-pole-gain. For example, if you connect a zero-pole-gain model to astate-space model, Series Model returns a state-space model.

    The following sections provide information about the kinds of connectionsyou can make with the CD Series VI.

  • 7/28/2019 371057 e

    52/225

    Chapter 4 Connecting Models

    Control Design Toolkit User Manual 4-2 ni.com

    Connecting SISO Systems in SeriesConsider a valve that controls the flow rate of water into a tank. Figure 4-1represents this system.

    Figure 4-1. Flow of Water into a Tank

    If you assume that the incoming water pressure to the valve is constant,only the valve input signal affects the level of the water in the tank. You canmodel the flow rate of water into the tank using the following transferfunctions, whereHv(s) is a model of the valve andHt(s) is a model of thetank.

    I(s), Q(s), andL(s) represent the Laplace transform of the input signal, theflow rate, and level of water in the tank, respectively. The constants Kv, ,, and Ktare parameters of the models that describe the valve and tank. Toobtain the effect of the input signal on the water level, place the two systemsin series and multiply their transfer functions.

    Ht(s)L

    L(s): Level

    I(s): Input Signal

    Hv(s)

    Q(s): Flow Rate

    Hv s( )Q s( )I s( )-----------

    Kv

    2s

    22s 1+ +

    -------------------------------------= Ht s( )L s( )Q s( )-----------

    Kt

    s-----=

    H s( ) L s( )I s( )---------- Hv s( ) Ht s( )K

    v

    2s

    22s 1+ +

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

    ts-----= =