14
Engineering Applications of MATLAB® 5.3 and SIMULINK® 3

Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Embed Size (px)

Citation preview

Page 1: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Engineering Applications of MATLAB® 5.3 and SIMULINK® 3

Page 2: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Springer London Berlin Heidelberg New York Barcelona Hong Kong Milan Paris Singapore Tokyo

Page 3: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Mohand Mokhtari and Michel Marie

Engineering Applications of MATLAB® 5.3 and SIMULINK® 3 Translated from the French by Mohand Mokhtari, Michel Marie, Cecile Davy and Martine Neveu

, Springer

Page 4: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Mohand Mokhtari, PhD Valeo THERMIQUE HABITACLE, 8 rue Louis Lormand, BP 13, 78321 La Verriere Cedex, France

Michel Marie, PhD Institut Lemonnier, BP269, rue d'Herouville 14031, Caen, France

ISBN 978-1-85233-214-3 Springer-Verlag London Berlin Heidelberg

British Library Cataloguing in Publication Data Mokhtari, Mohand

Engineering applications of MA TLAB 5.3 and SIMULINK 3 1.MATLAB (Computer file) 2.SIMULINK (Computer file) 3.Engineering - Computer simulation 4.Engineering mathematics - Data processing I. Title II.Marie, Michel 620.00285'5369 ISBN 978-1-85233-214-3

Library of Congress Cataloging-in-Publication Data Mokhtari, Mohand, 1954-

Engineering applications of MAT LAB 5.3 and SIMULINK31 Mohand Mokhtari and Michel Marie.

p.cm. Includes bibliographical references and index.

ISBN 978-1-85233-214-3 (alk. paper) 1. Engineering mathematics--Data processing. 2. MATLAB. 3. SIMULINK. I. Marie Michel, 1964- II. Title. TA345 .M57 2000 620'.001'SI--dc21 99-089481

Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of repro graphic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers.

e-ISBN-13:978-1-4471-0741-5 DOl: 1 0.1 007/978-1-4471-0741-5

© Springer-Verlag London Limited 2000

MA TLAB® and SIMULINK® are registered trademarks of The Math Works Inc., http://www.mathworks.com

The use of registered names, trademarks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use.

The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made.

Typesetting: Camera ready by author

69/3830-543210 Printed on acid-free paper SPIN 10736302

Page 5: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Foreword

In recent years MATLAB®, together with SIMULINK® and the many associated toolboxes, has became a standard in the fields of engineering, simulation and numerical calculation.

A veritable programming environment in themselves, MATLAB® and SIMULINK® bring unequalled possibilities of resolution and simulation in the fields of numerical calculation and the study of dynamic systems to students and professionals alike. These features are enhanced by excellent graphic visualisation in 2D and 3D.

The originality of this book is to intelligently marry theory and practice. The theory is exposed in the first half of the work, the second part of the work being devoted to the study of real applications of control process and signal processing. This approach allows the reader, at any stage, to see the importance of the theory worked out in practical examples and follow the examples with their theoretical structure presented in a clear and concise way.

The presentation of these applications begins with an initial mathematical study of the physical processes leading to the discrete modelling stage.

In each of these case studies, the authors demonstrate the power of MA TLAB® and SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes, fuzzy logic, neuronal networks and signal processing. This enlightening approach gives the reader (novice or specialist) a clear and thorough understanding of these tools.

The authors do not limit themselves to the traditional framework of commands and the representation of states but also approach the fields of fuzzy logic and neural networks. Their many years of teaching associated with their many research projects in these areas ensure us of the objective importance of these, alas little known, techniques.

Two appendices are given over to the study of concrete examples of two significant features of SIMULINK®; encapsulation of sets of blocks and the modelling of S-Functions.

Encapsulation or masking facilitates the presentation of clear and concise hierarchical models and the S-Functions allow the reader to extend the library of SIMULINK® by the addition of supplementary blocks specific to its field of application.

Aided by the many screenshots and graphs, the reader can easily appreciate the precision of these tools.

Page 6: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

vi Foreword

Already acknowledged as a reference for technicians, engineers and academics, the latest enhancements of MA TLAB® and SIMULINK® strengthen the quality of these tools. This book extensively explores each of their facets and so, in itself, becomes an invaluable new toolbox.

Joel Courtois Doctor in Computer Science

Manager of EPITA (Ecole Pour l'Informatique et les Techniques Avancees)

School of Computer Engineering, Paris

Page 7: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Preface

MATLAB® is a high-level computing language. It is widely used in industry, universities and engineering schools. It has become a necessary tool in engineering and scientific research, thanks to its simplicity of use and its great power in calculation and visualisation.

In addition, many toolboxes exist which are dedicated to a specific scientific field.

The additional SIMULINK® tool makes possible the modelling and simulation of analogue dynamic systems whether analogical, discrete or hybrid, using a graphic blocks representation

Since the release of its 5th version, new functionalities such as multidimensional arrays, object-oriented programming, structures and cells, have enabled MATLAB®, to become a real programming language.

This book is divided into two parts. The first one refers to the notions and theoretical bases necessary for a good understanding of the techniques used in the second part, which deals with process control and numerical signal processing.

Each application is dealt with using several techniques, including classical methods of automatic control, and both deterministic and random discrete signal processing, as well as fuzzy logic and neural networks.

The preliminary mathematical study of the modelling of physical processes starts by producing the equations that link their inputs/outputs to the editing of their analogical or discrete models.

In the use of M-files, the focus is placed on SIMULINK® and the S-functions for which an appendix has been created.

The encapsulation (masking) of a set of SIMULINK® blocks, the creation of personalised libraries - which is one of the main functionalities in SIMULINK® is studied in the appendix.

We have used the functions and blocks of SIMULINK® of the "Control System TOOLBOX", "Signal Processing TOOLBOX", "Neural Network TOOLBOX" and "Fuzzy Logic TOOLBOX".

This book is dedicated to any technician, engineer, university or industrial researcher who will find in it the necessary mathematical tools, as well as the means offered by MA TLAB® Toolboxes and SIMULINK® to solve any modelling or numerical computing problems in a quick and efficient way.

Page 8: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

viii Preface

Teachers, students and engineers will find this book an effective aid to the study and control of dynamic systems.

The M-files and SIMULINK® models developed in this book are collected on a CD ROM to enable the reader to carry out these programs easily.

Page 9: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Contents

Chapter 1: Analog and digital control ................................................................ 1 1. The principle ......................................................................................................................... 1

2. Presentation of main types of corrector.. ............................................................................... 2 2.1. Proportionnal corrector .............................................................................................. 2 2.2. Integral control ........................................................................................................... 3 2.3. Derivative corrector .................................................................................................... 3 2.4. Derivative return corrector ......................................................................................... 4 2.5. Phase lead corrector ................................................................................................... 5 2.6. Phase lag corrector ..................................................................................................... 7 2.7. PID controller. ............................................................................................................ 9 2.8. Predictive action corrector ....................................................................................... 13 2.9. PIR corrector, pure delay system .............................................................................. 14

3. Analog correctors discretisation .......................................................................................... 15

4. Corrected systems stability .................................................................................................. 16 4.1. General conditions of stability ................................................................................. 16 4.2. Nyquist criterion ....................................................................................................... 17 4.3. Discrete systems stability ......................................................................................... 17

5. Examples ............................................................................................................................. 18 5.1. Using some MATLAB® functions ............................................................................ 18 5.2. Using a PIR corrector ............................................................................................... 24

6. LQ, LQI, quadratic linear control... ..................................................................................... 27 6.1. LQI control of a monovariable process .................................................................... 27

6.1.1. Model without integrator. .............................................................................. 27 6.1.2. Model with integrator .................................................................................... 28

6.2. LQI control of a multi variable process ..................................................................... 28 6.2.1. LQ multi variable control ............................................................................... 29 6.2.2. LQI multi variable control .............................................................................. 30

6.3. Application example ................................................................................................ 30 6.3.1. LQI control of a monovariable aerothermal system ...................................... 31 6.3.2. LQI control of a multivariable system ........................................................... 36

7. RST control ......................................................................................................................... 38 7.1. Monovariable system ............................................................................................... 38 7.2. Multi variable system ................................................................................................ 40 7.3. Application example ................................................................................................ 40

7.3.1. RST monovariable control of the temperature ............................................. .41 7.3.2. RST multivariable control of the aerothermal process ................................. .43

Page 10: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

x Contents

Chapter 2: State representation of continuous and discrete systems .................................................................................................... 47

1. State representation of continuous systems ......................................................................... 47 1.1. Heuristic approach ................................................................................................... 47 1.2. State representation generalization ........................................................................... 49

2. State representation of discrete systems ........... '" ................................................................ 50 2.1. Heuristic approach ................................................................................................... 50 2.2. Application ............................................................................................................... 52

3. Controllability and observability ......................................................................................... 53 3.1. Controllability .......................................................................................................... 53 3.2. Observability ............................................................................................................ 53

4. State reconstruction of a discrete dynamic system .............................................................. 54 4.1. Closed-loop estimation of a deterministic process ................................................... 54

5. State return control .............................................................................................................. 56

6. Examples ............................................................................................................................. 57 6.1. State return control system of a process including an integration ........................... 57 6.2. State return control system of a process not including an integration ...................... 65 6.3. Control system by poles placing of a discrete system ............................................... 74

7. Kalman filter ....................................................................................................................... 78

8. Discrete stochastic Kalman predictor .................................................................................. 89

Chapter 3: Fuzzy logic control ............................................................................. 95

1. The fundamental principle .................................................................................................. 95

2. Stages of implementation of a fuzzy regulator .................................................................... 96 2.1. Fuzzification stage .................................................................................................... 96 2.2. Inference stage .......................................................................................................... 97 2.3. Defuzzification stage .............................................................................................. 100

3. Graphical interface of the" Fuzzy Logic TOOLBOX" ..................................................... 104

4. Creation of a fuzzy system using the toolbox commands .................................................. 109 4.1. Input and output variables fuzzification ................................................................. 11 0 4.2. Fuzzy Rules Editor ................................................................................................. 113 4.3. Defuzzification ....................................................................................................... 119 4.4. Using the regulator in a control law ....................................................................... 120

5. Fuzzy regulator use in SIMULINK® ................................................................................. 127

6. Sugeno's method ............................................................................................................... 131 6.1. Realisation of the fuzzy regulator using the graphic interface ................................ 131 6.2. Realisation of the fuzzy regulator using the TOOLBOX commands ..................... 139

Chapter 4: Neural networks ................................................................................ 149

1. Introduction ....................................................................................................................... 149

2. Linear adaptive neural networks ....................................................................................... 150 2.1. Architecture ............................................................................................................ 150

Page 11: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Contents xi

2.2. Training law ........................................................................................................... 151 2.3. Some applications fields ......................................................................................... 152

2.3.1. Process identification .................................................................................. 152 2.3.2. Signal prediction ......................................................................................... 156 2.3.3. Interference cancellation ............................................................................. 160

3. Neural networks with hidden layers, back-propagation error. ........................................... 165 3.1. Principle ................................................................................................................. 165 3.2. Transfer functions .................................................................................................. 166 3.3. Back-propagation algorithm ................................................................................... 170

4. Inverse neural model controL ........................................................................................... 173 4.1. First architecture ..................................................................................................... 173 4.2. Second architecture ................................................................................................ 188

4.2.1. Addition of an integration ........................................................................... 198 4.2.2. Adaptive control .......................................................................................... 200

5. Signal prediction ............................................................................................................... 213

Chapter 5: Adaptive filtering ............................................................................... 219 1. The adaptive filtering principle ......................................................................................... 219

2. Gradient algorithm, LMS criterion .................................................................................... 222 2.1. 15 scalar adaptation choice ...................................................................................... 222 2.2. Adaptation speed, filter time constant .................................................................... 223

3. The recursive least squares algorithm, exact least squares criterion .................................. 223

4. Examples of LMS adaptive filters ..................................................................................... 227 4.1. Adaptive predictor for an autoregressive process ................................................... 227 4.2. Interference cancellation ........................................................................................ 231 4.3. Extraction of a signal drowned in noise ................................................................. 239

5. RLS adaptive filter example .............................................................................................. 246 5.1. Extraction of a signal drowned in noise ................................................................. 246

Application 1: Power amplifier .......................................................................... 257 1. Description of amplifier .................................................................................................... 257

2. Characterization of amplifier ............................................................................................. 259

3. Amplifier with transistors stage feedback ......................................................................... 263

4. Amplifier with phase lag corrector .................................................................................... 267

5. Amplifier with feedback of phase lead type corrector ....................................................... 272

Application 2: Electromagnetic levitation ................................................... 275 1. Process modelling ............................................................................................................. 276

1.1. Expression of the F attraction power according to the I current in the coil and the e air gap ............................................................................................... 276

1.2. Process linearization around a quiescent point e(t)=eO .......................................... 277

Page 12: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

xii Contents

1.3. Process transfer functions ....................................................................................... 277

2. Electric current amplifier control system ......................................................................... 279

3. Analogical and discrete models of the x(t) position control system .................................. 282

4. x(t) digital follower control ............................................................................................... 286

5. Using a fuzzy corrector ..................................................................................................... 291 5 .1. Variables fuzzification ........................................................................................... 291 5.2. Inference rules definition ....................................................................................... 294 5.3. Output defuzzification ............................................................................................ 294

Application 3: Cart with inverted pendulum .............................................. 303 1. System modelling with 2 degrees of freedom. ................................................................... 304

1.1. Kinetic energy of the system on motion ................................................................. 304 1.2. Potential energy of the system ................................................................................ 305 1.3. Lagrange equation according to q(t)=8(t) degree offreedom ................................ 305 1.4. Lagrange equation according to q(t)= x(t) degree of freedom ................................ 306 1.5. Linear model around the operating point ............................................................... 306

2. Linear process state modelling .......................................................................................... 307

3. Edition and test of the discrete model ............................................................................... 308

4. Fuzzy regulation of the 8(t) angular position .................................................................... 315 4.1. Inputs fuzzification, membership functions definition ........................................... 316 4.2. Inference rules definition, defuzzification .............................................................. 318 4.3. Achieving the fuzzy controller ............................................................................... 322

5. Fuzzy control of the x(t) position and the 8(t) angle ......................................................... 328 5.1. Inputs fuzzification, membership functions ........................................................... 329 5.2. Inference rules definition, defuzzification .............................................................. 332 5.3. Achieving the fuzzy controller ............................................................................... 334

6. Graphical animation of the system .................................................................................... 340

Application 4: Oven control ................................................................................ 347 1. Oven modelling ................................................................................................................. 348

2. Integral control with compensation of poles and zeros ..................................................... 352

3. Discrete state representation of the oven ........................................................................... 355

4. Control by state return with integration ............................................................................ 360

5 . Using a Kalman reconstructor ........................................................................................... 364

6. LQ quadratic linear control ............................................................................................... 368

7. Control by neuronal inverse model ................................................................................... 371

Application 5: Travelling gantry crane with suspended mass ........ 381 1. Modelling the travelling gantry crane with 2 degrees of freedom ..................................... 382

1.1. Kinetic energy of the system on motion ................................................................. 382

Page 13: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

Contents xiii

1.2. Potential energy of the system ................................................................................ 382 1.3. Lagrange equation for the q(t)=8(t) degree of freedom .......................................... 382 1.4. Lagrange equation for the q(t)= x(t) degree of freedom ......................................... 383 1.5. Linear model upon the operating point .................................................................. 383

2. Transfer functions of the system ....................................................................................... 384 2.1. Step response of the open loop process .................................................................. 384 2.2. Edition and test of the model.. ................................................................................ 386

3. Regulation of the 8(t) angular position ............................................................................. 389

4. Regulation of the x(t) position truck and the 8(t) angle ..................................................... 391

5. State space modelling ....................................................................................................... 394 5.1. Discrete state space model.. .................................................................................... 398 5.2. Luenberger's state observer .................................................................................... 401 5.3. State space control of the process ........................................................................... 409 5.4. Adding an integral correction ................................................................................. 414

6. Graphical animation of the travelling gantry crane ........................................................... 418

7. Fuzzy control of the gantry ............................................................................................... 422

8. RST and LQI controllers ................................................................................................... 429 8.1. Discrete model of the gantry .................................................................................. 429 8.2. RST control law ..................................................................................................... 432

8.2.1. RST monovariable control of the truck position ......................................... 432 8.2.2. Multivariable RST control of the travelling gantry crane ............................ 435

8.3. LQI monovariable control of the cart position ....................................................... 440

Application 6: Hands-free telephone ............................................................. 445 1. Programming Adaline using MA TLAB® commands ........................................................ 445

2. Using S-function in a SIMULINK® model ....................................................................... 449

Application 7: Echo cancellation on a transmission line ................... 453 1. Transmission line modelling ............................................................................................. 454

2. LMS filtering, Ims 1 S-function ...................................................................................... 455

3. RLS filtering, rlsl S-function ....................................................................................... 460

Application 8 : Noise elimination in a conduit.. ........................................ 463 1. Conduit modelling ............................................................................................................ 463

2. LMS filtering, Ims2 S-function ...................................................................................... 464

3. RLS filtering, rls2 S-function ....................................................................................... 472

4. Composite noise filtering .................................................................................................. 477

Application 9 : Equalisation of a symmetrical binary channel ........ 481 1. Generation of a random binary sequence .......................................................................... 481

Page 14: Engineering Applications of MATLAB® 5.3 and SIMULINK…978-1-4471-0741-5/1.pdf · SIMULINK® tools as well as the power of the toolboxes dedicated to the control of processes,

xiv Contents

2. The dispersion channeL .................................................................................................... 484

3. Symmetrical channel equaliser .......................................................................................... 487

4. Use with SIMULINK® ...................................................................................................... 496 4.1. S-function transmission channel ............................................................................ 497 4.2. S-function LMS type adaptive equalizer ............................................................... 498 4.3. Simulation results ................................................................................................... 499

Appendix 1 : S-functions under SIMULlN~ 3 .......................................... 503 1. S-functions functioning principle under SIMULINK® 3 .................................................. 503

2. Various stages of the simulation ....................................................................................... 504

3. S-function creation through a M-file call .......................................................................... 504

3. S-function creation through a C MEX file call ................................................................. 512

Appendix 2 : Masking a set of blocks in SIMULlN~ 3 ........................ 515 1. Damped sinusoidal generator ............................................................................................ 515

2. Pseudo-random binary sequence generator (PRBS) .......................................................... 523

Bibliography ................................................................................................................ 529

Index ................................................................................................................................ 533